🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25851

Re: [PATCH net-next v6 3/3] dinghai: add async event queue for firmware notifications

#25851
From: han.junyang
Date: Wed, 02 Dec 2026 15:02
133 lines
15346 bytes
Thanks for the review. This is addressed in v7, where this patch is 2/2
(patch 1 of v6 has been applied upstream). The code items are fixed; the
question about users is answered at the end.

> [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.

You are right that there is no subscriber in this series: the notifier
chains are empty, and the queue is inert until the BAR message channel
handshake tells the firmware which vector to signal. The register/unregister
helper for subscribers will come with the first one.

We kept the queue in this series because the vector allocation, the IRQ
lifetime and the teardown order belong with the interrupt pools, and the
first subscriber, the event payload and the ownership of the mailbox offsets
are easier to review together with the channel. The valid bit of the header
is handled here.

If you would rather see this folded into the BAR message channel series, we
can hold it. Holding the queue also leaves the async pool in 1/2 without a
consumer, so in that case we would hold both patches and send them together
with the channel.

> [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?

The handler now reads the whole header word, checks the valid flag (bit 0 of
byte 0, the same position the DPDK PMD uses) and returns without dispatching
if it is not set.

> [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.

The valid flag is cleared with a read-modify-write of the first word once
the message has been dispatched, mirroring what the DPDK receive path does,
and this happens whether or not a subscriber handled the event.

This series only receives asynchronous notifications. The sync request/reply
path, including the ack header, comes with the BAR message channel series,
where both ends of the protocol are in the tree.

> [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?

Removed. It was only taken in the teardown path, while probe and remove are
already serialized by the driver core, and holding it across unregister and
free_irq did not protect anything.
Technical Details
Message-ID: <202612022302370821qwQKDNO-DJhRMwCSPHOK@zte.com.cn>
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375870-linux-kernel-netdev=dewy.ru
References: 202611131353550805pQNJ97v2tR6FK-IhhDQ0@zte.com.cn,20261121233139.1369298-1-kuba@kernel.org

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375870-linux-kernel-netdev=dewy.ru
From: han.junyang@zte.com.cn
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v6 3/3] dinghai: add async event queue for firmware notifications
Date: Wed, 2 Dec 2026 23:02:37 +0800 (CST)
Organization: Usenet Network
Message-ID: <202612022302370821qwQKDNO-DJhRMwCSPHOK@zte.com.cn>
References: 202611131353550805pQNJ97v2tR6FK-IhhDQ0@zte.com.cn,20261121233139.1369298-1-kuba@kernel.org
MIME-Version: 1.0
Content-Type: text/plain;
	charset="UTF-8"
Injection-Info: usenet.network;
	logging-data="1995712"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:yY5MLDN5IX0YCobF3e82af5oKqs= sha256:wt/nHYSCZJg/n7UfEyBkX+hQp72Tg6Z081iuGydJc/0=
	sha1:IeHBrnWeQ9QAbYgvpm3K1ed7/9w= sha256:ElEz2tzphdz30yJOyPwJ7xyWiqHVTVogxb0zkoRXRnE=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 30A9A117682; Wed,  2 Dec 2026 18:03:11 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001, URIBL_BLOCKED=0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=zte.com.cn
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 7YBGyWT3jRbB;
	Wed,  2 Dec 2026 18:03:07 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-375870-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=zte.com.cn
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 78A12117680; Wed,  2 Dec 2026 18:02:59 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 506292F9BB; Wed,  2 Dec 2026 15:02:54 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796223774;
	b=VMgj3dV3rsN/4D5prsTwmN4EjnvWQimaVXVaPAiwSAolIkegVCASc/wQvRTEgRKpJAis
	 GOkVSkfV/ZqbiTGEUrwQeGO4QdyCzjaOODLNRdiSYsCDpbo7ERSThcnEEYvI+GvL39bG2
	 /dqMCJ2K9uAE2yKDeRsc18l1ulURvlnqk+DfOoCkjQH09RCYwOQWJw9did3KaypBMId2p
	 ume16Ehls9sNuxMJFrqiy9+rhZGMBEzQw73+hCJZWS7UQf8aLZalgu2bi2FZeHXrNaVHQ
	 4H6As1jnkJR1q2LnDgyAwRO+iLdQkIm4nqYM6wA5Zc4FTvnfGTgyPc/uYvVW5RQUGZw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796223774;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:Received:
	 Received:X-Zmail-TransId:X-Mailer:Message-ID:In-Reply-To:References:
	 Date:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:Mime-Version:From:To:Cc:
	 Subject:Content-Type:X-MAIL:X-TLS:X-ENVELOPE-SENDER:X-SOURCE-IP:
	 X-CLEAN:X-Fangmail-Anti-Spam-Filtered:X-Fangmail-MID-QID;
	bh=ZlzT5ENwJMlM6oII1+hiolX9u240ow6khWvG0pKscMw=;
	b=FeqmEzJJhwPsEcQQZH1F2oA0mkVEgyQosSkpbPpwewDLTLISI/VwGfkeNLXr4tp6dRe0
	 9dVaPYeREcQfwLU7ntRUmSKty0DqqXucXL8QnHoHiFnO/D2EOOwOEjeHY23xBjakj/Mr0
	 zEniU5LyH9/vzSlkCWtCoWxfBtf/A5GKn0ACiWRa8fK49WMQlE0fDCdcN9hY/IMwYg316
	 mIUZa0KoHI5xQS+Xr8zkUzltgT3Eo4lwg+d5J+G1iA0mbxCZHuDgljl3JF6YUhwlk22E9
	 EzYzFJ+BRO5SKuzZhxieTf/QxO1X5bSqEU9GCgjZtqwIGKRamO0s753ZRZF1Rt+E41w==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=zte.com.cn header.i=@zte.com.cn header.a=rsa-sha256 header.s=z202610 header.b=zK2p4kp6;
	dmarc=pass header.from=zte.com.cn;
	spf=pass smtp.mailfrom=zte.com.cn;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 28DC4606A683;
	Wed,  2 Dec 2026 15:02:54 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=zte.com.cn header.i=@zte.com.cn header.a=rsa-sha256 header.s=z202610 header.b=zK2p4kp6
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=160.30.148.35
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796223768;
	b=y9YpJj0fapVTfLGiqa4Cn0REtsRC79n7tIyt1oqgJBHiQpk/fgFbyubRfKkOayCv5/aJ
	 4M13nvq3VvGd1uCPwfbtnoQMpWUTmJ4WlQgdZx12yDQIsLNF90DDOhdvatZS1M2TvGbLc
	 DYf0UymivYDJf4pNKH5h2FmE7QbSLn5L3cCd/S1IPzPBZnu8HDWHrrBi02gDJHhCk4e8c
	 GFkZQbYenC8+1VzhX1Jy8YxEQmO6ngRbWRbx8Sx76bKwIvXEFjqkZfK5IxnYYRhZfpSdt
	 RWBFyHzBeBDcI+aJxV93axdzPeJBvnl9jYxTdXnJWNbbs3BOmGQB4umht4B4Qc2QKhA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796223768;
	h=DMARC-Filter:Received:DKIM-Signature:Received:Received:
	 X-Zmail-TransId:X-Mailer:Message-ID:In-Reply-To:References:Date:
	 Mime-Version:From:To:Cc:Subject:Content-Type:X-MAIL:X-TLS:
	 X-ENVELOPE-SENDER:X-SOURCE-IP:X-CLEAN:X-Fangmail-Anti-Spam-Filtered:
	 X-Fangmail-MID-QID;
	bh=ZlzT5ENwJMlM6oII1+hiolX9u240ow6khWvG0pKscMw=;
	b=1q5LBRdFfHo69oIhpv4RBZn96SaGO5DRdyEy1Iuwo9PutWzFlT6oAA4ikmkfmxWvJmgQ
	 g/7AhBZlqTYOXR26hYcmdeuf0qVLu0wUMOUQ/b/U74ub4klmWf0jtKS6iUs79jlO/7xMG
	 WsTv6axDOoYG0ma6nnro7l+iUC8wNOxvcjtfnL10+tT5CBQL1bXytqTeGzSjwwCmIw0AK
	 j4zlUedYSATk0PQPL3pjL1vbd8mHh3GxrK8KqHi9Mvd1wbGd7OPSuUGAk+7cSMqhdS8uE
	 RFdoSD3nzi9ym2Ly0K/a+szkVea1w5h//Kh85avrgQMo4QYHd6SDc74SE4XT+vOdVIA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=zte.com.cn;
	spf=pass smtp.mailfrom=zte.com.cn;
	dkim=pass header.d=zte.com.cn header.i=@zte.com.cn header.a=rsa-sha256 header.s=z202610 header.b=zK2p4kp6;
	arc=none smtp.remote-ip=160.30.148.35
X-Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [160.30.148.35])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5106F606A33A;
	Wed,  2 Dec 2026 15:02:47 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5106F606A33A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zte.com.cn
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zte.com.cn
X-Received: from mse-fl1.zte.com.cn (unknown [10.5.228.132])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256)
	(No client certificate requested)
	by mxhk.zte.com.cn (FangMail) with ESMTPS id 4jfgwj294Pz8XrrJ;
	Wed, 02 Dec 2026 23:02:45 +0800 (CST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=zte.com.cn;
	s=z202610; t=1796223765;
	bh=+JPx4ngIr66o+t4zLrHULp+CIEc7hjb6NJYKeZJN3MU=;
	h=In-Reply-To:References:Date:From:To:Cc:Subject;
	b=zK2p4kp6slN1WS0e62SM/AeJ8a3kjc69V42/5mbQKnteXNKT6c/c9nLh6fIDgM7cS
	 5PZ7acuMeHTcYe1KSRs+qJqrYAzMOTfGZ7DP3R0TSqygTeSELoNEabJLMJLmydX16A
	 kC6uIGo4xStR33SH72zAHLaCTaTbFH3kX+Ip5ImVD/f1Fvw8d1coYf/IC3lMRIDdkz
	 UylR4cw/1D2jOJgpEjM2gDDJy2vVunPMy9XJFRF11q/aFFe5lVFZvFNFBTIZkETL+i
	 rzyUFeqz8O/ABoL+wc6zZvRGaDNPNIHVzt9hVt3ro5L/t5T7V4kIbJaSwbWK0Ao1CA
	 mR0OLsRjy4D4w==
X-Received: from njb2app05.zte.com.cn ([10.55.22.121])
	by mse-fl1.zte.com.cn with SMTP id 6B2F2XBV084589;
	Wed, 2 Dec 2026 23:02:33 +0800 (+08)
	(envelope-from han.junyang@zte.com.cn)
X-Received: from mapi (njy2app08[null])
	by mapi (Zmail) with MAPI id mid204;
	Wed, 2 Dec 2026 23:02:37 +0800 (CST)
X-Zmail-TransId: 2b006b10330d602-715dc
X-Mailer: Zmail v1.0
X-In-Reply-To: <20261121233139.1369298-1-kuba@kernel.org>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-Cc: <kuba@kernel.org>, <andrew+netdev@lunn.ch>, <davem@davemloft.net>,
        <edumazet@google.com>, <pabeni@redhat.com>, <horms@kernel.org>,
        <linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
        <ran.ming@zte.com.cn>, <han.chengfei@zte.com.cn>,
        <zhang.yanze@zte.com.cn>
X-MAIL: mse-fl1.zte.com.cn 6B2F2XBV084589
X-TLS: YES
X-ENVELOPE-SENDER: han.junyang@zte.com.cn
X-SOURCE-IP: 10.5.228.132 unknown Wed, 02 Dec 2026 23:02:45 +0800
X-CLEAN: YES
X-Fangmail-Anti-Spam-Filtered: true
X-Fangmail-MID-QID: 6B103315.000/4jfgwj294Pz8XrrJ