Revert "pinctrl: freescale: imx: Use 'devm_of_iomap()' to avoid a resource leak in case of error in 'imx_pinctrl_probe()'"
Subsystems (4)
PATCH v2 1/1 Revert "pinctrl: freescale: imx: Use 'devm_of_iomap()' to avoid a resource leak in case of error in 'imx_pinctrl_probe()'"
From: Haibo Chen <[email protected]>
This reverts commit ba403242615c2c99e27af7984b1650771a2cc2c9.
After commit 26d8cde5260b ("pinctrl: freescale: imx: add shared input select reg support"). i.MX7D has two iomux controllers iomuxc and iomuxc-lpsr which share select_input register for daisy chain settings.
If use 'devm_of_iomap()', when probe the iomuxc-lpsr, will call devm_request_mem_region() for the region <0x30330000-0x3033ffff> for the first time. Then, next time when probe the iomuxc, API devm_platform_ioremap_resource() will also use the API devm_request_mem_region() for the share region <0x30330000-0x3033ffff> again, then cause issue, log like below:
[ 0.179561] imx7d-pinctrl 302c0000.iomuxc-lpsr: initialized IMX pinctrl driver [ 0.191742] imx7d-pinctrl 30330000.pinctrl: can't request region for resource [mem 0x30330000-0x3033ffff] [ 0.191842] imx7d-pinctrl: probe of 30330000.pinctrl failed with error -16
--- drivers/pinctrl/freescale/pinctrl-imx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/pinctrl/freescale/pinctrl-imx.c +3 -4
@@ -824,13 +824,12 @@ int imx_pinctrl_probe(struct platform_device *pdev,return -EINVAL ; } - ipctl->input_sel_base =devm_of_iomap (&pdev->dev, np, -0 ,NULL ); + ipctl->input_sel_base =of_iomap (np,0 );of_node_put (np); -if (IS_ERR (ipctl->input_sel_base)) { +if (!ipctl->input_sel_base) {dev_err (&pdev->dev,"iomuxc input select base address not found\n" ); -return PTR_ERR (ipctl->input_sel_base); +return -ENOMEM ; } } }
Signature · 1 line
2.17.1
Aisheng Dong
maintainerHi Linus,
Could you help apply this patch as it blocked MX7D booting for a while?
Regards
Aisheng
Quoted 56 lines
From: [email protected] <[email protected]>
Sent: Tuesday, June 9, 2020 11:27 AMFrom: Haibo Chen <[email protected]>
This reverts commit
ba403242615c2c99e27af7984b1650771a2cc2c9.After commit
26d8cde5260b("pinctrl: freescale: imx: add shared input select reg support"). i.MX7D has two iomux controllers iomuxc and iomuxc-lpsr which shareselect_inputregister for daisy chain settings.
If use 'devm_of_iomap()', when probe the iomuxc-lpsr, will calldevm_request_mem_region()for the region <0x30330000-0x3033ffff> for the first time. Then, next time when probe the iomuxc, APIdevm_platform_ioremap_resource()will also use the APIdevm_request_mem_region()for the share region <0x30330000-0x3033ffff> again, then cause issue, log like below:[ 0.179561] imx7d-pinctrl 302c0000.iomuxc-lpsr: initialized IMX pinctrl driver [ 0.191742] imx7d-pinctrl 30330000.pinctrl: can't request region for resource [mem 0x30330000-0x3033ffff] [ 0.191842] imx7d-pinctrl: probe of 30330000.pinctrl failed with error -16Fixes ba403242615c ("pinctrl: freescale: imx: Use 'devm_of_iomap()' to avoid aresource leak in case of error in '
imx_pinctrl_probe()'")Signed-off-by Haibo Chen <[email protected]>Reviewed-by Dong Aisheng <[email protected]>--- drivers/pinctrl/freescale/pinctrl-imx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/pinctrl/freescale/pinctrl-imx.c +3
-5@@ -824,13 +824,12 @@ int imx_pinctrl_probe(struct platform_device *pdev,return -EINVAL ; } - ipctl->input_sel_base =devm_of_iomap (&pdev->dev, np, -0 ,NULL ); + ipctl->input_sel_base =of_iomap (np,0 );of_node_put (np); -if (IS_ERR (ipctl->input_sel_base)) { +if (!ipctl->input_sel_base) {dev_err (&pdev->dev,"iomuxc input select base address not found\n" ); -return PTR_ERR (ipctl->input_sel_base); +return -ENOMEM ; } } } --2.17.1
Quoted 19 lines · Aisheng Dong
Could you help apply this patch as it blocked MX7D booting for a while?
Quoted 17 lines
This reverts commit
ba403242615c2c99e27af7984b1650771a2cc2c9.After commit
26d8cde5260b("pinctrl: freescale: imx: add shared input select reg support"). i.MX7D has two iomux controllers iomuxc and iomuxc-lpsr which shareselect_inputregister for daisy chain settings.
If use 'devm_of_iomap()', when probe the iomuxc-lpsr, will calldevm_request_mem_region()for the region <0x30330000-0x3033ffff> for the first time. Then, next time when probe the iomuxc, APIdevm_platform_ioremap_resource()will also use the APIdevm_request_mem_region()for the share region <0x30330000-0x3033ffff> again, then cause issue, log like below:[ 0.179561] imx7d-pinctrl 302c0000.iomuxc-lpsr: initialized IMX pinctrl driver [ 0.191742] imx7d-pinctrl 30330000.pinctrl: can't request region for resource [mem 0x30330000-0x3033ffff] [ 0.191842] imx7d-pinctrl: probe of 30330000.pinctrl failed with error -16
It means that shared support took a wrong approach. If something has shared resources, another schema should be used, something like MFD (parent device which keeps only shared resources). Easiest way is to switch to the regmap API.
P.S. The revert is okay as a quick fix but... see above.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 26 lines
Subject: Re: [PATCH v2] Revert "pinctrl: freescale: imx: Use '
devm_of_iomap()' to avoid a resource leak in case of error in 'imx_pinctrl_probe()'"Quoted 15 lines · Aisheng Dong
Could you help apply this patch as it blocked MX7D booting for a while?
Quoted 13 lines
This reverts commit
ba403242615c2c99e27af7984b1650771a2cc2c9.After commit
26d8cde5260b("pinctrl: freescale: imx: add shared input select reg support"). i.MX7D has two iomux controllers iomuxc and iomuxc-lpsr which shareselect_inputregister for daisy chain settings. If use 'devm_of_iomap()', when probe the iomuxc-lpsr, will calldevm_request_mem_region()for the region <0x30330000-0x3033ffff> for the first time. Then, next time when probe the iomuxc, APIdevm_platform_ioremap_resource()will also use the APIdevm_request_mem_region()for the share region <0x30330000-0x3033ffff> again, then cause issue, log like below:[ 0.179561] imx7d-pinctrl 302c0000.iomuxc-lpsr: initialized IMXpinctrl
Quoted 4 lines
Quoted 4 lines
driver
[ 0.191742] imx7d-pinctrl 30330000.pinctrl: can't request region for resource [mem 0x30330000-0x3033ffff] [ 0.191842] imx7d-pinctrl: probe of 30330000.pinctrl failed with error
Quoted 6 lines
-16
It means that shared support took a wrong approach. If something has shared resources, another schema should be used, something like MFD (parent device which keeps only shared resources). Easiest way is to switch to the regmap API.
Actually not MFD, it is the dts use wrong address region.
iomuxc_lpsr: iomuxc-lpsr@302c0000 {
compatible = "fsl,imx7d-iomuxc-lpsr";
reg = <0x302c0000 0x10000>;
fsl,input-sel = <&iomuxc>;
};
iomuxc: pinctrl@30330000 {
compatible = "fsl,imx7d-iomuxc";
reg = <0x30330000 0x10000>;
};There is overlap between the two.
The iomuxc_lpsr using 0x10000 as size is wrong. It not have such large area.
With the size fix, devm_of_ioremap could be used I think.
Regards,
Peng.
Quoted 6 lines
P.S. The revert is okay as a quick fix but... see above.--
With Best Regards,
Andy Shevchenko
Aisheng Dong
maintainerQuoted 49 lines
From: Peng Fan <[email protected]>
Sent: Wednesday, June 17, 2020 9:15 AMQuoted 13 lines
Subject: Re: [PATCH v2] Revert "pinctrl: freescale: imx: Use '
devm_of_iomap()' to avoid a resource leak in case of error in 'imx_pinctrl_probe()'"Quoted 7 lines · Aisheng Dong
Could you help apply this patch as it blocked MX7D booting for a while?
Quoted 5 lines
This reverts commit
ba403242615c2c99e27af7984b1650771a2cc2c9.After commit
26d8cde5260b("pinctrl: freescale: imx: add shared input select reg support"). i.MX7D has two iomux controllers iomuxc and iomuxc-lpsr which shareselect_inputregister for daisy chainsettings.
Quoted 13 lines
Quoted 8 lines
Quoted 8 lines
If use '
devm_of_iomap()', when probe the iomuxc-lpsr, will calldevm_request_mem_region()for the region <0x30330000-0x3033ffff> for the first time. Then, next time when probe the iomuxc, APIdevm_platform_ioremap_resource()will also use the APIdevm_request_mem_region()for the share region <0x30330000-0x3033ffff> again, then cause issue, log like below:[ 0.179561] imx7d-pinctrl 302c0000.iomuxc-lpsr: initialized IMXpinctrl
Quoted 4 lines
Quoted 4 lines
driver
[ 0.191742] imx7d-pinctrl 30330000.pinctrl: can't request region for resource [mem 0x30330000-0x3033ffff] [ 0.191842] imx7d-pinctrl: probe of 30330000.pinctrl failed with errorQuoted 6 lines
-16
It means that shared support took a wrong approach. If something has shared resources, another schema should be used, something like MFD (parent device which keeps only shared resources). Easiest way is to switch to the regmap API.
Actually not MFD, it is the dts use wrong address region.
iomuxc_lpsr: iomuxc-lpsr@302c0000 { compatible = "fsl,imx7d-iomuxc-lpsr"; reg = <0x302c0000 0x10000>; fsl,input-sel = <&iomuxc>; }; iomuxc: pinctrl@30330000 { compatible = "fsl,imx7d-iomuxc"; reg = <0x30330000 0x10000>; };
Quoted 6 lines
There is overlap between the two.
The
iomuxc_lpsrusing0x10000as size is wrong. It not have such large area.With the size fix,
devm_of_ioremapcould be used I think.
Really overlapped?
I think the real issue is LPSR Sel Input part using the same memory region as iomux.
Regards
Aisheng
Quoted 9 lines
Regards,
Peng.Quoted 6 lines
P.S. The revert is okay as a quick fix but... see above.--
With Best Regards,
Andy Shevchenko
Quoted 58 lines
Subject: RE: [PATCH v2] Revert "pinctrl: freescale: imx: Use '
devm_of_iomap()' to avoid a resource leak in case of error in 'imx_pinctrl_probe()'"Quoted 4 lines
From: Peng Fan <[email protected]>
Sent: Wednesday, June 17, 2020 9:15 AMQuoted 1 line
Subject: Re: [PATCH v2] Revert "pinctrl: freescale: imx: Use
'
devm_of_iomap()'Quoted 7 lines
Quoted 7 lines
to avoid a resource leak in case of error in '
imx_pinctrl_probe()'"Quoted 1 line · Aisheng Dong
Could you help apply this patch as it blocked MX7D booting for a while?
Quoted 18 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
This reverts commit
ba403242615c2c99e27af7984b1650771a2cc2c9.After commit
26d8cde5260b("pinctrl: freescale: imx: add shared input select reg support"). i.MX7D has two iomux controllers iomuxc and iomuxc-lpsr which shareselect_inputregister for daisy chainsettings.
Quoted 11 lines
Quoted 8 lines
Quoted 8 lines
If use '
devm_of_iomap()', when probe the iomuxc-lpsr, will calldevm_request_mem_region()for the region <0x30330000-0x3033ffff> for the first time. Then, next time when probe the iomuxc, APIdevm_platform_ioremap_resource()will also use the APIdevm_request_mem_region()for the share region <0x30330000-0x3033ffff> again, then cause issue, log like below:[ 0.179561] imx7d-pinctrl 302c0000.iomuxc-lpsr: initialized IMXpinctrl
Quoted 2 lines
Quoted 2 lines
driver
[ 0.191742] imx7d-pinctrl 30330000.pinctrl: can't request regionfor
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
resource [mem 0x30330000-0x3033ffff]
[ 0.191842] imx7d-pinctrl: probe of 30330000.pinctrl failed witherror
Quoted 11 lines
Quoted 6 lines
-16
It means that shared support took a wrong approach. If something has shared resources, another schema should be used, something like MFD (parent device which keeps only shared resources). Easiest way is to switch to the regmap API.
Actually not MFD, it is the dts use wrong address region.
iomuxc_lpsr: iomuxc-lpsr@302c0000 { compatible ="fsl,imx7d-iomuxc-lpsr";
Quoted 8 lines
reg = <0x302c0000 0x10000>; fsl,input-sel = <&iomuxc>; }; iomuxc: pinctrl@30330000 { compatible = "fsl,imx7d-iomuxc"; reg = <0x30330000 0x10000>; };
Quoted 8 lines
Quoted 6 lines
There is overlap between the two.
The
iomuxc_lpsrusing0x10000as size is wrong. It not have such large area.With the size fix,
devm_of_ioremapcould be used I think.Really overlapped?
Oops.
Quoted 3 lines
I think the real issue is LPSR Sel Input part using the same memory region as iomux.
Indeed. Then mfd might be better to be used here.
Regards,
Peng.
Quoted 13 lines
Regards
AishengQuoted 9 lines
Regards,
Peng.Quoted 6 lines
P.S. The revert is okay as a quick fix but... see above.--
With Best Regards,
Andy Shevchenko
Aisheng Dong
maintainerQuoted 25 lines
From: Andy Shevchenko <[email protected]>
Sent: Wednesday, June 17, 2020 2:16 AMQuoted 19 lines · Aisheng Dong
Could you help apply this patch as it blocked MX7D booting for a while?
Quoted 17 lines
This reverts commit
ba403242615c2c99e27af7984b1650771a2cc2c9.After commit
26d8cde5260b("pinctrl: freescale: imx: add shared input select reg support"). i.MX7D has two iomux controllers iomuxc and iomuxc-lpsr which shareselect_inputregister for daisy chain settings. If use 'devm_of_iomap()', when probe the iomuxc-lpsr, will calldevm_request_mem_region()for the region <0x30330000-0x3033ffff> for the first time. Then, next time when probe the iomuxc, APIdevm_platform_ioremap_resource()will also use the APIdevm_request_mem_region()for the share region <0x30330000-0x3033ffff> again, then cause issue, log like below:[ 0.179561] imx7d-pinctrl 302c0000.iomuxc-lpsr: initialized IMX pinctrl driver [ 0.191742] imx7d-pinctrl 30330000.pinctrl: can't request region for resource [mem 0x30330000-0x3033ffff] [ 0.191842] imx7d-pinctrl: probe of 30330000.pinctrl failed with error
Quoted 6 lines
-16
It means that shared support took a wrong approach. If something has shared resources, another schema should be used, something like MFD (parent device which keeps only shared resources). Easiest way is to switch to the regmap API.
I think a bit more, probably it's not worth to do it in order to not break current driver design a lot. LPSR iomux case is bit complicated that only sel input is using the shared memory within another iomuxc. Current approach seems already the easiest and most clean way.
Regards
Aisheng
Quoted 5 lines
P.S. The revert is okay as a quick fix but... see above.--
With Best Regards,
Andy Shevchenko
Quoted 15 lines · On Tue, Jun 9, 2020 at 5:38 AM <[email protected]> wrote:
From: Haibo Chen <[email protected]>
This reverts commit
ba403242615c2c99e27af7984b1650771a2cc2c9.After commit
26d8cde5260b("pinctrl: freescale: imx: add shared input select reg support"). i.MX7D has two iomux controllers iomuxc and iomuxc-lpsr which shareselect_inputregister for daisy chain settings.
If use 'devm_of_iomap()', when probe the iomuxc-lpsr, will calldevm_request_mem_region()for the region <0x30330000-0x3033ffff> for the first time. Then, next time when probe the iomuxc, APIdevm_platform_ioremap_resource()will also use the APIdevm_request_mem_region()for the share region <0x30330000-0x3033ffff> again, then cause issue, log like below:
Quoted 7 lines
[ 0.179561] imx7d-pinctrl 302c0000.iomuxc-lpsr: initialized IMX pinctrl driver [ 0.191742] imx7d-pinctrl 30330000.pinctrl: can't request region for resource [mem 0x30330000-0x3033ffff] [ 0.191842] imx7d-pinctrl: probe of 30330000.pinctrl failed with error -16Fixes ba403242615c ("pinctrl: freescale: imx: Use 'devm_of_iomap()' to avoid a resource leak in case of error in 'imx_pinctrl_probe()'")Signed-off-by Haibo Chen <[email protected]>Reviewed-by Dong Aisheng <[email protected]>
Patch applied for fixes.
Yours,
Linus Walleij