From: Bjorn Helgaas <helgaas@kernel.org>
To: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
Cc: "Jianmin Lv" <lvjianmin@loongson.cn>,
"Qianhai Wu" <wuqianhai@loongson.cn>,
"Huacai Chen" <chenhuacai@kernel.org>,
"Mingcong Bai" <jeffbai@aosc.io>,
"Xi Ruoyao" <xry111@xry111.site>,
"Icenowy Zheng" <zhengxingda@iscas.ac.cn>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Philipp Stanner" <pstanner@redhat.com>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
dri-devel@lists.freedesktop.org, stable@vger.kernel.org,
"Vaibhav Gupta" <vaibhavgupta40@gmail.com>
Subject: Re: [PATCH] drm/loongson: Do not add a devres action on every resume
Date: Thu, 3 Dec 2026 09:48:19 -0600 [thread overview]
Message-ID: <20261203154819.GA802463@bhelgaas> (raw)
In-Reply-To: <20261201-s2p-d60-v1-1-d88cf22132ab@mbzuai.ac.ae>
[+cc Vaibhav, who's done a lot of PCI suspend/resume rework]
On Tue, Dec 01, 2026 at 02:56:08AM +0400, Arina Kharlamova wrote:
> lsdc_pm_suspend() disables the PCI device with pci_disable_device() and
> lsdc_pm_resume() enables it again with pcim_enable_device(). Since
> commit f748a07a0b64 ("PCI: Remove legacy pcim_release()") the managed
> variant registers a new pcim_disable_device() devres action on each
> call, so every suspend and resume cycle leaves one more action on the
> device. When the driver is unbound, all of them run: the first one
> drops the enable count to zero, the next one triggers the "disabling
> already-disabled device" warning, and each further one makes the count
> more negative.
>
> The device is already managed from lsdc_pci_probe(). Use the plain
> pci_enable_device() in the resume path so that it only balances the
> pci_disable_device() done at suspend. lsdc_pm_resume() is also the
> .restore callback, and .poweroff does not disable the device, so only
> enable it when it is disabled.
>
> Fixes: f748a07a0b64 ("PCI: Remove legacy pcim_release()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
> ---
> Found by checks derived from the spec2patch kernel API specifications,
> with the help of an AI coding assistant (Claude); I reviewed the
> analysis and the fix.
> ---
> drivers/gpu/drm/loongson/lsdc_drv.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/loongson/lsdc_drv.c b/drivers/gpu/drm/loongson/lsdc_drv.c
> index 5a13df31eb90..e5b7b34d739e 100644
> --- a/drivers/gpu/drm/loongson/lsdc_drv.c
> +++ b/drivers/gpu/drm/loongson/lsdc_drv.c
> @@ -428,7 +428,7 @@ static int lsdc_pm_resume(struct device *dev)
>
> pci_restore_state(pdev);
>
> - if (pcim_enable_device(pdev))
> + if (!pci_is_enabled(pdev) && pci_enable_device(pdev))
> return -EIO;
>
> return lsdc_pm_thaw(dev);
Taking a step back, why do lsdc_pm_suspend() and lsdc_pm_resume() need
those PCI things in the first place? The PCI core should take care of
the pci_save_state() and power management already, without having to
do it in the driver.
Bjorn
prev parent reply other threads:[~2026-12-03 15:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 22:56 [PATCH] drm/loongson: Do not add a devres action on every resume Arina Kharlamova via B4 Relay
2026-12-02 6:44 ` Icenowy Zheng
2026-12-03 11:17 ` Arina Kharlamova
2026-12-03 11:20 ` Icenowy Zheng
2026-12-03 15:48 ` Bjorn Helgaas [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=20261203154819.GA802463@bhelgaas \
--to=helgaas@kernel.org \
--cc=airlied@gmail.com \
--cc=arina.kharlamova@mbzuai.ac.ae \
--cc=bhelgaas@google.com \
--cc=chenhuacai@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jeffbai@aosc.io \
--cc=kwilczynski@kernel.org \
--cc=lvjianmin@loongson.cn \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=pstanner@redhat.com \
--cc=simona@ffwll.ch \
--cc=stable@vger.kernel.org \
--cc=tzimmermann@suse.de \
--cc=vaibhavgupta40@gmail.com \
--cc=wuqianhai@loongson.cn \
--cc=xry111@xry111.site \
--cc=zhengxingda@iscas.ac.cn \
/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