From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
To: "Jianjun Wang" <jianjun.wang@mediatek.com>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Manivannan Sadhasivam" <manivannan.sadhasivam@linaro.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Matthias Brugger" <matthias.bgg@gmail.com>
Cc: Ryder Lee <ryder.lee@mediatek.com>,
linux-pci@vger.kernel.org, linux-mediatek@lists.infradead.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Xavier Chang <Xavier.Chang@mediatek.com>
Subject: Re: [PATCH 5/5] PCI: mediatek-gen3: Keep PCIe power and clocks if suspend-to-idle
Date: Fri, 3 Jan 2025 10:14:45 +0100 [thread overview]
Message-ID: <f23dd67e-d3a5-47b5-af14-bf0120348ec8@collabora.com> (raw)
In-Reply-To: <20250103060035.30688-6-jianjun.wang@mediatek.com>
Il 03/01/25 07:00, Jianjun Wang ha scritto:
> If the target system sleep state is suspend-to-idle, the bridge is
> supposed to stay in D0, and the framework will not help to restore its
> configuration space, so keep its power and clocks during suspend.
>
> It's recommended to enable L1ss support, so the link can be changed to
> L1.2 state during suspend.
>
> Signed-off-by: Jianjun Wang <jianjun.wang@mediatek.com>
> ---
> drivers/pci/controller/pcie-mediatek-gen3.c | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
> index 48f83c2d91f7..11da68910502 100644
> --- a/drivers/pci/controller/pcie-mediatek-gen3.c
> +++ b/drivers/pci/controller/pcie-mediatek-gen3.c
> @@ -1291,6 +1291,19 @@ static int mtk_pcie_suspend_noirq(struct device *dev)
> int err;
> u32 val;
>
> + /*
> + * If the target system sleep state is suspend-to-idle, the bridge is supposed to stay in
> + * D0, and the framework will not help to restore its configuration space, so keep it's
> + * power and clocks during suspend.
> + *
> + * It's recommended to enable L1ss support, so the link can be changed to L1.2 state during
> + * suspend.
> + */
> + if (pm_suspend_default_s2idle()) {
AFAIK, this works only if s2idle is the default system sleep state.
...and besides, for good measure (especially in the event that in the future we
get hotplug support) you should also check if there is any active PCI-Express
device on the controller instance before deciding to leave the controller and
link UP, as PCI-Express controllers may be enabled even if there's no actually
connected device on a PCIe slot (full PCIe, or mPCIe, or M.2).
So, I suggest to:
- Add a `bool suspended` member to `struct mtk_gen3_pcie`, then
static int mtk_pcie_suspend_noirq(struct device *dev)
{
struct mtk_gen3_pcie *pcie = dev_get_drvdata(dev);
int err;
u32 val;
val = readl(pcie->base + PCIE_LINK_STATUS_REG);
val &= PCIE_PORT_LINKUP;
if (val && pm_suspend_target_state == PM_SUSPEND_TO_IDLE) {
dev_dbg(....)
return 0;
}
/* Trigger link to L2 state */
err = mtk_pcie_turn_off_link(pcie);
if (err) {
dev_err(pcie->dev, "cannot enter L2 state\n");
return err;
}
pcie->suspended = true;
/* Pull down the PERST# pin */
.... etc etc
and
static int mtk_pcie_resume_noirq(struct device *dev)
{
struct mtk_gen3_pcie *pcie = dev_get_drvdata(dev);
int err;
if (!pcie->suspended)
return 0;
err = pcie->soc->power_up .... etc etc
... so you only check if we're going in s2idle in the suspend handler, as
that dictates the value of pcie->suspended :-)
Cheers,
Angelo
> + dev_info(dev, "System enter s2idle state, keep PCIe power and clocks\n");
> + return 0;
> + }
> +
> /* Trigger link to L2 state */
> err = mtk_pcie_turn_off_link(pcie);
> if (err) {
> @@ -1316,6 +1329,11 @@ static int mtk_pcie_resume_noirq(struct device *dev)
> struct mtk_gen3_pcie *pcie = dev_get_drvdata(dev);
> int err;
>
> + if (pm_suspend_default_s2idle()) {
> + dev_info(dev, "System enter s2idle state, no need to reinitialization\n");
> + return 0;
> + }
> +
> err = pcie->soc->power_up(pcie);
> if (err)
> return err;
next prev parent reply other threads:[~2025-01-03 9:14 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-03 6:00 [PATCH 0/5] PCI: mediatek-gen3: Add MT8196 support Jianjun Wang
2025-01-03 6:00 ` [PATCH 1/5] dt-bindings: " Jianjun Wang
2025-01-03 9:10 ` Krzysztof Kozlowski
2025-01-06 9:26 ` Jianjun Wang (王建军)
2025-01-06 12:27 ` Krzysztof Kozlowski
2025-01-07 8:43 ` Jianjun Wang (王建军)
2025-01-07 9:02 ` Chen-Yu Tsai
2025-01-08 6:53 ` Jianjun Wang (王建军)
2025-01-08 7:16 ` Krzysztof Kozlowski
2025-01-08 7:30 ` Jianjun Wang (王建军)
2025-01-03 9:26 ` AngeloGioacchino Del Regno
2025-01-06 9:19 ` Jianjun Wang (王建军)
2025-01-07 13:04 ` AngeloGioacchino Del Regno
2025-01-08 7:24 ` Jianjun Wang (王建军)
2025-01-03 6:00 ` [PATCH 2/5] " Jianjun Wang
2025-01-03 19:02 ` Bjorn Helgaas
2025-01-07 1:51 ` Jianjun Wang (王建军)
2025-01-03 6:00 ` [PATCH 3/5] PCI: mediatek-gen3: Disable ASPM L0s Jianjun Wang
2025-01-03 9:16 ` AngeloGioacchino Del Regno
2025-01-07 2:18 ` Jianjun Wang (王建军)
2025-01-07 11:44 ` AngeloGioacchino Del Regno
2025-01-07 23:07 ` Bjorn Helgaas
2025-01-03 19:15 ` Bjorn Helgaas
2025-01-07 2:44 ` Jianjun Wang (王建军)
2025-01-07 23:06 ` Bjorn Helgaas
2025-01-06 16:09 ` Manivannan Sadhasivam
2025-01-03 6:00 ` [PATCH 4/5] PCI: mediatek-gen3: Don't reply AXI slave error Jianjun Wang
2025-01-03 9:29 ` AngeloGioacchino Del Regno
2025-01-06 9:27 ` Jianjun Wang (王建军)
2025-01-03 19:19 ` Bjorn Helgaas
2025-01-06 9:31 ` Jianjun Wang (王建军)
2025-01-06 16:16 ` Manivannan Sadhasivam
2025-01-07 3:21 ` Jianjun Wang (王建军)
2025-01-03 6:00 ` [PATCH 5/5] PCI: mediatek-gen3: Keep PCIe power and clocks if suspend-to-idle Jianjun Wang
2025-01-03 9:14 ` AngeloGioacchino Del Regno [this message]
2025-01-03 19:13 ` Bjorn Helgaas
2025-01-06 16:23 ` Manivannan Sadhasivam
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f23dd67e-d3a5-47b5-af14-bf0120348ec8@collabora.com \
--to=angelogioacchino.delregno@collabora.com \
--cc=Xavier.Chang@mediatek.com \
--cc=bhelgaas@google.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jianjun.wang@mediatek.com \
--cc=krzk+dt@kernel.org \
--cc=kw@linux.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
--cc=matthias.bgg@gmail.com \
--cc=robh@kernel.org \
--cc=ryder.lee@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox