linux-next: manual merge of the char-misc tree with the net-next tree

Subsystems: hyper-v/azure core and drivers, networking drivers, the rest

4 messages, 3 authors, 2016-09-06 · open the first message on its own page

linux-next: manual merge of the char-misc tree with the net-next tree

From: Stephen Rothwell <hidden>
Date: 2016-09-05 06:56:54

Hi all,

Today's linux-next merge of the char-misc tree got a conflict in:

  include/linux/hyperv.h

between commit:

  30d1de08c87d ("hv_netvsc: make inline functions static")

from the net-next tree and commit:

  bb08d431a914 ("Drivers: hv: ring_buffer: count on wrap around mappings in get_next_pkt_raw()")

from the char-misc tree.

I fixed it up (the former moved the code modified by the latter, so the
below patch applies to the new location of the code) and can carry the
fix as necessary. This is now fixed as far as linux-next is concerned,
but any non trivial conflicts should be mentioned to your upstream
maintainer when your tree is submitted for merging.  You may also want
to consider cooperating with the maintainer of the conflicting tree to
minimise any particularly complex conflicts.

From: Stephen Rothwell <redacted>
Date: Mon, 5 Sep 2016 16:53:06 +1000
Subject: [PATCH] Drivers: hv: ring_buffer: merge fix up for "hv_netvsc: make
 inline functions static"

Signed-off-by: Stephen Rothwell <redacted>
---
 drivers/net/hyperv/netvsc.c | 32 +++++++++++---------------------
 1 file changed, 11 insertions(+), 21 deletions(-)
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 2a9ccc4d9e3c..026df6556068 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -42,31 +42,23 @@ static struct vmpacket_descriptor *
 get_next_pkt_raw(struct vmbus_channel *channel)
 {
 	struct hv_ring_buffer_info *ring_info = &channel->inbound;
-	u32 read_loc = ring_info->priv_read_index;
+	u32 priv_read_loc = ring_info->priv_read_index;
 	void *ring_buffer = hv_get_ring_buffer(ring_info);
-	struct vmpacket_descriptor *cur_desc;
-	u32 packetlen;
 	u32 dsize = ring_info->ring_datasize;
-	u32 delta = read_loc - ring_info->ring_buffer->read_index;
+	/*
+	 * delta is the difference between what is available to read and
+	 * what was already consumed in place. We commit read index after
+	 * the whole batch is processed.
+	 */
+	u32 delta = priv_read_loc >= ring_info->ring_buffer->read_index ?
+		priv_read_loc - ring_info->ring_buffer->read_index :
+		(dsize - ring_info->ring_buffer->read_index) + priv_read_loc;
 	u32 bytes_avail_toread = (hv_get_bytes_to_read(ring_info) - delta);
 
 	if (bytes_avail_toread < sizeof(struct vmpacket_descriptor))
 		return NULL;
 
-	if ((read_loc + sizeof(*cur_desc)) > dsize)
-		return NULL;
-
-	cur_desc = ring_buffer + read_loc;
-	packetlen = cur_desc->len8 << 3;
-
-	/*
-	 * If the packet under consideration is wrapping around,
-	 * return failure.
-	 */
-	if ((read_loc + packetlen + VMBUS_PKT_TRAILER) > (dsize - 1))
-		return NULL;
-
-	return cur_desc;
+	return ring_buffer + priv_read_loc;
 }
 
 /*
@@ -78,16 +70,14 @@ static void put_pkt_raw(struct vmbus_channel *channel,
 			struct vmpacket_descriptor *desc)
 {
 	struct hv_ring_buffer_info *ring_info = &channel->inbound;
-	u32 read_loc = ring_info->priv_read_index;
 	u32 packetlen = desc->len8 << 3;
 	u32 dsize = ring_info->ring_datasize;
 
-	BUG_ON((read_loc + packetlen + VMBUS_PKT_TRAILER) > dsize);
-
 	/*
 	 * Include the packet trailer.
 	 */
 	ring_info->priv_read_index += packetlen + VMBUS_PKT_TRAILER;
