iommu/amd: SVA Support (part 2) - deprecate iommu_v2 module
Subsystems (2)
Vasant Hegde
maintainerv2 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 removing dependency on iommu_v2 module [1].
[1] https://patchwork.freedesktop.org/series/122124/
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 modue. 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 SVA Part 1 [1] :
https://lore.kernel.org/linux-iommu/[email protected]/T/#t
Also to build kernel with this series either we need above AMD GPU related changes [1] -OR- compile with kernel config 'CONFIG_HSA_AMD=n'.
This is also available at github :
https://github.com/AMDESE/linux/tree/iommu_sva_part2_v2_iommu_v2_v6.5_rc1
Thanks Jason for reviewing previous versions and providing feedbacks.
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 v2 1/5 iommu/amd: Remove iommu_v2 module
AMD GPU driver which was the only in-kernel user of iommu_v2 module is removing dependency on iommu_v2 module [1].
[1] https://patchwork.freedesktop.org/series/122124/
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
@@ -41,9 +41,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);
@@ -60,8 +57,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
@@ -2568,46 +2568,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
Re: [PATCH v2 1/5] iommu/amd: Remove iommu_v2 module
Quoted 9 lines · Vasant Hegde
AMD GPU driver which was the only in-kernel user of
iommu_v2module is removing dependency oniommu_v2module [1].[1] https://patchwork.freedesktop.org/series/122124/
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.
Quoted 7 lines
Removing
iommu_v2module and then adding SVA simplifies the development. Hence removeiommu_v2module.Cc Alex Deucher <[email protected]>Cc Joerg Roedel <[email protected]>Cc Felix Kuehling <[email protected]>Signed-off-by Vasant Hegde <[email protected]>
Vasant Hegde
maintainerPATCH v2 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
@@ -55,8 +55,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
Re: [PATCH v2 2/5] iommu/amd: Remove PPR support
Quoted 11 lines · Vasant Hegde
Remove 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.
Signed-off-by Vasant Hegde <[email protected]>--- 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(-)
Vasant Hegde
maintainerPATCH v2 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
Re: [PATCH v2 3/5] iommu/amd: Remove amd_iommu_device_info()
Quoted 5 lines · Vasant Hegde
No one is using this function. Hence remove it. Also move PCI device feature detection flags to
amd_iommu_types.has its only used inside AMD IOMMU driver.Signed-off-by Vasant Hegde <[email protected]>
Vasant Hegde
maintainerPATCH v2 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
@@ -2446,7 +2446,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) {
@@ -2606,7 +2605,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) {
@@ -2626,7 +2624,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) {
@@ -2706,7 +2703,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) {
@@ -2720,7 +2716,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)
@@ -2739,7 +2734,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
Re: [PATCH v2 4/5] iommu/amd: Remove unused EXPORT_SYMBOLS
Quoted 8 lines · Vasant Hegde
Drop
EXPORT_SYMBOLSfor the functions that are not used by any modules.Signed-off-by Vasant Hegde <[email protected]>--- drivers/iommu/amd/init.c | 1 - drivers/iommu/amd/iommu.c | 6 ------ 2 files changed, 7 deletions(-)
Vasant Hegde
maintainerPATCH v2 5/5 Revert "iommu: Fix false ownership failure on AMD systems with PASID activated"
In reply to Vasant HegdeThis reverts commit 2380f1e8195ef612deea1dc7a3d611c5d2b9b56a.
Previous patch deprecated 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
@@ -3062,24 +3062,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.
@@ -3099,7 +3081,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
Re: [PATCH v2 5/5] Revert "iommu: Fix false ownership failure on AMD systems with PASID activated"
Quoted 11 lines · Vasant Hegde
This reverts commit
2380f1e8195ef612deea1dc7a3d611c5d2b9b56a.Previous patch deprecated AMD
iommu_v2module. Hence its safe to revert this workaround.Suggested-by Jason Gunthorpe <[email protected]>Cc Robin Murphy <[email protected]>Cc Takashi Iwai <[email protected]>Cc Jason Gunthorpe <[email protected]>Cc Joerg Roedel <[email protected]>Signed-off-by Vasant Hegde <[email protected]>
Quoted 4 lines
--- drivers/iommu/iommu.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-)
Minor thing, but is the deprecate the correct term to use here and in the cover letter since the series removes the iommu_v2 module completely?
Vasant Hegde
maintainerRe: [PATCH v2 5/5] Revert "iommu: Fix false ownership failure on AMD systems with PASID activated"
Jerry,
Quoted 17 lines · Jerry Snitselaar
Quoted 11 lines · Vasant Hegde
This reverts commit
2380f1e8195ef612deea1dc7a3d611c5d2b9b56a.Previous patch deprecated AMD
iommu_v2module. Hence its safe to revert this workaround.Suggested-by Jason Gunthorpe <[email protected]>Cc Robin Murphy <[email protected]>Cc Takashi Iwai <[email protected]>Cc Jason Gunthorpe <[email protected]>Cc Joerg Roedel <[email protected]>Signed-off-by Vasant Hegde <[email protected]>Quoted 4 lines
--- drivers/iommu/iommu.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-)
Quoted 3 lines
Minor thing, but is the deprecate the correct term to use here and in the cover letter since the series removes the
iommu_v2module completely?
Yeah. I will fix it in next iteration.
Thanks
-Vasant
Quoted 38 lines · Vasant Hegde
This is part 2 of the 4-part series to introduce Share Virtual Address (SVA) support. This series removes
iommu_v2module support.AMD GPU driver which was the only in-kernel user of
iommu_v2module is removing dependency oniommu_v2module [1].[1] https://patchwork.freedesktop.org/series/122124/
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_v2module and the functions used to supportiommu_v2modue. 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 SVA Part 1 [1] :
https://lore.kernel.org/linux-iommu/[email protected]/T/#tAlso to build kernel with this series either we need above AMD GPU related changes [1] -OR- compile with kernel config '
CONFIG_HSA_AMD=n'.This is also available at github :
https://github.com/AMDESE/linux/tree/iommu_sva_part2_v2_iommu_v2_v6.5_rc1Thanks Jason for reviewing previous versions and providing feedbacks.
Changes from v1 -> v2:
- Added patch to revert commit2380f1e8195ev1 : https://lore.kernel.org/linux-iommu/[email protected]/
Thank you,
Vasant / Suravee
Quoted 6 lines
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"
For the series
Jason