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 2ABA0C74A5B for ; Fri, 17 Mar 2023 19:51:48 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=2dePFy0qxta9F2SFGOZoTNJ0REX8c2rrbBuPW3ZBFYs=; b=ZBDd6coBsNuUBPPxRWoRwSBk+N QR0vL7D0Mi6d/kOU3GjGTDs3rY/MGTSj8a4bmPTKCqlpR8RQDcZHmc2jtZBy46Tls6e6qcyMFwHKI 2O+3ZZjurvstzQVwHbWoNsZtoR76DmxfSbN8r4k6rLaiE9HIWEgdTS5in7UpPm+dF8gIwUjBrEZIm NLrnlRLx8Ojo4D/EKP81D2DQvhAZ1j6VFExgfy/jYsWRRojgCVGqbU8O0ywci+U9F7L/KxwyFRcBi fevY9OEUKJPHXmRfELUlEHvZO7tgfQGEIZlI2DWWuOaiWmQgDbRTMQhN6UeP/GJy/hsIMiZJynIZ/ yfXr4XlQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pdG6L-003DVg-2t; Fri, 17 Mar 2023 19:50:57 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pdG6B-003DOW-06 for linux-arm-kernel@lists.infradead.org; Fri, 17 Mar 2023 19:50:50 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id z4-20020a25bb04000000b00b392ae70300so6279290ybg.21 for ; Fri, 17 Mar 2023 12:50:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1679082640; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=OZanjZTFt34uWWoDx9vYeq6DUks9Yoj2omylf+sLhU4=; b=AMW9j8tEbrj6MYXjN/b9FSnbh3fXQMLX9tfkHPC9F7jJwZ01YPGtwz24YpzidXMxi8 m23kArz9p6kSzERBd2BZZgJtAaqxUhE1fopBbA6P/8gifMnmxYA31QHRnU+Xuw9WvPia LnU1zmz2HjxpvvTRn9Dbd0mJq4we5lMcS9Imz9njG7aY8oq85MLILdgvs43ttQJksVdV aWOasMGp+Nq5xvEuKpvIhvXGETdp6T5Imq1vxkzauSSxEnASzPELMrpy6nTH4aZD4IXv 2um0iht5fCU9hvi3UAu+2otk8U/0a0YV+It10xKBO9pQoNVoOYOvjbpO5ykdWfeTXWXT ARbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679082640; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=OZanjZTFt34uWWoDx9vYeq6DUks9Yoj2omylf+sLhU4=; b=SrxU+eU5Jv/6+9Gy/4a7aMUs23lCrqx+qCtU/73axi61BK8hxm7icNQmZHxeweXs4r JSRufMi89Zqx06JlepC/3UFvhFpxGh5f0T2oh7TEgsy3fAc1kcTLLTDpvyHgh2WjMc0q +k49CVYuuJFmFk2IRKm60kZoZWFZepY5a4Mc3MgDOhur6WMzzwkowXN7bdTrefNOGYIx +7TBjfKnzs2+Zl5iG0bqUdjyOUoKBziOS9OkKvOOx90OuqX8p2t8b4FK64Q0BPKCAUM5 fExQwhqMAqWZIzYDewUbZlLQKMIy3tYTreiTdjNN8fnpuELlPkaq3I4sq5gt+xqjejt7 JYUQ== X-Gm-Message-State: AO0yUKWWneZ6cfFcYq3HNJ4LfL5mMV2wUoSK0rwI+l7Hc4PQAHwDx/EN uks+KO5wN7OO/N+tZk54ooW/r9tQJgQhQKY= X-Google-Smtp-Source: AK7set/Hzrn9jsLu0odq0bRYnz52oqZFiiyGaEtR50yaGkrnqBm1Rhj7V03foPPkwfNFt5/UASXDJH3oMcMZMQU= X-Received: from zaidcloud.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5325]) (user=zalbassam job=sendgmr) by 2002:a05:6902:1004:b0:b54:c2d4:71cf with SMTP id w4-20020a056902100400b00b54c2d471cfmr549327ybt.3.1679082639729; Fri, 17 Mar 2023 12:50:39 -0700 (PDT) Date: Fri, 17 Mar 2023 15:50:22 -0400 In-Reply-To: <20230317195027.3746949-1-zalbassam@google.com> Mime-Version: 1.0 References: <20230317195027.3746949-1-zalbassam@google.com> X-Mailer: git-send-email 2.40.0.rc2.332.ga46443480c-goog Message-ID: <20230317195027.3746949-4-zalbassam@google.com> Subject: [PATCH v4 3/8] perf: pmuv3: Abstract PMU version checks From: Zaid Al-Bassam To: Jesus Sanchez-Palencia , Russell King , Catalin Marinas , Will Deacon , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Marc Zyngier , James Morse , Suzuki K Poulose , Oliver Upton , Zenghui Yu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu, f.fainelli@gmail.com Cc: Zaid Al-Bassam X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230317_125047_075709_A144F7E2 X-CRM114-Status: GOOD ( 12.97 ) 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: , 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 The current PMU version definitions are available for arm64 only, As we want to add PMUv3 support to arm (32-bit), abstracts these definitions by using arch-specific helpers. Signed-off-by: Zaid Al-Bassam Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/arm_pmuv3.h | 16 ++++++++++++++++ drivers/perf/arm_pmuv3.c | 7 +++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/arm_pmuv3.h b/arch/arm64/include/asm/arm_pmuv3.h index c444cbfb3acd..80cdfa4c3e88 100644 --- a/arch/arm64/include/asm/arm_pmuv3.h +++ b/arch/arm64/include/asm/arm_pmuv3.h @@ -134,4 +134,20 @@ static inline u32 read_pmceid1(void) return read_sysreg(pmceid1_el0); } +static inline bool pmuv3_implemented(int pmuver) +{ + return !(pmuver == ID_AA64DFR0_EL1_PMUVer_IMP_DEF || + pmuver == ID_AA64DFR0_EL1_PMUVer_NI); +} + +static inline bool is_pmuv3p4(int pmuver) +{ + return pmuver >= ID_AA64DFR0_EL1_PMUVer_V3P4; +} + +static inline bool is_pmuv3p5(int pmuver) +{ + return pmuver >= ID_AA64DFR0_EL1_PMUVer_V3P5; +} + #endif diff --git a/drivers/perf/arm_pmuv3.c b/drivers/perf/arm_pmuv3.c index f783f068d612..f7d890af8cc1 100644 --- a/drivers/perf/arm_pmuv3.c +++ b/drivers/perf/arm_pmuv3.c @@ -392,7 +392,7 @@ static const struct attribute_group armv8_pmuv3_caps_attr_group = { */ static bool armv8pmu_has_long_event(struct arm_pmu *cpu_pmu) { - return (cpu_pmu->pmuver >= ID_AA64DFR0_EL1_PMUVer_V3P5); + return (is_pmuv3p5(cpu_pmu->pmuver)); } static inline bool armv8pmu_event_has_user_read(struct perf_event *event) @@ -1084,8 +1084,7 @@ static void __armv8pmu_probe_pmu(void *info) int pmuver; pmuver = read_pmuver(); - if (pmuver == ID_AA64DFR0_EL1_PMUVer_IMP_DEF || - pmuver == ID_AA64DFR0_EL1_PMUVer_NI) + if (!pmuv3_implemented(pmuver)) return; cpu_pmu->pmuver = pmuver; @@ -1111,7 +1110,7 @@ static void __armv8pmu_probe_pmu(void *info) pmceid, ARMV8_PMUV3_MAX_COMMON_EVENTS); /* store PMMIR register for sysfs */ - if (pmuver >= ID_AA64DFR0_EL1_PMUVer_V3P4 && (pmceid_raw[1] & BIT(31))) + if (is_pmuv3p4(pmuver) && (pmceid_raw[1] & BIT(31))) cpu_pmu->reg_pmmir = read_pmmir(); else cpu_pmu->reg_pmmir = 0; -- 2.40.0.rc2.332.ga46443480c-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel