iommu/amd: SVA Support (part 2) - deprecate iommu_v2 module
Subsystems (2)
Vasant Hegde
maintainerv4 cover iommu/amd: SVA Support (part 2) - deprecate iommu_v2 module
This is part 2 of the 4-part series to introduce Share Virtual Address (SVA) support. This series removes iommu_v2 module support.
AMD GPU driver which was the only in-kernel user of iommu_v2 module is removed dependency on iommu_v2 module. These changes are already in upstream (v6.6 merge window).
Also subsequent series will add SVA spuport in AMD IOMMU driver. Device drivers are expected to use common SVA framework to enable device PASID/PRI features.
Hence this series removes iommu_v2 module and the functions used to support iommu_v2 module. Note that there are certain functions (ex: PPR interrupt handling code) which will be used in subsequent series for SVA support. Hence not removed those functions.
This patch series is based on top of iommu/next branch (Commit 8e5ab3f54a10).
Changes from v3 -> v4:
- Rebased on top of iommu/next branch
- Added 'Tested-by'
v3 : https://lore.kernel.org/linux-iommu/[email protected]/T/#t
Changes from v2 -> v3:
- Updated description as AMD GPU related changes are merged in v6.6 merge window
- Few other updated to description based on Jerry's suggestion
- Added Reviewed-by tags
v2 : https://lore.kernel.org/linux-iommu/[email protected]/T/#t
Changes from v1 -> v2:
- Added patch to revert commit 2380f1e8195e
v1 : https://lore.kernel.org/linux-iommu/[email protected]/
Thank you,
Vasant / Suravee
Vasant Hegde (5):
iommu/amd: Remove iommu_v2 module
iommu/amd: Remove PPR support
iommu/amd: Remove amd_iommu_device_info()
iommu/amd: Remove unused EXPORT_SYMBOLS
Revert "iommu: Fix false ownership failure on AMD systems with PASID activated"
drivers/iommu/amd/Kconfig | 9 - drivers/iommu/amd/Makefile | 1 - drivers/iommu/amd/amd_iommu.h | 7 - drivers/iommu/amd/amd_iommu_types.h | 21 +- drivers/iommu/amd/init.c | 1 - drivers/iommu/amd/iommu.c | 133 +--- drivers/iommu/amd/iommu_v2.c | 996 ---------------------------- drivers/iommu/iommu.c | 20 +- include/linux/amd-iommu.h | 120 ---- 9 files changed, 10 insertions(+), 1298 deletions(-) delete mode 100644 drivers/iommu/amd/iommu_v2.c
Signature · 1 line
2.31.1
Vasant Hegde
maintainerPATCH v4 1/5 iommu/amd: Remove iommu_v2 module
AMD GPU driver which was the only in-kernel user of iommu_v2 module removed dependency on iommu_v2 module.
Also we are working on adding SVA support in AMD IOMMU driver. Device drivers are expected to use common SVA framework to enable device PASID/PRI features.
Removing iommu_v2 module and then adding SVA simplifies the development. Hence remove iommu_v2 module.
--- drivers/iommu/amd/Kconfig | 9 - drivers/iommu/amd/Makefile | 1 - drivers/iommu/amd/amd_iommu.h | 5 - drivers/iommu/amd/iommu.c | 40 -- drivers/iommu/amd/iommu_v2.c | 996 ---------------------------------- include/linux/amd-iommu.h | 94 ---- 6 files changed, 1145 deletions(-) delete mode 100644 drivers/iommu/amd/iommu_v2.c
drivers/iommu/amd/Kconfig +0 -9
@@ -22,15 +22,6 @@ config AMD_IOMMU your BIOS for an option to enable it or if you have an IVRS ACPI table. -config AMD_IOMMU_V2 - tristate "AMD IOMMU Version 2 driver" - depends on AMD_IOMMU - select MMU_NOTIFIER - help - This option enables support for the AMD IOMMUv2 features of the IOMMU - hardware. Select this option if you want to use devices that support - the PCI PRI and PASID interface. - config AMD_IOMMU_DEBUGFS bool "Enable AMD IOMMU internals in DebugFS" depends on AMD_IOMMU && IOMMU_DEBUGFS
drivers/iommu/amd/Makefile +0 -1
@@ -1,4 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_AMD_IOMMU) += iommu.o init.o quirks.o io_pgtable.o io_pgtable_v2.o obj-$(CONFIG_AMD_IOMMU_DEBUGFS) += debugfs.o -obj-$(CONFIG_AMD_IOMMU_V2) += iommu_v2.o
drivers/iommu/amd/amd_iommu.h +0 -5
@@ -38,9 +38,6 @@ extern int amd_iommu_guest_ir;extern enum io_pgtable_fmt amd_iommu_pgtable;extern int amd_iommu_gpt_level; -/* IOMMUv2 specific functions */ -struct iommu_domain ; -bool amd_iommu_v2_supported (void );struct amd_iommu *get_amd_iommu (unsigned int idx);u8 amd_iommu_pc_get_max_banks (unsigned int idx);
@@ -57,8 +54,6 @@ void amd_iommu_pdev_disable_cap_pri(struct pci_dev *pdev);int amd_iommu_register_ppr_notifier (struct notifier_block *nb);int amd_iommu_unregister_ppr_notifier (struct notifier_block *nb); -void amd_iommu_domain_direct_map (struct iommu_domain *dom); -int amd_iommu_domain_enable_v2 (struct iommu_domain *dom,int pasids);int amd_iommu_flush_page (struct iommu_domain *dom,u32 pasid,u64 address);void amd_iommu_update_and_flush_device_table (struct protection_domain *domain);void amd_iommu_domain_update (struct protection_domain *domain);
drivers/iommu/amd/iommu.c +0 -40
@@ -2569,46 +2569,6 @@ int amd_iommu_unregister_ppr_notifier(struct notifier_block *nb) }EXPORT_SYMBOL (amd_iommu_unregister_ppr_notifier); -void amd_iommu_domain_direct_map (struct iommu_domain *dom) -{ -struct protection_domain *domain =to_pdomain (dom); -unsigned long flags; - -spin_lock_irqsave (&domain->lock, flags); - -if (domain->iop.pgtbl_cfg.tlb) -free_io_pgtable_ops (&domain->iop.iop.ops); - -spin_unlock_irqrestore (&domain->lock, flags); -} -EXPORT_SYMBOL (amd_iommu_domain_direct_map); - -int amd_iommu_domain_enable_v2 (struct iommu_domain *dom,int pasids) -{ -struct protection_domain *pdom =to_pdomain (dom); -unsigned long flags; -int ret; - -spin_lock_irqsave (&pdom->lock, flags); - -/* -* Save us all sanity checks whether devices already in the -* domain support IOMMUv2. Just force that the domain has no -* devices attached when it is switched into IOMMUv2 mode. -*/ - ret = -EBUSY ; -if (pdom->dev_cnt >0 || pdom->flags &PD_IOMMUV2_MASK ) - goto out; - -if (!pdom->gcr3_tbl) - ret =setup_gcr3_table (pdom, pasids); - -out: -spin_unlock_irqrestore (&pdom->lock, flags); -return ret; -} -EXPORT_SYMBOL (amd_iommu_domain_enable_v2); -static int __flush_pasid (struct protection_domain *domain,u32 pasid,u64 address,bool size) {
drivers/iommu/amd/iommu_v2.c deleted +0 -996
996 lines not on this page · raw message
include/linux/amd-iommu.h +0 -94
106 lines not on this page · raw message
Signature · 1 line
2.31.1
Vasant Hegde
maintainerPATCH v4 2/5 iommu/amd: Remove PPR support
In reply to Vasant HegdeRemove PPR handler and notifier related functions as its not used anymore. Note that we are retaining PPR interrupt handler support as it will be re-used when we introduce IOPF support.
--- drivers/iommu/amd/amd_iommu.h | 2 -- drivers/iommu/amd/amd_iommu_types.h | 13 --------- drivers/iommu/amd/iommu.c | 45 +---------------------------- 3 files changed, 1 insertion(+), 59 deletions(-)
drivers/iommu/amd/amd_iommu.h +0 -2
@@ -52,8 +52,6 @@ int amd_iommu_pc_set_reg(struct amd_iommu *iommu, u8 bank, u8 cntr,int amd_iommu_pdev_enable_cap_pri (struct pci_dev *pdev);void amd_iommu_pdev_disable_cap_pri (struct pci_dev *pdev); -int amd_iommu_register_ppr_notifier (struct notifier_block *nb); -int amd_iommu_unregister_ppr_notifier (struct notifier_block *nb);int amd_iommu_flush_page (struct iommu_domain *dom,u32 pasid,u64 address);void amd_iommu_update_and_flush_device_table (struct protection_domain *domain);void amd_iommu_domain_update (struct protection_domain *domain);
drivers/iommu/amd/amd_iommu_types.h +0 -13
@@ -509,19 +509,6 @@ extern struct kmem_cache *amd_iommu_irq_cache;#define APERTURE_RANGE_INDEX (a) ((a) >> APERTURE_RANGE_SHIFT)#define APERTURE_PAGE_INDEX (a) (((a) >> 21) & 0x3fULL) -/* -* This struct is used to pass information about -* incoming PPR faults around. -*/ -struct amd_iommu_fault { -u64 address;/* IO virtual address of the fault*/ -u32 pasid;/* Address space identifier */ -u32 sbdf;/* Originating PCI device id */ -u16 tag;/* PPR tag */ -u16 flags;/* Fault flags */ - -}; -struct amd_iommu ;struct iommu_domain ;
drivers/iommu/amd/iommu.c +1 -44
69 lines not on this page · raw message
Signature · 1 line
2.31.1
Vasant Hegde
maintainerPATCH v4 3/5 iommu/amd: Remove amd_iommu_device_info()
In reply to Vasant HegdeNo one is using this function. Hence remove it. Also move PCI device feature detection flags to amd_iommu_types.h as its only used inside AMD IOMMU driver.
--- drivers/iommu/amd/amd_iommu_types.h | 8 ++++++ drivers/iommu/amd/iommu.c | 42 ----------------------------- include/linux/amd-iommu.h | 26 ------------------ 3 files changed, 8 insertions(+), 68 deletions(-)
drivers/iommu/amd/amd_iommu_types.h +8 -0
@@ -786,6 +786,14 @@ struct devid_map {bool cmd_line; }; +#define AMD_IOMMU_DEVICE_FLAG_ATS_SUP 0x1/* ATS feature supported */ +#define AMD_IOMMU_DEVICE_FLAG_PRI_SUP 0x2/* PRI feature supported */ +#define AMD_IOMMU_DEVICE_FLAG_PASID_SUP 0x4/* PASID context supported */ +/* Device may request execution on memory pages */ +#define AMD_IOMMU_DEVICE_FLAG_EXEC_SUP 0x8 +/* Device may request super-user privileges */ +#define AMD_IOMMU_DEVICE_FLAG_PRIV_SUP 0x10 +/* * This struct contains device specific data for the IOMMU */
drivers/iommu/amd/iommu.c +0 -42
48 lines not on this page · raw message
include/linux/amd-iommu.h +0 -26
@@ -33,32 +33,6 @@ struct pci_dev;extern int amd_iommu_detect (void ); -/** -* amd_iommu_device_info() - Get information about IOMMUv2 support of a -* PCI device -* @pdev: PCI device to query information from -* @info: A pointer to an amd_iommu_device_info structure which will contain -* the information about the PCI device -* -* Returns 0 on success, negative value on error -*/ - -#define AMD_IOMMU_DEVICE_FLAG_ATS_SUP 0x1/* ATS feature supported */ -#define AMD_IOMMU_DEVICE_FLAG_PRI_SUP 0x2/* PRI feature supported */ -#define AMD_IOMMU_DEVICE_FLAG_PASID_SUP 0x4/* PASID context supported */ -#define AMD_IOMMU_DEVICE_FLAG_EXEC_SUP 0x8/* Device may request execution -on memory pages */ -#define AMD_IOMMU_DEVICE_FLAG_PRIV_SUP 0x10/* Device may request -super-user privileges */ - -struct amd_iommu_device_info { -int max_pasids; -u32 flags; -}; - -extern int amd_iommu_device_info (struct pci_dev *pdev, -struct amd_iommu_device_info *info); -#else /* CONFIG_AMD_IOMMU */ static inline int amd_iommu_detect (void ) {return -ENODEV ; }
Signature · 1 line
2.31.1
Vasant Hegde
maintainerPATCH v4 4/5 iommu/amd: Remove unused EXPORT_SYMBOLS
In reply to Vasant HegdeDrop EXPORT_SYMBOLS for the functions that are not used by any modules.
--- drivers/iommu/amd/init.c | 1 - drivers/iommu/amd/iommu.c | 6 ------ 2 files changed, 7 deletions(-)
drivers/iommu/amd/init.c +0 -1
@@ -3666,7 +3666,6 @@ bool amd_iommu_v2_supported(void)*/ return amd_iommu_gt_ppr_supported () && !amd_iommu_snp_en; } -EXPORT_SYMBOL (amd_iommu_v2_supported);struct amd_iommu *get_amd_iommu (unsigned int idx) {
drivers/iommu/amd/iommu.c +0 -6
@@ -2447,7 +2447,6 @@ bool amd_iommu_is_attach_deferred(struct device *dev)return dev_data->defer_attach; } -EXPORT_SYMBOL_GPL (amd_iommu_is_attach_deferred);static void amd_iommu_flush_iotlb_all (struct iommu_domain *domain) {
@@ -2607,7 +2606,6 @@ int amd_iommu_flush_page(struct iommu_domain *dom, u32 pasid,return ret; } -EXPORT_SYMBOL (amd_iommu_flush_page);static int __amd_iommu_flush_tlb (struct protection_domain *domain,u32 pasid) {
@@ -2627,7 +2625,6 @@ int amd_iommu_flush_tlb(struct iommu_domain *dom, u32 pasid)return ret; } -EXPORT_SYMBOL (amd_iommu_flush_tlb);static u64 *__get_gcr3_pte (u64 *root,int level,u32 pasid,bool alloc) {
@@ -2707,7 +2704,6 @@ int amd_iommu_domain_set_gcr3(struct iommu_domain *dom, u32 pasid,return ret; } -EXPORT_SYMBOL (amd_iommu_domain_set_gcr3);int amd_iommu_domain_clear_gcr3 (struct iommu_domain *dom,u32 pasid) {
@@ -2721,7 +2717,6 @@ int amd_iommu_domain_clear_gcr3(struct iommu_domain *dom, u32 pasid)return ret; } -EXPORT_SYMBOL (amd_iommu_domain_clear_gcr3);int amd_iommu_complete_ppr (struct pci_dev *pdev,u32 pasid,int status,int tag)
@@ -2740,7 +2735,6 @@ int amd_iommu_complete_ppr(struct pci_dev *pdev, u32 pasid,return iommu_queue_command (iommu, &cmd); } -EXPORT_SYMBOL (amd_iommu_complete_ppr);#ifdef CONFIG_IRQ_REMAP
Signature · 1 line
2.31.1
Vasant Hegde
maintainerPATCH v4 5/5 Revert "iommu: Fix false ownership failure on AMD systems with PASID activated"
In reply to Vasant HegdeThis reverts commit 2380f1e8195ef612deea1dc7a3d611c5d2b9b56a.
Previous patch removed AMD iommu_v2 module. Hence its safe to revert this workaround.
--- drivers/iommu/iommu.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-)
drivers/iommu/iommu.c +1 -19
@@ -2957,24 +2957,6 @@ static ssize_t iommu_group_store_type(struct iommu_group *group,return ret ?: count; } -static bool iommu_is_default_domain (struct iommu_group *group) -{ -if (group->domain == group->default_domain) -return true; - -/* -* If the default domain was set to identity and it is still an identity -* domain then we consider this a pass. This happens because of -* amd_iommu_init_device() replacing the default idenytity domain with an -* identity domain that has a different configuration for AMDGPU. -*/ -if (group->default_domain && - group->default_domain->type ==IOMMU_DOMAIN_IDENTITY && - group->domain && group->domain->type ==IOMMU_DOMAIN_IDENTITY ) -return true; -return false; -} -/** * iommu_device_use_default_domain() - Device driver wants to handle device * DMA through the kernel DMA API.
@@ -2994,7 +2976,7 @@ int iommu_device_use_default_domain(struct device *dev)mutex_lock (&group->mutex);if (group->owner_cnt) { -if (group->owner || !iommu_is_default_domain (group) || +if (group->domain != group->default_domain || group->owner || !xa_empty (&group->pasid_array)) { ret = -EBUSY ; goto unlock_out;
Signature · 1 line
2.31.1
Quoted 6 lines · Vasant Hegde
Vasant Hegde (5):
iommu/amd: Removeiommu_v2module
iommu/amd: Remove PPR support
iommu/amd: Removeamd_iommu_device_info()
iommu/amd: Remove unusedEXPORT_SYMBOLS
Revert "iommu: Fix false ownership failure on AMD systems with PASID activated"
Applied, thanks.