[v2,9/9] drm/i915: Stop using connector->encoder and encoder->crtc links in i915_display_info
diff mbox series

Message ID 20191129185434.25549-10-ville.syrjala@linux.intel.com
State New
Headers show
Series
  • drm/i915: i915_display_info cleanup
Related show

Commit Message

Ville Syrjälä Nov. 29, 2019, 6:54 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Migrate away from the legacy encoder->crtc and connector->encoder links
in the debugfs display_info code. Other users still remain so can't kill
these off yet.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/display/intel_display.h |  7 ++++
 drivers/gpu/drm/i915/i915_debugfs.c          | 43 ++++++++++++--------
 2 files changed, 34 insertions(+), 16 deletions(-)

Comments

Ramalingam C Dec. 2, 2019, 3:40 p.m. UTC | #1
On 2019-11-29 at 20:54:34 +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Migrate away from the legacy encoder->crtc and connector->encoder links
> in the debugfs display_info code. Other users still remain so can't kill
> these off yet.
May be I missed why we want to kill encoder->crtc and conn->encoder.
If you dont mind please explain the reasoning.

Apart from that the implementation looks good to me.

Reviewed-by: Ramalingam C <ramalingam.c@intel.com>
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_display.h |  7 ++++
>  drivers/gpu/drm/i915/i915_debugfs.c          | 43 ++++++++++++--------
>  2 files changed, 34 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_display.h b/drivers/gpu/drm/i915/display/intel_display.h
> index a5ec5eeff056..5ed716a986ad 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.h
> +++ b/drivers/gpu/drm/i915/display/intel_display.h
> @@ -380,6 +380,13 @@ enum phy_fia {
>  			    &(dev)->mode_config.encoder_list,	\
>  			    base.head)
>  
> +#define for_each_intel_encoder_mask(dev, intel_encoder, encoder_mask)	\
> +	list_for_each_entry(intel_encoder,				\
> +			    &(dev)->mode_config.encoder_list,		\
> +			    base.head)					\
> +		for_each_if((encoder_mask) &				\
> +			    drm_encoder_mask(&intel_encoder->base))
> +
>  #define for_each_intel_dp(dev, intel_encoder)			\
>  	for_each_intel_encoder(dev, intel_encoder)		\
>  		for_each_if(intel_encoder_is_dp(intel_encoder))
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index 414da0a542d6..eb80a2c4b55b 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -2382,15 +2382,24 @@ static void intel_encoder_info(struct seq_file *m,
>  			       struct intel_encoder *encoder)
>  {
>  	struct drm_i915_private *dev_priv = node_to_i915(m->private);
> -	struct drm_device *dev = &dev_priv->drm;
> -	struct intel_connector *connector;
> +	struct drm_connector_list_iter conn_iter;
> +	struct drm_connector *connector;
>  
>  	seq_printf(m, "\t[ENCODER:%d:%s]: connectors:\n",
>  		   encoder->base.base.id, encoder->base.name);
>  
> -	for_each_connector_on_encoder(dev, &encoder->base, connector)
> +	drm_connector_list_iter_begin(&dev_priv->drm, &conn_iter);
> +	drm_for_each_connector_iter(connector, &conn_iter) {
> +		const struct drm_connector_state *conn_state =
> +			connector->state;
> +
> +		if (conn_state->best_encoder != &encoder->base)
> +			continue;
> +
>  		seq_printf(m, "\t\t[CONNECTOR:%d:%s]\n",
> -			   connector->base.base.id, connector->base.name);
> +			   connector->base.id, connector->name);
> +	}
> +	drm_connector_list_iter_end(&conn_iter);
>  }
>  
>  static void intel_panel_info(struct seq_file *m, struct intel_panel *panel)
> @@ -2475,8 +2484,10 @@ static void intel_connector_info(struct seq_file *m,
>  				 struct drm_connector *connector)
>  {
>  	struct intel_connector *intel_connector = to_intel_connector(connector);
> -	struct intel_encoder *intel_encoder = intel_connector->encoder;
> -	struct drm_display_mode *mode;
> +	const struct drm_connector_state *conn_state = connector->state;
> +	struct intel_encoder *encoder =
> +		to_intel_encoder(conn_state->best_encoder);
> +	const struct drm_display_mode *mode;
>  
>  	seq_printf(m, "[CONNECTOR:%d:%s]: status: %s\n",
>  		   connector->base.id, connector->name,
> @@ -2492,24 +2503,24 @@ static void intel_connector_info(struct seq_file *m,
>  		   drm_get_subpixel_order_name(connector->display_info.subpixel_order));
>  	seq_printf(m, "\tCEA rev: %d\n", connector->display_info.cea_rev);
>  
> -	if (!intel_encoder)
> +	if (!encoder)
>  		return;
>  
>  	switch (connector->connector_type) {
>  	case DRM_MODE_CONNECTOR_DisplayPort:
>  	case DRM_MODE_CONNECTOR_eDP:
> -		if (intel_encoder->type == INTEL_OUTPUT_DP_MST)
> +		if (encoder->type == INTEL_OUTPUT_DP_MST)
>  			intel_dp_mst_info(m, intel_connector);
>  		else
>  			intel_dp_info(m, intel_connector);
>  		break;
>  	case DRM_MODE_CONNECTOR_LVDS:
> -		if (intel_encoder->type == INTEL_OUTPUT_LVDS)
> +		if (encoder->type == INTEL_OUTPUT_LVDS)
>  			intel_lvds_info(m, intel_connector);
>  		break;
>  	case DRM_MODE_CONNECTOR_HDMIA:
> -		if (intel_encoder->type == INTEL_OUTPUT_HDMI ||
> -		    intel_encoder->type == INTEL_OUTPUT_DDI)
> +		if (encoder->type == INTEL_OUTPUT_HDMI ||
> +		    encoder->type == INTEL_OUTPUT_DDI)
>  			intel_hdmi_info(m, intel_connector);
>  		break;
>  	default:
> @@ -2653,6 +2664,7 @@ static void intel_crtc_info(struct seq_file *m, struct intel_crtc *crtc)
>  	struct drm_i915_private *dev_priv = node_to_i915(m->private);
>  	const struct intel_crtc_state *crtc_state =
>  		to_intel_crtc_state(crtc->base.state);
> +	struct intel_encoder *encoder;
>  
>  	seq_printf(m, "[CRTC:%d:%s]:\n",
>  		   crtc->base.base.id, crtc->base.name);
> @@ -2663,8 +2675,6 @@ static void intel_crtc_info(struct seq_file *m, struct intel_crtc *crtc)
>  		   DRM_MODE_ARG(&crtc_state->uapi.mode));
>  
>  	if (crtc_state->hw.enable) {
> -		struct intel_encoder *encoder;
> -
>  		seq_printf(m, "\thw: active=%s, adjusted_mode=" DRM_MODE_FMT "\n",
>  			   yesno(crtc_state->hw.active),
>  			   DRM_MODE_ARG(&crtc_state->hw.adjusted_mode));
> @@ -2673,12 +2683,13 @@ static void intel_crtc_info(struct seq_file *m, struct intel_crtc *crtc)
>  			   crtc_state->pipe_src_w, crtc_state->pipe_src_h,
>  			   yesno(crtc_state->dither), crtc_state->pipe_bpp);
>  
> -		for_each_encoder_on_crtc(&dev_priv->drm, &crtc->base, encoder)
> -			intel_encoder_info(m, crtc, encoder);
> -
>  		intel_scaler_info(m, crtc);
>  	}
>  
> +	for_each_intel_encoder_mask(&dev_priv->drm, encoder,
> +				    crtc_state->uapi.encoder_mask)
> +		intel_encoder_info(m, crtc, encoder);
> +
>  	intel_plane_info(m, crtc);
>  
>  	seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s\n",
> -- 
> 2.23.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Ville Syrjälä Dec. 2, 2019, 4:24 p.m. UTC | #2
On Mon, Dec 02, 2019 at 09:10:08PM +0530, Ramalingam C wrote:
> On 2019-11-29 at 20:54:34 +0200, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > Migrate away from the legacy encoder->crtc and connector->encoder links
> > in the debugfs display_info code. Other users still remain so can't kill
> > these off yet.
> May be I missed why we want to kill encoder->crtc and conn->encoder.
> If you dont mind please explain the reasoning.

They are pre-atomic legacy state. With atomic everything should be
tracked in crtc_state/etc. instead. These things are being updated
in the middle of commit_tail() so any use during atomic_check() must
already be considered a bug. So I want to eliminate them completely
mainly to stop people from using them in new code out of ignorance.
Fortunately it doesn't look like this will be as difficult as I
originally feared.

> 
> Apart from that the implementation looks good to me.
> 
> Reviewed-by: Ramalingam C <ramalingam.c@intel.com>
> > 
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/i915/display/intel_display.h |  7 ++++
> >  drivers/gpu/drm/i915/i915_debugfs.c          | 43 ++++++++++++--------
> >  2 files changed, 34 insertions(+), 16 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/display/intel_display.h b/drivers/gpu/drm/i915/display/intel_display.h
> > index a5ec5eeff056..5ed716a986ad 100644
> > --- a/drivers/gpu/drm/i915/display/intel_display.h
> > +++ b/drivers/gpu/drm/i915/display/intel_display.h
> > @@ -380,6 +380,13 @@ enum phy_fia {
> >  			    &(dev)->mode_config.encoder_list,	\
> >  			    base.head)
> >  
> > +#define for_each_intel_encoder_mask(dev, intel_encoder, encoder_mask)	\
> > +	list_for_each_entry(intel_encoder,				\
> > +			    &(dev)->mode_config.encoder_list,		\
> > +			    base.head)					\
> > +		for_each_if((encoder_mask) &				\
> > +			    drm_encoder_mask(&intel_encoder->base))
> > +
> >  #define for_each_intel_dp(dev, intel_encoder)			\
> >  	for_each_intel_encoder(dev, intel_encoder)		\
> >  		for_each_if(intel_encoder_is_dp(intel_encoder))
> > diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> > index 414da0a542d6..eb80a2c4b55b 100644
> > --- a/drivers/gpu/drm/i915/i915_debugfs.c
> > +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> > @@ -2382,15 +2382,24 @@ static void intel_encoder_info(struct seq_file *m,
> >  			       struct intel_encoder *encoder)
> >  {
> >  	struct drm_i915_private *dev_priv = node_to_i915(m->private);
> > -	struct drm_device *dev = &dev_priv->drm;
> > -	struct intel_connector *connector;
> > +	struct drm_connector_list_iter conn_iter;
> > +	struct drm_connector *connector;
> >  
> >  	seq_printf(m, "\t[ENCODER:%d:%s]: connectors:\n",
> >  		   encoder->base.base.id, encoder->base.name);
> >  
> > -	for_each_connector_on_encoder(dev, &encoder->base, connector)
> > +	drm_connector_list_iter_begin(&dev_priv->drm, &conn_iter);
> > +	drm_for_each_connector_iter(connector, &conn_iter) {
> > +		const struct drm_connector_state *conn_state =
> > +			connector->state;
> > +
> > +		if (conn_state->best_encoder != &encoder->base)
> > +			continue;
> > +
> >  		seq_printf(m, "\t\t[CONNECTOR:%d:%s]\n",
> > -			   connector->base.base.id, connector->base.name);
> > +			   connector->base.id, connector->name);
> > +	}
> > +	drm_connector_list_iter_end(&conn_iter);
> >  }
> >  
> >  static void intel_panel_info(struct seq_file *m, struct intel_panel *panel)
> > @@ -2475,8 +2484,10 @@ static void intel_connector_info(struct seq_file *m,
> >  				 struct drm_connector *connector)
> >  {
> >  	struct intel_connector *intel_connector = to_intel_connector(connector);
> > -	struct intel_encoder *intel_encoder = intel_connector->encoder;
> > -	struct drm_display_mode *mode;
> > +	const struct drm_connector_state *conn_state = connector->state;
> > +	struct intel_encoder *encoder =
> > +		to_intel_encoder(conn_state->best_encoder);
> > +	const struct drm_display_mode *mode;
> >  
> >  	seq_printf(m, "[CONNECTOR:%d:%s]: status: %s\n",
> >  		   connector->base.id, connector->name,
> > @@ -2492,24 +2503,24 @@ static void intel_connector_info(struct seq_file *m,
> >  		   drm_get_subpixel_order_name(connector->display_info.subpixel_order));
> >  	seq_printf(m, "\tCEA rev: %d\n", connector->display_info.cea_rev);
> >  
> > -	if (!intel_encoder)
> > +	if (!encoder)
> >  		return;
> >  
> >  	switch (connector->connector_type) {
> >  	case DRM_MODE_CONNECTOR_DisplayPort:
> >  	case DRM_MODE_CONNECTOR_eDP:
> > -		if (intel_encoder->type == INTEL_OUTPUT_DP_MST)
> > +		if (encoder->type == INTEL_OUTPUT_DP_MST)
> >  			intel_dp_mst_info(m, intel_connector);
> >  		else
> >  			intel_dp_info(m, intel_connector);
> >  		break;
> >  	case DRM_MODE_CONNECTOR_LVDS:
> > -		if (intel_encoder->type == INTEL_OUTPUT_LVDS)
> > +		if (encoder->type == INTEL_OUTPUT_LVDS)
> >  			intel_lvds_info(m, intel_connector);
> >  		break;
> >  	case DRM_MODE_CONNECTOR_HDMIA:
> > -		if (intel_encoder->type == INTEL_OUTPUT_HDMI ||
> > -		    intel_encoder->type == INTEL_OUTPUT_DDI)
> > +		if (encoder->type == INTEL_OUTPUT_HDMI ||
> > +		    encoder->type == INTEL_OUTPUT_DDI)
> >  			intel_hdmi_info(m, intel_connector);
> >  		break;
> >  	default:
> > @@ -2653,6 +2664,7 @@ static void intel_crtc_info(struct seq_file *m, struct intel_crtc *crtc)
> >  	struct drm_i915_private *dev_priv = node_to_i915(m->private);
> >  	const struct intel_crtc_state *crtc_state =
> >  		to_intel_crtc_state(crtc->base.state);
> > +	struct intel_encoder *encoder;
> >  
> >  	seq_printf(m, "[CRTC:%d:%s]:\n",
> >  		   crtc->base.base.id, crtc->base.name);
> > @@ -2663,8 +2675,6 @@ static void intel_crtc_info(struct seq_file *m, struct intel_crtc *crtc)
> >  		   DRM_MODE_ARG(&crtc_state->uapi.mode));
> >  
> >  	if (crtc_state->hw.enable) {
> > -		struct intel_encoder *encoder;
> > -
> >  		seq_printf(m, "\thw: active=%s, adjusted_mode=" DRM_MODE_FMT "\n",
> >  			   yesno(crtc_state->hw.active),
> >  			   DRM_MODE_ARG(&crtc_state->hw.adjusted_mode));
> > @@ -2673,12 +2683,13 @@ static void intel_crtc_info(struct seq_file *m, struct intel_crtc *crtc)
> >  			   crtc_state->pipe_src_w, crtc_state->pipe_src_h,
> >  			   yesno(crtc_state->dither), crtc_state->pipe_bpp);
> >  
> > -		for_each_encoder_on_crtc(&dev_priv->drm, &crtc->base, encoder)
> > -			intel_encoder_info(m, crtc, encoder);
> > -
> >  		intel_scaler_info(m, crtc);
> >  	}
> >  
> > +	for_each_intel_encoder_mask(&dev_priv->drm, encoder,
> > +				    crtc_state->uapi.encoder_mask)
> > +		intel_encoder_info(m, crtc, encoder);
> > +
> >  	intel_plane_info(m, crtc);
> >  
> >  	seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s\n",
> > -- 
> > 2.23.0
> > 
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Ramalingam C Dec. 2, 2019, 4:52 p.m. UTC | #3
On 2019-12-02 at 18:24:56 +0200, Ville Syrjälä wrote:
> On Mon, Dec 02, 2019 at 09:10:08PM +0530, Ramalingam C wrote:
> > On 2019-11-29 at 20:54:34 +0200, Ville Syrjala wrote:
> > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > 
> > > Migrate away from the legacy encoder->crtc and connector->encoder links
> > > in the debugfs display_info code. Other users still remain so can't kill
> > > these off yet.
> > May be I missed why we want to kill encoder->crtc and conn->encoder.
> > If you dont mind please explain the reasoning.
> 
> They are pre-atomic legacy state. With atomic everything should be
> tracked in crtc_state/etc. instead. These things are being updated
> in the middle of commit_tail() so any use during atomic_check() must
> already be considered a bug. So I want to eliminate them completely
> mainly to stop people from using them in new code out of ignorance.
> Fortunately it doesn't look like this will be as difficult as I
> originally feared.

Thanks for the explanation Ville! That helps!

-Ram.
> 
> > 
> > Apart from that the implementation looks good to me.
> > 
> > Reviewed-by: Ramalingam C <ramalingam.c@intel.com>
> > > 
> > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > ---
> > >  drivers/gpu/drm/i915/display/intel_display.h |  7 ++++
> > >  drivers/gpu/drm/i915/i915_debugfs.c          | 43 ++++++++++++--------
> > >  2 files changed, 34 insertions(+), 16 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/i915/display/intel_display.h b/drivers/gpu/drm/i915/display/intel_display.h
> > > index a5ec5eeff056..5ed716a986ad 100644
> > > --- a/drivers/gpu/drm/i915/display/intel_display.h
> > > +++ b/drivers/gpu/drm/i915/display/intel_display.h
> > > @@ -380,6 +380,13 @@ enum phy_fia {
> > >  			    &(dev)->mode_config.encoder_list,	\
> > >  			    base.head)
> > >  
> > > +#define for_each_intel_encoder_mask(dev, intel_encoder, encoder_mask)	\
> > > +	list_for_each_entry(intel_encoder,				\
> > > +			    &(dev)->mode_config.encoder_list,		\
> > > +			    base.head)					\
> > > +		for_each_if((encoder_mask) &				\
> > > +			    drm_encoder_mask(&intel_encoder->base))
> > > +
> > >  #define for_each_intel_dp(dev, intel_encoder)			\
> > >  	for_each_intel_encoder(dev, intel_encoder)		\
> > >  		for_each_if(intel_encoder_is_dp(intel_encoder))
> > > diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> > > index 414da0a542d6..eb80a2c4b55b 100644
> > > --- a/drivers/gpu/drm/i915/i915_debugfs.c
> > > +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> > > @@ -2382,15 +2382,24 @@ static void intel_encoder_info(struct seq_file *m,
> > >  			       struct intel_encoder *encoder)
> > >  {
> > >  	struct drm_i915_private *dev_priv = node_to_i915(m->private);
> > > -	struct drm_device *dev = &dev_priv->drm;
> > > -	struct intel_connector *connector;
> > > +	struct drm_connector_list_iter conn_iter;
> > > +	struct drm_connector *connector;
> > >  
> > >  	seq_printf(m, "\t[ENCODER:%d:%s]: connectors:\n",
> > >  		   encoder->base.base.id, encoder->base.name);
> > >  
> > > -	for_each_connector_on_encoder(dev, &encoder->base, connector)
> > > +	drm_connector_list_iter_begin(&dev_priv->drm, &conn_iter);
> > > +	drm_for_each_connector_iter(connector, &conn_iter) {
> > > +		const struct drm_connector_state *conn_state =
> > > +			connector->state;
> > > +
> > > +		if (conn_state->best_encoder != &encoder->base)
> > > +			continue;
> > > +
> > >  		seq_printf(m, "\t\t[CONNECTOR:%d:%s]\n",
> > > -			   connector->base.base.id, connector->base.name);
> > > +			   connector->base.id, connector->name);
> > > +	}
> > > +	drm_connector_list_iter_end(&conn_iter);
> > >  }
> > >  
> > >  static void intel_panel_info(struct seq_file *m, struct intel_panel *panel)
> > > @@ -2475,8 +2484,10 @@ static void intel_connector_info(struct seq_file *m,
> > >  				 struct drm_connector *connector)
> > >  {
> > >  	struct intel_connector *intel_connector = to_intel_connector(connector);
> > > -	struct intel_encoder *intel_encoder = intel_connector->encoder;
> > > -	struct drm_display_mode *mode;
> > > +	const struct drm_connector_state *conn_state = connector->state;
> > > +	struct intel_encoder *encoder =
> > > +		to_intel_encoder(conn_state->best_encoder);
> > > +	const struct drm_display_mode *mode;
> > >  
> > >  	seq_printf(m, "[CONNECTOR:%d:%s]: status: %s\n",
> > >  		   connector->base.id, connector->name,
> > > @@ -2492,24 +2503,24 @@ static void intel_connector_info(struct seq_file *m,
> > >  		   drm_get_subpixel_order_name(connector->display_info.subpixel_order));
> > >  	seq_printf(m, "\tCEA rev: %d\n", connector->display_info.cea_rev);
> > >  
> > > -	if (!intel_encoder)
> > > +	if (!encoder)
> > >  		return;
> > >  
> > >  	switch (connector->connector_type) {
> > >  	case DRM_MODE_CONNECTOR_DisplayPort:
> > >  	case DRM_MODE_CONNECTOR_eDP:
> > > -		if (intel_encoder->type == INTEL_OUTPUT_DP_MST)
> > > +		if (encoder->type == INTEL_OUTPUT_DP_MST)
> > >  			intel_dp_mst_info(m, intel_connector);
> > >  		else
> > >  			intel_dp_info(m, intel_connector);
> > >  		break;
> > >  	case DRM_MODE_CONNECTOR_LVDS:
> > > -		if (intel_encoder->type == INTEL_OUTPUT_LVDS)
> > > +		if (encoder->type == INTEL_OUTPUT_LVDS)
> > >  			intel_lvds_info(m, intel_connector);
> > >  		break;
> > >  	case DRM_MODE_CONNECTOR_HDMIA:
> > > -		if (intel_encoder->type == INTEL_OUTPUT_HDMI ||
> > > -		    intel_encoder->type == INTEL_OUTPUT_DDI)
> > > +		if (encoder->type == INTEL_OUTPUT_HDMI ||
> > > +		    encoder->type == INTEL_OUTPUT_DDI)
> > >  			intel_hdmi_info(m, intel_connector);
> > >  		break;
> > >  	default:
> > > @@ -2653,6 +2664,7 @@ static void intel_crtc_info(struct seq_file *m, struct intel_crtc *crtc)
> > >  	struct drm_i915_private *dev_priv = node_to_i915(m->private);
> > >  	const struct intel_crtc_state *crtc_state =
> > >  		to_intel_crtc_state(crtc->base.state);
> > > +	struct intel_encoder *encoder;
> > >  
> > >  	seq_printf(m, "[CRTC:%d:%s]:\n",
> > >  		   crtc->base.base.id, crtc->base.name);
> > > @@ -2663,8 +2675,6 @@ static void intel_crtc_info(struct seq_file *m, struct intel_crtc *crtc)
> > >  		   DRM_MODE_ARG(&crtc_state->uapi.mode));
> > >  
> > >  	if (crtc_state->hw.enable) {
> > > -		struct intel_encoder *encoder;
> > > -
> > >  		seq_printf(m, "\thw: active=%s, adjusted_mode=" DRM_MODE_FMT "\n",
> > >  			   yesno(crtc_state->hw.active),
> > >  			   DRM_MODE_ARG(&crtc_state->hw.adjusted_mode));
> > > @@ -2673,12 +2683,13 @@ static void intel_crtc_info(struct seq_file *m, struct intel_crtc *crtc)
> > >  			   crtc_state->pipe_src_w, crtc_state->pipe_src_h,
> > >  			   yesno(crtc_state->dither), crtc_state->pipe_bpp);
> > >  
> > > -		for_each_encoder_on_crtc(&dev_priv->drm, &crtc->base, encoder)
> > > -			intel_encoder_info(m, crtc, encoder);
> > > -
> > >  		intel_scaler_info(m, crtc);
> > >  	}
> > >  
> > > +	for_each_intel_encoder_mask(&dev_priv->drm, encoder,
> > > +				    crtc_state->uapi.encoder_mask)
> > > +		intel_encoder_info(m, crtc, encoder);
> > > +
> > >  	intel_plane_info(m, crtc);
> > >  
> > >  	seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s\n",
> > > -- 
> > > 2.23.0
> > > 
> > > _______________________________________________
> > > Intel-gfx mailing list
> > > Intel-gfx@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
> 
> -- 
> Ville Syrjälä
> Intel

Patch
diff mbox series

diff --git a/drivers/gpu/drm/i915/display/intel_display.h b/drivers/gpu/drm/i915/display/intel_display.h
index a5ec5eeff056..5ed716a986ad 100644
--- a/drivers/gpu/drm/i915/display/intel_display.h
+++ b/drivers/gpu/drm/i915/display/intel_display.h
@@ -380,6 +380,13 @@  enum phy_fia {
 			    &(dev)->mode_config.encoder_list,	\
 			    base.head)
 
+#define for_each_intel_encoder_mask(dev, intel_encoder, encoder_mask)	\
+	list_for_each_entry(intel_encoder,				\
+			    &(dev)->mode_config.encoder_list,		\
+			    base.head)					\
+		for_each_if((encoder_mask) &				\
+			    drm_encoder_mask(&intel_encoder->base))
+
 #define for_each_intel_dp(dev, intel_encoder)			\
 	for_each_intel_encoder(dev, intel_encoder)		\
 		for_each_if(intel_encoder_is_dp(intel_encoder))
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 414da0a542d6..eb80a2c4b55b 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -2382,15 +2382,24 @@  static void intel_encoder_info(struct seq_file *m,
 			       struct intel_encoder *encoder)
 {
 	struct drm_i915_private *dev_priv = node_to_i915(m->private);
-	struct drm_device *dev = &dev_priv->drm;
-	struct intel_connector *connector;
+	struct drm_connector_list_iter conn_iter;
+	struct drm_connector *connector;
 
 	seq_printf(m, "\t[ENCODER:%d:%s]: connectors:\n",
 		   encoder->base.base.id, encoder->base.name);
 
-	for_each_connector_on_encoder(dev, &encoder->base, connector)
+	drm_connector_list_iter_begin(&dev_priv->drm, &conn_iter);
+	drm_for_each_connector_iter(connector, &conn_iter) {
+		const struct drm_connector_state *conn_state =
+			connector->state;
+
+		if (conn_state->best_encoder != &encoder->base)
+			continue;
+
 		seq_printf(m, "\t\t[CONNECTOR:%d:%s]\n",
-			   connector->base.base.id, connector->base.name);
+			   connector->base.id, connector->name);
+	}
+	drm_connector_list_iter_end(&conn_iter);
 }
 
 static void intel_panel_info(struct seq_file *m, struct intel_panel *panel)
@@ -2475,8 +2484,10 @@  static void intel_connector_info(struct seq_file *m,
 				 struct drm_connector *connector)
 {
 	struct intel_connector *intel_connector = to_intel_connector(connector);
-	struct intel_encoder *intel_encoder = intel_connector->encoder;
-	struct drm_display_mode *mode;
+	const struct drm_connector_state *conn_state = connector->state;
+	struct intel_encoder *encoder =
+		to_intel_encoder(conn_state->best_encoder);
+	const struct drm_display_mode *mode;
 
 	seq_printf(m, "[CONNECTOR:%d:%s]: status: %s\n",
 		   connector->base.id, connector->name,
@@ -2492,24 +2503,24 @@  static void intel_connector_info(struct seq_file *m,
 		   drm_get_subpixel_order_name(connector->display_info.subpixel_order));
 	seq_printf(m, "\tCEA rev: %d\n", connector->display_info.cea_rev);
 
-	if (!intel_encoder)
+	if (!encoder)
 		return;
 
 	switch (connector->connector_type) {
 	case DRM_MODE_CONNECTOR_DisplayPort:
 	case DRM_MODE_CONNECTOR_eDP:
-		if (intel_encoder->type == INTEL_OUTPUT_DP_MST)
+		if (encoder->type == INTEL_OUTPUT_DP_MST)
 			intel_dp_mst_info(m, intel_connector);
 		else
 			intel_dp_info(m, intel_connector);
 		break;
 	case DRM_MODE_CONNECTOR_LVDS:
-		if (intel_encoder->type == INTEL_OUTPUT_LVDS)
+		if (encoder->type == INTEL_OUTPUT_LVDS)
 			intel_lvds_info(m, intel_connector);
 		break;
 	case DRM_MODE_CONNECTOR_HDMIA:
-		if (intel_encoder->type == INTEL_OUTPUT_HDMI ||
-		    intel_encoder->type == INTEL_OUTPUT_DDI)
+		if (encoder->type == INTEL_OUTPUT_HDMI ||
+		    encoder->type == INTEL_OUTPUT_DDI)
 			intel_hdmi_info(m, intel_connector);
 		break;
 	default:
@@ -2653,6 +2664,7 @@  static void intel_crtc_info(struct seq_file *m, struct intel_crtc *crtc)
 	struct drm_i915_private *dev_priv = node_to_i915(m->private);
 	const struct intel_crtc_state *crtc_state =
 		to_intel_crtc_state(crtc->base.state);
+	struct intel_encoder *encoder;
 
 	seq_printf(m, "[CRTC:%d:%s]:\n",
 		   crtc->base.base.id, crtc->base.name);
@@ -2663,8 +2675,6 @@  static void intel_crtc_info(struct seq_file *m, struct intel_crtc *crtc)
 		   DRM_MODE_ARG(&crtc_state->uapi.mode));
 
 	if (crtc_state->hw.enable) {
-		struct intel_encoder *encoder;
-
 		seq_printf(m, "\thw: active=%s, adjusted_mode=" DRM_MODE_FMT "\n",
 			   yesno(crtc_state->hw.active),
 			   DRM_MODE_ARG(&crtc_state->hw.adjusted_mode));
@@ -2673,12 +2683,13 @@  static void intel_crtc_info(struct seq_file *m, struct intel_crtc *crtc)
 			   crtc_state->pipe_src_w, crtc_state->pipe_src_h,
 			   yesno(crtc_state->dither), crtc_state->pipe_bpp);
 
-		for_each_encoder_on_crtc(&dev_priv->drm, &crtc->base, encoder)
-			intel_encoder_info(m, crtc, encoder);
-
 		intel_scaler_info(m, crtc);
 	}
 
+	for_each_intel_encoder_mask(&dev_priv->drm, encoder,
+				    crtc_state->uapi.encoder_mask)
+		intel_encoder_info(m, crtc, encoder);
+
 	intel_plane_info(m, crtc);
 
 	seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s\n",