All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bnx2fc: fix incorrect DMA memory mapping in bnx2fc_unmap_sg_list()
@ 2014-09-02 18:34 Chad Dupuis
  2014-09-05  5:39 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Chad Dupuis @ 2014-09-02 18:34 UTC (permalink / raw)
  To: linux-scsi, hch; +Cc: giridhar.malavali

This patch is based on a problem and solution from Maurizio Lombardi
where bnx2fc isn't consistent in which device struct we using for DMA
map and unmap operations.  Make them consistent by using dma_sg_unmap
in bnx2fc_unmap_sg_list like bnx2fc_map_sg.

Reviewed-by: Eddie Wai <eddie.wai@broadcom.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
---
 drivers/scsi/bnx2fc/bnx2fc_io.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
index 4c5891e..0679782 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
@@ -1654,6 +1654,10 @@ static int bnx2fc_map_sg(struct bnx2fc_cmd *io_req)
 	u64 addr;
 	int i;
 
+	/*
+	 * Use dma_map_sg directly to ensure we're using the correct
+	 * dev struct off of pcidev.
+	 */
 	sg_count = dma_map_sg(&hba->pcidev->dev, scsi_sglist(sc),
 			      scsi_sg_count(sc), sc->sc_data_direction);
 	scsi_for_each_sg(sc, sg, sg_count, i) {
@@ -1703,9 +1707,16 @@ static int bnx2fc_build_bd_list_from_sg(struct bnx2fc_cmd *io_req)
 static void bnx2fc_unmap_sg_list(struct bnx2fc_cmd *io_req)
 {
 	struct scsi_cmnd *sc = io_req->sc_cmd;
+	struct bnx2fc_interface *interface = io_req->port->priv;
+	struct bnx2fc_hba *hba = interface->hba;
 
-	if (io_req->bd_tbl->bd_valid && sc) {
-		scsi_dma_unmap(sc);
+	/*
+	 * Use dma_unmap_sg directly to ensure we're using the correct
+	 * dev struct off of pcidev.
+	 */
+	if (io_req->bd_tbl->bd_valid && sc && scsi_sg_count(sc)) {
+		dma_unmap_sg(&hba->pcidev->dev, scsi_sglist(sc),
+		    scsi_sg_count(sc), sc->sc_data_direction);
 		io_req->bd_tbl->bd_valid = 0;
 	}
 }
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] bnx2fc: fix incorrect DMA memory mapping in bnx2fc_unmap_sg_list()
  2014-09-02 18:34 [PATCH] bnx2fc: fix incorrect DMA memory mapping in bnx2fc_unmap_sg_list() Chad Dupuis
@ 2014-09-05  5:39 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2014-09-05  5:39 UTC (permalink / raw)
  To: Chad Dupuis; +Cc: linux-scsi, giridhar.malavali

Thanks, applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-09-05  5:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-02 18:34 [PATCH] bnx2fc: fix incorrect DMA memory mapping in bnx2fc_unmap_sg_list() Chad Dupuis
2014-09-05  5:39 ` Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.