Re: [PATCH 3/3] NTB: Add flush_req and wakeup interface

2015-12-17 Thread kbuild test robot
Hi Xiangliang,

[auto build test WARNING on v4.4-rc5]
[also build test WARNING on next-20151217]

url:
https://github.com/0day-ci/linux/commits/Xiangliang-Yu/NTB-Add-AMD-PCI-Express-NTB-driver/20151217-113608
config: x86_64-randconfig-n0-12171710 (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All warnings (new ones prefixed by >>):

   drivers/ntb/hw/amd/ntb_hw_amd.c: In function 'amd_ntb_mw_set_trans':
   drivers/ntb/hw/amd/ntb_hw_amd.c:189:6: warning: 'limit' may be used 
uninitialized in this function [-Wmaybe-uninitialized]
  if (reg_val != limit) {
 ^
   drivers/ntb/hw/amd/ntb_hw_amd.c: In function 'amd_ntb_wakeup_peer_side':
>> drivers/ntb/hw/amd/ntb_hw_amd.c:526:6: warning: 'reg' may be used 
>> uninitialized in this function [-Wmaybe-uninitialized]
 reg |= 0x1;
 ^
   drivers/ntb/hw/amd/ntb_hw_amd.c:518:6: note: 'reg' was declared here
 u32 reg;
 ^

vim +/reg +526 drivers/ntb/hw/amd/ntb_hw_amd.c

58a6d117 Xiangliang Yu 2015-12-17  510  return 
amd_flush_peer_requests(ndev);
58a6d117 Xiangliang Yu 2015-12-17  511  }
58a6d117 Xiangliang Yu 2015-12-17  512  
a635755a Xiangliang Yu 2015-12-17  513  /*
a635755a Xiangliang Yu 2015-12-17  514   * wake up the peer side
a635755a Xiangliang Yu 2015-12-17  515   */
a635755a Xiangliang Yu 2015-12-17  516  static int amd_wakeup_peer_side(struct 
amd_ntb_dev *ndev)
a635755a Xiangliang Yu 2015-12-17  517  {
a635755a Xiangliang Yu 2015-12-17  518  u32 reg;
a635755a Xiangliang Yu 2015-12-17  519  
a635755a Xiangliang Yu 2015-12-17  520  if (!amd_link_is_up(ndev)) {
a635755a Xiangliang Yu 2015-12-17  521  
dev_warn(ndev_dev(ndev), "link is down.\n");
a635755a Xiangliang Yu 2015-12-17  522  return -EINVAL;
a635755a Xiangliang Yu 2015-12-17  523  }
a635755a Xiangliang Yu 2015-12-17  524  
a635755a Xiangliang Yu 2015-12-17  525  NTB_READ_REG(PMSGTRIG);
a635755a Xiangliang Yu 2015-12-17 @526  reg |= 0x1;
a635755a Xiangliang Yu 2015-12-17  527  NTB_WRITE_REG(reg, PMSGTRIG);
a635755a Xiangliang Yu 2015-12-17  528  
a635755a Xiangliang Yu 2015-12-17  529  
wait_for_completion(>wakeup_cmpl);
a635755a Xiangliang Yu 2015-12-17  530  
a635755a Xiangliang Yu 2015-12-17  531  return 0;
a635755a Xiangliang Yu 2015-12-17  532  }
a635755a Xiangliang Yu 2015-12-17  533  
58a6d117 Xiangliang Yu 2015-12-17  534  static int 
amd_ntb_wakeup_peer_side(struct ntb_dev *ntb)

:: The code at line 526 was first introduced by commit
:: a635755a710138a6f505cc7e62693741786fb19e NTB: Add AMD PCI-Express NTB 
driver

:: TO: Xiangliang Yu 
:: CC: 0day robot 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


Re: [PATCH 3/3] NTB: Add flush_req and wakeup interface

2015-12-17 Thread kbuild test robot
Hi Xiangliang,

[auto build test WARNING on v4.4-rc5]
[also build test WARNING on next-20151217]

url:
https://github.com/0day-ci/linux/commits/Xiangliang-Yu/NTB-Add-AMD-PCI-Express-NTB-driver/20151217-113608
config: x86_64-randconfig-n0-12171710 (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All warnings (new ones prefixed by >>):

   drivers/ntb/hw/amd/ntb_hw_amd.c: In function 'amd_ntb_mw_set_trans':
   drivers/ntb/hw/amd/ntb_hw_amd.c:189:6: warning: 'limit' may be used 
uninitialized in this function [-Wmaybe-uninitialized]
  if (reg_val != limit) {
 ^
   drivers/ntb/hw/amd/ntb_hw_amd.c: In function 'amd_ntb_wakeup_peer_side':
>> drivers/ntb/hw/amd/ntb_hw_amd.c:526:6: warning: 'reg' may be used 
>> uninitialized in this function [-Wmaybe-uninitialized]
 reg |= 0x1;
 ^
   drivers/ntb/hw/amd/ntb_hw_amd.c:518:6: note: 'reg' was declared here
 u32 reg;
 ^

vim +/reg +526 drivers/ntb/hw/amd/ntb_hw_amd.c

58a6d117 Xiangliang Yu 2015-12-17  510  return 
amd_flush_peer_requests(ndev);
58a6d117 Xiangliang Yu 2015-12-17  511  }
58a6d117 Xiangliang Yu 2015-12-17  512  
a635755a Xiangliang Yu 2015-12-17  513  /*
a635755a Xiangliang Yu 2015-12-17  514   * wake up the peer side
a635755a Xiangliang Yu 2015-12-17  515   */
a635755a Xiangliang Yu 2015-12-17  516  static int amd_wakeup_peer_side(struct 
amd_ntb_dev *ndev)
a635755a Xiangliang Yu 2015-12-17  517  {
a635755a Xiangliang Yu 2015-12-17  518  u32 reg;
a635755a Xiangliang Yu 2015-12-17  519  
a635755a Xiangliang Yu 2015-12-17  520  if (!amd_link_is_up(ndev)) {
a635755a Xiangliang Yu 2015-12-17  521  
dev_warn(ndev_dev(ndev), "link is down.\n");
a635755a Xiangliang Yu 2015-12-17  522  return -EINVAL;
a635755a Xiangliang Yu 2015-12-17  523  }
a635755a Xiangliang Yu 2015-12-17  524  
a635755a Xiangliang Yu 2015-12-17  525  NTB_READ_REG(PMSGTRIG);
a635755a Xiangliang Yu 2015-12-17 @526  reg |= 0x1;
a635755a Xiangliang Yu 2015-12-17  527  NTB_WRITE_REG(reg, PMSGTRIG);
a635755a Xiangliang Yu 2015-12-17  528  
a635755a Xiangliang Yu 2015-12-17  529  
wait_for_completion(>wakeup_cmpl);
a635755a Xiangliang Yu 2015-12-17  530  
a635755a Xiangliang Yu 2015-12-17  531  return 0;
a635755a Xiangliang Yu 2015-12-17  532  }
a635755a Xiangliang Yu 2015-12-17  533  
58a6d117 Xiangliang Yu 2015-12-17  534  static int 
amd_ntb_wakeup_peer_side(struct ntb_dev *ntb)

:: The code at line 526 was first introduced by commit
:: a635755a710138a6f505cc7e62693741786fb19e NTB: Add AMD PCI-Express NTB 
driver

:: TO: Xiangliang Yu 
:: CC: 0day robot 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


[PATCH 3/3] NTB: Add flush_req and wakeup interface

2015-12-16 Thread Xiangliang Yu
AMD NTB support two features: flush pending requests and wakeup
opposite side from low power state. This patch add two interface
to support these features.

Signed-off-by: Xiangliang Yu 
---
 drivers/ntb/hw/amd/ntb_hw_amd.c | 16 
 drivers/ntb/hw/amd/ntb_hw_amd.h |  2 ++
 include/linux/ntb.h | 33 +
 3 files changed, 51 insertions(+)

diff --git a/drivers/ntb/hw/amd/ntb_hw_amd.c b/drivers/ntb/hw/amd/ntb_hw_amd.c
index 931dcdc..e0ff663 100644
--- a/drivers/ntb/hw/amd/ntb_hw_amd.c
+++ b/drivers/ntb/hw/amd/ntb_hw_amd.c
@@ -93,6 +93,8 @@ static const struct ntb_dev_ops amd_ntb_ops = {
.peer_spad_addr = amd_ntb_peer_spad_addr,
.peer_spad_read = amd_ntb_peer_spad_read,
.peer_spad_write= amd_ntb_peer_spad_write,
+   .flush_req  = amd_ntb_flush_req,
+   .peer_wakeup= amd_ntb_wakeup_peer_side,
 };
 
 static int ndev_mw_to_bar(struct amd_ntb_dev *ndev, int idx)
@@ -501,6 +503,13 @@ static int amd_flush_peer_requests(struct amd_ntb_dev 
*ndev)
return 0;
 }
 
+static int amd_ntb_flush_req(struct ntb_dev *ntb)
+{
+   struct amd_ntb_dev *ndev = ntb_ndev(ntb);
+
+   return amd_flush_peer_requests(ndev);
+}
+
 /*
  * wake up the peer side
  */
@@ -522,6 +531,13 @@ static int amd_wakeup_peer_side(struct amd_ntb_dev *ndev)
return 0;
 }
 
+static int amd_ntb_wakeup_peer_side(struct ntb_dev *ntb)
+{
+   struct amd_ntb_dev *ndev = ntb_ndev(ntb);
+
+   return amd_wakeup_peer_side(ndev);
+}
+
 static void amd_handle_event(struct amd_ntb_dev *ndev, int vec)
 {
u32 status;
diff --git a/drivers/ntb/hw/amd/ntb_hw_amd.h b/drivers/ntb/hw/amd/ntb_hw_amd.h
index c3085c8..2d9b5be 100644
--- a/drivers/ntb/hw/amd/ntb_hw_amd.h
+++ b/drivers/ntb/hw/amd/ntb_hw_amd.h
@@ -263,4 +263,6 @@ static int amd_ntb_peer_spad_addr(struct ntb_dev *ntb, int 
idx,
phys_addr_t *spad_addr);
 static u32 amd_ntb_peer_spad_read(struct ntb_dev *ntb, int idx);
 static int amd_ntb_peer_spad_write(struct ntb_dev *ntb, int idx, u32 val);
+static int amd_ntb_flush_req(struct ntb_dev *ntb);
+static int amd_ntb_wakeup_peer_side(struct ntb_dev *ntb);
 #endif
diff --git a/include/linux/ntb.h b/include/linux/ntb.h
index f798e2a..9149138 100644
--- a/include/linux/ntb.h
+++ b/include/linux/ntb.h
@@ -210,6 +210,8 @@ static inline int ntb_ctx_ops_is_valid(const struct 
ntb_ctx_ops *ops)
  * @peer_spad_addr:See ntb_peer_spad_addr().
  * @peer_spad_read:See ntb_peer_spad_read().
  * @peer_spad_write:   See ntb_peer_spad_write().
+ * @flush_req: See ntb_flush_requests().
+ * @peer_wakeup:   See ntb_wakeup_peer_side().
  */
 struct ntb_dev_ops {
int (*mw_count)(struct ntb_dev *ntb);
@@ -259,6 +261,9 @@ struct ntb_dev_ops {
  phys_addr_t *spad_addr);
u32 (*peer_spad_read)(struct ntb_dev *ntb, int idx);
int (*peer_spad_write)(struct ntb_dev *ntb, int idx, u32 val);
+
+   int (*flush_req)(struct ntb_dev *ntb);
+   int (*peer_wakeup)(struct ntb_dev *ntb);
 };
 
 static inline int ntb_dev_ops_is_valid(const struct ntb_dev_ops *ops)
@@ -980,4 +985,32 @@ static inline int ntb_peer_spad_write(struct ntb_dev *ntb, 
int idx, u32 val)
return ntb->ops->peer_spad_write(ntb, idx, val);
 }
 
+/**
+ * ntb_flush_requests() - flush all pending requests
+ * @ntb:   NTB device context.
+ *
+ * For some usage, one side of NTB need to first make sure that all previous
+ * requests have been completed and then execute next step such as power down,
+ * or device removed.
+ *
+ * Return: Zero on success, otherwise an error number.
+ */
+static inline int ntb_flush_requests(struct ntb_dev *ntb)
+{
+   return ntb->ops->flush_req(ntb);
+}
+
+/**
+ * ntb_wakeup_peer_side() - wakeup peer side of NTB.
+ * @ntb:   NTB device context.
+ *
+ * Provide a mechanism that wakeup opposite side from low power state.
+ *
+ * Return: Zero on success, otherwise an error number.
+ */
+static inline int ntb_wakeup_peer_side(struct ntb_dev *ntb)
+{
+   return ntb->ops->peer_wakeup(ntb);
+}
+
 #endif
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] NTB: Add flush_req and wakeup interface

2015-12-16 Thread Xiangliang Yu
AMD NTB support two features: flush pending requests and wakeup
opposite side from low power state. This patch add two interface
to support these features.

Signed-off-by: Xiangliang Yu 
---
 drivers/ntb/hw/amd/ntb_hw_amd.c | 16 
 drivers/ntb/hw/amd/ntb_hw_amd.h |  2 ++
 include/linux/ntb.h | 33 +
 3 files changed, 51 insertions(+)

diff --git a/drivers/ntb/hw/amd/ntb_hw_amd.c b/drivers/ntb/hw/amd/ntb_hw_amd.c
index 931dcdc..e0ff663 100644
--- a/drivers/ntb/hw/amd/ntb_hw_amd.c
+++ b/drivers/ntb/hw/amd/ntb_hw_amd.c
@@ -93,6 +93,8 @@ static const struct ntb_dev_ops amd_ntb_ops = {
.peer_spad_addr = amd_ntb_peer_spad_addr,
.peer_spad_read = amd_ntb_peer_spad_read,
.peer_spad_write= amd_ntb_peer_spad_write,
+   .flush_req  = amd_ntb_flush_req,
+   .peer_wakeup= amd_ntb_wakeup_peer_side,
 };
 
 static int ndev_mw_to_bar(struct amd_ntb_dev *ndev, int idx)
@@ -501,6 +503,13 @@ static int amd_flush_peer_requests(struct amd_ntb_dev 
*ndev)
return 0;
 }
 
+static int amd_ntb_flush_req(struct ntb_dev *ntb)
+{
+   struct amd_ntb_dev *ndev = ntb_ndev(ntb);
+
+   return amd_flush_peer_requests(ndev);
+}
+
 /*
  * wake up the peer side
  */
@@ -522,6 +531,13 @@ static int amd_wakeup_peer_side(struct amd_ntb_dev *ndev)
return 0;
 }
 
+static int amd_ntb_wakeup_peer_side(struct ntb_dev *ntb)
+{
+   struct amd_ntb_dev *ndev = ntb_ndev(ntb);
+
+   return amd_wakeup_peer_side(ndev);
+}
+
 static void amd_handle_event(struct amd_ntb_dev *ndev, int vec)
 {
u32 status;
diff --git a/drivers/ntb/hw/amd/ntb_hw_amd.h b/drivers/ntb/hw/amd/ntb_hw_amd.h
index c3085c8..2d9b5be 100644
--- a/drivers/ntb/hw/amd/ntb_hw_amd.h
+++ b/drivers/ntb/hw/amd/ntb_hw_amd.h
@@ -263,4 +263,6 @@ static int amd_ntb_peer_spad_addr(struct ntb_dev *ntb, int 
idx,
phys_addr_t *spad_addr);
 static u32 amd_ntb_peer_spad_read(struct ntb_dev *ntb, int idx);
 static int amd_ntb_peer_spad_write(struct ntb_dev *ntb, int idx, u32 val);
+static int amd_ntb_flush_req(struct ntb_dev *ntb);
+static int amd_ntb_wakeup_peer_side(struct ntb_dev *ntb);
 #endif
diff --git a/include/linux/ntb.h b/include/linux/ntb.h
index f798e2a..9149138 100644
--- a/include/linux/ntb.h
+++ b/include/linux/ntb.h
@@ -210,6 +210,8 @@ static inline int ntb_ctx_ops_is_valid(const struct 
ntb_ctx_ops *ops)
  * @peer_spad_addr:See ntb_peer_spad_addr().
  * @peer_spad_read:See ntb_peer_spad_read().
  * @peer_spad_write:   See ntb_peer_spad_write().
+ * @flush_req: See ntb_flush_requests().
+ * @peer_wakeup:   See ntb_wakeup_peer_side().
  */
 struct ntb_dev_ops {
int (*mw_count)(struct ntb_dev *ntb);
@@ -259,6 +261,9 @@ struct ntb_dev_ops {
  phys_addr_t *spad_addr);
u32 (*peer_spad_read)(struct ntb_dev *ntb, int idx);
int (*peer_spad_write)(struct ntb_dev *ntb, int idx, u32 val);
+
+   int (*flush_req)(struct ntb_dev *ntb);
+   int (*peer_wakeup)(struct ntb_dev *ntb);
 };
 
 static inline int ntb_dev_ops_is_valid(const struct ntb_dev_ops *ops)
@@ -980,4 +985,32 @@ static inline int ntb_peer_spad_write(struct ntb_dev *ntb, 
int idx, u32 val)
return ntb->ops->peer_spad_write(ntb, idx, val);
 }
 
+/**
+ * ntb_flush_requests() - flush all pending requests
+ * @ntb:   NTB device context.
+ *
+ * For some usage, one side of NTB need to first make sure that all previous
+ * requests have been completed and then execute next step such as power down,
+ * or device removed.
+ *
+ * Return: Zero on success, otherwise an error number.
+ */
+static inline int ntb_flush_requests(struct ntb_dev *ntb)
+{
+   return ntb->ops->flush_req(ntb);
+}
+
+/**
+ * ntb_wakeup_peer_side() - wakeup peer side of NTB.
+ * @ntb:   NTB device context.
+ *
+ * Provide a mechanism that wakeup opposite side from low power state.
+ *
+ * Return: Zero on success, otherwise an error number.
+ */
+static inline int ntb_wakeup_peer_side(struct ntb_dev *ntb)
+{
+   return ntb->ops->peer_wakeup(ntb);
+}
+
 #endif
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/