Patchwork [3/8] drm/i915: use drm_for_each_connector_iter()

login
register
mail settings
Submitter Gustavo F. Padovan
Date May 11, 2017, 7:10 p.m.
Message ID <20170511191049.28944-4-gustavo@padovan.org>
Download mbox | patch
Permalink /patch/9722775/
State New
Headers show

Comments

Gustavo F. Padovan - May 11, 2017, 7:10 p.m.
From: Gustavo Padovan <gustavo.padovan@collabora.com>

Drop legacy drm_for_each_connector() in favor of the race-free
drm_for_each_connector_iter().

Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
---
 drivers/gpu/drm/i915/intel_display.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Daniel Vetter - May 12, 2017, 7:42 a.m.
On Thu, May 11, 2017 at 04:10:44PM -0300, Gustavo Padovan wrote:
> From: Gustavo Padovan <gustavo.padovan@collabora.com>
> 
> Drop legacy drm_for_each_connector() in favor of the race-free
> drm_for_each_connector_iter().
> 
> Cc: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
> ---
>  drivers/gpu/drm/i915/intel_display.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 3617927..207f144 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -11216,6 +11216,7 @@ static bool check_digital_port_conflicts(struct drm_atomic_state *state)
>  {
>  	struct drm_device *dev = state->dev;
>  	struct drm_connector *connector;
> +	struct drm_connector_list_iter conn_iter;
>  	unsigned int used_ports = 0;
>  	unsigned int used_mst_ports = 0;
>  
> @@ -11224,7 +11225,8 @@ static bool check_digital_port_conflicts(struct drm_atomic_state *state)
>  	 * list to detect the problem on ddi platforms
>  	 * where there's just one encoder per digital port.
>  	 */
> -	drm_for_each_connector(connector, dev) {
> +	drm_connector_list_iter_begin(dev, &conn_iter);
> +	drm_for_each_connector_iter(connector, &conn_iter) {

Since this checks an atomic state it'd probably be better to use
for_each_new_connector_in_state (to make sure we check the same connectors
as in the atomic state, and not something else due to hotplug changes
meanwhile). But this is ok as the mechanical change, so

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

>  		struct drm_connector_state *connector_state;
>  		struct intel_encoder *encoder;
>  
> @@ -11263,6 +11265,7 @@ static bool check_digital_port_conflicts(struct drm_atomic_state *state)
>  			break;
>  		}
>  	}
> +	drm_connector_list_iter_end(&conn_iter);
>  
>  	/* can't mix MST and SST/HDMI on the same port */
>  	if (used_ports & used_mst_ports)
> -- 
> 2.9.3
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Ville Syrjälä - May 12, 2017, 5:05 p.m.
On Fri, May 12, 2017 at 09:42:20AM +0200, Daniel Vetter wrote:
> On Thu, May 11, 2017 at 04:10:44PM -0300, Gustavo Padovan wrote:
> > From: Gustavo Padovan <gustavo.padovan@collabora.com>
> > 
> > Drop legacy drm_for_each_connector() in favor of the race-free
> > drm_for_each_connector_iter().
> > 
> > Cc: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Jani Nikula <jani.nikula@linux.intel.com>
> > Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
> > ---
> >  drivers/gpu/drm/i915/intel_display.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> > index 3617927..207f144 100644
> > --- a/drivers/gpu/drm/i915/intel_display.c
> > +++ b/drivers/gpu/drm/i915/intel_display.c
> > @@ -11216,6 +11216,7 @@ static bool check_digital_port_conflicts(struct drm_atomic_state *state)
> >  {
> >  	struct drm_device *dev = state->dev;
> >  	struct drm_connector *connector;
> > +	struct drm_connector_list_iter conn_iter;
> >  	unsigned int used_ports = 0;
> >  	unsigned int used_mst_ports = 0;
> >  
> > @@ -11224,7 +11225,8 @@ static bool check_digital_port_conflicts(struct drm_atomic_state *state)
> >  	 * list to detect the problem on ddi platforms
> >  	 * where there's just one encoder per digital port.
> >  	 */
> > -	drm_for_each_connector(connector, dev) {
> > +	drm_connector_list_iter_begin(dev, &conn_iter);
> > +	drm_for_each_connector_iter(connector, &conn_iter) {
> 
> Since this checks an atomic state it'd probably be better to use
> for_each_new_connector_in_state (to make sure we check the same connectors
> as in the atomic state,

We need to check all ports here, not just the ones part of the state.

> and not something else due to hotplug changes
> meanwhile). But this is ok as the mechanical change, so
> 
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> 
> >  		struct drm_connector_state *connector_state;
> >  		struct intel_encoder *encoder;
> >  
> > @@ -11263,6 +11265,7 @@ static bool check_digital_port_conflicts(struct drm_atomic_state *state)
> >  			break;
> >  		}
> >  	}
> > +	drm_connector_list_iter_end(&conn_iter);
> >  
> >  	/* can't mix MST and SST/HDMI on the same port */
> >  	if (used_ports & used_mst_ports)
> > -- 
> > 2.9.3
> > 
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

Patch

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 3617927..207f144 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -11216,6 +11216,7 @@  static bool check_digital_port_conflicts(struct drm_atomic_state *state)
 {
 	struct drm_device *dev = state->dev;
 	struct drm_connector *connector;
+	struct drm_connector_list_iter conn_iter;
 	unsigned int used_ports = 0;
 	unsigned int used_mst_ports = 0;
 
@@ -11224,7 +11225,8 @@  static bool check_digital_port_conflicts(struct drm_atomic_state *state)
 	 * list to detect the problem on ddi platforms
 	 * where there's just one encoder per digital port.
 	 */
-	drm_for_each_connector(connector, dev) {
+	drm_connector_list_iter_begin(dev, &conn_iter);
+	drm_for_each_connector_iter(connector, &conn_iter) {
 		struct drm_connector_state *connector_state;
 		struct intel_encoder *encoder;
 
@@ -11263,6 +11265,7 @@  static bool check_digital_port_conflicts(struct drm_atomic_state *state)
 			break;
 		}
 	}
+	drm_connector_list_iter_end(&conn_iter);
 
 	/* can't mix MST and SST/HDMI on the same port */
 	if (used_ports & used_mst_ports)