Skip to content

Commit 8c6b808

Browse files
kawasakimartinkpetersen
authored andcommitted
scsi: mpi3mr: Avoid MAX_PAGE_ORDER WARNING for buffer allocations
Commit fc44449 ("scsi: mpi3mr: HDB allocation and posting for hardware and firmware buffers") added mpi3mr_alloc_diag_bufs() which calls dma_alloc_coherent() to allocate the trace buffer and the firmware buffer. mpi3mr_alloc_diag_bufs() decides the buffer sizes from the driver configuration. In my environment, the sizes are 8MB. With the sizes, dma_alloc_coherent() fails and report this WARNING: WARNING: CPU: 4 PID: 438 at mm/page_alloc.c:4676 __alloc_pages_noprof+0x52f/0x640 The WARNING indicates that the order of the allocation size is larger than MAX_PAGE_ORDER. After this failure, mpi3mr_alloc_diag_bufs() reduces the buffer sizes and retries dma_alloc_coherent(). In the end, the buffer allocations succeed with 4MB size in my environment, which corresponds to MAX_PAGE_ORDER=10. Though the allocations succeed, the WARNING message is misleading and should be avoided. To avoid the WARNING, check the orders of the buffer allocation sizes before calling dma_alloc_coherent(). If the orders are larger than MAX_PAGE_ORDER, fall back to the retry path. Fixes: fc44449 ("scsi: mpi3mr: HDB allocation and posting for hardware and firmware buffers") Signed-off-by: Shin'ichiro Kawasaki <[email protected]> Link: https://lore.kernel.org/r/[email protected] Acked-by: Sathya Prakash Veerichetty <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 6b9935d commit 8c6b808

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

drivers/scsi/mpi3mr/mpi3mr_app.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ void mpi3mr_alloc_diag_bufs(struct mpi3mr_ioc *mrioc)
100100
dprint_init(mrioc,
101101
"trying to allocate trace diag buffer of size = %dKB\n",
102102
trace_size / 1024);
103-
if (mpi3mr_alloc_trace_buffer(mrioc, trace_size)) {
103+
if (get_order(trace_size) > MAX_PAGE_ORDER ||
104+
mpi3mr_alloc_trace_buffer(mrioc, trace_size)) {
104105
retry = true;
105106
trace_size -= trace_dec_size;
106107
dprint_init(mrioc, "trace diag buffer allocation failed\n"
@@ -118,8 +119,12 @@ void mpi3mr_alloc_diag_bufs(struct mpi3mr_ioc *mrioc)
118119
diag_buffer->type = MPI3_DIAG_BUFFER_TYPE_FW;
119120
diag_buffer->status = MPI3MR_HDB_BUFSTATUS_NOT_ALLOCATED;
120121
if ((mrioc->facts.diag_fw_sz < fw_size) && (fw_size >= fw_min_size)) {
121-
diag_buffer->addr = dma_alloc_coherent(&mrioc->pdev->dev,
122-
fw_size, &diag_buffer->dma_addr, GFP_KERNEL);
122+
if (get_order(fw_size) <= MAX_PAGE_ORDER) {
123+
diag_buffer->addr
124+
= dma_alloc_coherent(&mrioc->pdev->dev, fw_size,
125+
&diag_buffer->dma_addr,
126+
GFP_KERNEL);
127+
}
123128
if (!retry)
124129
dprint_init(mrioc,
125130
"%s:trying to allocate firmware diag buffer of size = %dKB\n",

0 commit comments

Comments
 (0)