[PATCH] IOMMU/x86: tidy adjust_irq_affinities hook

Jan Beulich posted 1 patch 2 years, 1 month ago
Failed in applying to current master (apply log)
[PATCH] IOMMU/x86: tidy adjust_irq_affinities hook
Posted by Jan Beulich 2 years, 1 month ago
As of 3e56754b0887 ("xen/cet: Fix __initconst_cf_clobber") there's no
need for a non-void return value anymore, as the hook functions are no
longer themselves passed to __initcall(). For the same reason the
iommu_enabled checks can now move from the individual functions to the
wrapper.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/x86/include/asm/iommu.h
+++ b/xen/arch/x86/include/asm/iommu.h
@@ -101,11 +101,10 @@ void iommu_update_ire_from_apic(unsigned
 unsigned int iommu_read_apic_from_ire(unsigned int apic, unsigned int reg);
 int iommu_setup_hpet_msi(struct msi_desc *);
 
-static inline int iommu_adjust_irq_affinities(void)
+static inline void iommu_adjust_irq_affinities(void)
 {
-    return iommu_ops.adjust_irq_affinities
-           ? iommu_call(&iommu_ops, adjust_irq_affinities)
-           : 0;
+    if ( iommu_enabled && iommu_ops.adjust_irq_affinities )
+        iommu_vcall(&iommu_ops, adjust_irq_affinities);
 }
 
 static inline bool iommu_supports_x2apic(void)
--- a/xen/drivers/passthrough/amd/iommu.h
+++ b/xen/drivers/passthrough/amd/iommu.h
@@ -234,7 +234,7 @@ int amd_iommu_prepare(bool xt);
 int amd_iommu_init(bool xt);
 int amd_iommu_init_late(void);
 int amd_iommu_update_ivrs_mapping_acpi(void);
-int cf_check iov_adjust_irq_affinities(void);
+void cf_check iov_adjust_irq_affinities(void);
 
 int cf_check amd_iommu_quarantine_init(struct domain *d);
 
--- a/xen/drivers/passthrough/amd/iommu_init.c
+++ b/xen/drivers/passthrough/amd/iommu_init.c
@@ -809,13 +809,10 @@ static bool_t __init set_iommu_interrupt
     return 1;
 }
 
