Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-8]: src/sys/arch/x86/pci Pull up following revision(s) (requested...



details:   https://anonhg.NetBSD.org/src/rev/af5e998b3268
branches:  netbsd-8
changeset: 852314:af5e998b3268
user:      martin <martin%NetBSD.org@localhost>
date:      Thu Mar 21 14:27:02 2019 +0000

description:
Pull up following revision(s) (requested by nonaka in ticket #1219):

        sys/arch/x86/pci/if_vmx.c: revision 1.27
PR/54058: vmx(4): Fix device enable command failure when the number of vCPUs
is not a power of two.

Make the size of the vmx(4) TX/RX queue a power of two not exceeding
the number of vCPUs.

diffstat:

 sys/arch/x86/pci/if_vmx.c |  33 +++++++++++++++++++++++++++++----
 1 files changed, 29 insertions(+), 4 deletions(-)

diffs (61 lines):

diff -r 7d66bce4c779 -r af5e998b3268 sys/arch/x86/pci/if_vmx.c
--- a/sys/arch/x86/pci/if_vmx.c Tue Mar 19 13:43:42 2019 +0000
+++ b/sys/arch/x86/pci/if_vmx.c Thu Mar 21 14:27:02 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_vmx.c,v 1.19.6.4 2018/04/16 14:34:43 martin Exp $   */
+/*     $NetBSD: if_vmx.c,v 1.19.6.5 2019/03/21 14:27:02 martin Exp $   */
 /*     $OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $        */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.19.6.4 2018/04/16 14:34:43 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.19.6.5 2019/03/21 14:27:02 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -395,6 +395,29 @@
 CFATTACH_DECL3_NEW(vmx, sizeof(struct vmxnet3_softc),
     vmxnet3_match, vmxnet3_attach, vmxnet3_detach, NULL, NULL, NULL, 0);
 
+/* round down to the nearest power of 2 */
+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;
+
+       return n;
+}
+
 static inline void
 vmxnet3_write_bar0(struct vmxnet3_softc *sc, bus_size_t r, uint32_t v)
 {
@@ -520,8 +543,10 @@
        sc->vmx_mtx = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NET);
        callout_init(&sc->vmx_tick, CALLOUT_MPSAFE);
 
-       sc->vmx_max_ntxqueues = ncpu;
-       sc->vmx_max_nrxqueues = ncpu;
+       sc->vmx_max_ntxqueues =
+           vmxnet3_calc_queue_size(MIN(VMXNET3_MAX_TX_QUEUES, ncpu));
+       sc->vmx_max_nrxqueues =
+           vmxnet3_calc_queue_size(MIN(VMXNET3_MAX_RX_QUEUES, ncpu));
        sc->vmx_ntxdescs = 512;
        sc->vmx_nrxdescs = 256;
        sc->vmx_max_rxsegs = VMXNET3_MAX_RX_SEGS;



Home | Main Index | Thread Index | Old Index