提交 dc5cd894 编写于 作者: H Haiyang Zhang 提交者: David S. Miller

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: NHaiyang Zhang <haiyangz@microsoft.com>
Reviewed-by: NK. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 9ec0db71
...@@ -478,6 +478,7 @@ struct netvsc_device { ...@@ -478,6 +478,7 @@ struct netvsc_device {
u32 nvsp_version; u32 nvsp_version;
atomic_t num_outstanding_sends; atomic_t num_outstanding_sends;
wait_queue_head_t wait_drain;
bool start_remove; bool start_remove;
bool destroy; bool destroy;
/* /*
......
...@@ -42,6 +42,7 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device) ...@@ -42,6 +42,7 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
if (!net_device) if (!net_device)
return NULL; return NULL;
init_waitqueue_head(&net_device->wait_drain);
net_device->start_remove = false; net_device->start_remove = false;
net_device->destroy = false; net_device->destroy = false;
net_device->dev = device; net_device->dev = device;
...@@ -387,12 +388,8 @@ int netvsc_device_remove(struct hv_device *device) ...@@ -387,12 +388,8 @@ int netvsc_device_remove(struct hv_device *device)
spin_unlock_irqrestore(&device->channel->inbound_lock, flags); spin_unlock_irqrestore(&device->channel->inbound_lock, flags);
/* Wait for all send completions */ /* Wait for all send completions */
while (atomic_read(&net_device->num_outstanding_sends)) { wait_event(net_device->wait_drain,
dev_info(&device->device, atomic_read(&net_device->num_outstanding_sends) == 0);
"waiting for %d requests to complete...\n",
atomic_read(&net_device->num_outstanding_sends));
udelay(100);
}
netvsc_disconnect_vsp(net_device); netvsc_disconnect_vsp(net_device);
...@@ -486,6 +483,9 @@ static void netvsc_send_completion(struct hv_device *device, ...@@ -486,6 +483,9 @@ static void netvsc_send_completion(struct hv_device *device,
num_outstanding_sends = num_outstanding_sends =
atomic_dec_return(&net_device->num_outstanding_sends); atomic_dec_return(&net_device->num_outstanding_sends);
if (net_device->destroy && num_outstanding_sends == 0)
wake_up(&net_device->wait_drain);
if (netif_queue_stopped(ndev) && !net_device->start_remove && if (netif_queue_stopped(ndev) && !net_device->start_remove &&
(hv_ringbuf_avail_percent(&device->channel->outbound) (hv_ringbuf_avail_percent(&device->channel->outbound)
> RING_AVAIL_PERCENT_HIWATER || > RING_AVAIL_PERCENT_HIWATER ||
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册