-int cf_check iov_adjust_irq_affinities(void)
+void cf_check iov_adjust_irq_affinities(void)
 {
     const struct amd_iommu *iommu;
 
-    if ( !iommu_enabled )
-        return 0;
-
     for_each_amd_iommu ( iommu )
     {
         struct irq_desc *desc = irq_to_desc(iommu->msi.irq);
@@ -828,8 +825,6 @@ int cf_check iov_adjust_irq_affinities(v
             set_msi_affinity(desc, NULL);
         spin_unlock_irqrestore(&desc->lock, flags);
     }
-
-    return 0;
 }
 
 /*
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -2107,17 +2107,12 @@ static void adjust_irq_affinity(struct a
     spin_unlock_irqrestore(&desc->lock, flags);
 }
 
-static int cf_check adjust_vtd_irq_affinities(void)
+static void cf_check adjust_vtd_irq_affinities(void)
 {
     struct acpi_drhd_unit *drhd;
 
-    if ( !iommu_enabled )
-        return 0;
-
     for_each_drhd_unit ( drhd )
         adjust_irq_affinity(drhd);
-
-    return 0;
 }
 
 static int __must_check init_vtd_hw(bool resume)
--- a/xen/drivers/passthrough/x86/iommu.c
+++ b/xen/drivers/passthrough/x86/iommu.c
@@ -464,7 +464,9 @@ bool arch_iommu_use_permitted(const stru
 
 static int __init cf_check adjust_irq_affinities(void)
 {
-    return iommu_adjust_irq_affinities();
+    iommu_adjust_irq_affinities();
+
+    return 0;
 }
 __initcall(adjust_irq_affinities);
 
--- a/xen/include/xen/iommu.h
+++ b/xen/include/xen/iommu.h
@@ -267,7 +267,7 @@ struct iommu_ops {
 
     int (*setup_hpet_msi)(struct msi_desc *);
 
-    int (*adjust_irq_affinities)(void);
+    void (*adjust_irq_affinities)(void);
     void (*clear_root_pgtable)(struct domain *d);
     int (*update_ire_from_msi)(struct msi_desc *msi_desc, struct msi_msg *msg);
 #endif /* CONFIG_X86 */
Re: [PATCH] IOMMU/x86: tidy adjust_irq_affinities hook
Posted by Andrew Cooper 2 years, 1 month ago
On 07/03/2022 12:40, Jan Beulich wrote:
> As of 3e56754b0887 ("xen/cet: Fix __initconst_cf_clobber") there's no
> need for a non-void return value anymore, as the hook functions are no
> longer themselves passed to __initcall(). For the same reason the
> iommu_enabled checks can now move from the individual functions to the
> wrapper.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
RE: [PATCH] IOMMU/x86: tidy adjust_irq_affinities hook
Posted by Tian, Kevin 2 years, 1 month ago
> From: Jan Beulich <jbeulich@suse.com>
> Sent: Monday, March 7, 2022 8:40 PM
> 
> As of 3e56754b0887 ("xen/cet: Fix __initconst_cf_clobber") there's no
> need for a non-void return value anymore, as the hook functions are no
> longer themselves passed to __initcall(). For the same reason the
> iommu_enabled checks can now move from the individual functions to the
> wrapper.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Kevin Tian <kevin.tian@intel.com>

> 
> --- a/xen/arch/x86/include/asm/iommu.h
> +++ b/xen/arch/x86/include/asm/iommu.h
> @@ -101,11 +101,10 @@ void iommu_update_ire_from_apic(unsigned
>  unsigned int iommu_read_apic_from_ire(unsigned int apic, unsigned int reg);
>  int iommu_setup_hpet_msi(struct msi_desc *);
> 
> -static inline int iommu_adjust_irq_affinities(void)
> +static inline void iommu_adjust_irq_affinities(void)
>  {
> -    return iommu_ops.adjust_irq_affinities
> -           ? iommu_call(&iommu_ops, adjust_irq_affinities)
> -           : 0;
> +    if ( iommu_enabled && iommu_ops.adjust_irq_affinities )
> +        iommu_vcall(&iommu_ops, adjust_irq_affinities);
>  }
> 
>  static inline bool iommu_supports_x2apic(void)
> --- a/xen/drivers/passthrough/amd/iommu.h
> +++ b/xen/drivers/passthrough/amd/iommu.h
> @@ -234,7 +234,7 @@ int amd_iommu_prepare(bool xt);
>  int amd_iommu_init(bool xt);
>  int amd_iommu_init_late(void);
>  int amd_iommu_update_ivrs_mapping_acpi(void);
> -int cf_check iov_adjust_irq_affinities(void);
> +void cf_check iov_adjust_irq_affinities(void);
> 
>  int cf_check amd_iommu_quarantine_init(struct domain *d);
> 
> --- a/xen/drivers/passthrough/amd/iommu_init.c
> +++ b/xen/drivers/passthrough/amd/iommu_init.c
> @@ -809,13 +809,10 @@ static bool_t __init set_iommu_interrupt
>      return 1;
>  }
> 
> -int cf_check iov_adjust_irq_affinities(void)
> +void cf_check iov_adjust_irq_affinities(void)
>  {
>      const struct amd_iommu *iommu;
> 
> -    if ( !iommu_enabled )
> -        return 0;
> -
>      for_each_amd_iommu ( iommu )
>      {
>          struct irq_desc *desc = irq_to_desc(iommu->msi.irq);
> @@ -828,8 +825,6 @@ int cf_check iov_adjust_irq_affinities(v
>              set_msi_affinity(desc, NULL);
>          spin_unlock_irqrestore(&desc->lock, flags);
>      }
> -
> -    return 0;
>  }
> 
>  /*
> --- a/xen/drivers/passthrough/vtd/iommu.c
> +++ b/xen/drivers/passthrough/vtd/iommu.c
> @@ -2107,17 +2107,12 @@ static void adjust_irq_affinity(struct a
>      spin_unlock_irqrestore(&desc->lock, flags);
>  }
> 
> -static int cf_check adjust_vtd_irq_affinities(void)
> +static void cf_check adjust_vtd_irq_affinities(void)
>  {
>      struct acpi_drhd_unit *drhd;
> 
> -    if ( !iommu_enabled )
> -        return 0;
> -
>      for_each_drhd_unit ( drhd )
>          adjust_irq_affinity(drhd);
> -
> -    return 0;
>  }
> 
>  static int __must_check init_vtd_hw(bool resume)
> --- a/xen/drivers/passthrough/x86/iommu.c
> +++ b/xen/drivers/passthrough/x86/iommu.c
> @@ -464,7 +464,9 @@ bool arch_iommu_use_permitted(const stru
> 
>  static int __init cf_check adjust_irq_affinities(void)
>  {
> -    return iommu_adjust_irq_affinities();
> +    iommu_adjust_irq_affinities();
> +
> +    return 0;
>  }
>  __initcall(adjust_irq_affinities);
> 
> --- a/xen/include/xen/iommu.h
> +++ b/xen/include/xen/iommu.h
> @@ -267,7 +267,7 @@ struct iommu_ops {
> 
>      int (*setup_hpet_msi)(struct msi_desc *);
> 
> -    int (*adjust_irq_affinities)(void);
> +    void (*adjust_irq_affinities)(void);
>      void (*clear_root_pgtable)(struct domain *d);
>      int (*update_ire_from_msi)(struct msi_desc *msi_desc, struct msi_msg
> *msg);
>  #endif /* CONFIG_X86 */