iommu/amd: Trivial fixes
Subsystems (2)
Vasant Hegde
maintainerv2 cover iommu/amd: Trivial fixes
This series contains minor cleanup and trivial fixes.
Changes from v1 -> v2:
- Consolidated protection domain free code and removed protection_domain_free()
- Added Reviewed-by tags
v1: https://lore.kernel.org/linux-iommu/[email protected]/T/#t
Vasant Hegde (7):
iommu/amd: Log IOMMU control register in event log path iommu/amd: Remove unused variable iommu/amd/pgtbl_v2: Improve error handling iommu/amd: Remove outdated comment
iommu/amd: Fix header file
iommu/amd: Remove unused forward declaration iommu/amd: Consolidate protection domain free code
drivers/iommu/amd/amd_iommu.h | 8 +++----- drivers/iommu/amd/amd_iommu_types.h | 3 --- drivers/iommu/amd/init.c | 1 - drivers/iommu/amd/io_pgtable.c | 7 ------- drivers/iommu/amd/io_pgtable_v2.c | 2 +- drivers/iommu/amd/iommu.c | 19 ++++++++----------- drivers/iommu/amd/pasid.c | 2 +- 7 files changed, 13 insertions(+), 29 deletions(-)
Signature · 1 line
2.31.1
Vasant Hegde
maintainerPATCH v2 1/7 iommu/amd: Log IOMMU control register in event log path
Useful for debugging ILLEGAL_DEV_TABLE_ENTRY events as some of the DTE settings depends on Control register settings.
--- drivers/iommu/amd/iommu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iommu/amd/iommu.c +3 -1
@@ -868,7 +868,7 @@ static void iommu_print_event(struct amd_iommu *iommu, void *__evt)int type, devid, flags, tag;volatile u32 *event = __evt;int count =0 ; -u64 address; +u64 address, ctrl;u32 pasid; retry:
@@ -878,6 +878,7 @@ static void iommu_print_event(struct amd_iommu *iommu, void *__evt) (event[1 ] &EVENT_DOMID_MASK_LO ); flags = (event[1 ] >>EVENT_FLAGS_SHIFT ) &EVENT_FLAGS_MASK ; address = (u64)(((u64 )event[3 ]) <<32 ) | event[2 ]; + ctrl =readq (iommu->mmio_base +MMIO_CONTROL_OFFSET );if (type ==0 ) {/* Did we hit the erratum? */
@@ -899,6 +900,7 @@ static void iommu_print_event(struct amd_iommu *iommu, void *__evt)dev_err (dev,"Event logged [ILLEGAL_DEV_TABLE_ENTRY device=%04x:%02x:%02x.%x pasid=0x%05x address=0x%llx flags=0x%04x]\n" , iommu->pci_seg->id,PCI_BUS_NUM (devid),PCI_SLOT (devid),PCI_FUNC (devid), pasid, address, flags); +dev_err (dev,"Control Reg : 0x%llx\n" , ctrl);dump_dte_entry (iommu, devid);break ;case EVENT_TYPE_DEV_TAB_ERR :
Signature · 1 line
2.31.1
Vasant Hegde
maintainerPATCH v2 2/7 iommu/amd: Remove unused variable
In reply to Vasant HegdeRemove 'amd_iommu_aperture_order' as its not used since commit d9cfed925448.
--- drivers/iommu/amd/amd_iommu_types.h | 3 --- 1 file changed, 3 deletions(-)
drivers/iommu/amd/amd_iommu_types.h +0 -3
@@ -928,9 +928,6 @@ struct unity_map_entry {* Data structures for device handling */ -/* size of the dma_ops aperture as power of 2 */ -extern unsigned amd_iommu_aperture_order; -extern bool amd_iommu_force_isolation;/* Max levels of glxval supported */
Signature · 1 line
2.31.1
Vasant Hegde
maintainerPATCH v2 3/7 iommu/amd/pgtbl_v2: Improve error handling
In reply to Vasant HegdeReturn -ENOMEM if v2_alloc_pte() fails to allocate memory.
--- drivers/iommu/amd/io_pgtable_v2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/amd/io_pgtable_v2.c +1 -1
@@ -254,7 +254,7 @@ static int iommu_v2_map_pages(struct io_pgtable_ops *ops, unsigned long iova, pte =v2_alloc_pte (cfg->amd.nid, pgtable->pgd, iova, map_size, gfp, &updated);if (!pte) { - ret = -EINVAL ; + ret = -ENOMEM ; goto out; }
Signature · 1 line
2.31.1
Vasant Hegde
maintainerPATCH v2 4/7 iommu/amd: Remove outdated comment
In reply to Vasant HegdeRemove outdated comment.
--- drivers/iommu/amd/io_pgtable.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/iommu/amd/io_pgtable.c +0 -7
@@ -47,13 +47,6 @@ static u64 *first_pte_l7(u64 *pte, unsigned long *page_size,return fpte; } -/**************************************************************************** -* -* The functions below are used the create the page table mappings for -* unity mapped regions. -* -****************************************************************************/ -static void free_pt_page (u64 *pt,struct list_head *freelist) {struct page *p =virt_to_page (pt);
Signature · 1 line
2.31.1
Vasant Hegde
maintainerPATCH v2 5/7 iommu/amd: Fix header file
In reply to Vasant HegdeMove function declaration inside AMD_IOMMU_H defination.
--- drivers/iommu/amd/amd_iommu.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/iommu/amd/amd_iommu.h +3 -4
@@ -176,12 +176,11 @@ void amd_iommu_apply_ivrs_quirks(void);#else static inline void amd_iommu_apply_ivrs_quirks (void ) { }#endif +struct dev_table_entry *amd_iommu_get_ivhd_dte_flags (u16 segid,u16 devid);void amd_iommu_domain_set_pgtable (struct protection_domain *domain,u64 *root,int mode);struct dev_table_entry *get_dev_table (struct amd_iommu *iommu); - -#endif - -struct dev_table_entry *amd_iommu_get_ivhd_dte_flags (u16 segid,u16 devid);struct iommu_dev_data *search_dev_data (struct amd_iommu *iommu,u16 devid); + +#endif /* AMD_IOMMU_H */
Signature · 1 line
2.31.1
Vasant Hegde
maintainerPATCH v2 6/7 iommu/amd: Remove unused forward declaration
In reply to Vasant HegdeRemove unused forward declaration.
--- drivers/iommu/amd/init.c | 1 - 1 file changed, 1 deletion(-)
drivers/iommu/amd/init.c +0 -1
@@ -219,7 +219,6 @@ static bool __initdata cmdline_maps;static enum iommu_init_state init_state =IOMMU_START_STATE ;static int amd_iommu_enable_interrupts (void ); -static int __init iommu_go_to_state (enum iommu_init_state state);static void init_device_table_dma (struct amd_iommu_pci_seg *pci_seg);static bool amd_iommu_pre_enabled = true;
Signature · 1 line
2.31.1
Vasant Hegde
maintainerPATCH v2 7/7 iommu/amd: Consolidate protection domain free code
In reply to Vasant HegdeConsolidate protection domain free code inside amd_iommu_domain_free() and remove protection_domain_free() function.
--- drivers/iommu/amd/amd_iommu.h | 1 - drivers/iommu/amd/iommu.c | 15 +++++---------- drivers/iommu/amd/pasid.c | 2 +- 3 files changed, 6 insertions(+), 12 deletions(-)
drivers/iommu/amd/amd_iommu.h +0 -1
@@ -47,7 +47,6 @@ extern unsigned long amd_iommu_pgsize_bitmap;/* Protection domain ops */ void amd_iommu_init_identity_domain (void );struct protection_domain *protection_domain_alloc (void ); -void protection_domain_free (struct protection_domain *domain);struct iommu_domain *amd_iommu_domain_alloc_sva (struct device *dev,struct mm_struct *mm);void amd_iommu_domain_free (struct iommu_domain *dom);
drivers/iommu/amd/iommu.c +5 -10
@@ -2434,15 +2434,6 @@ static struct iommu_group *amd_iommu_device_group(struct device *dev)* *****************************************************************************/ -void protection_domain_free (struct protection_domain *domain) -{ -WARN_ON (!list_empty (&domain->dev_list)); -if (domain->domain.type & __IOMMU_DOMAIN_PAGING) -free_io_pgtable_ops (&domain->iop.pgtbl.ops); -pdom_id_free (domain->id); -kfree (domain); -} -static void protection_domain_init (struct protection_domain *domain) {spin_lock_init (&domain->lock);
@@ -2580,7 +2571,11 @@ void amd_iommu_domain_free(struct iommu_domain *dom) {struct protection_domain *domain =to_pdomain (dom); -protection_domain_free (domain); +WARN_ON (!list_empty (&domain->dev_list)); +if (domain->domain.type & __IOMMU_DOMAIN_PAGING) +free_io_pgtable_ops (&domain->iop.pgtbl.ops); +pdom_id_free (domain->id); +kfree (domain); } static int blocked_domain_attach_device(struct iommu_domain *domain,
drivers/iommu/amd/pasid.c +1 -1
@@ -195,7 +195,7 @@ struct iommu_domain *amd_iommu_domain_alloc_sva(struct device *dev, ret =mmu_notifier_register (&pdom->mn, mm);if (ret) { -protection_domain_free (pdom); +amd_iommu_domain_free (&pdom->domain);return ERR_PTR (ret); }
Signature · 1 line
2.31.1
Quoted 20 lines · Vasant Hegde
This series contains minor cleanup and trivial fixes.
Changes from v1 -> v2:
- Consolidated protection domain free code and removedprotection_domain_free()
- Added Reviewed-by tagsv1: https://lore.kernel.org/linux-iommu/[email protected]/T/#t
Vasant Hegde (7):
iommu/amd: Log IOMMU control register in event log path iommu/amd: Remove unused variable iommu/amd/pgtbl_v2: Improve error handling iommu/amd: Remove outdated comment
iommu/amd: Fix header file
iommu/amd: Remove unused forward declaration iommu/amd: Consolidate protection domain free code
Quoted 8 lines
drivers/iommu/amd/amd_iommu.h | 8 +++----- drivers/iommu/amd/amd_iommu_types.h | 3 --- drivers/iommu/amd/init.c | 1 - drivers/iommu/amd/io_pgtable.c | 7 ------- drivers/iommu/amd/io_pgtable_v2.c | 2 +- drivers/iommu/amd/iommu.c | 19 ++++++++----------- drivers/iommu/amd/pasid.c | 2 +- 7 files changed, 13 insertions(+), 29 deletions(-)
Applied, thanks Vasant.