diff options
| author | Vitaly Kuznetsov <vkuznets@redhat.com> | 2016-06-03 20:09:23 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-08-31 07:05:40 -0400 |
| commit | 4d63763296ab7865a98bc29cc7d77145815ef89f (patch) | |
| tree | 677d1fb88a994e9b29198f038f5735e13bc82249 /drivers/hv | |
| parent | a9f61ca793becabdefab03b77568d6c6f8c1bc79 (diff) | |
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: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/hv')
| -rw-r--r-- | drivers/hv/channel.c | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c index 56dd261f7142..2b109e8a8c97 100644 --- a/drivers/hv/channel.c +++ b/drivers/hv/channel.c | |||
| @@ -238,8 +238,7 @@ EXPORT_SYMBOL_GPL(vmbus_send_tl_connect_request); | |||
| 238 | * create_gpadl_header - Creates a gpadl for the specified buffer | 238 | * create_gpadl_header - Creates a gpadl for the specified buffer |
| 239 | */ | 239 | */ |
| 240 | static int create_gpadl_header(void *kbuffer, u32 size, | 240 | static int create_gpadl_header(void *kbuffer, u32 size, |
| 241 | struct vmbus_channel_msginfo **msginfo, | 241 | struct vmbus_channel_msginfo **msginfo) |
| 242 | u32 *messagecount) | ||
| 243 | { | 242 | { |
| 244 | int i; | 243 | int i; |
| 245 | int pagecount; | 244 | int pagecount; |
| @@ -283,7 +282,6 @@ static int create_gpadl_header(void *kbuffer, u32 size, | |||
| 283 | gpadl_header->range[0].pfn_array[i] = slow_virt_to_phys( | 282 | gpadl_header->range[0].pfn_array[i] = slow_virt_to_phys( |
| 284 | kbuffer + PAGE_SIZE * i) >> PAGE_SHIFT; | 283 | kbuffer + PAGE_SIZE * i) >> PAGE_SHIFT; |
| 285 | *msginfo = msgheader; | 284 | *msginfo = msgheader; |
| 286 | *messagecount = 1; | ||
| 287 | 285 | ||
| 288 | pfnsum = pfncount; | 286 | pfnsum = pfncount; |
| 289 | pfnleft = pagecount - pfncount; | 287 | pfnleft = pagecount - pfncount; |
| @@ -323,7 +321,6 @@ static int create_gpadl_header(void *kbuffer, u32 size, | |||
| 323 | } | 321 | } |
| 324 | 322 | ||
| 325 | msgbody->msgsize = msgsize; | 323 | msgbody->msgsize = msgsize; |
| 326 | (*messagecount)++; | ||
| 327 | gpadl_body = | 324 | gpadl_body = |
| 328 | (struct vmbus_channel_gpadl_body *)msgbody->msg; | 325 | (struct vmbus_channel_gpadl_body *)msgbody->msg; |
| 329 | 326 | ||
| @@ -352,6 +349,8 @@ static int create_gpadl_header(void *kbuffer, u32 size, | |||
| 352 | msgheader = kzalloc(msgsize, GFP_KERNEL); | 349 | msgheader = kzalloc(msgsize, GFP_KERNEL); |
| 353 | if (msgheader == NULL) | 350 | if (msgheader == NULL) |
| 354 | goto nomem; | 351 | goto nomem; |
| 352 | |||
| 353 | INIT_LIST_HEAD(&msgheader->submsglist); | ||
| 355 | msgheader->msgsize = msgsize; | 354 | msgheader->msgsize = msgsize; |
| 356 | 355 | ||
| 357 | gpadl_header = (struct vmbus_channel_gpadl_header *) | 356 | gpadl_header = (struct vmbus_channel_gpadl_header *) |
| @@ -366,7 +365,6 @@ static int create_gpadl_header(void *kbuffer, u32 size, | |||
| 366 | kbuffer + PAGE_SIZE * i) >> PAGE_SHIFT; | 365 | kbuffer + PAGE_SIZE * i) >> PAGE_SHIFT; |
| 367 | 366 | ||
| 368 | *msginfo = msgheader; | 367 | *msginfo = msgheader; |
| 369 | *messagecount = 1; | ||
| 370 | } | 368 | } |
| 371 | 369 | ||
| 372 | return 0; | 370 | return 0; |
| @@ -391,7 +389,6 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, | |||
| 391 | struct vmbus_channel_gpadl_body *gpadl_body; | 389 | struct vmbus_channel_gpadl_body *gpadl_body; |
| 392 | struct vmbus_channel_msginfo *msginfo = NULL; | 390 | struct vmbus_channel_msginfo *msginfo = NULL; |
| 393 | struct vmbus_channel_msginfo *submsginfo; | 391 | struct vmbus_channel_msginfo *submsginfo; |
| 394 | u32 msgcount; | ||
| 395 | struct list_head *curr; | 392 | struct list_head *curr; |
| 396 | u32 next_gpadl_handle; | 393 | u32 next_gpadl_handle; |
| 397 | unsigned long flags; | 394 | unsigned long flags; |
| @@ -400,7 +397,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, | |||
| 400 | next_gpadl_handle = | 397 | next_gpadl_handle = |
| 401 | (atomic_inc_return(&vmbus_connection.next_gpadl_handle) - 1); | 398 | (atomic_inc_return(&vmbus_connection.next_gpadl_handle) - 1); |
| 402 | 399 | ||
| 403 | ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount); | 400 | ret = create_gpadl_header(kbuffer, size, &msginfo); |
| 404 | if (ret) | 401 | if (ret) |
| 405 | return ret; | 402 | return ret; |
| 406 | 403 | ||
| @@ -423,24 +420,21 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, | |||
| 423 | if (ret != 0) | 420 | if (ret != 0) |
| 424 | goto cleanup; | 421 | goto cleanup; |
| 425 | 422 | ||
| 426 | if (msgcount > 1) { | 423 | list_for_each(curr, &msginfo->submsglist) { |
| 427 | list_for_each(curr, &msginfo->submsglist) { | 424 | submsginfo = (struct vmbus_channel_msginfo *)curr; |
| 425 | gpadl_body = | ||
| 426 | (struct vmbus_channel_gpadl_body *)submsginfo->msg; | ||
| 428 | 427 | ||
| 429 | submsginfo = (struct vmbus_channel_msginfo *)curr; | 428 | gpadl_body->header.msgtype = |
| 430 | gpadl_body = | 429 | CHANNELMSG_GPADL_BODY; |
| 431 | (struct vmbus_channel_gpadl_body *)submsginfo->msg; | 430 | gpadl_body->gpadl = next_gpadl_handle; |
| 432 | 431 | ||
| 433 | gpadl_body->header.msgtype = | 432 | ret = vmbus_post_msg(gpadl_body, |
| 434 | CHANNELMSG_GPADL_BODY; | 433 | submsginfo->msgsize - |
| 435 | gpadl_body->gpadl = next_gpadl_handle; | 434 | sizeof(*submsginfo)); |
| 435 | if (ret != 0) | ||
| 436 | goto cleanup; | ||
| 436 | 437 | ||
| 437 | ret = vmbus_post_msg(gpadl_body, | ||
| 438 | submsginfo->msgsize - | ||
| 439 | sizeof(*submsginfo)); | ||
| 440 | if (ret != 0) | ||
| 441 | goto cleanup; | ||
| 442 | |||
| 443 | } | ||
| 444 | } | 438 | } |
| 445 | wait_for_completion(&msginfo->waitevent); | 439 | wait_for_completion(&msginfo->waitevent); |
| 446 | 440 | ||
