Skip to contentSkip to conversation

iommu/amd: Cleanup and fixes

PATCH In review Vasant Hegde 2 participants 7 messages Sep 11 – Sep 12

Subsystems (2)
lore
Share & tools
lore

Vasant Hegde

author maintainer
#0 lore raw

cover iommu/amd: Cleanup and fixes

This series contains few trivial cleanup (like removing redundant checks, unsed macros, etc,) and fixes.

Vasant Hegde (4):
iommu/amd: Make iommu_sva_set_dev_pasid as static iommu/amd: Remove redundant check in irq_remapping_select() iommu/amd: Remove redundant checks from interrupt handler path iommu/amd: Remove unused macro

 drivers/iommu/amd/amd_iommu.h       |  3 ---
 drivers/iommu/amd/amd_iommu_types.h | 16 ----------------
 drivers/iommu/amd/init.c            |  2 +-
 drivers/iommu/amd/iommu.c           |  6 ------
 drivers/iommu/amd/pasid.c           |  6 +++---
 drivers/iommu/amd/ppr.c             |  3 ---
 6 files changed, 4 insertions(+), 32 deletions(-)
Signature · 1 line
2.31.1
author maintainer
#1 lore raw

PATCH 1/4 iommu/amd: Make iommu_sva_set_dev_pasid as static

Its used inside pasid.c only.

No functional changes.

---
 drivers/iommu/amd/amd_iommu.h | 3 ---
 drivers/iommu/amd/pasid.c     | 6 +++---
 2 files changed, 3 insertions(+), 6 deletions(-)
drivers/iommu/amd/amd_iommu.h +0 -3
index a2fe804b038b..71113e860859 100644
@@ -54,9 +54,6 @@ struct protection_domain *protection_domain_alloc(void);
 struct iommu_domain *amd_iommu_domain_alloc_sva(struct device *dev,
 						struct mm_struct *mm);
 void amd_iommu_domain_free(struct iommu_domain *dom);
-int iommu_sva_set_dev_pasid(struct iommu_domain *domain,
-			    struct device *dev, ioasid_t pasid,
-			    struct iommu_domain *old);
 void amd_iommu_remove_dev_pasid(struct device *dev, ioasid_t pasid,
 				struct iommu_domain *domain);
 
drivers/iommu/amd/pasid.c +3 -3
index d708c6532480..40be5902087c 100644
@@ -99,9 +99,9 @@ static const struct mmu_notifier_ops sva_mn = {
 	.release = sva_mn_release,
 };
 
