virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] Staging: hv: netvsc: Fix a bug in accounting transmit slots
@ 2011-06-06 22:57 K. Y. Srinivasan
  2011-06-09 17:04 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: K. Y. Srinivasan @ 2011-06-06 22:57 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang, Abhishek Kane

The current code manipulates the available transmit slots without proper
locking; fix it.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
---
 drivers/staging/hv/netvsc_drv.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 33cab9c..38ca2c2 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -21,6 +21,7 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/init.h>
+#include <linux/atomic.h>
 #include <linux/module.h>
 #include <linux/highmem.h>
 #include <linux/device.h>
@@ -45,7 +46,7 @@
 struct net_device_context {
 	/* point back to our device context */
 	struct hv_device *device_ctx;
-	unsigned long avail;
+	atomic_t avail;
 	struct delayed_work dwork;
 };
 
@@ -118,8 +119,9 @@ static void netvsc_xmit_completion(void *context)
 
 		dev_kfree_skb_any(skb);
 
-		net_device_ctx->avail += num_pages;
-		if (net_device_ctx->avail >= PACKET_PAGES_HIWATER)
+		atomic_add(num_pages, &net_device_ctx->avail);
+		if (atomic_read(&net_device_ctx->avail) >=
+				PACKET_PAGES_HIWATER)
  			netif_wake_queue(net);
 	}
 }
@@ -133,7 +135,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
 
 	/* Add 1 for skb->data and additional one for RNDIS */
 	num_pages = skb_shinfo(skb)->nr_frags + 1 + 1;
-	if (num_pages > net_device_ctx->avail)
+	if (num_pages > atomic_read(&net_device_ctx->avail))
 		return NETDEV_TX_BUSY;
 
 	/* Allocate a netvsc packet based on # of frags. */
@@ -185,8 +187,8 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
 		net->stats.tx_bytes += skb->len;
 		net->stats.tx_packets++;
 
-		net_device_ctx->avail -= num_pages;
-		if (net_device_ctx->avail < PACKET_PAGES_LOWATER)
+		atomic_sub(num_pages, &net_device_ctx->avail);
+		if (atomic_read(&net_device_ctx->avail) < PACKET_PAGES_LOWATER)
 			netif_stop_queue(net);
 	} else {
 		/* we are shutting down or bus overloaded, just drop packet */
@@ -345,7 +347,7 @@ static int netvsc_probe(struct hv_device *dev)
 
 	net_device_ctx = netdev_priv(net);
 	net_device_ctx->device_ctx = dev;
-	net_device_ctx->avail = ring_size;
+	atomic_set(&net_device_ctx->avail, ring_size);
 	dev_set_drvdata(&dev->device, net);
 	INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_send_garp);
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/3] Staging: hv: netvsc: Fix a bug in accounting transmit slots
  2011-06-06 22:57 [PATCH 1/3] Staging: hv: netvsc: Fix a bug in accounting transmit slots K. Y. Srinivasan
@ 2011-06-09 17:04 ` Greg KH
  2011-06-09 17:23   ` KY Srinivasan
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2011-06-09 17:04 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang,
	Abhishek Kane

On Mon, Jun 06, 2011 at 03:57:35PM -0700, K. Y. Srinivasan wrote:

I only got 2 of these three patches, what happened to the third one?

Care to resend all 3 of these to ensure that I get them all?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH 1/3] Staging: hv: netvsc: Fix a bug in accounting transmit slots
  2011-06-09 17:04 ` Greg KH
@ 2011-06-09 17:23   ` KY Srinivasan
  2011-06-09 17:53     ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: KY Srinivasan @ 2011-06-09 17:23 UTC (permalink / raw)
  To: Greg KH
  Cc: gregkh@suse.de, linux-kernel@vger.kernel.org,
	devel@linuxdriverproject.org, virtualization@lists.osdl.org,
	Haiyang Zhang, Abhishek Kane (Mindtree Consulting PVT LTD)

> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Thursday, June 09, 2011 1:05 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang;
> Abhishek Kane (Mindtree Consulting PVT LTD)
> Subject: Re: [PATCH 1/3] Staging: hv: netvsc: Fix a bug in accounting transmit slots
> 
> On Mon, Jun 06, 2011 at 03:57:35PM -0700, K. Y. Srinivasan wrote:
> 
> I only got 2 of these three patches, what happened to the third one?
> 
> Care to resend all 3 of these to ensure that I get them all?

There really were only 2 patches I wanted to send. If you want I could reformat
and send only the 2 I wanted to send.

Regards,

K. Y 
> 
> thanks,
> 
> greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/3] Staging: hv: netvsc: Fix a bug in accounting transmit slots
  2011-06-09 17:23   ` KY Srinivasan
@ 2011-06-09 17:53     ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2011-06-09 17:53 UTC (permalink / raw)
  To: KY Srinivasan
  Cc: Greg KH, linux-kernel@vger.kernel.org,
	devel@linuxdriverproject.org, virtualization@lists.osdl.org,
	Haiyang Zhang, Abhishek Kane (Mindtree Consulting PVT LTD)

On Thu, Jun 09, 2011 at 05:23:50PM +0000, KY Srinivasan wrote:
> > -----Original Message-----
> > From: Greg KH [mailto:greg@kroah.com]
> > Sent: Thursday, June 09, 2011 1:05 PM
> > To: KY Srinivasan
> > Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> > devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang;
> > Abhishek Kane (Mindtree Consulting PVT LTD)
> > Subject: Re: [PATCH 1/3] Staging: hv: netvsc: Fix a bug in accounting transmit slots
> > 
> > On Mon, Jun 06, 2011 at 03:57:35PM -0700, K. Y. Srinivasan wrote:
> > 
> > I only got 2 of these three patches, what happened to the third one?
> > 
> > Care to resend all 3 of these to ensure that I get them all?
> 
> There really were only 2 patches I wanted to send. If you want I could reformat
> and send only the 2 I wanted to send.

Please do, as when you send something that says 1/3 and 2/3 and 3/3
never shows up, we have no idea what is going on...

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-06-09 17:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-06 22:57 [PATCH 1/3] Staging: hv: netvsc: Fix a bug in accounting transmit slots K. Y. Srinivasan
2011-06-09 17:04 ` Greg KH
2011-06-09 17:23   ` KY Srinivasan
2011-06-09 17:53     ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).