drm/i915/fbdev: Actually configure untiled displays

Submitted by Chris Wilson on Feb. 15, 2019, 12:30 p.m.

Details

Message ID 20190215123019.32283-1-chris@chris-wilson.co.uk
State Accepted
Commit d179b88deb3bf6fed4991a31fd6f0f2cad21fab5
Headers show
Series "drm/i915/fbdev: Actually configure untiled displays" ( rev: 1 ) in Intel GFX

Not browsing as part of any series.

Commit Message

Chris Wilson Feb. 15, 2019, 12:30 p.m.
If we skipped all the connectors that were not part of a tile, we would
leave conn_seq=0 and conn_configured=0, convincing ourselves that we
had stagnated in our configuration attempts. Avoid this situation by
starting conn_seq=ALL_CONNECTORS, and repeating until we find no more
connectors to configure.

Fixes: 754a76591b12 ("drm/i915/fbdev: Stop repeating tile configuration on stagnation")
Reported-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_fbdev.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
index 376ffe842e26..e8f694b57b8a 100644
--- a/drivers/gpu/drm/i915/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/intel_fbdev.c
@@ -338,8 +338,8 @@  static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
 				    bool *enabled, int width, int height)
 {
 	struct drm_i915_private *dev_priv = to_i915(fb_helper->dev);
-	unsigned long conn_configured, conn_seq, mask;
 	unsigned int count = min(fb_helper->connector_count, BITS_PER_LONG);
+	unsigned long conn_configured, conn_seq;
 	int i, j;
 	bool *save_enabled;
 	bool fallback = true, ret = true;
@@ -357,10 +357,9 @@  static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
 		drm_modeset_backoff(&ctx);
 
 	memcpy(save_enabled, enabled, count);
-	mask = GENMASK(count - 1, 0);
+	conn_seq = GENMASK(count - 1, 0);
 	conn_configured = 0;
 retry:
-	conn_seq = conn_configured;
 	for (i = 0; i < count; i++) {
 		struct drm_fb_helper_connector *fb_conn;
 		struct drm_connector *connector;
@@ -373,7 +372,8 @@  static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
 		if (conn_configured & BIT(i))
 			continue;
 
-		if (conn_seq == 0 && !connector->has_tile)
+		/* First pass, only consider tiled connectors */
+		if (conn_seq == GENMASK(count - 1, 0) && !connector->has_tile)
 			continue;
 
 		if (connector->status == connector_status_connected)
@@ -477,8 +477,10 @@  static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
 		conn_configured |= BIT(i);
 	}
 
-	if ((conn_configured & mask) != mask && conn_configured != conn_seq)
+	if (conn_configured != conn_seq) { /* repeat until no more are found */
+		conn_seq = conn_configured;
 		goto retry;
+	}
 
 	/*
 	 * If the BIOS didn't enable everything it could, fall back to have the

Comments

Op 15-02-2019 om 13:30 schreef Chris Wilson:
> If we skipped all the connectors that were not part of a tile, we would
> leave conn_seq=0 and conn_configured=0, convincing ourselves that we
> had stagnated in our configuration attempts. Avoid this situation by
> starting conn_seq=ALL_CONNECTORS, and repeating until we find no more
> connectors to configure.
>
> Fixes: 754a76591b12 ("drm/i915/fbdev: Stop repeating tile configuration on stagnation")
> Reported-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/intel_fbdev.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
> index 376ffe842e26..e8f694b57b8a 100644
> --- a/drivers/gpu/drm/i915/intel_fbdev.c
> +++ b/drivers/gpu/drm/i915/intel_fbdev.c
> @@ -338,8 +338,8 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
>  				    bool *enabled, int width, int height)
>  {
>  	struct drm_i915_private *dev_priv = to_i915(fb_helper->dev);
> -	unsigned long conn_configured, conn_seq, mask;
>  	unsigned int count = min(fb_helper->connector_count, BITS_PER_LONG);
> +	unsigned long conn_configured, conn_seq;
>  	int i, j;
>  	bool *save_enabled;
>  	bool fallback = true, ret = true;
> @@ -357,10 +357,9 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
>  		drm_modeset_backoff(&ctx);
>  
>  	memcpy(save_enabled, enabled, count);
> -	mask = GENMASK(count - 1, 0);
> +	conn_seq = GENMASK(count - 1, 0);
>  	conn_configured = 0;
>  retry:
> -	conn_seq = conn_configured;
>  	for (i = 0; i < count; i++) {
>  		struct drm_fb_helper_connector *fb_conn;
>  		struct drm_connector *connector;
> @@ -373,7 +372,8 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
>  		if (conn_configured & BIT(i))
>  			continue;
>  
> -		if (conn_seq == 0 && !connector->has_tile)
> +		/* First pass, only consider tiled connectors */
> +		if (conn_seq == GENMASK(count - 1, 0) && !connector->has_tile)
>  			continue;
>  
>  		if (connector->status == connector_status_connected)
> @@ -477,8 +477,10 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
>  		conn_configured |= BIT(i);
>  	}
>  
> -	if ((conn_configured & mask) != mask && conn_configured != conn_seq)
> +	if (conn_configured != conn_seq) { /* repeat until no more are found */
> +		conn_seq = conn_configured;
>  		goto retry;
> +	}
>  
>  	/*
>  	 * If the BIOS didn't enable everything it could, fall back to have the

Seems safer than the previous version.

We should really unloop this in a helper, but this is ok for now if BAT passes.

Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Op 15-02-2019 om 13:30 schreef Chris Wilson:
> If we skipped all the connectors that were not part of a tile, we would
> leave conn_seq=0 and conn_configured=0, convincing ourselves that we
> had stagnated in our configuration attempts. Avoid this situation by
> starting conn_seq=ALL_CONNECTORS, and repeating until we find no more
> connectors to configure.
>
> Fixes: 754a76591b12 ("drm/i915/fbdev: Stop repeating tile configuration on stagnation")
> Reported-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/intel_fbdev.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
> index 376ffe842e26..e8f694b57b8a 100644
> --- a/drivers/gpu/drm/i915/intel_fbdev.c
> +++ b/drivers/gpu/drm/i915/intel_fbdev.c
> @@ -338,8 +338,8 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
>  				    bool *enabled, int width, int height)
>  {
>  	struct drm_i915_private *dev_priv = to_i915(fb_helper->dev);
> -	unsigned long conn_configured, conn_seq, mask;
>  	unsigned int count = min(fb_helper->connector_count, BITS_PER_LONG);
> +	unsigned long conn_configured, conn_seq;
>  	int i, j;
>  	bool *save_enabled;
>  	bool fallback = true, ret = true;
> @@ -357,10 +357,9 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
>  		drm_modeset_backoff(&ctx);
>  
>  	memcpy(save_enabled, enabled, count);
> -	mask = GENMASK(count - 1, 0);
> +	conn_seq = GENMASK(count - 1, 0);
>  	conn_configured = 0;
>  retry:
> -	conn_seq = conn_configured;
>  	for (i = 0; i < count; i++) {
>  		struct drm_fb_helper_connector *fb_conn;
>  		struct drm_connector *connector;
> @@ -373,7 +372,8 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
>  		if (conn_configured & BIT(i))
>  			continue;
>  
> -		if (conn_seq == 0 && !connector->has_tile)
> +		/* First pass, only consider tiled connectors */
> +		if (conn_seq == GENMASK(count - 1, 0) && !connector->has_tile)
>  			continue;
>  
>  		if (connector->status == connector_status_connected)
> @@ -477,8 +477,10 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
>  		conn_configured |= BIT(i);
>  	}
>  
> -	if ((conn_configured & mask) != mask && conn_configured != conn_seq)
> +	if (conn_configured != conn_seq) { /* repeat until no more are found */
> +		conn_seq = conn_configured;
>  		goto retry;
> +	}
>  
>  	/*
>  	 * If the BIOS didn't enable everything it could, fall back to have the

Also Cc: <stable@vger.kernel.org> # v3.19+ , because it fixes a previous stable fix?
Quoting Maarten Lankhorst (2019-02-15 16:02:40)
> Op 15-02-2019 om 13:30 schreef Chris Wilson:
> > If we skipped all the connectors that were not part of a tile, we would
> > leave conn_seq=0 and conn_configured=0, convincing ourselves that we
> > had stagnated in our configuration attempts. Avoid this situation by
> > starting conn_seq=ALL_CONNECTORS, and repeating until we find no more
> > connectors to configure.
> >
> > Fixes: 754a76591b12 ("drm/i915/fbdev: Stop repeating tile configuration on stagnation")
> > Reported-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> > ---
> >  drivers/gpu/drm/i915/intel_fbdev.c | 12 +++++++-----
> >  1 file changed, 7 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
> > index 376ffe842e26..e8f694b57b8a 100644
> > --- a/drivers/gpu/drm/i915/intel_fbdev.c
> > +++ b/drivers/gpu/drm/i915/intel_fbdev.c
> > @@ -338,8 +338,8 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
> >                                   bool *enabled, int width, int height)
> >  {
> >       struct drm_i915_private *dev_priv = to_i915(fb_helper->dev);
> > -     unsigned long conn_configured, conn_seq, mask;
> >       unsigned int count = min(fb_helper->connector_count, BITS_PER_LONG);
> > +     unsigned long conn_configured, conn_seq;
> >       int i, j;
> >       bool *save_enabled;
> >       bool fallback = true, ret = true;
> > @@ -357,10 +357,9 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
> >               drm_modeset_backoff(&ctx);
> >  
> >       memcpy(save_enabled, enabled, count);
> > -     mask = GENMASK(count - 1, 0);
> > +     conn_seq = GENMASK(count - 1, 0);
> >       conn_configured = 0;
> >  retry:
> > -     conn_seq = conn_configured;
> >       for (i = 0; i < count; i++) {
> >               struct drm_fb_helper_connector *fb_conn;
> >               struct drm_connector *connector;
> > @@ -373,7 +372,8 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
> >               if (conn_configured & BIT(i))
> >                       continue;
> >  
> > -             if (conn_seq == 0 && !connector->has_tile)
> > +             /* First pass, only consider tiled connectors */
> > +             if (conn_seq == GENMASK(count - 1, 0) && !connector->has_tile)
> >                       continue;
> >  
> >               if (connector->status == connector_status_connected)
> > @@ -477,8 +477,10 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
> >               conn_configured |= BIT(i);
> >       }
> >  
> > -     if ((conn_configured & mask) != mask && conn_configured != conn_seq)
> > +     if (conn_configured != conn_seq) { /* repeat until no more are found */
> > +             conn_seq = conn_configured;
> >               goto retry;
> > +     }
> >  
> >       /*
> >        * If the BIOS didn't enable everything it could, fall back to have the
> 
> Also Cc: <stable@vger.kernel.org> # v3.19+ , because it fixes a previous stable fix?

I put the fixes there, the rest I leave to maintainers and AUTOSEL :-p
-Chris
Quoting Chris Wilson (2019-02-15 16:06:59)
> Quoting Maarten Lankhorst (2019-02-15 16:02:40)
> > Op 15-02-2019 om 13:30 schreef Chris Wilson:
> > > If we skipped all the connectors that were not part of a tile, we would
> > > leave conn_seq=0 and conn_configured=0, convincing ourselves that we
> > > had stagnated in our configuration attempts. Avoid this situation by
> > > starting conn_seq=ALL_CONNECTORS, and repeating until we find no more
> > > connectors to configure.
> > >
> > > Fixes: 754a76591b12 ("drm/i915/fbdev: Stop repeating tile configuration on stagnation")
> > > Reported-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> > > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > > Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> > > ---
> > >  drivers/gpu/drm/i915/intel_fbdev.c | 12 +++++++-----
> > >  1 file changed, 7 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
> > > index 376ffe842e26..e8f694b57b8a 100644
> > > --- a/drivers/gpu/drm/i915/intel_fbdev.c
> > > +++ b/drivers/gpu/drm/i915/intel_fbdev.c
> > > @@ -338,8 +338,8 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
> > >                                   bool *enabled, int width, int height)
> > >  {
> > >       struct drm_i915_private *dev_priv = to_i915(fb_helper->dev);
> > > -     unsigned long conn_configured, conn_seq, mask;
> > >       unsigned int count = min(fb_helper->connector_count, BITS_PER_LONG);
> > > +     unsigned long conn_configured, conn_seq;
> > >       int i, j;
> > >       bool *save_enabled;
> > >       bool fallback = true, ret = true;
> > > @@ -357,10 +357,9 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
> > >               drm_modeset_backoff(&ctx);
> > >  
> > >       memcpy(save_enabled, enabled, count);
> > > -     mask = GENMASK(count - 1, 0);
> > > +     conn_seq = GENMASK(count - 1, 0);
> > >       conn_configured = 0;
> > >  retry:
> > > -     conn_seq = conn_configured;
> > >       for (i = 0; i < count; i++) {
> > >               struct drm_fb_helper_connector *fb_conn;
> > >               struct drm_connector *connector;
> > > @@ -373,7 +372,8 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
> > >               if (conn_configured & BIT(i))
> > >                       continue;
> > >  
> > > -             if (conn_seq == 0 && !connector->has_tile)
> > > +             /* First pass, only consider tiled connectors */
> > > +             if (conn_seq == GENMASK(count - 1, 0) && !connector->has_tile)
> > >                       continue;
> > >  
> > >               if (connector->status == connector_status_connected)
> > > @@ -477,8 +477,10 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
> > >               conn_configured |= BIT(i);
> > >       }
> > >  
> > > -     if ((conn_configured & mask) != mask && conn_configured != conn_seq)
> > > +     if (conn_configured != conn_seq) { /* repeat until no more are found */
> > > +             conn_seq = conn_configured;
> > >               goto retry;
> > > +     }
> > >  
> > >       /*
> > >        * If the BIOS didn't enable everything it could, fall back to have the
> > 
> > Also Cc: <stable@vger.kernel.org> # v3.19+ , because it fixes a previous stable fix?
> 
> I put the fixes there, the rest I leave to maintainers and AUTOSEL :-p

Pushed with cc:stable. Thanks for spotting it,
-Chris