Commit 4d637632 authored by Vitaly Kuznetsov's avatar Vitaly Kuznetsov Committed by Greg Kroah-Hartman

Drivers: hv: get rid of redundant messagecount in create_gpadl_header()

We use messagecount only once in vmbus_establish_gpadl() to check if
it is safe to iterate through the submsglist. We can just initialize
the list header in all cases in create_gpadl_header() instead.
Signed-off-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a9f61ca7
...@@ -238,8 +238,7 @@ EXPORT_SYMBOL_GPL(vmbus_send_tl_connect_request); ...@@ -238,8 +238,7 @@ EXPORT_SYMBOL_GPL(vmbus_send_tl_connect_request);
* create_gpadl_header - Creates a gpadl for the specified buffer * create_gpadl_header - Creates a gpadl for the specified buffer
*/ */
static int create_gpadl_header(void *kbuffer, u32 size, static int create_gpadl_header(void *kbuffer, u32 size,
struct vmbus_channel_msginfo **msginfo, struct vmbus_channel_msginfo **msginfo)
u32 *messagecount)
{ {
int i; int i;
int pagecount; int pagecount;
...@@ -283,7 +282,6 @@ static int create_gpadl_header(void *kbuffer, u32 size, ...@@ -283,7 +282,6 @@ static int create_gpadl_header(void *kbuffer, u32 size,
gpadl_header->range[0].pfn_array[i] = slow_virt_to_phys( gpadl_header->range[0].pfn_array[i] = slow_virt_to_phys(
kbuffer + PAGE_SIZE * i) >> PAGE_SHIFT; kbuffer + PAGE_SIZE * i) >> PAGE_SHIFT;
*msginfo = msgheader; *msginfo = msgheader;
*messagecount = 1;
pfnsum = pfncount; pfnsum = pfncount;
pfnleft = pagecount - pfncount; pfnleft = pagecount - pfncount;
...@@ -323,7 +321,6 @@ static int create_gpadl_header(void *kbuffer, u32 size, ...@@ -323,7 +321,6 @@ static int create_gpadl_header(void *kbuffer, u32 size,
} }
msgbody->msgsize = msgsize; msgbody->msgsize = msgsize;
(*messagecount)++;
gpadl_body = gpadl_body =
(struct vmbus_channel_gpadl_body *)msgbody->msg; (struct vmbus_channel_gpadl_body *)msgbody->msg;
...@@ -352,6 +349,8 @@ static int create_gpadl_header(void *kbuffer, u32 size, ...@@ -352,6 +349,8 @@ static int create_gpadl_header(void *kbuffer, u32 size,
msgheader = kzalloc(msgsize, GFP_KERNEL); msgheader = kzalloc(msgsize, GFP_KERNEL);
if (msgheader == NULL) if (msgheader == NULL)
goto nomem; goto nomem;
INIT_LIST_HEAD(&msgheader->submsglist);
msgheader->msgsize = msgsize; msgheader->msgsize = msgsize;
gpadl_header = (struct vmbus_channel_gpadl_header *) gpadl_header = (struct vmbus_channel_gpadl_header *)
...@@ -366,7 +365,6 @@ static int create_gpadl_header(void *kbuffer, u32 size, ...@@ -366,7 +365,6 @@ static int create_gpadl_header(void *kbuffer, u32 size,
kbuffer + PAGE_SIZE * i) >> PAGE_SHIFT; kbuffer + PAGE_SIZE * i) >> PAGE_SHIFT;
*msginfo = msgheader; *msginfo = msgheader;
*messagecount = 1;
} }
return 0; return 0;
...@@ -391,7 +389,6 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, ...@@ -391,7 +389,6 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
struct vmbus_channel_gpadl_body *gpadl_body; struct vmbus_channel_gpadl_body *gpadl_body;
struct vmbus_channel_msginfo *msginfo = NULL; struct vmbus_channel_msginfo *msginfo = NULL;
struct vmbus_channel_msginfo *submsginfo; struct vmbus_channel_msginfo *submsginfo;
u32 msgcount;
struct list_head *curr; struct list_head *curr;
u32 next_gpadl_handle; u32 next_gpadl_handle;
unsigned long flags; unsigned long flags;
...@@ -400,7 +397,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, ...@@ -400,7 +397,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
next_gpadl_handle = next_gpadl_handle =
(atomic_inc_return(&vmbus_connection.next_gpadl_handle) - 1); (atomic_inc_return(&vmbus_connection.next_gpadl_handle) - 1);
ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount); ret = create_gpadl_header(kbuffer, size, &msginfo);
if (ret) if (ret)
return ret; return ret;
...@@ -423,9 +420,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, ...@@ -423,9 +420,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
if (ret != 0) if (ret != 0)
goto cleanup; goto cleanup;
if (msgcount > 1) {
list_for_each(curr, &msginfo->submsglist) { list_for_each(curr, &msginfo->submsglist) {
submsginfo = (struct vmbus_channel_msginfo *)curr; submsginfo = (struct vmbus_channel_msginfo *)curr;
gpadl_body = gpadl_body =
(struct vmbus_channel_gpadl_body *)submsginfo->msg; (struct vmbus_channel_gpadl_body *)submsginfo->msg;
...@@ -441,7 +436,6 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, ...@@ -441,7 +436,6 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
goto cleanup; goto cleanup;
} }
}
wait_for_completion(&msginfo->waitevent); wait_for_completion(&msginfo->waitevent);
/* At this point, we received the gpadl created msg */ /* At this point, we received the gpadl created msg */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment