<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">From b0ae5c46407a9474494019206c491e0d942eb864 Mon Sep 17 00:00:00 2001
Message-Id: &lt;b0ae5c46407a9474494019206c491e0d942eb864.1344844502.git.minovotn@redhat.com&gt;
In-Reply-To: &lt;0c740d356f8d30310bcff2b06cfefad0e72769e2.1344844502.git.minovotn@redhat.com&gt;
References: &lt;0c740d356f8d30310bcff2b06cfefad0e72769e2.1344844502.git.minovotn@redhat.com&gt;
From: Alex Williamson &lt;alex.williamson@redhat.com&gt;
Date: Tue, 7 Aug 2012 19:41:38 +0200
Subject: [PATCH 5/5] acpi: explicitly account for &gt;1 device per slot

RH-Author: Alex Williamson &lt;alex.williamson@redhat.com&gt;
Message-id: &lt;20120807194138.6021.10612.stgit@bling.home&gt;
Patchwork-id: 40609
O-Subject: [RHEL6.4 qemu-kvm PATCH 5/5] acpi: explicitly account for &gt;1 device per slot
Bugzilla: 807391
RH-Acked-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
RH-Acked-by: Igor Mammedov &lt;imammedo@redhat.com&gt;
RH-Acked-by: Don Dutile &lt;ddutile@redhat.com&gt;

From: Michael S. Tsirkin &lt;mst@redhat.com&gt;

Bugzilla: 807391
Upstream commit: 54bfa546a0b5af335128ef5c477f8af9834df498

Slot present bit is cleared apparently for each device. Hotplug and non
hotplug devices should not mix normally, and we only set the bit when we
add a device so it should all work out, but it's more robust to
explicitly account for more than one device per slot.

Acked-by: Alex Williamson &lt;alex.williamson@redhat.com&gt;
Signed-off-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
---

 hw/acpi.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

Signed-off-by: Michal Novotny &lt;minovotn@redhat.com&gt;
---
 hw/acpi.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/hw/acpi.c b/hw/acpi.c
index e1d8288..8501f3e 100644
--- a/hw/acpi.c
+++ b/hw/acpi.c
@@ -569,6 +569,7 @@ static void acpi_piix_eject_slot(PIIX4PMState *s, unsigned slots)
     DeviceState *qdev, *next;
     BusState *bus = qdev_get_parent_bus(&amp;s-&gt;dev.qdev);
     int slot = ffs(slots) - 1;
+    bool slot_free = true;
 
     /* Mark request as complete */
     s-&gt;pci0_status.down &amp;= ~(1U &lt;&lt; slot);
@@ -576,11 +577,17 @@ static void acpi_piix_eject_slot(PIIX4PMState *s, unsigned slots)
     QTAILQ_FOREACH_SAFE(qdev, &amp;bus-&gt;children, sibling, next) {
         PCIDevice *dev = DO_UPCAST(PCIDevice, qdev, qdev);
         PCIDeviceInfo *info = container_of(qdev-&gt;info, PCIDeviceInfo, qdev);
-        if (PCI_SLOT(dev-&gt;devfn) == slot &amp;&amp; !info-&gt;no_hotplug) {
-            s-&gt;pci0_slot_device_present &amp;= ~(1U &lt;&lt; slot);
-            qdev_free(qdev);
+        if (PCI_SLOT(dev-&gt;devfn) == slot) {
+            if (info-&gt;no_hotplug) {
+                slot_free = false;
+            } else {
+                qdev_free(qdev);
+            }
         }
     }
+    if (slot_free) {
+        s-&gt;pci0_slot_device_present &amp;= ~(1U &lt;&lt; slot);
+    }
 
 }
 
-- 
1.7.11.2

</pre></body></html>