scsi: csiostor: fix calls to dma_set_mask_and_coherent() [Linux 5.0]

scsi: csiostor: fix calls to dma_set_mask_and_coherent() [Linux 5.0]

This Linux kernel change "scsi: csiostor: 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]> on Mon Feb 18 08:34:24 2019 +0100. The commit for this change in Linux stable tree is 732f323 (patch).

scsi: csiostor: 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: c22b332d811b ("scsi: csiostor: switch to 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 7 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 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 cf62938..616b25b 100644
--- a/drivers/scsi/csiostor/csio_init.c
+++ b/drivers/scsi/csiostor/csio_init.c
@@ -210,8 +210,11 @@ static int csio_setup_debugfs(struct csio_hw *hw)

-   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;

Leave a Reply

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