Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm_pmu: acpi: Add a representative platform device for TRBE

ACPI TRBE does not have a HID for identification which could create and add
a platform device into the platform bus. Also without a platform device, it
cannot be probed and bound to a platform driver.

This creates a dummy platform device for TRBE after ascertaining that ACPI
provides required interrupts uniformly across all cpus on the system. This
device gets created inside drivers/perf/arm_pmu_acpi.c to accommodate TRBE
being built as a module.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
Link: https://lore.kernel.org/r/20230817055405.249630-3-anshuman.khandual@arm.com
Signed-off-by: Will Deacon <will@kernel.org>

authored by

Anshuman Khandual and committed by
Will Deacon
1aa3d027 81e5ee47

+39
+3
arch/arm64/include/asm/acpi.h
··· 42 42 #define ACPI_MADT_GICC_SPE (offsetof(struct acpi_madt_generic_interrupt, \ 43 43 spe_interrupt) + sizeof(u16)) 44 44 45 + #define ACPI_MADT_GICC_TRBE (offsetof(struct acpi_madt_generic_interrupt, \ 46 + trbe_interrupt) + sizeof(u16)) 47 + 45 48 /* Basic configuration for ACPI */ 46 49 #ifdef CONFIG_ACPI 47 50 pgprot_t __acpi_get_mem_attribute(phys_addr_t addr);
+35
drivers/perf/arm_pmu_acpi.c
··· 163 163 } 164 164 #endif /* CONFIG_ARM_SPE_PMU */ 165 165 166 + #if IS_ENABLED(CONFIG_CORESIGHT_TRBE) 167 + static struct resource trbe_resources[] = { 168 + { 169 + /* irq */ 170 + .flags = IORESOURCE_IRQ, 171 + } 172 + }; 173 + 174 + static struct platform_device trbe_dev = { 175 + .name = ARMV8_TRBE_PDEV_NAME, 176 + .id = -1, 177 + .resource = trbe_resources, 178 + .num_resources = ARRAY_SIZE(trbe_resources) 179 + }; 180 + 181 + static u16 arm_trbe_parse_gsi(struct acpi_madt_generic_interrupt *gicc) 182 + { 183 + return gicc->trbe_interrupt; 184 + } 185 + 186 + static void arm_trbe_acpi_register_device(void) 187 + { 188 + int ret = arm_acpi_register_pmu_device(&trbe_dev, ACPI_MADT_GICC_TRBE, 189 + arm_trbe_parse_gsi); 190 + if (ret) 191 + pr_warn("ACPI: TRBE: Unable to register device\n"); 192 + } 193 + #else 194 + static inline void arm_trbe_acpi_register_device(void) 195 + { 196 + 197 + } 198 + #endif /* CONFIG_CORESIGHT_TRBE */ 199 + 166 200 static int arm_pmu_acpi_parse_irqs(void) 167 201 { 168 202 int irq, cpu, irq_cpu, err; ··· 432 398 return 0; 433 399 434 400 arm_spe_acpi_register_device(); 401 + arm_trbe_acpi_register_device(); 435 402 436 403 return 0; 437 404 }
+1
include/linux/perf/arm_pmu.h
··· 187 187 #endif /* CONFIG_ARM_PMU */ 188 188 189 189 #define ARMV8_SPE_PDEV_NAME "arm,spe-v1" 190 + #define ARMV8_TRBE_PDEV_NAME "arm,trbe" 190 191 191 192 #endif /* __ARM_PMU_H__ */