From: Cao jin <caoj.fnst@cn.fujitsu.com>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: pbonzini@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/2] PCI-e device multi-function hot-add support
Date: Tue, 15 Sep 2015 14:23:00 +0800 [thread overview]
Message-ID: <55F7B944.1090108@cn.fujitsu.com> (raw)
In-Reply-To: <1441898967.20355.578.camel@redhat.com>
Hi, Alex,
Thanks very much for your quick review and I am sorry for my late
response.
On 09/10/2015 11:29 PM, Alex Williamson wrote:
> On Thu, 2015-09-10 at 20:12 +0800, Cao jin wrote:
>> Enable PCI-e device multifunction hot, just ensure the function 0
>> added last, then driver will got the notification to scan all the
>> function in the slot.
>>
>> Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
>> ---
>> hw/pci/pcie.c | 22 +++++++++++++---------
>> 1 file changed, 13 insertions(+), 9 deletions(-)
>>
>> diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
>> index 6e28985..61ebefd 100644
>> --- a/hw/pci/pcie.c
>> +++ b/hw/pci/pcie.c
>> @@ -249,16 +249,20 @@ void pcie_cap_slot_hotplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
>> return;
>> }
>>
>> - /* TODO: multifunction hot-plug.
>> - * Right now, only a device of function = 0 is allowed to be
>> - * hot plugged/unplugged.
>> + /* To enable multifunction hot-plug, we just ensure the function
>> + * 0 added last. Until function 0 added, we set the sltsta and
>> + * inform OS via event notification.
>> */
>> - assert(PCI_FUNC(pci_dev->devfn) == 0);
>> -
>> - pci_word_test_and_set_mask(exp_cap + PCI_EXP_SLTSTA,
>> - PCI_EXP_SLTSTA_PDS);
>> - pcie_cap_slot_event(PCI_DEVICE(hotplug_dev),
>> - PCI_EXP_HP_EV_PDC | PCI_EXP_HP_EV_ABP);
>> + if (!(pci_dev->cap_present & QEMU_PCI_CAP_MULTIFUNCTION) &&
>> + PCI_FUNC(pci_dev->devfn) > 0) {
>
> The PCI spec is actually not entirely clear about whether each function
> in a multifunction device needs to have the multifunction bit set or if
> only function 0 needs to set it. From a discovery perspective, a kernel
> should only scan for function 0 and only scan non-zero funcions if
> function 0 reports the multifunction bit set. Therefore, it doesn't
> particularly matter what non-zero functions report for the multifunction
> bit. QEMU allows either interpretation (see comment in
> pci_init_multifunction), so this appears to be a new requirement that
> breaks assumptions elsewhere. Thanks,
>
> Alex
>
Yes, PCI Spec does not describe it clearly. The if() here, is based on
the condition like following:
(qemu) device_add e1000,bus=pb1,id=net1,addr=00.1
(qemu) device_add e1000,bus=pb1,id=net0,addr=00.0
PCI: 0.0 indicates single function, but 0.1 is already populated.
Now, we can see the net1 via "info pci" while can`t see net1 in guest
via "lspci -t", so I think maybe it is not good condition, but no big
deal, so I use the if() to prevent the condition.
will remove the if() in next version.
>> + error_setg(errp, "single function device, function number must be 0,"
>> + "but got %d", PCI_FUNC(pci_dev->devfn));
>> + } else if (PCI_FUNC(pci_dev->devfn) == 0) {
>> + pci_word_test_and_set_mask(exp_cap + PCI_EXP_SLTSTA,
>> + PCI_EXP_SLTSTA_PDS);
>> + pcie_cap_slot_event(PCI_DEVICE(hotplug_dev),
>> + PCI_EXP_HP_EV_PDC | PCI_EXP_HP_EV_ABP);
>> + }
>> }
>>
>> void pcie_cap_slot_hot_unplug_request_cb(HotplugHandler *hotplug_dev,
>
>
>
> .
>
--
Yours Sincerely,
Cao Jin
next prev parent reply other threads:[~2015-09-15 6:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-10 12:12 [Qemu-devel] [PATCH 0/2] PCI-e device multi-function hot-add support Cao jin
2015-09-10 12:12 ` [Qemu-devel] [PATCH 1/2] " Cao jin
2015-09-10 15:29 ` Alex Williamson
2015-09-15 6:23 ` Cao jin [this message]
2015-09-10 12:12 ` [Qemu-devel] [PATCH 2/2] " Cao jin
2015-09-10 15:29 ` Alex Williamson
2015-09-11 14:35 ` Igor Mammedov
2015-09-16 2:17 ` Cao jin
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=55F7B944.1090108@cn.fujitsu.com \
--to=caoj.fnst@cn.fujitsu.com \
--cc=alex.williamson@redhat.com \
--cc=pbonzini@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.