🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #15591

[PATCH net-next v6 0/3] dinghai: firmware handshake, MSI-X pools and async event queues

#15591
From: han.junyang
Date: Fri, 13 Nov 2026 05:47
121 lines
15098 bytes
From: Junyang Han <han.junyang@zte.com.cn>

This series continues the DingHai (ZXDH) PF driver bring-up: after PCI
probing, it verifies the firmware version contract, waits for the
RISC-V management core to become ready, sets up the MSI-X interrupt
pools, and creates the async event queues through which the firmware
will report events.

Some notes on the IRQ design:

The vector space is partitioned into per-purpose pools (async, RDMA,
vq). Event queues share a vector through an atomic notifier chain
attached to the IRQ, and the sharing degree is governed by pool
thresholds. The IRQ table hangs off a void *priv in the shared core
device: the PF, MPF and SF core devices each carry a different pool
layout behind that pointer, so a type-specific struct in en_pf.c keeps
the shared header free of PF-only details.

Changes in v6:
- Guard the IRQ table teardown in patch 2 rather than deferring the
  guards to patch 3, so the probe error paths of the MSI-X patch are
  safe on their own and bisection cannot land on an unguarded cleanup
  (sashiko review of v5).
- Review findings not taken from v5:
  The sashiko automated review of v5 [1], which was not posted to the
  list, reported four findings. The IRQ table teardown NULL
  dereferences on the probe error paths were real and are fixed in
  this revision. The remaining three restate earlier findings or
  do not apply: the BAR0 bounds item repeats the BAR 0 entry below;
  the 20 s legacy wait is the legacy-firmware detection itself:
  firmware that predates the compat region never populates it and
  the driver reports and proceeds in legacy mode after the timeout
  (see Changes in v4); and the health_version read cannot race the
  RISC-V core initialization: the readiness skip fires only for
  firmware with patch < ZXDH_HPIRQ_PATCH, which never reports the
  power-on flag, while firmware that does report health_version
  carries patch >= ZXDH_HPIRQ_PATCH and initializes the health
  buffer before the compat block reports ready.

  [1] https://sashiko.dev/#/patchset/20261014151200489685SCIlolykW0NGfL5EtQ%40zte.com.cn

Changes in v5:
- Drop __packed from zxdh_fw_compat and zxdh_health_buffer: both
  structs are naturally aligned with no padding.

Changes in v4:
- Fold the irq and eq table create() steps into their init()
  counterparts and route every probe error path through the same
  destroy() functions remove() uses, so cleanup has a single
  authority from the start (review feedback on v3).
- Give the pool name a buffer bound of its own (16 bytes) instead of
  sharing the 100-byte IRQ name buffer, so W=1 builds stay clean of
  -Wformat-truncation (review feedback on v3).
- Lower the compat region wait from 200 s to 20 s: the firmware
  publishes the block within 10 s of boot, so twice that leaves
  margin, and the wait now sits far below the 180 s udev event
  window raised on the thread (review feedback on v3).
- Wait for the compat block with a per-field readiness check instead
  of only the first dword: the firmware fills the fields one by one,
  and a dword-granular check can read a half-populated block (the
  "single write" justification given in v3 was wrong).
- Log the legacy-firmware assumption when the compat region wait
  times out, making the intentionally ignored timeout visible.

Changes in v3:
- Unmap the modern config MMIO regions on the probe error paths added
  in this series; they used to leak when the fw compat check or the
  RISC-V readiness wait failed.
- Skip the RISC-V readiness wait for firmware without the compat
  region: the erased patch field read as 0xffff and defeated the skip.
- Make fw_minor unsigned so firmware minor versions >= 128 are not
  rejected through sign wrap.
- Balance the per-CPU IRQ accounting on release, so pool teardown does
  not trip its leftover WARN; set the IRQ affinity for real with
  irq_set_affinity_and_hint() instead of only updating the hint; name
  IRQs after their pool instead of a hardcoded prefix; assert that the
  pool is empty at free instead of force-releasing leftovers.
- Clear eq->irq when the async IRQ request fails, so teardown does not
  treat the ERR_PTR as a live IRQ.

Review findings not taken:

- xa_alloc() with a NULL entry does not fail: __xa_alloc() turns a
  NULL entry into the internal zero entry as a reservation
  (lib/xarray.c), which is the reservation semantics the pool relies
  on.
- BAR 0 length checks against a truncated bar: the bar layout is part
  of the board firmware contract and the driver does not defend
  against a broken device, as settled during the review of the
  earlier device bring-up series (Andrew Lunn).

Changes in v2:
- Convert both firmware readiness polls to readx_poll_timeout()
  (Andrew Lunn).
- Read the fw compat block field by field through ioread*() accessors
  instead of an ioread32_rep() bulk copy, which misplaces the u8/u16
  fields on big-endian; no __le annotations are needed since each
  accessor converts from little-endian (Andrew Lunn).
- Use kref for the IRQ reference count (Andrew Lunn).

Junyang Han (3):
  dinghai: add firmware version check and RISC-V readiness polling
  dinghai: add MSI-X interrupt pools
  dinghai: add async event queue for firmware notifications

 drivers/net/ethernet/zte/dinghai/Makefile   |   2 +-
 drivers/net/ethernet/zte/dinghai/en_pf.c    | 223 +++++++++++
 drivers/net/ethernet/zte/dinghai/en_pf.h    |  56 +++
 drivers/net/ethernet/zte/dinghai/zxdh_eq.c  | 137 +++++++
 drivers/net/ethernet/zte/dinghai/zxdh_eq.h  |  60 +++
 drivers/net/ethernet/zte/dinghai/zxdh_irq.c | 406 ++++++++++++++++++++
 drivers/net/ethernet/zte/dinghai/zxdh_irq.h |  73 ++++
 7 files changed, 956 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/zte/dinghai/zxdh_eq.c
 create mode 100644 drivers/net/ethernet/zte/dinghai/zxdh_eq.h
 create mode 100644 drivers/net/ethernet/zte/dinghai/zxdh_irq.c
 create mode 100644 drivers/net/ethernet/zte/dinghai/zxdh_irq.h

-- 
2.27.0
Technical Details
Message-ID: <20261113134743145KUhKvpwU6uqR0QzymEP96@zte.com.cn>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362434-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362434-linux-kernel-netdev=dewy.ru
From: han.junyang@zte.com.cn
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v6 0/3] dinghai: firmware handshake, MSI-X pools and async event queues
Date: Fri, 13 Nov 2026 13:47:43 +0800 (CST)
Organization: Usenet Network
Message-ID: <20261113134743145KUhKvpwU6uqR0QzymEP96@zte.com.cn>
MIME-Version: 1.0
Content-Type: text/plain;
	charset="UTF-8"
