From: netdev-bot+sashiko@kernel.org
To: nikhil.rao@amd.com
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
Subject: Re: [PATCH net-next v3 3/3] ionic: add devlink param for command timeout
Date: Mon, 23 Nov 2026 00:59:56 +0000 [thread overview]
Message-ID: <179539559673.3135.12079878343644861835@kernel.org> (raw)
In-Reply-To: <20261119-b4-ionic-cmd-timeout-v3-3-2cdb8fca15fd@amd.com>
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
prev parent reply other threads:[~2026-11-23 0:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 0:32 [PATCH net-next v3 0/3] ionic: make the device command timeout configurable Nikhil P. Rao
2026-11-19 0:32 ` [PATCH net-next v3 1/3] ionic: make the command timeout per device Nikhil P. Rao
2026-11-19 0:42 ` sashiko-bot
2026-11-19 0:32 ` [PATCH net-next v3 2/3] RDMA/ionic: Use the ionic command timeout for the admin queue Nikhil P. Rao
2026-11-19 0:42 ` sashiko-bot
2026-11-23 0:59 ` netdev-bot+sashiko
2026-11-19 0:32 ` [PATCH net-next v3 3/3] ionic: add devlink param for command timeout Nikhil P. Rao
2026-11-19 0:42 ` sashiko-bot
2026-11-23 0:59 ` netdev-bot+sashiko [this message]
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=179539559673.3135.12079878343644861835@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=ArunKumar.Prakash@amd.com \
--cc=abhijit.gangurde@amd.com \
--cc=allen.hubbe@amd.com \
--cc=andrew+netdev@lunn.ch \
--cc=brett.creeley@amd.com \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=eric.joyner@amd.com \
--cc=horms@kernel.org \
--cc=jgg@ziepe.ca \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nikhil.rao@amd.com \
--cc=pabeni@redhat.com \
--cc=rdunlap@infradead.org \
--cc=skhan@linuxfoundation.org \
/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