Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci mcx(4): ensure that RQT size is always a power o...



details:   https://anonhg.NetBSD.org/src/rev/bb239b07b5d7
branches:  trunk
changeset: 1024802:bb239b07b5d7
user:      andvar <andvar%NetBSD.org@localhost>
date:      Fri Nov 05 23:39:47 2021 +0000

description:
mcx(4): ensure that RQT size is always a power of two.
Fixes PR kern/56484.
Thanks riastradh for the power of two patch :). OK: mrg, jmcneill, riastradh.

diffstat:

 sys/dev/pci/if_mcx.c |  7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diffs (35 lines):

diff -r fa78624e9886 -r bb239b07b5d7 sys/dev/pci/if_mcx.c
--- a/sys/dev/pci/if_mcx.c      Fri Nov 05 22:39:35 2021 +0000
+++ b/sys/dev/pci/if_mcx.c      Fri Nov 05 23:39:47 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_mcx.c,v 1.22 2021/09/26 20:14:07 jmcneill Exp $ */
+/*     $NetBSD: if_mcx.c,v 1.23 2021/11/05 23:39:47 andvar Exp $ */
 /*     $OpenBSD: if_mcx.c,v 1.101 2021/06/02 19:16:11 patrick Exp $ */
 
 /*
@@ -23,7 +23,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_mcx.c,v 1.22 2021/09/26 20:14:07 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mcx.c,v 1.23 2021/11/05 23:39:47 andvar Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -43,6 +43,7 @@
 #include <sys/interrupt.h>
 #include <sys/pcq.h>
 #include <sys/cpu.h>
+#include <sys/bitops.h>
 
 #include <machine/intr.h>
 
@@ -2956,6 +2957,8 @@
 
        sc->sc_nqueues = uimin(MCX_MAX_QUEUES, msix);
        sc->sc_nqueues = uimin(sc->sc_nqueues, ncpu);
+       /* Round down to a power of two.  */
+       sc->sc_nqueues = 1U << ilog2(sc->sc_nqueues);
        sc->sc_queues = kmem_zalloc(sc->sc_nqueues * sizeof(*sc->sc_queues),
            KM_SLEEP);
 



Home | Main Index | Thread Index | Old Index