Don't update the domain information to the related DTE entry before iommu dev initialization. For this a new member 'domain_updated' is added to iommu_dev_data.
Signed-off-by: Baoquan He <b...@redhat.com> --- drivers/iommu/amd_iommu.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index c0b96e0..b6e669c 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -101,6 +101,7 @@ struct iommu_dev_data { bool pri_tlp; /* PASID TLB required for PPR completions */ u32 errata; /* Bitmap for errata to apply */ + bool domain_updated; }; /* @@ -2046,12 +2047,14 @@ static void do_attach(struct iommu_dev_data *dev_data, domain->dev_iommu[iommu->index] += 1; domain->dev_cnt += 1; - /* Update device table */ - set_dte_entry(dev_data->devid, domain, ats); - if (alias != dev_data->devid) + if (!translation_pre_enabled() || dev_data->domain_updated) { + /* Update device table */ set_dte_entry(dev_data->devid, domain, ats); + if (alias != dev_data->devid) + set_dte_entry(dev_data->devid, domain, ats); - device_flush_dte(dev_data); + device_flush_dte(dev_data); + } } static void do_detach(struct iommu_dev_data *dev_data) @@ -2402,7 +2405,8 @@ static void update_device_table(struct protection_domain *domain) struct iommu_dev_data *dev_data; list_for_each_entry(dev_data, &domain->dev_list, list) - set_dte_entry(dev_data->devid, domain, dev_data->ats.enabled); + if (!translation_pre_enabled() || dev_data->domain_updated) + set_dte_entry(dev_data->devid, domain, dev_data->ats.enabled); } static void update_domain(struct protection_domain *domain) -- 2.1.0 _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu