qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Marcel Apfelbaum <marcel@redhat.com>
To: Aleksandr Bezzubikov <zuban32s@gmail.com>, qemu-devel@nongnu.org
Cc: mst@redhat.com, imammedo@redhat.com, pbonzini@redhat.com,
	rth@twiddle.net, ehabkost@redhat.com, kevin@koconnor.net,
	kraxel@redhat.com, lersek@redhat.com, seabios@seabios.org
Subject: Re: [Qemu-devel] [PATCH v4 3/5] hw/pci: introduce bridge-only vendor-specific capability to provide some hints to firmware
Date: Mon, 7 Aug 2017 19:44:53 +0300	[thread overview]
Message-ID: <e45c9a22-8a8c-491e-d353-e207b7bfa841@redhat.com> (raw)
In-Reply-To: <1501964858-5159-4-git-send-email-zuban32s@gmail.com>

On 05/08/2017 23:27, Aleksandr Bezzubikov wrote:
> On PCI init PCI bridges may need some extra info about bus number,
> IO, memory and prefetchable memory to reserve. QEMU can provide this
> with a special vendor-specific PCI capability.
> 

Hi Aleksandr,

> Signed-off-by: Aleksandr Bezzubikov <zuban32s@gmail.com>
> ---
>   hw/pci/pci_bridge.c         | 29 +++++++++++++++++++++++++++++
>   include/hw/pci/pci_bridge.h | 21 +++++++++++++++++++++
>   2 files changed, 50 insertions(+)
> 
> diff --git a/hw/pci/pci_bridge.c b/hw/pci/pci_bridge.c
> index 720119b..889950d 100644
> --- a/hw/pci/pci_bridge.c
> +++ b/hw/pci/pci_bridge.c
> @@ -408,6 +408,35 @@ void pci_bridge_map_irq(PCIBridge *br, const char* bus_name,
>       br->bus_name = bus_name;
>   }
>   
> +
> +int pci_bridge_qemu_reserve_cap_init(PCIDevice *dev, int cap_offset,
> +                              uint32_t bus_reserve, uint64_t io_reserve,
> +                              uint64_t non_pref_mem_reserve,
> +                              uint64_t pref_mem_reserve,
> +                              Error **errp)
> +{
> +    size_t cap_len = sizeof(PCIBridgeQemuCap);
> +    PCIBridgeQemuCap cap = {
> +            .len = cap_len,
> +            .type = REDHAT_PCI_CAP_QEMU_RESERVE,

I would change the type to:
    REDHAT_PCI_CAP_RESOURCE_RESERVE

QEMU is less important here (I think) than "resource".

> +            .bus_res = bus_reserve,
> +            .io = io_reserve,
> +            .mem = non_pref_mem_reserve,
> +            .mem_pref = pref_mem_reserve
> +    };
> +
> +    int offset = pci_add_capability(dev, PCI_CAP_ID_VNDR,
> +                                    cap_offset, cap_len, errp);
> +    if (offset < 0) {
> +        return offset;
> +    }
> +
> +    memcpy(dev->config + offset + PCI_CAP_FLAGS,
> +            (char *)&cap + PCI_CAP_FLAGS,
> +            cap_len - PCI_CAP_FLAGS);
> +    return 0;
> +}
> +
>   static const TypeInfo pci_bridge_type_info = {
>       .name = TYPE_PCI_BRIDGE,
>       .parent = TYPE_PCI_DEVICE,
> diff --git a/include/hw/pci/pci_bridge.h b/include/hw/pci/pci_bridge.h
> index ff7cbaa..be565f7 100644
> --- a/include/hw/pci/pci_bridge.h
> +++ b/include/hw/pci/pci_bridge.h
> @@ -67,4 +67,25 @@ void pci_bridge_map_irq(PCIBridge *br, const char* bus_name,
>   #define  PCI_BRIDGE_CTL_DISCARD_STATUS	0x400	/* Discard timer status */
>   #define  PCI_BRIDGE_CTL_DISCARD_SERR	0x800	/* Discard timer SERR# enable */
>   
> +typedef struct PCIBridgeQemuCap {
> +    uint8_t id;     /* Standard PCI capability header field */
> +    uint8_t next;   /* Standard PCI capability header field */
> +    uint8_t len;    /* Standard PCI vendor-specific capability header field */
> +    uint8_t type;   /* Red Hat vendor-specific capability type.
> +                       Types are defined with REDHAT_PCI_CAP_ prefix */
> +
> +    uint32_t bus_res;   /* Minimum number of buses to reserve */
> +    uint64_t io;        /* IO space to reserve */
> +    uint64_t mem;       /* Non-prefetchable memory to reserve */
> +    uint64_t mem_pref;  /* Prefetchable memory to reserve */
> +} PCIBridgeQemuCap;
> +
> +#define REDHAT_PCI_CAP_QEMU_RESERVE     1
> +
> +int pci_bridge_qemu_reserve_cap_init(PCIDevice *dev, int cap_offset,
> +                              uint32_t bus_reserve, uint64_t io_reserve,
> +                              uint64_t non_pref_mem_reserve,
> +                              uint64_t pref_mem_reserve,
> +                              Error **errp);
> +
>   #endif /* QEMU_PCI_BRIDGE_H */
> 

With the name change, the layout looks good to me:

    Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>

Thanks,
Marcel

  reply	other threads:[~2017-08-07 16:45 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-05 20:27 [Qemu-devel] [PATCH v4 0/5] Generic PCIE-PCI Bridge Aleksandr Bezzubikov
2017-08-05 20:27 ` [Qemu-devel] [PATCH v4 1/5] hw/i386: allow SHPC for Q35 machine Aleksandr Bezzubikov
2017-08-08 14:48   ` [Qemu-devel] acpi-test: Warning! DSDT mismatch (was: [PATCH v4 1/5] hw/i386: allow SHPC for Q35 machine) Thomas Huth
2017-08-08 15:35     ` Michael S. Tsirkin
2017-08-08 18:38       ` [Qemu-devel] acpi-test: Warning! DSDT mismatch Thomas Huth
2017-08-08 19:37         ` Michael S. Tsirkin
2017-08-05 20:27 ` [Qemu-devel] [PATCH v4 2/5] hw/pci: introduce pcie-pci-bridge device Aleksandr Bezzubikov
2017-08-07 16:39   ` Marcel Apfelbaum
2017-08-07 16:42     ` Alexander Bezzubikov
2017-08-07 16:54       ` Marcel Apfelbaum
2017-08-05 20:27 ` [Qemu-devel] [PATCH v4 3/5] hw/pci: introduce bridge-only vendor-specific capability to provide some hints to firmware Aleksandr Bezzubikov
2017-08-07 16:44   ` Marcel Apfelbaum [this message]
2017-08-05 20:27 ` [Qemu-devel] [PATCH v4 4/5] hw/pci: add QEMU-specific PCI capability to the Generic PCI Express Root Port Aleksandr Bezzubikov
2017-08-07 16:48   ` Marcel Apfelbaum
2017-08-08 19:54   ` Michael S. Tsirkin
2017-08-08 20:10     ` Aleksandr Bezzubikov
2017-08-08 20:15       ` Michael S. Tsirkin
2017-08-05 20:27 ` [Qemu-devel] [PATCH v4 5/5] docs: update documentation considering PCIE-PCI bridge Aleksandr Bezzubikov
2017-08-08 15:11   ` Laszlo Ersek
2017-08-08 19:21     ` Aleksandr Bezzubikov
2017-08-09 10:18       ` Laszlo Ersek
2017-08-09 16:52         ` Aleksandr Bezzubikov
2017-08-09 17:44           ` Laszlo Ersek

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=e45c9a22-8a8c-491e-d353-e207b7bfa841@redhat.com \
    --to=marcel@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=kevin@koconnor.net \
    --cc=kraxel@redhat.com \
    --cc=lersek@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).