]> xenbits.xensource.com Git - seabios.git/commitdiff
pci: fix mmconfig support
authorGerd Hoffmann <kraxel@redhat.com>
Mon, 25 May 2020 09:06:27 +0000 (11:06 +0200)
committerKevin O'Connor <kevin@koconnor.net>
Mon, 25 May 2020 15:27:12 +0000 (11:27 -0400)
The MODESEGMENT condition is backwards, with the effect that
mmconfig mode is not used to configure pci bars during POST.

Oops.  Fix it.

The only real mode pci config space access seems to come from the
ipxe option rom initialiation.  Which happens to work via mmconfig
because it runs in big real mode so this went unnoticed ...

Fixes: 6a3b59ab9c7d ("pci: add mmconfig support")
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
src/hw/pci.c

index d9dbf313965c2a620cc7e3ea1b16f01095a3a483..3df1dae41d2b15de5a1948b6b3d3cf2a1e200b3e 100644 (file)
@@ -28,7 +28,7 @@ static u32 ioconfig_cmd(u16 bdf, u32 addr)
 
 void pci_config_writel(u16 bdf, u32 addr, u32 val)
 {
-    if (MODESEGMENT && mmconfig) {
+    if (!MODESEGMENT && mmconfig) {
         writel(mmconfig_addr(bdf, addr), val);
     } else {
         outl(ioconfig_cmd(bdf, addr), PORT_PCI_CMD);
@@ -38,7 +38,7 @@ void pci_config_writel(u16 bdf, u32 addr, u32 val)
 
 void pci_config_writew(u16 bdf, u32 addr, u16 val)
 {
-    if (MODESEGMENT && mmconfig) {
+    if (!MODESEGMENT && mmconfig) {
         writew(mmconfig_addr(bdf, addr), val);
     } else {
         outl(ioconfig_cmd(bdf, addr), PORT_PCI_CMD);
@@ -48,7 +48,7 @@ void pci_config_writew(u16 bdf, u32 addr, u16 val)
 
 void pci_config_writeb(u16 bdf, u32 addr, u8 val)
 {
-    if (MODESEGMENT && mmconfig) {
+    if (!MODESEGMENT && mmconfig) {
         writeb(mmconfig_addr(bdf, addr), val);
     } else {
         outl(ioconfig_cmd(bdf, addr), PORT_PCI_CMD);
@@ -58,7 +58,7 @@ void pci_config_writeb(u16 bdf, u32 addr, u8 val)
 
 u32 pci_config_readl(u16 bdf, u32 addr)
 {
-    if (MODESEGMENT && mmconfig) {
+    if (!MODESEGMENT && mmconfig) {
         return readl(mmconfig_addr(bdf, addr));
     } else {
         outl(ioconfig_cmd(bdf, addr), PORT_PCI_CMD);
@@ -68,7 +68,7 @@ u32 pci_config_readl(u16 bdf, u32 addr)
 
 u16 pci_config_readw(u16 bdf, u32 addr)
 {
-    if (MODESEGMENT && mmconfig) {
+    if (!MODESEGMENT && mmconfig) {
         return readw(mmconfig_addr(bdf, addr));
     } else {
         outl(ioconfig_cmd(bdf, addr), PORT_PCI_CMD);
@@ -78,7 +78,7 @@ u16 pci_config_readw(u16 bdf, u32 addr)
 
 u8 pci_config_readb(u16 bdf, u32 addr)
 {
-    if (MODESEGMENT && mmconfig) {
+    if (!MODESEGMENT && mmconfig) {
         return readb(mmconfig_addr(bdf, addr));
     } else {
         outl(ioconfig_cmd(bdf, addr), PORT_PCI_CMD);