From patchwork Tue Aug 8 08:22:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 132733 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2328951vqr; Tue, 8 Aug 2023 11:56:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFqOQmQ4xZKeLsr2mNoU2n+ijwt4CZi9XnjOJCT6f00wZzEsFPKXCY4APsOvJZVeMCEphbO X-Received: by 2002:a17:906:53ce:b0:993:f2c2:750b with SMTP id p14-20020a17090653ce00b00993f2c2750bmr392159ejo.17.1691520961007; Tue, 08 Aug 2023 11:56:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691520960; cv=none; d=google.com; s=arc-20160816; b=U5h7t+lRGYyXMeGpcvfarpOzGsuyNfTTesjCLOYRg+y3jTK1bCOAxiGTAYADIrcy4z 6zz/+mqhJBSraB1SqIrBIqeki+m7aYY1d8gvQzvjpmovuwVccSVNv9P3L3ht+Nrey1G4 y7FNZCAJzhU0mIdGcYtSSkZfeA77dbdrnwvpqiYFf2+jE2BEB63cdiPgfku1zAyXCK9J Dlrlb3HCz1DCa18xQGYOw+HZlNNPqVljsUVvfoNPoZoK3dNE7rVEJVrW5nfWDMq8Ze/T 6+CkV04C3CivI6OsGNJO17wCOmdnK9QAFOFhuNnFWgqhtp/2RBmXjO/XvJBc+YNOxKs6 t+xQ== 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=lI/hVQyQvDvsD0HETdTutcF+pouTxrydyWIe9iDn/mw=; fh=Amix3fM17tr65VI1fISDYxtFdk/MRmRQCaXTbLjGJHs=; b=LXKQwo4Gxdaf+KK2q00ApSOP58vbR4d8p1q5yptgKU+3nxVqVw7CpD55vrec4UNH4q blH5aFqIAzdWbOac68IKcOcKVu2y/o6d/rV4y93zYiRUcf7EgfAyxu/oS/gf88Ixk5m2 c1oKPedTzmwWFTEEke3RjogCFMfJxBYInMYrYsS+cnx62ro/l+PoOQAgFTqFJKsNuykv +ue8TFDb5MB/+ECCG+H3Y6xhe0kBJXNJXkls46iAz4I5bchRw2OcybdzlgkmUb87FLmT dlDSIejJqco+vkYlj/DRN+rscz2Qu+PizXodIiLEDuQDqQTXufaKbPBjgPffpJkqhBJv sdgQ== 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 t18-20020a1709063e5200b0099cfb5dcbeesi887201eji.74.2023.08.08.11.55.37; Tue, 08 Aug 2023 11:56:00 -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 S235854AbjHHSdz (ORCPT + 99 others); Tue, 8 Aug 2023 14:33:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235852AbjHHSdg (ORCPT ); Tue, 8 Aug 2023 14:33:36 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 10F3E2988C for ; Tue, 8 Aug 2023 10:55:43 -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 5754D1424; Tue, 8 Aug 2023 01:23:46 -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 1FBC03F64C; Tue, 8 Aug 2023 01:22:58 -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 1/4] arm_pmu: acpi: Refactor arm_spe_acpi_register_device() Date: Tue, 8 Aug 2023 13:52:44 +0530 Message-Id: <20230808082247.383405-2-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=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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: 1773679365885066085 X-GMAIL-MSGID: 1773688283081050434 Sanity checking all the GICC tables for same interrupt number, and ensuring a homogeneous ACPI based machine, could be used for other platform devices as well. Hence this refactors arm_spe_acpi_register_device() into a common helper arm_acpi_register_pmu_device(). Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Rutland Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Co-developed-by: Will Deacon Signed-off-by: Will Deacon Signed-off-by: Anshuman Khandual --- drivers/perf/arm_pmu_acpi.c | 105 ++++++++++++++++++++++-------------- 1 file changed, 65 insertions(+), 40 deletions(-) diff --git a/drivers/perf/arm_pmu_acpi.c b/drivers/perf/arm_pmu_acpi.c index 90815ad762eb..72454bef2a70 100644 --- a/drivers/perf/arm_pmu_acpi.c +++ b/drivers/perf/arm_pmu_acpi.c @@ -69,6 +69,63 @@ static void arm_pmu_acpi_unregister_irq(int cpu) acpi_unregister_gsi(gsi); } +static int __maybe_unused +arm_acpi_register_pmu_device(struct platform_device *pdev, u8 len, + u16 (*parse_gsi)(struct acpi_madt_generic_interrupt *)) +{ + int cpu, this_hetid, hetid, irq, ret; + u16 this_gsi, gsi = 0; + + /* + * Ensure that platform device must have IORESOURCE_IRQ + * resource to hold gsi interrupt. + */ + if (pdev->num_resources != 1) + return -ENXIO; + + if (pdev->resource[0].flags != IORESOURCE_IRQ) + return -ENXIO; + + /* + * Sanity check all the GICC tables for the same interrupt + * number. For now, only support homogeneous ACPI machines. + */ + for_each_possible_cpu(cpu) { + struct acpi_madt_generic_interrupt *gicc; + + gicc = acpi_cpu_get_madt_gicc(cpu); + if (gicc->header.length < len) + return gsi ? -ENXIO : 0; + + this_gsi = parse_gsi(gicc); + if (!this_gsi) + return gsi ? -ENXIO : 0; + + this_hetid = find_acpi_cpu_topology_hetero_id(cpu); + if (!gsi) { + hetid = this_hetid; + gsi = this_gsi; + } else if (hetid != this_hetid || gsi != this_gsi) { + pr_warn("ACPI: %s: must be homogeneous\n", pdev->name); + return -ENXIO; + } + } + + irq = acpi_register_gsi(NULL, gsi, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_HIGH); + if (irq < 0) { + pr_warn("ACPI: %s Unable to register interrupt: %d\n", pdev->name, gsi); + return -ENXIO; + } + + pdev->resource[0].start = irq; + ret = platform_device_register(pdev); + if (ret < 0) { + pr_warn("ACPI: %s: Unable to register device\n", pdev->name); + acpi_unregister_gsi(gsi); + } + return ret; +} + #if IS_ENABLED(CONFIG_ARM_SPE_PMU) static struct resource spe_resources[] = { { @@ -84,6 +141,11 @@ static struct platform_device spe_dev = { .num_resources = ARRAY_SIZE(spe_resources) }; +static u16 arm_spe_parse_gsi(struct acpi_madt_generic_interrupt *gicc) +{ + return gicc->spe_interrupt; +} + /* * For lack of a better place, hook the normal PMU MADT walk * and create a SPE device if we detect a recent MADT with @@ -91,47 +153,10 @@ static struct platform_device spe_dev = { */ static void arm_spe_acpi_register_device(void) { - int cpu, hetid, irq, ret; - bool first = true; - u16 gsi = 0; - - /* - * Sanity check all the GICC tables for the same interrupt number. - * For now, we only support homogeneous ACPI/SPE machines. - */ - for_each_possible_cpu(cpu) { - struct acpi_madt_generic_interrupt *gicc; - - gicc = acpi_cpu_get_madt_gicc(cpu); - if (gicc->header.length < ACPI_MADT_GICC_SPE) - return; - - if (first) { - gsi = gicc->spe_interrupt; - if (!gsi) - return; - hetid = find_acpi_cpu_topology_hetero_id(cpu); - first = false; - } else if ((gsi != gicc->spe_interrupt) || - (hetid != find_acpi_cpu_topology_hetero_id(cpu))) { - pr_warn("ACPI: SPE must be homogeneous\n"); - return; - } - } - - irq = acpi_register_gsi(NULL, gsi, ACPI_LEVEL_SENSITIVE, - ACPI_ACTIVE_HIGH); - if (irq < 0) { - pr_warn("ACPI: SPE Unable to register interrupt: %d\n", gsi); - return; - } - - spe_resources[0].start = irq; - ret = platform_device_register(&spe_dev); - if (ret < 0) { + int ret = arm_acpi_register_pmu_device(&spe_dev, ACPI_MADT_GICC_SPE, + arm_spe_parse_gsi); + if (ret) pr_warn("ACPI: SPE: Unable to register device\n"); - acpi_unregister_gsi(gsi); - } } #else static inline void arm_spe_acpi_register_device(void) 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__ */ From patchwork Tue Aug 8 08:22:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 132726 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2328557vqr; Tue, 8 Aug 2023 11:55:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFRAWpsuzDB6WYYysIynHTiW98J2HkK21Fd+gTPkhSHyYtIJoR1PYSYTbcyqNPvDrmMlipW X-Received: by 2002:a05:6a20:1443:b0:13e:c03a:7c5d with SMTP id a3-20020a056a20144300b0013ec03a7c5dmr768368pzi.8.1691520909060; Tue, 08 Aug 2023 11:55:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691520909; cv=none; d=google.com; s=arc-20160816; b=qG8sz4XnqW2ajjS4dc4GLy2iLUf9z3Vv/c1Ll+JHNXGEQDKAjUFpNxQym0HJ7oLINE CVt1iOsjYIWjLiEzJSOyba0+TLdu2xqrmo+etTGmKaiy4A0GM3M8dc157bYbtbnzKdYb +EcMPt8nPo6ekehTqL833Na86/59+54YtUykmOwpftGz6eHF4a/FysWVulkOvDKib8sG Ye4x4cHTkPekhiX6nAUrAYfSNun4yCVwARXalkhFduOzAmowmH9341TSmW7PUAeTmYIs 793ZcomOLS84gRSSodVh2ldcFMlK9GQy/ZkGyN5gjEMVb4YN3UoYOxuJ8YG6+1TVmQwg HvmA== 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=JC2u1t9TgRDx5k7FvJLmbLB8O7+Njf3hqFzd6Yv6PjE=; fh=Amix3fM17tr65VI1fISDYxtFdk/MRmRQCaXTbLjGJHs=; b=xd+1pAgMALTdjs+8S7BrMpWmfzJUJHkZqI8z3ClY87rVOjo2K4wLA0AuWktymefoWW 0ttozX5nED8NJz7g2x7BETDza14uXhuQAuiJei4LKTdpY3kGnkaVy7K3XKb1J5rFCHmW NT4SjDu59M4YuUupJi0+8g0l5FOtL0SY2ICMiyiVF4QGa7ku6uCaxIfNkZ+6up1wY6vR FeHoGWmKwKrjiPKw7mowmUtK8XBWWR7TmpP81ExpcAjzNY6tAG0+jd+CIKP0JVCl5OE8 DbBQvEyOjZguX8cDOOkPvEoEyjP2bjY4rXjj7aixtuSlsM9sEyC0fJR+vLnaIYY70WHh 3QfQ== 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 a7-20020a634d07000000b005307d9f387esi7248966pgb.536.2023.08.08.11.54.55; Tue, 08 Aug 2023 11:55:09 -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 S232713AbjHHSd5 (ORCPT + 99 others); Tue, 8 Aug 2023 14:33:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235853AbjHHSdg (ORCPT ); Tue, 8 Aug 2023 14:33:36 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1242C2988D for ; Tue, 8 Aug 2023 10:55:43 -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 D92D11480; Tue, 8 Aug 2023 01:23:55 -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 E37A23F64C; Tue, 8 Aug 2023 01:23:08 -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 3/4] coresight: trbe: Add a representative coresight_platform_data for TRBE Date: Tue, 8 Aug 2023 13:52:46 +0530 Message-Id: <20230808082247.383405-4-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=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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: 1773688228637902452 X-GMAIL-MSGID: 1773688228637902452 TRBE coresight devices do not need regular connections information, as the paths get built between all percpu source and their respective percpu sink devices. Please refer 'commit 2cd87a7b293d ("coresight: core: Add support for dedicated percpu sinks")' which added support for percpu sink devices. coresight_register() expect device connections via the platform_data. TRBE devices do not have any graph connections and thus is empty. With upcoming ACPI support for TRBE, we do not get a real acpi_device and thus coresight_get_platform_dat() will end up in failures. Hence this allocates a zeroed coresight_platform_data structure and assigns that back into the device. Cc: Suzuki K Poulose Cc: Mike Leach Cc: Leo Yan Cc: Alexander Shishkin Cc: coresight@lists.linaro.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- drivers/hwtracing/coresight/coresight-trbe.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c index 7720619909d6..9455d62ca620 100644 --- a/drivers/hwtracing/coresight/coresight-trbe.c +++ b/drivers/hwtracing/coresight/coresight-trbe.c @@ -1494,9 +1494,20 @@ static int arm_trbe_device_probe(struct platform_device *pdev) if (!drvdata) return -ENOMEM; - pdata = coresight_get_platform_data(dev); - if (IS_ERR(pdata)) - return PTR_ERR(pdata); + /* + * TRBE coresight devices do not need regular connections + * information, as the paths get built between all percpu + * source and their respective percpu sink devices. Though + * coresight_register() expect device connections via the + * platform_data, which TRBE devices do not have. As they + * are not real ACPI devices, coresight_get_platform_data() + * ends up failing. Instead let's allocate a dummy zeroed + * coresight_platform_data structure and assign that back + * into the device for that purpose. + */ + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return -ENOMEM; dev_set_drvdata(dev, drvdata); dev->platform_data = pdata; From patchwork Tue Aug 8 08:22:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 132856 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2378112vqr; Tue, 8 Aug 2023 13:30:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFcwG9uCib1lHKdO3vczzJEr+qDo4QHhalmHvtsU8rQsJC7RQUgX5nWUuEoKQk+1jXTgIDR X-Received: by 2002:a05:6a20:f3aa:b0:140:7b6a:68fe with SMTP id qr42-20020a056a20f3aa00b001407b6a68femr588430pzb.35.1691526646268; Tue, 08 Aug 2023 13:30:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691526646; cv=none; d=google.com; s=arc-20160816; b=F3nlmXy89imR8T9f9NIzoALPxDbi02iPZfF6RI9hmH9+vkG+zrAkEFx+mPo759WkDg gif149T4GGZrg7cCU2lBezryCnFC/WodyMC+yGxq3Pc3MrpEE+QzBP+YK8u/YrYnyeff hdgd2ggT0oxJWp7D2/hIw8YGPpwoHmAwAP7Hg1ht/KxmjvidgX5yRvAdBOS/3RLMU63R ZtyKeIzbdv+l47UzuK67xNbqaorVE1cYInGMb2JZxrSU6D+bD8AG/DC2lDn6KIwa0Iln OUPNKXE6Uj52GOVYClA2vbaLg9JqYH2J4RdpaG44V3DzetM1P0sFty1aiU4OoNd1M1L1 k25g== 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=4UhGJvisDVMQMCZv8SkHZ/CXNnJ+ricqwiek4ORpzZ8=; fh=Amix3fM17tr65VI1fISDYxtFdk/MRmRQCaXTbLjGJHs=; b=qy7kLmFOZ9HARC4a5KdCbwkaU25VpvyYobDJ79STM9ZEUU91CdnNLowYmb7vfgB/gX msizTow/5x3AGpnBZkLky1fa3+TSHh0W97cZN/dRCo8sE1Yxh0rkeFTc40iArJiNo9Sh vzMH07LQt8A7I4L/zD7/2xbbTqhbM25sfJqhgHjn9quwnoiIV0QzH+vX9pyKPo3ia/OI pLYCV7xCbZRig5QpzJzD7NKqVkrPNVJtM8d5rpaozQtdG2mJYFb02iWIXcDMFhp1F9hz dL5HQ54nES/RSIbMQyBSNqEyaCX7W9LzTbVcrjb5UqEVPjYpJEmhsNJYFWBP1LwxTDTH S9xg== 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 kf15-20020a17090305cf00b001b8698149f2si7646852plb.588.2023.08.08.13.30.31; Tue, 08 Aug 2023 13:30:46 -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 S235964AbjHHTS5 (ORCPT + 99 others); Tue, 8 Aug 2023 15:18:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235971AbjHHTSW (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 3F2FF15B9E for ; Tue, 8 Aug 2023 09:41:10 -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 CDA3B14BF; Tue, 8 Aug 2023 01:24:00 -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 E78953F64C; Tue, 8 Aug 2023 01:23:13 -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 4/4] coresight: trbe: Enable ACPI based TRBE devices Date: Tue, 8 Aug 2023 13:52:47 +0530 Message-Id: <20230808082247.383405-5-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: 1773694244117587440 X-GMAIL-MSGID: 1773694244117587440 This detects and enables ACPI based TRBE devices via the dummy platform device created earlier for this purpose. Cc: Suzuki K Poulose Cc: Mike Leach Cc: Leo Yan Cc: Alexander Shishkin Cc: coresight@lists.linaro.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- drivers/hwtracing/coresight/coresight-trbe.c | 9 +++++++++ drivers/hwtracing/coresight/coresight-trbe.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c index 9455d62ca620..9c59e2652b20 100644 --- a/drivers/hwtracing/coresight/coresight-trbe.c +++ b/drivers/hwtracing/coresight/coresight-trbe.c @@ -1548,7 +1548,16 @@ static const struct of_device_id arm_trbe_of_match[] = { }; MODULE_DEVICE_TABLE(of, arm_trbe_of_match); +#ifdef CONFIG_ACPI +static const struct platform_device_id arm_trbe_acpi_match[] = { + { ARMV8_TRBE_PDEV_NAME, 0 }, + { } +}; +MODULE_DEVICE_TABLE(platform, arm_trbe_acpi_match); +#endif + static struct platform_driver arm_trbe_driver = { + .id_table = ACPI_PTR(arm_trbe_acpi_match), .driver = { .name = DRVNAME, .of_match_table = of_match_ptr(arm_trbe_of_match), diff --git a/drivers/hwtracing/coresight/coresight-trbe.h b/drivers/hwtracing/coresight/coresight-trbe.h index 77cbb5c63878..fce1735d5c58 100644 --- a/drivers/hwtracing/coresight/coresight-trbe.h +++ b/drivers/hwtracing/coresight/coresight-trbe.h @@ -7,11 +7,13 @@ * * Author: Anshuman Khandual */ +#include #include #include #include #include #include +#include #include #include