* [PATCH 0/3] fbdev: Request memory regions in platform drivers
@ 2026-04-20 13:44 Amit Barzilai
2026-04-20 13:44 ` [PATCH 1/3] fbdev: cobalt_lcdfb: Request memory region Amit Barzilai
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Amit Barzilai @ 2026-04-20 13:44 UTC (permalink / raw)
To: deller; +Cc: thomas.zimmermann, linux-fbdev, dri-devel, Amit Barzilai
Several fbdev platform drivers call ioremap() on their hardware MMIO
without first claiming the range via request_mem_region(). This leaves
the kernel resource tree (/proc/iomem) with no record of the mapping,
allowing another driver to silently map the same registers.
This series fixes three platform_device drivers by switching to helpers
that combine resource claiming and ioremap in a single managed call.
cobalt_lcdfb and clps711x-fb are converted to
devm_platform_get_and_ioremap_resource(); goldfishfb is converted to
devm_ioremap_resource(), which also lets us drop the manual iounmap()
calls from the error path and remove function.
For clps711x-fb, resource 1 (the framebuffer range) already used
devm_platform_get_and_ioremap_resource() correctly; this series makes
resource 0 (the MMIO control registers) consistent with it.
This is part of the ongoing effort described in
Documentation/drm/todo.rst ("Request memory regions in all fbdev
drivers").
Amit Barzilai (3):
fbdev: cobalt_lcdfb: Request memory region
fbdev: clps711x-fb: Request memory region for MMIO
fbdev: goldfishfb: Request memory region
drivers/video/fbdev/clps711x-fb.c | 9 +++------
drivers/video/fbdev/cobalt_lcdfb.c | 12 +++---------
drivers/video/fbdev/goldfishfb.c | 8 +++-----
3 files changed, 9 insertions(+), 20 deletions(-)
base-commit: 3f9357c30a44734d45e3093c521d52b2aefb09f5
--
2.53.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/3] fbdev: cobalt_lcdfb: Request memory region
2026-04-20 13:44 [PATCH 0/3] fbdev: Request memory regions in platform drivers Amit Barzilai
@ 2026-04-20 13:44 ` Amit Barzilai
2026-04-22 14:50 ` Helge Deller
2026-04-22 23:34 ` Claude review: " Claude Code Review Bot
2026-04-20 13:44 ` [PATCH 2/3] fbdev: clps711x-fb: Request memory region for MMIO Amit Barzilai
` (2 subsequent siblings)
3 siblings, 2 replies; 10+ messages in thread
From: Amit Barzilai @ 2026-04-20 13:44 UTC (permalink / raw)
To: deller; +Cc: thomas.zimmermann, linux-fbdev, dri-devel, Amit Barzilai
Use devm_platform_get_and_ioremap_resource() instead of open-coding
platform_get_resource() and devm_ioremap() separately. The helper
requests the memory region before mapping it, which registers the range
in /proc/iomem and prevents another driver from mapping the same
registers.
Assisted-by: Claude:claude-sonnet-4-6
---
drivers/video/fbdev/cobalt_lcdfb.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/video/fbdev/cobalt_lcdfb.c b/drivers/video/fbdev/cobalt_lcdfb.c
index 308967b5096a..f7faa95fefd3 100644
--- a/drivers/video/fbdev/cobalt_lcdfb.c
+++ b/drivers/video/fbdev/cobalt_lcdfb.c
@@ -295,19 +295,13 @@ static int cobalt_lcdfb_probe(struct platform_device *dev)
if (!info)
return -ENOMEM;
- res = platform_get_resource(dev, IORESOURCE_MEM, 0);
- if (!res) {
+ info->screen_base = devm_platform_get_and_ioremap_resource(dev, 0, &res);
+ if (IS_ERR(info->screen_base)) {
framebuffer_release(info);
- return -EBUSY;
+ return PTR_ERR(info->screen_base);
}
info->screen_size = resource_size(res);
- info->screen_base = devm_ioremap(&dev->dev, res->start,
- info->screen_size);
- if (!info->screen_base) {
- framebuffer_release(info);
- return -ENOMEM;
- }
info->fbops = &cobalt_lcd_fbops;
info->fix = cobalt_lcdfb_fix;
--
2.53.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/3] fbdev: clps711x-fb: Request memory region for MMIO
2026-04-20 13:44 [PATCH 0/3] fbdev: Request memory regions in platform drivers Amit Barzilai
2026-04-20 13:44 ` [PATCH 1/3] fbdev: cobalt_lcdfb: Request memory region Amit Barzilai
@ 2026-04-20 13:44 ` Amit Barzilai
2026-04-22 23:34 ` Claude review: " Claude Code Review Bot
2026-04-20 13:44 ` [PATCH 3/3] fbdev: goldfishfb: Request memory region Amit Barzilai
2026-04-22 23:34 ` Claude review: fbdev: Request memory regions in platform drivers Claude Code Review Bot
3 siblings, 1 reply; 10+ messages in thread
From: Amit Barzilai @ 2026-04-20 13:44 UTC (permalink / raw)
To: deller; +Cc: thomas.zimmermann, linux-fbdev, dri-devel, Amit Barzilai
Use devm_platform_get_and_ioremap_resource() for resource 0 (the MMIO
control register range) instead of open-coding platform_get_resource()
and devm_ioremap() separately. The helper requests the memory region
before mapping it, which registers the range in /proc/iomem and prevents
another driver from mapping the same registers.
This makes resource 0 consistent with resource 1 (the framebuffer),
which already uses devm_platform_get_and_ioremap_resource().
Assisted-by: Claude:claude-sonnet-4-6
---
drivers/video/fbdev/clps711x-fb.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/video/fbdev/clps711x-fb.c b/drivers/video/fbdev/clps711x-fb.c
index 5e61a349a4ab..7a7db7100499 100644
--- a/drivers/video/fbdev/clps711x-fb.c
+++ b/drivers/video/fbdev/clps711x-fb.c
@@ -216,12 +216,9 @@ static int clps711x_fb_probe(struct platform_device *pdev)
cfb = info->par;
platform_set_drvdata(pdev, info);
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res)
- goto out_fb_release;
- cfb->base = devm_ioremap(dev, res->start, resource_size(res));
- if (!cfb->base) {
- ret = -ENOMEM;
+ cfb->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
+ if (IS_ERR(cfb->base)) {
+ ret = PTR_ERR(cfb->base);
goto out_fb_release;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/3] fbdev: goldfishfb: Request memory region
2026-04-20 13:44 [PATCH 0/3] fbdev: Request memory regions in platform drivers Amit Barzilai
2026-04-20 13:44 ` [PATCH 1/3] fbdev: cobalt_lcdfb: Request memory region Amit Barzilai
2026-04-20 13:44 ` [PATCH 2/3] fbdev: clps711x-fb: Request memory region for MMIO Amit Barzilai
@ 2026-04-20 13:44 ` Amit Barzilai
2026-04-22 14:43 ` Helge Deller
2026-04-22 23:34 ` Claude review: " Claude Code Review Bot
2026-04-22 23:34 ` Claude review: fbdev: Request memory regions in platform drivers Claude Code Review Bot
3 siblings, 2 replies; 10+ messages in thread
From: Amit Barzilai @ 2026-04-20 13:44 UTC (permalink / raw)
To: deller; +Cc: thomas.zimmermann, linux-fbdev, dri-devel, Amit Barzilai
Use devm_ioremap_resource() instead of plain ioremap(). The helper
requests the memory region before mapping it, which registers the range
in /proc/iomem and prevents another driver from mapping the same
registers. As it is device-managed, remove the corresponding iounmap()
calls from the error unwind path and the remove function.
Assisted-by: Claude:claude-sonnet-4-6
---
drivers/video/fbdev/goldfishfb.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/video/fbdev/goldfishfb.c b/drivers/video/fbdev/goldfishfb.c
index ffe33a36b944..14a7cb0a7a1c 100644
--- a/drivers/video/fbdev/goldfishfb.c
+++ b/drivers/video/fbdev/goldfishfb.c
@@ -194,9 +194,9 @@ static int goldfish_fb_probe(struct platform_device *pdev)
ret = -ENODEV;
goto err_no_io_base;
}
- fb->reg_base = ioremap(r->start, PAGE_SIZE);
- if (fb->reg_base == NULL) {
- ret = -ENOMEM;
+ fb->reg_base = devm_ioremap_resource(&pdev->dev, r);
+ if (IS_ERR(fb->reg_base)) {
+ ret = PTR_ERR(fb->reg_base);
goto err_no_io_base;
}
@@ -273,7 +273,6 @@ static int goldfish_fb_probe(struct platform_device *pdev)
fb->fb.fix.smem_start);
err_alloc_screen_base_failed:
err_no_irq:
- iounmap(fb->reg_base);
err_no_io_base:
kfree(fb);
err_fb_alloc_failed:
@@ -291,7 +290,6 @@ static void goldfish_fb_remove(struct platform_device *pdev)
dma_free_coherent(&pdev->dev, framesize, (void *)fb->fb.screen_base,
fb->fb.fix.smem_start);
- iounmap(fb->reg_base);
kfree(fb);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] fbdev: goldfishfb: Request memory region
2026-04-20 13:44 ` [PATCH 3/3] fbdev: goldfishfb: Request memory region Amit Barzilai
@ 2026-04-22 14:43 ` Helge Deller
2026-04-22 23:34 ` Claude review: " Claude Code Review Bot
1 sibling, 0 replies; 10+ messages in thread
From: Helge Deller @ 2026-04-22 14:43 UTC (permalink / raw)
To: Amit Barzilai; +Cc: thomas.zimmermann, linux-fbdev, dri-devel
On 4/20/26 15:44, Amit Barzilai wrote:
> Use devm_ioremap_resource() instead of plain ioremap(). The helper
> requests the memory region before mapping it, which registers the range
> in /proc/iomem and prevents another driver from mapping the same
> registers. As it is device-managed, remove the corresponding iounmap()
> calls from the error unwind path and the remove function.
>
> Assisted-by: Claude:claude-sonnet-4-6
> ---
> drivers/video/fbdev/goldfishfb.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
It was alreads fixed by another patch upstream...
Helge
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/3] fbdev: cobalt_lcdfb: Request memory region
2026-04-20 13:44 ` [PATCH 1/3] fbdev: cobalt_lcdfb: Request memory region Amit Barzilai
@ 2026-04-22 14:50 ` Helge Deller
2026-04-22 23:34 ` Claude review: " Claude Code Review Bot
1 sibling, 0 replies; 10+ messages in thread
From: Helge Deller @ 2026-04-22 14:50 UTC (permalink / raw)
To: Amit Barzilai; +Cc: thomas.zimmermann, linux-fbdev, dri-devel
Hi Amit,
On 4/20/26 15:44, Amit Barzilai wrote:
> Use devm_platform_get_and_ioremap_resource() instead of open-coding
> platform_get_resource() and devm_ioremap() separately. The helper
> requests the memory region before mapping it, which registers the range
> in /proc/iomem and prevents another driver from mapping the same
> registers.
>
> Assisted-by: Claude:claude-sonnet-4-6
You missed your signed-off line, which I added while applying patches #1 and #2:
Signed-off-by: Amit Barzilai <amit.barzilai22@gmail.com>
Amit, please confirm that you wrote patches #2 and #3 and that you
are OK with the added Signed-off-by line, otherwise I need to drop the patches.
Helge
> ---
> drivers/video/fbdev/cobalt_lcdfb.c | 12 +++---------
> 1 file changed, 3 insertions(+), 9 deletions(-)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Claude review: fbdev: Request memory regions in platform drivers
2026-04-20 13:44 [PATCH 0/3] fbdev: Request memory regions in platform drivers Amit Barzilai
` (2 preceding siblings ...)
2026-04-20 13:44 ` [PATCH 3/3] fbdev: goldfishfb: Request memory region Amit Barzilai
@ 2026-04-22 23:34 ` Claude Code Review Bot
3 siblings, 0 replies; 10+ messages in thread
From: Claude Code Review Bot @ 2026-04-22 23:34 UTC (permalink / raw)
To: dri-devel-reviews
Overall Series Review
Subject: fbdev: Request memory regions in platform drivers
Author: Amit Barzilai <amit.barzilai22@gmail.com>
Patches: 6
Reviewed: 2026-04-23T09:34:40.480748
---
This is a clean, well-motivated 3-patch series converting three fbdev platform drivers to use managed ioremap helpers that also claim the memory region via `request_mem_region()`. The work addresses a documented TODO item in `Documentation/drm/todo.rst`. Each patch is small, self-contained, and mechanically correct. The commit messages are clear and explain the "why" well.
One process note: all three patches carry `Assisted-by: Claude:claude-sonnet-4-6`. The kernel community hasn't settled on a standard trailer format for AI assistance, and this format (`Name:model-id`) doesn't follow the standard trailer convention of `Tag: Name <email>`. The author should check current mailing list guidance on the preferred format.
No functional bugs found. One minor behavioral observation on patch 3 noted below.
---
Generated by Claude Code Patch Reviewer
^ permalink raw reply [flat|nested] 10+ messages in thread
* Claude review: fbdev: cobalt_lcdfb: Request memory region
2026-04-20 13:44 ` [PATCH 1/3] fbdev: cobalt_lcdfb: Request memory region Amit Barzilai
2026-04-22 14:50 ` Helge Deller
@ 2026-04-22 23:34 ` Claude Code Review Bot
1 sibling, 0 replies; 10+ messages in thread
From: Claude Code Review Bot @ 2026-04-22 23:34 UTC (permalink / raw)
To: dri-devel-reviews
Patch Review
**Status: Good**
Replaces separate `platform_get_resource()` + `devm_ioremap()` with a single `devm_platform_get_and_ioremap_resource()` call. The conversion is correct:
```c
info->screen_base = devm_platform_get_and_ioremap_resource(dev, 0, &res);
if (IS_ERR(info->screen_base)) {
framebuffer_release(info);
return PTR_ERR(info->screen_base);
}
```
The `res` output parameter is correctly used on the following line (`info->screen_size = resource_size(res)`), and the reordering (screen_base assigned before screen_size) is fine since `screen_size` is not needed for the mapping itself.
The original code returned `-EBUSY` when the resource wasn't found, which was arguably the wrong error code. The new code will return the actual error from the helper (likely `-EINVAL`), which is a minor improvement.
No issues.
---
Generated by Claude Code Patch Reviewer
^ permalink raw reply [flat|nested] 10+ messages in thread
* Claude review: fbdev: clps711x-fb: Request memory region for MMIO
2026-04-20 13:44 ` [PATCH 2/3] fbdev: clps711x-fb: Request memory region for MMIO Amit Barzilai
@ 2026-04-22 23:34 ` Claude Code Review Bot
0 siblings, 0 replies; 10+ messages in thread
From: Claude Code Review Bot @ 2026-04-22 23:34 UTC (permalink / raw)
To: dri-devel-reviews
Patch Review
**Status: Good**
Makes resource 0 (MMIO registers) consistent with resource 1 (framebuffer), which already uses `devm_platform_get_and_ioremap_resource()` at line 231 of the current source. Good consistency improvement.
```c
cfb->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(cfb->base)) {
ret = PTR_ERR(cfb->base);
goto out_fb_release;
}
```
The original code had a subtle deficiency: when `platform_get_resource()` returned NULL, it jumped to `out_fb_release` with `ret` still at its init value of `-ENOENT` (line 206 of current source). While not a bug per se, the new code is better — `ret` is explicitly set to the actual error from the helper.
`res` is still used afterward (lines 228-229: `info->fix.mmio_start = res->start; info->fix.mmio_len = resource_size(res)`), and it's correctly populated by the `&res` output parameter.
No issues.
---
Generated by Claude Code Patch Reviewer
^ permalink raw reply [flat|nested] 10+ messages in thread
* Claude review: fbdev: goldfishfb: Request memory region
2026-04-20 13:44 ` [PATCH 3/3] fbdev: goldfishfb: Request memory region Amit Barzilai
2026-04-22 14:43 ` Helge Deller
@ 2026-04-22 23:34 ` Claude Code Review Bot
1 sibling, 0 replies; 10+ messages in thread
From: Claude Code Review Bot @ 2026-04-22 23:34 UTC (permalink / raw)
To: dri-devel-reviews
Patch Review
**Status: Good, with one observation**
Converts from bare `ioremap()` to `devm_ioremap_resource()`, and correctly removes the manual `iounmap()` calls from both the error unwind path and `goldfish_fb_remove()`.
```c
fb->reg_base = devm_ioremap_resource(&pdev->dev, r);
if (IS_ERR(fb->reg_base)) {
ret = PTR_ERR(fb->reg_base);
goto err_no_io_base;
}
```
**Observation on mapping size:** The original code maps exactly `PAGE_SIZE` bytes:
```c
fb->reg_base = ioremap(r->start, PAGE_SIZE);
```
The new `devm_ioremap_resource()` maps `resource_size(r)` bytes. The actual register space only extends to offset `0x20` (36 bytes), so both PAGE_SIZE and the platform-defined resource size are more than sufficient. Mapping exactly what the resource describes is the right thing to do, so this is a correct change — but it's worth the reviewer being aware that the mapped size is now determined by the platform resource rather than hardcoded.
**Cleanup correctness:** The `iounmap()` removal is safe. The `kfree(fb)` calls in both the error path and `goldfish_fb_remove()` are retained, which is correct — freeing the struct that holds the `reg_base` pointer doesn't conflict with the devm-managed mapping lifetime (the mapping is tied to the device, not the struct).
No issues.
---
Generated by Claude Code Patch Reviewer
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-04-22 23:34 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-20 13:44 [PATCH 0/3] fbdev: Request memory regions in platform drivers Amit Barzilai
2026-04-20 13:44 ` [PATCH 1/3] fbdev: cobalt_lcdfb: Request memory region Amit Barzilai
2026-04-22 14:50 ` Helge Deller
2026-04-22 23:34 ` Claude review: " Claude Code Review Bot
2026-04-20 13:44 ` [PATCH 2/3] fbdev: clps711x-fb: Request memory region for MMIO Amit Barzilai
2026-04-22 23:34 ` Claude review: " Claude Code Review Bot
2026-04-20 13:44 ` [PATCH 3/3] fbdev: goldfishfb: Request memory region Amit Barzilai
2026-04-22 14:43 ` Helge Deller
2026-04-22 23:34 ` Claude review: " Claude Code Review Bot
2026-04-22 23:34 ` Claude review: fbdev: Request memory regions in platform drivers Claude Code Review Bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox