diff mbox

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

Message ID 1505885055-30657-1-git-send-email-j-keerthy@ti.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

J, KEERTHY Sept. 20, 2017, 5:24 a.m. UTC
Add shutdown handler to cleanly turn off clocks. This will help
in cases of kexec where in a new kernel can boot abruptly.

Signed-off-by: Keerthy <j-keerthy@ti.com>
Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
---

Changes in v4:

  * Added the missing changes from v2!

Changes in v3:

  * Pushed the function outside #ifdef CONFIG_PM_SLEEP.
  * Added more details to commit log.

Changes in v2:

  * used a local dev pointer instead of dereferencing dev at multiple places.
  * dra7xx_pcie_stop_link before disabling clks in the shutdown path.

 drivers/pci/dwc/pci-dra7xx.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

Bjorn Helgaas Oct. 11, 2017, 7:32 p.m. UTC | #1
On Wed, Sep 20, 2017 at 10:54:15AM +0530, Keerthy wrote:
> Add shutdown handler to cleanly turn off clocks. This will help
> in cases of kexec where in a new kernel can boot abruptly.
> 
> Signed-off-by: Keerthy <j-keerthy@ti.com>
> Acked-by: Kishon Vijay Abraham I <kishon@ti.com>

Applied to pci/host-dra7xx for v4.15, thanks!

> ---
> 
> Changes in v4:
> 
>   * Added the missing changes from v2!
> 
> Changes in v3:
> 
>   * Pushed the function outside #ifdef CONFIG_PM_SLEEP.
>   * Added more details to commit log.
> 
> Changes in v2:
> 
>   * used a local dev pointer instead of dereferencing dev at multiple places.
>   * dra7xx_pcie_stop_link before disabling clks in the shutdown path.
> 
>  drivers/pci/dwc/pci-dra7xx.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/drivers/pci/dwc/pci-dra7xx.c b/drivers/pci/dwc/pci-dra7xx.c
> index 34427a6..d084800 100644
> --- a/drivers/pci/dwc/pci-dra7xx.c
> +++ b/drivers/pci/dwc/pci-dra7xx.c
> @@ -794,6 +794,22 @@ static int dra7xx_pcie_resume_noirq(struct device *dev)
>  }
>  #endif
>  
> +void dra7xx_pcie_shutdown(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev);
> +	int ret;
> +
> +	dra7xx_pcie_stop_link(dra7xx->pci);
> +
> +	ret = pm_runtime_put_sync(dev);
> +	if (ret < 0)
> +		dev_dbg(dev, "pm_runtime_put_sync failed\n");
> +
> +	pm_runtime_disable(dev);
> +	dra7xx_pcie_disable_phy(dra7xx);
> +}
> +
>  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,
> @@ -807,5 +823,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);
> -- 
> 1.9.1
>
Niklas Cassel Nov. 3, 2017, 2:30 p.m. UTC | #2
dra7xx_pcie_shutdown should be static.

This patch introduces a new sparse warning.

On Wed, Oct 11, 2017 at 9:32 PM, Bjorn Helgaas <helgaas@kernel.org> wrote:
> On Wed, Sep 20, 2017 at 10:54:15AM +0530, Keerthy wrote:
>> Add shutdown handler to cleanly turn off clocks. This will help
>> in cases of kexec where in a new kernel can boot abruptly.
>>
>> Signed-off-by: Keerthy <j-keerthy@ti.com>
>> Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
>
> Applied to pci/host-dra7xx for v4.15, thanks!
>
>> ---
>>
>> Changes in v4:
>>
>>   * Added the missing changes from v2!
>>
>> Changes in v3:
>>
>>   * Pushed the function outside #ifdef CONFIG_PM_SLEEP.
>>   * Added more details to commit log.
>>
>> Changes in v2:
>>
>>   * used a local dev pointer instead of dereferencing dev at multiple places.
>>   * dra7xx_pcie_stop_link before disabling clks in the shutdown path.
>>
>>  drivers/pci/dwc/pci-dra7xx.c | 17 +++++++++++++++++
>>  1 file changed, 17 insertions(+)
>>
>> diff --git a/drivers/pci/dwc/pci-dra7xx.c b/drivers/pci/dwc/pci-dra7xx.c
>> index 34427a6..d084800 100644
>> --- a/drivers/pci/dwc/pci-dra7xx.c
>> +++ b/drivers/pci/dwc/pci-dra7xx.c
>> @@ -794,6 +794,22 @@ static int dra7xx_pcie_resume_noirq(struct device *dev)
>>  }
>>  #endif
>>
>> +void dra7xx_pcie_shutdown(struct platform_device *pdev)
>> +{
>> +     struct device *dev = &pdev->dev;
>> +     struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev);
>> +     int ret;
>> +
>> +     dra7xx_pcie_stop_link(dra7xx->pci);
>> +
>> +     ret = pm_runtime_put_sync(dev);
>> +     if (ret < 0)
>> +             dev_dbg(dev, "pm_runtime_put_sync failed\n");
>> +
>> +     pm_runtime_disable(dev);
>> +     dra7xx_pcie_disable_phy(dra7xx);
>> +}
>> +
>>  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,
>> @@ -807,5 +823,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);
>> --
>> 1.9.1
>>
J, KEERTHY Nov. 6, 2017, 5:04 a.m. UTC | #3
On Friday 03 November 2017 08:00 PM, Niklas Cassel wrote:
> dra7xx_pcie_shutdown should be static.
> 
> This patch introduces a new sparse warning.

Thanks Niklas for reporting.

Bjorn,

Should i send a next version or just a fix patch on top of this?

Regards,
Keerthy

> 
> On Wed, Oct 11, 2017 at 9:32 PM, Bjorn Helgaas <helgaas@kernel.org> wrote:
>> On Wed, Sep 20, 2017 at 10:54:15AM +0530, Keerthy wrote:
>>> Add shutdown handler to cleanly turn off clocks. This will help
>>> in cases of kexec where in a new kernel can boot abruptly.
>>>
>>> Signed-off-by: Keerthy <j-keerthy@ti.com>
>>> Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
>>
>> Applied to pci/host-dra7xx for v4.15, thanks!
>>
>>> ---
>>>
>>> Changes in v4:
>>>
>>>   * Added the missing changes from v2!
>>>
>>> Changes in v3:
>>>
>>>   * Pushed the function outside #ifdef CONFIG_PM_SLEEP.
>>>   * Added more details to commit log.
>>>
>>> Changes in v2:
>>>
>>>   * used a local dev pointer instead of dereferencing dev at multiple places.
>>>   * dra7xx_pcie_stop_link before disabling clks in the shutdown path.
>>>
>>>  drivers/pci/dwc/pci-dra7xx.c | 17 +++++++++++++++++
>>>  1 file changed, 17 insertions(+)
>>>
>>> diff --git a/drivers/pci/dwc/pci-dra7xx.c b/drivers/pci/dwc/pci-dra7xx.c
>>> index 34427a6..d084800 100644
>>> --- a/drivers/pci/dwc/pci-dra7xx.c
>>> +++ b/drivers/pci/dwc/pci-dra7xx.c
>>> @@ -794,6 +794,22 @@ static int dra7xx_pcie_resume_noirq(struct device *dev)
>>>  }
>>>  #endif
>>>
>>> +void dra7xx_pcie_shutdown(struct platform_device *pdev)
>>> +{
>>> +     struct device *dev = &pdev->dev;
>>> +     struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev);
>>> +     int ret;
>>> +
>>> +     dra7xx_pcie_stop_link(dra7xx->pci);
>>> +
>>> +     ret = pm_runtime_put_sync(dev);
>>> +     if (ret < 0)
>>> +             dev_dbg(dev, "pm_runtime_put_sync failed\n");
>>> +
>>> +     pm_runtime_disable(dev);
>>> +     dra7xx_pcie_disable_phy(dra7xx);
>>> +}
>>> +
>>>  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,
>>> @@ -807,5 +823,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);
>>> --
>>> 1.9.1
>>>
Bjorn Helgaas Nov. 6, 2017, 5:22 p.m. UTC | #4
On Mon, Nov 06, 2017 at 10:34:28AM +0530, Keerthy wrote:
> 
> 
> On Friday 03 November 2017 08:00 PM, Niklas Cassel wrote:
> > dra7xx_pcie_shutdown should be static.
> > 
> > This patch introduces a new sparse warning.
> 
> Thanks Niklas for reporting.
> 
> Bjorn,
> 
> Should i send a next version or just a fix patch on top of this?

Either way is fine.  I'll just fold it in or replace the existing patch.

> > On Wed, Oct 11, 2017 at 9:32 PM, Bjorn Helgaas <helgaas@kernel.org> wrote:
> >> On Wed, Sep 20, 2017 at 10:54:15AM +0530, Keerthy wrote:
> >>> Add shutdown handler to cleanly turn off clocks. This will help
> >>> in cases of kexec where in a new kernel can boot abruptly.
> >>>
> >>> Signed-off-by: Keerthy <j-keerthy@ti.com>
> >>> Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
> >>
> >> Applied to pci/host-dra7xx for v4.15, thanks!
> >>
> >>> ---
> >>>
> >>> Changes in v4:
> >>>
> >>>   * Added the missing changes from v2!
> >>>
> >>> Changes in v3:
> >>>
> >>>   * Pushed the function outside #ifdef CONFIG_PM_SLEEP.
> >>>   * Added more details to commit log.
> >>>
> >>> Changes in v2:
> >>>
> >>>   * used a local dev pointer instead of dereferencing dev at multiple places.
> >>>   * dra7xx_pcie_stop_link before disabling clks in the shutdown path.
> >>>
> >>>  drivers/pci/dwc/pci-dra7xx.c | 17 +++++++++++++++++
> >>>  1 file changed, 17 insertions(+)
> >>>
> >>> diff --git a/drivers/pci/dwc/pci-dra7xx.c b/drivers/pci/dwc/pci-dra7xx.c
> >>> index 34427a6..d084800 100644
> >>> --- a/drivers/pci/dwc/pci-dra7xx.c
> >>> +++ b/drivers/pci/dwc/pci-dra7xx.c
> >>> @@ -794,6 +794,22 @@ static int dra7xx_pcie_resume_noirq(struct device *dev)
> >>>  }
> >>>  #endif
> >>>
> >>> +void dra7xx_pcie_shutdown(struct platform_device *pdev)
> >>> +{
> >>> +     struct device *dev = &pdev->dev;
> >>> +     struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev);
> >>> +     int ret;
> >>> +
> >>> +     dra7xx_pcie_stop_link(dra7xx->pci);
> >>> +
> >>> +     ret = pm_runtime_put_sync(dev);
> >>> +     if (ret < 0)
> >>> +             dev_dbg(dev, "pm_runtime_put_sync failed\n");
> >>> +
> >>> +     pm_runtime_disable(dev);
> >>> +     dra7xx_pcie_disable_phy(dra7xx);
> >>> +}
> >>> +
> >>>  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,
> >>> @@ -807,5 +823,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);
> >>> --
> >>> 1.9.1
> >>>
diff mbox

Patch

diff --git a/drivers/pci/dwc/pci-dra7xx.c b/drivers/pci/dwc/pci-dra7xx.c
index 34427a6..d084800 100644
--- a/drivers/pci/dwc/pci-dra7xx.c
+++ b/drivers/pci/dwc/pci-dra7xx.c
@@ -794,6 +794,22 @@  static int dra7xx_pcie_resume_noirq(struct device *dev)
 }
 #endif
 
+void dra7xx_pcie_shutdown(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev);
+	int ret;
+
+	dra7xx_pcie_stop_link(dra7xx->pci);
+
+	ret = pm_runtime_put_sync(dev);
+	if (ret < 0)
+		dev_dbg(dev, "pm_runtime_put_sync failed\n");
+
+	pm_runtime_disable(dev);
+	dra7xx_pcie_disable_phy(dra7xx);
+}
+
 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,
@@ -807,5 +823,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);