ANDROID: gic: Add affinity-setting vendor hooks to gic-v3

Add vendor hooks to allow vendor enhancements to GIC v3, specifically
implementation-defined multi-CPU IRQ target affinity setting.

The gic_v3_set_affinity() vendor hook is introduced as a restricted
vendor hook in order to allow trace hook to be called from irq migration
paths.

This patch includes content from these patches from previous releases:

commit 00c6f53e03 ("ANDROID: gic-v3: Add vendor hook to GIC v3")
commit fdb01338797f ("ANDROID: gic-v3: Update vendor hook to set affinity in GIC v3")
commit d8b068262090 ("ANDROID: gic-v3: Change GIC v3 vendor hook to restricted")
commit fbee76aa8d67 ("ANDROID: gic-v3: Update vendor hook to set affinity in GIC v3")

Bug: 266450121
Change-Id: I457070ba7ae53e012aa7bac846d2bdb11ef6f95d
Signed-off-by: Guru Das Srinagesh <quic_gurus@quicinc.com>
This commit is contained in:
Guru Das Srinagesh 2023-01-31 15:08:02 -08:00 committed by Treehugger Robot
parent 4cd99f6a6f
commit b2487c5b2b
3 changed files with 42 additions and 2 deletions

View file

@ -44,6 +44,7 @@
#include <trace/hooks/fips140.h>
#include <trace/hooks/dmabuf.h>
#include <trace/hooks/gic.h>
#include <trace/hooks/gic_v3.h>
#include <trace/hooks/timer.h>
#include <trace/hooks/topology.h>
#include <trace/hooks/hung_task.h>
@ -137,6 +138,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_aes_expandkey);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_aes_encrypt);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_aes_decrypt);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_timer_calc_index);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_gic_v3_set_affinity);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_gic_set_affinity);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_gic_v3_affinity_init);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_uninterrupt_tasks);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_uninterrupt_tasks_done);

View file

@ -18,6 +18,7 @@
#include <linux/percpu.h>
#include <linux/refcount.h>
#include <linux/slab.h>
#include <trace/hooks/gic_v3.h>
#include <linux/irqchip.h>
#include <linux/irqchip/arm-gic-common.h>
@ -881,11 +882,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 *))
@ -1347,6 +1352,9 @@ 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_rvh_gic_v3_set_affinity(d, mask_val, &val, force, gic_dist_base(d),
gic_data.redist_regions[0].redist_base,
gic_data.redist_stride);
gic_write_irouter(val, reg);
/*

View file

@ -0,0 +1,29 @@
/* 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 <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_RESTRICTED_HOOK(android_rvh_gic_v3_set_affinity,
TP_PROTO(struct irq_data *d, const struct cpumask *mask_val,
u64 *affinity, bool force, void __iomem *base,
void __iomem *rbase, u64 redist_stride),
TP_ARGS(d, mask_val, affinity, force, base, rbase, redist_stride),
1);
#endif /* _TRACE_HOOK_GIC_V3_H */
/* This part must be outside protection */
#include <trace/define_trace.h>