From patchwork Thu Jul 13 10:37:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 13311781 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 402A8C001DC for ; Thu, 13 Jul 2023 10:35:11 +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=KtRUofrVb2pwrM7KipU7p85ki+oTZJxK9Im5tw3LYHo=; b=0M/wv/0UL0JRzn XQYc472hHVS0APRgV9C7Cdo436tcHX9lS4yCVNV2GSkGpNice07BfZbPmHsMKiCl1DTPhdWZPvgz1 RhSd8GZeSauMP7mOe8ztOWTIloRqrlFA5XELT51SPHVLPJI83rPWPgM71k680qbzarwy3/B1jW+fS p4H93wUmvPp7Mwyt6c0Qib06iwaua+IkKySanMc0pzqggMN2tEHRU+NhQlPXTuxsDwrVgC6XRPmj9 0+esEnYWnHEto6oZQ4aSvfEv8Z3YOaD0X/U7/6HUR/qe0g7UeEWO1K1/o12zTsIL4xvzdxRJ/4fS1 XJhhUi1mptUD3eadkmkg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qJtec-002s2p-1w; Thu, 13 Jul 2023 10:34:34 +0000 Received: from mail-db3eur04on0612.outbound.protection.outlook.com ([2a01:111:f400:fe0c::612] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qJteW-002rvb-3A for linux-arm-kernel@lists.infradead.org; Thu, 13 Jul 2023 10:34:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VL8/Lv3xi9UpBxZuym0474RMZ2RHxsXi0haJf+J7+Oc3U2vHYVMG02BLKJSq6fpBwa12Js5Bc047dZ2jj0nYkn7XWfJHVW0enWszz0O1dPt0oUQ8P7lQtMjm3ZRvg/vEwGKVKDUo1dN7Z3jCT+5NJoscRacimqJWLH2sinVW94aCumAfT4QpexkDTttfpdUQKWB2pOEQfw3TG7fEBoNhFgul9Nn+DNvDyQAQbCrMnoqffYR5fBBycCG7mYqhx4IFbglCQ5ycB/DOpT42cEdUjdIaTJMTl4+/70dmCeeD+X5KQdFRCwvD/zVowNNGwZele/FCdCS6wCZCKGQlNDaxfg== 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=wHsFY6w9asKt3CyY9wYxL1KFv9ZonF0gt1dASt+Bqic=; b=HshMndk4+zsXnDCnwird6sWIAt8uE/Fmc+zGV/J72VwhPXuuHniwrLFnZr0DL/ExCjJ1ObAKA7BOTu/BdTG+9M9yrcmUAO3geredul9gyQTa8VqyUOfk/f0fhSIPTAi/AVEsuBC8AdEyVj2FBIxUJdbO+qLcKjeMiCtwSSnO9/dkojtyiEzZqq3M7wEKLYnSDXSE7BXBmG3vjrj6B1CysN5e3zDJSTXhRY3c+nQGBbJRvPOuBSjjDD4mYB3CLS9tm4jUeQZXxLJ4yzV6/LsIfBLnQS5dwj/cmiSlboqiN17SFWNOcUO15CUvmhMUy5KU94r30cCUCK7vNkqaJIaFkA== 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=wHsFY6w9asKt3CyY9wYxL1KFv9ZonF0gt1dASt+Bqic=; b=lI6xxOAbvrBwTD42TFOCm8vAcH7YOeuCddOjcPGda4xQlIHRSlaF+aQj193CeQ93SZHielnpKrWedGYTN6+KR/IgPMUPzbFH8cTYV8ViIS5Z7pspAcAtdSouViVKJt0X5/54YA27BaNjE+wg2fLXjbph7iOW13dTOxmowqF5mXk= 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 PA4PR04MB7968.eurprd04.prod.outlook.com (2603:10a6:102:c0::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.22; Thu, 13 Jul 2023 10:34:22 +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.6588.017; Thu, 13 Jul 2023 10:34:22 +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 Subject: [PATCH v2 2/3] perf/imx_ddr: adjust counter result after read cycle counter Date: Thu, 13 Jul 2023 18:37:57 +0800 Message-Id: <20230713103758.2627269-2-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230713103758.2627269-1-xu.yang_2@nxp.com> References: <20230713103758.2627269-1-xu.yang_2@nxp.com> X-ClientProxiedBy: SI2PR02CA0015.apcprd02.prod.outlook.com (2603:1096:4:194::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_|PA4PR04MB7968:EE_ X-MS-Office365-Filtering-Correlation-Id: 03aea57b-3c1a-4eb7-9d23-08db838cb8d0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JMy6soijdd9pvQL+QOy1piuS9syEFsuSjjDMr9MVA7x3DfAkh1YuVq0hgaOhST1PNND/zVXk0UnKblU/z4RfFQgeZ+EmQYk1JdfYHegEhijJGLeUU8Lc6decwyvoNkXRrzjGNGZIUHnkKMrAcHTnDphqHGd/6OpcqRk2se7jrQHTZPqafy0D/JAtkKIlIdsRUFnDHtiN+AfOUunmComXJp/xrVG40de2Gp3alDojRE4mA7Ovl8oKPJZtkrJF69ATeBgnA7tlb6dFktAVaUdFtbc2FnhBk3FWQ0lC3Uapr5pJ/1rnG04DoAqaLNnRkfujQG7aHnAWRrUcg9w7gCizuPlmMEH/STm1rUBHS3mpVMKRWlfzwVy2bNZI6MvPHXX3qBB4JVXWvJvaAPXJLMTvCGdt9ACMvfVqFZz4JdpLop+io+95W2i6pDwjLIfXnlUGile4dubpeziQd0PX/ymXQsiOeqX3az8On23NUUR8nm1L1VKlmyWZMLOBQrJ569y1/ik+s9Fvj3QyDZvBswWVKJ0guIKetTLNCXB9Kcc8RyH2IpAhig3gGSeiWCnNBm6TrULT6ttskD4ujQ1cPsmBx+1MiWcbJPCwTJfd192lrkRgcBO5iXmydnxi8ey5Tn0J 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)(366004)(346002)(136003)(39860400002)(376002)(451199021)(6512007)(4326008)(1076003)(26005)(6506007)(36756003)(37006003)(38350700002)(38100700002)(8676002)(5660300002)(8936002)(86362001)(4744005)(41300700001)(316002)(66476007)(2906002)(34206002)(66556008)(6636002)(66946007)(6486002)(52116002)(6666004)(478600001)(83380400001)(2616005)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AFTNEIemPCBAytBrahTbjcq/UQ38Y9ZETozYCtNPXtUgc6fD7eiyCaDSBhQqkIhIH+9uVYGJFha12nwc3tf+ieB/RrfQaqubSmZF8KTRF4nDFpiAgbj7Asy3RRqs078xik3YPZ0yd31DbrAtRSeAQMy4JDlQlG8BZYO+aKUZBe9CLtZPam8Mvx4BzLKLnfWMLgKRf4507N+EBCIcXi6jJwiyIWYnaer7yrvBRShmgNuwnLtCC5PYBUxtd/08c3zsTh2wGqaE6ozl0f+E3osHsOBcEJ/Jc/qGKPk/r+anP6j17YjQpjiAw616XvzYySVf5kXn/sXUtPULeFNk1WLj/Vr8+r5m3J8bZU/h9m5Di7ccrOzZ1CA3in4jTp7UjSLOUf6spzSbbEZZfpy++eaIO1+A/Ul9c2205BW+aOxBZ9RWTcQsIIqi21hM9eQn3zDFAqD9k+D/Jsex7UsUlIYmyQDXXPfDt4ox+J5UeOVDaz769HVf3/QsBaxW7CyfW8Vy0frdk3niH2q3rc7VnpRQpAZxl28+iff37EtxgkTyB0Ut6nT38DQYcFTwHc0cWtS2+5B+E6fqKL1uglUIjcXCUt3eZfalxmGw89Tf340CdOEjCiaIDP3ZJjUZGdMWq0e9iy+OtZuZxtZKxpsSzHWbFjIgUEaSem/JTc4C+66/asfGQiH+2BTnmggeise6OedNU+DLhni9AcM/kfidClb7Qd/khap5qxiLSEtbRaYhvlP+damUfvVKtliC6PHFDDgFtEW0ZkwG0ulrQkH98yR3LkURV5DkWh8SRYK1kqK/9N6Q+Tku8SNosdZCzLggMpJOjul3jV/Tb9MrlM/pLKQ4YcDFeWYViXDHhkhbN34Z8k25jJu5st90BeFaaIr1yPHcICcd8rm7wIRnmi1Ayw0gkBo5GhXUxgmZXFVhafMp4oqMyD3t18EDCKj6WjPfrCcM+CkEO2jSdBVreJW9OV+vMvSTLqXgG4I7FGQ/E/hR80n2WoDJ2cEwbEe5w+7Mc5MT/4ryxnbAF+e85j1ge0Zr3cQL9lvGf1m1fQebwwepDgb4jtnLlFtZhPU9zeKGbxlAnm6lO2iuPK0utwQZaSMO+kL92spDtY0QmYsjnYtevU1pEU57lRY/FqZKBlofi6mamduLMhCDd4VhDKYlLeWQzs+AkgWiHN/x+sX4J1bzji9FK1kFGdgTTLLL3VuxDjCX58ERO6HjaHBeiUaOLNUUqgCWI1yCxa4XhxTvDnqeG9N7pqyNo6b5zokqT6hnNbHk010gu/qrKOwGOQvTS/0Na3M7t7hFAsOQCOx9kvMZzM4GX8AnE37f4GRzGUZ/d7cwXyG9JEe/ctPWJTi/RE31OGog3oJWfP+iN9LqnNrWZsgzoLmnwI3QIZ5I+gWXkiEijNu8bOjkgRYcGgiQInF9L015eK1zP5lGFWSn9Csk0hlaS4XkmvuLPrTeqeRibPIEmv6tGsOBo6+nHbWAGY8ncUWKYwFo6bNZCvL9d5mFtLS6O8JMaWlU47ZiGtTRy7PmmU5Z1QNkrug2P2LjuPF7d9yYJnQomKr9nrYQRsaciKN19KRli8GXgZjYh3oRNRdK X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 03aea57b-3c1a-4eb7-9d23-08db838cb8d0 X-MS-Exchange-CrossTenant-AuthSource: DB7PR04MB4505.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2023 10:34:22.5794 (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: Fo1VCSi5PfGHWjZZnJP5FrOXpC1Wwg/wD/gQhbUowfjfzPUuQJC20SIyds3P3WApeMublRpgV9t0KeedhzKODA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7968 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230713_033429_021574_D9358210 X-CRM114-Status: GOOD ( 10.83 ) 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 Because we initialize CP filed to shorten counter0 overflow time, the cycle counter will start couting from a fixed/base value each time. We need to remove the base from the result too. Therefore, we could get precise result from cycle counter. Signed-off-by: Xu Yang --- Changes in v2: - improve if condition --- drivers/perf/fsl_imx8_ddr_perf.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/perf/fsl_imx8_ddr_perf.c b/drivers/perf/fsl_imx8_ddr_perf.c index 039069756bbc..d65200d4e96e 100644 --- a/drivers/perf/fsl_imx8_ddr_perf.c +++ b/drivers/perf/fsl_imx8_ddr_perf.c @@ -481,6 +481,12 @@ static void ddr_perf_event_update(struct perf_event *event) int ret; new_raw_count = ddr_perf_read_counter(pmu, counter); + /* Workaround for i.MX8MP */ + if (pmu->devtype_data->quirks & DDR_CAP_AXI_ID_FILTER_ENHANCED) { + if (counter == EVENT_CYCLES_COUNTER) + new_raw_count -= 0xF0000000; + } + local64_add(new_raw_count, &event->count); /*