From: "K. Y. Srinivasan" <kys@microsoft.com>
To: gregkh@suse.de, linux-kernel@vger.kernel.org,
devel@linuxdriverproject.org, virtualization@lists.osdl.org
Cc: "K. Y. Srinivasan" <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Hank Janssen <hjanssen@microsoft.com>, stable <stable@kernel.org>
Subject: [PATCH 04/77] Staging: hv: netvsc: Fix a bug in accounting transmit slots
Date: Thu, 16 Jun 2011 13:16:37 -0700 [thread overview]
Message-ID: <1308255470-3826-4-git-send-email-kys@microsoft.com> (raw)
In-Reply-To: <1308255470-3826-1-git-send-email-kys@microsoft.com>
The transmit slots were manipulated without proper locking. Fix this bug by
making the variable tracking the transmit slots atomic.
This patch should be ported to prior stable kernels 2.6.32 and later.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
Cc: stable <stable@kernel.org>
---
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
next prev parent reply other threads:[~2011-06-16 20:16 UTC|newest]
Thread overview: 91+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-16 20:16 [PATCH 00/77] Staging: hv: Driver cleanup K. Y. Srinivasan
2011-06-16 20:16 ` [PATCH 01/77] Staging: hv: vmbus: Increase the timeout value in the vmbus driver K. Y. Srinivasan
2011-06-16 20:16 ` [PATCH 02/77] Staging: hv: netvsc: Increase the timeout value in the netvsc driver K. Y. Srinivasan
2011-06-16 20:16 ` [PATCH 03/77] Staging: hv: storvsc: Increase the timeout value in the storvsc driver K. Y. Srinivasan
2011-06-16 20:16 ` K. Y. Srinivasan [this message]
2011-06-16 20:16 ` [PATCH 05/77] Staging: hv: vmbus: Properly handle the error in hv_acpi_init() K. Y. Srinivasan
2011-06-16 20:16 ` [PATCH 06/77] Staging: hv: vmbus: VMBUS is an ACPI enumerated device, get rid of the PCI signature K. Y. Srinivasan
2011-06-16 20:16 ` [PATCH 07/77] Staging: hv: vmbus: Introduce a function to map the dev_type guid to a name K. Y. Srinivasan
2011-07-05 16:01 ` Greg KH
2011-06-16 20:16 ` [PATCH 08/77] Staging: hv: vmbus: Introduce vmbus ID space in struct hv_driver K. Y. Srinivasan
2011-06-16 20:16 ` [PATCH 09/77] Staging: hv: blkvsc: Use the newly introduced vmbus ID in the blockvsc driver K. Y. Srinivasan
2011-07-05 16:04 ` Greg KH
2011-06-16 20:16 ` [PATCH 10/77] Staging: hv: storvsc: Use the newly introduced vmbus ID in storvsc driver K. Y. Srinivasan
2011-06-16 20:16 ` [PATCH 11/77] Staging: hv: netvsc: Use the newly introduced vmbus ID in netvsc driver K. Y. Srinivasan
2011-06-16 20:16 ` [PATCH 12/77] Staging: hv: mousevsc: Use the newly introduced vmbus ID in mouse driver K. Y. Srinivasan
2011-06-16 20:16 ` [PATCH 13/77] Staging: hv: vmbus: Introduce a human readable device type field to struct hv_device K. Y. Srinivasan
2011-06-16 20:16 ` [PATCH 14/77] Staging: hv: util: Make hv_utils a vmbus device driver K. Y. Srinivasan
2011-06-16 20:16 ` [PATCH 15/77] Staging: hv: blkvsc: Add the appropriate MODULE_ALIAS() line K. Y. Srinivasan
2011-07-05 16:06 ` Greg KH
2011-07-06 0:40 ` KY Srinivasan
2011-07-06 3:42 ` Greg KH
2011-07-06 14:55 ` KY Srinivasan
2011-07-06 15:02 ` Greg KH
2011-07-06 15:17 ` KY Srinivasan
2011-07-06 15:29 ` Greg KH
2011-07-06 15:47 ` KY Srinivasan
2011-06-16 20:16 ` [PATCH 16/77] Staging: hv: storvsc: " K. Y. Srinivasan
2011-06-16 20:16 ` [PATCH 17/77] Staging: hv: netvsc: " K. Y. Srinivasan
2011-06-16 20:16 ` [PATCH 18/77] Staging: hv: mousevsc: " K. Y. Srinivasan
2011-06-16 20:16 ` [PATCH 19/77] Staging: hv: util: " K. Y. Srinivasan
2011-06-16 20:16 ` [PATCH 20/77] Staging: hv: vmbus: Cleanup the vmbus_uevent() code K. Y. Srinivasan
2011-06-16 20:16 ` [PATCH 21/77] Staging: hv: vmbus: Get rid of an unnecessary include line in vmbus_drv.c K. Y. Srinivasan
2011-06-16 20:16 ` [PATCH 22/77] Staging: hv: storvsc: Get rid of the DMI signature K. Y. Srinivasan
2011-06-16 20:16 ` [PATCH 23/77] Staging: hv: netvsc: Get rid of the PCI signature K. Y. Srinivasan
2011-06-16 20:16 ` [PATCH 24/77] Staging: hv: netvsc: Get rid of the DMI signature in netvsc_drv.c K. Y. Srinivasan
2011-06-16 20:16 ` [PATCH 25/77] Staging: hv: util: Get rid of the DMI signature in hv_util.c K. Y. Srinivasan
2011-06-16 20:16 ` [PATCH 26/77] Staging: hv: util: Get rid of the PCI " K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 27/77] Staging: hv: vmbus: Cleanup vmbus_match() function K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 28/77] Staging: hv: blkvsc: Get rid of the dev_type guid from blkvsc_drv.c K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 29/77] Staging: hv: storvsc: Get rid of the device type guid from storvsc_drv.c K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 30/77] Staging: hv: netvsc: Get rid of the dev_type guid from netvsc.c K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 31/77] Staging: hv: netvsc: Initialize the driver name directly K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 32/77] Staging: hv: netvsc: Get rid of the driver name initialization in netvsc.c K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 33/77] Staging: hv: netvsc: Get rid of the empty function netvsc_initialize() K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 34/77] Staging: hv: vmbus: Get rid of the unused name field in struct hv_driver K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 35/77] Staging: hv: mouse: Get rid of the dev_type guid in hv_mouse.c K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 36/77] Staging: hv: vmbus: Cleanup the code displaying class_id K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 37/77] Staging: hv: vmbus: Do not initialize dev_type guid in vmbus_child_device_create() K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 38/77] Staging: hv: vmbus: Get rid of the unused dev_type field in hv_device and hv_driver K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 39/77] Staging: hv: vmbus: Get rid of the device_id attribute K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 40/77] Staging: hv: vmbus: Get rid of some unnecessary comments K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 41/77] Staging: hv: vmbus: Cleanup unnecessary comments in hv.c K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 42/77] Staging: hv: vmbus: Cleanup error handling in hv_init() K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 43/77] Staging: hv: vmbus: Get rid of unnecessay comments in connection.c K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 44/77] Staging: hv: vmbus: Get rid of the function dump_gpadl_body() K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 45/77] Staging: hv: vmbus: Get rid of the function dump_gpadl_header() K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 46/77] Staging: hv: vmbus: Rename openMsg to open_msg in channel.c K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 47/77] Staging: hv: vmbus: Get rid of unnecessary comments " K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 48/77] Staging: hv: vmbus: Change the variable name openInfo to open_info " K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 49/77] Staging: hv: vmbus: Cleanup error values in ringbuffer.c K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 50/77] Staging: hv: vmbus: Cleanup the error return value in vmbus_recvpacket_raw() K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 51/77] Staging: hv: netvsc: Get rid of an unnecessary print statement in netvsc_probe() K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 52/77] Staging: hv: vmbus: Retry vmbus_post_msg() before giving up K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 53/77] Staging: hv: storvsc: Cleanup error handling in storvsc_dev_add() K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 54/77] Staging: hv: storvsc: Cleanup error handling in storvsc_channel_init() K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 55/77] Staging: hv: storvsc: Cleanup error handling in storvsc_connect_to_vsp() K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 56/77] Staging: hv: storvsc: Cleanup error handling in storvsc_do_io() K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 57/77] Storage: hv: storvsc: Get rid of some unnecessary DPRINTs from storvsc.c K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 58/77] Staging: hv: storvsc: Fix/cleanup some dated comments in storvsc.c K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 59/77] Staging: hv: storvsc: Cleanup returned error code in storvsc_host_reset() K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 60/77] Staging: hv: storvsc: Cleanup error code returned in storvsc_probe() K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 61/77] Staging: hv: storvsc: Cleanup returned error code in storvsc_drv_init() K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 62/77] Staging: hv: netvsc: Cleanup the returned error code in netvsc_probe() K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 63/77] Staging: hv: netvsc: Cleanup error return codes in netvsc_destroy_recv_buf() K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 64/77] Staging: hv: netvsc: Cleanup error return values in netvsc_init_recv_buf() K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 65/77] Staging: hv: netvsc: Cleanup error returns in netvsc_connect_vsp() K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 66/77] Staging: hv: netvsc: Cleanup error return values in netvsc_send() K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 67/77] Staging: hv: netvsc: Cleanup error return codes in netvsc_device_add() K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 68/77] Staging: hv: netvsc: Cleanup error codes in rndis_filter_receive() K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 69/77] Staging: hv: netvsc: Cleanup error code in rndis_filter_query_device() K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 70/77] Staging: hv: netvsc: Cleanup error return values in rndis_filter_set_packet_filter() K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 71/77] Staging: hv: netvsc: Cleanup error returns in rndis_filter_init_device() K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 72/77] Staging: hv: netvsc: Cleanup error code in rndis_filter_device_add() K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 73/77] Staging: hv: mouse: Change the jump label Cleanup to cleanup K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 74/77] Staging: hv: mouse: Get rid of the unused PCI signature K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 75/77] Staging: hv: mouse: Disable auto-loading of the mouse driver K. Y. Srinivasan
2011-07-05 15:57 ` Greg KH
2011-07-05 16:10 ` KY Srinivasan
2011-07-05 16:18 ` Greg KH
2011-06-16 20:17 ` [PATCH 76/77] Staging: hv: netvsc: Change the jump label Cleanup to cleanup K. Y. Srinivasan
2011-06-16 20:17 ` [PATCH 77/77] Staging: hv: netvsc: Change the jump lable Exit to exit K. Y. Srinivasan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1308255470-3826-4-git-send-email-kys@microsoft.com \
--to=kys@microsoft.com \
--cc=devel@linuxdriverproject.org \
--cc=gregkh@suse.de \
--cc=haiyangz@microsoft.com \
--cc=hjanssen@microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@kernel.org \
--cc=virtualization@lists.osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).