From: Helge Deller <deller@gmx.de>
To: Swaraj Gaikwad <swarajgaikwad1925@gmail.com>,
Andres Salomon <dilinger@queued.net>,
"moderated list:AMD GEODE PROCESSOR/CHIPSET SUPPORT"
<linux-geode@lists.infradead.org>,
"open list:FRAMEBUFFER LAYER" <linux-fbdev@vger.kernel.org>,
"open list:FRAMEBUFFER LAYER" <dri-devel@lists.freedesktop.org>,
open list <linux-kernel@vger.kernel.org>
Cc: skhan@linuxfoundation.org, david.hunter.linux@gmail.com
Subject: Re: [PATCH] fbdev: geode: lxfb: Use devm_request_mem_region
Date: Tue, 30 Dec 2025 11:10:14 +0100 [thread overview]
Message-ID: <0e284b23-e753-4100-8959-2d01977c1ad0@gmx.de> (raw)
In-Reply-To: <20251214012059.304043-1-swarajgaikwad1925@gmail.com>
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 <swarajgaikwad1925@gmail.com>
> ---
> 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
>
prev parent reply other threads:[~2025-12-30 10:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-14 1:20 [PATCH] fbdev: geode: lxfb: Use devm_request_mem_region Swaraj Gaikwad
2025-12-30 10:10 ` Helge Deller [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0e284b23-e753-4100-8959-2d01977c1ad0@gmx.de \
--to=deller@gmx.de \
--cc=david.hunter.linux@gmail.com \
--cc=dilinger@queued.net \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-geode@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=swarajgaikwad1925@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox