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=1796290360; b=p6jZgvEDeCP6HI1PdruLOgdugubJ/7DfktX5a5AtUXws3iqJUd2KytamPtU0zDWSHFfU 7AdP2jKsqiIxj39tV7UfmCGjtkGAQmwXLKrOuM5tiWMcJxcA4dqeb9yzUuYkvpwpZr9vR wwYWPQtXWc6QrHg1vOZ51mlzx69Z+OQHa1JGLeOK1AvGODQ5/D2f0TMoD/Sv8gojBqNfk xcFl/Y4JrNCIRSrDwvUXnyuZQV3mREu0FSSj50/5VAOHdvJ6hvmdNuMyCXdkmP1Ez00Xs 6KuOtBOIrhv8lSVblKSQ93b94qhueP03Md7RMDHbkwwIgsIpd67Ylvi8rCHfvPOY1zg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796290360; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=VrPVPBziZZKgyLV65cy1hG2JSnchPTzGYdq8sF6RjHA=; b=x13cc37vP5AsO6vGVirMrsWw34Hug2cgPkQzYjatF3DsstDcbBsp8XrvdMH0cDxwhhfe uY8vEl3fdsgwRxkHZRD2k71tNc66JK4fRhGiFXW/2hk4FCc8yx/C6CvvGqQPeJkYAC8ke MH4IxoWfzNjnXdom8wmJGdfwD7Lp8EIiTy74HiFupuFpAnr0hBo8S9j4hLpEGLJ2QohAk 9+qLvCC0ITSAVwLAUML+2/K1YSIYlGk7R8BX1zAdrCR9+3h5yH9tWFAejDmdu0XlQR5NH ojpbiFojbw1ublJ1m3klTvKtpLWCvIVOfnS7gb8+q+Pxn/Fq4IF9fPw2VrzGktdo/Lg== 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=dUijf6rh; 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 DB0B1606A680; Thu, 3 Dec 2026 09:32:40 +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=dUijf6rh Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A0331F00896; Thu, 3 Dec 2026 09:32:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796290360; bh=VrPVPBziZZKgyLV65cy1hG2JSnchPTzGYdq8sF6RjHA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=dUijf6rh0G0R8DeobKu3Zy5RbbWjAxnxFt5HApp5aReA5seAvKLBFroAtLCyXIkPi ZHbBWGlj6zoaYGTWbK7aqm6wmZT3AhBrpIqaIwFdRX1BCGePgyIwjSCBLnmFWZMwqm cQK7y3IZqqsEnDsqeGrJ9xEvjcBblUZXkTDgoe/jJMt1XiGcJyKb+gTaNasmwZ4Cen bqxJSdItwpV/EhrcdjtuGzGTk5sUV11YN4jLlGvJNwVyUZXxoK5ffjPgiOf3pb4BlY T0BTE841c7QbtgpnR6ZUH99gS+YMW8KtqLFKxcEcxhuaqDzUL3raOLN9FZKSoZs+wG f2s+vDkM5xnig== 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, Claudiu Beznea , stable@vger.kernel.org, Lad Prabhakar , Wolfram Sang Subject: [PATCH 2/6] PCI: rzg3s-host: Fix runtime PM handling in the NOIRQ suspend/resume phase Date: Thu, 3 Dec 2026 11:32:20 +0200 Message-ID: <20261203093224.247349-3-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: Claudiu Beznea The runtime PM documentation states the following: - During system suspend, pm_runtime_get_noresume() is called for every device right before executing the subsystem-level .prepare() callback (in device_prepare()). In addition, the PM core disables runtime PM for every device right before executing the subsystem-level .suspend_late() callback (in device_suspend_late()). - During system resume, pm_runtime_enable() is called for every device right after executing the subsystem-level .resume_early() callback (in device_resume_early()), and pm_runtime_put() is called right after executing the subsystem-level .complete() callback (in device_complete()). The driver's .suspend_noirq() callback is invoked after .suspend_late(), while .resume_noirq() is invoked before .resume_early(). If: - the device is not part of the wake-up path, and - its runtime PM status is not RPM_SUSPENDED, the generic power domain .suspend_noirq()/.resume_noirq() callbacks (genpd_suspend_noirq()/genpd_resume_noirq()) invoke the driver's .suspend_noirq()/.resume_noirq() callbacks and call genpd_stop_dev()/genpd_start_dev() before and after them, respectively. Calling genpd_stop_dev()/genpd_start_dev() allows devices whose power is controlled by generic power domains to be powered off and on during system suspend and resume, even though their runtime PM usage count does not reach zero. Since the runtime PM usage count is incremented in device_prepare() and decremented in device_complete(), runtime PM operations performed from the driver's .suspend_noirq()/.resume_noirq() callbacks are no-ops. The actual power transitions are handled by the generic power domain .suspend_noirq()/.resume_noirq() callbacks. Moreover, attempting to runtime resume a device while runtime PM is disabled may return -EACCES. This may cause system resume to fail when resuming after a failed Root Port reset, as described in a subsequent patch adding hot-plug support. Remove the runtime PM calls from the driver's .suspend_noirq()/.resume_noirq() callbacks and rely on the generic power domain callbacks to power the device off and on. Fixes: 7ef502fb35b2 ("PCI: Add Renesas RZ/G3S host controller driver") Cc: stable@vger.kernel.org Reviewed-by: Lad Prabhakar Tested-by: Lad Prabhakar Tested-by: Wolfram Sang Signed-off-by: Claudiu Beznea --- Changes since [1]: - collected tags [1] https://lore.kernel.org/all/20261019065025.2146539-1-claudiu.beznea@kernel.org drivers/pci/controller/pcie-rzg3s-host.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/pci/controller/pcie-rzg3s-host.c b/drivers/pci/controller/pcie-rzg3s-host.c index 1dbe2a2a4bf1..66a5adf9db7e 100644 --- a/drivers/pci/controller/pcie-rzg3s-host.c +++ b/drivers/pci/controller/pcie-rzg3s-host.c @@ -1957,19 +1957,18 @@ static int rzg3s_pcie_suspend_noirq(struct device *dev) if (ret) goto config_reinit; - ret = pm_runtime_put_sync(dev); - if (ret) - goto power_resets_restore; + /* + * Since the power domain's genpd_suspend_noirq() will disable clocks, + * there is no need to manually invoke runtime PM API here. + */ ret = rzg3s_sysc_config_func(sysc, RZG3S_SYSC_FUNC_ID_RST_RSM_B, 0); if (ret) - goto rpm_resume; + goto power_resets_restore; return 0; /* Restore the previous state if any error happens */ -rpm_resume: - pm_runtime_resume_and_get(dev); power_resets_restore: reset_control_bulk_deassert(data->num_power_resets, host->power_resets); @@ -2007,13 +2006,14 @@ static int rzg3s_pcie_resume_noirq(struct device *dev) goto assert_rst_rsm_b; } - ret = pm_runtime_resume_and_get(dev); - if (ret) - goto assert_rst_rsm_b; + /* + * Since the power domain's genpd_resume_noirq() will enable clocks, + * there is no need to manually invoke runtime PM API here. + */ ret = rzg3s_pcie_power_resets_deassert(host); if (ret) - goto rpm_put; + goto assert_rst_rsm_b; ret = rzg3s_pcie_host_setup(host, rzg3s_pcie_msi_hw_setup, rzg3s_pcie_msi_hw_teardown); @@ -2029,8 +2029,6 @@ static int rzg3s_pcie_resume_noirq(struct device *dev) assert_power_resets: reset_control_bulk_assert(data->num_power_resets, host->power_resets); -rpm_put: - pm_runtime_put_sync(dev); assert_rst_rsm_b: rzg3s_sysc_config_func(sysc, RZG3S_SYSC_FUNC_ID_RST_RSM_B, 0); return ret; -- 2.43.0