[Bug 259541] [smartpqi] panic: Segment size is not aligned, in a call to bus_dmamap_load_ccb() from smartpqi_cam_action.

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 30 Oct 2021 02:33:55 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=259541

            Bug ID: 259541
           Summary: [smartpqi] panic: Segment size is not aligned, in a
                    call to bus_dmamap_load_ccb() from
                    smartpqi_cam_action.
           Product: Base System
           Version: Unspecified
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: khng@freebsd.org

The following is a stack trace and ddb(4) show pcpu output:
----
db> show pcpu
cpuid        = 151
dynamic pcpu = 0xfffffe020877ca40
curthread    = 0xfffffe019120a1e0: pid 571 tid 106262 critnest 1 "fsck_msdosfs"
curpcb       = 0xfffffe019120a6f0
fpcurthread  = 0xfffffe019120a1e0: pid 571 "fsck_msdosfs"
idlethread   = 0xfffffe01a0eb9900: tid 100154 "idle: cpu151"
self         = 0xffffffff82ea7000
curpmap      = 0xfffffe019120f518
tssp         = 0xffffffff82ea7384
rsp0         = 0xfffffe03dda97000
kcr3         = 0xffffffffffffffff
ucr3         = 0xffffffffffffffff
scr3         = 0x0
gs32p        = 0xffffffff82ea7404
ldt          = 0xffffffff82ea7444
tss          = 0xffffffff82ea7434
curvnet      = 0
spin locks held:
db> bt
Tracing pid 571 tid 106262 td 0xfffffe019120a1e0
kdb_enter() at kdb_enter+0x37/frame 0xfffffe03dda966d0
vpanic() at vpanic+0x1b8/frame 0xfffffe03dda96730
panic() at panic+0x43/frame 0xfffffe03dda96790
bounce_bus_dmamap_load_ma() at bounce_bus_dmamap_load_ma+0x3a9/frame
0xfffffe03dda96810
_bus_dmamap_load_bio() at _bus_dmamap_load_bio+0x113/frame 0xfffffe03dda96870
bus_dmamap_load_ccb() at bus_dmamap_load_ccb+0x92/frame 0xfffffe03dda968d0
smartpqi_cam_action() at smartpqi_cam_action+0xdb9/frame 0xfffffe03dda96940
xpt_run_devq() at xpt_run_devq+0x2f9/frame 0xfffffe03dda969a0
xpt_action_default() at xpt_action_default+0x471/frame 0xfffffe03dda969f0
dastart() at dastart+0x336/frame 0xfffffe03dda96a40
xpt_run_allocq() at xpt_run_allocq+0xb3/frame 0xfffffe03dda96a90
dastrategy() at dastrategy+0x6f/frame 0xfffffe03dda96ac0
g_disk_start() at g_disk_start+0x31c/frame 0xfffffe03dda96b30
g_io_request() at g_io_request+0x2d7/frame 0xfffffe03dda96b60
g_part_start() at g_part_start+0x289/frame 0xfffffe03dda96be0
g_io_request() at g_io_request+0x2d7/frame 0xfffffe03dda96c10
g_dev_strategy() at g_dev_strategy+0x155/frame 0xfffffe03dda96c40
physio() at physio+0x49b/frame 0xfffffe03dda96ce0
devfs_read_f() at devfs_read_f+0xe5/frame 0xfffffe03dda96d40
dofileread() at dofileread+0x81/frame 0xfffffe03dda96d90
sys_read() at sys_read+0xc0/frame 0xfffffe03dda96e00
amd64_syscall() at amd64_syscall+0x12e/frame 0xfffffe03dda96f30
fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe03dda96f30
--- syscall (3, FreeBSD ELF64, sys_read), rip = 0x8011c4cca, rsp =
0x7fffffffdac8, rbp = 0x7fffffffdb00 ---
db>
----

I git-bisected and found the offending commits to be
9fac68fc3853b696c8479bb3a8181d62cb9f59c9 in main, and
1569aab1cb38a38fb619f343ed1e47d4b4070ffe in stable/13. The following changes in
the commits look suspicious in my eye:
----
@@ -313,27 +347,31 @@ smartpqi_attach(device_t dev)
...
-
-        /*
-         * Create DMA tag for mapping buffers into controller-addressable
space.
-         */
-        if (bus_dma_tag_create(softs->os_specific.pqi_parent_dmat,/* parent */
-                               1, 0,                   /* algnmnt, boundary */
+    /*
+     * Create DMA tag for mapping buffers into controller-addressable space.
+     */
+    if (bus_dma_tag_create(softs->os_specific.pqi_parent_dmat,/* parent */
+                               PAGE_SIZE, 0,           /* algnmnt, boundary */
                                BUS_SPACE_MAXADDR_32BIT,/* lowaddr */
                                BUS_SPACE_MAXADDR,      /* highaddr */
                                NULL, NULL,             /* filter, filterarg */
-                              
softs->pqi_cap.max_sg_elem*PAGE_SIZE,/*maxsize*/
+                              
(bus_size_t)softs->pqi_cap.max_sg_elem*PAGE_SIZE,/* maxsize */
                                softs->pqi_cap.max_sg_elem,     /* nsegments */
                                BUS_SPACE_MAXSIZE_32BIT,        /* maxsegsize
*/
                                BUS_DMA_ALLOCNOW,               /* flags */
----

Reverting the change on algnmnt param worked around the issue.

-- 
You are receiving this mail because:
You are the assignee for the bug.