-int iommu_sva_set_dev_pasid(struct iommu_domain *domain,
-			    struct device *dev, ioasid_t pasid,
-			    struct iommu_domain *old)
+static int iommu_sva_set_dev_pasid(struct iommu_domain *domain,
+				   struct device *dev, ioasid_t pasid,
+				   struct iommu_domain *old)
 {
 	struct pdom_dev_data *pdom_dev_data;
 	struct protection_domain *sva_pdom = to_pdomain(domain);
Signature · 1 line
2.31.1
author maintainer
#2 lore raw

PATCH 2/4 iommu/amd: Remove redundant check in irq_remapping_select()

In reply to Vasant Hegde

The amd_iommu_irq_remap flag is already validated during irq remapping domain creation (before calling amd_iommu_create_irq_domain()). The duplicate check in irq_remapping_select() is unnecessary and can be removed.

Additionally, mark amd_iommu_irq_remap as static.

No functional changes.

---
 drivers/iommu/amd/amd_iommu_types.h | 3 ---
 drivers/iommu/amd/init.c            | 2 +-
 drivers/iommu/amd/iommu.c           | 3 ---
 3 files changed, 1 insertion(+), 7 deletions(-)
drivers/iommu/amd/amd_iommu_types.h +0 -3
index 3dbe20023456..bce5027388b9 100644
@@ -434,9 +434,6 @@ struct irq_remap_table {
 	u32 *table;
 };
 
-/* Interrupt remapping feature used? */
-extern bool amd_iommu_irq_remap;
-
 extern const struct iommu_ops amd_iommu_ops;
 
 /* IVRS indicates that pre-boot remapping was enabled */
drivers/iommu/amd/init.c +1 -1
index edcc187b8f14..8a410d4aa370 100644
@@ -152,7 +152,7 @@ struct ivmd_header {
 } __attribute__((packed));
 
 bool amd_iommu_dump;
-bool amd_iommu_irq_remap __read_mostly;
+static bool amd_iommu_irq_remap __read_mostly;
 
 enum protection_domain_mode amd_iommu_pgtable = PD_MODE_V1;
 /* Virtual address size */
drivers/iommu/amd/iommu.c +0 -3
index 9f9afec68969..5bb7d8cb506e 100644
@@ -3977,9 +3977,6 @@ static int irq_remapping_select(struct irq_domain *d, struct irq_fwspec *fwspec,
 	struct amd_iommu *iommu;
 	int devid = -1;
 
-	if (!amd_iommu_irq_remap)
-		return 0;
-
 	if (x86_fwspec_is_ioapic(fwspec))
 		devid = get_ioapic_devid(fwspec->param[0]);
 	else if (x86_fwspec_is_hpet(fwspec))
Signature · 1 line
2.31.1
author maintainer
#3 lore raw

PATCH 3/4 iommu/amd: Remove redundant checks from interrupt handler path

In reply to Vasant Hegde

PPR and GAlog interrupt is enabled only if buffer is allocated. (See amd_iommu_enable_ppr_log() and iommu_ga_log_enable()).

The duplicate check in interrupt hanlder path is unnecessary and can be removed.

No functional changes.

---
 drivers/iommu/amd/iommu.c | 3 ---
 drivers/iommu/amd/ppr.c   | 3 ---
 2 files changed, 6 deletions(-)
drivers/iommu/amd/iommu.c +0 -3
index 5bb7d8cb506e..ed38f2328618 100644
@@ -1076,9 +1076,6 @@ static void iommu_poll_ga_log(struct amd_iommu *iommu)
 {
 	u32 head, tail;
 
-	if (iommu->ga_log == NULL)
-		return;
-
 	head = readl(iommu->mmio_base + MMIO_GA_HEAD_OFFSET);
 	tail = readl(iommu->mmio_base + MMIO_GA_TAIL_OFFSET);
 
drivers/iommu/amd/ppr.c +0 -3
index 76296079bb8b..2039a9dd71ac 100644
@@ -165,9 +165,6 @@ void amd_iommu_poll_ppr_log(struct amd_iommu *iommu)
 {
 	u32 head, tail;
 
-	if (iommu->ppr_log == NULL)
-		return;
-
 	head = readl(iommu->mmio_base + MMIO_PPR_HEAD_OFFSET);
 	tail = readl(iommu->mmio_base + MMIO_PPR_TAIL_OFFSET);
 
Signature · 1 line
2.31.1
author maintainer
#4 lore raw

PATCH 4/4 iommu/amd: Remove unused macro

In reply to Vasant Hegde

Remove unsed device range capability related macros.

No functional changes.

---
 drivers/iommu/amd/amd_iommu_types.h | 13 -------------
 1 file changed, 13 deletions(-)
drivers/iommu/amd/amd_iommu_types.h +0 -13
index bce5027388b9..8241ef922519 100644
@@ -39,18 +39,6 @@
 #define MMIO_RANGE_OFFSET	0x0c
 #define MMIO_MISC_OFFSET	0x10
 
-/* Masks, shifts and macros to parse the device range capability */
-#define MMIO_RANGE_LD_MASK	0xff000000
-#define MMIO_RANGE_FD_MASK	0x00ff0000
-#define MMIO_RANGE_BUS_MASK	0x0000ff00
-#define MMIO_RANGE_LD_SHIFT	24
-#define MMIO_RANGE_FD_SHIFT	16
-#define MMIO_RANGE_BUS_SHIFT	8
-#define MMIO_GET_LD(x)  (((x) & MMIO_RANGE_LD_MASK) >> MMIO_RANGE_LD_SHIFT)
-#define MMIO_GET_FD(x)  (((x) & MMIO_RANGE_FD_MASK) >> MMIO_RANGE_FD_SHIFT)
-#define MMIO_GET_BUS(x) (((x) & MMIO_RANGE_BUS_MASK) >> MMIO_RANGE_BUS_SHIFT)
-#define MMIO_MSI_NUM(x)	((x) & 0x1f)
-
 /* Used offsets into the MMIO space */
 #define MMIO_DEV_TABLE_OFFSET   0x0000
 #define MMIO_CMD_BUF_OFFSET     0x0008
@@ -247,7 +235,6 @@
 
 /* constants to configure the command buffer */
 #define CMD_BUFFER_SIZE    8192
-#define CMD_BUFFER_UNINITIALIZED 1
 #define CMD_BUFFER_ENTRIES 512
 #define MMIO_CMD_SIZE_SHIFT 56
 #define MMIO_CMD_SIZE_512 (0x9ULL << MMIO_CMD_SIZE_SHIFT)
Signature · 1 line
2.31.1
author maintainer
#5 lore raw
In reply to Vasant Hegde
Quoted 2 lines · Vasant Hegde

This series contains few trivial cleanup (like removing redundant checks, unsed macros, etc,) and fixes.

Forgot to mention, this patch is based on top of iommu/fixes branch (Commit adbd8a08208dc6).

-Vasant

maintainer
#6 lore raw
In reply to Vasant Hegde
Quoted 8 lines · Vasant Hegde

This series contains few trivial cleanup (like removing redundant checks, unsed macros, etc,) and fixes.

Vasant Hegde (4):
iommu/amd: Make iommu_sva_set_dev_pasid as static iommu/amd: Remove redundant check in irq_remapping_select() iommu/amd: Remove redundant checks from interrupt handler path iommu/amd: Remove unused macro

Applied and on their way to Linus, thanks Vasant.