* [PATCH RESEND 1/2] scsi: vmw_pvscsi: Fix swiotlb operation
@ 2019-12-03 19:30 Thomas Hellström (VMware)
2019-12-03 19:30 ` [PATCH RESEND 2/2] scsi: vmw_pvscsi: Silence dma mapping errors Thomas Hellström (VMware)
2019-12-20 3:44 ` [PATCH RESEND 1/2] scsi: vmw_pvscsi: Fix swiotlb operation Martin K. Petersen
0 siblings, 2 replies; 4+ messages in thread
From: Thomas Hellström (VMware) @ 2019-12-03 19:30 UTC (permalink / raw)
To: linux-scsi, linux-kernel, pv-drivers
Cc: Thomas Hellstrom, James E.J. Bottomley, Martin K. Petersen,
Vishal Bhakta, Jim Gill
From: Thomas Hellstrom <thellstrom@vmware.com>
With swiotlb, the first byte of the sense buffer may in some cases be
uninitialized since we use DMA_FROM_DEVICE, and the device incorrectly
doesn't clear it. In those cases, clear it after DMA unmapping.
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Suggested-by: Vishal Bhakta <vbhakta@vmware.com>
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Acked-by: Jim Gill <jgill@vmware.com>
---
drivers/scsi/vmw_pvscsi.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c
index 70008816c91f..8a09d184a320 100644
--- a/drivers/scsi/vmw_pvscsi.c
+++ b/drivers/scsi/vmw_pvscsi.c
@@ -402,6 +402,17 @@ static int pvscsi_map_buffers(struct pvscsi_adapter *adapter,
return 0;
}
+/*
+ * The device incorrectly doesn't clear the first byte of the sense
+ * buffer in some cases. We have to do it ourselves.
+ * Otherwise we run into trouble when SWIOTLB is forced.
+ */
+static void pvscsi_patch_sense(struct scsi_cmnd *cmd)
+{
+ if (cmd->sense_buffer)
+ cmd->sense_buffer[0] = 0;
+}
+
static void pvscsi_unmap_buffers(const struct pvscsi_adapter *adapter,
struct pvscsi_ctx *ctx)
{
@@ -544,6 +555,8 @@ static void pvscsi_complete_request(struct pvscsi_adapter *adapter,
cmd = ctx->cmd;
abort_cmp = ctx->abort_cmp;
pvscsi_unmap_buffers(adapter, ctx);
+ if (sdstat != SAM_STAT_CHECK_CONDITION)
+ pvscsi_patch_sense(cmd);
pvscsi_release_context(adapter, ctx);
if (abort_cmp) {
/*
@@ -873,6 +886,7 @@ static void pvscsi_reset_all(struct pvscsi_adapter *adapter)
scmd_printk(KERN_ERR, cmd,
"Forced reset on cmd %p\n", cmd);
pvscsi_unmap_buffers(adapter, ctx);
+ pvscsi_patch_sense(cmd);
pvscsi_release_context(adapter, ctx);
cmd->result = (DID_RESET << 16);
cmd->scsi_done(cmd);
--
2.21.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH RESEND 2/2] scsi: vmw_pvscsi: Silence dma mapping errors
2019-12-03 19:30 [PATCH RESEND 1/2] scsi: vmw_pvscsi: Fix swiotlb operation Thomas Hellström (VMware)
@ 2019-12-03 19:30 ` Thomas Hellström (VMware)
2019-12-20 3:44 ` [PATCH RESEND 1/2] scsi: vmw_pvscsi: Fix swiotlb operation Martin K. Petersen
1 sibling, 0 replies; 4+ messages in thread
From: Thomas Hellström (VMware) @ 2019-12-03 19:30 UTC (permalink / raw)
To: linux-scsi, linux-kernel, pv-drivers
Cc: Thomas Hellstrom, James E.J. Bottomley, Martin K. Petersen, Jim Gill
From: Thomas Hellstrom <thellstrom@vmware.com>
These errors typically occur with swiotlb when the swiotlb buffer is full.
But they are transient and would typically unnecessarily worry a user.
Instead of errors, print debug messages.
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Acked-by: Jim Gill <jgill@vmware.com>
---
drivers/scsi/vmw_pvscsi.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c
index 8a09d184a320..c3f010df641e 100644
--- a/drivers/scsi/vmw_pvscsi.c
+++ b/drivers/scsi/vmw_pvscsi.c
@@ -365,7 +365,7 @@ static int pvscsi_map_buffers(struct pvscsi_adapter *adapter,
int segs = scsi_dma_map(cmd);
if (segs == -ENOMEM) {
- scmd_printk(KERN_ERR, cmd,
+ scmd_printk(KERN_DEBUG, cmd,
"vmw_pvscsi: Failed to map cmd sglist for DMA.\n");
return -ENOMEM;
} else if (segs > 1) {
@@ -392,7 +392,7 @@ static int pvscsi_map_buffers(struct pvscsi_adapter *adapter,
ctx->dataPA = dma_map_single(&adapter->dev->dev, sg, bufflen,
cmd->sc_data_direction);
if (dma_mapping_error(&adapter->dev->dev, ctx->dataPA)) {
- scmd_printk(KERN_ERR, cmd,
+ scmd_printk(KERN_DEBUG, cmd,
"vmw_pvscsi: Failed to map direct data buffer for DMA.\n");
return -ENOMEM;
}
@@ -725,7 +725,7 @@ static int pvscsi_queue_ring(struct pvscsi_adapter *adapter,
cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE,
DMA_FROM_DEVICE);
if (dma_mapping_error(&adapter->dev->dev, ctx->sensePA)) {
- scmd_printk(KERN_ERR, cmd,
+ scmd_printk(KERN_DEBUG, cmd,
"vmw_pvscsi: Failed to map sense buffer for DMA.\n");
ctx->sensePA = 0;
return -ENOMEM;
--
2.21.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH RESEND 1/2] scsi: vmw_pvscsi: Fix swiotlb operation
2019-12-03 19:30 [PATCH RESEND 1/2] scsi: vmw_pvscsi: Fix swiotlb operation Thomas Hellström (VMware)
2019-12-03 19:30 ` [PATCH RESEND 2/2] scsi: vmw_pvscsi: Silence dma mapping errors Thomas Hellström (VMware)
@ 2019-12-20 3:44 ` Martin K. Petersen
2019-12-20 8:56 ` Thomas Hellstrom
1 sibling, 1 reply; 4+ messages in thread
From: Martin K. Petersen @ 2019-12-20 3:44 UTC (permalink / raw)
To: Thomas Hellström (VMware)
Cc: linux-scsi, linux-kernel, pv-drivers, Thomas Hellstrom,
James E.J. Bottomley, Martin K. Petersen, Vishal Bhakta,
Jim Gill
Thomas,
> With swiotlb, the first byte of the sense buffer may in some cases be
> uninitialized since we use DMA_FROM_DEVICE, and the device incorrectly
> doesn't clear it. In those cases, clear it after DMA unmapping.
Applied 1+2 to 5.6/scsi-queue, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RESEND 1/2] scsi: vmw_pvscsi: Fix swiotlb operation
2019-12-20 3:44 ` [PATCH RESEND 1/2] scsi: vmw_pvscsi: Fix swiotlb operation Martin K. Petersen
@ 2019-12-20 8:56 ` Thomas Hellstrom
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Hellstrom @ 2019-12-20 8:56 UTC (permalink / raw)
To: Martin K. Petersen, Thomas Hellström (VMware)
Cc: linux-scsi, linux-kernel, Pv-drivers, James E.J. Bottomley,
Vishal Bhakta, Jim Gill
On 12/20/19 4:44 AM, Martin K. Petersen wrote:
> Thomas,
>
>> With swiotlb, the first byte of the sense buffer may in some cases be
>> uninitialized since we use DMA_FROM_DEVICE, and the device incorrectly
>> doesn't clear it. In those cases, clear it after DMA unmapping.
> Applied 1+2 to 5.6/scsi-queue, thanks!
>
Thanks!
Thomas
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-12-20 8:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-03 19:30 [PATCH RESEND 1/2] scsi: vmw_pvscsi: Fix swiotlb operation Thomas Hellström (VMware)
2019-12-03 19:30 ` [PATCH RESEND 2/2] scsi: vmw_pvscsi: Silence dma mapping errors Thomas Hellström (VMware)
2019-12-20 3:44 ` [PATCH RESEND 1/2] scsi: vmw_pvscsi: Fix swiotlb operation Martin K. Petersen
2019-12-20 8:56 ` Thomas Hellstrom
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).