]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Staging: hv: netvsc: Introduce state to manage the lifecycle of net device
authorK. Y. Srinivasan <kys@microsoft.com>
Sat, 27 Aug 2011 18:31:12 +0000 (11:31 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 29 Aug 2011 18:01:04 +0000 (11:01 -0700)
Introduce state to manage the lifecycle of net device.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/hv/hyperv_net.h
drivers/staging/hv/netvsc.c

index 5782fea9a17a7d185170c9787ee006fe0c140518..0b347c1edc360d1dc0e55e9a7e2923e4dff9c186 100644 (file)
@@ -371,6 +371,7 @@ struct netvsc_device {
 
        atomic_t refcnt;
        atomic_t num_outstanding_sends;
+       bool destroy;
        /*
         * List of free preallocated hv_netvsc_packet to represent receive
         * packet
index 772210268787ce96e9dd1af01e7fb5511d32d6b7..8eb4039b5ff8571a51df1ae1bfdc541a9887c813 100644 (file)
@@ -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 */
        atomic_set(&net_device->refcnt, 2);
 
+       net_device->destroy = false;
        net_device->dev = device;
        device->ext = net_device;
 
@@ -396,6 +397,7 @@ int netvsc_device_remove(struct hv_device *device)
 {
        struct netvsc_device *net_device;
        struct hv_netvsc_packet *netvsc_packet, *pos;
+       unsigned long flags;
 
        /* Stop outbound traffic ie sends and receives completions */
        net_device = release_outbound_net_device(device);
@@ -404,6 +406,10 @@ int netvsc_device_remove(struct hv_device *device)
                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 */
        while (atomic_read(&net_device->num_outstanding_sends)) {
                dev_err(&device->device,