Skip to content

Commit 924bd96

Browse files
author
Christoph Hellwig
committed
nvme-pci: set the DMA mask earlier
Set the DMA mask before calling dma_addressing_limited, which depends on it. Note that this stop checking the return value of dma_set_mask_and_coherent as this function can only fail for masks < 32-bit. Fixes: 3f30a79 ("nvme-pci: set constant paramters in nvme_pci_alloc_ctrl") Reported-by: Michael Kelley <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Jens Axboe <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Tested-by: Michael Kelley <[email protected]>
1 parent 5f69f00 commit 924bd96

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

drivers/nvme/host/pci.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2509,18 +2509,12 @@ static int nvme_pci_enable(struct nvme_dev *dev)
25092509
{
25102510
int result = -ENOMEM;
25112511
struct pci_dev *pdev = to_pci_dev(dev->dev);
2512-
int dma_address_bits = 64;
25132512

25142513
if (pci_enable_device_mem(pdev))
25152514
return result;
25162515

25172516
pci_set_master(pdev);
25182517

2519-
if (dev->ctrl.quirks & NVME_QUIRK_DMA_ADDRESS_BITS_48)
2520-
dma_address_bits = 48;
2521-
if (dma_set_mask_and_coherent(dev->dev, DMA_BIT_MASK(dma_address_bits)))
2522-
goto disable;
2523-
25242518
if (readl(dev->bar + NVME_REG_CSTS) == -1) {
25252519
result = -ENODEV;
25262520
goto disable;
@@ -2998,7 +2992,11 @@ static struct nvme_dev *nvme_pci_alloc_dev(struct pci_dev *pdev,
29982992
quirks);
29992993
if (ret)
30002994
goto out_put_device;
3001-
2995+
2996+
if (dev->ctrl.quirks & NVME_QUIRK_DMA_ADDRESS_BITS_48)
2997+
dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(48));
2998+
else
2999+
dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
30023000
dma_set_min_align_mask(&pdev->dev, NVME_CTRL_PAGE_SIZE - 1);
30033001
dma_set_max_seg_size(&pdev->dev, 0xffffffff);
30043002

0 commit comments

Comments
 (0)