From patchwork Mon Oct 17 05:57:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 3213 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1289366wrs; Sun, 16 Oct 2022 22:59:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7WZPnteQKd2tVvKacfjvYtZUeyShk4gBpsVssJp0q4BZ9MuyTWiph53Zlyx2n5siFC5oe1 X-Received: by 2002:a63:6a85:0:b0:43b:d845:f67d with SMTP id f127-20020a636a85000000b0043bd845f67dmr9043944pgc.349.1665986381728; Sun, 16 Oct 2022 22:59:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665986381; cv=none; d=google.com; s=arc-20160816; b=R6Tjb+OxyPLsI98cVA6UzKLY2hfyymODQ6OKlvU3ac21Db+7cOkP7LkTiWryygPYr/ G53OybUtTv82Sfb16o7wHB0w4e++mBoV4MfR/zU/SwPziKMbSQT1EsKgjb1C9x01fi7m iYGaiQPYkX3gP4vChyqqaEeTFC/8+Fw1LTaOYzvPDsel8SIJdf3ebPRvyp/huafPR38b j11Sia4E3vebaZmi74NQZYkBiBckwIszUUytSriRuXTfZ1BU8WHPW/FXKVgsRukPihvG reWwQ0hgirXGNT2wjHov7QOHi7RGemjYoqVJHh3SjlZq2o2d12wyvDvZEptu7wokCxS9 Z97A== 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=jmKfVqBDx6Q1JsVfcf2bav3tkpdhoe5RzNBcN7OyJnU=; b=Y2DgV/mvZ8q0ACKb/Mos8vt1hvAkhBSEk2pMbtMKG0fOvGm+wx5j5MXCM95Q/ZdOY5 WQcCfb0CQeX7tmKsWeXsgKiiln22aSlg51bYG/LlWxT4Qg0eSw4ysUQBinddQZMrU9LA aGGc1iq/5YbMcWSpOXEiKd0dPH6mMo8foESfoFbK6HqB/fduvjMRlhODYajCZgkDdf2D 9uR+YpSB1ylKBi1vTAtY+Mbbpk1zfUfK9imIeMsLpEY5X2PoNm36FCdt70DXcdBaCDtD EO8leTGOOg+PvgvtdVqMX7O/1yWdjlGhahEqIqnrjsDZbfvw0ZQycTKJf/zIfC+YjxU8 N4+w== 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 184-20020a6304c1000000b0046afcf0fa93si10491105pge.522.2022.10.16.22.59.29; Sun, 16 Oct 2022 22:59: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 S230164AbiJQF6Y (ORCPT + 99 others); Mon, 17 Oct 2022 01:58:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230137AbiJQF6Q (ORCPT ); Mon, 17 Oct 2022 01:58:16 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 273B3564EA; Sun, 16 Oct 2022 22:58:08 -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 DF3E31042; Sun, 16 Oct 2022 22:58:13 -0700 (PDT) Received: from a077893.blr.arm.com (unknown [10.162.42.7]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A96C03F7D8; Sun, 16 Oct 2022 22:58:02 -0700 (PDT) From: Anshuman Khandual To: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, peterz@infradead.org, acme@kernel.org, mark.rutland@arm.com, will@kernel.org, catalin.marinas@arm.com Cc: Anshuman Khandual , Mark Brown , James Clark , Rob Herring , Marc Zyngier , Suzuki Poulose , Ingo Molnar Subject: [PATCH V4 4/7] driver/perf/arm_pmu_platform: Add support for BRBE attributes detection Date: Mon, 17 Oct 2022 11:27:10 +0530 Message-Id: <20221017055713.451092-5-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221017055713.451092-1-anshuman.khandual@arm.com> References: <20221017055713.451092-1-anshuman.khandual@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746913336239431861?= X-GMAIL-MSGID: =?utf-8?q?1746913336239431861?= This adds arm pmu infrastrure to probe BRBE implementation's attributes via driver exported callbacks later. The actual BRBE feature detection will be added by the driver itself. CPU specific BRBE entries, cycle count, format support gets detected during PMU init. This information gets saved in per-cpu struct pmu_hw_events which later helps in operating BRBE during a perf event context. Cc: Will Deacon Cc: Mark Rutland Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- drivers/perf/arm_pmu_platform.c | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/perf/arm_pmu_platform.c b/drivers/perf/arm_pmu_platform.c index 933b96e243b8..acdc445081aa 100644 --- a/drivers/perf/arm_pmu_platform.c +++ b/drivers/perf/arm_pmu_platform.c @@ -172,6 +172,36 @@ static int armpmu_request_irqs(struct arm_pmu *armpmu) return err; } +static void arm_brbe_probe_cpu(void *info) +{ + struct pmu_hw_events *hw_events; + struct arm_pmu *armpmu = info; + + /* + * Return from here, if BRBE driver has not been + * implemented for this PMU. This helps prevent + * kernel crash later when brbe_probe() will be + * called on the PMU. + */ + if (!armpmu->brbe_probe) + return; + + hw_events = per_cpu_ptr(armpmu->hw_events, smp_processor_id()); + armpmu->brbe_probe(hw_events); +} + +static int armpmu_request_brbe(struct arm_pmu *armpmu) +{ + int cpu, err = 0; + + for_each_cpu(cpu, &armpmu->supported_cpus) { + err = smp_call_function_single(cpu, arm_brbe_probe_cpu, armpmu, 1); + if (err) + return err; + } + return err; +} + static void armpmu_free_irqs(struct arm_pmu *armpmu) { int cpu; @@ -229,6 +259,10 @@ int arm_pmu_device_probe(struct platform_device *pdev, if (ret) goto out_free_irqs; + ret = armpmu_request_brbe(pmu); + if (ret) + goto out_free_irqs; + ret = armpmu_register(pmu); if (ret) { dev_err(dev, "failed to register PMU devices!\n");