Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp978231rdh; Fri, 24 Nov 2023 02:32:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IHgrSlH1bbYgWnVGBck8HXCIuSeohSWAegfeN/U0AvtzXXsRy+48IuYDhRC6oJdH01CcfsB X-Received: by 2002:a05:6a21:150b:b0:187:b800:d2ef with SMTP id nq11-20020a056a21150b00b00187b800d2efmr2564484pzb.29.1700821968915; Fri, 24 Nov 2023 02:32:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700821968; cv=none; d=google.com; s=arc-20160816; b=yH3vywOsFz+WjRhI+UN798yxfXgxB3Mc4n/xQJsKU9NkRpp7wzShUvC9MjR3s9JejQ V/3Q+JoJvDGKS5VH8yGMjeYTvNVfTz8zouOuup/R8gaB2klYxtmY9uO34NPXrGVnMixu hExQJmS4oHyC3cMxonAc6uBi00L/Xzq98qX/L7dnVQzTMqnWldqVkn5jn1gX4duRyJFR lyyR1z4t/gFUSltNTTJo2hSYOGIjT+1osIDCFYhKjAxj/Z6+5jp4HWV1xp+9Io29Nuax wHLj3+UOgY/DmJLkfo+H/cDJnzKE4UIkIPQ/cLNhZqYaoAjkF0Mx4vEwK6IckmxyE7l7 Zb+A== 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=RdhqbyriAri86IQ7r5NkBKftmN9xH2AkGp+B7K5NIdA=; fh=oX6hmw7s8CVkCq535lmsJsLaGsKyCgbCHPgvYWotT9M=; b=VsyGA7neZ6ILBwVWfvEQhyBjzDNpA3OtQs3yr8arH+IFzGKwShLrvY3yjBCzJraEGn 12MJm4jE5Vhn1rexBxdyfv+oH6/QObUOMHx/O0kf2bl+bMO6CJ9uAld0MrtTmjU8g3yq SW2rlA3QrVHUm8fehAzGk3La1XeNzyQLTKhw2R3Gus9M3FQtBiFvxVfImp8HRzB+zbLa XxyQud0IWJebymUxSmGhjL//KvFzjAjj2kzl0D30V15K48nGXpcp1j5NlNaTm9m9a0F7 PGxl/om4rHfMjuIt1XcY/dLaYQEk3ke0j1wAjLHfJkigiU2cuTGEjylkyVA7MAN8PC0v CbDQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id q8-20020a17090311c800b001cc407388a8si3214847plh.337.2023.11.24.02.32.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 02:32:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id C27A58040EE3; Fri, 24 Nov 2023 02:32:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345358AbjKXKbq (ORCPT + 99 others); Fri, 24 Nov 2023 05:31:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230320AbjKXKbm (ORCPT ); Fri, 24 Nov 2023 05:31:42 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B65A21B2; Fri, 24 Nov 2023 02:31:47 -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 EEF0B1424; Fri, 24 Nov 2023 02:32:33 -0800 (PST) Received: from e127643.arm.com (unknown [10.57.5.4]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id AAF083F7A6; Fri, 24 Nov 2023 02:31:45 -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, anshuman.khandual@arm.com, namhyung@gmail.com Cc: James Clark , Catalin Marinas , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 1/3] arm64: perf: Include threshold control fields in PMEVTYPER mask Date: Fri, 24 Nov 2023 10:28:55 +0000 Message-Id: <20231124102857.1106453-2-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231124102857.1106453-1-james.clark@arm.com> References: <20231124102857.1106453-1-james.clark@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 24 Nov 2023 02:32:03 -0800 (PST) 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. Reviewed-by: Suzuki K Poulose Reviewed-by: Anshuman Khandual Signed-off-by: James Clark --- 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 */ /* -- 2.34.1