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.

Signed-off-by: Simon Richter <[email protected]>
---
 drivers/pci/pci.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index f3244630bfd0..0984a0aefb88 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -6198,6 +6198,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

Reply via email to