Skip to content

Commit d9a0045

Browse files
hreineckemartinkpetersen
authored andcommitted
scsi: hisi_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. [mkp: fixed commit message] Fixes: e4db40e ("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> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 732f323 commit d9a0045

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

drivers/scsi/hisi_sas/hisi_sas_main.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2323,6 +2323,7 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev,
23232323
struct Scsi_Host *shost;
23242324
struct hisi_hba *hisi_hba;
23252325
struct device *dev = &pdev->dev;
2326+
int error;
23262327

23272328
shost = scsi_host_alloc(hw->sht, sizeof(*hisi_hba));
23282329
if (!shost) {
@@ -2343,8 +2344,11 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev,
23432344
if (hisi_sas_get_fw_info(hisi_hba) < 0)
23442345
goto err_out;
23452346

2346-
if (dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)) &&
2347-
dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32))) {
2347+
error = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64));
2348+
if (error)
2349+
error = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
2350+
2351+
if (error) {
23482352
dev_err(dev, "No usable DMA addressing method\n");
23492353
goto err_out;
23502354
}

drivers/scsi/hisi_sas/hisi_sas_v3_hw.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,10 +2447,12 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id)
24472447
if (rc)
24482448
goto err_out_disable_device;
24492449

2450-
if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
2451-
dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
2450+
rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
2451+
if (rc)
2452+
rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
2453+
if (rc) {
24522454
dev_err(dev, "No usable DMA addressing method\n");
2453-
rc = -EIO;
2455+
rc = -ENODEV;
24542456
goto err_out_regions;
24552457
}
24562458

0 commit comments

Comments
 (0)