[PATCH v2 0/5] staging: fsl-dpaa2/eth: Frame buffer work

2017-10-29 Thread Bogdan Purcareata
This patchset does some refactoring in the frame buffer area, in order
for it to be in line with firmware (MC) configuration.

Patches 1 - 2 do some label cleanup and move the buffer layout setup
to a dedicated function.

Patch 3 updates tx_data_offset - the offset for Tx frame buffers - to
not account the software annotation area, since it's already accounted
for by the firmware. This results in slightly less allocated memory.

Patch 4 updates the required alignment for Rx frame buffers, based on
the accelerator hardware version.

Patch 5 configures a headroom in the Rx frame buffers to prevent
netstack reallocations in forwarding scenarios.

Patchset sent against staging-next.

v1 -> v2:
- clarified one commit message
- changed some macros to inline functions
- more comments per individual patches

Bogdan Purcareata (3):
  staging: fsl-dpaa2/eth: Don't account SWA in tx_data_offset
  staging: fsl-dpaa2/eth: Change RX buffer alignment
  staging: fsl-dpaa2/eth: Extra headroom in RX buffers

Ioana Radulescu (2):
  staging: fsl-dpaa2/eth: Label cleanup
  staging: fsl-dpaa2/eth: Split function

 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 176 ++---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h |  54 +---
 2 files changed, 141 insertions(+), 89 deletions(-)

-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 2/5] staging: fsl-dpaa2/eth: Split function

2017-10-29 Thread Bogdan Purcareata
From: Ioana Radulescu 

Since setup_dpni() became a bit too long, move the buffer layout
configuration to a separate function.

Signed-off-by: Ioana Radulescu 
Signed-off-by: Bogdan Purcareata 
---
v1 -> v2:
- no changes

 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 79 +++---
 1 file changed, 45 insertions(+), 34 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 5d2bd18..92faaaf 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -1776,42 +1776,12 @@ static void free_dpbp(struct dpaa2_eth_priv *priv)
fsl_mc_object_free(priv->dpbp_dev);
 }
 
-/* Configure the DPNI object this interface is associated with */
-static int setup_dpni(struct fsl_mc_device *ls_dev)
+static int set_buffer_layout(struct dpaa2_eth_priv *priv)
 {
-   struct device *dev = &ls_dev->dev;
-   struct dpaa2_eth_priv *priv;
-   struct net_device *net_dev;
+   struct device *dev = priv->net_dev->dev.parent;
struct dpni_buffer_layout buf_layout = {0};
int err;
 
-   net_dev = dev_get_drvdata(dev);
-   priv = netdev_priv(net_dev);
-
-   /* get a handle for the DPNI object */
-   err = dpni_open(priv->mc_io, 0, ls_dev->obj_desc.id, &priv->mc_token);
-   if (err) {
-   dev_err(dev, "dpni_open() failed\n");
-   return err;
-   }
-
-   ls_dev->mc_io = priv->mc_io;
-   ls_dev->mc_handle = priv->mc_token;
-
-   err = dpni_reset(priv->mc_io, 0, priv->mc_token);
-   if (err) {
-   dev_err(dev, "dpni_reset() failed\n");
-   goto close;
-   }
-
-   err = dpni_get_attributes(priv->mc_io, 0, priv->mc_token,
- &priv->dpni_attrs);
-   if (err) {
-   dev_err(dev, "dpni_get_attributes() failed (err=%d)\n", err);
-   goto close;
-   }
-
-   /* Configure buffer layouts */
/* rx buffer */
buf_layout.pass_parser_result = true;
buf_layout.pass_frame_status = true;
@@ -1825,7 +1795,7 @@ static int setup_dpni(struct fsl_mc_device *ls_dev)
 DPNI_QUEUE_RX, &buf_layout);
if (err) {
dev_err(dev, "dpni_set_buffer_layout(RX) failed\n");
-   goto close;
+   return err;
}
 
/* tx buffer */
@@ -1835,7 +1805,7 @@ static int setup_dpni(struct fsl_mc_device *ls_dev)
 DPNI_QUEUE_TX, &buf_layout);
if (err) {
dev_err(dev, "dpni_set_buffer_layout(TX) failed\n");
-   goto close;
+   return err;
}
 
/* tx-confirm buffer */
@@ -1844,9 +1814,50 @@ static int setup_dpni(struct fsl_mc_device *ls_dev)
 DPNI_QUEUE_TX_CONFIRM, &buf_layout);
if (err) {
dev_err(dev, "dpni_set_buffer_layout(TX_CONF) failed\n");
+   return err;
+   }
+
+   return 0;
+}
+
+/* Configure the DPNI object this interface is associated with */
+static int setup_dpni(struct fsl_mc_device *ls_dev)
+{
+   struct device *dev = &ls_dev->dev;
+   struct dpaa2_eth_priv *priv;
+   struct net_device *net_dev;
+   int err;
+
+   net_dev = dev_get_drvdata(dev);
+   priv = netdev_priv(net_dev);
+
+   /* get a handle for the DPNI object */
+   err = dpni_open(priv->mc_io, 0, ls_dev->obj_desc.id, &priv->mc_token);
+   if (err) {
+   dev_err(dev, "dpni_open() failed\n");
+   return err;
+   }
+
+   ls_dev->mc_io = priv->mc_io;
+   ls_dev->mc_handle = priv->mc_token;
+
+   err = dpni_reset(priv->mc_io, 0, priv->mc_token);
+   if (err) {
+   dev_err(dev, "dpni_reset() failed\n");
goto close;
}
 
+   err = dpni_get_attributes(priv->mc_io, 0, priv->mc_token,
+ &priv->dpni_attrs);
+   if (err) {
+   dev_err(dev, "dpni_get_attributes() failed (err=%d)\n", err);
+   goto close;
+   }
+
+   err = set_buffer_layout(priv);
+   if (err)
+   goto close;
+
/* Now that we've set our tx buffer layout, retrieve the minimum
 * required tx data offset.
 */
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 1/5] staging: fsl-dpaa2/eth: Label cleanup

2017-10-29 Thread Bogdan Purcareata
From: Ioana Radulescu 

Clean up goto labels in a couple of functions, by
removing/renaming redundant ones.

Signed-off-by: Ioana Radulescu 
Signed-off-by: Bogdan Purcareata 
---
v1 -> v2:
- no changes

 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 35 +++---
 1 file changed, 15 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 9fbc0ee..5d2bd18 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -1444,34 +1444,32 @@ static struct fsl_mc_device *setup_dpcon(struct 
dpaa2_eth_priv *priv)
err = dpcon_open(priv->mc_io, 0, dpcon->obj_desc.id, &dpcon->mc_handle);
if (err) {
dev_err(dev, "dpcon_open() failed\n");
-   goto err_open;
+   goto free;
}
 
err = dpcon_reset(priv->mc_io, 0, dpcon->mc_handle);
if (err) {
dev_err(dev, "dpcon_reset() failed\n");
-   goto err_reset;
+   goto close;
}
 
err = dpcon_get_attributes(priv->mc_io, 0, dpcon->mc_handle, &attrs);
if (err) {
dev_err(dev, "dpcon_get_attributes() failed\n");
-   goto err_get_attr;
+   goto close;
}
 
err = dpcon_enable(priv->mc_io, 0, dpcon->mc_handle);
if (err) {
dev_err(dev, "dpcon_enable() failed\n");
-   goto err_enable;
+   goto close;
}
 
return dpcon;
 
-err_enable:
-err_get_attr:
-err_reset:
+close:
dpcon_close(priv->mc_io, 0, dpcon->mc_handle);
-err_open:
+free:
fsl_mc_object_free(dpcon);
 
return NULL;
@@ -1794,7 +1792,7 @@ static int setup_dpni(struct fsl_mc_device *ls_dev)
err = dpni_open(priv->mc_io, 0, ls_dev->obj_desc.id, &priv->mc_token);
if (err) {
dev_err(dev, "dpni_open() failed\n");
-   goto err_open;
+   return err;
}
 
ls_dev->mc_io = priv->mc_io;
@@ -1803,14 +1801,14 @@ static int setup_dpni(struct fsl_mc_device *ls_dev)
err = dpni_reset(priv->mc_io, 0, priv->mc_token);
if (err) {
dev_err(dev, "dpni_reset() failed\n");
-   goto err_reset;
+   goto close;
}
 
err = dpni_get_attributes(priv->mc_io, 0, priv->mc_token,
  &priv->dpni_attrs);
if (err) {
dev_err(dev, "dpni_get_attributes() failed (err=%d)\n", err);
-   goto err_get_attr;
+   goto close;
}
 
/* Configure buffer layouts */
@@ -1827,7 +1825,7 @@ static int setup_dpni(struct fsl_mc_device *ls_dev)
 DPNI_QUEUE_RX, &buf_layout);
if (err) {
dev_err(dev, "dpni_set_buffer_layout(RX) failed\n");
-   goto err_buf_layout;
+   goto close;
}
 
/* tx buffer */
@@ -1837,7 +1835,7 @@ static int setup_dpni(struct fsl_mc_device *ls_dev)
 DPNI_QUEUE_TX, &buf_layout);
if (err) {
dev_err(dev, "dpni_set_buffer_layout(TX) failed\n");
-   goto err_buf_layout;
+   goto close;
}
 
/* tx-confirm buffer */
@@ -1846,7 +1844,7 @@ static int setup_dpni(struct fsl_mc_device *ls_dev)
 DPNI_QUEUE_TX_CONFIRM, &buf_layout);
if (err) {
dev_err(dev, "dpni_set_buffer_layout(TX_CONF) failed\n");
-   goto err_buf_layout;
+   goto close;
}
 
/* Now that we've set our tx buffer layout, retrieve the minimum
@@ -1856,7 +1854,7 @@ static int setup_dpni(struct fsl_mc_device *ls_dev)
  &priv->tx_data_offset);
if (err) {
dev_err(dev, "dpni_get_tx_data_offset() failed\n");
-   goto err_data_offset;
+   goto close;
}
 
if ((priv->tx_data_offset % 64) != 0)
@@ -1868,12 +1866,9 @@ static int setup_dpni(struct fsl_mc_device *ls_dev)
 
return 0;
 
-err_data_offset:
-err_buf_layout:
-err_get_attr:
-err_reset:
+close:
dpni_close(priv->mc_io, 0, priv->mc_token);
-err_open:
+
return err;
 }
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 5/5] staging: fsl-dpaa2/eth: Extra headroom in RX buffers

2017-10-29 Thread Bogdan Purcareata
The needed headroom that we ask the stack to reserve for us in TX
skbs is larger than the headroom available in RX frames, which
leads to skb reallocations in forwarding scenarios involving two
DPNI interfaces.

Configure the hardware to reserve some extra space in the RX
frame headroom to avoid this situation. The value is chosen based
on the Tx frame data offset, the Rx buffer alignment value and the
netdevice required headroom.

The network stack will take care to reserve space for HH_DATA_MOD when
building the skb, so there's no need to account for it in the netdevice
needed headroom.

Signed-off-by: Bogdan Purcareata 
Signed-off-by: Ioana Radulescu 
---
v1 -> v2:
- changed *_RX_HEAD_ROOM from macro to inline function
- since the patch is touching the area, did the same for *_NEEDED_HEADROOM

 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 85 +++---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 39 
 2 files changed, 76 insertions(+), 48 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index d65950d..0d8ed00 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -135,8 +135,7 @@ static struct sk_buff *build_linear_skb(struct 
dpaa2_eth_priv *priv,
 
ch->buf_count--;
 
-   skb = build_skb(fd_vaddr, DPAA2_ETH_RX_BUF_SIZE +
-   SKB_DATA_ALIGN(sizeof(struct skb_shared_info)));
+   skb = build_skb(fd_vaddr, DPAA2_ETH_SKB_SIZE);
if (unlikely(!skb))
return NULL;
 
@@ -178,8 +177,7 @@ static struct sk_buff *build_frag_skb(struct dpaa2_eth_priv 
*priv,
 
if (i == 0) {
/* We build the skb around the first data buffer */
-   skb = build_skb(sg_vaddr, DPAA2_ETH_RX_BUF_SIZE +
-   SKB_DATA_ALIGN(sizeof(struct skb_shared_info)));
+   skb = build_skb(sg_vaddr, DPAA2_ETH_SKB_SIZE);
if (unlikely(!skb)) {
/* Free the first SG entry now, since we already
 * unmapped it and obtained the virtual address
@@ -573,10 +571,10 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, 
struct net_device *net_dev)
percpu_stats = this_cpu_ptr(priv->percpu_stats);
percpu_extras = this_cpu_ptr(priv->percpu_extras);
 
-   if (unlikely(skb_headroom(skb) < DPAA2_ETH_NEEDED_HEADROOM(priv))) {
+   if (unlikely(skb_headroom(skb) < dpaa2_eth_needed_headroom(priv))) {
struct sk_buff *ns;
 
-   ns = skb_realloc_headroom(skb, DPAA2_ETH_NEEDED_HEADROOM(priv));
+   ns = skb_realloc_headroom(skb, dpaa2_eth_needed_headroom(priv));
if (unlikely(!ns)) {
percpu_stats->tx_dropped++;
goto err_alloc_headroom;
@@ -1792,23 +1790,9 @@ static int set_buffer_layout(struct dpaa2_eth_priv *priv)
else
priv->rx_buf_align = DPAA2_ETH_RX_BUF_ALIGN;
 
-   /* rx buffer */
-   buf_layout.pass_parser_result = true;
+   /* tx buffer */
buf_layout.pass_frame_status = true;
buf_layout.private_data_size = DPAA2_ETH_SWA_SIZE;
-   buf_layout.data_align = priv->rx_buf_align;
-   buf_layout.options = DPNI_BUF_LAYOUT_OPT_PARSER_RESULT |
-DPNI_BUF_LAYOUT_OPT_FRAME_STATUS |
-DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE |
-DPNI_BUF_LAYOUT_OPT_DATA_ALIGN;
-   err = dpni_set_buffer_layout(priv->mc_io, 0, priv->mc_token,
-DPNI_QUEUE_RX, &buf_layout);
-   if (err) {
-   dev_err(dev, "dpni_set_buffer_layout(RX) failed\n");
-   return err;
-   }
-
-   /* tx buffer */
buf_layout.options = DPNI_BUF_LAYOUT_OPT_FRAME_STATUS |
 DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE;
err = dpni_set_buffer_layout(priv->mc_io, 0, priv->mc_token,
@@ -1827,6 +1811,36 @@ static int set_buffer_layout(struct dpaa2_eth_priv *priv)
return err;
}
 
+   /* Now that we've set our tx buffer layout, retrieve the minimum
+* required tx data offset.
+*/
+   err = dpni_get_tx_data_offset(priv->mc_io, 0, priv->mc_token,
+ &priv->tx_data_offset);
+   if (err) {
+   dev_err(dev, "dpni_get_tx_data_offset() failed\n");
+   return err;
+   }
+
+   if ((priv->tx_data_offset % 64) != 0)
+   dev_warn(dev, "Tx data offset (%d) not a multiple of 64B\n",
+priv->tx_data_offset);
+
+   /* rx buffer */
+   buf_layout.pass_parser_result = true;
+   buf_layout.data_align = priv->rx_buf_align;
+   buf_layout.data_head_room = dpaa2_eth_rx_head_room(priv);
+   buf_layout.priv

[PATCH v2 3/5] staging: fsl-dpaa2/eth: Don't account SWA in tx_data_offset

2017-10-29 Thread Bogdan Purcareata
When configuring the Tx buffer layout, the software annotation size is
mentioned, and MC accounts for it when configuring the frame
tx_data_offset. No need to handle it in the driver as well.

This results in 64B less memory allocated per frame.

Signed-off-by: Bogdan Purcareata 
---
v1 -> v2:
- added clarification in commit message

 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 92faaaf..d68c1f5 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -1872,9 +1872,6 @@ static int setup_dpni(struct fsl_mc_device *ls_dev)
dev_warn(dev, "Tx data offset (%d) not a multiple of 64B\n",
 priv->tx_data_offset);
 
-   /* Accommodate software annotation space (SWA) */
-   priv->tx_data_offset += DPAA2_ETH_SWA_SIZE;
-
return 0;
 
 close:
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 4/5] staging: fsl-dpaa2/eth: Change RX buffer alignment

