Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1550126 > unrolled thread

[PATCH 5/5 v3] drm/bridge: adv7511: Reuse __adv7511_power_on/off() when probing EDID

Started byJohn Stultz <john.stultz@linaro.org>
First post2017-01-03 20:50 +0100
Last post2017-01-17 00:40 +0100
Articles 7 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 5/5 v3] drm/bridge: adv7511: Reuse __adv7511_power_on/off() when probing EDID John Stultz <john.stultz@linaro.org> - 2017-01-03 20:50 +0100
    Re: [PATCH 5/5 v3] drm/bridge: adv7511: Reuse __adv7511_power_on/off() when probing EDID Laurent Pinchart <laurent.pinchart@ideasonboard.com> - 2017-01-16 17:10 +0100
      Re: [PATCH 5/5 v3] drm/bridge: adv7511: Reuse __adv7511_power_on/off()  when probing EDID John Stultz <john.stultz@linaro.org> - 2017-01-16 21:20 +0100
        Re: [PATCH 5/5 v3] drm/bridge: adv7511: Reuse __adv7511_power_on/off() when probing EDID Laurent Pinchart <laurent.pinchart@ideasonboard.com> - 2017-01-16 23:30 +0100
          [RFC][PATCH] drm/bridge: adv7511: Re-write the i2c address as it may have been lost John Stultz <john.stultz@linaro.org> - 2017-01-17 00:20 +0100
            Re: [RFC][PATCH] drm/bridge: adv7511: Re-write the i2c address as it  may have been lost John Stultz <john.stultz@linaro.org> - 2017-01-17 00:40 +0100
            Re: [RFC][PATCH] drm/bridge: adv7511: Re-write the i2c address as it may have been lost Laurent Pinchart <laurent.pinchart@ideasonboard.com> - 2017-01-17 00:40 +0100

#1550126 — [PATCH 5/5 v3] drm/bridge: adv7511: Reuse __adv7511_power_on/off() when probing EDID

FromJohn Stultz <john.stultz@linaro.org>
Date2017-01-03 20:50 +0100
Subject[PATCH 5/5 v3] drm/bridge: adv7511: Reuse __adv7511_power_on/off() when probing EDID
Message-ID<sVDfP-2y2-1@gated-at.bofh.it>
I've found that by just turning the chip on and off via the
POWER_DOWN register, I end up getting i2c_transfer errors
on HiKey.

Investigating further, it seems some of the register state
in the regmap cache is somehow getting lost. Using the logic
in __adv7511_power_on/off() which syncs and dirtys the cache
avoids this issue.

Thus this patch changes the EDID probing logic so that we
re-use the __adv7511_power_on/off() calls.

Cc: David Airlie <airlied@linux.ie>
Cc: Archit Taneja <architt@codeaurora.org>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
 drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
index dbdb71c..24573e0 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
@@ -572,24 +572,13 @@ static int adv7511_get_modes(struct adv7511 *adv7511,
 	unsigned int count;
 
 	/* Reading the EDID only works if the device is powered */
-	if (!adv7511->powered) {
-		regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER,
-				   ADV7511_POWER_POWER_DOWN, 0);
-		if (adv7511->i2c_main->irq) {
-			regmap_write(adv7511->regmap, ADV7511_REG_INT_ENABLE(0),
-				     ADV7511_INT0_EDID_READY);
-			regmap_write(adv7511->regmap, ADV7511_REG_INT_ENABLE(1),
-				     ADV7511_INT1_DDC_ERROR);
-		}
-		adv7511->current_edid_segment = -1;
-	}
+	if (!adv7511->powered)
+		__adv7511_power_on(adv7511);
 
 	edid = drm_do_get_edid(connector, adv7511_get_edid_block, adv7511);
 
 	if (!adv7511->powered)
-		regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER,
-				   ADV7511_POWER_POWER_DOWN,
-				   ADV7511_POWER_POWER_DOWN);
+		__adv7511_power_off(adv7511);
 
 	kfree(adv7511->edid);
 	adv7511->edid = edid;
-- 
2.7.4

[toc] | [next] | [standalone]


#1559866

FromLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Date2017-01-16 17:10 +0100
Message-ID<t0i13-2KF-13@gated-at.bofh.it>
In reply to#1550126
Hi John,

Thank you for the patch.

On Tuesday 03 Jan 2017 11:41:42 John Stultz wrote:
> I've found that by just turning the chip on and off via the
> POWER_DOWN register, I end up getting i2c_transfer errors
> on HiKey.
> 
> Investigating further, it seems some of the register state
> in the regmap cache is somehow getting lost. Using the logic
> in __adv7511_power_on/off() which syncs and dirtys the cache
> avoids this issue.
> 
> Thus this patch changes the EDID probing logic so that we
> re-use the __adv7511_power_on/off() calls.

regcache_sync() is quite costly as it will write a bunch of registers. 
Wouldn't it be more efficient to only write the registers that are needed for 
EDID access ?

> Cc: David Airlie <airlied@linux.ie>
> Cc: Archit Taneja <architt@codeaurora.org>
> Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Cc: Lars-Peter Clausen <lars@metafoo.de>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: dri-devel@lists.freedesktop.org
> Signed-off-by: John Stultz <john.stultz@linaro.org>
> ---
>  drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 17 +++--------------
>  1 file changed, 3 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c index dbdb71c..24573e0
> 100644
> --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> @@ -572,24 +572,13 @@ static int adv7511_get_modes(struct adv7511 *adv7511,
>  	unsigned int count;
> 
>  	/* Reading the EDID only works if the device is powered */
> -	if (!adv7511->powered) {
> -		regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER,
> -				   ADV7511_POWER_POWER_DOWN, 0);
> -		if (adv7511->i2c_main->irq) {
> -			regmap_write(adv7511->regmap, 
ADV7511_REG_INT_ENABLE(0),
> -				     ADV7511_INT0_EDID_READY);
> -			regmap_write(adv7511->regmap, 
ADV7511_REG_INT_ENABLE(1),
> -				     ADV7511_INT1_DDC_ERROR);
> -		}
> -		adv7511->current_edid_segment = -1;
> -	}
> +	if (!adv7511->powered)
> +		__adv7511_power_on(adv7511);
> 
>  	edid = drm_do_get_edid(connector, adv7511_get_edid_block, adv7511);
> 
>  	if (!adv7511->powered)
> -		regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER,
> -				   ADV7511_POWER_POWER_DOWN,
> -				   ADV7511_POWER_POWER_DOWN);
> +		__adv7511_power_off(adv7511);
> 
>  	kfree(adv7511->edid);
>  	adv7511->edid = edid;

-- 
Regards,

Laurent Pinchart

[toc] | [prev] | [next] | [standalone]


#1560036 — Re: [PATCH 5/5 v3] drm/bridge: adv7511: Reuse __adv7511_power_on/off() when probing EDID

FromJohn Stultz <john.stultz@linaro.org>
Date2017-01-16 21:20 +0100
SubjectRe: [PATCH 5/5 v3] drm/bridge: adv7511: Reuse __adv7511_power_on/off() when probing EDID
Message-ID<t0lV0-5Di-21@gated-at.bofh.it>
In reply to#1559866
On Mon, Jan 16, 2017 at 8:03 AM, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> Hi John,
>
> Thank you for the patch.
>
> On Tuesday 03 Jan 2017 11:41:42 John Stultz wrote:
>> I've found that by just turning the chip on and off via the
>> POWER_DOWN register, I end up getting i2c_transfer errors
>> on HiKey.
>>
>> Investigating further, it seems some of the register state
>> in the regmap cache is somehow getting lost. Using the logic
>> in __adv7511_power_on/off() which syncs and dirtys the cache
>> avoids this issue.
>>
>> Thus this patch changes the EDID probing logic so that we
>> re-use the __adv7511_power_on/off() calls.
>
> regcache_sync() is quite costly as it will write a bunch of registers.
> Wouldn't it be more efficient to only write the registers that are needed for
> EDID access ?

So yes, you've mentioned this concern before, and I did spend some
time to narrow which lost-register state (0x43
 - ADV7511_REG_EDID_I2C_ADDR) was causing the trouble with i2c
trasnfer errors I was seeing:
  https://lkml.org/lkml/2016/11/22/677

However, I didn't get much feedback on that, and it seems (to me at
least) concerning that we are losing the underlying state of a
register in the cache, so just syncing that one register back to the
hardware might solve the issue I was seeing, but I worry what other
registers might also be out of sync.

The comment above the regmap_sync in adv7511_power_on after all states:
   "Most of the registers are reset during power down or when HPD is low."

So it seems like if we're setting the power down (and setting HPD in
cases where Archit had a patch to add HPD pulsing to the
adv7511_get_modes path), it seems reasonable to do the same
regmap_sync()?

But, I'm not really picky here, and I'm very open to other approaches
(including something like the patch in the link above) if you have
suggestions/preferences. I just want it to work reliably on my
hardware. :)

And just so I can better understand it, can you explain some about the
impact of your efficiency concerns?

thanks
-john

[toc] | [prev] | [next] | [standalone]


#1560138

FromLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Date2017-01-16 23:30 +0100
Message-ID<t0nWN-6UL-7@gated-at.bofh.it>
In reply to#1560036
Hi John,

On Monday 16 Jan 2017 12:14:48 John Stultz wrote:
> On Mon, Jan 16, 2017 at 8:03 AM, Laurent Pinchart wrote:
> > On Tuesday 03 Jan 2017 11:41:42 John Stultz wrote:
> >> I've found that by just turning the chip on and off via the
> >> POWER_DOWN register, I end up getting i2c_transfer errors
> >> on HiKey.
> >> 
> >> Investigating further, it seems some of the register state
> >> in the regmap cache is somehow getting lost. Using the logic
> >> in __adv7511_power_on/off() which syncs and dirtys the cache
> >> avoids this issue.
> >> 
> >> Thus this patch changes the EDID probing logic so that we
> >> re-use the __adv7511_power_on/off() calls.
> > 
> > regcache_sync() is quite costly as it will write a bunch of registers.
> > Wouldn't it be more efficient to only write the registers that are needed
> > for EDID access ?
> 
> So yes, you've mentioned this concern before, and I did spend some
> time to narrow which lost-register state (0x43
>  - ADV7511_REG_EDID_I2C_ADDR) was causing the trouble with i2c
> trasnfer errors I was seeing:
>   https://lkml.org/lkml/2016/11/22/677
> 
> However, I didn't get much feedback on that, and it seems (to me at
> least) concerning that we are losing the underlying state of a
> register in the cache, so just syncing that one register back to the
> hardware might solve the issue I was seeing, but I worry what other
> registers might also be out of sync.
>
> The comment above the regmap_sync in adv7511_power_on after all states:
>    "Most of the registers are reset during power down or when HPD is low."

You're right that most registers will be out of sync.

> So it seems like if we're setting the power down (and setting HPD in
> cases where Archit had a patch to add HPD pulsing to the
> adv7511_get_modes path), it seems reasonable to do the same
> regmap_sync()?

It would be if we had to keep the device powered up, but we're powering it 
down right after reading the EDID. I don't think there's a need to reconfigure 
it completely, only setting the registers needed to read the EDID should be 
enough.

> But, I'm not really picky here, and I'm very open to other approaches
> (including something like the patch in the link above) if you have
> suggestions/preferences. I just want it to work reliably on my
> hardware. :)
>
> And just so I can better understand it, can you explain some about the
> impact of your efficiency concerns?

I'm not too picky either :-) If we can't find a reliable way to read the EDID 
by just configuring the registers we need, we could go for a full 
reconfiguration. However, restoring the value of all cached registers will 
result in lots of I2C writes, which are time-consuming operations. EDID read 
would be sped up if we could avoid that.

-- 
Regards,

Laurent Pinchart

[toc] | [prev] | [next] | [standalone]


#1560161 — [RFC][PATCH] drm/bridge: adv7511: Re-write the i2c address as it may have been lost

FromJohn Stultz <john.stultz@linaro.org>
Date2017-01-17 00:20 +0100
Subject[RFC][PATCH] drm/bridge: adv7511: Re-write the i2c address as it may have been lost
Message-ID<t0oJb-7x8-7@gated-at.bofh.it>
In reply to#1560138
Laurent: Would something like the following be preferred? Seems
to work as well for me..

thanks
-john


I've found that by just turning the chip on and off via the
POWER_DOWN register, I end up getting i2c_transfer errors on
HiKey.

Investigating further, it seems some of the register state in
the regmap cache is somehow getting lost, likely as the device
registers were reset during power off.

Thus this patch simply re-writes the i2c address to the
ADV7511_REG_EDID_I2C_ADDR register to ensure its properly set
before we try to read the EDID data.

Cc: David Airlie <airlied@linux.ie>
Cc: Archit Taneja <architt@codeaurora.org>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
 drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
index 405e460..32c59cb 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
@@ -567,6 +567,8 @@ static int adv7511_get_modes(struct adv7511 *adv7511,
 
 	/* Reading the EDID only works if the device is powered */
 	if (!adv7511->powered) {
+		unsigned int edid_i2c_addr = (adv7511->i2c_main->addr << 1) + 4;
+
 		regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER,
 				   ADV7511_POWER_POWER_DOWN, 0);
 		if (adv7511->i2c_main->irq) {
@@ -576,6 +578,9 @@ static int adv7511_get_modes(struct adv7511 *adv7511,
 				     ADV7511_INT1_DDC_ERROR);
 		}
 		adv7511->current_edid_segment = -1;
+
+		/* Reset the EDID_I2C_ADDR register as it may have been cleared */
+		regmap_write(adv7511->regmap, ADV7511_REG_EDID_I2C_ADDR, edid_i2c_addr);
 	}
 
 	edid = drm_do_get_edid(connector, adv7511_get_edid_block, adv7511);
-- 
2.7.4

[toc] | [prev] | [next] | [standalone]


#1560165 — Re: [RFC][PATCH] drm/bridge: adv7511: Re-write the i2c address as it may have been lost

FromJohn Stultz <john.stultz@linaro.org>
Date2017-01-17 00:40 +0100
SubjectRe: [RFC][PATCH] drm/bridge: adv7511: Re-write the i2c address as it may have been lost
Message-ID<t0p2y-7EL-17@gated-at.bofh.it>
In reply to#1560161
On Mon, Jan 16, 2017 at 3:36 PM, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> Hi John,
>
> Thank you for the patch.
>
> On Monday 16 Jan 2017 15:16:51 John Stultz wrote:
>> Laurent: Would something like the following be preferred? Seems
>> to work as well for me..
>
> That looks good to me. Feel free to still de-duplicate the power on/off code
> if you want (but of course without adding the regcache_sync to the common
> power on function this time).

Ok.  Will do that. Thanks again for the feedback/direction here!

>> @@ -576,6 +578,9 @@ static int adv7511_get_modes(struct adv7511 *adv7511,
>>                                    ADV7511_INT1_DDC_ERROR);
>>               }
>>               adv7511->current_edid_segment = -1;
>> +
>> +             /* Reset the EDID_I2C_ADDR register as it may have been
> cleared */
>> +             regmap_write(adv7511->regmap, ADV7511_REG_EDID_I2C_ADDR,
> edid_i2c_addr);
>
> As powering the device off called regcache_mark_dirty(), this will perform an
> I2C write and cache the value. If we then try to read the EDID a second time
> without going through a full power on/off sequence, I believe that regmap will
> skip the write the second time, as the cache will contain the same value and
> won't be marked as dirty. Should we call regcache_mark_dirty() when powering
> the device down further down this function ?

Ah. Right. I had this in my earlier attempt, but thought I was
simplifying things here. I'll correct this in the next revision.

Thanks again!
-john

[toc] | [prev] | [next] | [standalone]


#1560167 — Re: [RFC][PATCH] drm/bridge: adv7511: Re-write the i2c address as it may have been lost

FromLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Date2017-01-17 00:40 +0100
SubjectRe: [RFC][PATCH] drm/bridge: adv7511: Re-write the i2c address as it may have been lost
Message-ID<t0p2y-7EL-9@gated-at.bofh.it>
In reply to#1560161
Hi John,

Thank you for the patch.

On Monday 16 Jan 2017 15:16:51 John Stultz wrote:
> Laurent: Would something like the following be preferred? Seems
> to work as well for me..

That looks good to me. Feel free to still de-duplicate the power on/off code 
if you want (but of course without adding the regcache_sync to the common 
power on function this time).

Please see below for an additional comment.

> I've found that by just turning the chip on and off via the
> POWER_DOWN register, I end up getting i2c_transfer errors on
> HiKey.
> 
> Investigating further, it seems some of the register state in
> the regmap cache is somehow getting lost, likely as the device
> registers were reset during power off.
> 
> Thus this patch simply re-writes the i2c address to the
> ADV7511_REG_EDID_I2C_ADDR register to ensure its properly set
> before we try to read the EDID data.
> 
> Cc: David Airlie <airlied@linux.ie>
> Cc: Archit Taneja <architt@codeaurora.org>
> Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Cc: Lars-Peter Clausen <lars@metafoo.de>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: dri-devel@lists.freedesktop.org
> Signed-off-by: John Stultz <john.stultz@linaro.org>
> ---
>  drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c index 405e460..32c59cb
> 100644
> --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> @@ -567,6 +567,8 @@ static int adv7511_get_modes(struct adv7511 *adv7511,
> 
>  	/* Reading the EDID only works if the device is powered */
>  	if (!adv7511->powered) {
> +		unsigned int edid_i2c_addr = (adv7511->i2c_main->addr << 1) + 
4;
> +
>  		regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER,
>  				   ADV7511_POWER_POWER_DOWN, 0);
>  		if (adv7511->i2c_main->irq) {
> @@ -576,6 +578,9 @@ static int adv7511_get_modes(struct adv7511 *adv7511,
>  				     ADV7511_INT1_DDC_ERROR);
>  		}
>  		adv7511->current_edid_segment = -1;
> +
> +		/* Reset the EDID_I2C_ADDR register as it may have been 
cleared */
> +		regmap_write(adv7511->regmap, ADV7511_REG_EDID_I2C_ADDR, 
edid_i2c_addr);

As powering the device off called regcache_mark_dirty(), this will perform an 
I2C write and cache the value. If we then try to read the EDID a second time 
without going through a full power on/off sequence, I believe that regmap will 
skip the write the second time, as the cache will contain the same value and 
won't be marked as dirty. Should we call regcache_mark_dirty() when powering 
the device down further down this function ?

>  	}
> 
>  	edid = drm_do_get_edid(connector, adv7511_get_edid_block, adv7511);

-- 
Regards,

Laurent Pinchart

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web