Skip to contentSkip to conversation

scsi: aha1542: Remove unneeded scsi_dma_unmap() call

PATCH Applied Matthew Whitehead 3 participants 4 messages Sep 29 – Oct 31 SCSI

lore
Share & tools
lore
#0 lore raw

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.

Fixes 2f2fef022c3e ("aha1542: use a local bounce buffer")
Assisted-by LLM
---
 drivers/scsi/aha1542.c | 2 --
 1 file changed, 2 deletions(-)
drivers/scsi/aha1542.c +0 -2
index fd766282d4a4..a197b3d0b26b 100644
@@ -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
Reviewed-by on v1 1/1
#1 lore raw
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() 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.

Fixes 2f2fef022c3e ("aha1542: use a local bounce buffer")
Assisted-by LLM

---
 drivers/scsi/aha1542.c | 2 --

 1 file changed, 2 deletions(-)
drivers/scsi/aha1542.c +0 -2
index fd766282d4a4..a197b3d0b26b 100644
@@ -271,8 +271,6 @@ static void aha1542_free_cmd(struct scsi_cmnd
 *cmd)
  			buf += bv.bv_len;
  		}
  	}
-
-	scsi_dma_unmap(cmd);
  }
Quoted 2 lines


 static irqreturn_t aha1542_interrupt(int irq, void *dev_id)

Looks correct to me, and was tested at Red Hat.

maintainer Applied
#2 lore raw
In reply to Matthew Whitehead

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() 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().

Applied to 7.4/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen
maintainer Applied
#3 lore raw
In reply to Matthew Whitehead
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() 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:

[...]

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