@@ -2452,9 +2452,6 @@ static void do_deferred_attach(struct de
static struct dmar_domain *deferred_attach_domain(struct device *dev)
{
- if (unlikely(attach_deferred(dev)))
- do_deferred_attach(dev);
-
return find_domain(dev);
}
@@ -3478,6 +3475,9 @@ static bool iommu_need_mapping(struct de
if (iommu_dummy(dev))
return false;
+ if (unlikely(attach_deferred(dev)))
+ do_deferred_attach(dev);
+
ret = identity_mapping(dev);
if (ret) {
u64 dma_mask = *dev->dma_mask;
@@ -3841,7 +3841,11 @@ bounce_map_single(struct device *dev, ph
int prot = 0;
int ret;
+ if (unlikely(attach_deferred(dev)))
+ do_deferred_attach(dev);
+
domain = deferred_attach_domain(dev);
+
if (WARN_ON(dir == DMA_NONE || !domain))
return DMA_MAPPING_ERROR;