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 D42D6C4167D for ; Wed, 13 Dec 2023 00:33:54 +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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:Message-ID:In-Reply-To: Subject:cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6mRysWVnpH2Rs6ThaRq93cFrbPAp7Er/WIIs9mUdVF4=; b=N2H2Ow7ipc8NwLD72XsSKeDiQJ bVf8li5qH/l8W017Pge9m4Ab7BerfkhFMWCSOmm2SJTowT21Th1rHTUY15Jn0lWp+T13/6+xcF1Xk h65YKgibuyBalXtpK7+lm+lFdVLotKXVPZ6Hox2jMFo00F0cw5F6pHSY+rrTNvnRzKOVJkJciEByo aqZypLGQIjgliwo4z16xI5O9krn70FHHBpfWt4tyBhDr9SoS2RvP8FvNEHeLtrbUzCEbyVY2M13qF dEnlh6/NxbVpyAoUrc0XF+jxoyoWu7AK9hdydTtOnYvVjvWn/aRh7KyHgDIF11AM34QU6A4HTzLkn BSVlq3Og==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDDBm-00DC31-20; Wed, 13 Dec 2023 00:33:26 +0000 Received: from mail-mw2nam12on20703.outbound.protection.outlook.com ([2a01:111:f400:fe5a::703] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDDBi-00DC1A-2S for linux-arm-kernel@lists.infradead.org; Wed, 13 Dec 2023 00:33:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=maS1mDJF5rgFihSk6pFjFRV0x6iqEaWE66KQq7FcCjFsfzCjBzZ71JKY18suKgrXgxJryLOM7jzhs7X88K1CUKj8IMyUSXGDd5uiUa3HGoLfxbTjwsT9dx6j+n56KlPOehzFrztAK3y9ZQLDunLI/WbyH8ITWPaZDB3+IU0zQxJngPHM/xumti3XlzYey0FGh/eeHN9iJZM6tl2mZAovsw/K+rEMIaoCgMrPZnVSk5nzl+yK03Pu6VAWkfcGkH5thGMOTMMq6lx6GccP/dgierILFOv4nEWhEK8e2LQ9meP9cYpzibvgM14o3aWrvv0W+odoWd0DnXImga0DtIDtWA== 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=LdN9LXS/iNHY43+T1i0wM1BCMGidQ+Q1M6HpqQjXJ6U=; b=PkIJ2ar06VeMyQiD/Ix5UA//lGClSJReiKnGZMM1JZ058dFf6AUdfA/dByyEUaICXHWfeLxfLXhrBm2cqrA4GR288KLyr1U64AkeIzB5fAq7CcXl0B/ZnbZ1OjtqCaeRmKpONo19HZ+Pi3LuaNa/biEBeB9vWNTX31zSSAEyKvLNsrZ/nC5sDEa1vSz43uCDfKM7zhpN8Q0sD5qozfGVhfxT0Qv98wsN6nDQhbbsNir3sL4tpxOf2YcjB6R8ZurQDUPtsujcV2edP7SopjRyJ0BuK4cNJSfPFzN7BFXW99BLC2GjNCi1WFnMZLpHQbQ3kWh6H4sIdLyw1xdHldbBcg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LdN9LXS/iNHY43+T1i0wM1BCMGidQ+Q1M6HpqQjXJ6U=; b=aFng+CfZpuJ52xYSlVtzLqZYiwQPq7yIfFfgwKd9NskGyMJ3ZTx1+4bypa6e0/uvjbjp9U08JDT38RyHc2nMYtAqKOn2G7kDUYa3vVcwpTzlnuV/ci+ADl8TSKRShirixN9CNcXFMQ3TsikiKdjidbErn2kUGlAOrCOUa8i2KH4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from DM5PR0102MB3590.prod.exchangelabs.com (2603:10b6:4:a4::25) by SJ0PR01MB7446.prod.exchangelabs.com (2603:10b6:a03:3d8::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.33; Wed, 13 Dec 2023 00:33:12 +0000 Received: from DM5PR0102MB3590.prod.exchangelabs.com ([fe80::49fa:8dc0:6fd1:72e6]) by DM5PR0102MB3590.prod.exchangelabs.com ([fe80::49fa:8dc0:6fd1:72e6%4]) with mapi id 15.20.7068.033; Wed, 13 Dec 2023 00:33:11 +0000 Date: Tue, 12 Dec 2023 16:32:56 -0800 (PST) From: Ilkka Koskinen To: Shuai Xue cc: ilkka@os.amperecomputing.com, kaishen@linux.alibaba.com, helgaas@kernel.org, yangyicong@huawei.com, will@kernel.org, Jonathan.Cameron@huawei.com, baolin.wang@linux.alibaba.com, robin.murphy@arm.com, chengyou@linux.alibaba.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, rdunlap@infradead.org, mark.rutland@arm.com, zhuo.song@linux.alibaba.com, renyu.zj@linux.alibaba.com Subject: Re: [PATCH v12 4/5] drivers/perf: add DesignWare PCIe PMU driver In-Reply-To: <20231208025652.87192-5-xueshuai@linux.alibaba.com> Message-ID: <2bbd5a57-b2ce-6e52-ebf-5935335c148@os.amperecomputing.com> References: <20231208025652.87192-1-xueshuai@linux.alibaba.com> <20231208025652.87192-5-xueshuai@linux.alibaba.com> X-ClientProxiedBy: CH0P221CA0014.NAMP221.PROD.OUTLOOK.COM (2603:10b6:610:11c::12) To DM5PR0102MB3590.prod.exchangelabs.com (2603:10b6:4:a4::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR0102MB3590:EE_|SJ0PR01MB7446:EE_ X-MS-Office365-Filtering-Correlation-Id: 4902cb90-d794-4640-aecd-08dbfb7315b1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 84t8rbqCih4hYMUpJiA6PIiFmv7YEWYtI5yv/s2am6zsgO2Dzc8Hnc9vZMQl4maATv8EEI5wnLfRQ1eSDCtRYb/+fJ87fuamaywBK7VmWMYlQQs/M3Z8U7CSDFZTRyki+mvNmxT3ZY1wo2KESHDPVv2VfBDdWonlYFz+iTFm8g7vcgxNfKcphmFYfb43xk7+RGBHHC3Bt8rcWOsHzQoHoEm1TFm98ftD3AzTwNdpgzcZLVNoAWirokZd3j9rohODCZaOunDBDwX9wyl4NZ0uORGC0k73IHb7iFl4PByg6iVoziKieGunYm0Pmm43c5qPR04nHXVr7QpUk2wOegtxw94r4UY1Zjouw5N3XhcveJD2943L2UwBcup9zL+FH4hEp3aWE2ADVk13FVxzY4DGNT6yY2T349tlK6RPnFJWsrPZF7oP1Qj6DaZA2be05+qgmt7+2uOAywdGHbd6yzSLt6s8RabVZ/qGUAShgssF5PmBOKRci39G9MMqu0rdBROXF5YaM0rOQY+OY5Xx8iDlAeIFkhE5m15wWGdT8ywj8fM6d1T6YUkv6//aMBt9V0nOEzIA2B8+N3OIEU9wt9oK2VokYx8bMg2FWKcy4UeTKkQ= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR0102MB3590.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(136003)(396003)(39850400004)(366004)(346002)(230922051799003)(451199024)(1800799012)(64100799003)(186009)(41300700001)(38100700002)(316002)(8936002)(66556008)(6916009)(66946007)(478600001)(7416002)(66476007)(86362001)(26005)(6486002)(6506007)(5660300002)(8676002)(6512007)(2616005)(52116002)(6666004)(2906002)(83380400001)(4326008)(38350700005)(19627235002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?gUg6JZVXBC+YE2BG+lG9+QTQAoUzB3cfct0G1fsVvCwt1sc0+I+Y1datH/pz?= =?us-ascii?Q?4MQnTib5HpqI8rW7VuH1st5Fq1uyzNOuZj7YGQ1Lna1+PeWDinCRhLEDECIZ?= =?us-ascii?Q?mYtGjXHqWO6LK98V9Zi8cNfvyQ3zBwd3GqvfmS7t/kJ0Y69mBCZ9geCodZfG?= =?us-ascii?Q?qyMp+3jNJddDMeUr/xaaXL6I5xhvlwI+uVMIovl4iKdAAu2pHG4hu1kXSbSW?= =?us-ascii?Q?McL4jbMTfRqnzCgBwm8wThlSehk4b57Zqi7Ao6F2oHv8NR5qV3etmozJBZnZ?= =?us-ascii?Q?GUjcht0J2a1IKqTuAMExdHbKq2GpQEVJjf2nAyChFxKbuHiL5ug5DPKdz3cR?= =?us-ascii?Q?oQJ3QcRkBiUTrxRVIR8P6JsZgkSKxVfcI9lp4IkjxK6gfA0KGr9OMbnGbO+0?= =?us-ascii?Q?VvmoeBrcMmZfVDd+lNMFmL9vHR16xaqQR8tIUk/IChcI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A9WkA6O1vpvRnSV23En66hmyXqWUH7Xp1CQ9h7V+Cf1r?= =?us-ascii?Q?lqN6lCUlZAOENjBtom/D0R08XyoUNg4WYKL/53fQMApkLTNPL2KHbUgvQ88Z?= =?us-ascii?Q?q2P99im3UtHdqNYCH+9zwB7rt9yR4oyjxj8XPT1yoFoe8WDRzCWrNIEqnbBU?= =?us-ascii?Q?5gk8gv6SHfb1QG1fAuGe7rpH6ovZLqHB+1n37Vj8kqkn7Bze1u+m3IGa852a?= =?us-ascii?Q?Lgw6lN5zc36srKlP3tZG5EsWV7QYhbvV5XmlJm+EY4MtTK3eOjyAttC5wR2x?= =?us-ascii?Q?E+JLs3HN2woq/64Caa5avgM=3D?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4902cb90-d794-4640-aecd-08dbfb7315b1 X-MS-Exchange-CrossTenant-AuthSource: DM5PR0102MB3590.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2023 00:33:11.3437 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: G1PQNn5e3BdRCPDp3zmYFc4sR9EuxFtf/DtIHbsWBr5JJvYCCZVLtpIPH8kdD9soifUZZ29elYVLy+emVpXnU814lO67tUs8JhqWDovQBH2RWI8Jpu9hYil6uF/a+KVM X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR01MB7446 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231212_163322_803387_E6FD2C14 X-CRM114-Status: GOOD ( 25.43 ) 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 8 Dec 2023, Shuai Xue wrote: > This commit adds the PCIe Performance Monitoring Unit (PMU) driver support > for T-Head Yitian SoC chip. Yitian is based on the Synopsys PCI Express > Core controller IP which provides statistics feature. The PMU is a PCIe > configuration space register block provided by each PCIe Root Port in a > Vendor-Specific Extended Capability named RAS D.E.S (Debug, Error > injection, and Statistics). > > To facilitate collection of statistics the controller provides the > following two features for each Root Port: > > - one 64-bit counter for Time Based Analysis (RX/TX data throughput and > time spent in each low-power LTSSM state) and > - one 32-bit counter for Event Counting (error and non-error events for > a specified lane) > > Note: There is no interrupt for counter overflow. > > This driver adds PMU devices for each PCIe Root Port. And the PMU device is > named based the BDF of Root Port. For example, > > 30:03.0 PCI bridge: Device 1ded:8000 (rev 01) > > the PMU device name for this Root Port is dwc_rootport_3018. > > Example usage of counting PCIe RX TLP data payload (Units of bytes):: > > $# perf stat -a -e dwc_rootport_3018/Rx_PCIe_TLP_Data_Payload/ > > average RX bandwidth can be calculated like this: > > PCIe TX Bandwidth = Rx_PCIe_TLP_Data_Payload / Measure_Time_Window > > Signed-off-by: Shuai Xue > Reviewed-by: Baolin Wang > Reviewed-by: Jonathan Cameron > Reviewed-by: Yicong Yang > Reviewed-and-tested-by: Ilkka Koskinen > --- > drivers/perf/Kconfig | 7 + > drivers/perf/Makefile | 1 + > drivers/perf/dwc_pcie_pmu.c | 792 ++++++++++++++++++++++++++++++++++++ > 3 files changed, 800 insertions(+) > create mode 100644 drivers/perf/dwc_pcie_pmu.c > > diff --git a/drivers/perf/dwc_pcie_pmu.c b/drivers/perf/dwc_pcie_pmu.c > new file mode 100644 > index 000000000000..6ee66c4b44bf > --- /dev/null > +++ b/drivers/perf/dwc_pcie_pmu.c > @@ -0,0 +1,792 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Synopsys DesignWare PCIe PMU driver > + * > + * Copyright (C) 2021-2023 Alibaba Inc. > + */ > + ... > +static int dwc_pcie_pmu_event_init(struct perf_event *event) > +{ > + struct dwc_pcie_pmu *pcie_pmu = to_dwc_pcie_pmu(event->pmu); > + enum dwc_pcie_event_type type = DWC_PCIE_EVENT_TYPE(event); > + struct perf_event *sibling; > + u32 lane; > + > + if (event->attr.type != event->pmu->type) > + return -ENOENT; > + > + /* We don't support sampling */ > + if (is_sampling_event(event)) > + return -EINVAL; > + > + /* We cannot support task bound events */ > + if (event->cpu < 0 || event->attach_state & PERF_ATTACH_TASK) > + return -EINVAL; > + > + if (event->group_leader != event && > + !is_software_event(event->group_leader)) > + return -EINVAL; > + > + for_each_sibling_event(sibling, event->group_leader) { > + if (sibling->pmu != event->pmu && !is_software_event(sibling)) > + return -EINVAL; > + } > + > + if (type < 0 || type >= DWC_PCIE_EVENT_TYPE_MAX) > + return -EINVAL; > + > + if (type == DWC_PCIE_LANE_EVENT) { > + lane = DWC_PCIE_EVENT_LANE(event); > + if (lane < 0 || lane >= pcie_pmu->nr_lanes) Just a minor thing that doesn't really matter: 'lane' is unsigned and, therefore, cannot be negative. Otherwise, everything looks good and seems to work fine still. Cheers, Ilkka _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel