Re: [Intel-gfx] [BXT MIPI PATCH v4 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

2015-10-01 Thread Jani Nikula
On Wed, 30 Sep 2015, "Shankar, Uma"  wrote:
>>-Original Message-
>>From: Jani Nikula [mailto:jani.nik...@linux.intel.com]
>>Sent: Tuesday, September 29, 2015 12:59 PM
>>To: Shankar, Uma; intel-gfx@lists.freedesktop.org
>>Cc: Kumar, Shobhit; Deak, Imre; Sharma, Shashank
>>Subject: RE: [BXT MIPI PATCH v4 05/14] drm/i915/bxt: DSI encoder support in
>>CRTC modeset
>>
>>I just sent two patches [1][2] to modify ddi_get_encoder_port a
>>little. Rebase on top, and don't modify ddi_get_encoder_port() or
>>intel_ddi_get_encoder_port() at all. Just make sure you don't call the
>>functions for DSI. No need to add PORT_INVALID either.
>>
>>BR,
>>Jani.
>>
>
> Thanks Jani.  I will rebase and re-submit. Personally I feel this will
> be best approach as it will avoid the call itself.  However, only flip
> side is protection at multiple places in code for DSI.

As I explain in my review, it is not necessary to add those checks
everywhere.

BR,
Jani.

>>[1] http://mid.gmane.org/1443511466-8017-1-git-send-email-
>>jani.nik...@intel.com
>>[2] http://mid.gmane.org/1443511466-8017-2-git-send-email-
>>jani.nik...@intel.com

-- 
Jani Nikula, Intel Open Source Technology Center
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [BXT MIPI PATCH v4 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

2015-09-30 Thread Shankar, Uma


>-Original Message-
>From: Jani Nikula [mailto:jani.nik...@linux.intel.com]
>Sent: Tuesday, September 29, 2015 12:59 PM
>To: Shankar, Uma; intel-gfx@lists.freedesktop.org
>Cc: Kumar, Shobhit; Deak, Imre; Sharma, Shashank
>Subject: RE: [BXT MIPI PATCH v4 05/14] drm/i915/bxt: DSI encoder support in
>CRTC modeset
>
>On Mon, 28 Sep 2015, "Shankar, Uma"  wrote:
>>>-Original Message-
>>>From: Jani Nikula [mailto:jani.nik...@linux.intel.com]
>>>Sent: Monday, September 28, 2015 6:58 PM
>>>To: Shankar, Uma; intel-gfx@lists.freedesktop.org
>>>Cc: Kumar, Shobhit; Deak, Imre; Sharma, Shashank; Shankar, Uma
>>>Subject: Re: [BXT MIPI PATCH v4 05/14] drm/i915/bxt: DSI encoder
>>>support in CRTC modeset
>>>
>>>On Wed, 23 Sep 2015, Uma Shankar  wrote:
 From: Shashank Sharma 

 SKL and BXT qualifies the HAS_DDI() check, and hence haswell modeset
 functions are re-used for modeset sequence. But DDI interface
 doesn't include support for DSI.
 This patch adds:
 1. cases for DSI encoder, in those modeset functions and allows
a CRTC modeset
 2. Adds call to pre_pll enabled from CRTC modeset function. Nothing
needs to be done as such in CRTC for DSI encoder, as PLL, clock
and and transcoder programming will be taken care in encoder's
pre_enable and pre_pll_enable function.

 v2: Fixed Jani's review comments. Added INVALID_PORT for non DDI
 encoder like DSI for platforms having HAS_DDI as true.

 v3: Rebased on latest drm-nightly branch. Added a WARN_ON for invalid
 encoder.

 v4: WARN_ON for invalid encoder is refactored as per Jani's suggestion.
 Fixed the sequence for pre_pll_enable.

 Signed-off-by: Shashank Sharma 
 Signed-off-by: Uma Shankar 
 ---
  drivers/gpu/drm/i915/i915_drv.h   |1 +
  drivers/gpu/drm/i915/intel_ddi.c  |   21 -
  drivers/gpu/drm/i915/intel_display.c  |   21 +++--
  drivers/gpu/drm/i915/intel_opregion.c |3 ++-
  4 files changed, 38 insertions(+), 8 deletions(-)

 diff --git a/drivers/gpu/drm/i915/i915_drv.h
 b/drivers/gpu/drm/i915/i915_drv.h index fd1de45..78d31c5 100644
 --- a/drivers/gpu/drm/i915/i915_drv.h
 +++ b/drivers/gpu/drm/i915/i915_drv.h
 @@ -142,6 +142,7 @@ enum plane {
  #define sprite_name(p, s) ((p) * INTEL_INFO(dev)->num_sprites[(p)]
 +
 (s) + 'A')

  enum port {
 +  PORT_INVALID = -1,
>>>
>>>My idea was that you wouldn't add this. Maybe I wasn't clear enough.
>>>
PORT_A = 0,
PORT_B,
PORT_C,
 diff --git a/drivers/gpu/drm/i915/intel_ddi.c
 b/drivers/gpu/drm/i915/intel_ddi.c
 index cacb07b..8edb632 100644
 --- a/drivers/gpu/drm/i915/intel_ddi.c
 +++ b/drivers/gpu/drm/i915/intel_ddi.c
 @@ -227,6 +227,10 @@ static void ddi_get_encoder_port(struct
>>>intel_encoder *intel_encoder,
} else if (type == INTEL_OUTPUT_ANALOG) {
*dig_port = NULL;
*port = PORT_E;
 +  } else if (type == INTEL_OUTPUT_DSI) {
 +  *dig_port = NULL;
 +  *port = PORT_INVALID;
 +  DRM_DEBUG_KMS("Encoder type: DSI. Returning...\n");
>>>
>>>My idea was that you'd only call this function on DDI (i.e. non-DSI)
>>>encoders. So you could do a warn here. Doesn't matter what you set
>>>*port to, it's going to be wrong anyway, and this is only slightly
>>>better than not oopsing on the BUG below.
>>>
} else {
DRM_ERROR("Invalid DDI encoder type %d\n", type);
BUG();
 @@ -237,6 +241,15 @@ enum port intel_ddi_get_encoder_port(struct
 intel_encoder *intel_encoder)  {
struct intel_digital_port *dig_port;
enum port port;
 +  int type = intel_encoder->type;
 +
 +  if (type == INTEL_OUTPUT_DSI) {
 +  port = PORT_INVALID;
 +  DRM_DEBUG_KMS("Encoder type: DSI. Returning...\n");
 +  WARN_ON(1);
 +
 +  return port;
 +  }
>>>
>>>Remove these.
>>>
>>
>> intel_ddi_get_encoder_port is the one getting called from multiple
>> locations. This expects an enum to be returned.  We could either set
>> the *port in
>>
>>  @@ -227,6 +227,10 @@ static void ddi_get_encoder_port(struct
>> intel_encoder *intel_encoder,
>>  } else if (type == INTEL_OUTPUT_ANALOG) {
>>  *dig_port = NULL;
>>  *port = PORT_E;
>> +} else if (type == INTEL_OUTPUT_DSI) {
>> +*dig_port = NULL;
>> +*port = PORT_INVALID;
>> +DRM_DEBUG_KMS("Encoder type: DSI. Returning...\n");
>>
>> And let this function return the PORT_INVALID with a WARN. Or we can
>initialize the port to PORT_INVALID and return that instead. Then I can remove
>these lines from here.
>> Also, If we try to avoid this 

Re: [Intel-gfx] [BXT MIPI PATCH v4 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

2015-09-28 Thread Shankar, Uma


>-Original Message-
>From: Jani Nikula [mailto:jani.nik...@linux.intel.com]
>Sent: Monday, September 28, 2015 6:58 PM
>To: Shankar, Uma; intel-gfx@lists.freedesktop.org
>Cc: Kumar, Shobhit; Deak, Imre; Sharma, Shashank; Shankar, Uma
>Subject: Re: [BXT MIPI PATCH v4 05/14] drm/i915/bxt: DSI encoder support in
>CRTC modeset
>
>On Wed, 23 Sep 2015, Uma Shankar  wrote:
>> From: Shashank Sharma 
>>
>> SKL and BXT qualifies the HAS_DDI() check, and hence haswell modeset
>> functions are re-used for modeset sequence. But DDI interface doesn't
>> include support for DSI.
>> This patch adds:
>> 1. cases for DSI encoder, in those modeset functions and allows
>>a CRTC modeset
>> 2. Adds call to pre_pll enabled from CRTC modeset function. Nothing
>>needs to be done as such in CRTC for DSI encoder, as PLL, clock
>>and and transcoder programming will be taken care in encoder's
>>pre_enable and pre_pll_enable function.
>>
>> v2: Fixed Jani's review comments. Added INVALID_PORT for non DDI
>> encoder like DSI for platforms having HAS_DDI as true.
>>
>> v3: Rebased on latest drm-nightly branch. Added a WARN_ON for invalid
>> encoder.
>>
>> v4: WARN_ON for invalid encoder is refactored as per Jani's suggestion.
>> Fixed the sequence for pre_pll_enable.
>>
>> Signed-off-by: Shashank Sharma 
>> Signed-off-by: Uma Shankar 
>> ---
>>  drivers/gpu/drm/i915/i915_drv.h   |1 +
>>  drivers/gpu/drm/i915/intel_ddi.c  |   21 -
>>  drivers/gpu/drm/i915/intel_display.c  |   21 +++--
>>  drivers/gpu/drm/i915/intel_opregion.c |3 ++-
>>  4 files changed, 38 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/i915_drv.h
>> b/drivers/gpu/drm/i915/i915_drv.h index fd1de45..78d31c5 100644
>> --- a/drivers/gpu/drm/i915/i915_drv.h
>> +++ b/drivers/gpu/drm/i915/i915_drv.h
>> @@ -142,6 +142,7 @@ enum plane {
>>  #define sprite_name(p, s) ((p) * INTEL_INFO(dev)->num_sprites[(p)] +
>> (s) + 'A')
>>
>>  enum port {
>> +PORT_INVALID = -1,
>
>My idea was that you wouldn't add this. Maybe I wasn't clear enough.
>
>>  PORT_A = 0,
>>  PORT_B,
>>  PORT_C,
>> diff --git a/drivers/gpu/drm/i915/intel_ddi.c
>> b/drivers/gpu/drm/i915/intel_ddi.c
>> index cacb07b..8edb632 100644
>> --- a/drivers/gpu/drm/i915/intel_ddi.c
>> +++ b/drivers/gpu/drm/i915/intel_ddi.c
>> @@ -227,6 +227,10 @@ static void ddi_get_encoder_port(struct
>intel_encoder *intel_encoder,
>>  } else if (type == INTEL_OUTPUT_ANALOG) {
>>  *dig_port = NULL;
>>  *port = PORT_E;
>> +} else if (type == INTEL_OUTPUT_DSI) {
>> +*dig_port = NULL;
>> +*port = PORT_INVALID;
>> +DRM_DEBUG_KMS("Encoder type: DSI. Returning...\n");
>
>My idea was that you'd only call this function on DDI (i.e. non-DSI) encoders. 
>So
>you could do a warn here. Doesn't matter what you set *port to, it's going to 
>be
>wrong anyway, and this is only slightly better than not oopsing on the BUG
>below.
>
>>  } else {
>>  DRM_ERROR("Invalid DDI encoder type %d\n", type);
>>  BUG();
>> @@ -237,6 +241,15 @@ enum port intel_ddi_get_encoder_port(struct
>> intel_encoder *intel_encoder)  {
>>  struct intel_digital_port *dig_port;
>>  enum port port;
>> +int type = intel_encoder->type;
>> +
>> +if (type == INTEL_OUTPUT_DSI) {
>> +port = PORT_INVALID;
>> +DRM_DEBUG_KMS("Encoder type: DSI. Returning...\n");
>> +WARN_ON(1);
>> +
>> +return port;
>> +}
>
>Remove these.
>

intel_ddi_get_encoder_port is the one getting called from multiple locations. 
This expects an enum to be returned.  We could either set the *port in 

 @@ -227,6 +227,10 @@ static void ddi_get_encoder_port(struct
intel_encoder *intel_encoder,
} else if (type == INTEL_OUTPUT_ANALOG) {
*dig_port = NULL;
*port = PORT_E;
+   } else if (type == INTEL_OUTPUT_DSI) {
+   *dig_port = NULL;
+   *port = PORT_INVALID;
+   DRM_DEBUG_KMS("Encoder type: DSI. Returning...\n");

And let this function return the PORT_INVALID with a WARN. Or we can initialize 
the port to PORT_INVALID and return that instead. Then I can remove these lines 
from here.
Also, If we try to avoid this function getting called from various locations, 
we will again end up to the original problem of spilled over DSI checks at 
multiple places in code.

Please suggest which ever looks ok. 

>>
>>  ddi_get_encoder_port(intel_encoder, _port, );
>>
>> @@ -392,6 +405,11 @@ void intel_prepare_ddi(struct drm_device *dev)
>>
>>  ddi_get_encoder_port(intel_encoder, _dig_port, );
>>
>
>My idea was that you'd only call this function on DDI (i.e. non-DSI) encoders. 
>So
>you'd have to add a check for DSI here.
>
>> +if (port == PORT_INVALID) 

Re: [Intel-gfx] [BXT MIPI PATCH v4 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

2015-09-28 Thread Jani Nikula
On Wed, 23 Sep 2015, Uma Shankar  wrote:
> From: Shashank Sharma 
>
> SKL and BXT qualifies the HAS_DDI() check, and hence haswell
> modeset functions are re-used for modeset sequence. But DDI
> interface doesn't include support for DSI.
> This patch adds:
> 1. cases for DSI encoder, in those modeset functions and allows
>a CRTC modeset
> 2. Adds call to pre_pll enabled from CRTC modeset function. Nothing
>needs to be done as such in CRTC for DSI encoder, as PLL, clock
>and and transcoder programming will be taken care in encoder's
>pre_enable and pre_pll_enable function.
>
> v2: Fixed Jani's review comments. Added INVALID_PORT for non DDI
> encoder like DSI for platforms having HAS_DDI as true.
>
> v3: Rebased on latest drm-nightly branch. Added a WARN_ON for invalid
> encoder.
>
> v4: WARN_ON for invalid encoder is refactored as per Jani's suggestion.
> Fixed the sequence for pre_pll_enable.
>
> Signed-off-by: Shashank Sharma 
> Signed-off-by: Uma Shankar 
> ---
>  drivers/gpu/drm/i915/i915_drv.h   |1 +
>  drivers/gpu/drm/i915/intel_ddi.c  |   21 -
>  drivers/gpu/drm/i915/intel_display.c  |   21 +++--
>  drivers/gpu/drm/i915/intel_opregion.c |3 ++-
>  4 files changed, 38 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index fd1de45..78d31c5 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -142,6 +142,7 @@ enum plane {
>  #define sprite_name(p, s) ((p) * INTEL_INFO(dev)->num_sprites[(p)] + (s) + 
> 'A')
>  
>  enum port {
> + PORT_INVALID = -1,

My idea was that you wouldn't add this. Maybe I wasn't clear enough.

>   PORT_A = 0,
>   PORT_B,
>   PORT_C,
> diff --git a/drivers/gpu/drm/i915/intel_ddi.c 
> b/drivers/gpu/drm/i915/intel_ddi.c
> index cacb07b..8edb632 100644
> --- a/drivers/gpu/drm/i915/intel_ddi.c
> +++ b/drivers/gpu/drm/i915/intel_ddi.c
> @@ -227,6 +227,10 @@ static void ddi_get_encoder_port(struct intel_encoder 
> *intel_encoder,
>   } else if (type == INTEL_OUTPUT_ANALOG) {
>   *dig_port = NULL;
>   *port = PORT_E;
> + } else if (type == INTEL_OUTPUT_DSI) {
> + *dig_port = NULL;
> + *port = PORT_INVALID;
> + DRM_DEBUG_KMS("Encoder type: DSI. Returning...\n");

My idea was that you'd only call this function on DDI (i.e. non-DSI)
encoders. So you could do a warn here. Doesn't matter what you set *port
to, it's going to be wrong anyway, and this is only slightly better than
not oopsing on the BUG below.

>   } else {
>   DRM_ERROR("Invalid DDI encoder type %d\n", type);
>   BUG();
> @@ -237,6 +241,15 @@ enum port intel_ddi_get_encoder_port(struct 
> intel_encoder *intel_encoder)
>  {
>   struct intel_digital_port *dig_port;
>   enum port port;
> + int type = intel_encoder->type;
> +
> + if (type == INTEL_OUTPUT_DSI) {
> + port = PORT_INVALID;
> + DRM_DEBUG_KMS("Encoder type: DSI. Returning...\n");
> + WARN_ON(1);
> +
> + return port;
> + }

Remove these.

>  
>   ddi_get_encoder_port(intel_encoder, _port, );
>  
> @@ -392,6 +405,11 @@ void intel_prepare_ddi(struct drm_device *dev)
>  
>   ddi_get_encoder_port(intel_encoder, _dig_port, );
>  

My idea was that you'd only call this function on DDI (i.e. non-DSI)
encoders. So you'd have to add a check for DSI here.

> + if (port == PORT_INVALID) {
> + WARN_ON(1);

But this warn now makes me think we don't ever get here on with
DSI. Don't warn for normal cases.

> + continue;
> + }
> +
>   if (visited[port])
>   continue;
>  
> @@ -1779,7 +1797,8 @@ bool intel_ddi_get_hw_state(struct intel_encoder 
> *encoder,
>  void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc)
>  {
>   struct drm_crtc *crtc = _crtc->base;
> - struct drm_i915_private *dev_priv = crtc->dev->dev_private;
> + struct drm_device *dev = crtc->dev;
> + struct drm_i915_private *dev_priv = dev->dev_private;
>   struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc);
>   enum port port = intel_ddi_get_encoder_port(intel_encoder);
>   enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
> diff --git a/drivers/gpu/drm/i915/intel_display.c 
> b/drivers/gpu/drm/i915/intel_display.c
> index b8e0310..ea0f533 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -4991,6 +4991,7 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
>   struct drm_i915_private *dev_priv = dev->dev_private;
>   struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
>   struct intel_encoder *encoder;
> +