Skip to content

Commit 1aa3d02

Browse files
Anshuman Khandualwilldeacon
authored andcommitted
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>
1 parent 81e5ee4 commit 1aa3d02

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

arch/arm64/include/asm/acpi.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
#define ACPI_MADT_GICC_SPE (offsetof(struct acpi_madt_generic_interrupt, \
4343
spe_interrupt) + sizeof(u16))
4444

45+
#define ACPI_MADT_GICC_TRBE (offsetof(struct acpi_madt_generic_interrupt, \
46+
trbe_interrupt) + sizeof(u16))
47+
4548
/* Basic configuration for ACPI */
4649
#ifdef CONFIG_ACPI
4750
pgprot_t __acpi_get_mem_attribute(phys_addr_t addr);

drivers/perf/arm_pmu_acpi.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,40 @@ static inline void arm_spe_acpi_register_device(void)
163163
}
164164
#endif /* CONFIG_ARM_SPE_PMU */
165165

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+
166200
static int arm_pmu_acpi_parse_irqs(void)
167201
{
168202
int irq, cpu, irq_cpu, err;
@@ -398,6 +432,7 @@ static int arm_pmu_acpi_init(void)
398432
return 0;
399433

400434
arm_spe_acpi_register_device();
435+
arm_trbe_acpi_register_device();
401436

402437
return 0;
403438
}

include/linux/perf/arm_pmu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,5 +187,6 @@ void armpmu_free_irq(int irq, int cpu);
187187
#endif /* CONFIG_ARM_PMU */
188188

189189
#define ARMV8_SPE_PDEV_NAME "arm,spe-v1"
190+
#define ARMV8_TRBE_PDEV_NAME "arm,trbe"
190191

191192
#endif /* __ARM_PMU_H__ */

0 commit comments

Comments
 (0)