Module Name: src Committed By: martin Date: Wed May 13 12:39:20 UTC 2020
Modified Files: src/sys/arch/x86/pci [netbsd-8]: if_vmx.c Log Message: Pull up following revision(s) (requested by yamaguchi in ticket #1547): sys/arch/x86/pci/if_vmx.c: revision 1.60 Fix the wrong logic about making the number of vmx(4) TX/RX queue be power of two reviewed by nonaka@n.o. To generate a diff of this commit: cvs rdiff -u -r1.19.6.7 -r1.19.6.8 src/sys/arch/x86/pci/if_vmx.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/arch/x86/pci/if_vmx.c diff -u src/sys/arch/x86/pci/if_vmx.c:1.19.6.7 src/sys/arch/x86/pci/if_vmx.c:1.19.6.8 --- src/sys/arch/x86/pci/if_vmx.c:1.19.6.7 Thu Dec 26 20:23:39 2019 +++ src/sys/arch/x86/pci/if_vmx.c Wed May 13 12:39:20 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_vmx.c,v 1.19.6.7 2019/12/26 20:23:39 martin Exp $ */ +/* $NetBSD: if_vmx.c,v 1.19.6.8 2020/05/13 12:39:20 martin Exp $ */ /* $OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $ */ /* @@ -19,12 +19,13 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.19.6.7 2019/12/26 20:23:39 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.19.6.8 2020/05/13 12:39:20 martin Exp $"); #include <sys/param.h> #include <sys/cpu.h> #include <sys/kernel.h> #include <sys/kmem.h> +#include <sys/bitops.h> #include <sys/bus.h> #include <sys/device.h> #include <sys/mbuf.h> @@ -398,23 +399,11 @@ CFATTACH_DECL3_NEW(vmx, sizeof(struct vm static int vmxnet3_calc_queue_size(int n) { - int v, q; - v = n; - while (v != 0) { - if (powerof2(n) != 0) - break; - v /= 2; - q = rounddown2(n, v); - if (q != 0) { - n = q; - break; - } - } - if (n == 0) - n = 1; + if (__predict_false(n <= 0)) + return 1; - return n; + return (1U << (fls32(n) - 1)); } static inline void