Skip to content

Commit a447dbb

Browse files
ShayAgrosgregkh
authored andcommitted
net: ena: set initial DMA width to avoid intel iommu issue
[ Upstream commit 09323b3 ] The ENA driver uses the readless mechanism, which uses DMA, to find out what the DMA mask is supposed to be. If DMA is used without setting the dma_mask first, it causes the Intel IOMMU driver to think that ENA is a 32-bit device and therefore disables IOMMU passthrough permanently. This patch sets the dma_mask to be ENA_MAX_PHYS_ADDR_SIZE_BITS=48 before readless initialization in ena_device_init()->ena_com_mmio_reg_read_request_init(), which is large enough to workaround the intel_iommu issue. DMA mask is set again to the correct value after it's received from the device after readless is initialized. The patch also changes the driver to use dma_set_mask_and_coherent() function instead of the two pci_set_dma_mask() and pci_set_consistent_dma_mask() ones. Both methods achieve the same effect. Fixes: 1738cd3 ("net: ena: Add a driver for Amazon Elastic Network Adapters (ENA)") Signed-off-by: Mike Cui <[email protected]> Signed-off-by: Arthur Kiyanovski <[email protected]> Signed-off-by: Shay Agroskin <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 7869696 commit a447dbb

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

drivers/net/ethernet/amazon/ena/ena_netdev.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2622,16 +2622,9 @@ static int ena_device_init(struct ena_com_dev *ena_dev, struct pci_dev *pdev,
26222622
goto err_mmio_read_less;
26232623
}
26242624

2625-
rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(dma_width));
2625+
rc = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(dma_width));
26262626
if (rc) {
2627-
dev_err(dev, "pci_set_dma_mask failed 0x%x\n", rc);
2628-
goto err_mmio_read_less;
2629-
}
2630-
2631-
rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(dma_width));
2632-
if (rc) {
2633-
dev_err(dev, "err_pci_set_consistent_dma_mask failed 0x%x\n",
2634-
rc);
2627+
dev_err(dev, "dma_set_mask_and_coherent failed %d\n", rc);
26352628
goto err_mmio_read_less;
26362629
}
26372630

@@ -3450,6 +3443,12 @@ static int ena_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
34503443
return rc;
34513444
}
34523445

3446+
rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(ENA_MAX_PHYS_ADDR_SIZE_BITS));
3447+
if (rc) {
3448+
dev_err(&pdev->dev, "dma_set_mask_and_coherent failed %d\n", rc);
3449+
goto err_disable_device;
3450+
}
3451+
34533452
pci_set_master(pdev);
34543453

34553454
ena_dev = vzalloc(sizeof(*ena_dev));

0 commit comments

Comments
 (0)