Hello Swaraj,
On 12/14/25 02:20, Swaraj Gaikwad wrote:
The lxfb driver currently uses pci_request_region() for memory
reservation, which requires manual error handling and cleanup using
pci_release_region().
Simplify the driver by migrating to the managed helper
devm_request_mem_region(). This ensures that resources are automatically
released on driver detach, allowing the removal of explicit cleanup code
in the probe error path and the remove function.
This addresses the TODO item "Request memory regions in all fbdev
drivers" in Documentation/gpu/todo.rst.
Signed-off-by: Swaraj Gaikwad <[email protected]>
---
Compile-tested only on x86_64.
I'm somewhat hesitated to apply your geode and arkfb patches.
IIRC, geode and arkfb chips were mostly (only?) used in some
laptops. That means, beside the arkfb and geode onboard graphics
chips there were no other (PCI) graphic cards which could conflict
at VGA addresses. So basically there is no real benefit for
those drivers to switching using devm_* functions.
Then, although your patches seem to be correct, it's hard to say
they are okay without actual testing.
That said, maybe someone still has the hardware and is able to test?
Helge
drivers/video/fbdev/geode/lxfb_core.c | 36 +++++++++------------------
1 file changed, 12 insertions(+), 24 deletions(-)
diff --git a/drivers/video/fbdev/geode/lxfb_core.c
b/drivers/video/fbdev/geode/lxfb_core.c
index cad99f5b7fe8..8189d6a13c5d 100644
--- a/drivers/video/fbdev/geode/lxfb_core.c
+++ b/drivers/video/fbdev/geode/lxfb_core.c
@@ -335,25 +335,21 @@ static int lxfb_map_video_memory(struct fb_info *info,
struct pci_dev *dev)
if (ret)
return ret;
- ret = pci_request_region(dev, 0, "lxfb-framebuffer");
+ if (!devm_request_mem_region(&dev->dev, pci_resource_start(dev, 0),
+ pci_resource_len(dev, 0), "lxfb-framebuffer"))
+ return -EBUSY;
- if (ret)
- return ret;
-
- ret = pci_request_region(dev, 1, "lxfb-gp");
-
- if (ret)
- return ret;
+ if (!devm_request_mem_region(&dev->dev, pci_resource_start(dev, 1),
+ pci_resource_len(dev, 1), "lxfb-gp"))
+ return -EBUSY;
- ret = pci_request_region(dev, 2, "lxfb-vg");
+ if (!devm_request_mem_region(&dev->dev, pci_resource_start(dev, 2),
+ pci_resource_len(dev, 2), "lxfb-vg"))
+ return -EBUSY;
- if (ret)
- return ret;
-
- ret = pci_request_region(dev, 3, "lxfb-vp");
-
- if (ret)
- return ret;
+ if (!devm_request_mem_region(&dev->dev, pci_resource_start(dev, 3),
+ pci_resource_len(dev, 3), "lxfb-vp"))
+ return -EBUSY;
info->fix.smem_start = pci_resource_start(dev, 0);
info->fix.smem_len = vram ? vram : lx_framebuffer_size();
@@ -546,19 +542,15 @@ static int lxfb_probe(struct pci_dev *pdev, const struct
pci_device_id *id)
err:
if (info->screen_base) {
iounmap(info->screen_base);
- pci_release_region(pdev, 0);
}
if (par->gp_regs) {
iounmap(par->gp_regs);
- pci_release_region(pdev, 1);
}
if (par->dc_regs) {
iounmap(par->dc_regs);
- pci_release_region(pdev, 2);
}
if (par->vp_regs) {
iounmap(par->vp_regs);
- pci_release_region(pdev, 3);
}
fb_dealloc_cmap(&info->cmap);
@@ -575,16 +567,12 @@ static void lxfb_remove(struct pci_dev *pdev)
unregister_framebuffer(info);
iounmap(info->screen_base);
- pci_release_region(pdev, 0);
iounmap(par->gp_regs);
- pci_release_region(pdev, 1);
iounmap(par->dc_regs);
- pci_release_region(pdev, 2);
iounmap(par->vp_regs);
- pci_release_region(pdev, 3);
fb_dealloc_cmap(&info->cmap);
framebuffer_release(info);
base-commit: a859eca0e4cc96f63ff125dbe5388d961558b0e9
--
2.52.0