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

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

This Linux kernel change "scsi: aic94xx: 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:22 2019 +0100. The commit for this change in Linux stable tree is c326de5 (patch).

scsi: aic94xx: 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.

[mkp: fixed subject]

Fixes: 3a21986f1a59 ("scsi: aic94xx: 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 8 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 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 07efcb9..bbdae67 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;

Leave a Reply

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