Commit b14d749a authored by Himadri Pandya's avatar Himadri Pandya Committed by Sasha Levin

Drivers: hv: Specify receive buffer size using Hyper-V page size

The recv_buffer is used to retrieve data from the VMbus ring buffer.
VMbus ring buffers are sized based on the guest page size which
Hyper-V assumes to be 4KB. But it may be different on some
architectures. So use the Hyper-V page size to allocate the
recv_buffer and set the maximum size to receive.
Signed-off-by: default avatarHimadri Pandya <himadri18.07@gmail.com>
Reviewed-by: default avatarMichael Kelley <mikelley@microsoft.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent c48d8b04
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/hyperv.h> #include <linux/hyperv.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <asm/hyperv-tlfs.h>
#include "hyperv_vmbus.h" #include "hyperv_vmbus.h"
#include "hv_utils_transport.h" #include "hv_utils_transport.h"
...@@ -234,7 +235,7 @@ void hv_fcopy_onchannelcallback(void *context) ...@@ -234,7 +235,7 @@ void hv_fcopy_onchannelcallback(void *context)
if (fcopy_transaction.state > HVUTIL_READY) if (fcopy_transaction.state > HVUTIL_READY)
return; return;
vmbus_recvpacket(channel, recv_buffer, PAGE_SIZE * 2, &recvlen, vmbus_recvpacket(channel, recv_buffer, HV_HYP_PAGE_SIZE * 2, &recvlen,
&requestid); &requestid);
if (recvlen <= 0) if (recvlen <= 0)
return; return;
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <linux/connector.h> #include <linux/connector.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/hyperv.h> #include <linux/hyperv.h>
#include <asm/hyperv-tlfs.h>
#include "hyperv_vmbus.h" #include "hyperv_vmbus.h"
#include "hv_utils_transport.h" #include "hv_utils_transport.h"
...@@ -661,7 +662,7 @@ void hv_kvp_onchannelcallback(void *context) ...@@ -661,7 +662,7 @@ void hv_kvp_onchannelcallback(void *context)
if (kvp_transaction.state > HVUTIL_READY) if (kvp_transaction.state > HVUTIL_READY)
return; return;
vmbus_recvpacket(channel, recv_buffer, PAGE_SIZE * 4, &recvlen, vmbus_recvpacket(channel, recv_buffer, HV_HYP_PAGE_SIZE * 4, &recvlen,
&requestid); &requestid);
if (recvlen > 0) { if (recvlen > 0) {
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <linux/connector.h> #include <linux/connector.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/hyperv.h> #include <linux/hyperv.h>
#include <asm/hyperv-tlfs.h>
#include "hyperv_vmbus.h" #include "hyperv_vmbus.h"
#include "hv_utils_transport.h" #include "hv_utils_transport.h"
...@@ -297,7 +298,7 @@ void hv_vss_onchannelcallback(void *context) ...@@ -297,7 +298,7 @@ void hv_vss_onchannelcallback(void *context)
if (vss_transaction.state > HVUTIL_READY) if (vss_transaction.state > HVUTIL_READY)
return; return;
vmbus_recvpacket(channel, recv_buffer, PAGE_SIZE * 2, &recvlen, vmbus_recvpacket(channel, recv_buffer, HV_HYP_PAGE_SIZE * 2, &recvlen,
&requestid); &requestid);
if (recvlen > 0) { if (recvlen > 0) {
......
...@@ -136,7 +136,7 @@ static void shutdown_onchannelcallback(void *context) ...@@ -136,7 +136,7 @@ static void shutdown_onchannelcallback(void *context)
struct icmsg_hdr *icmsghdrp; struct icmsg_hdr *icmsghdrp;
vmbus_recvpacket(channel, shut_txf_buf, vmbus_recvpacket(channel, shut_txf_buf,
PAGE_SIZE, &recvlen, &requestid); HV_HYP_PAGE_SIZE, &recvlen, &requestid);
if (recvlen > 0) { if (recvlen > 0) {
icmsghdrp = (struct icmsg_hdr *)&shut_txf_buf[ icmsghdrp = (struct icmsg_hdr *)&shut_txf_buf[
...@@ -284,7 +284,7 @@ static void timesync_onchannelcallback(void *context) ...@@ -284,7 +284,7 @@ static void timesync_onchannelcallback(void *context)
u8 *time_txf_buf = util_timesynch.recv_buffer; u8 *time_txf_buf = util_timesynch.recv_buffer;
vmbus_recvpacket(channel, time_txf_buf, vmbus_recvpacket(channel, time_txf_buf,
PAGE_SIZE, &recvlen, &requestid); HV_HYP_PAGE_SIZE, &recvlen, &requestid);
if (recvlen > 0) { if (recvlen > 0) {
icmsghdrp = (struct icmsg_hdr *)&time_txf_buf[ icmsghdrp = (struct icmsg_hdr *)&time_txf_buf[
...@@ -346,7 +346,7 @@ static void heartbeat_onchannelcallback(void *context) ...@@ -346,7 +346,7 @@ static void heartbeat_onchannelcallback(void *context)
while (1) { while (1) {
vmbus_recvpacket(channel, hbeat_txf_buf, vmbus_recvpacket(channel, hbeat_txf_buf,
PAGE_SIZE, &recvlen, &requestid); HV_HYP_PAGE_SIZE, &recvlen, &requestid);
if (!recvlen) if (!recvlen)
break; break;
...@@ -390,7 +390,7 @@ static int util_probe(struct hv_device *dev, ...@@ -390,7 +390,7 @@ static int util_probe(struct hv_device *dev,
(struct hv_util_service *)dev_id->driver_data; (struct hv_util_service *)dev_id->driver_data;
int ret; int ret;
srv->recv_buffer = kmalloc(PAGE_SIZE * 4, GFP_KERNEL); srv->recv_buffer = kmalloc(HV_HYP_PAGE_SIZE * 4, GFP_KERNEL);
if (!srv->recv_buffer) if (!srv->recv_buffer)
return -ENOMEM; return -ENOMEM;
srv->channel = dev->channel; srv->channel = dev->channel;
......
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