Re: [PATCH net 1/4] ionic: fix devcmds racing the BAR unmap on PCI reset
From: netdev-bot+sashiko
Date: Wed Dec 02 2026 - 19:42:37 EST
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The patch makes `ionic->dev_cmd_lock` protect the lifetime of the
`idev.dev_cmd_regs` pointer, but the lock's comment in `struct ionic`…
--
ionic: fix devcmds racing the BAR unmap on PCI reset
This patch makes dev_cmd_lock protect idev.dev_cmd_regs. ionic_clear_pci()
now clears the pointer under the lock before BAR0 is unmapped.
ionic_get_regs() and ionic_firmware_update() now check the pointer for
NULL while holding the lock, and ionic_vf_start() now takes the lock
around its devcmd.
Closes: https://lore.kernel.org/netdev/179539559673.3135.12079878343644861835@xxxxxxxxxx/
> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c b/drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c
> index ddc2f9770df45..49941fc6bbc41 100644
> --- a/drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c
> +++ b/drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c
> @@ -219,7 +219,9 @@ static void ionic_clear_pci(struct ionic *ionic)
> {
> if (ionic->num_bars) {
> ionic->idev.dev_info_regs = NULL;
> + mutex_lock(&ionic->dev_cmd_lock);
> ionic->idev.dev_cmd_regs = NULL;
> + mutex_unlock(&ionic->dev_cmd_lock);
[Severity: Low]
This isn't a bug, but should the comment on dev_cmd_lock in struct ionic
(drivers/net/ethernet/pensando/ionic/ionic.h) be updated too? It still
says only:
struct mutex dev_cmd_lock; /* lock for dev_cmd operations */
After this patch, three places rely on the lock to keep
idev.dev_cmd_regs alive. This teardown in ionic_clear_pci() needs it, and
so do the new NULL checks in ionic_get_regs() and in the per-chunk loop
of ionic_firmware_update(). The code doesn't say anywhere that a reader
must hold dev_cmd_lock from the NULL check through the MMIO access.
The comment is still unchanged at the end of the series. The sibling
patch "ionic: fix PHC reads racing the BAR unmap on PCI reset" does
document its matching rule:
spinlock_t lock; /* lock for state_page, cc, tc and idev.hwstamp_regs */
Could dev_cmd_lock get a similar note, for example "lock for dev_cmd
operations and idev.dev_cmd_regs"?
One site still uses the pointer without the lock.
ionic_lif_queue_identify() computes &idev->dev_cmd_regs->data outside
the lock. Its only caller chain is ionic_probe()->ionic_lif_alloc(), and
the commit message excludes probe-time identify on purpose. That
exception is only in the commit message, though, and not in the code.
> ionic->idev.intr_status = NULL;
> ionic->idev.intr_ctrl = NULL;
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202-b4-pr60-v1-0-b1f6706e065b%40amd.com