Skip to content

Commit

Permalink
Drivers: hv: util: Fix a bug in the KVP code
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
K. Y. Srinivasan authored and Greg Kroah-Hartman committed Jul 9, 2014
1 parent affb1af commit 9bd2d0d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions drivers/hv/hv_kvp.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,17 @@ kvp_work_func(struct work_struct *dummy)
kvp_respond_to_host(NULL, HV_E_FAIL);
}

static void poll_channel(struct vmbus_channel *channel)
{
if (channel->target_cpu != smp_processor_id())
smp_call_function_single(channel->target_cpu,
hv_kvp_onchannelcallback,
channel, true);
else
hv_kvp_onchannelcallback(channel);
}


static int kvp_handle_handshake(struct hv_kvp_msg *msg)
{
int ret = 1;
Expand Down Expand Up @@ -155,7 +166,7 @@ static int kvp_handle_handshake(struct hv_kvp_msg *msg)
kvp_register(dm_reg_value);
kvp_transaction.active = false;
if (kvp_transaction.kvp_context)
hv_kvp_onchannelcallback(kvp_transaction.kvp_context);
poll_channel(kvp_transaction.kvp_context);
}
return ret;
}
Expand Down Expand Up @@ -568,7 +579,7 @@ kvp_respond_to_host(struct hv_kvp_msg *msg_to_host, int error)

vmbus_sendpacket(channel, recv_buffer, buf_len, req_id,
VM_PKT_DATA_INBAND, 0);

poll_channel(channel);
}

/*
Expand Down Expand Up @@ -603,7 +614,7 @@ void hv_kvp_onchannelcallback(void *context)
return;
}

vmbus_recvpacket(channel, recv_buffer, PAGE_SIZE * 2, &recvlen,
vmbus_recvpacket(channel, recv_buffer, PAGE_SIZE * 4, &recvlen,
&requestid);

if (recvlen > 0) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/hv/hv_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ static int util_probe(struct hv_device *dev,
(struct hv_util_service *)dev_id->driver_data;
int ret;

srv->recv_buffer = kmalloc(PAGE_SIZE * 2, GFP_KERNEL);
srv->recv_buffer = kmalloc(PAGE_SIZE * 4, GFP_KERNEL);
if (!srv->recv_buffer)
return -ENOMEM;
if (srv->util_init) {
Expand Down

0 comments on commit 9bd2d0d

Please sign in to comment.