public inbox for linux-fbdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] fbdev/hga: Request memory region before ioremap
@ 2026-03-10 11:38 Hardik Phalet
  2026-03-10 11:49 ` Thomas Zimmermann
  0 siblings, 1 reply; 2+ messages in thread
From: Hardik Phalet @ 2026-03-10 11:38 UTC (permalink / raw)
  To: Ferenc Bakonyi, Helge Deller
  Cc: Shuah Khan, Brigham Campbell, Thomas Zimmermann, linux-nvidia,
	linux-fbdev, dri-devel, linux-kernel, Hardik Phalet

The driver calls ioremap() on the HGA video memory at 0xb0000 without
first reserving the physical address range. This leaves the kernel
resource tree incomplete and can cause silent conflicts with other
drivers claiming the same range.

Add a devm_request_mem_region() call before ioremap() in
hga_card_detect() to reserve the memory region.

Signed-off-by: Hardik Phalet <hardik.phalet@pm.me>
---
Changes in v2:
- Used devm_request_mem_region instead of request_mem_region, based on a
	review comment by Thomas [1].

v1: https://lore.kernel.org/all/20260310064124.602848-1-hardik.phalet@pm.me/
[1]: https://lore.kernel.org/all/5f9749ba-18a8-4b6b-a6e7-a011a3871bfb@suse.de/

 drivers/video/fbdev/hgafb.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/hgafb.c b/drivers/video/fbdev/hgafb.c
index 14418aa3791a..fffd34141f8d 100644
--- a/drivers/video/fbdev/hgafb.c
+++ b/drivers/video/fbdev/hgafb.c
@@ -276,7 +276,7 @@ static void hga_blank(int blank_mode)
 	spin_unlock_irqrestore(&hga_reg_lock, flags);
 }
 
-static int hga_card_detect(void)
+static int hga_card_detect(struct platform_device *pdev)
 {
 	int count = 0;
 	void __iomem *p, *q;
@@ -284,6 +284,11 @@ static int hga_card_detect(void)
 
 	hga_vram_len  = 0x08000;
 
+	if (!devm_request_mem_region(&pdev->dev, 0xb0000, hga_vram_len, "hgafb")) {
+		pr_err("hgafb: cannot reserve video memory at 0xb0000\n");
+		return -EBUSY;
+	}
+
 	hga_vram = ioremap(0xb0000, hga_vram_len);
 	if (!hga_vram)
 		return -ENOMEM;
@@ -568,7 +573,7 @@ static int hgafb_probe(struct platform_device *pdev)
 	struct fb_info *info;
 	int ret;
 
-	ret = hga_card_detect();
+	ret = hga_card_detect(pdev);
 	if (ret)
 		return ret;
 
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-10 11:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-10 11:38 [PATCH v2] fbdev/hga: Request memory region before ioremap Hardik Phalet
2026-03-10 11:49 ` Thomas Zimmermann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox