Skip to contentSkip to conversation

pci: dwc: dra7xx: Add shutdown handler to cleanly turn off clocks

PATCH Superseded Keerthy 2 participants 4 messages Sep 6, 2017 PCI

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Keerthy

author
#0 lore raw

PATCH 1/1 pci: dwc: dra7xx: Add shutdown handler to cleanly turn off clocks

Add shutdown handler to cleanly turn off clocks.

---
 drivers/pci/dwc/pci-dra7xx.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/pci/dwc/pci-dra7xx.c +14 -0
index d4e98f3..66d1cfe 100644
@@ -874,6 +874,19 @@ static int dra7xx_pcie_suspend_noirq(struct device *dev)
 	return 0;
 }
 
+void dra7xx_pcie_shutdown(struct platform_device *pdev)
+{
+	struct dra7xx_pcie *dra7xx = dev_get_drvdata(&pdev->dev);
+	int ret;
+
+	ret = pm_runtime_put_sync(&pdev->dev);
+	if (ret < 0)
+		dev_dbg(&pdev->dev, "pm_runtime_put_sync failed\n");
+
+	pm_runtime_disable(&pdev->dev);
+	dra7xx_pcie_disable_phy(dra7xx);
+}
+
 static int dra7xx_pcie_resume_noirq(struct device *dev)
 {
 	struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev);
@@ -902,5 +915,6 @@ static int dra7xx_pcie_resume_noirq(struct device *dev)
 		.suppress_bind_attrs = true,
 		.pm	= &dra7xx_pcie_pm_ops,
 	},
+	.shutdown = dra7xx_pcie_shutdown,
 };
 builtin_platform_driver_probe(dra7xx_pcie_driver, dra7xx_pcie_probe);
Signature · 1 line
1.9.1
Acked-by on v1 1/1
#1 lore raw

Keerthy,

Quoted 1 line · Keerthy

Add shutdown handler to cleanly turn off clocks.

one minor comment below.. with that fixed you can add my

Quoted 11 lines
---
 drivers/pci/dwc/pci-dra7xx.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/pci/dwc/pci-dra7xx.c +0 -0
index d4e98f3..66d1cfe 100644

drivers/pci/dwc/pci-dra7xx.c static int dra7xx_pcie_suspend_noirq(struct device *dev) · line 879

Quoted 6 lines
drivers/pci/dwc/pci-dra7xx.c +3 -0
@@ -874,6 +874,19 @@ static int dra7xx_pcie_suspend_noirq(struct device *dev)
 	return 0;
 }
 
+void dra7xx_pcie_shutdown(struct platform_device *pdev)
+{
+	struct dra7xx_pcie *dra7xx = dev_get_drvdata(&pdev->dev);

Use struct device *dev = &pdev->dev, instead of de-referencing device pointer multiple times.

Thanks
Kishon

#2 lore raw
Quoted 22 lines · Kishon Vijay Abraham I

Keerthy,

Quoted 1 line · Keerthy

Add shutdown handler to cleanly turn off clocks.

one minor comment below.. with that fixed you can add my

Quoted 14 lines
---
 drivers/pci/dwc/pci-dra7xx.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/pci/dwc/pci-dra7xx.c +0 -0
index d4e98f3..66d1cfe 100644
@@ -874,6 +874,19 @@ static int dra7xx_pcie_suspend_noirq(struct device *dev)
 	return 0;
 }
 
Quoted 6 lines

drivers/pci/dwc/pci-dra7xx.c static int dra7xx_pcie_suspend_noirq(struct device *dev) · line 879

Quoted 3 lines
drivers/pci/dwc/pci-dra7xx.c +3 -0
+void dra7xx_pcie_shutdown(struct platform_device *pdev)
+{
+	struct dra7xx_pcie *dra7xx = dev_get_drvdata(&pdev->dev);

Use struct device *dev = &pdev->dev, instead of de-referencing device pointer multiple times.

You might also have to dra7xx_pcie_stop_link() before disabling the clocks.

Thanks
Kishon

author
#3 lore raw
Quoted 25 lines · Kishon Vijay Abraham I
Quoted 22 lines · Kishon Vijay Abraham I

Keerthy,

Quoted 1 line · Keerthy

Add shutdown handler to cleanly turn off clocks.

one minor comment below.. with that fixed you can add my

Quoted 14 lines
---
 drivers/pci/dwc/pci-dra7xx.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/pci/dwc/pci-dra7xx.c +0 -0
index d4e98f3..66d1cfe 100644
@@ -874,6 +874,19 @@ static int dra7xx_pcie_suspend_noirq(struct device *dev)
 	return 0;
 }
 
Quoted 8 lines
Quoted 6 lines

drivers/pci/dwc/pci-dra7xx.c static int dra7xx_pcie_suspend_noirq(struct device *dev) · line 879

Quoted 3 lines
drivers/pci/dwc/pci-dra7xx.c +3 -0
+void dra7xx_pcie_shutdown(struct platform_device *pdev)
+{
+	struct dra7xx_pcie *dra7xx = dev_get_drvdata(&pdev->dev);

Use struct device *dev = &pdev->dev, instead of de-referencing device pointer multiple times.

You might also have to dra7xx_pcie_stop_link() before disabling the clocks.

Thanks for the quick review. I will incorporate the above comments and post v2.

Regards,
Keerthy

Quoted 4 lines

Thanks
Kishon