From patchwork Tue Aug 8 08:22:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 132824 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2366713vqr; Tue, 8 Aug 2023 13:06:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEYZ5Tgw57XA4Q7FfojQjohO04PgHh5fTx3QOghhpEOuxAAhPtrbZ/hs9JlDZEI5984kJ9u X-Received: by 2002:a17:906:ef8c:b0:99c:e1f4:193d with SMTP id ze12-20020a170906ef8c00b0099ce1f4193dmr430335ejb.31.1691525201613; Tue, 08 Aug 2023 13:06:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691525201; cv=none; d=google.com; s=arc-20160816; b=zME/Mxpy5BUkxCMR0VB9EljbNjhKkJFV+64OSXvxwdrMg/yzTkwfV03L3oCjz5Aqpv oqM+OAQU/TpaTwraTnaR1ENkm2YssMf325rZox/s+nGmh49lRNJUWALopBeldj7fGv+6 zkGGPtrsAltfAKM6k7YMk97hew/REtub7g21iSjYnr50Hoy9v2Gtt26UMejYxsALwPVd WSIENI1Wf6+gyPNyLlLyWU+/ewqoOWYfHr59hj9ptYg7QgPVi4U4RFxaNEE3t7jCvTDB tC9LqeEYnzpxk9A0Ra0IJLLt3mrt2hC/FYfnTtQzvwEHTIVcu8FM38cAzEfsEpJTVSTP HPxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=63UQpwUEBDUl7D0WykWHSqlfBEqKTp9QG2rc9pnFf5M=; fh=Amix3fM17tr65VI1fISDYxtFdk/MRmRQCaXTbLjGJHs=; b=gI2zsQxZYXjcmHIpeTi1V6H7MfLuu6eUGIxFqUFX7b4vb8n7RJIosexJo26DhYDKFn mBBbTHEtj5uaDBhWSMa50wSNy5zEHsiAcPn0n6/2PFUjnE0pUKOFHJ2svJkQvPFYw9lV Cd6jYSb0BWiiMWGkzEu/XxQsf9rrAzQDSnQbOywhGOBrjaQ2I63YT51viK+5OkztwSwQ U2dKQhI9yK6HFEO1WuQHNK9oG4SPFwJReYZGRmdCpEb7hQpZl7RmwfJu8h3IAdJ1aGXr of1yWl1LSuF9JbJZKHLcfQeap7DDQ/n8H8qMPoktCubvKNRr1s5WOg3LRxx9SLxY4jP3 co0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q12-20020a170906770c00b009952c411259si2358143ejm.197.2023.08.08.13.06.17; Tue, 08 Aug 2023 13:06:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232126AbjHHTTB (ORCPT + 99 others); Tue, 8 Aug 2023 15:19:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235968AbjHHTSW (ORCPT ); Tue, 8 Aug 2023 15:18:22 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9D97FFF622 for ; Tue, 8 Aug 2023 09:41:09 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D7512143D; Tue, 8 Aug 2023 01:23:50 -0700 (PDT) Received: from a077893.blr.arm.com (unknown [10.162.40.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 050733F7A6; Tue, 8 Aug 2023 01:23:03 -0700 (PDT) From: Anshuman Khandual To: linux-arm-kernel@lists.infradead.org, suzuki.poulose@arm.com Cc: yangyicong@huawei.com, Anshuman Khandual , Sami Mujawar , Catalin Marinas , Will Deacon , Mark Rutland , Mike Leach , Leo Yan , Alexander Shishkin , James Clark , coresight@lists.linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH V4 2/4] arm_pmu: acpi: Add a representative platform device for TRBE Date: Tue, 8 Aug 2023 13:52:45 +0530 Message-Id: <20230808082247.383405-3-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230808082247.383405-1-anshuman.khandual@arm.com> References: <20230808082247.383405-1-anshuman.khandual@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773692729823270913 X-GMAIL-MSGID: 1773692729823270913 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 Cc: Will Deacon Cc: Mark Rutland Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- arch/arm64/include/asm/acpi.h | 3 +++ drivers/perf/arm_pmu_acpi.c | 35 +++++++++++++++++++++++++++++++++++ include/linux/perf/arm_pmu.h | 1 + 3 files changed, 39 insertions(+) diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h index bd68e1b7f29f..4d537d56eb84 100644 --- a/arch/arm64/include/asm/acpi.h +++ b/arch/arm64/include/asm/acpi.h @@ -42,6 +42,9 @@ #define ACPI_MADT_GICC_SPE (offsetof(struct acpi_madt_generic_interrupt, \ spe_interrupt) + sizeof(u16)) +#define ACPI_MADT_GICC_TRBE (offsetof(struct acpi_madt_generic_interrupt, \ + trbe_interrupt) + sizeof(u16)) + /* Basic configuration for ACPI */ #ifdef CONFIG_ACPI pgprot_t __acpi_get_mem_attribute(phys_addr_t addr); diff --git a/drivers/perf/arm_pmu_acpi.c b/drivers/perf/arm_pmu_acpi.c index 72454bef2a70..845683ca7c64 100644 --- a/drivers/perf/arm_pmu_acpi.c +++ b/drivers/perf/arm_pmu_acpi.c @@ -164,6 +164,40 @@ static inline void arm_spe_acpi_register_device(void) } #endif /* CONFIG_ARM_SPE_PMU */ +#if IS_ENABLED(CONFIG_CORESIGHT_TRBE) +static struct resource trbe_resources[] = { + { + /* irq */ + .flags = IORESOURCE_IRQ, + } +}; + +static struct platform_device trbe_dev = { + .name = ARMV8_TRBE_PDEV_NAME, + .id = -1, + .resource = trbe_resources, + .num_resources = ARRAY_SIZE(trbe_resources) +}; + +static u16 arm_trbe_parse_gsi(struct acpi_madt_generic_interrupt *gicc) +{ + return gicc->trbe_interrupt; +} + +static void arm_trbe_acpi_register_device(void) +{ + int ret = arm_acpi_register_pmu_device(&trbe_dev, ACPI_MADT_GICC_TRBE, + arm_trbe_parse_gsi); + if (ret) + pr_warn("ACPI: TRBE: Unable to register device\n"); +} +#else +static inline void arm_trbe_acpi_register_device(void) +{ + +} +#endif /* CONFIG_CORESIGHT_TRBE */ + static int arm_pmu_acpi_parse_irqs(void) { int irq, cpu, irq_cpu, err; @@ -399,6 +433,7 @@ static int arm_pmu_acpi_init(void) return 0; arm_spe_acpi_register_device(); + arm_trbe_acpi_register_device(); return 0; } diff --git a/include/linux/perf/arm_pmu.h b/include/linux/perf/arm_pmu.h index a0801f68762b..143fbc10ecfe 100644 --- a/include/linux/perf/arm_pmu.h +++ b/include/linux/perf/arm_pmu.h @@ -187,5 +187,6 @@ void armpmu_free_irq(int irq, int cpu); #endif /* CONFIG_ARM_PMU */ #define ARMV8_SPE_PDEV_NAME "arm,spe-v1" +#define ARMV8_TRBE_PDEV_NAME "arm,trbe" #endif /* __ARM_PMU_H__ */