Skip to contentSkip to conversation

fix wrong argument to pci_dma_sync_sg in megaraid driver

PATCH In review Christoph Hellwig 2 participants 2 messages Feb 1, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix wrong argument to pci_dma_sync_sg in megaraid driver

sgl is incremented for each element in the routine, but pci_dma_sync_sg needs the original buffer.

drivers/scsi/megaraid.c +1 -1
@@ -1805,7 +1805,7 @@
 	*len = (u32)cmd->request_bufflen;
 
 	if( scb->dma_direction == PCI_DMA_TODEVICE ) {
-		pci_dma_sync_sg(adapter->dev, sgl, cmd->use_sg,
+		pci_dma_sync_sg(adapter->dev, cmd->request_buffer, cmd->use_sg,
 				PCI_DMA_TODEVICE);
 	}
 
#1 lore raw
Quoted 7 lines · Christoph Hellwig

sgl is incremented for each element in the routine, but pci_dma_sync_sg needs the original buffer.

drivers/scsi/megaraid.c line 1810

Quoted 7 lines
drivers/scsi/megaraid.c +1 -1
@@ -1805,7 +1805,7 @@
 	*len = (u32)cmd->request_bufflen;
 
 	if( scb->dma_direction == PCI_DMA_TODEVICE ) {
-		pci_dma_sync_sg(adapter->dev, sgl, cmd->use_sg,
+		pci_dma_sync_sg(adapter->dev, cmd->request_buffer, cmd->use_sg,
 				PCI_DMA_TODEVICE);
 	}

Hang on a minute, none of these syncs (including all the other syncs to and from the device) looks to be necessary.

Once the buffers are mapped, their cache line ownership is transferred automatically to the device. Once they are unmapped, it is transferred back. There's no need to do additional syncs after mapping and unmapping *unless* the driver needs to touch the actual data in between the mapping and the unmapping. I didn't notice the megaraid actually doing this (but even if it does, the sync would be in the wrong place).

James