stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/8] lpfc: fix calls to dma_set_mask_and_coherent()
       [not found] <20190218073426.111853-1-hare@suse.de>
@ 2019-02-18  7:34 ` Hannes Reinecke
  2019-02-18  9:24   ` Christoph Hellwig
  2019-02-26  0:29   ` Ewan Milne
  2019-02-18  7:34 ` [PATCH 2/8] 3w-9xxx: " Hannes Reinecke
                   ` (6 subsequent siblings)
  7 siblings, 2 replies; 25+ messages in thread
From: Hannes Reinecke @ 2019-02-18  7:34 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke,
	stable, Ewan D . Milne, Hannes Reinecke

The change to use dma_set_mask_and_coherent() incorrectly made a second
call with the 32 bit DMA mask value when the call with the 64 bit DMA
mask value succeeded.  This resulted in NVMe/FC connections failing due
to corrupted data buffers, and various other SCSI/FCP I/O errors.

Fixes: f30e1bfd6154 ("scsi: lpfc: use dma_set_mask_and_coherent")
Cc: <stable@vger.kernel.org>
Suggested-by: Don Dutile <ddutile@redhat.com>
Signed-off-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/lpfc/lpfc_init.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index eef6b929c327..59b098cb5787 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -7693,15 +7693,18 @@ lpfc_sli_pci_mem_setup(struct lpfc_hba *phba)
 	unsigned long bar0map_len, bar2map_len;
 	int i, hbq_count;
 	void *ptr;
-	int error = -ENODEV;
+	int error;
 
 	if (!pdev)
-		return error;
+		return -ENODEV;
 
 	/* Set the device DMA mask size */
-	if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
-	    dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)))
+	error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+	if (error)
+		error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+	if (error)
 		return error;
+	error = -ENODEV;
 
 	/* Get the bus address of Bar0 and Bar2 and the number of bytes
 	 * required by each mapping.
@@ -10053,11 +10056,13 @@ lpfc_sli4_pci_mem_setup(struct lpfc_hba *phba)
 	uint32_t if_type;
 
 	if (!pdev)
-		return error;
+		return -ENODEV;
 
 	/* Set the device DMA mask size */
-	if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
-	    dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)))
+	error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+	if (error)
+		error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+	if (error)
 		return error;
 
 	/*
-- 
2.16.4


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

* [PATCH 2/8] 3w-9xxx: fix calls to dma_set_mask_and_coherent()
       [not found] <20190218073426.111853-1-hare@suse.de>
  2019-02-18  7:34 ` [PATCH 1/8] lpfc: fix calls to dma_set_mask_and_coherent() Hannes Reinecke
@ 2019-02-18  7:34 ` Hannes Reinecke
  2019-02-18  9:24   ` Christoph Hellwig
  2019-02-26  0:30   ` Ewan Milne
  2019-02-18  7:34 ` [PATCH 3/8] 3w-sas: " Hannes Reinecke
                   ` (5 subsequent siblings)
  7 siblings, 2 replies; 25+ messages in thread
From: Hannes Reinecke @ 2019-02-18  7:34 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke,
	stable, Hannes Reinecke

The change to use dma_set_mask_and_coherent() incorrectly made a second
call with the 32 bit DMA mask value when the call with the 64 bit DMA
mask value succeeded.

Fixes: b000bced5739 ("scsi: 3w-9xxx: fully convert to the generic DMA API")
Cc: <stable@vger.kernel.org>
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/3w-9xxx.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index a3c20e3a8b7c..3337b1e80412 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -2009,7 +2009,7 @@ static int twa_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)
 	struct Scsi_Host *host = NULL;
 	TW_Device_Extension *tw_dev;
 	unsigned long mem_addr, mem_len;
-	int retval = -ENODEV;
+	int retval;
 
 	retval = pci_enable_device(pdev);
 	if (retval) {
@@ -2020,8 +2020,10 @@ static int twa_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)
 	pci_set_master(pdev);
 	pci_try_set_mwi(pdev);
 
-	if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
-	    dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
+	retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+	if (retval)
+		retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+	if (retval) {
 		TW_PRINTK(host, TW_DRIVER, 0x23, "Failed to set dma mask");
 		retval = -ENODEV;
 		goto out_disable_device;
@@ -2240,8 +2242,10 @@ static int twa_resume(struct pci_dev *pdev)
 	pci_set_master(pdev);
 	pci_try_set_mwi(pdev);
 
-	if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
-	    dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
+	retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+	if (retval)
+		retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+	if (retval) {
 		TW_PRINTK(host, TW_DRIVER, 0x40, "Failed to set dma mask during resume");
 		retval = -ENODEV;
 		goto out_disable_device;
-- 
2.16.4


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

* [PATCH 3/8] 3w-sas: fix calls to dma_set_mask_and_coherent()
       [not found] <20190218073426.111853-1-hare@suse.de>
  2019-02-18  7:34 ` [PATCH 1/8] lpfc: fix calls to dma_set_mask_and_coherent() Hannes Reinecke
  2019-02-18  7:34 ` [PATCH 2/8] 3w-9xxx: " Hannes Reinecke
@ 2019-02-18  7:34 ` Hannes Reinecke
  2019-02-18  9:24   ` Christoph Hellwig
  2019-02-26  0:30   ` Ewan Milne
  2019-02-18  7:34 ` [PATCH 4/8] " Hannes Reinecke
                   ` (4 subsequent siblings)
  7 siblings, 2 replies; 25+ messages in thread
From: Hannes Reinecke @ 2019-02-18  7:34 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke,
	stable, Hannes Reinecke

The change to use dma_set_mask_and_coherent() incorrectly made a second
call with the 32 bit DMA mask value when the call with the 64 bit DMA
mask value succeeded.

Fixes: b1fa122930c4 ("scsi: 3w-sas: fully convert to the generic DMA API")
Cc: <stable@vger.kernel.org>
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/3w-sas.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
index e8f5f7c63190..2d15b878bd94 100644
--- a/drivers/scsi/3w-sas.c
+++ b/drivers/scsi/3w-sas.c
@@ -1572,8 +1572,10 @@ static int twl_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)
 	pci_set_master(pdev);
 	pci_try_set_mwi(pdev);
 
-	if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
-	    dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
+	retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+	if (retval)
+		retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+	if (retval) {
 		TW_PRINTK(host, TW_DRIVER, 0x18, "Failed to set dma mask");
 		retval = -ENODEV;
 		goto out_disable_device;
@@ -1804,8 +1806,10 @@ static int twl_resume(struct pci_dev *pdev)
 	pci_set_master(pdev);
 	pci_try_set_mwi(pdev);
 
-	if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
-	    dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
+	retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+	if (retval)
+		retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+	if (retval) {
 		TW_PRINTK(host, TW_DRIVER, 0x25, "Failed to set dma mask during resume");
 		retval = -ENODEV;
 		goto out_disable_device;
-- 
2.16.4


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

* [PATCH 4/8] 3w-sas: fix calls to dma_set_mask_and_coherent()
       [not found] <20190218073426.111853-1-hare@suse.de>
                   ` (2 preceding siblings ...)
  2019-02-18  7:34 ` [PATCH 3/8] 3w-sas: " Hannes Reinecke
@ 2019-02-18  7:34 ` Hannes Reinecke
  2019-02-18  9:25   ` Christoph Hellwig
  2019-02-26  0:32   ` Ewan Milne
  2019-02-18  7:34 ` [PATCH 5/8] bfa: " Hannes Reinecke
                   ` (3 subsequent siblings)
  7 siblings, 2 replies; 25+ messages in thread
From: Hannes Reinecke @ 2019-02-18  7:34 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke,
	stable, Hannes Reinecke

The change to use dma_set_mask_and_coherent() incorrectly made a second
call with the 32 bit DMA mask value when the call with the 64 bit DMA
mask value succeeded.

Fixes: 3a21986f1a59 ("scsi: aic94xx: fully convert to the generic DMA API")
Cc: <stable@vger.kernel.org>
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/aic94xx/aic94xx_init.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c
index f83f79b07b50..d41f645e8454 100644
--- a/drivers/scsi/aic94xx/aic94xx_init.c
+++ b/drivers/scsi/aic94xx/aic94xx_init.c
@@ -769,9 +769,11 @@ static int asd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 	if (err)
 		goto Err_remove;
 
-	err = -ENODEV;
-	if (dma_set_mask_and_coherent(&dev->dev, DMA_BIT_MASK(64)) ||
-	    dma_set_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32))) {
+	err = dma_set_mask_and_coherent(&dev->dev, DMA_BIT_MASK(64));
+	if (err)
+		err = dma_set_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32));
+	if (err) {
+		err = -ENODEV;
 		asd_printk("no suitable DMA mask for %s\n", pci_name(dev));
 		goto Err_remove;
 	}
-- 
2.16.4


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

* [PATCH 5/8] bfa: fix calls to dma_set_mask_and_coherent()
       [not found] <20190218073426.111853-1-hare@suse.de>
                   ` (3 preceding siblings ...)
  2019-02-18  7:34 ` [PATCH 4/8] " Hannes Reinecke
@ 2019-02-18  7:34 ` Hannes Reinecke
  2019-02-18  9:25   ` Christoph Hellwig
  2019-02-26  0:34   ` Ewan Milne
  2019-02-18  7:34 ` [PATCH 6/8] csiostor: " Hannes Reinecke
                   ` (2 subsequent siblings)
  7 siblings, 2 replies; 25+ messages in thread
From: Hannes Reinecke @ 2019-02-18  7:34 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke,
	stable, Hannes Reinecke

The change to use dma_set_mask_and_coherent() incorrectly made a second
call with the 32 bit DMA mask value when the call with the 64 bit DMA
mask value succeeded.  This resulted in FC connections failing due
to corrupted data buffers, and various other SCSI/FCP I/O errors.

Fixes: a69b080025ea ("scsi: bfa: use dma_set_mask_and_coherent")
Cc: <stable@vger.kernel.org>
Suggested-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/bfa/bfad.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c
index 42a0caf6740d..88880a66a189 100644
--- a/drivers/scsi/bfa/bfad.c
+++ b/drivers/scsi/bfa/bfad.c
@@ -727,7 +727,7 @@ bfad_init_timer(struct bfad_s *bfad)
 int
 bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad)
 {
-	int		rc = -ENODEV;
+	int rc = -ENODEV;
 
 	if (pci_enable_device(pdev)) {
 		printk(KERN_ERR "pci_enable_device fail %p\n", pdev);
@@ -739,8 +739,12 @@ bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad)
 
 	pci_set_master(pdev);
 
-	if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
-	    dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
+	rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+	if (rc)
+		rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+
+	if (rc) {
+		rc = -ENODEV;
 		printk(KERN_ERR "dma_set_mask_and_coherent fail %p\n", pdev);
 		goto out_release_region;
 	}
@@ -1534,6 +1538,7 @@ bfad_pci_slot_reset(struct pci_dev *pdev)
 {
 	struct bfad_s *bfad = pci_get_drvdata(pdev);
 	u8 byte;
+	int rc;
 
 	dev_printk(KERN_ERR, &pdev->dev,
 		   "bfad_pci_slot_reset flags: 0x%x\n", bfad->bfad_flags);
@@ -1561,8 +1566,11 @@ bfad_pci_slot_reset(struct pci_dev *pdev)
 	pci_save_state(pdev);
 	pci_set_master(pdev);
 
-	if (dma_set_mask_and_coherent(&bfad->pcidev->dev, DMA_BIT_MASK(64)) ||
-	    dma_set_mask_and_coherent(&bfad->pcidev->dev, DMA_BIT_MASK(32)))
+	rc = dma_set_mask_and_coherent(&bfad->pcidev->dev, DMA_BIT_MASK(64));
+	if (rc)
+		rc = dma_set_mask_and_coherent(&bfad->pcidev->dev,
+					       DMA_BIT_MASK(32));
+	if (rc)
 		goto out_disable_device;
 
 	if (restart_bfa(bfad) == -1)
-- 
2.16.4


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

* [PATCH 6/8] csiostor: fix calls to dma_set_mask_and_coherent()
       [not found] <20190218073426.111853-1-hare@suse.de>
                   ` (4 preceding siblings ...)
  2019-02-18  7:34 ` [PATCH 5/8] bfa: " Hannes Reinecke
@ 2019-02-18  7:34 ` Hannes Reinecke
  2019-02-18  9:25   ` Christoph Hellwig
  2019-02-26  0:35   ` Ewan Milne
  2019-02-18  7:34 ` [PATCH 7/8] hisi_sas: " Hannes Reinecke
  2019-02-18  7:34 ` [PATCH 8/8] hptiop: fix calls to dma_set_mask() Hannes Reinecke
  7 siblings, 2 replies; 25+ messages in thread
From: Hannes Reinecke @ 2019-02-18  7:34 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke,
	stable, Hannes Reinecke

The change to use dma_set_mask_and_coherent() incorrectly made a second
call with the 32 bit DMA mask value when the call with the 64 bit DMA
mask value succeeded.

Fixes: c22b332d811b ("scsi: csiostor: switch to generic DMA API")
Cc: <stable@vger.kernel.org>
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/csiostor/csio_init.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/csiostor/csio_init.c b/drivers/scsi/csiostor/csio_init.c
index 460e4ee1c8fe..a6dd704d7f2d 100644
--- a/drivers/scsi/csiostor/csio_init.c
+++ b/drivers/scsi/csiostor/csio_init.c
@@ -206,8 +206,11 @@ csio_pci_init(struct pci_dev *pdev, int *bars)
 	pci_set_master(pdev);
 	pci_try_set_mwi(pdev);
 
-	if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
-	    dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
+	rv = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+	if (rv)
+		rv = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+	if (rv) {
+		rv = -ENODEV;
 		dev_err(&pdev->dev, "No suitable DMA available.\n");
 		goto err_release_regions;
 	}
-- 
2.16.4


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

* [PATCH 7/8] hisi_sas: fix calls to dma_set_mask_and_coherent()
       [not found] <20190218073426.111853-1-hare@suse.de>
                   ` (5 preceding siblings ...)
  2019-02-18  7:34 ` [PATCH 6/8] csiostor: " Hannes Reinecke
@ 2019-02-18  7:34 ` Hannes Reinecke
  2019-02-18  9:24   ` John Garry
                     ` (2 more replies)
  2019-02-18  7:34 ` [PATCH 8/8] hptiop: fix calls to dma_set_mask() Hannes Reinecke
  7 siblings, 3 replies; 25+ messages in thread
From: Hannes Reinecke @ 2019-02-18  7:34 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke,
	stable, Hannes Reinecke

The change to use dma_set_mask_and_coherent() incorrectly made a second
call with the 32 bit DMA mask value when the call with the 64 bit DMA
mask value succeeded.  This resulted in FC connections failing due
to corrupted data buffers, and various other SCSI/FCP I/O errors.

Fixes: e4db40e7a1a2 ("scsi: hisi_sas: use dma_set_mask_and_coherent")
Cc: <stable@vger.kernel.org>
Suggested-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/hisi_sas/hisi_sas_main.c  | 8 ++++++--
 drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 8 +++++---
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 923296653ed7..13ca5a0bdf6b 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -2484,6 +2484,7 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev,
 	struct Scsi_Host *shost;
 	struct hisi_hba *hisi_hba;
 	struct device *dev = &pdev->dev;
+	int error;
 
 	shost = scsi_host_alloc(hw->sht, sizeof(*hisi_hba));
 	if (!shost) {
@@ -2504,8 +2505,11 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev,
 	if (hisi_sas_get_fw_info(hisi_hba) < 0)
 		goto err_out;
 
-	if (dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)) &&
-	    dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32))) {
+	error = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64));
+	if (error)
+		error = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
+
+	if (error) {
 		dev_err(dev, "No usable DMA addressing method\n");
 		goto err_out;
 	}
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
index 00738d0673fe..79390f235c7e 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
@@ -2742,10 +2742,12 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	if (rc)
 		goto err_out_disable_device;
 
-	if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
-	    dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
+	rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+	if (rc)
+		rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+	if (rc) {
 		dev_err(dev, "No usable DMA addressing method\n");
-		rc = -EIO;
+		rc = -ENODEV;
 		goto err_out_regions;
 	}
 
-- 
2.16.4


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

* [PATCH 8/8] hptiop: fix calls to dma_set_mask()
       [not found] <20190218073426.111853-1-hare@suse.de>
                   ` (6 preceding siblings ...)
  2019-02-18  7:34 ` [PATCH 7/8] hisi_sas: " Hannes Reinecke
@ 2019-02-18  7:34 ` Hannes Reinecke
  2019-02-18  9:26   ` Christoph Hellwig
  2019-02-26  0:38   ` Ewan Milne
  7 siblings, 2 replies; 25+ messages in thread
From: Hannes Reinecke @ 2019-02-18  7:34 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke,
	stable, Hannes Reinecke

The change to use dma_set_mask() incorrectly made a second call with the
32 bit DMA mask value when the call with the 64 bit DMA mask value succeeded.

Fixes: 453cd3700ca3 ("scsi: hptiop: use dma_set_mask")
Cc: <stable@vger.kernel.org>
Suggested-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/hptiop.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c
index 3eedfd4f8f57..251c084a6ff0 100644
--- a/drivers/scsi/hptiop.c
+++ b/drivers/scsi/hptiop.c
@@ -1292,6 +1292,7 @@ static int hptiop_probe(struct pci_dev *pcidev, const struct pci_device_id *id)
 	dma_addr_t start_phy;
 	void *start_virt;
 	u32 offset, i, req_size;
+	int rc;
 
 	dprintk("hptiop_probe(%p)\n", pcidev);
 
@@ -1308,9 +1309,12 @@ static int hptiop_probe(struct pci_dev *pcidev, const struct pci_device_id *id)
 
 	/* Enable 64bit DMA if possible */
 	iop_ops = (struct hptiop_adapter_ops *)id->driver_data;
-	if (dma_set_mask(&pcidev->dev,
-			 DMA_BIT_MASK(iop_ops->hw_dma_bit_mask)) ||
-	    dma_set_mask(&pcidev->dev, DMA_BIT_MASK(32))) {
+	rc = dma_set_mask(&pcidev->dev,
+			  DMA_BIT_MASK(iop_ops->hw_dma_bit_mask));
+	if (rc)
+		rc = dma_set_mask(&pcidev->dev, DMA_BIT_MASK(32));
+
+	if (rc) {
 		printk(KERN_ERR "hptiop: fail to set dma_mask\n");
 		goto disable_pci_device;
 	}
-- 
2.16.4


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

* Re: [PATCH 7/8] hisi_sas: fix calls to dma_set_mask_and_coherent()
  2019-02-18  7:34 ` [PATCH 7/8] hisi_sas: " Hannes Reinecke
@ 2019-02-18  9:24   ` John Garry
  2019-02-18  9:26   ` Christoph Hellwig
  2019-02-26  0:37   ` Ewan Milne
  2 siblings, 0 replies; 25+ messages in thread
From: John Garry @ 2019-02-18  9:24 UTC (permalink / raw)
  To: Hannes Reinecke, Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, stable,
	Hannes Reinecke, chenxiang

On 18/02/2019 07:34, Hannes Reinecke wrote:

Hi Hannes,

Thanks for this. I have some comments, below.

> The change to use dma_set_mask_and_coherent() incorrectly made a second
> call with the 32 bit DMA mask value when the call with the 64 bit DMA
> mask value succeeded.

And the second call to dma_set_mask_and_coherent() is not done if first 
fails, and we just bail out.

This resulted in FC connections failing due
> to corrupted data buffers, and various other SCSI/FCP I/O errors.
>

Not relevant.

> Fixes: e4db40e7a1a2 ("scsi: hisi_sas: use dma_set_mask_and_coherent")
> Cc: <stable@vger.kernel.org>

e4db40e7a1a2 only went into 5.0, so I don't know which stable kernel 
we're trying to fix. I am assuming that we can get this fix into 5.0.

> Suggested-by: Ewan D. Milne <emilne@redhat.com>
> Signed-off-by: Hannes Reinecke <hare@suse.com>
> ---
>  drivers/scsi/hisi_sas/hisi_sas_main.c  | 8 ++++++--
>  drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 8 +++++---
>  2 files changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
> index 923296653ed7..13ca5a0bdf6b 100644
> --- a/drivers/scsi/hisi_sas/hisi_sas_main.c
> +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
> @@ -2484,6 +2484,7 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev,
>  	struct Scsi_Host *shost;
>  	struct hisi_hba *hisi_hba;
>  	struct device *dev = &pdev->dev;
> +	int error;
>
>  	shost = scsi_host_alloc(hw->sht, sizeof(*hisi_hba));
>  	if (!shost) {
> @@ -2504,8 +2505,11 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev,
>  	if (hisi_sas_get_fw_info(hisi_hba) < 0)
>  		goto err_out;
>
> -	if (dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)) &&
> -	    dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32))) {
> +	error = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64));
> +	if (error)
> +		error = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
> +
> +	if (error) {
>  		dev_err(dev, "No usable DMA addressing method\n");
>  		goto err_out;


This code was ok as is, so we're not really fixing anything. And 
certainly not fixing e4db40e7a1a2, so I am unsure if this should be 
included.

>  	}
> diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
> index 00738d0673fe..79390f235c7e 100644
> --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
> +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
> @@ -2742,10 +2742,12 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>  	if (rc)
>  		goto err_out_disable_device;
>
> -	if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
> -	    dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
> +	rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
> +	if (rc)
> +		rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
> +	if (rc) {
>  		dev_err(dev, "No usable DMA addressing method\n");
> -		rc = -EIO;
> +		rc = -ENODEV;
>  		goto err_out_regions;
>  	}
>
>



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

* Re: [PATCH 1/8] lpfc: fix calls to dma_set_mask_and_coherent()
  2019-02-18  7:34 ` [PATCH 1/8] lpfc: fix calls to dma_set_mask_and_coherent() Hannes Reinecke
@ 2019-02-18  9:24   ` Christoph Hellwig
  2019-02-26  0:29   ` Ewan Milne
  1 sibling, 0 replies; 25+ messages in thread
From: Christoph Hellwig @ 2019-02-18  9:24 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Martin K. Petersen, Christoph Hellwig, James Bottomley,
	linux-scsi, stable, Ewan D . Milne, Hannes Reinecke

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH 2/8] 3w-9xxx: fix calls to dma_set_mask_and_coherent()
  2019-02-18  7:34 ` [PATCH 2/8] 3w-9xxx: " Hannes Reinecke
@ 2019-02-18  9:24   ` Christoph Hellwig
  2019-02-26  0:30   ` Ewan Milne
  1 sibling, 0 replies; 25+ messages in thread
From: Christoph Hellwig @ 2019-02-18  9:24 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Martin K. Petersen, Christoph Hellwig, James Bottomley,
	linux-scsi, stable, Hannes Reinecke

On Mon, Feb 18, 2019 at 08:34:20AM +0100, Hannes Reinecke wrote:
> The change to use dma_set_mask_and_coherent() incorrectly made a second
> call with the 32 bit DMA mask value when the call with the 64 bit DMA
> mask value succeeded.

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH 3/8] 3w-sas: fix calls to dma_set_mask_and_coherent()
  2019-02-18  7:34 ` [PATCH 3/8] 3w-sas: " Hannes Reinecke
@ 2019-02-18  9:24   ` Christoph Hellwig
  2019-02-26  0:30   ` Ewan Milne
  1 sibling, 0 replies; 25+ messages in thread
From: Christoph Hellwig @ 2019-02-18  9:24 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Martin K. Petersen, Christoph Hellwig, James Bottomley,
	linux-scsi, stable, Hannes Reinecke

On Mon, Feb 18, 2019 at 08:34:21AM +0100, Hannes Reinecke wrote:
> The change to use dma_set_mask_and_coherent() incorrectly made a second
> call with the 32 bit DMA mask value when the call with the 64 bit DMA
> mask value succeeded.

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH 4/8] 3w-sas: fix calls to dma_set_mask_and_coherent()
  2019-02-18  7:34 ` [PATCH 4/8] " Hannes Reinecke
