From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA56D606A322 for ; Thu, 3 Dec 2026 15:48:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PlAL6Mlo Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2ACC3112A06; Thu, 3 Dec 2026 15:48:27 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id 801EF112A06 for ; Thu, 3 Dec 2026 15:48:21 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 9053E61249; Thu, 3 Dec 2026 15:48:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C7391F000C1; Thu, 3 Dec 2026 15:48:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796312900; bh=w7bESoPNXjWjKPRU0jzEaIdAHmXsiYcF3V6wwb4cQeA=; h=Date:From:To:Cc:Subject:In-Reply-To; b=PlAL6Mlo934/hCsT98VFJzK0mI6LxAglZyM2oQu8yofON6xk1doG5K/wVWWA02vpb 10Z/DzmMEwYSfFkbjsyK1eQh+/35aonru/vEn5CSNxZSzguoqGr4kthq20z5MJm+Hb iEIUbWu+600MLGQr2xfMxs8RxyYIBbA5VZ07NJTeJeiFGGwOQxLB/bBFeeuxxZzwQX eDeqfUSaRKO4QcP1zxmjjI/Ib8fwQ1lmB0J4DxD7pdwE44XDqJKFY7F4OMLcovTgpm rMnEt71yCCF9t6I2bmQdit9jpmrjMODSoNgFO6HXfkdUV0F0QImbyYJ10Ef/ToiMM1 l54JDndoPBikw== Date: Thu, 3 Dec 2026 09:48:19 -0600 From: Bjorn Helgaas To: Arina Kharlamova Cc: Jianmin Lv , Qianhai Wu , Huacai Chen , Mingcong Bai , Xi Ruoyao , Icenowy Zheng , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Philipp Stanner , Bjorn Helgaas , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , dri-devel@lists.freedesktop.org, stable@vger.kernel.org, Vaibhav Gupta Subject: Re: [PATCH] drm/loongson: Do not add a devres action on every resume Message-ID: <20261203154819.GA802463@bhelgaas> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261201-s2p-d60-v1-1-d88cf22132ab@mbzuai.ac.ae> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "dri-devel" X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 [+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 > --- > 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