Module Name: src Committed By: nonaka Date: Mon May 25 10:14:58 UTC 2020
Modified Files: src/sys/dev/hyperv: hvs.c vmbus.c Log Message: Use howmany() macro. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/hyperv/hvs.c cvs rdiff -u -r1.8 -r1.9 src/sys/dev/hyperv/vmbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/hyperv/hvs.c diff -u src/sys/dev/hyperv/hvs.c:1.3 src/sys/dev/hyperv/hvs.c:1.4 --- src/sys/dev/hyperv/hvs.c:1.3 Mon Nov 25 08:53:39 2019 +++ src/sys/dev/hyperv/hvs.c Mon May 25 10:14:58 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: hvs.c,v 1.3 2019/11/25 08:53:39 nonaka Exp $ */ +/* $NetBSD: hvs.c,v 1.4 2020/05/25 10:14:58 nonaka Exp $ */ /* $OpenBSD: hvs.c,v 1.17 2017/08/10 17:22:48 mikeb Exp $ */ /*- @@ -37,7 +37,7 @@ /* #define HVS_DEBUG_IO */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: hvs.c,v 1.3 2019/11/25 08:53:39 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hvs.c,v 1.4 2020/05/25 10:14:58 nonaka Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -180,7 +180,7 @@ union hvs_cmd { #define HVS_RING_SIZE (20 * PAGE_SIZE) #define HVS_MAX_CCB 128 -#define HVS_MAX_SGE (MAXPHYS / PAGE_SIZE + 1) +#define HVS_MAX_SGE (howmany(MAXPHYS, PAGE_SIZE) + 1) struct hvs_softc; Index: src/sys/dev/hyperv/vmbus.c diff -u src/sys/dev/hyperv/vmbus.c:1.8 src/sys/dev/hyperv/vmbus.c:1.9 --- src/sys/dev/hyperv/vmbus.c:1.8 Tue Dec 10 12:20:20 2019 +++ src/sys/dev/hyperv/vmbus.c Mon May 25 10:14:58 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vmbus.c,v 1.8 2019/12/10 12:20:20 nonaka Exp $ */ +/* $NetBSD: vmbus.c,v 1.9 2020/05/25 10:14:58 nonaka Exp $ */ /* $OpenBSD: hyperv.c,v 1.43 2017/06/27 13:56:15 mikeb Exp $ */ /*- @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.8 2019/12/10 12:20:20 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.9 2020/05/25 10:14:58 nonaka Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -1911,7 +1911,7 @@ vmbus_handle_alloc(struct vmbus_channel /* Allocate additional gpadl_body structures if required */ if (left > 0) { - ncmds = MAX(1, left / VMBUS_NPFNBODY + left % VMBUS_NPFNBODY); + ncmds = howmany(left, VMBUS_NPFNBODY); bodylen = ncmds * VMBUS_MSG_DSIZE_MAX; body = kmem_zalloc(bodylen, kmemflags); if (body == NULL) {