From: Jani Nikula <jani.nikula@linux.intel.com>
To: Simon Richter <Simon.Richter@hogyros.de>,
intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: Simon Richter <Simon.Richter@hogyros.de>
Subject: Re: [PATCH 1/1] drm/i915: handle failure from vga_get
Date: Thu, 26 Feb 2026 12:44:28 +0200 [thread overview]
Message-ID: <27abe19ab816cf112b1eade65e6287b881477a9f@intel.com> (raw)
In-Reply-To: <20260217165214.236482-2-Simon.Richter@hogyros.de>
On Wed, 18 Feb 2026, Simon Richter <Simon.Richter@hogyros.de> wrote:
> This function returns an error code.
Which function? Please make commit messages independent of the Subject
line.
Also, the function we call is vga_get_uninterruptible().
> If that code is non-zero, VGA decoding
> is undefined, and the lock counter has not been increased, so it is not valid
> to access registers or call vga_put afterwards.
>
> Signed-off-by: Simon Richter <Simon.Richter@hogyros.de>
> Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/1824
> ---
> drivers/gpu/drm/i915/display/intel_vga.c | 29 ++++++++++++++++++++----
> 1 file changed, 24 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_vga.c b/drivers/gpu/drm/i915/display/intel_vga.c
> index 6fc3e3702cb8..4118c451d53c 100644
> --- a/drivers/gpu/drm/i915/display/intel_vga.c
> +++ b/drivers/gpu/drm/i915/display/intel_vga.c
> @@ -112,12 +112,17 @@ static bool intel_pci_bridge_set_vga(struct pci_dev *pdev, bool enable)
> return old & PCI_BRIDGE_CTL_VGA;
> }
>
> -static bool intel_vga_get(struct intel_display *display, bool mmio)
> +static int __must_check intel_vga_get(struct intel_display *display,
I'm not convinced by __must_check annotations for static
functions. Global stuff, sure, but we'd be adding tons and tons of these
annotations if we decided to go this path.
> + bool mmio, bool *old_io_decode)
> {
> struct pci_dev *pdev = to_pci_dev(display->drm->dev);
> + int err;
>
> if (mmio)
> - return false;
> + {
Brace location, please see checkpatch.
> + *old_io_decode = false;
> + return 0;
> + }
>
> /*
> * Bypass the VGA arbiter on the iGPU and just enable
> @@ -131,9 +136,14 @@ static bool intel_vga_get(struct intel_display *display, bool mmio)
> * of how any other VGA routing bits are configured.
> */
> if (display->platform.dgfx)
> - vga_get_uninterruptible(pdev, VGA_RSRC_LEGACY_IO);
> + {
Brace location.
> + err = vga_get_uninterruptible(pdev, VGA_RSRC_LEGACY_IO);
> + if (unlikely(err))
I'm not convinced by unlikely annotations in cases like this. It's just
more stuff to read, for no clear benefit. Again, if we set the example,
we'll be adding these absolutely everywhere.
> + return err;
> + }
>
> - return intel_pci_set_io_decode(pdev, true);
> + *old_io_decode = intel_pci_set_io_decode(pdev, true);
Blank line before return.
> + return 0;
> }
>
> static void intel_vga_put(struct intel_display *display, bool io_decode, bool mmio)
> @@ -175,6 +185,7 @@ void intel_vga_disable(struct intel_display *display)
> bool io_decode;
> u8 msr, sr1;
> u32 tmp;
> + int err;
>
> if (!intel_vga_decode_is_enabled(display)) {
> drm_dbg_kms(display->drm, "VGA decode is disabled\n");
> @@ -216,7 +227,15 @@ void intel_vga_disable(struct intel_display *display)
> goto reset_vgacntr;
> }
>
> - io_decode = intel_vga_get(display, mmio);
> + /* This should not fail, because vga_get will only report errors for
/* on its own line please.
> + * dGPUs that are unreachable via the bridge, and cannot be made
> + * reachable either. We shouldn't even get here for this case, but if
> + * we do, we assume that the bridge will also refuse future requests
> + * to forward VGA accesses.
> + */
> + err = intel_vga_get(display, mmio, &io_decode);
> + if (unlikely(err))
Please no unlikely.
> + goto reset_vgacntr;
>
> drm_WARN_ON(display->drm, !mmio && !intel_pci_has_vga_io_decode(pdev));
--
Jani Nikula, Intel
next prev parent reply other threads:[~2026-02-26 10:44 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-17 16:51 [PATCH 0/1] Avoid oops on illegal VGA register access Simon Richter
2026-02-17 16:51 ` [PATCH 1/1] drm/i915: handle failure from vga_get Simon Richter
2026-02-18 13:10 ` [PATCH v2 " Simon Richter
2026-03-06 15:13 ` [PATCH v3 1/1] drm/i915: handle failure from vga_get_uninterruptible() Simon Richter
2026-03-10 11:10 ` Ville Syrjälä
2026-03-10 14:45 ` Simon Richter
2026-03-10 15:11 ` Ville Syrjälä
2026-02-26 10:44 ` Jani Nikula [this message]
2026-02-17 17:03 ` ✗ CI.checkpatch: warning for Avoid oops on illegal VGA register access Patchwork
2026-02-17 17:04 ` ✓ CI.KUnit: success " Patchwork
2026-02-17 17:42 ` ✓ Xe.CI.BAT: " Patchwork
2026-02-17 20:50 ` ✓ Xe.CI.FULL: " Patchwork
2026-02-18 17:11 ` ✓ CI.KUnit: success for Avoid oops on illegal VGA register access (rev2) Patchwork
2026-02-18 18:04 ` ✓ Xe.CI.BAT: " Patchwork
2026-02-18 19:47 ` ✓ Xe.CI.FULL: " Patchwork
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=27abe19ab816cf112b1eade65e6287b881477a9f@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=Simon.Richter@hogyros.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.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