From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 88659C433EF for ; Mon, 9 May 2022 17:30:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=LHhC9PYExOQ+WTOrIQCEZ3smOoAjkt40/Q8R5r0pJ8A=; b=3OKOUl1/d7IzSV 4YKV0qOfrs7z94YJ4Vkxiy2Suoq5/5EdASy9CQHYG45qaPUq2yj2UTBALvFgmwQo1pSWx30DDLadx BDXSpQcr/iejCp+OpHs+MlsdID0XbHwquY1MpG+wiT0ew5gvk6h75TBQUTIWQA42Ck1BJ5g9j2acS RFD1Vms1HVzzEiYCRZKvWQr/PkrLBZEO1nQ2PJ+uwtOryBuCBSkF4NWjZMJ7cgPAqEa64fe9WJ3om aXPEqcYonI/fdcxTAdZcSFDUgIo8CIwkcU7BcMLZ53wCesjH+9H+QvmwBwpKu0UDatyHvfDf1bA/1 y7Z8vrl6GW/MulZOYs8Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1no7CD-00FaeZ-4t; Mon, 09 May 2022 17:29:21 +0000 Received: from alexa-out.qualcomm.com ([129.46.98.28]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1no7C9-00FadZ-Rm for linux-arm-kernel@lists.infradead.org; Mon, 09 May 2022 17:29:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1652117358; x=1683653358; h=from:to:cc:subject:date:message-id; bh=w8WwiKdUcDjQO2d2znxaFZegHXKvmkZZDdebrvYoFpk=; b=HKzneDhxvSCFaCEGERkl3xiBz9/urDsT4oswMmHXXdFqhNoUamdlV4t4 tQmqdTdZqlTAEOnYI0KQwsifiXxUJYy1jvEy/55dW2FDGxjP8KtfCTeJB YWSX39ARHBWiL0fJtKulWc/I3W6Ydgln4tiQTPndYzvuQXNIWYch5ZmfO Q=; Received: from ironmsg09-lv.qualcomm.com ([10.47.202.153]) by alexa-out.qualcomm.com with ESMTP; 09 May 2022 10:29:17 -0700 X-QCInternal: smtphost Received: from ironmsg01-blr.qualcomm.com ([10.86.208.130]) by ironmsg09-lv.qualcomm.com with ESMTP/TLS/AES256-SHA; 09 May 2022 10:29:15 -0700 X-QCInternal: smtphost Received: from hu-c-spathi-hyd.qualcomm.com (HELO hu-sgudaval-hyd.qualcomm.com) ([10.213.108.59]) by ironmsg01-blr.qualcomm.com with ESMTP; 09 May 2022 22:58:59 +0530 Received: by hu-sgudaval-hyd.qualcomm.com (Postfix, from userid 212714) id 19C663D62; Mon, 9 May 2022 22:58:58 +0530 (+0530) From: Srinivasarao Pathipati To: will@kernel.org, mark.rutland@arm.com, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, catalin.marinas@arm.com, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Srinivasarao Pathipati Subject: [PATCH V3] arm64: perf: Retain PMCR.X of PMCR_EL0 during reset Date: Mon, 9 May 2022 22:58:50 +0530 Message-Id: <1652117330-21976-1-git-send-email-quic_c_spathi@quicinc.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220509_102917_989494_6791DF17 X-CRM114-Status: GOOD ( 12.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Preserve the bit PMCR.X of PMCR_EL0 during PMU reset to export PMU events. as it could be set before PMU initialization. Exporting events could result in additional power consumption so making it configurable. Signed-off-by: Srinivasarao Pathipati --- Changes since V2: Done below changes as per Will's comments - enabling pmcr_x now configurable with kernel parameters and by default it is disabled. Changes since V1: - Preserving only PMCR_X bit as per Robin Murphy's comment. --- Documentation/admin-guide/kernel-parameters.txt | 4 ++++ arch/arm64/kernel/perf_event.c | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index de3da15..cf3410e 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -5150,6 +5150,10 @@ Useful for devices that are detected asynchronously (e.g. USB and MMC devices). + retain_pmcr_x + [KNL] Retain export bit of PMCR_EL0 that is getting reset + during pmu reset. + retain_initrd [RAM] Keep initrd memory after extraction rfkill.default_state= diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c index cb69ff1..1ac251f 100644 --- a/arch/arm64/kernel/perf_event.c +++ b/arch/arm64/kernel/perf_event.c @@ -34,6 +34,7 @@ #define ARMV8_THUNDER_PERFCTR_L1I_CACHE_PREF_ACCESS 0xEC #define ARMV8_THUNDER_PERFCTR_L1I_CACHE_PREF_MISS 0xED +static int export_pmu_events __read_mostly; /* * ARMv8 Architectural defined events, not all of these may * be supported on any given implementation. Unsupported events will @@ -1025,6 +1026,14 @@ static int armv8pmu_filter_match(struct perf_event *event) return evtype != ARMV8_PMUV3_PERFCTR_CHAIN; } +static int __init retain_pmcr_x(char *str) +{ + export_pmu_events = 1; + return 0; +} + +early_param("retain_pmcr_x", retain_pmcr_x); + static void armv8pmu_reset(void *info) { struct arm_pmu *cpu_pmu = (struct arm_pmu *)info; @@ -1047,6 +1056,10 @@ static void armv8pmu_reset(void *info) if (armv8pmu_has_long_event(cpu_pmu)) pmcr |= ARMV8_PMU_PMCR_LP; + /* Preserve PMCR_X to export PMU events */ + if (export_pmu_events) + pmcr |= (armv8pmu_pmcr_read() & ARMV8_PMU_PMCR_X); + armv8pmu_pmcr_write(pmcr); } -- 2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel