diff mbox series

[1/2] drm/bridge/lontium-lt9611uxc: fix waiting for EDID to become available

Message ID 20201127092316.122246-1-dmitry.baryshkov@linaro.org
State New
Headers show
Series [1/2] drm/bridge/lontium-lt9611uxc: fix waiting for EDID to become available | expand

Commit Message

Dmitry Baryshkov Nov. 27, 2020, 9:23 a.m. UTC
- Call wake_up() when EDID ready event is received to wake
  wait_event_interruptible_timeout()

- Increase waiting timeout, reading EDID can take longer than 100ms, so
  let's be on a safe side.

- Return NULL pointer from get_edid() callback rather than ERR_PTR()
  pointer, as DRM code does NULL checks rather than IS_ERR().

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

---
 drivers/gpu/drm/bridge/lontium-lt9611uxc.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

-- 
2.29.2

Comments

Dmitry Baryshkov Jan. 5, 2021, 5:20 p.m. UTC | #1
Gracious ping for these two patches

On Fri, 27 Nov 2020 at 12:23, Dmitry Baryshkov
<dmitry.baryshkov@linaro.org> wrote:
>

> - Call wake_up() when EDID ready event is received to wake

>   wait_event_interruptible_timeout()

>

> - Increase waiting timeout, reading EDID can take longer than 100ms, so

>   let's be on a safe side.

>

> - Return NULL pointer from get_edid() callback rather than ERR_PTR()

>   pointer, as DRM code does NULL checks rather than IS_ERR().

>

> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

> ---

>  drivers/gpu/drm/bridge/lontium-lt9611uxc.c | 11 ++++++++---

>  1 file changed, 8 insertions(+), 3 deletions(-)

>

> diff --git a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c

> index 0c98d27f84ac..b708700e182d 100644

> --- a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c

> +++ b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c

> @@ -145,8 +145,10 @@ static irqreturn_t lt9611uxc_irq_thread_handler(int irq, void *dev_id)

>

>         lt9611uxc_unlock(lt9611uxc);

>

> -       if (irq_status & BIT(0))

> +       if (irq_status & BIT(0)) {

>                 lt9611uxc->edid_read = !!(hpd_status & BIT(0));

> +               wake_up_all(&lt9611uxc->wq);

> +       }

>

