qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 1/6] pcie: fix pcie_cap_slot_write_config().


From: Isaku Yamahata
Subject: [Qemu-devel] [PATCH 1/6] pcie: fix pcie_cap_slot_write_config().
Date: Wed, 27 Oct 2010 19:21:16 +0900

This patch fixes pcie_cap_slot_write_config() which is broken by
5704608988972359473ce609f9e4884808115b58
The command completion event should generated only when the command
is issued (and the command is completed).

>From 6.7.3.2
> Software issues a command to a hot-plug capable Downstream Port by
> issuing a write transaction that targets any portion of the
> Port's Slot Control register. A single write to the Slot Control
> register is considered to be a single command
...
> The Port must process the command normally even if the status field is
> already set when the command is issued.

Signed-off-by: Isaku Yamahata <address@hidden>
---
 hw/pcie.c |   25 ++++++++++++++-----------
 1 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/hw/pcie.c b/hw/pcie.c
index 0385f53..64cc003 100644
--- a/hw/pcie.c
+++ b/hw/pcie.c
@@ -19,6 +19,7 @@
  */
 
 #include "sysemu.h"
+#include "range.h"
 #include "pci_bridge.h"
 #include "pcie.h"
 #include "msix.h"
@@ -323,17 +324,19 @@ void pcie_cap_slot_write_config(PCIDevice *dev,
 
     hotplug_event_notify(dev);
 
-    /* command completion.
-     * Real hardware might take a while to complete
-     * requested command because physical movement would be involved
-     * like locking the electromechanical lock.
-     * However in our case, command is completed instantaneously above,
-     * so send a command completion event right now.
-     *
-     * 6.7.3.2 Command Completed Events
-     */
-    /* set command completed bit */
-    pcie_cap_slot_event(dev, PCI_EXP_HP_EV_CCI);
+    if (ranges_overlap(addr, len, pos + PCI_EXP_SLTCTL, 2)) {
+        /* command completion.
+         * Real hardware might take a while to complete
+         * requested command because physical movement would be involved
+         * like locking the electromechanical lock.
+         * However in our case, command is completed instantaneously above,
+         * so send a command completion event right now.
+         *
+         * 6.7.3.2 Command Completed Events
+         */
+        /* set command completed bit */
+        pcie_cap_slot_event(dev, PCI_EXP_HP_EV_CCI);
+    }
 }
 
 void pcie_cap_slot_push_attention_button(PCIDevice *dev)
-- 
1.7.1.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]