scsi: 3w-sas: fix calls to dma_set_mask_and_coherent() [Linux 5.0]

This Linux kernel change "scsi: 3w-sas: fix calls to dma_set_mask_and_coherent()" is included in the Linux 5.0 release. This change is authored by Hannes Reinecke <hare [at] suse.de> on Mon Feb 18 08:34:21 2019 +0100. The commit for this change in Linux stable tree is 1feb3b0 (patch).

scsi: 3w-sas: fix calls to dma_set_mask_and_coherent()

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: <[email protected]>
Signed-off-by: Hannes Reinecke <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Reviewed-by: Ewan D. Milne <[email protected]>
Signed-off-by: Martin K. Petersen <[email protected]>

There are 12 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 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 e8f5f7c..2d15b87 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;

Leave a Reply

Your email address will not be published. Required fields are marked *