davinci: vpif: add pm_runtime support
PATCH 1/1 davinci: vpif: add pm_runtime support
From: Lad, Prabhakar <[email protected]>
Add pm_runtime support to the TI Davinci VPIF driver. Along side this patch replaces clk_get() with devm_clk_get() to simplify the error handling.
--- drivers/media/platform/davinci/vpif.c | 21 +++++++++++---------- 1 files changed, 11 insertions(+), 10 deletions(-)
drivers/media/platform/davinci/vpif.c +11 -10
@@ -25,6 +25,7 @@#include <linux/io.h> #include <linux/clk.h> #include <linux/err.h> +#include <linux/pm_runtime.h> #include <linux/v4l2-dv-timings.h> #include <mach/hardware.h>
@@ -44,7 +45,6 @@ static struct resource *res;spinlock_t vpif_lock;void __iomem *vpif_base; -struct clk *vpif_clk;/** * ch_params: video standard configuration parameters for vpif
@@ -421,6 +421,7 @@ EXPORT_SYMBOL(vpif_channel_getfid);static int vpif_probe (struct platform_device *pdev) { +struct clk *vpif_clk;int status =0 ; res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );
@@ -439,12 +440,17 @@ static int vpif_probe(struct platform_device *pdev) goto fail; } - vpif_clk =clk_get (&pdev->dev,"vpif" ); + vpif_clk =devm_clk_get (&pdev->dev,"vpif" );if (IS_ERR (vpif_clk)) { status =PTR_ERR (vpif_clk); goto clk_fail; } -clk_prepare_enable (vpif_clk); +clk_put (vpif_clk); + +pm_runtime_enable (&pdev->dev); +pm_runtime_resume (&pdev->dev); + +pm_runtime_get (&pdev->dev);spin_lock_init (&vpif_lock);dev_info (&pdev->dev,"vpif probe success\n" );
@@ -459,11 +465,6 @@ fail:static int vpif_remove (struct platform_device *pdev) { -if (vpif_clk) { -clk_disable_unprepare (vpif_clk); -clk_put (vpif_clk); - } -iounmap (vpif_base);release_mem_region (res->start, res_len);return 0 ;
@@ -472,13 +473,13 @@ static int vpif_remove(struct platform_device *pdev)#ifdef CONFIG_PM static int vpif_suspend (struct device *dev) { -clk_disable_unprepare (vpif_clk); +pm_runtime_put (dev);return 0 ; }static int vpif_resume (struct device *dev) { -clk_prepare_enable (vpif_clk); +pm_runtime_get (dev);return 0 ; }
Signature · 1 line
1.7.4.1
Hi Prabhakar,
Thanks for the patch.
Quoted 41 lines · On Thursday 28 March 2013 14:20:32 Prabhakar lad wrote:
From: Lad, Prabhakar <[email protected]>
Add
pm_runtimesupport to the TI Davinci VPIF driver. Along side this patch replacesclk_get()withdevm_clk_get()to simplify the error handling.Signed-off-by Lad, Prabhakar <[email protected]>--- drivers/media/platform/davinci/vpif.c | 21 +++++++++++---------- 1 files changed, 11 insertions(+), 10 deletions(-)(quoted diff) +0
-0
b/drivers/media/platform/davinci/vpif.cindex 28638a8..7d14625 100644drivers/media/platform/davinci/vpif.c +2
-1@@ -25,6 +25,7 @@#include <linux/io.h> #include <linux/clk.h> #include <linux/err.h> +#include <linux/pm_runtime.h> #include <linux/v4l2-dv-timings.h> #include <mach/hardware.h> @@ -44,7 +45,6 @@ static struct resource *res;spinlock_t vpif_lock;void __iomem *vpif_base; -struct clk *vpif_clk;/** * ch_params: video standard configuration parameters for vpif @@ -421,6 +421,7 @@ EXPORT_SYMBOL(vpif_channel_getfid);static int vpif_probe (struct platform_device *pdev) { +struct clk *vpif_clk;int status =0 ; res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );@@ -439,12 +440,17 @@ static int vpif_probe(struct platform_device *pdev) goto fail;
drivers/media/platform/davinci/vpif.c static int vpif_probe(struct platform_device *pdev) · line 448
Quoted 10 lines
drivers/media/platform/davinci/vpif.c +2
-2} - vpif_clk =clk_get (&pdev->dev,"vpif" ); + vpif_clk =devm_clk_get (&pdev->dev,"vpif" );if (IS_ERR (vpif_clk)) { status =PTR_ERR (vpif_clk); goto clk_fail; } -clk_prepare_enable (vpif_clk); +clk_put (vpif_clk);
Why do you need to call clk_put() here ?
drivers/media/platform/davinci/vpif.c static int vpif_probe(struct platform_device *pdev) · line 453
Quoted 4 lines
drivers/media/platform/davinci/vpif.c +4
-0+pm_runtime_enable (&pdev->dev); +pm_runtime_resume (&pdev->dev); + +pm_runtime_get (&pdev->dev);
Does runtime PM automatically handle your clock ? If so can't you remove clock handling from the driver completely ?
Quoted 29 lines
drivers/media/platform/davinci/vpif.c +2
-7spin_lock_init (&vpif_lock);dev_info (&pdev->dev,"vpif probe success\n" );@@ -459,11 +465,6 @@ fail:static int vpif_remove (struct platform_device *pdev) { -if (vpif_clk) { -clk_disable_unprepare (vpif_clk); -clk_put (vpif_clk); - } -iounmap (vpif_base);release_mem_region (res->start, res_len);return 0 ;@@ -472,13 +473,13 @@ static int vpif_remove(struct platform_device *pdev)#ifdef CONFIG_PM static int vpif_suspend (struct device *dev) { -clk_disable_unprepare (vpif_clk); +pm_runtime_put (dev);return 0 ; }static int vpif_resume (struct device *dev) { -clk_prepare_enable (vpif_clk); +pm_runtime_get (dev);return 0 ; }
Signature · 3 lines
Regards, Laurent Pinchart
Hi Laurent,
Thanks for the quick review!
Quoted 48 lines · Laurent Pinchart
Hi Prabhakar,
Thanks for the patch.
Quoted 43 lines · On Thursday 28 March 2013 14:20:32 Prabhakar lad wrote:
From: Lad, Prabhakar <[email protected]>
Add
pm_runtimesupport to the TI Davinci VPIF driver. Along side this patch replacesclk_get()withdevm_clk_get()to simplify the error handling.Signed-off-by Lad, Prabhakar <[email protected]>--- drivers/media/platform/davinci/vpif.c | 21 +++++++++++---------- 1 files changed, 11 insertions(+), 10 deletions(-)(quoted diff) +0
-0
b/drivers/media/platform/davinci/vpif.cindex 28638a8..7d14625 100644drivers/media/platform/davinci/vpif.c +2
-1@@ -25,6 +25,7 @@#include <linux/io.h> #include <linux/clk.h> #include <linux/err.h> +#include <linux/pm_runtime.h> #include <linux/v4l2-dv-timings.h> #include <mach/hardware.h> @@ -44,7 +45,6 @@ static struct resource *res;spinlock_t vpif_lock;void __iomem *vpif_base; -struct clk *vpif_clk;/** * ch_params: video standard configuration parameters for vpif @@ -421,6 +421,7 @@ EXPORT_SYMBOL(vpif_channel_getfid);static int vpif_probe (struct platform_device *pdev) { +struct clk *vpif_clk;int status =0 ; res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );@@ -439,12 +440,17 @@ static int vpif_probe(struct platform_device *pdev) goto fail; }
Quoted 11 lines
drivers/media/platform/davinci/vpif.c static int vpif_probe(struct platform_device *pdev) · line 448
Quoted 8 lines
drivers/media/platform/davinci/vpif.c +2
-2- vpif_clk =clk_get (&pdev->dev,"vpif" ); + vpif_clk =devm_clk_get (&pdev->dev,"vpif" );if (IS_ERR (vpif_clk)) { status =PTR_ERR (vpif_clk); goto clk_fail; } -clk_prepare_enable (vpif_clk); +clk_put (vpif_clk);Why do you need to call
clk_put()here ?
The above check is to see if the clock is provided, once done we free it using clk_put().
Quoted 8 lines
drivers/media/platform/davinci/vpif.c static int vpif_probe(struct platform_device *pdev) · line 453
Quoted 4 lines
drivers/media/platform/davinci/vpif.c +4
-0+pm_runtime_enable (&pdev->dev); +pm_runtime_resume (&pdev->dev); + +pm_runtime_get (&pdev->dev);Does runtime PM automatically handle your clock ? If so can't you remove clock handling from the driver completely ?
Yes pm runtime take care of enabling/disabling the clocks
so that we don't have to do it in drivers. I believe clock handling is removed with this patch, with just devm_clk_get() remaining ;)
Regards,
--Prabhakar
Quoted 34 lines
Quoted 19 lines
drivers/media/platform/davinci/vpif.c +0
-6spin_lock_init (&vpif_lock);dev_info (&pdev->dev,"vpif probe success\n" );@@ -459,11 +465,6 @@ fail:static int vpif_remove (struct platform_device *pdev) { -if (vpif_clk) { -clk_disable_unprepare (vpif_clk); -clk_put (vpif_clk); - } -iounmap (vpif_base);release_mem_region (res->start, res_len);return 0 ;@@ -472,13 +473,13 @@ static int vpif_remove(struct platform_device *pdev)#ifdef CONFIG_PM static int vpif_suspend (struct device *dev) { -clk_disable_unprepare (vpif_clk);drivers/media/platform/davinci/vpif.c static int vpif_remove(struct platform_device *pdev) · line 484
Quoted 10 lines
drivers/media/platform/davinci/vpif.c +2
-1+pm_runtime_put (dev);return 0 ; }static int vpif_resume (struct device *dev) { -clk_prepare_enable (vpif_clk); +pm_runtime_get (dev);return 0 ; }--
Regards,Laurent Pinchart
Hi Prabhakar,
Quoted 18 lines · On Thursday 28 March 2013 15:36:11 Prabhakar Lad wrote:
Quoted 17 lines · Laurent Pinchart
Quoted 16 lines · On Thursday 28 March 2013 14:20:32 Prabhakar lad wrote:
From: Lad, Prabhakar <[email protected]>
Add
pm_runtimesupport to the TI Davinci VPIF driver. Along side this patch replacesclk_get()withdevm_clk_get()to simplify the error handling.Signed-off-by Lad, Prabhakar <[email protected]>---
drivers/media/platform/davinci/vpif.c | 21 +++++++++++---------- 1 files changed, 11 insertions(+), 10 deletions(-)(quoted diff) +0
-0
b/drivers/media/platform/davinci/vpif.cindex 28638a8..7d14625 100644drivers/media/platform/davinci/vpif.c +0
-0
[snip]
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/media/platform/davinci/vpif.c +1
-1@@ -439,12 +440,17 @@ static int vpif_probe(struct platform_device *pdev) goto fail; } - vpif_clk =clk_get (&pdev->dev,"vpif" ); + vpif_clk =devm_clk_get (&pdev->dev,"vpif" );if (IS_ERR (vpif_clk)) { status =PTR_ERR (vpif_clk); goto clk_fail; }
Quoted 7 lines
Quoted 4 lines
drivers/media/platform/davinci/vpif.c static int vpif_probe(struct platform_device *pdev) · line 448
Quoted 2 lines
drivers/media/platform/davinci/vpif.c +1
-1-clk_prepare_enable (vpif_clk); +clk_put (vpif_clk);Why do you need to call
clk_put()here ?The above check is to see if the clock is provided, once done we free it using
clk_put().
In that case you shouldn't use devm_clk_get(), otherwise clk_put() will be called again automatically at remove() time.
Quoted 11 lines
Quoted 7 lines
drivers/media/platform/davinci/vpif.c static int vpif_probe(struct platform_device *pdev) · line 453
Quoted 4 lines
drivers/media/platform/davinci/vpif.c +4
-0+pm_runtime_enable (&pdev->dev); +pm_runtime_resume (&pdev->dev); + +pm_runtime_get (&pdev->dev);Does runtime PM automatically handle your clock ? If so can't you remove clock handling from the driver completely ?
Yes pm runtime take care of enabling/disabling the clocks
so that we don't have to do it in drivers. I believe clock handling is removed with this patch, with justdevm_clk_get()remaining ;)
When is the clk_get() call expected to fail ? If the clock is provided by the SoC and always available, can't the check be removed completely ?
Signature · 3 lines
Regards, Laurent Pinchart
Hi Laurent,
Quoted 40 lines · Laurent Pinchart
Hi Prabhakar,
Quoted 18 lines · On Thursday 28 March 2013 15:36:11 Prabhakar Lad wrote:
Quoted 17 lines · Laurent Pinchart
Quoted 16 lines · On Thursday 28 March 2013 14:20:32 Prabhakar lad wrote:
From: Lad, Prabhakar <[email protected]>
Add
pm_runtimesupport to the TI Davinci VPIF driver. Along side this patch replacesclk_get()withdevm_clk_get()to simplify the error handling.Signed-off-by Lad, Prabhakar <[email protected]>---
drivers/media/platform/davinci/vpif.c | 21 +++++++++++---------- 1 files changed, 11 insertions(+), 10 deletions(-)(quoted diff) +0
-0
b/drivers/media/platform/davinci/vpif.cindex 28638a8..7d14625 100644drivers/media/platform/davinci/vpif.c +0
-0[snip]
Quoted 16 lines
Quoted 15 lines
drivers/media/platform/davinci/vpif.c static int vpif_probe(struct platform_device *pdev) · line 449
Quoted 13 lines
drivers/media/platform/davinci/vpif.c +2
-2@@ -439,12 +440,17 @@ static int vpif_probe(struct platform_device *pdev) goto fail; } - vpif_clk =clk_get (&pdev->dev,"vpif" ); + vpif_clk =devm_clk_get (&pdev->dev,"vpif" );if (IS_ERR (vpif_clk)) { status =PTR_ERR (vpif_clk); goto clk_fail; } -clk_prepare_enable (vpif_clk); +clk_put (vpif_clk);Why do you need to call
clk_put()here ?
Quoted 6 lines
Quoted 2 lines
The above check is to see if the clock is provided, once done we free it using
clk_put().In that case you shouldn't use
devm_clk_get(), otherwiseclk_put()will be called again automatically atremove()time.
Yes agreed it should be clk_get() only.
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
drivers/media/platform/davinci/vpif.c static int vpif_probe(struct platform_device *pdev) · line 453
Quoted 4 lines
drivers/media/platform/davinci/vpif.c +4
-0+pm_runtime_enable (&pdev->dev); +pm_runtime_resume (&pdev->dev); + +pm_runtime_get (&pdev->dev);Does runtime PM automatically handle your clock ? If so can't you remove clock handling from the driver completely ?
Quoted 7 lines
Quoted 3 lines
Yes pm runtime take care of enabling/disabling the clocks
so that we don't have to do it in drivers. I believe clock handling is removed with this patch, with justdevm_clk_get()remaining ;)When is the
clk_get()call expected to fail ? If the clock is provided by the SoC and always available, can't the check be removed completely ?
Yes I agree with you it can be removed completely assuming the clock is always available from the Soc.
But may be I need feedback from others Hans/Sekhar what do you suggest ?
Regards,
--Prabhakar
Quoted 5 lines
--
Regards,Laurent Pinchart
Quoted 64 lines · Prabhakar Lad
Hi Laurent,
Quoted 40 lines · Laurent Pinchart
Hi Prabhakar,
Quoted 18 lines · On Thursday 28 March 2013 15:36:11 Prabhakar Lad wrote:
Quoted 17 lines · Laurent Pinchart
Quoted 16 lines · On Thursday 28 March 2013 14:20:32 Prabhakar lad wrote:
From: Lad, Prabhakar <[email protected]>
Add
pm_runtimesupport to the TI Davinci VPIF driver. Along side this patch replacesclk_get()withdevm_clk_get()to simplify the error handling.Signed-off-by Lad, Prabhakar <[email protected]>---
drivers/media/platform/davinci/vpif.c | 21 +++++++++++---------- 1 files changed, 11 insertions(+), 10 deletions(-)(quoted diff) +0
-0
b/drivers/media/platform/davinci/vpif.cindex 28638a8..7d14625 100644drivers/media/platform/davinci/vpif.c +0
-0[snip]
Quoted 16 lines
Quoted 15 lines
drivers/media/platform/davinci/vpif.c static int vpif_probe(struct platform_device *pdev) · line 449
Quoted 13 lines
drivers/media/platform/davinci/vpif.c +2
-2@@ -439,12 +440,17 @@ static int vpif_probe(struct platform_device *pdev) goto fail; } - vpif_clk =clk_get (&pdev->dev,"vpif" ); + vpif_clk =devm_clk_get (&pdev->dev,"vpif" );if (IS_ERR (vpif_clk)) { status =PTR_ERR (vpif_clk); goto clk_fail; } -clk_prepare_enable (vpif_clk); +clk_put (vpif_clk);Why do you need to call
clk_put()here ?Quoted 6 lines
Quoted 2 lines
The above check is to see if the clock is provided, once done we free it using
clk_put().In that case you shouldn't use
devm_clk_get(), otherwiseclk_put()will be called again automatically atremove()time.Yes agreed it should be
clk_get()only.Quoted 12 lines
Quoted 11 lines
Quoted 7 lines
drivers/media/platform/davinci/vpif.c static int vpif_probe(struct platform_device *pdev) · line 453
Quoted 4 lines
drivers/media/platform/davinci/vpif.c +4
-0+pm_runtime_enable (&pdev->dev); +pm_runtime_resume (&pdev->dev); + +pm_runtime_get (&pdev->dev);Does runtime PM automatically handle your clock ? If so can't you remove clock handling from the driver completely ?
Yes pm runtime take care of enabling/disabling the clocks
so that we don't have to do it in drivers. I believe clock handling is removed with this patch, with justdevm_clk_get()remaining ;)
Quoted 6 lines
Quoted 3 lines
When is the
clk_get()call expected to fail ? If the clock is provided by the SoC and always available, can't the check be removed completely ?Yes I agree with you it can be removed completely assuming the clock is always available from the Soc.
But may be I need feedback from others Hans/Sekhar what do you suggest ?
Unless you need the clk handle to get the clock rate or something, you should simply rely on runtime PM calls to enable clocks for you and not have any clk API call at all in your driver.
Thanks,
Sekhar
Hi Sekhar,
Quoted 68 lines · Sekhar Nori
Quoted 67 lines · Prabhakar Lad
Hi Laurent,
Quoted 40 lines · Laurent Pinchart
Hi Prabhakar,
Quoted 18 lines · On Thursday 28 March 2013 15:36:11 Prabhakar Lad wrote:
Quoted 17 lines · Laurent Pinchart
Quoted 16 lines · On Thursday 28 March 2013 14:20:32 Prabhakar lad wrote:
From: Lad, Prabhakar <[email protected]>
Add
pm_runtimesupport to the TI Davinci VPIF driver. Along side this patch replacesclk_get()withdevm_clk_get()to simplify the error handling.Signed-off-by Lad, Prabhakar <[email protected]>---
drivers/media/platform/davinci/vpif.c | 21 +++++++++++---------- 1 files changed, 11 insertions(+), 10 deletions(-)(quoted diff) +0
-0
b/drivers/media/platform/davinci/vpif.cindex 28638a8..7d14625 100644drivers/media/platform/davinci/vpif.c +0
-0[snip]
Quoted 16 lines
Quoted 15 lines
drivers/media/platform/davinci/vpif.c static int vpif_probe(struct platform_device *pdev) · line 449
Quoted 13 lines
drivers/media/platform/davinci/vpif.c +2
-2@@ -439,12 +440,17 @@ static int vpif_probe(struct platform_device *pdev) goto fail; } - vpif_clk =clk_get (&pdev->dev,"vpif" ); + vpif_clk =devm_clk_get (&pdev->dev,"vpif" );if (IS_ERR (vpif_clk)) { status =PTR_ERR (vpif_clk); goto clk_fail; } -clk_prepare_enable (vpif_clk); +clk_put (vpif_clk);Why do you need to call
clk_put()here ?Quoted 6 lines
Quoted 2 lines
The above check is to see if the clock is provided, once done we free it using
clk_put().In that case you shouldn't use
devm_clk_get(), otherwiseclk_put()will be called again automatically atremove()time.Yes agreed it should be
clk_get()only.Quoted 15 lines
Quoted 11 lines
Quoted 7 lines
drivers/media/platform/davinci/vpif.c static int vpif_probe(struct platform_device *pdev) · line 453
Quoted 4 lines
drivers/media/platform/davinci/vpif.c +4
-0+pm_runtime_enable (&pdev->dev); +pm_runtime_resume (&pdev->dev); + +pm_runtime_get (&pdev->dev);Does runtime PM automatically handle your clock ? If so can't you remove clock handling from the driver completely ?
Yes pm runtime take care of enabling/disabling the clocks
so that we don't have to do it in drivers. I believe clock handling is removed with this patch, with justdevm_clk_get()remaining ;)When is the
clk_get()call expected to fail ? If the clock is provided by the SoC and always available, can't the check be removed completely ?
Quoted 8 lines
Quoted 3 lines
Yes I agree with you it can be removed completely assuming the clock is always available from the Soc.
But may be I need feedback from others Hans/Sekhar what do you suggest ?Unless you need the clk handle to get the clock rate or something, you should simply rely on runtime PM calls to enable clocks for you and not have any clk API call at all in your driver.
Thanks this helps!, I'll post a v2 fixing it.
Regards,
--Prabhakar
Quoted 2 lines
Thanks,
Sekhar