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=1796313612; b=x5UP4JHqjfUlh4mV8R7KsdN/8zfIHzbuuqCSHAHn1ihnt6nNmJu0iG4fRK8gKetnWwZ/ ujxp2l1w3A75avWMCPnW40FrXaRtMvUn4SsNgzRX0H5ydTBWLP8bRC5Hw011jiGxBtAik 5y8QbpxSeGLwUVx+DNY3PQffPDlzTrQQwrId0GIbLeTczLZ+tI30ZhIpC6/AdOedD1TV6 woQjcgehG1S0nDqeNH+0dm0ZuQ2iBSaDhFY9rIgQYe2QlQudTt+F6xARbhrpjGCXQ4Rfl FqLdspdhuQdcc3iJUuq6UTgtwQujeeaf7IV5MAqQhVU5yQqfQ5Crrj+oMJUyb00Hf6A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796313612; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=LEZ4Gk6+MTMVkPlk0atZ9ZFFcSGG57HqUuwzGdwYTLM=; b=zGf4wNJKC0SKbft4PXD76JMsWZMZ26qajxfT9dTjwr99H3PyvzxM0kQ9/dMjouClJ/fr NMxE8Ac2x3sq0z+zEyFL6DYKrNjcB5AkY4/BAyvChk1KttpJSjaINMuzNP1xSsSqPl51O +ZRVvFb8DIVHb5BQSMljGD3M+ZlGxP6O9w8LhfJUsvs5Ed/ER6PeB3oSV5/IhNDrHOMEn HuF/edtcG++asiWUBGc3TdQpXhhLzYbHVNI4lQ7GHgjJp0MkpQ1MNeG2heb/yFR40Yc8b pWV2ikTcDxERUSG81BUE9xMqAehFUfM7qB4HDlGpG/4G7O5Wu7LNMlj/gOVbRX21Smg== 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=ZiLbNbN9; 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 23954606A322; Thu, 3 Dec 2026 16:00:11 +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=ZiLbNbN9 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 488841F00898; Thu, 3 Dec 2026 16:00:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796313611; bh=LEZ4Gk6+MTMVkPlk0atZ9ZFFcSGG57HqUuwzGdwYTLM=; h=Date:From:To:Cc:Subject:In-Reply-To; b=ZiLbNbN9CeRZwYoo5PRPwVvLN62rvcNMGxbs7QBXcCwXIEnWlfU8S6pFpGdW3TNTH 7maYzs8F2ijNOVonMfb9HfqyCjV4X/VMRH9+LZkOud2361Mc1J4uZlsaxiGFojAApQ zW6NDHKRajQN4MOxYLHLfku3n0ThnfDjX45FR/BezeICiiuSwOx8M29mbiYcKHCRQ0 8L8eAPlbxsDhBE7gQn+F1MLz4/W6/0kUwfULzs1On6uCP6j4EcgZdpXgR+edyNvixQ neqLbWi8Qp0h5wwAo5Z5QYBl39C54v1v836eAtF6zWpj9Mb5qXuMwXllTBbkZgInVh /j8meYMO9KhRw== Date: Thu, 3 Dec 2026 10:00:10 -0600 From: Bjorn Helgaas To: Arina Kharlamova Cc: Damien Le Moal , Niklas Cassel , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Bjorn Helgaas , Philipp Stanner , linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, Weidong Wang , linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Vaibhav Gupta Subject: Re: [PATCH] ata: pata_macio: Do not disable the PCI device on suspend Message-ID: <20261203160010.GA809615@bhelgaas> X-Mailing-List: linux-kernel@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-d104-v1-1-df4a9ef2b79d@mbzuai.ac.ae> [+cc Vaibhav] On Tue, Dec 01, 2026 at 11:17:11PM +0400, Arina Kharlamova wrote: > pata_macio_suspend() disables the PCI device with pci_disable_device(), > and pata_macio_reset_hw() enables it again on resume with > pcim_enable_device(). Since commit f748a07a0b64 ("PCI: Remove legacy > pcim_release()") every pcim_enable_device() call adds a > pcim_disable_device() devres action, so each suspend and resume leaves > one more action behind. On unbind they all run, and every one after > the first warns about disabling an already disabled device. > > The device is enabled with pcim_enable_device() in probe and stays > managed until unbind, so the driver should not disable and enable it by > hand. On suspend, clear only the bus master bit, which is all that > pci_disable_device() did on this hardware, and set it again on resume > without enabling the device. > > Fixes: f748a07a0b64 ("PCI: Remove legacy pcim_release()") > Signed-off-by: Arina Kharlamova > --- > I found this while checking the other drivers that call > pcim_enable_device() again on resume, after the discussion of the t7xx > fix: > https://lore.kernel.org/all/20261201-s2p-d64-v1-1-c9147b2eedb0@mbzuai.ac.ae/ > > Weidong Wang's patch for ata_pci_device_do_resume() fixes the same > problem in libata core by switching resume to pci_enable_device(): > https://lore.kernel.org/all/20261128-kbug-l080-v1-1-90f7309990ea@illinois.edu/ > Philipp replied there that a driver should either use only pcim_ and > never undo it, or use only the pci_ functions. This patch takes the > first way, so the device is no longer disabled on suspend. > > With the help of an AI coding assistant (Claude); I reviewed the > analysis and the fix. Not triggered at runtime. Compile-tested only > (powerpc pmac32_defconfig), not tested on hardware. > --- > drivers/ata/pata_macio.c | 12 ++---------- > 1 file changed, 2 insertions(+), 10 deletions(-) > > diff --git a/drivers/ata/pata_macio.c b/drivers/ata/pata_macio.c > index a11a1eae2ae8..ba946a4116c3 100644 > --- a/drivers/ata/pata_macio.c > +++ b/drivers/ata/pata_macio.c > @@ -788,16 +788,8 @@ static void pata_macio_reset_hw(struct pata_macio_priv *priv, int resume) > > /* If resuming a PCI device, restore the config space here */ > if (priv->pdev && resume) { > - int rc; > - > pci_restore_state(priv->pdev); > - rc = pcim_enable_device(priv->pdev); > - if (rc) > - dev_err(&priv->pdev->dev, > - "Failed to enable device after resume (%d)\n", > - rc); > - else > - pci_set_master(priv->pdev); > + pci_set_master(priv->pdev); > } > > /* On Kauai, initialize the FCR. We don't perform a reset, doesn't really > @@ -898,7 +890,7 @@ static int pata_macio_do_suspend(struct pata_macio_priv *priv, pm_message_t mesg > */ > if (priv->pdev) { > pci_save_state(priv->pdev); > - pci_disable_device(priv->pdev); > + pci_clear_master(priv->pdev); > } > > /* Disable the bus on older machines and the cell on kauai */ This driver uses legacy PCI power management, i.e., pci_driver.suspend() and .resume(). If converted to generic power management (pci_driver.driver.pm hooks), it probably wouldn't need any of the pci_save_state() and related gunk because the PCI core would take care of it. For example: d5376026f926 ("gpio: bt8xx: use generic power management") 892bb0740b02 ("firewire: ohci: use generic power management") 0aeddbd0cb07 ("via-agp: convert to generic power management") Bjorn