git: ee81cd1d8f55 - main - dpaa/qman: Fix various pool allocation bugs

From: Justin Hibbits <jhibbits_at_FreeBSD.org>
Date: Sat, 22 Aug 2026 16:04:55 UTC
The branch main has been updated by jhibbits:

URL: https://cgit.FreeBSD.org/src/commit/?id=ee81cd1d8f5596a6ab4c8eb29009405572cc162b

commit ee81cd1d8f5596a6ab4c8eb29009405572cc162b
Author:     Justin Hibbits <jhibbits@FreeBSD.org>
AuthorDate: 2026-08-13 14:50:06 +0000
Commit:     Justin Hibbits <jhibbits@FreeBSD.org>
CommitDate: 2026-08-22 16:04:38 +0000

    dpaa/qman: Fix various pool allocation bugs
    
    * Set qman_channel_base after determining if QMan is v3, otherwise this
      global stays at 0x21, which messes up the shift in
      qman_portal_static_dequeue_channel().
    * Fix the base shift in qman_portal_static_dequeue_channel(), there are
      only 15 channels available, not 16, so starting at a shift of 15
      yields shifting into the portal-specific channel.
    * Correct vmem pool names for QMan resource pools.
---
 sys/dev/dpaa/qman.c         | 6 +++---
 sys/dev/dpaa/qman_portals.c | 7 +++----
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/sys/dev/dpaa/qman.c b/sys/dev/dpaa/qman.c
index 6e16ae96257b..2cebae163dab 100644
--- a/sys/dev/dpaa/qman.c
+++ b/sys/dev/dpaa/qman.c
@@ -311,7 +311,6 @@ qman_attach(device_t dev)
 	 */
 	nfqd = fqd_sz / 64;
 	qman_total_fqids = nfqd;
-	qman_channel_base = qman_channel_pool1;
 	qman_fq_list = malloc(nfqd * sizeof(struct qman_fq *), M_QMAN,
 	    M_WAITOK);
 
@@ -340,15 +339,16 @@ qman_attach(device_t dev)
 
 	if (qman3)
 		qman_channel_pool1 = QMAN_CHANNEL_POOL1_REV3;
+	qman_channel_base = qman_channel_pool1;
 
 	sc->sc_qman_base_channel = qman_channel_pool1;
 
 	sc->sc_fqalloc =
 	    vmem_create("qman-fqalloc", 1, nfqd - 1, 1, 0, M_WAITOK);
 	sc->sc_qpalloc =
-	    vmem_create("qman-fqalloc", qman_channel_pool1,
+	    vmem_create("qman-qpalloc", qman_channel_pool1,
 	    QMAN_POOL_CHANNELS, 1, 0, M_WAITOK);
-	sc->sc_cgalloc = vmem_create("qman->cgalloc", 0, QMAN_CGRS,
+	sc->sc_cgalloc = vmem_create("qman-cgalloc", 0, QMAN_CGRS,
 	    1, 0, M_WAITOK);
 
 	if (bus_setup_intr(dev, sc->sc_ires, INTR_TYPE_NET, NULL, qman_isr,
diff --git a/sys/dev/dpaa/qman_portals.c b/sys/dev/dpaa/qman_portals.c
index 1b90951ee229..be271c24bf06 100644
--- a/sys/dev/dpaa/qman_portals.c
+++ b/sys/dev/dpaa/qman_portals.c
@@ -246,8 +246,7 @@ qman_dqrr_init(struct qman_portal_softc *sc)
 	/* Dequeue from the direct-connect channel and pool 0, up to 3 frames */
 	bus_write_4(regs, QCSP_DQRR_SDQCR,
 	    SDQCR_FC | SDQCR_DP | SDQCR_DCT_PRI_PREC |
-	    (DEF_SDQCR_TOKEN << SDQCR_TOKEN_S) |
-	    DQRR_DQ_SRC_DCP | SDQCR_DQ_SRC_CHAN(0));
+	    (DEF_SDQCR_TOKEN << SDQCR_TOKEN_S) | DQRR_DQ_SRC_DCP);
 	bus_write_4(regs, QCSP_DQRR_VDQCR, 0);
 	bus_write_4(regs, QCSP_DQRR_PDQCR, 0);
 
@@ -462,7 +461,7 @@ qman_portal_static_dequeue_channel(device_t dev, int channel)
 	uint32_t reg;
 
 	reg = bus_read_4(sc->sc_base.sc_mres[1], QCSP_DQRR_SDQCR);
-	reg |= (1 << (15 - (channel - qman_channel_base)));
+	reg |= (1 << (14 - (channel - qman_channel_base)));
 	bus_write_4(sc->sc_base.sc_mres[1], QCSP_DQRR_SDQCR, reg);
 }
 
@@ -473,7 +472,7 @@ qman_portal_static_dequeue_rm_channel(device_t dev, int channel)
 	uint32_t reg;
 
 	reg = bus_read_4(sc->sc_base.sc_mres[1], QCSP_DQRR_SDQCR);
-	reg &= ~(1 << (15 - (channel - qman_channel_base)));
+	reg &= ~(1 << (14 - (channel - qman_channel_base)));
 	bus_write_4(sc->sc_base.sc_mres[1], QCSP_DQRR_SDQCR, reg);
 }