>         if (irq_status & BIT(1)) {

>                 if (lt9611uxc->connector.dev)

> @@ -465,7 +467,7 @@ static enum drm_connector_status lt9611uxc_bridge_detect(struct drm_bridge *brid

>  static int lt9611uxc_wait_for_edid(struct lt9611uxc *lt9611uxc)

>  {

>         return wait_event_interruptible_timeout(lt9611uxc->wq, lt9611uxc->edid_read,

> -                       msecs_to_jiffies(100));

> +                       msecs_to_jiffies(500));

>  }

>

>  static int lt9611uxc_get_edid_block(void *data, u8 *buf, unsigned int block, size_t len)

> @@ -503,7 +505,10 @@ static struct edid *lt9611uxc_bridge_get_edid(struct drm_bridge *bridge,

>         ret = lt9611uxc_wait_for_edid(lt9611uxc);

>         if (ret < 0) {

>                 dev_err(lt9611uxc->dev, "wait for EDID failed: %d\n", ret);

> -               return ERR_PTR(ret);

> +               return NULL;

> +       } else if (ret == 0) {

> +               dev_err(lt9611uxc->dev, "wait for EDID timeout\n");

> +               return NULL;

>         }

>

>         return drm_do_get_edid(connector, lt9611uxc_get_edid_block, lt9611uxc);

> --

> 2.29.2

>



-- 
With best wishes
Dmitry
Laurent Pinchart Jan. 14, 2021, 6:14 a.m. UTC | #2
Hi Dmitry,

On Tue, Jan 05, 2021 at 08:20:39PM +0300, Dmitry Baryshkov wrote:
> Gracious ping for these two patches

I'm afraid I have very little time for DRM bridge maintenance at the
moment :-S Judging by the lack of replies, it seems the other
maintainers are also AWOL. We seem to have a shortage of maintainers for
this part of the subsystem.

> On Fri, 27 Nov 2020 at 12:23, Dmitry Baryshkov wrote:
> >
> > - Call wake_up() when EDID ready event is received to wake
> >   wait_event_interruptible_timeout()
> >
> > - Increase waiting timeout, reading EDID can take longer than 100ms, so
> >   let's be on a safe side.
> >
> > - Return NULL pointer from get_edid() callback rather than ERR_PTR()
> >   pointer, as DRM code does NULL checks rather than IS_ERR().
> >
> > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> > ---
> >  drivers/gpu/drm/bridge/lontium-lt9611uxc.c | 11 ++++++++---
> >  1 file changed, 8 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c
> > index 0c98d27f84ac..b708700e182d 100644
> > --- a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c
> > +++ b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c
> > @@ -145,8 +145,10 @@ static irqreturn_t lt9611uxc_irq_thread_handler(int irq, void *dev_id)
> >
> >         lt9611uxc_unlock(lt9611uxc);
> >
> > -       if (irq_status & BIT(0))
> > +       if (irq_status & BIT(0)) {
> >                 lt9611uxc->edid_read = !!(hpd_status & BIT(0));
> > +               wake_up_all(&lt9611uxc->wq);
> > +       }
> >
> >         if (irq_status & BIT(1)) {
> >                 if (lt9611uxc->connector.dev)
> > @@ -465,7 +467,7 @@ static enum drm_connector_status lt9611uxc_bridge_detect(struct drm_bridge *brid
> >  static int lt9611uxc_wait_for_edid(struct lt9611uxc *lt9611uxc)
> >  {
> >         return wait_event_interruptible_timeout(lt9611uxc->wq, lt9611uxc->edid_read,
> > -                       msecs_to_jiffies(100));
> > +                       msecs_to_jiffies(500));
> >  }
> >
> >  static int lt9611uxc_get_edid_block(void *data, u8 *buf, unsigned int block, size_t len)
> > @@ -503,7 +505,10 @@ static struct edid *lt9611uxc_bridge_get_edid(struct drm_bridge *bridge,
> >         ret = lt9611uxc_wait_for_edid(lt9611uxc);
> >         if (ret < 0) {
> >                 dev_err(lt9611uxc->dev, "wait for EDID failed: %d\n", ret);
> > -               return ERR_PTR(ret);
> > +               return NULL;
> > +       } else if (ret == 0) {
> > +               dev_err(lt9611uxc->dev, "wait for EDID timeout\n");
> > +               return NULL;
> >         }
> >
> >         return drm_do_get_edid(connector, lt9611uxc_get_edid_block, lt9611uxc);
Bjorn Andersson Jan. 15, 2021, 3:49 a.m. UTC | #3
On Fri 27 Nov 03:23 CST 2020, Dmitry Baryshkov wrote:

> - Call wake_up() when EDID ready event is received to wake

>   wait_event_interruptible_timeout()

> 

> - Increase waiting timeout, reading EDID can take longer than 100ms, so

>   let's be on a safe side.

> 

> - Return NULL pointer from get_edid() callback rather than ERR_PTR()

>   pointer, as DRM code does NULL checks rather than IS_ERR().

> 

> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

> ---

>  drivers/gpu/drm/bridge/lontium-lt9611uxc.c | 11 ++++++++---

>  1 file changed, 8 insertions(+), 3 deletions(-)

> 

> diff --git a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c

> index 0c98d27f84ac..b708700e182d 100644

> --- a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c

> +++ b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c

> @@ -145,8 +145,10 @@ static irqreturn_t lt9611uxc_irq_thread_handler(int irq, void *dev_id)

>  

>  	lt9611uxc_unlock(lt9611uxc);

>  

> -	if (irq_status & BIT(0))

> +	if (irq_status & BIT(0)) {

>  		lt9611uxc->edid_read = !!(hpd_status & BIT(0));

> +		wake_up_all(&lt9611uxc->wq);


This seems like a really good idea :)

> +	}

>  

>  	if (irq_status & BIT(1)) {

>  		if (lt9611uxc->connector.dev)

> @@ -465,7 +467,7 @@ static enum drm_connector_status lt9611uxc_bridge_detect(struct drm_bridge *brid

>  static int lt9611uxc_wait_for_edid(struct lt9611uxc *lt9611uxc)

>  {

>  	return wait_event_interruptible_timeout(lt9611uxc->wq, lt9611uxc->edid_read,

> -			msecs_to_jiffies(100));

> +			msecs_to_jiffies(500));

>  }

>  

>  static int lt9611uxc_get_edid_block(void *data, u8 *buf, unsigned int block, size_t len)

> @@ -503,7 +505,10 @@ static struct edid *lt9611uxc_bridge_get_edid(struct drm_bridge *bridge,

>  	ret = lt9611uxc_wait_for_edid(lt9611uxc);

>  	if (ret < 0) {

>  		dev_err(lt9611uxc->dev, "wait for EDID failed: %d\n", ret);

> -		return ERR_PTR(ret);

> +		return NULL;

> +	} else if (ret == 0) {

> +		dev_err(lt9611uxc->dev, "wait for EDID timeout\n");

> +		return NULL;


This looks like it should be a separate patch.

Regards,
Bjorn

>  	}

>  

>  	return drm_do_get_edid(connector, lt9611uxc_get_edid_block, lt9611uxc);

> -- 

> 2.29.2

>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c
index 0c98d27f84ac..b708700e182d 100644
--- a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c
+++ b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c
@@ -145,8 +145,10 @@  static irqreturn_t lt9611uxc_irq_thread_handler(int irq, void *dev_id)
 
 	lt9611uxc_unlock(lt9611uxc);
 
-	if (irq_status & BIT(0))
+	if (irq_status & BIT(0)) {
 		lt9611uxc->edid_read = !!(hpd_status & BIT(0));
+		wake_up_all(&lt9611uxc->wq);
+	}
 
 	if (irq_status & BIT(1)) {
 		if (lt9611uxc->connector.dev)
@@ -465,7 +467,7 @@  static enum drm_connector_status lt9611uxc_bridge_detect(struct drm_bridge *brid
 static int lt9611uxc_wait_for_edid(struct lt9611uxc *lt9611uxc)
 {
 	return wait_event_interruptible_timeout(lt9611uxc->wq, lt9611uxc->edid_read,
-			msecs_to_jiffies(100));
+			msecs_to_jiffies(500));
 }
 
 static int lt9611uxc_get_edid_block(void *data, u8 *buf, unsigned int block, size_t len)
@@ -503,7 +505,10 @@  static struct edid *lt9611uxc_bridge_get_edid(struct drm_bridge *bridge,
 	ret = lt9611uxc_wait_for_edid(lt9611uxc);
 	if (ret < 0) {
 		dev_err(lt9611uxc->dev, "wait for EDID failed: %d\n", ret);
-		return ERR_PTR(ret);
+		return NULL;
+	} else if (ret == 0) {
+		dev_err(lt9611uxc->dev, "wait for EDID timeout\n");
+		return NULL;
 	}
 
 	return drm_do_get_edid(connector, lt9611uxc_get_edid_block, lt9611uxc);