| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| From: Elliot Berman <eberman@codeaurora.org> |
| Date: Mon, 14 Sep 2020 15:35:41 -0700 |
| Subject: NOUPSTREAM: ANDROID: irqchip: IRQ Chip releated vendor hooks |
| |
| Add vendor hook for gic-v3 resume to allow vendor GIC enhancement. |
| |
| [CPNOTE: 03/06/21] Lee: Vendor related code - maintain forever |
| |
| Squash |
| NOUPSTREAM: ANDROID: gic-v3: Add vendor hook to GIC v3 |
| |
| Bug: 168730134 |
| Bug: 172637074 |
| Change-Id: Id3298715355c8f592f58393db6aa903b18dd812c |
| Signed-off-by: Elliot Berman <eberman@codeaurora.org> |
| --- |
| drivers/android/vendor_hooks.c | 5 +++++ |
| drivers/irqchip/irq-gic-v3.c | 34 ++++++++++++++++++++++++++++++++-- |
| include/trace/hooks/gic.h | 21 +++++++++++++++++++++ |
| include/trace/hooks/gic_v3.h | 25 +++++++++++++++++++++++++ |
| 4 files changed, 83 insertions(+), 2 deletions(-) |
| create mode 100644 include/trace/hooks/gic.h |
| create mode 100644 include/trace/hooks/gic_v3.h |
| |
| diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c |
| --- a/drivers/android/vendor_hooks.c |
| +++ b/drivers/android/vendor_hooks.c |
| @@ -15,9 +15,11 @@ |
| #include <trace/hooks/cpuidle.h> |
| #include <trace/hooks/topology.h> |
| #include <trace/hooks/mpam.h> |
| +#include <trace/hooks/gic.h> |
| #include <trace/hooks/wqlockup.h> |
| #include <trace/hooks/debug.h> |
| #include <trace/hooks/printk.h> |
| +#include <trace/hooks/gic_v3.h> |
| #include <trace/hooks/epoch.h> |
| #include <trace/hooks/mm.h> |
| #include <trace/hooks/preemptirq.h> |
| @@ -63,11 +65,14 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cpu_idle_enter); |
| EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cpu_idle_exit); |
| EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mpam_set); |
| EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_find_busiest_group); |
| +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_gic_resume); |
| EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_wq_lockup_pool); |
| EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ipi_stop); |
| EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_dump_throttled_rt_tasks); |
| EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_printk_hotplug); |
| EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_jiffies_update); |
| +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_gic_v3_set_affinity); |
| +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_gic_v3_affinity_init); |
| EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_show_suspend_epoch_val); |
| EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_show_resume_epoch_val); |
| EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_sched_newidle_balance); |
| diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c |
| --- a/drivers/irqchip/irq-gic-v3.c |
| +++ b/drivers/irqchip/irq-gic-v3.c |
| @@ -18,7 +18,9 @@ |
| #include <linux/percpu.h> |
| #include <linux/refcount.h> |
| #include <linux/slab.h> |
| +#include <linux/syscore_ops.h> |
| #include <linux/wakeup_reason.h> |
| +#include <trace/hooks/gic_v3.h> |
| |
| |
| #include <linux/irqchip.h> |
| @@ -31,6 +33,8 @@ |
| #include <asm/smp_plat.h> |
| #include <asm/virt.h> |
| |
| +#include <trace/hooks/gic.h> |
| + |
| #include "irq-gic-common.h" |
| |
| #define GICD_INT_NMI_PRI (GICD_INT_DEF_PRI & ~0x80) |
| @@ -827,11 +831,15 @@ static void __init gic_dist_init(void) |
| * enabled. |
| */ |
| affinity = gic_mpidr_to_affinity(cpu_logical_map(smp_processor_id())); |
| - for (i = 32; i < GIC_LINE_NR; i++) |
| + for (i = 32; i < GIC_LINE_NR; i++) { |
| + trace_android_vh_gic_v3_affinity_init(i, GICD_IROUTER, &affinity); |
| gic_write_irouter(affinity, base + GICD_IROUTER + i * 8); |
| + } |
| |
| - for (i = 0; i < GIC_ESPI_NR; i++) |
| + for (i = 0; i < GIC_ESPI_NR; i++) { |
| + trace_android_vh_gic_v3_affinity_init(i, GICD_IROUTERnE, &affinity); |
| gic_write_irouter(affinity, base + GICD_IROUTERnE + i * 8); |
| + } |
| } |
| |
| static int gic_iterate_rdists(int (*fn)(struct redist_region *, void __iomem *)) |
| @@ -1263,6 +1271,7 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val, |
| reg = gic_dist_base(d) + offset + (index * 8); |
| val = gic_mpidr_to_affinity(cpu_logical_map(cpu)); |
| |
| + trace_android_vh_gic_v3_set_affinity(d, mask_val, &val); |
| gic_write_irouter(val, reg); |
| |
| /* |
| @@ -1317,6 +1326,26 @@ static void gic_cpu_pm_init(void) |
| static inline void gic_cpu_pm_init(void) { } |
| #endif /* CONFIG_CPU_PM */ |
| |
| +#ifdef CONFIG_PM |
| +static void gic_resume(void) |
| +{ |
| + trace_android_vh_gic_resume(gic_data.domain, gic_data.dist_base); |
| +} |
| + |
| +static struct syscore_ops gic_syscore_ops = { |
| + .resume = gic_resume, |
| +}; |
| + |
| +static void gic_syscore_init(void) |
| +{ |
| + register_syscore_ops(&gic_syscore_ops); |
| +} |
| + |
| +#else |
| +static inline void gic_syscore_init(void) { } |
| +#endif |
| + |
| + |
| static struct irq_chip gic_chip = { |
| .name = "GICv3", |
| .irq_mask = gic_mask_irq, |
| @@ -1801,6 +1830,7 @@ static int __init gic_init_bases(void __iomem *dist_base, |
| gic_cpu_init(); |
| gic_smp_init(); |
| gic_cpu_pm_init(); |
| + gic_syscore_init(); |
| |
| if (gic_dist_supports_lpis()) { |
| its_init(handle, &gic_data.rdists, gic_data.domain); |
| diff --git a/include/trace/hooks/gic.h b/include/trace/hooks/gic.h |
| new file mode 100644 |
| --- /dev/null |
| +++ b/include/trace/hooks/gic.h |
| @@ -0,0 +1,21 @@ |
| +/* SPDX-License-Identifier: GPL-2.0 */ |
| +#undef TRACE_SYSTEM |
| +#define TRACE_SYSTEM gic |
| + |
| +#define TRACE_INCLUDE_PATH trace/hooks |
| + |
| +#if !defined(_TRACE_HOOK_GIC_H) || defined(TRACE_HEADER_MULTI_READ) |
| +#define _TRACE_HOOK_GIC_H |
| + |
| +#include <linux/irqdomain.h> |
| + |
| +#include <linux/tracepoint.h> |
| +#include <trace/hooks/vendor_hooks.h> |
| + |
| +DECLARE_HOOK(android_vh_gic_resume, |
| + TP_PROTO(struct irq_domain *domain, void __iomem *dist_base), |
| + TP_ARGS(domain, dist_base)); |
| + |
| +#endif /* _TRACE_HOOK_GIC_H */ |
| +/* This part must be outside protection */ |
| +#include <trace/define_trace.h> |
| diff --git a/include/trace/hooks/gic_v3.h b/include/trace/hooks/gic_v3.h |
| new file mode 100644 |
| --- /dev/null |
| +++ b/include/trace/hooks/gic_v3.h |
| @@ -0,0 +1,25 @@ |
| +/* SPDX-License-Identifier: GPL-2.0-only */ |
| +#undef TRACE_SYSTEM |
| +#define TRACE_SYSTEM gic_v3 |
| +#define TRACE_INCLUDE_PATH trace/hooks |
| +#if !defined(_TRACE_HOOK_GIC_V3_H) || defined(TRACE_HEADER_MULTI_READ) |
| +#define _TRACE_HOOK_GIC_V3_H |
| +#include <linux/tracepoint.h> |
| +#include <trace/hooks/vendor_hooks.h> |
| +/* |
| + * Following tracepoints are not exported in tracefs and provide a |
| + * mechanism for vendor modules to hook and extend functionality |
| + */ |
| +struct irq_data; |
| +struct cpumask; |
| +DECLARE_HOOK(android_vh_gic_v3_affinity_init, |
| + TP_PROTO(int irq, u32 offset, u64 *affinity), |
| + TP_ARGS(irq, offset, affinity)); |
| +DECLARE_HOOK(android_vh_gic_v3_set_affinity, |
| + TP_PROTO(struct irq_data *d, const struct cpumask *mask_val, |
| + u64 *affinity), |
| + TP_ARGS(d, mask_val, affinity)); |
| + |
| +#endif /* _TRACE_HOOK_GIC_V3_H */ |
| +/* This part must be outside protection */ |
| +#include <trace/define_trace.h> |