From: <han.junyang@zte.com.cn>
To: <horms@kernel.org>
Cc: <andrew+netdev@lunn.ch>, <davem@davemloft.net>,
<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
<linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
<ran.ming@zte.com.cn>, <han.chengfei@zte.com.cn>,
<zhang.yanze@zte.com.cn>
Subject: Re: [PATCH net-next v3 1/3] dinghai: add firmware version check and? RISC-V readiness polling
Date: Mon, 28 Sep 2026 20:00:09 +0800 (CST) [thread overview]
Message-ID: <202609282000093256VYStp2PkmdFF-bDbs4Yv@zte.com.cn> (raw)
In-Reply-To: <20260922101132.GB13925@horms.kernel.org>
On Mon, Sep 21, 2026 at 02:56:44PM +0800, han.junyang@zte.com.cn wrote:
> From: Junyang Han <han.junyang@zte.com.cn>
>
> The DingHai firmware publishes a version compatibility block and a
> RISC-V health buffer at fixed offsets within BAR 0.
>
> After the PCI capabilities are mapped, poll the compatibility block
> until the firmware populates it (the region reads as all ones until
> then) and verify the driver/firmware version contract. Then wait for
> the RISC-V management core to set its power-on flag in the health
> buffer before the rest of the probe continues.
>
> Firmware images predating the health buffer protocol (health version
> other than 1 and patch level below ZXDH_HPIRQ_PATCH) skip the
> readiness wait.
>
> Signed-off-by: Junyang Han <han.junyang@zte.com.cn>
> ---
> drivers/net/ethernet/zte/dinghai/en_pf.c | 113 +++++++++++++++++++++++
> drivers/net/ethernet/zte/dinghai/en_pf.h | 46 +++++++++
> 2 files changed, 159 insertions(+)
>
> diff --git a/drivers/net/ethernet/zte/dinghai/en_pf.c b/drivers/net/ethernet/zte/dinghai/en_pf.c
> index 86d437408820..7c991e0951a8 100644
> --- a/drivers/net/ethernet/zte/dinghai/en_pf.c
> +++ b/drivers/net/ethernet/zte/dinghai/en_pf.c
> @@ -6,6 +6,8 @@
>
> #include <linux/module.h>
> #include <linux/pci.h>
> +#include <linux/io.h>
> +#include <linux/iopoll.h>
> #include <net/devlink.h>
> #include <linux/dma-mapping.h>
> #include "en_pf.h"
> @@ -369,6 +371,103 @@ int zxdh_pf_modern_cfg_init(struct zxdh_core_dev *zxdh_dev)
> return ret;
> }
>
> +/* Read the firmware version block and verify the driver/firmware
> + * version contract.
> + */
> +static int zxdh_pf_fw_compat_check(struct zxdh_core_dev *zxdh_dev)
> +{
> + struct zxdh_pf_dev *pf_dev = zxdh_dev->priv;
> + struct zxdh_fw_compat __iomem *compat;
> + struct zxdh_fw_compat *fw_compat;
> + u32 erased;
> +
> + fw_compat = &pf_dev->fw_compat;
> + compat = pf_dev->pci_ioremap_addr[0] + ZXDH_FW_COMPAT_OFFSET;
> +
> + /* The region reads as all ones until the firmware populates it at
> + * the end of its boot; allow up to 200 s for a cold boot.
> + */
> + readx_poll_timeout(ioread32, compat, erased, erased != 0xffffffffU,
> + USEC_PER_SEC,
> + ZXDH_FW_COMPAT_TIMEOUT_SEC * USEC_PER_SEC);
> Hi,
> There is an AI-generated review of this patch available at
> https://sashiko.dev/#/patchset/202609211451400236_aZ55Ox3y7NW8MQnYImM%40zte.com.cn
> In my view the critical point made there, which I'd appreciate you looking
> into, is:
> Is the timeout error intentionally ignored here? If legacy firmware never
> populates this region, wouldn't the 200 second stall exceed the default
> udev timeout (180s), causing the worker to be killed and completely
> breaking legacy hardware support?
The ignored return value is intentional: distinguishing "firmware has not
populated the region yet" from "firmware never will" is only possible by waiting,
so the timeout itself is the legacy-firmware detection. On timeout the module id
check fails and the driver defers the decision to the readiness wait as
described in the commit message.
The udev concern is addressed in v4 by budget: the firmware publishes
the block within 10 s of boot, and the wait is now bounded at 20 s, an
order of magnitude below the 180 s event window, so even the
module-load path no longer risks the worker timeout. v4 also logs
the "assuming legacy firmware" case when the wait gives up.
While at it, the wait now checks every field of the block instead of
only the first dword: the firmware fills the fields one by one, so a
dword-granular check could observe a half-populated block.
next prev parent reply other threads:[~2026-09-28 12:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 6:51 [PATCH net-next v3 0/3] dinghai: firmware handshake, MSI-X pools and async event queues han.junyang
2026-09-21 6:56 ` [PATCH net-next v3 1/3] dinghai: add firmware version check and RISC-V readiness polling han.junyang
2026-09-22 10:11 ` [PATCH net-next v3 1/3] dinghai: add firmware version check and? " Simon Horman
2026-09-28 12:00 ` han.junyang [this message]
2026-09-21 6:59 ` [PATCH net-next v3 2/3] dinghai: add MSI-X interrupt pools han.junyang
2026-09-22 10:09 ` Simon Horman
2026-09-24 16:00 ` Jakub Kicinski
2026-09-25 13:16 ` Simon Horman
2026-09-28 12:10 ` han.junyang
2026-09-21 7:03 ` [PATCH net-next v3 3/3] dinghai: add async event queue for firmware notifications han.junyang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202609282000093256VYStp2PkmdFF-bDbs4Yv@zte.com.cn \
--to=han.junyang@zte.com.cn \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=han.chengfei@zte.com.cn \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=ran.ming@zte.com.cn \
--cc=zhang.yanze@zte.com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®