From: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
To: Alex Williamson <alex.williamson@redhat.com>,
Cao jin <caoj.fnst@cn.fujitsu.com>,
qemu-devel@nongnu.org
Cc: izumi.taku@jp.fujitsu.com, mst@redhat.com
Subject: Re: [Qemu-devel] [PATCH v16 10/14] pci: introduce pci bus pre reset
Date: Tue, 19 Jan 2016 18:15:35 +0800 [thread overview]
Message-ID: <569E0CC7.8030304@cn.fujitsu.com> (raw)
In-Reply-To: <1452803789.14628.88.camel@redhat.com>
On 01/15/2016 04:36 AM, Alex Williamson wrote:
> On Tue, 2016-01-12 at 10:43 +0800, Cao jin wrote:
>> From: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
>>
>> 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 <chen.fan.fnst@cn.fujitsu.com>
>> ---
>> 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++;
> Doesn't this need to come from a global sequence ID? Imagine the case
> of a nested bus, the leaf bus is reset incrementing the sequence ID.
> The devices on that bus store that sequence ID as they're reset. The
> parent bus is then reset, but all the devices on the leaf bus have
> already been reset for that sequence ID and ignore the reset.
>
>> +
>> + pci_bus_pre_reset(&s->sec_bus, seqid ? seqid : 1);
> Does this work? Seems like this would make devices ignore the second
> bus reset after the VM is instantiated. ie. the first bus reset seqid
> is 0, so we call pre_reset with 1, the second time we call it with 1
> again.
>
>> qbus_reset_all(&s->sec_bus.qbus);
> I'd be tempted to call qbus_walk_children() directly, it already has a
> pre_busfn callback hook.
Hi Alex,
this looks like need to change much pci core code, as Michael suggested
in 00/14,
maybe we should simply the aer implementation. what do you think of that?
Thanks,
Chen
>
>> }
>> }
>> 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;
>> };
>>
>
>
> .
>
next prev parent reply other threads:[~2016-01-19 10:20 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-12 2:43 [Qemu-devel] [PATCH v16 00/14] vfio-pci: pass the aer error to guest Cao jin
2016-01-12 2:43 ` [Qemu-devel] [PATCH v16 01/14] vfio: extract vfio_get_hot_reset_info as a single function Cao jin
2016-01-17 12:48 ` Marcel Apfelbaum
2016-01-12 2:43 ` [Qemu-devel] [PATCH v16 02/14] vfio: squeeze out vfio_pci_do_hot_reset for support bus reset Cao jin
2016-01-17 13:01 ` Marcel Apfelbaum
2016-01-12 2:43 ` [Qemu-devel] [PATCH v16 03/14] pcie: modify the capability size assert Cao jin
2016-01-12 2:43 ` [Qemu-devel] [PATCH v16 04/14] vfio: make the 4 bytes aligned for capability size Cao jin
2016-01-17 12:30 ` Marcel Apfelbaum
2016-01-12 2:43 ` [Qemu-devel] [PATCH v16 05/14] vfio: add pcie extanded capability support Cao jin
2016-01-17 13:22 ` Marcel Apfelbaum
2016-01-19 9:44 ` Chen Fan
2016-01-12 2:43 ` [Qemu-devel] [PATCH v16 06/14] aer: impove pcie_aer_init to support vfio device Cao jin
2016-01-12 2:43 ` [Qemu-devel] [PATCH v16 07/14] vfio: add aer support for " Cao jin
2016-01-18 9:12 ` Marcel Apfelbaum
2016-01-19 9:47 ` Chen Fan
2016-01-12 2:43 ` [Qemu-devel] [PATCH v16 08/14] vfio: add check host bus reset is support or not Cao jin
2016-01-18 10:32 ` Marcel Apfelbaum
2016-01-19 9:55 ` Chen Fan
2016-01-12 2:43 ` [Qemu-devel] [PATCH v16 09/14] add check reset mechanism when hotplug vfio device Cao jin
2016-01-18 11:03 ` Marcel Apfelbaum
2016-01-19 1:46 ` Cao jin
2016-01-12 2:43 ` [Qemu-devel] [PATCH v16 10/14] pci: introduce pci bus pre reset Cao jin
2016-01-14 20:36 ` Alex Williamson
2016-01-19 10:15 ` Chen Fan [this message]
2016-01-12 2:43 ` [Qemu-devel] [PATCH v16 11/14] vfio: introduce last reset sequence id Cao jin
2016-01-14 20:43 ` Alex Williamson
2016-01-12 2:43 ` [Qemu-devel] [PATCH v16 12/14] pcie_aer: expose pcie_aer_msg() interface Cao jin
2016-01-12 2:43 ` [Qemu-devel] [PATCH v16 13/14] vfio-pci: pass the aer error to guest Cao jin
2016-01-18 10:45 ` Marcel Apfelbaum
2016-01-19 9:27 ` Chen Fan
2016-01-12 2:43 ` [Qemu-devel] [PATCH v16 14/14] vfio: add 'aer' property to expose aercap Cao jin
2016-01-18 10:46 ` Marcel Apfelbaum
2016-01-16 18:34 ` [Qemu-devel] [PATCH v16 00/14] vfio-pci: pass the aer error to guest Michael S. Tsirkin
2016-01-19 9:09 ` Chen Fan
2016-02-03 8:54 ` Chen Fan
2016-02-03 13:57 ` Michael S. Tsirkin
2016-02-04 2:04 ` Chen Fan
2016-02-04 11:21 ` Michael S. Tsirkin
2016-02-04 17:46 ` Alex Williamson
2016-02-04 18:09 ` Michael S. Tsirkin
2016-02-04 20:15 ` Alex Williamson
2016-02-04 21:58 ` Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=569E0CC7.8030304@cn.fujitsu.com \
--to=chen.fan.fnst@cn.fujitsu.com \
--cc=alex.williamson@redhat.com \
--cc=caoj.fnst@cn.fujitsu.com \
--cc=izumi.taku@jp.fujitsu.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.