Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp203546ybk; Tue, 19 May 2020 20:01:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3gr/F3iA1n8+N5NsXg6P8eyUfIfU+LdJaZmZdRBfmwZxIsHRjvPTq3jzN/5HPYfPBaEFB X-Received: by 2002:a50:f610:: with SMTP id c16mr1472850edn.175.1589943703063; Tue, 19 May 2020 20:01:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1589943703; cv=pass; d=google.com; s=arc-20160816; b=CeczugLUtXAfhylPtVcZgN7Lk8PxIzEIIM9DfeX+4Rfukt30ln9++zoofrj/g40L7l vk4rUOCZgqew3K200jZQl6IA3sZWoaxMT/D3pHlIXrPIZIyhuZk2CS9vwrU5ycz8T3cX 9cwK8EFDqsljQQJIPPCJYri1W73+HahWt4LWioNvEz64HbLWIUtBOUqBzOH+ZNJiM/0t VoPfSFugj97GDD6RxyFMaSVboz2x5wdF4917dudD3MmEh0HJeZy3+ZM6vjWC7YZW/Upm 3AkPLIHGOP3CpAOBlcAWPK8pYz+ORG3Iq4nYQNKfFoXKfrGBQxIBpBDbBDUA00UAKIqZ Tobw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=vEGsCpOy3etkzy1XeQgJjouVhubNgqAGDo4ExtLZTF0=; b=je7tmu4JDkxV41jPKRClbT0osImW7Y3bxdbEry4kgcQ/2AZfY/broYy/ek+YQyRmiK vFwM/F9XffyMNtBuhnGN/6r3wQjrNoRaYifiznkkSPeS43kcWhL8oH9OI3Q0d6r/hTDv 1fwvSHQDz0LAj1tTU4f6EfZBR/TODLNSO8BFiffdO8pADXzAkj/MCAgX8mvZdo0z5RC4 onYjYXQ9/E6Jt5N3hl+JJwTkakmefOGzoiPhTGq+lwOdDHmJXILR/j5y8Nkm7fqrVrib jDCw3wBvGuzq4UbSxLmS60gmWHDDbrwxMM231397CsPNFmfE9STteLpkNaAtEAPIbeOU cTdA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b="QZGy/+IO"; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f14si695832edj.235.2020.05.19.20.01.20; Tue, 19 May 2020 20:01:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b="QZGy/+IO"; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728703AbgETC7d (ORCPT + 99 others); Tue, 19 May 2020 22:59:33 -0400 Received: from mail-eopbgr10087.outbound.protection.outlook.com ([40.107.1.87]:39045 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726318AbgETC7c (ORCPT ); Tue, 19 May 2020 22:59:32 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BodrMynLNd/06xyJLFNGKzlgagfyWRUd9LRu4lStAa2Wis1IwgFrjwd2Df5LsPZHtY6NzNRgxTWYK9K85+39xRqNPu9Y+UE3j2k/RitJslZVDj+SnGkwONZf1N/o9wABXfB01E09MUDRSkvBigGqziA6OnfYt5rT/mWxMighn06XMp5UBTeSZzyo7+b/b3RPBzGgxstYhvNj1U30nkwtrtJhYdF2yC+PPcx8MWVTXFJADIjxzCUmz7t5FhxvjLjVlJ4n+1k6xzM6LV5PqpfVJaqZ3GeHrHyKYUK+jhcsVnL2lANwBhGXt8blpbCVfD8U7co+7Gk2Yw81Yf5++j2wRQ== 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-SenderADCheck; bh=vEGsCpOy3etkzy1XeQgJjouVhubNgqAGDo4ExtLZTF0=; b=V9QB8/SBByQgQ8HRPAiKUAeo/9OCxogmUqpdhPFcagG52TLzhz69zWJvzkvkImqsyPhJUpNskrOKGfDpQfnqbwQWThpCJbL7xgxs3rWb4lJ+YnqbV/EPdVmk1UbQD8gfSPP2YTq7elLufwD+zoyALz0SiY/QivziZKPhaMQxoP2dOLq40KbfcfnsICmLKq9nBoTwJmeuP4bW3mi75wt1zaCcBoV7RXPOfoio6RWlfN6swUsMJ+OnpcaMjpC3IiPycPl5SU8YERgFWkcjcxLMKqYQIPosnh8nUY6SWlitgoQXqDLZr9gfpdCwPpM32uxAefHZNPoPxkDa/l7ZVLAl2g== 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=vEGsCpOy3etkzy1XeQgJjouVhubNgqAGDo4ExtLZTF0=; b=QZGy/+IObabbPSlqcJD/wgVSZKBt8UWlVBRCuYItEE+ov91lvVD8GfdomA28MDNCUv2tTL17hs7fdEz12+d2WD+SX1K/9cb7yKhTAVXQUxd50TDTXtzMzK4lNou+rNu/WCtCshOLkNqnGctq4crvuFKiH2P93xKBZ+ot7obvHaU= Authentication-Results: huawei.com; dkim=none (message not signed) header.d=none;huawei.com; dmarc=none action=none header.from=nxp.com; Received: from DB8PR04MB6795.eurprd04.prod.outlook.com (2603:10a6:10:fa::15) by DB8PR04MB6634.eurprd04.prod.outlook.com (2603:10a6:10:10e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.27; Wed, 20 May 2020 02:59:28 +0000 Received: from DB8PR04MB6795.eurprd04.prod.outlook.com ([fe80::2924:94ba:2206:216e]) by DB8PR04MB6795.eurprd04.prod.outlook.com ([fe80::2924:94ba:2206:216e%7]) with mapi id 15.20.3000.034; Wed, 20 May 2020 02:59:28 +0000 From: Joakim Zhang To: john.garry@huawei.com, will@kernel.org, mark.rutland@arm.com, robh+dt@kernel.org, shawnguo@kernel.org Cc: linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 2/3] perf/imx_ddr: Add system PMU identifier for userspace Date: Wed, 20 May 2020 10:56:18 +0800 Message-Id: <20200520025619.687-3-qiangqing.zhang@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200520025619.687-1-qiangqing.zhang@nxp.com> References: <20200520025619.687-1-qiangqing.zhang@nxp.com> Content-Type: text/plain X-ClientProxiedBy: SG2PR01CA0142.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::22) To DB8PR04MB6795.eurprd04.prod.outlook.com (2603:10a6:10:fa::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by SG2PR01CA0142.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23 via Frontend Transport; Wed, 20 May 2020 02:59:24 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.71] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: e52fac7e-475b-4541-4a58-08d7fc69cf62 X-MS-TrafficTypeDiagnostic: DB8PR04MB6634: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3044; X-Forefront-PRVS: 04097B7F7F X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: piKfqpcLu3STl/XPD5B8ev6isnC36YgEHQojdkihwf538NYAwpZZf+zYii5RNVkGY/WK86yKJ28PQ+Ow6nBAkYXYiE210Wtp3nqQBuj0yij/hpsMhSBScKRy1IN0HBX5XYXDHx/PQli+NcBgn7UgNzgsfg2aU+7XRHNzleZXx9SP4/0jBjYDp2oa7mAYPGQTlIcVhSI+wj5+BDMjXdxsfh9ovMkLvNqOy2av5w+jFTr7i68ohGHQyxiU/oLGPgGWYcOUJQZD+cesNueg4585naUEDU+xukj+IeVhEFsu0EE9MHt0FPhYKuDpL06CAxXJ/jFflttRkiiWQQa49c3VC9fwMOEDl9U6QmftPou5z+i7v0cgztFgaAoslH1/B+X49LSx1jPC9upVydPPtLPoq3wWyxE12Iv9lMyoufrR3eCXulU0S9aC8hFdjO2esuMafyr4JbJ6rfvhVIuZeZjOv303XmeoZkmk0xId+rpdoBdoCJsGGn9ixLma9rcACVTa X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB8PR04MB6795.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(346002)(376002)(396003)(136003)(39860400002)(366004)(8676002)(478600001)(2906002)(6486002)(956004)(8936002)(6666004)(2616005)(36756003)(6506007)(16526019)(5660300002)(66556008)(66476007)(4326008)(26005)(66946007)(1076003)(6512007)(316002)(86362001)(69590400007)(186003)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 4+sYkLKLXMr4cNpfsU5MgNC7m/vBDkBh75QlZXXmtQRdn8jc69+AFFEd9USs11jaZ8V0D1ZFuQxEj82LP80jxatT4HdrG77qxTMzjKvdIzuN9VCFRrfuksvP1T4voLq9O+b/iKOK2PHf1KdYOA/kVfQScwyUMulMR9EieisRnjb7dY09i/PVFY3eQqXEeFq30QaQJxJZkqmoXiTfIdfatVga4rpjTvlaHVT/hkOYhF7yCz6+DwDkfJDOuki5oPKlxDVnscUwK0iOXv6XAwAP+llQNXJjIqP+jR5KtG2eohrHowO/DCONhBd+yu+YgO9tisaSL+VK0FLLkeeJ8L5F1cd9271H1BWH04lCwTFV7+cwXy2yMbjZy9WPcVVnap6mobG8jT/b84zd4i+erUTezwWDCLRCL9pczzYPo6roTTTVStFMnT3rBQj/CNa094FVFgN76bn8PpVYRDhF7q6zSz5slKK1C4UJ8G2kyCs5Hcc= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e52fac7e-475b-4541-4a58-08d7fc69cf62 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2020 02:59:27.9177 (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: LbNWthLNhCP7DwpbNDUI9lbPl214A5ERIfjbT5OsZngBHQ+1p+pGUTQgI2CadVoK7F5J6+kruWAMZZnK22Q4mA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB6634 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The DDR Perf for i.MX8 is a system PMU whose axi id would different from SoC to SoC. Need expose system PMU identifier for userspace which refer to /sys/bus/event_source/devices//identifier. Signed-off-by: Joakim Zhang --- drivers/perf/fsl_imx8_ddr_perf.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/perf/fsl_imx8_ddr_perf.c b/drivers/perf/fsl_imx8_ddr_perf.c index 90884d14f95f..ba523a94f4d7 100644 --- a/drivers/perf/fsl_imx8_ddr_perf.c +++ b/drivers/perf/fsl_imx8_ddr_perf.c @@ -76,6 +76,7 @@ struct ddr_pmu { unsigned int cpu; struct hlist_node node; struct device *dev; + const char *identifier; struct perf_event *events[NUM_COUNTERS]; int active_events; enum cpuhp_state cpuhp_state; @@ -84,6 +85,27 @@ struct ddr_pmu { int id; }; +static ssize_t ddr_perf_identifier_show(struct device *dev, + struct device_attribute *attr, + char *page) +{ + struct ddr_pmu *pmu = dev_get_drvdata(dev); + + return sprintf(page, "%s\n", pmu->identifier); +} + +static struct device_attribute ddr_perf_identifier_attr = + __ATTR(identifier, 0444, ddr_perf_identifier_show, NULL); + +static struct attribute *ddr_perf_identifier_attrs[] = { + &ddr_perf_identifier_attr.attr, + NULL, +}; + +static struct attribute_group ddr_perf_identifier_attr_group = { + .attrs = ddr_perf_identifier_attrs, +}; + enum ddr_perf_filter_capabilities { PERF_CAP_AXI_ID_FILTER = 0, PERF_CAP_AXI_ID_FILTER_ENHANCED, @@ -237,6 +259,7 @@ static const struct attribute_group *attr_groups[] = { &ddr_perf_format_attr_group, &ddr_perf_cpumask_attr_group, &ddr_perf_filter_cap_attr_group, + &ddr_perf_identifier_attr_group, NULL, }; @@ -601,6 +624,7 @@ static int ddr_perf_probe(struct platform_device *pdev) struct ddr_pmu *pmu; struct device_node *np; void __iomem *base; + const char *identifier = NULL; char *name; int num; int ret; @@ -620,6 +644,11 @@ static int ddr_perf_probe(struct platform_device *pdev) platform_set_drvdata(pdev, pmu); + ret = of_property_read_string(np, "identifier", &identifier); + if (ret < 0) + dev_warn(&pdev->dev, "Failed to get identifier\n"); + pmu->identifier = identifier; + name = devm_kasprintf(&pdev->dev, GFP_KERNEL, DDR_PERF_DEV_NAME "%d", num); if (!name) -- 2.17.1