Injection-Info: usenet.network;
	logging-data="1276230"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:xBABr+MfqXv+yE8npDm7DHsuUlE= sha256:QO+zkKJHxL77AyOR8hfJhw2sk93SFurIJx2t016nhUg=
	sha1:YkJ6R862E5fcsFF0qk+kX8l14pE= sha256:OO9RyLMs/OrKI3G9x6nMmem/RhWIBcz9aw0Lxwar9R8=
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 19BF1114493; Fri, 13 Nov 2026 09:04:47 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.149
X-Spam-Status: No, score=-3.149 tagged_above=-9999 required=6.31
	tests=[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 s8GWWXwSTVAJ;
	Fri, 13 Nov 2026 09:04:42 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-362434-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 6D50B114464; Fri, 13 Nov 2026 09:04:32 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 3CB016155BA; Fri, 13 Nov 2026 05:48:12 +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=1794548885;
	b=LQSHVGdBjNcTNMCm4QEGve/w0+d0V5L61q+IDargnPkJbrDLhDRz8MhHFl0/B8dKhoLl
	 dDlJHpb3IaXslLZixVE4o2nrVC/hFDtd+Pt+f0RsdlRzjD0HlXWz4o31uo2yFCccZpQIm
	 wOnUYcuNKiJFoOaCQmKsUuIClWqQQZdcGbJfh8pqQRAiZR78/BOscnHQ3LTo34n1TUjpN
	 cGKmn4lPz2UoxhufsuZWpPtiflqNvVFSsSysQGNeMetqfHqOW3n8TRWwhgAVn2912Punr
	 8+o9EseBnKn9EEsiyHm94Mekn3j9ezp1UiM7UWA5LZDMwL3W2SAWpWZxraF2rZ5s8pQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794548885;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:Received:
	 Received:X-Zmail-TransId:X-Mailer:Message-ID: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=R/hztUFaUrZAxIgTvQh2iT2CdtlyFnFy+Eg07zRqZOY=;
	b=PeR6AZAv9A9LZVlleLR/vGg3HfuF1YTXCPgNwVc5++lA0uXTA5ju9QBE0fywJcD203Gu
	 Bk3ozH2B+Jm3GegNajLdz/aNP2cun9B6TEnR4/yGiY4RZYJl8Zg3Dh2ykXf5NEgO7Dk15
	 cEZ8Y5d6BwOyEG/XlWlCnCtxfqlMIg9vRTX4mLOzPgVqVRT/JMAYMN9cwt1UodqklWEq9
	 hE+54Hk9vuCI+EpQEqaw3cG7yNbbAwFhfHg4yNLzbqKA0bnSMFgT8GYb8+zg+pxrDXaKf
	 y76dxLTpUDUAMh355EGe0qK/OORlDoR4gZY/LMHlIjnCv1gXdR0AEdWGVhcMKI3Nnog==
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=AfzLxChg;
	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 8F9DE606A332;
	Fri, 13 Nov 2026 05:48:05 +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=AfzLxChg
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=1794548879;
	b=v7sPsP56a4NjTackHHFaZqlaqQdfK21Z1QiZ5NSEBre44PyfqQBqU6GxH2ZhT6dLqJDE
	 /W2D2FFUyEP8fvUcx1T3D/l5viwnfq/pOWtkjv+NoedCZwH+u1vnCksggRVNPRQvQDllB
	 eyUaLY9DhrL4OGALgE5tTAYUVFrTmP2Ao19polvxsBByXpjzojS1e5nRocRfsEkBG2JlV
	 ZPDBpvdu0zI0+3vLAx8kCJXIzWD9Dzr8/ZK2wkU9vTCNknGG0pGw21wia7pW66msGhunZ
	 lExvlV0yAS6Z1LFSpKrshySD4YlT2rpGNhsFTMXzXqB+f8vSJWDIeQ4KGJto5EmXPCA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794548879;
	h=DMARC-Filter:Received:DKIM-Signature:Received:Received:
	 X-Zmail-TransId:X-Mailer:Message-ID: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=R/hztUFaUrZAxIgTvQh2iT2CdtlyFnFy+Eg07zRqZOY=;
	b=j51XL0vjeqRMf45oJqvnse+v3+WX35EwS3PpK7b8vYKulglG8QVw6VJuE4N3cw1oiJju
	 4TTvfw/Zjl5z3y/7p49HqpzLnQ3PAkrIBQ64VQW2FrVX2hsPFiY0XxaISUDbJNRK5MAPW
	 mAx8K7XDmXa6XGpRn6DQitZf3nmNiViy3oPRcYxDwG2Fqi0Nleg8xrYhKv0J/+MKsOHPq
	 oLCThvm10IdOkTfDeproox+c1FioyTl2WQvPDvKVJQgsrSvD6FIQHZDSmK0pnGbiNl/oC
	 /v1X6Jm0qMr7m7cnCxNdD1Q/MYAZrP/XWbQxTfUxNipOm3PQFxjywG84NFU24BFBNWA==
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=AfzLxChg;
	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 A1EB5606A31C;
	Fri, 13 Nov 2026 05:47:58 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A1EB5606A31C
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 4jQmWB36d5z8XrrX;
	Fri, 13 Nov 2026 13:47:50 +0800 (CST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=zte.com.cn;
	s=z202610; t=1794548870;
	bh=UkjlPYbBuRGHzyN4ugD8RnQAqPPcq9laiZwvRkBQXrM=;
	h=Date:From:To:Cc:Subject;
	b=AfzLxChgLbyzAcIvsQD3luXLmJNhwgRBhIyKuG+GNGbToA4WSO8+pvxReMuLf+Cd9
	 txmQkvo9NZ9YdyM/TEDxLcYPSrHqsiYJCuYPIfR1S16bobSK+w8ThOiKXtk5wAcA48
	 BCvfq+aAn+BU4lSXdwRRNCeljbwZjPlF1OLOAgbUfLj3iYdV+69xLFKi/8htoLAUSn
	 2zZTO0vhHKAfd/JS70MrifMik6ncyGH5uE7dCdjTiRmsxH9KYiTGD0I4rQyuRWbi+d
	 31dOoLHrThrs/wt4V5EfL/diAaHAyOfzgZTqCq62KTaTwE2fT9clqDhqKIH3fJtgM3
	 R2DFGRm1ASedg==
X-Received: from njb2app06.zte.com.cn ([10.55.23.119])
	by mse-fl1.zte.com.cn with SMTP id 6AD5lfHB034786;
	Fri, 13 Nov 2026 13:47:41 +0800 (+08)
	(envelope-from han.junyang@zte.com.cn)
X-Received: from mapi (njb2app07[null])
	by mapi (Zmail) with MAPI id mid204;
	Fri, 13 Nov 2026 13:47:43 +0800 (CST)
X-Zmail-TransId: 2aff6af6a47f68e-346b4
X-Mailer: Zmail v1.0
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: <linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
        <han.junyang@zte.com.cn>, <ran.ming@zte.com.cn>,
        <han.chengfei@zte.com.cn>, <zhang.yanze@zte.com.cn>
X-MAIL: mse-fl1.zte.com.cn 6AD5lfHB034786
X-TLS: YES
X-ENVELOPE-SENDER: han.junyang@zte.com.cn
X-SOURCE-IP: 10.5.228.132 unknown Fri, 13 Nov 2026 13:47:50 +0800
X-CLEAN: YES
X-Fangmail-Anti-Spam-Filtered: true
X-Fangmail-MID-QID: 6AF6A486.000/4jQmWB36d5z8XrrX