Skip to content

Commit 061dc93

Browse files
fbqliuw
authored andcommitted
Driver: hv: util: Use VMBUS_RING_SIZE() for ringbuffer sizes
For a Hyper-V vmbus, the size of the ringbuffer has two requirements: 1) it has to take one PAGE_SIZE for the header 2) it has to be PAGE_SIZE aligned so that double-mapping can work VMBUS_RING_SIZE() could calculate a correct ringbuffer size which fulfills both requirements, therefore use it to make sure vmbus work when PAGE_SIZE != HV_HYP_PAGE_SIZE (4K). Note that since the argument for VMBUS_RING_SIZE() is the size of payload (data part), so it will be minus 4k (the size of header when PAGE_SIZE = 4k) than the original value to keep the ringbuffer total size unchanged when PAGE_SIZE = 4k. Signed-off-by: Boqun Feng <boqun.feng@gmail.com> Cc: Michael Kelley <mikelley@microsoft.com> Reviewed-by: Michael Kelley <mikelley@microsoft.com> Link: https://lore.kernel.org/r/20200916034817.30282-11-boqun.feng@gmail.com Signed-off-by: Wei Liu <wei.liu@kernel.org>
1 parent d02a269 commit 061dc93

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

drivers/hv/hv_util.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,9 @@ static void heartbeat_onchannelcallback(void *context)
461461
}
462462
}
463463

464+
#define HV_UTIL_RING_SEND_SIZE VMBUS_RING_SIZE(3 * HV_HYP_PAGE_SIZE)
465+
#define HV_UTIL_RING_RECV_SIZE VMBUS_RING_SIZE(3 * HV_HYP_PAGE_SIZE)
466+
464467
static int util_probe(struct hv_device *dev,
465468
const struct hv_vmbus_device_id *dev_id)
466469
{
@@ -491,8 +494,8 @@ static int util_probe(struct hv_device *dev,
491494

492495
hv_set_drvdata(dev, srv);
493496

494-
ret = vmbus_open(dev->channel, 4 * HV_HYP_PAGE_SIZE,
495-
4 * HV_HYP_PAGE_SIZE, NULL, 0, srv->util_cb,
497+
ret = vmbus_open(dev->channel, HV_UTIL_RING_SEND_SIZE,
498+
HV_UTIL_RING_RECV_SIZE, NULL, 0, srv->util_cb,
496499
dev->channel);
497500
if (ret)
498501
goto error;
@@ -551,8 +554,8 @@ static int util_resume(struct hv_device *dev)
551554
return ret;
552555
}
553556

554-
ret = vmbus_open(dev->channel, 4 * HV_HYP_PAGE_SIZE,
555-
4 * HV_HYP_PAGE_SIZE, NULL, 0, srv->util_cb,
557+
ret = vmbus_open(dev->channel, HV_UTIL_RING_SEND_SIZE,
558+
HV_UTIL_RING_RECV_SIZE, NULL, 0, srv->util_cb,
556559
dev->channel);
557560
return ret;
558561
}

0 commit comments

Comments
 (0)