在 2026-12-01二的 02:56 +0400,Arina Kharlamova via B4 Relay写道:
> From: Arina Kharlamova <[email protected]>
> 
> 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: [email protected]
> Signed-off-by: Arina Kharlamova <[email protected]>
> ---
> 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))

Will this lead to -EIO when the device is enabled? The && operator would
return the false if the first condition is false.

Should it be `(pci_is_enabled(pdev) || pci_enable_device(pdev))` instead?

Thanks,
Icenowy

>               return -EIO;
>  
>       return lsdc_pm_thaw(dev);
> 
> ---
> base-commit: 25faec9ce61c01fb45abf812a222c5b43c3cd5c5
> change-id: 20261129-s2p-d60-877e4d1f97de
> 
> Best regards,
> --  
> Arina Kharlamova <[email protected]>

Reply via email to