From patchwork Tue Feb 27 17:00:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadim Shakirov X-Patchwork-Id: 207400 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2924446dyb; Tue, 27 Feb 2024 11:40:29 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUgJM5B4OOiOwzaYnz0QhLABakNNaSrHjuVywE+yWc7xXoqzQNfqqr3HoxJbj1BE87i7qBiUmhKAgn9hFbbhB5p50QF5g== X-Google-Smtp-Source: AGHT+IGUDlP7lMYNEPxcOZAPW+mCRUWgnjbtvLJxxwQs55sxsKpEEoiqQRbWEl0V7Dn5RdU2Vm95 X-Received: by 2002:a17:902:e885:b0:1dc:a84c:987c with SMTP id w5-20020a170902e88500b001dca84c987cmr6268481plg.10.1709062829136; Tue, 27 Feb 2024 11:40:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709062829; cv=pass; d=google.com; s=arc-20160816; b=USzdAJUMAZDLd9ouvOlZgDVurbESdcDMmvu+CdEq/J4n05pMgzLMqjF+r0VoVhCAPI w1s0iUnnsAYRQYKkIUE9cAT+D2CnMUR5WrM0pzHil0wQDjL/+7lW6ENrU6flkaJIZrxT 5p6gg6RNbQcYL4+7hUB4n36MMw0qPRAeStXXR6ighGEJjADq2iKh/kvvMzegxqE0kJ5q AjcnQ5kbx8+LFlg1fiYC7RtwEVjtQtoa+BlLcAgnwGUkh3qr56sqSoWIqxS4fFPPefxa gvr/qdiJsnTEnv0oq7BqtyEFdrgda1zy2kOfp1wfcX4A++RJ5dPOZ1oslI1zCwGwwihW 2xQQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature:dkim-filter; bh=mczoY9NKf5IBt5T4Xh9ynOn0nMrRnFZ+wXSkQuHkLYM=; fh=GiuQLpP47Fx4Gxe+vA7zmxmm5objAsCwOHsMjIB74A4=; b=rmT9qx+akzBV/yE+HkxFF5jZRtNTdRyiDJApr6eWgVGz/pLmFGBuEx6nB96cuZwga5 228rY66ypUjepLCmo+F3faXVBr4ba66ktEBX9FcuTt53LCPNZsJuW9N6O4JsvIPB2m8n uwJyMFeXUq4qbm85qGtIBqgNGc4LB2Xxu9kDHqj+Dt8EjTbMdwZuHShW9ch0Q63R8sSK fM2gNm0/qbyS0vHJp5hgyX0w4AreN3lX0U7IUbGZJ5lRfF+ESGgA68/X3p5gKB0THVUB vFabpj/b69V556Y+3qV3Mf4vq1SwFk7O5sZ1SgVV39Bq+XjBzfB72pbqxdPUiLG4rlgU bcgA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@syntacore.com header.s=mta-04 header.b="ss/rCZVI"; dkim=pass header.i=@syntacore.com header.s=mta-03 header.b=Ac+HUnNY; arc=pass (i=1 dkim=pass dkdomain=syntacore.com dkim=pass dkdomain=syntacore.com dmarc=pass fromdomain=syntacore.com); spf=pass (google.com: domain of linux-kernel+bounces-83666-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83666-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=syntacore.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id n12-20020a170902d2cc00b001d9642def85si1842835plc.202.2024.02.27.11.40.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 11:40:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-83666-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@syntacore.com header.s=mta-04 header.b="ss/rCZVI"; dkim=pass header.i=@syntacore.com header.s=mta-03 header.b=Ac+HUnNY; arc=pass (i=1 dkim=pass dkdomain=syntacore.com dkim=pass dkdomain=syntacore.com dmarc=pass fromdomain=syntacore.com); spf=pass (google.com: domain of linux-kernel+bounces-83666-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83666-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=syntacore.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9B72A288267 for ; Tue, 27 Feb 2024 17:01:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 174A44879B; Tue, 27 Feb 2024 17:01:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=syntacore.com header.i=@syntacore.com header.b="ss/rCZVI"; dkim=pass (2048-bit key) header.d=syntacore.com header.i=@syntacore.com header.b="Ac+HUnNY" Received: from mta-04.yadro.com (mta-04.yadro.com [89.207.88.248]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 373C21D54A for ; Tue, 27 Feb 2024 17:01:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=89.207.88.248 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709053277; cv=none; b=uaHuesXcOS+dzvKlhNP7HKBSRYS3aOlVA+jetL7mXECPyv5lCCUGH/yRxrm6ntW0NsrQDhZH8xuzQ8T8XYWTnMWwY7BmpHxlYZN3Erj6f47v+P5mj0EZ8UuDJN22qVpsQ2t0w45Vn+nOgy1J+IaRg6WC1qZJa5oZyNdTBbGoTfg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709053277; c=relaxed/simple; bh=bznWHDXOpwAbmVELiNtkF+Zamo+nMl6cy7ms9jMVmTI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Rbpff0ZYvVCQ2FBojk2ujoPXQNulFh5d8HpmyCyXOAEi9//y/a/A0TgnAu/fwtLFvgfmh/mpZbNXBE2YYu5fpsG1YwgGjw/pr1VnzqPs1isCuCuv228KJCGKr27sYYfBpaWflCbipPilua+LU8Ccs4009+1NHlpAYCbGuAJLD8Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=syntacore.com; spf=fail smtp.mailfrom=syntacore.com; dkim=pass (2048-bit key) header.d=syntacore.com header.i=@syntacore.com header.b=ss/rCZVI; dkim=pass (2048-bit key) header.d=syntacore.com header.i=@syntacore.com header.b=Ac+HUnNY; arc=none smtp.client-ip=89.207.88.248 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=syntacore.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=syntacore.com DKIM-Filter: OpenDKIM Filter v2.11.0 mta-04.yadro.com 219C4C002E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syntacore.com; s=mta-04; t=1709053273; bh=mczoY9NKf5IBt5T4Xh9ynOn0nMrRnFZ+wXSkQuHkLYM=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=ss/rCZVIbpEiLw/81MIs41zgCIYwQ7eO1waUK8E2lC8XV1bPZ/ADFEl5i9RCdVgQn NVgXiB2dxEOFXWIKocoDXNdcQ+2ppyHptremx/GYff26TGVX6GRbvNeIWq329bsEcI XulHE91KC1Oj9t/Wb+cDtuvFR2oD13+CZd7wHbiH5dFfRx797j4UOCCsGy+p+yG4UH Sv7JIk/FNsJzUVcdNGIKyYsXSwav/yKU9qqMTUEyzTYlCrBl4aG6epatfU/yYXgdcx DTmEnXn7rAKjOaIxBvQxaYWh+AXP4XiOx3HHj6wqal3uhghxS37F+2xk4PNEbb+FC6 mFvMoAegilq5A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syntacore.com; s=mta-03; t=1709053273; bh=mczoY9NKf5IBt5T4Xh9ynOn0nMrRnFZ+wXSkQuHkLYM=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=Ac+HUnNYE6GR09eK4K4fDoSgzTYJDSzmjFTWbF4DHCLei8ZJ7/ZyhmedErh8tfw/i ouFn25bFeAJZgIzuSuoykv3pDYUCflzkbH6U8QlAqtW91cdxy81wrCSF9EiXM2TfeY C9o+l/5J39JIugvNl1fy+cxk7SYW88+zIyh7Wut7B+P4/c5hDjf4i++9/lRgLOIlES /DEqtjTlehyFThpiclkVrSV4eKqotjf2z0f/8pwTDZ1H5z6ktgfNd0CKiUB3Nlt5PS EG22pwa7H5Ytcv4YEx+XLMI0F6XLVE/XPzEiu+fI8+C8duGJUJ5V1PkM22tR1q1E7F UqQTU2G4Q4SXQ== From: Vadim Shakirov To: CC: Vadim Shakirov , Atish Patra , Anup Patel , Will Deacon , Mark Rutland , Paul Walmsley , Palmer Dabbelt , Albert Ou , , , Atish Patra Subject: [PATCH v2,RESEND 1/2] drivers: perf: added capabilities for legacy PMU Date: Tue, 27 Feb 2024 20:00:01 +0300 Message-ID: <20240227170002.188671-2-vadim.shakirov@syntacore.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240227170002.188671-1-vadim.shakirov@syntacore.com> References: <20240227170002.188671-1-vadim.shakirov@syntacore.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: T-Exch-05.corp.yadro.com (172.17.10.109) To S-Exch-01.corp.yadro.com (10.78.5.241) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792082172599716141 X-GMAIL-MSGID: 1792082265415259098 Added the PERF_PMU_CAP_NO_INTERRUPT flag because the legacy pmu driver does not provide sampling capabilities Added the PERF_PMU_CAP_NO_EXCLUDE flag because the legacy pmu driver does not provide the ability to disable counter incrementation in different privilege modes Suggested-by: Atish Patra Signed-off-by: Vadim Shakirov Reviewed-by: Atish Patra --- drivers/perf/riscv_pmu_legacy.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/perf/riscv_pmu_legacy.c b/drivers/perf/riscv_pmu_legacy.c index 79fdd667922e..a85fc9a15f03 100644 --- a/drivers/perf/riscv_pmu_legacy.c +++ b/drivers/perf/riscv_pmu_legacy.c @@ -117,6 +117,8 @@ static void pmu_legacy_init(struct riscv_pmu *pmu) pmu->event_mapped = pmu_legacy_event_mapped; pmu->event_unmapped = pmu_legacy_event_unmapped; pmu->csr_index = pmu_legacy_csr_index; + pmu->pmu.capabilities |= PERF_PMU_CAP_NO_INTERRUPT; + pmu->pmu.capabilities |= PERF_PMU_CAP_NO_EXCLUDE; perf_pmu_register(&pmu->pmu, "cpu", PERF_TYPE_RAW); } From patchwork Tue Feb 27 17:00:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadim Shakirov X-Patchwork-Id: 207409 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2937257dyb; Tue, 27 Feb 2024 12:06:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUUsPOktpejSpKjyP+2XzEA9p79H1GyPZsdVyY6NrKFU5LQWHfrpXn9iC9dfkqulR6jMFL9oa1A9VU9NpyivK6mvIj68w== X-Google-Smtp-Source: AGHT+IEH9GB62tI6i2U/4I1AVFk4gJ4zDl6HlqCEJroMNDNb8y8lO9nJerZ5jXWjkQAcBFn3rCY/ X-Received: by 2002:aa7:df0f:0:b0:566:4624:b11f with SMTP id c15-20020aa7df0f000000b005664624b11fmr1615319edy.30.1709064402923; Tue, 27 Feb 2024 12:06:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709064402; cv=pass; d=google.com; s=arc-20160816; b=OcIrbrsAmPvDmN9JcuflPI2CY8qcYzaKxLliUWPqS1/dWHRgEE111UzTQZh3V+zqbh IoucOWYT0bWbHPNZHPT+L5yJcSi2JeCVt4KJkkRxymucSfFTDw+Xm1n6a8NwmzEzkyYH e2GF8qIRyZNolLMTo1Ffr/0UfunfLzW3BI1xqnk9IviL5ZiMCqSQd4Enmwlug+5mtG33 ZOeZuynrK3J0HcfoygFeRjDvV6sVx97vWHjcwoFFLy5WYmQV/N8f4JRPLs3MO9+s/dLS OIv2bvneYRcZQwKBAxzenChmu7qBoJnHeg68twBWaAh93Rnx/c3iGBtCX4Kg7u7mVDDs Rl6Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature:dkim-filter; bh=58gVXq+fU1x+uUoPziMkIzpX3sjFEwU5Vn/YTcTbObo=; fh=nYlBdgVoG/dV0KM2IIXyhLoJcFYuxsFOGeAANJ+35DM=; b=bN1lxYuAzs5qwvMrv97vYDS/zfIJx17ho7BZhVXZOsAlj7HcVLByfXJpA4NCi5HT6g W/3UGWh/4T/CBSWkcDJ1cKm0gdiGOu2CtXKSQ50OqiLJq3EbAeOKidtWOoSkVIQeYnH+ ZYxLZOqaRbRiOslkM9E3RfqK18N3gvN7o/UeYACTPABBmoqLflDzu7Nd7pWcjIA8JEQX OaTee+PnrcCYZnhwlb5LEIU4XoY+aPlnAhEntupl3SZOljE1JKRofHpNqxAd0BNINydV R2mpgHZayjBGAuyMOZs80eN0izN+p9HlzUOvCDTLH62y7zJ9/G410FV4rGcwnt7VphTa JP3A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@syntacore.com header.s=mta-04 header.b=YomI9yAF; dkim=pass header.i=@syntacore.com header.s=mta-03 header.b=Sw+v6nCX; arc=pass (i=1 dkim=pass dkdomain=syntacore.com dkim=pass dkdomain=syntacore.com dmarc=pass fromdomain=syntacore.com); spf=pass (google.com: domain of linux-kernel+bounces-83667-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83667-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=syntacore.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id l2-20020a50d6c2000000b00564951ae492si998318edj.118.2024.02.27.12.06.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 12:06:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-83667-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@syntacore.com header.s=mta-04 header.b=YomI9yAF; dkim=pass header.i=@syntacore.com header.s=mta-03 header.b=Sw+v6nCX; arc=pass (i=1 dkim=pass dkdomain=syntacore.com dkim=pass dkdomain=syntacore.com dmarc=pass fromdomain=syntacore.com); spf=pass (google.com: domain of linux-kernel+bounces-83667-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83667-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=syntacore.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 960771F23255 for ; Tue, 27 Feb 2024 17:01:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 199A04D9F4; Tue, 27 Feb 2024 17:01:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=syntacore.com header.i=@syntacore.com header.b="YomI9yAF"; dkim=pass (2048-bit key) header.d=syntacore.com header.i=@syntacore.com header.b="Sw+v6nCX" Received: from mta-04.yadro.com (mta-04.yadro.com [89.207.88.248]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0EA272C6A8 for ; Tue, 27 Feb 2024 17:01:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=89.207.88.248 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709053279; cv=none; b=LuCA+gmvT+BkrJ/Vh9cTI1NSaS4ePjKj+v/ka5jXUQnw3ygX9T/QQTnkjHk/irIBU1QBw9Lv+N+LVnFOx8Fqna52nKRbxI08VFcSnblP4RGbfwuzNO+WVpqHeQ0Vpx5GZQ+fwv4R7xvji1uKGZtc0gyFRqnj5fCa3Ghxxrie6Vc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709053279; c=relaxed/simple; bh=Wc36hb848H6AezPZUzkfq3Obvb02VGA/gbMjVQzW1ZI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=riTVrn1qLb5TGjhyArn6QaeBduFgwjsOmiYxQzfZB8A53JrkHeRSpHnnUEhMO4encA0CZWAimQ7PhldrtEsj8AiOpDvS9RDcd7/OL5j6DNHVpr6292Jdsdkim6UE8lOsgcj2eXRCHfIcBDAlP6JoXSnLfyinzIuj39g21OZJ4HI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=syntacore.com; spf=fail smtp.mailfrom=syntacore.com; dkim=pass (2048-bit key) header.d=syntacore.com header.i=@syntacore.com header.b=YomI9yAF; dkim=pass (2048-bit key) header.d=syntacore.com header.i=@syntacore.com header.b=Sw+v6nCX; arc=none smtp.client-ip=89.207.88.248 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=syntacore.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=syntacore.com DKIM-Filter: OpenDKIM Filter v2.11.0 mta-04.yadro.com BA0A9C002E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syntacore.com; s=mta-04; t=1709053275; bh=58gVXq+fU1x+uUoPziMkIzpX3sjFEwU5Vn/YTcTbObo=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=YomI9yAFG8F/frgktYSH7jplWkGnY9i/2jh26JfW2wGrqzSCguhuoPSqj1nnB1/zm kbJ6d/TswN+97CFwWKo0BuDceoEzUSrMSR4q1gqzYCRXc/4pY8W3PQvL9PIWlxd4zb Pg+NwfQ4oZMF9A4VOf2fzJecRHDPMDHh886oov221qUBHa9uEoXrr+Zpkdv0mYeMl0 rAVVxJlTjBnwaVCFn6Ujd7GALRtqg2rDHdZHI4+GPNSFZk+jzVZWCTw57d7s8hQBIl xoGZdjXn0q3wxbUXW5BTekDwJc2PsW+ligZ+4lZ1nMUpL/po6oDD8rruwFT2+rjkiB J+i+8Qhe1xzeQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syntacore.com; s=mta-03; t=1709053275; bh=58gVXq+fU1x+uUoPziMkIzpX3sjFEwU5Vn/YTcTbObo=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=Sw+v6nCXYfNqRDiz9nMh9YSb7rEs/WY+Qyhfw7oXQn3mTol5l8A2Kq/zZd3tLY8X/ 5yvyyu5VxMQWDVZjMo5xTG1CkrTT8iBHXdcqK6zdFHOkpC7heLfOSY5rlKjKQy+Cyt bO3GoBUru16lY8itxcjYSvzmhYNyuDn/4easMam88Xcw+aEKlYWL/qv+vARXE7Lyvu mlkkuGOYlQAzokvMiUZG7LnE9BbOqz7X/oLh5RBJ4QkHWVcGiixnqU7u9Bh3RMMjQx WyCXFdNcaugoMQWkaLpKHuW7CedrQ0719Byz6wNWmwv0qruydnf6CCDpPVO8HGRWUi AhpNC0x7Y6K5w== From: Vadim Shakirov To: CC: Vadim Shakirov , Atish Patra , Anup Patel , Will Deacon , Mark Rutland , Paul Walmsley , Palmer Dabbelt , Albert Ou , , , Alexandre Ghiti , Atish Patra Subject: [PATCH v2,RESEND 2/2] drivers: perf: ctr_get_width function for legacy is not defined Date: Tue, 27 Feb 2024 20:00:02 +0300 Message-ID: <20240227170002.188671-3-vadim.shakirov@syntacore.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240227170002.188671-1-vadim.shakirov@syntacore.com> References: <20240227170002.188671-1-vadim.shakirov@syntacore.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: T-Exch-05.corp.yadro.com (172.17.10.109) To S-Exch-01.corp.yadro.com (10.78.5.241) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792080860279041696 X-GMAIL-MSGID: 1792083914869691812 With parameters CONFIG_RISCV_PMU_LEGACY=y and CONFIG_RISCV_PMU_SBI=n linux kernel crashes when you try perf record: $ perf record ls [ 46.749286] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000 [ 46.750199] Oops [#1] [ 46.750342] Modules linked in: [ 46.750608] CPU: 0 PID: 107 Comm: perf-exec Not tainted 6.6.0 #2 [ 46.750906] Hardware name: riscv-virtio,qemu (DT) [ 46.751184] epc : 0x0 [ 46.751430] ra : arch_perf_update_userpage+0x54/0x13e [ 46.751680] epc : 0000000000000000 ra : ffffffff8072ee52 sp : ff2000000022b8f0 [ 46.751958] gp : ffffffff81505988 tp : ff6000000290d400 t0 : ff2000000022b9c0 [ 46.752229] t1 : 0000000000000001 t2 : 0000000000000003 s0 : ff2000000022b930 [ 46.752451] s1 : ff600000028fb000 a0 : 0000000000000000 a1 : ff600000028fb000 [ 46.752673] a2 : 0000000ae2751268 a3 : 00000000004fb708 a4 : 0000000000000004 [ 46.752895] a5 : 0000000000000000 a6 : 000000000017ffe3 a7 : 00000000000000d2 [ 46.753117] s2 : ff600000028fb000 s3 : 0000000ae2751268 s4 : 0000000000000000 [ 46.753338] s5 : ffffffff8153e290 s6 : ff600000863b9000 s7 : ff60000002961078 [ 46.753562] s8 : ff60000002961048 s9 : ff60000002961058 s10: 0000000000000001 [ 46.753783] s11: 0000000000000018 t3 : ffffffffffffffff t4 : ffffffffffffffff [ 46.754005] t5 : ff6000000292270c t6 : ff2000000022bb30 [ 46.754179] status: 0000000200000100 badaddr: 0000000000000000 cause: 000000000000000c [ 46.754653] Code: Unable to access instruction at 0xffffffffffffffec. [ 46.754939] ---[ end trace 0000000000000000 ]--- [ 46.755131] note: perf-exec[107] exited with irqs disabled [ 46.755546] note: perf-exec[107] exited with preempt_count 4 This happens because in the legacy case the ctr_get_width function was not defined, but it is used in arch_perf_update_userpage. Also remove extra check in riscv_pmu_ctr_get_width_mask Signed-off-by: Vadim Shakirov Reviewed-by: Alexandre Ghiti Reviewed-by: Atish Patra --- drivers/perf/riscv_pmu.c | 18 +++++------------- drivers/perf/riscv_pmu_legacy.c | 8 +++++++- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/perf/riscv_pmu.c b/drivers/perf/riscv_pmu.c index 0dda70e1ef90..c78a6fd6c57f 100644 --- a/drivers/perf/riscv_pmu.c +++ b/drivers/perf/riscv_pmu.c @@ -150,19 +150,11 @@ u64 riscv_pmu_ctr_get_width_mask(struct perf_event *event) struct riscv_pmu *rvpmu = to_riscv_pmu(event->pmu); struct hw_perf_event *hwc = &event->hw; - if (!rvpmu->ctr_get_width) - /** - * If the pmu driver doesn't support counter width, set it to default - * maximum allowed by the specification. - */ - cwidth = 63; - else { - if (hwc->idx == -1) - /* Handle init case where idx is not initialized yet */ - cwidth = rvpmu->ctr_get_width(0); - else - cwidth = rvpmu->ctr_get_width(hwc->idx); - } + if (hwc->idx == -1) + /* Handle init case where idx is not initialized yet */ + cwidth = rvpmu->ctr_get_width(0); + else + cwidth = rvpmu->ctr_get_width(hwc->idx); return GENMASK_ULL(cwidth, 0); } diff --git a/drivers/perf/riscv_pmu_legacy.c b/drivers/perf/riscv_pmu_legacy.c index a85fc9a15f03..fa0bccf4edf2 100644 --- a/drivers/perf/riscv_pmu_legacy.c +++ b/drivers/perf/riscv_pmu_legacy.c @@ -37,6 +37,12 @@ static int pmu_legacy_event_map(struct perf_event *event, u64 *config) return pmu_legacy_ctr_get_idx(event); } +/* cycle & instret are always 64 bit, one bit less according to SBI spec */ +static int pmu_legacy_ctr_get_width(int idx) +{ + return 63; +} + static u64 pmu_legacy_read_ctr(struct perf_event *event) { struct hw_perf_event *hwc = &event->hw; @@ -111,7 +117,7 @@ static void pmu_legacy_init(struct riscv_pmu *pmu) pmu->ctr_stop = NULL; pmu->event_map = pmu_legacy_event_map; pmu->ctr_get_idx = pmu_legacy_ctr_get_idx; - pmu->ctr_get_width = NULL; + pmu->ctr_get_width = pmu_legacy_ctr_get_width; pmu->ctr_clear_idx = NULL; pmu->ctr_read = pmu_legacy_read_ctr; pmu->event_mapped = pmu_legacy_event_mapped;