diff mbox

[3/3] drm/i915: Fix enc_to_dig_port for MST encoders

Message ID 1470188796-31850-4-git-send-email-dhinakaran.pandiyan@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Dhinakaran Pandiyan Aug. 3, 2016, 1:46 a.m. UTC
When a MST encoder is passed to enc_to_dig_port(), the container_of() macro
does not return the digital port. Handle this by returning the member
"primary" in "struct intel_dp_mst_encoder"

Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
---
 drivers/gpu/drm/i915/intel_drv.h | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

Comments

Yang, Libin Aug. 3, 2016, 1:48 a.m. UTC | #1
Add Takashi

Regards,
Libin


> -----Original Message-----
> From: Pandiyan, Dhinakaran
> Sent: Wednesday, August 3, 2016 9:47 AM
> To: intel-gfx@lists.freedesktop.org
> Cc: cpaul@redhat.com; ville.syrjala@linux.intel.com; Yang, Libin
> <libin.yang@intel.com>; Pandiyan, Dhinakaran
> <dhinakaran.pandiyan@intel.com>
> Subject: [PATCH 3/3] drm/i915: Fix enc_to_dig_port for MST encoders
> 
> When a MST encoder is passed to enc_to_dig_port(), the container_of() macro
> does not return the digital port. Handle this by returning the member
> "primary" in "struct intel_dp_mst_encoder"
> 
> Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_drv.h | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_drv.h
> b/drivers/gpu/drm/i915/intel_drv.h
> index 45020d2..66af444 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -1023,18 +1023,22 @@ intel_attached_encoder(struct drm_connector
> *connector)
>  	return to_intel_connector(connector)->encoder;
>  }
> 
> -static inline struct intel_digital_port * -enc_to_dig_port(struct drm_encoder
> *encoder) -{
> -	return container_of(encoder, struct intel_digital_port, base.base);
> -}
> -
>  static inline struct intel_dp_mst_encoder *  enc_to_mst(struct drm_encoder
> *encoder)  {
>  	return container_of(encoder, struct intel_dp_mst_encoder,
> base.base);  }
> 
> +static inline struct intel_digital_port * enc_to_dig_port(struct
> +drm_encoder *encoder) {
> +	if (encoder->encoder_type == DRM_MODE_ENCODER_DPMST)
> +		return enc_to_mst(encoder)->primary;
> +	else
> +		return container_of(encoder, struct intel_digital_port,
> +				    base.base);
> +}
> +
>  static inline struct intel_dp *enc_to_intel_dp(struct drm_encoder *encoder)  {
>  	return &enc_to_dig_port(encoder)->dp;
> --
> 2.5.0
cpaul@redhat.com Aug. 4, 2016, 11:51 p.m. UTC | #2
There was some discussion that happened on the original version of this
patch:

https://patchwork.kernel.org/patch/8960831/

The general consensus was while this fixed the issue, it probably isn't
the way we want to fix it. It would be a better idea just to have
enc_to_mst_primary() or something along those lines, or just use
enc_to_mst()->primary explicitly.

On Tue, 2016-08-02 at 18:46 -0700, Dhinakaran Pandiyan wrote:
> When a MST encoder is passed to enc_to_dig_port(), the container_of()
> macro
> does not return the digital port. Handle this by returning the member
> "primary" in "struct intel_dp_mst_encoder"
> 
> Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_drv.h | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_drv.h
> b/drivers/gpu/drm/i915/intel_drv.h
> index 45020d2..66af444 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -1023,18 +1023,22 @@ intel_attached_encoder(struct drm_connector
> *connector)
>  	return to_intel_connector(connector)->encoder;
>  }
>  
> -static inline struct intel_digital_port *
> -enc_to_dig_port(struct drm_encoder *encoder)
> -{
> -	return container_of(encoder, struct intel_digital_port,
> base.base);
> -}
> -
>  static inline struct intel_dp_mst_encoder *
>  enc_to_mst(struct drm_encoder *encoder)
>  {
>  	return container_of(encoder, struct intel_dp_mst_encoder,
> base.base);
>  }
>  
> +static inline struct intel_digital_port *
> +enc_to_dig_port(struct drm_encoder *encoder)
> +{
> +	if (encoder->encoder_type == DRM_MODE_ENCODER_DPMST)
> +		return enc_to_mst(encoder)->primary;
> +	else
> +		return container_of(encoder, struct
> intel_digital_port,
> +				    base.base);
> +}
> +
>  static inline struct intel_dp *enc_to_intel_dp(struct drm_encoder
> *encoder)
>  {
>  	return &enc_to_dig_port(encoder)->dp;
Dhinakaran Pandiyan Aug. 5, 2016, 5:48 p.m. UTC | #3
On Thu, 2016-08-04 at 19:51 -0400, Lyude wrote:
> There was some discussion that happened on the original version of this

> patch:

> 

> https://patchwork.kernel.org/patch/8960831/

> 

> The general consensus was while this fixed the issue, it probably isn't

> the way we want to fix it. It would be a better idea just to have

> enc_to_mst_primary() or something along those lines, or just use

> enc_to_mst()->primary explicitly.

> 


Thanks for the pointer and the review.

It seems like the concerns were about DP MST audio not working anyway. I
wonder with DP MST audio support coming up
(https://patchwork.kernel.org/patch/9260671/) , if the patch is more
acceptable.

> On Tue, 2016-08-02 at 18:46 -0700, Dhinakaran Pandiyan wrote:

> > When a MST encoder is passed to enc_to_dig_port(), the container_of()

> > macro

> > does not return the digital port. Handle this by returning the member

> > "primary" in "struct intel_dp_mst_encoder"

> > 

> > Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>

> > ---

> >  drivers/gpu/drm/i915/intel_drv.h | 16 ++++++++++------

> >  1 file changed, 10 insertions(+), 6 deletions(-)

> > 

> > diff --git a/drivers/gpu/drm/i915/intel_drv.h

> > b/drivers/gpu/drm/i915/intel_drv.h

> > index 45020d2..66af444 100644

> > --- a/drivers/gpu/drm/i915/intel_drv.h

> > +++ b/drivers/gpu/drm/i915/intel_drv.h

> > @@ -1023,18 +1023,22 @@ intel_attached_encoder(struct drm_connector

> > *connector)

> >  	return to_intel_connector(connector)->encoder;

> >  }

> >  

> > -static inline struct intel_digital_port *

> > -enc_to_dig_port(struct drm_encoder *encoder)

> > -{

> > -	return container_of(encoder, struct intel_digital_port,

> > base.base);

> > -}

> > -

> >  static inline struct intel_dp_mst_encoder *

> >  enc_to_mst(struct drm_encoder *encoder)

> >  {

> >  	return container_of(encoder, struct intel_dp_mst_encoder,

> > base.base);

> >  }

> >  

> > +static inline struct intel_digital_port *

> > +enc_to_dig_port(struct drm_encoder *encoder)

> > +{

> > +	if (encoder->encoder_type == DRM_MODE_ENCODER_DPMST)

> > +		return enc_to_mst(encoder)->primary;

> > +	else

> > +		return container_of(encoder, struct

> > intel_digital_port,

> > +				    base.base);

> > +}

> > +

> >  static inline struct intel_dp *enc_to_intel_dp(struct drm_encoder

> > *encoder)

> >  {

> >  	return &enc_to_dig_port(encoder)->dp;
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 45020d2..66af444 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1023,18 +1023,22 @@  intel_attached_encoder(struct drm_connector *connector)
 	return to_intel_connector(connector)->encoder;
 }
 
-static inline struct intel_digital_port *
-enc_to_dig_port(struct drm_encoder *encoder)
-{
-	return container_of(encoder, struct intel_digital_port, base.base);
-}
-
 static inline struct intel_dp_mst_encoder *
 enc_to_mst(struct drm_encoder *encoder)
 {
 	return container_of(encoder, struct intel_dp_mst_encoder, base.base);
 }
 
+static inline struct intel_digital_port *
+enc_to_dig_port(struct drm_encoder *encoder)
+{
+	if (encoder->encoder_type == DRM_MODE_ENCODER_DPMST)
+		return enc_to_mst(encoder)->primary;
+	else
+		return container_of(encoder, struct intel_digital_port,
+				    base.base);
+}
+
 static inline struct intel_dp *enc_to_intel_dp(struct drm_encoder *encoder)
 {
 	return &enc_to_dig_port(encoder)->dp;