* [PATCH v2] fbdev: arkfb: Request legacy VGA I/O region
@ 2025-12-13 20:22 Swaraj Gaikwad
2025-12-13 22:38 ` Sam Ravnborg
0 siblings, 1 reply; 3+ messages in thread
From: Swaraj Gaikwad @ 2025-12-13 20:22 UTC (permalink / raw)
To: Helge Deller, Andrew Morton, Hans Verkuil, Nicolas Dufresne,
Frank Li, Zi Yan, Donet Tom, Yann Dirson, Konrad Dybcio,
Vivek Kasireddy, Qianfeng Rong, Kees Cook,
open list:FRAMEBUFFER LAYER, open list:FRAMEBUFFER LAYER,
open list
Cc: skhan, david.hunter.linux, Swaraj Gaikwad
The arkfb driver uses the legacy VGA I/O range (0x3c0+) but does not
request it. This can cause conflicts with other drivers that try to
reserve these ports.
Fix this by using devm_request_region() during the probe function.
This ensures the region is properly reserved and automatically released
on driver detach.
v1: https://lore.kernel.org/lkml/20251213154937.104301-1-swarajgaikwad1925@gmail.com/
Signed-off-by: Swaraj Gaikwad <swarajgaikwad1925@gmail.com>
---
v2:
- Use resource_size(&vga_res) instead of hardcoded 64 * 1024.
- (Feedback from Kees Cook)
Compile-tested only on x86_64.
drivers/video/fbdev/arkfb.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/video/fbdev/arkfb.c b/drivers/video/fbdev/arkfb.c
index ec084323115f..24e4c20d1a32 100644
--- a/drivers/video/fbdev/arkfb.c
+++ b/drivers/video/fbdev/arkfb.c
@@ -1018,6 +1018,12 @@ static int ark_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
pcibios_bus_to_resource(dev->bus, &vga_res, &bus_reg);
+ if (!devm_request_region(&dev->dev, vga_res.start, resource_size(&vga_res), "arkfb-vga")) {
+ dev_err(info->device, "cannot reserve legacy VGA ports\n");
+ rc = -EBUSY;
+ goto err_find_mode;
+ }
+
par->state.vgabase = (void __iomem *) (unsigned long) vga_res.start;
/* FIXME get memsize */
base-commit: a859eca0e4cc96f63ff125dbe5388d961558b0e9
--
2.52.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] fbdev: arkfb: Request legacy VGA I/O region
2025-12-13 20:22 [PATCH v2] fbdev: arkfb: Request legacy VGA I/O region Swaraj Gaikwad
@ 2025-12-13 22:38 ` Sam Ravnborg
2025-12-14 11:19 ` Swaraj Gaikwad
0 siblings, 1 reply; 3+ messages in thread
From: Sam Ravnborg @ 2025-12-13 22:38 UTC (permalink / raw)
To: Swaraj Gaikwad
Cc: Helge Deller, Andrew Morton, Hans Verkuil, Nicolas Dufresne,
Frank Li, Zi Yan, Donet Tom, Yann Dirson, Konrad Dybcio,
Vivek Kasireddy, Qianfeng Rong, Kees Cook,
open list:FRAMEBUFFER LAYER, open list:FRAMEBUFFER LAYER,
open list, skhan, david.hunter.linux
Hi Swaraj,
On Sat, Dec 13, 2025 at 08:22:34PM +0000, Swaraj Gaikwad wrote:
> The arkfb driver uses the legacy VGA I/O range (0x3c0+) but does not
> request it. This can cause conflicts with other drivers that try to
> reserve these ports.
>
> Fix this by using devm_request_region() during the probe function.
> This ensures the region is properly reserved and automatically released
> on driver detach.
>
> v1: https://lore.kernel.org/lkml/20251213154937.104301-1-swarajgaikwad1925@gmail.com/
> Signed-off-by: Swaraj Gaikwad <swarajgaikwad1925@gmail.com>
> ---
> v2:
> - Use resource_size(&vga_res) instead of hardcoded 64 * 1024.
> - (Feedback from Kees Cook)
>
> Compile-tested only on x86_64.
>
> drivers/video/fbdev/arkfb.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/video/fbdev/arkfb.c b/drivers/video/fbdev/arkfb.c
> index ec084323115f..24e4c20d1a32 100644
> --- a/drivers/video/fbdev/arkfb.c
> +++ b/drivers/video/fbdev/arkfb.c
> @@ -1018,6 +1018,12 @@ static int ark_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
>
> pcibios_bus_to_resource(dev->bus, &vga_res, &bus_reg);
>
> + if (!devm_request_region(&dev->dev, vga_res.start, resource_size(&vga_res), "arkfb-vga")) {
> + dev_err(info->device, "cannot reserve legacy VGA ports\n");
> + rc = -EBUSY;
> + goto err_find_mode;
> + }
> +
> par->state.vgabase = (void __iomem *) (unsigned long) vga_res.start;
Any explanation why devm_request_region() is the right choice here?
As per the line above vga_res.start is iomem, and I had expected to see
devm_request_mem_region() used.
I looked only briefly, so I may be wrong.
Sam
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] fbdev: arkfb: Request legacy VGA I/O region
2025-12-13 22:38 ` Sam Ravnborg
@ 2025-12-14 11:19 ` Swaraj Gaikwad
0 siblings, 0 replies; 3+ messages in thread
From: Swaraj Gaikwad @ 2025-12-14 11:19 UTC (permalink / raw)
To: sam
Cc: Frank.Li, akpm, david.hunter.linux, deller, donettom, dri-devel,
hverkuil+cisco, kees, konrad.dybcio, linux-fbdev, linux-kernel,
nicolas.dufresne, rongqianfeng, skhan, swarajgaikwad1925,
vivek.kasireddy, ydirson, ziy
Hi Sam,
Thanks for the review.
You are right that the cast to (void __iomem *) makes it look like memory,
but the resource is explicitly initialized as I/O ports a few lines earlier:
vga_res.flags = IORESOURCE_IO;
Since the resource flag is IORESOURCE_IO (targeting the legacy VGA ports),
I used devm_request_region() instead of devm_request_mem_region().
Best regards,
Swaraj
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-12-14 5:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-13 20:22 [PATCH v2] fbdev: arkfb: Request legacy VGA I/O region Swaraj Gaikwad
2025-12-13 22:38 ` Sam Ravnborg
2025-12-14 11:19 ` Swaraj Gaikwad
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox