Hello,
This patch series, based on v3.12-rc7, prepares various Renesas SH-Mobile, R-Mobile and R-Car drivers for migration to CCF by adding clock prepare and unprepare support.
The patches are pretty straightforward. Most of the drivers called clk_enable and clk_disable in sleepable context, I've thus just converted them to clk_prepare_enable and clk_disable_unprepare.
The clocksource drivers were slightly more complex to handle as clk_enable and clk_disable were called in non-sleepable context. As the clocksource framework architecture doesn't provide any sleepable callback in which clocks could be prepared and unprepared, I've added clk_prepare and clk_unprepare calls in the probe and suspend/resume handlers (clocksources can't be removed so the remove handler doesn't need a clk_unprepare call).
I'd like to get all these patches merged in v3.14. As they will need to go through their respective subsystems' trees, I would appreciate if all maintainers involved could notify me when they merge patches from this series in their tree to help me tracking the merge status. I don't plan to send pull requests individually for these patches, and I will repost patches individually if changes are requested during review.
Cc: Daniel Lezcano daniel.lezcano@linaro.org Cc: linux-kernel@vger.kernel.org Cc: Tejun Heo tj@kernel.org Cc: linux-ide@vger.kernel.org Cc: David Airlie airlied@linux.ie Cc: dri-devel@lists.freedesktop.org Cc: Wolfram Sang wsa@the-dreams.de Cc: linux-i2c@vger.kernel.org Cc: Chris Ball cjb@laptop.org Cc: Guennadi Liakhovetski g.liakhovetski+renesas@gmail.com Cc: linux-mmc@vger.kernel.org Cc: Felipe Balbi balbi@ti.com Cc: linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman gregkh@linuxfoundation.org Cc: Yoshihiro Shimoda yoshihiro.shimoda.uh@renesas.com Cc: Jean-Christophe Plagniol-Villard plagnioj@jcrosoft.com Cc: Tomi Valkeinen tomi.valkeinen@ti.com Cc: linux-fbdev@vger.kernel.org
Laurent Pinchart (12): clocksource: sh_cmt: Add clk_prepare/unprepare support clocksource: sh_mtu2: Add clk_prepare/unprepare support clocksource: sh_tmu: Add clk_prepare/unprepare support sata_rcar: Convert to clk_prepare/unprepare drm: shmob_drm: Convert to clk_prepare/unprepare i2c: sh_mobile: Convert to clk_prepare/unprepare mmc: sh_mmcif: Convert to clk_prepare/unprepare mmc: sh_mobile_sdhi: Convert to clk_prepare/unprepare usb: gadget: r8a66597-udc: Convert to clk_prepare/unprepare usb: r8a66597-hcd: Convert to clk_prepare/unprepare fbdev: shmobile-hdmi: Convert to clk_prepare/unprepare fbdev: shmobile-lcdcfb: Convert to clk_prepare/unprepare
drivers/ata/sata_rcar.c | 10 +++++----- drivers/clocksource/sh_cmt.c | 20 ++++++++++++++++---- drivers/clocksource/sh_mtu2.c | 16 ++++++++++++++-- drivers/clocksource/sh_tmu.c | 20 +++++++++++++++++--- drivers/gpu/drm/shmobile/shmob_drm_crtc.c | 4 ++-- drivers/i2c/busses/i2c-sh_mobile.c | 8 ++++---- drivers/mmc/host/sh_mmcif.c | 12 ++++++------ drivers/mmc/host/sh_mobile_sdhi.c | 4 ++-- drivers/usb/gadget/r8a66597-udc.c | 6 +++--- drivers/usb/host/r8a66597-hcd.c | 4 ++-- drivers/video/sh_mobile_hdmi.c | 6 +++--- drivers/video/sh_mobile_lcdcfb.c | 4 ++-- 12 files changed, 76 insertions(+), 38 deletions(-)
Turn clk_enable() and clk_disable() calls into clk_prepare_enable() and clk_disable_unprepare() to get ready for the migration to the common clock framework.
Cc: David Airlie airlied@linux.ie Cc: dri-devel@lists.freedesktop.org Signed-off-by: Laurent Pinchart laurent.pinchart+renesas@ideasonboard.com --- drivers/gpu/drm/shmobile/shmob_drm_crtc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_crtc.c b/drivers/gpu/drm/shmobile/shmob_drm_crtc.c index 54bad98..562f9a4 100644 --- a/drivers/gpu/drm/shmobile/shmob_drm_crtc.c +++ b/drivers/gpu/drm/shmobile/shmob_drm_crtc.c @@ -40,7 +40,7 @@ static void shmob_drm_clk_on(struct shmob_drm_device *sdev) { if (sdev->clock) - clk_enable(sdev->clock); + clk_prepare_enable(sdev->clock); #if 0 if (sdev->meram_dev && sdev->meram_dev->pdev) pm_runtime_get_sync(&sdev->meram_dev->pdev->dev); @@ -54,7 +54,7 @@ static void shmob_drm_clk_off(struct shmob_drm_device *sdev) pm_runtime_put_sync(&sdev->meram_dev->pdev->dev); #endif if (sdev->clock) - clk_disable(sdev->clock); + clk_disable_unprepare(sdev->clock); }
/* -----------------------------------------------------------------------------
Hi Dave,
Could you please pick this patch up ?
On Monday 28 October 2013 23:49:22 Laurent Pinchart wrote:
Turn clk_enable() and clk_disable() calls into clk_prepare_enable() and clk_disable_unprepare() to get ready for the migration to the common clock framework.
Cc: David Airlie airlied@linux.ie Cc: dri-devel@lists.freedesktop.org Signed-off-by: Laurent Pinchart laurent.pinchart+renesas@ideasonboard.com
drivers/gpu/drm/shmobile/shmob_drm_crtc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_crtc.c b/drivers/gpu/drm/shmobile/shmob_drm_crtc.c index 54bad98..562f9a4 100644 --- a/drivers/gpu/drm/shmobile/shmob_drm_crtc.c +++ b/drivers/gpu/drm/shmobile/shmob_drm_crtc.c @@ -40,7 +40,7 @@ static void shmob_drm_clk_on(struct shmob_drm_device *sdev) { if (sdev->clock)
clk_enable(sdev->clock);
clk_prepare_enable(sdev->clock);
#if 0 if (sdev->meram_dev && sdev->meram_dev->pdev) pm_runtime_get_sync(&sdev->meram_dev->pdev->dev); @@ -54,7 +54,7 @@ static void shmob_drm_clk_off(struct shmob_drm_device *sdev) pm_runtime_put_sync(&sdev->meram_dev->pdev->dev); #endif if (sdev->clock)
clk_disable(sdev->clock);
clk_disable_unprepare(sdev->clock);
}
/*
On Sat, Nov 09, 2013 at 01:51:04PM +0100, Laurent Pinchart wrote:
Hi Dave,
Could you please pick this patch up ?
On Monday 28 October 2013 23:49:22 Laurent Pinchart wrote:
Turn clk_enable() and clk_disable() calls into clk_prepare_enable() and clk_disable_unprepare() to get ready for the migration to the common clock framework.
Cc: David Airlie airlied@linux.ie Cc: dri-devel@lists.freedesktop.org Signed-off-by: Laurent Pinchart laurent.pinchart+renesas@ideasonboard.com
drivers/gpu/drm/shmobile/shmob_drm_crtc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_crtc.c b/drivers/gpu/drm/shmobile/shmob_drm_crtc.c index 54bad98..562f9a4 100644 --- a/drivers/gpu/drm/shmobile/shmob_drm_crtc.c +++ b/drivers/gpu/drm/shmobile/shmob_drm_crtc.c @@ -40,7 +40,7 @@ static void shmob_drm_clk_on(struct shmob_drm_device *sdev) { if (sdev->clock)
clk_enable(sdev->clock);
clk_prepare_enable(sdev->clock);
Sorry for jumping in so late, but shouldn't this be split into two separate calls, clk_prepare() in .probe() and clk_enable() here?
Also note that both clk_prepare() and clk_enable() (and therefore clk_prepare_enable() as well) can fail, so you should really check the return values here.
#if 0 if (sdev->meram_dev && sdev->meram_dev->pdev) pm_runtime_get_sync(&sdev->meram_dev->pdev->dev); @@ -54,7 +54,7 @@ static void shmob_drm_clk_off(struct shmob_drm_device *sdev) pm_runtime_put_sync(&sdev->meram_dev->pdev->dev); #endif if (sdev->clock)
clk_disable(sdev->clock);
clk_disable_unprepare(sdev->clock);
Similarily I'd expect this to be clk_disable() only, with the clk_unprepare() in .remove(). Or perhaps there's a very good reason to do both here?
Thierry
Hi Thierry,
On Monday 11 November 2013 09:55:24 Thierry Reding wrote:
On Sat, Nov 09, 2013 at 01:51:04PM +0100, Laurent Pinchart wrote:
Hi Dave,
Could you please pick this patch up ?
On Monday 28 October 2013 23:49:22 Laurent Pinchart wrote:
Turn clk_enable() and clk_disable() calls into clk_prepare_enable() and clk_disable_unprepare() to get ready for the migration to the common clock framework.
Cc: David Airlie airlied@linux.ie Cc: dri-devel@lists.freedesktop.org Signed-off-by: Laurent Pinchart
laurent.pinchart+renesas@ideasonboard.com
drivers/gpu/drm/shmobile/shmob_drm_crtc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_crtc.c b/drivers/gpu/drm/shmobile/shmob_drm_crtc.c index 54bad98..562f9a4 100644 --- a/drivers/gpu/drm/shmobile/shmob_drm_crtc.c +++ b/drivers/gpu/drm/shmobile/shmob_drm_crtc.c @@ -40,7 +40,7 @@ static void shmob_drm_clk_on(struct shmob_drm_device *sdev) { if (sdev->clock)
clk_enable(sdev->clock);
clk_prepare_enable(sdev->clock);
Sorry for jumping in so late, but shouldn't this be split into two separate calls, clk_prepare() in .probe() and clk_enable() here?
The clock prepare and enable operations are split to allow clock implementations to sleep. Clocks should be kept disable whenever possible, the clk_enable() and clk_disable() calls should be as close as possible to the time range during which the clock needs to be enabled. This means that those calls might happen in a context where sleeping isn't allowed. If a clock implementation needs to sleep to enable the clock (by performing an I2C access for instance), that operation should be performed at prepare time.
From a clock user point of view, both clk_prepare() and clk_enable() should be
called as late as possible. If clk_enable() needs to be called in an atomic context clk_prepare() must be called earlier, in a non-atomic context(). Otherwise there'e no point in splitting the two calls.
Also note that both clk_prepare() and clk_enable() (and therefore clk_prepare_enable() as well) can fail, so you should really check the return values here.
Yes, that's a good point. I'd like to fix that in a separate patch in order to avoid delaying this one.
#if 0 if (sdev->meram_dev && sdev->meram_dev->pdev) pm_runtime_get_sync(&sdev->meram_dev->pdev->dev); @@ -54,7 +54,7 @@ static void shmob_drm_clk_off(struct shmob_drm_device *sdev) pm_runtime_put_sync(&sdev->meram_dev->pdev->dev); #endif if (sdev->clock)
clk_disable(sdev->clock);
clk_disable_unprepare(sdev->clock);
Similarily I'd expect this to be clk_disable() only, with the clk_unprepare() in .remove(). Or perhaps there's a very good reason to do both here?
dri-devel@lists.freedesktop.org