Commit 8594c3b8 authored by Marc Zyngier's avatar Marc Zyngier

irqchip/gic: Cleanup Franken-GIC handling

Introduce a static key identifying Samsung's unique creation, allowing
to replace the indirect call to compute the base addresses with
a simple test on the static key.

Faster, cheaper, negative diffstat.
Tested-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
parent c3330399
...@@ -83,9 +83,6 @@ struct gic_chip_data { ...@@ -83,9 +83,6 @@ struct gic_chip_data {
#endif #endif
struct irq_domain *domain; struct irq_domain *domain;
unsigned int gic_irqs; unsigned int gic_irqs;
#ifdef CONFIG_GIC_NON_BANKED
void __iomem *(*get_base)(union gic_base *);
#endif
}; };
#ifdef CONFIG_BL_SWITCHER #ifdef CONFIG_BL_SWITCHER
...@@ -127,35 +124,27 @@ static struct gic_kvm_info gic_v2_kvm_info; ...@@ -127,35 +124,27 @@ static struct gic_kvm_info gic_v2_kvm_info;
static DEFINE_PER_CPU(u32, sgi_intid); static DEFINE_PER_CPU(u32, sgi_intid);
#ifdef CONFIG_GIC_NON_BANKED #ifdef CONFIG_GIC_NON_BANKED
static void __iomem *gic_get_percpu_base(union gic_base *base) static DEFINE_STATIC_KEY_FALSE(frankengic_key);
{
return raw_cpu_read(*base->percpu_base);
}
static void __iomem *gic_get_common_base(union gic_base *base) static void enable_frankengic(void)
{ {
return base->common_base; static_branch_enable(&frankengic_key);
} }
static inline void __iomem *gic_data_dist_base(struct gic_chip_data *data) static inline void __iomem *__get_base(union gic_base *base)
{ {
return data->get_base(&data->dist_base); if (static_branch_unlikely(&frankengic_key))
} return raw_cpu_read(*base->percpu_base);
static inline void __iomem *gic_data_cpu_base(struct gic_chip_data *data) return base->common_base;
{
return data->get_base(&data->cpu_base);
} }
static inline void gic_set_base_accessor(struct gic_chip_data *data, #define gic_data_dist_base(d) __get_base(&(d)->dist_base)
void __iomem *(*f)(union gic_base *)) #define gic_data_cpu_base(d) __get_base(&(d)->cpu_base)
{
data->get_base = f;
}
#else #else
#define gic_data_dist_base(d) ((d)->dist_base.common_base) #define gic_data_dist_base(d) ((d)->dist_base.common_base)
#define gic_data_cpu_base(d) ((d)->cpu_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)
#endif #endif
static inline void __iomem *gic_dist_base(struct irq_data *d) static inline void __iomem *gic_dist_base(struct irq_data *d)
...@@ -307,7 +296,7 @@ static int gic_set_type(struct irq_data *d, unsigned int type) ...@@ -307,7 +296,7 @@ static int gic_set_type(struct irq_data *d, unsigned int type)
/* Interrupt configuration for SGIs can't be changed */ /* Interrupt configuration for SGIs can't be changed */
if (gicirq < 16) if (gicirq < 16)
return type == IRQ_TYPE_EDGE_RISING ? 0 : -EINVAL; return type != IRQ_TYPE_EDGE_RISING ? -EINVAL : 0;
/* SPIs have restrictions on the supported types */ /* SPIs have restrictions on the supported types */
if (gicirq >= 32 && type != IRQ_TYPE_LEVEL_HIGH && if (gicirq >= 32 && type != IRQ_TYPE_LEVEL_HIGH &&
...@@ -720,11 +709,6 @@ static int gic_notifier(struct notifier_block *self, unsigned long cmd, void *v) ...@@ -720,11 +709,6 @@ static int gic_notifier(struct notifier_block *self, unsigned long cmd, void *v)
int i; int i;
for (i = 0; i < CONFIG_ARM_GIC_MAX_NR; 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) { switch (cmd) {
case CPU_PM_ENTER: case CPU_PM_ENTER:
gic_cpu_save(&gic_data[i]); gic_cpu_save(&gic_data[i]);
...@@ -1165,7 +1149,7 @@ static int gic_init_bases(struct gic_chip_data *gic, ...@@ -1165,7 +1149,7 @@ static int gic_init_bases(struct gic_chip_data *gic,
gic->raw_cpu_base + offset; gic->raw_cpu_base + offset;
} }
gic_set_base_accessor(gic, gic_get_percpu_base); enable_frankengic();
} else { } else {
/* Normal, sane GIC... */ /* Normal, sane GIC... */
WARN(gic->percpu_offset, WARN(gic->percpu_offset,
...@@ -1173,7 +1157,6 @@ static int gic_init_bases(struct gic_chip_data *gic, ...@@ -1173,7 +1157,6 @@ static int gic_init_bases(struct gic_chip_data *gic,
gic->percpu_offset); gic->percpu_offset);
gic->dist_base.common_base = gic->raw_dist_base; gic->dist_base.common_base = gic->raw_dist_base;
gic->cpu_base.common_base = gic->raw_cpu_base; gic->cpu_base.common_base = gic->raw_cpu_base;
gic_set_base_accessor(gic, gic_get_common_base);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment