mbox series

[v4,0/1] PCI: qcom: Add support for system suspend and resume

Message ID 20230403154922.20704-1-manivannan.sadhasivam@linaro.org
Headers show
Series PCI: qcom: Add support for system suspend and resume | expand

Message

Manivannan Sadhasivam April 3, 2023, 3:49 p.m. UTC
Hello,

This series (a single patch) adds the system suspend and resume support
to the Qualcomm PCIe RC controller.

Background
==========

There were previous attempts [1][2] to add system suspend and resume
support to this driver.

In previous versions, the controller was put into low power mode by turning
OFF the resources even if there were active PCIe devices connected. Thanks
to Qualcomm's internal power topology, the link did not enter L2/L3 state
and the devices were still powered ON. But during very late end of suspend
cycle, kernel tried to disable MSIs of the PCIe devices. This caused access
violations as the resources needed to access the PCIe devices config space
were turned OFF. Series [1] worked around this issue by not accessing the
PCIe config space if the link was down in dw_msi_{un}mask_irq() functions.
But that approach was not accepted.

Then, series [2] implemented the suspend and resume operations using the
syscore framework that disabled the resources at the end of the suspend
cycle. But that approach also did not get much acceptance.

Proposal
========

So the proposal here is to just vote for minimal interconnect bandwidth to
keep the interconnect path active and not turn OFF the resources if there
are active PCIe devices connected to the controllers. This avoids the
access violation issue during suspend and also saves some power due to the
lower interconnect bandwidth used.

Then if there are no active PCIe devices connected to the controller,
the resources are turned OFF completely and brought back during resume.
This also saves power if there are controllers in a system without any
devices connected.

Testing
=======

This series has been tested on Lenovo Thinkpad X13s.

Thanks,
Mani

[1] https://lore.kernel.org/linux-pci/1656055682-18817-1-git-send-email-quic_krichai@quicinc.com/
[2] https://lore.kernel.org/linux-pci/1663669347-29308-1-git-send-email-quic_krichai@quicinc.com/

Changes in v4:

* Used 1KiB interconnect bandwidth during suspend

Changes in v3:

* Limited comments to 80 column
* Added error handling in resume_noirq()

Changes in v2:

* Used minimum icc vote to keep data path functional during suspend
* Collected Ack

Manivannan Sadhasivam (1):
  PCI: qcom: Add support for system suspend and resume

 drivers/pci/controller/dwc/pcie-qcom.c | 62 ++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)

Comments

Johan Hovold April 4, 2023, 9:06 a.m. UTC | #1
On Mon, Apr 03, 2023 at 09:19:22PM +0530, Manivannan Sadhasivam wrote:
> During the system suspend, vote for minimal interconnect bandwidth (1KiB)
> to keep the interconnect path active for config access and also turn OFF
> the resources like clock and PHY if there are no active devices connected
> to the controller. For the controllers with active devices, the resources
> are kept ON as removing the resources will trigger access violation during
> the late end of suspend cycle as kernel tries to access the config space of
> PCIe devices to mask the MSIs.
> 
> Also, it is not desirable to put the link into L2/L3 state as that
> implies VDD supply will be removed and the devices may go into powerdown
> state. This will affect the lifetime of storage devices like NVMe.
> 
> And finally, during resume, turn ON the resources if the controller was
> truly suspended (resources OFF) and update the interconnect bandwidth
> based on PCIe Gen speed.
> 
> Suggested-by: Krishna chaitanya chundru <quic_krichai@quicinc.com>
> Acked-by: Dhruva Gole <d-gole@ti.com>
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

> +	/*
> +	 * Set minimum bandwidth required to keep data path functional during
> +	 * suspend

Nit: For some reason you dropped the full stop ('.') here in v4 I
noticed when comparing the diff.

> +	 */

Looks good to me now otherwise:

Reviewed-by: Johan Hovold <johan+linaro@kernel.org>
Tested-by: Johan Hovold <johan+linaro@kernel.org>

Johan
Lorenzo Pieralisi April 11, 2023, 9:52 a.m. UTC | #2
On Mon, 03 Apr 2023 21:19:21 +0530, Manivannan Sadhasivam wrote:
> This series (a single patch) adds the system suspend and resume support
> to the Qualcomm PCIe RC controller.
> 
> Background
> ==========
> 
> There were previous attempts [1][2] to add system suspend and resume
> support to this driver.
> 
> [...]

Applied to controller/qcom, thanks!

[1/1] PCI: qcom: Add support for system suspend and resume
      https://git.kernel.org/pci/pci/c/ca0e2aad2720

Thanks,
Lorenzo