[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v16 10/14] pci: introduce pci bus pre reset
From: |
Cao jin |
Subject: |
[Qemu-devel] [PATCH v16 10/14] pci: introduce pci bus pre reset |
Date: |
Tue, 12 Jan 2016 10:43:11 +0800 |
From: Chen Fan <address@hidden>
avoid repeat bus reset, here introduce a sequence ID for each time
bus hot reset, so each vfio device could know whether they've already
been reset for that sequence ID.
Signed-off-by: Chen Fan <address@hidden>
---
hw/pci/pci.c | 13 +++++++++++++
hw/pci/pci_bridge.c | 3 +++
include/hw/pci/pci.h | 1 +
include/hw/pci/pci_bus.h | 3 +++
4 files changed, 20 insertions(+)
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index f6ca6ef..ceb72d5 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -91,6 +91,18 @@ static void pci_bus_unrealize(BusState *qbus, Error **errp)
vmstate_unregister(NULL, &vmstate_pcibus, bus);
}
+void pci_bus_pre_reset(PCIBus *bus, uint32_t seqid)
+{
+ PCIBus *sec;
+
+ bus->in_reset = true;
+ bus->reset_seqid = seqid;
+
+ QLIST_FOREACH(sec, &bus->child, sibling) {
+ pci_bus_pre_reset(sec, seqid);
+ }
+}
+
static bool pcibus_is_root(PCIBus *bus)
{
return !bus->parent_dev;
@@ -276,6 +288,7 @@ static void pcibus_reset(BusState *qbus)
for (i = 0; i < bus->nirq; i++) {
assert(bus->irq_count[i] == 0);
}
+ bus->in_reset = false;
}
static void pci_host_bus_register(PCIBus *bus, DeviceState *parent)
diff --git a/hw/pci/pci_bridge.c b/hw/pci/pci_bridge.c
index 40c97b1..c7f15a1 100644
--- a/hw/pci/pci_bridge.c
+++ b/hw/pci/pci_bridge.c
@@ -268,6 +268,9 @@ void pci_bridge_write_config(PCIDevice *d,
newctl = pci_get_word(d->config + PCI_BRIDGE_CONTROL);
if (~oldctl & newctl & PCI_BRIDGE_CTL_BUS_RESET) {
/* Trigger hot reset on 0->1 transition. */
+ uint32_t seqid = s->sec_bus.reset_seqid++;
+
+ pci_bus_pre_reset(&s->sec_bus, seqid ? seqid : 1);
qbus_reset_all(&s->sec_bus.qbus);
}
}
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index 379b6e1..b811279 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -381,6 +381,7 @@ void pci_bus_fire_intx_routing_notifier(PCIBus *bus);
void pci_device_set_intx_routing_notifier(PCIDevice *dev,
PCIINTxRoutingNotifier notifier);
void pci_device_reset(PCIDevice *dev);
+void pci_bus_pre_reset(PCIBus *bus, uint32_t seqid);
PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *rootbus,
const char *default_model,
diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
index 7812fa9..dd6aaf1 100644
--- a/include/hw/pci/pci_bus.h
+++ b/include/hw/pci/pci_bus.h
@@ -40,6 +40,9 @@ struct PCIBus {
int nirq;
int *irq_count;
+ bool in_reset;
+ uint32_t reset_seqid;
+
NotifierWithReturnList hotplug_notifiers;
};
--
1.9.3
- [Qemu-devel] [PATCH v16 05/14] vfio: add pcie extanded capability support, (continued)
- [Qemu-devel] [PATCH v16 05/14] vfio: add pcie extanded capability support, Cao jin, 2016/01/11
- [Qemu-devel] [PATCH v16 07/14] vfio: add aer support for vfio device, Cao jin, 2016/01/11
- [Qemu-devel] [PATCH v16 06/14] aer: impove pcie_aer_init to support vfio device, Cao jin, 2016/01/11
- [Qemu-devel] [PATCH v16 08/14] vfio: add check host bus reset is support or not, Cao jin, 2016/01/11
- [Qemu-devel] [PATCH v16 10/14] pci: introduce pci bus pre reset,
Cao jin <=
- [Qemu-devel] [PATCH v16 09/14] add check reset mechanism when hotplug vfio device, Cao jin, 2016/01/11
- [Qemu-devel] [PATCH v16 12/14] pcie_aer: expose pcie_aer_msg() interface, Cao jin, 2016/01/11
- [Qemu-devel] [PATCH v16 11/14] vfio: introduce last reset sequence id, Cao jin, 2016/01/11
- [Qemu-devel] [PATCH v16 13/14] vfio-pci: pass the aer error to guest, Cao jin, 2016/01/11