mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Francisco Beltrán Millalén" <fbeltranmillalen@gmail.com>
To: helgaas@kernel.org
Cc: bhelgaas@google.com, linux-pci@vger.kernel.org,
	stern@rowland.harvard.edu, gregkh@linuxfoundation.org,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	lukas@wunner.de, alifm@linux.ibm.com, andreas.noever@gmail.com,
	westeri@kernel.org, YehezkelShB@gmail.com
Subject: Re: [PATCH v2 2/3] PCI/PM: Do not save the config space of an inaccessible device
Date: Sun, 11 Oct 2026 18:04:51 -0300	[thread overview]
Message-ID: <20261011210451.12129-1-fbeltranmillalen@gmail.com> (raw)
In-Reply-To: <7ed02ff5-d7f8-42e4-bca9-b3d3ce7b6795@linux.ibm.com>

Hi Bjorn,

Thanks, Farhan, for the pointer to the earlier discussion.  I hadn't
seen it.

On Fri, Oct 09, 2026 at 10:08:15AM -0700, Farhan Ali wrote:
> When I had initially looked into this, I had proposed adding the
> accessibility check in pci_save_state() as well [1]. Though Lukas had
> some valid concerns around the additional overhead from adding it in
> pci_save_state(). But maybe its worth re-visiting again?

After reading that thread I went through the callers of
pci_save_state().  When a device is already inaccessible while its
driver's suspend callback runs, for example because it dropped off the
bus and hasn't been removed yet, returning -EIO from pci_save_state()
changes what some drivers do:

- Some return the error from their suspend callback, so system suspend
  is aborted: stmmac_pci_plat_suspend() (used by stmmac_pci,
  dwmac-loongson and dwmac-motorcomm), intel_eth_pci_suspend(),
  atl1e_suspend(), atl2_suspend() and amd_mp2_pci_suspend().  Today
  pci_save_state() returns 0 in that case, and these drivers go on.

- Many more ignore the return value and then put the device into D3hot,
  for example ata_pci_device_do_suspend(), which most libata PCI drivers
  use.  On an inaccessible device that marks it D3cold, and since
  state_saved is now false, pci_legacy_suspend() or pci_pm_suspend()
  warns once that the state was not saved.  This is the same warning
  that patch 1 avoids for the USB HCD in suspend_noirq.

I found all of this by reading the code; I can't test these drivers.
I think this is what Lukas meant about callers that don't need the
check.

The underlying problem is that pci_save_state() doesn't check that the
device answered: for an inaccessible device it fills the saved header
with all ones, marks the state saved and returns 0, and
pci_restore_state() later writes those values back.  What I have
prepared for v3 fixes it in pci_save_state() itself, with the changes
you suggested: it checks once that the device is accessible and returns
-EIO if it isn't, and pci_dev_save_and_disable() uses the return value.
v2 2/3 returns -EIO in the same way.  The drivers above are the side
effect of that: they now see a failure where they never saw one before.

I found this only recently, so I'd rather not send v3, and I'd ask you
not to apply v2 2/3 as it is, until you've had a chance to look at
this.  Patch 3 doesn't depend on it.  How would you like these drivers
to be handled?

Thanks again,
Francisco

[1] https://lore.kernel.org/all/aOQX6ZTMvekd6gWy@wunner.de/

  reply	other threads:[~2026-10-11 21:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-30 14:19 [PATCH v2 0/3] " Francisco Beltrán Millalén
2026-09-30 14:19 ` [PATCH v2 1/3] usb: hcd-pci: Honour pci_save_state() failure Francisco Beltrán Millalén
2026-09-30 14:19 ` [PATCH v2 2/3] PCI/PM: Do not save the config space of an inaccessible device Francisco Beltrán Millalén
2026-10-08 22:58   ` Bjorn Helgaas
2026-10-09  2:41     ` Francisco Beltrán Millalén
2026-10-09 17:08     ` Farhan Ali
2026-10-11 21:04       ` Francisco Beltrán Millalén [this message]
2026-09-30 14:19 ` [PATCH v2 3/3] PCI: Do not mistake an absent device for an active link Francisco Beltrán Millalén
2026-10-08 18:55 ` [PATCH v2 0/3] PCI/PM: Do not save the config space of an inaccessible device Darrell Gum
2026-10-08 22:34 ` Bjorn Helgaas
2026-10-09  2:40   ` Francisco Beltrán Millalén

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=20261011210451.12129-1-fbeltranmillalen@gmail.com \
    --to=fbeltranmillalen@gmail.com \
    --cc=YehezkelShB@gmail.com \
    --cc=alifm@linux.ibm.com \
    --cc=andreas.noever@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=helgaas@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=stern@rowland.harvard.edu \
    --cc=westeri@kernel.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

all inboxes | Powered by JetHome®