Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Simon Richter <Simon.Richter@hogyros.de>
Cc: dri-devel@lists.freedesktop.org, intel-xe@lists.freedesktop.org,
	Steve Wahl <steve.wahl@hpe.com>
Subject: Re: vgaarb, and bridges not capable of VGA forwarding
Date: Fri, 12 Dec 2025 13:34:53 +0200	[thread overview]
Message-ID: <aTv93a2Sqpj88Low@intel.com> (raw)
In-Reply-To: <f5069152-3cb7-459e-9727-f5a25256fd9c@hogyros.de>

On Thu, Dec 11, 2025 at 11:43:13PM +0900, Simon Richter wrote:
> Hi,
> 
> (cc Steve Wahl because UV BIOS is tangentially involved)
> (cc Ville Syrjala because of the recent thread about VGA arbiter)
> 
> I'm looking into
> 
>      https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/1824
> 
> again because I have a similar problem.
> 
> In pci_set_vga_state, we traverse the PCI bridges upwards, and set the 
> VGA forwarding bit on all of them up to the root. Now I happen to have a 
> root bridge that refuses to set this bit, so if I read it back after 
> setting it, it is still unset.
> 
> TTBOMK, that is allowed in the PCI specification, and the correct way to 
> indicate that a bridge cannot forward VGA accesses.
> 
> The smallest possible change is to read back the bridge control 
> register, and if the bit is still unset, terminate the loop and return 
> an error.
> 
> I'm trying to find out now if this is a good idea, and am a bit puzzled:
> 
> It appears the only place that can generate errors is 
> pci_set_vga_state_arch, which is a dispatch mechanism with a single 
> user, uv_bios_set_legacy_vga_target.
> 
> According to the comment, the errors generated here are -EINVAL, -ENOSYS 
> and -EBUSY. The implementation returns the return value from an EFI 
> call, which appears to be defined to be a negated POSIX errno number, so 
> this has a high chance of being correct.
> 
> If pci_set_vga_state_arch does not return an error, the normal 
> pci_set_vga_state function runs, and there is no way for the arch 
> specific function to indicate that the rest of the function should not 
> run. Is that intentional, or should the BIOS call replace the normal 
> implementation?
> 
> It also seems that vgaarb is the only caller, and it does not look at 
> the return value from this function. So if I fix that, and propagate the 
> error upwards, I first need a way to indicate that __try_vga_get failed 
> without there being a conflict, and then I need all vga_get callers to 
> have error handling. The latter sounds doable.
> 
> What I'm unsure about:
> 
> 1. Does this seem like a viable approach?
> 
> 2. What interface makes sense for returning an error here? This function 
> is supposed to return the conflicting device -- should I just make this 
> a PTR_ERR?
> 
> 3. What error would be appropriate for a bridge refusing to activate the 
> VGA bit? It's not EIO, it's not EACCES, it's not EINVAL, the closest is 
> probably ENOSYS, but even that feels wrong.
> 
> 4. How likely is it for this to break something else? Are there PCI 
> bridges that forward VGA but implement the bridge control register 
> incorrectly?
> 
>     Simon

I wonder how bad it would be to just tickle the VGA bit
when the bridge is added. Basically something like:

if (BRIDGECTL.VGA) {
	bridge.has_vga = true;
} else {
	BRIDGECTL.VGA = 1
	if (BRIDGECTL.VGA)
		bridge.has_vga = true;
	BRIDGECTL.VGA = 0
}

Obviously there is a tiny race there where the bridge might
temporarily forward VGA accesses to the wrong device. But
maybe the race is small enough to not really matter? Or I
guess if you're really worried about the race you could do
this check under stop_machine() *shudder*.

BTW I recently posted this:
https://lore.kernel.org/intel-gfx/20251208182637.334-1-ville.syrjala@linux.intel.com/
where I'm trying to fix the mess around VGA accesses in i915/xe.
Some of the more hacky things there should probably be properly
fixed in vgaarb, but I don't really have the time/energy to
deal with that right now.

-- 
Ville Syrjälä
Intel

  reply	other threads:[~2025-12-12 11:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-11 14:43 vgaarb, and bridges not capable of VGA forwarding Simon Richter
2025-12-12 11:34 ` Ville Syrjälä [this message]
2025-12-12 17:59   ` Steve Wahl

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=aTv93a2Sqpj88Low@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=Simon.Richter@hogyros.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=steve.wahl@hpe.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