linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: imx8qxp-lpcg: Warn against devm_platform_ioremap_resource
@ 2019-12-09 20:56 Leonard Crestez
  2019-12-10  6:07 ` Peng Fan
  2019-12-11  8:06 ` Shawn Guo
  0 siblings, 2 replies; 3+ messages in thread
From: Leonard Crestez @ 2019-12-09 20:56 UTC (permalink / raw)
  To: Stephen Boyd, Shawn Guo, Dong Aisheng
  Cc: Peng Fan, Michael Turquette, Yangtao Li, Anson Huang,
	Fabio Estevam, Rob Herring, Mark Rutland, linux-clk, kernel,
	linux-imx

On imx8 the LPCG nodes map entire subsystems and overlap peripherals,
this means that using devm_platform_ioremap_resource will cause many
devices to fail to probe including serial ports.

Well-meaning but boot-breaking patches were posted multiple times so add
a comment explaining this issue.

Suggested-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
---
 drivers/clk/imx/clk-imx8qxp-lpcg.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/clk/imx/clk-imx8qxp-lpcg.c b/drivers/clk/imx/clk-imx8qxp-lpcg.c
index c0aff7ca6374..04c8ee35e14c 100644
--- a/drivers/clk/imx/clk-imx8qxp-lpcg.c
+++ b/drivers/clk/imx/clk-imx8qxp-lpcg.c
@@ -171,10 +171,21 @@ static int imx8qxp_lpcg_clk_probe(struct platform_device *pdev)
 
 	ss_lpcg = of_device_get_match_data(dev);
 	if (!ss_lpcg)
 		return -ENODEV;
 
+	/*
+	 * Please don't replace this with devm_platform_ioremap_resource.
+	 *
+	 * devm_platform_ioremap_resource calls devm_ioremap_resource which
+	 * differs from devm_ioremap by also calling devm_request_mem_region
+	 * and preventing other mappings in the same area.
+	 *
+	 * On imx8 the LPCG nodes map entire subsystems and overlap
+	 * peripherals, this means that using devm_platform_ioremap_resource
+	 * will cause many devices to fail to probe including serial ports.
+	 */
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res)
 		return -EINVAL;
 	base = devm_ioremap(dev, res->start, resource_size(res));
 	if (!base)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH] clk: imx8qxp-lpcg: Warn against devm_platform_ioremap_resource
  2019-12-09 20:56 [PATCH] clk: imx8qxp-lpcg: Warn against devm_platform_ioremap_resource Leonard Crestez
@ 2019-12-10  6:07 ` Peng Fan
  2019-12-11  8:06 ` Shawn Guo
  1 sibling, 0 replies; 3+ messages in thread
From: Peng Fan @ 2019-12-10  6:07 UTC (permalink / raw)
  To: Leonard Crestez, Stephen Boyd, Shawn Guo, Aisheng Dong
  Cc: Michael Turquette, Yangtao Li, Anson Huang, Fabio Estevam,
	Rob Herring, Mark Rutland, linux-clk, kernel, dl-linux-imx

> Subject: [PATCH] clk: imx8qxp-lpcg: Warn against
> devm_platform_ioremap_resource
> 
> On imx8 the LPCG nodes map entire subsystems and overlap peripherals, this
> means that using devm_platform_ioremap_resource will cause many devices
> to fail to probe including serial ports.
> 
> Well-meaning but boot-breaking patches were posted multiple times so add a
> comment explaining this issue.
> 
> Suggested-by: Peng Fan <peng.fan@nxp.com>
> Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>

Reviewed-by: Peng Fan <peng.fan@nxp.com>

> ---
>  drivers/clk/imx/clk-imx8qxp-lpcg.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/clk/imx/clk-imx8qxp-lpcg.c
> b/drivers/clk/imx/clk-imx8qxp-lpcg.c
> index c0aff7ca6374..04c8ee35e14c 100644
> --- a/drivers/clk/imx/clk-imx8qxp-lpcg.c
> +++ b/drivers/clk/imx/clk-imx8qxp-lpcg.c
> @@ -171,10 +171,21 @@ static int imx8qxp_lpcg_clk_probe(struct
> platform_device *pdev)
> 
>  	ss_lpcg = of_device_get_match_data(dev);
>  	if (!ss_lpcg)
>  		return -ENODEV;
> 
> +	/*
> +	 * Please don't replace this with devm_platform_ioremap_resource.
> +	 *
> +	 * devm_platform_ioremap_resource calls devm_ioremap_resource
> which
> +	 * differs from devm_ioremap by also calling
> devm_request_mem_region
> +	 * and preventing other mappings in the same area.
> +	 *
> +	 * On imx8 the LPCG nodes map entire subsystems and overlap
> +	 * peripherals, this means that using devm_platform_ioremap_resource
> +	 * will cause many devices to fail to probe including serial ports.
> +	 */
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	if (!res)
>  		return -EINVAL;
>  	base = devm_ioremap(dev, res->start, resource_size(res));
>  	if (!base)
> --
> 2.17.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] clk: imx8qxp-lpcg: Warn against devm_platform_ioremap_resource
  2019-12-09 20:56 [PATCH] clk: imx8qxp-lpcg: Warn against devm_platform_ioremap_resource Leonard Crestez
  2019-12-10  6:07 ` Peng Fan
@ 2019-12-11  8:06 ` Shawn Guo
  1 sibling, 0 replies; 3+ messages in thread
From: Shawn Guo @ 2019-12-11  8:06 UTC (permalink / raw)
  To: Leonard Crestez
  Cc: Stephen Boyd, Dong Aisheng, Peng Fan, Michael Turquette,
	Yangtao Li, Anson Huang, Fabio Estevam, Rob Herring,
	Mark Rutland, linux-clk, kernel, linux-imx

On Mon, Dec 09, 2019 at 10:56:28PM +0200, Leonard Crestez wrote:
> On imx8 the LPCG nodes map entire subsystems and overlap peripherals,
> this means that using devm_platform_ioremap_resource will cause many
> devices to fail to probe including serial ports.
> 
> Well-meaning but boot-breaking patches were posted multiple times so add
> a comment explaining this issue.
> 
> Suggested-by: Peng Fan <peng.fan@nxp.com>
> Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-12-11  8:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-09 20:56 [PATCH] clk: imx8qxp-lpcg: Warn against devm_platform_ioremap_resource Leonard Crestez
2019-12-10  6:07 ` Peng Fan
2019-12-11  8:06 ` 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).