From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796312900; b=yadkw8Jbfm4yQoW+qcL67Uyj7+HbGtXxOpbvNaK/SxpNAof14kG5EcDGeMUHXn0+/slz XD9fyOc0MgZmeUcRNNdeS0kSGirMvOvc4xtc6K5dC8llQSvl+IlMFSTTKhondbrYEbyAv LtCvXSjPv3wP7a/U6cOcRRvflxyOb4bbHZhBqIaRLsNKGvE+s5XT/2de6c2ZybIoU+vFS 3YQ3YxxMnslunDZnZj7MTxbaess7uH3MJ3u1UuQzbTpobIZUhKuqn1LOouGDS2hrNbodU tTWO1BS8zmITFXTyD979jtnxamvDyA659tIhD84Io/qMlUaMcQ75fg8kYH1kEuqfElg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796312900; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=w7bESoPNXjWjKPRU0jzEaIdAHmXsiYcF3V6wwb4cQeA=; b=Oi7snEwtSd0WQ+M2JSEePbAxzyKk9Zf6umRUXE9tH+zyJv23V+1fIhgoXNgKSZocntB1 /wSy/VKqCnJoAVQB6sMskSPS9zyjOQ1cskSTE4Tq6ERP/2nGr//CVNyFlONr19+WNyGFD gBNjRfk4MYb/1tv2Nst2690CNflnJnSIPkjdNsW1klaue4qY7sZPT6MuBIFZo6yCGJxZW VLKbyl1wTAy8/XXNfRRmWq/5jGZSMClrtrfLJ/aIrcMAK+sx7KhGlkFT4hzoWZnJ5RGlo fprHUq8YCPIVKpDkSZi/hWd8v5Fku1PuKQvlT56b1UUgccaa3NtOViIvo6N1pLtdcUg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PlAL6Mlo; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ACA14606A32C for ; Thu, 3 Dec 2026 15:48:20 +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: 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-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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> [+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