+	ring_info->priv_read_index %= dsize;
 }
 
 /*
-- 
2.8.1

-- 
Cheers,
Stephen Rothwell

Re: linux-next: manual merge of the char-misc tree with the net-next tree

From: Greg KH <hidden>
Date: 2016-09-05 11:33:49

On Mon, Sep 05, 2016 at 04:56:50PM +1000, Stephen Rothwell wrote:
quoted hunk
Hi all,

Today's linux-next merge of the char-misc tree got a conflict in:

  include/linux/hyperv.h

between commit:

  30d1de08c87d ("hv_netvsc: make inline functions static")

from the net-next tree and commit:

  bb08d431a914 ("Drivers: hv: ring_buffer: count on wrap around mappings in get_next_pkt_raw()")

from the char-misc tree.

I fixed it up (the former moved the code modified by the latter, so the
below patch applies to the new location of the code) and can carry the
fix as necessary. This is now fixed as far as linux-next is concerned,
but any non trivial conflicts should be mentioned to your upstream
maintainer when your tree is submitted for merging.  You may also want
to consider cooperating with the maintainer of the conflicting tree to
minimise any particularly complex conflicts.

From: Stephen Rothwell <redacted>
Date: Mon, 5 Sep 2016 16:53:06 +1000
Subject: [PATCH] Drivers: hv: ring_buffer: merge fix up for "hv_netvsc: make
 inline functions static"

Signed-off-by: Stephen Rothwell <redacted>
---
 drivers/net/hyperv/netvsc.c | 32 +++++++++++---------------------
 1 file changed, 11 insertions(+), 21 deletions(-)
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 2a9ccc4d9e3c..026df6556068 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -42,31 +42,23 @@ static struct vmpacket_descriptor *
 get_next_pkt_raw(struct vmbus_channel *channel)
 {
 	struct hv_ring_buffer_info *ring_info = &channel->inbound;
-	u32 read_loc = ring_info->priv_read_index;
+	u32 priv_read_loc = ring_info->priv_read_index;
 	void *ring_buffer = hv_get_ring_buffer(ring_info);
-	struct vmpacket_descriptor *cur_desc;
-	u32 packetlen;
 	u32 dsize = ring_info->ring_datasize;
-	u32 delta = read_loc - ring_info->ring_buffer->read_index;
+	/*
+	 * delta is the difference between what is available to read and
+	 * what was already consumed in place. We commit read index after
+	 * the whole batch is processed.
+	 */
+	u32 delta = priv_read_loc >= ring_info->ring_buffer->read_index ?
+		priv_read_loc - ring_info->ring_buffer->read_index :
+		(dsize - ring_info->ring_buffer->read_index) + priv_read_loc;
 	u32 bytes_avail_toread = (hv_get_bytes_to_read(ring_info) - delta);
 
 	if (bytes_avail_toread < sizeof(struct vmpacket_descriptor))
 		return NULL;
 
-	if ((read_loc + sizeof(*cur_desc)) > dsize)
-		return NULL;
-
-	cur_desc = ring_buffer + read_loc;
-	packetlen = cur_desc->len8 << 3;
-
-	/*
-	 * If the packet under consideration is wrapping around,
-	 * return failure.
-	 */
-	if ((read_loc + packetlen + VMBUS_PKT_TRAILER) > (dsize - 1))
-		return NULL;
-
-	return cur_desc;
+	return ring_buffer + priv_read_loc;
 }
 
 /*
@@ -78,16 +70,14 @@ static void put_pkt_raw(struct vmbus_channel *channel,
 			struct vmpacket_descriptor *desc)
 {
 	struct hv_ring_buffer_info *ring_info = &channel->inbound;
-	u32 read_loc = ring_info->priv_read_index;
 	u32 packetlen = desc->len8 << 3;
 	u32 dsize = ring_info->ring_datasize;
 
-	BUG_ON((read_loc + packetlen + VMBUS_PKT_TRAILER) > dsize);
-
 	/*
 	 * Include the packet trailer.
 	 */
 	ring_info->priv_read_index += packetlen + VMBUS_PKT_TRAILER;
