Generic PCIE-PCI Bridge
v2 cover Generic PCIE-PCI Bridge
This series introduces a new device - generic PCI Express to PCI bridge, and also makes all necessary changes to enable hotplug of the bridge itself and any device into the bridge.
Obvious reasons to remain RFC:
1. The new PCI capability: layout, creation interface.
2. Windows SHPC issue - devices hotplugging into the bridge doens't work on Windows 7 (unlike Windows 10), whereas an old pci-bridge usage is fine.
3. Hot-unplug not completely tested.
Changes v1->v2:
1. Enable SHPC for the bridge.
2. Enable SHPC support for the Q35 machine (ACPI stuff).
3. Introduce PCI capability to help firmware on the system init. This allows the bridge to be hotpluggable. Now it's supported only for pcie-root-port. Now it's supposed to used with SeaBIOS only, look at the SeaBIOS corresponding series "".
Aleksandr Bezzubikov (6):
hw/pci: introduce pcie-pci-bridge device
hw/i386: allow SHPC for Q35 machine
hw/pci: enable SHPC for PCIE-PCI bridge
hw/pci: introduce bridge-only vendor-specific capability to provide
some hints to firmware
hw/pci: add bus_reserve property to pcie-root-port hw/pci: add hint capabilty for additional bus reservation to
pcie-root-port
hw/i386/acpi-build.c | 2 +- hw/pci-bridge/Makefile.objs | 2 +- hw/pci-bridge/pcie_pci_bridge.c | 212 ++++++++++++++++++++++++++++++++++++++++ hw/pci-bridge/pcie_root_port.c | 6 ++ hw/pci/pci_bridge.c | 27 +++++ include/hw/pci/pci.h | 1 + include/hw/pci/pci_bridge.h | 18 ++++ include/hw/pci/pcie_port.h | 3 + 8 files changed, 269 insertions(+), 2 deletions(-) create mode 100644 hw/pci-bridge/pcie_pci_bridge.c
Signature · 1 line
2.7.4
RFC PATCH v2 1/6 hw/pci: introduce pcie-pci-bridge device
--- hw/pci-bridge/Makefile.objs | 2 +- hw/pci-bridge/pcie_pci_bridge.c | 151 ++++++++++++++++++++++++++++++++++++++++ include/hw/pci/pci.h | 1 + 3 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 hw/pci-bridge/pcie_pci_bridge.c
hw/pci-bridge/Makefile.objs +1 -1
@@ -1,4 +1,4 @@ -common-obj-y += pci_bridge_dev.o +common-obj-y += pci_bridge_dev.o pcie_pci_bridge.o common-obj-$(CONFIG_PCIE_PORT) += pcie_root_port.o gen_pcie_root_port.o common-obj-$(CONFIG_PXB) += pci_expander_bridge.o common-obj-$(CONFIG_XIO3130) += xio3130_upstream.o xio3130_downstream.o
hw/pci-bridge/pcie_pci_bridge.c new file +151 -0
151 lines not on this page · raw message
include/hw/pci/pci.h +1 -0
@@ -98,6 +98,7 @@#define PCI_DEVICE_ID_REDHAT_PXB_PCIE 0x000b#define PCI_DEVICE_ID_REDHAT_PCIE_RP 0x000c#define PCI_DEVICE_ID_REDHAT_XHCI 0x000d +#define PCI_DEVICE_ID_REDHAT_PCIE_BRIDGE 0x000e#define PCI_DEVICE_ID_REDHAT_QXL 0x0100#define FMT_PCIBUS PRIx64
Signature · 1 line
2.7.4
RFC PATCH v2 2/6 hw/i386: allow SHPC for Q35 machine
In reply to Aleksandr BezzubikovUnmask previously masked SHPC feature in _OSC method.
--- hw/i386/acpi-build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/acpi-build.c +1 -1
@@ -1850,7 +1850,7 @@ static Aml *build_q35_osc_method(void)* Always allow native PME, AER (no dependencies) * Never allow SHPC (no SHPC controller in this system) */ -aml_append (if_ctx,aml_and (a_ctrl,aml_int (0x1D ), a_ctrl)); +aml_append (if_ctx,aml_and (a_ctrl,aml_int (0x1F ), a_ctrl)); if_ctx2 =aml_if (aml_lnot (aml_equal (aml_arg (1 ),aml_int (1 ))));/* Unknown revision */
Signature · 1 line
2.7.4
Re: [Qemu-devel] [RFC PATCH v2 2/6] hw/i386: allow SHPC for Q35 machine
Quoted 12 lines · Aleksandr Bezzubikov
Unmask previously masked SHPC feature in
_OSCmethod.Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/i386/acpi-build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/i386/acpi-build.c +0
-0
hw/i386/acpi-build.c static Aml *build_q35_osc_method(void) · line 1851
Quoted 2 lines
hw/i386/acpi-build.c +0
-0@@ -1850,7 +1850,7 @@ static Aml *build_q35_osc_method(void)* Always allow native PME, AER (no dependencies) * Never allow SHPC (no SHPC controller in this system)
Seems the above comment is not longer correct :)
Thanks,
Marcel
Quoted 7 lines
hw/i386/acpi-build.c +1
-1*/ -aml_append (if_ctx,aml_and (a_ctrl,aml_int (0x1D ), a_ctrl)); +aml_append (if_ctx,aml_and (a_ctrl,aml_int (0x1F ), a_ctrl)); if_ctx2 =aml_if (aml_lnot (aml_equal (aml_arg (1 ),aml_int (1 ))));/* Unknown revision */
Re: [Qemu-devel] [RFC PATCH v2 2/6] hw/i386: allow SHPC for Q35 machine
2017-07-23 18:59 GMT+03:00 Marcel Apfelbaum <[email protected]>:
Quoted 9 lines · Aleksandr Bezzubikov
Quoted 8 lines
Unmask previously masked SHPC feature in
_OSCmethod.Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/i386/acpi-build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 11 lines
hw/i386/acpi-build.c static Aml *build_q35_osc_method(void) · line 1852
Quoted 8 lines
hw/i386/acpi-build.c +0
-0@@ -1850,7 +1850,7 @@ static Aml *build_q35_osc_method(void)* Always allow native PME, AER (no dependencies) * Never allow SHPC (no SHPC controller in this system) Seems the above comment is not longer correct :)
Just missed it, will fix in v3.
Quoted 13 lines
Thanks,
Marcel*/Quoted 6 lines
hw/i386/acpi-build.c +1
-1-aml_append (if_ctx,aml_and (a_ctrl,aml_int (0x1D ), a_ctrl)); +aml_append (if_ctx,aml_and (a_ctrl,aml_int (0x1F ), a_ctrl)); if_ctx2 =aml_if (aml_lnot (aml_equal (aml_arg (1 ),aml_int (1 ))));/* Unknown revision */
Signature · 1 line
Alexander Bezzubikov
RFC PATCH v2 3/6 hw/pci: enable SHPC for PCIE-PCI bridge
In reply to Aleksandr Bezzubikov--- hw/pci-bridge/pcie_pci_bridge.c | 63 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-)
hw/pci-bridge/pcie_pci_bridge.c +62 -1
@@ -28,6 +28,7 @@#include "hw/pci/pci_bus.h" #include "hw/pci/pci_bridge.h" #include "hw/pci/msi.h" +#include "hw/pci/shpc.h" #include "hw/pci/slotid_cap.h" typedef struct PCIEPCIBridge {
@@ -35,6 +36,7 @@ typedef struct PCIEPCIBridge {PCIBridge parent_obj;uint32_t flags; +MemoryRegion bar;/*< public >*/ } PCIEPCIBridge;
@@ -44,11 +46,22 @@ typedef struct PCIEPCIBridge {static void pciepci_bridge_realize (PCIDevice *d,Error **errp) { +PCIBridge *br =PCI_BRIDGE (d); +PCIEPCIBridge *bridge_dev =PCIE_PCI_BRIDGE_DEV (d);int rc, pos;Error *local_err =NULL ;pci_bridge_initfn (d,TYPE_PCI_BUS ); + d->config[PCI_INTERRUPT_PIN ] =0x1 ; +memory_region_init (&bridge_dev->bar,OBJECT (d),"shpc-bar" , +shpc_bar_size (d)); + rc =shpc_init (d, &br->sec_bus, &bridge_dev->bar,0 , &local_err); +if (rc) { +error_propagate (errp, local_err); + goto error; + } + rc =pcie_cap_init (d,0 ,PCI_EXP_TYPE_PCI_BRIDGE ,0 , &local_err);if (rc <0 ) {error_propagate (errp, local_err);
@@ -78,6 +91,9 @@ static void pciepci_bridge_realize(PCIDevice *d, Error **errp) goto error; } +pci_register_bar (d,0 ,PCI_BASE_ADDRESS_SPACE_MEMORY | +PCI_BASE_ADDRESS_MEM_TYPE_64 , &bridge_dev->bar); +return ; error:
@@ -86,7 +102,9 @@ static void pciepci_bridge_realize(PCIDevice *d, Error **errp)static void pciepci_bridge_exit (PCIDevice *d) { +PCIEPCIBridge *bridge_dev =PCIE_PCI_BRIDGE_DEV (d);pcie_cap_exit (d); +shpc_cleanup (d, &bridge_dev->bar);pci_bridge_exitfn (d); }
@@ -95,6 +113,7 @@ static void pciepci_bridge_reset(DeviceState *qdev)PCIDevice *d =PCI_DEVICE (qdev);pci_bridge_reset (qdev);msi_reset (d); +shpc_reset (d); } static void pcie_pci_bridge_write_config(PCIDevice *d,
@@ -102,8 +121,15 @@ static void pcie_pci_bridge_write_config(PCIDevice *d, {pci_bridge_write_config (d, address, val, len);msi_write_config (d, address, val, len); +shpc_cap_write_config (d, address, val, len); } +static bool pci_device_shpc_present (void *opaque,int version_id) +{ +PCIDevice *dev = opaque; + +return shpc_present (dev); +}static Property pcie_pci_bridge_dev_properties[] = {DEFINE_PROP_END_OF_LIST (),
@@ -113,14 +139,43 @@ static const VMStateDescription pciepci_bridge_dev_vmstate = { .name = TYPE_PCIE_PCI_BRIDGE_DEV, .fields = (VMStateField []) {VMSTATE_PCI_DEVICE (parent_obj, PCIBridge), +SHPC_VMSTATE (shpc, PCIDevice, pci_device_shpc_present),VMSTATE_END_OF_LIST () } }; +static void pcie_pci_bridge_hotplug_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) +{ +PCIDevice *pci_hotplug_dev =PCI_DEVICE (hotplug_dev); + +if (!shpc_present (pci_hotplug_dev)) { +error_setg (errp,"standard hotplug controller has been disabled for " +"this %s" ,TYPE_PCIE_PCI_BRIDGE_DEV ); +return ; + } +shpc_device_hotplug_cb (hotplug_dev, dev, errp); +} + +static void pcie_pci_bridge_hot_unplug_request_cb (HotplugHandler *hotplug_dev, +DeviceState *dev, +Error **errp) +{ +PCIDevice *pci_hotplug_dev =PCI_DEVICE (hotplug_dev); + +if (!shpc_present (pci_hotplug_dev)) { +error_setg (errp,"standard hotplug controller has been disabled for " +"this %s" ,TYPE_PCIE_PCI_BRIDGE_DEV ); +return ; + } +shpc_device_hot_unplug_request_cb (hotplug_dev, dev, errp); +} +static void pciepci_bridge_class_init (ObjectClass *klass,void *data) {PCIDeviceClass *k =PCI_DEVICE_CLASS (klass);DeviceClass *dc =DEVICE_CLASS (klass); +HotplugHandlerClass *hc =HOTPLUG_HANDLER_CLASS (klass); k->is_express =1 ; k->is_bridge =1 ;
@@ -134,13 +189,19 @@ static void pciepci_bridge_class_init(ObjectClass *klass, void *data) dc->vmsd = &pciepci_bridge_dev_vmstate; dc->reset = &pciepci_bridge_reset;set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); + hc->plug = pcie_pci_bridge_hotplug_cb; + hc->unplug_request = pcie_pci_bridge_hot_unplug_request_cb; }static const TypeInfo pciepci_bridge_info = { .name =TYPE_PCIE_PCI_BRIDGE_DEV , .parent =TYPE_PCI_BRIDGE , .instance_size =sizeof (PCIEPCIBridge), - .class_init = pciepci_bridge_class_init + .class_init = pciepci_bridge_class_init, + .interfaces = (InterfaceInfo []) { + {TYPE_HOTPLUG_HANDLER }, + { }, + } };static void pciepci_register (void )
Signature · 1 line
2.7.4
RFC PATCH v2 4/6 hw/pci: introduce bridge-only vendor-specific capability to provide some hints to firmware
In reply to Aleksandr BezzubikovOn PCI init PCI bridges 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.
Sizes of limits match ones from
PCI Type 1 Configuration Space Header,
number of buses to reserve occupies only 1 byte since it is the size of Subordinate Bus Number register.
--- hw/pci/pci_bridge.c | 27 +++++++++++++++++++++++++++ include/hw/pci/pci_bridge.h | 18 ++++++++++++++++++ 2 files changed, 45 insertions(+)
hw/pci/pci_bridge.c +27 -0
@@ -408,6 +408,33 @@ void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, br->bus_name = bus_name; } + +int pci_bridge_help_cap_init (PCIDevice *dev,int cap_offset, +uint8_t bus_reserve,uint32_t io_limit, +uint16_t mem_limit,uint64_t pref_limit, +Error **errp) +{ +size_t cap_len =sizeof (PCIBridgeQemuCap); +PCIBridgeQemuCap cap; + + cap.len = cap_len; + cap.bus_res = bus_reserve; + cap.io_lim = io_limit &0xFF ; + cap.io_lim_upper = io_limit >>8 &0xFFFF ; + cap.mem_lim = mem_limit; + cap.pref_lim = pref_limit &0xFFFF ; + cap.pref_lim_upper = pref_limit >>16 &0xFFFFFFFF ; + +int offset =pci_add_capability (dev,PCI_CAP_ID_VNDR , + cap_offset, cap_len, errp); +if (offset <0 ) { +return offset; + } + +memcpy (dev->config + offset +2 , (char *)&cap +2 , cap_len -2 ); +return 0 ; +} +static const TypeInfo pci_bridge_type_info = { .name =TYPE_PCI_BRIDGE , .parent =TYPE_PCI_DEVICE ,
include/hw/pci/pci_bridge.h +18 -0
@@ -67,4 +67,22 @@ 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 bus_res; +uint32_t pref_lim_upper; +uint16_t pref_lim; +uint16_t mem_lim; +uint16_t io_lim_upper; +uint8_t io_lim; +uint8_t padding; +}PCIBridgeQemuCap ; + +int pci_bridge_help_cap_init (PCIDevice *dev,int cap_offset, +uint8_t bus_reserve,uint32_t io_limit, +uint16_t mem_limit,uint64_t pref_limit, +Error **errp); +#endif /* QEMU_PCI_BRIDGE_H */
Signature · 1 line
2.7.4
Re: [Qemu-devel] [RFC PATCH v2 4/6] hw/pci: introduce bridge-only vendor-specific capability to provide some hints to firmware
Quoted 10 lines · Aleksandr Bezzubikov
On PCI init PCI bridges 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.Sizes of limits match ones from
PCI Type 1 Configuration Space Header,
number of buses to reserve occupies only 1 byte since it is the size of Subordinate Bus Number register.
Hi Alexandr,
Quoted 11 lines
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/pci/pci_bridge.c | 27 +++++++++++++++++++++++++++ include/hw/pci/pci_bridge.h | 18 ++++++++++++++++++ 2 files changed, 45 insertions(+)hw/pci/pci_bridge.c +0
-0
hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 412
Quoted 5 lines
hw/pci/pci_bridge.c +2
-0@@ -408,6 +408,33 @@ void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, br->bus_name = bus_name; } + +int pci_bridge_help_cap_init(PCIDevice *dev, int cap_offset,
Can you please rename to something like
'pci_bridge_qemu_cap_init' to be more specific?
hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 414
Quoted 2 lines
hw/pci/pci_bridge.c +2
-0+ uint8_t bus_reserve, uint32_t io_limit, + uint16_t mem_limit, uint64_t pref_limit,
I am not sure regarding "limit" suffix, this
is a reservation, not a limitation.
Quoted 32 lines
hw/pci/pci_bridge.c +23
-0+ Error **errp) +{ +size_t cap_len =sizeof (PCIBridgeQemuCap); +PCIBridgeQemuCap cap; + + cap.len = cap_len; + cap.bus_res = bus_reserve; + cap.io_lim = io_limit &0xFF ; + cap.io_lim_upper = io_limit >>8 &0xFFFF ; + cap.mem_lim = mem_limit; + cap.pref_lim = pref_limit &0xFFFF ; + cap.pref_lim_upper = pref_limit >>16 &0xFFFFFFFF ; + +int offset =pci_add_capability (dev,PCI_CAP_ID_VNDR , + cap_offset, cap_len, errp); +if (offset <0 ) { +return offset; + } + +memcpy (dev->config + offset +2 , (char *)&cap +2 , cap_len -2 ); +return 0 ; +} +static const TypeInfo pci_bridge_type_info = { .name =TYPE_PCI_BRIDGE , .parent =TYPE_PCI_DEVICE ,include/hw/pci/pci_bridge.h +0
-0@@ -67,4 +67,22 @@ void pci_bridge_map_irq(PCIBridge *br, const char* bus_name,#define PCI_BRIDGE_CTL_DISCARD_STATUS 0x400/* Discard timer status */
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 77
Quoted 10 lines
include/hw/pci/pci_bridge.h +8
-0#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 bus_res; + uint32_t pref_lim_upper; + uint16_t pref_lim; + uint16_t mem_lim;
This 32bit IOMEM, right?
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 79
Quoted 2 lines
include/hw/pci/pci_bridge.h +2
-0+uint16_t io_lim_upper; +uint8_t io_lim;
Why do we need io_lim and io_lim_upper?
Thanks,
Marcel
Quoted 10 lines
include/hw/pci/pci_bridge.h +8
-0+ uint8_t padding; +} PCIBridgeQemuCap; + +int pci_bridge_help_cap_init (PCIDevice *dev,int cap_offset, +uint8_t bus_reserve,uint32_t io_limit, +uint16_t mem_limit,uint64_t pref_limit, +Error **errp); +#endif /* QEMU_PCI_BRIDGE_H */
Re: [Qemu-devel] [RFC PATCH v2 4/6] hw/pci: introduce bridge-only vendor-specific capability to provide some hints to firmware
2017-07-23 18:57 GMT+03:00 Marcel Apfelbaum <[email protected]>:
Quoted 36 lines · Aleksandr Bezzubikov
Quoted 6 lines
On PCI init PCI bridges 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.Quoted 6 lines
Sizes of limits match ones from
PCI Type 1 Configuration Space Header,
number of buses to reserve occupies only 1 byte since it is the size of Subordinate Bus Number register.Hi Alexandr,
Signed-off-by Aleksandr Bezzubikov <[email protected]>Quoted 10 lines
--- hw/pci/pci_bridge.c | 27 +++++++++++++++++++++++++++ include/hw/pci/pci_bridge.h | 18 ++++++++++++++++++ 2 files changed, 45 insertions(+)hw/pci/pci_bridge.c +0
-0hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* · line 413
Quoted 6 lines
hw/pci/pci_bridge.c +1
-0@@ -408,6 +408,33 @@ void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, br->bus_name = bus_name; } + +int pci_bridge_help_cap_init(PCIDevice *dev, int cap_offset,Can you please rename to something like
'pci_bridge_qemu_cap_init' to be more specific?
Quoted 7 lines
+
uint8_tbus_reserve,uint32_tio_limit,hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* · line 415
Quoted 2 lines
hw/pci/pci_bridge.c +1
-0+ uint16_t mem_limit, uint64_t pref_limit,I am not sure regarding "limit" suffix, this
is a reservation, not a limitation.
I'd like this fields names to match actual registers which are going to get the values.
Quoted 51 lines
+ Error **errp)
Quoted 41 lines
hw/pci/pci_bridge.c +22
-0+{ +size_t cap_len =sizeof (PCIBridgeQemuCap); +PCIBridgeQemuCap cap; + + cap.len = cap_len; + cap.bus_res = bus_reserve; + cap.io_lim = io_limit &0xFF ; + cap.io_lim_upper = io_limit >>8 &0xFFFF ; + cap.mem_lim = mem_limit; + cap.pref_lim = pref_limit &0xFFFF ; + cap.pref_lim_upper = pref_limit >>16 &0xFFFFFFFF ; + +int offset =pci_add_capability (dev,PCI_CAP_ID_VNDR , + cap_offset, cap_len, errp); +if (offset <0 ) { +return offset; + } + +memcpy (dev->config + offset +2 , (char *)&cap +2 , cap_len -2 ); +return 0 ; +} +static const TypeInfo pci_bridge_type_info = { .name =TYPE_PCI_BRIDGE , .parent =TYPE_PCI_DEVICE ,include/hw/pci/pci_bridge.h +0
-0@@ -67,4 +67,22 @@ void pci_bridge_map_irq(PCIBridge *br, const char* bus_name,#define PCI_BRIDGE_CTL_DISCARD_STATUS 0x400/* Discard timer status */
#definePCI_BRIDGE_CTL_DISCARD_SERR0x800/* Discard timer SERR#
enable */
+typedef struct PCIBridgeQemuCap {include/hw/pci/pci_bridge.h +3
-0+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 */
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 77
Quoted 4 lines
include/hw/pci/pci_bridge.h +4
-0+uint8_t bus_res; +uint32_t pref_lim_upper; +uint16_t pref_lim; +uint16_t mem_lim;This 32bit IOMEM, right?
Quoted 6 lines
+
uint16_tio_lim_upper;Quoted 2 lines
+
uint8_tio_lim;Why do we need
io_limandio_lim_upper?
The idea was to be able to directly move the capability fields values to the registers when actually using it (in firmware) code. Secondly, it saves a little space by avoding usage 32-bit types when 24-bit ones are desired. And the same thing with prefetchable (48->64). But if it's more convenient no to split this value, I can do that.
Quoted 17 lines
Thanks,
Marcel+
uint8_tpadding;Quoted 10 lines
include/hw/pci/pci_bridge.h +7
-0+} PCIBridgeQemuCap; + +int pci_bridge_help_cap_init (PCIDevice *dev,int cap_offset, +uint8_t bus_reserve,uint32_t io_limit, +uint16_t mem_limit,uint64_t pref_limit, +Error **errp); +#endif /* QEMU_PCI_BRIDGE_H */
Signature · 1 line
Alexander Bezzubikov
Re: [Qemu-devel] [RFC PATCH v2 4/6] hw/pci: introduce bridge-only vendor-specific capability to provide some hints to firmware
Quoted 46 lines · Alexander Bezzubikov
2017-07-23 18:57 GMT+03:00 Marcel Apfelbaum <[email protected] <mailto:[email protected]>>:
On 23/07/2017 1:15, Aleksandr Bezzubikov wrote:
On PCI init PCI bridges 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.Sizes of limits match ones from
PCI Type 1 Configuration Space Header,
number of buses to reserve occupies only 1 byte since it is the size of Subordinate Bus Number register.Hi Alexandr,
Signed-off-by Aleksandr Bezzubikov <[email protected]<mailto:[email protected]>>
---
hw/pci/pci_bridge.c| 27 +++++++++++++++++++++++++++
include/hw/pci/pci_bridge.h| 18 ++++++++++++++++++ 2 files changed, 45 insertions(+)diff --git
a/hw/pci/pci_bridge.cb/hw/pci/pci_bridge.cindex 720119b..8ec6c2c 100644
---a/hw/pci/pci_bridge.c
+++b/hw/pci/pci_bridge.c
@@ -408,6 +408,33 @@ void pci_bridge_map_irq(PCIBridge *br, const char*bus_name,
br->bus_name=bus_name;
}
+
+int pci_bridge_help_cap_init(PCIDevice *dev, intcap_offset,Can you please rename to something like '
pci_bridge_qemu_cap_init' to be more specific?+
uint8_tbus_reserve,uint32_t
io_limit,
+uint16_tmem_limit,uint64_t
pref_limit,
Quoted 7 lines
I am not sure regarding "limit" suffix, this
is a reservation, not a limitation.I'd like this fields names to match actual registers which are going to get the values.
For this case I think is better to have io_res..., to describe the parameter rather than match the registers.
Quoted 57 lines
+ Error **errp)
+{
+size_tcap_len= sizeof(PCIBridgeQemuCap);
+ PCIBridgeQemuCap cap;
+
+ cap.len =cap_len;
+ cap.bus_res =bus_reserve;
+ cap.io_lim =io_limit&0xFF;
+ cap.io_lim_upper =io_limit>> 8 &0xFFFF;
+ cap.mem_lim =mem_limit;
+ cap.pref_lim =pref_limit&0xFFFF;
+ cap.pref_lim_upper =pref_limit>> 16 &0xFFFFFFFF;
+
+ int offset = pci_add_capability(dev,PCI_CAP_ID_VNDR,
+cap_offset,cap_len, errp);
+ if (offset < 0) {
+ return offset;
+ }
+
+ memcpy(dev->config + offset + 2, (char *)&cap + 2,cap_len
- 2);
+ return 0;
+}
+
static const TypeInfopci_bridge_type_info= {
.name =TYPE_PCI_BRIDGE,
.parent =TYPE_PCI_DEVICE,
diff --gita/include/hw/pci/pci_bridge.hb/include/hw/pci/pci_bridge.h
index ff7cbaa..c9f642c 100644
---a/include/hw/pci/pci_bridge.h
+++b/include/hw/pci/pci_bridge.h
@@ -67,4 +67,22 @@ void pci_bridge_map_irq(PCIBridge *br, const char*bus_name,
#definePCI_BRIDGE_CTL_DISCARD_STATUS0x400/*
Discard timer status */
#definePCI_BRIDGE_CTL_DISCARD_SERR0x800/* Discard
timer SERR# enable */
+typedef struct PCIBridgeQemuCap {
+uint8_tid; /* Standard PCI capability header field */
+uint8_tnext; /* Standard PCI capability header field */
+uint8_tlen; /* Standard PCI vendor-specific capability
header field */
+uint8_tbus_res;
+uint32_tpref_lim_upper;
+uint16_tpref_lim;
+uint16_tmem_lim;This 32bit IOMEM, right?
+
uint16_tio_lim_upper;
+uint8_tio_lim;
Quoted 8 lines
Why do we need
io_limandio_lim_upper?The idea was to be able to directly move the capability fields values to the registers when actually using it (in firmware) code. Secondly, it saves a little space by avoding usage 32-bit types when 24-bit ones are desired. And the same thing with prefetchable (48->64). But if it's more convenient no to split this value, I can do that.
With a clear explanation (Mimic of the <PCI config space field>) I personally don't mind keeping it like that.
Thanks,
Marcel
Quoted 24 lines
Thanks,
Marcel+
uint8_tpadding;
+} PCIBridgeQemuCap;
+
+int pci_bridge_help_cap_init(PCIDevice *dev, intcap_offset,
+uint8_tbus_reserve,uint32_t
io_limit,
+uint16_tmem_limit,uint64_t
pref_limit,
+ Error **errp);
+
#endif /*QEMU_PCI_BRIDGE_H*/Signature · 1 line
Alexander Bezzubikov
Re: [Qemu-devel] [RFC PATCH v2 4/6] hw/pci: introduce bridge-only vendor-specific capability to provide some hints to firmware
In reply to Aleksandr BezzubikovQuoted 4 lines · Aleksandr Bezzubikov
On PCI init PCI bridges may need some
extra info about bus number to reserve, IO, memory and prefetchable memory limits. QEMU can provide this with special
with a special
Quoted 18 lines
vendor-specific PCI capability.
Sizes of limits match ones from
PCI Type 1 Configuration Space Header,
number of buses to reserve occupies only 1 byte since it is the size of Subordinate Bus Number register.Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/pci/pci_bridge.c | 27 +++++++++++++++++++++++++++ include/hw/pci/pci_bridge.h | 18 ++++++++++++++++++ 2 files changed, 45 insertions(+)hw/pci/pci_bridge.c +0
-0
hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 412
Quoted 5 lines
hw/pci/pci_bridge.c +2
-0@@ -408,6 +408,33 @@ void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, br->bus_name = bus_name; } + +int pci_bridge_help_cap_init(PCIDevice *dev, int cap_offset,
help? should be qemu_cap_init?
hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 418
Quoted 6 lines
hw/pci/pci_bridge.c +6
-0+ uint8_t bus_reserve, uint32_t io_limit, + uint16_t mem_limit, uint64_t pref_limit, + Error **errp) +{ + size_t cap_len = sizeof(PCIBridgeQemuCap); +PCIBridgeQemuCap cap;
This leaks info to guest. You want to init all fields here:
cap = {
.len = ....
};
hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 426
Quoted 8 lines
hw/pci/pci_bridge.c +8
-0+ + cap.len = cap_len; + cap.bus_res = bus_reserve; + cap.io_lim = io_limit &0xFF ; + cap.io_lim_upper = io_limit >>8 &0xFFFF ; + cap.mem_lim = mem_limit; + cap.pref_lim = pref_limit &0xFFFF ; + cap.pref_lim_upper = pref_limit >>16 &0xFFFFFFFF ;
Please use pci_set_word etc or cpu_to_leXX.
I think it's easiest to replace struct with a set of macros then pci_set_word does the work for you.
hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 434
Quoted 8 lines
hw/pci/pci_bridge.c +8
-0+ +int offset =pci_add_capability (dev,PCI_CAP_ID_VNDR , + cap_offset, cap_len, errp); +if (offset <0 ) { +return offset; + } + +memcpy (dev->config + offset +2 , (char *)&cap +2 , cap_len -2 );
+2 is yacky. See how virtio does it:
memcpy(dev->config + offset + PCI_CAP_FLAGS, &cap->cap_len,
cap->cap_len - PCI_CAP_FLAGS);Quoted 11 lines
hw/pci/pci_bridge.c +3
-0+return 0 ; +} +static const TypeInfo pci_bridge_type_info = { .name =TYPE_PCI_BRIDGE , .parent =TYPE_PCI_DEVICE ,include/hw/pci/pci_bridge.h +0
-0
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 75
Quoted 9 lines
include/hw/pci/pci_bridge.h +6
-0@@ -67,4 +67,22 @@ 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 bus_res; + uint32_t pref_lim_upper;
Big endian? Ugh.
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 77
Quoted 2 lines
include/hw/pci/pci_bridge.h +2
-0+uint16_t pref_lim; +uint16_t mem_lim;
I'd say we need 64 bit for memory.
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 80
Quoted 3 lines
include/hw/pci/pci_bridge.h +3
-0+uint16_t io_lim_upper; +uint8_t io_lim; +uint8_t padding;
IMHO each type should have a special "don't care" flag that would mean "I don't know".
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 81
Quoted 1 line
include/hw/pci/pci_bridge.h +1
-0+} PCIBridgeQemuCap;
You don't really need this struct in the header. And pls document all fields.
Quoted 9 lines
include/hw/pci/pci_bridge.h +6
-0+ +int pci_bridge_help_cap_init (PCIDevice *dev,int cap_offset, +uint8_t bus_reserve,uint32_t io_limit, +uint16_t mem_limit,uint64_t pref_limit, +Error **errp); +#endif /* QEMU_PCI_BRIDGE_H */ Signature · 1 line
2.7.4
Re: [Qemu-devel] [RFC PATCH v2 4/6] hw/pci: introduce bridge-only vendor-specific capability to provide some hints to firmware
2017-07-26 22:43 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 41 lines · Aleksandr Bezzubikov
Quoted 4 lines
On PCI init PCI bridges may need some
extra info about bus number to reserve, IO, memory and prefetchable memory limits. QEMU can provide this with specialwith a special
Quoted 18 lines
vendor-specific PCI capability.
Sizes of limits match ones from
PCI Type 1 Configuration Space Header,
number of buses to reserve occupies only 1 byte since it is the size of Subordinate Bus Number register.Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/pci/pci_bridge.c | 27 +++++++++++++++++++++++++++ include/hw/pci/pci_bridge.h | 18 ++++++++++++++++++ 2 files changed, 45 insertions(+)hw/pci/pci_bridge.c +0
-0hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 412
Quoted 5 lines
hw/pci/pci_bridge.c +2
-0@@ -408,6 +408,33 @@ void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, br->bus_name = bus_name; } + +int pci_bridge_help_cap_init(PCIDevice *dev, int cap_offset,help? should be
qemu_cap_init?hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 418
Quoted 6 lines
hw/pci/pci_bridge.c +6
-0+ uint8_t bus_reserve, uint32_t io_limit, + uint16_t mem_limit, uint64_t pref_limit, + Error **errp) +{ + size_t cap_len = sizeof(PCIBridgeQemuCap); +PCIBridgeQemuCap cap;
Quoted 5 lines
This leaks info to guest. You want to init all fields here:
cap = {
.len = ....
};
I surely can do this for len field, but as Laszlo proposed we can use mutually exclusive fields,
e.g. pref_32 and pref_64, the only way I have left is to use ternary operator (if we surely need this big initializer). Keeping some if's would look better, I think.
Quoted 10 lines
hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 426
Quoted 9 lines
hw/pci/pci_bridge.c +8
-0+ + cap.len = cap_len; + cap.bus_res = bus_reserve; + cap.io_lim = io_limit &0xFF ; + cap.io_lim_upper = io_limit >>8 &0xFFFF ; + cap.mem_lim = mem_limit; + cap.pref_lim = pref_limit &0xFFFF ; + cap.pref_lim_upper = pref_limit >>16 &0xFFFFFFFF ;
Quoted 2 lines
Please use
pci_set_wordetc orcpu_to_leXX.
Since now we've decided to avoid fields separation into <field> + <field_upper>, this bitmask along with pci_set_word are no longer needed.
Quoted 3 lines
I think it's easiest to replace struct with a set of macros then
pci_set_worddoes the work for you.
I don't really want to use macros here because structure show us the whole capability layout and this can decrease documenting efforts. More than that, memcpy usage is very convenient here, and I wouldn't like to lose it.
Quoted 12 lines
hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 434
Quoted 9 lines
hw/pci/pci_bridge.c +8
-0+ +int offset =pci_add_capability (dev,PCI_CAP_ID_VNDR , + cap_offset, cap_len, errp); +if (offset <0 ) { +return offset; + } + +memcpy (dev->config + offset +2 , (char *)&cap +2 , cap_len -2 );+2 is yacky. See how virtio does it:
Quoted 4 lines
memcpy(dev->config + offset + PCI_CAP_FLAGS, &cap->cap_len,
cap->cap_len - PCI_CAP_FLAGS);OK.
Quoted 14 lines
Quoted 14 lines
hw/pci/pci_bridge.c +3
-0+return 0 ; +} +static const TypeInfo pci_bridge_type_info = { .name =TYPE_PCI_BRIDGE , .parent =TYPE_PCI_DEVICE ,include/hw/pci/pci_bridge.h +0
-0@@ -67,4 +67,22 @@ 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 */
Quoted 9 lines
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 75
Quoted 6 lines
include/hw/pci/pci_bridge.h +6
-0+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 bus_res; + uint32_t pref_lim_upper;Big endian? Ugh.
Agreed, and this's gonna to disappear with
the new layout.
Quoted 5 lines
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 77
Quoted 2 lines
include/hw/pci/pci_bridge.h +2
-0+uint16_t pref_lim; +uint16_t mem_lim;I'd say we need 64 bit for memory.
Why? Non-prefetchable MEMORY_LIMIT register is 16 bits long.
Quoted 8 lines
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 80
Quoted 3 lines
include/hw/pci/pci_bridge.h +3
-0+uint16_t io_lim_upper; +uint8_t io_lim; +uint8_t padding;IMHO each type should have a special "don't care" flag that would mean "I don't know".
Don't know what? Now 0 is an indicator to do nothing with this field.
Quoted 4 lines
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 81
Quoted 1 line
include/hw/pci/pci_bridge.h +1
-0+} PCIBridgeQemuCap;You don't really need this struct in the header. And pls document all fields.
Quoted 9 lines
Quoted 9 lines
include/hw/pci/pci_bridge.h +6
-1+ +int pci_bridge_help_cap_init (PCIDevice *dev,int cap_offset, +uint8_t bus_reserve,uint32_t io_limit, +uint16_t mem_limit,uint64_t pref_limit, +Error **errp); +#endif /* QEMU_PCI_BRIDGE_H */ --2.7.4
--
Alexander Bezzubikov
Re: [Qemu-devel] [SeaBIOS] [RFC PATCH v2 4/6] hw/pci: introduce bridge-only vendor-specific capability to provide some hints to firmware
Quoted 11 lines · Alexander Bezzubikov
2017-07-26 22:43 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 9 lines · Aleksandr Bezzubikov
Quoted 2 lines
+ PCIBridgeQemuCap cap;
This leaks info to guest. You want to init all fields here:
cap = {
.len = ....
};
Quoted 6 lines
I surely can do this for len field, but as Laszlo proposed we can use mutually exclusive fields,
e.g.pref_32andpref_64, the only way I have left is to use ternary operator (if we surely need this big initializer). Keeping some if's would look better, I think.
I think it's fine to use "if"s in order to set up the structure partially / gradually, but then please clear the structure up-front:
PCIBridgeQemuCap cap = { 0 };(In general "{ 0 }" is the best initializer ever, because it can zero-init a variable of *any* type at all. Gcc might complain about the inexact depth of {} nesting of course, but it's nonetheless valid C.)
Or else add a memset-to-zero.
Or else, do just
PCIBridgeQemuCap cap = { .len = ... };which will zero-fill every other field. ("[...] all subobjects that are not initialized explicitly shall be initialized implicitly the same as objects that have static storage duration").
Thanks
Laszlo
Re: [Qemu-devel] [RFC PATCH v2 4/6] hw/pci: introduce bridge-only vendor-specific capability to provide some hints to firmware
In reply to Alexander BezzubikovQuoted 127 lines · Alexander Bezzubikov
2017-07-26 22:43 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 41 lines · Aleksandr Bezzubikov
Quoted 4 lines
On PCI init PCI bridges may need some
extra info about bus number to reserve, IO, memory and prefetchable memory limits. QEMU can provide this with specialwith a special
Quoted 18 lines
vendor-specific PCI capability.
Sizes of limits match ones from
PCI Type 1 Configuration Space Header,
number of buses to reserve occupies only 1 byte since it is the size of Subordinate Bus Number register.Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/pci/pci_bridge.c | 27 +++++++++++++++++++++++++++ include/hw/pci/pci_bridge.h | 18 ++++++++++++++++++ 2 files changed, 45 insertions(+)hw/pci/pci_bridge.c +0
-0hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 412
Quoted 5 lines
hw/pci/pci_bridge.c +2
-0@@ -408,6 +408,33 @@ void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, br->bus_name = bus_name; } + +int pci_bridge_help_cap_init(PCIDevice *dev, int cap_offset,help? should be
qemu_cap_init?hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 418
Quoted 6 lines
hw/pci/pci_bridge.c +6
-0+ uint8_t bus_reserve, uint32_t io_limit, + uint16_t mem_limit, uint64_t pref_limit, + Error **errp) +{ + size_t cap_len = sizeof(PCIBridgeQemuCap); +PCIBridgeQemuCap cap;Quoted 5 lines
This leaks info to guest. You want to init all fields here:
cap = {
.len = ....
};I surely can do this for len field, but as Laszlo proposed we can use mutually exclusive fields,
e.g.pref_32andpref_64, the only way I have left is to use ternary operator (if we surely need this big initializer). Keeping some if's would look better, I think.Quoted 10 lines
hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 426
Quoted 9 lines
hw/pci/pci_bridge.c +8
-0+ + cap.len = cap_len; + cap.bus_res = bus_reserve; + cap.io_lim = io_limit &0xFF ; + cap.io_lim_upper = io_limit >>8 &0xFFFF ; + cap.mem_lim = mem_limit; + cap.pref_lim = pref_limit &0xFFFF ; + cap.pref_lim_upper = pref_limit >>16 &0xFFFFFFFF ;Quoted 2 lines
Please use
pci_set_wordetc orcpu_to_leXX.Since now we've decided to avoid fields separation into <field> + <
field_upper>, this bitmask along withpci_set_wordare no longer needed.Quoted 3 lines
I think it's easiest to replace struct with a set of macros then
pci_set_worddoes the work for you.I don't really want to use macros here because structure show us the whole capability layout and this can decrease documenting efforts. More than that, memcpy usage is very convenient here, and I wouldn't like to lose it.
Quoted 12 lines
hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 434
Quoted 9 lines
hw/pci/pci_bridge.c +8
-0+ +int offset =pci_add_capability (dev,PCI_CAP_ID_VNDR , + cap_offset, cap_len, errp); +if (offset <0 ) { +return offset; + } + +memcpy (dev->config + offset +2 , (char *)&cap +2 , cap_len -2 );+2 is yacky. See how virtio does it:
Quoted 4 lines
memcpy(dev->config + offset + PCI_CAP_FLAGS, &cap->cap_len, cap->cap_len - PCI_CAP_FLAGS);OK.
Quoted 14 lines
Quoted 14 lines
hw/pci/pci_bridge.c +3
-0+return 0 ; +} +static const TypeInfo pci_bridge_type_info = { .name =TYPE_PCI_BRIDGE , .parent =TYPE_PCI_DEVICE ,include/hw/pci/pci_bridge.h +0
-0@@ -67,4 +67,22 @@ 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 */ Quoted 9 lines
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 75
Quoted 6 lines
include/hw/pci/pci_bridge.h +6
-0+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 bus_res; + uint32_t pref_lim_upper;Big endian? Ugh.
Agreed, and this's gonna to disappear with
the new layout.
Quoted 7 lines
Quoted 5 lines
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 77
Quoted 2 lines
include/hw/pci/pci_bridge.h +2
-0+uint16_t pref_lim; +uint16_t mem_lim;I'd say we need 64 bit for memory.
Why? Non-prefetchable
MEMORY_LIMITregister is 16 bits long.
Hmm ok, but e.g. for io there are bridges that have extra registers to specify non-standard non-aligned registers.
Quoted 10 lines
Quoted 8 lines
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 80
Quoted 3 lines
include/hw/pci/pci_bridge.h +3
-0+uint16_t io_lim_upper; +uint8_t io_lim; +uint8_t padding;IMHO each type should have a special "don't care" flag that would mean "I don't know".
Don't know what? Now 0 is an indicator to do nothing with this field.
In that case how do you say "don't allocate any memory"?
Quoted 18 lines
Quoted 4 lines
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 81
Quoted 1 line
include/hw/pci/pci_bridge.h +1
-0+} PCIBridgeQemuCap;You don't really need this struct in the header. And pls document all fields.
Quoted 9 lines
Quoted 9 lines
include/hw/pci/pci_bridge.h +6
-1+ +int pci_bridge_help_cap_init (PCIDevice *dev,int cap_offset, +uint8_t bus_reserve,uint32_t io_limit, +uint16_t mem_limit,uint64_t pref_limit, +Error **errp); +#endif /* QEMU_PCI_BRIDGE_H */ --2.7.4
--
Alexander Bezzubikov
Re: [Qemu-devel] [RFC PATCH v2 4/6] hw/pci: introduce bridge-only vendor-specific capability to provide some hints to firmware
Quoted 143 lines · Michael S. Tsirkin
Quoted 127 lines · Alexander Bezzubikov
2017-07-26 22:43 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 41 lines · Aleksandr Bezzubikov
Quoted 4 lines
On PCI init PCI bridges may need some
extra info about bus number to reserve, IO, memory and prefetchable memory limits. QEMU can provide this with specialwith a special
Quoted 18 lines
vendor-specific PCI capability.
Sizes of limits match ones from
PCI Type 1 Configuration Space Header,
number of buses to reserve occupies only 1 byte since it is the size of Subordinate Bus Number register.Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/pci/pci_bridge.c | 27 +++++++++++++++++++++++++++ include/hw/pci/pci_bridge.h | 18 ++++++++++++++++++ 2 files changed, 45 insertions(+)hw/pci/pci_bridge.c +0
-0hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 412
Quoted 5 lines
hw/pci/pci_bridge.c +2
-0@@ -408,6 +408,33 @@ void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, br->bus_name = bus_name; } + +int pci_bridge_help_cap_init(PCIDevice *dev, int cap_offset,help? should be
qemu_cap_init?hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 418
Quoted 6 lines
hw/pci/pci_bridge.c +6
-0+ uint8_t bus_reserve, uint32_t io_limit, + uint16_t mem_limit, uint64_t pref_limit, + Error **errp) +{ + size_t cap_len = sizeof(PCIBridgeQemuCap); +PCIBridgeQemuCap cap;Quoted 5 lines
This leaks info to guest. You want to init all fields here:
cap = {
.len = ....
};I surely can do this for len field, but as Laszlo proposed we can use mutually exclusive fields,
e.g.pref_32andpref_64, the only way I have left is to use ternary operator (if we surely need this big initializer). Keeping some if's would look better, I think.Quoted 10 lines
hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 426
Quoted 9 lines
hw/pci/pci_bridge.c +8
-0+ + cap.len = cap_len; + cap.bus_res = bus_reserve; + cap.io_lim = io_limit &0xFF ; + cap.io_lim_upper = io_limit >>8 &0xFFFF ; + cap.mem_lim = mem_limit; + cap.pref_lim = pref_limit &0xFFFF ; + cap.pref_lim_upper = pref_limit >>16 &0xFFFFFFFF ;Quoted 2 lines
Please use
pci_set_wordetc orcpu_to_leXX.Since now we've decided to avoid fields separation into <field> + <
field_upper>, this bitmask along withpci_set_wordare no longer needed.Quoted 3 lines
I think it's easiest to replace struct with a set of macros then
pci_set_worddoes the work for you.I don't really want to use macros here because structure show us the whole capability layout and this can decrease documenting efforts. More than that, memcpy usage is very convenient here, and I wouldn't like to lose it.
Quoted 12 lines
hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 434
Quoted 9 lines
hw/pci/pci_bridge.c +8
-0+ +int offset =pci_add_capability (dev,PCI_CAP_ID_VNDR , + cap_offset, cap_len, errp); +if (offset <0 ) { +return offset; + } + +memcpy (dev->config + offset +2 , (char *)&cap +2 , cap_len -2 );+2 is yacky. See how virtio does it:
Quoted 4 lines
memcpy(dev->config + offset + PCI_CAP_FLAGS, &cap->cap_len, cap->cap_len - PCI_CAP_FLAGS);OK.
Quoted 14 lines
Quoted 14 lines
hw/pci/pci_bridge.c +3
-0+return 0 ; +} +static const TypeInfo pci_bridge_type_info = { .name =TYPE_PCI_BRIDGE , .parent =TYPE_PCI_DEVICE ,include/hw/pci/pci_bridge.h +0
-0@@ -67,4 +67,22 @@ 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 */ Quoted 9 lines
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 75
Quoted 6 lines
include/hw/pci/pci_bridge.h +6
-0+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 bus_res; + uint32_t pref_lim_upper;Big endian? Ugh.
Agreed, and this's gonna to disappear with
the new layout.Quoted 7 lines
Quoted 5 lines
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 77
Quoted 2 lines
include/hw/pci/pci_bridge.h +2
-0+uint16_t pref_lim; +uint16_t mem_lim;I'd say we need 64 bit for memory.
Why? Non-prefetchable
MEMORY_LIMITregister is 16 bits long.Hmm ok, but e.g. for io there are bridges that have extra registers to specify non-standard non-aligned registers.
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
include/hw/pci/pci_bridge.h +3
-0+uint16_t io_lim_upper; +uint8_t io_lim; +uint8_t padding;
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
IMHO each type should have a special "don't care" flag that would mean "I don't know".
Don't know what? Now 0 is an indicator to do nothing with this field.
In that case how do you say "don't allocate any memory"?
We can keep the MEM/Limit registers read-only for such cases, as they are optional registers.
Thanks,
Marcel
Quoted 19 lines
Quoted 19 lines
Quoted 5 lines
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 81
Quoted 2 lines
include/hw/pci/pci_bridge.h +1
-0+} PCIBridgeQemuCap;You don't really need this struct in the header. And pls document all fields.
Quoted 9 lines
Quoted 9 lines
include/hw/pci/pci_bridge.h +6
-1+ +int pci_bridge_help_cap_init (PCIDevice *dev,int cap_offset, +uint8_t bus_reserve,uint32_t io_limit, +uint16_t mem_limit,uint64_t pref_limit, +Error **errp); +#endif /* QEMU_PCI_BRIDGE_H */ --2.7.4
--
Alexander Bezzubikov
Re: [Qemu-devel] [SeaBIOS] [RFC PATCH v2 4/6] hw/pci: introduce bridge-only vendor-specific capability to provide some hints to firmware
Quoted 156 lines · Marcel Apfelbaum
Quoted 155 lines · Michael S. Tsirkin
Quoted 134 lines · Alexander Bezzubikov
2017-07-26 22:43 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 43 lines · Aleksandr Bezzubikov
Quoted 4 lines
On PCI init PCI bridges may need some
extra info about bus number to reserve, IO, memory and prefetchable memory limits. QEMU can provide this with specialwith a special
Quoted 18 lines
vendor-specific PCI capability.
Sizes of limits match ones from
PCI Type 1 Configuration Space Header,
number of buses to reserve occupies only 1 byte since it is the size of Subordinate Bus Number register.Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/pci/pci_bridge.c | 27 +++++++++++++++++++++++++++ include/hw/pci/pci_bridge.h | 18 ++++++++++++++++++ 2 files changed, 45 insertions(+)hw/pci/pci_bridge.c +0
-0hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const · line 413
Quoted 6 lines
hw/pci/pci_bridge.c +2
-0@@ -408,6 +408,33 @@ void pci_bridge_map_irq(PCIBridge *br, constchar * bus_name, br->bus_name = bus_name; } + +int pci_bridge_help_cap_init(PCIDevice *dev, int cap_offset,help? should be
qemu_cap_init?hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 418
Quoted 7 lines
hw/pci/pci_bridge.c +6
-0+ uint8_t bus_reserve, uint32_t io_limit, + uint16_t mem_limit, uint64_t pref_limit, + Error **errp) +{ + size_t cap_len = sizeof(PCIBridgeQemuCap); +PCIBridgeQemuCap cap;Quoted 5 lines
This leaks info to guest. You want to init all fields here:
cap = {
.len = ....
};I surely can do this for len field, but as Laszlo proposed we can use mutually exclusive fields,
e.g.pref_32andpref_64, the only way I have left is to use ternary operator (if we surely need this big initializer). Keeping some if's would look better, I think.Quoted 10 lines
hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 426
Quoted 9 lines
hw/pci/pci_bridge.c +8
-0+ + cap.len = cap_len; + cap.bus_res = bus_reserve; + cap.io_lim = io_limit &0xFF ; + cap.io_lim_upper = io_limit >>8 &0xFFFF ; + cap.mem_lim = mem_limit; + cap.pref_lim = pref_limit &0xFFFF ; + cap.pref_lim_upper = pref_limit >>16 &0xFFFFFFFF ;Quoted 2 lines
Please use
pci_set_wordetc orcpu_to_leXX.Since now we've decided to avoid fields separation into <field> + <
field_upper>,
this bitmask along withpci_set_wordare no longer needed.Quoted 3 lines
I think it's easiest to replace struct with a set of macros then
pci_set_worddoes the work for you.I don't really want to use macros here because structure show us the whole capability layout and this can decrease documenting efforts. More than that, memcpy usage is very convenient here, and I wouldn't like to lose it.
Quoted 12 lines
hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 434
Quoted 9 lines
hw/pci/pci_bridge.c +8
-0+ +int offset =pci_add_capability (dev,PCI_CAP_ID_VNDR , + cap_offset, cap_len, errp); +if (offset <0 ) { +return offset; + } + +memcpy (dev->config + offset +2 , (char *)&cap +2 , cap_len -2 );+2 is yacky. See how virtio does it:
Quoted 4 lines
memcpy(dev->config + offset + PCI_CAP_FLAGS, &cap->cap_len, cap->cap_len - PCI_CAP_FLAGS);OK.
Quoted 17 lines
Quoted 17 lines
hw/pci/pci_bridge.c +3
-0+return 0 ; +} +static const TypeInfo pci_bridge_type_info = {.name =
TYPE_PCI_BRIDGE,
.parent =TYPE_PCI_DEVICE,include/hw/pci/pci_bridge.h +0
-0@@ -67,4 +67,22 @@ void pci_bridge_map_irq(PCIBridge *br, const char* bus_name,#define PCI_BRIDGE_CTL_DISCARD_STATUS 0x400/* Discard timer status */
#definePCI_BRIDGE_CTL_DISCARD_SERR0x800/* Discard timer
SERR# enable */Quoted 10 lines
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 75
Quoted 7 lines
include/hw/pci/pci_bridge.h +4
-0+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 capabilityheader field */
include/hw/pci/pci_bridge.h +2
-0+uint8_t bus_res; +uint32_t pref_lim_upper;Big endian? Ugh.
Agreed, and this's gonna to disappear with
the new layout.Quoted 7 lines
Quoted 5 lines
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 77
Quoted 2 lines
include/hw/pci/pci_bridge.h +2
-0+uint16_t pref_lim; +uint16_t mem_lim;I'd say we need 64 bit for memory.
Why? Non-prefetchable
MEMORY_LIMITregister is 16 bits long.Hmm ok, but e.g. for io there are bridges that have extra registers to specify non-standard non-aligned registers.
Quoted 9 lines
Quoted 8 lines
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 80
Quoted 3 lines
include/hw/pci/pci_bridge.h +3
-0+uint16_t io_lim_upper; +uint8_t io_lim; +uint8_t padding;IMHO each type should have a special "don't care" flag that would mean "I don't know".
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Don't know what? Now 0 is an indicator to do nothing with this field.
In that case how do you say "don't allocate any memory"?
We can keep the MEM/Limit registers read-only for such cases, as they are optional registers.
For OVMF, it would be really nice if OVMF could gather the reservation numbers with
- read-only accesses
- to the one exact hotplug controller (root port, bridge, etc) that's being queried for reservation.
Deciding whether some registers in config space are r/o would require OVMF to attempt a write and check the result (and if it succeeded, to restore the original value). I'm not too attracted to doing this in a platform hook, while PciBusDxe is in the middle of enumerating / configuring the PCI(e) hierarchy :)
Thanks
Laszlo
Re: [Qemu-devel] [SeaBIOS] [RFC PATCH v2 4/6] hw/pci: introduce bridge-only vendor-specific capability to provide some hints to firmware
Quoted 171 lines · Laszlo Ersek
Quoted 156 lines · Marcel Apfelbaum
Quoted 155 lines · Michael S. Tsirkin
Quoted 134 lines · Alexander Bezzubikov
2017-07-26 22:43 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 43 lines · Aleksandr Bezzubikov
Quoted 4 lines
On PCI init PCI bridges may need some
extra info about bus number to reserve, IO, memory and prefetchable memory limits. QEMU can provide this with specialwith a special
Quoted 18 lines
vendor-specific PCI capability.
Sizes of limits match ones from
PCI Type 1 Configuration Space Header,
number of buses to reserve occupies only 1 byte since it is the size of Subordinate Bus Number register.Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/pci/pci_bridge.c | 27 +++++++++++++++++++++++++++ include/hw/pci/pci_bridge.h | 18 ++++++++++++++++++ 2 files changed, 45 insertions(+)hw/pci/pci_bridge.c +0
-0hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const · line 413
Quoted 6 lines
hw/pci/pci_bridge.c +2
-0@@ -408,6 +408,33 @@ void pci_bridge_map_irq(PCIBridge *br, constchar * bus_name, br->bus_name = bus_name; } + +int pci_bridge_help_cap_init(PCIDevice *dev, int cap_offset,help? should be
qemu_cap_init?hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 418
Quoted 7 lines
hw/pci/pci_bridge.c +6
-0+ uint8_t bus_reserve, uint32_t io_limit, + uint16_t mem_limit, uint64_t pref_limit, + Error **errp) +{ + size_t cap_len = sizeof(PCIBridgeQemuCap); +PCIBridgeQemuCap cap;Quoted 5 lines
This leaks info to guest. You want to init all fields here:
cap = {
.len = ....
};I surely can do this for len field, but as Laszlo proposed we can use mutually exclusive fields,
e.g.pref_32andpref_64, the only way I have left is to use ternary operator (if we surely need this big initializer). Keeping some if's would look better, I think.Quoted 10 lines
hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 426
Quoted 9 lines
hw/pci/pci_bridge.c +8
-0+ + cap.len = cap_len; + cap.bus_res = bus_reserve; + cap.io_lim = io_limit &0xFF ; + cap.io_lim_upper = io_limit >>8 &0xFFFF ; + cap.mem_lim = mem_limit; + cap.pref_lim = pref_limit &0xFFFF ; + cap.pref_lim_upper = pref_limit >>16 &0xFFFFFFFF ;Quoted 2 lines
Please use
pci_set_wordetc orcpu_to_leXX.Since now we've decided to avoid fields separation into <field> + <
field_upper>,
this bitmask along withpci_set_wordare no longer needed.Quoted 3 lines
I think it's easiest to replace struct with a set of macros then
pci_set_worddoes the work for you.I don't really want to use macros here because structure show us the whole capability layout and this can decrease documenting efforts. More than that, memcpy usage is very convenient here, and I wouldn't like to lose it.
Quoted 12 lines
hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 434
Quoted 9 lines
hw/pci/pci_bridge.c +8
-0+ +int offset =pci_add_capability (dev,PCI_CAP_ID_VNDR , + cap_offset, cap_len, errp); +if (offset <0 ) { +return offset; + } + +memcpy (dev->config + offset +2 , (char *)&cap +2 , cap_len -2 );+2 is yacky. See how virtio does it:
Quoted 4 lines
memcpy(dev->config + offset + PCI_CAP_FLAGS, &cap->cap_len, cap->cap_len - PCI_CAP_FLAGS);OK.
Quoted 17 lines
Quoted 17 lines
hw/pci/pci_bridge.c +3
-0+return 0 ; +} +static const TypeInfo pci_bridge_type_info = {.name =
TYPE_PCI_BRIDGE,
.parent =TYPE_PCI_DEVICE,include/hw/pci/pci_bridge.h +0
-0@@ -67,4 +67,22 @@ void pci_bridge_map_irq(PCIBridge *br, const char* bus_name,#define PCI_BRIDGE_CTL_DISCARD_STATUS 0x400/* Discard timer status */
#definePCI_BRIDGE_CTL_DISCARD_SERR0x800/* Discard timer
SERR# enable */Quoted 10 lines
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 75
Quoted 7 lines
include/hw/pci/pci_bridge.h +4
-0+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 capabilityheader field */
include/hw/pci/pci_bridge.h +2
-0+uint8_t bus_res; +uint32_t pref_lim_upper;Big endian? Ugh.
Agreed, and this's gonna to disappear with
the new layout.Quoted 7 lines
Quoted 5 lines
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 77
Quoted 2 lines
include/hw/pci/pci_bridge.h +2
-0+uint16_t pref_lim; +uint16_t mem_lim;I'd say we need 64 bit for memory.
Why? Non-prefetchable
MEMORY_LIMITregister is 16 bits long.Hmm ok, but e.g. for io there are bridges that have extra registers to specify non-standard non-aligned registers.
Quoted 9 lines
Quoted 8 lines
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 80
Quoted 3 lines
include/hw/pci/pci_bridge.h +3
-0+uint16_t io_lim_upper; +uint8_t io_lim; +uint8_t padding;IMHO each type should have a special "don't care" flag that would mean "I don't know".
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Don't know what? Now 0 is an indicator to do nothing with this field.
In that case how do you say "don't allocate any memory"?
We can keep the MEM/Limit registers read-only for such cases, as they are optional registers.
For OVMF, it would be really nice if OVMF could gather the reservation numbers with
- read-only accesses
- to the one exact hotplug controller (root port, bridge, etc) that's being queried for reservation.
Quoted 8 lines
Deciding whether some registers in config space are r/o would require OVMF to attempt a write and check the result (and if it succeeded, to restore the original value). I'm not too attracted to doing this in a platform hook, while PciBusDxe is in the middle of enumerating / configuring the PCI(e) hierarchy :)
Thanks
Laszlo
Well that's the PCI spec, I don't think there's a choice for regular bridges. If we have this capability this is a possible optimization.
But without it, if you assign ranges without checking whether they are available they won't have any effect practically.
It's mostly harmless, but you are going to waste resources.
Signature · 1 line
MST
Re: [Qemu-devel] [SeaBIOS] [RFC PATCH v2 4/6] hw/pci: introduce bridge-only vendor-specific capability to provide some hints to firmware
Quoted 181 lines · Michael S. Tsirkin
Quoted 171 lines · Laszlo Ersek
Quoted 156 lines · Marcel Apfelbaum
Quoted 155 lines · Michael S. Tsirkin
Quoted 134 lines · Alexander Bezzubikov
2017-07-26 22:43 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 43 lines · Aleksandr Bezzubikov
Quoted 4 lines
On PCI init PCI bridges may need some
extra info about bus number to reserve, IO, memory and prefetchable memory limits. QEMU can provide this with specialwith a special
Quoted 18 lines
vendor-specific PCI capability.
Sizes of limits match ones from
PCI Type 1 Configuration Space Header,
number of buses to reserve occupies only 1 byte since it is the size of Subordinate Bus Number register.Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/pci/pci_bridge.c | 27 +++++++++++++++++++++++++++ include/hw/pci/pci_bridge.h | 18 ++++++++++++++++++ 2 files changed, 45 insertions(+)hw/pci/pci_bridge.c +0
-0hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const · line 413
Quoted 6 lines
hw/pci/pci_bridge.c +2
-0@@ -408,6 +408,33 @@ void pci_bridge_map_irq(PCIBridge *br, constchar * bus_name, br->bus_name = bus_name; } + +int pci_bridge_help_cap_init(PCIDevice *dev, int cap_offset,help? should be
qemu_cap_init?hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const · line 420
Quoted 7 lines
hw/pci/pci_bridge.c +6
-0+ uint8_t bus_reserve, uint32_t io_limit, + uint16_t mem_limit, uint64_t pref_limit, + Error **errp) +{ + size_t cap_len = sizeof(PCIBridgeQemuCap); +PCIBridgeQemuCap cap;Quoted 5 lines
This leaks info to guest. You want to init all fields here:
cap = {
.len = ....
};I surely can do this for len field, but as Laszlo proposed we can use mutually exclusive fields,
e.g.pref_32andpref_64, the only way I have left is to use ternary operator (if we surely need this big initializer). Keeping some if's would look better, I think.Quoted 10 lines
hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const · line 428
Quoted 9 lines
hw/pci/pci_bridge.c +8
-0+ + cap.len = cap_len; + cap.bus_res = bus_reserve; + cap.io_lim = io_limit &0xFF ; + cap.io_lim_upper = io_limit >>8 &0xFFFF ; + cap.mem_lim = mem_limit; + cap.pref_lim = pref_limit &0xFFFF ; + cap.pref_lim_upper = pref_limit >>16 &0xFFFFFFFF ;Quoted 2 lines
Please use
pci_set_wordetc orcpu_to_leXX.Since now we've decided to avoid fields separation into <field> + <
field_upper>,
this bitmask along withpci_set_wordare no longer needed.Quoted 3 lines
I think it's easiest to replace struct with a set of macros then
pci_set_worddoes the work for you.I don't really want to use macros here because structure show us the whole capability layout and this can decrease documenting efforts. More than that, memcpy usage is very convenient here, and I wouldn't like to lose it.
Quoted 12 lines
hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const · line 436
Quoted 9 lines
hw/pci/pci_bridge.c +8
-0+ +int offset =pci_add_capability (dev,PCI_CAP_ID_VNDR , + cap_offset, cap_len, errp); +if (offset <0 ) { +return offset; + } + +memcpy (dev->config + offset +2 , (char *)&cap +2 , cap_len -2 );+2 is yacky. See how virtio does it:
Quoted 4 lines
memcpy(dev->config + offset + PCI_CAP_FLAGS, &cap->cap_len, cap->cap_len - PCI_CAP_FLAGS);OK.
Quoted 17 lines
Quoted 17 lines
hw/pci/pci_bridge.c +3
-0+return 0 ; +} +static const TypeInfo pci_bridge_type_info = {.name =
TYPE_PCI_BRIDGE,
.parent =TYPE_PCI_DEVICE,include/hw/pci/pci_bridge.h +0
-0@@ -67,4 +67,22 @@ void pci_bridge_map_irq(PCIBridge *br, const char* bus_name,#define PCI_BRIDGE_CTL_DISCARD_STATUS 0x400/* Discard timer status */
#definePCI_BRIDGE_CTL_DISCARD_SERR0x800/* Discard timer
SERR# enable */Quoted 10 lines
include/hw/pci/pci_bridge.h
Quoted 7 lines
include/hw/pci/pci_bridge.h +4
-0+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 capabilityheader field */
include/hw/pci/pci_bridge.h +2
-0+uint8_t bus_res; +uint32_t pref_lim_upper;Big endian? Ugh.
Agreed, and this's gonna to disappear with
the new layout.Quoted 7 lines
Quoted 5 lines
include/hw/pci/pci_bridge.h
Quoted 2 lines
include/hw/pci/pci_bridge.h +2
-0+uint16_t pref_lim; +uint16_t mem_lim;I'd say we need 64 bit for memory.
Why? Non-prefetchable
MEMORY_LIMITregister is 16 bits long.Hmm ok, but e.g. for io there are bridges that have extra registers to specify non-standard non-aligned registers.
Quoted 9 lines
Quoted 8 lines
include/hw/pci/pci_bridge.h
Quoted 3 lines
include/hw/pci/pci_bridge.h +3
-0+uint16_t io_lim_upper; +uint8_t io_lim; +uint8_t padding;IMHO each type should have a special "don't care" flag that would mean "I don't know".
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Don't know what? Now 0 is an indicator to do nothing with this field.
In that case how do you say "don't allocate any memory"?
We can keep the MEM/Limit registers read-only for such cases, as they are optional registers.
For OVMF, it would be really nice if OVMF could gather the reservation numbers with
- read-only accesses
- to the one exact hotplug controller (root port, bridge, etc) that's being queried for reservation.Quoted 8 lines
Deciding whether some registers in config space are r/o would require OVMF to attempt a write and check the result (and if it succeeded, to restore the original value). I'm not too attracted to doing this in a platform hook, while PciBusDxe is in the middle of enumerating / configuring the PCI(e) hierarchy :)
Thanks
Laszlo
Quoted 7 lines
Well that's the PCI spec, I don't think there's a choice for regular bridges. If we have this capability this is a possible optimization.
But without it, if you assign ranges without checking whether they are available they won't have any effect practically.
It's mostly harmless, but you are going to waste resources.
OK. If the proposed solution with the r/o mem base/limit registers is rooted in the spec (and I think it indeed must be; apparently this would be the same as what we're already planning for IO disablement), then that's a strong argument for PciBusDxe to accommodate this probing in the platform hook.
Thanks
Laszlo
Re: [Qemu-devel] [SeaBIOS] [RFC PATCH v2 4/6] hw/pci: introduce bridge-only vendor-specific capability to provide some hints to firmware
Quoted 8 lines · Laszlo Ersek
OK. If the proposed solution with the r/o mem base/limit registers is rooted in the spec (and I think it indeed must be; apparently this would be the same as what we're already planning for IO disablement), then that's a strong argument for PciBusDxe to accommodate this probing in the platform hook.
Thanks
Laszlo
Do you mean making base/limit read-only?
Re: [Qemu-devel] [SeaBIOS] [RFC PATCH v2 4/6] hw/pci: introduce bridge-only vendor-specific capability to provide some hints to firmware
Quoted 11 lines · Michael S. Tsirkin
Quoted 8 lines · Laszlo Ersek
OK. If the proposed solution with the r/o mem base/limit registers is rooted in the spec (and I think it indeed must be; apparently this would be the same as what we're already planning for IO disablement), then that's a strong argument for PciBusDxe to accommodate this probing in the platform hook.
Thanks
LaszloDo you mean making base/limit read-only?
Yes, I do. (Perhaps writing "r/o" was too terse.)
Thanks
Laszlo
Re: [Qemu-devel] [RFC PATCH v2 4/6] hw/pci: introduce bridge-only vendor-specific capability to provide some hints to firmware
In reply to Marcel ApfelbaumQuoted 151 lines · Marcel Apfelbaum
Quoted 150 lines · Michael S. Tsirkin
Quoted 127 lines · Alexander Bezzubikov
2017-07-26 22:43 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 41 lines · Aleksandr Bezzubikov
Quoted 4 lines
On PCI init PCI bridges may need some
extra info about bus number to reserve, IO, memory and prefetchable memory limits. QEMU can provide this with specialwith a special
Quoted 18 lines
vendor-specific PCI capability.
Sizes of limits match ones from
PCI Type 1 Configuration Space Header,
number of buses to reserve occupies only 1 byte since it is the size of Subordinate Bus Number register.Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/pci/pci_bridge.c | 27 +++++++++++++++++++++++++++ include/hw/pci/pci_bridge.h | 18 ++++++++++++++++++ 2 files changed, 45 insertions(+)hw/pci/pci_bridge.c +0
-0hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 412
Quoted 5 lines
hw/pci/pci_bridge.c +2
-0@@ -408,6 +408,33 @@ void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, br->bus_name = bus_name; } + +int pci_bridge_help_cap_init(PCIDevice *dev, int cap_offset,help? should be
qemu_cap_init?hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 418
Quoted 6 lines
hw/pci/pci_bridge.c +6
-0+ uint8_t bus_reserve, uint32_t io_limit, + uint16_t mem_limit, uint64_t pref_limit, + Error **errp) +{ + size_t cap_len = sizeof(PCIBridgeQemuCap); +PCIBridgeQemuCap cap;Quoted 5 lines
This leaks info to guest. You want to init all fields here:
cap = {
.len = ....
};I surely can do this for len field, but as Laszlo proposed we can use mutually exclusive fields,
e.g.pref_32andpref_64, the only way I have left is to use ternary operator (if we surely need this big initializer). Keeping some if's would look better, I think.Quoted 10 lines
hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 426
Quoted 9 lines
hw/pci/pci_bridge.c +8
-0+ + cap.len = cap_len; + cap.bus_res = bus_reserve; + cap.io_lim = io_limit &0xFF ; + cap.io_lim_upper = io_limit >>8 &0xFFFF ; + cap.mem_lim = mem_limit; + cap.pref_lim = pref_limit &0xFFFF ; + cap.pref_lim_upper = pref_limit >>16 &0xFFFFFFFF ;Quoted 2 lines
Please use
pci_set_wordetc orcpu_to_leXX.Since now we've decided to avoid fields separation into <field> + <
field_upper>, this bitmask along withpci_set_wordare no longer needed.Quoted 3 lines
I think it's easiest to replace struct with a set of macros then
pci_set_worddoes the work for you.I don't really want to use macros here because structure show us the whole capability layout and this can decrease documenting efforts. More than that, memcpy usage is very convenient here, and I wouldn't like to lose it.
Quoted 12 lines
hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 434
Quoted 9 lines
hw/pci/pci_bridge.c +8
-0+ +int offset =pci_add_capability (dev,PCI_CAP_ID_VNDR , + cap_offset, cap_len, errp); +if (offset <0 ) { +return offset; + } + +memcpy (dev->config + offset +2 , (char *)&cap +2 , cap_len -2 );+2 is yacky. See how virtio does it:
Quoted 4 lines
memcpy(dev->config + offset + PCI_CAP_FLAGS, &cap->cap_len, cap->cap_len - PCI_CAP_FLAGS);OK.
Quoted 14 lines
Quoted 14 lines
hw/pci/pci_bridge.c +3
-0+return 0 ; +} +static const TypeInfo pci_bridge_type_info = { .name =TYPE_PCI_BRIDGE , .parent =TYPE_PCI_DEVICE ,include/hw/pci/pci_bridge.h +0
-0@@ -67,4 +67,22 @@ 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 */ Quoted 9 lines
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 75
Quoted 6 lines
include/hw/pci/pci_bridge.h +6
-0+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 bus_res; + uint32_t pref_lim_upper;Big endian? Ugh.
Agreed, and this's gonna to disappear with
the new layout.Quoted 7 lines
Quoted 5 lines
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 77
Quoted 2 lines
include/hw/pci/pci_bridge.h +2
-0+uint16_t pref_lim; +uint16_t mem_lim;I'd say we need 64 bit for memory.
Why? Non-prefetchable
MEMORY_LIMITregister is 16 bits long.Hmm ok, but e.g. for io there are bridges that have extra registers to specify non-standard non-aligned registers.
Quoted 10 lines
Quoted 8 lines
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 80
Quoted 3 lines
include/hw/pci/pci_bridge.h +3
-0+uint16_t io_lim_upper; +uint8_t io_lim; +uint8_t padding;IMHO each type should have a special "don't care" flag that would mean "I don't know".
Don't know what? Now 0 is an indicator to do nothing with this field.
Quoted 8 lines
Quoted 2 lines
In that case how do you say "don't allocate any memory"?
We can keep the MEM/Limit registers read-only for such cases, as they are optional registers.
Thanks,
Marcel
I don't believe they are - from the spec (1.2):
The Memory Base and Memory Limit registers are both required registers
Rest of ranges are indeed optional.
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 5 lines
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 81
Quoted 2 lines
include/hw/pci/pci_bridge.h +1
-0+} PCIBridgeQemuCap;You don't really need this struct in the header. And pls document all fields.
Quoted 9 lines
Quoted 9 lines
include/hw/pci/pci_bridge.h +6
-1+ +int pci_bridge_help_cap_init (PCIDevice *dev,int cap_offset, +uint8_t bus_reserve,uint32_t io_limit, +uint16_t mem_limit,uint64_t pref_limit, +Error **errp); +#endif /* QEMU_PCI_BRIDGE_H */ --2.7.4
--
Alexander Bezzubikov
Re: [Qemu-devel] [RFC PATCH v2 4/6] hw/pci: introduce bridge-only vendor-specific capability to provide some hints to firmware
Quoted 152 lines · Michael S. Tsirkin
Quoted 151 lines · Marcel Apfelbaum
Quoted 150 lines · Michael S. Tsirkin
Quoted 127 lines · Alexander Bezzubikov
2017-07-26 22:43 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 41 lines · Aleksandr Bezzubikov
Quoted 4 lines
On PCI init PCI bridges may need some
extra info about bus number to reserve, IO, memory and prefetchable memory limits. QEMU can provide this with specialwith a special
Quoted 18 lines
vendor-specific PCI capability.
Sizes of limits match ones from
PCI Type 1 Configuration Space Header,
number of buses to reserve occupies only 1 byte since it is the size of Subordinate Bus Number register.Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/pci/pci_bridge.c | 27 +++++++++++++++++++++++++++ include/hw/pci/pci_bridge.h | 18 ++++++++++++++++++ 2 files changed, 45 insertions(+)hw/pci/pci_bridge.c +0
-0hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 412
Quoted 5 lines
hw/pci/pci_bridge.c +2
-0@@ -408,6 +408,33 @@ void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, br->bus_name = bus_name; } + +int pci_bridge_help_cap_init(PCIDevice *dev, int cap_offset,help? should be
qemu_cap_init?hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 418
Quoted 6 lines
hw/pci/pci_bridge.c +6
-0+ uint8_t bus_reserve, uint32_t io_limit, + uint16_t mem_limit, uint64_t pref_limit, + Error **errp) +{ + size_t cap_len = sizeof(PCIBridgeQemuCap); +PCIBridgeQemuCap cap;Quoted 5 lines
This leaks info to guest. You want to init all fields here:
cap = { .len = .... };I surely can do this for len field, but as Laszlo proposed we can use mutually exclusive fields,
e.g.pref_32andpref_64, the only way I have left is to use ternary operator (if we surely need this big initializer). Keeping some if's would look better, I think.Quoted 10 lines
hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 426
Quoted 9 lines
hw/pci/pci_bridge.c +8
-0+ + cap.len = cap_len; + cap.bus_res = bus_reserve; + cap.io_lim = io_limit &0xFF ; + cap.io_lim_upper = io_limit >>8 &0xFFFF ; + cap.mem_lim = mem_limit; + cap.pref_lim = pref_limit &0xFFFF ; + cap.pref_lim_upper = pref_limit >>16 &0xFFFFFFFF ;Quoted 2 lines
Please use
pci_set_wordetc orcpu_to_leXX.Since now we've decided to avoid fields separation into <field> + <
field_upper>, this bitmask along withpci_set_wordare no longer needed.Quoted 3 lines
I think it's easiest to replace struct with a set of macros then
pci_set_worddoes the work for you.I don't really want to use macros here because structure show us the whole capability layout and this can decrease documenting efforts. More than that, memcpy usage is very convenient here, and I wouldn't like to lose it.
Quoted 12 lines
hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 434
Quoted 9 lines
hw/pci/pci_bridge.c +8
-0+ +int offset =pci_add_capability (dev,PCI_CAP_ID_VNDR , + cap_offset, cap_len, errp); +if (offset <0 ) { +return offset; + } + +memcpy (dev->config + offset +2 , (char *)&cap +2 , cap_len -2 );+2 is yacky. See how virtio does it:
Quoted 4 lines
memcpy(dev->config + offset + PCI_CAP_FLAGS, &cap->cap_len, cap->cap_len - PCI_CAP_FLAGS);OK.
Quoted 14 lines
Quoted 14 lines
hw/pci/pci_bridge.c +3
-0+return 0 ; +} +static const TypeInfo pci_bridge_type_info = { .name =TYPE_PCI_BRIDGE , .parent =TYPE_PCI_DEVICE ,include/hw/pci/pci_bridge.h +0
-0@@ -67,4 +67,22 @@ 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 */ Quoted 9 lines
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 75
Quoted 6 lines
include/hw/pci/pci_bridge.h +6
-0+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 bus_res; + uint32_t pref_lim_upper;Big endian? Ugh.
Agreed, and this's gonna to disappear with
the new layout.Quoted 7 lines
Quoted 5 lines
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 77
Quoted 2 lines
include/hw/pci/pci_bridge.h +2
-0+uint16_t pref_lim; +uint16_t mem_lim;I'd say we need 64 bit for memory.
Why? Non-prefetchable
MEMORY_LIMITregister is 16 bits long.Hmm ok, but e.g. for io there are bridges that have extra registers to specify non-standard non-aligned registers.
Quoted 10 lines
Quoted 8 lines
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 80
Quoted 3 lines
include/hw/pci/pci_bridge.h +3
-0+uint16_t io_lim_upper; +uint8_t io_lim; +uint8_t padding;IMHO each type should have a special "don't care" flag that would mean "I don't know".
Don't know what? Now 0 is an indicator to do nothing with this field.
Quoted 9 lines
Quoted 8 lines
Quoted 2 lines
In that case how do you say "don't allocate any memory"?
We can keep the MEM/Limit registers read-only for such cases, as they are optional registers.
Thanks,
Marcel
Hi Michael,
Quoted 5 lines
I don't believe they are - from the spec (1.2):
The Memory Base and Memory Limit registers are both required registersRest of ranges are indeed optional.
Oops, my mistake, I looked at prefetchable memory, sorry for the mix-up. I wonder what would be the use case to disable IOMEM.
Anyway, we can have a "-1" default value giving the hint: do not reserve anything, but in this case we should use it also for IO/prefetch mem. The problem is, the guest OS can try to allocate IO space even if the firmware didn't; Linux does it today.
Having IO-base/IO-limit registers read-only will solve the problem.
What am I getting at is we would have now 2 ways to solve the same problem and the hint would be inferior.
I would use the hint to reserve a specific range and read only registers to disable the range. IOMEM cannot be disabled in this way, but should not bother us.
Thanks,
Marcel
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 6 lines
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 81
Quoted 3 lines
include/hw/pci/pci_bridge.h +1
-0+} PCIBridgeQemuCap;You don't really need this struct in the header. And pls document all fields.
Quoted 9 lines
Quoted 9 lines
include/hw/pci/pci_bridge.h +6
-1+ +int pci_bridge_help_cap_init (PCIDevice *dev,int cap_offset, +uint8_t bus_reserve,uint32_t io_limit, +uint16_t mem_limit,uint64_t pref_limit, +Error **errp); +#endif /* QEMU_PCI_BRIDGE_H */ --2.7.4
--
Alexander Bezzubikov
Re: [Qemu-devel] [RFC PATCH v2 4/6] hw/pci: introduce bridge-only vendor-specific capability to provide some hints to firmware
Quoted 173 lines · Marcel Apfelbaum
Quoted 152 lines · Michael S. Tsirkin
Quoted 151 lines · Marcel Apfelbaum
Quoted 150 lines · Michael S. Tsirkin
Quoted 127 lines · Alexander Bezzubikov
2017-07-26 22:43 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 41 lines · Aleksandr Bezzubikov
Quoted 4 lines
On PCI init PCI bridges may need some
extra info about bus number to reserve, IO, memory and prefetchable memory limits. QEMU can provide this with specialwith a special
Quoted 18 lines
vendor-specific PCI capability.
Sizes of limits match ones from
PCI Type 1 Configuration Space Header,
number of buses to reserve occupies only 1 byte since it is the size of Subordinate Bus Number register.Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/pci/pci_bridge.c | 27 +++++++++++++++++++++++++++ include/hw/pci/pci_bridge.h | 18 ++++++++++++++++++ 2 files changed, 45 insertions(+)hw/pci/pci_bridge.c +0
-0hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 412
Quoted 5 lines
hw/pci/pci_bridge.c +2
-0@@ -408,6 +408,33 @@ void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, br->bus_name = bus_name; } + +int pci_bridge_help_cap_init(PCIDevice *dev, int cap_offset,help? should be
qemu_cap_init?hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 418
Quoted 6 lines
hw/pci/pci_bridge.c +6
-0+ uint8_t bus_reserve, uint32_t io_limit, + uint16_t mem_limit, uint64_t pref_limit, + Error **errp) +{ + size_t cap_len = sizeof(PCIBridgeQemuCap); +PCIBridgeQemuCap cap;Quoted 5 lines
This leaks info to guest. You want to init all fields here:
cap = { .len = .... };I surely can do this for len field, but as Laszlo proposed we can use mutually exclusive fields,
e.g.pref_32andpref_64, the only way I have left is to use ternary operator (if we surely need this big initializer). Keeping some if's would look better, I think.Quoted 10 lines
hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 426
Quoted 9 lines
hw/pci/pci_bridge.c +8
-0+ + cap.len = cap_len; + cap.bus_res = bus_reserve; + cap.io_lim = io_limit &0xFF ; + cap.io_lim_upper = io_limit >>8 &0xFFFF ; + cap.mem_lim = mem_limit; + cap.pref_lim = pref_limit &0xFFFF ; + cap.pref_lim_upper = pref_limit >>16 &0xFFFFFFFF ;Quoted 2 lines
Please use
pci_set_wordetc orcpu_to_leXX.Since now we've decided to avoid fields separation into <field> + <
field_upper>, this bitmask along withpci_set_wordare no longer needed.Quoted 3 lines
I think it's easiest to replace struct with a set of macros then
pci_set_worddoes the work for you.I don't really want to use macros here because structure show us the whole capability layout and this can decrease documenting efforts. More than that, memcpy usage is very convenient here, and I wouldn't like to lose it.
Quoted 12 lines
hw/pci/pci_bridge.c void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 434
Quoted 9 lines
hw/pci/pci_bridge.c +8
-0+ +int offset =pci_add_capability (dev,PCI_CAP_ID_VNDR , + cap_offset, cap_len, errp); +if (offset <0 ) { +return offset; + } + +memcpy (dev->config + offset +2 , (char *)&cap +2 , cap_len -2 );+2 is yacky. See how virtio does it:
Quoted 4 lines
memcpy(dev->config + offset + PCI_CAP_FLAGS, &cap->cap_len, cap->cap_len - PCI_CAP_FLAGS);OK.
Quoted 14 lines
Quoted 14 lines
hw/pci/pci_bridge.c +3
-0+return 0 ; +} +static const TypeInfo pci_bridge_type_info = { .name =TYPE_PCI_BRIDGE , .parent =TYPE_PCI_DEVICE ,include/hw/pci/pci_bridge.h +0
-0@@ -67,4 +67,22 @@ 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 */ Quoted 9 lines
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 75
Quoted 6 lines
include/hw/pci/pci_bridge.h +6
-0+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 bus_res; + uint32_t pref_lim_upper;Big endian? Ugh.
Agreed, and this's gonna to disappear with
the new layout.Quoted 7 lines
Quoted 5 lines
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 77
Quoted 2 lines
include/hw/pci/pci_bridge.h +2
-0+uint16_t pref_lim; +uint16_t mem_lim;I'd say we need 64 bit for memory.
Why? Non-prefetchable
MEMORY_LIMITregister is 16 bits long.Hmm ok, but e.g. for io there are bridges that have extra registers to specify non-standard non-aligned registers.
Quoted 10 lines
Quoted 8 lines
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 80
Quoted 3 lines
include/hw/pci/pci_bridge.h +3
-0+uint16_t io_lim_upper; +uint8_t io_lim; +uint8_t padding;IMHO each type should have a special "don't care" flag that would mean "I don't know".
Don't know what? Now 0 is an indicator to do nothing with this field.
Quoted 9 lines
Quoted 8 lines
Quoted 2 lines
In that case how do you say "don't allocate any memory"?
We can keep the MEM/Limit registers read-only for such cases, as they are optional registers.
Thanks,
MarcelHi Michael,
Quoted 5 lines
I don't believe they are - from the spec (1.2):
The Memory Base and Memory Limit registers are both required registersRest of ranges are indeed optional.
Quoted 8 lines
Oops, my mistake, I looked at prefetchable memory, sorry for the mix-up. I wonder what would be the use case to disable IOMEM.
Anyway, we can have a "-1" default value giving the hint: do not reserve anything, but in this case we should use it also for IO/prefetch mem. The problem is, the guest OS can try to allocate IO space even if the firmware didn't; Linux does it today.
Having IO-base/IO-limit registers read-only will solve the problem.
Makes sense.
Quoted 9 lines
What am I getting at is we would have now 2 ways to solve the same problem and the hint would be inferior.
I would use the hint to reserve a specific range and read only registers to disable the range. IOMEM cannot be disabled in this way, but should not bother us.
Thanks,
Marcel
I think Laszlo said that RO as an interface to indicate optional range is tricky to use.
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 6 lines
include/hw/pci/pci_bridge.h void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, · line 81
Quoted 3 lines
include/hw/pci/pci_bridge.h +1
-0+} PCIBridgeQemuCap;You don't really need this struct in the header. And pls document all fields.
Quoted 9 lines
Quoted 9 lines
include/hw/pci/pci_bridge.h +6
-1+ +int pci_bridge_help_cap_init (PCIDevice *dev,int cap_offset, +uint8_t bus_reserve,uint32_t io_limit, +uint16_t mem_limit,uint64_t pref_limit, +Error **errp); +#endif /* QEMU_PCI_BRIDGE_H */ --2.7.4
--
Alexander Bezzubikov
RFC PATCH v2 5/6 hw/pci: add bus_reserve property to pcie-root-port
In reply to Aleksandr BezzubikovTo enable hotplugging of a newly created pcie-pci-bridge,
we need to tell firmware (SeaBIOS in this case) to reserve additional buses for pcie-root-port, that allows us to
hotplug pcie-pci-bridge into this root port.
The number of buses to reserve is provided to the device via a corresponding property, and to the firmware via new PCI capability (next patch). The property's default value is 1 as we want to hotplug at least 1 bridge.
--- hw/pci-bridge/pcie_root_port.c | 1 + include/hw/pci/pcie_port.h | 3 +++ 2 files changed, 4 insertions(+)
hw/pci-bridge/pcie_root_port.c +1 -0
@@ -137,6 +137,7 @@ static void rp_exit(PCIDevice *d)static Property rp_props[] = {DEFINE_PROP_BIT (COMPAT_PROP_PCP , PCIDevice, cap_present,QEMU_PCIE_SLTCAP_PCP_BITNR , true), +DEFINE_PROP_UINT8 ("bus_reserve" , PCIEPort, bus_reserve,1 ),DEFINE_PROP_END_OF_LIST () };
include/hw/pci/pcie_port.h +3 -0
@@ -34,6 +34,9 @@ struct PCIEPort {/* pci express switch port */ uint8_t port; + +/* additional buses to reserve on firmware init */ +uint8_t bus_reserve; };void pcie_port_init_reg (PCIDevice *d);
Signature · 1 line
2.7.4
Re: [Qemu-devel] [RFC PATCH v2 5/6] hw/pci: add bus_reserve property to pcie-root-port
Quoted 2 lines · Aleksandr Bezzubikov
To enable hotplugging of a newly created pcie-pci-bridge, we need to tell firmware (SeaBIOS in this case)
Presumably, EFI would need to support this too?
Quoted 6 lines
to reserve
additional buses for pcie-root-port, that allows us to
hotplug pcie-pci-bridge into this root port.
The number of buses to reserve is provided to the device via a corresponding property, and to the firmware via new PCI capability (next patch). The property's default value is 1 as we want to hotplug at least 1 bridge.
If so you should just teach firmware to allocate one bus # unconditionally.
But why would that be so? What's wrong with a device directly in the root port?
Quoted 24 lines
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/pci-bridge/pcie_root_port.c | 1 + include/hw/pci/pcie_port.h | 3 +++ 2 files changed, 4 insertions(+)hw/pci-bridge/pcie_root_port.c +1
-0@@ -137,6 +137,7 @@ static void rp_exit(PCIDevice *d)static Property rp_props[] = {DEFINE_PROP_BIT (COMPAT_PROP_PCP , PCIDevice, cap_present,QEMU_PCIE_SLTCAP_PCP_BITNR , true), +DEFINE_PROP_UINT8 ("bus_reserve" , PCIEPort, bus_reserve,1 ),DEFINE_PROP_END_OF_LIST () };include/hw/pci/pcie_port.h +0
-0
include/hw/pci/pcie_port.h struct PCIEPort { · line 42
Quoted 9 lines
include/hw/pci/pcie_port.h +3
-0@@ -34,6 +34,9 @@ struct PCIEPort {/* pci express switch port */ uint8_t port; + +/* additional buses to reserve on firmware init */ +uint8_t bus_reserve; };void pcie_port_init_reg (PCIDevice *d);
So here is a property and it does not do anything.
It makes it easier to work on series maybe, but review is harder since we do not see what it does at all. Please do not split up patches like this - you can maintain it split up in your branch if you like and merge before sending.
Quoted 2 lines
Signature · 1 line
2.7.4
Re: [Qemu-devel] [RFC PATCH v2 5/6] hw/pci: add bus_reserve property to pcie-root-port
Quoted 4 lines · Michael S. Tsirkin
Quoted 2 lines · Aleksandr Bezzubikov
To enable hotplugging of a newly created pcie-pci-bridge, we need to tell firmware (SeaBIOS in this case)
Hi Michael,
Quoted 2 lines
Presumably, EFI would need to support this too?
Sure, Eduardo added to CC, but he is in PTO now.
Quoted 10 lines
Quoted 6 lines
to reserve
additional buses for pcie-root-port, that allows us to
hotplug pcie-pci-bridge into this root port.
The number of buses to reserve is provided to the device via a corresponding property, and to the firmware via new PCI capability (next patch). The property's default value is 1 as we want to hotplug at least 1 bridge.If so you should just teach firmware to allocate one bus # unconditionally.
That would be a problem for the PCIe machines, since each PCIe devices is plugged in a different bus and we are already limited to 256 PCIe devices. Allocating an extra-bus always would really limit the PCIe devices we can use.
Quoted 3 lines
But why would that be so? What's wrong with a device directly in the root port?
First, plugging a legacy PCI device into a PCIe Root Port looks strange at least, and it can;t be done on real HW anyway. (incompatible slots)
Second (and more important), if we want 2 or more PCI devices we would loose both IO ports space and bus numbers.
Quoted 33 lines
Quoted 33 lines
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/pci-bridge/pcie_root_port.c | 1 + include/hw/pci/pcie_port.h | 3 +++ 2 files changed, 4 insertions(+)hw/pci-bridge/pcie_root_port.c +1
-0@@ -137,6 +137,7 @@ static void rp_exit(PCIDevice *d)static Property rp_props[] = {DEFINE_PROP_BIT (COMPAT_PROP_PCP , PCIDevice, cap_present,QEMU_PCIE_SLTCAP_PCP_BITNR , true), +DEFINE_PROP_UINT8 ("bus_reserve" , PCIEPort, bus_reserve,1 ),DEFINE_PROP_END_OF_LIST () };include/hw/pci/pcie_port.h +3
-0@@ -34,6 +34,9 @@ struct PCIEPort {/* pci express switch port */ uint8_t port; + +/* additional buses to reserve on firmware init */ +uint8_t bus_reserve; };
Quoted 8 lines
include/hw/pci/pcie_port.h struct PCIEPort { · line 42
Quoted 1 line
include/hw/pci/pcie_port.h +0
-0void pcie_port_init_reg (PCIDevice *d);So here is a property and it does not do anything.
It makes it easier to work on series maybe, but review is harder since we do not see what it does at all. Please do not split up patches like this - you can maintain it split up in your branch if you like and merge before sending.
Agreed, Alexandr please merge patches 4-5-6 for your next submission.
Thanks,
Marcel
Quoted 2 lines
Quoted 2 lines
Signature · 1 line
2.7.4
Re: [Qemu-devel] [RFC PATCH v2 5/6] hw/pci: add bus_reserve property to pcie-root-port
Quoted 20 lines · Marcel Apfelbaum
Quoted 4 lines · Michael S. Tsirkin
Quoted 2 lines · Aleksandr Bezzubikov
To enable hotplugging of a newly created pcie-pci-bridge, we need to tell firmware (SeaBIOS in this case)
Hi Michael,
Quoted 2 lines
Presumably, EFI would need to support this too?
Sure, Eduardo added to CC, but he is in PTO now.
Quoted 7 lines
Quoted 6 lines
to reserve
additional buses for pcie-root-port, that allows us to
hotplug pcie-pci-bridge into this root port.
The number of buses to reserve is provided to the device via a corresponding property, and to the firmware via new PCI capability (next patch). The property's default value is 1 as we want to hotplug at least 1 bridge.
Quoted 8 lines
Quoted 3 lines
If so you should just teach firmware to allocate one bus # unconditionally.
That would be a problem for the PCIe machines, since each PCIe devices is plugged in a different bus and we are already limited to 256 PCIe devices. Allocating an extra-bus always would really limit the PCIe devices we can use.
But this is exactly what this patch does as the property is added to all buses and default to 1 (1 extra bus).
Quoted 7 lines
Quoted 3 lines
But why would that be so? What's wrong with a device directly in the root port?
First, plugging a legacy PCI device into a PCIe Root Port looks strange at least, and it can;t be done on real HW anyway. (incompatible slots)
You can still plug in PCIe devices there.
Quoted 2 lines
Second (and more important), if we want 2 or more PCI devices we would loose both IO ports space and bus numbers.
What I am saying is maybe default should not be 1.
Quoted 47 lines
Quoted 29 lines
Quoted 29 lines
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/pci-bridge/pcie_root_port.c | 1 + include/hw/pci/pcie_port.h | 3 +++ 2 files changed, 4 insertions(+)hw/pci-bridge/pcie_root_port.c +1
-0@@ -137,6 +137,7 @@ static void rp_exit(PCIDevice *d)static Property rp_props[] = {DEFINE_PROP_BIT (COMPAT_PROP_PCP , PCIDevice, cap_present,QEMU_PCIE_SLTCAP_PCP_BITNR , true), +DEFINE_PROP_UINT8 ("bus_reserve" , PCIEPort, bus_reserve,1 ),DEFINE_PROP_END_OF_LIST () };include/hw/pci/pcie_port.h +3
-0@@ -34,6 +34,9 @@ struct PCIEPort {/* pci express switch port */ uint8_t port; + +/* additional buses to reserve on firmware init */ +uint8_t bus_reserve;Quoted 9 lines
include/hw/pci/pcie_port.h struct PCIEPort { · line 42
Quoted 2 lines
include/hw/pci/pcie_port.h +0
-0};void pcie_port_init_reg (PCIDevice *d);So here is a property and it does not do anything.
It makes it easier to work on series maybe, but review is harder since we do not see what it does at all. Please do not split up patches like this - you can maintain it split up in your branch if you like and merge before sending.Agreed, Alexandr please merge patches 4-5-6 for your next submission.
Thanks,
MarcelQuoted 2 lines
Quoted 2 lines
Signature · 1 line
2.7.4
Re: [Qemu-devel] [RFC PATCH v2 5/6] hw/pci: add bus_reserve property to pcie-root-port
2017-07-24 23:46 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 41 lines · Marcel Apfelbaum
Quoted 20 lines · Michael S. Tsirkin
Quoted 4 lines · Aleksandr Bezzubikov
Quoted 2 lines
To enable hotplugging of a newly created pcie-pci-bridge, we need to tell firmware (SeaBIOS in this case)
Hi Michael,
Quoted 2 lines
Presumably, EFI would need to support this too?
Sure, Eduardo added to CC, but he is in PTO now.
Quoted 7 lines
Quoted 6 lines
to reserve
additional buses for pcie-root-port, that allows us to
hotplug pcie-pci-bridge into this root port.
The number of buses to reserve is provided to the device via a corresponding property, and to the firmware via new PCI capability (next patch). The property's default value is 1 as we want to hotplug at least 1 bridge.Quoted 8 lines
Quoted 3 lines
If so you should just teach firmware to allocate one bus # unconditionally.
That would be a problem for the PCIe machines, since each PCIe devices is plugged in a different bus and we are already limited to 256 PCIe devices. Allocating an extra-bus always would really limit the PCIe devices we can use.
But this is exactly what this patch does as the property is added to all buses and default to 1 (1 extra bus).
Quoted 7 lines
Quoted 3 lines
But why would that be so? What's wrong with a device directly in the root port?
First, plugging a legacy PCI device into a PCIe Root Port looks strange at least, and it can;t be done on real HW anyway. (incompatible slots)
Quoted 6 lines
You can still plug in PCIe devices there.
Quoted 2 lines
Second (and more important), if we want 2 or more PCI devices we would loose both IO ports space and bus numbers.
What I am saying is maybe default should not be 1.
The only sensible variant left is 0.
But as we want pcie-pci-bridge to be used for every legacy PCI device on q35 machine, every time one hotplugs the bridge into the root port, he must be sure rp's prop value >0 (for Linux). I'm not sure that it is a very convenient way to utilize the bridge - always remember to set property.
Another way - we can set this to 0 by default, and to 1 for pcie-root-port, and recommend to use it for hotplugging of the pcie-pci-bridge itself.
Quoted 48 lines
Quoted 48 lines
Quoted 30 lines
Quoted 30 lines
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/pci-bridge/pcie_root_port.c | 1 + include/hw/pci/pcie_port.h | 3 +++ 2 files changed, 4 insertions(+)hw/pci-bridge/pcie_root_port.c +1
-0@@ -137,6 +137,7 @@ static void rp_exit(PCIDevice *d)static Property rp_props[] = {DEFINE_PROP_BIT (COMPAT_PROP_PCP , PCIDevice, cap_present,QEMU_PCIE_SLTCAP_PCP_BITNR , true), +DEFINE_PROP_UINT8 ("bus_reserve" , PCIEPort, bus_reserve,1 ),DEFINE_PROP_END_OF_LIST () };include/hw/pci/pcie_port.h +3
-0@@ -34,6 +34,9 @@ struct PCIEPort {/* pci express switch port */ uint8_t port; + +/* additional buses to reserve on firmware init */ +uint8_t bus_reserve;Quoted 9 lines
include/hw/pci/pcie_port.h struct PCIEPort { · line 42
Quoted 2 lines
include/hw/pci/pcie_port.h +0
-0};void pcie_port_init_reg (PCIDevice *d);So here is a property and it does not do anything.
It makes it easier to work on series maybe, but review is harder since we do not see what it does at all. Please do not split up patches like this - you can maintain it split up in your branch if you like and merge before sending.Agreed, Alexandr please merge patches 4-5-6 for your next submission.
Thanks,
MarcelQuoted 2 lines
Quoted 2 lines
include/hw/pci/pcie_port.h +0
-1--2.7.4
Signature · 1 line
Alexander Bezzubikov
Re: [Qemu-devel] [RFC PATCH v2 5/6] hw/pci: add bus_reserve property to pcie-root-port
Quoted 47 lines · Alexander Bezzubikov
2017-07-24 23:46 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 46 lines · Marcel Apfelbaum
Quoted 20 lines · Michael S. Tsirkin
Quoted 4 lines · Aleksandr Bezzubikov
Quoted 2 lines
To enable hotplugging of a newly created pcie-pci-bridge, we need to tell firmware (SeaBIOS in this case)
Hi Michael,
Quoted 2 lines
Presumably, EFI would need to support this too?
Sure, Eduardo added to CC, but he is in PTO now.
Quoted 7 lines
Quoted 6 lines
to reserve
additional buses for pcie-root-port, that allows us to
hotplug pcie-pci-bridge into this root port.
The number of buses to reserve is provided to the device via a corresponding property, and to the firmware via new PCI capability (next patch). The property's default value is 1 as we want to hotplug at least 1 bridge.Quoted 8 lines
Quoted 3 lines
If so you should just teach firmware to allocate one bus # unconditionally.
That would be a problem for the PCIe machines, since each PCIe devices is plugged in a different bus and we are already limited to 256 PCIe devices. Allocating an extra-bus always would really limit the PCIe devices we can use.
But this is exactly what this patch does as the property is added to all buses and default to 1 (1 extra bus).
Quoted 7 lines
Quoted 3 lines
But why would that be so? What's wrong with a device directly in the root port?
First, plugging a legacy PCI device into a PCIe Root Port looks strange at least, and it can;t be done on real HW anyway. (incompatible slots)
You can still plug in PCIe devices there.
Quoted 2 lines
Second (and more important), if we want 2 or more PCI devices we would loose both IO ports space and bus numbers.
Quoted 8 lines
Quoted 1 line
What I am saying is maybe default should not be 1.
The only sensible variant left is 0.
But as we want pcie-pci-bridge to be used for every legacy PCI device on q35 machine, every time one hotplugs the bridge into the root port, he must be sure rp's prop value >0 (for Linux). I'm not sure that it is a very convenient way to utilize the bridge - always remember to set property.
That's what I'm saying then - if in your opinion default is >0 anyway, tweak firmware to do it by default.
Quoted 2 lines
Another way - we can set this to 0 by default, and to 1 for pcie-root-port, and recommend to use it for hotplugging of the pcie-pci-bridge itself.
I wonder about something: imagine hotplugging a hierarchy of bridges below a root port. It seems that nothing prevents guest from finding a free range of buses to cover this hierarchy and setting that as secondary/subordinate bus for this bridge.
This does need support on QEMU side to hotplug a hierarchy at once, and might need some fixes in Linux, on the plus side you can defer management decision on how many are needed until you are actually adding something, and you don't need vendor specific patches.
Quoted 53 lines
Quoted 48 lines
Quoted 48 lines
Quoted 30 lines
Quoted 30 lines
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/pci-bridge/pcie_root_port.c | 1 + include/hw/pci/pcie_port.h | 3 +++ 2 files changed, 4 insertions(+)hw/pci-bridge/pcie_root_port.c +1
-0@@ -137,6 +137,7 @@ static void rp_exit(PCIDevice *d)static Property rp_props[] = {DEFINE_PROP_BIT (COMPAT_PROP_PCP , PCIDevice, cap_present,QEMU_PCIE_SLTCAP_PCP_BITNR , true), +DEFINE_PROP_UINT8 ("bus_reserve" , PCIEPort, bus_reserve,1 ),DEFINE_PROP_END_OF_LIST () };include/hw/pci/pcie_port.h +3
-0@@ -34,6 +34,9 @@ struct PCIEPort {/* pci express switch port */ uint8_t port; + +/* additional buses to reserve on firmware init */ +uint8_t bus_reserve;Quoted 9 lines
include/hw/pci/pcie_port.h struct PCIEPort { · line 42
Quoted 2 lines
include/hw/pci/pcie_port.h +0
-0};void pcie_port_init_reg (PCIDevice *d);So here is a property and it does not do anything.
It makes it easier to work on series maybe, but review is harder since we do not see what it does at all. Please do not split up patches like this - you can maintain it split up in your branch if you like and merge before sending.Agreed, Alexandr please merge patches 4-5-6 for your next submission.
Thanks,
MarcelQuoted 2 lines
Quoted 2 lines
include/hw/pci/pcie_port.h +0
-1--2.7.4
Signature · 1 line
Alexander Bezzubikov
Re: [Qemu-devel] [RFC PATCH v2 5/6] hw/pci: add bus_reserve property to pcie-root-port
Quoted 43 lines · Michael S. Tsirkin
Quoted 42 lines · Alexander Bezzubikov
2017-07-24 23:46 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 41 lines · Marcel Apfelbaum
Quoted 20 lines · Michael S. Tsirkin
Quoted 4 lines · Aleksandr Bezzubikov
Quoted 2 lines
To enable hotplugging of a newly created pcie-pci-bridge, we need to tell firmware (SeaBIOS in this case)
Hi Michael,
Quoted 2 lines
Presumably, EFI would need to support this too?
Sure, Eduardo added to CC, but he is in PTO now.
Quoted 7 lines
Quoted 6 lines
to reserve
additional buses for pcie-root-port, that allows us to
hotplug pcie-pci-bridge into this root port.
The number of buses to reserve is provided to the device via a corresponding property, and to the firmware via new PCI capability (next patch). The property's default value is 1 as we want to hotplug at least 1 bridge.Quoted 8 lines
Quoted 3 lines
If so you should just teach firmware to allocate one bus # unconditionally.
That would be a problem for the PCIe machines, since each PCIe devices is plugged in a different bus and we are already limited to 256 PCIe devices. Allocating an extra-bus always would really limit the PCIe devices we can use.
But this is exactly what this patch does as the property is added to all buses and default to 1 (1 extra bus).
Quoted 7 lines
Quoted 3 lines
But why would that be so? What's wrong with a device directly in the root port?
First, plugging a legacy PCI device into a PCIe Root Port looks strange at least, and it can;t be done on real HW anyway. (incompatible slots)
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
You can still plug in PCIe devices there.
Quoted 2 lines
Second (and more important), if we want 2 or more PCI devices we would loose both IO ports space and bus numbers.
What I am saying is maybe default should not be 1.
Hi Michael, Alexander
Quoted 7 lines
Quoted 6 lines
The only sensible variant left is 0.
But as we want pcie-pci-bridge to be used for every legacy PCI device on q35 machine, every time one hotplugs the bridge into the root port, he must be sure rp's prop value >0 (for Linux). I'm not sure that it is a very convenient way to utilize the bridge - always remember to set property.
Is not for Linux only, is for all guest OSes.
I also think setting the property is OK, libvirt can always add a single PCIe Root Port port with this property set, while upper layers can create flavors (if the feature needed or not for the current setup)
Quoted 3 lines
That's what I'm saying then - if in your opinion default is >0 anyway, tweak firmware to do it by default.
Default should be 0 for sure - because of the hard limitation on the number of PCIe devices for single PCI domain (the same as the number of buses, 256).
For a positive value we will should add a property "buses-reserve = x".
Quoted 12 lines
Quoted 2 lines
Another way - we can set this to 0 by default, and to 1 for pcie-root-port, and recommend to use it for hotplugging of the pcie-pci-bridge itself.
I wonder about something: imagine hotplugging a hierarchy of bridges below a root port. It seems that nothing prevents guest from finding a free range of buses to cover this hierarchy and setting that as secondary/subordinate bus for this bridge.
Quoted 1 line
This does need support on QEMU side to hotplug a hierarchy at once,
and might need some fixes in Linux, on the plus side you can defer management decision on how many are needed until you are actually adding something, and you don't need vendor specific patches.
We can teach Linux kernel, that's for sure (OK, almost sure...) but what we don't want is to be dependent on specific guest Operating Systems. For example, most configurations are not supported by Windows guests.
Also is a great opportunity adding PCI IO resources hints to guest FW, something we wanted to do for some time.
Thanks,
Marcel
Quoted 54 lines
Quoted 54 lines
Quoted 49 lines
Quoted 49 lines
Quoted 31 lines
Quoted 31 lines
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/pci-bridge/pcie_root_port.c | 1 + include/hw/pci/pcie_port.h | 3 +++ 2 files changed, 4 insertions(+)hw/pci-bridge/pcie_root_port.c +1
-0@@ -137,6 +137,7 @@ static void rp_exit(PCIDevice *d)static Property rp_props[] = {DEFINE_PROP_BIT (COMPAT_PROP_PCP , PCIDevice, cap_present,QEMU_PCIE_SLTCAP_PCP_BITNR , true), +DEFINE_PROP_UINT8 ("bus_reserve" , PCIEPort, bus_reserve,1 ),DEFINE_PROP_END_OF_LIST () };include/hw/pci/pcie_port.h +3
-0@@ -34,6 +34,9 @@ struct PCIEPort {/* pci express switch port */ uint8_t port; + +/* additional buses to reserve on firmware init */ +uint8_t bus_reserve;Quoted 9 lines
include/hw/pci/pcie_port.h struct PCIEPort { · line 42
Quoted 2 lines
include/hw/pci/pcie_port.h +0
-0};void pcie_port_init_reg (PCIDevice *d);So here is a property and it does not do anything.
It makes it easier to work on series maybe, but review is harder since we do not see what it does at all. Please do not split up patches like this - you can maintain it split up in your branch if you like and merge before sending.Agreed, Alexandr please merge patches 4-5-6 for your next submission.
Thanks,
MarcelQuoted 2 lines
Quoted 2 lines
include/hw/pci/pcie_port.h +0
-1--2.7.4
Signature · 1 line
Alexander Bezzubikov
Re: [Qemu-devel] [RFC PATCH v2 5/6] hw/pci: add bus_reserve property to pcie-root-port
Quoted 62 lines · Marcel Apfelbaum
Quoted 43 lines · Michael S. Tsirkin
Quoted 42 lines · Alexander Bezzubikov
2017-07-24 23:46 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 41 lines · Marcel Apfelbaum
Quoted 20 lines · Michael S. Tsirkin
Quoted 4 lines · Aleksandr Bezzubikov
Quoted 2 lines
To enable hotplugging of a newly created pcie-pci-bridge, we need to tell firmware (SeaBIOS in this case)
Hi Michael,
Quoted 2 lines
Presumably, EFI would need to support this too?
Sure, Eduardo added to CC, but he is in PTO now.
Quoted 7 lines
Quoted 6 lines
to reserve
additional buses for pcie-root-port, that allows us to
hotplug pcie-pci-bridge into this root port.
The number of buses to reserve is provided to the device via a corresponding property, and to the firmware via new PCI capability (next patch). The property's default value is 1 as we want to hotplug at least 1 bridge.Quoted 8 lines
Quoted 3 lines
If so you should just teach firmware to allocate one bus # unconditionally.
That would be a problem for the PCIe machines, since each PCIe devices is plugged in a different bus and we are already limited to 256 PCIe devices. Allocating an extra-bus always would really limit the PCIe devices we can use.
But this is exactly what this patch does as the property is added to all buses and default to 1 (1 extra bus).
Quoted 7 lines
Quoted 3 lines
But why would that be so? What's wrong with a device directly in the root port?
First, plugging a legacy PCI device into a PCIe Root Port looks strange at least, and it can;t be done on real HW anyway. (incompatible slots)
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
You can still plug in PCIe devices there.
Quoted 2 lines
Second (and more important), if we want 2 or more PCI devices we would loose both IO ports space and bus numbers.
What I am saying is maybe default should not be 1.
Hi Michael, Alexander
Quoted 7 lines
Quoted 6 lines
The only sensible variant left is 0.
But as we want pcie-pci-bridge to be used for every legacy PCI device on q35 machine, every time one hotplugs the bridge into the root port, he must be sure rp's prop value >0 (for Linux). I'm not sure that it is a very convenient way to utilize the bridge - always remember to set property.
Quoted 5 lines
Is not for Linux only, is for all guest OSes.
I also think setting the property is OK, libvirt can always add a single PCIe Root Port port with this property set, while upper layers can create flavors (if the feature needed or not for the current setup)
If you are going to always do this, it kind of looks like Laszlo's idea of always cold-plugging a pci bridge.
Quoted 9 lines
Quoted 3 lines
That's what I'm saying then - if in your opinion default is >0 anyway, tweak firmware to do it by default.
Default should be 0 for sure - because of the hard limitation on the number of PCIe devices for single PCI domain (the same as the number of buses, 256).
For a positive value we will should add a property "buses-reserve = x".
So value here is borderline but if it includes other resources then value seems clearer.
Quoted 13 lines
Quoted 12 lines
Quoted 2 lines
Another way - we can set this to 0 by default, and to 1 for pcie-root-port, and recommend to use it for hotplugging of the pcie-pci-bridge itself.
I wonder about something: imagine hotplugging a hierarchy of bridges below a root port. It seems that nothing prevents guest from finding a free range of buses to cover this hierarchy and setting that as secondary/subordinate bus for this bridge.
Quoted 1 line
This does need support on QEMU side to hotplug a hierarchy at once,
and might need some fixes in Linux, on the plus side you can defer management decision on how many are needed until you are actually adding something, and you don't need vendor specific patches.
Quoted 4 lines
We can teach Linux kernel, that's for sure (OK, almost sure...) but what we don't want is to be dependent on specific guest Operating Systems. For example, most configurations are not supported by Windows guests.
If you fix Linux then windows will not want to be left behind and will implement this too.
Quoted 5 lines
Also is a great opportunity adding PCI IO resources hints to guest FW, something we wanted to do for some time.
Thanks,
Marcel
I agree, it's a good reason to add this capability.
Quoted 54 lines
Quoted 54 lines
Quoted 54 lines
Quoted 49 lines
Quoted 49 lines
Quoted 31 lines
Quoted 31 lines
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/pci-bridge/pcie_root_port.c | 1 + include/hw/pci/pcie_port.h | 3 +++ 2 files changed, 4 insertions(+)hw/pci-bridge/pcie_root_port.c +1
-0@@ -137,6 +137,7 @@ static void rp_exit(PCIDevice *d)static Property rp_props[] = {DEFINE_PROP_BIT (COMPAT_PROP_PCP , PCIDevice, cap_present,QEMU_PCIE_SLTCAP_PCP_BITNR , true), +DEFINE_PROP_UINT8 ("bus_reserve" , PCIEPort, bus_reserve,1 ),DEFINE_PROP_END_OF_LIST () };include/hw/pci/pcie_port.h +3
-0@@ -34,6 +34,9 @@ struct PCIEPort {/* pci express switch port */ uint8_t port; + +/* additional buses to reserve on firmware init */ +uint8_t bus_reserve;Quoted 9 lines
include/hw/pci/pcie_port.h struct PCIEPort { · line 40
Quoted 2 lines
include/hw/pci/pcie_port.h +0
-0};void pcie_port_init_reg (PCIDevice *d);So here is a property and it does not do anything.
It makes it easier to work on series maybe, but review is harder since we do not see what it does at all. Please do not split up patches like this - you can maintain it split up in your branch if you like and merge before sending.Agreed, Alexandr please merge patches 4-5-6 for your next submission.
Thanks,
MarcelQuoted 2 lines
Quoted 2 lines
include/hw/pci/pcie_port.h +0
-1--2.7.4
Signature · 1 line
Alexander Bezzubikov
Re: [Qemu-devel] [RFC PATCH v2 5/6] hw/pci: add bus_reserve property to pcie-root-port
In reply to Marcel ApfelbaumQuoted 20 lines · Marcel Apfelbaum
Quoted 4 lines · Michael S. Tsirkin
Quoted 2 lines · Aleksandr Bezzubikov
To enable hotplugging of a newly created pcie-pci-bridge, we need to tell firmware (SeaBIOS in this case)
Hi Michael,
Quoted 2 lines
Presumably, EFI would need to support this too?
Sure, Eduardo added to CC, but he is in PTO now.
Quoted 7 lines
Quoted 6 lines
to reserve
additional buses for pcie-root-port, that allows us to
hotplug pcie-pci-bridge into this root port.
The number of buses to reserve is provided to the device via a corresponding property, and to the firmware via new PCI capability (next patch). The property's default value is 1 as we want to hotplug at least 1 bridge.
Quoted 8 lines
Quoted 3 lines
If so you should just teach firmware to allocate one bus # unconditionally.
That would be a problem for the PCIe machines, since each PCIe devices is plugged in a different bus and we are already limited to 256 PCIe devices. Allocating an extra-bus always would really limit the PCIe devices we can use.
One of the declared advantages of PCIe is easy support for multiple roots. We really should look at that IMHO so we do not need to pile up hacks.
Quoted 3 lines
Quoted 3 lines
But why would that be so? What's wrong with a device directly in the root port?
To clarify, my point is we might be wasting bus numbers by reservation since someone might just want to put pcie devices there.
Quoted 54 lines
First, plugging a legacy PCI device into a PCIe Root Port looks strange at least, and it can;t be done on real HW anyway. (incompatible slots)
Second (and more important), if we want 2 or more PCI devices we would loose both IO ports space and bus numbers.
Quoted 29 lines
Quoted 29 lines
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/pci-bridge/pcie_root_port.c | 1 + include/hw/pci/pcie_port.h | 3 +++ 2 files changed, 4 insertions(+)hw/pci-bridge/pcie_root_port.c +1
-0@@ -137,6 +137,7 @@ static void rp_exit(PCIDevice *d)static Property rp_props[] = {DEFINE_PROP_BIT (COMPAT_PROP_PCP , PCIDevice, cap_present,QEMU_PCIE_SLTCAP_PCP_BITNR , true), +DEFINE_PROP_UINT8 ("bus_reserve" , PCIEPort, bus_reserve,1 ),DEFINE_PROP_END_OF_LIST () };include/hw/pci/pcie_port.h +3
-0@@ -34,6 +34,9 @@ struct PCIEPort {/* pci express switch port */ uint8_t port; + +/* additional buses to reserve on firmware init */ +uint8_t bus_reserve;Quoted 9 lines
include/hw/pci/pcie_port.h struct PCIEPort { · line 42
Quoted 2 lines
include/hw/pci/pcie_port.h +0
-0};void pcie_port_init_reg (PCIDevice *d);So here is a property and it does not do anything.
It makes it easier to work on series maybe, but review is harder since we do not see what it does at all. Please do not split up patches like this - you can maintain it split up in your branch if you like and merge before sending.Agreed, Alexandr please merge patches 4-5-6 for your next submission.
Thanks,
MarcelQuoted 2 lines
Quoted 2 lines
Signature · 1 line
2.7.4
Re: [Qemu-devel] [RFC PATCH v2 5/6] hw/pci: add bus_reserve property to pcie-root-port
2017-07-25 16:43 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 33 lines · Marcel Apfelbaum
Quoted 20 lines · Michael S. Tsirkin
Quoted 4 lines · Aleksandr Bezzubikov
Quoted 2 lines
To enable hotplugging of a newly created pcie-pci-bridge, we need to tell firmware (SeaBIOS in this case)
Hi Michael,
Quoted 2 lines
Presumably, EFI would need to support this too?
Sure, Eduardo added to CC, but he is in PTO now.
Quoted 7 lines
Quoted 6 lines
to reserve
additional buses for pcie-root-port, that allows us to
hotplug pcie-pci-bridge into this root port.
The number of buses to reserve is provided to the device via a corresponding property, and to the firmware via new PCI capability (next patch). The property's default value is 1 as we want to hotplug at least 1 bridge.Quoted 8 lines
Quoted 3 lines
If so you should just teach firmware to allocate one bus # unconditionally.
That would be a problem for the PCIe machines, since each PCIe devices is plugged in a different bus and we are already limited to 256 PCIe devices. Allocating an extra-bus always would really limit the PCIe devices we can use.
One of the declared advantages of PCIe is easy support for multiple roots. We really should look at that IMHO so we do not need to pile up hacks.
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
But why would that be so? What's wrong with a device directly in the root port?
To clarify, my point is we might be wasting bus numbers by reservation since someone might just want to put pcie devices there.
I think, changing default value to 0 can help us avoid this, as no bus reservation by default. If one's surely wants to hotplug pcie-pci-bridge into this root port in future, the property gives him such an opportunity.
So, sure need pcie-pci-bridge hotplug -> creating a root port with bus_reserve > 0. Otherwise (and default) - just as now, no changes in bus topology.
Quoted 55 lines
Quoted 55 lines
First, plugging a legacy PCI device into a PCIe Root Port looks strange at least, and it can;t be done on real HW anyway. (incompatible slots)
Second (and more important), if we want 2 or more PCI devices we would loose both IO ports space and bus numbers.
Quoted 29 lines
Quoted 29 lines
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/pci-bridge/pcie_root_port.c | 1 + include/hw/pci/pcie_port.h | 3 +++ 2 files changed, 4 insertions(+)hw/pci-bridge/pcie_root_port.c +1
-0@@ -137,6 +137,7 @@ static void rp_exit(PCIDevice *d)static Property rp_props[] = {DEFINE_PROP_BIT (COMPAT_PROP_PCP , PCIDevice, cap_present,QEMU_PCIE_SLTCAP_PCP_BITNR , true), +DEFINE_PROP_UINT8 ("bus_reserve" , PCIEPort, bus_reserve,1 ),DEFINE_PROP_END_OF_LIST () };include/hw/pci/pcie_port.h +3
-0@@ -34,6 +34,9 @@ struct PCIEPort {/* pci express switch port */ uint8_t port; + +/* additional buses to reserve on firmware init */ +uint8_t bus_reserve;Quoted 9 lines
include/hw/pci/pcie_port.h struct PCIEPort { · line 42
Quoted 2 lines
include/hw/pci/pcie_port.h +0
-0};void pcie_port_init_reg (PCIDevice *d);So here is a property and it does not do anything.
It makes it easier to work on series maybe, but review is harder since we do not see what it does at all. Please do not split up patches like this - you can maintain it split up in your branch if you like and merge before sending.Agreed, Alexandr please merge patches 4-5-6 for your next submission.
Thanks,
MarcelQuoted 2 lines
Quoted 2 lines
include/hw/pci/pcie_port.h +0
-1--2.7.4
Signature · 1 line
Alexander Bezzubikov
Re: [Qemu-devel] [RFC PATCH v2 5/6] hw/pci: add bus_reserve property to pcie-root-port
Quoted 41 lines · Alexander Bezzubikov
2017-07-25 16:43 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 33 lines · Marcel Apfelbaum
Quoted 20 lines · Michael S. Tsirkin
Quoted 4 lines · Aleksandr Bezzubikov
Quoted 2 lines
To enable hotplugging of a newly created pcie-pci-bridge, we need to tell firmware (SeaBIOS in this case)
Hi Michael,
Quoted 2 lines
Presumably, EFI would need to support this too?
Sure, Eduardo added to CC, but he is in PTO now.
Quoted 7 lines
Quoted 6 lines
to reserve
additional buses for pcie-root-port, that allows us to
hotplug pcie-pci-bridge into this root port.
The number of buses to reserve is provided to the device via a corresponding property, and to the firmware via new PCI capability (next patch). The property's default value is 1 as we want to hotplug at least 1 bridge.Quoted 8 lines
Quoted 3 lines
If so you should just teach firmware to allocate one bus # unconditionally.
That would be a problem for the PCIe machines, since each PCIe devices is plugged in a different bus and we are already limited to 256 PCIe devices. Allocating an extra-bus always would really limit the PCIe devices we can use.
One of the declared advantages of PCIe is easy support for multiple roots. We really should look at that IMHO so we do not need to pile up hacks.
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
But why would that be so? What's wrong with a device directly in the root port?
To clarify, my point is we might be wasting bus numbers by reservation since someone might just want to put pcie devices there.
Quoted 7 lines
I think, changing default value to 0 can help us avoid this, as no bus reservation by default. If one's surely wants to hotplug pcie-pci-bridge into this root port in future, the property gives him such an opportunity.
So, sure need pcie-pci-bridge hotplug -> creating a root port withbus_reserve> 0. Otherwise (and default) - just as now, no changes in bus topology.
I guess 0 should mean "do not reserve any buses". So I think we also need a flag to just avoid the capability altogether. Maybe -1? *That* should be the default.
Quoted 60 lines
Quoted 55 lines
Quoted 55 lines
First, plugging a legacy PCI device into a PCIe Root Port looks strange at least, and it can;t be done on real HW anyway. (incompatible slots)
Second (and more important), if we want 2 or more PCI devices we would loose both IO ports space and bus numbers.
Quoted 29 lines
Quoted 29 lines
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/pci-bridge/pcie_root_port.c | 1 + include/hw/pci/pcie_port.h | 3 +++ 2 files changed, 4 insertions(+)hw/pci-bridge/pcie_root_port.c +1
-0@@ -137,6 +137,7 @@ static void rp_exit(PCIDevice *d)static Property rp_props[] = {DEFINE_PROP_BIT (COMPAT_PROP_PCP , PCIDevice, cap_present,QEMU_PCIE_SLTCAP_PCP_BITNR , true), +DEFINE_PROP_UINT8 ("bus_reserve" , PCIEPort, bus_reserve,1 ),DEFINE_PROP_END_OF_LIST () };include/hw/pci/pcie_port.h +3
-0@@ -34,6 +34,9 @@ struct PCIEPort {/* pci express switch port */ uint8_t port; + +/* additional buses to reserve on firmware init */ +uint8_t bus_reserve;Quoted 9 lines
include/hw/pci/pcie_port.h struct PCIEPort { · line 42
Quoted 2 lines
include/hw/pci/pcie_port.h +0
-0};void pcie_port_init_reg (PCIDevice *d);So here is a property and it does not do anything.
It makes it easier to work on series maybe, but review is harder since we do not see what it does at all. Please do not split up patches like this - you can maintain it split up in your branch if you like and merge before sending.Agreed, Alexandr please merge patches 4-5-6 for your next submission.
Thanks,
MarcelQuoted 2 lines
Quoted 2 lines
include/hw/pci/pcie_port.h +0
-1--2.7.4
Signature · 1 line
Alexander Bezzubikov
Re: [Qemu-devel] [RFC PATCH v2 5/6] hw/pci: add bus_reserve property to pcie-root-port
2017-07-25 16:53 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 50 lines · Alexander Bezzubikov
Quoted 41 lines
2017-07-25 16:43 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 33 lines · Marcel Apfelbaum
Quoted 20 lines · Michael S. Tsirkin
Quoted 4 lines · Aleksandr Bezzubikov
Quoted 2 lines
To enable hotplugging of a newly created pcie-pci-bridge, we need to tell firmware (SeaBIOS in this case)
Hi Michael,
Quoted 2 lines
Presumably, EFI would need to support this too?
Sure, Eduardo added to CC, but he is in PTO now.
Quoted 7 lines
Quoted 6 lines
to reserve
additional buses for pcie-root-port, that allows us to
hotplug pcie-pci-bridge into this root port.
The number of buses to reserve is provided to the device via a corresponding property, and to the firmware via new PCI capability (next patch). The property's default value is 1 as we want to hotplug at least 1 bridge.Quoted 8 lines
Quoted 3 lines
If so you should just teach firmware to allocate one bus # unconditionally.
That would be a problem for the PCIe machines, since each PCIe devices is plugged in a different bus and we are already limited to 256 PCIe devices. Allocating an extra-bus always would really limit the PCIe devices we can use.
One of the declared advantages of PCIe is easy support for multiple roots. We really should look at that IMHO so we do not need to pile up hacks.
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
But why would that be so? What's wrong with a device directly in the root port?
To clarify, my point is we might be wasting bus numbers by reservation since someone might just want to put pcie devices there.
Quoted 7 lines
I think, changing default value to 0 can help us avoid this, as no bus reservation by default. If one's surely wants to hotplug pcie-pci-bridge into this root port in future, the property gives him such an opportunity.
So, sure need pcie-pci-bridge hotplug -> creating a root port withbus_reserve> 0. Otherwise (and default) - just as now, no changes in bus topology.
Quoted 3 lines
I guess 0 should mean "do not reserve any buses". So I think we also need a flag to just avoid the capability altogether. Maybe -1? *That* should be the default.
-1 might be useful if any limit value 0 is legal, but is it? If not, we can set every field to 0 and
this is a sign of avoiding capability since none legal values are provided.
Quoted 61 lines
Quoted 61 lines
Quoted 48 lines
Quoted 48 lines
First, plugging a legacy PCI device into a PCIe Root Port looks strange at least, and it can;t be done on real HW anyway. (incompatible slots)
Second (and more important), if we want 2 or more PCI devices we would loose both IO ports space and bus numbers.
Quoted 38 lines
Quoted 24 lines
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/pci-bridge/pcie_root_port.c | 1 + include/hw/pci/pcie_port.h | 3 +++ 2 files changed, 4 insertions(+)hw/pci-bridge/pcie_root_port.c +1
-0@@ -137,6 +137,7 @@ static void rp_exit(PCIDevice *d)static Property rp_props[] = {DEFINE_PROP_BIT (COMPAT_PROP_PCP , PCIDevice, cap_present,QEMU_PCIE_SLTCAP_PCP_BITNR , true), +DEFINE_PROP_UINT8 ("bus_reserve" , PCIEPort, bus_reserve,1 ),DEFINE_PROP_END_OF_LIST () };include/hw/pci/pcie_port.h +0
-0include/hw/pci/pcie_port.h struct PCIEPort { · line 40
Quoted 7 lines
include/hw/pci/pcie_port.h +3
-0@@ -34,6 +34,9 @@ struct PCIEPort {/* pci express switch port */ uint8_t port; + +/* additional buses to reserve on firmware init */ +uint8_t bus_reserve; };void pcie_port_init_reg (PCIDevice *d);So here is a property and it does not do anything.
It makes it easier to work on series maybe, but review is harder since we do not see what it does at all. Please do not split up patches like this - you can maintain it split up in your branch if you like and merge before sending.Quoted 8 lines
Quoted 8 lines
Agreed, Alexandr please merge patches 4-5-6 for your next submission.
Thanks,
MarcelQuoted 2 lines
Quoted 2 lines
include/hw/pci/pcie_port.h +0
-1--2.7.4
--
Alexander Bezzubikov
Signature · 1 line
Alexander Bezzubikov
Re: [Qemu-devel] [RFC PATCH v2 5/6] hw/pci: add bus_reserve property to pcie-root-port
Quoted 51 lines · Alexander Bezzubikov
2017-07-25 16:53 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 50 lines · Alexander Bezzubikov
Quoted 48 lines
2017-07-25 16:43 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 33 lines · Marcel Apfelbaum
Quoted 20 lines · Michael S. Tsirkin
Quoted 4 lines · Aleksandr Bezzubikov
Quoted 2 lines
To enable hotplugging of a newly created pcie-pci-bridge, we need to tell firmware (SeaBIOS in this case)
Hi Michael,
Quoted 2 lines
Presumably, EFI would need to support this too?
Sure, Eduardo added to CC, but he is in PTO now.
Quoted 7 lines
Quoted 6 lines
to reserve
additional buses for pcie-root-port, that allows us to
hotplug pcie-pci-bridge into this root port.
The number of buses to reserve is provided to the device via a corresponding property, and to the firmware via new PCI capability (next patch). The property's default value is 1 as we want to hotplug at least 1 bridge.Quoted 8 lines
Quoted 3 lines
If so you should just teach firmware to allocate one bus # unconditionally.
That would be a problem for the PCIe machines, since each PCIe devices is plugged in a different bus and we are already limited to 256 PCIe devices. Allocating an extra-bus always would really limit the PCIe devices we can use.
One of the declared advantages of PCIe is easy support for multiple roots. We really should look at that IMHO so we do not need to pile up hacks.
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
But why would that be so? What's wrong with a device directly in the root port?
To clarify, my point is we might be wasting bus numbers by reservation since someone might just want to put pcie devices there.
I think, changing default value to 0 can help us avoid this, as no bus reservation by default. If one's surely wants to hotplug pcie-pci-bridge into this root port in future, the property gives him such an opportunity.
So, sure need pcie-pci-bridge hotplug -> creating a root port withbus_reserve> 0. Otherwise (and default) - just as now, no changes in bus topology.
Quoted 9 lines
Quoted 3 lines
I guess 0 should mean "do not reserve any buses". So I think we also need a flag to just avoid the capability altogether. Maybe -1? *That* should be the default.
-1 might be useful if any limit value 0 is legal, but is it? If not, we can set every field to 0 and
this is a sign of avoiding capability since none legal values are provided.
As Gerd suggested, this value is not a "delta" but the number of buses to be reserved behind the bridge. If I got it right, 0 is not a valid value, since the bridge by definition has a list one bus behind.
Michael, would you be OK with that?
Thanks,
Marcel
Quoted 64 lines
Quoted 61 lines
Quoted 61 lines
Quoted 48 lines
Quoted 48 lines
First, plugging a legacy PCI device into a PCIe Root Port looks strange at least, and it can;t be done on real HW anyway. (incompatible slots)
Second (and more important), if we want 2 or more PCI devices we would loose both IO ports space and bus numbers.
Quoted 38 lines
Quoted 24 lines
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/pci-bridge/pcie_root_port.c | 1 + include/hw/pci/pcie_port.h | 3 +++ 2 files changed, 4 insertions(+)hw/pci-bridge/pcie_root_port.c +1
-0@@ -137,6 +137,7 @@ static void rp_exit(PCIDevice *d)static Property rp_props[] = {DEFINE_PROP_BIT (COMPAT_PROP_PCP , PCIDevice, cap_present,QEMU_PCIE_SLTCAP_PCP_BITNR , true), +DEFINE_PROP_UINT8 ("bus_reserve" , PCIEPort, bus_reserve,1 ),DEFINE_PROP_END_OF_LIST () };include/hw/pci/pcie_port.h +0
-0include/hw/pci/pcie_port.h struct PCIEPort { · line 40
Quoted 7 lines
include/hw/pci/pcie_port.h +3
-0@@ -34,6 +34,9 @@ struct PCIEPort {/* pci express switch port */ uint8_t port; + +/* additional buses to reserve on firmware init */ +uint8_t bus_reserve; };void pcie_port_init_reg (PCIDevice *d);So here is a property and it does not do anything.
It makes it easier to work on series maybe, but review is harder since we do not see what it does at all. Please do not split up patches like this - you can maintain it split up in your branch if you like and merge before sending.Quoted 8 lines
Quoted 8 lines
Agreed, Alexandr please merge patches 4-5-6 for your next submission.
Thanks,
MarcelQuoted 2 lines
Quoted 2 lines
include/hw/pci/pcie_port.h +0
-1--2.7.4
--
Alexander Bezzubikov
Re: [Qemu-devel] [RFC PATCH v2 5/6] hw/pci: add bus_reserve property to pcie-root-port
вт, 25 июля 2017 г. в 19:10, Marcel Apfelbaum <[email protected]>:
Quoted 66 lines · Alexander Bezzubikov
Quoted 6 lines
2017-07-25 16:53 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 5 lines · Alexander Bezzubikov
Quoted 4 lines
2017-07-25 16:43 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 3 lines · Marcel Apfelbaum
Quoted 2 lines · Michael S. Tsirkin
Quoted 1 line
On Sun, Jul 23, 2017 at 01:15:42AM +0300, Aleksandr Bezzubikov
Quoted 9 lines · wrote:
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
Quoted 2 lines
To enable hotplugging of a newly created pcie-pci-bridge, we need to tell firmware (SeaBIOS in this case)
Hi Michael,
Quoted 2 lines
Presumably, EFI would need to support this too?
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Sure, Eduardo added to CC, but he is in PTO now.
Quoted 4 lines
Quoted 4 lines
to reserve
additional buses for pcie-root-port, that allows us to hotplug pcie-pci-bridge into this root port.
The number of buses to reserve is provided to the device via acorresponding
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
property, and to the firmware via new PCI capability (next patch). The property's default value is 1 as we want to hotplug at least 1
bridge.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 9 lines
Quoted 4 lines
If so you should just teach firmware to allocate one bus # unconditionally.
That would be a problem for the PCIe machines, since each PCIe devices is plugged in a different bus and we are already limited to 256 PCIe devices. Allocating an extra-bus always would really limit the PCIe devices we can use.
One of the declared advantages of PCIe is easy support for multiple
roots.
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
Quoted 8 lines
We really should look at that IMHO so we do not need to pile up hacks.
Quoted 3 lines
Quoted 3 lines
But why would that be so? What's wrong with a device directly in the root port?
To clarify, my point is we might be wasting bus numbers by reservation since someone might just want to put pcie devices there.
I think, changing default value to 0 can help us avoid this, as no bus reservation by default. If one's surely wants to hotplug pcie-pci-bridge into this root port in future, the property gives him such an opportunity.
So, sure need pcie-pci-bridge hotplug -> creating a root port withbus_reserve> 0. Otherwise (and default) - just as now, no changes in bus topology.Quoted 9 lines
Quoted 3 lines
I guess 0 should mean "do not reserve any buses". So I think we also need a flag to just avoid the capability altogether. Maybe -1? *That* should be the default.
-1 might be useful if any limit value 0 is legal, but is it? If not, we can set every field to 0 and
this is a sign of avoiding capability since none legal values are provided.
Quoted 4 lines
As Gerd suggested, this value is not a "delta" but the number of buses to be reserved behind the bridge. If I got it right, 0 is not a valid value, since the bridge by definition has a list one bus behind.
Gerd's suggestion was to set min(cap_value, children_found). From such point of view 0 can be a valid value.
Quoted 67 lines
Michael, would you be OK with that?
Thanks,
MarcelQuoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
First, plugging a legacy PCI device into a PCIe Root Port looks strange at least, and it can;t be done on real HW anyway. (incompatible slots)
Second (and more important), if we want 2 or more PCI devices we would loose both IO ports space and bus numbers.
Quoted 2 lines
Quoted 2 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Review
Quoted 7 lines
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/pci-bridge/pcie_root_port.c | 1 + include/hw/pci/pcie_port.h | 3 +++ 2 files changed, 4 insertions(+)(quoted diff) +0
-0
b/hw/pci-bridge/pcie_root_port.cQuoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Review
Quoted 11 lines
index 4d588cb..b0e49e1 100644
hw/pci-bridge/pcie_root_port.c +1
-0@@ -137,6 +137,7 @@ static void rp_exit(PCIDevice *d)static Property rp_props[] = {DEFINE_PROP_BIT (COMPAT_PROP_PCP , PCIDevice, cap_present,QEMU_PCIE_SLTCAP_PCP_BITNR , true), +DEFINE_PROP_UINT8 ("bus_reserve" , PCIEPort, bus_reserve,1 ),DEFINE_PROP_END_OF_LIST () };(quoted diff) +0
-0
b/include/hw/pci/pcie_port.hQuoted 30 lines
Quoted 30 lines
Quoted 30 lines
Quoted 27 lines
Quoted 27 lines
Quoted 9 lines
Quoted 9 lines
index 1333266..1b2dd1f 100644
include/hw/pci/pcie_port.h +3
-0@@ -34,6 +34,9 @@ struct PCIEPort {/* pci express switch port */ uint8_t port; + +/* additional buses to reserve on firmware init */ +uint8_t bus_reserve;Quoted 9 lines
include/hw/pci/pcie_port.h struct PCIEPort { · line 40
Quoted 2 lines
include/hw/pci/pcie_port.h +0
-0};void pcie_port_init_reg (PCIDevice *d);So here is a property and it does not do anything.
It makes it easier to work on series maybe, but review is harder since we do not see what it does at all. Please do not split up patches like this - you can maintain it split up in your branch if you like and merge before sending.Agreed, Alexandr please merge patches 4-5-6 for your next submission.
Thanks,
MarcelQuoted 2 lines
Quoted 2 lines
include/hw/pci/pcie_port.h +0
-1--2.7.4
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
--
Alexander Bezzubikov--
Alexander Bezzubikov
Re: [Qemu-devel] [RFC PATCH v2 5/6] hw/pci: add bus_reserve property to pcie-root-port
Quoted 77 lines · Alexander Bezzubikov
вт, 25 июля 2017 г. в 19:10, Marcel Apfelbaum <[email protected] <mailto:[email protected]>>:
On 25/07/2017 17:09, Alexander Bezzubikov wrote:
> 2017-07-25 16:53 GMT+03:00 Michael S. Tsirkin <[email protected]
<mailto:[email protected]>>:
>> On Tue, Jul 25, 2017 at 04:50:49PM +0300, Alexander Bezzubikov
wrote:
>>> 2017-07-25 16:43 GMT+03:00 Michael S. Tsirkin <[email protected]
<mailto:[email protected]>>:
>>>> On Sun, Jul 23, 2017 at 05:13:11PM +0300, Marcel Apfelbaum wrote:
>>>>> On 23/07/2017 15:22, Michael S. Tsirkin wrote:
>>>>>> On Sun, Jul 23, 2017 at 01:15:42AM +0300, Aleksandr
Bezzubikov wrote:
>>>>>>> To enable hotplugging of a newly created pcie-pci-bridge, >>>>>>> we need to tell firmware (SeaBIOS in this case) >>>>>>
>>>>>
>>>>> Hi Michael,
>>>>>
>>>>>> Presumably, EFI would need to support this too? >>>>>>
>>>>>
>>>>> Sure, Eduardo added to CC, but he is in PTO now. >>>>>
>>>>>>> to reserve
>>>>>>> additional buses for pcie-root-port, that allows us to >>>>>>> hotplug pcie-pci-bridge into this root port. >>>>>>> The number of buses to reserve is provided to the device
via a corresponding
>>>>>>> property, and to the firmware via new PCI capability (next
patch).
>>>>>>> The property's default value is 1 as we want to hotplug at
least 1 bridge.
>>>>>>
>>>>>> If so you should just teach firmware to allocate one bus # >>>>>> unconditionally.
>>>>>>
>>>>>
>>>>> That would be a problem for the PCIe machines, since each PCIe >>>>> devices is plugged in a different bus and we are already >>>>> limited to 256 PCIe devices. Allocating an extra-bus always >>>>> would really limit the PCIe devices we can use.
>>>>
>>>> One of the declared advantages of PCIe is easy support for
multiple roots.
>>>> We really should look at that IMHO so we do not need to pile
up hacks.
>>>>
>>>>>> But why would that be so? What's wrong with a device >>>>>> directly in the root port?
>>>>>>
>>>>
>>>> To clarify, my point is we might be wasting bus numbers by
reservation
>>>> since someone might just want to put pcie devices there. >>>
>>> I think, changing default value to 0 can help us avoid this, >>> as no bus reservation by default. If one's surely wants >>> to hotplug pcie-pci-bridge into this root port in future, >>> the property gives him such an opportunity.
>>> So, sure need pcie-pci-bridge hotplug -> creating a root port with >>>bus_reserve> 0. Otherwise (and default) - just as now, no changes >>> in bus topology.
>>
>> I guess 0 should mean "do not reserve any buses". So I think we
also
>> need a flag to just avoid the capability altogether. Maybe -1?
*That*
>> should be the default.
>
> -1 might be useful if any limit value 0 is legal, but is it? > If not, we can set every field to 0 and
> this is a sign of avoiding capability since none legal
> values are provided.
>
Quoted 8 lines
As Gerd suggested, this value is not a "delta" but the number of buses to be reserved behind the bridge. If I got it right, 0 is not a valid value, since the bridge by definition has a list one bus behind.
Gerd's suggestion was to set
min(cap_value, children_found). From such point of view 0 can be a valid value.
I am lost now :)
How can we use the capability to reserve "more" buses since children-found will be always the smaller value?
I think you should use max(cap_value, children_found) to ensure you always reserve enough buses for existing children.
In this case 0 is actually an invalid value since children_found > 0 for a bridge.
Thanks,
Marcel
Quoted 79 lines
Michael, would you be OK with that? Thanks, Marcel >> >>>> >>>>> First, plugging a legacy PCI device into a PCIe Root Port >>>>> looks strange at least, and it can;t be done on real HW anyway. >>>>> (incompatible slots) >>>>> >>>>> Second (and more important), if we want 2 or more PCI >>>>> devices we would loose both IO ports space and bus numbers. >>>>> >>>>>> >>>>>>> >>>>>>> Signed-off-by: Aleksandr Bezzubikov <[email protected] <mailto:[email protected]>> >>>>>>> --- >>>>>>> hw/pci-bridge/pcie_root_port.c | 1 + >>>>>>> include/hw/pci/pcie_port.h | 3 +++ >>>>>>> 2 files changed, 4 insertions(+) >>>>>>> >>>>>>> diff --git a/hw/pci-bridge/pcie_root_port.c b/hw/pci-bridge/pcie_root_port.c >>>>>>> index 4d588cb..b0e49e1 100644 >>>>>>> --- a/hw/pci-bridge/pcie_root_port.c >>>>>>> +++ b/hw/pci-bridge/pcie_root_port.c >>>>>>> @@ -137,6 +137,7 @@ static void rp_exit(PCIDevice *d) >>>>>>> static Property rp_props[] = { >>>>>>> DEFINE_PROP_BIT(COMPAT_PROP_PCP, PCIDevice, cap_present, >>>>>>> QEMU_PCIE_SLTCAP_PCP_BITNR, true), >>>>>>> + DEFINE_PROP_UINT8("bus_reserve", PCIEPort, bus_reserve, 1), >>>>>>> DEFINE_PROP_END_OF_LIST() >>>>>>> }; >>>>>>> diff --git a/include/hw/pci/pcie_port.h b/include/hw/pci/pcie_port.h >>>>>>> index 1333266..1b2dd1f 100644 >>>>>>> --- a/include/hw/pci/pcie_port.h >>>>>>> +++ b/include/hw/pci/pcie_port.h >>>>>>> @@ -34,6 +34,9 @@ struct PCIEPort { >>>>>>> /* pci express switch port */ >>>>>>> uint8_t port; >>>>>>> + >>>>>>> + /* additional buses to reserve on firmware init */ >>>>>>> + uint8_t bus_reserve; >>>>>>> }; >>>>>>> void pcie_port_init_reg(PCIDevice *d); >>>>>> >>>>>> So here is a property and it does not do anything. >>>>>> It makes it easier to work on series maybe, but review >>>>>> is harder since we do not see what it does at all. >>>>>> Please do not split up patches like this - you can maintain >>>>>> it split up in your branch if you like and merge before sending. >>>>>> >>>>> >>>>> Agreed, Alexandr please merge patches 4-5-6 for your next submission. >>>>> >>>>> Thanks, >>>>> Marcel >>>>> >>>>> >>>>>>> -- >>>>>>> 2.7.4 >>> >>> >>> >>> -- >>> Alexander Bezzubikov > > >Signature · 1 line
Alexander Bezzubikov
Re: [Qemu-devel] [RFC PATCH v2 5/6] hw/pci: add bus_reserve property to pcie-root-port
Hi,
Quoted 11 lines
Quoted 4 lines
Gerd's suggestion was to set
min(cap_value, children_found). From such
point of view 0 can be a valid value.I am lost now :)
How can we use the capability to reserve "more" buses since children-found will be always the smaller value?I think you should use
max(cap_value, children_found)to ensure you always reserve enough buses for existing children.
Was about to point out the same ;)
Yes, should be max(reserve-buses, child-buses-found). And reserve- buses is actually a minimum, because the result can't be smaller than reserve-buses.
cheers,
Gerd
Re: [Qemu-devel] [RFC PATCH v2 5/6] hw/pci: add bus_reserve property to pcie-root-port
In reply to Marcel ApfelbaumQuoted 67 lines · Marcel Apfelbaum
Quoted 51 lines · Alexander Bezzubikov
2017-07-25 16:53 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 50 lines · Alexander Bezzubikov
Quoted 48 lines
2017-07-25 16:43 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 33 lines · Marcel Apfelbaum
Quoted 20 lines · Michael S. Tsirkin
Quoted 4 lines · Aleksandr Bezzubikov
Quoted 2 lines
To enable hotplugging of a newly created pcie-pci-bridge, we need to tell firmware (SeaBIOS in this case)
Hi Michael,
Quoted 2 lines
Presumably, EFI would need to support this too?
Sure, Eduardo added to CC, but he is in PTO now.
Quoted 7 lines
Quoted 6 lines
to reserve
additional buses for pcie-root-port, that allows us to
hotplug pcie-pci-bridge into this root port.
The number of buses to reserve is provided to the device via a corresponding property, and to the firmware via new PCI capability (next patch). The property's default value is 1 as we want to hotplug at least 1 bridge.Quoted 8 lines
Quoted 3 lines
If so you should just teach firmware to allocate one bus # unconditionally.
That would be a problem for the PCIe machines, since each PCIe devices is plugged in a different bus and we are already limited to 256 PCIe devices. Allocating an extra-bus always would really limit the PCIe devices we can use.
One of the declared advantages of PCIe is easy support for multiple roots. We really should look at that IMHO so we do not need to pile up hacks.
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
But why would that be so? What's wrong with a device directly in the root port?
To clarify, my point is we might be wasting bus numbers by reservation since someone might just want to put pcie devices there.
I think, changing default value to 0 can help us avoid this, as no bus reservation by default. If one's surely wants to hotplug pcie-pci-bridge into this root port in future, the property gives him such an opportunity.
So, sure need pcie-pci-bridge hotplug -> creating a root port withbus_reserve> 0. Otherwise (and default) - just as now, no changes in bus topology.Quoted 9 lines
Quoted 3 lines
I guess 0 should mean "do not reserve any buses". So I think we also need a flag to just avoid the capability altogether. Maybe -1? *That* should be the default.
-1 might be useful if any limit value 0 is legal, but is it? If not, we can set every field to 0 and
this is a sign of avoiding capability since none legal values are provided.As Gerd suggested, this value is not a "delta" but the number of buses to be reserved behind the bridge. If I got it right, 0 is not a valid value, since the bridge by definition has a list one bus behind.
Quoted 4 lines
Michael, would you be OK with that?
Thanks,
Marcel
IMHO we want an encoding that works for IO and memory too.
Quoted 64 lines
Quoted 64 lines
Quoted 61 lines
Quoted 61 lines
Quoted 48 lines
Quoted 48 lines
First, plugging a legacy PCI device into a PCIe Root Port looks strange at least, and it can;t be done on real HW anyway. (incompatible slots)
Second (and more important), if we want 2 or more PCI devices we would loose both IO ports space and bus numbers.
Quoted 38 lines
Quoted 24 lines
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/pci-bridge/pcie_root_port.c | 1 + include/hw/pci/pcie_port.h | 3 +++ 2 files changed, 4 insertions(+)hw/pci-bridge/pcie_root_port.c +1
-0@@ -137,6 +137,7 @@ static void rp_exit(PCIDevice *d)static Property rp_props[] = {DEFINE_PROP_BIT (COMPAT_PROP_PCP , PCIDevice, cap_present,QEMU_PCIE_SLTCAP_PCP_BITNR , true), +DEFINE_PROP_UINT8 ("bus_reserve" , PCIEPort, bus_reserve,1 ),DEFINE_PROP_END_OF_LIST () };include/hw/pci/pcie_port.h +0
-0include/hw/pci/pcie_port.h struct PCIEPort { · line 40
Quoted 7 lines
include/hw/pci/pcie_port.h +3
-0@@ -34,6 +34,9 @@ struct PCIEPort {/* pci express switch port */ uint8_t port; + +/* additional buses to reserve on firmware init */ +uint8_t bus_reserve; };void pcie_port_init_reg (PCIDevice *d);So here is a property and it does not do anything.
It makes it easier to work on series maybe, but review is harder since we do not see what it does at all. Please do not split up patches like this - you can maintain it split up in your branch if you like and merge before sending.Quoted 8 lines
Quoted 8 lines
Agreed, Alexandr please merge patches 4-5-6 for your next submission.
Thanks,
MarcelQuoted 2 lines
Quoted 2 lines
include/hw/pci/pcie_port.h +0
-1--2.7.4
--
Alexander Bezzubikov
RFC PATCH v2 6/6 hw/pci: add hint capabilty for additional bus reservation to pcie-root-port
In reply to Aleksandr Bezzubikov--- hw/pci-bridge/pcie_root_port.c | 5 +++++ 1 file changed, 5 insertions(+)
hw/pci-bridge/pcie_root_port.c +5 -0
@@ -106,6 +106,11 @@ static void rp_realize(PCIDevice *d, Error **errp)pcie_aer_root_init (d);rp_aer_vector_update (d); + rc =pci_bridge_help_cap_init (d,0 , p->bus_reserve,0 ,0 ,0 , errp); +if (rc <0 ) { + goto err; + } +return ; err:
Signature · 1 line
2.7.4
Re: [Qemu-devel] [RFC PATCH v2 6/6] hw/pci: add hint capabilty for additional bus reservation to pcie-root-port
Quoted 11 lines · Aleksandr Bezzubikov
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/pci-bridge/pcie_root_port.c | 5 +++++ 1 file changed, 5 insertions(+)hw/pci-bridge/pcie_root_port.c +0
-0@@ -106,6 +106,11 @@ static void rp_realize(PCIDevice *d, Error **errp)pcie_aer_root_init (d);
hw/pci-bridge/pcie_root_port.c static void rp_realize(PCIDevice *d, Error **errp) · line 116
Quoted 10 lines
hw/pci-bridge/pcie_root_port.c +5
-0rp_aer_vector_update (d); + rc =pci_bridge_help_cap_init (d,0 , p->bus_reserve,0 ,0 ,0 , errp); +if (rc <0 ) { + goto err; + } +return ; err:
It looks like this will add the capability unconditionally to all pcie root ports. Two issues with it:
1. you can't add vendor properties to devices where vendor is not qemu as they might have their own concept of what it does.
2. this will break compatibility with old machine types, need to disable for these
Quoted 2 lines
Signature · 1 line
2.7.4
Re: [Qemu-devel] [RFC PATCH v2 6/6] hw/pci: add hint capabilty for additional bus reservation to pcie-root-port
2017-07-24 23:43 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 21 lines · Aleksandr Bezzubikov
Quoted 20 lines
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/pci-bridge/pcie_root_port.c | 5 +++++ 1 file changed, 5 insertions(+)hw/pci-bridge/pcie_root_port.c +5
-0@@ -106,6 +106,11 @@ static void rp_realize(PCIDevice *d, Error **errp)pcie_aer_root_init (d);rp_aer_vector_update (d); + rc =pci_bridge_help_cap_init (d,0 , p->bus_reserve,0 ,0 ,0 , errp); +if (rc <0 ) { + goto err; + } +return ;
Quoted 9 lines
hw/pci-bridge/pcie_root_port.c static void rp_realize(PCIDevice *d, Error **errp) · line 116
Quoted 1 line
hw/pci-bridge/pcie_root_port.c +0
-0err:It looks like this will add the capability unconditionally to all pcie root ports. Two issues with it:
1. you can't add vendor properties to devices where vendor is not qemu as they might have their own concept of what it does.
2. this will break compatibility with old machine types, need to disable for these
Actually the original idea was to add it for pcie-root-port excusively (for now at least), looks like I've confused a little with files naming. Will add it for v3.
Quoted 2 lines
Quoted 2 lines
--
2.7.4
Signature · 1 line
Alexander Bezzubikov
Re: [Qemu-devel] [RFC PATCH v2 6/6] hw/pci: add hint capabilty for additional bus reservation to pcie-root-port
Quoted 32 lines · Alexander Bezzubikov
2017-07-24 23:43 GMT+03:00 Michael S. Tsirkin <[email protected]>:
Quoted 21 lines · Aleksandr Bezzubikov
Quoted 20 lines
Signed-off-by Aleksandr Bezzubikov <[email protected]>--- hw/pci-bridge/pcie_root_port.c | 5 +++++ 1 file changed, 5 insertions(+)hw/pci-bridge/pcie_root_port.c +5
-0@@ -106,6 +106,11 @@ static void rp_realize(PCIDevice *d, Error **errp)pcie_aer_root_init (d);rp_aer_vector_update (d); + rc =pci_bridge_help_cap_init (d,0 , p->bus_reserve,0 ,0 ,0 , errp); +if (rc <0 ) { + goto err; + } +return ;Quoted 9 lines
hw/pci-bridge/pcie_root_port.c static void rp_realize(PCIDevice *d, Error **errp) · line 116
Quoted 1 line
hw/pci-bridge/pcie_root_port.c +0
-0err:It looks like this will add the capability unconditionally to all pcie root ports. Two issues with it:
1. you can't add vendor properties to devices where vendor is not qemu as they might have their own concept of what it does.
2. this will break compatibility with old machine types, need to disable for these
Quoted 2 lines
Actually the original idea was to add it for pcie-root-port excusively (for now at least), looks like I've confused a little with files naming.
Right, for the Generic PCIe Root Port and not for all the root ports. In the future we may want to add it to the PCI-brigde so we can have nested bridges, but we are not there yet.
Quoted 2 lines
Will add it for v3.
Thanks,
Marcel
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
--
2.7.4