RE: [Pv-drivers] [PATCH] VMW_PVSCSI: Fix the issue of DMA-API related warnings.
Hi James, Can you help get this patch in now as it has got a review? Thanks! Arvind From: Thomas Hellstrom Sent: Thursday, June 11, 2015 11:11 AM To: Josh Boyer; Arvind Kumar; James Bottomley Cc: VMware PV-Drivers; Linus Torvalds; linux-scsi@vger.kernel.org Subject: Re: [Pv-drivers] [PATCH] VMW_PVSCSI: Fix the issue of DMA-API related warnings. On 06/11/2015 02:32 PM, Josh Boyer wrote: > On Fri, Mar 21, 2014 at 2:08 PM, Arvind Kumar wrote: >> The driver is missing calls to pci_dma_mapping_error() after >> performing the DMA mapping, which caused DMA-API warning to >> show up in dmesg's output. Though that happens only when >> DMA_API_DEBUG option is enabled. This change fixes the issue >> and makes pvscsi_map_buffers() function more robust. >> >> Signed-off-by: Arvind Kumar >> Cc: Josh Boyer > This patch has been sent and pinged for 3 months now. It's gotten no > comments at all. Should we send it to Linus so it actually gets > picked up? > > josh Reviewed-by: Thomas Hellstrom > >> --- >> drivers/scsi/vmw_pvscsi.c | 45 >> +++-- >> drivers/scsi/vmw_pvscsi.h |2 +- >> 2 files changed, 40 insertions(+), 7 deletions(-) >> >> diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c >> index c88e146..9478a00 100644 >> --- a/drivers/scsi/vmw_pvscsi.c >> +++ b/drivers/scsi/vmw_pvscsi.c >> @@ -349,9 +349,9 @@ static void pvscsi_create_sg(struct pvscsi_ctx *ctx, >> * Map all data buffers for a command into PCI space and >> * setup the scatter/gather list if needed. >> */ >> -static void pvscsi_map_buffers(struct pvscsi_adapter *adapter, >> - struct pvscsi_ctx *ctx, struct scsi_cmnd *cmd, >> - struct PVSCSIRingReqDesc *e) >> +static int pvscsi_map_buffers(struct pvscsi_adapter *adapter, >> + struct pvscsi_ctx *ctx, struct scsi_cmnd *cmd, >> + struct PVSCSIRingReqDesc *e) >> { >> unsigned count; >> unsigned bufflen = scsi_bufflen(cmd); >> @@ -360,18 +360,30 @@ static void pvscsi_map_buffers(struct pvscsi_adapter >> *adapter, >> e->dataLen = bufflen; >> e->dataAddr = 0; >> if (bufflen == 0) >> - return; >> + return 0; >> >> sg = scsi_sglist(cmd); >> count = scsi_sg_count(cmd); >> if (count != 0) { >> int segs = scsi_dma_map(cmd); >> - if (segs > 1) { >> + >> + if (segs == -ENOMEM) { >> + scmd_printk(KERN_ERR, cmd, >> + "vmw_pvscsi: Failed to map cmd sglist >> for DMA.\n"); >> + return -1; >> + } else if (segs > 1) { >> pvscsi_create_sg(ctx, sg, segs); >> >> e->flags |= PVSCSI_FLAG_CMD_WITH_SG_LIST; >> ctx->sglPA = pci_map_single(adapter->dev, ctx->sgl, >> SGL_SIZE, >> PCI_DMA_TODEVICE); >> + if (pci_dma_mapping_error(adapter->dev, ctx->sglPA)) >> { >> + scmd_printk(KERN_ERR, cmd, >> + "vmw_pvscsi: Failed to map ctx >> sglist for DMA.\n"); >> + scsi_dma_unmap(cmd); >> + ctx->sglPA = 0; >> + return -1; >> + } >> e->dataAddr = ctx->sglPA; >> } else >> e->dataAddr = sg_dma_address(sg); >> @@ -382,8 +394,15 @@ static void pvscsi_map_buffers(struct pvscsi_adapter >> *adapter, >> */ >> ctx->dataPA = pci_map_single(adapter->dev, sg, bufflen, >> cmd->sc_data_direction); >> + if (pci_dma_mapping_error(adapter->dev, ctx->dataPA)) { >> + scmd_printk(KERN_ERR, cmd, >> + "vmw_pvscsi: Failed to map direct data >> buffer for DMA.\n"); >> + return -1; >> + } >> e->dataAddr = ctx->dataPA; >> } >> + >> + return 0; >> } >> >> static void
Re: [Pv-drivers] [PATCH] VMW_PVSCSI: Fix the issue of DMA-API related warnings.
On 06/11/2015 02:32 PM, Josh Boyer wrote: > On Fri, Mar 21, 2014 at 2:08 PM, Arvind Kumar wrote: >> The driver is missing calls to pci_dma_mapping_error() after >> performing the DMA mapping, which caused DMA-API warning to >> show up in dmesg's output. Though that happens only when >> DMA_API_DEBUG option is enabled. This change fixes the issue >> and makes pvscsi_map_buffers() function more robust. >> >> Signed-off-by: Arvind Kumar >> Cc: Josh Boyer > This patch has been sent and pinged for 3 months now. It's gotten no > comments at all. Should we send it to Linus so it actually gets > picked up? > > josh Reviewed-by: Thomas Hellstrom > >> --- >> drivers/scsi/vmw_pvscsi.c | 45 >> +++-- >> drivers/scsi/vmw_pvscsi.h |2 +- >> 2 files changed, 40 insertions(+), 7 deletions(-) >> >> diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c >> index c88e146..9478a00 100644 >> --- a/drivers/scsi/vmw_pvscsi.c >> +++ b/drivers/scsi/vmw_pvscsi.c >> @@ -349,9 +349,9 @@ static void pvscsi_create_sg(struct pvscsi_ctx *ctx, >> * Map all data buffers for a command into PCI space and >> * setup the scatter/gather list if needed. >> */ >> -static void pvscsi_map_buffers(struct pvscsi_adapter *adapter, >> - struct pvscsi_ctx *ctx, struct scsi_cmnd *cmd, >> - struct PVSCSIRingReqDesc *e) >> +static int pvscsi_map_buffers(struct pvscsi_adapter *adapter, >> + struct pvscsi_ctx *ctx, struct scsi_cmnd *cmd, >> + struct PVSCSIRingReqDesc *e) >> { >> unsigned count; >> unsigned bufflen = scsi_bufflen(cmd); >> @@ -360,18 +360,30 @@ static void pvscsi_map_buffers(struct pvscsi_adapter >> *adapter, >> e->dataLen = bufflen; >> e->dataAddr = 0; >> if (bufflen == 0) >> - return; >> + return 0; >> >> sg = scsi_sglist(cmd); >> count = scsi_sg_count(cmd); >> if (count != 0) { >> int segs = scsi_dma_map(cmd); >> - if (segs > 1) { >> + >> + if (segs == -ENOMEM) { >> + scmd_printk(KERN_ERR, cmd, >> + "vmw_pvscsi: Failed to map cmd sglist >> for DMA.\n"); >> + return -1; >> + } else if (segs > 1) { >> pvscsi_create_sg(ctx, sg, segs); >> >> e->flags |= PVSCSI_FLAG_CMD_WITH_SG_LIST; >> ctx->sglPA = pci_map_single(adapter->dev, ctx->sgl, >> SGL_SIZE, >> PCI_DMA_TODEVICE); >> + if (pci_dma_mapping_error(adapter->dev, ctx->sglPA)) >> { >> + scmd_printk(KERN_ERR, cmd, >> + "vmw_pvscsi: Failed to map ctx >> sglist for DMA.\n"); >> + scsi_dma_unmap(cmd); >> + ctx->sglPA = 0; >> + return -1; >> + } >> e->dataAddr = ctx->sglPA; >> } else >> e->dataAddr = sg_dma_address(sg); >> @@ -382,8 +394,15 @@ static void pvscsi_map_buffers(struct pvscsi_adapter >> *adapter, >> */ >> ctx->dataPA = pci_map_single(adapter->dev, sg, bufflen, >> cmd->sc_data_direction); >> + if (pci_dma_mapping_error(adapter->dev, ctx->dataPA)) { >> + scmd_printk(KERN_ERR, cmd, >> + "vmw_pvscsi: Failed to map direct data >> buffer for DMA.\n"); >> + return -1; >> + } >> e->dataAddr = ctx->dataPA; >> } >> + >> + return 0; >> } >> >> static void pvscsi_unmap_buffers(const struct pvscsi_adapter *adapter, >> @@ -712,6 +731,12 @@ static int pvscsi_queue_ring(struct pvscsi_adapter >> *adapter, >> ctx->sensePA = pci_map_single(adapter->dev, >> cmd->sense_buffer, >> SCSI_SENSE_BUFFERSIZE, >> PCI_DMA_FROMDEVICE); >> + if (pci_dma_mapping_error(adapter->dev, ctx->sensePA)) { >> + scmd_printk(KERN_ERR, cmd, >> + "vmw_pvscsi: Failed to map sense buffer >> for DMA.\n"); >> + ctx->sensePA = 0; >> + return -1; >> + } >> e->senseAddr = ctx->sensePA; >> e->senseLen = SCSI_SENSE_BUFFERSIZE; >> } else { >> @@ -737,7 +762,15 @@ static int pvscsi_queue_ring(struct pvscsi_adapter >> *adapter, >> else >> e->flags = 0; >> >> - pvscsi_map_buffers(adapter, ctx, cmd, e); >> + if (pvscsi_m
Re: [Pv-drivers] [PATCH] VMW_PVSCSI: Fix the issue of DMA-API related warnings.
Hi James, Could you please help getting this in? Thanks! Arvind - Original Message - From: "Arvind Kumar" To: jbottom...@parallels.com, linux-scsi@vger.kernel.org Cc: pv-driv...@vmware.com, "Josh Boyer" Sent: Friday, March 21, 2014 11:08:32 AM Subject: [Pv-drivers] [PATCH] VMW_PVSCSI: Fix the issue of DMA-API related warnings. The driver is missing calls to pci_dma_mapping_error() after performing the DMA mapping, which caused DMA-API warning to show up in dmesg's output. Though that happens only when DMA_API_DEBUG option is enabled. This change fixes the issue and makes pvscsi_map_buffers() function more robust. Signed-off-by: Arvind Kumar Cc: Josh Boyer --- drivers/scsi/vmw_pvscsi.c | 45 +++-- drivers/scsi/vmw_pvscsi.h |2 +- 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c index c88e146..9478a00 100644 --- a/drivers/scsi/vmw_pvscsi.c +++ b/drivers/scsi/vmw_pvscsi.c @@ -349,9 +349,9 @@ static void pvscsi_create_sg(struct pvscsi_ctx *ctx, * Map all data buffers for a command into PCI space and * setup the scatter/gather list if needed. */ -static void pvscsi_map_buffers(struct pvscsi_adapter *adapter, - struct pvscsi_ctx *ctx, struct scsi_cmnd *cmd, - struct PVSCSIRingReqDesc *e) +static int pvscsi_map_buffers(struct pvscsi_adapter *adapter, + struct pvscsi_ctx *ctx, struct scsi_cmnd *cmd, + struct PVSCSIRingReqDesc *e) { unsigned count; unsigned bufflen = scsi_bufflen(cmd); @@ -360,18 +360,30 @@ static void pvscsi_map_buffers(struct pvscsi_adapter *adapter, e->dataLen = bufflen; e->dataAddr = 0; if (bufflen == 0) - return; + return 0; sg = scsi_sglist(cmd); count = scsi_sg_count(cmd); if (count != 0) { int segs = scsi_dma_map(cmd); - if (segs > 1) { + + if (segs == -ENOMEM) { + scmd_printk(KERN_ERR, cmd, + "vmw_pvscsi: Failed to map cmd sglist for DMA.\n"); + return -1; + } else if (segs > 1) { pvscsi_create_sg(ctx, sg, segs); e->flags |= PVSCSI_FLAG_CMD_WITH_SG_LIST; ctx->sglPA = pci_map_single(adapter->dev, ctx->sgl, SGL_SIZE, PCI_DMA_TODEVICE); + if (pci_dma_mapping_error(adapter->dev, ctx->sglPA)) { + scmd_printk(KERN_ERR, cmd, + "vmw_pvscsi: Failed to map ctx sglist for DMA.\n"); + scsi_dma_unmap(cmd); + ctx->sglPA = 0; + return -1; + } e->dataAddr = ctx->sglPA; } else e->dataAddr = sg_dma_address(sg); @@ -382,8 +394,15 @@ static void pvscsi_map_buffers(struct pvscsi_adapter *adapter, */ ctx->dataPA = pci_map_single(adapter->dev, sg, bufflen, cmd->sc_data_direction); + if (pci_dma_mapping_error(adapter->dev, ctx->dataPA)) { + scmd_printk(KERN_ERR, cmd, + "vmw_pvscsi: Failed to map direct data buffer for DMA.\n"); + return -1; + } e->dataAddr = ctx->dataPA; } + + return 0; } static void pvscsi_unmap_buffers(const struct pvscsi_adapter *adapter, @@ -712,6 +731,12 @@ static int pvscsi_queue_ring(struct pvscsi_adapter *adapter, ctx->sensePA = pci_map_single(adapter->dev, cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE, PCI_DMA_FROMDEVICE); + if (pci_dma_mapping_error(adapter->dev, ctx->sensePA)) { + scmd_printk(KERN_ERR, cmd, + "vmw_pvscsi: Failed to map sense buffer for DMA.\n"); + ctx->sensePA = 0; + return -1; + } e->senseAddr = ctx->sensePA; e->senseLen = SCSI_SENSE_BUFFERSIZE; } else { @@ -737,7 +762,15 @@ static int pvscsi_queue_ring(struct pvscsi_adapter *adapter, else e->flags = 0; - pvscsi_map_buffers(adapter, ctx, cmd, e); + if (pvscsi_map_buffers(adapter, ctx, cmd, e) != 0) { +
Re: [Pv-drivers] [PATCH] VMW_PVSCSI: Fix the issue of DMA-API related warnings.
Hi James, I was wondering if you got time to get to this one. It would be great if you could please help out with getting this patch in. Thanks! Arvind On Mon, 2014-04-14 at 11:17 -0700, Arvind Kumar wrote: > Hi James, > > Could you please help getting this in? > > Thanks! > Arvind > > - Original Message - > From: "Arvind Kumar" > To: jbottom...@parallels.com, linux-scsi@vger.kernel.org > Cc: pv-driv...@vmware.com, "Josh Boyer" > Sent: Friday, March 21, 2014 11:08:32 AM > Subject: [Pv-drivers] [PATCH] VMW_PVSCSI: Fix the issue of DMA-API related > warnings. > > The driver is missing calls to pci_dma_mapping_error() after > performing the DMA mapping, which caused DMA-API warning to > show up in dmesg's output. Though that happens only when > DMA_API_DEBUG option is enabled. This change fixes the issue > and makes pvscsi_map_buffers() function more robust. > > Signed-off-by: Arvind Kumar > Cc: Josh Boyer > --- > drivers/scsi/vmw_pvscsi.c | 45 > +++-- > drivers/scsi/vmw_pvscsi.h |2 +- > 2 files changed, 40 insertions(+), 7 deletions(-) > > diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c > index c88e146..9478a00 100644 > --- a/drivers/scsi/vmw_pvscsi.c > +++ b/drivers/scsi/vmw_pvscsi.c > @@ -349,9 +349,9 @@ static void pvscsi_create_sg(struct pvscsi_ctx *ctx, > * Map all data buffers for a command into PCI space and > * setup the scatter/gather list if needed. > */ > -static void pvscsi_map_buffers(struct pvscsi_adapter *adapter, > -struct pvscsi_ctx *ctx, struct scsi_cmnd *cmd, > -struct PVSCSIRingReqDesc *e) > +static int pvscsi_map_buffers(struct pvscsi_adapter *adapter, > + struct pvscsi_ctx *ctx, struct scsi_cmnd *cmd, > + struct PVSCSIRingReqDesc *e) > { > unsigned count; > unsigned bufflen = scsi_bufflen(cmd); > @@ -360,18 +360,30 @@ static void pvscsi_map_buffers(struct pvscsi_adapter > *adapter, > e->dataLen = bufflen; > e->dataAddr = 0; > if (bufflen == 0) > - return; > + return 0; > > sg = scsi_sglist(cmd); > count = scsi_sg_count(cmd); > if (count != 0) { > int segs = scsi_dma_map(cmd); > - if (segs > 1) { > + > + if (segs == -ENOMEM) { > + scmd_printk(KERN_ERR, cmd, > + "vmw_pvscsi: Failed to map cmd sglist for > DMA.\n"); > + return -1; > + } else if (segs > 1) { > pvscsi_create_sg(ctx, sg, segs); > > e->flags |= PVSCSI_FLAG_CMD_WITH_SG_LIST; > ctx->sglPA = pci_map_single(adapter->dev, ctx->sgl, > SGL_SIZE, PCI_DMA_TODEVICE); > + if (pci_dma_mapping_error(adapter->dev, ctx->sglPA)) { > + scmd_printk(KERN_ERR, cmd, > + "vmw_pvscsi: Failed to map ctx > sglist for DMA.\n"); > + scsi_dma_unmap(cmd); > + ctx->sglPA = 0; > + return -1; > + } > e->dataAddr = ctx->sglPA; > } else > e->dataAddr = sg_dma_address(sg); > @@ -382,8 +394,15 @@ static void pvscsi_map_buffers(struct pvscsi_adapter > *adapter, >*/ > ctx->dataPA = pci_map_single(adapter->dev, sg, bufflen, >cmd->sc_data_direction); > + if (pci_dma_mapping_error(adapter->dev, ctx->dataPA)) { > + scmd_printk(KERN_ERR, cmd, > + "vmw_pvscsi: Failed to map direct data > buffer for DMA.\n"); > + return -1; > + } > e->dataAddr = ctx->dataPA; > } > + > + return 0; > } > > static void pvscsi_unmap_buffers(const struct pvscsi_adapter *adapter, > @@ -712,6 +731,12 @@ static int pvscsi_queue_ring(struct pvscsi_adapter > *adapter, > ctx->sensePA = pci_map_single(adapter->dev, cmd->sense_buffer, > SCSI_SENSE_BUFFERSIZE, > PCI_DMA_FROMDEVICE); > + if (pci_dma_mapping_error(adapter->dev, ctx->sensePA)) { > + scmd