pci/pcie: implement ARI enable bit correctly
v2 cover pci/pcie: implement ARI enable bit correctly
Changes v1 -> v2:
- dropped PCI_DEVFN_MAX
- use uint8_t for devfn instead of int
- move pcie_check_slot into pci.h and made it static inline
- minor clean ups
Isaku Yamahata (5):
pci: replace the magic, 256, for the maximum of devfn
pci: use devfn for pci_find_device() instead of (slot, fn) pair pci/pcie: make pci_find_device() ARI aware.
pci: use PCI_SLOT in pci_get_bus_devfn()
pci: use uint8_t for devfn_min
hw/pci-hotplug.c | 5 +++-- hw/pci.c | 18 ++++++++++++------ hw/pci.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++---- hw/pci_host.c | 2 +- hw/pci_internals.h | 4 ++-- hw/pcie.c | 13 ------------- hw/pcie.h | 1 - hw/pcie_host.c | 3 +-- 8 files changed, 66 insertions(+), 31 deletions(-)
PATCH v2 1/5 pci: replace the magic, 256, for the maximum of devfn
Introduce symbol PCI_DEVFN_MAX for the maximum of devfn and replace the magic, 256.
--- hw/pci.h | 1 + hw/pci_internals.h | 2 +- 2 files changed, 2 insertions(+), 1 deletions(-)
hw/pci.h +1 -0
@@ -16,6 +16,7 @@#define PCI_DEVFN (slot, func) ((((slot) & 0x1f) << 3) | ((func) & 0x07))#define PCI_SLOT (devfn) (((devfn) >> 3) & 0x1f)#define PCI_FUNC (devfn) ((devfn) & 0x07) +#define PCI_SLOT_MAX 32#define PCI_FUNC_MAX 8/* Class, Vendor and Device IDs from Linux's pci_ids.h */
hw/pci_internals.h +1 -1
@@ -22,7 +22,7 @@ struct PCIBus {pci_hotplug_fn hotplug;DeviceState *hotplug_qdev;void *irq_opaque; -PCIDevice *devices[256 ]; +PCIDevice *devices[PCI_SLOT_MAX *PCI_FUNC_MAX ];PCIDevice *parent_dev;target_phys_addr_t mem_base;
Signature · 1 line
1.7.1.1
Michael S. Tsirkin
Applied[Qemu-devel] Re: [PATCH v2 1/5] pci: replace the magic, 256, for the maximum of devfn
Quoted 4 lines · Isaku Yamahata
Introduce symbol
PCI_DEVFN_MAXfor the maximum of devfn and replace the magic, 256.Signed-off-by Isaku Yamahata <[email protected]>
Applied, tweaked the comment.
Quoted 32 lines
--- hw/pci.h | 1 + hw/pci_internals.h | 2 +- 2 files changed, 2 insertions(+), 1 deletions(-)hw/pci.h +1
-0@@ -16,6 +16,7 @@#define PCI_DEVFN (slot, func) ((((slot) & 0x1f) << 3) | ((func) & 0x07))#define PCI_SLOT (devfn) (((devfn) >> 3) & 0x1f)#define PCI_FUNC (devfn) ((devfn) & 0x07) +#define PCI_SLOT_MAX 32#define PCI_FUNC_MAX 8/* Class, Vendor and Device IDs from Linux's pci_ids.h */ hw/pci_internals.h +1
-1@@ -22,7 +22,7 @@ struct PCIBus {pci_hotplug_fn hotplug;DeviceState *hotplug_qdev;void *irq_opaque; -PCIDevice *devices[256 ]; +PCIDevice *devices[PCI_SLOT_MAX *PCI_FUNC_MAX ];PCIDevice *parent_dev;target_phys_addr_t mem_base;Signature · 1 line
1.7.1.1
PATCH v2 2/5 pci: use devfn for pci_find_device() instead of (slot, fn) pair
In reply to Isaku Yamahata(slot, fn) pair is somewhat confusing because of ARI. So use devfn for pci_find_device() instead of (slot, fn).
--- hw/pci-hotplug.c | 5 +++-- hw/pci.c | 4 ++-- hw/pci.h | 2 +- hw/pci_host.c | 2 +- hw/pcie_host.c | 3 +-- 5 files changed, 8 insertions(+), 8 deletions(-)
hw/pci-hotplug.c +3 -2
@@ -126,7 +126,8 @@ void drive_hot_add(Monitor *mon, const QDict *qdict)if (pci_read_devaddr (mon, pci_addr, &dom, &pci_bus, &slot)) { goto err; } - dev =pci_find_device (pci_find_root_bus (dom), pci_bus, slot,0 ); + dev =pci_find_device (pci_find_root_bus (dom), pci_bus, +PCI_DEVFN (slot,0 ));if (!dev) {monitor_printf (mon,"no pci device with address %s\n" , pci_addr); goto err;
@@ -276,7 +277,7 @@ static int pci_device_hot_remove(Monitor *mon, const char *pci_addr)return -1 ; } - d =pci_find_device (pci_find_root_bus (dom), bus, slot,0 ); + d =pci_find_device (pci_find_root_bus (dom), bus,PCI_DEVFN (slot,0 ));if (!d) {monitor_printf (mon,"slot %d empty\n" , slot);return -1 ;
hw/pci.c +2 -2
@@ -1602,14 +1602,14 @@ PCIBus *pci_find_bus(PCIBus *bus, int bus_num)return NULL ; } -PCIDevice *pci_find_device (PCIBus *bus,int bus_num,int slot,int function) +PCIDevice *pci_find_device (PCIBus *bus,int bus_num,uint8_t devfn) { bus =pci_find_bus (bus, bus_num);if (!bus)return NULL ; -return bus->devices[PCI_DEVFN (slot, function)]; +return bus->devices[devfn]; }static int pci_qdev_init (DeviceState *qdev,DeviceInfo *base)
hw/pci.h +1 -1
@@ -252,7 +252,7 @@ void pci_for_each_device(PCIBus *bus, int bus_num, void (*fn)(PCIBus *bus, PCIDePCIBus *pci_find_root_bus (int domain);int pci_find_domain (const PCIBus *bus);PCIBus *pci_find_bus (PCIBus *bus,int bus_num); -PCIDevice *pci_find_device (PCIBus *bus,int bus_num,int slot,int function); +PCIDevice *pci_find_device (PCIBus *bus,int bus_num,uint8_t devfn);int pci_qdev_find_device (const char *id,PCIDevice **pdev);PCIBus *pci_get_bus_devfn (int *devfnp,const char *devaddr);
hw/pci_host.c +1 -1
@@ -44,7 +44,7 @@ static inline PCIDevice *pci_dev_find_by_addr(PCIBus *bus, uint32_t addr)uint8_t bus_num = addr >>16 ;uint8_t devfn = addr >>8 ; -return pci_find_device (bus, bus_num,PCI_SLOT (devfn),PCI_FUNC (devfn)); +return pci_find_device (bus, bus_num, devfn); }void pci_data_write (PCIBus *s,uint32_t addr,uint32_t val,int len)
hw/pcie_host.c +1 -2
@@ -49,8 +49,7 @@ static inline PCIDevice *pcie_dev_find_by_mmcfg_addr(PCIBus *s, uint32_t mmcfg_addr) {return pci_find_device (s,PCIE_MMCFG_BUS (mmcfg_addr), -PCI_SLOT (PCIE_MMCFG_DEVFN (mmcfg_addr)), -PCI_FUNC (PCIE_MMCFG_DEVFN (mmcfg_addr))); +PCIE_MMCFG_DEVFN (mmcfg_addr)); } static void pcie_mmcfg_data_write(PCIBus *s,
Signature · 1 line
1.7.1.1
Michael S. Tsirkin
Applied[Qemu-devel] Re: [PATCH v2 2/5] pci: use devfn for pci_find_device() instead of (slot, fn) pair
Quoted 4 lines · Isaku Yamahata
(slot, fn) pair is somewhat confusing because of ARI. So use devfn for
pci_find_device()instead of (slot, fn).Signed-off-by Isaku Yamahata <[email protected]>
Applied, thanks.
Quoted 94 lines
--- hw/pci-hotplug.c | 5 +++-- hw/pci.c | 4 ++-- hw/pci.h | 2 +- hw/pci_host.c | 2 +- hw/pcie_host.c | 3 +-- 5 files changed, 8 insertions(+), 8 deletions(-)hw/pci-hotplug.c +3
-2@@ -126,7 +126,8 @@ void drive_hot_add(Monitor *mon, const QDict *qdict)if (pci_read_devaddr (mon, pci_addr, &dom, &pci_bus, &slot)) { goto err; } - dev =pci_find_device (pci_find_root_bus (dom), pci_bus, slot,0 ); + dev =pci_find_device (pci_find_root_bus (dom), pci_bus, +PCI_DEVFN (slot,0 ));if (!dev) {monitor_printf (mon,"no pci device with address %s\n" , pci_addr); goto err;@@ -276,7 +277,7 @@ static int pci_device_hot_remove(Monitor *mon, const char *pci_addr)return -1 ; } - d =pci_find_device (pci_find_root_bus (dom), bus, slot,0 ); + d =pci_find_device (pci_find_root_bus (dom), bus,PCI_DEVFN (slot,0 ));if (!d) {monitor_printf (mon,"slot %d empty\n" , slot);return -1 ;hw/pci.c +2
-2@@ -1602,14 +1602,14 @@ PCIBus *pci_find_bus(PCIBus *bus, int bus_num)return NULL ; } -PCIDevice *pci_find_device (PCIBus *bus,int bus_num,int slot,int function) +PCIDevice *pci_find_device (PCIBus *bus,int bus_num,uint8_t devfn) { bus =pci_find_bus (bus, bus_num);if (!bus)return NULL ; -return bus->devices[PCI_DEVFN (slot, function)]; +return bus->devices[devfn]; }static int pci_qdev_init (DeviceState *qdev,DeviceInfo *base)hw/pci.h +1
-1@@ -252,7 +252,7 @@ void pci_for_each_device(PCIBus *bus, int bus_num, void (*fn)(PCIBus *bus, PCIDePCIBus *pci_find_root_bus (int domain);int pci_find_domain (const PCIBus *bus);PCIBus *pci_find_bus (PCIBus *bus,int bus_num); -PCIDevice *pci_find_device (PCIBus *bus,int bus_num,int slot,int function); +PCIDevice *pci_find_device (PCIBus *bus,int bus_num,uint8_t devfn);int pci_qdev_find_device (const char *id,PCIDevice **pdev);PCIBus *pci_get_bus_devfn (int *devfnp,const char *devaddr);hw/pci_host.c +1
-1@@ -44,7 +44,7 @@ static inline PCIDevice *pci_dev_find_by_addr(PCIBus *bus, uint32_t addr)uint8_t bus_num = addr >>16 ;uint8_t devfn = addr >>8 ; -return pci_find_device (bus, bus_num,PCI_SLOT (devfn),PCI_FUNC (devfn)); +return pci_find_device (bus, bus_num, devfn); }void pci_data_write (PCIBus *s,uint32_t addr,uint32_t val,int len)hw/pcie_host.c +1
-2@@ -49,8 +49,7 @@ static inline PCIDevice *pcie_dev_find_by_mmcfg_addr(PCIBus *s, uint32_t mmcfg_addr) {return pci_find_device (s,PCIE_MMCFG_BUS (mmcfg_addr), -PCI_SLOT (PCIE_MMCFG_DEVFN (mmcfg_addr)), -PCI_FUNC (PCIE_MMCFG_DEVFN (mmcfg_addr))); +PCIE_MMCFG_DEVFN (mmcfg_addr)); } static void pcie_mmcfg_data_write(PCIBus *s,Signature · 1 line
1.7.1.1
PATCH v2 3/5 pci/pcie: make pci_find_device() ARI aware.
In reply to Isaku Yamahatamake pci_find_device() ARI aware.
--- hw/pci.c | 6 ++++++ hw/pci.h | 42 ++++++++++++++++++++++++++++++++++++++++++ hw/pcie.c | 13 ------------- hw/pcie.h | 1 - 4 files changed, 48 insertions(+), 14 deletions(-)
hw/pci.c +6 -0
@@ -1604,11 +1604,17 @@ PCIBus *pci_find_bus(PCIBus *bus, int bus_num)PCIDevice *pci_find_device (PCIBus *bus,int bus_num,uint8_t devfn) { +PCIDevice *d; bus =pci_find_bus (bus, bus_num);if (!bus)return NULL ; + d = bus->parent_dev; +/* ARI: See the comment above the pcie_check_slot() for details */ +if (d && !pcie_check_slot (d, devfn)) { +return NULL ; + }return bus->devices[devfn]; }
hw/pci.h +42 -0
46 lines not on this page · raw message
hw/pcie.c +0 -13
@@ -424,19 +424,6 @@ void pcie_cap_ari_reset(PCIDevice *dev)pci_long_test_and_clear_mask (devctl2,PCI_EXP_DEVCTL2_ARI ); } -bool pcie_cap_is_ari_enabled (const PCIDevice *dev) -{ -if (!pci_is_express (dev)) { -return false; - } -if (!dev->exp.exp_cap) { -return false; - } - -return pci_get_long (dev->config + dev->exp.exp_cap +PCI_EXP_DEVCTL2 ) & -PCI_EXP_DEVCTL2_ARI ; -} -/************************************************************************** * pci express extended capability allocation functions * uint16_t ext_cap_id (16 bit)
hw/pcie.h +0 -1
@@ -119,7 +119,6 @@ void pcie_cap_flr_write_config(PCIDevice *dev,void pcie_cap_ari_init (PCIDevice *dev);void pcie_cap_ari_reset (PCIDevice *dev); -bool pcie_cap_is_ari_enabled (const PCIDevice *dev);/* PCI express extended capability helper functions */ uint16_t pcie_find_capability (PCIDevice *dev,uint16_t cap_id);
Signature · 1 line
1.7.1.1
[Qemu-devel] Re: [PATCH v2 3/5] pci/pcie: make pci_find_device() ARI aware.
Quoted 3 lines · Isaku Yamahata
make
pci_find_device()ARI aware.Signed-off-by Isaku Yamahata <[email protected]>
I moved the function to pci.c and renamed it to pci_devfn_enabled (it does not deal with the slot anymore).
Quoted 118 lines
--- hw/pci.c | 6 ++++++ hw/pci.h | 42 ++++++++++++++++++++++++++++++++++++++++++ hw/pcie.c | 13 ------------- hw/pcie.h | 1 - 4 files changed, 48 insertions(+), 14 deletions(-)hw/pci.c +6
-0@@ -1604,11 +1604,17 @@ PCIBus *pci_find_bus(PCIBus *bus, int bus_num)PCIDevice *pci_find_device (PCIBus *bus,int bus_num,uint8_t devfn) { +PCIDevice *d; bus =pci_find_bus (bus, bus_num);if (!bus)return NULL ; + d = bus->parent_dev; +/* ARI: See the comment above the pcie_check_slot() for details */ +if (d && !pcie_check_slot (d, devfn)) { +return NULL ; + }return bus->devices[devfn]; }hw/pci.h +42
-0@@ -467,4 +467,46 @@ static inline uint32_t pci_config_size(const PCIDevice *d) return pci_is_express(d) ? PCIE_CONFIG_SPACE_SIZE : PCI_CONFIG_SPACE_SIZE; } +/* +* Although this function should be in pcie.h ideally, +* it is here because pci.h depends on pcie.h and this function depdnds +* on pci.h +* +* 6.13 Alternative routing-ID Interpretation(ARI) +* 7.8.16 Device control 2 register +* ARI forwarding Enable +* +* With PCI Express Endpoints, there's a single device behind +* each downstream port bus, and bits 3:7 of the function number get +* encoded in the slot number (the Express spec calls it the Device +* Number). This allows > 8 functions, but +* these extended functions are only accessible when the +* Alternative routing-ID Interpretation (ARI) +* capability is enabled in the root/downstream port. With that capability +* disabled the port enforces the Device Number field being 0. +*/ +static inline bool pcie_check_slot (const PCIDevice *dev,uint8_t devfn) +{ +uint8_t type; + +if (!pci_is_express (dev)) { +return true; + } + + type =pcie_cap_get_type (dev); +if (!(type ==PCI_EXP_TYPE_ROOT_PORT || + type ==PCI_EXP_TYPE_DOWNSTREAM )) { +return true; + } + +if (!PCI_SLOT (devfn)) { +/* With ARI, this means function < 8. +functions < 8 are always accesible. */ +return true; + } + +return pci_get_long (dev->config + dev->exp.exp_cap +PCI_EXP_DEVCTL2 ) & +PCI_EXP_DEVCTL2_ARI ; +} +#endif hw/pcie.c +0
-13@@ -424,19 +424,6 @@ void pcie_cap_ari_reset(PCIDevice *dev)pci_long_test_and_clear_mask (devctl2,PCI_EXP_DEVCTL2_ARI ); } -bool pcie_cap_is_ari_enabled (const PCIDevice *dev) -{ -if (!pci_is_express (dev)) { -return false; - } -if (!dev->exp.exp_cap) { -return false; - } - -return pci_get_long (dev->config + dev->exp.exp_cap +PCI_EXP_DEVCTL2 ) & -PCI_EXP_DEVCTL2_ARI ; -} -/************************************************************************** * pci express extended capability allocation functions * uint16_t ext_cap_id (16 bit) hw/pcie.h +0
-1@@ -119,7 +119,6 @@ void pcie_cap_flr_write_config(PCIDevice *dev,void pcie_cap_ari_init (PCIDevice *dev);void pcie_cap_ari_reset (PCIDevice *dev); -bool pcie_cap_is_ari_enabled (const PCIDevice *dev);/* PCI express extended capability helper functions */ uint16_t pcie_find_capability (PCIDevice *dev,uint16_t cap_id);Signature · 1 line
1.7.1.1
PATCH v2 4/5 pci: use PCI_SLOT in pci_get_bus_devfn()
In reply to Isaku Yamahatause PCI_SLOT in pci_get_bus_devfn().
--- hw/pci.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
hw/pci.c +1 -1
@@ -558,7 +558,7 @@ PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr)return NULL ; } - *devfnp = slot <<3 ; + *devfnp =PCI_DEVFN (slot,0 );return pci_find_bus (pci_find_root_bus (dom), bus); }
Signature · 1 line
1.7.1.1
[Qemu-devel] Re: [PATCH v2 4/5] pci: use PCI_SLOT in pci_get_bus_devfn()
Quoted 3 lines · Isaku Yamahata
use
PCI_SLOTinpci_get_bus_devfn().Signed-off-by Isaku Yamahata <[email protected]>
Tweaked the comment and applied.
Quoted 19 lines
--- hw/pci.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)hw/pci.c +1
-1@@ -558,7 +558,7 @@ PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr)return NULL ; } - *devfnp = slot <<3 ; + *devfnp =PCI_DEVFN (slot,0 );return pci_find_bus (pci_find_root_bus (dom), bus); }Signature · 1 line
1.7.1.1
PATCH v2 5/5 pci: use uint8_t for devfn_min
In reply to Isaku Yamahatause uint8_t for devfn_min instead of int.
--- hw/pci.c | 6 +++--- hw/pci.h | 6 +++--- hw/pci_internals.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-)
hw/pci.c +3 -3
@@ -256,7 +256,7 @@ int pci_find_domain(const PCIBus *bus) }void pci_bus_new_inplace (PCIBus *bus,DeviceState *parent, -const char *name,int devfn_min) +const char *name,uint8_t devfn_min) {qbus_create_inplace (&bus->qbus, &pci_bus_info, parent, name);assert (PCI_FUNC (devfn_min) ==0 );
@@ -269,7 +269,7 @@ void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent,vmstate_register (NULL ,-1 , &vmstate_pcibus, bus); } -PCIBus *pci_bus_new (DeviceState *parent,const char *name,int devfn_min) +PCIBus *pci_bus_new (DeviceState *parent,const char *name,uint8_t devfn_min) {PCIBus *bus;
@@ -303,7 +303,7 @@ void pci_bus_set_mem_base(PCIBus *bus, target_phys_addr_t base)PCIBus *pci_register_bus (DeviceState *parent,const char *name,pci_set_irq_fn set_irq,pci_map_irq_fn map_irq, -void *irq_opaque,int devfn_min,int nirq) +void *irq_opaque,uint8_t devfn_min,int nirq) {PCIBus *bus;
hw/pci.h +3 -3
@@ -230,14 +230,14 @@ typedef enum {typedef int (*pci_hotplug_fn )(DeviceState *qdev,PCIDevice *pci_dev,PCIHotplugState state);void pci_bus_new_inplace (PCIBus *bus,DeviceState *parent, -const char *name,int devfn_min); -PCIBus *pci_bus_new (DeviceState *parent,const char *name,int devfn_min); +const char *name,uint8_t devfn_min); +PCIBus *pci_bus_new (DeviceState *parent,const char *name,uint8_t devfn_min);void pci_bus_irqs (PCIBus *bus,pci_set_irq_fn set_irq,pci_map_irq_fn map_irq,void *irq_opaque,int nirq);void pci_bus_hotplug (PCIBus *bus,pci_hotplug_fn hotplug,DeviceState *dev);PCIBus *pci_register_bus (DeviceState *parent,const char *name,pci_set_irq_fn set_irq,pci_map_irq_fn map_irq, -void *irq_opaque,int devfn_min,int nirq); +void *irq_opaque,uint8_t devfn_min,int nirq);void pci_device_reset (PCIDevice *dev);void pci_bus_reset (PCIBus *bus);
hw/pci_internals.h +1 -1
@@ -16,7 +16,7 @@ extern struct BusInfo pci_bus_info;struct PCIBus {BusState qbus; -int devfn_min; +uint8_t devfn_min;pci_set_irq_fn set_irq;pci_map_irq_fn map_irq;pci_hotplug_fn hotplug;
Signature · 1 line
1.7.1.1
Michael S. Tsirkin
Applied[Qemu-devel] Re: [PATCH v2 5/5] pci: use uint8_t for devfn_min
Quoted 3 lines · Isaku Yamahata
use
uint8_tfordevfn_mininstead of int.Signed-off-by Isaku Yamahata <[email protected]>
Applied, thanks.
Quoted 74 lines
--- hw/pci.c | 6 +++--- hw/pci.h | 6 +++--- hw/pci_internals.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-)hw/pci.c +3
-3@@ -256,7 +256,7 @@ int pci_find_domain(const PCIBus *bus) }void pci_bus_new_inplace (PCIBus *bus,DeviceState *parent, -const char *name,int devfn_min) +const char *name,uint8_t devfn_min) {qbus_create_inplace (&bus->qbus, &pci_bus_info, parent, name);assert (PCI_FUNC (devfn_min) ==0 );@@ -269,7 +269,7 @@ void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent,vmstate_register (NULL ,-1 , &vmstate_pcibus, bus); } -PCIBus *pci_bus_new (DeviceState *parent,const char *name,int devfn_min) +PCIBus *pci_bus_new (DeviceState *parent,const char *name,uint8_t devfn_min) {PCIBus *bus;@@ -303,7 +303,7 @@ void pci_bus_set_mem_base(PCIBus *bus, target_phys_addr_t base)PCIBus *pci_register_bus (DeviceState *parent,const char *name,pci_set_irq_fn set_irq,pci_map_irq_fn map_irq, -void *irq_opaque,int devfn_min,int nirq) +void *irq_opaque,uint8_t devfn_min,int nirq) {PCIBus *bus;hw/pci.h +3
-3@@ -230,14 +230,14 @@ typedef enum {typedef int (*pci_hotplug_fn )(DeviceState *qdev,PCIDevice *pci_dev,PCIHotplugState state);void pci_bus_new_inplace (PCIBus *bus,DeviceState *parent, -const char *name,int devfn_min); -PCIBus *pci_bus_new (DeviceState *parent,const char *name,int devfn_min); +const char *name,uint8_t devfn_min); +PCIBus *pci_bus_new (DeviceState *parent,const char *name,uint8_t devfn_min);void pci_bus_irqs (PCIBus *bus,pci_set_irq_fn set_irq,pci_map_irq_fn map_irq,void *irq_opaque,int nirq);void pci_bus_hotplug (PCIBus *bus,pci_hotplug_fn hotplug,DeviceState *dev);PCIBus *pci_register_bus (DeviceState *parent,const char *name,pci_set_irq_fn set_irq,pci_map_irq_fn map_irq, -void *irq_opaque,int devfn_min,int nirq); +void *irq_opaque,uint8_t devfn_min,int nirq);void pci_device_reset (PCIDevice *dev);void pci_bus_reset (PCIBus *bus);hw/pci_internals.h +1
-1@@ -16,7 +16,7 @@ extern struct BusInfo pci_bus_info;struct PCIBus {BusState qbus; -int devfn_min; +uint8_t devfn_min;pci_set_irq_fn set_irq;pci_map_irq_fn map_irq;pci_hotplug_fn hotplug;Signature · 1 line
1.7.1.1
Quoted 5 lines · Isaku Yamahata
Changes v1 -> v2:
- droppedPCI_DEVFN_MAX
- useuint8_tfor devfn instead of int
- movepcie_check_slotintopci.hand made it static inline
- minor clean ups
So I put this on the pci branch but
we need to at least consider the following:
- command line/monitor/qmp: do we need to tweak it to force slot 0? Or just declare that slot >= 1 should be used to support insane # of functions?
- management needs to learn about ARI anyway, so
maybe a clean change is better?
- multifunction: need to detect and support ARI:
see pci_init_multifunction.
- And, we still did not implement the idea
where parent id for the device is specified.
So while I don't think these patches make anything worse, I think I'll give these a bit of time to stew on my branch so we can hopefully see a bit more of the full picture.
Quoted 16 lines
Isaku Yamahata (5):
pci: replace the magic, 256, for the maximum of devfn
pci: use devfn forpci_find_device()instead of (slot, fn) pair pci/pcie: makepci_find_device()ARI aware.
pci: usePCI_SLOTinpci_get_bus_devfn()
pci: useuint8_tfordevfn_minhw/pci-hotplug.c | 5 +++-- hw/pci.c | 18 ++++++++++++------ hw/pci.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++---- hw/pci_host.c | 2 +- hw/pci_internals.h | 4 ++-- hw/pcie.c | 13 ------------- hw/pcie.h | 1 - hw/pcie_host.c | 3 +-- 8 files changed, 66 insertions(+), 31 deletions(-)
Quoted 8 lines · Michael S. Tsirkin
Quoted 5 lines · Isaku Yamahata
Changes v1 -> v2:
- droppedPCI_DEVFN_MAX
- useuint8_tfor devfn instead of int
- movepcie_check_slotintopci.hand made it static inline
- minor clean upsSo I put this on the pci branch but
Thank you.
Quoted 1 line
we need to at least consider the following:
Yes, there are several issues to consider.
What I have in mind at the moment for the first step is to directly assign a physical pcie ARI device to a guest as a while.
Quoted 3 lines
- command line/monitor/qmp: do we need to tweak it to force slot 0? Or just declare that slot >= 1 should be used to support insane # of functions?
So far I've thought of slot >= 1 way.
But I'm not sure it's good or not. Anyway we will see.
Quoted 6 lines
- management needs to learn about ARI anyway, so
maybe a clean change is better?
- multifunction: need to detect and support ARI:
seepci_init_multifunction.
- And, we still did not implement the idea
where parent id for the device is specified.
Parent id is definitely necessary for pcie hot plug too.
thanks,
Quoted 22 lines
So while I don't think these patches make anything worse, I think I'll give these a bit of time to stew on my branch so we can hopefully see a bit more of the full picture.
Quoted 16 lines
Isaku Yamahata (5):
pci: replace the magic, 256, for the maximum of devfn
pci: use devfn forpci_find_device()instead of (slot, fn) pair pci/pcie: makepci_find_device()ARI aware.
pci: usePCI_SLOTinpci_get_bus_devfn()
pci: useuint8_tfordevfn_minhw/pci-hotplug.c | 5 +++-- hw/pci.c | 18 ++++++++++++------ hw/pci.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++---- hw/pci_host.c | 2 +- hw/pci_internals.h | 4 ++-- hw/pcie.c | 13 ------------- hw/pcie.h | 1 - hw/pcie_host.c | 3 +-- 8 files changed, 66 insertions(+), 31 deletions(-)
Signature · 1 line
yamahata