Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: sashiko-reviews@lists.linux.dev, linux-pci@vger.kernel.org,
	"Rafael J . Wysocki" <rafael@kernel.org>,
	Marco Nenciarini <mnencia@kcore.it>,
	Michal Winiarski <michal.winiarski@intel.com>,
	Ilpo Jarvinen <ilpo.jarvinen@linux.intel.com>,
	Eric Chanudet <echanude@redhat.com>,
	Jean Guyader <jean.guyader@gmail.com>,
	Alex Williamson <alex@shazbot.org>, Sinan Kaya <okaya@kernel.org>,
	Mario Limonciello <superm1@kernel.org>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	linux-kernel@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>
Subject: Re: [PATCH v1] PCI: Wait for device readiness after D3hot -> D0uninitialized transition
Date: Fri, 15 May 2026 14:46:54 +0200	[thread overview]
Message-ID: <agcVvg1ntQPbivr9@wunner.de> (raw)
In-Reply-To: <20260514213811.GA434353@bhelgaas>

On Thu, May 14, 2026 at 04:38:11PM -0500, Bjorn Helgaas wrote:
> On Thu, May 14, 2026 at 08:06:25PM +0000, sashiko-bot@kernel.org wrote:
> > > +		if (!(pmcsr & PCI_PM_CTRL_NO_SOFT_RESET))
> > > +			pci_dev_wait(dev, "power up D3hot->D0uninitialized",
> > > +				     PCIE_RESET_READY_POLL_MS);
> > 
> > Is it safe to ignore the return value of pci_dev_wait() here?
> > 
> > If the device times out or disconnects, pci_dev_wait() returns -ENOTTY. By
> > ignoring this error, pci_power_up() continues, unconditionally sets
> > dev->current_state = PCI_D0, and can return success (1 for need_restore).
> > 
> > If pci_power_up() returns success, will callers like pci_back_from_sleep()
> > execute pci_restore_state() against an unresponsive device, which could
> > potentially trigger PCIe Master Aborts, AER events, or system crashes?
> > 
> > Should pci_power_up() propagate the error from pci_dev_wait() to prevent
> > this?
> 
> Good point.  I think it should look like this instead:
> 
>     if (state == PCI_D3hot) {
>             pci_dev_d3_sleep(dev);
>             if (!(pmcsr & PCI_PM_CTRL_NO_SOFT_RESET)) {
>                     ret = pci_dev_wait(dev, "power up D3hot->D0uninitialized",
>                                        PCIE_RESET_READY_POLL_MS);
>                     if (ret) {
>                             pci_err(dev, "Not ready after soft reset\n");
>                             dev->current_state = PCI_D3cold;
>                             return -EIO;
>                     }

pci_dev_wait() already emits a warning message on timeout, so the
additional pci_err() is probably not needed.  Otherwise the user
would see duplicate messages, i.e.:

  pci SSSS:BB:DD.F: not ready 60000ms after power up D3hot->D0uninitialized
  pci SSSS:BB:DD.F: Not ready after soft reset

Thanks,

Lukas

  parent reply	other threads:[~2026-05-15 12:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-14 15:31 [PATCH v1] PCI: Wait for device readiness after D3hot -> D0uninitialized transition Bjorn Helgaas
2026-05-14 18:52 ` Mario Limonciello
2026-05-14 20:06 ` sashiko-bot
2026-05-14 21:38   ` Bjorn Helgaas
2026-05-15 11:26     ` Rafael J. Wysocki
2026-05-15 11:41     ` Mika Westerberg
2026-05-15 11:57       ` Rafael J. Wysocki
2026-05-15 12:15         ` Mika Westerberg
2026-05-15 12:46     ` Lukas Wunner [this message]
2026-05-15 15:47       ` Bjorn Helgaas

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=agcVvg1ntQPbivr9@wunner.de \
    --to=lukas@wunner.de \
    --cc=alex@shazbot.org \
    --cc=bhelgaas@google.com \
    --cc=echanude@redhat.com \
    --cc=helgaas@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jean.guyader@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=michal.winiarski@intel.com \
    --cc=mika.westerberg@linux.intel.com \
    --cc=mnencia@kcore.it \
    --cc=okaya@kernel.org \
    --cc=rafael@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=superm1@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