From: Bjorn Helgaas <helgaas@kernel.org>
To: Simon Richter <Simon.Richter@hogyros.de>
Cc: linux-pci@vger.kernel.org, intel-xe@lists.freedesktop.org,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 4/5] pci: check if VGA decoding was really activated
Date: Tue, 10 Mar 2026 15:22:59 -0500 [thread overview]
Message-ID: <20260310202259.GA777598@bhelgaas> (raw)
In-Reply-To: <20260307173538.763188-5-Simon.Richter@hogyros.de>
On Sun, Mar 08, 2026 at 02:35:37AM +0900, Simon Richter wrote:
> PCI bridges are allowed to refuse activating VGA decoding, by simply
> ignoring attempts to set the bit that enables it, so after setting the bit,
> read it back to verify.
>
> One example of such a bridge is the root bridge in IBM PowerNV, but this is
> also useful for GPU passthrough into virtual machines, where it is
> difficult to set up routing for legacy IO through IOMMU.
Based on this:
https://lore.kernel.org/all/9f297568-5616-40b6-b401-df1af57d5e14@hogyros.de
I *guess* this is the critical patch, and together with
https://patchwork.freedesktop.org/patch/709684/?series=161721&rev=4,
it fixes an issue?
Without these two patches, i915 assumes its
vga_get_uninterruptible(pdev, VGA_RSRC_LEGACY_IO) always succeeds, and
I guess the problem is that if it *didn't* succeed, i915's subsequent
ioport accesses may go to the wrong device or to no device at all,
which might corrupt another device or cause a PCI error?
We could include the i915 patch in this series. Wouldn't be a
problem from the PCI side, I dunno about the DRM side.
> Signed-off-by: Simon Richter <Simon.Richter@hogyros.de>
> ---
> drivers/pci/pci.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 8479c2e1f74f..e60b948f8576 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -6197,6 +6197,12 @@ int pci_set_vga_state(struct pci_dev *dev, bool decode,
> cmd &= ~PCI_BRIDGE_CTL_VGA;
> pci_write_config_word(bridge, PCI_BRIDGE_CONTROL,
> cmd);
> + if (decode) {
> + pci_read_config_word(bridge, PCI_BRIDGE_CONTROL,
> + &cmd);
> + if(!(cmd & PCI_BRIDGE_CTL_VGA))
> + return -EIO;
> + }
> }
> bus = bus->parent;
> }
> --
> 2.47.3
>
next prev parent reply other threads:[~2026-03-10 20:23 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-07 17:35 [PATCH v3 0/5] Bridges without VGA support Simon Richter
2026-03-07 17:35 ` [PATCH v3 1/5] vgaarb: pass vga_get_uninterruptible() errors to userspace Simon Richter
2026-03-24 19:37 ` Bjorn Helgaas
2026-03-25 6:52 ` Simon Richter
2026-03-25 18:29 ` Bjorn Helgaas
2026-03-07 17:35 ` [PATCH v3 2/5] vgaarb: pass errors from pci_set_vga_state() up Simon Richter
2026-03-10 11:37 ` Ville Syrjälä
2026-03-07 17:35 ` [PATCH v3 3/5] vgaarb: mark vga_get() and wrappers as __must_check Simon Richter
2026-03-10 20:07 ` Bjorn Helgaas
2026-03-11 22:51 ` Simon Richter
2026-03-11 23:14 ` Bjorn Helgaas
2026-03-11 23:29 ` Simon Richter
2026-03-07 17:35 ` [PATCH v3 4/5] pci: check if VGA decoding was really activated Simon Richter
2026-03-10 11:37 ` Ville Syrjälä
2026-03-10 14:08 ` Simon Richter
2026-03-10 15:19 ` Ville Syrjälä
2026-03-10 20:22 ` Bjorn Helgaas [this message]
2026-03-11 7:07 ` Simon Richter
2026-03-07 17:35 ` [PATCH v3 5/5] pci: mark pci_set_vga_state() as __must_check Simon Richter
2026-03-10 19:36 ` Bjorn Helgaas
2026-03-11 23:23 ` Simon Richter
2026-03-24 19:34 ` [PATCH v3 0/5] Bridges without VGA support Bjorn Helgaas
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=20260310202259.GA777598@bhelgaas \
--to=helgaas@kernel.org \
--cc=Simon.Richter@hogyros.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=linux-pci@vger.kernel.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