Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4079501rdb; Mon, 11 Dec 2023 08:16:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IFgxF8m1hp18W3NQyx+6z6kZlIa+LvyUSZp41NmfC1rZcaB3NESiM9IUiHOYccHqdrbjiXG X-Received: by 2002:a17:903:1104:b0:1d3:16a6:d498 with SMTP id n4-20020a170903110400b001d316a6d498mr3063889plh.60.1702311375482; Mon, 11 Dec 2023 08:16:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702311375; cv=none; d=google.com; s=arc-20160816; b=TGRPICLk7SQqRHKgeuaXJiv/RzuBeqaxQM+uLs8K1XXuOvCAR/tBDhyO8oFir6KEJX wR3MQGUhcgVoS8tDcWppqqbQ31Dj6JS4d5POxRDCZyiyGenYSEgdANC8pGYucNuSg26c mEYhPtWFefjGl174rMgKCWUOsRVAmldTQrhzBoPZ++GxZT5X12b5in7XJKnoIiQpBHE6 j4krYFwxv8+qsUmoeVrFKLM77m+RepL6PVd271NeHlClaPEPb6lzrZqdPbRLVnQ2OEFc P5Xu/e20YuOx1vph/Rd7dh9TxSn8hlp3eJJGtDjpLRBUTqVPExOps6f4ea9JgEafLHE9 HtCw== 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=jYI1AvYhknoKh/5i/C7XspMbyp6aB5zFKWrWA0QBcR8=; fh=oRTr1d7mCDMKQCV8DFHHjee6VGmKsUMMuSV4+yK9gas=; b=cO+TIOYmGT2C40UkV8SSzOuvznZhn8drKkBFzJ3mCX0vjCnCOVMN7b/PezbdeqoG+3 u8GLppKWfD3Ln7MSkr2MXroLEP7ruWdOAeAFYB5rzFJr7bPHh9nE9NxQksyLBaLJP5QV QH41E49fPy/aab8zs8o1mxDtzVPVfQu9kDEuDZPyfJZIPjZCfUH14dSYUAkftyMRRrJZ mCGLSffa6kd8dC24CUj1oJdUK/2zK7f8OyX2yFETh++AsD/aLJ3RMRB3kba4btp8j4NH HYfrmxWcZpWar1Q9Ak5aYRYllj9ZawFF0AK/dlP5+z/wVEkTFY7Io9hn7NtjFuogNz/t oa1Q== 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:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id l5-20020a170903120500b001d00a866032si6336766plh.223.2023.12.11.08.16.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 08:16:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 99EF480843EF; Mon, 11 Dec 2023 08:16:12 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344370AbjLKQP7 (ORCPT + 99 others); Mon, 11 Dec 2023 11:15:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344624AbjLKQPR (ORCPT ); Mon, 11 Dec 2023 11:15:17 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D7D2AD56; Mon, 11 Dec 2023 08:14:54 -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 2B79F16F3; Mon, 11 Dec 2023 08:15:41 -0800 (PST) Received: from e127643.broadband (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A91923F738; Mon, 11 Dec 2023 08:14:50 -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 Cc: namhyung@gmail.com, James Clark , Catalin Marinas , Jonathan Corbet , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Russell King , Marc Zyngier , Oliver Upton , James Morse , Zenghui Yu , Paolo Bonzini , Shuah Khan , Zaid Al-Bassam , Raghavendra Rao Ananta , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v7 05/11] arm64: perf: Include threshold control fields in PMEVTYPER mask Date: Mon, 11 Dec 2023 16:13:17 +0000 Message-Id: <20231211161331.1277825-6-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231211161331.1277825-1-james.clark@arm.com> References: <20231211161331.1277825-1-james.clark@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 morse.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 (morse.vger.email [0.0.0.0]); Mon, 11 Dec 2023 08:16:12 -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 fbdf3cab8e66..16ef8448afc0 100644 --- a/drivers/perf/arm_pmuv3.c +++ b/drivers/perf/arm_pmuv3.c @@ -554,8 +554,15 @@ static void armv8pmu_write_counter(struct perf_event *event, u64 value) static 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 daa63542242d..91957b3468e9 100644 --- a/include/linux/perf/arm_pmuv3.h +++ b/include/linux/perf/arm_pmuv3.h @@ -233,8 +233,9 @@ /* * PMXEVTYPER: Event selection reg */ -#define ARMV8_PMU_EVTYPE_MASK 0xc800ffff /* Mask for writable bits */ #define ARMV8_PMU_EVTYPE_EVENT GENMASK(15, 0) /* Mask for EVENT bits */ +#define ARMV8_PMU_EVTYPE_TH GENMASK(43, 32) +#define ARMV8_PMU_EVTYPE_TC GENMASK(63, 61) /* * Event filters for PMUv3 -- 2.34.1