From: "Marek Behún" <kabel@kernel.org>
To: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: "Bjorn Helgaas" <helgaas@kernel.org>,
"Gregory CLEMENT" <gregory.clement@bootlin.com>,
pali@kernel.org, "Krzysztof Wilczyński" <kw@linux.com>,
linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
"Miquel Raynal" <miquel.raynal@bootlin.com>,
"Marek Behún" <kabel@kernel.org>
Subject: [PATCH v2 06/10] PCI: aardvark: Add suspend to RAM support
Date: Tue, 27 Sep 2022 16:19:22 +0200 [thread overview]
Message-ID: <20220927141926.8895-7-kabel@kernel.org> (raw)
In-Reply-To: <20220927141926.8895-1-kabel@kernel.org>
From: Miquel Raynal <miquel.raynal@bootlin.com>
Add suspend and resume callbacks. We need to use the _noirq variants
via
NOIRQ_SYSTEM_SLEEP_PM_OPS(),
because these are called when IRQ handlers are disabled, as explained
in Documentation/driver-api/pm/devices.rst. This ensures that the
PCIe controller's IRQ handler is not called during suspend/resume
handler, as this could cause races, as explained in the above
mentioned file, section Entering System Suspend.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Marek Behún <kabel@kernel.org>
---
Changes since batch 6 v1:
- more explicit commit message
Changes since batch 5:
- clarified commit message
- changed to new macro NOIRQ_SYSTEM_SLEEP_PM_OPS, as was done for many
PCI controller drivers with commit 19b7858c3357 ("PCI: Convert to new
*_PM_OPS macros")
---
drivers/pci/controller/pci-aardvark.c | 34 +++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c
index 3beafc893969..e30a33a4ecc6 100644
--- a/drivers/pci/controller/pci-aardvark.c
+++ b/drivers/pci/controller/pci-aardvark.c
@@ -1890,6 +1890,39 @@ static int advk_pcie_setup_phy(struct advk_pcie *pcie)
return ret;
}
+static int advk_pcie_suspend(struct device *dev)
+{
+ struct advk_pcie *pcie = dev_get_drvdata(dev);
+
+ advk_pcie_disable_phy(pcie);
+
+ clk_disable_unprepare(pcie->clk);
+
+ return 0;
+}
+
+static int advk_pcie_resume(struct device *dev)
+{
+ struct advk_pcie *pcie = dev_get_drvdata(dev);
+ int ret;
+
+ ret = clk_prepare_enable(pcie->clk);
+ if (ret)
+ return ret;
+
+ ret = advk_pcie_enable_phy(pcie);
+ if (ret)
+ return ret;
+
+ advk_pcie_setup_hw(pcie);
+
+ return 0;
+}
+
+static const struct dev_pm_ops advk_pcie_dev_pm_ops = {
+ NOIRQ_SYSTEM_SLEEP_PM_OPS(advk_pcie_suspend, advk_pcie_resume)
+};
+
static int advk_pcie_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -2167,6 +2200,7 @@ static struct platform_driver advk_pcie_driver = {
.driver = {
.name = "advk-pcie",
.of_match_table = advk_pcie_of_match_table,
+ .pm = &advk_pcie_dev_pm_ops,
},
.probe = advk_pcie_probe,
.remove = advk_pcie_remove,
--
2.35.1
WARNING: multiple messages have this Message-ID (diff)
From: "Marek Behún" <kabel@kernel.org>
To: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: "Bjorn Helgaas" <helgaas@kernel.org>,
"Gregory CLEMENT" <gregory.clement@bootlin.com>,
pali@kernel.org, "Krzysztof Wilczyński" <kw@linux.com>,
linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
"Miquel Raynal" <miquel.raynal@bootlin.com>,
"Marek Behún" <kabel@kernel.org>
Subject: [PATCH v2 06/10] PCI: aardvark: Add suspend to RAM support
Date: Tue, 27 Sep 2022 16:19:22 +0200 [thread overview]
Message-ID: <20220927141926.8895-7-kabel@kernel.org> (raw)
In-Reply-To: <20220927141926.8895-1-kabel@kernel.org>
From: Miquel Raynal <miquel.raynal@bootlin.com>
Add suspend and resume callbacks. We need to use the _noirq variants
via
NOIRQ_SYSTEM_SLEEP_PM_OPS(),
because these are called when IRQ handlers are disabled, as explained
in Documentation/driver-api/pm/devices.rst. This ensures that the
PCIe controller's IRQ handler is not called during suspend/resume
handler, as this could cause races, as explained in the above
mentioned file, section Entering System Suspend.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Marek Behún <kabel@kernel.org>
---
Changes since batch 6 v1:
- more explicit commit message
Changes since batch 5:
- clarified commit message
- changed to new macro NOIRQ_SYSTEM_SLEEP_PM_OPS, as was done for many
PCI controller drivers with commit 19b7858c3357 ("PCI: Convert to new
*_PM_OPS macros")
---
drivers/pci/controller/pci-aardvark.c | 34 +++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c
index 3beafc893969..e30a33a4ecc6 100644
--- a/drivers/pci/controller/pci-aardvark.c
+++ b/drivers/pci/controller/pci-aardvark.c
@@ -1890,6 +1890,39 @@ static int advk_pcie_setup_phy(struct advk_pcie *pcie)
return ret;
}
+static int advk_pcie_suspend(struct device *dev)
+{
+ struct advk_pcie *pcie = dev_get_drvdata(dev);
+
+ advk_pcie_disable_phy(pcie);
+
+ clk_disable_unprepare(pcie->clk);
+
+ return 0;
+}
+
+static int advk_pcie_resume(struct device *dev)
+{
+ struct advk_pcie *pcie = dev_get_drvdata(dev);
+ int ret;
+
+ ret = clk_prepare_enable(pcie->clk);
+ if (ret)
+ return ret;
+
+ ret = advk_pcie_enable_phy(pcie);
+ if (ret)
+ return ret;
+
+ advk_pcie_setup_hw(pcie);
+
+ return 0;
+}
+
+static const struct dev_pm_ops advk_pcie_dev_pm_ops = {
+ NOIRQ_SYSTEM_SLEEP_PM_OPS(advk_pcie_suspend, advk_pcie_resume)
+};
+
static int advk_pcie_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -2167,6 +2200,7 @@ static struct platform_driver advk_pcie_driver = {
.driver = {
.name = "advk-pcie",
.of_match_table = advk_pcie_of_match_table,
+ .pm = &advk_pcie_dev_pm_ops,
},
.probe = advk_pcie_probe,
.remove = advk_pcie_remove,
--
2.35.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-09-27 14:20 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-27 14:19 [PATCH v2 00/10] PCI: aardvark controller changes BATCH 6 Marek Behún
2022-09-27 14:19 ` Marek Behún
2022-09-27 14:19 ` [PATCH v2 01/10] PCI: pciehp: Enable Command Completed Interrupt only if supported Marek Behún
2022-09-27 14:19 ` Marek Behún
2022-12-07 14:29 ` Bjorn Helgaas
2022-12-07 14:29 ` Bjorn Helgaas
2022-09-27 14:19 ` [PATCH v2 02/10] PCI: aardvark: Add support for DLLSC and hotplug interrupt Marek Behún
2022-09-27 14:19 ` Marek Behún
2022-09-27 14:19 ` [PATCH v2 03/10] PCI: aardvark: Send Set_Slot_Power_Limit message Marek Behún
2022-09-27 14:19 ` Marek Behún
2022-09-27 14:19 ` [PATCH v2 04/10] arm64: dts: armada-3720-turris-mox: Define slot-power-limit-milliwatt for PCIe Marek Behún
2022-09-27 14:19 ` Marek Behún
2022-11-27 23:36 ` Gregory CLEMENT
2022-11-27 23:36 ` Gregory CLEMENT
2022-09-27 14:19 ` [PATCH v2 05/10] PCI: aardvark: Add clock support Marek Behún
2022-09-27 14:19 ` Marek Behún
2022-09-27 14:19 ` Marek Behún [this message]
2022-09-27 14:19 ` [PATCH v2 06/10] PCI: aardvark: Add suspend to RAM support Marek Behún
2022-09-27 14:19 ` [PATCH v2 07/10] PCI: aardvark: Replace custom PCIE_CORE_ERR_CAPCTL_* macros by linux/pci_regs.h macros Marek Behún
2022-09-27 14:19 ` Marek Behún
2022-09-27 14:19 ` [PATCH v2 08/10] PCI: aardvark: Don't write read-only bits explicitly in PCI_ERR_CAP register Marek Behún
2022-09-27 14:19 ` Marek Behún
2022-09-27 14:19 ` [PATCH v2 09/10] PCI: aardvark: Explicitly disable Marvell strict ordering Marek Behún
2022-09-27 14:19 ` Marek Behún
2022-09-27 14:19 ` [PATCH v2 10/10] PCI: aardvark: Cleanup some register macros Marek Behún
2022-09-27 14:19 ` Marek Behún
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=20220927141926.8895-7-kabel@kernel.org \
--to=kabel@kernel.org \
--cc=gregory.clement@bootlin.com \
--cc=helgaas@kernel.org \
--cc=kw@linux.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pci@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=miquel.raynal@bootlin.com \
--cc=pali@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.