* [PATCH v2 0/2] clk: eyeq: Reserve OLB memory regions
@ 2026-09-14 12:16 Benoît Monin
2026-09-14 12:16 ` [PATCH v2 1/2] clk: eyeq: Use devm_platform_ioremap_resource() Benoît Monin
2026-09-14 12:16 ` [PATCH v2 2/2] clk: eyeq: Add mobileye,eyeq6h-central-olb compatible Benoît Monin
0 siblings, 2 replies; 5+ messages in thread
From: Benoît Monin @ 2026-09-14 12:16 UTC (permalink / raw)
To: Vladimir Kondratiev, Gregory CLEMENT, Théo Lebrun,
Stephen Boyd, Brian Masney, Jerome Brunet
Cc: Benoît Monin, Thomas Petazzoni, Tawfik Bayouk, linux-mips,
linux-clk, linux-kernel
The Other Logic Blocks of Mobileye SoCs are clock providers, and some of
them are registered early with CLK_OF_DECLARE_DRIVER(). Their early init
maps the registers with of_iomap(), which does not request the memory
region. On the platform device side, eqc_probe() used a plain ioremap()
too, so none of the OLB regions were reserved in the iomem_resource
tree.
Patch 1 converts eqc_probe() to devm_platform_ioremap_resource(): the
region gets requested and the mapping is released by the devres
machinery on unbind. The mapping is moved before the match data check so
that OLBs bound without match data also get mapped and reserved.
Patch 2 adds a match table entry for mobileye,eyeq6h-central-olb without
match data. All of its clocks are registered by the early init and it
has no auxiliary devices; bind it to get its region reserved.
No functional change, besides the region reservation.
Signed-off-by: Benoît Monin <benoit.monin@bootlin.com>
---
Changes in v2:
- Fix early return comment in eqc_probe() (Thanks Théo for the review)
- Split the patch in two (Thanks Brian for the review)
- Link to v1: https://patch.msgid.link/20260911-clk-eyeq-res-v1-1-39b04542db38@bootlin.com
To: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
To: Gregory CLEMENT <gregory.clement@bootlin.com>
To: Théo Lebrun <theo.lebrun@bootlin.com>
To: Stephen Boyd <sboyd@kernel.org>
To: Brian Masney <bmasney+clk@redhat.com>
To: Jerome Brunet <jbrunet+clk@baylibre.com>
To: Benoît Monin <benoit.monin@bootlin.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Tawfik Bayouk <tawfik.bayouk@mobileye.com>
Cc: linux-mips@vger.kernel.org
Cc: linux-clk@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
Benoît Monin (2):
clk: eyeq: Use devm_platform_ioremap_resource()
clk: eyeq: Add mobileye,eyeq6h-central-olb compatible
drivers/clk/clk-eyeq.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
---
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
change-id: 20260910-clk-eyeq-res-ddbf87fc4fd4
Best regards,
--
Benoît Monin, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] clk: eyeq: Use devm_platform_ioremap_resource()
2026-09-14 12:16 [PATCH v2 0/2] clk: eyeq: Reserve OLB memory regions Benoît Monin
@ 2026-09-14 12:16 ` Benoît Monin
2026-09-14 12:30 ` sashiko-bot
2026-09-14 16:57 ` Brian Masney
2026-09-14 12:16 ` [PATCH v2 2/2] clk: eyeq: Add mobileye,eyeq6h-central-olb compatible Benoît Monin
1 sibling, 2 replies; 5+ messages in thread
From: Benoît Monin @ 2026-09-14 12:16 UTC (permalink / raw)
To: Vladimir Kondratiev, Gregory CLEMENT, Théo Lebrun,
Stephen Boyd, Brian Masney, Jerome Brunet
Cc: Benoît Monin, Thomas Petazzoni, Tawfik Bayouk, linux-mips,
linux-clk, linux-kernel
Convert eqc_probe() from the open-coded platform_get_resource() +
ioremap() sequence to devm_platform_ioremap_resource(). Besides less
code, this requests the memory region so the OLB registers are properly
reserved in the iomem_resource tree.
Move devm_platform_ioremap_resource() before checking for device match
data, so OLBs bound without match data also get their memory region
mapped and reserved.
Suggested-by: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
Signed-off-by: Benoît Monin <benoit.monin@bootlin.com>
---
drivers/clk/clk-eyeq.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/drivers/clk/clk-eyeq.c b/drivers/clk/clk-eyeq.c
index cf37feccc734..3662e6990bf7 100644
--- a/drivers/clk/clk-eyeq.c
+++ b/drivers/clk/clk-eyeq.c
@@ -513,21 +513,16 @@ static int eqc_probe(struct platform_device *pdev)
const struct eqc_match_data *data;
struct clk_hw_onecell_data *cells;
unsigned int i, clk_count;
- struct resource *res;
void __iomem *base;
int ret;
+ base = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(base))
+ return PTR_ERR(base);
+
data = device_get_match_data(dev);
if (!data)
- return 0; /* No clocks nor auxdevs, we are done. */
-
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res)
- return -ENODEV;
-
- base = ioremap(res->start, resource_size(res));
- if (!base)
- return -ENOMEM;
+ return 0; /* No clocks nor auxdevs, stop here but keep resource reserved */
/* Init optional auxiliary devices. */
eqc_auxdev_create_optional(dev, base, data->reset_auxdev_name);
--
2.55.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] clk: eyeq: Add mobileye,eyeq6h-central-olb compatible
2026-09-14 12:16 [PATCH v2 0/2] clk: eyeq: Reserve OLB memory regions Benoît Monin
2026-09-14 12:16 ` [PATCH v2 1/2] clk: eyeq: Use devm_platform_ioremap_resource() Benoît Monin
@ 2026-09-14 12:16 ` Benoît Monin
1 sibling, 0 replies; 5+ messages in thread
From: Benoît Monin @ 2026-09-14 12:16 UTC (permalink / raw)
To: Vladimir Kondratiev, Gregory CLEMENT, Théo Lebrun,
Stephen Boyd, Brian Masney, Jerome Brunet
Cc: Benoît Monin, Thomas Petazzoni, Tawfik Bayouk, linux-mips,
linux-clk, linux-kernel
Add an entry for mobileye,eyeq6h-central-olb without match data: its
clocks are all registered by the early init and it has no auxiliary
devices, so probe() now reserves its region and stops there.
Signed-off-by: Benoît Monin <benoit.monin@bootlin.com>
---
drivers/clk/clk-eyeq.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/clk/clk-eyeq.c b/drivers/clk/clk-eyeq.c
index 3662e6990bf7..b32f251614c7 100644
--- a/drivers/clk/clk-eyeq.c
+++ b/drivers/clk/clk-eyeq.c
@@ -1170,6 +1170,7 @@ static const struct of_device_id eqc_match_table[] = {
{ .compatible = "mobileye,eyeq5-olb", .data = &eqc_eyeq5_match_data },
{ .compatible = "mobileye,eyeq6l-olb", .data = &eqc_eyeq6l_match_data },
{ .compatible = "mobileye,eyeq6lplus-olb", .data = &eqc_eyeq6lplus_match_data },
+ { .compatible = "mobileye,eyeq6h-central-olb" /* no data, early only */ },
{ .compatible = "mobileye,eyeq6h-west-olb", .data = &eqc_eyeq6h_west_match_data },
{ .compatible = "mobileye,eyeq6h-east-olb", .data = &eqc_eyeq6h_east_match_data },
{ .compatible = "mobileye,eyeq6h-south-olb", .data = &eqc_eyeq6h_south_match_data },
--
2.55.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] clk: eyeq: Use devm_platform_ioremap_resource()
2026-09-14 12:16 ` [PATCH v2 1/2] clk: eyeq: Use devm_platform_ioremap_resource() Benoît Monin
@ 2026-09-14 12:30 ` sashiko-bot
2026-09-14 16:57 ` Brian Masney
1 sibling, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-09-14 12:30 UTC (permalink / raw)
To: Benoît Monin; +Cc: linux-clk
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Switching to devm_platform_ioremap_resource causes the MMIO region to be unmapped on probe failure, leaving dangling pointers in registered clocks.
--
commit d16beda6863fd4b206a647746c109b76b72334fa
Author: Benoît Monin <benoit.monin@bootlin.com>
clk: eyeq: Use devm_platform_ioremap_resource()
Convert eqc_probe() from the open-coded platform_get_resource() +
ioremap() sequence to devm_platform_ioremap_resource(). Besides less
code, this requests the memory region so the OLB registers are properly
reserved in the iomem_resource tree.
Move devm_platform_ioremap_resource() before checking for device match
data, so OLBs bound without match data also get their memory region
mapped and reserved.
> diff --git a/drivers/clk/clk-eyeq.c b/drivers/clk/clk-eyeq.c
> index cf37feccc734f..3662e6990bf7f 100644
> --- a/drivers/clk/clk-eyeq.c
> +++ b/drivers/clk/clk-eyeq.c
> @@ -513,21 +513,16 @@ static int eqc_probe(struct platform_device *pdev)
> const struct eqc_match_data *data;
> struct clk_hw_onecell_data *cells;
> unsigned int i, clk_count;
> - struct resource *res;
> void __iomem *base;
> int ret;
>
> + base = devm_platform_ioremap_resource(pdev, 0);
> + if (IS_ERR(base))
> + return PTR_ERR(base);
> +
[Severity: High]
Does this change introduce a regression if of_clk_add_hw_provider() fails
later in eqc_probe()?
If the provider registration fails, the probe function aborts and triggers
devres cleanup, which unmaps this base memory region.
However, the clocks are registered earlier in eqc_probe() using non-devm
functions:
drivers/clk/clk-eyeq.c:eqc_probe() {
...
for (i = 0; i < data->clk_count; i++) {
...
ret = clk->probe(dev, NULL, clk, base, cells);
...
}
return of_clk_add_hw_provider(np, of_clk_hw_onecell_get, cells);
}
drivers/clk/clk-eyeq.c:eqc_probe_divider() {
...
hw = clk_hw_register_divider_table_parent_data(dev, ...,
base + clk->div.reg, ...);
...
}
Because the clocks are registered with non-devm functions, they remain in
the clock framework on probe failure. Since base is now managed by devres,
the clock framework will hold dangling pointers to the unmapped base memory.
Prior to this change, the manual ioremap() was not unmapped on failure,
which avoided a use-after-free.
Would it be safer to convert the clock registrations to their devm
equivalents, or explicitly unregister them on probe failure to prevent
these dangling pointers?
> data = device_get_match_data(dev);
> if (!data)
> - return 0; /* No clocks nor auxdevs, we are done. */
> -
> - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - if (!res)
> - return -ENODEV;
> -
> - base = ioremap(res->start, resource_size(res));
> - if (!base)
> - return -ENOMEM;
> + return 0; /* No clocks nor auxdevs, stop here but keep resource reserved */
>
> /* Init optional auxiliary devices. */
> eqc_auxdev_create_optional(dev, base, data->reset_auxdev_name);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260914-clk-eyeq-res-v2-0-687e5de3aba7@bootlin.com?part=1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] clk: eyeq: Use devm_platform_ioremap_resource()
2026-09-14 12:16 ` [PATCH v2 1/2] clk: eyeq: Use devm_platform_ioremap_resource() Benoît Monin
2026-09-14 12:30 ` sashiko-bot
@ 2026-09-14 16:57 ` Brian Masney
1 sibling, 0 replies; 5+ messages in thread
From: Brian Masney @ 2026-09-14 16:57 UTC (permalink / raw)
To: Benoît Monin
Cc: Vladimir Kondratiev, Gregory CLEMENT, Théo Lebrun,
Stephen Boyd, Brian Masney, Jerome Brunet, Thomas Petazzoni,
Tawfik Bayouk, linux-mips, linux-clk, linux-kernel
Hi Benoît,
On Mon, Sep 14, 2026 at 02:16:44PM +0200, Benoît Monin wrote:
> Convert eqc_probe() from the open-coded platform_get_resource() +
> ioremap() sequence to devm_platform_ioremap_resource(). Besides less
> code, this requests the memory region so the OLB registers are properly
> reserved in the iomem_resource tree.
>
> Move devm_platform_ioremap_resource() before checking for device match
> data, so OLBs bound without match data also get their memory region
> mapped and reserved.
>
> Suggested-by: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
> Signed-off-by: Benoît Monin <benoit.monin@bootlin.com>
> ---
> drivers/clk/clk-eyeq.c | 15 +++++----------
> 1 file changed, 5 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/clk/clk-eyeq.c b/drivers/clk/clk-eyeq.c
> index cf37feccc734..3662e6990bf7 100644
> --- a/drivers/clk/clk-eyeq.c
> +++ b/drivers/clk/clk-eyeq.c
> @@ -513,21 +513,16 @@ static int eqc_probe(struct platform_device *pdev)
> const struct eqc_match_data *data;
> struct clk_hw_onecell_data *cells;
> unsigned int i, clk_count;
> - struct resource *res;
> void __iomem *base;
> int ret;
>
> + base = devm_platform_ioremap_resource(pdev, 0);
> + if (IS_ERR(base))
> + return PTR_ERR(base);
> +
As Sashiko pointed out, it would probably make sense to just convert the
rest of the driver over to use the devm_ variants where available (like
of_clk_add_hw_provider).
Brian
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-09-14 16:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-14 12:16 [PATCH v2 0/2] clk: eyeq: Reserve OLB memory regions Benoît Monin
2026-09-14 12:16 ` [PATCH v2 1/2] clk: eyeq: Use devm_platform_ioremap_resource() Benoît Monin
2026-09-14 12:30 ` sashiko-bot
2026-09-14 16:57 ` Brian Masney
2026-09-14 12:16 ` [PATCH v2 2/2] clk: eyeq: Add mobileye,eyeq6h-central-olb compatible Benoît Monin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.