From: "Michael S. Tsirkin" <mst@redhat.com>
To: Aleksandr Bezzubikov <zuban32s@gmail.com>
Cc: seabios@seabios.org, marcel@redhat.com, kraxel@redhat.com,
kevin@koconnor.net, lersek@redhat.com, qemu-devel@nongnu.org,
konrad.wilk@oracle.com
Subject: Re: [Qemu-devel] [RFC PATCH v2 4/4] pci: enable RedHat PCI bridges to reserve additional buses on PCI init
Date: Sun, 23 Jul 2017 05:49:18 +0300 [thread overview]
Message-ID: <20170723054445-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <1500761510-1556-5-git-send-email-zuban32s@gmail.com>
On Sun, Jul 23, 2017 at 01:11:50AM +0300, Aleksandr Bezzubikov wrote:
> In case of Red Hat PCI bridges reserve additional buses, which number is provided
> in a vendor-specific capability.
>
> Signed-off-by: Aleksandr Bezzubikov <zuban32s@gmail.com>
> ---
> src/fw/pciinit.c | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/src/fw/pciinit.c b/src/fw/pciinit.c
> index 864954f..f05a8b9 100644
> --- a/src/fw/pciinit.c
> +++ b/src/fw/pciinit.c
> @@ -15,6 +15,7 @@
> #include "hw/pcidevice.h" // pci_probe_devices
> #include "hw/pci_ids.h" // PCI_VENDOR_ID_INTEL
> #include "hw/pci_regs.h" // PCI_COMMAND
> +#include "hw/pci_cap.h" // qemu_pci_cap
> #include "list.h" // struct hlist_node
> #include "malloc.h" // free
> #include "output.h" // dprintf
> @@ -578,9 +579,18 @@ pci_bios_init_bus_rec(int bus, u8 *pci_bus)
> pci_bios_init_bus_rec(secbus, pci_bus);
>
> if (subbus != *pci_bus) {
> + u8 res_bus = 0;
> + if (pci_config_readw(bdf, PCI_VENDOR_ID) == PCI_VENDOR_ID_REDHAT) {
Check device ID as well.
> + u8 cap = pci_find_capability(bdf, PCI_CAP_ID_VNDR, 0);
There could be multiple vendor capabilities. You want to scan them all.
> + if (cap) {
> + res_bus = pci_config_readb(bdf,
> + cap + offsetof(struct redhat_pci_bridge_cap,
> + bus_res));
You might want to add sanity checks e.g. overflow, and capability
length.
Also, if all you use is offsetof, don't bother with a struct, just
add some defines.
> + }
> + }
> dprintf(1, "PCI: subordinate bus = 0x%x -> 0x%x\n",
> - subbus, *pci_bus);
> - subbus = *pci_bus;
> + subbus, *pci_bus + res_bus);
> + subbus = *pci_bus + res_bus;
So you take all present devices and add reserved ones - is that it?
If so it looks like this will steal extra buses each time you
add a child bus and reboot.
> } else {
> dprintf(1, "PCI: subordinate bus = 0x%x\n", subbus);
> }
> --
> 2.7.4
next prev parent reply other threads:[~2017-07-23 2:49 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-22 22:11 [Qemu-devel] [RFC PATCH v2 0/4] Allow RedHat PCI bridges reserve more buses than necessary during init Aleksandr Bezzubikov
2017-07-22 22:11 ` [Qemu-devel] [RFC PATCH v2 1/4] pci: refactor pci_find_capapibilty to get bdf as the first argument instead of the whole pci_device Aleksandr Bezzubikov
2017-07-23 16:04 ` Marcel Apfelbaum
2017-07-23 16:24 ` Kevin O'Connor
2017-07-22 22:11 ` [Qemu-devel] [RFC PATCH v2 2/4] pci: add RedHat vendor ID Aleksandr Bezzubikov
2017-07-23 16:05 ` Marcel Apfelbaum
2017-07-22 22:11 ` [Qemu-devel] [RFC PATCH v2 3/4] pci: add QEMU-specific PCI capability structure Aleksandr Bezzubikov
2017-07-23 2:44 ` Michael S. Tsirkin
2017-07-23 16:12 ` Alexander Bezzubikov
2017-07-23 16:30 ` Kevin O'Connor
2017-07-23 16:47 ` Alexander Bezzubikov
2017-07-22 22:11 ` [Qemu-devel] [RFC PATCH v2 4/4] pci: enable RedHat PCI bridges to reserve additional buses on PCI init Aleksandr Bezzubikov
2017-07-23 2:49 ` Michael S. Tsirkin [this message]
2017-07-23 16:43 ` Alexander Bezzubikov
2017-07-23 19:44 ` Alexander Bezzubikov
2017-07-24 9:42 ` Gerd Hoffmann
2017-07-24 14:39 ` Alexander Bezzubikov
2017-07-24 14:55 ` Marcel Apfelbaum
2017-07-25 15:46 ` [Qemu-devel] [RFC PATCH v2 0/4] Allow RedHat PCI bridges reserve more buses than necessary during init Laszlo Ersek
2017-07-26 6:48 ` Marcel Apfelbaum
2017-07-26 15:20 ` Laszlo Ersek
2017-07-26 16:22 ` Marcel Apfelbaum
2017-07-26 18:31 ` Laszlo Ersek
2017-07-27 18:18 ` Marcel Apfelbaum
2017-07-26 18:49 ` Michael S. Tsirkin
2017-07-27 18:24 ` Marcel Apfelbaum
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=20170723054445-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=kevin@koconnor.net \
--cc=konrad.wilk@oracle.com \
--cc=kraxel@redhat.com \
--cc=lersek@redhat.com \
--cc=marcel@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=seabios@seabios.org \
--cc=zuban32s@gmail.com \
/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.