diff options
| author | Simon Richter <Simon.Richter@hogyros.de> | 2026-03-08 02:35:37 +0900 |
|---|---|---|
| committer | Bjorn Helgaas <bhelgaas@google.com> | 2026-03-30 10:44:50 -0500 |
| commit | 5b6471fc72a42e6110adca54f46fd2c287dc49d4 (patch) | |
| tree | 2286668f9eb3c4fffdb47e0c61f520cff66e50a2 | |
| parent | 94555ea9a0488c5c1bba90242cfa149a84a8928d (diff) | |
PCI/VGA: Fail pci_set_vga_state() if VGA decoding not supported
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.
Signed-off-by: Simon Richter <Simon.Richter@hogyros.de>
[bhelgaas: subject, add comment about VGA Enable writability]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20260307173538.763188-5-Simon.Richter@hogyros.de
| -rw-r--r-- | drivers/pci/pci.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 8479c2e1f74f..52eb3ef0f487 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -6197,6 +6197,18 @@ 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); + + + /* + * VGA Enable may not be writable if bridge doesn't + * support it. + */ + if (decode) { + pci_read_config_word(bridge, PCI_BRIDGE_CONTROL, + &cmd); + if (!(cmd & PCI_BRIDGE_CTL_VGA)) + return -EIO; + } } bus = bus->parent; } |
