Linux ATA/IDE development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Weidong Wang" <weidongw@illinois.edu>
Cc: linux-ide@vger.kernel.org, dlemoal@kernel.org, cassel@kernel.org
Subject: Re: [PATCH] ata: libata-core: Do not use pcim_enable_device() on PCI resume
Date: Sun, 29 Nov 2026 03:21:53 +0000	[thread overview]
Message-ID: <sashiko-outbox-239294@kernel.org> (raw)
In-Reply-To: <20261128-kbug-l080-v1-1-90f7309990ea@illinois.edu>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] ata: pata_triflex: unbalanced pci_enable_device() on resume
--

commit ec840bfcc0d665f55fd42682dab5f06844d5702d
Author: Weidong Wang <weidongw@illinois.edu>

ata: libata-core: Do not use pcim_enable_device() on PCI resume

This commit switches ata_pci_device_do_resume() from pcim_enable_device()
to pci_enable_device() so that resume does not register a duplicate
devres disable action, and open-codes cs5520_reinit_one() to avoid an
enable count imbalance on pata_cs5520.

> diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
> index f41ab71fc9e2b..587a393d27535 100644
> --- a/drivers/ata/libata-core.c
> +++ b/drivers/ata/libata-core.c
> @@ -6622,7 +6622,13 @@ int ata_pci_device_do_resume(struct pci_dev *pdev)
>  	pci_set_power_state(pdev, PCI_D0);
>  	pci_restore_state(pdev);
>  
> -	rc = pcim_enable_device(pdev);
> +	/*
> +	 * Balance the pci_disable_device() done on suspend. The devres action
> +	 * registered by pcim_enable_device() at probe time is still in place,
> +	 * so do not use pcim_enable_device() here or one more disable action
> +	 * would be added on every resume.
> +	 */
> +	rc = pci_enable_device(pdev);
>  	if (rc) {
>  		dev_err(&pdev->dev,
>  			"failed to enable device after resume (%d)\n", rc);

[Severity: Medium]
Does this leave pdev->enable_cnt unbalanced on pata_triflex after
suspend and resume?

Like pata_cs5520, pata_triflex does not disable the PCI device on
suspend, but still uses ata_pci_device_resume() ->
ata_pci_device_do_resume() for resume:

drivers/ata/pata_triflex.c:triflex_ata_pci_device_suspend() {
	...
	/*
	 * We must not disable or powerdown the device.
	 * APM bios refuses to suspend if IDE is not accessible.
	 */
	pci_save_state(pdev);

	return 0;
}

With pci_enable_device() here, each resume of pata_triflex increments
pdev->enable_cnt without a matching disable on suspend or devres action
on detach, so the single probe-time pcim_disable_device() action no
longer brings enable_cnt to zero on driver unbind or module unload and
leaves the PCI device enabled.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261128-kbug-l080-v1-1-90f7309990ea@illinois.edu?part=1

  reply	other threads:[~2026-11-29  3:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29  3:11 [PATCH] ata: libata-core: Do not use pcim_enable_device() on PCI resume Weidong Wang via B4 Relay
2026-11-29  3:21 ` sashiko-bot [this message]
2026-11-30 13:00 ` pstanner
2026-12-01 20:15   ` Weidong Wang
2026-12-03 13:27     ` Niklas Cassel
2026-12-03 13:39       ` Niklas Cassel
2026-12-03 13:48         ` Niklas Cassel

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-239294@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=cassel@kernel.org \
    --cc=dlemoal@kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=weidongw@illinois.edu \
    /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