]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - drivers/hv/channel.c
Allow mac address to be set in smsc95xx
[mirror_ubuntu-zesty-kernel.git] / drivers / hv / channel.c
index 5fb4c6d9209b753a12dcddb4c441ff00c3e8746a..1606e7f08f4b36750be747feb5d0e9f36b3e6dd0 100644 (file)
@@ -157,6 +157,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
        }
 
        init_completion(&open_info->waitevent);
+       open_info->waiting_channel = newchannel;
 
        open_msg = (struct vmbus_channel_open_channel *)open_info->msg;
        open_msg->header.msgtype = CHANNELMSG_OPENCHANNEL;
@@ -181,7 +182,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
        spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
 
        ret = vmbus_post_msg(open_msg,
-                              sizeof(struct vmbus_channel_open_channel));
+                            sizeof(struct vmbus_channel_open_channel), true);
 
        if (ret != 0) {
                err = ret;
@@ -194,6 +195,11 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
        list_del(&open_info->msglistentry);
        spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
 
+       if (newchannel->rescind) {
+               err = -ENODEV;
+               goto error_free_gpadl;
+       }
+
        if (open_info->response.open_result.status) {
                err = -EAGAIN;
                goto error_free_gpadl;
@@ -233,7 +239,7 @@ int vmbus_send_tl_connect_request(const uuid_le *shv_guest_servie_id,
        conn_msg.guest_endpoint_id = *shv_guest_servie_id;
        conn_msg.host_service_id = *shv_host_servie_id;
 
-       return vmbus_post_msg(&conn_msg, sizeof(conn_msg));
+       return vmbus_post_msg(&conn_msg, sizeof(conn_msg), true);
 }
 EXPORT_SYMBOL_GPL(vmbus_send_tl_connect_request);
 
@@ -405,6 +411,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
                return ret;
 
        init_completion(&msginfo->waitevent);
+       msginfo->waiting_channel = channel;
 
        gpadlmsg = (struct vmbus_channel_gpadl_header *)msginfo->msg;
        gpadlmsg->header.msgtype = CHANNELMSG_GPADL_HEADER;
@@ -419,7 +426,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
        spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
 
        ret = vmbus_post_msg(gpadlmsg, msginfo->msgsize -
-                              sizeof(*msginfo));
+                            sizeof(*msginfo), true);
        if (ret != 0)
                goto cleanup;
 
@@ -433,14 +440,19 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
                gpadl_body->gpadl = next_gpadl_handle;
 
                ret = vmbus_post_msg(gpadl_body,
-                                    submsginfo->msgsize -
-                                    sizeof(*submsginfo));
+                                    submsginfo->msgsize - sizeof(*submsginfo),
+                                    true);
                if (ret != 0)
                        goto cleanup;
 
        }
        wait_for_completion(&msginfo->waitevent);
 
+       if (channel->rescind) {
+               ret = -ENODEV;
+               goto cleanup;
+       }
+
        /* At this point, we received the gpadl created msg */
        *gpadl_handle = gpadlmsg->gpadl;
 
@@ -474,6 +486,7 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
                return -ENOMEM;
 
        init_completion(&info->waitevent);
+       info->waiting_channel = channel;
 
        msg = (struct vmbus_channel_gpadl_teardown *)info->msg;
 
@@ -485,8 +498,8 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
        list_add_tail(&info->msglistentry,
                      &vmbus_connection.chn_msg_list);
        spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
-       ret = vmbus_post_msg(msg,
-                              sizeof(struct vmbus_channel_gpadl_teardown));
+       ret = vmbus_post_msg(msg, sizeof(struct vmbus_channel_gpadl_teardown),
+                            true);
 
        if (ret)
                goto post_msg_err;
@@ -494,6 +507,14 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
        wait_for_completion(&info->waitevent);
 
 post_msg_err:
+       /*
+        * If the channel has been rescinded;
+        * we will be awakened by the rescind
+        * handler; set the error code to zero so we don't leak memory.
+        */
+       if (channel->rescind)
+               ret = 0;
+
        spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
        list_del(&info->msglistentry);
        spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
@@ -557,7 +578,8 @@ static int vmbus_close_internal(struct vmbus_channel *channel)
        msg->header.msgtype = CHANNELMSG_CLOSECHANNEL;
        msg->child_relid = channel->offermsg.child_relid;
 
-       ret = vmbus_post_msg(msg, sizeof(struct vmbus_channel_close_channel));
+       ret = vmbus_post_msg(msg, sizeof(struct vmbus_channel_close_channel),
+                            true);
 
        if (ret) {
                pr_err("Close failed: close post msg return is %d\n", ret);