+	ring_info->priv_read_index %= dsize;
 }
 
 /*
Ugh, messy.  Thanks for this.

KY, how did this happen?

greg k-h

RE: linux-next: manual merge of the char-misc tree with the net-next tree

From: KY Srinivasan <hidden>
Date: 2016-09-06 05:36:15

-----Original Message-----
From: Greg KH [mailto:greg@kroah.com]
Sent: Monday, September 5, 2016 5:04 PM
To: Stephen Rothwell <redacted>
Cc: Arnd Bergmann <arnd@arndb.de>; David Miller <davem@davemloft.net>;
Networking [off-list ref]; linux-next@vger.kernel.org; linux-
kernel@vger.kernel.org; Stephen Hemminger [off-list ref];
Vitaly Kuznetsov [off-list ref]; KY Srinivasan [off-list ref]
Subject: Re: linux-next: manual merge of the char-misc tree with the net-next
tree

On Mon, Sep 05, 2016 at 04:56:50PM +1000, Stephen Rothwell wrote:
quoted
Hi all,

Today's linux-next merge of the char-misc tree got a conflict in:

  include/linux/hyperv.h

between commit:

  30d1de08c87d ("hv_netvsc: make inline functions static")

from the net-next tree and commit:

  bb08d431a914 ("Drivers: hv: ring_buffer: count on wrap around mappings in
get_next_pkt_raw()")
quoted
from the char-misc tree.

I fixed it up (the former moved the code modified by the latter, so the
below patch applies to the new location of the code) and can carry the
fix as necessary. This is now fixed as far as linux-next is concerned,
but any non trivial conflicts should be mentioned to your upstream
maintainer when your tree is submitted for merging.  You may also want
to consider cooperating with the maintainer of the conflicting tree to
minimise any particularly complex conflicts.

From: Stephen Rothwell <redacted>
Date: Mon, 5 Sep 2016 16:53:06 +1000
Subject: [PATCH] Drivers: hv: ring_buffer: merge fix up for "hv_netvsc: make
 inline functions static"

Signed-off-by: Stephen Rothwell <redacted>
---
 drivers/net/hyperv/netvsc.c | 32 +++++++++++---------------------
 1 file changed, 11 insertions(+), 21 deletions(-)
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 2a9ccc4d9e3c..026df6556068 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -42,31 +42,23 @@ static struct vmpacket_descriptor *
 get_next_pkt_raw(struct vmbus_channel *channel)
 {
 	struct hv_ring_buffer_info *ring_info = &channel->inbound;
-	u32 read_loc = ring_info->priv_read_index;
+	u32 priv_read_loc = ring_info->priv_read_index;
 	void *ring_buffer = hv_get_ring_buffer(ring_info);
-	struct vmpacket_descriptor *cur_desc;
-	u32 packetlen;
 	u32 dsize = ring_info->ring_datasize;
-	u32 delta = read_loc - ring_info->ring_buffer->read_index;
+	/*
+	 * delta is the difference between what is available to read and
+	 * what was already consumed in place. We commit read index after
+	 * the whole batch is processed.
+	 */
+	u32 delta = priv_read_loc >= ring_info->ring_buffer->read_index ?
+		priv_read_loc - ring_info->ring_buffer->read_index :
+		(dsize - ring_info->ring_buffer->read_index) + priv_read_loc;
 	u32 bytes_avail_toread = (hv_get_bytes_to_read(ring_info) - delta);

 	if (bytes_avail_toread < sizeof(struct vmpacket_descriptor))
 		return NULL;

-	if ((read_loc + sizeof(*cur_desc)) > dsize)
-		return NULL;
-
-	cur_desc = ring_buffer + read_loc;
-	packetlen = cur_desc->len8 << 3;
-
-	/*
-	 * If the packet under consideration is wrapping around,
-	 * return failure.
-	 */
-	if ((read_loc + packetlen + VMBUS_PKT_TRAILER) > (dsize - 1))
-		return NULL;
-
-	return cur_desc;
+	return ring_buffer + priv_read_loc;
 }

 /*
@@ -78,16 +70,14 @@ static void put_pkt_raw(struct vmbus_channel
*channel,
quoted
 			struct vmpacket_descriptor *desc)
 {
 	struct hv_ring_buffer_info *ring_info = &channel->inbound;
-	u32 read_loc = ring_info->priv_read_index;
 	u32 packetlen = desc->len8 << 3;
 	u32 dsize = ring_info->ring_datasize;

-	BUG_ON((read_loc + packetlen + VMBUS_PKT_TRAILER) > dsize);
-
 	/*
 	 * Include the packet trailer.
 	 */
 	ring_info->priv_read_index += packetlen + VMBUS_PKT_TRAILER;
