From patchwork Mon Nov 13 11:25:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 164435 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1136497vqg; Mon, 13 Nov 2023 03:28:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IHU6MpcHfcR2MXFiYyMhIHVTnkLuX9skbKZsRdCh1RKuVnkl0v/guWTXfWms2TtvbhrFbmm X-Received: by 2002:a17:902:ab0f:b0:1c0:cbaf:6930 with SMTP id ik15-20020a170902ab0f00b001c0cbaf6930mr7057483plb.54.1699874896229; Mon, 13 Nov 2023 03:28:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699874896; cv=none; d=google.com; s=arc-20160816; b=k17+NDtxa3zGPDmKJNTIr9LndcHvTCa+SfT8Rruh403ZaZYiPvaqhYHOyrmAlGooI2 RDJo7c5kfAbwFMzdMm9Ygp0VSgUrPkSB9Fani+H164YZO6YEwE7i6Afy5N55nhge+gAf GR+wVpGaOn8xZ8x2hL1bZgUB1F95Mjrtstab8ANRK8VqDmrU79mvOArIHl3qoFkGL3+t DJNrjksDt8qA/hkEYizIt/vGDgnjGGQt8AOkjVAI6/AN6M9Yk3bEd1BfeMxNqvmQwtAt 2Kg1+2B3Cakq0WgPNWUjFStG9R21jaZhYsoQTMEizIcSJzE2QZ1YpNZd6LtAxIF1K302 z9lw== 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=TsatTn4oeWBpju4qpkUjZL591X6IsGDiDcU8AoqMfME=; fh=SnCd4bvG88NEfyCdvKK/GXg69kKL/C759z8uFsR/n/U=; b=cSXCU8LN6RrQwz7mpf4cVdsb2mRKLnmK+mUEX6l93a84khbwfI++4wdYhgCdzMJbT8 Ce3JaUQO+Z+TENhbS9hb1BkbYqw0ZrrWGP5yYUb7aOuBc4bbOUVFGiYWyIjm4T62mn6g jHQMZijMpvDs69OuQVpDrr1DaPWWzC/on3YbSRb/P9udXvdD4W8z33zlJD0QsOj6bKa0 B3Jg1MXCZBcU29R9GQxDebpIZzZSe+wC+33POT7t+lDAAHtgWDFgiK9DGEzqZOeiW07u xeqxjPDMZgcMDc9i9pnh2vIDoKjgQ3pULLOMGvQL/XCurY3+kNYj9lZSUq3lF1lWVb2T jsiQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id je5-20020a170903264500b001c32d285db8si5210974plb.308.2023.11.13.03.28.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 03:28:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id DDFCC8057B2A; Mon, 13 Nov 2023 03:28:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230297AbjKML2C (ORCPT + 29 others); Mon, 13 Nov 2023 06:28:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230056AbjKML1s (ORCPT ); Mon, 13 Nov 2023 06:27:48 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0A3BE49CB; Mon, 13 Nov 2023 03:26:06 -0800 (PST) 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 AC2711007; Mon, 13 Nov 2023 03:26:41 -0800 (PST) Received: from e127643.arm.com (unknown [10.57.71.191]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D16533F6C4; Mon, 13 Nov 2023 03:25:53 -0800 (PST) From: James Clark To: linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, suzuki.poulose@arm.com, will@kernel.org, mark.rutland@arm.com Cc: James Clark , Catalin Marinas , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 1/3] arm64: perf: Include threshold control fields in PMEVTYPER mask Date: Mon, 13 Nov 2023 11:25:04 +0000 Message-Id: <20231113112507.917107-2-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231113112507.917107-1-james.clark@arm.com> References: <20231113112507.917107-1-james.clark@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 13 Nov 2023 03:28:13 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782448019040125120 X-GMAIL-MSGID: 1782448019040125120 FEAT_PMUv3_TH (Armv8.8) adds two new fields to PMEVTYPER, so include them in the mask. These aren't writable on 32 bit kernels as they are in the high part of the register, so only include them for arm64. It would be difficult to do this statically in the asm header files for each platform without resulting in circular includes or #ifdefs inline in the code. For that reason the ARMV8_PMU_EVTYPE_MASK definition has been removed and the mask is constructed programmatically. Signed-off-by: James Clark Reviewed-by: Suzuki K Poulose Reviewed-by: Anshuman Khandual --- drivers/perf/arm_pmuv3.c | 9 ++++++++- include/linux/perf/arm_pmuv3.h | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/perf/arm_pmuv3.c b/drivers/perf/arm_pmuv3.c index 6ca7be05229c..1d40d794f5e4 100644 --- a/drivers/perf/arm_pmuv3.c +++ b/drivers/perf/arm_pmuv3.c @@ -555,8 +555,15 @@ static void armv8pmu_write_counter(struct perf_event *event, u64 value) static inline void armv8pmu_write_evtype(int idx, u32 val) { u32 counter = ARMV8_IDX_TO_COUNTER(idx); + unsigned long mask = ARMV8_PMU_EVTYPE_EVENT | + ARMV8_PMU_INCLUDE_EL2 | + ARMV8_PMU_EXCLUDE_EL0 | + ARMV8_PMU_EXCLUDE_EL1; - val &= ARMV8_PMU_EVTYPE_MASK; + if (IS_ENABLED(CONFIG_ARM64)) + mask |= ARMV8_PMU_EVTYPE_TC | ARMV8_PMU_EVTYPE_TH; + + val &= mask; write_pmevtypern(counter, val); } diff --git a/include/linux/perf/arm_pmuv3.h b/include/linux/perf/arm_pmuv3.h index 9c226adf938a..ddd1fec86739 100644 --- a/include/linux/perf/arm_pmuv3.h +++ b/include/linux/perf/arm_pmuv3.h @@ -228,7 +228,8 @@ /* * PMXEVTYPER: Event selection reg */ -#define ARMV8_PMU_EVTYPE_MASK 0xc800ffff /* Mask for writable bits */ +#define ARMV8_PMU_EVTYPE_TH GENMASK(43, 32) +#define ARMV8_PMU_EVTYPE_TC GENMASK(63, 61) #define ARMV8_PMU_EVTYPE_EVENT 0xffff /* Mask for EVENT bits */ /*