From patchwork Wed Jul 5 10:48:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 13301948 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 5EBF3EB64DA for ; Wed, 5 Jul 2023 10:45:31 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FYnMe254hNdGghe13cM2lUZbJxV7LGb0ZVOJGooJgK4=; b=2QbrUTJGT1NLMr v2I6VO0lg/FuUeN3GiYj8uA4cLEjP3Pogqi33bI+b/sdathSLKXyb5Bivwz3oFZZOR8IDKJ//gh78 sAnzuRtVR6W+gS8lUrRYmNZGLejMOVpUMqdtVxfX13t/b/fds6tTITNZhk/07AFbicsmHTn0N8KdY kwNZrOjf3xGSSVkREdQFd3KT2r7LLKEpRwiDxDTbt3P9NiRmbJctcNZ/WNh0j83fCLxcWgWHkuBDt /6qbGcW8NZchqKpvzVU5KNYQLNCONhBgKNbQHld3fwfKy1NQJREy3V5eliRbvbJAF6b7XQ9nqES1W V6Pu9iy99rC2qJ3KSczw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qH00F-00FdHA-0Z; Wed, 05 Jul 2023 10:44:55 +0000 Received: from mail-vi1eur04on0605.outbound.protection.outlook.com ([2a01:111:f400:fe0e::605] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qH00A-00FdCU-1Z for linux-arm-kernel@lists.infradead.org; Wed, 05 Jul 2023 10:44:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ihBrbcLau54/MsycMfq2E8ViEntfLieP2U2yG6nSXv6pv61Xzz9cvZs909PIFeVBUY4VXCRasZNbkVS93ochR+KCINksqBsYkdCFvhQIg13uVhVQEPCJ/M/nlQIEitFN5tqmbkICxfXZy4nfWwBv6sNLPoGsag5GlHoAmswgJTL2Ho3Jq2Tn/UTv7g9SNW2HAM+1S8wZzma9wkD5wLdSLpRqjpru1zVZbixFyCH4o4QygbShisZixXCB8Tj0pOEH9xOj8A0WxDW/qE2PWRmia4ow272rtQazuTIuQErbmgEuGpYv1vg0465QECO2ChpQVFBS0PhZjiD8uJe2pUbDCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5Rp02+YlCb/o/exrldBQKo3DcVwa6k6iwh5PrIZg+mo=; b=XdZZ4J6Lbhzvvx8CIG1JVSRbZc4Rst2uwaygN2mhEt7aL0k48HLrRk/juHgB7tFR90k1rDrXpnw3iKsla10EViQaaL6RqBJ/ag8QSSrDAjB4AAGwDo/EXcrWrFkSlYiCYgQW6qGUciiRZj5l8hBknX2cfXP0jD8C4Puu36XPxJi3gZEvAeXN1Mrk/06YzRzXWNHchwIP0KBdV5FbgTopkgO7WuUFcDqUhIXVe30O8Xhj3xI3QnJH1cUeE3Ug0tjTBOv7YrJOGAsQy04RGXtakvrHavLLzV3dg7yqQyDY+kT9I2d52Edzk5mJdXMxlplwcwMSLN4FjsA0jSpH9xa1Vw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5Rp02+YlCb/o/exrldBQKo3DcVwa6k6iwh5PrIZg+mo=; b=nB5coiBeV2w9JSHnXsGKXUSH6FlzBOkFDRB86ELaYYWhzg/AOiq1I1tVQKrryMl+xZKHV+/MIewfU4VKwno9A8LUHI2OgLEk6BuBiXF897bgBV6KVPO5Cq5d57GhPvoApAyyh0ehRrNBslEGexpSdmo8lSy4O+Gzk4z88DNfEEA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB7PR04MB4505.eurprd04.prod.outlook.com (2603:10a6:5:39::26) by AM9PR04MB8698.eurprd04.prod.outlook.com (2603:10a6:20b:43d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.17; Wed, 5 Jul 2023 10:44:43 +0000 Received: from DB7PR04MB4505.eurprd04.prod.outlook.com ([fe80::f9b0:8c34:e57:92a4]) by DB7PR04MB4505.eurprd04.prod.outlook.com ([fe80::f9b0:8c34:e57:92a4%7]) with mapi id 15.20.6544.024; Wed, 5 Jul 2023 10:44:43 +0000 From: Xu Yang To: Frank.li@nxp.com Cc: will@kernel.org, mark.rutland@arm.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org, xu.yang_2@nxp.com Subject: [PATCH 3/3] perf/imx_ddr: don't enable counter0 if none of 4 counters are used Date: Wed, 5 Jul 2023 18:48:15 +0800 Message-Id: <20230705104815.511400-3-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230705104815.511400-1-xu.yang_2@nxp.com> References: <20230705104815.511400-1-xu.yang_2@nxp.com> X-ClientProxiedBy: SG3P274CA0004.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:be::16) To DB7PR04MB4505.eurprd04.prod.outlook.com (2603:10a6:5:39::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB7PR04MB4505:EE_|AM9PR04MB8698:EE_ X-MS-Office365-Filtering-Correlation-Id: dd4e6359-cbd2-4bc2-abc2-08db7d44d779 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HaQlLv8UvicwkEArpehpX8F2+hd/tcywGDOfAhyORJWg8bMkxFsOtezsv7VLPEVWyPXRBgnFoicqMb9Cyi4d5oGKblPCa5FHMnByARFVTR42yFBdd93bSu/3EAJpcPygpdFTkz0ZJY2myxRxGj94tViWNHjGWPaGop4Bgc9C6mO1EMrFBkjy5T2Egq96RKHhJCweaDvg5xpsZw4ey+29g6yLBSCaFrhu2IWOhGV/AtL6sE6CMh1Xl9w0OktLm5qqPqz01m5j2zzj0MzH9WruhOYVhguyBuGzOw3mVCZHLAqRKbMx2cJKdN2BDA6m4Hd9ZSHMiRe5qq9q0JyByeKhqOGmVawW4cIx+TDH2P3sgONhjHSl6Bdqkq9uGNyaBy7LNG2kffDoLWfdVW7DTwfOBmNtxRus9xLni/YHOwUWFuJnNMqeb3jBatcQnJJyUgnEjGOC0TRjazqvMJrpjjfm87BLI0OCCCZ/v8A/0oGUp6WnjgfT0zz9TATAiATSDr6GlbJcR0CcDgqb6ykXilen+1mC9K/Eb8CLbctM4DOnrlXNAVjQ0AVQzdozbUVSCXNxFZj7SWQ3sK4Jpt5cipg1zYEv/yVVsS1GPvllngQ9YBnBJW1eyKn2Hsro75+sXMAA X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR04MB4505.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(376002)(366004)(346002)(136003)(451199021)(38100700002)(38350700002)(66476007)(66556008)(4326008)(6636002)(66946007)(2616005)(186003)(86362001)(6486002)(52116002)(6666004)(36756003)(6512007)(26005)(6506007)(478600001)(37006003)(1076003)(34206002)(8936002)(8676002)(5660300002)(316002)(2906002)(41300700001)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: K6RFWzhlXe+tLw+vwwHxNmSQRZURIxLnOOdfek0AwPoMG1ONSQ0JefTkgUS7QCDKQsnUnDYlxVfcBkVSFm9QxKjpQIHVIECQHPa207qnDOg8BZ/H5nyYjFAuD8/huTmfftAFATaKlU2cJQZuyLQ4hMQUEdgHGeOlPvxKtlQz0FyHxKJ71CBHttBUThnOjMreF8kKFJyIgUktbtEeUDG382z1+p+LvI2wKz+qaeQ8LYT0Cb2P2ATPcyhwCvgxzgdadOmEYxaecmQNhLv4A7POIlL4/7tozvMBpdb9vWYYhJYjqtbGh7SZls4ebIWHMOIJ6sl6EvrfahemOC5+egq2O/KWdJA0nG3ERNfTf1ZSLPk13IYvsHBMRiOUSShVh+MbaQ6FD7L2YL4sfe+JqVYZy9fHx69f6b0MmxDOxgrovHf27Pynz7EkdlH5uPAnudShGULhZMwz86N8g5JKqS8Ma3N4mAxAjqGSEXsSVS1qknr4GBfXW0Eq99rlxpUIZw8cqotsJydOeAt7SzQI39VpCG7QyVutgiyZeZN0WSwb7bMInGl7xtEtQ5C+TSVZ6UwFhCLPtePdi8MSvZ0qK3UQCAKJuBJInt9lPdcwquCPhtcEe6EgEsvbs/GLi4Sg0OfpkbKrNj4kMIZTtpK+DEjzySrAhjFWjASHJ0xom1iOjnyc7udFV78TsaumrdV2bLWP917CHbHSdbeR7tPf/4Glxiu1U96gu9WcgooQ1b1gXITp5NZ91LpiKHNXk4ow4bb3hGSFmQd+GSqrZu3JEgYgdnQwX8UZPGi8tCbUc1odrJmm/93wKr2cgCTfmmhuXGyhLFxgT/rzjd88zct8dHn5rBrUmJ1rHBO/Z5AMrvsa5IG4Ys8JFX19KIj8jA2vbQW/mnEMW/iZ2Kp76ZApDEoXwy621WdK6KANJqpnJzDMBSCSv+dm1kwcl/mSYNiAMDNL/SCB5xxrP05z2CbRr8k6WH15yvq3BrdzQ5o5cZEtJQJozEXIH8hj1PeMSX0PyakAP9uyH7tyVwUMmzJUV/wQrruiSCRGKqbthyHlLDgwdbnapSOYZJ2AJZ0XVxW31Rt4uGhuc7tTQDUMpZgUtcbsYuvseootsplyyATaErDWjKsZNsRXwI4TNkxbAchD48ALF+COx0LgXrIOx4+oPN9kGxSn6zRYgzy6gNoJix5fs3MIImHKpMQvj72Zb4KfbfeWE3D65c2VRiyVagdEfq2MCVQt4Pp4Zkf/inn3B80xOyAp84CdOQBe/GBDvwIujhuHxmBH5pjLJPnjCVNNrjbs8jhzsYEH61Zygr1pgBgtHBRp4ATfaiqVrk5eelES6EoGOgoId9dIbAW/D8U/PSEvg7DvNbtrGajkp4j67it1w5iqltPFiJaLtfivcwyo6ozJcb0lsZkyByVK90460Cnm/O7+5gSeH3bvTFaz2G1C/zWC4PeAdlNM2CFd3Ds/yrHm2tPt1fluIQv4RpZftMDAT+fGYfG+pjOiU8V9MD+zzMFvrURQ0fOm4w+GDPDTIR2P6fRzLtC65Jd0V95zMhbOZDWBzNamKi32cp9MNCNUfKTRIs0KydBjVqGFwglulUu/ X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: dd4e6359-cbd2-4bc2-abc2-08db7d44d779 X-MS-Exchange-CrossTenant-AuthSource: DB7PR04MB4505.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2023 10:44:43.2078 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: w9IDEuNs/vPjGcpZ/W0LnrMh8d3Jtl7RdUbuudz2AodSnCTt3T3QkgfbtotjtGOslG+/4Wi0HsNp8MYN/Syjmw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8698 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230705_034450_527568_37C552EC X-CRM114-Status: GOOD ( 13.06 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In current driver, counter0 will be enabled after ddr_perf_pmu_enable() is called even though none of the 4 counters are used. This will cause counter0 continue to count until ddr_perf_pmu_disabled() is called. If pmu is not disabled all the time, the pmu interrupt will be asserted from time to time due to counter0 will overflow and irq handler will clear it. It's not an expected behavior. This patch will not enable counter0 if none of 4 counters are used. Fixes: 9a66d36cc7ac ("drivers/perf: imx_ddr: Add DDR performance counter support to perf") Signed-off-by: Xu Yang --- drivers/perf/fsl_imx8_ddr_perf.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/perf/fsl_imx8_ddr_perf.c b/drivers/perf/fsl_imx8_ddr_perf.c index 4e6cbfc48429..f7c832611713 100644 --- a/drivers/perf/fsl_imx8_ddr_perf.c +++ b/drivers/perf/fsl_imx8_ddr_perf.c @@ -591,7 +591,9 @@ static void ddr_perf_pmu_enable(struct pmu *pmu) struct ddr_pmu *ddr_pmu = to_ddr_pmu(pmu); /* enable cycle counter if cycle is not active event list */ - if (ddr_pmu->events[EVENT_CYCLES_COUNTER] == NULL) + if (ddr_pmu->events[EVENT_CYCLES_COUNTER] == NULL && + (ddr_pmu->events[0] || ddr_pmu->events[1] || + ddr_pmu->events[2] || ddr_pmu->events[3])) ddr_perf_counter_enable(ddr_pmu, EVENT_CYCLES_ID, EVENT_CYCLES_COUNTER, @@ -602,7 +604,9 @@ static void ddr_perf_pmu_disable(struct pmu *pmu) { struct ddr_pmu *ddr_pmu = to_ddr_pmu(pmu); - if (ddr_pmu->events[EVENT_CYCLES_COUNTER] == NULL) + if (ddr_pmu->events[EVENT_CYCLES_COUNTER] == NULL && + (ddr_pmu->events[0] || ddr_pmu->events[1] || + ddr_pmu->events[2] || ddr_pmu->events[3])) ddr_perf_counter_enable(ddr_pmu, EVENT_CYCLES_ID, EVENT_CYCLES_COUNTER,