All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] drm/tegra: Add guard to avoid double disable/enable of RGB outputs
@ 2014-02-11 17:12 Dmitry Osipenko
  2014-02-11 19:13 ` Erik Faye-Lund
  2014-02-12 10:18   ` Thierry Reding
  0 siblings, 2 replies; 7+ messages in thread
From: Dmitry Osipenko @ 2014-02-11 17:12 UTC (permalink / raw)
  To: thierry.reding, tbergstrom, airlied, swarren
  Cc: dri-devel, linux-tegra, linux-kernel, Dmitry Osipenko

Add guard to check whether RGB output is already enabled in the way it's
done for HDMI output. Fixes possible hang on trying to disable output twice
(first time during driver probe and second on fb registering).

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/gpu/drm/tegra/rgb.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c
index 338f7f6..0266fb4 100644
--- a/drivers/gpu/drm/tegra/rgb.c
+++ b/drivers/gpu/drm/tegra/rgb.c
@@ -15,6 +15,7 @@
 struct tegra_rgb {
 	struct tegra_output output;
 	struct tegra_dc *dc;
+	bool enabled;
 
 	struct clk *clk_parent;
 	struct clk *clk;
@@ -89,6 +90,9 @@ static int tegra_output_rgb_enable(struct tegra_output *output)
 	struct tegra_rgb *rgb = to_rgb(output);
 	unsigned long value;
 
+	if (rgb->enabled)
+		return 0;
+
 	tegra_dc_write_regs(rgb->dc, rgb_enable, ARRAY_SIZE(rgb_enable));
 
 	value = DE_SELECT_ACTIVE | DE_CONTROL_NORMAL;
@@ -122,6 +126,8 @@ static int tegra_output_rgb_enable(struct tegra_output *output)
 	tegra_dc_writel(rgb->dc, GENERAL_ACT_REQ << 8, DC_CMD_STATE_CONTROL);
 	tegra_dc_writel(rgb->dc, GENERAL_ACT_REQ, DC_CMD_STATE_CONTROL);
 
+	rgb->enabled = true;
+
 	return 0;
 }
 
@@ -130,6 +136,9 @@ static int tegra_output_rgb_disable(struct tegra_output *output)
 	struct tegra_rgb *rgb = to_rgb(output);
 	unsigned long value;
 
+	if (!rgb->enabled)
+		return 0;
+
 	value = tegra_dc_readl(rgb->dc, DC_CMD_DISPLAY_POWER_CONTROL);
 	value &= ~(PW0_ENABLE | PW1_ENABLE | PW2_ENABLE | PW3_ENABLE |
 		   PW4_ENABLE | PM0_ENABLE | PM1_ENABLE);
@@ -144,6 +153,8 @@ static int tegra_output_rgb_disable(struct tegra_output *output)
 
 	tegra_dc_write_regs(rgb->dc, rgb_disable, ARRAY_SIZE(rgb_disable));
 
+	rgb->enabled = false;
+
 	return 0;
 }
 
-- 
1.8.5.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] drm/tegra: Add guard to avoid double disable/enable of RGB outputs
  2014-02-11 17:12 [PATCH 1/1] drm/tegra: Add guard to avoid double disable/enable of RGB outputs Dmitry Osipenko
@ 2014-02-11 19:13 ` Erik Faye-Lund
  2014-02-11 19:48   ` Dmitry Osipenko
  2014-02-11 20:54     ` Thierry Reding
  2014-02-12 10:18   ` Thierry Reding
  1 sibling, 2 replies; 7+ messages in thread
From: Erik Faye-Lund @ 2014-02-11 19:13 UTC (permalink / raw)
  To: Dmitry Osipenko
  Cc: thierry.reding, tbergstrom, airlied, swarren, dri-devel,
	linux-tegra, linux-kernel

On Tue, Feb 11, 2014 at 6:12 PM, Dmitry Osipenko <digetx@gmail.com> wrote:
> Add guard to check whether RGB output is already enabled in the way it's
> done for HDMI output. Fixes possible hang on trying to disable output twice
> (first time during driver probe and second on fb registering).
>
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
>  drivers/gpu/drm/tegra/rgb.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c
> index 338f7f6..0266fb4 100644
> --- a/drivers/gpu/drm/tegra/rgb.c
> +++ b/drivers/gpu/drm/tegra/rgb.c
> @@ -15,6 +15,7 @@
>  struct tegra_rgb {
>         struct tegra_output output;
>         struct tegra_dc *dc;
> +       bool enabled;
>
>         struct clk *clk_parent;
>         struct clk *clk;
> @@ -89,6 +90,9 @@ static int tegra_output_rgb_enable(struct tegra_output *output)
>         struct tegra_rgb *rgb = to_rgb(output);
>         unsigned long value;
>
> +       if (rgb->enabled)
> +               return 0;
> +
>         tegra_dc_write_regs(rgb->dc, rgb_enable, ARRAY_SIZE(rgb_enable));
>
>         value = DE_SELECT_ACTIVE | DE_CONTROL_NORMAL;
> @@ -122,6 +126,8 @@ static int tegra_output_rgb_enable(struct tegra_output *output)
>         tegra_dc_writel(rgb->dc, GENERAL_ACT_REQ << 8, DC_CMD_STATE_CONTROL);
>         tegra_dc_writel(rgb->dc, GENERAL_ACT_REQ, DC_CMD_STATE_CONTROL);
>
> +       rgb->enabled = true;
> +
>         return 0;
>  }
>
> @@ -130,6 +136,9 @@ static int tegra_output_rgb_disable(struct tegra_output *output)
>         struct tegra_rgb *rgb = to_rgb(output);
>         unsigned long value;
>
> +       if (!rgb->enabled)
> +               return 0;
> +
>         value = tegra_dc_readl(rgb->dc, DC_CMD_DISPLAY_POWER_CONTROL);
>         value &= ~(PW0_ENABLE | PW1_ENABLE | PW2_ENABLE | PW3_ENABLE |
>                    PW4_ENABLE | PM0_ENABLE | PM1_ENABLE);
> @@ -144,6 +153,8 @@ static int tegra_output_rgb_disable(struct tegra_output *output)
>
>         tegra_dc_write_regs(rgb->dc, rgb_disable, ARRAY_SIZE(rgb_disable));
>
> +       rgb->enabled = false;
> +
>         return 0;
>  }
>

Wouldn't it make more sense to make "enabled" and int that counts how
many times tegra_output_rgb_enable has been called? That way you can
have tegra_output_rgb_disable only really disable the display once the
same amount of disables have been performed...

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] drm/tegra: Add guard to avoid double disable/enable of RGB outputs
  2014-02-11 19:13 ` Erik Faye-Lund
@ 2014-02-11 19:48   ` Dmitry Osipenko
  2014-02-11 20:54     ` Thierry Reding
  1 sibling, 0 replies; 7+ messages in thread
From: Dmitry Osipenko @ 2014-02-11 19:48 UTC (permalink / raw)
  To: kusmabite
  Cc: thierry.reding, tbergstrom, airlied, swarren, dri-devel,
	linux-tegra, linux-kernel

11.02.2014 23:13, Erik Faye-Lund пишет:
> On Tue, Feb 11, 2014 at 6:12 PM, Dmitry Osipenko <digetx@gmail.com> wrote:
>> Add guard to check whether RGB output is already enabled in the way it's
>> done for HDMI output. Fixes possible hang on trying to disable output twice
>> (first time during driver probe and second on fb registering).
>>
>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>> ---
>>  drivers/gpu/drm/tegra/rgb.c | 11 +++++++++++
>>  1 file changed, 11 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c
>> index 338f7f6..0266fb4 100644
>> --- a/drivers/gpu/drm/tegra/rgb.c
>> +++ b/drivers/gpu/drm/tegra/rgb.c
>> @@ -15,6 +15,7 @@
>>  struct tegra_rgb {
>>         struct tegra_output output;
>>         struct tegra_dc *dc;
>> +       bool enabled;
>>
>>         struct clk *clk_parent;
>>         struct clk *clk;
>> @@ -89,6 +90,9 @@ static int tegra_output_rgb_enable(struct tegra_output *output)
>>         struct tegra_rgb *rgb = to_rgb(output);
>>         unsigned long value;
>>
>> +       if (rgb->enabled)
>> +               return 0;
>> +
>>         tegra_dc_write_regs(rgb->dc, rgb_enable, ARRAY_SIZE(rgb_enable));
>>
>>         value = DE_SELECT_ACTIVE | DE_CONTROL_NORMAL;
>> @@ -122,6 +126,8 @@ static int tegra_output_rgb_enable(struct tegra_output *output)
>>         tegra_dc_writel(rgb->dc, GENERAL_ACT_REQ << 8, DC_CMD_STATE_CONTROL);
>>         tegra_dc_writel(rgb->dc, GENERAL_ACT_REQ, DC_CMD_STATE_CONTROL);
>>
>> +       rgb->enabled = true;
>> +
>>         return 0;
>>  }
>>
>> @@ -130,6 +136,9 @@ static int tegra_output_rgb_disable(struct tegra_output *output)
>>         struct tegra_rgb *rgb = to_rgb(output);
>>         unsigned long value;
>>
>> +       if (!rgb->enabled)
>> +               return 0;
>> +
>>         value = tegra_dc_readl(rgb->dc, DC_CMD_DISPLAY_POWER_CONTROL);
>>         value &= ~(PW0_ENABLE | PW1_ENABLE | PW2_ENABLE | PW3_ENABLE |
>>                    PW4_ENABLE | PM0_ENABLE | PM1_ENABLE);
>> @@ -144,6 +153,8 @@ static int tegra_output_rgb_disable(struct tegra_output *output)
>>
>>         tegra_dc_write_regs(rgb->dc, rgb_disable, ARRAY_SIZE(rgb_disable));
>>
>> +       rgb->enabled = false;
>> +
>>         return 0;
>>  }
>>
> 
> Wouldn't it make more sense to make "enabled" and int that counts how
> many times tegra_output_rgb_enable has been called? That way you can
> have tegra_output_rgb_disable only really disable the display once the
> same amount of disables have been performed...
> 
RGB is a part of DC, i.e. one per DC. tegra_output_rgb_enable() would be called
for each individual DC, so it doesn't make any sense. Besides, I doubt tegra
device with two panels ever existed or will be :)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] drm/tegra: Add guard to avoid double disable/enable of RGB outputs
  2014-02-11 19:13 ` Erik Faye-Lund
@ 2014-02-11 20:54     ` Thierry Reding
  2014-02-11 20:54     ` Thierry Reding
  1 sibling, 0 replies; 7+ messages in thread
From: Thierry Reding @ 2014-02-11 20:54 UTC (permalink / raw)
  To: Erik Faye-Lund
  Cc: tbergstrom, swarren, linux-kernel, dri-devel, linux-tegra,
	Dmitry Osipenko


[-- Attachment #1.1: Type: text/plain, Size: 3165 bytes --]

On Tue, Feb 11, 2014 at 08:13:14PM +0100, Erik Faye-Lund wrote:
> On Tue, Feb 11, 2014 at 6:12 PM, Dmitry Osipenko <digetx@gmail.com> wrote:
> > Add guard to check whether RGB output is already enabled in the way it's
> > done for HDMI output. Fixes possible hang on trying to disable output twice
> > (first time during driver probe and second on fb registering).
> >
> > Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> > ---
> >  drivers/gpu/drm/tegra/rgb.c | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c
> > index 338f7f6..0266fb4 100644
> > --- a/drivers/gpu/drm/tegra/rgb.c
> > +++ b/drivers/gpu/drm/tegra/rgb.c
> > @@ -15,6 +15,7 @@
> >  struct tegra_rgb {
> >         struct tegra_output output;
> >         struct tegra_dc *dc;
> > +       bool enabled;
> >
> >         struct clk *clk_parent;
> >         struct clk *clk;
> > @@ -89,6 +90,9 @@ static int tegra_output_rgb_enable(struct tegra_output *output)
> >         struct tegra_rgb *rgb = to_rgb(output);
> >         unsigned long value;
> >
> > +       if (rgb->enabled)
> > +               return 0;
> > +
> >         tegra_dc_write_regs(rgb->dc, rgb_enable, ARRAY_SIZE(rgb_enable));
> >
> >         value = DE_SELECT_ACTIVE | DE_CONTROL_NORMAL;
> > @@ -122,6 +126,8 @@ static int tegra_output_rgb_enable(struct tegra_output *output)
> >         tegra_dc_writel(rgb->dc, GENERAL_ACT_REQ << 8, DC_CMD_STATE_CONTROL);
> >         tegra_dc_writel(rgb->dc, GENERAL_ACT_REQ, DC_CMD_STATE_CONTROL);
> >
> > +       rgb->enabled = true;
> > +
> >         return 0;
> >  }
> >
> > @@ -130,6 +136,9 @@ static int tegra_output_rgb_disable(struct tegra_output *output)
> >         struct tegra_rgb *rgb = to_rgb(output);
> >         unsigned long value;
> >
> > +       if (!rgb->enabled)
> > +               return 0;
> > +
> >         value = tegra_dc_readl(rgb->dc, DC_CMD_DISPLAY_POWER_CONTROL);
> >         value &= ~(PW0_ENABLE | PW1_ENABLE | PW2_ENABLE | PW3_ENABLE |
> >                    PW4_ENABLE | PM0_ENABLE | PM1_ENABLE);
> > @@ -144,6 +153,8 @@ static int tegra_output_rgb_disable(struct tegra_output *output)
> >
> >         tegra_dc_write_regs(rgb->dc, rgb_disable, ARRAY_SIZE(rgb_disable));
> >
> > +       rgb->enabled = false;
> > +
> >         return 0;
> >  }
> >
> 
> Wouldn't it make more sense to make "enabled" and int that counts how
> many times tegra_output_rgb_enable has been called? That way you can
> have tegra_output_rgb_disable only really disable the display once the
> same amount of disables have been performed...

I don't think that will work. Calls to tegra_output_rgb_enable/disable()
and the .enable/disable for any other outputs aren't guaranteed to be
balanced. Therefore reference counting the enables and disables will
break things.

Thinking about it, maybe the current interface to outputs isn't the best
solution. It's simple and with the guards in place it works pretty well.
Perhaps if I can find some spare time I'll investigate whether something
a little cleaner can be done.

Thierry

[-- Attachment #1.2: Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] drm/tegra: Add guard to avoid double disable/enable of RGB outputs
@ 2014-02-11 20:54     ` Thierry Reding
  0 siblings, 0 replies; 7+ messages in thread
From: Thierry Reding @ 2014-02-11 20:54 UTC (permalink / raw)
  To: Erik Faye-Lund
  Cc: Dmitry Osipenko, tbergstrom, airlied, swarren, dri-devel,
	linux-tegra, linux-kernel

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

On Tue, Feb 11, 2014 at 08:13:14PM +0100, Erik Faye-Lund wrote:
> On Tue, Feb 11, 2014 at 6:12 PM, Dmitry Osipenko <digetx@gmail.com> wrote:
> > Add guard to check whether RGB output is already enabled in the way it's
> > done for HDMI output. Fixes possible hang on trying to disable output twice
> > (first time during driver probe and second on fb registering).
> >
> > Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> > ---
> >  drivers/gpu/drm/tegra/rgb.c | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c
> > index 338f7f6..0266fb4 100644
> > --- a/drivers/gpu/drm/tegra/rgb.c
> > +++ b/drivers/gpu/drm/tegra/rgb.c
> > @@ -15,6 +15,7 @@
> >  struct tegra_rgb {
> >         struct tegra_output output;
> >         struct tegra_dc *dc;
> > +       bool enabled;
> >
> >         struct clk *clk_parent;
> >         struct clk *clk;
> > @@ -89,6 +90,9 @@ static int tegra_output_rgb_enable(struct tegra_output *output)
> >         struct tegra_rgb *rgb = to_rgb(output);
> >         unsigned long value;
> >
> > +       if (rgb->enabled)
> > +               return 0;
> > +
> >         tegra_dc_write_regs(rgb->dc, rgb_enable, ARRAY_SIZE(rgb_enable));
> >
> >         value = DE_SELECT_ACTIVE | DE_CONTROL_NORMAL;
> > @@ -122,6 +126,8 @@ static int tegra_output_rgb_enable(struct tegra_output *output)
> >         tegra_dc_writel(rgb->dc, GENERAL_ACT_REQ << 8, DC_CMD_STATE_CONTROL);
> >         tegra_dc_writel(rgb->dc, GENERAL_ACT_REQ, DC_CMD_STATE_CONTROL);
> >
> > +       rgb->enabled = true;
> > +
> >         return 0;
> >  }
> >
> > @@ -130,6 +136,9 @@ static int tegra_output_rgb_disable(struct tegra_output *output)
> >         struct tegra_rgb *rgb = to_rgb(output);
> >         unsigned long value;
> >
> > +       if (!rgb->enabled)
> > +               return 0;
> > +
> >         value = tegra_dc_readl(rgb->dc, DC_CMD_DISPLAY_POWER_CONTROL);
> >         value &= ~(PW0_ENABLE | PW1_ENABLE | PW2_ENABLE | PW3_ENABLE |
> >                    PW4_ENABLE | PM0_ENABLE | PM1_ENABLE);
> > @@ -144,6 +153,8 @@ static int tegra_output_rgb_disable(struct tegra_output *output)
> >
> >         tegra_dc_write_regs(rgb->dc, rgb_disable, ARRAY_SIZE(rgb_disable));
> >
> > +       rgb->enabled = false;
> > +
> >         return 0;
> >  }
> >
> 
> Wouldn't it make more sense to make "enabled" and int that counts how
> many times tegra_output_rgb_enable has been called? That way you can
> have tegra_output_rgb_disable only really disable the display once the
> same amount of disables have been performed...

I don't think that will work. Calls to tegra_output_rgb_enable/disable()
and the .enable/disable for any other outputs aren't guaranteed to be
balanced. Therefore reference counting the enables and disables will
break things.

Thinking about it, maybe the current interface to outputs isn't the best
solution. It's simple and with the guards in place it works pretty well.
Perhaps if I can find some spare time I'll investigate whether something
a little cleaner can be done.

Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] drm/tegra: Add guard to avoid double disable/enable of RGB outputs
  2014-02-11 17:12 [PATCH 1/1] drm/tegra: Add guard to avoid double disable/enable of RGB outputs Dmitry Osipenko
@ 2014-02-12 10:18   ` Thierry Reding
  2014-02-12 10:18   ` Thierry Reding
  1 sibling, 0 replies; 7+ messages in thread
From: Thierry Reding @ 2014-02-12 10:18 UTC (permalink / raw)
  To: Dmitry Osipenko; +Cc: tbergstrom, swarren, linux-kernel, dri-devel, linux-tegra


[-- Attachment #1.1: Type: text/plain, Size: 468 bytes --]

On Tue, Feb 11, 2014 at 09:12:27PM +0400, Dmitry Osipenko wrote:
> Add guard to check whether RGB output is already enabled in the way it's
> done for HDMI output. Fixes possible hang on trying to disable output twice
> (first time during driver probe and second on fb registering).
> 
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
>  drivers/gpu/drm/tegra/rgb.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)

Applied, thanks!

Thierry

[-- Attachment #1.2: Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] drm/tegra: Add guard to avoid double disable/enable of RGB outputs
@ 2014-02-12 10:18   ` Thierry Reding
  0 siblings, 0 replies; 7+ messages in thread
From: Thierry Reding @ 2014-02-12 10:18 UTC (permalink / raw)
  To: Dmitry Osipenko
  Cc: tbergstrom, airlied, swarren, dri-devel, linux-tegra, linux-kernel

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

On Tue, Feb 11, 2014 at 09:12:27PM +0400, Dmitry Osipenko wrote:
> Add guard to check whether RGB output is already enabled in the way it's
> done for HDMI output. Fixes possible hang on trying to disable output twice
> (first time during driver probe and second on fb registering).
> 
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
>  drivers/gpu/drm/tegra/rgb.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)

Applied, thanks!

Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-02-12 10:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-11 17:12 [PATCH 1/1] drm/tegra: Add guard to avoid double disable/enable of RGB outputs Dmitry Osipenko
2014-02-11 19:13 ` Erik Faye-Lund
2014-02-11 19:48   ` Dmitry Osipenko
2014-02-11 20:54   ` Thierry Reding
2014-02-11 20:54     ` Thierry Reding
2014-02-12 10:18 ` Thierry Reding
2014-02-12 10:18   ` Thierry Reding

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.