Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Feb 2025 17:27:24 GMT
From:      Justin Hibbits <jhibbits@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 80ec95226e17 - main - busdma: Always initialize bounce page STAILQ
Message-ID:  <202502091727.519HROao014448@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by jhibbits:

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

commit 80ec95226e170d36071b0542ade8fbcf417e7aa5
Author:     Shawn Anastasio <sanastasio@raptorengineering.com>
AuthorDate: 2025-02-09 17:27:07 +0000
Commit:     Justin Hibbits <jhibbits@FreeBSD.org>
CommitDate: 2025-02-09 17:29:56 +0000

    busdma: Always initialize bounce page STAILQ
    
    Summary:
        Always call STAILQ_INIT in bus_dmamap_create regardless of whether
        BUS_DMA_COULD_BOUNCE is set. This avoids tripping the assertions added
        by commit 34740937f7a4 when the queue is checked with STAILQ_EMPTY in
        free_bounce_pages.
    
    Test Plan:
    Without this patch applied, booting fails as follows (pseries guest on Linux/ppc64le KVM host):
    
    vtblk0: <VirtIO Block Adapter> numa-domain 0 on virtio_pci1
    panic: Empty stailq 0x8ed4480->stqh_last is 0, not head's first field address
    cpuid = 0
    time = 1
    KDB: stack backtrace:
    0xc00800000000bcc0: at kdb_backtrace+0x60
    0xc00800000000bdd0: at vpanic+0x1d4
    0xc00800000000be80: at panic+0x44
    0xc00800000000beb0: at bus_dmamap_unload+0x394
    0xc00800000000bf60: at vtblk_poll_request+0x16c
    0xc00800000000bff0: at vtblk_attach_completed+0x208
    0xc00800000000c220: at vtpci_legacy_probe_and_attach_child+0x224
    0xc00800000000c270: at vtpci_legacy_attach+0x2c0
    0xc00800000000c320: at device_attach+0x568
    0xc00800000000c400: at bus_attach_children+0x8c
    0xc00800000000c440: at ofw_pcibus_attach+0x398
    0xc00800000000c550: at device_attach+0x568
    0xc00800000000c630: at bus_attach_children+0x8c
    0xc00800000000c670: at ofw_pcib_attach+0x68
    0xc00800000000c6a0: at rtaspci_attach+0x18c
    0xc00800000000c6f0: at device_attach+0x568
    0xc00800000000c7d0: at bus_generic_new_pass+0x198
    0xc00800000000c820: at bus_generic_new_pass+0x10c
    0xc00800000000c870: at bus_generic_new_pass+0x10c
    0xc00800000000c8c0: at root_bus_configure+0x6c
    0xc00800000000c910: at configure+0x1c
    0xc00800000000c940: at mi_startup+0x298
    0xc00800000000ca50: at __start+0xfc
    KDB: enter: panic
    [ thread pid 0 tid 100000 ]
    Stopped at      kdb_enter+0x70: ori     r0, r0, 0x0
    
    With the patch applied to properly initialize the STAILQ unconditionally, the assertion is no longer hit and the system boots as expected.
    
    Reviewers: jhibbits, jhb, #powerpc, markj
    
    Reviewed By: jhibbits, jhb, #powerpc, markj
    
    Subscribers: imp, bdragon, luporl, alfredo, #powerpc
    
    Tags: #powerpc
    
    Differential Revision: https://reviews.freebsd.org/D48600
---
 sys/powerpc/powerpc/busdma_machdep.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sys/powerpc/powerpc/busdma_machdep.c b/sys/powerpc/powerpc/busdma_machdep.c
index 34dcea8de9ee..65f90aa4affa 100644
--- a/sys/powerpc/powerpc/busdma_machdep.c
+++ b/sys/powerpc/powerpc/busdma_machdep.c
@@ -303,6 +303,9 @@ bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp)
 		return (ENOMEM);
 	}
 
+	/* Initialize the new map */
+	STAILQ_INIT(&((*mapp)->bpages));
+
 	/*
 	 * Bouncing might be required if the driver asks for an active
 	 * exclusion region, a data alignment that is stricter than 1, and/or
@@ -319,9 +322,6 @@ bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp)
 		}
 		bz = dmat->bounce_zone;
 
-		/* Initialize the new map */
-		STAILQ_INIT(&((*mapp)->bpages));
-
 		/*
 		 * Attempt to add pages to our pool on a per-instance
 		 * basis up to a sane limit.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202502091727.519HROao014448>