Re: [PATCH net-next v6 3/3] dinghai: add async event queue for firmware notifications
From: Jakub Kicinski
Date: Sat Nov 21 2026 - 18:31:50 EST
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
---
--- Patch [3]: [PATCH net-next v6 3/3] dinghai: add async event queue for firmware
notifications ---
commit 0beec1cea24be93e6e75a8732e384d617376a13d
Author: Junyang Han <han.junyang@xxxxxxxxxx>
dinghai: add async event queue for firmware notifications
This adds an event queue table and one async event queue that receives
firmware notifications from the RISC-V management core. The queue takes
one MSI-X vector from the async pool. Its interrupt handler reads an
event_id from the PF receive sub-channel of the BAR message area and
dispatches it through per-event-type notifier chains, and the PF
probe/remove paths create and tear down the queue.
> diff --git a/drivers/net/ethernet/zte/dinghai/en_pf.c b/drivers/net/ethernet/zte/dinghai/en_pf.c
> index 5927f1f39b02a..f7400d66bc690 100644
> --- a/drivers/net/ethernet/zte/dinghai/en_pf.c
> +++ b/drivers/net/ethernet/zte/dinghai/en_pf.c
[ ... ]
> @@ -617,10 +614,18 @@ static int zxdh_pf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> goto err_irq_table;
> }
>
> + ret = zxdh_pf_eq_table_init(zxdh_dev);
> + if (ret) {
> + dev_err(&pdev->dev, "zxdh_pf_eq_table_init failed: %d\n", ret);
> + goto err_eq_table;
> + }
[Severity: Low]
Does this queue have any users in this series? Every probe now takes an
async-pool vector and installs a hard IRQ handler:
zxdh_pf_eq_table_init()
zxdh_pf_async_irq_request()
zxdh_get_irq_of_pool()
zxdh_irq_affinity_request()
zxdh_irq_pool_request_irq()
zxdh_irq_alloc()
request_irq()
When the interrupt fires, zxdh_eq_async_riscv_int() dispatches to
zxdh_dev->eq_table.nh[], but nothing registers on those chains. Under
drivers/net/ethernet/zte/, the only reference to eq_table.nh[] is the
atomic_notifier_call_chain() call in zxdh_eq_async_riscv_int().
zxdh_eq.h also exports only zxdh_pf_eq_table_init() and
zxdh_pf_eq_table_destroy(), with no register/unregister helper. Later
subscribers would have to reach into struct zxdh_eq_table directly.
The commit message says:
"the PF side wired here is live as soon as that channel is enabled.
Subscribers for the RISCV_READY event register on the notifier chains
in later series as well."
Even with the channel enabled, every RISCV_READY dispatch would go to an
empty chain. Could this be merged together with the BAR message channel
and the first subscriber? Then the design could be reviewed against its
consumers, including the event payload, valid/ack handling and ownership
of the mailbox offsets.
[ ... ]
> diff --git a/drivers/net/ethernet/zte/dinghai/zxdh_eq.c b/drivers/net/ethernet/zte/dinghai/zxdh_eq.c
> new file mode 100644
> index 0000000000000..3e70f4f3063fe
> --- /dev/null
> +++ b/drivers/net/ethernet/zte/dinghai/zxdh_eq.c
[ ... ]
> +/* Fetch the event_id the RISC-V core posted in the PF receive
> + * sub-channel of the BAR message area. The field lives at byte offset
> + * 2 of the 12-byte message header, so a single 32-bit read of the
> + * sub-channel start covers it.
> + */
> +static u16 zxdh_eq_event_id_get(struct zxdh_core_dev *zxdh_dev)
> +{
> + struct zxdh_pf_dev *pf_dev = zxdh_dev->priv;
> + void __iomem *subchan;
> +
> + subchan = pf_dev->pci_ioremap_addr[0] + ZXDH_BAR_MSG_SUBCHAN_RECV;
> +
> + return ioread32(subchan) >> 16;
[Severity: Medium]
Should the handler check that a new message was actually posted before
it uses this event_id?
The >> 16 discards bytes 0-1 of the header. In the 12-byte BAR message
header, byte 0 holds the per-message flag bits (valid, sync, emec, ack,
poll, usr).
The BAR mailbox protocol isn't in the tree yet, so this is based on the
DPDK zxdh PMD. Its header layout matches the comment here (event_id at
offset 2, RISC_READY = 13). Its receive path rejects any header without
the valid bit in zxdh_bar_chan_msg_header_check().
zxdh_irq_int_handler() calls the chain on every interrupt:
atomic_notifier_call_chain(&zxdh_irq->nh, 0, NULL);
return IRQ_HANDLED;
so nothing earlier filters these events. If the mailbox still says 13,
ZXDH_EQ_EVENT_TYPE_RISCV_READY would be dispatched again on any
interrupt on this vector. That includes a stale header from an earlier
notification, an uninitialized mailbox, or a spurious MSI-X. It also
covers interrupts meant for other users if zxdh_irq_affinity_request()
shares the vector when the pool runs out.
Can subscribers then receive a RISCV_READY event that the firmware
didn't post for this interrupt?
> +}
[ ... ]
> +static int zxdh_eq_async_riscv_int(struct notifier_block *nb,
> + unsigned long action, void *data)
> +{
> + struct zxdh_eq_async *eq = container_of(nb, struct zxdh_eq_async, irq_nb);
> + struct zxdh_core_dev *zxdh_dev = eq->priv;
> + enum zxdh_eq_event_type event_type;
> +
> + event_type = zxdh_eq_event_type_get(zxdh_eq_event_id_get(zxdh_dev));
> + if (event_type == ZXDH_EQ_EVENT_TYPE_MAX)
> + return NOTIFY_DONE;
> +
> + atomic_notifier_call_chain(&zxdh_dev->eq_table.nh[event_type],
> + event_type, NULL);
> +
> + return NOTIFY_OK;
[Severity: Medium]
What gives the receive sub-channel back to the firmware once the
message is handled? This handler is its only consumer, and it returns
without writing anything to the mailbox.
In the DPDK zxdh receive path, zxdh_bar_irq_recv() resets the header's
valid field to usable. For sync messages it also writes a reply header
with the ack bit set.
Without this, could the RISC-V core keep seeing an unconsumed message
and fail to post the next notification? Could a sync-flagged sender
wait for an ack until it times out? The old header would also stay in
the mailbox, so the stale re-dispatch described above could repeat on
every later interrupt.
> +}
[ ... ]
> +void zxdh_pf_eq_table_destroy(struct zxdh_core_dev *zxdh_dev)
> +{
> + struct zxdh_pf_eq_table *pf_eq_table = zxdh_dev->eq_table.priv;
> + struct zxdh_eq_table *table = &zxdh_dev->eq_table;
> + struct zxdh_eq_async *eq;
> +
> + if (!pf_eq_table)
> + return;
> +
> + eq = &pf_eq_table->riscv_eq;
> +
> + mutex_lock(&table->lock);
> + if (eq->irq) {
> + zxdh_irq_detach_nb(eq->irq, &eq->irq_nb);
> + zxdh_irqs_release_vectors(&eq->irq, 1);
> + eq->irq = NULL;
> + }
> + mutex_unlock(&table->lock);
[Severity: Low]
This isn't a bug, but what does table->lock protect? zxdh_eq.h
documents it as:
/* Serializes async EQ setup/teardown. */
struct mutex lock;
zxdh_pf_eq_table_init() only calls mutex_init(). It then sets eq->irq
and calls zxdh_irq_attach_nb() without taking the lock. This
mutex_lock() in zxdh_pf_eq_table_destroy() is the only place it is
acquired.
The driver core already serializes probe and remove, and the hard IRQ
path can't take a mutex. Holding the lock here also keeps it held across
synchronize_rcu() in atomic_notifier_chain_unregister(),
synchronize_irq(), pool->lock and free_irq().
Could the lock be removed, or the comment changed to match what it
actually guarantees?
> +
> + mutex_destroy(&table->lock);
> + kvfree(table->priv);
> + table->priv = NULL;
> +}
[ ... ]