]> git.karo-electronics.de Git - linux-beck.git/commitdiff
Drivers: hv: vmbus: Introduce a function to remove a rescinded offer
authorK. Y. Srinivasan <kys@microsoft.com>
Sat, 28 Feb 2015 19:18:17 +0000 (11:18 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 2 Mar 2015 03:31:02 +0000 (19:31 -0800)
In response to a rescind message, we need to remove the channel and the
corresponding device. Cleanup this code path by factoring out the code
to remove a channel.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hv/channel.c
drivers/hv/channel_mgmt.c
drivers/hv/vmbus_drv.c
include/linux/hyperv.h

index bf0cf8f3bcafd8d194d25a51dd5b981a4e66b503..9b79aca7e565d6fe0d915d00071e9daaca3edd0b 100644 (file)
@@ -501,6 +501,15 @@ static int vmbus_close_internal(struct vmbus_channel *channel)
                put_cpu();
        }
 
+       /*
+        * If the channel has been rescinded; process device removal.
+        */
+       if (channel->rescind) {
+               hv_process_channel_removal(channel,
+                                          channel->offermsg.child_relid);
+               return 0;
+       }
+
        /* Send a closing message */
 
        msg = &channel->close_msg.msg;
index 0ba6b5c303e68a636ce07887abef6a3b93ebe536..b93389124ec4e8e4762e0505edd2d09f7efbd986 100644 (file)
@@ -207,33 +207,21 @@ static void percpu_channel_deq(void *arg)
        list_del(&channel->percpu_list);
 }
 
-/*
- * vmbus_process_rescind_offer -
- * Rescind the offer by initiating a device removal
- */
-static void vmbus_process_rescind_offer(struct work_struct *work)
+
+void hv_process_channel_removal(struct vmbus_channel *channel, u32 relid)
 {
-       struct vmbus_channel *channel = container_of(work,
-                                                    struct vmbus_channel,
-                                                    work);
+       struct vmbus_channel_relid_released msg;
        unsigned long flags;
        struct vmbus_channel *primary_channel;
-       struct vmbus_channel_relid_released msg;
-       struct device *dev;
-
-       if (channel->device_obj) {
-               dev = get_device(&channel->device_obj->device);
-               if (dev) {
-                       vmbus_device_unregister(channel->device_obj);
-                       put_device(dev);
-               }
-       }
 
        memset(&msg, 0, sizeof(struct vmbus_channel_relid_released));
-       msg.child_relid = channel->offermsg.child_relid;
+       msg.child_relid = relid;
        msg.header.msgtype = CHANNELMSG_RELID_RELEASED;
        vmbus_post_msg(&msg, sizeof(struct vmbus_channel_relid_released));
 
+       if (channel == NULL)
+               return;
+
        if (channel->target_cpu != get_cpu()) {
                put_cpu();
                smp_call_function_single(channel->target_cpu,
@@ -256,6 +244,29 @@ static void vmbus_process_rescind_offer(struct work_struct *work)
        free_channel(channel);
 }
 
+/*
+ * vmbus_process_rescind_offer -
+ * Rescind the offer by initiating a device removal
+ */
+static void vmbus_process_rescind_offer(struct work_struct *work)
+{
+       struct vmbus_channel *channel = container_of(work,
+                                                    struct vmbus_channel,
+                                                    work);
+       struct device *dev;
+
+       if (channel->device_obj) {
+               dev = get_device(&channel->device_obj->device);
+               if (dev) {
+                       vmbus_device_unregister(channel->device_obj);
+                       put_device(dev);
+               }
+       } else {
+               hv_process_channel_removal(channel,
+                                          channel->offermsg.child_relid);
+       }
+}
+
 void vmbus_free_channels(void)
 {
        struct vmbus_channel *channel;
index a12666d075ea65c2eed4210320d56d31140df4db..2b7b51d264f1b8269f33cee9c427195d23e46ba2 100644 (file)
@@ -510,14 +510,23 @@ static int vmbus_remove(struct device *child_device)
 {
        struct hv_driver *drv;
        struct hv_device *dev = device_to_hv_device(child_device);
+       u32 relid = dev->channel->offermsg.child_relid;
 
        if (child_device->driver) {
                drv = drv_to_hv_drv(child_device->driver);
                if (drv->remove)
                        drv->remove(dev);
-               else
+               else {
+                       hv_process_channel_removal(dev->channel, relid);
                        pr_err("remove not set for driver %s\n",
                                dev_name(child_device));
+               }
+       } else {
+               /*
+                * We don't have a driver for this device; deal with the
+                * rescind message by removing the channel.
+                */
+               hv_process_channel_removal(dev->channel, relid);
        }
 
        return 0;
index 7d976ac01facdf3e90bd2bada458078345cbfe8e..dd92a854c7002de4b872feb53cae632a56f4017a 100644 (file)
@@ -1226,6 +1226,7 @@ void hv_kvp_onchannelcallback(void *);
 int hv_vss_init(struct hv_util_service *);
 void hv_vss_deinit(void);
 void hv_vss_onchannelcallback(void *);
+void hv_process_channel_removal(struct vmbus_channel *channel, u32 relid);
 
 extern struct resource hyperv_mmio;