diff mbox series

[3/3,for-next] pvscsi: Fix uninitialized sense buffer with swiotlb

Message ID 20200812205615.GA18423@petr-dev3.eng.vmware.com (mailing list archive)
State Changes Requested
Headers show
Series [1/3,for-next] pvscsi: Use coherent memory instead of dma mapping sg lists | expand

Commit Message

Jim Gill Aug. 12, 2020, 8:56 p.m. UTC
It seems like the device sometimes leaves part of the
 sense buffer uninitialized. This causes massive problems with swiotlb where
 any previous initialization of the sense buffer by the scsi middle-layer is
 not propagated to the device since we use DMA_FROM_DEVICE when dma-mapping
 the sense buffer. Fix this by specifying DMA_BIDIRECTIONAL instead. Makes the
 scsi errors go away.

Tested using a bonnie++ run on an swiotlb=force booted kernel.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
[jgill@vmware.com: Forwarding patch on behalf of thellstrom]
Acked-by: jgill@vmware.com
---
 drivers/scsi/vmw_pvscsi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c
index fa2748f..c179a5d 100644
--- a/drivers/scsi/vmw_pvscsi.c
+++ b/drivers/scsi/vmw_pvscsi.c
@@ -429,7 +429,7 @@  static void pvscsi_unmap_buffers(const struct pvscsi_adapter *adapter,
 	}
 	if (cmd->sense_buffer)
 		dma_unmap_single(&adapter->dev->dev, ctx->sensePA,
-				 SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
+				 SCSI_SENSE_BUFFERSIZE, DMA_BIDIRECTIONAL);
 }
 
 static int pvscsi_allocate_rings(struct pvscsi_adapter *adapter)
@@ -714,7 +714,7 @@  static int pvscsi_queue_ring(struct pvscsi_adapter *adapter,
 	if (cmd->sense_buffer) {
 		ctx->sensePA = dma_map_single(&adapter->dev->dev,
 				cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE,
-				DMA_FROM_DEVICE);
+				DMA_BIDIRECTIONAL);
 		if (dma_mapping_error(&adapter->dev->dev, ctx->sensePA)) {
 			scmd_printk(KERN_DEBUG, cmd,
 				    "vmw_pvscsi: Failed to map sense buffer for DMA.\n");
@@ -746,7 +746,7 @@  static int pvscsi_queue_ring(struct pvscsi_adapter *adapter,
 		if (cmd->sense_buffer) {
 			dma_unmap_single(&adapter->dev->dev, ctx->sensePA,
 					 SCSI_SENSE_BUFFERSIZE,
-					 DMA_FROM_DEVICE);
+					 DMA_BIDIRECTIONAL);
 			ctx->sensePA = 0;
 		}
 		return -ENOMEM;