🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #20619

Re: [PATCH net-next v3 3/3] ionic: add devlink param for command timeout

#20619
From: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 00:59
221 lines
15743 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 2 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] If the firmware advertises IONIC_DEV_CAP_CMD_TIMEOUT but the
  IONIC_DEV_ATTR_CMD_TIMEOUT GETATTR fails, ionic_update_cmd_timeout()…
- [Medium] ionic_dl_cmd_timeout_set()
  (drivers/net/ethernet/pensando/ionic/ionic_devlink.c) checks…
- [Low] ionic_set_cmd_timeout()
  (drivers/net/ethernet/pensando/ionic/ionic_dev.c) sends the SETATTR…

--

ionic: add devlink param for command timeout

This adds a permanent devlink parameter, cmd_timeout (u8, seconds), to
ionic. It is stored in device NVM through a new device attribute and is
only offered when the firmware advertises IONIC_DEV_CAP_CMD_TIMEOUT. A
non-zero value replaces the device command and admin queue timeouts and
the heartbeat interval at the next probe or reset.

> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.c b/drivers/net/ethernet/pensando/ionic/ionic_dev.c
> index f14fff4a74278..8e8f7d8d174e1 100644
> --- a/drivers/net/ethernet/pensando/ionic/ionic_dev.c
> +++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.c

[ ... ]

> @@ -689,6 +690,62 @@ void ionic_dev_cmd_reset(struct ionic_dev *idev)
>  	ionic_dev_cmd_go(idev, &cmd);
>  }
>  
> +void ionic_update_cmd_timeout(struct ionic *ionic)
> +{
> +	union ionic_dev_cmd_comp comp = {};
> +	union ionic_dev_cmd cmd = {
> +		.getattr.opcode = IONIC_CMD_GETATTR,
> +		.getattr.attr = IONIC_DEV_ATTR_CMD_TIMEOUT,
> +	};
> +	u8 timeout = IONIC_CMD_TIMEOUT_DEF;
> +	int err;
> +
> +	mutex_lock(&ionic->dev_cmd_lock);
> +	if (!ionic_cmd_timeout_supported(ionic)) {
> +		WRITE_ONCE(ionic->cmd_timeout, timeout);
> +		WRITE_ONCE(ionic->cmd_timeout_param, -EOPNOTSUPP);
> +		goto out;
> +	}
> +
> +	ionic_dev_cmd_go(&ionic->idev, &cmd);
> +	err = ionic_dev_cmd_wait_nomsg(ionic, ionic->cmd_timeout);
> +	if (err) {
> +		dev_warn(ionic->dev, "Cannot get cmd_timeout: %d, keeping %u\n",
> +			 err, ionic->cmd_timeout);
> +		goto out;
> +	}

[Severity: Medium]
What happens to cmd_timeout_param if the firmware advertises
IONIC_DEV_CAP_CMD_TIMEOUT but this GETATTR fails? It could fail with
-ETIMEDOUT after the 5 second default wait, with -ENXIO when the firmware
is down, or with a firmware error status.

At probe time, ionic_probe() has just done this:

	ionic->cmd_timeout_param = -EOPNOTSUPP;

The goto out leaves that value in place. Both devlink callbacks then treat
the negative value as "unsupported":

ionic_dl_cmd_timeout_get()
	val = READ_ONCE(ionic->cmd_timeout_param);
	if (val < 0)
		return val;

ionic_dl_cmd_timeout_validate()
	cur = READ_ONCE(ionic->cmd_timeout_param);
	if (cur < 0)
		return cur;

As a result, a devlink param dump silently skips the parameter, a single
get reports "not supported", and validate rejects every set before
ionic_dl_cmd_timeout_set() is reached.

Doesn't that leave the user unable to see or raise cmd_timeout until the
next FW-up or PCI reset? That would happen on exactly the slow-firmware
device this parameter is meant for. The -EOPNOTSUPP also hides the fact
that the query itself failed.

On the fw_up path, after an earlier query succeeded, the same failure
leaves a stale positive value instead. What the user sees then depends on
what happened before.

> +
> +	ionic_dev_cmd_comp(&ionic->idev, &comp);
> +	if (comp.getattr.cmd_timeout >= IONIC_CMD_TIMEOUT_DEF)
> +		timeout = comp.getattr.cmd_timeout;
> +	else if (comp.getattr.cmd_timeout)
> +		dev_warn(ionic->dev, "Ignoring out of range cmd_timeout %u\n",
> +			 comp.getattr.cmd_timeout);
> +	WRITE_ONCE(ionic->cmd_timeout, timeout);
> +	WRITE_ONCE(ionic->cmd_timeout_param, comp.getattr.cmd_timeout);
> +out:
> +	mutex_unlock(&ionic->dev_cmd_lock);
> +}
> +
> +int ionic_set_cmd_timeout(struct ionic *ionic, u8 timeout)
> +{
> +	union ionic_dev_cmd cmd = {
> +		.setattr.opcode = IONIC_CMD_SETATTR,
> +		.setattr.attr = IONIC_DEV_ATTR_CMD_TIMEOUT,
> +		.setattr.cmd_timeout = timeout,
> +	};
> +	int err;
> +
> +	mutex_lock(&ionic->dev_cmd_lock);
> +	ionic_dev_cmd_go(&ionic->idev, &cmd);
> +	err = ionic_dev_cmd_wait(ionic, ionic->cmd_timeout);
> +	if (!err)
> +		WRITE_ONCE(ionic->cmd_timeout_param, timeout);

[Severity: Low]
This SETATTR writes the new value to NVM, but it only waits for the
current ionic->cmd_timeout, which is 5 seconds by default. The commit
message itself says the firmware can be alive but slower than that.

On timeout, __ionic_dev_cmd_wait() clears the command registers and
returns:

	if (!done && !time_before(jiffies, max_wait)) {
		ionic_dev_cmd_clean(ionic);
		...
		return -ETIMEDOUT;
	}

cmd_timeout_param is only updated on success, and nothing reads the
attribute back afterwards.

If the slow firmware still commits the NVM write, would
ionic_dl_cmd_timeout_get() keep reporting the old cached value while the
device holds the new one? The new value would then take effect without
notice at the next probe or reset, when ionic_update_cmd_timeout() reads
it again.

> +	mutex_unlock(&ionic->dev_cmd_lock);
> +
> +	return err;
> +}

[ ... ]

> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_devlink.c b/drivers/net/ethernet/pensando/ionic/ionic_devlink.c
> index 4ec66a6be0738..87bf23c3404ff 100644
> --- a/drivers/net/ethernet/pensando/ionic/ionic_devlink.c
> +++ b/drivers/net/ethernet/pensando/ionic/ionic_devlink.c

[ ... ]

> +static int ionic_dl_cmd_timeout_set(struct devlink *dl, u32 id,
> +				    struct devlink_param_gset_ctx *ctx,
> +				    struct netlink_ext_ack *extack)
> +{
> +	struct ionic *ionic = devlink_priv(dl);
> +
> +	if (test_bit(IONIC_LIF_F_FW_RESET, ionic->lif->state))
> +		return -EBUSY;
> +
> +	return ionic_set_cmd_timeout(ionic, ctx->val.vu8);
> +}

[Severity: Medium]
Is this test_bit() enough to keep ionic_set_cmd_timeout() from running
during a PCI reset?

The check takes no lock. ionic_set_cmd_timeout() then holds only
dev_cmd_lock while it uses the dev_cmd registers for up to cmd_timeout
seconds. The FLR/AER path takes neither dev_cmd_lock nor the devlink
instance lock:

ionic_reset_prepare()
	set_bit(IONIC_LIF_F_FW_RESET, lif->state);
	...
	ionic_dev_teardown(ionic);
	ionic_clear_pci(ionic);

ionic_clear_pci()
	ionic->idev.dev_info_regs = NULL;
	ionic->idev.dev_cmd_regs = NULL;
	...
	ionic_unmap_bars(ionic);
	pci_release_regions(ionic->pdev);

