Linux Framebuffer Layer development
 help / color / mirror / Atom feed
* Re: [PATCH 05/17] OMAPDSS: Add some new fields to omap_video_timings
From: Tomi Valkeinen @ 2012-06-27 12:42 UTC (permalink / raw)
  To: Archit Taneja; +Cc: Archit Taneja, rob, linux-fbdev, linux-omap
In-Reply-To: <4FEAFC02.2070006@ti.com>

[-- Attachment #1: Type: text/plain, Size: 2899 bytes --]

On Wed, 2012-06-27 at 17:56 +0530, Archit Taneja wrote:
> On Wednesday 27 June 2012 05:18 PM, Tomi Valkeinen wrote:
> > On Tue, 2012-06-26 at 15:06 +0530, Archit Taneja wrote:
> >> Some panel timing related fields are contained in omap_panel_config in the form
> >> of flags. The fields are:
> >>
> >> - Hsync logic level
> >> - Vsync logic level
> >> - Data driven on rising/falling edge of pixel clock
> >> - Output enable/Data enable logic level
> >> - HSYNC/VSYNC driven on rising/falling edge of pixel clock
> >>
> >> Out of these parameters, Hsync and Vsync logic levels are a part of the timings
> >> in the Xorg modeline configuration. So it makes sense to move the to
> >> omap_video_timings. The rest aren't a part of modeline, but it still makes
> >> sense to move these since they are related to panel timings.
> >>
> >> These fields stored in omap_panel_config in dssdev are configured for LCD
> >> panels, and the corresponding LCD managers in the DISPC_POL_FREQo registers.
> >>
> >> Add the above fields in omap_video_timings. Represent their state via new enums.
> >> The parameter pclk_edge is configured via omap_dss_signal_level, however it
> >> actually configures whether data is driven on the rising or falling edge. This
> >> is a bit unclean, but it prevents us from creating another enum.
> >
> > Hmm, why can't omap_dss_signal_edge be used for pclk_edge? I think it'd
> > fit fine, except OMAPDSS_DRIVE_SIG_OPPOSITE_EDGES would be an illegal
> > value for it.
> 
> I think my paragraph is a bit misleading. The issue is more about the 
> default value. For hsync_vsync_edge(which programs ONOFF and RF), the 
> default value is OMAPDSS_DRIVE_SIG_OPPOSITE_EDGES, and is the case for 
> most panels. But for pclk_edge, the value for most panels is 
> OMAPDSS_DRIVE_SIG_ACTIVE_HIGH.
> 
> So if I use the same enum for both, I'll need to populate either 
> pclk_edge or hsync_vsync_edge for almost every panel. With my approach, 
> I only need to populate these fields for panels having the non-default 
> requirements. The negative thing is that it's a bit misleading to 
> represent pclk_edge with the omap_dss_signal_level enum.

Ah, I see.

I really think using the ACTIVE_LOW/HIGH for pclk_edge is quite ugly =).

Well, one option is to add new entry for the enums, "UNDEFINED" or
perhaps "DEFAULT", which would have value 0. Then omapdss would know
that it should use the default value, whatever that is.

Another option is to have all panels define the pclk_edge, so that
there's no default value needed.

Also, related thing, I see you're writing enum values directly to the
registers. If you do that, it'd be good to explicitly set the number
value of the enums. Otherwise it's quite easy to add a new enum value
later between the old ones, breaking everything (perhaps not a problem
here, though).

 Tomi


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply

* Re: [PATCH 05/17] OMAPDSS: Add some new fields to omap_video_timings
From: Archit Taneja @ 2012-06-27 12:38 UTC (permalink / raw)
  To: Tomi Valkeinen; +Cc: Archit Taneja, rob, linux-fbdev, linux-omap
In-Reply-To: <1340797733.2649.48.camel@deskari>

On Wednesday 27 June 2012 05:18 PM, Tomi Valkeinen wrote:
> On Tue, 2012-06-26 at 15:06 +0530, Archit Taneja wrote:
>> Some panel timing related fields are contained in omap_panel_config in the form
>> of flags. The fields are:
>>
>> - Hsync logic level
>> - Vsync logic level
>> - Data driven on rising/falling edge of pixel clock
>> - Output enable/Data enable logic level
>> - HSYNC/VSYNC driven on rising/falling edge of pixel clock
>>
>> Out of these parameters, Hsync and Vsync logic levels are a part of the timings
>> in the Xorg modeline configuration. So it makes sense to move the to
>> omap_video_timings. The rest aren't a part of modeline, but it still makes
>> sense to move these since they are related to panel timings.
>>
>> These fields stored in omap_panel_config in dssdev are configured for LCD
>> panels, and the corresponding LCD managers in the DISPC_POL_FREQo registers.
>>
>> Add the above fields in omap_video_timings. Represent their state via new enums.
>> The parameter pclk_edge is configured via omap_dss_signal_level, however it
>> actually configures whether data is driven on the rising or falling edge. This
>> is a bit unclean, but it prevents us from creating another enum.
>
> Hmm, why can't omap_dss_signal_edge be used for pclk_edge? I think it'd
> fit fine, except OMAPDSS_DRIVE_SIG_OPPOSITE_EDGES would be an illegal
> value for it.

I think my paragraph is a bit misleading. The issue is more about the 
default value. For hsync_vsync_edge(which programs ONOFF and RF), the 
default value is OMAPDSS_DRIVE_SIG_OPPOSITE_EDGES, and is the case for 
most panels. But for pclk_edge, the value for most panels is 
OMAPDSS_DRIVE_SIG_ACTIVE_HIGH.

So if I use the same enum for both, I'll need to populate either 
pclk_edge or hsync_vsync_edge for almost every panel. With my approach, 
I only need to populate these fields for panels having the non-default 
requirements. The negative thing is that it's a bit misleading to 
represent pclk_edge with the omap_dss_signal_level enum.

Archit


^ permalink raw reply

* Re: [PATCH 17/17] OMAPDSS: DSI: Remove redundant fields in omap_dss_dsi_videomode_data
From: Tomi Valkeinen @ 2012-06-27 12:31 UTC (permalink / raw)
  To: Archit Taneja; +Cc: rob, linux-fbdev, linux-omap
In-Reply-To: <4FEAFA18.3070908@ti.com>

[-- Attachment #1: Type: text/plain, Size: 1862 bytes --]

On Wed, 2012-06-27 at 17:48 +0530, Archit Taneja wrote:
> On Wednesday 27 June 2012 05:35 PM, Tomi Valkeinen wrote:

> > The sync polarities between DISPC and DSI do not matter elsewhere, they
> > do not affect the DSI output, so why do we have them in the panel data?
> > Why doesn't dsi.c just use some hardcoded values for these.
> 
> Ok, are you saying that unlike DPI, where a panel may request for some 
> different polarities. There is no such need for DSI panels, and we can 
> set the polarities of DISPC and DSI always to active high(or any other 
> combination)?

Yes. There are no sync polarities in DSI bus, there are only sync
packets. So afaik, the polarities used here matter only for DISPC and
DSI communication. And there the only thing that matters is that both
DISPC and DSI have the same configuration for the polarities, so that
the communication works.

> Well, we are doing that indirectly in a way, a DSI panel driver would 
> populate a omap_video_timings struct, and would leave hsync_level, 
> vsync_level and de_level empty(i.e, the default values). This would be 
> passed to the DSI driver, and the timings would be applied to DISPC. The 
> function above would just pick up the same default values and program to 
> the DSI registers.
> 
> What we could do is ignore these fields in the omap_video_timings when 
> passed from the panel driver to DSI driver, and always use a fixed value 
> for them, and this way we can use the same fixed values for DSI too. Do 
> you think that is better?

I think that is clearer. Optimally we wouldn't even have a video timings
struct for DSI panels, the kind that contains sync polarities and such,
but a separate timings struct that contains stuff relevant for DSI. But
for now I think we should just ignore the "extra" values in video
timings.

 Tomi


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply

* Re: [PATCH 17/17] OMAPDSS: DSI: Remove redundant fields in omap_dss_dsi_videomode_data
From: Archit Taneja @ 2012-06-27 12:30 UTC (permalink / raw)
  To: Tomi Valkeinen; +Cc: rob, linux-fbdev, linux-omap
In-Reply-To: <1340798746.2649.51.camel@deskari>

On Wednesday 27 June 2012 05:35 PM, Tomi Valkeinen wrote:
> On Tue, 2012-06-26 at 15:06 +0530, Archit Taneja wrote:
>> The struct omap_dss_dsi_videomode_data holds polaritiy/logic level information
>> of the DISPC video port signals DE, HSYNC and VSYNC. This information already
>> exists in the omap_video_timings struct.
>>
>> Use the fields in omap_video_timings to program VP_DE_POL, VP_HSYNC_POL and
>> VP_VSYNC_POL in DSI_CTRL. Remove the redundant fields in
>> omap_dss_dsi_videomode_data.
>>
>> Signed-off-by: Archit Taneja<archit@ti.com>
>> ---
>>   drivers/video/omap2/dss/dsi.c |   11 ++++++++---
>>   include/video/omapdss.h       |    3 ---
>>   2 files changed, 8 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/video/omap2/dss/dsi.c b/drivers/video/omap2/dss/dsi.c
>> index 061bf53..3844430 100644
>> --- a/drivers/video/omap2/dss/dsi.c
>> +++ b/drivers/video/omap2/dss/dsi.c
>> @@ -3628,13 +3628,18 @@ static void dsi_config_vp_num_line_buffers(struct omap_dss_device *dssdev)
>>   static void dsi_config_vp_sync_events(struct omap_dss_device *dssdev)
>>   {
>>   	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
>> -	int de_pol = dssdev->panel.dsi_vm_data.vp_de_pol;
>> -	int hsync_pol = dssdev->panel.dsi_vm_data.vp_hsync_pol;
>> -	int vsync_pol = dssdev->panel.dsi_vm_data.vp_vsync_pol;
>> +	int de_pol, hsync_pol, vsync_pol;
>> +	int de_level = dssdev->panel.timings.de_level;
>> +	int hsync_level = dssdev->panel.timings.hsync_level;
>> +	int vsync_level = dssdev->panel.timings.vsync_level;
>>   	bool vsync_end = dssdev->panel.dsi_vm_data.vp_vsync_end;
>>   	bool hsync_end = dssdev->panel.dsi_vm_data.vp_hsync_end;
>>   	u32 r;
>>
>> +	de_pol = de_level = OMAPDSS_SIG_ACTIVE_HIGH ? 1 : 0;
>> +	hsync_pol = hsync_level = OMAPDSS_SIG_ACTIVE_HIGH ? 1 : 0;
>> +	vsync_pol = vsync_level = OMAPDSS_SIG_ACTIVE_HIGH ? 1 : 0;
>> +
>>   	r = dsi_read_reg(dsidev, DSI_CTRL);
>>   	r = FLD_MOD(r, de_pol, 9, 9);		/* VP_DE_POL */
>>   	r = FLD_MOD(r, hsync_pol, 10, 10);	/* VP_HSYNC_POL */
>
> This patch makes the code cleaner, but I find this DSI sync code a bit
> strange.
>
> The sync polarities between DISPC and DSI do not matter elsewhere, they
> do not affect the DSI output, so why do we have them in the panel data?
> Why doesn't dsi.c just use some hardcoded values for these.

Ok, are you saying that unlike DPI, where a panel may request for some 
different polarities. There is no such need for DSI panels, and we can 
set the polarities of DISPC and DSI always to active high(or any other 
combination)?

Well, we are doing that indirectly in a way, a DSI panel driver would 
populate a omap_video_timings struct, and would leave hsync_level, 
vsync_level and de_level empty(i.e, the default values). This would be 
passed to the DSI driver, and the timings would be applied to DISPC. The 
function above would just pick up the same default values and program to 
the DSI registers.

What we could do is ignore these fields in the omap_video_timings when 
passed from the panel driver to DSI driver, and always use a fixed value 
for them, and this way we can use the same fixed values for DSI too. Do 
you think that is better?

Archit

^ permalink raw reply

* Re: [PATCH 17/17] OMAPDSS: DSI: Remove redundant fields in omap_dss_dsi_videomode_data
From: Tomi Valkeinen @ 2012-06-27 12:05 UTC (permalink / raw)
  To: Archit Taneja; +Cc: rob, linux-fbdev, linux-omap
In-Reply-To: <1340703414-1915-19-git-send-email-archit@ti.com>

[-- Attachment #1: Type: text/plain, Size: 2273 bytes --]

On Tue, 2012-06-26 at 15:06 +0530, Archit Taneja wrote:
> The struct omap_dss_dsi_videomode_data holds polaritiy/logic level information
> of the DISPC video port signals DE, HSYNC and VSYNC. This information already
> exists in the omap_video_timings struct.
> 
> Use the fields in omap_video_timings to program VP_DE_POL, VP_HSYNC_POL and
> VP_VSYNC_POL in DSI_CTRL. Remove the redundant fields in
> omap_dss_dsi_videomode_data.
> 
> Signed-off-by: Archit Taneja <archit@ti.com>
> ---
>  drivers/video/omap2/dss/dsi.c |   11 ++++++++---
>  include/video/omapdss.h       |    3 ---
>  2 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/video/omap2/dss/dsi.c b/drivers/video/omap2/dss/dsi.c
> index 061bf53..3844430 100644
> --- a/drivers/video/omap2/dss/dsi.c
> +++ b/drivers/video/omap2/dss/dsi.c
> @@ -3628,13 +3628,18 @@ static void dsi_config_vp_num_line_buffers(struct omap_dss_device *dssdev)
>  static void dsi_config_vp_sync_events(struct omap_dss_device *dssdev)
>  {
>  	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> -	int de_pol = dssdev->panel.dsi_vm_data.vp_de_pol;
> -	int hsync_pol = dssdev->panel.dsi_vm_data.vp_hsync_pol;
> -	int vsync_pol = dssdev->panel.dsi_vm_data.vp_vsync_pol;
> +	int de_pol, hsync_pol, vsync_pol;
> +	int de_level = dssdev->panel.timings.de_level;
> +	int hsync_level = dssdev->panel.timings.hsync_level;
> +	int vsync_level = dssdev->panel.timings.vsync_level;
>  	bool vsync_end = dssdev->panel.dsi_vm_data.vp_vsync_end;
>  	bool hsync_end = dssdev->panel.dsi_vm_data.vp_hsync_end;
>  	u32 r;
>  
> +	de_pol = de_level == OMAPDSS_SIG_ACTIVE_HIGH ? 1 : 0;
> +	hsync_pol = hsync_level == OMAPDSS_SIG_ACTIVE_HIGH ? 1 : 0;
> +	vsync_pol = vsync_level == OMAPDSS_SIG_ACTIVE_HIGH ? 1 : 0;
> +
>  	r = dsi_read_reg(dsidev, DSI_CTRL);
>  	r = FLD_MOD(r, de_pol, 9, 9);		/* VP_DE_POL */
>  	r = FLD_MOD(r, hsync_pol, 10, 10);	/* VP_HSYNC_POL */

This patch makes the code cleaner, but I find this DSI sync code a bit
strange.

The sync polarities between DISPC and DSI do not matter elsewhere, they
do not affect the DSI output, so why do we have them in the panel data?
Why doesn't dsi.c just use some hardcoded values for these.

 Tomi


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply

* Re: [PATCH 05/17] OMAPDSS: Add some new fields to omap_video_timings
From: Tomi Valkeinen @ 2012-06-27 11:48 UTC (permalink / raw)
  To: Archit Taneja; +Cc: rob, linux-fbdev, linux-omap
In-Reply-To: <1340703414-1915-7-git-send-email-archit@ti.com>

[-- Attachment #1: Type: text/plain, Size: 1330 bytes --]

On Tue, 2012-06-26 at 15:06 +0530, Archit Taneja wrote:
> Some panel timing related fields are contained in omap_panel_config in the form
> of flags. The fields are:
> 
> - Hsync logic level
> - Vsync logic level
> - Data driven on rising/falling edge of pixel clock
> - Output enable/Data enable logic level
> - HSYNC/VSYNC driven on rising/falling edge of pixel clock
> 
> Out of these parameters, Hsync and Vsync logic levels are a part of the timings
> in the Xorg modeline configuration. So it makes sense to move the to
> omap_video_timings. The rest aren't a part of modeline, but it still makes
> sense to move these since they are related to panel timings.
> 
> These fields stored in omap_panel_config in dssdev are configured for LCD
> panels, and the corresponding LCD managers in the DISPC_POL_FREQo registers.
> 
> Add the above fields in omap_video_timings. Represent their state via new enums.
> The parameter pclk_edge is configured via omap_dss_signal_level, however it
> actually configures whether data is driven on the rising or falling edge. This
> is a bit unclean, but it prevents us from creating another enum.

Hmm, why can't omap_dss_signal_edge be used for pclk_edge? I think it'd
fit fine, except OMAPDSS_DRIVE_SIG_OPPOSITE_EDGES would be an illegal
value for it.

 Tomi


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply

* Re: [PATCH v2] OMAPDSS: add clk_prepare and clk_unprepare
From: Tomi Valkeinen @ 2012-06-27 10:42 UTC (permalink / raw)
  To: Rajendra Nayak; +Cc: linux-omap, linux-fbdev, Paul Walmsley, Mike Turquette
In-Reply-To: <1340787086-29619-1-git-send-email-rnayak@ti.com>

[-- Attachment #1: Type: text/plain, Size: 380 bytes --]

On Wed, 2012-06-27 at 14:21 +0530, Rajendra Nayak wrote:
> In preparation of OMAP moving to Common Clk Framework(CCF) add clk_prepare()
> and clk_unprepare() for the omapdss clocks.

Looks fine, and works fine with a quick test.

I'll update the subject and desc to match the use of clk_prepare_enable
and clk_disable_unprepare, and apply this to omapdss tree.

 Tomi


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply

* [PATCH v2] OMAPDSS: add clk_prepare and clk_unprepare
From: Rajendra Nayak @ 2012-06-27  8:55 UTC (permalink / raw)
  To: linux-omap
  Cc: Rajendra Nayak, Tomi Valkeinen, linux-fbdev, Paul Walmsley,
	Mike Turquette

In preparation of OMAP moving to Common Clk Framework(CCF) add clk_prepare()
and clk_unprepare() for the omapdss clocks.

Signed-off-by: Rajendra Nayak <rnayak@ti.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: <linux-fbdev@vger.kernel.org>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Mike Turquette <mturquette@linaro.org>
---
 drivers/video/omap2/dss/dsi.c  |    4 ++--
 drivers/video/omap2/dss/hdmi.c |    4 ++--
 drivers/video/omap2/dss/venc.c |    4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/video/omap2/dss/dsi.c b/drivers/video/omap2/dss/dsi.c
index ca8382d..423ef6a 100644
--- a/drivers/video/omap2/dss/dsi.c
+++ b/drivers/video/omap2/dss/dsi.c
@@ -1085,9 +1085,9 @@ static inline void dsi_enable_pll_clock(struct platform_device *dsidev,
 	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 
 	if (enable)
-		clk_enable(dsi->sys_clk);
+		clk_prepare_enable(dsi->sys_clk);
 	else
-		clk_disable(dsi->sys_clk);
+		clk_disable_unprepare(dsi->sys_clk);
 
 	if (enable && dsi->pll_locked) {
 		if (wait_for_bit_change(dsidev, DSI_PLL_STATUS, 1, 1) != 1)
diff --git a/drivers/video/omap2/dss/hdmi.c b/drivers/video/omap2/dss/hdmi.c
index 8195c71..b9424b3 100644
--- a/drivers/video/omap2/dss/hdmi.c
+++ b/drivers/video/omap2/dss/hdmi.c
@@ -785,7 +785,7 @@ static int __exit omapdss_hdmihw_remove(struct platform_device *pdev)
 
 static int hdmi_runtime_suspend(struct device *dev)
 {
-	clk_disable(hdmi.sys_clk);
+	clk_disable_unprepare(hdmi.sys_clk);
 
 	dispc_runtime_put();
 
@@ -800,7 +800,7 @@ static int hdmi_runtime_resume(struct device *dev)
 	if (r < 0)
 		return r;
 
-	clk_enable(hdmi.sys_clk);
+	clk_prepare_enable(hdmi.sys_clk);
 
 	return 0;
 }
diff --git a/drivers/video/omap2/dss/venc.c b/drivers/video/omap2/dss/venc.c
index 2b89739..fd37440 100644
--- a/drivers/video/omap2/dss/venc.c
+++ b/drivers/video/omap2/dss/venc.c
@@ -930,7 +930,7 @@ static int __exit omap_venchw_remove(struct platform_device *pdev)
 static int venc_runtime_suspend(struct device *dev)
 {
 	if (venc.tv_dac_clk)
-		clk_disable(venc.tv_dac_clk);
+		clk_disable_unprepare(venc.tv_dac_clk);
 
 	dispc_runtime_put();
 
@@ -946,7 +946,7 @@ static int venc_runtime_resume(struct device *dev)
 		return r;
 
 	if (venc.tv_dac_clk)
-		clk_enable(venc.tv_dac_clk);
+		clk_prepare_enable(venc.tv_dac_clk);
 
 	return 0;
 }
-- 
1.7.1


^ permalink raw reply related

* Re: [PATCH] OMAPDSS: Check if RPM enabled before trying to change state
From: Tomi Valkeinen @ 2012-06-27  8:13 UTC (permalink / raw)
  To: Jassi Brar; +Cc: mythripk, linux-omap, linux-fbdev, andy.green, n-dechesne
In-Reply-To: <CAJe_Zhdz5mAZbyer8fL4YfvcQ8xMF31cPG2zr3AbBNWv8nctnw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3862 bytes --]

On Wed, 2012-06-27 at 13:11 +0530, Jassi Brar wrote:
> On 27 June 2012 11:28, Tomi Valkeinen <tomi.valkeinen@ti.com> wrote:
> >
> > It doesn't matter how omapdss is organized, -EACCES _is_ an error. It
> > tells us that something unexpected happened, and we should react to it
> > somehow.
> >
>   $ git show 5025ce070
> Exactly how omapdss is organised is the reason -EBUSY isn't an error there :)
> Otherwise, omapdss should panic that somehow 'imbalance' has been
> introduced in rpm.

There's no imbalance there, as each get() is still matched by a put(),
and the use count is correct. Your patch may cause either get or put to
be skipped.

In 5025ce070 the function in question is dss_runtime_put(), and -EBUSY
_is_ an error there. Normally if you call pm_runtime_put_sync() and the
use count drops to zero, the device should be suspended. In this case,
however, it won't be suspended as a child device is still enabled. Thus,
the framework informs about this with -EBUSY.

It's ok to ignore -EBUSY, because we're not really interested about if
the device is actually suspended or not.

However, dispc_runtime_get() is a different matter, because there we
_are_ interested about the state of the HW. If we skip
dispc_runtime_get() because runtime PM is disabled, we don't know
whether the HW is enabled or not.

And even if your patch was modified to check the HW status after
pm_runtime_enabled(), and return 0 is HW is enabled and an error if HW
is disabled, it'd be wrong, because you skip the pm_runtime_get() call.
This means that the use count is not increased, and there's no guarantee
that the HW would be functional after dispc_runtime_get() returns.

> > Sure, in the current omapdss neither is a breaking problem, because 1)
> > the matching dispc_runtime_put() is called also with runtime PM
> > disabled, and thus we don't decrease the use count, and 2) the HW
> > happens to be already enabled. But that's just by "luck", and tomorrow
> > omapdss could be different.
> >
> It's no 'luck', but it's because today omapdss takes proper care of PM
> enable/disable and get/put.
> Rather, if tomorrow that stops working, it would hint that we managed
> to screw up the balance.
> Because if omapdss suspended and disabled PM on DISPC, and still HDMI
> attempted to access dss regs, that clearly means HDMI hasn't been duly
> made aware of the DISPC status.

There are two different things here. First one is how
dispc_runtime_get/put & co. should work. The second is how they are
used.

As I see, you are arguing that it's ok to have dispc_runtime_get/put
broken, as long as they are used in a way that causes no problems.

> Just as preemption and suspend/resume don't introduce any race in
> locking, RPM won't introduce new imbalance in get/put of omapdss.
> 
> I am afraid, we won't reach any eureka moment on this, so I would
> leave us to our conditions. This patch and discussion made me look
> deep into rpm, I thank you for that and for your patience.

Yes, same here. I think this discussion and related code digging has
really improved my understanding of runtime PM =). Perhaps I'll get it
correct this time with this new information.

There's still the system suspend, which I think is quite broken. The
patch I gave fixes it for the time being, but I see it as a temporary
solution.

I don't like it at all that omapdss disables and enables the panels in
omapdss's suspend/resume hooks. But I'm not sure how this should work...
Should panel drivers each have their own suspend/resume hooks, and
handle it themselves? Or should the call to suspend/resume come from
upper layers, like omapfb or omapdrm.

I made a prototype patch a few weeks ago to move the suspend to omapfb,
and it feels better than the current one, but I'm still not sure...

 Tomi


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply

* Re: [PATCH] OMAPDSS: Check if RPM enabled before trying to change state
From: Jassi Brar @ 2012-06-27  7:53 UTC (permalink / raw)
  To: Tomi Valkeinen; +Cc: mythripk, linux-omap, linux-fbdev, andy.green, n-dechesne
In-Reply-To: <1340776683.1972.41.camel@lappyti>

On 27 June 2012 11:28, Tomi Valkeinen <tomi.valkeinen@ti.com> wrote:
>
> It doesn't matter how omapdss is organized, -EACCES _is_ an error. It
> tells us that something unexpected happened, and we should react to it
> somehow.
>
  $ git show 5025ce070
Exactly how omapdss is organised is the reason -EBUSY isn't an error there :)
Otherwise, omapdss should panic that somehow 'imbalance' has been
introduced in rpm.


>
> Sure, in the current omapdss neither is a breaking problem, because 1)
> the matching dispc_runtime_put() is called also with runtime PM
> disabled, and thus we don't decrease the use count, and 2) the HW
> happens to be already enabled. But that's just by "luck", and tomorrow
> omapdss could be different.
>
It's no 'luck', but it's because today omapdss takes proper care of PM
enable/disable and get/put.
Rather, if tomorrow that stops working, it would hint that we managed
to screw up the balance.
Because if omapdss suspended and disabled PM on DISPC, and still HDMI
attempted to access dss regs, that clearly means HDMI hasn't been duly
made aware of the DISPC status.

Just as preemption and suspend/resume don't introduce any race in
locking, RPM won't introduce new imbalance in get/put of omapdss.

I am afraid, we won't reach any eureka moment on this, so I would
leave us to our conditions. This patch and discussion made me look
deep into rpm, I thank you for that and for your patience.

Cheers!

^ permalink raw reply

* Re: [PATCH] OMAPDSS: Check if RPM enabled before trying to change state
From: Tomi Valkeinen @ 2012-06-27  5:58 UTC (permalink / raw)
  To: Jassi Brar; +Cc: mythripk, linux-omap, linux-fbdev, andy.green, n-dechesne
In-Reply-To: <CAJe_ZheovnRsJ6opMPkMxwjLSv-OKBPCHu5rsAX_KNz1mb64ZQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2212 bytes --]

On Wed, 2012-06-27 at 10:12 +0530, Jassi Brar wrote:

> > True. But the HW could also be in disabled state. And that would lead to
> > a crash when accessing the registers.
> >
> > It is not a fatal error if pm_runtime_get returns -EACCES, but we sure
> > shouldn't ignore it (or avoid it with pm_runtime_enabled()), but handle
> > it. In some rare cases it could be ok to get -EACCES, but that's a
> > special case, not standard.
> >
> You are mixing up generic concepts with what we have in omapdss.
> Believe me, I do understand it's bad to proceed without caring for
> returned _errors_.
> The way omapdss is organized -EACCESS is _not_ an  error, it just
> denotes PM is disabled on the device and that DISPC is in RPM_ACTIVE
> is backed by the fact that HDMI always hold a reference between
> resume-suspend and DISPC goes to suspend last and resume first.

I'm not arguing that your solution would not work with the omapdss code
we have now, and presuming the underlying frameworks work fine. But I
want omapdss to have code that works also in the future, when other
parts of omapdss change.

It doesn't matter how omapdss is organized, -EACCES _is_ an error. It
tells us that something unexpected happened, and we should react to it
somehow.

When we call, for example, dispc_runtime_get(), we normally expect that
runtime PM is enabled, and it 1) "gets" it, increasing the use count,
and 2) makes sure the HW is enabled so it can be used. Your patch breaks
both of these if runtime PM is disabled.

Sure, in the current omapdss neither is a breaking problem, because 1)
the matching dispc_runtime_put() is called also with runtime PM
disabled, and thus we don't decrease the use count, and 2) the HW
happens to be already enabled. But that's just by "luck", and tomorrow
omapdss could be different. 

If, for some reason, we need to call dispc_runtime_get/put during
suspend, the caller should either 1) realize that we're suspending,
runtime PM is disabled, but the HW is anyway enabled, and thus skip
calling both get and put, or 2) call both get and put, but handle the
-EACCES, understanding what it means and knowing the HW is anyway
enabled.

 Tomi


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply

* Re: [PATCH 05/11] OMAPDSS: add clk_prepare and clk_unprepare
From: Rajendra Nayak @ 2012-06-27  5:31 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1340770798.1972.4.camel@lappyti>

On Wednesday 27 June 2012 09:49 AM, Tomi Valkeinen wrote:
> On Tue, 2012-06-26 at 17:47 -0700, Mike Turquette wrote:
>> On 20120625-16:14, Tomi Valkeinen wrote:
>>> A question about clk_prepare/unprepare, not directly related: let's say
>>> I have a driver for some HW block. The driver doesn't use clk functions,
>>> but uses runtime PM. The driver also sets pm_runtime_irq_safe().
>>>
>>> Now, the driver can call pm_runtime_get_sync() in an atomic context, and
>>> this would lead to the underlying framework (hwmod, omap_device, I don't
>>> know who =) enabling the func clock for that HW. But this would happen
>>> in atomic context, so the underlying framework can't use clk_prepare.
>>>
>>> How does the underlying framework handle that case? (sorry if that's a
>>> stupid question =).
>>>
>>
>> I think it's a good question!
>>
>> If we're going to call clk_prepare_enable from within a runtime pm
>> callback then I think we'll need to check if _irq_safe() is set and
>> conditionally call only clk_enable in such a case.
>>
>> I'm not a runtime pm expert, but if the driver owns the responsibility
>> of calling pm_runtime_irq_safe then the driver has the proper context
>> to know that it should call clk_prepare BEFORE calling
>> pm_runtime_get_sync.
>
> That's not quite what I meant. If it's the driver that does clk_enable,
> be it in runtime PM callback or not, it's driver's responsibility.
>
> But some clocks are not handled by the driver, but the hwmod/omap_device
> framework. Mainly I think this is for the functional and interface
> clocks. The driver has no visibility to those, they are implicitly
> enabled via pm_runtime_get.

yes, thats the tricky part on how would hwmod/omap_device know if the
driver would use runtime pm within atomic context or non-atomic context.
The driver does inform the runtime pm framework about this by calling a
pm_runtime_irq_safe(), which is then used to set the .irq_safe flag 
telling it to leave the interrupts disabled during callbacks.
This information however does not flow down to hwmod/omap_device in any
way. So the way its currently handled is to do an early prepare of all
hwmod controlled clocks.

I have copied Kevin in case he has any better ideas on how this should
be handled.

>
>   Tomi
>


^ permalink raw reply

* Re: [PATCH] OMAPDSS: Check if RPM enabled before trying to change state
From: Jassi Brar @ 2012-06-27  4:54 UTC (permalink / raw)
  To: Tomi Valkeinen; +Cc: mythripk, linux-omap, linux-fbdev, andy.green, n-dechesne
In-Reply-To: <1340736243.24530.98.camel@deskari>

On 27 June 2012 00:14, Tomi Valkeinen <tomi.valkeinen@ti.com> wrote:
> On Tue, 2012-06-26 at 22:31 +0530, Jassi Brar wrote:
>>
>> > But if pm_runtime_get_sync() returns an error, it means the HW has not
>> > been resumed successfully, and is not operational,
>> >
>> Not always. The HW could be in RPM_ACTIVE state while PM on it could
>> be disabled, if the returned error is -EACCESS.   And
>> pm_runtime_enabled() only catches a potential -EACCESS.
>
> True. But the HW could also be in disabled state. And that would lead to
> a crash when accessing the registers.
>
> It is not a fatal error if pm_runtime_get returns -EACCES, but we sure
> shouldn't ignore it (or avoid it with pm_runtime_enabled()), but handle
> it. In some rare cases it could be ok to get -EACCES, but that's a
> special case, not standard.
>
You are mixing up generic concepts with what we have in omapdss.
Believe me, I do understand it's bad to proceed without caring for
returned _errors_.
The way omapdss is organized -EACCESS is _not_ an  error, it just
denotes PM is disabled on the device and that DISPC is in RPM_ACTIVE
is backed by the fact that HDMI always hold a reference between
resume-suspend and DISPC goes to suspend last and resume first.


>> BTW, I just tested your patch and it worked for me as well. But as
>> suspected, it doesn't help the stack spew of CONFIG_PM_RUNTIME:=n
>>
>> So I understand, I only need to resend the other three patches ?
>
> Yes, please.
>
OK, will do today later.

Regards.

^ permalink raw reply

* Re: [PATCH 05/11] OMAPDSS: add clk_prepare and clk_unprepare
From: Tomi Valkeinen @ 2012-06-27  4:19 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20120627004709.GA22766@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1617 bytes --]

On Tue, 2012-06-26 at 17:47 -0700, Mike Turquette wrote:
> On 20120625-16:14, Tomi Valkeinen wrote:
> > A question about clk_prepare/unprepare, not directly related: let's say
> > I have a driver for some HW block. The driver doesn't use clk functions,
> > but uses runtime PM. The driver also sets pm_runtime_irq_safe().
> > 
> > Now, the driver can call pm_runtime_get_sync() in an atomic context, and
> > this would lead to the underlying framework (hwmod, omap_device, I don't
> > know who =) enabling the func clock for that HW. But this would happen
> > in atomic context, so the underlying framework can't use clk_prepare.
> > 
> > How does the underlying framework handle that case? (sorry if that's a
> > stupid question =).
> > 
> 
> I think it's a good question!
> 
> If we're going to call clk_prepare_enable from within a runtime pm
> callback then I think we'll need to check if _irq_safe() is set and
> conditionally call only clk_enable in such a case.
> 
> I'm not a runtime pm expert, but if the driver owns the responsibility
> of calling pm_runtime_irq_safe then the driver has the proper context
> to know that it should call clk_prepare BEFORE calling
> pm_runtime_get_sync.

That's not quite what I meant. If it's the driver that does clk_enable,
be it in runtime PM callback or not, it's driver's responsibility.

But some clocks are not handled by the driver, but the hwmod/omap_device
framework. Mainly I think this is for the functional and interface
clocks. The driver has no visibility to those, they are implicitly
enabled via pm_runtime_get.

 Tomi


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply

* Re: [PATCH 05/11] OMAPDSS: add clk_prepare and clk_unprepare
From: Mike Turquette @ 2012-06-27  0:47 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1340630090.3395.85.camel@deskari>

On 20120625-16:14, Tomi Valkeinen wrote:
> A question about clk_prepare/unprepare, not directly related: let's say
> I have a driver for some HW block. The driver doesn't use clk functions,
> but uses runtime PM. The driver also sets pm_runtime_irq_safe().
> 
> Now, the driver can call pm_runtime_get_sync() in an atomic context, and
> this would lead to the underlying framework (hwmod, omap_device, I don't
> know who =) enabling the func clock for that HW. But this would happen
> in atomic context, so the underlying framework can't use clk_prepare.
> 
> How does the underlying framework handle that case? (sorry if that's a
> stupid question =).
> 

I think it's a good question!

If we're going to call clk_prepare_enable from within a runtime pm
callback then I think we'll need to check if _irq_safe() is set and
conditionally call only clk_enable in such a case.

I'm not a runtime pm expert, but if the driver owns the responsibility
of calling pm_runtime_irq_safe then the driver has the proper context
to know that it should call clk_prepare BEFORE calling
pm_runtime_get_sync.

However if some other framework (outside of the driver) calls
pm_runtime_irq_safe then it will be difficult for the driver to know
what to do...

Regards,
Mike

>  Tomi
> 



^ permalink raw reply

* Re: [PATCH] OMAPDSS: Check if RPM enabled before trying to change state
From: Tomi Valkeinen @ 2012-06-26 18:44 UTC (permalink / raw)
  To: Jassi Brar; +Cc: mythripk, linux-omap, linux-fbdev, andy.green, n-dechesne
In-Reply-To: <CAJe_ZheXSquxOtOD9iPyQjZ-jxWKzVGZHYkjM=wC37qgMZeJug@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1554 bytes --]

On Tue, 2012-06-26 at 22:31 +0530, Jassi Brar wrote:

> While I think your patch is simpler and achieve the same, I also think
> your fears about this patch are unfounded.

Perhaps. But I do get a bad feeling from your patch, and I don't like
when that happens =). What I fear with changes like you made is that
they'll hide problems that should be fixed in other ways.

And I think that was the case here also. I think we should not call
dispc_runtime_get() during suspend. If pm_runtime_get returns -EACCES,
we do have a possible problem, and we should not silently ignore it.

> A quick snack for thought...
> >
> > But if pm_runtime_get_sync() returns an error, it means the HW has not
> > been resumed successfully, and is not operational,
> >
> Not always. The HW could be in RPM_ACTIVE state while PM on it could
> be disabled, if the returned error is -EACCESS.   And
> pm_runtime_enabled() only catches a potential -EACCESS.

True. But the HW could also be in disabled state. And that would lead to
a crash when accessing the registers.

It is not a fatal error if pm_runtime_get returns -EACCES, but we sure
shouldn't ignore it (or avoid it with pm_runtime_enabled()), but handle
it. In some rare cases it could be ok to get -EACCES, but that's a
special case, not standard.

> BTW, I just tested your patch and it worked for me as well. But as
> suspected, it doesn't help the stack spew of CONFIG_PM_RUNTIME:=n
> 
> So I understand, I only need to resend the other three patches ?

Yes, please.

 Tomi


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply

* Re: [PATCH] OMAPDSS: Check if RPM enabled before trying to change state
From: Jassi Brar @ 2012-06-26 17:13 UTC (permalink / raw)
  To: Tomi Valkeinen; +Cc: mythripk, linux-omap, linux-fbdev, andy.green, n-dechesne
In-Reply-To: <1340723514.24530.70.camel@deskari>

On 26 June 2012 20:41, Tomi Valkeinen <tomi.valkeinen@ti.com> wrote:
> On Tue, 2012-06-26 at 20:39 +0530, Jassi Brar wrote:
>> On 26 June 2012 20:38, Tomi Valkeinen <tomi.valkeinen@ti.com> wrote:
>> > On Tue, 2012-06-26 at 20:19 +0530, Jassi Brar wrote:
>> >> On 26 June 2012 17:33, Tomi Valkeinen <tomi.valkeinen@ti.com> wrote:
>> >> > On Tue, 2012-06-26 at 15:27 +0530, Jassi Brar wrote:
>> >> >
>> >> >> Seems similar, but I only tested OMAP4 HDMI.
>> >> >
>> >> > Would something like this one below work for you? It fixes the issues on
>> >> > my overo board.
>> >> >
>> >> I think this should work too (I will get to test it only tomorrow).
>> >>
>> >> Though I don't think it'll fix stack spew when run without
>> >> CONFIG_PM_RUNTIME. Maybe we could simply remove the WARN_ON in the
>> >> xxx_runtime_put() as Alan noted?
>> >
>> > Yes, that's a different issue. I'll look at that also.
>> >
>> Well, my patch took care of that also. But I agree, that could be
>> added separately as well.
>
> Well, I don't agree that your patch is correct =). I don't think it's
> right to skip runtime get and put when pm_runtime_enabled() returns
> false.
>
While I think your patch is simpler and achieve the same, I also think
your fears about this patch are unfounded.

A quick snack for thought...
>
> But if pm_runtime_get_sync() returns an error, it means the HW has not
> been resumed successfully, and is not operational,
>
Not always. The HW could be in RPM_ACTIVE state while PM on it could
be disabled, if the returned error is -EACCESS.   And
pm_runtime_enabled() only catches a potential -EACCESS.


BTW, I just tested your patch and it worked for me as well. But as
suspected, it doesn't help the stack spew of CONFIG_PM_RUNTIME:=n

So I understand, I only need to resend the other three patches ?

Thanks.

^ permalink raw reply

* Re: [PATCH] OMAPDSS: Check if RPM enabled before trying to change state
From: Jassi Brar @ 2012-06-26 15:21 UTC (permalink / raw)
  To: Tomi Valkeinen; +Cc: mythripk, linux-omap, linux-fbdev, andy.green, n-dechesne
In-Reply-To: <1340723296.24530.68.camel@deskari>

On 26 June 2012 20:38, Tomi Valkeinen <tomi.valkeinen@ti.com> wrote:
> On Tue, 2012-06-26 at 20:19 +0530, Jassi Brar wrote:
>> On 26 June 2012 17:33, Tomi Valkeinen <tomi.valkeinen@ti.com> wrote:
>> > On Tue, 2012-06-26 at 15:27 +0530, Jassi Brar wrote:
>> >
>> >> Seems similar, but I only tested OMAP4 HDMI.
>> >
>> > Would something like this one below work for you? It fixes the issues on
>> > my overo board.
>> >
>> I think this should work too (I will get to test it only tomorrow).
>>
>> Though I don't think it'll fix stack spew when run without
>> CONFIG_PM_RUNTIME. Maybe we could simply remove the WARN_ON in the
>> xxx_runtime_put() as Alan noted?
>
> Yes, that's a different issue. I'll look at that also.
>
Well, my patch took care of that also. But I agree, that could be
added separately as well.

^ permalink raw reply

* Re: [PATCH] OMAPDSS: Check if RPM enabled before trying to change state
From: Tomi Valkeinen @ 2012-06-26 15:11 UTC (permalink / raw)
  To: Jassi Brar; +Cc: mythripk, linux-omap, linux-fbdev, andy.green, n-dechesne
In-Reply-To: <CAJe_ZheMN_sqaANSMepmhDDp2a2sQAVPYD1-owBWpwwbxqAtHQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1089 bytes --]

On Tue, 2012-06-26 at 20:39 +0530, Jassi Brar wrote:
> On 26 June 2012 20:38, Tomi Valkeinen <tomi.valkeinen@ti.com> wrote:
> > On Tue, 2012-06-26 at 20:19 +0530, Jassi Brar wrote:
> >> On 26 June 2012 17:33, Tomi Valkeinen <tomi.valkeinen@ti.com> wrote:
> >> > On Tue, 2012-06-26 at 15:27 +0530, Jassi Brar wrote:
> >> >
> >> >> Seems similar, but I only tested OMAP4 HDMI.
> >> >
> >> > Would something like this one below work for you? It fixes the issues on
> >> > my overo board.
> >> >
> >> I think this should work too (I will get to test it only tomorrow).
> >>
> >> Though I don't think it'll fix stack spew when run without
> >> CONFIG_PM_RUNTIME. Maybe we could simply remove the WARN_ON in the
> >> xxx_runtime_put() as Alan noted?
> >
> > Yes, that's a different issue. I'll look at that also.
> >
> Well, my patch took care of that also. But I agree, that could be
> added separately as well.

Well, I don't agree that your patch is correct =). I don't think it's
right to skip runtime get and put when pm_runtime_enabled() returns
false.

 Tomi


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply

* Re: [PATCH] OMAPDSS: Check if RPM enabled before trying to change state
From: Alan Stern @ 2012-06-26 15:11 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Grazvydas Ignotas, Rajendra Nayak, jaswinder.singh, mythripk,
	linux-omap, linux-fbdev, andy.green, n-dechesne,
	Rafael J. Wysocki, linux-pm
In-Reply-To: <1340722875.24530.66.camel@deskari>

On Tue, 26 Jun 2012, Tomi Valkeinen wrote:

> > Failure to suspend a device should not be regarded as particularly bad, 
> > because it doesn't affect the device's functionality.  That's true even 
> > when CONFIG_RUNTIME_PM is enabled.
> 
> This makes sense. So if CONFIG_RUNTIME_PM=n, using pm_runtime_get_sync()
> will return 1, meaning the HW is already enabled, and using
> pm_runtime_put_sync() will return -ENOSYS, meaning the hardware cannot
> be suspended.
> 
> With CONFIG_RUNTIME_PM=y, it's a bit more complex. If I read the code
> correctly, when I call pm_runtime_get_sync(), the usage counter is
> always increased, even if the pm_runtime_resume() fails. So a get()
> needs to be always matched with a put(), even if get() has returned an
> error.

Right.  Of course, it doesn't hurt to match a get() with a put() even 
when CONFIG_RUNTIME_PM=n.

> But if pm_runtime_get_sync() returns an error, it means the HW has not
> been resumed successfully, and is not operational, so the code should
> bail out somehow. So basically I'd use this kind of pattern everywhere I
> use pm_runtime_get_sync():
> 
> ---
> 
> r = pm_runtime_get_sync(dev);
> if (r < 0) {
> 	pm_runtime_put_sync(dev);

Here you could just as well call pm_runtime_put_noidle().  Since the 
device wasn't resumed, the put operation doesn't need to try to suspend 
it.

> 	/* handle error */
> 	return -ESOMETHING;
> }
> 
> /* do the work */
> 
> pm_runtime_put_sync(dev);
> 
> ---
> 
> Is this correct?

Yep, you've got it.

Alan Stern


^ permalink raw reply

* Re: [PATCH] OMAPDSS: Check if RPM enabled before trying to change state
From: Tomi Valkeinen @ 2012-06-26 15:08 UTC (permalink / raw)
  To: Jassi Brar; +Cc: mythripk, linux-omap, linux-fbdev, andy.green, n-dechesne
In-Reply-To: <CAJe_ZhcxVAUuuMDZ8p1LVae4N2aZb_vFs_nRLfb7atJ2j6j=Sg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 661 bytes --]

On Tue, 2012-06-26 at 20:19 +0530, Jassi Brar wrote:
> On 26 June 2012 17:33, Tomi Valkeinen <tomi.valkeinen@ti.com> wrote:
> > On Tue, 2012-06-26 at 15:27 +0530, Jassi Brar wrote:
> >
> >> Seems similar, but I only tested OMAP4 HDMI.
> >
> > Would something like this one below work for you? It fixes the issues on
> > my overo board.
> >
> I think this should work too (I will get to test it only tomorrow).
> 
> Though I don't think it'll fix stack spew when run without
> CONFIG_PM_RUNTIME. Maybe we could simply remove the WARN_ON in the
> xxx_runtime_put() as Alan noted?

Yes, that's a different issue. I'll look at that also.

 Tomi


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply

* Re: [PATCH] OMAPDSS: Check if RPM enabled before trying to change state
From: Tomi Valkeinen @ 2012-06-26 15:01 UTC (permalink / raw)
  To: Alan Stern
  Cc: Grazvydas Ignotas, Rajendra Nayak, jaswinder.singh, mythripk,
	linux-omap, linux-fbdev, andy.green, n-dechesne,
	Rafael J. Wysocki, linux-pm
In-Reply-To: <Pine.LNX.4.44L0.1206261031450.1636-100000@iolanthe.rowland.org>