2017-10-29 Thread Bogdan Purcareata
The WRIOP hardware block v1.0.0 (found on LS2080A board)
requires data in RX buffers to be aligned to 256B, but
newer revisions (e.g. on LS2088A, LS1088A) only require
64B alignment.

Check WRIOP version and decide at runtime which alignment
requirement to configure for ingress buffers.

Signed-off-by: Bogdan Purcareata 
Signed-off-by: Ioana Radulescu 
---
v1 -> v2:
- changed *_RAW_BUF_SIZE macro to inline function

 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 18 +
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 27 ++
 2 files changed, 33 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index d68c1f5..d65950d 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -766,11 +766,11 @@ static int add_bufs(struct dpaa2_eth_priv *priv, u16 bpid)
/* Allocate buffer visible to WRIOP + skb shared info +
 * alignment padding
 */
-   buf = napi_alloc_frag(DPAA2_ETH_BUF_RAW_SIZE);
+   buf = napi_alloc_frag(dpaa2_eth_buf_raw_size(priv));
if (unlikely(!buf))
goto err_alloc;
 
-   buf = PTR_ALIGN(buf, DPAA2_ETH_RX_BUF_ALIGN);
+   buf = PTR_ALIGN(buf, priv->rx_buf_align);
 
addr = dma_map_single(dev, buf, DPAA2_ETH_RX_BUF_SIZE,
  DMA_FROM_DEVICE);
@@ -781,7 +781,7 @@ static int add_bufs(struct dpaa2_eth_priv *priv, u16 bpid)
 
/* tracing point */
trace_dpaa2_eth_buf_seed(priv->net_dev,
-buf, DPAA2_ETH_BUF_RAW_SIZE,
+buf, dpaa2_eth_buf_raw_size(priv),
 addr, DPAA2_ETH_RX_BUF_SIZE,
 bpid);
}
@@ -1782,11 +1782,21 @@ static int set_buffer_layout(struct dpaa2_eth_priv 
*priv)
struct dpni_buffer_layout buf_layout = {0};
int err;
 
+   /* We need to check for WRIOP version 1.0.0, but depending on the MC
+* version, this number is not always provided correctly on rev1.
+* We need to check for both alternatives in this situation.
+*/
+   if (priv->dpni_attrs.wriop_version == DPAA2_WRIOP_VERSION(0, 0, 0) ||
+   priv->dpni_attrs.wriop_version == DPAA2_WRIOP_VERSION(1, 0, 0))
+   priv->rx_buf_align = DPAA2_ETH_RX_BUF_ALIGN_REV1;
+   else
+   priv->rx_buf_align = DPAA2_ETH_RX_BUF_ALIGN;
+
/* rx buffer */
buf_layout.pass_parser_result = true;
buf_layout.pass_frame_status = true;
buf_layout.private_data_size = DPAA2_ETH_SWA_SIZE;
-   buf_layout.data_align = DPAA2_ETH_RX_BUF_ALIGN;
+   buf_layout.data_align = priv->rx_buf_align;
buf_layout.options = DPNI_BUF_LAYOUT_OPT_PARSER_RESULT |
 DPNI_BUF_LAYOUT_OPT_FRAME_STATUS |
 DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE |
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index bfbabae..749bd6b 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -45,6 +45,8 @@
 
 #include "dpaa2-eth-trace.h"
 
+#define DPAA2_WRIOP_VERSION(x, y, z) ((x) << 10 | (y) << 5 | (z) << 0)
+
 #define DPAA2_ETH_STORE_SIZE   16
 
 /* Maximum number of scatter-gather entries in an ingress frame,
@@ -85,18 +87,15 @@
  */
 #define DPAA2_ETH_RX_BUF_SIZE  2048
 #define DPAA2_ETH_TX_BUF_ALIGN 64
-#define DPAA2_ETH_RX_BUF_ALIGN 256
+
 #define DPAA2_ETH_NEEDED_HEADROOM(p_priv) \
((p_priv)->tx_data_offset + DPAA2_ETH_TX_BUF_ALIGN)
 
-/* Hardware only sees DPAA2_ETH_RX_BUF_SIZE, but we need to allocate ingress
- * buffers large enough to allow building an skb around them and also account
- * for alignment restrictions
+/* Due to a limitation in WRIOP 1.0.0, the RX buffer data must be aligned
+ * to 256B. For newer revisions, the requirement is only for 64B alignment
  */
-#define DPAA2_ETH_BUF_RAW_SIZE \
-   (DPAA2_ETH_RX_BUF_SIZE + \
-   SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) + \
-   DPAA2_ETH_RX_BUF_ALIGN)
+#define DPAA2_ETH_RX_BUF_ALIGN_REV1256
+#define DPAA2_ETH_RX_BUF_ALIGN 64
 
 /* We are accommodating a skb backpointer and some S/G info
  * in the frame's software annotation. The hardware
@@ -318,6 +317,7 @@ struct dpaa2_eth_priv {
struct iommu_domain *iommu_domain;
 
u16 tx_qdid;
+   u16 rx_buf_align;
struct fsl_mc_io *mc_io;
/* Cores which have an affine DPIO/DPCON.
 * This is the cpu set on which Rx and Tx conf frames are processed
@@ -353,6 +353,17 @@ struct dpaa2_eth_priv {
 extern const struct ethtool_ops dpaa2_ethtool_ops;
 ex

[PATCH] staging: greybus: spilib: fix use-after-free after deregistration

2017-10-29 Thread Johan Hovold
Remove erroneous spi_master_put() after controller deregistration which
would access the already freed spi controller.

Note that spi_unregister_master() drops our only controller reference.

Fixes: ba3e67001b42 ("greybus: SPI: convert to a gpbridge driver")
Cc: stable  # 4.9
Cc: Greg Kroah-Hartman 
Signed-off-by: Johan Hovold 
---
 drivers/staging/greybus/spilib.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/greybus/spilib.c b/drivers/staging/greybus/spilib.c
index e97b19148497..1e7321a1404c 100644
--- a/drivers/staging/greybus/spilib.c
+++ b/drivers/staging/greybus/spilib.c
@@ -544,11 +544,14 @@ int gb_spilib_master_init(struct gb_connection 
*connection, struct device *dev,
 
return 0;
 
-exit_spi_unregister:
-   spi_unregister_master(master);
 exit_spi_put:
spi_master_put(master);
 
+   return ret;
+
+exit_spi_unregister:
+   spi_unregister_master(master);
+
return ret;
 }
 EXPORT_SYMBOL_GPL(gb_spilib_master_init);
@@ -558,7 +561,6 @@ void gb_spilib_master_exit(struct gb_connection *connection)
struct spi_master *master = gb_connection_get_data(connection);
 
spi_unregister_master(master);
-   spi_master_put(master);
 }
 EXPORT_SYMBOL_GPL(gb_spilib_master_exit);
 
-- 
2.14.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: greybus: spilib: fix use-after-free after deregistration

2017-10-29 Thread Viresh Kumar
On 29-10-17, 13:01, Johan Hovold wrote:
> Remove erroneous spi_master_put() after controller deregistration which
> would access the already freed spi controller.
> 
> Note that spi_unregister_master() drops our only controller reference.
> 
> Fixes: ba3e67001b42 ("greybus: SPI: convert to a gpbridge driver")
> Cc: stable  # 4.9
> Cc: Greg Kroah-Hartman 
> Signed-off-by: Johan Hovold 
> ---
>  drivers/staging/greybus/spilib.c | 8 +---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/greybus/spilib.c 
> b/drivers/staging/greybus/spilib.c
> index e97b19148497..1e7321a1404c 100644
> --- a/drivers/staging/greybus/spilib.c
> +++ b/drivers/staging/greybus/spilib.c
> @@ -544,11 +544,14 @@ int gb_spilib_master_init(struct gb_connection 
> *connection, struct device *dev,
>  
>   return 0;
>  
> -exit_spi_unregister:
> - spi_unregister_master(master);
>  exit_spi_put:
>   spi_master_put(master);
>  
> + return ret;
> +
> +exit_spi_unregister:
> + spi_unregister_master(master);
> +
>   return ret;
>  }
>  EXPORT_SYMBOL_GPL(gb_spilib_master_init);
> @@ -558,7 +561,6 @@ void gb_spilib_master_exit(struct gb_connection 
> *connection)
>   struct spi_master *master = gb_connection_get_data(connection);
>  
>   spi_unregister_master(master);
> - spi_master_put(master);
>  }
>  EXPORT_SYMBOL_GPL(gb_spilib_master_exit);

Acked-by: Viresh Kumar 

While looking at this I think I found another problem (I will send it as a
separate patch later on) and this fixes it:

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 6e65524cbfd9..af7ca751b4f7 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -2261,11 +2261,11 @@ void spi_unregister_controller(struct spi_controller 
*ctlr)
mutex_unlock(&board_lock);
 
dummy = device_for_each_child(&ctlr->dev, NULL, __unregister);
-   device_unregister(&ctlr->dev);
/* free bus id */
mutex_lock(&board_lock);
idr_remove(&spi_master_idr, ctlr->bus_num);
mutex_unlock(&board_lock);
+   device_unregister(&ctlr->dev);
 }
 EXPORT_SYMBOL_GPL(spi_unregister_controller);
 
-- 
viresh
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: greybus: spilib: fix use-after-free after deregistration

2017-10-29 Thread Johan Hovold
On Sun, Oct 29, 2017 at 06:13:28PM +0530, Viresh Kumar wrote:
> On 29-10-17, 13:01, Johan Hovold wrote:
> > Remove erroneous spi_master_put() after controller deregistration which
> > would access the already freed spi controller.
> > 
> > Note that spi_unregister_master() drops our only controller reference.
> > 
> > Fixes: ba3e67001b42 ("greybus: SPI: convert to a gpbridge driver")
> > Cc: stable  # 4.9
> > Cc: Greg Kroah-Hartman 
> > Signed-off-by: Johan Hovold 

> Acked-by: Viresh Kumar 
> 
> While looking at this I think I found another problem (I will send it as a
> separate patch later on) and this fixes it:

That's right, and I already posted a fix for that use-after-free:

https://lkml.kernel.org/r/20171029115625.32385-1-jo...@kernel.org

Thanks,
Johan
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: greybus: spilib: fix use-after-free after deregistration

2017-10-29 Thread Viresh Kumar
On 29-10-17, 13:51, Johan Hovold wrote:
> That's right, and I already posted a fix for that use-after-free:
> 
>   https://lkml.kernel.org/r/20171029115625.32385-1-jo...@kernel.org

Great :)

-- 
viresh
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Fix line too long warning

2017-10-29 Thread Joe Perches
On Sat, 2017-10-28 at 22:46 -0400, Kien Ha wrote:
> From fc52a98aca0c033f2c03fdc7e8f83ae49625675a Mon Sep 17 00:00:00 2001
> From: Kien Ha 
> Date: Fri, 27 Oct 2017 14:07:55 -0400
> Subject: [PATCH] Fix line too long warning
> 
> Signed-off-by: Kien Ha 

Hi.

Instead of merely shutting up checkpatch warnings,
always try to improve the code instead.

Look at the flow of this cascaded if / else { if
and transform it to a simpler if ... else if ... else if ...

   if (sta && sta->vht_cap.vht_supported) {
   tcb_desc->hw_rate =
   _rtl_get_vht_highest_n_rate(hw, sta);
   } else {
   if (sta && (sta->ht_cap.ht_supported)) {
   tcb_desc->hw_rate =
   _rtl_get_highest_n_rate(hw, sta);
   } else {
   if (rtlmac->mode == WIRELESS_MODE_B) {
   tcb_desc->hw_rate =
   
rtlpriv->cfg->maps[RTL_RC_CCK_RATE11M];
   } else {
   tcb_desc->hw_rate =
   
rtlpriv->cfg->maps[RTL_RC_OFDM_RATE54M];
   }
   }
   }


This block could be

tcb_desc->hw_rate =
sta && sta->vht_cap.vht_supported ?
_rtl_get_vht_highest_n_rate(hw, sta) :
sta && sta->ht_cap.ht_supported ?
_rtl_get_highest_n_rate(hw, sta) :
rtlmac->mode == WIRELESS_MODE_B ?
rtlpriv->cfg->maps[RTL_RC_CCK_RATE11M] :
rtlpriv->cfg->maps[RTL_RC_OFDM_RATE54M];

which seems easier to read.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Fix line too long warning

2017-10-29 Thread Yury Norov
Hi Kien,

On Sat, Oct 28, 2017 at 10:46:13PM -0400, Kien Ha wrote:
> >From fc52a98aca0c033f2c03fdc7e8f83ae49625675a Mon Sep 17 00:00:00 2001
> From: Kien Ha 
> Date: Fri, 27 Oct 2017 14:07:55 -0400
> Subject: [PATCH] Fix line too long warning
> 
> Signed-off-by: Kien Ha 
> ---
>  drivers/staging/rtlwifi/base.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/rtlwifi/base.c b/drivers/staging/rtlwifi/base.c
> index b88b0e8edd3d..bbc80f976e12 100644
> --- a/drivers/staging/rtlwifi/base.c
> +++ b/drivers/staging/rtlwifi/base.c
> @@ -1283,7 +1283,8 @@ void rtl_get_tcb_desc(struct ieee80211_hw *hw,
>   } else {
>   if (rtlmac->mode == WIRELESS_MODE_B) {
>   tcb_desc->hw_rate =
> - 
> rtlpriv->cfg->maps[RTL_RC_CCK_RATE11M];
> + rtlpriv->cfg->maps[
> + RTL_RC_CCK_RATE11M];

At first, if you fix this, you should also fix similar problem 3 lines
below, right?

>   } else {
>   tcb_desc->hw_rate =
>   
> rtlpriv->cfg->maps[RTL_RC_OFDM_RATE54M];

At second, and most important, refer Documentation/process/coding-style.rst:
Now, some people will claim that having 8-character indentations makes
the code move too far to the right, and makes it hard to read on a 
80-character terminal screen.  The answer to that is that if you need 
more than 3 levels of indentation, you're screwed anyway, and should fix
your program.

The real problem here is not "line too long", but "indentation level too
big" - 5. And it worth to address real problem.

Yury
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Fix line too long warning

2017-10-29 Thread Yury Norov
On Sun, Oct 29, 2017 at 06:54:09PM +0300, Yury Norov wrote:
> Hi Kien,
> 
> On Sat, Oct 28, 2017 at 10:46:13PM -0400, Kien Ha wrote:
> > >From fc52a98aca0c033f2c03fdc7e8f83ae49625675a Mon Sep 17 00:00:00 2001
> > From: Kien Ha 
> > Date: Fri, 27 Oct 2017 14:07:55 -0400
> > Subject: [PATCH] Fix line too long warning
> > 
> > Signed-off-by: Kien Ha 
> > ---
> >  drivers/staging/rtlwifi/base.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/staging/rtlwifi/base.c b/drivers/staging/rtlwifi/base.c
> > index b88b0e8edd3d..bbc80f976e12 100644
> > --- a/drivers/staging/rtlwifi/base.c
> > +++ b/drivers/staging/rtlwifi/base.c
> > @@ -1283,7 +1283,8 @@ void rtl_get_tcb_desc(struct ieee80211_hw *hw,
> > } else {
> > if (rtlmac->mode == WIRELESS_MODE_B) {
> > tcb_desc->hw_rate =
> > -   
> > rtlpriv->cfg->maps[RTL_RC_CCK_RATE11M];
> > +   rtlpriv->cfg->maps[
> > +   RTL_RC_CCK_RATE11M];
> 
> At first, if you fix this, you should also fix similar problem 3 lines
> below, right?
> 
> > } else {
> > tcb_desc->hw_rate =
> > 
> > rtlpriv->cfg->maps[RTL_RC_OFDM_RATE54M];
> 
> At second, and most important, refer Documentation/process/coding-style.rst:
> Now, some people will claim that having 8-character indentations makes
> the code move too far to the right, and makes it hard to read on a 
> 80-character terminal screen.  The answer to that is that if you need 
> more than 3 levels of indentation, you're screwed anyway, and should fix
> your program.
> 
> The real problem here is not "line too long", but "indentation level too
> big" - 5. And it worth to address real problem.

It's not so hard though, something like this:

void rtl_get_tcb_desc(struct ieee80211_hw *hw,
  struct ieee80211_tx_info *info,
  struct ieee80211_sta *sta,
  struct sk_buff *skb, struct rtl_tcb_desc *tcb_desc)
{
#define SET_RATE_ID(rate_id)\
((rtlpriv->cfg->spec_ver & RTL_SPEC_NEW_RATEID) ?   \
rtl_mrate_idx_to_arfr_id(hw, rate_id,   \
(sta_entry ? sta_entry->wireless_mode : \
 WIRELESS_MODE_G)) :\
rate_id)

struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_mac *rtlmac = rtl_mac(rtl_priv(hw));
struct ieee80211_hdr *hdr = rtl_get_hdr(skb);
struct rtl_sta_info *sta_entry =
(sta ? (struct rtl_sta_info *)sta->drv_priv : NULL);

__le16 fc = rtl_get_fc(skb);

tcb_desc->hw_rate = _rtl_get_tx_hw_rate(hw, info);

if (rtl_is_tx_report_skb(hw, skb))
tcb_desc->use_spe_rpt = 1;

if (!ieee80211_is_data(fc)) {
tcb_desc->use_driver_rate = true;
tcb_desc->ratr_index = SET_RATE_ID(RATR_INX_WIRELESS_MC);
tcb_desc->disable_ratefallback = 1;
tcb_desc->mac_id = 0;
tcb_desc->packet_bw = false;
return;
}

if (is_multicast_ether_addr(hdr->addr1))
tcb_desc->multicast = 1;
else if (is_broadcast_ether_addr(hdr->addr1))
tcb_desc->broadcast = 1;

/*
 * we set data rate INX 0 in rtl_rc.c if skb is special data or
 * mgt which need low data rate. So tcb_desc->hw_rate is just used
 * for special data and mgt frames
 */
if (info->control.rates[0].idx == 0 || ieee80211_is_nullfunc(fc)) {
tcb_desc->use_driver_rate = true;
tcb_desc->ratr_index = SET_RATE_ID(RATR_INX_WIRELESS_MC);
tcb_desc->disable_ratefallback = 1;
goto rtl_query;
}

/* because hw will never use hw_rate
 * when tcb_desc->use_driver_rate = false
 * so we never set highest N rate here,
 * and N rate will all be controlled by FW
 * when tcb_desc->use_driver_rate = false
 */
if (sta && sta->vht_cap.vht_supported) {
tcb_desc->hw_rate = _rtl_get_vht_highest_n_rate(hw, sta);
goto rtl_query;
}

if (sta && (sta->ht_cap.ht_supported)) {
tcb_desc->hw_rate = _rtl_get_highest_n_rate(hw, sta);
goto rtl_query;
}

if (rtlmac->mode == WIRELESS_MODE_B)
tcb_desc->hw_rate = rtlpriv->cfg->maps[RTL_RC_CCK_RATE11M];
else
tcb_desc->hw_rate = rtlpriv->cfg->maps[RTL_RC_OFDM_RATE54M];
rtl_query:
_rtl_txrate_selectmode(hw, sta, tcb_desc);
_rtl_query_bandwidth_mode(h

[PATCH v2] Fix line too long warning

2017-10-29 Thread Kien Ha
>From dbe17bd47c0e76372a5ca391543dc15ddb35c9dd Mon Sep 17 00:00:00 2001
From: Kien Ha 
Date: Fri, 27 Oct 2017 14:07:55 -0400
Subject: [PATCH v2] Fix line too long warning

Signed-off-by: Kien Ha 
---
 drivers/staging/rtlwifi/base.c | 25 -
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/rtlwifi/base.c b/drivers/staging/rtlwifi/base.c
index b88b0e8edd3d..fdd1ab1e38c5 100644
--- a/drivers/staging/rtlwifi/base.c
+++ b/drivers/staging/rtlwifi/base.c
@@ -1273,23 +1273,14 @@ void rtl_get_tcb_desc(struct ieee80211_hw *hw,
 * and N rate will all be controlled by FW
 * when tcb_desc->use_driver_rate = false
 */
-   if (sta && sta->vht_cap.vht_supported) {
-   tcb_desc->hw_rate =
-   _rtl_get_vht_highest_n_rate(hw, sta);
-   } else {
-   if (sta && (sta->ht_cap.ht_supported)) {
-   tcb_desc->hw_rate =
-   _rtl_get_highest_n_rate(hw, sta);
-   } else {
-   if (rtlmac->mode == WIRELESS_MODE_B) {
-   tcb_desc->hw_rate =
-   
rtlpriv->cfg->maps[RTL_RC_CCK_RATE11M];
-   } else {
-   tcb_desc->hw_rate =
-   
rtlpriv->cfg->maps[RTL_RC_OFDM_RATE54M];
-   }
-   }
-   }
+   tcb_desc->hw_rate =
+   sta && sta->vht_cap.vht_supported ?
+   rtl_get_vht_highest_n_rate(hw, sta) :
+   sta && sta->ht_cap.ht_supported ?
+   _rtl_get_highest_n_rate(hw, sta) :
+   rtlmac->mode == WIRELESS_MODE_B ?
+   rtlpriv->cfg->maps[RTL_RC_CCK_RATE11M] :
+   rtlpriv->cfg->maps[RTL_RC_OFDM_RATE54M];
}
 
if (is_multicast_ether_addr(hdr->addr1))
-- 
2.14.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Fix line too long warning

2017-10-29 Thread Kien Ha
On Sun, 2017-10-29 at 18:54 +0300, Yury Norov wrote:
> Hi Kien,
> 
> On Sat, Oct 28, 2017 at 10:46:13PM -0400, Kien Ha wrote:
> > > From fc52a98aca0c033f2c03fdc7e8f83ae49625675a Mon Sep 17 00:00:00
> > > 2001
> > 
> > From: Kien Ha 
> > Date: Fri, 27 Oct 2017 14:07:55 -0400
> > Subject: [PATCH] Fix line too long warning
> > 
> > Signed-off-by: Kien Ha 
> > ---
> >  drivers/staging/rtlwifi/base.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/staging/rtlwifi/base.c
> > b/drivers/staging/rtlwifi/base.c
> > index b88b0e8edd3d..bbc80f976e12 100644
> > --- a/drivers/staging/rtlwifi/base.c
> > +++ b/drivers/staging/rtlwifi/base.c
> > @@ -1283,7 +1283,8 @@ void rtl_get_tcb_desc(struct ieee80211_hw
> > *hw,
> > } else {
> > if (rtlmac->mode ==
> > WIRELESS_MODE_B) {
> > tcb_desc->hw_rate
> > =
> > -   rtlpriv->cfg-
> > >maps[RTL_RC_CCK_RATE11M];
> > +   rtlpriv->cfg-
> > >maps[
> > +   RTL_RC_CCK_RAT
> > E11M];
> 
> At first, if you fix this, you should also fix similar problem 3
> lines
> below, right?
> 
> > } else {
> > tcb_desc->hw_rate
> > =
> > rtlpriv->cfg-
> > >maps[RTL_RC_OFDM_RATE54M];
> 
> At second, and most important, refer Documentation/process/coding-
> style.rst:
> Now, some people will claim that having 8-character indentations
> makes
> the code move too far to the right, and makes it hard to read on a 
> 80-character terminal screen.  The answer to that is that if you
> need 
> more than 3 levels of indentation, you're screwed anyway, and should
> fix
> your program.
> 
> The real problem here is not "line too long", but "indentation level
> too
> big" - 5. And it worth to address real problem.
> 
> Yury

Thank you for taking some of your time to review my patch, providing
valuable feedback and pointing me in the right direction Joe and Yury.
I submitted another patch with improved code based on your
suggestions.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: greybus: spilib: fix use-after-free after deregistration

2017-10-29 Thread Rui Miguel Silva
Hi Johan,
Thanks for the patch.

On Sun 29 Oct 2017 at 12:01, Johan Hovold  wrote:
> Remove erroneous spi_master_put() after controller deregistration which
> would access the already freed spi controller.
>
> Note that spi_unregister_master() drops our only controller reference.
>
> Fixes: ba3e67001b42 ("greybus: SPI: convert to a gpbridge driver")
> Cc: stable  # 4.9
> Cc: Greg Kroah-Hartman 
> Signed-off-by: Johan Hovold 

Reviewed-by: Rui Miguel Silva 

---
Cheers,
Rui

> ---
>  drivers/staging/greybus/spilib.c | 8 +---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/greybus/spilib.c 
> b/drivers/staging/greybus/spilib.c
> index e97b19148497..1e7321a1404c 100644
> --- a/drivers/staging/greybus/spilib.c
> +++ b/drivers/staging/greybus/spilib.c
> @@ -544,11 +544,14 @@ int gb_spilib_master_init(struct gb_connection 
> *connection, struct device *dev,
>  
>   return 0;
>  
> -exit_spi_unregister:
> - spi_unregister_master(master);
>  exit_spi_put:
>   spi_master_put(master);
>  
> + return ret;
> +
> +exit_spi_unregister:
> + spi_unregister_master(master);
> +
>   return ret;
>  }
>  EXPORT_SYMBOL_GPL(gb_spilib_master_init);
> @@ -558,7 +561,6 @@ void gb_spilib_master_exit(struct gb_connection 
> *connection)
>   struct spi_master *master = gb_connection_get_data(connection);
>  
>   spi_unregister_master(master);
> - spi_master_put(master);
>  }
>  EXPORT_SYMBOL_GPL(gb_spilib_master_exit);

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: lustre: Replaces 'uint32_t' with '__u32' and 'uint64_t' with '__u64'.

2017-10-29 Thread Roman Storozhenko
There are two reasons for that:
1) As Linus Torvalds said we should use kernel types:
http://lkml.iu.edu/hypermail//linux/kernel/1506.0/00160.html

2) There are only few places in the lustre codebase that use such types.
In the most cases it uses '__u32' and '__u64'.

Signed-off-by: Roman Storozhenko 

---
 drivers/staging/lustre/lustre/include/lustre_sec.h |  4 ++--
 drivers/staging/lustre/lustre/llite/vvp_dev.c  |  2 +-
 drivers/staging/lustre/lustre/lov/lov_internal.h   | 12 ++--
 drivers/staging/lustre/lustre/osc/osc_internal.h   |  6 +++---
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_sec.h 
b/drivers/staging/lustre/lustre/include/lustre_sec.h
index 03a970b..c616ae5 100644
--- a/drivers/staging/lustre/lustre/include/lustre_sec.h
+++ b/drivers/staging/lustre/lustre/include/lustre_sec.h
@@ -340,8 +340,8 @@ void sptlrpc_conf_client_adapt(struct obd_device *obd);
 #define SPTLRPC_MAX_PAYLOAD (1024)
 
 struct vfs_cred {
-   uint32_tvc_uid;
-   uint32_tvc_gid;
+   __u32   vc_uid;
+   __u32   vc_gid;
 };
 
 struct ptlrpc_ctx_ops {
diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c 
b/drivers/staging/lustre/lustre/llite/vvp_dev.c
index f9d9a16..9a98a95 100644
--- a/drivers/staging/lustre/lustre/llite/vvp_dev.c
+++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c
@@ -383,7 +383,7 @@ int cl_sb_fini(struct super_block *sb)
 struct vvp_pgcache_id {
unsigned int vpi_bucket;
unsigned int vpi_depth;
-   uint32_t vpi_index;
+   __u32vpi_index;
 
unsigned int vpi_curdep;
struct lu_object_header *vpi_obj;
diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h 
b/drivers/staging/lustre/lustre/lov/lov_internal.h
index a21f074..49a106c 100644
--- a/drivers/staging/lustre/lustre/lov/lov_internal.h
+++ b/drivers/staging/lustre/lustre/lov/lov_internal.h
@@ -114,19 +114,19 @@ static inline const struct lsm_operations 
*lsm_op_find(int magic)
  */
 #if BITS_PER_LONG == 64
 # define lov_do_div64(n, base) ({  \
-   uint64_t __base = (base);   \
-   uint64_t __rem; \
-   __rem = ((uint64_t)(n)) % __base;   \
-   (n) = ((uint64_t)(n)) / __base; \
+   __u64 __base = (base);  \
+   __u64 __rem;\
+   __rem = ((__u64)(n)) % __base;  \
+   (n) = ((__u64)(n)) / __base;\
__rem;  \
 })
 #elif BITS_PER_LONG == 32
 # define lov_do_div64(n, base) ({  \
-   uint64_t __rem; \
+   __u64 __rem;\
if ((sizeof(base) > 4) && (((base) & 0xULL) != 0)) {  \
int __remainder;  \
LASSERTF(!((base) & (LOV_MIN_STRIPE_SIZE - 1)), "64 bit lov " \
-"division %llu / %llu\n", (n), (uint64_t)(base));\
+"division %llu / %llu\n", (n), (__u64)(base));\
__remainder = (n) & (LOV_MIN_STRIPE_SIZE - 1);  \
(n) >>= LOV_MIN_STRIPE_BITS;\
__rem = do_div(n, (base) >> LOV_MIN_STRIPE_BITS);   \
diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h 
b/drivers/staging/lustre/lustre/osc/osc_internal.h
index a536908..92d2e1f 100644
--- a/drivers/staging/lustre/lustre/osc/osc_internal.h
+++ b/drivers/staging/lustre/lustre/osc/osc_internal.h
@@ -167,9 +167,9 @@ struct osc_device {
 
/* Write stats is actually protected by client_obd's lock. */
struct osc_stats {
-   uint64_t os_lockless_writes;  /* by bytes */
-   uint64_t os_lockless_reads;/* by bytes */
-   uint64_t os_lockless_truncates;   /* by times */
+   __u64 os_lockless_writes; /* by bytes */
+   __u64 os_lockless_reads;   /* by bytes */
+   __u64 os_lockless_truncates;   /* by times */
} od_stats;
 
/* configuration item(s) */
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 0/2] Drivers: hv: vmbus: Miscellaneous enhancements

2017-10-29 Thread kys
From: "K. Y. Srinivasan" 

Reply-To: k...@microsoft.com

Miscellaneous enhancements.

K. Y. Srinivasan (1):
  Drivers: hv: vmbus: Make pannic reporting to be more useful

Stephen Hemminger (1):
  Drivers: hv: vmbus: Expose per-channel interrupts and events counters

 Documentation/ABI/stable/sysfs-bus-vmbus | 26 --
 arch/x86/hyperv/hv_init.c| 15 +--
 arch/x86/include/asm/mshyperv.h  |  2 +-
 drivers/hv/connection.c  |  2 ++
 drivers/hv/vmbus_drv.c   | 20 ++--
 include/linux/hyperv.h   |  4 
 6 files changed, 54 insertions(+), 15 deletions(-)

-- 
2.14.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/2] Drivers: hv: vmbus: Make pannic reporting to be more useful

2017-10-29 Thread kys
From: "K. Y. Srinivasan" 

Hyper-V allows the guest to report panic and the guest can pass additional
information. All this is logged on the host. Currently Linux is passing back
information that is not particularly useful. Make the following changes:

1. Windows uses crash MSR P0 to report bugcheck code. Follow the same
convention for Linux as well.
2. It will be useful to know the gust ID of the Linux guest that has
paniced. Pass back this information.

These changes will help in better supporting Linux on Hyper-V

Signed-off-by: K. Y. Srinivasan 
---
 arch/x86/hyperv/hv_init.c   | 15 +--
 arch/x86/include/asm/mshyperv.h |  2 +-
 drivers/hv/vmbus_drv.c  |  4 ++--
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index a5db63f728a2..aeb8edf32e2b 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -210,9 +210,10 @@ void hyperv_cleanup(void)
 }
 EXPORT_SYMBOL_GPL(hyperv_cleanup);
 
-void hyperv_report_panic(struct pt_regs *regs)
+void hyperv_report_panic(struct pt_regs *regs, long err)
 {
static bool panic_reported;
+   u64 guest_id;
 
/*
 * We prefer to report panic on 'die' chain as we have proper
@@ -223,11 +224,13 @@ void hyperv_report_panic(struct pt_regs *regs)
return;
panic_reported = true;
 
-   wrmsrl(HV_X64_MSR_CRASH_P0, regs->ip);
-   wrmsrl(HV_X64_MSR_CRASH_P1, regs->ax);
-   wrmsrl(HV_X64_MSR_CRASH_P2, regs->bx);
-   wrmsrl(HV_X64_MSR_CRASH_P3, regs->cx);
-   wrmsrl(HV_X64_MSR_CRASH_P4, regs->dx);
+   rdmsrl(HV_X64_MSR_GUEST_OS_ID, guest_id);
+
+   wrmsrl(HV_X64_MSR_CRASH_P0, err);
+   wrmsrl(HV_X64_MSR_CRASH_P1, guest_id);
+   wrmsrl(HV_X64_MSR_CRASH_P2, regs->ip);
+   wrmsrl(HV_X64_MSR_CRASH_P3, regs->ax);
+   wrmsrl(HV_X64_MSR_CRASH_P4, regs->sp);
 
/*
 * Let Hyper-V know there is crash data available
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 530f448fddaf..bd89104a5533 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -310,7 +310,7 @@ static inline int hv_cpu_number_to_vp_number(int cpu_number)
 void hyperv_init(void);
 void hyperv_setup_mmu_ops(void);
 void hyper_alloc_mmu(void);
-void hyperv_report_panic(struct pt_regs *regs);
+void hyperv_report_panic(struct pt_regs *regs, long err);
 bool hv_is_hypercall_page_setup(void);
 void hyperv_cleanup(void);
 #else /* CONFIG_HYPERV */
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index bca8188f3c8c..8fe13cd76acf 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -65,7 +65,7 @@ static int hyperv_panic_event(struct notifier_block *nb, 
unsigned long val,
 
regs = current_pt_regs();
 
-   hyperv_report_panic(regs);
+   hyperv_report_panic(regs, val);
return NOTIFY_DONE;
 }
 
@@ -75,7 +75,7 @@ static int hyperv_die_event(struct notifier_block *nb, 
unsigned long val,
struct die_args *die = (struct die_args *)args;
struct pt_regs *regs = die->regs;
 
-   hyperv_report_panic(regs);
+   hyperv_report_panic(regs, val);
return NOTIFY_DONE;
 }
 
-- 
2.14.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2] Drivers: hv: vmbus: Expose per-channel interrupts and events counters

2017-10-29 Thread kys
From: Stephen Hemminger 

When investigating performance, it is useful to be able to look at
the number of host and guest events per-channel. This is equivalent
to per-device interrupt statistics.

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 Documentation/ABI/stable/sysfs-bus-vmbus | 26 --
 drivers/hv/connection.c  |  2 ++
 drivers/hv/vmbus_drv.c   | 16 
 include/linux/hyperv.h   |  4 
 4 files changed, 42 insertions(+), 6 deletions(-)

diff --git a/Documentation/ABI/stable/sysfs-bus-vmbus 
b/Documentation/ABI/stable/sysfs-bus-vmbus
index 0ebd8a1537a0..d4077cc60d55 100644
--- a/Documentation/ABI/stable/sysfs-bus-vmbus
+++ b/Documentation/ABI/stable/sysfs-bus-vmbus
@@ -61,39 +61,53 @@ Date:   September. 2017
 KernelVersion: 4.14
 Contact:   Stephen Hemminger 
 Description:   Inbound channel signaling state
-Users: Debuggig tools
+Users: Debugging tools
 
 What:  /sys/bus/vmbus/devices/vmbus_*/channels/relid/latency
 Date:  September. 2017
 KernelVersion: 4.14
 Contact:   Stephen Hemminger 
 Description:   Channel signaling latency
-Users: Debuggig tools
+Users: Debugging tools
 
 What:  /sys/bus/vmbus/devices/vmbus_*/channels/relid/out_mask
 Date:  September. 2017
 KernelVersion: 4.14
 Contact:   Stephen Hemminger 
 Description:   Outbound channel signaling state
-Users: Debuggig tools
+Users: Debugging tools
 
 What:  /sys/bus/vmbus/devices/vmbus_*/channels/relid/pending
 Date:  September. 2017
 KernelVersion: 4.14
 Contact:   Stephen Hemminger 
 Description:   Channel interrupt pending state
-Users: Debuggig tools
+Users: Debugging tools
 
 What:  /sys/bus/vmbus/devices/vmbus_*/channels/relid/read_avail
 Date:  September. 2017
 KernelVersion: 4.14
 Contact:   Stephen Hemminger 
 Description:   Bytes availabble to read
-Users: Debuggig tools
+Users: Debugging tools
 
 What:  /sys/bus/vmbus/devices/vmbus_*/channels/relid/write_avail
 Date:  September. 2017
 KernelVersion: 4.14
 Contact:   Stephen Hemminger 
 Description:   Bytes availabble to write
-Users: Debuggig tools
+Users: Debugging tools
+
+What:  /sys/bus/vmbus/devices/vmbus_*/channels/relid/events
+Date:  September. 2017
+KernelVersion: 4.14
+Contact:   Stephen Hemminger 
+Description:   Number of times we have signaled the host
+Users: Debugging tools
+
+What:  /sys/bus/vmbus/devices/vmbus_*/channels/relid/interrupts
+Date:  September. 2017
+KernelVersion: 4.14
+Contact:   Stephen Hemminger 
+Description:   Number of times we have taken an interrupt (incoming)
+Users: Debugging tools
diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index f41901f80b64..b06a6b796819 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -409,6 +409,8 @@ void vmbus_set_event(struct vmbus_channel *channel)
if (!channel->is_dedicated_interrupt)
vmbus_send_interrupt(child_relid);
 
+   ++channel->sig_events;
+
hv_do_fast_hypercall8(HVCALL_SIGNAL_EVENT, channel->sig_event);
 }
 EXPORT_SYMBOL_GPL(vmbus_set_event);
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 1da8e818f4de..bca8188f3c8c 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -944,6 +944,8 @@ static void vmbus_chan_sched(struct hv_per_cpu_context 
*hv_cpu)
if (channel->rescind)
continue;
 
+   ++channel->interrupts;
+
switch (channel->callback_mode) {
case HV_CALL_ISR:
vmbus_channel_isr(channel);
@@ -1237,6 +1239,18 @@ static ssize_t channel_latency_show(const struct 
vmbus_channel *channel,
 }
 VMBUS_CHAN_ATTR(latency, S_IRUGO, channel_latency_show, NULL);
 
+static ssize_t channel_interrupts_show(const struct vmbus_channel *channel, 
char *buf)
+{
+   return sprintf(buf, "%llu\n", channel->interrupts);
+}
+VMBUS_CHAN_ATTR(interrupts, S_IRUGO, channel_interrupts_show, NULL);
+
+static ssize_t channel_events_show(const struct vmbus_channel *channel, char 
*buf)
+{
+   return sprintf(buf, "%llu\n", channel->sig_events);
+}
+VMBUS_CHAN_ATTR(events, S_IRUGO, channel_events_show, NULL);
+
 static struct attribute *vmbus_chan_attrs[] = {
&chan_attr_out_mask.attr,
&chan_attr_in_mask.attr,
@@ -1245,6 +1259,8 @@ static struct attribute *vmbus_chan_attrs[] = {
&chan_attr_cpu.attr,
&chan_attr_pending.attr,
&chan_attr_latency.attr,
+   &chan_attr_interrupts.attr,
+   &chan_attr_events.attr,
NULL
 };
 
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index ea6b5586ad77..f3e97c5f94c9 100644
--- a/include/linux/hyper

Re: [PATCH] Fix line too long warning

2017-10-29 Thread Yury Norov
On Sun, Oct 29, 2017 at 10:28:27AM -0700, Joe Perches wrote:
> On Sun, 2017-10-29 at 18:54 +0300, Yury Norov wrote:
> > At second, and most important, refer Documentation/process/coding-style.rst:
> > Now, some people will claim that having 8-character indentations makes
> > the code move too far to the right, and makes it hard to read on a 
> > 80-character terminal screen.  The answer to that is that if you need 
> > more than 3 levels of indentation, you're screwed anyway, and should fix
> > your program.
> > 
> > The real problem here is not "line too long", but "indentation level too
> > big" - 5. And it worth to address real problem.
> 
> Line length issues can be a combination of several factors:
> 
> o identifier length
> o quantity of dereferences
> o indentation depth
> o code complexity
> 
> 4 indentation depth levels are not a real issue.
> A significant percentage of lines in the kernel
> are 4 or more tab indent levels deep.
> 
> checkpatch suggests that 6 or more is the depth level
> that should cause real concern.
> 
> Here's a little breakdown of lines that start with
> a tab followed by a c90 keyword in the kernel
> 
> $ git grep -P 
> "^\t+(if|for|do|while|\}|else|switch|return|case|break|continue|goto)\b" -- 
> "*.[ch]" | \
>   cut -f2- -d":" | perl -p -e 's/(^\t+).*/\1/' | \
>   sort | uniq -c | sort -rn | \
>   awk '{total += $1; count[i++] = $1} END { for (j = 0; j < i; j++) { printf 
> "%d\t%d\t%.2f%%\n", j + 1, count[j], count[j] / total * 100 }}'
> 1 1325462 52.19%
> 2 863007  33.98%
> 3 271844  10.70%
> 4 64009   2.52%
> 5 12502   0.49%
> 6 21990.09%
> 7 501 0.02%
> 8 166 0.01%
> 9 51  0.00%
> 1020  0.00%
> 1110  0.00%
> 124   0.00%
> 131   0.00%
> 
> I think it could reasonably be argued that the
> indentation depth warning (DEEP_INDENTATION)
> should start at 5 and not at 6.
> 
> ---
>  scripts/checkpatch.pl | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 6bdd43d5dec5..923e4ff09d24 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -3353,7 +3353,7 @@ sub process {
>  
>   my ($level, @ctx) = ctx_statement_level($linenr, 
> $realcnt, 0);
>  
> - if ($line =~ /^\+\t{6,}/) {
> + if ($line =~ /^\+\t{5,}/) {
>   WARN("DEEP_INDENTATION",
>"Too many leading tabs - consider code 
> refactoring\n" . $herecurr);
>   }

There are 2 different subjects here - this specific function in staging
driver and general considerations.

Regarding the function, it has very simple structure, and so deep indentation
level is definitely a symptom of bad design.

Regarding general considerations, the kernel is very complex, and I admit
that indentations deeper than 3 are unavoidable in some cases.

But we have coding style that insists on 3, and this rule is (probably ?)
written by Linus, so... :-)

Nevertheless, your patch is the step toward right direction, so if you
need my ack,
Acked-by: Yury Norov 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 02/17] hyper-v: trace vmbus_on_message()

2017-10-29 Thread kys
From: Vitaly Kuznetsov 

Add tracepoint to vmbus_on_message() which is called when we start
processing a blocking from work context.

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel_mgmt.c | 2 ++
 drivers/hv/hv_trace.h | 5 +
 2 files changed, 7 insertions(+)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index a8dc9a164631..71d4d68488d4 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -1176,6 +1176,8 @@ void vmbus_onmessage(void *context)
hdr = (struct vmbus_channel_message_header *)msg->u.payload;
size = msg->header.payload_size;
 
+   trace_vmbus_on_message(hdr);
+
if (hdr->msgtype >= CHANNELMSG_COUNT) {
pr_err("Received invalid channel message type %d size %d\n",
   hdr->msgtype, size);
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index 9c2772922c76..d432aba5df8a 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -19,6 +19,11 @@ DEFINE_EVENT(vmbus_hdr_msg, vmbus_on_msg_dpc,
TP_ARGS(hdr)
 );
 
+DEFINE_EVENT(vmbus_hdr_msg, vmbus_on_message,
+   TP_PROTO(const struct vmbus_channel_message_header *hdr),
+   TP_ARGS(hdr)
+);
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.14.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 00/17] Drivers: hv: vmbus: Add tracing to VMBus

2017-10-29 Thread kys
From: "K. Y. Srinivasan" 

Reply-To: k...@microsoft.com

Messages between guest and host are used in Hyper-V as control flow. To
simplify debugging various issues which are often hard to reproduce add
tracepoints to all message senders and handlers. This is not a
performance
critical path and tracing overhead should be negligible.

The example usage and output is:

Enable all tracing events:
# echo 1 > /sys/kernel/debug/tracing/events/hyperv/enable 

Do something which causes messages to be sent between host and guest,
e.g.
hot remove a VMBus device.

Check events:
# cat /sys/kernel/debug/tracing/trace 

# tracer: nop
#
#  _-=> irqs-off
# / _=> need-resched
#| / _---=> hardirq/softirq
#|| / _--=> preempt-depth
#||| / delay
#   TASK-PID   CPU#  TIMESTAMP  FUNCTION
#  | |   |      | |
  -0 [011] ..s.   122.981583: vmbus_on_msg_dpc:
msgtype=1
kworker/11:7-1506  [011]    122.981597: vmbus_on_message:
msgtype=1
kworker/11:7-1506  [011]    122.981598: vmbus_onoffer:
child_relid 0x10, monitorid 0x2, is_dedicated 1, connection_id 0x10010,
if_type f8615163-df3e-46c5-913f-f2d2f965ed0e, if_instance
6676e078-e4b3-44da-8a7d-12eafb577d31, chn_flags 0x0, mmio_megabytes 0,
sub_channel_index 0
kworker/11:7-1506  [011]    122.982130:
vmbus_establish_gpadl_header: sending child_relid 0x10, gpadl 0xe1e34,
range_buflen 2056 rangecount 1, ret 0
kworker/11:7-1506  [011]    122.982133:
vmbus_establish_gpadl_body: sending msgnumber 0, gpadl 0xe1e34, ret 0
kworker/11:7-1506  [011]    122.982136:
vmbus_establish_gpadl_body: sending msgnumber 0, gpadl 0xe1e34, ret 0
kworker/11:7-1506  [011]    122.982137:
vmbus_establish_gpadl_body: sending msgnumber 0, gpadl 0xe1e34, ret 0
kworker/11:7-1506  [011]    122.982139:
vmbus_establish_gpadl_body: sending msgnumber 0, gpadl 0xe1e34, ret 0
kworker/11:7-1506  [011]    122.982141:
vmbus_establish_gpadl_body: sending msgnumber 0, gpadl 0xe1e34, ret 0
kworker/11:7-1506  [011]    122.982142:
vmbus_establish_gpadl_body: sending msgnumber 0, gpadl 0xe1e34, ret 0
kworker/11:7-1506  [011]    122.982144:
vmbus_establish_gpadl_body: sending msgnumber 0, gpadl 0xe1e34, ret 0
kworker/11:7-1506  [011]    122.982146:
vmbus_establish_gpadl_body: sending msgnumber 0, gpadl 0xe1e34, ret 0
kworker/11:7-1506  [011]    122.982148:
vmbus_establish_gpadl_body: sending msgnumber 0, gpadl 0xe1e34, ret 0
  -0 [011] ..s.   122.982336: vmbus_on_msg_dpc:
msgtype=10
  -0 [011] ..s.   122.982337: vmbus_ongpadl_created:
child_relid 0x10, gpadl 0xe1e34, creation_status 0
kworker/11:7-1506  [011]    122.982351: vmbus_open: sending
child_relid 0x10, openid 16, gpadlhandle 0xe1e34, target_vp 0xb, offset
0x80, ret 0
 kworker/3:1-214   [003]    123.015007: vmbus_setevent: relid
0x5
  -0 [011] ..s.   123.029467: vmbus_on_msg_dpc:
msgtype=6
  -0 [011] ..s.   123.029470: vmbus_onopen_result:
child_relid 0x10, openid 16, status 0
kworker/11:7-1506  [011]    123.029492: vmbus_setevent: relid
0x10
  -0 [011] d.h.   123.029533: vmbus_chan_sched: relid
0x10
kworker/11:7-1506  [011]    123.029539: vmbus_setevent: relid
0x10

CHANNELMSG_UNLOAD/CHANNELMSG_UNLOAD_RESPONSE are not traced as these are
mostly used on crash.


Vitaly Kuznetsov (17):
  hyper-v: trace vmbus_on_msg_dpc()
  hyper-v: trace vmbus_on_message()
  hyper-v: trace vmbus_onoffer()
  hyper-v: trace vmbus_onoffer_rescind()
  hyper-v: trace vmbus_onopen_result()
  hyper-v: trace vmbus_ongpadl_created()
  hyper-v: trace vmbus_ongpadl_torndown()
  hyper-v: trace vmbus_onversion_response()
  hyper-v: trace vmbus_request_offers()
  hyper-v: trace vmbus_open()
  hyper-v: trace vmbus_close_internal()
  hyper-v: trace vmbus_establish_gpadl()
  hyper-v: trace vmbus_teardown_gpadl()
  hyper-v: trace vmbus_negotiate_version()
  hyper-v: trace vmbus_release_relid()
  hyper-v: trace vmbus_send_tl_connect_request()
  hyper-v: trace channel events

 drivers/hv/Makefile   |   4 +-
 drivers/hv/channel.c  |  21 ++-
 drivers/hv/channel_mgmt.c |  26 +++-
 drivers/hv/connection.c   |   5 +
 drivers/hv/hv_trace.c |   4 +
 drivers/hv/hv_trace.h | 327 ++
 drivers/hv/hyperv_vmbus.h |   2 +
 drivers/hv/vmbus_drv.c|   4 +
 8 files changed, 388 insertions(+), 5 deletions(-)
 create mode 100644 drivers/hv/hv_trace.c
 create mode 100644 drivers/hv/hv_trace.h

-- 
2.14.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 06/17] hyper-v: trace vmbus_ongpadl_created()

2017-10-29 Thread kys
From: Vitaly Kuznetsov 

Add tracepoint to CHANNELMSG_GPADL_CREATED handler.

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel_mgmt.c |  2 ++
 drivers/hv/hv_trace.h | 17 +
 2 files changed, 19 insertions(+)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index c735abe01712..4bff75449afb 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -1032,6 +1032,8 @@ static void vmbus_ongpadl_created(struct 
vmbus_channel_message_header *hdr)
 
gpadlcreated = (struct vmbus_channel_gpadl_created *)hdr;
 
+   trace_vmbus_ongpadl_created(gpadlcreated);
+
/*
 * Find the establish msg, copy the result and signal/unblock the wait
 * event
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index 9757c19d1c08..20734b7b341b 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -86,6 +86,23 @@ TRACE_EVENT(vmbus_onopen_result,
)
);
 
+TRACE_EVENT(vmbus_ongpadl_created,
+   TP_PROTO(const struct vmbus_channel_gpadl_created *gpadlcreated),
+   TP_ARGS(gpadlcreated),
+   TP_STRUCT__entry(
+   __field(u32, child_relid)
+   __field(u32, gpadl)
+   __field(u32, status)
+   ),
+   TP_fast_assign(__entry->child_relid = gpadlcreated->child_relid;
+  __entry->gpadl = gpadlcreated->gpadl;
+  __entry->status = gpadlcreated->creation_status;
+   ),
+   TP_printk("child_relid 0x%x, gpadl 0x%x, creation_status %d",
+ __entry->child_relid,  __entry->gpadl,  __entry->status
+   )
+   );
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.14.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 03/17] hyper-v: trace vmbus_onoffer()

2017-10-29 Thread kys
From: Vitaly Kuznetsov 

Add tracepoint to CHANNELMSG_OFFERCHANNEL handler.

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel_mgmt.c |  2 ++
 drivers/hv/hv_trace.h | 37 +
 2 files changed, 39 insertions(+)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 71d4d68488d4..7c11e17ad295 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -813,6 +813,8 @@ static void vmbus_onoffer(struct 
vmbus_channel_message_header *hdr)
 
offer = (struct vmbus_channel_offer_channel *)hdr;
 
+   trace_vmbus_onoffer(offer);
+
/* Allocate the channel object and save this offer. */
newchannel = alloc_channel();
if (!newchannel) {
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index d432aba5df8a..488b873b563e 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -24,6 +24,43 @@ DEFINE_EVENT(vmbus_hdr_msg, vmbus_on_message,
TP_ARGS(hdr)
 );
 
+TRACE_EVENT(vmbus_onoffer,
+   TP_PROTO(const struct vmbus_channel_offer_channel *offer),
+   TP_ARGS(offer),
+   TP_STRUCT__entry(
+   __field(u32, child_relid)
+   __field(u8, monitorid)
+   __field(u16, is_ddc_int)
+   __field(u32, connection_id)
+   __array(char, if_type, 16)
+   __array(char, if_instance, 16)
+   __field(u16, chn_flags)
+   __field(u16, mmio_mb)
+   __field(u16, sub_idx)
+   ),
+   TP_fast_assign(__entry->child_relid = offer->child_relid;
+  __entry->monitorid = offer->monitorid;
+  __entry->is_ddc_int = offer->is_dedicated_interrupt;
+  __entry->connection_id = offer->connection_id;
+  memcpy(__entry->if_type,
+ &offer->offer.if_type.b, 16);
+  memcpy(__entry->if_instance,
+ &offer->offer.if_instance.b, 16);
+  __entry->chn_flags = offer->offer.chn_flags;
+  __entry->mmio_mb = offer->offer.mmio_megabytes;
+  __entry->sub_idx = offer->offer.sub_channel_index;
+   ),
+   TP_printk("child_relid 0x%x, monitorid 0x%x, is_dedicated %d, "
+ "connection_id 0x%x, if_type %pUl, if_instance %pUl, "
+ "chn_flags 0x%x, mmio_megabytes %d, sub_channel_index %d",
+ __entry->child_relid, __entry->monitorid,
+ __entry->is_ddc_int, __entry->connection_id,
+ __entry->if_type, __entry->if_instance,
+ __entry->chn_flags, __entry->mmio_mb,
+ __entry->sub_idx
+   )
+   );
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.14.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 01/17] hyper-v: trace vmbus_on_msg_dpc()

2017-10-29 Thread kys
From: Vitaly Kuznetsov 

Add tracing subsystem to Hyper-V VMBus module and add tracepoint
to vmbus_on_msg_dpc() which is called when we receive a message from host.

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/Makefile   |  4 +++-
 drivers/hv/hv_trace.c |  4 
 drivers/hv/hv_trace.h | 29 +
 drivers/hv/hyperv_vmbus.h |  2 ++
 drivers/hv/vmbus_drv.c|  2 ++
 5 files changed, 40 insertions(+), 1 deletion(-)
 create mode 100644 drivers/hv/hv_trace.c
 create mode 100644 drivers/hv/hv_trace.h

diff --git a/drivers/hv/Makefile b/drivers/hv/Makefile
index 39c9b2c08d33..ad791e00230f 100644
--- a/drivers/hv/Makefile
+++ b/drivers/hv/Makefile
@@ -2,7 +2,9 @@ obj-$(CONFIG_HYPERV)+= hv_vmbus.o
 obj-$(CONFIG_HYPERV_UTILS) += hv_utils.o
 obj-$(CONFIG_HYPERV_BALLOON)   += hv_balloon.o
 
+CFLAGS_hv_trace.o = -I$(src)
+
 hv_vmbus-y := vmbus_drv.o \
 hv.o connection.o channel.o \
-channel_mgmt.o ring_buffer.o
+channel_mgmt.o ring_buffer.o hv_trace.o
 hv_utils-y := hv_util.o hv_kvp.o hv_snapshot.o hv_fcopy.o hv_utils_transport.o
diff --git a/drivers/hv/hv_trace.c b/drivers/hv/hv_trace.c
new file mode 100644
index ..df47acd01a81
--- /dev/null
+++ b/drivers/hv/hv_trace.c
@@ -0,0 +1,4 @@
+#include "hyperv_vmbus.h"
+
+#define CREATE_TRACE_POINTS
+#include "hv_trace.h"
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
new file mode 100644
index ..9c2772922c76
--- /dev/null
+++ b/drivers/hv/hv_trace.h
@@ -0,0 +1,29 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM hyperv
+
+#if !defined(_HV_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _HV_TRACE_H
+
+#include 
+
+DECLARE_EVENT_CLASS(vmbus_hdr_msg,
+   TP_PROTO(const struct vmbus_channel_message_header *hdr),
+   TP_ARGS(hdr),
+   TP_STRUCT__entry(__field(unsigned int, msgtype)),
+   TP_fast_assign(__entry->msgtype = hdr->msgtype;),
+   TP_printk("msgtype=%u", __entry->msgtype)
+);
+
+DEFINE_EVENT(vmbus_hdr_msg, vmbus_on_msg_dpc,
+   TP_PROTO(const struct vmbus_channel_message_header *hdr),
+   TP_ARGS(hdr)
+);
+
+#undef TRACE_INCLUDE_PATH
+#define TRACE_INCLUDE_PATH .
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_FILE hv_trace
+#endif /* _HV_TRACE_H */
+
+/* This part must be outside protection */
+#include 
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index de6f01df9592..22300ec7b556 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -31,6 +31,8 @@
 #include 
 #include 
 
+#include "hv_trace.h"
+
 /*
  * Timeout for services such as KVP and fcopy.
  */
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 8fe13cd76acf..8f9293a87c6b 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -835,6 +835,8 @@ void vmbus_on_msg_dpc(unsigned long data)
 
hdr = (struct vmbus_channel_message_header *)msg->u.payload;
 
+   trace_vmbus_on_msg_dpc(hdr);
+
if (hdr->msgtype >= CHANNELMSG_COUNT) {
WARN_ONCE(1, "unknown msgtype=%d\n", hdr->msgtype);
goto msg_handled;
-- 
2.14.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 13/17] hyper-v: trace vmbus_teardown_gpadl()

2017-10-29 Thread kys
From: Vitaly Kuznetsov 

Add tracepoint to CHANNELMSG_GPADL_TEARDOWN sender.

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel.c  |  2 ++
 drivers/hv/hv_trace.h | 18 ++
 2 files changed, 20 insertions(+)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 823ddc714d56..0382d7b600a1 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -519,6 +519,8 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 
gpadl_handle)
ret = vmbus_post_msg(msg, sizeof(struct vmbus_channel_gpadl_teardown),
 true);
 
+   trace_vmbus_teardown_gpadl(msg, ret);
+
if (ret)
goto post_msg_err;
 
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index 978e70bdc7c5..cd33a52ef27f 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -214,6 +214,24 @@ TRACE_EVENT(vmbus_establish_gpadl_body,
)
);
 
+TRACE_EVENT(vmbus_teardown_gpadl,
+   TP_PROTO(const struct vmbus_channel_gpadl_teardown *msg, int ret),
+   TP_ARGS(msg, ret),
+   TP_STRUCT__entry(
+   __field(u32, child_relid)
+   __field(u32, gpadl)
+   __field(int, ret)
+   ),
+   TP_fast_assign(
+   __entry->child_relid = msg->child_relid;
+   __entry->gpadl = msg->gpadl;
+   __entry->ret = ret;
+   ),
+   TP_printk("sending child_relid 0x%x, gpadl 0x%x, ret %d",
+ __entry->child_relid, __entry->gpadl, __entry->ret
+   )
+   );
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.14.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 07/17] hyper-v: trace vmbus_ongpadl_torndown()

2017-10-29 Thread kys
From: Vitaly Kuznetsov 

Add tracepoint to CHANNELMSG_GPADL_TORNDOWN handler.

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel_mgmt.c | 2 ++
 drivers/hv/hv_trace.h | 8 
 2 files changed, 10 insertions(+)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 4bff75449afb..d1cb85257bf0 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -1082,6 +1082,8 @@ static void vmbus_ongpadl_torndown(
 
gpadl_torndown = (struct vmbus_channel_gpadl_torndown *)hdr;
 
+   trace_vmbus_ongpadl_torndown(gpadl_torndown);
+
/*
 * Find the open msg, copy the result and signal/unblock the wait event
 */
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index 20734b7b341b..84c08cdf7235 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -103,6 +103,14 @@ TRACE_EVENT(vmbus_ongpadl_created,
)
);
 
+TRACE_EVENT(vmbus_ongpadl_torndown,
+   TP_PROTO(const struct vmbus_channel_gpadl_torndown *gpadltorndown),
+   TP_ARGS(gpadltorndown),
+   TP_STRUCT__entry(__field(u32, gpadl)),
+   TP_fast_assign(__entry->gpadl = gpadltorndown->gpadl),
+   TP_printk("gpadl 0x%x", __entry->gpadl)
+   );
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.14.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 09/17] hyper-v: trace vmbus_request_offers()

2017-10-29 Thread kys
From: Vitaly Kuznetsov 

Add tracepoint to CHANNELMSG_REQUESTOFFERS sender.

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel_mgmt.c | 4 +++-
 drivers/hv/hv_trace.h | 8 
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index c33b7412f303..b27edff8796e 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -1224,9 +1224,11 @@ int vmbus_request_offers(void)
 
msg->msgtype = CHANNELMSG_REQUESTOFFERS;
 
-
ret = vmbus_post_msg(msg, sizeof(struct vmbus_channel_message_header),
 true);
+
+   trace_vmbus_request_offers(ret);
+
if (ret != 0) {
pr_err("Unable to request offers - %d\n", ret);
 
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index 2a046547107f..566ac0f2fe56 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -122,6 +122,14 @@ TRACE_EVENT(vmbus_onversion_response,
TP_printk("version_supported %d", __entry->ver)
);
 
+TRACE_EVENT(vmbus_request_offers,
+   TP_PROTO(int ret),
+   TP_ARGS(ret),
+   TP_STRUCT__entry(__field(int, ret)),
+   TP_fast_assign(__entry->ret = ret),
+   TP_printk("sending ret %d", __entry->ret)
+   );
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.14.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 14/17] hyper-v: trace vmbus_negotiate_version()

