From patchwork Thu Jan 5 06:11:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angus Chen X-Patchwork-Id: 1722116 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=0fhEV6Tj; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=jaguarmicro.com header.i=@jaguarmicro.com header.a=rsa-sha256 header.s=selector1 header.b=b1W43QNA; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Nnwtk1dplz23fC for ; Fri, 6 Jan 2023 06:06:38 +1100 (AEDT) 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=oUYC3ERviXjGdA1+bJe9PQeu57Yt/vvwDUnzu3NCmy4=; b=0fhEV6Tj5bHIYx 0fA7fm/8JjFQ9YOFVEhuL5NfyDvEpARAA0iYZa+s4sb/4mjBizEI1eoS78if5ZQTRg8ZvKrcxvIZV OPPmT5Eb+4wxz/p6oLpyF9tYHTAL1LH1AI+NJTnBENU6sSKeHcLIf7/iHMHfOT3rpNrX3B0Kr4VYD ylUxNfPCQBlHLJX/wzJuKQ/OsKtPIT/zox3noh/Qv6G97VkKsmNt6wZQWLdL98AfWprcMLyWIAnlu Cycf8/ANsQd01XdIl83bKESkVnPDd5l6p7AB20w1gOnLEiTAsqBV0hpfVK8lIilbksXD55E/vpwOv OZGHGmQb1F2GUOHTGVQA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pDVZD-00Dxl5-Ef; Thu, 05 Jan 2023 19:06:20 +0000 Received: from mail-sgaapc01on2078.outbound.protection.outlook.com ([40.107.215.78] helo=APC01-SG2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pDJTv-005fax-1z for linux-arm-kernel@lists.infradead.org; Thu, 05 Jan 2023 06:12:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HBBbbmPeGsWY+k6tcKSCvMoAG9Wvq2YCiSJPCpGKPbT6ixCecJzBcbo7z87A64jEAxSgdjyDbIxfCWonnMIevMmmE7lXIOz2Vn86P5oFf/qpwR5SdYpxbERbs39IHCvn9a5E5o5iY+3I2RFu1nKrdr5R/eu7/pk+CUSO2zKnnpTcuGOwITXeJlcVx3+WZvoAw/Zhr9tsAZWRZran1pHFfRm3GmegQSQ3Kceo2E/wzzJSAKb/oLQlnO1tpWqKkmy/mOPPPPIreabPqQtOd1ehHE9SAiC9LjS53EQZozFgNkDcjmwEqyNOmfurje89pTL4QoXNRxhmF7lzVKNquxEfiA== 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=4rKRVSzykACwn5bikUEXNKnXq2+ovWPNIKgtEAuVvWE=; b=bRYik8UMnGdYUGkT20/uyyAlc9bYGLcWflvaD9VP/FJSTVOQ/cOjYflHpJSsHGOhptCDSf16svJjatEZx9oG8Bs9ZCti0XcVAffCLFuNNFhmLooqBVFlRMVvvzzPQOz54aucTROeoAz3P5aryQUCKW71GUiOmtg+sq0UD/WxFcXMRTykFWuxYcv/NkcKwiebymBHTzc9/NMD676tb5XJd8E/0UEScnpot6hguwUAQiVWYPp9WHdj29BNyuqjX8U5MQIdWijqjP3gPc2TJSnx4duJzW0ppx6D29cbZbMODjp619CxYYaGEi3Dw2Bas9h7dF0jQbtP7oZRyYUZ/SYFrA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=jaguarmicro.com; dmarc=pass action=none header.from=jaguarmicro.com; dkim=pass header.d=jaguarmicro.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jaguarmicro.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4rKRVSzykACwn5bikUEXNKnXq2+ovWPNIKgtEAuVvWE=; b=b1W43QNAAXyfYzzDfVuwbe2R59UKH2ApHqnbHFOkN4OtFFU8QRTvmHUPI2VPpa1PFoLVBZ5qeZ5VrXp0zgT1lgDjuh7OfbMAVrZMbw2BTBffBLjtg8bilbvOXLspzNhG8cxEoBmiAodLc2HerfVe/u6AzevUVnVRHz8kP4xL6iS+87YElzCjfn0ue+jHmm38FS09nVMoJtHpAODgDPnHWqkTPGh7x8hnpo7EyqHYUl5thl4Ga0BSEbHNrJMliJ+D99Hnq2Eo24eh92o91WUIwAYayv8quAD8lvZFDVfndgUSeScZLyR4JpSG4aHS2CwyXrEv7CZGW5xSHDyZH95vhA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=jaguarmicro.com; Received: from TY2PR06MB3424.apcprd06.prod.outlook.com (2603:1096:404:104::19) by KL1PR0601MB4291.apcprd06.prod.outlook.com (2603:1096:820:76::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Thu, 5 Jan 2023 06:11:49 +0000 Received: from TY2PR06MB3424.apcprd06.prod.outlook.com ([fe80::6ddb:f49:dd40:1b9f]) by TY2PR06MB3424.apcprd06.prod.outlook.com ([fe80::6ddb:f49:dd40:1b9f%4]) with mapi id 15.20.5944.019; Thu, 5 Jan 2023 06:11:49 +0000 From: Angus Chen To: s.hauer@pengutronix.de, shawnguo@kernel.org Cc: linux-imx@nxp.com, kernel@pengutronix.de, festevam@gmail.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux@armlinux.org.uk, Angus Chen Subject: [PATCH] ARM: imx: Call ida_simple_remove() for ida_simple_get Date: Thu, 5 Jan 2023 14:11:23 +0800 Message-Id: <20230105061123.2085-1-angus.chen@jaguarmicro.com> X-Mailer: git-send-email 2.33.0.windows.1 X-ClientProxiedBy: SI2P153CA0007.APCP153.PROD.OUTLOOK.COM (2603:1096:4:140::8) To TY2PR06MB3424.apcprd06.prod.outlook.com (2603:1096:404:104::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TY2PR06MB3424:EE_|KL1PR0601MB4291:EE_ X-MS-Office365-Filtering-Correlation-Id: 339fbc73-bfe7-4a3d-37cb-08daeee3ba67 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YwBMhY1d6VB+JaHccK9Zg9OHHa/TnF+OYkcZAD0YZbd6zn/rIFTHpIDyzMDpKGsrLsy0PBW/jQIGeio7zvYyLrqa8fti8QdGP2oMI1zWHY+K/riFvkajLKlJQ/ZkekCPanNHsapRcbR1I5WAG6VqUgfiZREpahsyEJ1RCekqRuO/UsxMHhFbmj7aHRc+zbjkE3ePE6BbWjfcPC150V8fO1pyHCix2wY7FOHFVGiXcrDK8AfuyaxznlLLlLTJhqcAQ090boC70LxVL0N4/rCOtKbUXtvBe5sfdS0l910FBALxRQXEFusB8jMPdFtmdeTzgauC7hAJGlO3IXd5s7KVb/DoQ1N79HR3T/E9dYg/tEbaz3pFui20nVst0dxHRAGoFfn9+NMFh6Fr9ronE3RZLoLIo+yqtBQd0GU3dHCjv79FvJ6VLpd8Q2XG68fXBc40yvdgsgdTpuw0Dsx2vb5LQdvvhsiFaqWNSEOyYr2uaoKPTp9Pahs8+mi3/13Zh3nTqDoVQ1MU2Qw08j32jSmmmIkS8MchhsCLNFqd1Nv+ZpmI8QlNdwI0Un8oW5Zv8z8iL3w8+anfLkFPvpOkqL/31eriEQYTuyhgyg/9cGLoCQNzcG4tablObRZdrxRpmTWjssjqqEuKlA6sTYIK3mnvo3RP86bDRse87L2qZsghOMvNcnRdST+8A9HwV0WXbLm9 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TY2PR06MB3424.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(366004)(39830400003)(346002)(376002)(396003)(136003)(451199015)(2616005)(83380400001)(1076003)(86362001)(38100700002)(38350700002)(36756003)(4326008)(2906002)(316002)(66899015)(41300700001)(66556008)(66946007)(8936002)(5660300002)(66476007)(8676002)(186003)(6486002)(6512007)(478600001)(26005)(107886003)(6666004)(44832011)(6506007)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3u++U/XaQ5RZv6qoehCKSJREEizrw/yzjrHb/7ea+HCVx4l7QIth51fJFmglkg8Pk13AiaVk1sj5ztSbUeiOk6xfHty7DjIl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cgWdUkuHI7O57S251MXZlvhStaj2OnK8+ztgB3be6d3ufqiHaL17x6i0hf5S/6SVaW0cSFi8upCYy2V9GNfp0kUA0tn71oaSHZOCJM8MaL8IPmJ5LXJuYKyVQuad1+xds2GoKPAXzXSDr0ibWopfXSpYP4Q7B8yxdmfLOEW6yPWfyaJJV1b00x+N9hlVQdtLNaeSC5jAf5G7OBI1jKZYpxkPwVBn6XlPOBxVmuoPdGLJgQVsFO3Lhrk7q4TPR8me52Cy3XkR6NEQGXIV/3FyQimodGoESxyHgOGbxVzzRIleVtuNHVhEP/LLxLQIb7jC/6aiBiYGtj6AzOb6YNmWpRpHc0D9IJQ37UCcYEdEtwUveO0a7ksb9utwykexo9F1vZrxVhK/XJo6B9OJS84Pz97Zs0RAM/WAFti26+dwHD1RsCFfy9YFHPe3IT6O18gyN2N7A== X-OriginatorOrg: jaguarmicro.com X-MS-Exchange-CrossTenant-Network-Message-Id: 339fbc73-bfe7-4a3d-37cb-08daeee3ba67 X-MS-Exchange-CrossTenant-AuthSource: TY2PR06MB3424.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2023 06:11:49.4908 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 1e45a5c2-d3e1-46b3-a0e6-c5ebf6d8ba7b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: yzYpK9Z1X93OXP5voHyqfchiyFwE6PmA307bdS5yPtn0KSsHOjrhSkfKeQTCYWNLUyAZSE8N4xh34dVj6D9veHehFeTWe8Ww0Y6KQgV4J8w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR0601MB4291 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230104_221203_724029_BC1F30BF X-CRM114-Status: GOOD ( 14.02 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The function call ida_simple_get maybe fail,we should deal with it. And if ida_simple_get success ,it need to call ida_simple_remove also. BTW,devm_kasprintf can handle id is zero for consistency. Fixes: e76bdfd7403a ("ARM: imx: Added perf functionality to mmdc driver") Signed-off-by: Angus Chen --- arch/arm/mach-imx/mmdc.c | 24 ++++++++++++ 1 file chang [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [40.107.215.78 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [40.107.215.78 listed in wl.mailspike.net] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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+incoming-imx=patchwork.ozlabs.org@lists.infradead.org The function call ida_simple_get maybe fail,we should deal with it. And if ida_simple_get success ,it need to call ida_simple_remove also. BTW,devm_kasprintf can handle id is zero for consistency. Fixes: e76bdfd7403a ("ARM: imx: Added perf functionality to mmdc driver") Signed-off-by: Angus Chen --- arch/arm/mach-imx/mmdc.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/arch/arm/mach-imx/mmdc.c b/arch/arm/mach-imx/mmdc.c index af12668d0bf5..b9efe9da06e0 100644 --- a/arch/arm/mach-imx/mmdc.c +++ b/arch/arm/mach-imx/mmdc.c @@ -99,6 +99,7 @@ struct mmdc_pmu { cpumask_t cpu; struct hrtimer hrtimer; unsigned int active_events; + int id; struct device *dev; struct perf_event *mmdc_events[MMDC_NUM_COUNTERS]; struct hlist_node node; @@ -433,8 +434,6 @@ static enum hrtimer_restart mmdc_pmu_timer_handler(struct hrtimer *hrtimer) static int mmdc_pmu_init(struct mmdc_pmu *pmu_mmdc, void __iomem *mmdc_base, struct device *dev) { - int mmdc_num; - *pmu_mmdc = (struct mmdc_pmu) { .pmu = (struct pmu) { .task_ctx_nr = perf_invalid_context, @@ -452,15 +451,16 @@ static int mmdc_pmu_init(struct mmdc_pmu *pmu_mmdc, .active_events = 0, }; - mmdc_num = ida_simple_get(&mmdc_ida, 0, 0, GFP_KERNEL); + pmu_mmdc->id = ida_simple_get(&mmdc_ida, 0, 0, GFP_KERNEL); - return mmdc_num; + return pmu_mmdc->id; } static int imx_mmdc_remove(struct platform_device *pdev) { struct mmdc_pmu *pmu_mmdc = platform_get_drvdata(pdev); + ida_simple_remove(&mmdc_ida, pmu_mmdc->id); cpuhp_state_remove_instance_nocalls(cpuhp_mmdc_state, &pmu_mmdc->node); perf_pmu_unregister(&pmu_mmdc->pmu); iounmap(pmu_mmdc->mmdc_base); @@ -474,7 +474,6 @@ static int imx_mmdc_perf_init(struct platform_device *pdev, void __iomem *mmdc_b { struct mmdc_pmu *pmu_mmdc; char *name; - int mmdc_num; int ret; const struct of_device_id *of_id = of_match_device(imx_mmdc_dt_ids, &pdev->dev); @@ -497,14 +496,14 @@ static int imx_mmdc_perf_init(struct platform_device *pdev, void __iomem *mmdc_b cpuhp_mmdc_state = ret; } - mmdc_num = mmdc_pmu_init(pmu_mmdc, mmdc_base, &pdev->dev); - pmu_mmdc->mmdc_ipg_clk = mmdc_ipg_clk; - if (mmdc_num == 0) - name = "mmdc"; - else - name = devm_kasprintf(&pdev->dev, - GFP_KERNEL, "mmdc%d", mmdc_num); + ret = mmdc_pmu_init(pmu_mmdc, mmdc_base, &pdev->dev); + if (ret < 0) + goto pmu_free; + name = devm_kasprintf(&pdev->dev, + GFP_KERNEL, "mmdc%d", ret); + + pmu_mmdc->mmdc_ipg_clk = mmdc_ipg_clk; pmu_mmdc->devtype_data = (struct fsl_mmdc_devtype_data *)of_id->data; hrtimer_init(&pmu_mmdc->hrtimer, CLOCK_MONOTONIC, @@ -525,6 +524,7 @@ static int imx_mmdc_perf_init(struct platform_device *pdev, void __iomem *mmdc_b pmu_register_err: pr_warn("MMDC Perf PMU failed (%d), disabled\n", ret); + ida_simple_remove(&mmdc_ida, pmu_mmdc->id); cpuhp_state_remove_instance_nocalls(cpuhp_mmdc_state, &pmu_mmdc->node); hrtimer_cancel(&pmu_mmdc->hrtimer); pmu_free: