14f0fd
From c449d0540e5f990d2710812cc4b4c35699ffd82e Mon Sep 17 00:00:00 2001
14f0fd
From: Marcel Apfelbaum <marcel@redhat.com>
14f0fd
Date: Wed, 17 Jan 2018 20:13:10 +0100
14f0fd
Subject: [PATCH] pci: fix 'io hints' capability for RedHat PCI bridges
14f0fd
14f0fd
RH-Author: Marcel Apfelbaum <marcel@redhat.com>
14f0fd
Message-id: <20180117201310.18787-1-marcel@redhat.com>
14f0fd
Patchwork-id: 78658
14f0fd
O-Subject: [RHEL-7.5 seabios PATCH] pci: fix 'io hints' capability for RedHat PCI bridges
14f0fd
Bugzilla: 1523166
14f0fd
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
14f0fd
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
14f0fd
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
14f0fd
14f0fd
Commit ec6cb17f (pci: enable RedHat PCI bridges to reserve additional
14f0fd
                 resources on PCI init)
14f0fd
added a new vendor specific PCI capability for RedHat PCI bridges
14f0fd
allowing them to reserve additional buses and/or IO/MEM space.
14f0fd
14f0fd
When adding the IO hints PCI capability to the pcie-root-port
14f0fd
without specifying a value for bus reservation, the subordinate bus
14f0fd
computation is wrong and the guest kernel gets messed up.
14f0fd
14f0fd
Fix it by returning to prev code if the value for bus
14f0fd
reservation is not set.
14f0fd
14f0fd
Removed also a wrong debug print "PCI: invalid QEMU resource reserve
14f0fd
cap offset" which appears if the 'IO hints' capability is not present.
14f0fd
14f0fd
Acked-by: Michael S. Tsirkin <mst@redhat.com>
14f0fd
Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
14f0fd
(cherry picked from commit 14d91c353e19b7085fdbb7b2dcc43f3355665670)
14f0fd
Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
14f0fd
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
14f0fd
---
14f0fd
 src/fw/pciinit.c | 14 +++++---------
14f0fd
 1 file changed, 5 insertions(+), 9 deletions(-)
14f0fd
14f0fd
diff --git a/src/fw/pciinit.c b/src/fw/pciinit.c
14f0fd
index 7f0e439..3a2f747 100644
14f0fd
--- a/src/fw/pciinit.c
14f0fd
+++ b/src/fw/pciinit.c
14f0fd
@@ -540,8 +540,6 @@ static u8 pci_find_resource_reserve_capability(u16 bdf)
14f0fd
                 dprintf(1, "PCI: QEMU resource reserve cap length %d is invalid\n",
14f0fd
                         cap_len);
14f0fd
             }
14f0fd
-        } else {
14f0fd
-            dprintf(1, "PCI: invalid QEMU resource reserve cap offset\n");
14f0fd
         }
14f0fd
         return cap;
14f0fd
     } else {
14f0fd
@@ -619,13 +617,11 @@ pci_bios_init_bus_rec(int bus, u8 *pci_bus)
14f0fd
                                 res_bus);
14f0fd
                         res_bus = 0;
14f0fd
                     }
14f0fd
-                }
14f0fd
-                if (secbus + res_bus > *pci_bus) {
14f0fd
-                    dprintf(1, "PCI: QEMU resource reserve cap: bus = %u\n",
14f0fd
-                            res_bus);
14f0fd
-                    res_bus = secbus + res_bus;
14f0fd
-                } else {
14f0fd
-                    res_bus = *pci_bus;
14f0fd
+                    if (secbus + res_bus > *pci_bus) {
14f0fd
+                        dprintf(1, "PCI: QEMU resource reserve cap: bus = %u\n",
14f0fd
+                                res_bus);
14f0fd
+                        res_bus = secbus + res_bus;
14f0fd
+                    }
14f0fd
                 }
14f0fd
             }
14f0fd
             dprintf(1, "PCI: subordinate bus = 0x%x -> 0x%x\n",
14f0fd
-- 
14f0fd
1.8.3.1
14f0fd