From patchwork Thu Feb 29 07:27:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ji Sheng Teoh X-Patchwork-Id: 13576783 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 A1BD7C48BF6 for ; Thu, 29 Feb 2024 07:30:50 +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: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:In-Reply-To:References: List-Owner; bh=lZEBqh0MPmHRAsOVd/QXY+97ZKKAsu9D//iaTy8qX3Q=; b=gQXM6k7fUEAQYO HILlsMvfKNcPdKcLFpMl+dG6J2msPqzvQojHYxlZRMm7Snp1eoE9aOS35MEuaVUWCPf/aF/2QKogR beYwi9m8zz3fjITHoN50Xz2rGT7R6nmSk2FslTwmJosIvoX/afEonhVmLA1VmG5TPuWi8I3s/Z0uJ ZgpSfw2gjp9cyEFmch87QDBbT6O0ZXMCcomywOC+KPkM5ggt+JyTfWbaNiUmOeSXrRRYFdzfeVmaQ X7HatZJ1U2Q1f0UcUgoFi8ikTvajw+iU2uC94m6fjrV1Unc/S1a3WgCh47UR+gL5zwIpPlR1t9Ejj wRd2bVB+SAEqxUAXXs+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfasD-0000000CUtw-2aKi; Thu, 29 Feb 2024 07:30:33 +0000 Received: from mail-sh0chn02on20719.outbound.protection.partner.outlook.cn ([2406:e500:4420:2::719] helo=CHN02-SH0-obe.outbound.protection.partner.outlook.cn) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfas7-0000000CUpw-2Vd9 for linux-arm-kernel@lists.infradead.org; Thu, 29 Feb 2024 07:30:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KRzEB5XoTWNAnzbe5VpmfjuWdP+iqFwAwZCbDIqT1y4Wm1tWcC33XTBPdOQWC1pFeXobG9nxJx07F7AfO2e0VwwS4fF997xehW6NIeNbHBwut6Ti4fpAl04Sk+GTbuT3QnWXFXa93GPZmnh8CqCcKaOKYOzU8+73lJOyWY3GeVddwBMd6EBYOka7Eevi5G12RzaG4ZOt4dezox1n+lvaI7LUAagcjJ/fcy4UY9/fxEShrMfiZlq9z1/JDAAWodVZP87sfJp+ALB7XUwwGJ8Gv2wVgeu1RdZvVM+GxxUBPICrFoEGRSxwjz259Ig2IMRk5RiAfHGkshW9SfWmKTkdbA== 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=zp8FbaXxs9K4B9KJkviYLlBYUubtPkGmpyn2WDeAIzc=; b=FNq3pbD+YF/eiZLk5k3HYR72pyQimOpGYCMLrK+a4yHGLZCV2qNrts4oMqI+BVJuoCesnDtViL9xG5Fw0REGZVlS/bnRJNI8BQPCp6IDN4UwJN9mZLSehMmZEas/V2UUfmxxTKh5DYSVubpp1beqwvl2q5PZmagMc7ALieFJmQheYssgdCFZqq4KZhmmEZ9mdM/faSqjGwJRpkgEDMwvRto8PYkReBXUPFUYK9M5VNOJi44MewJx4QXtwVnWaGLiJnbyjSmdFucI5RivnOhXnoNxf0oFGuWBSXKD9v047PtNgnP8XJceY2dDZHTVNHRkEPTxqTqRqefv1SfxYTe+5w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from ZQ0PR01MB1160.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:19::6) by ZQ0PR01MB1013.CHNPR01.prod.partner.outlook.cn (2406:e500:c550::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.47; Thu, 29 Feb 2024 07:30:09 +0000 Received: from ZQ0PR01MB1160.CHNPR01.prod.partner.outlook.cn ([fe80::2f41:68f:6f07:6c8b]) by ZQ0PR01MB1160.CHNPR01.prod.partner.outlook.cn ([fe80::2f41:68f:6f07:6c8b%4]) with mapi id 15.20.7316.039; Thu, 29 Feb 2024 07:30:09 +0000 From: Ji Sheng Teoh To: Jonathan Corbet , Will Deacon , Mark Rutland , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Dan Williams , Ilkka Koskinen , Jonathan Cameron , Dave Jiang , Kan Liang Cc: Ji Sheng Teoh , Ley Foon Tan , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org Subject: [PATCH v7 0/4] StarFive's StarLink PMU Support Date: Thu, 29 Feb 2024 15:27:16 +0800 Message-ID: <20240229072720.3987876-1-jisheng.teoh@starfivetech.com> X-Mailer: git-send-email 2.43.0 X-ClientProxiedBy: NT0PR01CA0026.CHNPR01.prod.partner.outlook.cn (2406:e500:c510:c::21) To ZQ0PR01MB1160.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:19::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: ZQ0PR01MB1160:EE_|ZQ0PR01MB1013:EE_ X-MS-Office365-Filtering-Correlation-Id: 2d73a6fa-d306-4377-7210-08dc38f84248 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nvvQOvsLVjYycXbwWDcCLx4NUzespTKXZ6sxUly4GPEmtLpONMFowyuCRmzLjzoZeSeZmWaxXfgCxR8VB+6Lx+lBx9rsSojK2bCqv9UYkJYst4Pu+Qefj90yYYD4+g46gnsbH2U2ASg2zmxyDXFUZpTu+xllOcRxFonm2hW3o6JJqPvrDTBpAzlxuA3QaChxOEalF4UYuFroKtzuiiL0jg+fNRjcCKRUyEaHriJiGw/3RFOQVWzite9Uc3ghCl+wlli5HXIeo1kQ8GA7Uy8yaovbF+NkdJtukMse/L8oy8VOElHa0UNBPlpxEfiGGr1UmJ2JH8DdeZ8BHwgriiLE3l1MIDG/D7hndrdaHghAsJA2DBixo7MFR230EAODgOaFU74JVwx90KOPAa2d9T8GIFgPCpXalOpE//x6pECV+XHTCvN+B4VqNVGN9ZDIo4TrqGHRIdXwADqQ9MY6KvqHSfoTAD8VKefVRA9WG/H6g9MUGfxVCcCWfu+FKWOegPr57Yl01ZBthN+oFUGZovDeF0qJNNcEwOCyTjFPzP9RiujHtJO8DxL7PUBTfIKD+UG0QJxndw0BvoQsUVG6COZDwhwxVSBF9SbFXmjEu0a8DG7aDp3ydkCIp4byGGSLwM/NmW6FY5G2V146HE0isrK23g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:ZQ0PR01MB1160.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(921011)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: noRj8JAsqdi8Og9m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os7LPKrnVj871lRd0H/M4Er++flirbKTFAXKWrQSfgRR2jyv73C2fmsHrcjF5hGyhOkqH6l1V8OpX823B19W8hyHkebHs7gkhhIPCMn257WDBFv9w952Yf9JB53QhvoGN4wSRN+dD5DIQi0hmcmAtztjEHbma0+s3jzwLbv70nXbOrcE9Zp7oErmxrLNLdwSzrqG0rT4HlA4MwCl5jN34lFoxNqvvZQ6Jezbygqwa7hcw98A71OrlsohsT/m6btbEqloo+sp4Y9eqVunLUm5ci2rlNP4LoKWDTHtSSQy9qfh99kYRLZ+EJ8cpVi9fnRd4yqGBpvAGp/p1FA8B440UQcKOUEeCZIJX1QceqY5B8oUVpYHbcdtfVIaiJBiy2xAaWB/RkD6q5jxsqimao+M0JrsnW1+Vf9nrv6k9Fd4L1qKDriJb0GXhRQox1eTZAXJySoW3NDHp6bhsinS8J4MfwLv9nP+fFd2jTcDM4/idDMiwDP8c+9dqgFDPJCJV1Ij9C3K89p3Wkw== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2d73a6fa-d306-4377-7210-08dc38f84248 X-MS-Exchange-CrossTenant-AuthSource: ZQ0PR01MB1160.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Feb 2024 07:30:09.6949 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UFZDv/ugyGVPo9+6YRZ0Ca3pV7GEToAhUYOU6f46FpLaOXZGq9NeJbINOfCKeHGJOOksQ5Yynoeg87V7JqHe+V//vOqM68a+idY5pYOmrrY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZQ0PR01MB1013 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240228_233027_764823_8B207151 X-CRM114-Status: GOOD ( 14.73 ) 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 Changes since v6: - Address comments from Will - Add "COMPILE_TEST" to STARFIVE_STARLINK_PMU Kconfig dependency. - Fix incorrect bitmask with BIT_ULL(). - Drop kfree() which is not needed in devm_kzalloc() allocation. Changes since v5: - Add entry to MAINTAINERS and mark the driver as "Maintained". Changes since v4: - Add Reviewed-by tag from Conor to dt-bindings. - Add Documentation/admin-guide/perf/starfive_starlink_pmu.rst. - Rework starfive_starlink_pmu.c based on Jonathan's comment. - Use in place of . - Prefix CYCLES to STARLINK_CYCLES. - Fixup error handling, remove unnecessary comma after NULL and comments. Changes since v3: - Change dt-bindings filename along with the compatible field to "starfive,jh8100-starlink-pmu" with SOC specific naming convention. - Drop unused label defined in examples section in dt-bindings. - Update compatible field in starfive_starlink_pmu.c to the aforementioned. Changes since v2: - Change compatible field from generic "starfive,starlink-pmu" to "starfive,starlink-500-pmu" with specific IP versioning in bindings and driver. - Fix warning '-Wmissing-prototypes' reported by kernel test robot, by appending static to starlink_pmu_set_event_period() in starfive_starlink_pmu.c. Changes since v1: - Change 'depends on SOC_STARFIVE' to 'depends on ARCH_STARFIVE' in Kconfig ---- This patch series adds support for StarFive's StarLink Performance Monitor Unit(PMU). StarFive's StarLink PMU integrates one or more CPU cores with a shared L3 memory system. The PMU supports overflow interrupt, up to 16 programmable 64bit event counters, and an independent 64bit cycle counter. StarLink PMU is accessed via MMIO. Example Perf stat output: [root@user]# perf stat -a -e /starfive_starlink_pmu/cycles/ \ -e /starfive_starlink_pmu/read_miss/ \ -e /starfive_starlink_pmu/read_hit/ \ -e /starfive_starlink_pmu/release_request/ \ -e /starfive_starlink_pmu/write_hit/ \ -e /starfive_starlink_pmu/write_miss/ \ -e /starfive_starlink_pmu/write_request/ \ -e /starfive_starlink_pmu/writeback/ \ -e /starfive_starlink_pmu/read_request/ \ -- openssl speed rsa2048 Doing 2048 bits private rsa's for 10s: 5 2048 bits private RSA's in 2.84s Doing 2048 bits public rsa's for 10s: 169 2048 bits public RSA's in 2.42s version: 3.0.11 built on: Tue Sep 19 13:02:31 2023 UTC options: bn(64,64) CPUINFO: N/A sign verify sign/s verify/s rsa 2048 bits 0.568000s 0.014320s 1.8 69.8 ///////// Performance counter stats for 'system wide': 649991998 starfive_starlink_pmu/cycles/ 1009690 starfive_starlink_pmu/read_miss/ 1079750 starfive_starlink_pmu/read_hit/ 2089405 starfive_starlink_pmu/release_request/ 129 starfive_starlink_pmu/write_hit/ 70 starfive_starlink_pmu/write_miss/ 194 starfive_starlink_pmu/write_request/ 150080 starfive_starlink_pmu/writeback/ 2089423 starfive_starlink_pmu/read_request/ 27.062755678 seconds time elapsed Ji Sheng Teoh (4): perf: starfive: Add StarLink PMU support dt-bindings: perf: starfive: Add JH8100 StarLink PMU docs: perf: Add description for StarFive's StarLink PMU MAINTAINERS: Add entry for StarFive StarLink PMU Documentation/admin-guide/perf/index.rst | 1 + .../perf/starfive_starlink_pmu.rst | 46 ++ .../perf/starfive,jh8100-starlink-pmu.yaml | 46 ++ MAINTAINERS | 7 + drivers/perf/Kconfig | 9 + drivers/perf/Makefile | 1 + drivers/perf/starfive_starlink_pmu.c | 642 ++++++++++++++++++ 7 files changed, 752 insertions(+) create mode 100644 Documentation/admin-guide/perf/starfive_starlink_pmu.rst create mode 100644 Documentation/devicetree/bindings/perf/starfive,jh8100-starlink-pmu.yaml create mode 100644 drivers/perf/starfive_starlink_pmu.c