[PATCH 3/5 v2] iommu/vt-d: Do deferred attachment in iommu_need_mapping()

From: Joerg Roedel
Date: Tue Feb 18 2020 - 04:28:36 EST


Hi Baolu,

On Tue, Feb 18, 2020 at 10:38:14AM +0800, Lu Baolu wrote:
> > diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
> > index 42cdcce1602e..32f43695a22b 100644
> > --- a/drivers/iommu/intel-iommu.c
> > +++ b/drivers/iommu/intel-iommu.c
> > @@ -2541,9 +2541,6 @@ static void do_deferred_attach(struct device *dev)
> > static struct dmar_domain *deferred_attach_domain(struct device *dev)
> > {
> > - if (unlikely(attach_deferred(dev)))
> > - do_deferred_attach(dev);
> > -
>
> This should also be moved to the call place of deferred_attach_domain()
> in bounce_map_single().
>
> bounce_map_single() assumes that devices always use DMA domain, so it
> doesn't call iommu_need_mapping(). We could do_deferred_attach() there
> manually.

Good point, thanks for your review. Updated patch below.