So a set that passes the test_bit() can still be polling when the BARs
are unmapped.

The NULL checks in ionic_dev_cmd_go(), ionic_dev_cmd_done() and
__ionic_is_fw_running() are unlocked check-then-use. The EAGAIN retry
branch in __ionic_dev_cmd_wait() has no NULL check at all:

	iowrite32(0, &idev->dev_cmd_regs->done);
	msleep(1000);
	iowrite32(1, &idev->dev_cmd_regs->doorbell);

Could a reset during that msleep() cause a NULL+offset MMIO write, or an
access to unmapped I/O memory?

The missing serialisation between reset teardown and dev_cmd users
predates this patch. The same test_bit(IONIC_LIF_F_FW_RESET) guard is also
used in ionic_set_link_ksettings() and ionic_set_pauseparam(). This patch
adds a new userspace entry point into that race.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119-b4-ionic-cmd-timeout-v3-0-2cdb8fca15fd%40amd.com
Technical Details
Message-ID: <179539559673.3135.12079878343644861835@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368921-linux-kernel-netdev=dewy.ru
References: <20261119-b4-ionic-cmd-timeout-v3-3-2cdb8fca15fd@amd.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368921-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v3 3/3] ionic: add devlink param for command timeout
Date: Mon, 23 Nov 2026 00:59:56 +0000
Organization: Usenet Network
Message-ID: <179539559673.3135.12079878343644861835@kernel.org>
References: <20261119-b4-ionic-cmd-timeout-v3-3-2cdb8fca15fd@amd.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3759054"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:MOuGU57kTkoSMdKq1l1LjPJz8KM= sha256:xnvFLk9DgBHJ9Ya84FNLcQzdg0D2Rz/gBhXnH/GH+FU=
	sha1:spZ/Fnc5Bm5eGB4fdxXZAgSmsQM= sha256:vLgKxOY5KE8hbvmdxluHVeu//gVSLlb8mNfCI79KtcM=
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 AF209125D87; Mon, 23 Nov 2026 04:00:42 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-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=kernel.org
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 w3aCMBLaEOG9;
	Mon, 23 Nov 2026 04:00:38 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-368921-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 457AC125D89; Mon, 23 Nov 2026 04:00:29 +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 78CE12DB4D; Mon, 23 Nov 2026 01:00:08 +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=1795395604;
	b=vknivnZolPeEiv3YSEm7YMmMhG7cifDGND5Unkh9oVUm+Bys41LKr/8w669gd45dhexa
	 stEYsVM8vhdUlm3A+UNRuGy1hDepuRs26nhgKTh/cGCbUs4dcqD5yaeZmSVDYKE/KQ+CC
	 yUuSu++A//aMG521dFZRH1OCDhUnUiIDQPPf+BIctE84QloCp9AdTZc6by6YejSQRRSJL
	 Mkzz9DffbwgaTNHXp9Ga0Kle0Vikmspdm8dodatgA+fSH0AmnTuOOcwp8/VA4nftX0ZGB
	 ZRqDfIIT/QtuhXQmd84cunGDwV7JNNhFKcNmxmCSgRHZKyzDulrglV/8TpnI2iiy+Bg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795395604;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=qTxce4dhFrzTlXqQZV4d0/BQMYVrWdfgLn8c+4Vl3nU=;
	b=mZQHaD3jcguQkD6WRTXeTuKpw4SaGsG5AHGGGSxbxrGRaGKV5pgKwpoTaySX8BzzF1wG
	 o0wSGNaSAjXU7ekgkQWlcDDY7qq9dSTqLM1XUbR418T3POpm6N6O5H0PIdqw8P+UB7lSy
	 lhPLSfCSJ6OstZgBxRuN1LsBOGMVqjD7uyNg9TlgUVq1LEvTTy/xT3YO9v5x67qQnHVAk
	 Apcg5rJx8QcwDmVQYmUmG7Aao7aqospnWgu/Ay2os5emUmeAPjCXx0jIANAcaNHCL9MOw
	 o5P2nFeVDVBPRx4eoEmwqtMkKwU28HGDnFS0yWC+PkHIeMrDkrIi0BNqtlmNuA8+qmg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KmTnxCTq;
	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 3B782606A6AD;
	Mon, 23 Nov 2026 01:00:04 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KmTnxCTq
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795395598;
	b=4Kphq0kiJBVVfOdd3ktRmGzaMB4aKQTkDx0kJVVs/QFVkbUQX8T5LMu8qwzLxdG6cxLH
	 Tk+kB8SuKkdWMnCs3D+jykW8+HIAQnVPwNIz/QTkneHUGvIl6+XyRQyBhbyQao7wMyvHY
	 1/SWNmYdRBTCAa7MB02Ri/0AiSO6oiYyUqP7ahjXeNuwHhp9fLPWp8VZY5wAFkiehCUjM
	 EZtuizw4O2hH5vp+9UhE+6j/czwz+01c87mrrQmdC38J9jC9IJCBofuQK0YgzZBgKKOtl
	 szq8xn+TkI0pT3gTrArfgRvroZCzXbXGuAd2LvnVIF9xTOT1R1LRmejmE99Y+hrE/UA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795395598;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=qTxce4dhFrzTlXqQZV4d0/BQMYVrWdfgLn8c+4Vl3nU=;
	b=WkOIoDynRo7vluTjiIHS+0jIwvYeBlfAcpLQ1sXefumB1UO+K4tAqNXrKyFL6gAVk+2u
	 U0i/mEMlGsdPf8KoaPJ/ta9qwHWqdVvDEfbJpzMXQobCa3AL9ccnckOjwPBlGbvwWJ6OS
	 PPdLDPrJVTLuAHzEw0KT2Evl66fQnk8EutdV1R4+NaUvvg4+9DjpxAVcNLEENtCz0hLPx
	 dF33c62//M4TuB/kf0KKqTvLXVfSFrSIZR9b1aOoB0PgvEWB8jZvRwRva2skVK/ArCMWE
	 T4d03QMDKbo8DFAOSmIDQrVIZdrDDcAa3+30uPbCGzQN42nD8NXffDufhPqVt4C7OaA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KmTnxCTq;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5ADB0606A681;
	Mon, 23 Nov 2026 00:59:58 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 248E21F000D3;
	Mon, 23 Nov 2026 00:59:57 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795395598;
	bh=qTxce4dhFrzTlXqQZV4d0/BQMYVrWdfgLn8c+4Vl3nU=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=KmTnxCTqxKsJd88PcN9Awqo3gQBgjz/elGW6aR7vMeLFZiEh8c/b3Y+VzhLZfPxTQ
	 PzmVLUgfRmYW/oy68Zi+pIDjMdtMoJ8r4U88lMLf1uQdT4CJ6uT3s7psK2S80fwZ6u
	 ZODpWk/h2+Scdh3BH42pO5PE9Sp1NCgmeTmATGReJxRoIowI/ZKsby2pqsRnpbHubb
	 d0Aftyau5E0b+uGow5M0wRAtG9R2SsjYEzOFqGDQHbIXLLprJ+atbFXWGxB87ZPMV/
	 0yf7rJueSkJhhXb++obdqXRb6IcU7+ZL7bif1LRsainm/kI7Iq51HWKeLRjeVWldfs
	 Ogx8tDttaVmRA==
X-Cc: brett.creeley@amd.com, andrew+netdev@lunn.ch, davem@davemloft.net,
 edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
 abhijit.gangurde@amd.com, allen.hubbe@amd.com, jgg@ziepe.ca, leon@kernel.org,
 jiri@resnulli.us, horms@kernel.org, corbet@lwn.net, skhan@linuxfoundation.org,
 rdunlap@infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
 linux-rdma@vger.kernel.org, linux-doc@vger.kernel.org, eric.joyner@amd.com,
 ArunKumar.Prakash@amd.com
X-In-Reply-To: <20261119-b4-ionic-cmd-timeout-v3-3-2cdb8fca15fd@amd.com>
X-sashiko-severity: Medium
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