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=1796290373; b=E4PFOp1RgI8JMV4mFYA9UDeudjQS73+0299qcBkIQXcPDIf2vE7zzwzPo1GEDaIShaA0 KY0kuVkv2zFOtkpcm/LXmy1AeqRZRsu3cIa00eyo5f4jJwuFwXWhofTjFtiwjWFVa/PzT cNKVesgku+SFiCcF0DY4kzr14Yutlq1/VX/8Q36AbUDVtoKaCzozDh6sLfXajEFPGQ8nm ck80Qsuc66l/FfL8mc1DonxbBXWFN6CRWbejrzKFwOdB19pZRpYE6tnsc0iWwUTJspFKL 2yChiQLKEG+HcsXqsaOPJ2wv2LF6So+l4mhEoAFMW46LrjyU4aNr5ufukW401R99WBQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796290373; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=LXIg6PJ0cUDf3L6c0OtIoN8hUjf5JJngfpKJRpSswIA=; b=KhlIbUPGcCc4j6tn36XtXzhty73x08GADU78vUl301TQ0TLulEEcDYrIi3ibbaBT9SBL 89gOq/6+6RlU7H28s1QtNzhBUPBC6joDmDyxqBHscEXjDPXQhUrGDkzo4FJy73BQLU52x 6nsuQMXzBFQj+muiJrB5H3UppbekrXNIz6g/WjaJ3Cn6/4jiupycXadxRfgTbwHk4w6vy utvU92jMiDqPgH8RKKFaDKvkKGbTZbv2ogascp7SnG/NJp2C+eCf7BJdKuNVvy+Zh+fW8 Rix8PfWskwj9cGLMjw4av6CJPUU7gsDxQ9pX5XR4cOrhuAShhputjS5avDCmo8ngGfw== 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=Kz7mdI18; 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 8A2E7606A32D; Thu, 3 Dec 2026 09:32:53 +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=Kz7mdI18 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B27F01F000C1; Thu, 3 Dec 2026 09:32:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796290373; bh=LXIg6PJ0cUDf3L6c0OtIoN8hUjf5JJngfpKJRpSswIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Kz7mdI18vIfpIxz5QiGXUKCXSrYPWA7jDkSxHdbT91nhsBFuqPlcQKmpiBX0cvnxc aRc8x3Zee8YBsL+cRyjNEjsqheMfLRMv9N2JI6tpBZHsBvLVZ5mbbaCZO++fmUD/FH t3tGx0pZXy336V+tFL7Xh/SvEeQk2Yv9WlrfBntzsKUpJlgUBb37xn5uatiJTT2HCr 8BbJJU272cWs31zGQaCncPIpueRAhHDApRkg5bf12A3id1ataYh2b4jk3+tjlvp44V dZSbSDtSaiJv/9Updus6ofX8Lxr/VS6GvQZHrheHvN4Kx37Uvn5PKC5AxbkfofcCNx ENOXNu5jY0rKQ== From: Claudiu Beznea To: lpieralisi@kernel.org, kwilczynski@kernel.org, mani@kernel.org, robh@kernel.org, bhelgaas@google.com, p.zabel@pengutronix.de Cc: claudiu.beznea@tuxon.dev, linux-pci@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Ovidiu Panait , Claudiu Beznea Subject: [PATCH 6/6] PCI: rzg3s-host: Fix NVMe resume errors after s2idle Date: Thu, 3 Dec 2026 11:32:24 +0200 Message-ID: <20261203093224.247349-7-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261203093224.247349-1-claudiu.beznea@kernel.org> References: <20261203093224.247349-1-claudiu.beznea@kernel.org> X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Ovidiu Panait On the Renesas RZ/V2H platform, when ASPM is enabled, resuming from s2idle with an NVMe SSD connected fails with: nvme nvme0: I/O tag 27 (001b) opcode 0x9 (Admin Cmd) QID 0 timeout, reset controller nvme nvme0: Disabling device after reset failure: -19 This happens because during s2idle, when ASPM is enabled, nvme_suspend() does not shut the drive down. It leaves it in D0, puts it in its lowest NVMe power state, so that resume only has to restore the previous power state instead of a full reinitialization. This assumes the drive keeps its context over the suspend. However, rzg3s_pcie_suspend_noirq() doesn't take this into account and it always powers down the controller and asserts the controller resets, including PERST#. That resets the drive, and the command the NVMe driver sends on resume never completes. To fix this, similar to the dwc driver, use pci_host_common_d3cold_possible() to check if the controller should be powered down and keep the controller running otherwise. To keep the controller running, also call device_set_awake_path(), so that the PM domain does not turn off the controller clocks. Do this only for s2idle. In s2ram the SoC could be powered off, and neither the PM domain nor the driver would restore the controller clocks and resets on resume. In hibernation, the controller must be reinitialized on restore. Fixes: 7ef502fb35b2 ("PCI: Add Renesas RZ/G3S host controller driver") Signed-off-by: Ovidiu Panait [claudiu.beznea: - added "#include " - added the suspended flag so that resume_noirq() does not re-initialize a controller that was not suspended, which would break it] Signed-off-by: Claudiu Beznea --- Changes since [1]: - rebased on top of the fixes patches - added suspended flags so that resume_noirq() does not re-initialize a controller that was not suspended, which could break it [1] https://lore.kernel.org/all/20261029172831.9409-1-ovidiu.panait.rb@renesas.com drivers/pci/controller/pcie-rzg3s-host.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/pci/controller/pcie-rzg3s-host.c b/drivers/pci/controller/pcie-rzg3s-host.c index ad75e6895259..67a338cece3e 100644 --- a/drivers/pci/controller/pcie-rzg3s-host.c +++ b/drivers/pci/controller/pcie-rzg3s-host.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include "pci-host-common.h" @@ -327,6 +328,7 @@ struct rzg3s_pcie_port { * @intx_irqs: INTx interrupts * @max_link_speed: maximum supported link speed * @controller_id: PCIe controller identifier, used for System Controller access + * @suspended: true if the controller was suspended in suspend_noirq() * @num_lanes: The number of lanes */ struct rzg3s_pcie_host { @@ -344,6 +346,7 @@ struct rzg3s_pcie_host { int intx_irqs[PCI_NUM_INTX]; int max_link_speed; enum rzg3s_pcie_controller_id controller_id; + bool suspended; u8 num_lanes; }; @@ -1936,11 +1939,19 @@ static int rzg3s_pcie_probe(struct platform_device *pdev) static int rzg3s_pcie_suspend_noirq(struct device *dev) { struct rzg3s_pcie_host *host = dev_get_drvdata(dev); + struct pci_host_bridge *bridge = pci_host_bridge_from_priv(host); const struct rzg3s_pcie_soc_data *data = host->data; struct rzg3s_pcie_port *port = &host->port; struct rzg3s_sysc *sysc = host->sysc; + bool pme_capable; int ret; + if (pm_suspend_target_state == PM_SUSPEND_TO_IDLE && + !pci_host_common_d3cold_possible(bridge, &pme_capable)) { + device_set_awake_path(dev); + return 0; + } + clk_disable_unprepare(port->refclk); /* SoC-specific de-initialization */ @@ -1962,6 +1973,8 @@ static int rzg3s_pcie_suspend_noirq(struct device *dev) if (ret) goto power_resets_restore; + host->suspended = true; + return 0; /* Restore the previous state if any error happens */ @@ -1984,6 +1997,9 @@ static int rzg3s_pcie_resume_noirq(struct device *dev) struct rzg3s_sysc *sysc = host->sysc; int ret; + if (!host->suspended) + return 0; + ret = rzg3s_sysc_config_func(sysc, RZG3S_SYSC_FUNC_ID_MODE, 1); if (ret) return ret; @@ -2016,6 +2032,8 @@ static int rzg3s_pcie_resume_noirq(struct device *dev) if (ret) goto assert_power_resets; + host->suspended = false; + return 0; /* -- 2.43.0