2017-10-29 Thread kys
From: Vitaly Kuznetsov 

Add tracepoint to CHANNELMSG_INITIATE_CONTACT sender.

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/connection.c |  3 +++
 drivers/hv/hv_trace.h   | 26 ++
 2 files changed, 29 insertions(+)

diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index b06a6b796819..05f413c4fe3b 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -117,6 +117,9 @@ static int vmbus_negotiate_version(struct 
vmbus_channel_msginfo *msginfo,
ret = vmbus_post_msg(msg,
 sizeof(struct vmbus_channel_initiate_contact),
 true);
+
+   trace_vmbus_negotiate_version(msg, ret);
+
if (ret != 0) {
spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
list_del(&msginfo->msglistentry);
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index cd33a52ef27f..f06284d64a8c 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -232,6 +232,32 @@ TRACE_EVENT(vmbus_teardown_gpadl,
)
);
 
+TRACE_EVENT(vmbus_negotiate_version,
+   TP_PROTO(const struct vmbus_channel_initiate_contact *msg, int ret),
+   TP_ARGS(msg, ret),
+   TP_STRUCT__entry(
+   __field(u32, ver)
+   __field(u32, target_vcpu)
+   __field(int, ret)
+   __field(u64, int_page)
+   __field(u64, mon_page1)
+   __field(u64, mon_page2)
+   ),
+   TP_fast_assign(
+   __entry->ver = msg->vmbus_version_requested;
+   __entry->target_vcpu = msg->target_vcpu;
+   __entry->int_page = msg->interrupt_page;
+   __entry->mon_page1 = msg->monitor_page1;
+   __entry->mon_page2 = msg->monitor_page2;
+   __entry->ret = ret;
+   ),
+   TP_printk("sending vmbus_version_requested %d, target_vcpu 0x%x, "
+ "pages %llx:%llx:%llx, ret %d",
+ __entry->ver, __entry->target_vcpu, __entry->int_page,
+ __entry->mon_page1, __entry->mon_page2, __entry->ret
+   )
+   );
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.14.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 04/17] hyper-v: trace vmbus_onoffer_rescind()

2017-10-29 Thread kys
From: Vitaly Kuznetsov 

Add tracepoint to CHANNELMSG_RESCIND_CHANNELOFFER handler.

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel_mgmt.c | 2 ++
 drivers/hv/hv_trace.h | 8 
 2 files changed, 10 insertions(+)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 7c11e17ad295..cfe5c9c6a87c 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -856,6 +856,8 @@ static void vmbus_onoffer_rescind(struct 
vmbus_channel_message_header *hdr)
 
rescind = (struct vmbus_channel_rescind_offer *)hdr;
 
+   trace_vmbus_onoffer_rescind(rescind);
+
/*
 * The offer msg and the corresponding rescind msg
 * from the host are guranteed to be ordered -
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index 488b873b563e..dbbed1d1f327 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -61,6 +61,14 @@ TRACE_EVENT(vmbus_onoffer,
)
);
 
+TRACE_EVENT(vmbus_onoffer_rescind,
+   TP_PROTO(const struct vmbus_channel_rescind_offer *offer),
+   TP_ARGS(offer),
+   TP_STRUCT__entry(__field(u32, child_relid)),
+   TP_fast_assign(__entry->child_relid = offer->child_relid),
+   TP_printk("child_relid 0x%x", __entry->child_relid)
+   );
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.14.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 12/17] hyper-v: trace vmbus_establish_gpadl()

2017-10-29 Thread kys
From: Vitaly Kuznetsov 

Add tracepoint to CHANNELMSG_GPADL_HEADER/CHANNELMSG_GPADL_BODY sender.

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel.c  |  6 ++
 drivers/hv/hv_trace.h | 42 ++
 2 files changed, 48 insertions(+)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index a827f43aa408..823ddc714d56 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -435,6 +435,9 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, 
void *kbuffer,
 
ret = vmbus_post_msg(gpadlmsg, msginfo->msgsize -
 sizeof(*msginfo), true);
+
+   trace_vmbus_establish_gpadl_header(gpadlmsg, ret);
+
if (ret != 0)
goto cleanup;
 
@@ -450,6 +453,9 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, 
void *kbuffer,
ret = vmbus_post_msg(gpadl_body,
 submsginfo->msgsize - sizeof(*submsginfo),
 true);
+
+   trace_vmbus_establish_gpadl_body(gpadl_body, ret);
+
if (ret != 0)
goto cleanup;
 
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index 302bd4e964f0..978e70bdc7c5 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -172,6 +172,48 @@ TRACE_EVENT(vmbus_close_internal,
__entry->ret)
);
 
+TRACE_EVENT(vmbus_establish_gpadl_header,
+   TP_PROTO(const struct vmbus_channel_gpadl_header *msg, int ret),
+   TP_ARGS(msg, ret),
+   TP_STRUCT__entry(
+   __field(u32, child_relid)
+   __field(u32, gpadl)
+   __field(u16, range_buflen)
+   __field(u16, rangecount)
+   __field(int, ret)
+   ),
+   TP_fast_assign(
+   __entry->child_relid = msg->child_relid;
+   __entry->gpadl = msg->gpadl;
+   __entry->range_buflen = msg->range_buflen;
+   __entry->rangecount = msg->rangecount;
+   __entry->ret = ret;
+   ),
+   TP_printk("sending child_relid 0x%x, gpadl 0x%x, range_buflen %d "
+ "rangecount %d, ret %d",
+ __entry->child_relid, __entry->gpadl,
+ __entry->range_buflen, __entry->rangecount, __entry->ret
+   )
+   );
+
+TRACE_EVENT(vmbus_establish_gpadl_body,
+   TP_PROTO(const struct vmbus_channel_gpadl_body *msg, int ret),
+   TP_ARGS(msg, ret),
+   TP_STRUCT__entry(
+   __field(u32, msgnumber)
+   __field(u32, gpadl)
+   __field(int, ret)
+   ),
+   TP_fast_assign(
+   __entry->msgnumber = msg->msgnumber;
+   __entry->gpadl = msg->gpadl;
+   __entry->ret = ret;
+   ),
+   TP_printk("sending msgnumber %d, gpadl 0x%x, ret %d",
+ __entry->msgnumber, __entry->gpadl, __entry->ret
+   )
+   );
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.14.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 17/17] hyper-v: trace channel events

2017-10-29 Thread kys
From: Vitaly Kuznetsov 

Added an additional set of trace points for when channel gets notified
or signals host.

Suggested-by: Stephen Hemminger 
Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel.c|  2 ++
 drivers/hv/connection.c |  2 ++
 drivers/hv/hv_trace.h   | 23 +++
 drivers/hv/vmbus_drv.c  |  2 ++
 4 files changed, 29 insertions(+)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index ed3634e53e15..19f0cf37e0ed 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -43,6 +43,8 @@ void vmbus_setevent(struct vmbus_channel *channel)
 {
struct hv_monitor_page *monitorpage;
 
+   trace_vmbus_setevent(channel);
+
/*
 * For channels marked as in "low latency" mode
 * bypass the monitor page mechanism.
diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index 05f413c4fe3b..447371f4de56 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -322,6 +322,8 @@ void vmbus_on_event(unsigned long data)
struct vmbus_channel *channel = (void *) data;
unsigned long time_limit = jiffies + 2;
 
+   trace_vmbus_on_event(channel);
+
do {
void (*callback_fn)(void *);
 
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index 5382d9630306..d635ee95b20d 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -294,6 +294,29 @@ TRACE_EVENT(vmbus_send_tl_connect_request,
)
);
 
+DECLARE_EVENT_CLASS(vmbus_channel,
+   TP_PROTO(const struct vmbus_channel *channel),
+   TP_ARGS(channel),
+   TP_STRUCT__entry(__field(u32, relid)),
+   TP_fast_assign(__entry->relid = channel->offermsg.child_relid),
+   TP_printk("relid 0x%x", __entry->relid)
+);
+
+DEFINE_EVENT(vmbus_channel, vmbus_chan_sched,
+   TP_PROTO(const struct vmbus_channel *channel),
+   TP_ARGS(channel)
+);
+
+DEFINE_EVENT(vmbus_channel, vmbus_setevent,
+   TP_PROTO(const struct vmbus_channel *channel),
+   TP_ARGS(channel)
+);
+
+DEFINE_EVENT(vmbus_channel, vmbus_on_event,
+   TP_PROTO(const struct vmbus_channel *channel),
+   TP_ARGS(channel)
+);
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 8f9293a87c6b..6a86746d4f60 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -946,6 +946,8 @@ static void vmbus_chan_sched(struct hv_per_cpu_context 
*hv_cpu)
if (channel->rescind)
continue;
 
+   trace_vmbus_chan_sched(channel);
+
++channel->interrupts;
 
switch (channel->callback_mode) {
-- 
2.14.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 15/17] hyper-v: trace vmbus_release_relid()

2017-10-29 Thread kys
From: Vitaly Kuznetsov 

Add tracepoint to CHANNELMSG_RELID_RELEASED sender.

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel_mgmt.c |  7 +--
 drivers/hv/hv_trace.h | 16 
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index b27edff8796e..ec5454f3f4a6 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -373,12 +373,15 @@ static void percpu_channel_deq(void *arg)
 static void vmbus_release_relid(u32 relid)
 {
struct vmbus_channel_relid_released msg;
+   int ret;
 
memset(&msg, 0, sizeof(struct vmbus_channel_relid_released));
msg.child_relid = relid;
msg.header.msgtype = CHANNELMSG_RELID_RELEASED;
-   vmbus_post_msg(&msg, sizeof(struct vmbus_channel_relid_released),
-  true);
+   ret = vmbus_post_msg(&msg, sizeof(struct vmbus_channel_relid_released),
+true);
+
+   trace_vmbus_release_relid(&msg, ret);
 }
 
 void hv_process_channel_removal(u32 relid)
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index f06284d64a8c..f0e437c3522f 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -258,6 +258,22 @@ TRACE_EVENT(vmbus_negotiate_version,
)
);
 
+TRACE_EVENT(vmbus_release_relid,
+   TP_PROTO(const struct vmbus_channel_relid_released *msg, int ret),
+   TP_ARGS(msg, ret),
+   TP_STRUCT__entry(
+   __field(u32, child_relid)
+   __field(int, ret)
+   ),
+   TP_fast_assign(
+   __entry->child_relid = msg->child_relid;
+   __entry->ret = ret;
+   ),
+   TP_printk("sending child_relid 0x%x, ret %d",
+ __entry->child_relid, __entry->ret
+   )
+   );
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.14.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 08/17] hyper-v: trace vmbus_onversion_response()

2017-10-29 Thread kys
From: Vitaly Kuznetsov 

Add tracepoint to CHANNELMSG_VERSION_RESPONSE handler.

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel_mgmt.c |  3 +++
 drivers/hv/hv_trace.h | 11 +++
 2 files changed, 14 insertions(+)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index d1cb85257bf0..c33b7412f303 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -1127,6 +1127,9 @@ static void vmbus_onversion_response(
unsigned long flags;
 
version_response = (struct vmbus_channel_version_response *)hdr;
+
+   trace_vmbus_onversion_response(version_response);
+
spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
 
list_for_each_entry(msginfo, &vmbus_connection.chn_msg_list,
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index 84c08cdf7235..2a046547107f 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -111,6 +111,17 @@ TRACE_EVENT(vmbus_ongpadl_torndown,
TP_printk("gpadl 0x%x", __entry->gpadl)
);
 
+TRACE_EVENT(vmbus_onversion_response,
+   TP_PROTO(const struct vmbus_channel_version_response *response),
+   TP_ARGS(response),
+   TP_STRUCT__entry(
+   __field(u8, ver)
+   ),
+   TP_fast_assign(__entry->ver = response->version_supported;
+   ),
+   TP_printk("version_supported %d", __entry->ver)
+   );
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.14.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 16/17] hyper-v: trace vmbus_send_tl_connect_request()

2017-10-29 Thread kys
From: Vitaly Kuznetsov 

Add tracepoint to CHANNELMSG_TL_CONNECT_REQUEST sender.

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel.c  |  7 ++-
 drivers/hv/hv_trace.h | 20 
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 0382d7b600a1..ed3634e53e15 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -236,13 +236,18 @@ int vmbus_send_tl_connect_request(const uuid_le 
*shv_guest_servie_id,
  const uuid_le *shv_host_servie_id)
 {
struct vmbus_channel_tl_connect_request conn_msg;
+   int ret;
 
memset(&conn_msg, 0, sizeof(conn_msg));
conn_msg.header.msgtype = CHANNELMSG_TL_CONNECT_REQUEST;
conn_msg.guest_endpoint_id = *shv_guest_servie_id;
conn_msg.host_service_id = *shv_host_servie_id;
 
-   return vmbus_post_msg(&conn_msg, sizeof(conn_msg), true);
+   ret = vmbus_post_msg(&conn_msg, sizeof(conn_msg), true);
+
+   trace_vmbus_send_tl_connect_request(&conn_msg, ret);
+
+   return ret;
 }
 EXPORT_SYMBOL_GPL(vmbus_send_tl_connect_request);
 
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index f0e437c3522f..5382d9630306 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -274,6 +274,26 @@ TRACE_EVENT(vmbus_release_relid,
)
);
 
+TRACE_EVENT(vmbus_send_tl_connect_request,
+   TP_PROTO(const struct vmbus_channel_tl_connect_request *msg,
+int ret),
+   TP_ARGS(msg, ret),
+   TP_STRUCT__entry(
+   __array(char, guest_id, 16)
+   __array(char, host_id, 16)
+   __field(int, ret)
+   ),
+   TP_fast_assign(
+   memcpy(__entry->guest_id, &msg->guest_endpoint_id.b, 16);
+   memcpy(__entry->host_id, &msg->host_service_id.b, 16);
+   __entry->ret = ret;
+   ),
+   TP_printk("sending guest_endpoint_id %pUl, host_service_id %pUl, "
+ "ret %d",
+ __entry->guest_id, __entry->host_id, __entry->ret
+   )
+   );
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.14.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 05/17] hyper-v: trace vmbus_onopen_result()

2017-10-29 Thread kys
From: Vitaly Kuznetsov 

Add tracepoint to CHANNELMSG_OPENCHANNEL_RESULT handler.

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel_mgmt.c |  2 ++
 drivers/hv/hv_trace.h | 17 +
 2 files changed, 19 insertions(+)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index cfe5c9c6a87c..c735abe01712 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -986,6 +986,8 @@ static void vmbus_onopen_result(struct 
vmbus_channel_message_header *hdr)
 
result = (struct vmbus_channel_open_result *)hdr;
 
+   trace_vmbus_onopen_result(result);
+
/*
 * Find the open msg, copy the result and signal/unblock the wait event
 */
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index dbbed1d1f327..9757c19d1c08 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -69,6 +69,23 @@ TRACE_EVENT(vmbus_onoffer_rescind,
TP_printk("child_relid 0x%x", __entry->child_relid)
);
 
