Skip to content

Commit 739eb25

Browse files
ssuthiku-amdjoergroedel
authored andcommitted
iommu/amd: Introduce iommu_dev_data.ppr
For AMD IOMMU, the PPR feature is needed to support IO page fault (IOPF). PPR is enabled per PCI end-point device, and is configured by the PPR bit in the IOMMU device table entry (i.e DTE[PPR]). Introducing struct iommu_dev_data.ppr track PPR setting for each device. Also iommu_dev_data.ppr will be set only when IOMMU supports PPR. Hence remove redundant feature support check in set_dte_entry(). Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Co-developed-by: Vasant Hegde <vasant.hegde@amd.com> Signed-off-by: Vasant Hegde <vasant.hegde@amd.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com> Link: https://lore.kernel.org/r/20230921092147.5930-12-vasant.hegde@amd.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent b0cc5da commit 739eb25

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

drivers/iommu/amd/amd_iommu_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,7 @@ struct iommu_dev_data {
816816
u8 ats_enabled :1; /* ATS state */
817817
u8 pri_tlp :1; /* PASID TLB required for
818818
PPR completions */
819+
u8 ppr :1; /* Enable device PPR support */
819820
bool use_vapic; /* Enable device to use vapic mode */
820821
bool defer_attach;
821822

drivers/iommu/amd/iommu.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,10 +1638,8 @@ static void set_dte_entry(struct amd_iommu *iommu, u16 devid,
16381638
if (ats)
16391639
flags |= DTE_FLAG_IOTLB;
16401640

1641-
if (ppr) {
1642-
if (check_feature(FEATURE_EPHSUP))
1643-
pte_root |= 1ULL << DEV_ENTRY_PPR;
1644-
}
1641+
if (ppr)
1642+
pte_root |= 1ULL << DEV_ENTRY_PPR;
16451643

16461644
if (domain->flags & PD_IOMMUV2_MASK) {
16471645
u64 gcr3 = iommu_virt_to_phys(domain->gcr3_tbl);
@@ -1734,7 +1732,7 @@ static void do_attach(struct iommu_dev_data *dev_data,
17341732

17351733
/* Update device table */
17361734
set_dte_entry(iommu, dev_data->devid, domain,
1737-
ats, dev_data->iommu_v2);
1735+
ats, dev_data->ppr);
17381736
clone_aliases(iommu, dev_data->dev);
17391737

17401738
device_flush_dte(dev_data);
@@ -2013,7 +2011,7 @@ static void update_device_table(struct protection_domain *domain)
20132011
if (!iommu)
20142012
continue;
20152013
set_dte_entry(iommu, dev_data->devid, domain,
2016-
dev_data->ats_enabled, dev_data->iommu_v2);
2014+
dev_data->ats_enabled, dev_data->ppr);
20172015
clone_aliases(iommu, dev_data->dev);
20182016
}
20192017
}

0 commit comments

Comments
 (0)