diff mbox series

[2/2] irqchip/gic: Cleanup Franken-GIC handling

Message ID 20200915133944.1285456-3-maz@kernel.org (mailing list archive)
State New, archived
Headers show
Series irqchip/gic: Fix handling of Samsung's non-standard GIC | expand

Commit Message

Marc Zyngier Sept. 15, 2020, 1:39 p.m. UTC
Now that we have a static key identifying Samsung's unique creation,
let's replace the indirect call to compute the base addresses by
a simple test on the static key.

Faster, cheaper, negative diffstat.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 drivers/irqchip/irq-gic.c | 48 +++++++++------------------------------
 1 file changed, 11 insertions(+), 37 deletions(-)

Comments

Marek Szyprowski Sept. 15, 2020, 2:06 p.m. UTC | #1
On 15.09.2020 15:39, Marc Zyngier wrote:
> Now that we have a static key identifying Samsung's unique creation,
> let's replace the indirect call to compute the base addresses by
> a simple test on the static key.
>
> Faster, cheaper, negative diffstat.
>
> Signed-off-by: Marc Zyngier <maz@kernel.org>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
>   drivers/irqchip/irq-gic.c | 48 +++++++++------------------------------
>   1 file changed, 11 insertions(+), 37 deletions(-)
>
> diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
> index 84a2d2a1aab7..98743afdaea6 100644
> --- a/drivers/irqchip/irq-gic.c
> +++ b/drivers/irqchip/irq-gic.c
> @@ -83,9 +83,6 @@ struct gic_chip_data {
>   #endif
>   	struct irq_domain *domain;
>   	unsigned int gic_irqs;
> -#ifdef CONFIG_GIC_NON_BANKED
> -	void __iomem *(*get_base)(union gic_base *);
> -#endif
>   };
>   
>   #ifdef CONFIG_BL_SWITCHER
> @@ -125,32 +122,6 @@ static struct gic_chip_data gic_data[CONFIG_ARM_GIC_MAX_NR] __read_mostly;
>   static struct gic_kvm_info gic_v2_kvm_info;
>   
>   #ifdef CONFIG_GIC_NON_BANKED
> -static void __iomem *gic_get_percpu_base(union gic_base *base)
> -{
> -	return raw_cpu_read(*base->percpu_base);
> -}
> -
> -static void __iomem *gic_get_common_base(union gic_base *base)
> -{
> -	return base->common_base;
> -}
> -
> -static inline void __iomem *gic_data_dist_base(struct gic_chip_data *data)
> -{
> -	return data->get_base(&data->dist_base);
> -}
> -
> -static inline void __iomem *gic_data_cpu_base(struct gic_chip_data *data)
> -{
> -	return data->get_base(&data->cpu_base);
> -}
> -
> -static inline void gic_set_base_accessor(struct gic_chip_data *data,
> -					 void __iomem *(*f)(union gic_base *))
> -{
> -	data->get_base = f;
> -}
> -
>   static DEFINE_STATIC_KEY_FALSE(frankengic_key);
>   static DEFINE_PER_CPU(u32, sgi_intid);
>   
> @@ -173,10 +144,20 @@ static inline u32 get_sgi_intid(void)
>   {
>   	return this_cpu_read(sgi_intid);
>   }
> +
> +static inline void __iomem *__get_base(union gic_base *base)
> +{
> +	if (is_frankengic())
> +		return raw_cpu_read(*base->percpu_base);
> +
> +	return base->common_base;
> +}
> +
> +#define gic_data_dist_base(d)	__get_base(&(d)->dist_base)
> +#define gic_data_cpu_base(d)	__get_base(&(d)->cpu_base)
>   #else
>   #define gic_data_dist_base(d)	((d)->dist_base.common_base)
>   #define gic_data_cpu_base(d)	((d)->cpu_base.common_base)
> -#define gic_set_base_accessor(d, f)
>   #define enable_frankengic()	do { } while(0)
>   #define is_frankengic()		false
>   #define set_sgi_intid(i)	do { } while(0)
> @@ -741,11 +722,6 @@ static int gic_notifier(struct notifier_block *self, unsigned long cmd,	void *v)
>   	int i;
>   
>   	for (i = 0; i < CONFIG_ARM_GIC_MAX_NR; i++) {
> -#ifdef CONFIG_GIC_NON_BANKED
> -		/* Skip over unused GICs */
> -		if (!gic_data[i].get_base)
> -			continue;
> -#endif
>   		switch (cmd) {
>   		case CPU_PM_ENTER:
>   			gic_cpu_save(&gic_data[i]);
> @@ -1187,7 +1163,6 @@ static int gic_init_bases(struct gic_chip_data *gic,
>   		}
>   
>   		enable_frankengic();
> -		gic_set_base_accessor(gic, gic_get_percpu_base);
>   	} else {
>   		/* Normal, sane GIC... */
>   		WARN(gic->percpu_offset,
> @@ -1195,7 +1170,6 @@ static int gic_init_bases(struct gic_chip_data *gic,
>   		     gic->percpu_offset);
>   		gic->dist_base.common_base = gic->raw_dist_base;
>   		gic->cpu_base.common_base = gic->raw_cpu_base;
> -		gic_set_base_accessor(gic, gic_get_common_base);
>   	}
>   
>   	/*

Best regards
diff mbox series

Patch

diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
index 84a2d2a1aab7..98743afdaea6 100644
--- a/drivers/irqchip/irq-gic.c
+++ b/drivers/irqchip/irq-gic.c
@@ -83,9 +83,6 @@  struct gic_chip_data {
 #endif
 	struct irq_domain *domain;
 	unsigned int gic_irqs;
-#ifdef CONFIG_GIC_NON_BANKED
-	void __iomem *(*get_base)(union gic_base *);
-#endif
 };
 
 #ifdef CONFIG_BL_SWITCHER
@@ -125,32 +122,6 @@  static struct gic_chip_data gic_data[CONFIG_ARM_GIC_MAX_NR] __read_mostly;
 static struct gic_kvm_info gic_v2_kvm_info;
 
 #ifdef CONFIG_GIC_NON_BANKED
-static void __iomem *gic_get_percpu_base(union gic_base *base)
-{
-	return raw_cpu_read(*base->percpu_base);
-}
-
-static void __iomem *gic_get_common_base(union gic_base *base)
-{
-	return base->common_base;
-}
-
-static inline void __iomem *gic_data_dist_base(struct gic_chip_data *data)
-{
-	return data->get_base(&data->dist_base);
-}
-
-static inline void __iomem *gic_data_cpu_base(struct gic_chip_data *data)
-{
-	return data->get_base(&data->cpu_base);
-}
-
-static inline void gic_set_base_accessor(struct gic_chip_data *data,
-					 void __iomem *(*f)(union gic_base *))
-{
-	data->get_base = f;
-}
-
 static DEFINE_STATIC_KEY_FALSE(frankengic_key);
 static DEFINE_PER_CPU(u32, sgi_intid);
 
@@ -173,10 +144,20 @@  static inline u32 get_sgi_intid(void)
 {
 	return this_cpu_read(sgi_intid);
 }
+
+static inline void __iomem *__get_base(union gic_base *base)
+{
+	if (is_frankengic())
+		return raw_cpu_read(*base->percpu_base);
+
+	return base->common_base;
+}
+
+#define gic_data_dist_base(d)	__get_base(&(d)->dist_base)
+#define gic_data_cpu_base(d)	__get_base(&(d)->cpu_base)
 #else
 #define gic_data_dist_base(d)	((d)->dist_base.common_base)
 #define gic_data_cpu_base(d)	((d)->cpu_base.common_base)
-#define gic_set_base_accessor(d, f)
 #define enable_frankengic()	do { } while(0)
 #define is_frankengic()		false
 #define set_sgi_intid(i)	do { } while(0)
@@ -741,11 +722,6 @@  static int gic_notifier(struct notifier_block *self, unsigned long cmd,	void *v)
 	int i;
 
 	for (i = 0; i < CONFIG_ARM_GIC_MAX_NR; i++) {
-#ifdef CONFIG_GIC_NON_BANKED
-		/* Skip over unused GICs */
-		if (!gic_data[i].get_base)
-			continue;
-#endif
 		switch (cmd) {
 		case CPU_PM_ENTER:
 			gic_cpu_save(&gic_data[i]);
@@ -1187,7 +1163,6 @@  static int gic_init_bases(struct gic_chip_data *gic,
 		}
 
 		enable_frankengic();
-		gic_set_base_accessor(gic, gic_get_percpu_base);
 	} else {
 		/* Normal, sane GIC... */
 		WARN(gic->percpu_offset,
@@ -1195,7 +1170,6 @@  static int gic_init_bases(struct gic_chip_data *gic,
 		     gic->percpu_offset);
 		gic->dist_base.common_base = gic->raw_dist_base;
 		gic->cpu_base.common_base = gic->raw_cpu_base;
-		gic_set_base_accessor(gic, gic_get_common_base);
 	}
 
 	/*