aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorHaiyang Zhang <haiyangz@microsoft.com>2012-06-04 02:42:38 -0400
committerDavid S. Miller <davem@davemloft.net>2012-06-04 13:50:38 -0400
commitdc5cd894cace7bda4a743487a9f87d59a3f0a095 (patch)
treeecb62686a8cb1764b7ca49c61ef9dfc22eb6d8b9 /drivers/net
parent9ec0db71af04f4560e27a3c2f5a0411ba3155198 (diff)
net/hyperv: Use wait_event on outstanding sends during device removal
Change the busy-waiting/udelay to wait_event on outstanding sends. Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com> Reviewed-by: K. Y. Srinivasan <kys@microsoft.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/hyperv/hyperv_net.h1
-rw-r--r--drivers/net/hyperv/netvsc.c12
2 files changed, 7 insertions, 6 deletions
diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 4ffcd57b011..2857ab078aa 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -478,6 +478,7 @@ struct netvsc_device {
478 u32 nvsp_version; 478 u32 nvsp_version;
479 479
480 atomic_t num_outstanding_sends; 480 atomic_t num_outstanding_sends;
481 wait_queue_head_t wait_drain;
481 bool start_remove; 482 bool start_remove;
482 bool destroy; 483 bool destroy;
483 /* 484 /*
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 8b919471472..0c569831db5 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -42,6 +42,7 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
42 if (!net_device) 42 if (!net_device)
43 return NULL; 43 return NULL;
44 44
45 init_waitqueue_head(&net_device->wait_drain);
45 net_device->start_remove = false; 46 net_device->start_remove = false;
46 net_device->destroy = false; 47 net_device->destroy = false;
47 net_device->dev = device; 48 net_device->dev = device;
@@ -387,12 +388,8 @@ int netvsc_device_remove(struct hv_device *device)
387 spin_unlock_irqrestore(&device->channel->inbound_lock, flags); 388 spin_unlock_irqrestore(&device->channel->inbound_lock, flags);
388 389
389 /* Wait for all send completions */ 390 /* Wait for all send completions */
390 while (atomic_read(&net_device->num_outstanding_sends)) { 391 wait_event(net_device->wait_drain,
391 dev_info(&device->device, 392 atomic_read(&net_device->num_outstanding_sends) == 0);
392 "waiting for %d requests to complete...\n",
393 atomic_read(&net_device->num_outstanding_sends));
394 udelay(100);
395 }
396 393
397 netvsc_disconnect_vsp(net_device); 394 netvsc_disconnect_vsp(net_device);
398 395
@@ -486,6 +483,9 @@ static void netvsc_send_completion(struct hv_device *device,
486 num_outstanding_sends = 483 num_outstanding_sends =
487 atomic_dec_return(&net_device->num_outstanding_sends); 484 atomic_dec_return(&net_device->num_outstanding_sends);
488 485
486 if (net_device->destroy && num_outstanding_sends == 0)
487 wake_up(&net_device->wait_drain);
488
489 if (netif_queue_stopped(ndev) && !net_device->start_remove && 489 if (netif_queue_stopped(ndev) && !net_device->start_remove &&
490 (hv_ringbuf_avail_percent(&device->channel->outbound) 490 (hv_ringbuf_avail_percent(&device->channel->outbound)
491 > RING_AVAIL_PERCENT_HIWATER || 491 > RING_AVAIL_PERCENT_HIWATER ||