aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hv/channel.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hv/channel.c')
-rw-r--r--drivers/hv/channel.c42
1 files changed, 23 insertions, 19 deletions
diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 69ea36f07b4d..602ca86a6488 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -27,6 +27,7 @@
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/hyperv.h> 29#include <linux/hyperv.h>
30#include <linux/uio.h>
30 31
31#include "hyperv_vmbus.h" 32#include "hyperv_vmbus.h"
32 33
@@ -554,14 +555,14 @@ EXPORT_SYMBOL_GPL(vmbus_close);
554 * 555 *
555 * Mainly used by Hyper-V drivers. 556 * Mainly used by Hyper-V drivers.
556 */ 557 */
557int vmbus_sendpacket(struct vmbus_channel *channel, const void *buffer, 558int vmbus_sendpacket(struct vmbus_channel *channel, void *buffer,
558 u32 bufferlen, u64 requestid, 559 u32 bufferlen, u64 requestid,
559 enum vmbus_packet_type type, u32 flags) 560 enum vmbus_packet_type type, u32 flags)
560{ 561{
561 struct vmpacket_descriptor desc; 562 struct vmpacket_descriptor desc;
562 u32 packetlen = sizeof(struct vmpacket_descriptor) + bufferlen; 563 u32 packetlen = sizeof(struct vmpacket_descriptor) + bufferlen;
563 u32 packetlen_aligned = ALIGN(packetlen, sizeof(u64)); 564 u32 packetlen_aligned = ALIGN(packetlen, sizeof(u64));
564 struct scatterlist bufferlist[3]; 565 struct kvec bufferlist[3];
565 u64 aligned_data = 0; 566 u64 aligned_data = 0;
566 int ret; 567 int ret;
567 bool signal = false; 568 bool signal = false;
@@ -575,11 +576,12 @@ int vmbus_sendpacket(struct vmbus_channel *channel, const void *buffer,
575 desc.len8 = (u16)(packetlen_aligned >> 3); 576 desc.len8 = (u16)(packetlen_aligned >> 3);
576 desc.trans_id = requestid; 577 desc.trans_id = requestid;
577 578
578 sg_init_table(bufferlist, 3); 579 bufferlist[0].iov_base = &desc;
579 sg_set_buf(&bufferlist[0], &desc, sizeof(struct vmpacket_descriptor)); 580 bufferlist[0].iov_len = sizeof(struct vmpacket_descriptor);
580 sg_set_buf(&bufferlist[1], buffer, bufferlen); 581 bufferlist[1].iov_base = buffer;
581 sg_set_buf(&bufferlist[2], &aligned_data, 582 bufferlist[1].iov_len = bufferlen;
582 packetlen_aligned - packetlen); 583 bufferlist[2].iov_base = &aligned_data;
584 bufferlist[2].iov_len = (packetlen_aligned - packetlen);
583 585
584 ret = hv_ringbuffer_write(&channel->outbound, bufferlist, 3, &signal); 586 ret = hv_ringbuffer_write(&channel->outbound, bufferlist, 3, &signal);
585 587
@@ -605,7 +607,7 @@ int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel,
605 u32 descsize; 607 u32 descsize;
606 u32 packetlen; 608 u32 packetlen;
607 u32 packetlen_aligned; 609 u32 packetlen_aligned;
608 struct scatterlist bufferlist[3]; 610 struct kvec bufferlist[3];
609 u64 aligned_data = 0; 611 u64 aligned_data = 0;
610 bool signal = false; 612 bool signal = false;
611 613
@@ -637,11 +639,12 @@ int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel,
637 desc.range[i].pfn = pagebuffers[i].pfn; 639 desc.range[i].pfn = pagebuffers[i].pfn;
638 } 640 }
639 641
640 sg_init_table(bufferlist, 3); 642 bufferlist[0].iov_base = &desc;
641 sg_set_buf(&bufferlist[0], &desc, descsize); 643 bufferlist[0].iov_len = descsize;
642 sg_set_buf(&bufferlist[1], buffer, bufferlen); 644 bufferlist[1].iov_base = buffer;
643 sg_set_buf(&bufferlist[2], &aligned_data, 645 bufferlist[1].iov_len = bufferlen;
644 packetlen_aligned - packetlen); 646 bufferlist[2].iov_base = &aligned_data;
647 bufferlist[2].iov_len = (packetlen_aligned - packetlen);
645 648
646 ret = hv_ringbuffer_write(&channel->outbound, bufferlist, 3, &signal); 649 ret = hv_ringbuffer_write(&channel->outbound, bufferlist, 3, &signal);
647 650
@@ -665,7 +668,7 @@ int vmbus_sendpacket_multipagebuffer(struct vmbus_channel *channel,
665 u32 descsize; 668 u32 descsize;
666 u32 packetlen; 669 u32 packetlen;
667 u32 packetlen_aligned; 670 u32 packetlen_aligned;
668 struct scatterlist bufferlist[3]; 671 struct kvec bufferlist[3];
669 u64 aligned_data = 0; 672 u64 aligned_data = 0;
670 bool signal = false; 673 bool signal = false;
671 u32 pfncount = NUM_PAGES_SPANNED(multi_pagebuffer->offset, 674 u32 pfncount = NUM_PAGES_SPANNED(multi_pagebuffer->offset,
@@ -700,11 +703,12 @@ int vmbus_sendpacket_multipagebuffer(struct vmbus_channel *channel,
700 memcpy(desc.range.pfn_array, multi_pagebuffer->pfn_array, 703 memcpy(desc.range.pfn_array, multi_pagebuffer->pfn_array,
701 pfncount * sizeof(u64)); 704 pfncount * sizeof(u64));
702 705
703 sg_init_table(bufferlist, 3); 706 bufferlist[0].iov_base = &desc;
704 sg_set_buf(&bufferlist[0], &desc, descsize); 707 bufferlist[0].iov_len = descsize;
705 sg_set_buf(&bufferlist[1], buffer, bufferlen); 708 bufferlist[1].iov_base = buffer;
706 sg_set_buf(&bufferlist[2], &aligned_data, 709 bufferlist[1].iov_len = bufferlen;
707 packetlen_aligned - packetlen); 710 bufferlist[2].iov_base = &aligned_data;
711 bufferlist[2].iov_len = (packetlen_aligned - packetlen);
708 712
709 ret = hv_ringbuffer_write(&channel->outbound, bufferlist, 3, &signal); 713 ret = hv_ringbuffer_write(&channel->outbound, bufferlist, 3, &signal);
710 714