public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: Hardik Phalet <hardik.phalet@pm.me>,
	Ferenc Bakonyi <fero@drama.obuda.kando.hu>,
	Helge Deller <deller@gmx.de>
Cc: Shuah Khan <skhan@linuxfoundation.org>,
	Brigham Campbell <me@brighamcampbell.com>,
	linux-nvidia@lists.surfsouth.com, linux-fbdev@vger.kernel.org,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fbdev/hga: Request memory region before ioremap
Date: Tue, 10 Mar 2026 11:03:51 +0100	[thread overview]
Message-ID: <5f9749ba-18a8-4b6b-a6e7-a011a3871bfb@suse.de> (raw)
In-Reply-To: <20260310064124.602848-1-hardik.phalet@pm.me>

Hi

Am 10.03.26 um 07:41 schrieb Hardik Phalet:
> The driver calls ioremap() on the HGA video memory at 0xb0000 without
> first reserving the physical address range via request_mem_region().
> This leaves the kernel resource tree incomplete and can cause silent
> conflicts with other drivers claiming the same range.
>
> Add a request_mem_region() call before ioremap() in hga_card_detect()
> and release the region in all error paths and in hgafb_remove().
>
> Signed-off-by: Hardik Phalet <hardik.phalet@pm.me>
> ---
>   drivers/video/fbdev/hgafb.c | 11 ++++++++++-
>   1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/video/fbdev/hgafb.c b/drivers/video/fbdev/hgafb.c
> index 14418aa3791a..ceca6cc2c928 100644
> --- a/drivers/video/fbdev/hgafb.c
> +++ b/drivers/video/fbdev/hgafb.c
> @@ -284,9 +284,16 @@ static int hga_card_detect(void)

You can pass the platform device from hga_probe() and ...

>   
>   	hga_vram_len  = 0x08000;
>   
> +	if (!request_mem_region(0xb0000, hga_vram_len, "hgafb")) {

... use devm_request_mem_region() here.  That would avoid all the 
clean-up calls below AFAICT.

Best regards
Thomas


> +		pr_err("hgafb: cannot reserve video memory at 0xb0000\n");
> +		return -EBUSY;
> +	}
> +
>   	hga_vram = ioremap(0xb0000, hga_vram_len);
> -	if (!hga_vram)
> +	if (!hga_vram) {
> +		release_mem_region(0xb0000, hga_vram_len);
>   		return -ENOMEM;
> +	}
>   
>   	if (request_region(0x3b0, 12, "hgafb"))
>   		release_io_ports = 1;
> @@ -348,6 +355,7 @@ static int hga_card_detect(void)
>   	}
>   	return 0;
>   error:
> +	release_mem_region(0xb0000, hga_vram_len);
>   	if (release_io_ports)
>   		release_region(0x3b0, 12);
>   	if (release_io_port)
> @@ -619,6 +627,7 @@ static void hgafb_remove(struct platform_device *pdev)
>   	}
>   
>   	iounmap(hga_vram);
> +	release_mem_region(0xb0000, hga_vram_len);
>   
>   	if (release_io_ports)
>   		release_region(0x3b0, 12);

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)



  reply	other threads:[~2026-03-10 10:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-10  6:41 [PATCH] fbdev/hga: Request memory region before ioremap Hardik Phalet
2026-03-10 10:03 ` Thomas Zimmermann [this message]
2026-03-11  3:36 ` Claude review: " Claude Code Review Bot
2026-03-11  3:36 ` Claude Code Review Bot

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=5f9749ba-18a8-4b6b-a6e7-a011a3871bfb@suse.de \
    --to=tzimmermann@suse.de \
    --cc=deller@gmx.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=fero@drama.obuda.kando.hu \
    --cc=hardik.phalet@pm.me \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvidia@lists.surfsouth.com \
    --cc=me@brighamcampbell.com \
    --cc=skhan@linuxfoundation.org \
    /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