+TRACE_EVENT(vmbus_onopen_result,
+   TP_PROTO(const struct vmbus_channel_open_result *result),
+   TP_ARGS(result),
+   TP_STRUCT__entry(
+   __field(u32, child_relid)
+   __field(u32, openid)
+   __field(u32, status)
+   ),
+   TP_fast_assign(__entry->child_relid = result->child_relid;
+  __entry->openid = result->openid;
+  __entry->status = result->status;
+   ),
+   TP_printk("child_relid 0x%x, openid %d, status %d",
+ __entry->child_relid,  __entry->openid,  __entry->status
+   )
+   );
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.14.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 11/17] hyper-v: trace vmbus_close_internal()

2017-10-29 Thread kys
From: Vitaly Kuznetsov 

Add tracepoint to CHANNELMSG_CLOSECHANNEL sender.

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel.c  |  2 ++
 drivers/hv/hv_trace.h | 15 +++
 2 files changed, 17 insertions(+)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 739b3fe1e0fb..a827f43aa408 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -591,6 +591,8 @@ static int vmbus_close_internal(struct vmbus_channel 
*channel)
ret = vmbus_post_msg(msg, sizeof(struct vmbus_channel_close_channel),
 true);
 
+   trace_vmbus_close_internal(msg, ret);
+
if (ret) {
pr_err("Close failed: close post msg return is %d\n", ret);
/*
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index 38fedb803bd8..302bd4e964f0 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -157,6 +157,21 @@ TRACE_EVENT(vmbus_open,
)
);
 
+TRACE_EVENT(vmbus_close_internal,
+   TP_PROTO(const struct vmbus_channel_close_channel *msg, int ret),
+   TP_ARGS(msg, ret),
+   TP_STRUCT__entry(
+   __field(u32, child_relid)
+   __field(int, ret)
+   ),
+   TP_fast_assign(
+   __entry->child_relid = msg->child_relid;
+   __entry->ret = ret;
+   ),
+   TP_printk("sending child_relid 0x%x, ret %d", __entry->child_relid,
+   __entry->ret)
+   );
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.14.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 10/17] hyper-v: trace vmbus_open()

2017-10-29 Thread kys
From: Vitaly Kuznetsov 

Add tracepoint to CHANNELMSG_OPENCHANNEL sender.

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel.c  |  2 ++
 drivers/hv/hv_trace.h | 27 +++
 2 files changed, 29 insertions(+)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index a406beb10dd0..739b3fe1e0fb 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -185,6 +185,8 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 
send_ringbuffer_size,
ret = vmbus_post_msg(open_msg,
 sizeof(struct vmbus_channel_open_channel), true);
 
+   trace_vmbus_open(open_msg, ret);
+
if (ret != 0) {
err = ret;
goto error_clean_msglist;
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index 566ac0f2fe56..38fedb803bd8 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -130,6 +130,33 @@ TRACE_EVENT(vmbus_request_offers,
TP_printk("sending ret %d", __entry->ret)
);
 
+TRACE_EVENT(vmbus_open,
+   TP_PROTO(const struct vmbus_channel_open_channel *msg, int ret),
+   TP_ARGS(msg, ret),
+   TP_STRUCT__entry(
+   __field(u32, child_relid)
+   __field(u32, openid)
+   __field(u32, gpadlhandle)
+   __field(u32, target_vp)
+   __field(u32, offset)
+   __field(int, ret)
+   ),
+   TP_fast_assign(
+   __entry->child_relid = msg->child_relid;
+   __entry->openid = msg->openid;
+   __entry->gpadlhandle = msg->ringbuffer_gpadlhandle;
+   __entry->target_vp = msg->target_vp;
+   __entry->offset = msg->downstream_ringbuffer_pageoffset;
+   __entry->ret = ret;
+   ),
+   TP_printk("sending child_relid 0x%x, openid %d, "
+ "gpadlhandle 0x%x, target_vp 0x%x, offset 0x%x, ret %d",
+ __entry->child_relid,  __entry->openid,
+ __entry->gpadlhandle, __entry->target_vp,
+ __entry->offset, __entry->ret
+   )
+   );
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.14.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH char-misc 1/1] Hyper-V: Remove x86-isms from architecture independent Hyper-V drivers

2017-10-29 Thread KY Srinivasan


> -Original Message-
> From: mikel...@exchange.microsoft.com
> [mailto:mikel...@exchange.microsoft.com]
> Sent: Wednesday, October 25, 2017 3:31 PM
> To: gre...@linuxfoundation.org; linux-ker...@vger.kernel.org;
> de...@linuxdriverproject.org; o...@aepfle.de; a...@canonical.com;
> vkuzn...@redhat.com; jasow...@redhat.com;
> leann.ogasaw...@canonical.com; marcelo.ce...@canonical.com; Stephen
> Hemminger ; KY Srinivasan
> 
> Cc: Michael Kelley (EOSG) 
> Subject: [PATCH char-misc 1/1] Hyper-V: Remove x86-isms from architecture
> independent Hyper-V drivers
> 
> [This sender failed our fraud detection checks and may not be who they
> appear to be. Learn about spoofing at http://aka.ms/LearnAboutSpoofing]
> 
> From: Michael Kelley 
> 
> hv_is_hypercall_page_setup() is used to check if Hyper-V is
> initialized, but a 'hypercall page' is an x86 implementation detail
> that isn't necessarily present on other architectures.  Rename to the
> architecture independent hv_is_hyperv_initialized(). Use this function
> instead of direct references to x86-specific data structures in
> vmbus_drv.c, and remove 'x86' from the string name passed to
> cpuhp_setup_state().
> 
> Signed-off-by: Michael Kelley 
> ---
>  arch/x86/hyperv/hv_init.c   | 4 ++--
>  arch/x86/include/asm/mshyperv.h | 4 ++--
>  drivers/hv/hv.c | 2 +-
>  drivers/hv/vmbus_drv.c  | 5 ++---
>  4 files changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
> index a5db63f728a2..38310bd091c2 100644
> --- a/arch/x86/hyperv/hv_init.c
> +++ b/arch/x86/hyperv/hv_init.c
> @@ -236,7 +236,7 @@ void hyperv_report_panic(struct pt_regs *regs)
>  }
>  EXPORT_SYMBOL_GPL(hyperv_report_panic);
> 
> -bool hv_is_hypercall_page_setup(void)
> +bool hv_is_hyperv_initialized(void)
>  {
> union hv_x64_msr_hypercall_contents hypercall_msr;
> 
> @@ -249,4 +249,4 @@ bool hv_is_hypercall_page_setup(void)
> 
> return true;
>  }
> -EXPORT_SYMBOL_GPL(hv_is_hypercall_page_setup);
> +EXPORT_SYMBOL_GPL(hv_is_hyperv_initialized);
> diff --git a/arch/x86/include/asm/mshyperv.h
> b/arch/x86/include/asm/mshyperv.h
> index 530f448fddaf..b001f898ccf3 100644
> --- a/arch/x86/include/asm/mshyperv.h
> +++ b/arch/x86/include/asm/mshyperv.h
> @@ -311,11 +311,11 @@ void hyperv_init(void);
>  void hyperv_setup_mmu_ops(void);
>  void hyper_alloc_mmu(void);
>  void hyperv_report_panic(struct pt_regs *regs);
> -bool hv_is_hypercall_page_setup(void);
> +bool hv_is_hyperv_initialized(void);
>  void hyperv_cleanup(void);
>  #else /* CONFIG_HYPERV */
>  static inline void hyperv_init(void) {}
> -static inline bool hv_is_hypercall_page_setup(void) { return false; }
> +static inline bool hv_is_hyperv_initialized(void) { return false; }
>  static inline void hyperv_cleanup(void) {}
>  static inline void hyperv_setup_mmu_ops(void) {}
>  #endif /* CONFIG_HYPERV */
> diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
> index 8267439dd1ee..ebad26053362 100644
> --- a/drivers/hv/hv.c
> +++ b/drivers/hv/hv.c
> @@ -49,7 +49,7 @@ struct hv_context hv_context = {
>   */
>  int hv_init(void)
>  {
> -   if (!hv_is_hypercall_page_setup())
> +   if (!hv_is_hyperv_initialized())
> return -ENOTSUPP;
> 
> hv_context.cpu_context = alloc_percpu(struct hv_per_cpu_context);
> diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> index 1da8e818f4de..12c51dc6bb7b 100644
> --- a/drivers/hv/vmbus_drv.c
> +++ b/drivers/hv/vmbus_drv.c
> @@ -37,7 +37,6 @@
>  #include 
> 
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 
> @@ -1047,7 +1046,7 @@ static int vmbus_bus_init(void)
>  * Initialize the per-cpu interrupt state and
>  * connect to the host.
>  */
> -   ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,
> "x86/hyperv:online",
> +   ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,
> "hyperv/vmbus:online",
> hv_synic_init, hv_synic_cleanup);
> if (ret < 0)
> goto err_alloc;
> @@ -1695,7 +1694,7 @@ static int __init hv_acpi_init(void)
>  {
> int ret, t;
> 
> -   if (x86_hyper != &x86_hyper_ms_hyperv)
> +   if (!hv_is_hyperv_initialized())

We are checking to see if we are running on MSFT Hyper-V. This check was added 
to
deal with situations where Xen/KVM were emulating Hyper-V. It may not be safe to
replace this check with the call to hv_is_hyperv_initialized(). Perhaps we can 
add a new architecture
independent function to check the hypervisor - something like 
running_on_mshyperv() that can be used
here.

Regards,

K. Y
  
> return -ENODEV;
> 
> init_completion(&probe_event);
> --
> 2.14.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Fix line too long warning

2017-10-29 Thread Joe Perches
On Sun, 2017-10-29 at 18:54 +0300, Yury Norov wrote:
> At second, and most important, refer Documentation/process/coding-style.rst:
> Now, some people will claim that having 8-character indentations makes
> the code move too far to the right, and makes it hard to read on a 
> 80-character terminal screen.  The answer to that is that if you need 
> more than 3 levels of indentation, you're screwed anyway, and should fix
> your program.
> 
> The real problem here is not "line too long", but "indentation level too
> big" - 5. And it worth to address real problem.

Line length issues can be a combination of several factors:

o identifier length
o quantity of dereferences
o indentation depth
o code complexity

4 indentation depth levels are not a real issue.
A significant percentage of lines in the kernel
are 4 or more tab indent levels deep.

checkpatch suggests that 6 or more is the depth level
that should cause real concern.

Here's a little breakdown of lines that start with
a tab followed by a c90 keyword in the kernel

$ git grep -P 
"^\t+(if|for|do|while|\}|else|switch|return|case|break|continue|goto)\b" -- 
"*.[ch]" | \
  cut -f2- -d":" | perl -p -e 's/(^\t+).*/\1/' | \
  sort | uniq -c | sort -rn | \
  awk '{total += $1; count[i++] = $1} END { for (j = 0; j < i; j++) { printf 
"%d\t%d\t%.2f%%\n", j + 1, count[j], count[j] / total * 100 }}'
1   1325462 52.19%
2   863007  33.98%
3   271844  10.70%
4   64009   2.52%
5   12502   0.49%
6   21990.09%
7   501 0.02%
8   166 0.01%
9   51  0.00%
10  20  0.00%
11  10  0.00%
12  4   0.00%
13  1   0.00%

I think it could reasonably be argued that the
indentation depth warning (DEEP_INDENTATION)
should start at 5 and not at 6.

---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 6bdd43d5dec5..923e4ff09d24 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3353,7 +3353,7 @@ sub process {
 
my ($level, @ctx) = ctx_statement_level($linenr, 
$realcnt, 0);
 
-   if ($line =~ /^\+\t{6,}/) {
+   if ($line =~ /^\+\t{5,}/) {
WARN("DEEP_INDENTATION",
 "Too many leading tabs - consider code 
refactoring\n" . $herecurr);
}
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 10/17] hyper-v: trace vmbus_open()

2017-10-29 Thread Greg KH
On Sun, Oct 29, 2017 at 12:21:09PM -0700, k...@exchange.microsoft.com wrote:
> From: Vitaly Kuznetsov 
> 
> Add tracepoint to CHANNELMSG_OPENCHANNEL sender.
> 
> Signed-off-by: Vitaly Kuznetsov 
> Signed-off-by: K. Y. Srinivasan 
> ---
>  drivers/hv/channel.c  |  2 ++
>  drivers/hv/hv_trace.h | 27 +++
>  2 files changed, 29 insertions(+)
> 
> diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
> index a406beb10dd0..739b3fe1e0fb 100644
> --- a/drivers/hv/channel.c
> +++ b/drivers/hv/channel.c
> @@ -185,6 +185,8 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 
> send_ringbuffer_size,
>   ret = vmbus_post_msg(open_msg,
>sizeof(struct vmbus_channel_open_channel), true);
>  
> + trace_vmbus_open(open_msg, ret);

Why add tracepoints for things that ftrace can handle automatically?
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel