Merge tag 'for-4.5' of git://git.osdn.jp/gitroot/uclinux-h8/linux
[deliverable/linux.git] / drivers / hv / channel_mgmt.c
index 7903acc3403e99c9722e945d7634482b7ce15aea..1c1ad47042c5d7e9a90f29d8a232bab0ad6f2a8a 100644 (file)
@@ -177,19 +177,22 @@ static void percpu_channel_deq(void *arg)
 }
 
 
-void hv_process_channel_removal(struct vmbus_channel *channel, u32 relid)
+static void vmbus_release_relid(u32 relid)
 {
        struct vmbus_channel_relid_released msg;
-       unsigned long flags;
-       struct vmbus_channel *primary_channel;
 
        memset(&msg, 0, sizeof(struct vmbus_channel_relid_released));
        msg.child_relid = relid;
        msg.header.msgtype = CHANNELMSG_RELID_RELEASED;
        vmbus_post_msg(&msg, sizeof(struct vmbus_channel_relid_released));
+}
 
-       if (channel == NULL)
-               return;
+void hv_process_channel_removal(struct vmbus_channel *channel, u32 relid)
+{
+       unsigned long flags;
+       struct vmbus_channel *primary_channel;
+
+       vmbus_release_relid(relid);
 
        BUG_ON(!channel->rescind);
 
@@ -203,9 +206,9 @@ void hv_process_channel_removal(struct vmbus_channel *channel, u32 relid)
        }
 
        if (channel->primary_channel == NULL) {
-               spin_lock_irqsave(&vmbus_connection.channel_lock, flags);
+               mutex_lock(&vmbus_connection.channel_mutex);
                list_del(&channel->listentry);
-               spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags);
+               mutex_unlock(&vmbus_connection.channel_mutex);
 
                primary_channel = channel;
        } else {
@@ -250,7 +253,7 @@ static void vmbus_process_offer(struct vmbus_channel *newchannel)
        unsigned long flags;
 
        /* Make sure this is a new offer */
-       spin_lock_irqsave(&vmbus_connection.channel_lock, flags);
+       mutex_lock(&vmbus_connection.channel_mutex);
 
        list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
                if (!uuid_le_cmp(channel->offermsg.offer.if_type,
@@ -266,7 +269,7 @@ static void vmbus_process_offer(struct vmbus_channel *newchannel)
                list_add_tail(&newchannel->listentry,
                              &vmbus_connection.chn_list);
 
-       spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags);
+       mutex_unlock(&vmbus_connection.channel_mutex);
 
        if (!fnew) {
                /*
@@ -336,9 +339,11 @@ static void vmbus_process_offer(struct vmbus_channel *newchannel)
        return;
 
 err_deq_chan:
-       spin_lock_irqsave(&vmbus_connection.channel_lock, flags);
+       vmbus_release_relid(newchannel->offermsg.child_relid);
+
+       mutex_lock(&vmbus_connection.channel_mutex);
        list_del(&newchannel->listentry);
-       spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags);
+       mutex_unlock(&vmbus_connection.channel_mutex);
 
        if (newchannel->target_cpu != get_cpu()) {
                put_cpu();
@@ -356,6 +361,7 @@ err_free_chan:
 enum {
        IDE = 0,
        SCSI,
+       FC,
        NIC,
        ND_NIC,
        PCIE,
@@ -372,6 +378,8 @@ static const struct hv_vmbus_device_id hp_devs[] = {
        { HV_IDE_GUID, },
        /* Storage - SCSI */
        { HV_SCSI_GUID, },
+       /* Storage - FC */
+       { HV_SYNTHFC_GUID, },
        /* Network */
        { HV_NIC_GUID, },
        /* NetworkDirect Guest RDMA */
@@ -587,7 +595,11 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr)
        channel = relid2channel(rescind->child_relid);
 
        if (channel == NULL) {
-               hv_process_channel_removal(NULL, rescind->child_relid);
+               /*
+                * This is very impossible, because in
+                * vmbus_process_offer(), we have already invoked
+                * vmbus_release_relid() on error.
+                */
                return;
        }
 
This page took 0.039171 seconds and 5 git commands to generate.