scsi: aha1542: Remove unneeded scsi_dma_unmap() call
PATCH 1/1 scsi: aha1542: Remove unneeded scsi_dma_unmap() call
aha1542 never DMA maps the command's scatterlist. Data is bounced through a per-command buffer allocated with dma_alloc_coherent() in aha1542_init_cmd_priv(), the adapter is programmed with acmd->data_buffer_handle, and the payload is copied to and from the request segments in aha1542_queuecommand() and aha1542_free_cmd().
The scsi_dma_unmap() call left in aha1542_free_cmd() therefore unmaps a scatterlist that was never mapped. With CONFIG_DMA_API_DEBUG enabled this results in:
device driver tries to free DMA memory it has not allocated
[device address=0x0000000000000000] [size=0 bytes]
Remove the call.
Verified by testing on real hardware.
--- drivers/scsi/aha1542.c | 2 -- 1 file changed, 2 deletions(-)
drivers/scsi/aha1542.c +0 -2
@@ -271,8 +271,6 @@ static void aha1542_free_cmd(struct scsi_cmnd *cmd) buf += bv.bv_len; } } - -scsi_dma_unmap (cmd); }static irqreturn_t aha1542_interrupt (int irq,void *dev_id)
Signature · 1 line
2.52.0
Quoted 38 lines · Matthew Whitehead
aha1542 never DMA maps the command's scatterlist. Data is bounced through a per-command buffer allocated with
dma_alloc_coherent()inaha1542_init_cmd_priv(), the adapter is programmed withacmd->data_buffer_handle, and the payload is copied to and from the request segments inaha1542_queuecommand()andaha1542_free_cmd().The
scsi_dma_unmap()call left inaha1542_free_cmd()therefore unmaps a scatterlist that was never mapped. WithCONFIG_DMA_API_DEBUGenabled
this results in:device driver tries to free DMA memory it has not allocated [device address=0x0000000000000000] [size=0 bytes]
Remove the call.
Verified by testing on real hardware.
Fixes 2f2fef022c3e ("aha1542: use a local bounce buffer")Suggested-by Laurence Oberman <[email protected]>Assisted-by LLMSigned-off-by Matthew Whitehead <[email protected]>---
drivers/scsi/aha1542.c | 2 --1 file changed, 2 deletions(-)drivers/scsi/aha1542.c +0
-2@@ -271,8 +271,6 @@ static void aha1542_free_cmd(struct scsi_cmnd *cmd) buf += bv.bv_len; } } - -scsi_dma_unmap (cmd); }
Quoted 2 lines
staticirqreturn_taha1542_interrupt(int irq, void *dev_id)
Looks correct to me, and was tested at Red Hat.
Matthew,
Quoted 5 lines
aha1542 never DMA maps the command's scatterlist. Data is bounced through a per-command buffer allocated with
dma_alloc_coherent()inaha1542_init_cmd_priv(), the adapter is programmed withacmd->data_buffer_handle, and the payload is copied to and from the request segments inaha1542_queuecommand()andaha1542_free_cmd().
Applied to 7.4/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen
Quoted 11 lines · Matthew Whitehead
aha1542 never DMA maps the command's scatterlist. Data is bounced through a per-command buffer allocated with
dma_alloc_coherent()inaha1542_init_cmd_priv(), the adapter is programmed withacmd->data_buffer_handle, and the payload is copied to and from the request segments inaha1542_queuecommand()andaha1542_free_cmd().The
scsi_dma_unmap()call left inaha1542_free_cmd()therefore unmaps a scatterlist that was never mapped. WithCONFIG_DMA_API_DEBUGenabled this results in:[...]
Applied to 7.4/scsi-queue, thanks!
[1/1] scsi: aha1542: Remove unneeded scsi_dma_unmap() call
https://git.kernel.org/mkp/scsi/c/9ec6671b137d
Signature · 1 line
Martin K. Petersen