diff mbox series

[v4,16/27] drm/panel: panel-simple: Get rid of hacky HPD chicken-and-egg code

Message ID 20210416153909.v4.16.I40eeedc23459d1e3fc96fa6cdad775d88c6e706c@changeid
State Superseded
Headers show
Series drm: Fix EDID reading on ti-sn65dsi86; solve some chicken-and-egg problems | expand

Commit Message

Doug Anderson April 16, 2021, 10:39 p.m. UTC
When I added support for the hpd-gpio to simple-panel in commit
48834e6084f1 ("drm/panel-simple: Support hpd-gpios for delaying
prepare()"), I added a special case to handle a circular dependency I
was running into on the ti-sn65dsi86 bridge chip. On my board the
hpd-gpio is actually provided by the bridge chip. That was causing
some circular dependency problems that I had to work around by getting
the hpd-gpio late.

I've now reorganized the ti-sn65dsi86 bridge chip driver to be a
collection of sub-drivers. Now the GPIO part can probe separately and
that breaks the chain. Let's get rid of the old code to clean things
up.

Signed-off-by: Douglas Anderson <dianders@chromium.org>
---

(no changes since v1)

 drivers/gpu/drm/panel/panel-simple.c | 24 +++++-------------------
 1 file changed, 5 insertions(+), 19 deletions(-)

Comments

Bjorn Andersson April 23, 2021, 2:50 p.m. UTC | #1
On Fri 16 Apr 17:39 CDT 2021, Douglas Anderson wrote:

> When I added support for the hpd-gpio to simple-panel in commit

> 48834e6084f1 ("drm/panel-simple: Support hpd-gpios for delaying

> prepare()"), I added a special case to handle a circular dependency I

> was running into on the ti-sn65dsi86 bridge chip. On my board the

> hpd-gpio is actually provided by the bridge chip. That was causing

> some circular dependency problems that I had to work around by getting

> the hpd-gpio late.

> 

> I've now reorganized the ti-sn65dsi86 bridge chip driver to be a

> collection of sub-drivers. Now the GPIO part can probe separately and

> that breaks the chain. Let's get rid of the old code to clean things

> up.

> 


Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>


Regards,
Bjorn

> Signed-off-by: Douglas Anderson <dianders@chromium.org>

> ---

> 

> (no changes since v1)

> 

>  drivers/gpu/drm/panel/panel-simple.c | 24 +++++-------------------

>  1 file changed, 5 insertions(+), 19 deletions(-)

> 

> diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c

> index 6b22872b3281..90a17ca79d06 100644

> --- a/drivers/gpu/drm/panel/panel-simple.c

> +++ b/drivers/gpu/drm/panel/panel-simple.c

> @@ -366,8 +366,7 @@ static int panel_simple_unprepare(struct drm_panel *panel)

>  	return 0;

>  }

>  

> -static int panel_simple_get_hpd_gpio(struct device *dev,

> -				     struct panel_simple *p, bool from_probe)

> +static int panel_simple_get_hpd_gpio(struct device *dev, struct panel_simple *p)

>  {

>  	int err;

>  

> @@ -375,17 +374,10 @@ static int panel_simple_get_hpd_gpio(struct device *dev,

>  	if (IS_ERR(p->hpd_gpio)) {

>  		err = PTR_ERR(p->hpd_gpio);

>  

> -		/*

> -		 * If we're called from probe we won't consider '-EPROBE_DEFER'

> -		 * to be an error--we'll leave the error code in "hpd_gpio".

> -		 * When we try to use it we'll try again.  This allows for

> -		 * circular dependencies where the component providing the

> -		 * hpd gpio needs the panel to init before probing.

> -		 */

> -		if (err != -EPROBE_DEFER || !from_probe) {

> +		if (err != -EPROBE_DEFER)

>  			dev_err(dev, "failed to get 'hpd' GPIO: %d\n", err);

> -			return err;

> -		}

> +

> +		return err;

>  	}

>  

>  	return 0;

> @@ -416,12 +408,6 @@ static int panel_simple_prepare_once(struct panel_simple *p)

>  		msleep(delay);

>  

>  	if (p->hpd_gpio) {

> -		if (IS_ERR(p->hpd_gpio)) {

> -			err = panel_simple_get_hpd_gpio(dev, p, false);

> -			if (err)

> -				goto error;

> -		}

> -

>  		if (p->desc->delay.hpd_absent_delay)

>  			hpd_wait_us = p->desc->delay.hpd_absent_delay * 1000UL;

>  		else

> @@ -682,7 +668,7 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc)

>  

>  	panel->no_hpd = of_property_read_bool(dev->of_node, "no-hpd");

>  	if (!panel->no_hpd) {

> -		err = panel_simple_get_hpd_gpio(dev, panel, true);

> +		err = panel_simple_get_hpd_gpio(dev, panel);

>  		if (err)

>  			return err;

>  	}

> -- 

> 2.31.1.368.gbe11c130af-goog

>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c
index 6b22872b3281..90a17ca79d06 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -366,8 +366,7 @@  static int panel_simple_unprepare(struct drm_panel *panel)
 	return 0;
 }
 
-static int panel_simple_get_hpd_gpio(struct device *dev,
-				     struct panel_simple *p, bool from_probe)
+static int panel_simple_get_hpd_gpio(struct device *dev, struct panel_simple *p)
 {
 	int err;
 
@@ -375,17 +374,10 @@  static int panel_simple_get_hpd_gpio(struct device *dev,
 	if (IS_ERR(p->hpd_gpio)) {
 		err = PTR_ERR(p->hpd_gpio);
 
-		/*
-		 * If we're called from probe we won't consider '-EPROBE_DEFER'
-		 * to be an error--we'll leave the error code in "hpd_gpio".
-		 * When we try to use it we'll try again.  This allows for
-		 * circular dependencies where the component providing the
-		 * hpd gpio needs the panel to init before probing.
-		 */
-		if (err != -EPROBE_DEFER || !from_probe) {
+		if (err != -EPROBE_DEFER)
 			dev_err(dev, "failed to get 'hpd' GPIO: %d\n", err);
-			return err;
-		}
+
+		return err;
 	}
 
 	return 0;
@@ -416,12 +408,6 @@  static int panel_simple_prepare_once(struct panel_simple *p)
 		msleep(delay);
 
 	if (p->hpd_gpio) {
-		if (IS_ERR(p->hpd_gpio)) {
-			err = panel_simple_get_hpd_gpio(dev, p, false);
-			if (err)
-				goto error;
-		}
-
 		if (p->desc->delay.hpd_absent_delay)
 			hpd_wait_us = p->desc->delay.hpd_absent_delay * 1000UL;
 		else
@@ -682,7 +668,7 @@  static int panel_simple_probe(struct device *dev, const struct panel_desc *desc)
 
 	panel->no_hpd = of_property_read_bool(dev->of_node, "no-hpd");
 	if (!panel->no_hpd) {
-		err = panel_simple_get_hpd_gpio(dev, panel, true);
+		err = panel_simple_get_hpd_gpio(dev, panel);
 		if (err)
 			return err;
 	}