提交 c38b9c71 编写于 作者: K K. Y. Srinivasan 提交者: Greg Kroah-Hartman

Staging: hv: netvsc: Introduce state to manage the lifecycle of net device

Introduce state to manage the lifecycle of net device.
Signed-off-by: NK. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: NHaiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 509ee387
...@@ -371,6 +371,7 @@ struct netvsc_device { ...@@ -371,6 +371,7 @@ struct netvsc_device {
atomic_t refcnt; atomic_t refcnt;
atomic_t num_outstanding_sends; atomic_t num_outstanding_sends;
bool destroy;
/* /*
* List of free preallocated hv_netvsc_packet to represent receive * List of free preallocated hv_netvsc_packet to represent receive
* packet * packet
......
...@@ -43,6 +43,7 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device) ...@@ -43,6 +43,7 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
/* Set to 2 to allow both inbound and outbound traffic */ /* Set to 2 to allow both inbound and outbound traffic */
atomic_set(&net_device->refcnt, 2); atomic_set(&net_device->refcnt, 2);
net_device->destroy = false;
net_device->dev = device; net_device->dev = device;
device->ext = net_device; device->ext = net_device;
...@@ -396,6 +397,7 @@ int netvsc_device_remove(struct hv_device *device) ...@@ -396,6 +397,7 @@ int netvsc_device_remove(struct hv_device *device)
{ {
struct netvsc_device *net_device; struct netvsc_device *net_device;
struct hv_netvsc_packet *netvsc_packet, *pos; struct hv_netvsc_packet *netvsc_packet, *pos;
unsigned long flags;
/* Stop outbound traffic ie sends and receives completions */ /* Stop outbound traffic ie sends and receives completions */
net_device = release_outbound_net_device(device); net_device = release_outbound_net_device(device);
...@@ -404,6 +406,10 @@ int netvsc_device_remove(struct hv_device *device) ...@@ -404,6 +406,10 @@ int netvsc_device_remove(struct hv_device *device)
return -ENODEV; return -ENODEV;
} }
spin_lock_irqsave(&device->channel->inbound_lock, flags);
net_device->destroy = true;
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)) { while (atomic_read(&net_device->num_outstanding_sends)) {
dev_err(&device->device, dev_err(&device->device,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册