From: "Michael S. Tsirkin" <mst@redhat.com>
To: Aleksandr Bezzubikov <zuban32s@gmail.com>
Cc: seabios@seabios.org, marcel@redhat.com, kevin@koconnor.net,
lersek@redhat.com, qemu-devel@nongnu.org, kraxel@redhat.com
Subject: Re: [Qemu-devel] [PATCH v3 3/3] pci: enable RedHat PCI bridges to reserve additional buses on PCI init
Date: Mon, 31 Jul 2017 16:56:26 +0300 [thread overview]
Message-ID: <20170731165401-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <1501284872-2078-4-git-send-email-zuban32s@gmail.com>
On Sat, Jul 29, 2017 at 02:34:32AM +0300, Aleksandr Bezzubikov wrote:
> In case of Red Hat Generic PCIE Root Port reserve additional buses,
> which number is provided in a vendor-specific capability.
>
> Signed-off-by: Aleksandr Bezzubikov <zuban32s@gmail.com>
Why does this ignore io/memory reserve parts of the capability?
> ---
> src/fw/pciinit.c | 37 +++++++++++++++++++++++++++++++++++--
> src/hw/pci_ids.h | 3 +++
> src/types.h | 2 ++
> 3 files changed, 40 insertions(+), 2 deletions(-)
>
> diff --git a/src/fw/pciinit.c b/src/fw/pciinit.c
> index 864954f..a302a85 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 "fw/dev-pci.h" // qemu_pci_cap
> #include "list.h" // struct hlist_node
> #include "malloc.h" // free
> #include "output.h" // dprintf
> @@ -578,9 +579,41 @@ 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 &&
> + pci_config_readw(bdf, PCI_DEVICE_ID) ==
> + PCI_DEVICE_ID_REDHAT_ROOT_PORT) {
> + u8 cap;
> + do {
> + cap = pci_find_capability(bdf, PCI_CAP_ID_VNDR, 0);
> + } while (cap &&
> + pci_config_readb(bdf, cap + PCI_CAP_VNDR_SPEC_TYPE) !=
> + REDHAT_CAP_TYPE_QEMU);
> + if (cap) {
> + u8 cap_len = pci_config_readb(bdf, cap + PCI_CAP_FLAGS);
> + if (cap_len != QEMU_PCI_CAP_SIZE) {
> + dprintf(1, "PCI: QEMU cap length %d is invalid\n",
> + cap_len);
> + } else {
> + res_bus = pci_config_readb(bdf,
> + cap + QEMU_PCI_CAP_BUS_RES);
> + if ((u8)(res_bus + secbus) < secbus ||
> + (u8)(res_bus + secbus) < res_bus) {
> + dprintf(1, "PCI: bus_reserve value %d is invalid\n",
> + res_bus);
> + res_bus = 0;
> + } else {
> + dprintf(1, "PCI: QEMU cap is found, value = %u\n",
> + res_bus);
> + }
> + }
> + }
> + res_bus = MAX(*pci_bus, secbus + res_bus);
> + }
> dprintf(1, "PCI: subordinate bus = 0x%x -> 0x%x\n",
> - subbus, *pci_bus);
> - subbus = *pci_bus;
> + subbus, res_bus);
> + subbus = res_bus;
> + *pci_bus = res_bus;
> } else {
> dprintf(1, "PCI: subordinate bus = 0x%x\n", subbus);
> }
> diff --git a/src/hw/pci_ids.h b/src/hw/pci_ids.h
> index 4ac73b4..38fa2ca 100644
> --- a/src/hw/pci_ids.h
> +++ b/src/hw/pci_ids.h
> @@ -2263,6 +2263,9 @@
> #define PCI_DEVICE_ID_KORENIX_JETCARDF0 0x1600
> #define PCI_DEVICE_ID_KORENIX_JETCARDF1 0x16ff
>
> +#define PCI_VENDOR_ID_REDHAT 0x1b36
> +#define PCI_DEVICE_ID_REDHAT_ROOT_PORT 0x000C
> +
> #define PCI_VENDOR_ID_TEKRAM 0x1de1
> #define PCI_DEVICE_ID_TEKRAM_DC290 0xdc29
>
> diff --git a/src/types.h b/src/types.h
> index 19d9f6c..75d9108 100644
> --- a/src/types.h
> +++ b/src/types.h
> @@ -122,6 +122,8 @@ extern void __force_link_error__only_in_16bit(void) __noreturn;
> typeof(divisor) __divisor = divisor; \
> (((x) + ((__divisor) / 2)) / (__divisor)); \
> })
> +#define MIN(a, b) (((a) < (b)) ? (a) : (b))
> +#define MAX(a, b) (((a) > (b)) ? (a) : (b))
> #define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
> #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
> #define ALIGN_DOWN(x,a) ((x) & ~((typeof(x))(a)-1))
> --
> 2.7.4
prev parent reply other threads:[~2017-07-31 13:56 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-28 23:34 [Qemu-devel] [PATCH v3 0/3] Allow RedHat PCI bridges reserve more buses than necessary during init Aleksandr Bezzubikov
2017-07-28 23:34 ` [Qemu-devel] [PATCH v3 1/3] pci: refactor pci_find_capapibilty to get bdf as the first argument instead of the whole pci_device Aleksandr Bezzubikov
2017-07-28 23:34 ` [Qemu-devel] [PATCH v3 2/3] pci: add QEMU-specific PCI capability structure Aleksandr Bezzubikov
2017-07-31 10:48 ` Marcel Apfelbaum
2017-07-31 14:00 ` Michael S. Tsirkin
2017-07-31 14:09 ` Marcel Apfelbaum
2017-07-31 18:54 ` Alexander Bezzubikov
2017-07-31 18:57 ` Michael S. Tsirkin
2017-07-31 19:01 ` Alexander Bezzubikov
2017-08-01 13:38 ` Marcel Apfelbaum
2017-08-01 17:28 ` Alexander Bezzubikov
2017-08-04 18:59 ` Alexander Bezzubikov
2017-08-04 20:28 ` Laszlo Ersek
2017-08-04 20:47 ` Alexander Bezzubikov
2017-08-06 19:58 ` Marcel Apfelbaum
2017-07-28 23:34 ` [Qemu-devel] [PATCH v3 3/3] pci: enable RedHat PCI bridges to reserve additional buses on PCI init Aleksandr Bezzubikov
2017-07-31 11:00 ` Marcel Apfelbaum
2017-07-31 13:50 ` Kevin O'Connor
2017-07-31 13:56 ` Michael S. Tsirkin [this message]
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=20170731165401-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=kevin@koconnor.net \
--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.