Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "François-Xavier Gsell" <fxgsell@gmail.com>,
	intel-wired-lan@lists.osuosl.org
Subject: Re: [PATCH iwl-net 2/2] igb: restore hw_addr on resume after a failed register read
Date: Sun, 06 Dec 2026 11:37:48 +0000	[thread overview]
Message-ID: <sashiko-outbox-252382@kernel.org> (raw)
In-Reply-To: <20261205113710.1833153-3-fxgsell@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] igb: hw_addr restored before pci_enable_device_mem() in
  __igb_resume()
- [Low] igb: unmarked hw_addr write in __igb_resume() races with
  READ_ONCE()
--

commit 334886b78bdce69dc089cafc1bf95f645f2e0b59
Author: François-Xavier Gsell <fxgsell@gmail.com>

igb: restore hw_addr on resume after a failed register read

This commit restores hw->hw_addr from adapter->io_addr in __igb_resume()
once pci_device_is_present() succeeds.

> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
> index dc59a429cb058..8451c79f61304 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> @@ -9614,6 +9614,10 @@ static int __igb_resume(struct device *dev, bool rpm)
>  
>  	if (!pci_device_is_present(pdev))
>  		return -ENODEV;
> +
> +	/* A failed register read may have cleared hw_addr. */
> +	hw->hw_addr = adapter->io_addr;
> +
>  	err = pci_enable_device_mem(pdev);
>  	if (err) {
>  		dev_err(&pdev->dev,

[Severity: Medium]
Should hw->hw_addr be restored after pci_enable_device_mem() succeeds
rather than before it?

If pci_enable_device_mem() fails, __igb_resume() returns an error while
leaving hw->hw_addr non-NULL on a disabled PCI device.  Later callers
such as igb_remove() then bypass E1000_REMOVED(hw_addr) and issue MMIO
accesses to a disabled device.

During runtime resume, publishing hw->hw_addr before memory decoding is
enabled also lets a concurrent reader without a runtime PM reference undo
the recovery:

CPU0                              CPU1
igb_runtime_resume()
  __igb_resume()
    hw->hw_addr = adapter->io_addr
                                  igb_ptp_gettimex_i210()
                                    rd32(E1000_SYSTIMR)
                                      readl() -> 0xffffffff
                                      hw->hw_addr = NULL  <-- clears again
    pci_enable_device_mem()

Restoring hw->hw_addr right before igb_init_interrupt_scheme(), after
pci_enable_device_mem() and pci_set_master() as igb_io_slot_reset() does,
avoids both issues.

[Severity: Low]
Should this use WRITE_ONCE(hw->hw_addr, adapter->io_addr)?

igb_rd32() and wr32() load hw->hw_addr locklessly with READ_ONCE(), while
igb_runtime_resume() runs concurrently with readers like
igb_ptp_gettimex_i210() without a shared lock.  A plain store causes a
KCSAN data race and permits store tearing of the pointer write.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261205113710.1833153-1-fxgsell@gmail.com?part=2

      reply	other threads:[~2026-12-06 11:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05 11:37 [PATCH iwl-net 0/2] igc/igb: recover register access on resume François-Xavier Gsell
2026-12-05 11:37 ` [PATCH iwl-net 1/2] igc: restore hw_addr on resume after a failed register read François-Xavier Gsell
2026-12-06 11:37   ` sashiko-bot
2026-12-05 11:37 ` [PATCH iwl-net 2/2] igb: " François-Xavier Gsell
2026-12-06 11:37   ` sashiko-bot [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=sashiko-outbox-252382@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=fxgsell@gmail.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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