aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iommu
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/iommu')
-rw-r--r--drivers/iommu/amd_iommu_init.c13
-rw-r--r--drivers/iommu/amd_iommu_types.h6
2 files changed, 19 insertions, 0 deletions
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 17e0f77c7dad..fb4afd6d357d 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -141,6 +141,8 @@ int amd_iommus_present;
141bool amd_iommu_np_cache __read_mostly; 141bool amd_iommu_np_cache __read_mostly;
142bool amd_iommu_iotlb_sup __read_mostly = true; 142bool amd_iommu_iotlb_sup __read_mostly = true;
143 143
144u32 amd_iommu_max_pasids __read_mostly = ~0;
145
144/* 146/*
145 * The ACPI table parsing functions set this variable on an error 147 * The ACPI table parsing functions set this variable on an error
146 */ 148 */
@@ -699,6 +701,17 @@ static void __init init_iommu_from_pci(struct amd_iommu *iommu)
699 701
700 iommu->features = ((u64)high << 32) | low; 702 iommu->features = ((u64)high << 32) | low;
701 703
704 if (iommu_feature(iommu, FEATURE_GT)) {
705 u32 pasids;
706 u64 shift;
707
708 shift = iommu->features & FEATURE_PASID_MASK;
709 shift >>= FEATURE_PASID_SHIFT;
710 pasids = (1 << shift);
711
712 amd_iommu_max_pasids = min(amd_iommu_max_pasids, pasids);
713 }
714
702 if (!is_rd890_iommu(iommu->dev)) 715 if (!is_rd890_iommu(iommu->dev))
703 return; 716 return;
704 717
diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h
index f8dd9ae693d1..0d984ca925be 100644
--- a/drivers/iommu/amd_iommu_types.h
+++ b/drivers/iommu/amd_iommu_types.h
@@ -87,6 +87,9 @@
87#define FEATURE_HE (1ULL<<8) 87#define FEATURE_HE (1ULL<<8)
88#define FEATURE_PC (1ULL<<9) 88#define FEATURE_PC (1ULL<<9)
89 89
90#define FEATURE_PASID_SHIFT 32
91#define FEATURE_PASID_MASK (0x1fULL << FEATURE_PASID_SHIFT)
92
90/* MMIO status bits */ 93/* MMIO status bits */
91#define MMIO_STATUS_COM_WAIT_INT_MASK 0x04 94#define MMIO_STATUS_COM_WAIT_INT_MASK 0x04
92 95
@@ -549,6 +552,9 @@ extern unsigned long *amd_iommu_pd_alloc_bitmap;
549 */ 552 */
550extern bool amd_iommu_unmap_flush; 553extern bool amd_iommu_unmap_flush;
551 554
555/* Smallest number of PASIDs supported by any IOMMU in the system */
556extern u32 amd_iommu_max_pasids;
557
552/* takes bus and device/function and returns the device id 558/* takes bus and device/function and returns the device id
553 * FIXME: should that be in generic PCI code? */ 559 * FIXME: should that be in generic PCI code? */
554static inline u16 calc_devid(u8 bus, u8 devfn) 560static inline u16 calc_devid(u8 bus, u8 devfn)