Allow RedHat PCI bridges reserve more buses than necessary during init
v3 cover Allow RedHat PCI bridges reserve more buses than necessary during init
Now PCI bridges get a bus range number on a system init,
basing on currently plugged devices. That's why when one wants to hotplug another bridge, it needs his child bus, which the parent is unable to provide (speaking about virtual device). The suggested workaround is to have vendor-specific capability in Red Hat PCI bridges that contains number of additional bus to reserve (as well as various space limit hints, unused for now) on BIOS PCI init.
So this capability is intented only for pure QEMU->SeaBIOS usage.
Considering all aforesaid, this series is directly connected with QEMU series (v3) "Generic PCIE-PCI Bridge".
Although the new PCI capability is supposed to contain various limits along with bus number to reserve, now only its full layout is proposed. And only bus_reserve field is used in QEMU and BIOS. Limits usage
is still a subject for implementation as now
the main goal of this series to provide necessary support from the firmware side to PCIE-PCI bridge hotplug.
Changes v2->v3:
1. Merge commit 2 (Red Hat vendor ID) into commit 4 - addresses Marcel's comment, and add Generic PCIE Root Port device ID - addresses Michael's comment.
2. Changes of the capability layout (QEMU side has the same changes):
- add 'type' field to distinguish multiple
RedHat-specific capabilities - addresses Michael's comment
- do not mimiс PCI Config space register layout, but use mutually exclusive differently sized fields for IO and prefetchable memory limits - addresses Laszlo's comment
- use defines instead of structure and offsetof - addresses Michael's comment
3. Interpret 'bus_reserve' field as a minimum necessary
range to reserve - addresses Gerd's comment
4. pci_find_capability moved to pci.c - addresses Kevin's comment
5. Move capability layout header to src/fw/dev-pci.h - addresses Kevin's comment
6. Add the capability documentation - addresses Michael's comment
7. Add capability length and bus_reserve field sanity checks - addresses Michael's comment
Changes v1->v2:
1. New #define for Red Hat vendor added (addresses Konrad's comment).
2. Refactored pci_find_capability function (addresses Marcel's comment).
3. Capability reworked:
- data type added;
- reserve space in a structure for IO, memory and prefetchable memory limits.
Aleksandr Bezzubikov (3):
pci: refactor pci_find_capapibilty to get bdf as the first argument
instead of the whole pci_device
pci: add QEMU-specific PCI capability structure
pci: enable RedHat PCI bridges to reserve additional buses on PCI init
src/fw/dev-pci.h | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/fw/pciinit.c | 41 +++++++++++++++++++++++++++++++---- src/hw/pci.c | 25 +++++++++++++++++++++ src/hw/pci.h | 1 + src/hw/pci_ids.h | 3 +++ src/hw/pcidevice.c | 24 --------------------- src/hw/pcidevice.h | 1 - src/hw/virtio-pci.c | 6 +++--- src/types.h | 2 ++ 9 files changed, 133 insertions(+), 32 deletions(-) create mode 100644 src/fw/dev-pci.h
Signature · 1 line
2.7.4
PATCH v3 1/3 pci: refactor pci_find_capapibilty to get bdf as the first argument instead of the whole pci_device
Refactor pci_find_capability function to get bdf instead of a whole pci_device* as the only necessary field for this function is still bdf.
--- src/fw/pciinit.c | 4 ++-- src/hw/pci.c | 25 +++++++++++++++++++++++++ src/hw/pci.h | 1 + src/hw/pcidevice.c | 24 ------------------------ src/hw/pcidevice.h | 1 - src/hw/virtio-pci.c | 6 +++--- 6 files changed, 31 insertions(+), 30 deletions(-)
src/fw/pciinit.c +2 -2
@@ -762,7 +762,7 @@ static int pci_bus_hotplug_support(struct pci_bus *bus, u8 pcie_cap)return downstream_port && slot_implemented; } - shpc_cap =pci_find_capability (bus->bus_dev,PCI_CAP_ID_SHPC ,0 ); + shpc_cap =pci_find_capability (bus->bus_dev->bdf,PCI_CAP_ID_SHPC ,0 );return !!shpc_cap; }
@@ -844,7 +844,7 @@ static int pci_bios_check_devices(struct pci_bus *busses)*/ parent = &busses[0 ];int type; -u8 pcie_cap =pci_find_capability (s->bus_dev,PCI_CAP_ID_EXP ,0 ); +u8 pcie_cap =pci_find_capability (s->bus_dev->bdf,PCI_CAP_ID_EXP ,0 );int hotplug_support =pci_bus_hotplug_support (s, pcie_cap);for (type =0 ; type <PCI_REGION_TYPE_COUNT ; type++) { u64 align = (type == PCI_REGION_TYPE_IO) ?
src/hw/pci.c +25 -0
@@ -58,6 +58,30 @@ pci_config_maskw(u16 bdf, u32 addr, u16 off, u16 on)pci_config_writew (bdf, addr, val); } +u8 pci_find_capability (u16 bdf,u8 cap_id,u8 cap) +{ +int i; +u16 status =pci_config_readw (bdf,PCI_STATUS ); + +if (!(status &PCI_STATUS_CAP_LIST )) +return 0 ; + +if (cap ==0 ) { +/* find first */ + cap =pci_config_readb (bdf,PCI_CAPABILITY_LIST ); + }else { +/* find next */ + cap =pci_config_readb (bdf, cap +PCI_CAP_LIST_NEXT ); + } +for (i =0 ; cap && i <=0xff ; i++) { +if (pci_config_readb (bdf, cap +PCI_CAP_LIST_ID ) == cap_id) +return cap; + cap =pci_config_readb (bdf, cap +PCI_CAP_LIST_NEXT ); + } + +return 0 ; +} +// Helper function for foreachbdf() macro - return next device int pci_next (int bdf,int bus)
@@ -107,3 +131,4 @@ pci_reboot(void)outb (v|6 ,PORT_PCI_REBOOT );/* Actually do the reset */ udelay (50 ); } +
src/hw/pci.h +1 -0
@@ -39,6 +39,7 @@ u32 pci_config_readl(u16 bdf, u32 addr);u16 pci_config_readw (u16 bdf,u32 addr);u8 pci_config_readb (u16 bdf,u32 addr);void pci_config_maskw (u16 bdf,u32 addr,u16 off,u16 on); +u8 pci_find_capability (u16 bdf,u8 cap_id,u8 cap);int pci_next (int bdf,int bus);int pci_probe_host (void );void pci_reboot (void );
src/hw/pcidevice.c +0 -24
@@ -134,30 +134,6 @@ pci_find_init_device(const struct pci_device_id *ids, void *arg)return NULL ; } -u8 pci_find_capability (struct pci_device *pci,u8 cap_id,u8 cap) -{ -int i; -u16 status =pci_config_readw (pci->bdf,PCI_STATUS ); - -if (!(status &PCI_STATUS_CAP_LIST )) -return 0 ; - -if (cap ==0 ) { -/* find first */ - cap =pci_config_readb (pci->bdf,PCI_CAPABILITY_LIST ); - }else { -/* find next */ - cap =pci_config_readb (pci->bdf, cap +PCI_CAP_LIST_NEXT ); - } -for (i =0 ; cap && i <=0xff ; i++) { -if (pci_config_readb (pci->bdf, cap +PCI_CAP_LIST_ID ) == cap_id) -return cap; - cap =pci_config_readb (pci->bdf, cap +PCI_CAP_LIST_NEXT ); - } - -return 0 ; -} -// Enable PCI bus-mastering (ie, DMA) support on a pci device void pci_enable_busmaster (struct pci_device *pci)
src/hw/pcidevice.h +0 -1
@@ -69,7 +69,6 @@ int pci_init_device(const struct pci_device_id *ids , struct pci_device *pci, void *arg);struct pci_device *pci_find_init_device (const struct pci_device_id *ids ,void *arg); -u8 pci_find_capability (struct pci_device *pci,u8 cap_id,u8 cap);void pci_enable_busmaster (struct pci_device *pci);u16 pci_enable_iobar (struct pci_device *pci,u32 addr);void *pci_enable_membar (struct pci_device *pci,u32 addr);
src/hw/virtio-pci.c +3 -3
@@ -19,7 +19,7 @@#include "malloc.h" // free #include "output.h" // dprintf #include "pci.h" // pci_config_readl -#include "pcidevice.h" // pci_find_capability +#include "pcidevice.h" // struct pci_device #include "pci_regs.h" // PCI_BASE_ADDRESS_0 #include "string.h" // memset #include "virtio-pci.h"
@@ -381,7 +381,7 @@ fail:void vp_init_simple (struct vp_device *vp,struct pci_device *pci) { -u8 cap =pci_find_capability (pci,PCI_CAP_ID_VNDR ,0 ); +u8 cap =pci_find_capability (pci->bdf,PCI_CAP_ID_VNDR ,0 );struct vp_cap *vp_cap;const char *mode;u32 offset, base, mul;
@@ -479,7 +479,7 @@ void vp_init_simple(struct vp_device *vp, struct pci_device *pci) vp_cap->cap, type, vp_cap->bar, addr, offset, mode); } - cap =pci_find_capability (pci,PCI_CAP_ID_VNDR , cap); + cap =pci_find_capability (pci->bdf,PCI_CAP_ID_VNDR , cap); }if (vp->common.cap && vp->notify.cap && vp->isr.cap && vp->device.cap) {
Signature · 1 line
2.7.4
PATCH v3 2/3 pci: add QEMU-specific PCI capability structure
In reply to Aleksandr BezzubikovOn PCI init PCI bridge devices may need some extra info about bus number to reserve, IO, memory and prefetchable memory limits. QEMU can provide this with special vendor-specific PCI capability.
This capability is intended to be used only for Red Hat PCI bridges, i.e. QEMU cooperation.
--- src/fw/dev-pci.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/fw/dev-pci.h
src/fw/dev-pci.h new file +62 -0
@@ -0,0 +1,62 @@ +#ifndef _PCI_CAP_H +#define _PCI_CAP_H + +#include "types.h" + +/* + +QEMU-specific vendor(Red Hat)-specific capability. +It's intended to provide some hints for firmware to init PCI devices. + +Its is shown below: + +Header: + +u8 id; Standard PCI Capability Header field +u8 next; Standard PCI Capability Header field +u8 len; Standard PCI Capability Header field +u8 type; Red Hat vendor-specific capability type: +now only REDHAT_QEMU_CAP 1 exists +Data: + +u16 non_prefetchable_16; non-prefetchable memory limit + +u8 bus_res; minimum bus number to reserve; +this is necessary for PCI Express Root Ports +to support PCIE-to-PCI bridge hotplug + +u8 io_8; IO limit in case of 8-bit limit value +u32 io_32; IO limit in case of 16-bit limit value +io_8 and io_16 are mutually exclusive, in other words, +they can't be non-zero simultaneously + +u32 prefetchable_32; non-prefetchable memory limit +in case of 32-bit limit value +u64 prefetchable_64; non-prefetchable memory limit +in case of 64-bit limit value +prefetachable_32 and prefetchable_64 are +mutually exclusive, in other words, +they can't be non-zero simultaneously +If any field in Data section is 0, +it means that such kind of reservation +is not needed. + +*/ + +/* Offset of vendor-specific capability type field */ +#define PCI_CAP_VNDR_SPEC_TYPE 3 + +/* List of valid Red Hat vendor-specific capability types */ +#define REDHAT_CAP_TYPE_QEMU 1 + + +/* Offsets of QEMU capability fields */ +#define QEMU_PCI_CAP_NON_PREF 4 +#define QEMU_PCI_CAP_BUS_RES 6 +#define QEMU_PCI_CAP_IO_8 7 +#define QEMU_PCI_CAP_IO_32 8 +#define QEMU_PCI_CAP_PREF_32 12 +#define QEMU_PCI_CAP_PREF_64 16 +#define QEMU_PCI_CAP_SIZE 24 + +#endif /* _PCI_CAP_H */
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v3 2/3] pci: add QEMU-specific PCI capability structure
Quoted 20 lines · Aleksandr Bezzubikov
On PCI init PCI bridge devices may need some extra info about bus number to reserve, IO, memory and prefetchable memory limits. QEMU can provide this with special vendor-specific PCI capability.
This capability is intended to be used only for Red Hat PCI bridges, i.e. QEMU cooperation.
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- src/fw/dev-pci.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)create mode 100644
src/fw/dev-pci.hsrc/fw/dev-pci.h new file +0
-0
src/fw/dev-pci.h line 7
Quoted 7 lines
src/fw/dev-pci.h new file +7
-0@@ -0,0 +1,62 @@ +#ifndef _PCI_CAP_H +#define _PCI_CAP_H + +#include "types.h" + +/* +
Hi Aleksander,
Quoted 6 lines
src/fw/dev-pci.h new file +6
-0+QEMU-specific vendor(Red Hat)-specific capability. +It's intended to provide some hints for firmware to init PCI devices. + +Its is shown below: + +Header:
src/fw/dev-pci.h line 23
Quoted 10 lines
src/fw/dev-pci.h new file +10
-0+ +u8 id; Standard PCI Capability Header field +u8 next; Standard PCI Capability Header field +u8 len; Standard PCI Capability Header field +u8 type; Red Hat vendor-specific capability type: + now only REDHAT_QEMU_CAP 1 exists +Data: + +u16 non_prefetchable_16; non-prefetchable memory limit +
Maybe we should name it "mem". And if I remember right Gerd suggested keeping them all 32 bits:
u32 mem_res
src/fw/dev-pci.h line 28
Quoted 5 lines
src/fw/dev-pci.h new file +5
-0+u8 bus_res; minimum bus number to reserve; + this is necessary for PCI Express Root Ports + to support PCIE-to-PCI bridge hotplug + +u8 io_8; IO limit in case of 8-bit limit value
I must have missed it, but why do we need io_8 field?
src/fw/dev-pci.h line 31
Quoted 3 lines
src/fw/dev-pci.h new file +3
-0+u32 io_32; IO limit in case of 16-bit limit value + io_8 and io_16 are mutually exclusive, in other words, + they can't be non-zero simultaneously
I don't see any io_16 field.
Maybe only one field:
u32 io_res
src/fw/dev-pci.h line 34
Quoted 3 lines
src/fw/dev-pci.h new file +3
-0+ +u32 prefetchable_32; non-prefetchable memory limit + in case of 32-bit limit value
Name and comment mismatch
src/fw/dev-pci.h line 39
Quoted 5 lines
src/fw/dev-pci.h new file +5
-0+u64 prefetchable_64; non-prefetchable memory limit + in case of 64-bit limit value + prefetachable_32 and prefetchable_64 are + mutually exclusive, in other words, + they can't be non-zero simultaneously
Name and comment mismatch
It should look like:
- u32 bus_res
- u32 io_res
- u32 mem_res,
- u32 mem_prefetchable_32,
- u64 mem_prefetchable_64, (mutually exclusive with the above)
Does it look right to all?
src/fw/dev-pci.h line 50
Quoted 11 lines
src/fw/dev-pci.h new file +11
-0+If any field in Data section is 0, +it means that such kind of reservation +is not needed. + +*/ + +/* Offset of vendor-specific capability type field */ +#define PCI_CAP_VNDR_SPEC_TYPE 3 + +/* List of valid Red Hat vendor-specific capability types */ +#define REDHAT_CAP_TYPE_QEMU 1
Maybe we should be more concrete:
REDHAT_CAP_TYPE_RES_RESERVE
src/fw/dev-pci.h line 62
Quoted 13 lines
src/fw/dev-pci.h new file +12
-0+ + +/* Offsets of QEMU capability fields */ +#define QEMU_PCI_CAP_NON_PREF 4 +#define QEMU_PCI_CAP_BUS_RES 6 +#define QEMU_PCI_CAP_IO_8 7 +#define QEMU_PCI_CAP_IO_32 8 +#define QEMU_PCI_CAP_PREF_32 12 +#define QEMU_PCI_CAP_PREF_64 16 +#define QEMU_PCI_CAP_SIZE 24 + +#endif /* _PCI_CAP_H */
I know the exact layout is less important for your current project, but is important to get it right the first time.
Thanks,
Marcel
Re: [Qemu-devel] [PATCH v3 2/3] pci: add QEMU-specific PCI capability structure
In reply to Aleksandr BezzubikovQuoted 52 lines · Aleksandr Bezzubikov
On PCI init PCI bridge devices may need some extra info about bus number to reserve, IO, memory and prefetchable memory limits. QEMU can provide this with special vendor-specific PCI capability.
This capability is intended to be used only for Red Hat PCI bridges, i.e. QEMU cooperation.
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- src/fw/dev-pci.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/fw/dev-pci.hsrc/fw/dev-pci.h new file +32
-0@@ -0,0 +1,62 @@ +#ifndef _PCI_CAP_H +#define _PCI_CAP_H + +#include "types.h" + +/* + +QEMU-specific vendor(Red Hat)-specific capability. +It's intended to provide some hints for firmware to init PCI devices. + +Its is shown below: + +Header: + +u8 id; Standard PCI Capability Header field +u8 next; Standard PCI Capability Header field +u8 len; Standard PCI Capability Header field +u8 type; Red Hat vendor-specific capability type: +now only REDHAT_QEMU_CAP 1 exists +Data: + +u16 non_prefetchable_16; non-prefetchable memory limit + +u8 bus_res; minimum bus number to reserve; +this is necessary for PCI Express Root Ports +to support PCIE-to-PCI bridge hotplug + +u8 io_8; IO limit in case of 8-bit limit value +u32 io_32; IO limit in case of 16-bit limit value +io_8 and io_16 are mutually exclusive, in other words, +they can't be non-zero simultaneously +
src/fw/dev-pci.h line 42
Quoted 10 lines
src/fw/dev-pci.h new file +10
-0+u32 prefetchable_32; non-prefetchable memory limit + in case of 32-bit limit value +u64 prefetchable_64; non-prefetchable memory limit + in case of 64-bit limit value + prefetachable_32 and prefetchable_64 are + mutually exclusive, in other words, + they can't be non-zero simultaneously +If any field in Data section is 0, +it means that such kind of reservation +is not needed.
We also want a way to say "no hint for this type".
One way to achive this would be to have instead multiple vendor specific capabilities, one for each of bus#/io/mem/prefetch. 0 would mean do not reserve anything, absence of capability would mean "no info, up to firmware".
src/fw/dev-pci.h line 47
Quoted 5 lines
src/fw/dev-pci.h new file +5
-0+ +*/ + +/* Offset of vendor-specific capability type field */ +#define PCI_CAP_VNDR_SPEC_TYPE 3
This is a QEMU specific thing. Please name it as such.
Quoted 17 lines
src/fw/dev-pci.h new file +15
-0+ +/* List of valid Red Hat vendor-specific capability types */ +#define REDHAT_CAP_TYPE_QEMU 1 + + +/* Offsets of QEMU capability fields */ +#define QEMU_PCI_CAP_NON_PREF 4 +#define QEMU_PCI_CAP_BUS_RES 6 +#define QEMU_PCI_CAP_IO_8 7 +#define QEMU_PCI_CAP_IO_32 8 +#define QEMU_PCI_CAP_PREF_32 12 +#define QEMU_PCI_CAP_PREF_64 16 +#define QEMU_PCI_CAP_SIZE 24 + +#endif /* _PCI_CAP_H */ Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v3 2/3] pci: add QEMU-specific PCI capability structure
Quoted 55 lines · Michael S. Tsirkin
Quoted 54 lines · Aleksandr Bezzubikov
On PCI init PCI bridge devices may need some extra info about bus number to reserve, IO, memory and prefetchable memory limits. QEMU can provide this with special vendor-specific PCI capability.
This capability is intended to be used only for Red Hat PCI bridges, i.e. QEMU cooperation.
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- src/fw/dev-pci.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)create mode 100644
src/fw/dev-pci.hsrc/fw/dev-pci.h new file +34
-0@@ -0,0 +1,62 @@ +#ifndef _PCI_CAP_H +#define _PCI_CAP_H + +#include "types.h" + +/* + +QEMU-specific vendor(Red Hat)-specific capability. +It's intended to provide some hints for firmware to init PCI devices. + +Its is shown below: + +Header: + +u8 id; Standard PCI Capability Header field +u8 next; Standard PCI Capability Header field +u8 len; Standard PCI Capability Header field +u8 type; Red Hat vendor-specific capability type: +now only REDHAT_QEMU_CAP 1 exists +Data: + +u16 non_prefetchable_16; non-prefetchable memory limit + +u8 bus_res; minimum bus number to reserve; +this is necessary for PCI Express Root Ports +to support PCIE-to-PCI bridge hotplug + +u8 io_8; IO limit in case of 8-bit limit value +u32 io_32; IO limit in case of 16-bit limit value +io_8 and io_16 are mutually exclusive, in other words, +they can't be non-zero simultaneously + +u32 prefetchable_32; non-prefetchable memory limit +in case of 32-bit limit value
Quoted 9 lines
src/fw/dev-pci.h line 42
Quoted 8 lines
src/fw/dev-pci.h new file +8
-0+u64 prefetchable_64; non-prefetchable memory limit + in case of 64-bit limit value + prefetachable_32 and prefetchable_64 are + mutually exclusive, in other words, + they can't be non-zero simultaneously +If any field in Data section is 0, +it means that such kind of reservation +is not needed.
Hi Michael,
Quoted 7 lines
We also want a way to say "no hint for this type".
One way to achive this would be to have instead multiple vendor specific capabilities, one for each of bus#/io/mem/prefetch. 0 would mean do not reserve anything, absence of capability would mean "no info, up to firmware".
First version of the series was implemented exactly like you propose, however Gerd preferred only one capability with multiple fields.
I personally like the simplicity of vendor cap per io/mem/bus, even if it is on the expense of the limited PCI Config space.
We need a consensus here :)
Thanks,
Marcel
Quoted 26 lines
src/fw/dev-pci.h line 47
Quoted 6 lines
src/fw/dev-pci.h new file +5
-0+ +*/ + +/* Offset of vendor-specific capability type field */ +#define PCI_CAP_VNDR_SPEC_TYPE 3This is a QEMU specific thing. Please name it as such.
Quoted 17 lines
src/fw/dev-pci.h new file +15
-0+ +/* List of valid Red Hat vendor-specific capability types */ +#define REDHAT_CAP_TYPE_QEMU 1 + + +/* Offsets of QEMU capability fields */ +#define QEMU_PCI_CAP_NON_PREF 4 +#define QEMU_PCI_CAP_BUS_RES 6 +#define QEMU_PCI_CAP_IO_8 7 +#define QEMU_PCI_CAP_IO_32 8 +#define QEMU_PCI_CAP_PREF_32 12 +#define QEMU_PCI_CAP_PREF_64 16 +#define QEMU_PCI_CAP_SIZE 24 + +#endif /* _PCI_CAP_H */ Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v3 2/3] pci: add QEMU-specific PCI capability structure
2017-07-31 17:09 GMT+03:00 Marcel Apfelbaum <[email protected]>:
Quoted 59 lines · Michael S. Tsirkin
Quoted 58 lines · Aleksandr Bezzubikov
Quoted 56 lines
On PCI init PCI bridge devices may need some extra info about bus number to reserve, IO, memory and prefetchable memory limits. QEMU can provide this with special vendor-specific PCI capability.
This capability is intended to be used only for Red Hat PCI bridges, i.e. QEMU cooperation.
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- src/fw/dev-pci.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)create mode 100644
src/fw/dev-pci.hsrc/fw/dev-pci.h new file +34
-0@@ -0,0 +1,62 @@ +#ifndef _PCI_CAP_H +#define _PCI_CAP_H + +#include "types.h" + +/* + +QEMU-specific vendor(Red Hat)-specific capability. +It's intended to provide some hints for firmware to init PCI devices. + +Its is shown below: + +Header: + +u8 id; Standard PCI Capability Header field +u8 next; Standard PCI Capability Header field +u8 len; Standard PCI Capability Header field +u8 type; Red Hat vendor-specific capability type: +now only REDHAT_QEMU_CAP 1 exists +Data: + +u16 non_prefetchable_16; non-prefetchable memory limit + +u8 bus_res; minimum bus number to reserve; +this is necessary for PCI Express Root Ports +to support PCIE-to-PCI bridge hotplug + +u8 io_8; IO limit in case of 8-bit limit value +u32 io_32; IO limit in case of 16-bit limit value +io_8 and io_16 are mutually exclusive, in other words, +they can't be non-zero simultaneously + +u32 prefetchable_32; non-prefetchable memory limit +in case of 32-bit limit value
Quoted 8 lines
Quoted 8 lines
src/fw/dev-pci.h line 42
Quoted 8 lines
src/fw/dev-pci.h new file +8
-0+u64 prefetchable_64; non-prefetchable memory limit + in case of 64-bit limit value + prefetachable_32 and prefetchable_64 are + mutually exclusive, in other words, + they can't be non-zero simultaneously +If any field in Data section is 0, +it means that such kind of reservation +is not needed.
I really don't like this 'mutually exclusive' fields approach because IMHO it increases confusion level when undertanding this capability structure. But - if we came to consensus on that, then IO fields should be used in the same way,
because as I understand, this 'mutual exclusivity' serves to distinguish cases when we employ only *_LIMIT register and both *_LIMIT an UPPER_*_LIMIT registers.
And this is how both IO and PREFETCHABLE works, isn't it?
Quoted 13 lines
Quoted 2 lines
Hi Michael,
Quoted 7 lines
We also want a way to say "no hint for this type".
One way to achive this would be to have instead multiple vendor specific capabilities, one for each of bus#/io/mem/prefetch. 0 would mean do not reserve anything, absence of capability would mean "no info, up to firmware".
Quoted 6 lines
First version of the series was implemented exactly like you propose, however Gerd preferred only one capability with multiple fields.
I personally like the simplicity of vendor cap per io/mem/bus, even if it is on the expense of the limited PCI Config space.
Personally I agree with Marcel since all this fields express reservations of some objects.
Quoted 2 lines
We need a consensus here :)
Absolutely :)
Quoted 33 lines
Thanks,
MarcelQuoted 27 lines
src/fw/dev-pci.h line 47
Quoted 6 lines
src/fw/dev-pci.h new file +5
-0+ +*/ + +/* Offset of vendor-specific capability type field */ +#define PCI_CAP_VNDR_SPEC_TYPE 3This is a QEMU specific thing. Please name it as such.
Quoted 17 lines
src/fw/dev-pci.h new file +15
-1+ +/* List of valid Red Hat vendor-specific capability types */ +#define REDHAT_CAP_TYPE_QEMU 1 + + +/* Offsets of QEMU capability fields */ +#define QEMU_PCI_CAP_NON_PREF 4 +#define QEMU_PCI_CAP_BUS_RES 6 +#define QEMU_PCI_CAP_IO_8 7 +#define QEMU_PCI_CAP_IO_32 8 +#define QEMU_PCI_CAP_PREF_32 12 +#define QEMU_PCI_CAP_PREF_64 16 +#define QEMU_PCI_CAP_SIZE 24 + +#endif /* _PCI_CAP_H */ --2.7.4
Signature · 1 line
Alexander Bezzubikov
Re: [Qemu-devel] [PATCH v3 2/3] pci: add QEMU-specific PCI capability structure
Quoted 69 lines · Alexander Bezzubikov
2017-07-31 17:09 GMT+03:00 Marcel Apfelbaum <[email protected]>:
Quoted 59 lines · Michael S. Tsirkin
Quoted 58 lines · Aleksandr Bezzubikov
Quoted 56 lines
On PCI init PCI bridge devices may need some extra info about bus number to reserve, IO, memory and prefetchable memory limits. QEMU can provide this with special vendor-specific PCI capability.
This capability is intended to be used only for Red Hat PCI bridges, i.e. QEMU cooperation.
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- src/fw/dev-pci.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)create mode 100644
src/fw/dev-pci.hsrc/fw/dev-pci.h new file +34
-0@@ -0,0 +1,62 @@ +#ifndef _PCI_CAP_H +#define _PCI_CAP_H + +#include "types.h" + +/* + +QEMU-specific vendor(Red Hat)-specific capability. +It's intended to provide some hints for firmware to init PCI devices. + +Its is shown below: + +Header: + +u8 id; Standard PCI Capability Header field +u8 next; Standard PCI Capability Header field +u8 len; Standard PCI Capability Header field +u8 type; Red Hat vendor-specific capability type: +now only REDHAT_QEMU_CAP 1 exists +Data: + +u16 non_prefetchable_16; non-prefetchable memory limit + +u8 bus_res; minimum bus number to reserve; +this is necessary for PCI Express Root Ports +to support PCIE-to-PCI bridge hotplug + +u8 io_8; IO limit in case of 8-bit limit value +u32 io_32; IO limit in case of 16-bit limit value +io_8 and io_16 are mutually exclusive, in other words, +they can't be non-zero simultaneously + +u32 prefetchable_32; non-prefetchable memory limit +in case of 32-bit limit value Quoted 8 lines
Quoted 8 lines
src/fw/dev-pci.h line 42
Quoted 8 lines
src/fw/dev-pci.h new file +8
-0+u64 prefetchable_64; non-prefetchable memory limit + in case of 64-bit limit value + prefetachable_32 and prefetchable_64 are + mutually exclusive, in other words, + they can't be non-zero simultaneously +If any field in Data section is 0, +it means that such kind of reservation +is not needed.
Quoted 8 lines
I really don't like this 'mutually exclusive' fields approach because IMHO it increases confusion level when undertanding this capability structure. But - if we came to consensus on that, then IO fields should be used in the same way,
because as I understand, this 'mutual exclusivity' serves to distinguish cases when we employ only*_LIMITregister and both*_LIMITan UPPER_*_LIMIT registers.
And this is how both IO and PREFETCHABLE works, isn't it?
I would just use simeple 64 bit registers. PCI spec has an ugly format with fields spread all over the place but that is because of compatibility concerns. It makes not sense to spend cycles just to be similarly messy.
Quoted 66 lines
Quoted 13 lines
Quoted 2 lines
Hi Michael,
Quoted 7 lines
We also want a way to say "no hint for this type".
One way to achive this would be to have instead multiple vendor specific capabilities, one for each of bus#/io/mem/prefetch. 0 would mean do not reserve anything, absence of capability would mean "no info, up to firmware".
Quoted 6 lines
First version of the series was implemented exactly like you propose, however Gerd preferred only one capability with multiple fields.
I personally like the simplicity of vendor cap per io/mem/bus, even if it is on the expense of the limited PCI Config space.
Personally I agree with Marcel since all this fields express reservations of some objects.
Quoted 2 lines
We need a consensus here :)
Absolutely :)
Quoted 33 lines
Thanks,
MarcelQuoted 27 lines
src/fw/dev-pci.h line 47
Quoted 6 lines
src/fw/dev-pci.h new file +5
-0+ +*/ + +/* Offset of vendor-specific capability type field */ +#define PCI_CAP_VNDR_SPEC_TYPE 3This is a QEMU specific thing. Please name it as such.
Quoted 17 lines
src/fw/dev-pci.h new file +15
-1+ +/* List of valid Red Hat vendor-specific capability types */ +#define REDHAT_CAP_TYPE_QEMU 1 + + +/* Offsets of QEMU capability fields */ +#define QEMU_PCI_CAP_NON_PREF 4 +#define QEMU_PCI_CAP_BUS_RES 6 +#define QEMU_PCI_CAP_IO_8 7 +#define QEMU_PCI_CAP_IO_32 8 +#define QEMU_PCI_CAP_PREF_32 12 +#define QEMU_PCI_CAP_PREF_64 16 +#define QEMU_PCI_CAP_SIZE 24 + +#endif /* _PCI_CAP_H */ --2.7.4
Signature · 1 line
Alexander Bezzubikov
Re: [Qemu-devel] [PATCH v3 2/3] pci: add QEMU-specific PCI capability structure
2017-07-31 21:57 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 79 lines · Alexander Bezzubikov
Quoted 69 lines
2017-07-31 17:09 GMT+03:00 Marcel Apfelbaum <[email protected]>:
Quoted 59 lines · Michael S. Tsirkin
Quoted 58 lines · Aleksandr Bezzubikov
Quoted 56 lines
On PCI init PCI bridge devices may need some extra info about bus number to reserve, IO, memory and prefetchable memory limits. QEMU can provide this with special vendor-specific PCI capability.
This capability is intended to be used only for Red Hat PCI bridges, i.e. QEMU cooperation.
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- src/fw/dev-pci.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)create mode 100644
src/fw/dev-pci.hsrc/fw/dev-pci.h new file +34
-0@@ -0,0 +1,62 @@ +#ifndef _PCI_CAP_H +#define _PCI_CAP_H + +#include "types.h" + +/* + +QEMU-specific vendor(Red Hat)-specific capability. +It's intended to provide some hints for firmware to init PCI devices. + +Its is shown below: + +Header: + +u8 id; Standard PCI Capability Header field +u8 next; Standard PCI Capability Header field +u8 len; Standard PCI Capability Header field +u8 type; Red Hat vendor-specific capability type: +now only REDHAT_QEMU_CAP 1 exists +Data: + +u16 non_prefetchable_16; non-prefetchable memory limit + +u8 bus_res; minimum bus number to reserve; +this is necessary for PCI Express Root Ports +to support PCIE-to-PCI bridge hotplug + +u8 io_8; IO limit in case of 8-bit limit value +u32 io_32; IO limit in case of 16-bit limit value +io_8 and io_16 are mutually exclusive, in other words, +they can't be non-zero simultaneously + +u32 prefetchable_32; non-prefetchable memory limit +in case of 32-bit limit value Quoted 8 lines
Quoted 8 lines
src/fw/dev-pci.h line 42
Quoted 8 lines
src/fw/dev-pci.h new file +8
-0+u64 prefetchable_64; non-prefetchable memory limit + in case of 64-bit limit value + prefetachable_32 and prefetchable_64 are + mutually exclusive, in other words, + they can't be non-zero simultaneously +If any field in Data section is 0, +it means that such kind of reservation +is not needed.Quoted 8 lines
I really don't like this 'mutually exclusive' fields approach because IMHO it increases confusion level when undertanding this capability structure. But - if we came to consensus on that, then IO fields should be used in the same way,
because as I understand, this 'mutual exclusivity' serves to distinguish cases when we employ only*_LIMITregister and both*_LIMITan UPPER_*_LIMIT registers.
And this is how both IO and PREFETCHABLE works, isn't it?
Quoted 4 lines
I would just use simeple 64 bit registers. PCI spec has an ugly format with fields spread all over the place but that is because of compatibility concerns. It makes not sense to spend cycles just to be similarly messy.
Then I suggest to use exactly one field of a maximum possible size for each reserving object, and get rid of mutually exclusive fields. Then it can be something like that (order and names can be changed):
u8 bus;
u16 non_pref;
u32 io;
u64 pref;
Quoted 68 lines
Quoted 68 lines
Quoted 15 lines
Quoted 4 lines
Hi Michael,
Quoted 7 lines
We also want a way to say "no hint for this type".
One way to achive this would be to have instead multiple vendor specific capabilities, one for each of bus#/io/mem/prefetch. 0 would mean do not reserve anything, absence of capability would mean "no info, up to firmware".
Quoted 6 lines
First version of the series was implemented exactly like you propose, however Gerd preferred only one capability with multiple fields.
I personally like the simplicity of vendor cap per io/mem/bus, even if it is on the expense of the limited PCI Config space.
Personally I agree with Marcel since all this fields express reservations of some objects.
Quoted 2 lines
We need a consensus here :)
Absolutely :)
Quoted 23 lines
Thanks,
MarcelQuoted 19 lines
src/fw/dev-pci.h line 47
Quoted 6 lines
src/fw/dev-pci.h new file +5
-0+ +*/ + +/* Offset of vendor-specific capability type field */ +#define PCI_CAP_VNDR_SPEC_TYPE 3This is a QEMU specific thing. Please name it as such.
Quoted 9 lines
src/fw/dev-pci.h new file +9
-0+ +/* List of valid Red Hat vendor-specific capability types */ +#define REDHAT_CAP_TYPE_QEMU 1 + + +/* Offsets of QEMU capability fields */ +#define QEMU_PCI_CAP_NON_PREF 4 +#define QEMU_PCI_CAP_BUS_RES 6 +#define QEMU_PCI_CAP_IO_8 7Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
src/fw/dev-pci.h new file +6
-1+#define QEMU_PCI_CAP_IO_32 8 +#define QEMU_PCI_CAP_PREF_32 12 +#define QEMU_PCI_CAP_PREF_64 16 +#define QEMU_PCI_CAP_SIZE 24 + +#endif /* _PCI_CAP_H */ --2.7.4
--
Alexander Bezzubikov
Signature · 1 line
Alexander Bezzubikov
Re: [Qemu-devel] [PATCH v3 2/3] pci: add QEMU-specific PCI capability structure
Quoted 85 lines · Alexander Bezzubikov
2017-07-31 21:57 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 79 lines · Alexander Bezzubikov
Quoted 69 lines
2017-07-31 17:09 GMT+03:00 Marcel Apfelbaum <[email protected]>:
Quoted 59 lines · Michael S. Tsirkin
Quoted 58 lines · Aleksandr Bezzubikov
Quoted 56 lines
On PCI init PCI bridge devices may need some extra info about bus number to reserve, IO, memory and prefetchable memory limits. QEMU can provide this with special vendor-specific PCI capability.
This capability is intended to be used only for Red Hat PCI bridges, i.e. QEMU cooperation.
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- src/fw/dev-pci.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)create mode 100644
src/fw/dev-pci.hsrc/fw/dev-pci.h new file +34
-0@@ -0,0 +1,62 @@ +#ifndef _PCI_CAP_H +#define _PCI_CAP_H + +#include "types.h" + +/* + +QEMU-specific vendor(Red Hat)-specific capability. +It's intended to provide some hints for firmware to init PCI devices. + +Its is shown below: + +Header: + +u8 id; Standard PCI Capability Header field +u8 next; Standard PCI Capability Header field +u8 len; Standard PCI Capability Header field +u8 type; Red Hat vendor-specific capability type: +now only REDHAT_QEMU_CAP 1 exists +Data: + +u16 non_prefetchable_16; non-prefetchable memory limit + +u8 bus_res; minimum bus number to reserve; +this is necessary for PCI Express Root Ports +to support PCIE-to-PCI bridge hotplug + +u8 io_8; IO limit in case of 8-bit limit value +u32 io_32; IO limit in case of 16-bit limit value +io_8 and io_16 are mutually exclusive, in other words, +they can't be non-zero simultaneously + +u32 prefetchable_32; non-prefetchable memory limit +in case of 32-bit limit value Quoted 8 lines
Quoted 8 lines
src/fw/dev-pci.h line 42
Quoted 8 lines
src/fw/dev-pci.h new file +8
-0+u64 prefetchable_64; non-prefetchable memory limit + in case of 64-bit limit value + prefetachable_32 and prefetchable_64 are + mutually exclusive, in other words, + they can't be non-zero simultaneously +If any field in Data section is 0, +it means that such kind of reservation +is not needed.Quoted 8 lines
I really don't like this 'mutually exclusive' fields approach because IMHO it increases confusion level when undertanding this capability structure. But - if we came to consensus on that, then IO fields should be used in the same way,
because as I understand, this 'mutual exclusivity' serves to distinguish cases when we employ only*_LIMITregister and both*_LIMITan UPPER_*_LIMIT registers.
And this is how both IO and PREFETCHABLE works, isn't it?Quoted 4 lines
I would just use simeple 64 bit registers. PCI spec has an ugly format with fields spread all over the place but that is because of compatibility concerns. It makes not sense to spend cycles just to be similarly messy.
Quoted 8 lines
Then I suggest to use exactly one field of a maximum possible size for each reserving object, and get rid of mutually exclusive fields. Then it can be something like that (order and names can be changed):
u8 bus;
u16non_pref;
u32 io;
u64 pref;
I think Michael suggested:
u64 bus_res;
u64 mem_res;
u64 io_res;
u64 mem_pref_res;OR:
u32 bus_res;
u32 mem_res;
u32 io_res;
u64 mem_pref_res;We can use 0XFFF..F as "not-set" value "merging" Gerd's and Michael's requests.
Thanks,
Marcel
Quoted 72 lines
Quoted 69 lines
Quoted 69 lines
Quoted 16 lines
Quoted 5 lines
Hi Michael,
Quoted 7 lines
We also want a way to say "no hint for this type".
One way to achive this would be to have instead multiple vendor specific capabilities, one for each of bus#/io/mem/prefetch. 0 would mean do not reserve anything, absence of capability would mean "no info, up to firmware".
Quoted 6 lines
First version of the series was implemented exactly like you propose, however Gerd preferred only one capability with multiple fields.
I personally like the simplicity of vendor cap per io/mem/bus, even if it is on the expense of the limited PCI Config space.
Personally I agree with Marcel since all this fields express reservations of some objects.
Quoted 2 lines
We need a consensus here :)
Absolutely :)
Quoted 23 lines
Thanks,
MarcelQuoted 19 lines
src/fw/dev-pci.h line 47
Quoted 6 lines
src/fw/dev-pci.h new file +5
-0+ +*/ + +/* Offset of vendor-specific capability type field */ +#define PCI_CAP_VNDR_SPEC_TYPE 3This is a QEMU specific thing. Please name it as such.
Quoted 9 lines
src/fw/dev-pci.h new file +9
-0+ +/* List of valid Red Hat vendor-specific capability types */ +#define REDHAT_CAP_TYPE_QEMU 1 + + +/* Offsets of QEMU capability fields */ +#define QEMU_PCI_CAP_NON_PREF 4 +#define QEMU_PCI_CAP_BUS_RES 6 +#define QEMU_PCI_CAP_IO_8 7Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
src/fw/dev-pci.h new file +6
-1+#define QEMU_PCI_CAP_IO_32 8 +#define QEMU_PCI_CAP_PREF_32 12 +#define QEMU_PCI_CAP_PREF_64 16 +#define QEMU_PCI_CAP_SIZE 24 + +#endif /* _PCI_CAP_H */ --2.7.4
--
Alexander Bezzubikov
Re: [Qemu-devel] [PATCH v3 2/3] pci: add QEMU-specific PCI capability structure
2017-08-01 16:38 GMT+03:00 Marcel Apfelbaum <[email protected]>:
Quoted 116 lines · Alexander Bezzubikov
Quoted 98 lines
2017-07-31 21:57 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 90 lines · Alexander Bezzubikov
Quoted 78 lines
2017-07-31 17:09 GMT+03:00 Marcel Apfelbaum <[email protected]>:
Quoted 64 lines · Michael S. Tsirkin
Quoted 62 lines · Aleksandr Bezzubikov
Quoted 59 lines
On PCI init PCI bridge devices may need some extra info about bus number to reserve, IO, memory and prefetchable memory limits. QEMU can provide this with special vendor-specific PCI capability.
This capability is intended to be used only for Red Hat PCI bridges, i.e. QEMU cooperation.
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- src/fw/dev-pci.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)create mode 100644
src/fw/dev-pci.hsrc/fw/dev-pci.h new file +9
-0@@ -0,0 +1,62 @@ +#ifndef _PCI_CAP_H +#define _PCI_CAP_H + +#include "types.h" + +/* + +QEMU-specific vendor(Red Hat)-specific capability. +It's intended to provide some hints for firmware to init PCI devices.
src/fw/dev-pci.h new file +26
-0+ +Its is shown below: + +Header: + +u8 id; Standard PCI Capability Header field +u8 next; Standard PCI Capability Header field +u8 len; Standard PCI Capability Header field +u8 type; Red Hat vendor-specific capability type: + now only REDHAT_QEMU_CAP 1 exists +Data: + +u16 non_prefetchable_16; non-prefetchable memory limit + +u8 bus_res; minimum bus number to reserve; + this is necessary for PCI Express Root Ports + to support PCIE-to-PCI bridge hotplug + +u8 io_8; IO limit in case of 8-bit limit value +u32 io_32; IO limit in case of 16-bit limit value + io_8 and io_16 are mutually exclusive, in other words, + they can't be non-zero simultaneously + +u32 prefetchable_32; non-prefetchable memory limit + in case of 32-bit limit value +u64 prefetchable_64; non-prefetchable memory limitQuoted 8 lines
Quoted 8 lines
src/fw/dev-pci.h
Quoted 8 lines
src/fw/dev-pci.h new file +2
-0+ in case of 64-bit limit value + prefetachable_32 and prefetchable_64are
src/fw/dev-pci.h new file +5
-0+ mutually exclusive, in other words, + they can't be non-zero simultaneously +If any field in Data section is 0, +it means that such kind of reservation +is not needed.I really don't like this 'mutually exclusive' fields approach because IMHO it increases confusion level when undertanding this capability
Quoted 8 lines
structure.
But - if we came to consensus on that, then IO fields should be used in the same way,
because as I understand, this 'mutual exclusivity' serves to distinguish cases
when we employ only*_LIMITregister and both*_LIMITan UPPER_*_LIMIT registers.
And this is how both IO and PREFETCHABLE works, isn't it?Quoted 4 lines
I would just use simeple 64 bit registers. PCI spec has an ugly format with fields spread all over the place but that is because of compatibility concerns. It makes not sense to spend cycles just to be similarly messy.
Quoted 8 lines
Then I suggest to use exactly one field of a maximum possible size for each reserving object, and get rid of mutually exclusive fields. Then it can be something like that (order and names can be changed):
u8 bus;
u16non_pref;
u32 io;
u64 pref;I think Michael suggested:
u64 bus_res; u64 mem_res; u64 io_res; u64 mem_pref_res;OR:
Quoted 8 lines
u32 bus_res; u32 mem_res; u32 io_res; u64 mem_pref_res;We can use 0XFFF..F as "not-set" value "merging" Gerd's and Michael's requests.
Let's dwell on the second option (with -1 as 'ignore' sign), if no new objections.
Quoted 81 lines
Thanks,
MarcelQuoted 75 lines
Quoted 71 lines
Quoted 71 lines
Quoted 16 lines
Quoted 5 lines
Hi Michael,
Quoted 7 lines
We also want a way to say "no hint for this type".
One way to achive this would be to have instead multiple vendor specific capabilities, one for each of bus#/io/mem/prefetch. 0 would mean do not reserve anything, absence of capability would mean "no info, up to firmware".
Quoted 6 lines
First version of the series was implemented exactly like you propose, however Gerd preferred only one capability with multiple fields.
I personally like the simplicity of vendor cap per io/mem/bus, even if it is on the expense of the limited PCI Config space.
Personally I agree with Marcel since all this fields express reservations of some objects.
Quoted 2 lines
We need a consensus here :)
Absolutely :)
Quoted 24 lines
Thanks,
MarcelQuoted 20 lines
src/fw/dev-pci.h
Quoted 6 lines
src/fw/dev-pci.h new file +5
-0+ +*/ + +/* Offset of vendor-specific capability type field */ +#define PCI_CAP_VNDR_SPEC_TYPE 3This is a QEMU specific thing. Please name it as such.
Quoted 9 lines
src/fw/dev-pci.h new file +9
-0+ +/* List of valid Red Hat vendor-specific capability types */ +#define REDHAT_CAP_TYPE_QEMU 1 + + +/* Offsets of QEMU capability fields */ +#define QEMU_PCI_CAP_NON_PREF 4 +#define QEMU_PCI_CAP_BUS_RES 6 +#define QEMU_PCI_CAP_IO_8 7Quoted 11 lines
Quoted 8 lines
Quoted 8 lines
src/fw/dev-pci.h new file +6
-1+#define QEMU_PCI_CAP_IO_32 8 +#define QEMU_PCI_CAP_PREF_32 12 +#define QEMU_PCI_CAP_PREF_64 16 +#define QEMU_PCI_CAP_SIZE 24 + +#endif /* _PCI_CAP_H */ --2.7.4
--
Alexander Bezzubikov
Signature · 1 line
Aleksandr Bezzubikov
Re: [Qemu-devel] [PATCH v3 2/3] pci: add QEMU-specific PCI capability structure
2017-08-01 20:28 GMT+03:00 Alexander Bezzubikov <[email protected]>:
Quoted 123 lines
2017-08-01 16:38 GMT+03:00 Marcel Apfelbaum <[email protected]>:
Quoted 122 lines · Alexander Bezzubikov
Quoted 98 lines
2017-07-31 21:57 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 90 lines · Alexander Bezzubikov
Quoted 78 lines
2017-07-31 17:09 GMT+03:00 Marcel Apfelbaum <[email protected]>:
Quoted 64 lines · Michael S. Tsirkin
Quoted 62 lines · Aleksandr Bezzubikov
Quoted 59 lines
On PCI init PCI bridge devices may need some extra info about bus number to reserve, IO, memory and prefetchable memory limits. QEMU can provide this with special vendor-specific PCI capability.
This capability is intended to be used only for Red Hat PCI bridges, i.e. QEMU cooperation.
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- src/fw/dev-pci.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)create mode 100644
src/fw/dev-pci.hsrc/fw/dev-pci.h new file +9
-0@@ -0,0 +1,62 @@ +#ifndef _PCI_CAP_H +#define _PCI_CAP_H + +#include "types.h" + +/* + +QEMU-specific vendor(Red Hat)-specific capability. +It's intended to provide some hints for firmware to init PCI devices.
src/fw/dev-pci.h new file +26
-0+ +Its is shown below: + +Header: + +u8 id; Standard PCI Capability Header field +u8 next; Standard PCI Capability Header field +u8 len; Standard PCI Capability Header field +u8 type; Red Hat vendor-specific capability type: + now only REDHAT_QEMU_CAP 1 exists +Data: + +u16 non_prefetchable_16; non-prefetchable memory limit + +u8 bus_res; minimum bus number to reserve; + this is necessary for PCI Express Root Ports + to support PCIE-to-PCI bridge hotplug + +u8 io_8; IO limit in case of 8-bit limit value +u32 io_32; IO limit in case of 16-bit limit value + io_8 and io_16 are mutually exclusive, in other words, + they can't be non-zero simultaneously + +u32 prefetchable_32; non-prefetchable memory limit + in case of 32-bit limit value +u64 prefetchable_64; non-prefetchable memory limitQuoted 8 lines
Quoted 8 lines
src/fw/dev-pci.h
Quoted 8 lines
src/fw/dev-pci.h new file +2
-0+ in case of 64-bit limit value + prefetachable_32 and prefetchable_64are
src/fw/dev-pci.h new file +5
-0+ mutually exclusive, in other words, + they can't be non-zero simultaneously +If any field in Data section is 0, +it means that such kind of reservation +is not needed.I really don't like this 'mutually exclusive' fields approach because IMHO it increases confusion level when undertanding this capability
Quoted 8 lines
structure.
But - if we came to consensus on that, then IO fields should be used in the same way,
because as I understand, this 'mutual exclusivity' serves to distinguish cases
when we employ only*_LIMITregister and both*_LIMITan UPPER_*_LIMIT registers.
And this is how both IO and PREFETCHABLE works, isn't it?Quoted 4 lines
I would just use simeple 64 bit registers. PCI spec has an ugly format with fields spread all over the place but that is because of compatibility concerns. It makes not sense to spend cycles just to be similarly messy.
Quoted 8 lines
Then I suggest to use exactly one field of a maximum possible size for each reserving object, and get rid of mutually exclusive fields. Then it can be something like that (order and names can be changed):
u8 bus;
u16non_pref;
u32 io;
u64 pref;I think Michael suggested:
u64 bus_res; u64 mem_res; u64 io_res; u64 mem_pref_res;OR:
u32 bus_res; u32 mem_res; u32 io_res; u64 mem_pref_res;
Quoted 6 lines
Quoted 2 lines
We can use 0XFFF..F as "not-set" value "merging" Gerd's and Michael's requests.
Let's dwell on the second option (with -1 as 'ignore' sign), if no new objections.
BTW, talking about limit values provided in the capability - do we want to completely override
existing PCI resources allocation mechanism being used in SeaBIOS, I mean, to assign capability
values hardly, not taking into consideration any existing checks, or somehow make this process soft (not an obvious way, can lead to another big discussion)?
In other words, how do we plan to use IO/MEM/PREF limits provided in this capability
in application to the PCIE Root Port, what result is this supposed to achieve?
Quoted 86 lines
Quoted 81 lines
Thanks,
MarcelQuoted 75 lines
Quoted 71 lines
Quoted 71 lines
Quoted 16 lines
Quoted 5 lines
Hi Michael,
Quoted 7 lines
We also want a way to say "no hint for this type".
One way to achive this would be to have instead multiple vendor specific capabilities, one for each of bus#/io/mem/prefetch. 0 would mean do not reserve anything, absence of capability would mean "no info, up to firmware".
Quoted 6 lines
First version of the series was implemented exactly like you propose, however Gerd preferred only one capability with multiple fields.
I personally like the simplicity of vendor cap per io/mem/bus, even if it is on the expense of the limited PCI Config space.
Personally I agree with Marcel since all this fields express reservations of some objects.
Quoted 2 lines
We need a consensus here :)
Absolutely :)
Quoted 24 lines
Thanks,
MarcelQuoted 20 lines
src/fw/dev-pci.h
Quoted 6 lines
src/fw/dev-pci.h new file +5
-0+ +*/ + +/* Offset of vendor-specific capability type field */ +#define PCI_CAP_VNDR_SPEC_TYPE 3This is a QEMU specific thing. Please name it as such.
Quoted 9 lines
src/fw/dev-pci.h new file +9
-0+ +/* List of valid Red Hat vendor-specific capability types */ +#define REDHAT_CAP_TYPE_QEMU 1 + + +/* Offsets of QEMU capability fields */ +#define QEMU_PCI_CAP_NON_PREF 4 +#define QEMU_PCI_CAP_BUS_RES 6 +#define QEMU_PCI_CAP_IO_8 7Quoted 11 lines
Quoted 8 lines
Quoted 8 lines
src/fw/dev-pci.h new file +6
-1+#define QEMU_PCI_CAP_IO_32 8 +#define QEMU_PCI_CAP_PREF_32 12 +#define QEMU_PCI_CAP_PREF_64 16 +#define QEMU_PCI_CAP_SIZE 24 + +#endif /* _PCI_CAP_H */ --2.7.4
--
Alexander Bezzubikov--
Aleksandr Bezzubikov
Signature · 1 line
Aleksandr Bezzubikov
Re: [Qemu-devel] [PATCH v3 2/3] pci: add QEMU-specific PCI capability structure
Quoted 139 lines · Alexander Bezzubikov
2017-08-01 20:28 GMT+03:00 Alexander Bezzubikov <[email protected]>:
Quoted 123 lines
2017-08-01 16:38 GMT+03:00 Marcel Apfelbaum <[email protected]>:
Quoted 122 lines · Alexander Bezzubikov
Quoted 98 lines
2017-07-31 21:57 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 90 lines · Alexander Bezzubikov
Quoted 78 lines
2017-07-31 17:09 GMT+03:00 Marcel Apfelbaum <[email protected]>:
Quoted 64 lines · Michael S. Tsirkin
Quoted 62 lines · Aleksandr Bezzubikov
Quoted 59 lines
On PCI init PCI bridge devices may need some extra info about bus number to reserve, IO, memory and prefetchable memory limits. QEMU can provide this with special vendor-specific PCI capability.
This capability is intended to be used only for Red Hat PCI bridges, i.e. QEMU cooperation.
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- src/fw/dev-pci.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)create mode 100644
src/fw/dev-pci.hsrc/fw/dev-pci.h new file +9
-0@@ -0,0 +1,62 @@ +#ifndef _PCI_CAP_H +#define _PCI_CAP_H + +#include "types.h" + +/* + +QEMU-specific vendor(Red Hat)-specific capability. +It's intended to provide some hints for firmware to init PCI devices.
src/fw/dev-pci.h new file +26
-0+ +Its is shown below: + +Header: + +u8 id; Standard PCI Capability Header field +u8 next; Standard PCI Capability Header field +u8 len; Standard PCI Capability Header field +u8 type; Red Hat vendor-specific capability type: + now only REDHAT_QEMU_CAP 1 exists +Data: + +u16 non_prefetchable_16; non-prefetchable memory limit + +u8 bus_res; minimum bus number to reserve; + this is necessary for PCI Express Root Ports + to support PCIE-to-PCI bridge hotplug + +u8 io_8; IO limit in case of 8-bit limit value +u32 io_32; IO limit in case of 16-bit limit value + io_8 and io_16 are mutually exclusive, in other words, + they can't be non-zero simultaneously + +u32 prefetchable_32; non-prefetchable memory limit + in case of 32-bit limit value +u64 prefetchable_64; non-prefetchable memory limitQuoted 8 lines
Quoted 8 lines
src/fw/dev-pci.h
Quoted 8 lines
src/fw/dev-pci.h new file +2
-0+ in case of 64-bit limit value + prefetachable_32 and prefetchable_64are
src/fw/dev-pci.h new file +5
-0+ mutually exclusive, in other words, + they can't be non-zero simultaneously +If any field in Data section is 0, +it means that such kind of reservation +is not needed.I really don't like this 'mutually exclusive' fields approach because IMHO it increases confusion level when undertanding this capability
Quoted 8 lines
structure.
But - if we came to consensus on that, then IO fields should be used in the same way,
because as I understand, this 'mutual exclusivity' serves to distinguish cases
when we employ only*_LIMITregister and both*_LIMITan UPPER_*_LIMIT registers.
And this is how both IO and PREFETCHABLE works, isn't it?Quoted 4 lines
I would just use simeple 64 bit registers. PCI spec has an ugly format with fields spread all over the place but that is because of compatibility concerns. It makes not sense to spend cycles just to be similarly messy.
Quoted 8 lines
Then I suggest to use exactly one field of a maximum possible size for each reserving object, and get rid of mutually exclusive fields. Then it can be something like that (order and names can be changed):
u8 bus;
u16non_pref;
u32 io;
u64 pref;I think Michael suggested:
u64 bus_res; u64 mem_res; u64 io_res; u64 mem_pref_res;OR:
u32 bus_res; u32 mem_res; u32 io_res; u64 mem_pref_res;Quoted 6 lines
Quoted 2 lines
We can use 0XFFF..F as "not-set" value "merging" Gerd's and Michael's requests.
Let's dwell on the second option (with -1 as 'ignore' sign), if no new objections.
BTW, talking about limit values provided in the capability - do we want to completely override
existing PCI resources allocation mechanism being used in SeaBIOS, I mean, to assign capability
values hardly, not taking into consideration any existing checks, or somehow make this process soft (not an obvious way, can lead to another big discussion)?
Quoted 3 lines
In other words, how do we plan to use IO/MEM/PREF limits provided in this capability
in application to the PCIE Root Port, what result is this supposed to achieve?
I think Gerd spoke about this earlier: when determining a given kind of aperture for a given bridge, pick the maximum of:
- the actual cumulative need of the devices behind the bridge, and
- the hint for the given kind of aperture.
So basically, do the same thing as before, but if the hint is larger, grow the aperture to that.
This is how I recall the discussion anyway.
Thanks
Laszlo
Re: [Qemu-devel] [PATCH v3 2/3] pci: add QEMU-specific PCI capability structure
2017-08-04 23:28 GMT+03:00 Laszlo Ersek <[email protected]>:
Quoted 144 lines · Alexander Bezzubikov
Quoted 139 lines
2017-08-01 20:28 GMT+03:00 Alexander Bezzubikov <[email protected]>:
Quoted 123 lines
2017-08-01 16:38 GMT+03:00 Marcel Apfelbaum <[email protected]>:
Quoted 122 lines · Alexander Bezzubikov
Quoted 98 lines
2017-07-31 21:57 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 90 lines · Alexander Bezzubikov
Quoted 78 lines
2017-07-31 17:09 GMT+03:00 Marcel Apfelbaum <[email protected]>:
Quoted 64 lines · Michael S. Tsirkin
Quoted 62 lines · Aleksandr Bezzubikov
Quoted 59 lines
On PCI init PCI bridge devices may need some extra info about bus number to reserve, IO, memory and prefetchable memory limits. QEMU can provide this with special vendor-specific PCI capability.
This capability is intended to be used only for Red Hat PCI bridges, i.e. QEMU cooperation.
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- src/fw/dev-pci.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)create mode 100644
src/fw/dev-pci.hsrc/fw/dev-pci.h new file +9
-0@@ -0,0 +1,62 @@ +#ifndef _PCI_CAP_H +#define _PCI_CAP_H + +#include "types.h" + +/* + +QEMU-specific vendor(Red Hat)-specific capability. +It's intended to provide some hints for firmware to init PCI devices.
src/fw/dev-pci.h new file +26
-0+ +Its is shown below: + +Header: + +u8 id; Standard PCI Capability Header field +u8 next; Standard PCI Capability Header field +u8 len; Standard PCI Capability Header field +u8 type; Red Hat vendor-specific capability type: + now only REDHAT_QEMU_CAP 1 exists +Data: + +u16 non_prefetchable_16; non-prefetchable memory limit + +u8 bus_res; minimum bus number to reserve; + this is necessary for PCI Express Root Ports + to support PCIE-to-PCI bridge hotplug + +u8 io_8; IO limit in case of 8-bit limit value +u32 io_32; IO limit in case of 16-bit limit value + io_8 and io_16 are mutually exclusive, in other words, + they can't be non-zero simultaneously + +u32 prefetchable_32; non-prefetchable memory limit + in case of 32-bit limit value +u64 prefetchable_64; non-prefetchable memory limitQuoted 8 lines
Quoted 8 lines
src/fw/dev-pci.h
Quoted 8 lines
src/fw/dev-pci.h new file +2
-0+ in case of 64-bit limit value + prefetachable_32 and prefetchable_64are
src/fw/dev-pci.h new file +5
-0+ mutually exclusive, in other words, + they can't be non-zero simultaneously +If any field in Data section is 0, +it means that such kind of reservation +is not needed.I really don't like this 'mutually exclusive' fields approach because IMHO it increases confusion level when undertanding this capability
Quoted 8 lines
structure.
But - if we came to consensus on that, then IO fields should be used in the same way,
because as I understand, this 'mutual exclusivity' serves to distinguish cases
when we employ only*_LIMITregister and both*_LIMITan UPPER_*_LIMIT registers.
And this is how both IO and PREFETCHABLE works, isn't it?Quoted 4 lines
I would just use simeple 64 bit registers. PCI spec has an ugly format with fields spread all over the place but that is because of compatibility concerns. It makes not sense to spend cycles just to be similarly messy.
Quoted 8 lines
Then I suggest to use exactly one field of a maximum possible size for each reserving object, and get rid of mutually exclusive fields. Then it can be something like that (order and names can be changed):
u8 bus;
u16non_pref;
u32 io;
u64 pref;I think Michael suggested:
u64 bus_res; u64 mem_res; u64 io_res; u64 mem_pref_res;OR:
u32 bus_res; u32 mem_res; u32 io_res; u64 mem_pref_res;Quoted 6 lines
Quoted 2 lines
We can use 0XFFF..F as "not-set" value "merging" Gerd's and Michael's requests.
Let's dwell on the second option (with -1 as 'ignore' sign), if no new objections.
BTW, talking about limit values provided in the capability - do we want to completely override
existing PCI resources allocation mechanism being used in SeaBIOS, I mean, to assign capability
values hardly, not taking into consideration any existing checks, or somehow make this process soft (not an obvious way, can lead to another big discussion)?Quoted 3 lines
In other words, how do we plan to use IO/MEM/PREF limits provided in this capability
in application to the PCIE Root Port, what result is this supposed to achieve?
Quoted 7 lines
I think Gerd spoke about this earlier: when determining a given kind of aperture for a given bridge, pick the maximum of:
- the actual cumulative need of the devices behind the bridge, and
- the hint for the given kind of aperture.So basically, do the same thing as before, but if the hint is larger, grow the aperture to that.
Looks like current SeaBIOS resource allocation implementation is incorrect. E.g. let's look at IO for pcie-root-port (and ioh3420 too) - we have 2 different pci_region_entry objects, where one of them have bar = -1 (that respresent a bridge
region as it as in the comment there) and size = 0. This leads to the next situation after
the whole BIOS init: root port's IO has base=0x5000,size=0x4FFF. And then Linux reconfigures this values itself.
Should the size of the pci_region be checked for emptiness before creation or this isn't an error for some reason?
Quoted 5 lines
This is how I recall the discussion anyway.
Thanks
Laszlo
Signature · 1 line
Aleksandr Bezzubikov
Re: [Qemu-devel] [PATCH v3 2/3] pci: add QEMU-specific PCI capability structure
Quoted 153 lines · Alexander Bezzubikov
2017-08-04 23:28 GMT+03:00 Laszlo Ersek <[email protected]>:
Quoted 144 lines · Alexander Bezzubikov
Quoted 139 lines
2017-08-01 20:28 GMT+03:00 Alexander Bezzubikov <[email protected]>:
Quoted 123 lines
2017-08-01 16:38 GMT+03:00 Marcel Apfelbaum <[email protected]>:
Quoted 122 lines · Alexander Bezzubikov
Quoted 98 lines
2017-07-31 21:57 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 90 lines · Alexander Bezzubikov
Quoted 78 lines
2017-07-31 17:09 GMT+03:00 Marcel Apfelbaum <[email protected]>:
Quoted 64 lines · Michael S. Tsirkin
Quoted 62 lines · Aleksandr Bezzubikov
Quoted 59 lines
On PCI init PCI bridge devices may need some extra info about bus number to reserve, IO, memory and prefetchable memory limits. QEMU can provide this with special vendor-specific PCI capability.
This capability is intended to be used only for Red Hat PCI bridges, i.e. QEMU cooperation.
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- src/fw/dev-pci.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/fw/dev-pci.hsrc/fw/dev-pci.h new file +9
-0@@ -0,0 +1,62 @@ +#ifndef _PCI_CAP_H +#define _PCI_CAP_H + +#include "types.h" + +/* + +QEMU-specific vendor(Red Hat)-specific capability. +It's intended to provide some hints for firmware to init PCI devices.
src/fw/dev-pci.h new file +26
-0+ +Its is shown below: + +Header: + +u8 id; Standard PCI Capability Header field +u8 next; Standard PCI Capability Header field +u8 len; Standard PCI Capability Header field +u8 type; Red Hat vendor-specific capability type: + now only REDHAT_QEMU_CAP 1 exists +Data: + +u16 non_prefetchable_16; non-prefetchable memory limit + +u8 bus_res; minimum bus number to reserve; + this is necessary for PCI Express Root Ports + to support PCIE-to-PCI bridge hotplug + +u8 io_8; IO limit in case of 8-bit limit value +u32 io_32; IO limit in case of 16-bit limit value + io_8 and io_16 are mutually exclusive, in other words, + they can't be non-zero simultaneously + +u32 prefetchable_32; non-prefetchable memory limit + in case of 32-bit limit value +u64 prefetchable_64; non-prefetchable memory limitQuoted 8 lines
Quoted 8 lines
src/fw/dev-pci.h
Quoted 8 lines
src/fw/dev-pci.h new file +2
-0+ in case of 64-bit limit value + prefetachable_32 and prefetchable_64are
src/fw/dev-pci.h new file +5
-0+ mutually exclusive, in other words, + they can't be non-zero simultaneously +If any field in Data section is 0, +it means that such kind of reservation +is not needed.I really don't like this 'mutually exclusive' fields approach because IMHO it increases confusion level when undertanding this capability
Quoted 8 lines
structure.
But - if we came to consensus on that, then IO fields should be used in the same way,
because as I understand, this 'mutual exclusivity' serves to distinguish cases
when we employ only*_LIMITregister and both*_LIMITan UPPER_*_LIMIT registers.
And this is how both IO and PREFETCHABLE works, isn't it?Quoted 4 lines
I would just use simeple 64 bit registers. PCI spec has an ugly format with fields spread all over the place but that is because of compatibility concerns. It makes not sense to spend cycles just to be similarly messy.
Quoted 8 lines
Then I suggest to use exactly one field of a maximum possible size for each reserving object, and get rid of mutually exclusive fields. Then it can be something like that (order and names can be changed):
u8 bus;
u16non_pref;
u32 io;
u64 pref;I think Michael suggested:
u64 bus_res; u64 mem_res; u64 io_res; u64 mem_pref_res;OR:
u32 bus_res; u32 mem_res; u32 io_res; u64 mem_pref_res;Quoted 6 lines
Quoted 2 lines
We can use 0XFFF..F as "not-set" value "merging" Gerd's and Michael's requests.
Let's dwell on the second option (with -1 as 'ignore' sign), if no new objections.
BTW, talking about limit values provided in the capability - do we want to completely override
existing PCI resources allocation mechanism being used in SeaBIOS, I mean, to assign capability
values hardly, not taking into consideration any existing checks, or somehow make this process soft (not an obvious way, can lead to another big discussion)?Quoted 3 lines
In other words, how do we plan to use IO/MEM/PREF limits provided in this capability
in application to the PCIE Root Port, what result is this supposed to achieve?Quoted 7 lines
I think Gerd spoke about this earlier: when determining a given kind of aperture for a given bridge, pick the maximum of:
- the actual cumulative need of the devices behind the bridge, and
- the hint for the given kind of aperture.So basically, do the same thing as before, but if the hint is larger, grow the aperture to that.
Quoted 10 lines
Looks like current SeaBIOS resource allocation implementation is incorrect. E.g. let's look at IO for pcie-root-port (and ioh3420 too) - we have 2 different
pci_region_entryobjects, where one of them have bar = -1 (that respresent a bridge
region as it as in the comment there) and size = 0. This leads to the next situation after
the whole BIOS init: root port's IO has base=0x5000,size=0x4FFF. And then Linux reconfigures this values itself.
Should the size of thepci_regionbe checked for emptiness before creation or this isn't an error for some reason?
I am not aware of such issue, however there is a patch that prevents SeaBIOS to allocate IO range for PCIe Root Ports if the device attached to it does not require IO ports. (or if a Root Port is empty)
Can you provide more info? (a debug log) Or a patch that could fix the issue you see? So we can better understand the problem.
Thanks,
Marcel
Quoted 9 lines
Quoted 6 lines
This is how I recall the discussion anyway.
Thanks
Laszlo
PATCH v3 3/3 pci: enable RedHat PCI bridges to reserve additional buses on PCI init
In reply to Aleksandr BezzubikovIn case of Red Hat Generic PCIE Root Port reserve additional buses, which number is provided in a vendor-specific capability.
--- src/fw/pciinit.c | 37 +++++++++++++++++++++++++++++++++++-- src/hw/pci_ids.h | 3 +++ src/types.h | 2 ++ 3 files changed, 40 insertions(+), 2 deletions(-)
src/fw/pciinit.c +35 -2
@@ -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); }
src/hw/pci_ids.h +3 -0
@@ -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
src/types.h +2 -0
@@ -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))
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v3 3/3] pci: enable RedHat PCI bridges to reserve additional buses on PCI init
Quoted 26 lines · Aleksandr Bezzubikov
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 <[email protected]>--- src/fw/pciinit.c | 37 +++++++++++++++++++++++++++++++++++-- src/hw/pci_ids.h | 3 +++ src/types.h | 2 ++ 3 files changed, 40 insertions(+), 2 deletions(-)src/fw/pciinit.c +1
-0@@ -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) {
src/fw/pciinit.c pci_bios_init_bus_rec(int bus, u8 *pci_bus) · line 591
Quoted 10 lines
src/fw/pciinit.c +10
-0+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 );
I suggest to extract the bus_reserve computation in a different function.
src/fw/pciinit.c pci_bios_init_bus_rec(int bus, u8 *pci_bus) · line 601
Quoted 10 lines
src/fw/pciinit.c +10
-0+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) {
What do you check here, "garbage" values? Even so, all values are unsigned, are you checking for overflow?
src/fw/pciinit.c pci_bios_init_bus_rec(int bus, u8 *pci_bus) · line 611
Quoted 10 lines
src/fw/pciinit.c +10
-0+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);
Did you re-check the reboot "issue"?
Thanks,
Marcel
Quoted 38 lines
src/fw/pciinit.c +4
-2+ }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); }src/hw/pci_ids.h +3
-0@@ -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 0xdc29src/types.h +2
-0@@ -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))
Re: [Qemu-devel] [PATCH v3 3/3] pci: enable RedHat PCI bridges to reserve additional buses on PCI init
In reply to Aleksandr BezzubikovQuoted 85 lines · Aleksandr Bezzubikov
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 <[email protected]>--- src/fw/pciinit.c | 37 +++++++++++++++++++++++++++++++++++-- src/hw/pci_ids.h | 3 +++ src/types.h | 2 ++ 3 files changed, 40 insertions(+), 2 deletions(-)src/fw/pciinit.c +35
-2@@ -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); }src/hw/pci_ids.h +3
-0@@ -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 0xdc29src/types.h +0
-0
src/types.h extern void __force_link_error__only_in_16bit(void) __noreturn; · line 126
Quoted 5 lines
src/types.h +2
-0@@ -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))
It seems there are many different implementations of min/max macros and how they handle the issue of multiple evaluation. It may be a good idea to add these to SeaBIOS, but not as part of a PCI patch. For now, so as not to complicate this patch, I suggest you just open-code the single use of MAX in your patch.
Otherwise, I'm okay with the SeaBIOS patch series. The QEMU series will need to be committed prior to committing the SeaBIOS patches. However, please continue to address Marcel's (and other's) comments.
-Kevin
Re: [Qemu-devel] [PATCH v3 3/3] pci: enable RedHat PCI bridges to reserve additional buses on PCI init
In reply to Aleksandr BezzubikovQuoted 4 lines · Aleksandr Bezzubikov
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 <[email protected]>
Why does this ignore io/memory reserve parts of the capability?
Quoted 91 lines
--- src/fw/pciinit.c | 37 +++++++++++++++++++++++++++++++++++-- src/hw/pci_ids.h | 3 +++ src/types.h | 2 ++ 3 files changed, 40 insertions(+), 2 deletions(-)src/fw/pciinit.c +35
-2@@ -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); }src/hw/pci_ids.h +3
-0@@ -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 0xdc29src/types.h +2
-0@@ -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))Signature · 1 line
2.7.4