+	ring_info->priv_read_index %= dsize;
 }

 /*
Ugh, messy.  Thanks for this.

KY, how did this happen?
Thanks Stephen. Greg, sorry about this. We should have split Vitaly's patch to avoid this inter-tree issue. Vitaly and I will work to fix this.

Regards,

K. Y 
greg k-h

RE: linux-next: manual merge of the char-misc tree with the net-next tree

From: KY Srinivasan <hidden>
Date: 2016-09-06 10:43:19

-----Original Message-----
From: KY Srinivasan
Sent: Tuesday, September 6, 2016 11:06 AM
To: 'Greg KH' <redacted>; Stephen Rothwell <redacted>
Cc: Arnd Bergmann <arnd@arndb.de>; David Miller <davem@davemloft.net>;
Networking [off-list ref]; linux-next@vger.kernel.org; linux-
kernel@vger.kernel.org; Stephen Hemminger [off-list ref];
Vitaly Kuznetsov [off-list ref]
Subject: RE: linux-next: manual merge of the char-misc tree with the net-next
tree


quoted
-----Original Message-----
From: Greg KH [mailto:greg@kroah.com]
Sent: Monday, September 5, 2016 5:04 PM
To: Stephen Rothwell <redacted>
Cc: Arnd Bergmann <arnd@arndb.de>; David Miller
[off-list ref];
quoted
Networking [off-list ref]; linux-next@vger.kernel.org; linux-
kernel@vger.kernel.org; Stephen Hemminger [off-list ref];
Vitaly Kuznetsov [off-list ref]; KY Srinivasan
[off-list ref]
quoted
Subject: Re: linux-next: manual merge of the char-misc tree with the net-next
tree

On Mon, Sep 05, 2016 at 04:56:50PM +1000, Stephen Rothwell wrote:
quoted
Hi all,

Today's linux-next merge of the char-misc tree got a conflict in:

  include/linux/hyperv.h

between commit:

  30d1de08c87d ("hv_netvsc: make inline functions static")

from the net-next tree and commit:

  bb08d431a914 ("Drivers: hv: ring_buffer: count on wrap around mappings
in
quoted
get_next_pkt_raw()")
quoted
from the char-misc tree.

I fixed it up (the former moved the code modified by the latter, so the
below patch applies to the new location of the code) and can carry the
fix as necessary. This is now fixed as far as linux-next is concerned,
but any non trivial conflicts should be mentioned to your upstream
maintainer when your tree is submitted for merging.  You may also want
to consider cooperating with the maintainer of the conflicting tree to
minimise any particularly complex conflicts.

From: Stephen Rothwell <redacted>
Date: Mon, 5 Sep 2016 16:53:06 +1000
Subject: [PATCH] Drivers: hv: ring_buffer: merge fix up for "hv_netvsc:
make
quoted
quoted
 inline functions static"

Signed-off-by: Stephen Rothwell <redacted>
---
 drivers/net/hyperv/netvsc.c | 32 +++++++++++---------------------
 1 file changed, 11 insertions(+), 21 deletions(-)
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 2a9ccc4d9e3c..026df6556068 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -42,31 +42,23 @@ static struct vmpacket_descriptor *
 get_next_pkt_raw(struct vmbus_channel *channel)
 {
 	struct hv_ring_buffer_info *ring_info = &channel->inbound;
-	u32 read_loc = ring_info->priv_read_index;
+	u32 priv_read_loc = ring_info->priv_read_index;
 	void *ring_buffer = hv_get_ring_buffer(ring_info);
-	struct vmpacket_descriptor *cur_desc;
-	u32 packetlen;
 	u32 dsize = ring_info->ring_datasize;
-	u32 delta = read_loc - ring_info->ring_buffer->read_index;
+	/*
+	 * delta is the difference between what is available to read and
+	 * what was already consumed in place. We commit read index after
+	 * the whole batch is processed.
+	 */
+	u32 delta = priv_read_loc >= ring_info->ring_buffer->read_index ?
+		priv_read_loc - ring_info->ring_buffer->read_index :
+		(dsize - ring_info->ring_buffer->read_index) + priv_read_loc;
 	u32 bytes_avail_toread = (hv_get_bytes_to_read(ring_info) - delta);

 	if (bytes_avail_toread < sizeof(struct vmpacket_descriptor))
 		return NULL;

-	if ((read_loc + sizeof(*cur_desc)) > dsize)
-		return NULL;
-
-	cur_desc = ring_buffer + read_loc;
-	packetlen = cur_desc->len8 << 3;
-
-	/*
-	 * If the packet under consideration is wrapping around,
-	 * return failure.
-	 */
-	if ((read_loc + packetlen + VMBUS_PKT_TRAILER) > (dsize - 1))
-		return NULL;
-
-	return cur_desc;
+	return ring_buffer + priv_read_loc;
 }

 /*
@@ -78,16 +70,14 @@ static void put_pkt_raw(struct vmbus_channel
*channel,
quoted
 			struct vmpacket_descriptor *desc)
 {
 	struct hv_ring_buffer_info *ring_info = &channel->inbound;
-	u32 read_loc = ring_info->priv_read_index;
 	u32 packetlen = desc->len8 << 3;
 	u32 dsize = ring_info->ring_datasize;

-	BUG_ON((read_loc + packetlen + VMBUS_PKT_TRAILER) > dsize);
-
 	/*
 	 * Include the packet trailer.
 	 */
 	ring_info->priv_read_index += packetlen + VMBUS_PKT_TRAILER;
+	ring_info->priv_read_index %= dsize;
 }

 /*
Ugh, messy.  Thanks for this.

KY, how did this happen?
Thanks Stephen. Greg, sorry about this. We should have split Vitaly's patch to
avoid this inter-tree issue. Vitaly and I will work to fix this.
Stephen,

I am sending Greg a patch to revert commit bb08d431a914. This should address the
merge problem you ran into. Once net-next tree synchs up with the char-misc tree,
we will submit a patch to net-next to make the necessary adjustments.

Regards,

K. Y

Regards,

K. Y
quoted
greg k-h
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help