Message ID | 593e7b7d97c6e064b29716b091a9d4fd122241fb.1671473163.git.christophe.jaillet@wanadoo.fr |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp2541962wrn; Mon, 19 Dec 2022 10:16:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf6VIupcstcAfp7JZF8Hlhdy0GCnA9/yuGpqQeFc3Bxgvf59jsD/NvCDisKgS6igI+KahRfE X-Received: by 2002:a17:902:c14c:b0:189:9733:59d3 with SMTP id 12-20020a170902c14c00b00189973359d3mr43195454plj.29.1671473794171; Mon, 19 Dec 2022 10:16:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671473794; cv=none; d=google.com; s=arc-20160816; b=ervVrBWc2bbPGd9g1txhAFEciIcA9EaeTPxV+AS3Zzpq26sT9a9Oph0mlmC31T/k69 iSuqc39JhvQtXXLVm6Ya4Si2iLRM25C3sf7XVUxZkFwAyBuCKNjyhbreUpzE0bYY5Hnc pNc++pbCrBXM5naTv7ERFVOoz39ZaLQb4HB22q2lbylgUc5OYFsTkDm/GRqqCVP75IGp hZguf62HI+jepv1vPXJGRGDORYJtZWv7aNjlCCR0t0wxFKhvu5DmvNOmqwBTOtRrscUB mHnH7HmCdB9UCvddNBM3dsLqRXUiZRfNFgcw0xA3aqevXlYBxKTkkGYhMPELrFFKw91w e23Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=A2WAYdUU3varTXOPkMTS3h5NIplRbt3MGEr5rGN+UVs=; b=g7yOSUdXamaukyQFmTJLmkda5FjyWUXW6bXoA81xj8EBMgHGyJcVZtLHhpeRApFY2/ yeMz6fG86R5cSKH0pLwlNcnKj+o0ffxf0GFaqSvmOVJdSyxxB0Rw8muwXhiVklaldQtd XtJH7n363Tkaf/gjCrzniCixxgwYq8oVuKfM53KVT2TvxtdAODRTahWCsHbeYj3n0JN5 Y63YcIVRSetmTtxYrCAPY2JyRQ1XJe8ddypGAGt3SDSldJfg1F85ULzx3XR9ArK732Je 3u8mg1Vx7j6w6HUctXl0qx4oYBuT8kitcO3KpXplP5iP8x58mme5owzhcHr63x4g81+D 2Cnw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x7-20020a170902820700b0018996404dd9si3252433pln.267.2022.12.19.10.16.21; Mon, 19 Dec 2022 10:16:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231761AbiLSSGf (ORCPT <rfc822;abdi.embedded@gmail.com> + 99 others); Mon, 19 Dec 2022 13:06:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231739AbiLSSGc (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 19 Dec 2022 13:06:32 -0500 Received: from smtp.smtpout.orange.fr (smtp-15.smtpout.orange.fr [80.12.242.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAC4C11821 for <linux-kernel@vger.kernel.org>; Mon, 19 Dec 2022 10:06:30 -0800 (PST) Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id 7KWtpg0ivBonI7KWtprGLS; Mon, 19 Dec 2022 19:06:28 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Mon, 19 Dec 2022 19:06:28 +0100 X-ME-IP: 86.243.100.34 From: Christophe JAILLET <christophe.jaillet@wanadoo.fr> To: Yong Wu <yong.wu@mediatek.com>, Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>, Robin Murphy <robin.murphy@arm.com>, Matthias Brugger <matthias.bgg@gmail.com>, Honghui Zhang <honghui.zhang@mediatek.com> Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET <christophe.jaillet@wanadoo.fr>, Joerg Roedel <jroedel@suse.de>, iommu@lists.linux.dev, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] iommu/mediatek-v1: Fix an error handling path in mtk_iommu_v1_probe() Date: Mon, 19 Dec 2022 19:06:22 +0100 Message-Id: <593e7b7d97c6e064b29716b091a9d4fd122241fb.1671473163.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752667305271992335?= X-GMAIL-MSGID: =?utf-8?q?1752667305271992335?= |
Series |
iommu/mediatek-v1: Fix an error handling path in mtk_iommu_v1_probe()
|
|
Commit Message
Christophe JAILLET
Dec. 19, 2022, 6:06 p.m. UTC
A clk, prepared and enabled in mtk_iommu_v1_hw_init(), is not released in
the error handling path of mtk_iommu_v1_probe().
Add the corresponding clk_disable_unprepare(), as already done in the
remove function.
Fixes: b17336c55d89 ("iommu/mediatek: add support for mtk iommu generation one HW")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Another option would be to use devm_clk_get_enabled(). This would save a
few LoC in mtk_iommu_v1_hw_init() and in the remove function.
However, it would change the order of function calls in the remove function
so I leave it as-is.
Let me know if it is fine and if you prefer this alternative.
---
drivers/iommu/mtk_iommu_v1.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Comments
On 19/12/2022 19:06, Christophe JAILLET wrote: > A clk, prepared and enabled in mtk_iommu_v1_hw_init(), is not released in > the error handling path of mtk_iommu_v1_probe(). > > Add the corresponding clk_disable_unprepare(), as already done in the > remove function. > > Fixes: b17336c55d89 ("iommu/mediatek: add support for mtk iommu generation one HW") > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com> > --- > Another option would be to use devm_clk_get_enabled(). This would save a > few LoC in mtk_iommu_v1_hw_init() and in the remove function. > However, it would change the order of function calls in the remove function > so I leave it as-is. > Let me know if it is fine and if you prefer this alternative. > --- > drivers/iommu/mtk_iommu_v1.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c > index 69682ee068d2..ca581ff1c769 100644 > --- a/drivers/iommu/mtk_iommu_v1.c > +++ b/drivers/iommu/mtk_iommu_v1.c > @@ -683,7 +683,7 @@ static int mtk_iommu_v1_probe(struct platform_device *pdev) > ret = iommu_device_sysfs_add(&data->iommu, &pdev->dev, NULL, > dev_name(&pdev->dev)); > if (ret) > - return ret; > + goto out_clk_unprepare; > > ret = iommu_device_register(&data->iommu, &mtk_iommu_v1_ops, dev); > if (ret) > @@ -698,6 +698,8 @@ static int mtk_iommu_v1_probe(struct platform_device *pdev) > iommu_device_unregister(&data->iommu); > out_sysfs_remove: > iommu_device_sysfs_remove(&data->iommu); > +out_clk_unprepare: > + clk_disable_unprepare(data->bclk); > return ret; > } >
Il 19/12/22 19:06, Christophe JAILLET ha scritto: > A clk, prepared and enabled in mtk_iommu_v1_hw_init(), is not released in > the error handling path of mtk_iommu_v1_probe(). > > Add the corresponding clk_disable_unprepare(), as already done in the > remove function. > > Fixes: b17336c55d89 ("iommu/mediatek: add support for mtk iommu generation one HW") > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
On Mon, 2022-12-19 at 19:06 +0100, Christophe JAILLET wrote: > A clk, prepared and enabled in mtk_iommu_v1_hw_init(), is not > released in > the error handling path of mtk_iommu_v1_probe(). > > Add the corresponding clk_disable_unprepare(), as already done in the > remove function. > > Fixes: b17336c55d89 ("iommu/mediatek: add support for mtk iommu > generation one HW") > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Reviewed-by: Yong Wu <yong.wu@mediatek.com> Thanks.
On Mon, Dec 19, 2022 at 07:06:22PM +0100, Christophe JAILLET wrote: > Fixes: b17336c55d89 ("iommu/mediatek: add support for mtk iommu generation one HW") > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > --- > Another option would be to use devm_clk_get_enabled(). This would save a > few LoC in mtk_iommu_v1_hw_init() and in the remove function. > However, it would change the order of function calls in the remove function > so I leave it as-is. > Let me know if it is fine and if you prefer this alternative. > --- > drivers/iommu/mtk_iommu_v1.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) Applied, thanks.
diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c index 69682ee068d2..ca581ff1c769 100644 --- a/drivers/iommu/mtk_iommu_v1.c +++ b/drivers/iommu/mtk_iommu_v1.c @@ -683,7 +683,7 @@ static int mtk_iommu_v1_probe(struct platform_device *pdev) ret = iommu_device_sysfs_add(&data->iommu, &pdev->dev, NULL, dev_name(&pdev->dev)); if (ret) - return ret; + goto out_clk_unprepare; ret = iommu_device_register(&data->iommu, &mtk_iommu_v1_ops, dev); if (ret) @@ -698,6 +698,8 @@ static int mtk_iommu_v1_probe(struct platform_device *pdev) iommu_device_unregister(&data->iommu); out_sysfs_remove: iommu_device_sysfs_remove(&data->iommu); +out_clk_unprepare: + clk_disable_unprepare(data->bclk); return ret; }