* [PATCH -next v2 0/2] ARM: imx: free resources @ 2021-06-15 12:52 Yang Yingliang 2021-06-15 12:52 ` [PATCH -next v2 1/2] ARM: imx: add missing iounmap() Yang Yingliang ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Yang Yingliang @ 2021-06-15 12:52 UTC (permalink / raw) To: linux-kernel, linux-arm-kernel, linux-imx; +Cc: shawnguo mmdc_base need be unmapped and mmdc_ipg_clk need be disable and unprepared in remove and error path. v2: hold mmdc_base in structure and free the resources on error path. Yang Yingliang (2): ARM: imx: add missing iounmap() ARM: imx: add missing clk_disable_unprepare() arch/arm/mach-imx/mmdc.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH -next v2 1/2] ARM: imx: add missing iounmap() 2021-06-15 12:52 [PATCH -next v2 0/2] ARM: imx: free resources Yang Yingliang @ 2021-06-15 12:52 ` Yang Yingliang 2021-06-17 12:20 ` Aisheng Dong 2021-06-15 12:52 ` [PATCH -next v2 2/2] ARM: imx: add missing clk_disable_unprepare() Yang Yingliang 2021-07-14 7:19 ` [PATCH -next v2 0/2] ARM: imx: free resources Shawn Guo 2 siblings, 1 reply; 6+ messages in thread From: Yang Yingliang @ 2021-06-15 12:52 UTC (permalink / raw) To: linux-kernel, linux-arm-kernel, linux-imx; +Cc: shawnguo Commit e76bdfd7403a ("ARM: imx: Added perf functionality to mmdc driver") introduced imx_mmdc_remove(), the mmdc_base need be unmapped in it if config PERF_EVENTS is enabled. If imx_mmdc_perf_init() fails, the mmdc_base also need be unmapped. Fixes: e76bdfd7403a ("ARM: imx: Added perf functionality to mmdc driver") Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> --- arch/arm/mach-imx/mmdc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-imx/mmdc.c b/arch/arm/mach-imx/mmdc.c index 0dfd0ae7a63d..8e57691aafe2 100644 --- a/arch/arm/mach-imx/mmdc.c +++ b/arch/arm/mach-imx/mmdc.c @@ -462,6 +462,7 @@ static int imx_mmdc_remove(struct platform_device *pdev) cpuhp_state_remove_instance_nocalls(cpuhp_mmdc_state, &pmu_mmdc->node); perf_pmu_unregister(&pmu_mmdc->pmu); + iounmap(pmu_mmdc->mmdc_base); kfree(pmu_mmdc); return 0; } @@ -567,7 +568,11 @@ static int imx_mmdc_probe(struct platform_device *pdev) val &= ~(1 << BP_MMDC_MAPSR_PSD); writel_relaxed(val, reg); - return imx_mmdc_perf_init(pdev, mmdc_base); + err = imx_mmdc_perf_init(pdev, mmdc_base); + if (err) + iounmap(mmdc_base); + + return err; } int imx_mmdc_get_ddr_type(void) -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 6+ messages in thread
* RE: [PATCH -next v2 1/2] ARM: imx: add missing iounmap() 2021-06-15 12:52 ` [PATCH -next v2 1/2] ARM: imx: add missing iounmap() Yang Yingliang @ 2021-06-17 12:20 ` Aisheng Dong 0 siblings, 0 replies; 6+ messages in thread From: Aisheng Dong @ 2021-06-17 12:20 UTC (permalink / raw) To: Yang Yingliang, linux-kernel, linux-arm-kernel, dl-linux-imx; +Cc: shawnguo > From: Yang Yingliang <yangyingliang@huawei.com> > Sent: Tuesday, June 15, 2021 8:53 PM > Subject: [PATCH -next v2 1/2] ARM: imx: add missing iounmap() > > Commit e76bdfd7403a ("ARM: imx: Added perf functionality to mmdc driver") > introduced imx_mmdc_remove(), the mmdc_base need be unmapped in it if > config PERF_EVENTS is enabled. > > If imx_mmdc_perf_init() fails, the mmdc_base also need be unmapped. > > Fixes: e76bdfd7403a ("ARM: imx: Added perf functionality to mmdc driver") > Reported-by: Hulk Robot <hulkci@huawei.com> > Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com> Regards Aisheng _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH -next v2 2/2] ARM: imx: add missing clk_disable_unprepare() 2021-06-15 12:52 [PATCH -next v2 0/2] ARM: imx: free resources Yang Yingliang 2021-06-15 12:52 ` [PATCH -next v2 1/2] ARM: imx: add missing iounmap() Yang Yingliang @ 2021-06-15 12:52 ` Yang Yingliang 2021-06-17 12:20 ` Aisheng Dong 2021-07-14 7:19 ` [PATCH -next v2 0/2] ARM: imx: free resources Shawn Guo 2 siblings, 1 reply; 6+ messages in thread From: Yang Yingliang @ 2021-06-15 12:52 UTC (permalink / raw) To: linux-kernel, linux-arm-kernel, linux-imx; +Cc: shawnguo clock source is prepared and enabled by clk_prepare_enable() in probe function, but no disable or unprepare in remove and error path. Fixes: 9454a0caff6a ("ARM: imx: add mmdc ipg clock operation for mmdc") Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> --- arch/arm/mach-imx/mmdc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-imx/mmdc.c b/arch/arm/mach-imx/mmdc.c index 8e57691aafe2..4a6f1359e1e9 100644 --- a/arch/arm/mach-imx/mmdc.c +++ b/arch/arm/mach-imx/mmdc.c @@ -103,6 +103,7 @@ struct mmdc_pmu { struct perf_event *mmdc_events[MMDC_NUM_COUNTERS]; struct hlist_node node; struct fsl_mmdc_devtype_data *devtype_data; + struct clk *mmdc_ipg_clk; }; /* @@ -463,11 +464,13 @@ static int imx_mmdc_remove(struct platform_device *pdev) cpuhp_state_remove_instance_nocalls(cpuhp_mmdc_state, &pmu_mmdc->node); perf_pmu_unregister(&pmu_mmdc->pmu); iounmap(pmu_mmdc->mmdc_base); + clk_disable_unprepare(pmu_mmdc->mmdc_ipg_clk); kfree(pmu_mmdc); return 0; } -static int imx_mmdc_perf_init(struct platform_device *pdev, void __iomem *mmdc_base) +static int imx_mmdc_perf_init(struct platform_device *pdev, void __iomem *mmdc_base, + struct clk *mmdc_ipg_clk) { struct mmdc_pmu *pmu_mmdc; char *name; @@ -495,6 +498,7 @@ static int imx_mmdc_perf_init(struct platform_device *pdev, void __iomem *mmdc_b } 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 @@ -568,9 +572,11 @@ static int imx_mmdc_probe(struct platform_device *pdev) val &= ~(1 << BP_MMDC_MAPSR_PSD); writel_relaxed(val, reg); - err = imx_mmdc_perf_init(pdev, mmdc_base); - if (err) + err = imx_mmdc_perf_init(pdev, mmdc_base, mmdc_ipg_clk); + if (err) { iounmap(mmdc_base); + clk_disable_unprepare(mmdc_ipg_clk); + } return err; } -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 6+ messages in thread
* RE: [PATCH -next v2 2/2] ARM: imx: add missing clk_disable_unprepare() 2021-06-15 12:52 ` [PATCH -next v2 2/2] ARM: imx: add missing clk_disable_unprepare() Yang Yingliang @ 2021-06-17 12:20 ` Aisheng Dong 0 siblings, 0 replies; 6+ messages in thread From: Aisheng Dong @ 2021-06-17 12:20 UTC (permalink / raw) To: Yang Yingliang, linux-kernel, linux-arm-kernel, dl-linux-imx; +Cc: shawnguo > From: Yang Yingliang <yangyingliang@huawei.com> > Sent: Tuesday, June 15, 2021 8:53 PM > > clock source is prepared and enabled by clk_prepare_enable() in probe > function, but no disable or unprepare in remove and error path. > > Fixes: 9454a0caff6a ("ARM: imx: add mmdc ipg clock operation for mmdc") > Reported-by: Hulk Robot <hulkci@huawei.com> > Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com> Regards Aisheng > --- > arch/arm/mach-imx/mmdc.c | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) > > diff --git a/arch/arm/mach-imx/mmdc.c b/arch/arm/mach-imx/mmdc.c index > 8e57691aafe2..4a6f1359e1e9 100644 > --- a/arch/arm/mach-imx/mmdc.c > +++ b/arch/arm/mach-imx/mmdc.c > @@ -103,6 +103,7 @@ struct mmdc_pmu { > struct perf_event *mmdc_events[MMDC_NUM_COUNTERS]; > struct hlist_node node; > struct fsl_mmdc_devtype_data *devtype_data; > + struct clk *mmdc_ipg_clk; > }; > > /* > @@ -463,11 +464,13 @@ static int imx_mmdc_remove(struct > platform_device *pdev) > cpuhp_state_remove_instance_nocalls(cpuhp_mmdc_state, > &pmu_mmdc->node); > perf_pmu_unregister(&pmu_mmdc->pmu); > iounmap(pmu_mmdc->mmdc_base); > + clk_disable_unprepare(pmu_mmdc->mmdc_ipg_clk); > kfree(pmu_mmdc); > return 0; > } > > -static int imx_mmdc_perf_init(struct platform_device *pdev, void __iomem > *mmdc_base) > +static int imx_mmdc_perf_init(struct platform_device *pdev, void __iomem > *mmdc_base, > + struct clk *mmdc_ipg_clk) > { > struct mmdc_pmu *pmu_mmdc; > char *name; > @@ -495,6 +498,7 @@ static int imx_mmdc_perf_init(struct platform_device > *pdev, void __iomem *mmdc_b > } > > 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 > @@ -568,9 +572,11 @@ static int imx_mmdc_probe(struct platform_device > *pdev) > val &= ~(1 << BP_MMDC_MAPSR_PSD); > writel_relaxed(val, reg); > > - err = imx_mmdc_perf_init(pdev, mmdc_base); > - if (err) > + err = imx_mmdc_perf_init(pdev, mmdc_base, mmdc_ipg_clk); > + if (err) { > iounmap(mmdc_base); > + clk_disable_unprepare(mmdc_ipg_clk); > + } > > return err; > } > -- > 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH -next v2 0/2] ARM: imx: free resources 2021-06-15 12:52 [PATCH -next v2 0/2] ARM: imx: free resources Yang Yingliang 2021-06-15 12:52 ` [PATCH -next v2 1/2] ARM: imx: add missing iounmap() Yang Yingliang 2021-06-15 12:52 ` [PATCH -next v2 2/2] ARM: imx: add missing clk_disable_unprepare() Yang Yingliang @ 2021-07-14 7:19 ` Shawn Guo 2 siblings, 0 replies; 6+ messages in thread From: Shawn Guo @ 2021-07-14 7:19 UTC (permalink / raw) To: Yang Yingliang; +Cc: linux-kernel, linux-arm-kernel, linux-imx On Tue, Jun 15, 2021 at 08:52:37PM +0800, Yang Yingliang wrote: > mmdc_base need be unmapped and mmdc_ipg_clk need be disable and unprepared > in remove and error path. > > v2: > hold mmdc_base in structure and free the resources on error path. > > Yang Yingliang (2): > ARM: imx: add missing iounmap() > ARM: imx: add missing clk_disable_unprepare() Applied both, thanks. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-07-14 7:21 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-06-15 12:52 [PATCH -next v2 0/2] ARM: imx: free resources Yang Yingliang 2021-06-15 12:52 ` [PATCH -next v2 1/2] ARM: imx: add missing iounmap() Yang Yingliang 2021-06-17 12:20 ` Aisheng Dong 2021-06-15 12:52 ` [PATCH -next v2 2/2] ARM: imx: add missing clk_disable_unprepare() Yang Yingliang 2021-06-17 12:20 ` Aisheng Dong 2021-07-14 7:19 ` [PATCH -next v2 0/2] ARM: imx: free resources Shawn Guo
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).