@ 2019-02-18  9:25   ` Christoph Hellwig
  2019-02-26  0:32   ` Ewan Milne
  1 sibling, 0 replies; 25+ messages in thread
From: Christoph Hellwig @ 2019-02-18  9:25 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Martin K. Petersen, Christoph Hellwig, James Bottomley,
	linux-scsi, stable, Hannes Reinecke

On Mon, Feb 18, 2019 at 08:34:22AM +0100, Hannes Reinecke wrote:
> The change to use dma_set_mask_and_coherent() incorrectly made a second
> call with the 32 bit DMA mask value when the call with the 64 bit DMA
> mask value succeeded.

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH 5/8] bfa: fix calls to dma_set_mask_and_coherent()
  2019-02-18  7:34 ` [PATCH 5/8] bfa: " Hannes Reinecke
@ 2019-02-18  9:25   ` Christoph Hellwig
  2019-02-26  0:34   ` Ewan Milne
  1 sibling, 0 replies; 25+ messages in thread
From: Christoph Hellwig @ 2019-02-18  9:25 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Martin K. Petersen, Christoph Hellwig, James Bottomley,
	linux-scsi, stable, Hannes Reinecke

On Mon, Feb 18, 2019 at 08:34:23AM +0100, Hannes Reinecke wrote:
> The change to use dma_set_mask_and_coherent() incorrectly made a second
> call with the 32 bit DMA mask value when the call with the 64 bit DMA
> mask value succeeded.  This resulted in FC connections failing due
> to corrupted data buffers, and various other SCSI/FCP I/O errors.

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH 6/8] csiostor: fix calls to dma_set_mask_and_coherent()
  2019-02-18  7:34 ` [PATCH 6/8] csiostor: " Hannes Reinecke
@ 2019-02-18  9:25   ` Christoph Hellwig
  2019-02-26  0:35   ` Ewan Milne
  1 sibling, 0 replies; 25+ messages in thread
From: Christoph Hellwig @ 2019-02-18  9:25 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Martin K. Petersen, Christoph Hellwig, James Bottomley,
	linux-scsi, stable, Hannes Reinecke

On Mon, Feb 18, 2019 at 08:34:24AM +0100, Hannes Reinecke wrote:
> The change to use dma_set_mask_and_coherent() incorrectly made a second
> call with the 32 bit DMA mask value when the call with the 64 bit DMA
> mask value succeeded.

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH 7/8] hisi_sas: fix calls to dma_set_mask_and_coherent()
  2019-02-18  7:34 ` [PATCH 7/8] hisi_sas: " Hannes Reinecke
  2019-02-18  9:24   ` John Garry
@ 2019-02-18  9:26   ` Christoph Hellwig
  2019-02-26  0:37   ` Ewan Milne
  2 siblings, 0 replies; 25+ messages in thread
From: Christoph Hellwig @ 2019-02-18  9:26 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Martin K. Petersen, Christoph Hellwig, James Bottomley,
	linux-scsi, stable, Hannes Reinecke

On Mon, Feb 18, 2019 at 08:34:25AM +0100, Hannes Reinecke wrote:
> The change to use dma_set_mask_and_coherent() incorrectly made a second
> call with the 32 bit DMA mask value when the call with the 64 bit DMA
> mask value succeeded.  This resulted in FC connections failing due
> to corrupted data buffers, and various other SCSI/FCP I/O errors.

Looks good (modulo the FCP copy and paste noticed by John):

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH 8/8] hptiop: fix calls to dma_set_mask()
  2019-02-18  7:34 ` [PATCH 8/8] hptiop: fix calls to dma_set_mask() Hannes Reinecke
@ 2019-02-18  9:26   ` Christoph Hellwig
  2019-02-26  0:38   ` Ewan Milne
  1 sibling, 0 replies; 25+ messages in thread
From: Christoph Hellwig @ 2019-02-18  9:26 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Martin K. Petersen, Christoph Hellwig, James Bottomley,
	linux-scsi, stable, Hannes Reinecke

On Mon, Feb 18, 2019 at 08:34:26AM +0100, Hannes Reinecke wrote:
> The change to use dma_set_mask() incorrectly made a second call with the
> 32 bit DMA mask value when the call with the 64 bit DMA mask value succeeded.

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH 1/8] lpfc: fix calls to dma_set_mask_and_coherent()
  2019-02-18  7:34 ` [PATCH 1/8] lpfc: fix calls to dma_set_mask_and_coherent() Hannes Reinecke
  2019-02-18  9:24   ` Christoph Hellwig
@ 2019-02-26  0:29   ` Ewan Milne
  1 sibling, 0 replies; 25+ messages in thread
From: Ewan Milne @ 2019-02-26  0:29 UTC (permalink / raw)
  To: Hannes Reinecke; +Cc: Martin K. Petersen, James Bottomley, linux-scsi, stable

The change to use dma_set_mask_and_coherent() incorrectly made a second
call with the 32 bit DMA mask value when the call with the 64 bit DMA
mask value succeeded.  This resulted in NVMe/FC connections failing due
to corrupted data buffers, and various other SCSI/FCP I/O errors.

Fixes: f30e1bfd6154 ("scsi: lpfc: use dma_set_mask_and_coherent")
Cc: <stable@vger.kernel.org>
Suggested-by: Don Dutile <ddutile@redhat.com>
Signed-off-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/lpfc/lpfc_init.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index eef6b929c327..59b098cb5787 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -7693,15 +7693,18 @@ lpfc_sli_pci_mem_setup(struct lpfc_hba *phba)
 	unsigned long bar0map_len, bar2map_len;
 	int i, hbq_count;
 	void *ptr;
-	int error = -ENODEV;
+	int error;
 
 	if (!pdev)
-		return error;
+		return -ENODEV;
 
 	/* Set the device DMA mask size */
-	if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
-	    dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)))
+	error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+	if (error)
+		error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+	if (error)
 		return error;
+	error = -ENODEV;
 
 	/* Get the bus address of Bar0 and Bar2 and the number of bytes
 	 * required by each mapping.
@@ -10053,11 +10056,13 @@ lpfc_sli4_pci_mem_setup(struct lpfc_hba *phba)
 	uint32_t if_type;
 
 	if (!pdev)
-		return error;
+		return -ENODEV;
 
 	/* Set the device DMA mask size */
-	if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
-	    dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)))
+	error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+	if (error)
+		error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+	if (error)
 		return error;
 
 	/*
-- 
2.16.4

Reviewed-by: Ewan D. Milne <emilne@redhat.com>

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

* Re: [PATCH 2/8] 3w-9xxx: fix calls to dma_set_mask_and_coherent()
  2019-02-18  7:34 ` [PATCH 2/8] 3w-9xxx: " Hannes Reinecke
  2019-02-18  9:24   ` Christoph Hellwig
@ 2019-02-26  0:30   ` Ewan Milne
  1 sibling, 0 replies; 25+ messages in thread
From: Ewan Milne @ 2019-02-26  0:30 UTC (permalink / raw)
  To: Hannes Reinecke; +Cc: Martin K. Petersen, James Bottomley, linux-scsi, stable

The change to use dma_set_mask_and_coherent() incorrectly made a second
call with the 32 bit DMA mask value when the call with the 64 bit DMA
mask value succeeded.

Fixes: b000bced5739 ("scsi: 3w-9xxx: fully convert to the generic DMA API")
Cc: <stable@vger.kernel.org>
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/3w-9xxx.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index a3c20e3a8b7c..3337b1e80412 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -2009,7 +2009,7 @@ static int twa_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)
 	struct Scsi_Host *host = NULL;
 	TW_Device_Extension *tw_dev;
 	unsigned long mem_addr, mem_len;
-	int retval = -ENODEV;
+	int retval;
 
 	retval = pci_enable_device(pdev);
 	if (retval) {
@@ -2020,8 +2020,10 @@ static int twa_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)
 	pci_set_master(pdev);
 	pci_try_set_mwi(pdev);
 
-	if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
-	    dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
+	retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+	if (retval)
+		retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+	if (retval) {
 		TW_PRINTK(host, TW_DRIVER, 0x23, "Failed to set dma mask");
 		retval = -ENODEV;
 		goto out_disable_device;
@@ -2240,8 +2242,10 @@ static int twa_resume(struct pci_dev *pdev)
 	pci_set_master(pdev);
 	pci_try_set_mwi(pdev);
 
-	if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
-	    dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
+	retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+	if (retval)
+		retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+	if (retval) {
 		TW_PRINTK(host, TW_DRIVER, 0x40, "Failed to set dma mask during resume");
 		retval = -ENODEV;
 		goto out_disable_device;
-- 
2.16.4

Reviewed-by: Ewan D. Milne <emilne@redhat.com>


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

* Re: [PATCH 3/8] 3w-sas: fix calls to dma_set_mask_and_coherent()
  2019-02-18  7:34 ` [PATCH 3/8] 3w-sas: " Hannes Reinecke
  2019-02-18  9:24   ` Christoph Hellwig
@ 2019-02-26  0:30   ` Ewan Milne
  1 sibling, 0 replies; 25+ messages in thread
From: Ewan Milne @ 2019-02-26  0:30 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Martin K. Petersen, James Bottomley, linux-scsi, stable, Hannes Reinecke

The change to use dma_set_mask_and_coherent() incorrectly made a second
call with the 32 bit DMA mask value when the call with the 64 bit DMA
mask value succeeded.

Fixes: b1fa122930c4 ("scsi: 3w-sas: fully convert to the generic DMA API")
Cc: <stable@vger.kernel.org>
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/3w-sas.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
index e8f5f7c63190..2d15b878bd94 100644
--- a/drivers/scsi/3w-sas.c
+++ b/drivers/scsi/3w-sas.c
@@ -1572,8 +1572,10 @@ static int twl_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)
 	pci_set_master(pdev);
 	pci_try_set_mwi(pdev);
 
-	if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
-	    dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
+	retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+	if (retval)
+		retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+	if (retval) {
 		TW_PRINTK(host, TW_DRIVER, 0x18, "Failed to set dma mask");
 		retval = -ENODEV;
 		goto out_disable_device;
@@ -1804,8 +1806,10 @@ static int twl_resume(struct pci_dev *pdev)
 	pci_set_master(pdev);
 	pci_try_set_mwi(pdev);
 
-	if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
-	    dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
+	retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+	if (retval)
+		retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+	if (retval) {
 		TW_PRINTK(host, TW_DRIVER, 0x25, "Failed to set dma mask during resume");
 		retval = -ENODEV;
 		goto out_disable_device;
-- 
2.16.4

Reviewed-by: Ewan D. Milne <emilne@redhat.com>


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

* Re: [PATCH 4/8] 3w-sas: fix calls to dma_set_mask_and_coherent()
  2019-02-18  7:34 ` [PATCH 4/8] " Hannes Reinecke
  2019-02-18  9:25   ` Christoph Hellwig
@ 2019-02-26  0:32   ` Ewan Milne
  1 sibling, 0 replies; 25+ messages in thread
From: Ewan Milne @ 2019-02-26  0:32 UTC (permalink / raw)
  To: Hannes Reinecke; +Cc: Martin K. Petersen, James Bottomley, linux-scsi, stable

The change to use dma_set_mask_and_coherent() incorrectly made a second
call with the 32 bit DMA mask value when the call with the 64 bit DMA
mask value succeeded.

Fixes: 3a21986f1a59 ("scsi: aic94xx: fully convert to the generic DMA API")
Cc: <stable@vger.kernel.org>
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/aic94xx/aic94xx_init.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c
index f83f79b07b50..d41f645e8454 100644
--- a/drivers/scsi/aic94xx/aic94xx_init.c
+++ b/drivers/scsi/aic94xx/aic94xx_init.c
@@ -769,9 +769,11 @@ static int asd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 	if (err)
 		goto Err_remove;
 
-	err = -ENODEV;
-	if (dma_set_mask_and_coherent(&dev->dev, DMA_BIT_MASK(64)) ||
-	    dma_set_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32))) {
+	err = dma_set_mask_and_coherent(&dev->dev, DMA_BIT_MASK(64));
+	if (err)
+		err = dma_set_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32));
+	if (err) {
+		err = -ENODEV;
 		asd_printk("no suitable DMA mask for %s\n", pci_name(dev));
 		goto Err_remove;
 	}
-- 
2.16.4

The patch subject should be "aic94xx:", Martin, can you fix this up?

Reviewed-by: Ewan D. Milne <emilne@redhat.com>

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

* Re: [PATCH 5/8] bfa: fix calls to dma_set_mask_and_coherent()
  2019-02-18  7:34 ` [PATCH 5/8] bfa: " Hannes Reinecke
  2019-02-18  9:25   ` Christoph Hellwig
@ 2019-02-26  0:34   ` Ewan Milne
  1 sibling, 0 replies; 25+ messages in thread
From: Ewan Milne @ 2019-02-26  0:34 UTC (permalink / raw)
  To: Hannes Reinecke; +Cc: Martin K. Petersen, James Bottomley, linux-scsi, stable

The change to use dma_set_mask_and_coherent() incorrectly made a second
call with the 32 bit DMA mask value when the call with the 64 bit DMA
mask value succeeded.  This resulted in FC connections failing due
to corrupted data buffers, and various other SCSI/FCP I/O errors.

Fixes: a69b080025ea ("scsi: bfa: use dma_set_mask_and_coherent")
Cc: <stable@vger.kernel.org>
Suggested-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/bfa/bfad.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c
index 42a0caf6740d..88880a66a189 100644
--- a/drivers/scsi/bfa/bfad.c
+++ b/drivers/scsi/bfa/bfad.c
@@ -727,7 +727,7 @@ bfad_init_timer(struct bfad_s *bfad)
 int
 bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad)
 {
-	int		rc = -ENODEV;
+	int rc = -ENODEV;
 
 	if (pci_enable_device(pdev)) {
 		printk(KERN_ERR "pci_enable_device fail %p\n", pdev);
@@ -739,8 +739,12 @@ bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad)
 
 	pci_set_master(pdev);
 
-	if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
-	    dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
+	rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+	if (rc)
+		rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+
+	if (rc) {
+		rc = -ENODEV;
 		printk(KERN_ERR "dma_set_mask_and_coherent fail %p\n", pdev);
 		goto out_release_region;
 	}
@@ -1534,6 +1538,7 @@ bfad_pci_slot_reset(struct pci_dev *pdev)
 {
 	struct bfad_s *bfad = pci_get_drvdata(pdev);
 	u8 byte;
+	int rc;
 
 	dev_printk(KERN_ERR, &pdev->dev,
 		   "bfad_pci_slot_reset flags: 0x%x\n", bfad->bfad_flags);
@@ -1561,8 +1566,11 @@ bfad_pci_slot_reset(struct pci_dev *pdev)
 	pci_save_state(pdev);
 	pci_set_master(pdev);
 
-	if (dma_set_mask_and_coherent(&bfad->pcidev->dev, DMA_BIT_MASK(64)) ||
-	    dma_set_mask_and_coherent(&bfad->pcidev->dev, DMA_BIT_MASK(32)))
+	rc = dma_set_mask_and_coherent(&bfad->pcidev->dev, DMA_BIT_MASK(64));
+	if (rc)
+		rc = dma_set_mask_and_coherent(&bfad->pcidev->dev,
+					       DMA_BIT_MASK(32));
+	if (rc)
 		goto out_disable_device;
 
 	if (restart_bfa(bfad) == -1)
-- 
2.16.4

Can we remove the last sentence "This resulted in...", Martin?

Reviewed-by: Ewan D. Milne <emilne@redhat.com>


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

* Re: [PATCH 6/8] csiostor: fix calls to dma_set_mask_and_coherent()
  2019-02-18  7:34 ` [PATCH 6/8] csiostor: " Hannes Reinecke
  2019-02-18  9:25   ` Christoph Hellwig
@ 2019-02-26  0:35   ` Ewan Milne
  1 sibling, 0 replies; 25+ messages in thread
From: Ewan Milne @ 2019-02-26  0:35 UTC (permalink / raw)
  To: Hannes Reinecke; +Cc: Martin K. Petersen, James Bottomley, linux-scsi, stable

The change to use dma_set_mask_and_coherent() incorrectly made a second
call with the 32 bit DMA mask value when the call with the 64 bit DMA
mask value succeeded.

Fixes: c22b332d811b ("scsi: csiostor: switch to generic DMA API")
Cc: <stable@vger.kernel.org>
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/csiostor/csio_init.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/csiostor/csio_init.c b/drivers/scsi/csiostor/csio_init.c
index 460e4ee1c8fe..a6dd704d7f2d 100644
--- a/drivers/scsi/csiostor/csio_init.c
+++ b/drivers/scsi/csiostor/csio_init.c
@@ -206,8 +206,11 @@ csio_pci_init(struct pci_dev *pdev, int *bars)
 	pci_set_master(pdev);
 	pci_try_set_mwi(pdev);
 
-	if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
-	    dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
+	rv = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+	if (rv)
+		rv = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+	if (rv) {
+		rv = -ENODEV;
 		dev_err(&pdev->dev, "No suitable DMA available.\n");
 		goto err_release_regions;
 	}
-- 
2.16.4

Reviewed-by: Ewan D. Milne <emilne@redhat.com>

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

* Re: [PATCH 7/8] hisi_sas: fix calls to dma_set_mask_and_coherent()
  2019-02-18  7:34 ` [PATCH 7/8] hisi_sas: " Hannes Reinecke
  2019-02-18  9:24   ` John Garry
  2019-02-18  9:26   ` Christoph Hellwig
@ 2019-02-26  0:37   ` Ewan Milne
  2 siblings, 0 replies; 25+ messages in thread
From: Ewan Milne @ 2019-02-26  0:37 UTC (permalink / raw)
  To: Hannes Reinecke; +Cc: Martin K. Petersen, James Bottomley, linux-scsi, stable

The change to use dma_set_mask_and_coherent() incorrectly made a second
call with the 32 bit DMA mask value when the call with the 64 bit DMA
mask value succeeded.  This resulted in FC connections failing due
to corrupted data buffers, and various other SCSI/FCP I/O errors.

Fixes: e4db40e7a1a2 ("scsi: hisi_sas: use dma_set_mask_and_coherent")
Cc: <stable@vger.kernel.org>
Suggested-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/hisi_sas/hisi_sas_main.c  | 8 ++++++--
 drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 8 +++++---
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 923296653ed7..13ca5a0bdf6b 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -2484,6 +2484,7 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev,
 	struct Scsi_Host *shost;
 	struct hisi_hba *hisi_hba;
 	struct device *dev = &pdev->dev;
+	int error;
 
 	shost = scsi_host_alloc(hw->sht, sizeof(*hisi_hba));
 	if (!shost) {
@@ -2504,8 +2505,11 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev,
 	if (hisi_sas_get_fw_info(hisi_hba) < 0)
 		goto err_out;
 
-	if (dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)) &&
-	    dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32))) {
+	error = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64));
+	if (error)
+		error = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
+
+	if (error) {
 		dev_err(dev, "No usable DMA addressing method\n");
 		goto err_out;
 	}
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
index 00738d0673fe..79390f235c7e 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
@@ -2742,10 +2742,12 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	if (rc)
 		goto err_out_disable_device;
 
-	if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
-	    dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
+	rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+	if (rc)
+		rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+	if (rc) {
 		dev_err(dev, "No usable DMA addressing method\n");
-		rc = -EIO;
+		rc = -ENODEV;
 		goto err_out_regions;
 	}
 
-- 
2.16.4

Can we remove the last sentence "This resulted in...", Martin?

Reviewed-by: Ewan D. Milne <emilne@redhat.com>

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

* Re: [PATCH 8/8] hptiop: fix calls to dma_set_mask()
  2019-02-18  7:34 ` [PATCH 8/8] hptiop: fix calls to dma_set_mask() Hannes Reinecke
  2019-02-18  9:26   ` Christoph Hellwig
@ 2019-02-26  0:38   ` Ewan Milne
  1 sibling, 0 replies; 25+ messages in thread
From: Ewan Milne @ 2019-02-26  0:38 UTC (permalink / raw)
  To: Hannes Reinecke; +Cc: Martin K. Petersen, James Bottomley, linux-scsi, stable

The change to use dma_set_mask() incorrectly made a second call with the
32 bit DMA mask value when the call with the 64 bit DMA mask value succeeded.

Fixes: 453cd3700ca3 ("scsi: hptiop: use dma_set_mask")
Cc: <stable@vger.kernel.org>
Suggested-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/hptiop.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c
index 3eedfd4f8f57..251c084a6ff0 100644
--- a/drivers/scsi/hptiop.c
+++ b/drivers/scsi/hptiop.c
@@ -1292,6 +1292,7 @@ static int hptiop_probe(struct pci_dev *pcidev, const struct pci_device_id *id)
 	dma_addr_t start_phy;
 	void *start_virt;
 	u32 offset, i, req_size;
+	int rc;
 
 	dprintk("hptiop_probe(%p)\n", pcidev);
 
@@ -1308,9 +1309,12 @@ static int hptiop_probe(struct pci_dev *pcidev, const struct pci_device_id *id)
 
 	/* Enable 64bit DMA if possible */
 	iop_ops = (struct hptiop_adapter_ops *)id->driver_data;
-	if (dma_set_mask(&pcidev->dev,
-			 DMA_BIT_MASK(iop_ops->hw_dma_bit_mask)) ||
-	    dma_set_mask(&pcidev->dev, DMA_BIT_MASK(32))) {
+	rc = dma_set_mask(&pcidev->dev,
+			  DMA_BIT_MASK(iop_ops->hw_dma_bit_mask));
+	if (rc)
+		rc = dma_set_mask(&pcidev->dev, DMA_BIT_MASK(32));
+
+	if (rc) {
 		printk(KERN_ERR "hptiop: fail to set dma_mask\n");
 		goto disable_pci_device;
 	}
-- 
2.16.4

Reviewed-by: Ewan D. Milne <emilne@redhat.com>


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

end of thread, other threads:[~2019-02-26  0:38 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20190218073426.111853-1-hare@suse.de>
2019-02-18  7:34 ` [PATCH 1/8] lpfc: fix calls to dma_set_mask_and_coherent() Hannes Reinecke
2019-02-18  9:24   ` Christoph Hellwig
2019-02-26  0:29   ` Ewan Milne
2019-02-18  7:34 ` [PATCH 2/8] 3w-9xxx: " Hannes Reinecke
2019-02-18  9:24   ` Christoph Hellwig
2019-02-26  0:30   ` Ewan Milne
2019-02-18  7:34 ` [PATCH 3/8] 3w-sas: " Hannes Reinecke
2019-02-18  9:24   ` Christoph Hellwig
2019-02-26  0:30   ` Ewan Milne
2019-02-18  7:34 ` [PATCH 4/8] " Hannes Reinecke
2019-02-18  9:25   ` Christoph Hellwig
2019-02-26  0:32   ` Ewan Milne
2019-02-18  7:34 ` [PATCH 5/8] bfa: " Hannes Reinecke
2019-02-18  9:25   ` Christoph Hellwig
2019-02-26  0:34   ` Ewan Milne
2019-02-18  7:34 ` [PATCH 6/8] csiostor: " Hannes Reinecke
2019-02-18  9:25   ` Christoph Hellwig
2019-02-26  0:35   ` Ewan Milne
2019-02-18  7:34 ` [PATCH 7/8] hisi_sas: " Hannes Reinecke
2019-02-18  9:24   ` John Garry
2019-02-18  9:26   ` Christoph Hellwig
2019-02-26  0:37   ` Ewan Milne
2019-02-18  7:34 ` [PATCH 8/8] hptiop: fix calls to dma_set_mask() Hannes Reinecke
2019-02-18  9:26   ` Christoph Hellwig
2019-02-26  0:38   ` Ewan Milne

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).