* [PATCH v5 1/3] PCI: host: pci-dra7xx: Disable pm_runtime on get_sync failure
2015-07-31 12:25 [PATCH v5 0/3] dra7xx: Add PM support to PCIe Kishon Vijay Abraham I
@ 2015-07-31 12:25 ` Kishon Vijay Abraham I
2015-07-31 12:25 ` [PATCH v5 2/3] PCI: host: pci-dra7xx: add pm support to pci dra7xx Kishon Vijay Abraham I
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Kishon Vijay Abraham I @ 2015-07-31 12:25 UTC (permalink / raw)
To: bhelgaas, linux-omap, linux-pci, linux-kernel, jingoohan1,
nsekhar; +Cc: kishon
Fix the error handling code in case pm_runtime_get_sync fails. Now
when pm_runtime_get_sync fails pm_runtime_disable is invoked so that
there is no unbalanced pm_runtime_enable calls.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
drivers/pci/host/pci-dra7xx.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/host/pci-dra7xx.c b/drivers/pci/host/pci-dra7xx.c
index 80db09e..d8b6d66 100644
--- a/drivers/pci/host/pci-dra7xx.c
+++ b/drivers/pci/host/pci-dra7xx.c
@@ -384,7 +384,7 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
ret = pm_runtime_get_sync(dev);
if (IS_ERR_VALUE(ret)) {
dev_err(dev, "pm_runtime_get_sync failed\n");
- goto err_phy;
+ goto err_get_sync;
}
reg = dra7xx_pcie_readl(dra7xx, PCIECTRL_DRA7XX_CONF_DEVICE_CMD);
@@ -401,6 +401,8 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
err_add_port:
pm_runtime_put(dev);
+
+err_get_sync:
pm_runtime_disable(dev);
err_phy:
--
1.7.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v5 2/3] PCI: host: pci-dra7xx: add pm support to pci dra7xx
2015-07-31 12:25 [PATCH v5 0/3] dra7xx: Add PM support to PCIe Kishon Vijay Abraham I
2015-07-31 12:25 ` [PATCH v5 1/3] PCI: host: pci-dra7xx: Disable pm_runtime on get_sync failure Kishon Vijay Abraham I
@ 2015-07-31 12:25 ` Kishon Vijay Abraham I
2015-07-31 12:25 ` [PATCH v5 3/3] PCI: host: pci-dra7xx: Idle the module by disabling MSE bit Kishon Vijay Abraham I
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Kishon Vijay Abraham I @ 2015-07-31 12:25 UTC (permalink / raw)
To: bhelgaas, linux-omap, linux-pci, linux-kernel, jingoohan1,
nsekhar; +Cc: kishon
Add PM support to pci-dra7xx so that PCI clocks can be disabled
during suspend and enabled back during resume without affecting
PCI functionality.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
drivers/pci/host/pci-dra7xx.c | 51 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/drivers/pci/host/pci-dra7xx.c b/drivers/pci/host/pci-dra7xx.c
index d8b6d66..08b999a 100644
--- a/drivers/pci/host/pci-dra7xx.c
+++ b/drivers/pci/host/pci-dra7xx.c
@@ -433,6 +433,56 @@ static int __exit dra7xx_pcie_remove(struct platform_device *pdev)
return 0;
}
+#ifdef CONFIG_PM_SLEEP
+static int dra7xx_pcie_suspend_noirq(struct device *dev)
+{
+ struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev);
+ int count = dra7xx->phy_count;
+
+ while (count--) {
+ phy_power_off(dra7xx->phy[count]);
+ phy_exit(dra7xx->phy[count]);
+ }
+
+ return 0;
+}
+
+static int dra7xx_pcie_resume_noirq(struct device *dev)
+{
+ struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev);
+ int phy_count = dra7xx->phy_count;
+ int ret;
+ int i;
+
+ for (i = 0; i < phy_count; i++) {
+ ret = phy_init(dra7xx->phy[i]);
+ if (ret < 0)
+ goto err_phy;
+
+ ret = phy_power_on(dra7xx->phy[i]);
+ if (ret < 0) {
+ phy_exit(dra7xx->phy[i]);
+ goto err_phy;
+ }
+ }
+
+ return 0;
+
+err_phy:
+ while (--i >= 0) {
+ phy_power_off(dra7xx->phy[i]);
+ phy_exit(dra7xx->phy[i]);
+ }
+
+ return ret;
+}
+#endif
+
+static const struct dev_pm_ops dra7xx_pcie_pm_ops = {
+ SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(dra7xx_pcie_suspend_noirq,
+ dra7xx_pcie_resume_noirq)
+};
+
static const struct of_device_id of_dra7xx_pcie_match[] = {
{ .compatible = "ti,dra7-pcie", },
{},
@@ -444,6 +494,7 @@ static struct platform_driver dra7xx_pcie_driver = {
.driver = {
.name = "dra7-pcie",
.of_match_table = of_dra7xx_pcie_match,
+ .pm = &dra7xx_pcie_pm_ops,
},
};
--
1.7.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v5 3/3] PCI: host: pci-dra7xx: Idle the module by disabling MSE bit
2015-07-31 12:25 [PATCH v5 0/3] dra7xx: Add PM support to PCIe Kishon Vijay Abraham I
2015-07-31 12:25 ` [PATCH v5 1/3] PCI: host: pci-dra7xx: Disable pm_runtime on get_sync failure Kishon Vijay Abraham I
2015-07-31 12:25 ` [PATCH v5 2/3] PCI: host: pci-dra7xx: add pm support to pci dra7xx Kishon Vijay Abraham I
@ 2015-07-31 12:25 ` Kishon Vijay Abraham I
2015-08-06 15:33 ` [PATCH v5 0/3] dra7xx: Add PM support to PCIe Jingoo Han
2015-08-11 20:52 ` Bjorn Helgaas
4 siblings, 0 replies; 7+ messages in thread
From: Kishon Vijay Abraham I @ 2015-07-31 12:25 UTC (permalink / raw)
To: bhelgaas, linux-omap, linux-pci, linux-kernel, jingoohan1,
nsekhar; +Cc: kishon
DRA7xx require MSE bit to be cleared to set the master in
standby mode. (In DRA7xx TRM_vE, section 24.9.4.5.2.2.1 PCIe
Controller Master Standby Behavior advises to use the clearing
of the local MSE bit to set the master in standby. Without this
some of the clocks do not idle).
Cleared the MSE bit on suspend and enabled it back on resume.
Clearing MSE bit is required to get clocks to be idled after
suspend.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
---
drivers/pci/host/pci-dra7xx.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/drivers/pci/host/pci-dra7xx.c b/drivers/pci/host/pci-dra7xx.c
index 08b999a..3772aff 100644
--- a/drivers/pci/host/pci-dra7xx.c
+++ b/drivers/pci/host/pci-dra7xx.c
@@ -83,6 +83,17 @@ static inline void dra7xx_pcie_writel(struct dra7xx_pcie *pcie, u32 offset,
writel(value, pcie->base + offset);
}
+static inline u32 dra7xx_pcie_readl_rc(struct pcie_port *pp, u32 offset)
+{
+ return readl(pp->dbi_base + offset);
+}
+
+static inline void dra7xx_pcie_writel_rc(struct pcie_port *pp, u32 offset,
+ u32 value)
+{
+ writel(value, pp->dbi_base + offset);
+}
+
static int dra7xx_pcie_link_up(struct pcie_port *pp)
{
struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pp);
@@ -434,6 +445,34 @@ static int __exit dra7xx_pcie_remove(struct platform_device *pdev)
}
#ifdef CONFIG_PM_SLEEP
+static int dra7xx_pcie_suspend(struct device *dev)
+{
+ struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev);
+ struct pcie_port *pp = &dra7xx->pp;
+ u32 val;
+
+ /* clear MSE */
+ val = dra7xx_pcie_readl_rc(pp, PCI_COMMAND);
+ val &= ~PCI_COMMAND_MEMORY;
+ dra7xx_pcie_writel_rc(pp, PCI_COMMAND, val);
+
+ return 0;
+}
+
+static int dra7xx_pcie_resume(struct device *dev)
+{
+ struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev);
+ struct pcie_port *pp = &dra7xx->pp;
+ u32 val;
+
+ /* set MSE */
+ val = dra7xx_pcie_readl_rc(pp, PCI_COMMAND);
+ val |= PCI_COMMAND_MEMORY;
+ dra7xx_pcie_writel_rc(pp, PCI_COMMAND, val);
+
+ return 0;
+}
+
static int dra7xx_pcie_suspend_noirq(struct device *dev)
{
struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev);
@@ -479,6 +518,7 @@ err_phy:
#endif
static const struct dev_pm_ops dra7xx_pcie_pm_ops = {
+ SET_SYSTEM_SLEEP_PM_OPS(dra7xx_pcie_suspend, dra7xx_pcie_resume)
SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(dra7xx_pcie_suspend_noirq,
dra7xx_pcie_resume_noirq)
};
--
1.7.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH v5 0/3] dra7xx: Add PM support to PCIe
2015-07-31 12:25 [PATCH v5 0/3] dra7xx: Add PM support to PCIe Kishon Vijay Abraham I
` (2 preceding siblings ...)
2015-07-31 12:25 ` [PATCH v5 3/3] PCI: host: pci-dra7xx: Idle the module by disabling MSE bit Kishon Vijay Abraham I
@ 2015-08-06 15:33 ` Jingoo Han
2015-08-11 20:52 ` Bjorn Helgaas
4 siblings, 0 replies; 7+ messages in thread
From: Jingoo Han @ 2015-08-06 15:33 UTC (permalink / raw)
To: 'Kishon Vijay Abraham I'
Cc: bhelgaas, linux-omap, linux-pci, linux-kernel, nsekhar,
'Jingoo Han'
On Friday, July 31, 2015 9:25 PM, Kishon Vijay Abraham I wrote:
>
> This series adds PM support to pci-dra7xx so that PCI clocks can be disabled
> during suspend and enabled back during resume without affecting
> PCI functionality.
>
> Changes from v4:
> *) Fixed a bug caused by sending incomplete patch.
>
> Changes from v3:
> *) Fix compilation errors when individual patches are applied
>
> Changes from v2:
> *) Used SET_SYSTEM_SLEEP_PM_OPS and SET_NOIRQ_SYSTEM_SLEEP_PM_OPS for
> populating PM ops.
>
> Changes from v1:
> *) Moved resetting and setting of MSE bit to pci-dra7xx.
>
> The comment to reset and set ISE is not done now since I don't have a card
> with IO space. Once I get to test that, I'll post a separate patch for
> handling that.
>
> Kishon Vijay Abraham I (3):
> PCI: host: pci-dra7xx: Disable pm_runtime on get_sync failure
> PCI: host: pci-dra7xx: add pm support to pci dra7xx
> PCI: host: pci-dra7xx: Idle the module by disabling MSE bit
Hi Kishon,
Looks good! :-)
Reviewed-by: Jingoo Han <jingoohan1@gmail.com>
Best regards,
Jingoo Han
>
> drivers/pci/host/pci-dra7xx.c | 95 ++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 94 insertions(+), 1 deletion(-)
>
> --
> 1.7.9.5
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v5 0/3] dra7xx: Add PM support to PCIe
2015-07-31 12:25 [PATCH v5 0/3] dra7xx: Add PM support to PCIe Kishon Vijay Abraham I
` (3 preceding siblings ...)
2015-08-06 15:33 ` [PATCH v5 0/3] dra7xx: Add PM support to PCIe Jingoo Han
@ 2015-08-11 20:52 ` Bjorn Helgaas
2015-08-12 5:40 ` Kishon Vijay Abraham I
4 siblings, 1 reply; 7+ messages in thread
From: Bjorn Helgaas @ 2015-08-11 20:52 UTC (permalink / raw)
To: Kishon Vijay Abraham I
Cc: linux-omap, linux-pci, linux-kernel, jingoohan1, nsekhar
On Fri, Jul 31, 2015 at 05:55:09PM +0530, Kishon Vijay Abraham I wrote:
> This series adds PM support to pci-dra7xx so that PCI clocks can be disabled
> during suspend and enabled back during resume without affecting
> PCI functionality.
>
> Changes from v4:
> *) Fixed a bug caused by sending incomplete patch.
>
> Changes from v3:
> *) Fix compilation errors when individual patches are applied
>
> Changes from v2:
> *) Used SET_SYSTEM_SLEEP_PM_OPS and SET_NOIRQ_SYSTEM_SLEEP_PM_OPS for
> populating PM ops.
>
> Changes from v1:
> *) Moved resetting and setting of MSE bit to pci-dra7xx.
>
> The comment to reset and set ISE is not done now since I don't have a card
> with IO space. Once I get to test that, I'll post a separate patch for
> handling that.
>
> Kishon Vijay Abraham I (3):
> PCI: host: pci-dra7xx: Disable pm_runtime on get_sync failure
> PCI: host: pci-dra7xx: add pm support to pci dra7xx
> PCI: host: pci-dra7xx: Idle the module by disabling MSE bit
>
> drivers/pci/host/pci-dra7xx.c | 95 ++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 94 insertions(+), 1 deletion(-)
Applied with Jingoo's Reviewed-by to pci/host-dra7xx for v4.3, thanks!
I tweaked the changelogs as follows:
commit 0e2bdb0e7abf4b5170874e415ec42df547916dd3
Author: Kishon Vijay Abraham I <kishon@ti.com>
Date: Fri Jul 31 17:55:10 2015 +0530
PCI: dra7xx: Disable pm_runtime on get_sync failure
Fix the error handling when pm_runtime_get_sync() fails.
If pm_runtime_get_sync() fails, call pm_runtime_disable() so there are no
unbalanced pm_runtime_enable() calls.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Jingoo Han <jingoohan1@gmail.com>
commit e52eb445ea1d97bf7fb92d2297e487a305392136
Author: Kishon Vijay Abraham I <kishon@ti.com>
Date: Fri Jul 31 17:55:11 2015 +0530
PCI: dra7xx: Add PM support
Add PM support to pci-dra7xx so PCI clocks can be disabled during suspend
and enabled during resume without affecting PCI functionality.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Jingoo Han <jingoohan1@gmail.com>
commit 389c7094ec241ee8ebe358ba10fe392018692c8c
Author: Kishon Vijay Abraham I <kishon@ti.com>
Date: Fri Jul 31 17:55:12 2015 +0530
PCI: dra7xx: Clear MSE bit during suspend so clocks will idle
DRA7xx requires the MSE bit to be cleared to set the master in standby
mode. (In DRA7xx TRM_vE, section 24.9.4.5.2.2.1 PCIe Controller Master
Standby Behavior advises to use the clearing of the local MSE bit to set
the master in standby. Without this some of the clocks do not idle).
Clear the MSE bit on suspend and enable it on resume. Clearing MSE bit is
required to get clocks to be idled after suspend.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Jingoo Han <jingoohan1@gmail.com>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v5 0/3] dra7xx: Add PM support to PCIe
2015-08-11 20:52 ` Bjorn Helgaas
@ 2015-08-12 5:40 ` Kishon Vijay Abraham I
0 siblings, 0 replies; 7+ messages in thread
From: Kishon Vijay Abraham I @ 2015-08-12 5:40 UTC (permalink / raw)
To: Bjorn Helgaas; +Cc: linux-omap, linux-pci, linux-kernel, jingoohan1, nsekhar
On Wednesday 12 August 2015 02:22 AM, Bjorn Helgaas wrote:
> On Fri, Jul 31, 2015 at 05:55:09PM +0530, Kishon Vijay Abraham I wrote:
>> This series adds PM support to pci-dra7xx so that PCI clocks can be disabled
>> during suspend and enabled back during resume without affecting
>> PCI functionality.
>>
>> Changes from v4:
>> *) Fixed a bug caused by sending incomplete patch.
>>
>> Changes from v3:
>> *) Fix compilation errors when individual patches are applied
>>
>> Changes from v2:
>> *) Used SET_SYSTEM_SLEEP_PM_OPS and SET_NOIRQ_SYSTEM_SLEEP_PM_OPS for
>> populating PM ops.
>>
>> Changes from v1:
>> *) Moved resetting and setting of MSE bit to pci-dra7xx.
>>
>> The comment to reset and set ISE is not done now since I don't have a card
>> with IO space. Once I get to test that, I'll post a separate patch for
>> handling that.
>>
>> Kishon Vijay Abraham I (3):
>> PCI: host: pci-dra7xx: Disable pm_runtime on get_sync failure
>> PCI: host: pci-dra7xx: add pm support to pci dra7xx
>> PCI: host: pci-dra7xx: Idle the module by disabling MSE bit
>>
>> drivers/pci/host/pci-dra7xx.c | 95 ++++++++++++++++++++++++++++++++++++++++-
>> 1 file changed, 94 insertions(+), 1 deletion(-)
>
> Applied with Jingoo's Reviewed-by to pci/host-dra7xx for v4.3, thanks!
>
> I tweaked the changelogs as follows:
>
>
> commit 0e2bdb0e7abf4b5170874e415ec42df547916dd3
> Author: Kishon Vijay Abraham I <kishon@ti.com>
> Date: Fri Jul 31 17:55:10 2015 +0530
>
> PCI: dra7xx: Disable pm_runtime on get_sync failure
>
> Fix the error handling when pm_runtime_get_sync() fails.
>
> If pm_runtime_get_sync() fails, call pm_runtime_disable() so there are no
> unbalanced pm_runtime_enable() calls.
>
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> Reviewed-by: Jingoo Han <jingoohan1@gmail.com>
>
> commit e52eb445ea1d97bf7fb92d2297e487a305392136
> Author: Kishon Vijay Abraham I <kishon@ti.com>
> Date: Fri Jul 31 17:55:11 2015 +0530
>
> PCI: dra7xx: Add PM support
>
> Add PM support to pci-dra7xx so PCI clocks can be disabled during suspend
> and enabled during resume without affecting PCI functionality.
>
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> Reviewed-by: Jingoo Han <jingoohan1@gmail.com>
>
> commit 389c7094ec241ee8ebe358ba10fe392018692c8c
> Author: Kishon Vijay Abraham I <kishon@ti.com>
> Date: Fri Jul 31 17:55:12 2015 +0530
>
> PCI: dra7xx: Clear MSE bit during suspend so clocks will idle
>
> DRA7xx requires the MSE bit to be cleared to set the master in standby
> mode. (In DRA7xx TRM_vE, section 24.9.4.5.2.2.1 PCIe Controller Master
> Standby Behavior advises to use the clearing of the local MSE bit to set
> the master in standby. Without this some of the clocks do not idle).
>
> Clear the MSE bit on suspend and enable it on resume. Clearing MSE bit is
> required to get clocks to be idled after suspend.
>
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> Signed-off-by: Sekhar Nori <nsekhar@ti.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> Reviewed-by: Jingoo Han <jingoohan1@gmail.com>
Thanks Bjorn!
-Kishon
^ permalink raw reply [flat|nested] 7+ messages in thread