Skip to content

Commit 9bd2d0d

Browse files
kattisrinivasangregkh
authored andcommitted
Drivers: hv: util: Fix a bug in the KVP code
Add code to poll the channel since we process only one message at a time and the host may not interrupt us. Also increase the receive buffer size since some KVP messages are close to 8K bytes in size. Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> Cc: <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent affb1af commit 9bd2d0d

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

‎drivers/hv/hv_kvp.c‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,17 @@ kvp_work_func(struct work_struct *dummy)
127127
kvp_respond_to_host(NULL, HV_E_FAIL);
128128
}
129129

130+
static void poll_channel(struct vmbus_channel *channel)
131+
{
132+
if (channel->target_cpu != smp_processor_id())
133+
smp_call_function_single(channel->target_cpu,
134+
hv_kvp_onchannelcallback,
135+
channel, true);
136+
else
137+
hv_kvp_onchannelcallback(channel);
138+
}
139+
140+
130141
static int kvp_handle_handshake(struct hv_kvp_msg *msg)
131142
{
132143
int ret = 1;
@@ -155,7 +166,7 @@ static int kvp_handle_handshake(struct hv_kvp_msg *msg)
155166
kvp_register(dm_reg_value);
156167
kvp_transaction.active = false;
157168
if (kvp_transaction.kvp_context)
158-
hv_kvp_onchannelcallback(kvp_transaction.kvp_context);
169+
poll_channel(kvp_transaction.kvp_context);
159170
}
160171
return ret;
161172
}
@@ -568,7 +579,7 @@ kvp_respond_to_host(struct hv_kvp_msg *msg_to_host, int error)
568579

569580
vmbus_sendpacket(channel, recv_buffer, buf_len, req_id,
570581
VM_PKT_DATA_INBAND, 0);
571-
582+
poll_channel(channel);
572583
}
573584

574585
/*
@@ -603,7 +614,7 @@ void hv_kvp_onchannelcallback(void *context)
603614
return;
604615
}
605616

606-
vmbus_recvpacket(channel, recv_buffer, PAGE_SIZE * 2, &recvlen,
617+
vmbus_recvpacket(channel, recv_buffer, PAGE_SIZE * 4, &recvlen,
607618
&requestid);
608619

609620
if (recvlen > 0) {

‎drivers/hv/hv_util.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ static int util_probe(struct hv_device *dev,
319319
(struct hv_util_service *)dev_id->driver_data;
320320
int ret;
321321

322-
srv->recv_buffer = kmalloc(PAGE_SIZE * 2, GFP_KERNEL);
322+
srv->recv_buffer = kmalloc(PAGE_SIZE * 4, GFP_KERNEL);
323323
if (!srv->recv_buffer)
324324
return -ENOMEM;
325325
if (srv->util_init) {

0 commit comments

Comments
 (0)