Re: [Patch v1 2/4] RDMA/mana_ib: create and process EQ events

From: Simon Horman
Date: Sun Nov 26 2023 - 12:15:16 EST


On Wed, Nov 22, 2023 at 07:10:08PM -0800, longli@xxxxxxxxxxxxxxxxx wrote:
> From: Long Li <longli@xxxxxxxxxxxxx>
>
> Before the software can create an RDMA adapter handle with SoC, it needs to
> create EQs for processing SoC events from RDMA device. Because MSI-X
> vectors are shared between MANA Ethernet device and RDMA device, this
> patch adds support to share EQs on MSI-X vectors and creates management
> EQ for RDMA device.
>
> Signed-off-by: Long Li <longli@xxxxxxxxxxxxx>

...

> diff --git a/drivers/net/ethernet/microsoft/mana/gdma_main.c b/drivers/net/ethernet/microsoft/mana/gdma_main.c

...

> -static void mana_gd_deregiser_irq(struct gdma_queue *queue)
> +static void mana_gd_deregister_irq(struct gdma_queue *queue)
> {
> struct gdma_dev *gd = queue->gdma_dev;
> struct gdma_irq_context *gic;
> struct gdma_context *gc;
> struct gdma_resource *r;
> unsigned int msix_index;
> + struct gdma_queue *eq;
> unsigned long flags;
> + struct list_head *p;
>
> gc = gd->gdma_context;
> r = &gc->msix_resource;
> @@ -505,14 +507,24 @@ static void mana_gd_deregiser_irq(struct gdma_queue *queue)
> if (WARN_ON(msix_index >= gc->num_msix_usable))
> return;
>
> + spin_lock_irqsave(&r->lock, flags);
> +
> gic = &gc->irq_contexts[msix_index];
> - gic->handler = NULL;
> - gic->arg = NULL;
> + list_for_each_rcu(p, &gic->eq_list) {
> + eq = list_entry(p, struct gdma_queue, entry);

Hi Long Li,

Sparse complains a bit about this construction:

.../gdma_main.c:513:9: error: incompatible types in comparison expression (different address spaces):
.../gdma_main.c:513:9: struct list_head [noderef] __rcu *
.../gdma_main.c:513:9: struct list_head *
.../gdma_main.c:513:9: error: incompatible types in comparison expression (different address spaces):
.../gdma_main.c:513:9: struct list_head [noderef] __rcu *
.../gdma_main.c:513:9: struct list_head *

Perhaps using list_for_each_entry_rcu() is appropriate here.


> + if (queue == eq) {
> + list_del(&eq->entry);
> + synchronize_rcu();
> + break;
> + }
> + }
>
> - spin_lock_irqsave(&r->lock, flags);
> - bitmap_clear(r->map, msix_index, 1);
> - spin_unlock_irqrestore(&r->lock, flags);
> + if (list_empty(&gic->eq_list)) {
> + gic->handler = NULL;
> + bitmap_clear(r->map, msix_index, 1);
> + }
>
> + spin_unlock_irqrestore(&r->lock, flags);
> queue->eq.msix_index = INVALID_PCI_MSIX_INDEX;
> }
>

...