[-- Attachment #1: Type: text/plain, Size: 1951 bytes --]

On Tue, 2012-06-26 at 10:34 -0400, Alan Stern wrote:
> On Tue, 26 Jun 2012, Grazvydas Ignotas wrote:
> 
> > CCing some PM people, maybe they can comment?
> > 
> > On Tue, Jun 26, 2012 at 7:51 AM, Rajendra Nayak <rnayak@ti.com> wrote:
> > > On Monday 25 June 2012 06:20 PM, Tomi Valkeinen wrote:
> > >>
> > >> Do you know how the drivers should handle CONFIG_PM_RUNTIME=n?
> > >> Are they supposed to handle the error values returned by runtime PM
> > >> functions somehow, or should they use #ifdef CONFIG_PM_RUNTIME?
> > >
> > > hmm, I always though with CONFIG_RUNTIME_PM=n, the functions would
> > > be stubbed to return success and not failure.
> 
> Not exactly.  They are stubbed to indicate that the device cannot be 
> suspended, that it is always active.
> 
> Failure to suspend a device should not be regarded as particularly bad, 
> because it doesn't affect the device's functionality.  That's true even 
> when CONFIG_RUNTIME_PM is enabled.

This makes sense. So if CONFIG_RUNTIME_PM=n, using pm_runtime_get_sync()
will return 1, meaning the HW is already enabled, and using
pm_runtime_put_sync() will return -ENOSYS, meaning the hardware cannot
be suspended.

With CONFIG_RUNTIME_PM=y, it's a bit more complex. If I read the code
correctly, when I call pm_runtime_get_sync(), the usage counter is
always increased, even if the pm_runtime_resume() fails. So a get()
needs to be always matched with a put(), even if get() has returned an
error.

But if pm_runtime_get_sync() returns an error, it means the HW has not
been resumed successfully, and is not operational, so the code should
bail out somehow. So basically I'd use this kind of pattern everywhere I
use pm_runtime_get_sync():

---

r = pm_runtime_get_sync(dev);
if (r < 0) {
	pm_runtime_put_sync(dev);
	/* handle error */
	return -ESOMETHING;
}

/* do the work */

pm_runtime_put_sync(dev);

---

Is this correct?

 Tomi


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply

* Re: [PATCH] OMAPDSS: Check if RPM enabled before trying to change state
From: Jassi Brar @ 2012-06-26 14:52 UTC (permalink / raw)
  To: Tomi Valkeinen; +Cc: mythripk, linux-omap, linux-fbdev, andy.green, n-dechesne
In-Reply-To: <1340712213.24530.21.camel@deskari>

On 26 June 2012 17:33, Tomi Valkeinen <tomi.valkeinen@ti.com> wrote:
> On Tue, 2012-06-26 at 15:27 +0530, Jassi Brar wrote:
>
>> Seems similar, but I only tested OMAP4 HDMI.
>
> Would something like this one below work for you? It fixes the issues on
> my overo board.
>
I think this should work too (I will get to test it only tomorrow).

Though I don't think it'll fix stack spew when run without
CONFIG_PM_RUNTIME. Maybe we could simply remove the WARN_ON in the
xxx_runtime_put() as Alan noted?

-j

> Instead of using omapdss device's suspend/resume callbacks, this one
> uses PM notifier calls which happen before suspend and after resume.
>
> I still think the suspend handling is wrong, omapdss shouldn't be
> enabling and disabling panel devices like that, but this one should
> remove the biggest issues with the current suspend method.
>
>  Tomi
>
> diff --git a/drivers/video/omap2/dss/core.c b/drivers/video/omap2/dss/core.c
> index 5066eee..c35a248 100644
> --- a/drivers/video/omap2/dss/core.c
> +++ b/drivers/video/omap2/dss/core.c
> @@ -32,6 +32,7 @@
>  #include <linux/io.h>
>  #include <linux/device.h>
>  #include <linux/regulator/consumer.h>
> +#include <linux/suspend.h>
>
>  #include <video/omapdss.h>
>
> @@ -201,6 +202,30 @@ int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *))
>  #endif /* CONFIG_DEBUG_FS && CONFIG_OMAP2_DSS_DEBUG_SUPPORT */
>
>  /* PLATFORM DEVICE */
> +static int omap_dss_pm_notif(struct notifier_block *b, unsigned long v, void *d)
> +{
> +       DSSDBG("pm notif %lu\n", v);
> +
> +       switch (v)
> +       {
> +       case PM_SUSPEND_PREPARE:
> +               DSSDBG("suspending displays\n");
> +               return dss_suspend_all_devices();
> +
> +       case PM_POST_SUSPEND:
> +               DSSDBG("resuming displays\n");
> +               return dss_resume_all_devices();
> +
> +       default:
> +               return 0;
> +       }
> +}
> +
> +static struct notifier_block omap_dss_pm_notif_block > +{
> +       .notifier_call = omap_dss_pm_notif,
> +};
> +
>  static int __init omap_dss_probe(struct platform_device *pdev)
>  {
>        struct omap_dss_board_info *pdata = pdev->dev.platform_data;
> @@ -224,6 +249,8 @@ static int __init omap_dss_probe(struct platform_device *pdev)
>        else if (pdata->default_device)
>                core.default_display_name = pdata->default_device->name;
>
> +       register_pm_notifier(&omap_dss_pm_notif_block);
> +
>        return 0;
>
>  err_debugfs:
> @@ -233,6 +260,8 @@ err_debugfs:
>
>  static int omap_dss_remove(struct platform_device *pdev)
>  {
> +       unregister_pm_notifier(&omap_dss_pm_notif_block);
> +
>        dss_uninitialize_debugfs();
>
>        dss_uninit_overlays(pdev);
> @@ -247,25 +276,9 @@ static void omap_dss_shutdown(struct platform_device *pdev)
>        dss_disable_all_devices();
>  }
>
> -static int omap_dss_suspend(struct platform_device *pdev, pm_message_t state)
> -{
> -       DSSDBG("suspend %d\n", state.event);
> -
> -       return dss_suspend_all_devices();
> -}
> -
> -static int omap_dss_resume(struct platform_device *pdev)
> -{
> -       DSSDBG("resume\n");
> -
> -       return dss_resume_all_devices();
> -}
> -
>  static struct platform_driver omap_dss_driver = {
>        .remove         = omap_dss_remove,
>        .shutdown       = omap_dss_shutdown,
> -       .suspend        = omap_dss_suspend,
> -       .resume         = omap_dss_resume,
>        .driver         = {
>                .name   = "omapdss",
>                .owner  = THIS_MODULE,
>



-- 
Linaro.org │ Open source software for ARM SoCs | Follow Linaro
http://facebook.com/pages/Linaro/155974581091106  -
http://twitter.com/#!/linaroorg - http://linaro.org/linaro-blog

^ permalink raw reply

* Re: [PATCH] OMAPDSS: Check if RPM enabled before trying to change state
From: Alan Stern @ 2012-06-26 14:34 UTC (permalink / raw)
  To: Grazvydas Ignotas
  Cc: Rajendra Nayak, Tomi Valkeinen, jaswinder.singh, mythripk,
	linux-omap, linux-fbdev, andy.green, n-dechesne,
	Rafael J. Wysocki, linux-pm
In-Reply-To: <CANOLnOP_z47QCB234y-BOWyRGHeO8u-pJct=Kq6+2XCig-tX=w@mail.gmail.com>

On Tue, 26 Jun 2012, Grazvydas Ignotas wrote:

> CCing some PM people, maybe they can comment?
> 
> On Tue, Jun 26, 2012 at 7:51 AM, Rajendra Nayak <rnayak@ti.com> wrote:
> > On Monday 25 June 2012 06:20 PM, Tomi Valkeinen wrote:
> >>
> >> Do you know how the drivers should handle CONFIG_PM_RUNTIME=n?
> >> Are they supposed to handle the error values returned by runtime PM
> >> functions somehow, or should they use #ifdef CONFIG_PM_RUNTIME?
> >
> > hmm, I always though with CONFIG_RUNTIME_PM=n, the functions would
> > be stubbed to return success and not failure.

Not exactly.  They are stubbed to indicate that the device cannot be 
suspended, that it is always active.

Failure to suspend a device should not be regarded as particularly bad, 
because it doesn't affect the device's functionality.  That's true even 
when CONFIG_RUNTIME_PM is enabled.

> And the _pm_runtime_resume
> > function indeed seems to return 1, which is not failure but just saying
> > that your device is already active/enabled.
> > The _pm_runtime_suspend and _pm_runtime_idle do return a -ENOSYS, which
> > is something only returned when CONFIG_RUNTIME_PM=n, so if you really
> > want to handle failing pm_runtime_put_sync cases, maybe you still can.
> > But then, I don't know if there is anything you can do to recover from
> > a failing pm_runtime_put_sync, except for warning the user maybe.

I don't see much point in warning the user that a device was unable to 
go to low power.

Alan Stern


^ permalink raw reply

* Re: [PATCH] OMAPDSS: Check if RPM enabled before trying to change state
From: Grazvydas Ignotas @ 2012-06-26 13:02 UTC (permalink / raw)
  To: Rajendra Nayak
  Cc: Tomi Valkeinen, jaswinder.singh, mythripk, linux-omap,
	linux-fbdev, andy.green, n-dechesne, Rafael J. Wysocki, linux-pm
In-Reply-To: <4FE93FB9.3080705@ti.com>

CCing some PM people, maybe they can comment?

On Tue, Jun 26, 2012 at 7:51 AM, Rajendra Nayak <rnayak@ti.com> wrote:
> On Monday 25 June 2012 06:20 PM, Tomi Valkeinen wrote:
>>
>> Do you know how the drivers should handle CONFIG_PM_RUNTIME=n?
>> Are they supposed to handle the error values returned by runtime PM
>> functions somehow, or should they use #ifdef CONFIG_PM_RUNTIME?
>
> hmm, I always though with CONFIG_RUNTIME_PM=n, the functions would
> be stubbed to return success and not failure. And the _pm_runtime_resume
> function indeed seems to return 1, which is not failure but just saying
> that your device is already active/enabled.
> The _pm_runtime_suspend and _pm_runtime_idle do return a -ENOSYS, which
> is something only returned when CONFIG_RUNTIME_PM=n, so if you really
> want to handle failing pm_runtime_put_sync cases, maybe you still can.
> But then, I don't know if there is anything you can do to recover from
> a failing pm_runtime_put_sync, except for warning the user maybe.
>
>> Both options sound a bit difficult to me... With the first one it's
>> difficult to see if there was an actual error and we should somehow
>> react to it, or is everything fine and we just shouldn't care about
>> runtime PM. The second one requires ifdefs in many places.

-- 
Gražvydas

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox