vDPA/ifcvf: implement shared IRQ feature
Subsystems (5)
v3 cover vDPA/ifcvf: implement shared IRQ feature
It has been observed that on some platforms/devices, there may not be enough MSI vectors for virtqueues and the config change. Under such circumstances, the interrupt sources of a device have to share vectors/IRQs.
This series implemented a shared IRQ feature for ifcvf.
Please help review.
Changes from V2:
(1) Fix misuse of nvectors(in ifcvf_alloc_vectors return value)(Michael)
(2) Fix misuse of irq = get_vq_irq() in setup irqbypass(Michael)
(3) Coding style improvements(Michael)
(4) Better naming of device shared irq/shared vq irq
Changes from V1:
(1) Enable config interrupt when only one vector is allocated(Michael)
(2) Clean vectors/IRQs if failed to request config interrupt since config interrupt is a must(Michael)
(3) Keep local vdpa_ops, disable irq_bypass by setting IRQ = -EINVAL for shared IRQ case(Michael)
(4) Improvements on error messages(Michael)
(5) Squash functions implementation patches to the callers(Michael)
Zhu Lingshan (4):
vDPA/ifcvf: implement IO read/write helpers in the header file vDPA/ifcvf: implement device MSIX vector allocator
vhost_vdpa: don't setup irq offloading when irq_num < 0 vDPA/ifcvf: implement shared IRQ feature
drivers/vdpa/ifcvf/ifcvf_base.c | 67 +++----- drivers/vdpa/ifcvf/ifcvf_base.h | 60 +++++++- drivers/vdpa/ifcvf/ifcvf_main.c | 260 ++++++++++++++++++++++++++++---- drivers/vhost/vdpa.c | 4 + 4 files changed, 312 insertions(+), 79 deletions(-)
Signature · 1 line
2.27.0
PATCH v3 1/4 vDPA/ifcvf: implement IO read/write helpers in the header file
re-implement IO read/write helpers in the header file, so that they can be utilized among modules.
--- drivers/vdpa/ifcvf/ifcvf_base.c | 36 -------------------------------- drivers/vdpa/ifcvf/ifcvf_base.h | 37 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 36 deletions(-)
drivers/vdpa/ifcvf/ifcvf_base.c +0 -36
@@ -10,42 +10,6 @@#include "ifcvf_base.h" -static inline u8 ifc_ioread8 (u8 __iomem *addr) -{ -return ioread8 (addr); -} -static inline u16 ifc_ioread16 (__le16 __iomem *addr) -{ -return ioread16 (addr); -} - -static inline u32 ifc_ioread32 (__le32 __iomem *addr) -{ -return ioread32 (addr); -} - -static inline void ifc_iowrite8 (u8 value,u8 __iomem *addr) -{ -iowrite8 (value, addr); -} - -static inline void ifc_iowrite16 (u16 value,__le16 __iomem *addr) -{ -iowrite16 (value, addr); -} - -static inline void ifc_iowrite32 (u32 value,__le32 __iomem *addr) -{ -iowrite32 (value, addr); -} - -static void ifc_iowrite64_twopart (u64 val, -__le32 __iomem *lo,__le32 __iomem *hi) -{ -ifc_iowrite32 ((u32 )val, lo); -ifc_iowrite32 (val >>32 , hi); -} -struct ifcvf_adapter *vf_to_adapter (struct ifcvf_hw *hw) { return container_of(hw, struct ifcvf_adapter, vf);
drivers/vdpa/ifcvf/ifcvf_base.h +37 -0
@@ -42,6 +42,43 @@#define ifcvf_private_to_vf (adapter) \ (&((struct ifcvf_adapter *)adapter)->vf) +static inline u8 ifc_ioread8 (u8 __iomem *addr) +{ +return ioread8 (addr); +} + +static inline u16 ifc_ioread16 (__le16 __iomem *addr) +{ +return ioread16 (addr); +} + +static inline u32 ifc_ioread32 (__le32 __iomem *addr) +{ +return ioread32 (addr); +} + +static inline void ifc_iowrite8 (u8 value,u8 __iomem *addr) +{ +iowrite8 (value, addr); +} + +static inline void ifc_iowrite16 (u16 value,__le16 __iomem *addr) +{ +iowrite16 (value, addr); +} + +static inline void ifc_iowrite32 (u32 value,__le32 __iomem *addr) +{ +iowrite32 (value, addr); +} + +static inline void ifc_iowrite64_twopart (u64 val, +__le32 __iomem *lo,__le32 __iomem *hi) +{ +ifc_iowrite32 ((u32 )val, lo); +ifc_iowrite32 (val >>32 , hi); +} +struct vring_info {u64 desc;u64 avail;
Signature · 1 line
2.27.0
PATCH v3 2/4 vDPA/ifcvf: implement device MSIX vector allocator
In reply to Zhu LingshanThis commit implements a MSIX vector allocation helper for vqs and config interrupts.
--- drivers/vdpa/ifcvf/ifcvf_main.c | 35 +++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-)
drivers/vdpa/ifcvf/ifcvf_main.c +33 -2
@@ -58,14 +58,45 @@ static void ifcvf_free_irq(struct ifcvf_adapter *adapter, int queues)ifcvf_free_irq_vectors (pdev); } +/* ifcvf MSIX vectors allocator, this helper tries to allocate +* vectors for all virtqueues and the config interrupt. +* It returns the number of allocated vectors, negative +* return value when fails. +*/ +static int ifcvf_alloc_vectors (struct ifcvf_adapter *adapter) +{ +struct pci_dev *pdev = adapter->pdev; +struct ifcvf_hw *vf = &adapter->vf; +int max_intr, ret; + +/* all queues and config interrupt */ + max_intr = vf->nr_vring +1 ; + ret =pci_alloc_irq_vectors (pdev,1 , max_intr,PCI_IRQ_MSIX |PCI_IRQ_AFFINITY ); + +if (ret <0 ) { +IFCVF_ERR (pdev,"Failed to alloc IRQ vectors\n" ); +return ret; + } + +if (ret < max_intr) +IFCVF_INFO (pdev, +"Requested %u vectors, however only %u allocated, lower performance\n" , + max_intr, ret); + +return ret; +} +static int ifcvf_request_irq (struct ifcvf_adapter *adapter) {struct pci_dev *pdev = adapter->pdev;struct ifcvf_hw *vf = &adapter->vf; -int vector, i, ret, irq; +int vector, nvectors, i, ret, irq;u16 max_intr; -/* all queues and config interrupt */ + nvectors =ifcvf_alloc_vectors (adapter); +if (!(nvectors >0 )) +return nvectors; + max_intr = vf->nr_vring +1 ; ret = pci_alloc_irq_vectors(pdev, max_intr,
Signature · 1 line
2.27.0
PATCH v3 3/4 vhost_vdpa: don't setup irq offloading when irq_num < 0
In reply to Zhu LingshanWhen irq number is negative(e.g., -EINVAL), the virtqueue may be disabled or the virtqueues are sharing a device irq. In such case, we should not setup irq offloading for a virtqueue.
--- drivers/vhost/vdpa.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/vhost/vdpa.c +4 -0
@@ -96,6 +96,10 @@ static void vhost_vdpa_setup_vq_irq(struct vhost_vdpa *v, u16 qid)if (!ops->get_vq_irq)return ; + irq = ops->get_vq_irq (vdpa, qid); +if (irq <0 ) +return ; + irq = ops->get_vq_irq (vdpa, qid);irq_bypass_unregister_producer (&vq->call_ctx.producer);if (!vq->call_ctx.ctx || irq <0 )
Signature · 1 line
2.27.0
PATCH v3 4/4 vDPA/ifcvf: implement shared IRQ feature
In reply to Zhu LingshanOn some platforms/devices, there may not be enough MSI vector slots allocated for virtqueues and config changes. In such a case, the interrupt sources(virtqueues, config changes) must share an IRQ/vector, to avoid initialization failures, keep the device functional.
This commit handles three cases:
(1) number of the allocated vectors == the number of virtqueues + 1 (config changes), every virtqueue and the config interrupt has a separated vector/IRQ, the best and the most likely case.
(2) number of the allocated vectors is less than the best case, but greater than 1. In this case, all virtqueues share a vector/IRQ, the config interrupt has a separated vector/IRQ
(3) only one vector is allocated, in this case, the virtqueues and the config interrupt share a vector/IRQ. The worst and most unlikely case.
Otherwise, it needs to fail.
This commit introduces some helper functions:ifcvf_set_vq_vector() and ifcvf_set_config_vector() sets virtqueue vector and config vector in the device config space, so that the device can send interrupt DMA.
This commit adds some fields in struct ifcvf_hw and re-placed the existed fields to be aligned with the cacheline.
--- drivers/vdpa/ifcvf/ifcvf_base.c | 47 +++++-- drivers/vdpa/ifcvf/ifcvf_base.h | 23 ++- drivers/vdpa/ifcvf/ifcvf_main.c | 241 +++++++++++++++++++++++++++----- 3 files changed, 254 insertions(+), 57 deletions(-)
drivers/vdpa/ifcvf/ifcvf_base.c +32 -15
@@ -15,6 +15,36 @@ struct ifcvf_adapter *vf_to_adapter(struct ifcvf_hw *hw) return container_of(hw, struct ifcvf_adapter, vf); } +int ifcvf_set_vq_vector (struct ifcvf_hw *hw,u16 qid,int vector) +{ +struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; +struct ifcvf_adapter *ifcvf =vf_to_adapter (hw); + +ifc_iowrite16 (qid, &cfg->queue_select); +ifc_iowrite16 (vector, &cfg->queue_msix_vector); +if (ifc_ioread16 (&cfg->queue_msix_vector) ==VIRTIO_MSI_NO_VECTOR ) { +IFCVF_ERR (ifcvf->pdev,"No msix vector for queue %u\n" , qid); +return -EINVAL ; + } + +return 0 ; +} + +int ifcvf_set_config_vector (struct ifcvf_hw *hw,int vector) +{ +struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; +struct ifcvf_adapter *ifcvf =vf_to_adapter (hw); + + cfg = hw->common_cfg; +ifc_iowrite16 (vector, &cfg->msix_config); +if (ifc_ioread16 (&cfg->msix_config) ==VIRTIO_MSI_NO_VECTOR ) { +IFCVF_ERR (ifcvf->pdev,"No msix vector for device config\n" ); +return -EINVAL ; + } + +return 0 ; +} +static void __iomem *get_cap_addr (struct ifcvf_hw *hw,struct virtio_pci_cap *cap) {
@@ -140,6 +170,8 @@ int ifcvf_init_hw(struct ifcvf_hw *hw, struct pci_dev *pdev) hw->common_cfg, hw->notify_base, hw->isr, hw->dev_cfg, hw->notify_off_multiplier); + hw->vqs_shared_irq = -EINVAL ; +return 0 ; }
@@ -321,12 +353,6 @@ static int ifcvf_hw_enable(struct ifcvf_hw *hw) ifcvf =vf_to_adapter (hw); cfg = hw->common_cfg; -ifc_iowrite16 (IFCVF_MSI_CONFIG_OFF , &cfg->msix_config); - -if (ifc_ioread16 (&cfg->msix_config) ==VIRTIO_MSI_NO_VECTOR ) { -IFCVF_ERR (ifcvf->pdev,"No msix vector for device config\n" ); -return -EINVAL ; - }for (i =0 ; i < hw->nr_vring; i++) {if (!hw->vring[i].ready)
@@ -340,15 +366,6 @@ static int ifcvf_hw_enable(struct ifcvf_hw *hw)ifc_iowrite64_twopart (hw->vring[i].used, &cfg->queue_used_lo, &cfg->queue_used_hi);ifc_iowrite16 (hw->vring[i].size, &cfg->queue_size); -ifc_iowrite16 (i +IFCVF_MSI_QUEUE_OFF , &cfg->queue_msix_vector); - -if (ifc_ioread16 (&cfg->queue_msix_vector) == -VIRTIO_MSI_NO_VECTOR ) { -IFCVF_ERR (ifcvf->pdev, -"No msix vector for queue %u\n" , i); -return -EINVAL ; - } -ifcvf_set_vq_state (hw, i, hw->vring[i].last_avail_idx);ifc_iowrite16 (1 , &cfg->queue_enable); }
drivers/vdpa/ifcvf/ifcvf_base.h +16 -7
@@ -27,8 +27,6 @@#define IFCVF_QUEUE_ALIGNMENT PAGE_SIZE#define IFCVF_QUEUE_MAX 32768 -#define IFCVF_MSI_CONFIG_OFF 0 -#define IFCVF_MSI_QUEUE_OFF 1#define IFCVF_PCI_MAX_RESOURCE 6#define IFCVF_LM_CFG_SIZE 0x40
@@ -42,6 +40,13 @@#define ifcvf_private_to_vf (adapter) \ (&((struct ifcvf_adapter *)adapter)->vf) +/* all vqs and config interrupt has its own vector */ +#define MSIX_VECTOR_PER_VQ_AND_CONFIG 1 +/* all vqs share a vector, and config interrupt has a separate vector */ +#define MSIX_VECTOR_SHARED_VQ_AND_CONFIG 2 +/* all vqs and config interrupt share a vector */ +#define MSIX_VECTOR_DEV_SHARED 3 +static inline u8 ifc_ioread8 (u8 __iomem *addr) {return ioread8 (addr);
@@ -97,25 +102,27 @@ struct ifcvf_hw {u8 __iomem *isr;/* Live migration */ u8 __iomem *lm_cfg; -u16 nr_vring;/* Notification bar number */ u8 notify_bar; +u8 msix_vector_status; +/* virtio-net or virtio-blk device config size */ +u32 config_size;/* Notificaiton bar address */ void __iomem *notify_base;phys_addr_t notify_base_pa;u32 notify_off_multiplier; +u32 dev_type;u64 req_features;u64 hw_features; -u32 dev_type;struct virtio_pci_common_cfg __iomem *common_cfg;void __iomem *dev_cfg;struct vring_info vring[IFCVF_MAX_QUEUES ];void __iomem *const *base;char config_msix_name[256 ];struct vdpa_callback config_cb; -unsigned int config_irq; -/* virtio-net or virtio-blk device config size */ -u32 config_size; +int config_irq; +int vqs_shared_irq; +u16 nr_vring; };struct ifcvf_adapter {
@@ -160,4 +167,6 @@ int ifcvf_set_vq_state(struct ifcvf_hw *hw, u16 qid, u16 num);struct ifcvf_adapter *vf_to_adapter (struct ifcvf_hw *hw);int ifcvf_probed_virtio_net (struct ifcvf_hw *hw);u32 ifcvf_get_config_size (struct ifcvf_hw *hw); +int ifcvf_set_vq_vector (struct ifcvf_hw *hw,u16 qid,int vector); +int ifcvf_set_config_vector (struct ifcvf_hw *hw,int vector);#endif /* _IFCVF_H_ */
drivers/vdpa/ifcvf/ifcvf_main.c +206 -35
307 lines not on this page · raw message
Signature · 1 line
2.27.0
Michael S. Tsirkin
maintainerQuoted 8 lines · Zhu Lingshan
It has been observed that on some platforms/devices, there may not be enough MSI vectors for virtqueues and the config change. Under such circumstances, the interrupt sources of a device have to share vectors/IRQs.
This series implemented a shared IRQ feature for ifcvf.
Please help review.
Given the history, can you please report which tests were performed with this patchset? Which configs tested? Thanks?
Quoted 29 lines
Changes from V2:
(1) Fix misuse ofnvectors(in ifcvf_alloc_vectors return value)(Michael)
(2) Fix misuse of irq =get_vq_irq()in setup irqbypass(Michael)
(3) Coding style improvements(Michael)
(4) Better naming of device shared irq/shared vq irqChanges from V1:
(1) Enable config interrupt when only one vector is allocated(Michael)
(2) Clean vectors/IRQs if failed to request config interrupt since config interrupt is a must(Michael)
(3) Keep localvdpa_ops, disableirq_bypassby setting IRQ =-EINVALfor shared IRQ case(Michael)
(4) Improvements on error messages(Michael)
(5) Squash functions implementation patches to the callers(Michael)Zhu Lingshan (4):
vDPA/ifcvf: implement IO read/write helpers in the header file vDPA/ifcvf: implement device MSIX vector allocator
vhost_vdpa: don't setup irq offloading whenirq_num< 0 vDPA/ifcvf: implement shared IRQ featuredrivers/vdpa/ifcvf/ifcvf_base.c | 67 +++----- drivers/vdpa/ifcvf/ifcvf_base.h | 60 +++++++- drivers/vdpa/ifcvf/ifcvf_main.c | 260 ++++++++++++++++++++++++++++---- drivers/vhost/vdpa.c | 4 + 4 files changed, 312 insertions(+), 79 deletions(-)Signature · 1 line
2.27.0
Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Zhu Lingshan
It has been observed that on some platforms/devices, there may not be enough MSI vectors for virtqueues and the config change. Under such circumstances, the interrupt sources of a device have to share vectors/IRQs.
Quoted 6 lines
Quoted 3 lines
This series implemented a shared IRQ feature for ifcvf.
Please help review.
Given the history, can you please report which tests were performed with this patchset? Which configs tested? Thanks?
Hi Michael,
It is ping and netperf tests, and I have set nvectors = 1 and 2 in ifcvf_request_irq(), after ifcvf_alloc_vectors(),
to hard coded the number of the allocate vectors.
Thanks,
Zhu Lingshan
Quoted 30 lines
Quoted 30 lines
Changes from V2:
(1) Fix misuse ofnvectors(in ifcvf_alloc_vectors return value)(Michael)
(2) Fix misuse of irq =get_vq_irq()in setup irqbypass(Michael)
(3) Coding style improvements(Michael)
(4) Better naming of device shared irq/shared vq irqChanges from V1:
(1) Enable config interrupt when only one vector is allocated(Michael)
(2) Clean vectors/IRQs if failed to request config interrupt since config interrupt is a must(Michael)
(3) Keep localvdpa_ops, disableirq_bypassby setting IRQ =-EINVALfor shared IRQ case(Michael)
(4) Improvements on error messages(Michael)
(5) Squash functions implementation patches to the callers(Michael)Zhu Lingshan (4):
vDPA/ifcvf: implement IO read/write helpers in the header file vDPA/ifcvf: implement device MSIX vector allocator
vhost_vdpa: don't setup irq offloading whenirq_num< 0 vDPA/ifcvf: implement shared IRQ featuredrivers/vdpa/ifcvf/ifcvf_base.c | 67 +++----- drivers/vdpa/ifcvf/ifcvf_base.h | 60 +++++++- drivers/vdpa/ifcvf/ifcvf_main.c | 260 ++++++++++++++++++++++++++++---- drivers/vhost/vdpa.c | 4 + 4 files changed, 312 insertions(+), 79 deletions(-)Signature · 1 line
2.27.0
Quoted 15 lines · Lingshan
Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Zhu Lingshan
It has been observed that on some platforms/devices, there may not be enough MSI vectors for virtqueues and the config change. Under such circumstances, the interrupt sources of a device have to share vectors/IRQs.
Quoted 6 lines
Quoted 3 lines
This series implemented a shared IRQ feature for ifcvf.
Please help review.
Given the history, can you please report which tests were performed with this patchset? Which configs tested? Thanks?
Quoted 8 lines
Hi Michael,
It is ping and netperf tests, and I have set nvectors = 1 and 2 in
ifcvf_request_irq(), afterifcvf_alloc_vectors(),
to hard coded the number of the allocate vectors.Thanks,
Zhu Lingshan
We can verify the tests result by checking the requested IRQs for the two VMs(one vhost-vdpa device per VM).
(1)when setting nvectors = 1, only one IRQs requested per VM/device, all vqs and the config interrupt share this IRQ.
[lszhu@cra01infra01 ~]$ cat /proc/interrupts | grep ifc
241: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 45 0 0 0 0 0 0 0 0 0 IR-PCI-MSI 534528-edge ifcvf[0000:01:00.5]-dev-shared-irq 251: 0 0 0 0 0 0 0 0 0 0 0 41 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IR-PCI-MSI 536576-edge ifcvf[0000:01:00.6]-dev-shared-irq
(2)when setting nvectors = 2, two IRQs requested for each VM/device, one for all vqs, the other for the config interrupt
[lszhu@cra01infra01 ~]$ cat /proc/interrupts | grep ifc
241: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 39 0 0 0 0 0 0 0 0 0 IR-PCI-MSI 534528-edge ifcvf[0000:01:00.5]-vqs-shared-irq 242: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IR-PCI-MSI 534529-edge ifcvf[0000:01:00.5]-config 251: 0 0 0 0 0 0 0 0 0 0 0 39 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IR-PCI-MSI 536576-edge ifcvf[0000:01:00.6]-vqs-shared-irq 252: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IR-PCI-MSI 536577-edge ifcvf[0000:01:00.6]-config
(3)when remove nvectors hardcode, the driver allocates enough vectors for the queues and config interrupt,
and we do see better performance because irq_bypass is enabled:(too many lines, cut off)
[lszhu@cra01infra01 linux]$ cat /proc/interrupts | grep ifc
241: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IR-PCI-MSI 534528-edge ifcvf[0000:01:00.5]-0 242: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IR-PCI-MSI 534529-edge ifcvf[0000:01:00.5]-1 243: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IR-PCI-MSI 534530-edge ifcvf[0000:01:00.5]-2 244: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IR-PCI-MSI 534531-edge ifcvf[0000:01:00.5]-3 245: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IR-PCI-MSI 534532-edge ifcvf[0000:01:00.5]-4 246: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IR-PCI-MSI 534533-edge ifcvf[0000:01:00.5]-5 247: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IR-PCI-MSI 534534-edge ifcvf[0000:01:00.5]-6 248: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IR-PCI-MSI 534535-edge ifcvf[0000:01:00.5]-7 249: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IR-PCI-MSI 534536-edge ifcvf[0000:01:00.5]-8 250: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IR-PCI-MSI 534537-edge ifcvf[0000:01:00.5]-config 251: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IR-PCI-MSI 536576-edge ifcvf[0000:01:00.6]-0 252: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IR-PCI-MSI 536577-edge ifcvf[0000:01:00.6]-1
Thanks,
Zhu Lingshan
Quoted 32 lines
Quoted 31 lines
Quoted 31 lines
Changes from V2:
(1) Fix misuse ofnvectors(in ifcvf_alloc_vectors return value)(Michael)
(2) Fix misuse of irq =get_vq_irq()in setup irqbypass(Michael)
(3) Coding style improvements(Michael)
(4) Better naming of device shared irq/shared vq irqChanges from V1:
(1) Enable config interrupt when only one vector is allocated(Michael)
(2) Clean vectors/IRQs if failed to request config interrupt since config interrupt is a must(Michael)
(3) Keep localvdpa_ops, disableirq_bypassby setting IRQ =-EINVALfor shared IRQ case(Michael)
(4) Improvements on error messages(Michael)
(5) Squash functions implementation patches to the callers(Michael)Zhu Lingshan (4):
vDPA/ifcvf: implement IO read/write helpers in the header file vDPA/ifcvf: implement device MSIX vector allocator
vhost_vdpa: don't setup irq offloading whenirq_num< 0 vDPA/ifcvf: implement shared IRQ featuredrivers/vdpa/ifcvf/ifcvf_base.c | 67 +++----- drivers/vdpa/ifcvf/ifcvf_base.h | 60 +++++++- drivers/vdpa/ifcvf/ifcvf_main.c | 260 ++++++++++++++++++++++++++++---- drivers/vhost/vdpa.c | 4 + 4 files changed, 312 insertions(+), 79 deletions(-)Signature · 1 line
2.27.0
kernel test robot
build botThank you for the patch! Perhaps something to improve:
Hi Zhu,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on mst-vhost/linux-next]
[also build test WARNING on horms-ipvs/master linus/master v5.17-rc2 next-20220128] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Zhu-Lingshan/vDPA-ifcvf-implement-shared-IRQ-feature/20220126-205804 base: https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git linux-next config: i386-randconfig-m021-20220131 (https://download.01.org/0day-ci/archive/20220131/202201311421.yRzlUeOz-lkp(a)intel.com/config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
If you fix the issue, kindly add following tag as appropriate
smatch warnings:drivers/vdpa/ifcvf/ifcvf_main.c:89 ifcvf_free_vq_irq() warn: inconsistent indenting drivers/vdpa/ifcvf/ifcvf_main.c:265 ifcvf_request_config_irq() error: uninitialized symbol 'config_vector'. drivers/vdpa/ifcvf/ifcvf_main.c:274 ifcvf_request_config_irq() warn: inconsistent indenting
vim +89 drivers/vdpa/ifcvf/ifcvf_main.c
75
76 static void ifcvf_free_vq_irq(struct ifcvf_adapter *adapter, int queues)
77 {
78 struct pci_dev *pdev = adapter->pdev;
79 struct ifcvf_hw *vf = &adapter->vf;
80 int i;
81
82 if (vf->msix_vector_status == MSIX_VECTOR_PER_VQ_AND_CONFIG) {
83 for (i = 0; i < queues; i++) {
84 devm_free_irq(&pdev->dev, vf->vring[i].irq, &vf->vring[i]);
85 vf->vring[i].irq = -EINVAL;
86 }
87 } else {
88 devm_free_irq(&pdev->dev, vf->vqs_shared_irq, vf);
> 89 } vf->vqs_shared_irq = -EINVAL;
90 }
91
92 static void ifcvf_free_config_irq(struct ifcvf_adapter *adapter)
93 {
94 struct pci_dev *pdev = adapter->pdev;
95 struct ifcvf_hw *vf = &adapter->vf;
96
97 /* If the irq is shared by all vqs and the config interrupt,
98 * it is already freed in ifcvf_free_vq_irq, so here only
99 * need to free config irq when msix_vector_status != MSIX_VECTOR_DEV_SHARED
100 */
101 if (vf->msix_vector_status != MSIX_VECTOR_DEV_SHARED) {
102 devm_free_irq(&pdev->dev, vf->config_irq, vf);
103 vf->config_irq = -EINVAL;
104 }
105 }
106
107 static void ifcvf_free_irq(struct ifcvf_adapter *adapter, int queues)
108 {
109 struct pci_dev *pdev = adapter->pdev;
110
111 ifcvf_free_vq_irq(adapter, queues);
112 ifcvf_free_config_irq(adapter);
113 ifcvf_free_irq_vectors(pdev);
114 }
115
116 /* ifcvf MSIX vectors allocator, this helper tries to allocate
117 * vectors for all virtqueues and the config interrupt.
118 * It returns the number of allocated vectors, negative
119 * return value when fails.
120 */
121 static int ifcvf_alloc_vectors(struct ifcvf_adapter *adapter)
122 {
123 struct pci_dev *pdev = adapter->pdev;
124 struct ifcvf_hw *vf = &adapter->vf;
125 int max_intr, ret;
126
127 /* all queues and config interrupt */
128 max_intr = vf->nr_vring + 1;
129 ret = pci_alloc_irq_vectors(pdev, 1, max_intr, PCI_IRQ_MSIX | PCI_IRQ_AFFINITY);
130
131 if (ret < 0) {
132 IFCVF_ERR(pdev, "Failed to alloc IRQ vectors\n");
133 return ret;
134 }
135
136 if (ret < max_intr)
137 IFCVF_INFO(pdev,
138 "Requested %u vectors, however only %u allocated, lower performance\n",
139 max_intr, ret);
140
141 return ret;
142 }
143
144 static int ifcvf_request_per_vq_irq(struct ifcvf_adapter *adapter)
145 {
146 struct pci_dev *pdev = adapter->pdev;
147 struct ifcvf_hw *vf = &adapter->vf;
148 int i, vector, ret, irq;
149
150 for (i = 0; i < vf->nr_vring; i++) {
151 snprintf(vf->vring[i].msix_name, 256, "ifcvf[%s]-%d\n", pci_name(pdev), i);
152 vector = i;
153 irq = pci_irq_vector(pdev, vector);
154 ret = devm_request_irq(&pdev->dev, irq,
155 ifcvf_intr_handler, 0,
156 vf->vring[i].msix_name,
157 &vf->vring[i]);
158 if (ret) {
159 IFCVF_ERR(pdev, "Failed to request irq for vq %d\n", i);
160 ifcvf_free_vq_irq(adapter, i);
161 } else {
162 vf->vring[i].irq = irq;
163 ifcvf_set_vq_vector(vf, i, vector);
164 }
165 }
166
167 vf->vqs_shared_irq = -EINVAL;
168
169 return 0;
170 }
171
172 static int ifcvf_request_shared_vq_irq(struct ifcvf_adapter *adapter)
173 {
174 struct pci_dev *pdev = adapter->pdev;
175 struct ifcvf_hw *vf = &adapter->vf;
176 int i, vector, ret, irq;
177
178 vector = 0;
179 /* reuse msix_name[256] space of vring0 to store shared vqs interrupt name */
180 snprintf(vf->vring[0].msix_name, 256, "ifcvf[%s]-vqs-shared-irq\n", pci_name(pdev));
181 irq = pci_irq_vector(pdev, vector);
182 ret = devm_request_irq(&pdev->dev, irq,
183 ifcvf_vq_shared_intr_handler, 0,
184 vf->vring[0].msix_name, vf);
185 if (ret) {
186 IFCVF_ERR(pdev, "Failed to request shared irq for vf\n");
187
188 return ret;
189 }
190
191 vf->vqs_shared_irq = irq;
192 for (i = 0; i < vf->nr_vring; i++) {
193 vf->vring[i].irq = -EINVAL;
194 ifcvf_set_vq_vector(vf, i, vector);
195 }
196
197 return 0;
198
199 }
200
201 static int ifcvf_request_dev_shared_irq(struct ifcvf_adapter *adapter)
202 {
203 struct pci_dev *pdev = adapter->pdev;
204 struct ifcvf_hw *vf = &adapter->vf;
205 int i, vector, ret, irq;
206
207 vector = 0;
208 /* reuse msix_name[256] space of vring0 to store shared device interrupt name */
209 snprintf(vf->vring[0].msix_name, 256, "ifcvf[%s]-dev-shared-irq\n", pci_name(pdev));
210 irq = pci_irq_vector(pdev, vector);
211 ret = devm_request_irq(&pdev->dev, irq,
212 ifcvf_dev_shared_intr_handler, 0,
213 vf->vring[0].msix_name, vf);
214 if (ret) {
215 IFCVF_ERR(pdev, "Failed to request shared irq for vf\n");
216
217 return ret;
218 }
219
220 vf->vqs_shared_irq = irq;
221 for (i = 0; i < vf->nr_vring; i++) {
222 vf->vring[i].irq = -EINVAL;
223 ifcvf_set_vq_vector(vf, i, vector);
224 }
225
226 vf->config_irq = irq;
227 ifcvf_set_config_vector(vf, vector);
228
229 return 0;
230
231 }
232
233 static int ifcvf_request_vq_irq(struct ifcvf_adapter *adapter)
234 {
235 struct ifcvf_hw *vf = &adapter->vf;
236 int ret;
237
238 if (vf->msix_vector_status == MSIX_VECTOR_PER_VQ_AND_CONFIG)
239 ret = ifcvf_request_per_vq_irq(adapter);
240 else
241 ret = ifcvf_request_shared_vq_irq(adapter);
242
243 return ret;
244 }
245
246 static int ifcvf_request_config_irq(struct ifcvf_adapter *adapter)
247 {
248 struct pci_dev *pdev = adapter->pdev;
249 struct ifcvf_hw *vf = &adapter->vf;
250 int config_vector, ret;
251
252 if (vf->msix_vector_status == MSIX_VECTOR_DEV_SHARED)
253 return 0;
254
255 if (vf->msix_vector_status == MSIX_VECTOR_PER_VQ_AND_CONFIG)
256 /* vector 0 ~ vf->nr_vring for vqs, num vf->nr_vring vector for config interrupt */
257 config_vector = vf->nr_vring;
258
259 if (vf->msix_vector_status == MSIX_VECTOR_SHARED_VQ_AND_CONFIG)
260 /* vector 0 for vqs and 1 for config interrupt */
261 config_vector = 1;
262
263 snprintf(vf->config_msix_name, 256, "ifcvf[%s]-config\n",
264 pci_name(pdev));
> 265 vf->config_irq = pci_irq_vector(pdev, config_vector);
266 ret = devm_request_irq(&pdev->dev, vf->config_irq,
267 ifcvf_config_changed, 0,
268 vf->config_msix_name, vf);
269 if (ret) {
270 IFCVF_ERR(pdev, "Failed to request config irq\n");
271 ifcvf_free_vq_irq(adapter, vf->nr_vring);
272 return ret;
273 }
> 274 ifcvf_set_config_vector(vf, config_vector); 275
276 return 0;
277 }
278
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org