Skip to content

Commit 56de835

Browse files
hreineckemartinkpetersen
authored andcommitted
scsi: lpfc: 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. This resulted in NVMe/FC connections failing due to corrupted data buffers, and various other SCSI/FCP I/O errors. Fixes: f30e1bf ("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> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Ewan D. Milne <emilne@redhat.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 4a067cf commit 56de835

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

drivers/scsi/lpfc/lpfc_init.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7361,15 +7361,18 @@ lpfc_sli_pci_mem_setup(struct lpfc_hba *phba)
73617361
unsigned long bar0map_len, bar2map_len;
73627362
int i, hbq_count;
73637363
void *ptr;
7364-
int error = -ENODEV;
7364+
int error;
73657365

73667366
if (!pdev)
7367-
return error;
7367+
return -ENODEV;
73687368

73697369
/* Set the device DMA mask size */
7370-
if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
7371-
dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)))
7370+
error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
7371+
if (error)
7372+
error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
7373+
if (error)
73727374
return error;
7375+
error = -ENODEV;
73737376

73747377
/* Get the bus address of Bar0 and Bar2 and the number of bytes
73757378
* required by each mapping.
@@ -9742,11 +9745,13 @@ lpfc_sli4_pci_mem_setup(struct lpfc_hba *phba)
97429745
uint32_t if_type;
97439746

97449747
if (!pdev)
9745-
return error;
9748+
return -ENODEV;
97469749

97479750
/* Set the device DMA mask size */
9748-
if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
9749-
dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)))
9751+
error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
9752+
if (error)
9753+
error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
9754+
if (error)
97509755
return error;
97519756

97529757
/*

0 commit comments

Comments
 (0)