Skip to content

Commit a11bfde

Browse files
committed
iommu/vt-d: Do deferred attachment in iommu_need_mapping()
The attachment of deferred devices needs to happen before the check whether the device is identity mapped or not. Otherwise the check will return wrong results, cause warnings boot failures in kdump kernels, like WARNING: CPU: 0 PID: 318 at ../drivers/iommu/intel-iommu.c:592 domain_get_iommu+0x61/0x70 [...] Call Trace: __intel_map_single+0x55/0x190 intel_alloc_coherent+0xac/0x110 dmam_alloc_attrs+0x50/0xa0 ahci_port_start+0xfb/0x1f0 [libahci] ata_host_start.part.39+0x104/0x1e0 [libata] With the earlier check the kdump boot succeeds and a crashdump is written. Fixes: 1ee0186 ("iommu/vt-d: Refactor find_domain() helper") Cc: [email protected] # v5.5 Reviewed-by: Jerry Snitselaar <[email protected]> Acked-by: Lu Baolu <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent 034d98c commit a11bfde

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/iommu/intel-iommu.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2541,9 +2541,6 @@ static void do_deferred_attach(struct device *dev)
25412541

25422542
static struct dmar_domain *deferred_attach_domain(struct device *dev)
25432543
{
2544-
if (unlikely(attach_deferred(dev)))
2545-
do_deferred_attach(dev);
2546-
25472544
return find_domain(dev);
25482545
}
25492546

@@ -3595,6 +3592,9 @@ static bool iommu_need_mapping(struct device *dev)
35953592
if (iommu_dummy(dev))
35963593
return false;
35973594

3595+
if (unlikely(attach_deferred(dev)))
3596+
do_deferred_attach(dev);
3597+
35983598
ret = identity_mapping(dev);
35993599
if (ret) {
36003600
u64 dma_mask = *dev->dma_mask;
@@ -3958,7 +3958,11 @@ bounce_map_single(struct device *dev, phys_addr_t paddr, size_t size,
39583958
int prot = 0;
39593959
int ret;
39603960

3961+
if (unlikely(attach_deferred(dev)))
3962+
do_deferred_attach(dev);
3963+
39613964
domain = deferred_attach_domain(dev);
3965+
39623966
if (WARN_ON(dir == DMA_NONE || !domain))
39633967
return DMA_MAPPING_ERROR;
39643968

0 commit comments

Comments
 (0)