Re: [Intel-gfx] [PATCH v3] drm/i915/ddi: Get AUX power domain for DP main link too

2018-06-26 Thread Manasi Navare
On Tue, Jun 26, 2018 at 09:03:48PM +0300, Imre Deak wrote:
> On Tue, Jun 26, 2018 at 10:40:26AM -0700, Paulo Zanoni wrote:
> > Em Seg, 2018-06-25 às 16:55 -0700, Souza, Jose escreveu:
> > > On Thu, 2018-06-21 at 21:44 +0300, Imre Deak wrote:
> > > > So far we got an AUX power domain reference only for the duration
> > > > of
> > > > DP
> > > > AUX transfers. However, the following suggests that we also need
> > > > these
> > > > for main link functionality:
> > > > - The specification doesn't state whether it's needed or not for
> > > > main
> > > >   link functionality, but suggests that these power wells need to
> > > > be
> > > >   enabled already during display core initialization (Sequences to
> > > >   Initialize Display).
> > 
> > No, the specification states it's needed. Page "Sequences for
> > DisplayPort" (the ICL version, of course), step 1.b:
> > 
> > "TC: Note that AUX power is required for running main link."
> > 
> > Same for the HDMI page.
> 
> Yes, for ICL MG PHY ports (in all modes) it's clearly stated as I also
> wrote it below. The above is about the ICL combo PHY ports and the other
> platforms. For those the only hint is that enabling the AUX power wells
> is listed as a step in the 'Sequences to Initialize Display".
>

I tested this patch with the latest stepping with DP on Combo PHY port.
Without this patch it was giving me AUX timeouts and could never succeed with 
link
training. I needed this patch to successfully train the link and get display out
on Combo PHy Port B DP.
So,

Tested-by: Manasi Navare 

Manasi

> > 
> > > > - For PSR we need to keep the AUX power well enabled.
> > > > - On ICL combo PHY ports (non-TC) the AUX power well is needed for
> > > >   link training too: while the port is enabled with a DP link
> > > > training
> > > >   test pattern trying to toggle the AUX power well will time out.
> > > > - On ICL MG PHY ports (TC) the AUX power well is needed also for
> > > > main
> > > >   link functionality (both in DP and HDMI modes).
> > > > - Windows enables these power wells both for main and AUX lane
> > > >   functionality.
> > > > 
> > > > Based on the above take an AUX power reference for main link
> > > > functionality too. This makes a difference only on GEN10+ (GLK+)
> > > > platforms, where we have separate port specific AUX power wells.
> > > > 
> > > > For PSR we still need to distinguish between port A and the other
> > > > ports, since on port A DC states must stay enabled for main link
> > > > functionality, but DC states must be disabled for driver initiated
> > > > AUX transfers. So re-use the corresponding helper from intel_psr.c.
> > > > 
> > > > Since we take now a reference for main link functionality on all DP
> > > > ports we can forgo taking the separate power ref for PSR
> > > > functionality.
> > > > 
> > > > v2:
> > > > - Make sure DC states stay enabled when taking the ref on port A.
> > > >   (Ville)
> > > > 
> > > > v3: (Ville)
> > > > - Fix comment about logic for encoders without a crtc state and
> > > >   add FIXME note for a simplification to avoid calling
> > > > get_power_domains
> > > >   in such cases.
> > > > - Use intel_crtc_has_dp_encoder() instead
> > > > !intel_crtc_has_type(HDMI).
> > > > 
> > > > Cc: Ville Syrjälä 
> > > > Cc: Dhinakaran Pandiyan 
> > > > Cc: Paulo Zanoni 
> > > > Signed-off-by: Imre Deak 
> > > 
> > > The spec is not clear but this fix the "aux power well" enable
> > > timeouts
> > > that I was getting in aux B so looks like your interpretation is
> > > right.
> > > 
> > > Reviewed-by: José Roberto de Souza 
> > > 
> > > > ---
> > > >  drivers/gpu/drm/i915/intel_ddi.c| 54
> > > > ++---
> > > >  drivers/gpu/drm/i915/intel_display.c| 12 +++-
> > > >  drivers/gpu/drm/i915/intel_drv.h|  3 +-
> > > >  drivers/gpu/drm/i915/intel_psr.c| 41 -
> > > > 
> > > >  drivers/gpu/drm/i915/intel_runtime_pm.c |  1 +
> > > >  5 files changed, 64 insertions(+), 47 deletions(-)
> > > > 
> > > > diff --git a/drivers/gpu/drm/i915/intel_ddi.c
> > > > b/drivers/gpu/drm/i915/intel_ddi.c
> > > > index 044fe1fb9872..0319825b725b 100644
> > > > --- a/drivers/gpu/drm/i915/intel_ddi.c
> > > > +++ b/drivers/gpu/drm/i915/intel_ddi.c
> > > > @@ -1983,15 +1983,55 @@ bool intel_ddi_get_hw_state(struct
> > > > intel_encoder *encoder,
> > > > return ret;
> > > >  }
> > > >  
> > > > -static u64 intel_ddi_get_power_domains(struct intel_encoder
> > > > *encoder)
> > > > +static inline enum intel_display_power_domain
> > > > +intel_ddi_main_link_aux_domain(struct intel_dp *intel_dp)
> > > > +{
> > > > +   /* CNL HW requires corresponding AUX IOs to be powered up
> > > > for PSR with
> > > > +* DC states enabled at the same time, while for driver
> > > > initiated AUX
> > > > +* transfers we need the same AUX IOs to be powered but
> > > > with
> > > > DC states
> > > > +* disabled. Accordingly use the AUX power domain here
> 

Re: [Intel-gfx] [PATCH v3] drm/i915/ddi: Get AUX power domain for DP main link too

2018-06-26 Thread Imre Deak
On Tue, Jun 26, 2018 at 10:40:26AM -0700, Paulo Zanoni wrote:
> Em Seg, 2018-06-25 às 16:55 -0700, Souza, Jose escreveu:
> > On Thu, 2018-06-21 at 21:44 +0300, Imre Deak wrote:
> > > So far we got an AUX power domain reference only for the duration
> > > of
> > > DP
> > > AUX transfers. However, the following suggests that we also need
> > > these
> > > for main link functionality:
> > > - The specification doesn't state whether it's needed or not for
> > > main
> > >   link functionality, but suggests that these power wells need to
> > > be
> > >   enabled already during display core initialization (Sequences to
> > >   Initialize Display).
> 
> No, the specification states it's needed. Page "Sequences for
> DisplayPort" (the ICL version, of course), step 1.b:
> 
> "TC: Note that AUX power is required for running main link."
> 
> Same for the HDMI page.

Yes, for ICL MG PHY ports (in all modes) it's clearly stated as I also
wrote it below. The above is about the ICL combo PHY ports and the other
platforms. For those the only hint is that enabling the AUX power wells
is listed as a step in the 'Sequences to Initialize Display".

> 
> > > - For PSR we need to keep the AUX power well enabled.
> > > - On ICL combo PHY ports (non-TC) the AUX power well is needed for
> > >   link training too: while the port is enabled with a DP link
> > > training
> > >   test pattern trying to toggle the AUX power well will time out.
> > > - On ICL MG PHY ports (TC) the AUX power well is needed also for
> > > main
> > >   link functionality (both in DP and HDMI modes).
> > > - Windows enables these power wells both for main and AUX lane
> > >   functionality.
> > > 
> > > Based on the above take an AUX power reference for main link
> > > functionality too. This makes a difference only on GEN10+ (GLK+)
> > > platforms, where we have separate port specific AUX power wells.
> > > 
> > > For PSR we still need to distinguish between port A and the other
> > > ports, since on port A DC states must stay enabled for main link
> > > functionality, but DC states must be disabled for driver initiated
> > > AUX transfers. So re-use the corresponding helper from intel_psr.c.
> > > 
> > > Since we take now a reference for main link functionality on all DP
> > > ports we can forgo taking the separate power ref for PSR
> > > functionality.
> > > 
> > > v2:
> > > - Make sure DC states stay enabled when taking the ref on port A.
> > >   (Ville)
> > > 
> > > v3: (Ville)
> > > - Fix comment about logic for encoders without a crtc state and
> > >   add FIXME note for a simplification to avoid calling
> > > get_power_domains
> > >   in such cases.
> > > - Use intel_crtc_has_dp_encoder() instead
> > > !intel_crtc_has_type(HDMI).
> > > 
> > > Cc: Ville Syrjälä 
> > > Cc: Dhinakaran Pandiyan 
> > > Cc: Paulo Zanoni 
> > > Signed-off-by: Imre Deak 
> > 
> > The spec is not clear but this fix the "aux power well" enable
> > timeouts
> > that I was getting in aux B so looks like your interpretation is
> > right.
> > 
> > Reviewed-by: José Roberto de Souza 
> > 
> > > ---
> > >  drivers/gpu/drm/i915/intel_ddi.c| 54
> > > ++---
> > >  drivers/gpu/drm/i915/intel_display.c| 12 +++-
> > >  drivers/gpu/drm/i915/intel_drv.h|  3 +-
> > >  drivers/gpu/drm/i915/intel_psr.c| 41 -
> > > 
> > >  drivers/gpu/drm/i915/intel_runtime_pm.c |  1 +
> > >  5 files changed, 64 insertions(+), 47 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/i915/intel_ddi.c
> > > b/drivers/gpu/drm/i915/intel_ddi.c
> > > index 044fe1fb9872..0319825b725b 100644
> > > --- a/drivers/gpu/drm/i915/intel_ddi.c
> > > +++ b/drivers/gpu/drm/i915/intel_ddi.c
> > > @@ -1983,15 +1983,55 @@ bool intel_ddi_get_hw_state(struct
> > > intel_encoder *encoder,
> > >   return ret;
> > >  }
> > >  
> > > -static u64 intel_ddi_get_power_domains(struct intel_encoder
> > > *encoder)
> > > +static inline enum intel_display_power_domain
> > > +intel_ddi_main_link_aux_domain(struct intel_dp *intel_dp)
> > > +{
> > > + /* CNL HW requires corresponding AUX IOs to be powered up
> > > for PSR with
> > > +  * DC states enabled at the same time, while for driver
> > > initiated AUX
> > > +  * transfers we need the same AUX IOs to be powered but
> > > with
> > > DC states
> > > +  * disabled. Accordingly use the AUX power domain here
> > > which
> > > leaves DC
> > > +  * states enabled.
> > > +  * However, for non-A AUX ports the corresponding non-EDP
> > > transcoders
> > > +  * would have already enabled power well 2 and DC_OFF.
> > > This
> > > means we can
> > > +  * acquire a wider POWER_DOMAIN_AUX_{B,C,D,F} reference
> > > instead of a
> > > +  * specific AUX_IO reference without powering up any extra
> > > wells.
> > > +  * Note that PSR is enabled only on Port A even though
> > > this
> > > function
> > > +  * returns the correct domain for other ports too.
> > > +  */
> > > + return intel_dp->aux_ch == AUX_CH_A ?
> > > 

Re: [Intel-gfx] [PATCH v3] drm/i915/ddi: Get AUX power domain for DP main link too

2018-06-26 Thread Paulo Zanoni
Em Seg, 2018-06-25 às 16:55 -0700, Souza, Jose escreveu:
> On Thu, 2018-06-21 at 21:44 +0300, Imre Deak wrote:
> > So far we got an AUX power domain reference only for the duration
> > of
> > DP
> > AUX transfers. However, the following suggests that we also need
> > these
> > for main link functionality:
> > - The specification doesn't state whether it's needed or not for
> > main
> >   link functionality, but suggests that these power wells need to
> > be
> >   enabled already during display core initialization (Sequences to
> >   Initialize Display).

No, the specification states it's needed. Page "Sequences for
DisplayPort" (the ICL version, of course), step 1.b:

"TC: Note that AUX power is required for running main link."

Same for the HDMI page.

> > - For PSR we need to keep the AUX power well enabled.
> > - On ICL combo PHY ports (non-TC) the AUX power well is needed for
> >   link training too: while the port is enabled with a DP link
> > training
> >   test pattern trying to toggle the AUX power well will time out.
> > - On ICL MG PHY ports (TC) the AUX power well is needed also for
> > main
> >   link functionality (both in DP and HDMI modes).
> > - Windows enables these power wells both for main and AUX lane
> >   functionality.
> > 
> > Based on the above take an AUX power reference for main link
> > functionality too. This makes a difference only on GEN10+ (GLK+)
> > platforms, where we have separate port specific AUX power wells.
> > 
> > For PSR we still need to distinguish between port A and the other
> > ports, since on port A DC states must stay enabled for main link
> > functionality, but DC states must be disabled for driver initiated
> > AUX transfers. So re-use the corresponding helper from intel_psr.c.
> > 
> > Since we take now a reference for main link functionality on all DP
> > ports we can forgo taking the separate power ref for PSR
> > functionality.
> > 
> > v2:
> > - Make sure DC states stay enabled when taking the ref on port A.
> >   (Ville)
> > 
> > v3: (Ville)
> > - Fix comment about logic for encoders without a crtc state and
> >   add FIXME note for a simplification to avoid calling
> > get_power_domains
> >   in such cases.
> > - Use intel_crtc_has_dp_encoder() instead
> > !intel_crtc_has_type(HDMI).
> > 
> > Cc: Ville Syrjälä 
> > Cc: Dhinakaran Pandiyan 
> > Cc: Paulo Zanoni 
> > Signed-off-by: Imre Deak 
> 
> The spec is not clear but this fix the "aux power well" enable
> timeouts
> that I was getting in aux B so looks like your interpretation is
> right.
> 
> Reviewed-by: José Roberto de Souza 
> 
> > ---
> >  drivers/gpu/drm/i915/intel_ddi.c| 54
> > ++---
> >  drivers/gpu/drm/i915/intel_display.c| 12 +++-
> >  drivers/gpu/drm/i915/intel_drv.h|  3 +-
> >  drivers/gpu/drm/i915/intel_psr.c| 41 -
> > 
> >  drivers/gpu/drm/i915/intel_runtime_pm.c |  1 +
> >  5 files changed, 64 insertions(+), 47 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/intel_ddi.c
> > b/drivers/gpu/drm/i915/intel_ddi.c
> > index 044fe1fb9872..0319825b725b 100644
> > --- a/drivers/gpu/drm/i915/intel_ddi.c
> > +++ b/drivers/gpu/drm/i915/intel_ddi.c
> > @@ -1983,15 +1983,55 @@ bool intel_ddi_get_hw_state(struct
> > intel_encoder *encoder,
> > return ret;
> >  }
> >  
> > -static u64 intel_ddi_get_power_domains(struct intel_encoder
> > *encoder)
> > +static inline enum intel_display_power_domain
> > +intel_ddi_main_link_aux_domain(struct intel_dp *intel_dp)
> > +{
> > +   /* CNL HW requires corresponding AUX IOs to be powered up
> > for PSR with
> > +* DC states enabled at the same time, while for driver
> > initiated AUX
> > +* transfers we need the same AUX IOs to be powered but
> > with
> > DC states
> > +* disabled. Accordingly use the AUX power domain here
> > which
> > leaves DC
> > +* states enabled.
> > +* However, for non-A AUX ports the corresponding non-EDP
> > transcoders
> > +* would have already enabled power well 2 and DC_OFF.
> > This
> > means we can
> > +* acquire a wider POWER_DOMAIN_AUX_{B,C,D,F} reference
> > instead of a
> > +* specific AUX_IO reference without powering up any extra
> > wells.
> > +* Note that PSR is enabled only on Port A even though
> > this
> > function
> > +* returns the correct domain for other ports too.
> > +*/
> > +   return intel_dp->aux_ch == AUX_CH_A ?
> > POWER_DOMAIN_AUX_IO_A
> > :
> > + intel_dp-
> > > aux_power_domain;
> > 
> > +}
> > +
> > +static u64 intel_ddi_get_power_domains(struct intel_encoder
> > *encoder,
> > +  struct intel_crtc_state
> > *crtc_state)
> >  {
> > struct intel_digital_port *dig_port =
> > enc_to_dig_port(>base);
> > enum pipe pipe;
> > +   u64 domains;
> >  
> > -   if (intel_ddi_get_hw_state(encoder, ))
> > -   return BIT_ULL(dig_port->ddi_io_power_domain);
> > +   if 

Re: [Intel-gfx] [PATCH v3] drm/i915/ddi: Get AUX power domain for DP main link too

2018-06-25 Thread Souza, Jose
On Thu, 2018-06-21 at 21:44 +0300, Imre Deak wrote:
> So far we got an AUX power domain reference only for the duration of
> DP
> AUX transfers. However, the following suggests that we also need
> these
> for main link functionality:
> - The specification doesn't state whether it's needed or not for main
>   link functionality, but suggests that these power wells need to be
>   enabled already during display core initialization (Sequences to
>   Initialize Display).
> - For PSR we need to keep the AUX power well enabled.
> - On ICL combo PHY ports (non-TC) the AUX power well is needed for
>   link training too: while the port is enabled with a DP link
> training
>   test pattern trying to toggle the AUX power well will time out.
> - On ICL MG PHY ports (TC) the AUX power well is needed also for main
>   link functionality (both in DP and HDMI modes).
> - Windows enables these power wells both for main and AUX lane
>   functionality.
> 
> Based on the above take an AUX power reference for main link
> functionality too. This makes a difference only on GEN10+ (GLK+)
> platforms, where we have separate port specific AUX power wells.
> 
> For PSR we still need to distinguish between port A and the other
> ports, since on port A DC states must stay enabled for main link
> functionality, but DC states must be disabled for driver initiated
> AUX transfers. So re-use the corresponding helper from intel_psr.c.
> 
> Since we take now a reference for main link functionality on all DP
> ports we can forgo taking the separate power ref for PSR
> functionality.
> 
> v2:
> - Make sure DC states stay enabled when taking the ref on port A.
>   (Ville)
> 
> v3: (Ville)
> - Fix comment about logic for encoders without a crtc state and
>   add FIXME note for a simplification to avoid calling
> get_power_domains
>   in such cases.
> - Use intel_crtc_has_dp_encoder() instead !intel_crtc_has_type(HDMI).
> 
> Cc: Ville Syrjälä 
> Cc: Dhinakaran Pandiyan 
> Cc: Paulo Zanoni 
> Signed-off-by: Imre Deak 

The spec is not clear but this fix the "aux power well" enable timeouts
that I was getting in aux B so looks like your interpretation is right.

Reviewed-by: José Roberto de Souza 

> ---
>  drivers/gpu/drm/i915/intel_ddi.c| 54
> ++---
>  drivers/gpu/drm/i915/intel_display.c| 12 +++-
>  drivers/gpu/drm/i915/intel_drv.h|  3 +-
>  drivers/gpu/drm/i915/intel_psr.c| 41 -
> 
>  drivers/gpu/drm/i915/intel_runtime_pm.c |  1 +
>  5 files changed, 64 insertions(+), 47 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_ddi.c
> b/drivers/gpu/drm/i915/intel_ddi.c
> index 044fe1fb9872..0319825b725b 100644
> --- a/drivers/gpu/drm/i915/intel_ddi.c
> +++ b/drivers/gpu/drm/i915/intel_ddi.c
> @@ -1983,15 +1983,55 @@ bool intel_ddi_get_hw_state(struct
> intel_encoder *encoder,
>   return ret;
>  }
>  
> -static u64 intel_ddi_get_power_domains(struct intel_encoder
> *encoder)
> +static inline enum intel_display_power_domain
> +intel_ddi_main_link_aux_domain(struct intel_dp *intel_dp)
> +{
> + /* CNL HW requires corresponding AUX IOs to be powered up
> for PSR with
> +  * DC states enabled at the same time, while for driver
> initiated AUX
> +  * transfers we need the same AUX IOs to be powered but with
> DC states
> +  * disabled. Accordingly use the AUX power domain here which
> leaves DC
> +  * states enabled.
> +  * However, for non-A AUX ports the corresponding non-EDP
> transcoders
> +  * would have already enabled power well 2 and DC_OFF. This
> means we can
> +  * acquire a wider POWER_DOMAIN_AUX_{B,C,D,F} reference
> instead of a
> +  * specific AUX_IO reference without powering up any extra
> wells.
> +  * Note that PSR is enabled only on Port A even though this
> function
> +  * returns the correct domain for other ports too.
> +  */
> + return intel_dp->aux_ch == AUX_CH_A ? POWER_DOMAIN_AUX_IO_A
> :
> +   intel_dp-
> >aux_power_domain;
> +}
> +
> +static u64 intel_ddi_get_power_domains(struct intel_encoder
> *encoder,
> +struct intel_crtc_state
> *crtc_state)
>  {
>   struct intel_digital_port *dig_port =
> enc_to_dig_port(>base);
>   enum pipe pipe;
> + u64 domains;
>  
> - if (intel_ddi_get_hw_state(encoder, ))
> - return BIT_ULL(dig_port->ddi_io_power_domain);
> + if (!intel_ddi_get_hw_state(encoder, ))
> + return 0;
>  
> - return 0;
> + domains = BIT_ULL(dig_port->ddi_io_power_domain);
> + if (!crtc_state)
> + return domains;
> +
> + /*
> +  * TODO: Add support for MST encoders. Atm, the following
> should never
> +  * happen since this function will be called only for the
> primary
> +  * encoder which doesn't have its own pipe/crtc_state.
> +  */
> + if (WARN_ON(intel_crtc_has_type(crtc_state,
> INTEL_OUTPUT_DP_MST)))
> +

Re: [Intel-gfx] [PATCH v3] drm/i915/ddi: Get AUX power domain for DP main link too

2018-06-21 Thread Imre Deak
On Thu, Jun 21, 2018 at 01:28:40PM -0700, Dhinakaran Pandiyan wrote:
> On Thu, 2018-06-21 at 22:54 +0300, Imre Deak wrote:
> > On Thu, Jun 21, 2018 at 01:14:30PM -0700, Dhinakaran Pandiyan wrote:
> > > 
> > > On Thu, 2018-06-21 at 21:44 +0300, Imre Deak wrote:
> > > > 
> > > > So far we got an AUX power domain reference only for the duration
> > > > of
> > > > DP
> > > > AUX transfers. However, the following suggests that we also need
> > > > these
> > > > for main link functionality:
> > > > - The specification doesn't state whether it's needed or not for
> > > > main
> > > >   link functionality, but suggests that these power wells need to
> > > > be
> > > >   enabled already during display core initialization (Sequences
> > > > to
> > > >   Initialize Display).
> > > Hmm. The sequence also says "If an Aux channel will not be used, it
> > > does not need to be powered up."
> > Well, I consider that hints at not using the port at all for DP,
> > since
> > for DP you will need AUX.
> > 
> 
> I also see an instruction to "set PORT_CL_DW12_ Lane
> Enable Aux to 1b" for aux channels on combo ports. A quick check shows
> the register is not defined in the driver. My concern is we might be
> missing a step for combo ports.

It is added in the ICL power well enabling patch (see internal branch),
and is something I tested the above scenario with.

> 
> 
> > > 
> > > 
> > > > 
> > > > - For PSR we need to keep the AUX power well enabled.
> > > > - On ICL combo PHY ports (non-TC) the AUX power well is needed
> > > > for
> > > >   link training too: while the port is enabled with a DP link
> > > > training
> > > I don't see this in the spec, is this something you observed?
> > Yes.
> > 
> > > 
> > > 
> > > > 
> > > >   test pattern trying to toggle the AUX power well will time out.
> > > Can we enable AUX power well before link training starts and
> > > disable
> > > after we are done training? Is that enough?
> > That was my first idea too, but given the rest of the points I
> > consider
> > it a safer option to enable it for main link functionality.
> > 
> > > 
> > > 
> > > > 
> > > > - On ICL MG PHY ports (TC) the AUX power well is needed also for
> > > > main
> > > >   link functionality (both in DP and HDMI modes).
> > > > - Windows enables these power wells both for main and AUX lane
> > > >   functionality.
> > > > 
> > > > Based on the above take an AUX power reference for main link
> > > > functionality too. This makes a difference only on GEN10+ (GLK+)
> > > > platforms, where we have separate port specific AUX power wells.
> > > > 
> > > > For PSR we still need to distinguish between port A and the other
> > > > ports, since on port A DC states must stay enabled for main link
> > > > functionality, but DC states must be disabled for driver
> > > > initiated
> > > > AUX transfers. So re-use the corresponding helper from
> > > > intel_psr.c.
> > > > 
> > > > Since we take now a reference for main link functionality on all
> > > > DP
> > > > ports we can forgo taking the separate power ref for PSR
> > > > functionality.
> > > > 
> > > > v2:
> > > > - Make sure DC states stay enabled when taking the ref on port A.
> > > >   (Ville)
> > > > 
> > > > v3: (Ville)
> > > > - Fix comment about logic for encoders without a crtc state and
> > > >   add FIXME note for a simplification to avoid calling
> > > > get_power_domains
> > > >   in such cases.
> > > > - Use intel_crtc_has_dp_encoder() instead
> > > > !intel_crtc_has_type(HDMI).
> > > > 
> > > > Cc: Ville Syrjälä 
> > > > Cc: Dhinakaran Pandiyan 
> > > > Cc: Paulo Zanoni 
> > > > Signed-off-by: Imre Deak 
> > > > ---
> > > >  drivers/gpu/drm/i915/intel_ddi.c| 54
> > > > ++---
> > > >  drivers/gpu/drm/i915/intel_display.c| 12 +++-
> > > >  drivers/gpu/drm/i915/intel_drv.h|  3 +-
> > > >  drivers/gpu/drm/i915/intel_psr.c| 41 -
> > > > 
> > > > 
> > > >  drivers/gpu/drm/i915/intel_runtime_pm.c |  1 +
> > > >  5 files changed, 64 insertions(+), 47 deletions(-)
> > > > 
> > > > diff --git a/drivers/gpu/drm/i915/intel_ddi.c
> > > > b/drivers/gpu/drm/i915/intel_ddi.c
> > > > index 044fe1fb9872..0319825b725b 100644
> > > > --- a/drivers/gpu/drm/i915/intel_ddi.c
> > > > +++ b/drivers/gpu/drm/i915/intel_ddi.c
> > > > @@ -1983,15 +1983,55 @@ bool intel_ddi_get_hw_state(struct
> > > > intel_encoder *encoder,
> > > >     return ret;
> > > >  }
> > > >  
> > > > -static u64 intel_ddi_get_power_domains(struct intel_encoder
> > > > *encoder)
> > > > +static inline enum intel_display_power_domain
> > > > +intel_ddi_main_link_aux_domain(struct intel_dp *intel_dp)
> > > > +{
> > > > +   /* CNL HW requires corresponding AUX IOs to be powered
> > > > up
> > > > for PSR with
> > > > +    * DC states enabled at the same time, while for driver
> > > > initiated AUX
> > > > +    * transfers we need the same AUX IOs to be powered but
> > > > with
> > > > DC states
> > > > +    * 

Re: [Intel-gfx] [PATCH v3] drm/i915/ddi: Get AUX power domain for DP main link too

2018-06-21 Thread Dhinakaran Pandiyan
On Thu, 2018-06-21 at 22:54 +0300, Imre Deak wrote:
> On Thu, Jun 21, 2018 at 01:14:30PM -0700, Dhinakaran Pandiyan wrote:
> > 
> > On Thu, 2018-06-21 at 21:44 +0300, Imre Deak wrote:
> > > 
> > > So far we got an AUX power domain reference only for the duration
> > > of
> > > DP
> > > AUX transfers. However, the following suggests that we also need
> > > these
> > > for main link functionality:
> > > - The specification doesn't state whether it's needed or not for
> > > main
> > >   link functionality, but suggests that these power wells need to
> > > be
> > >   enabled already during display core initialization (Sequences
> > > to
> > >   Initialize Display).
> > Hmm. The sequence also says "If an Aux channel will not be used, it
> > does not need to be powered up."
> Well, I consider that hints at not using the port at all for DP,
> since
> for DP you will need AUX.
> 

I also see an instruction to "set PORT_CL_DW12_ Lane
Enable Aux to 1b" for aux channels on combo ports. A quick check shows
the register is not defined in the driver. My concern is we might be
missing a step for combo ports.


> > 
> > 
> > > 
> > > - For PSR we need to keep the AUX power well enabled.
> > > - On ICL combo PHY ports (non-TC) the AUX power well is needed
> > > for
> > >   link training too: while the port is enabled with a DP link
> > > training
> > I don't see this in the spec, is this something you observed?
> Yes.
> 
> > 
> > 
> > > 
> > >   test pattern trying to toggle the AUX power well will time out.
> > Can we enable AUX power well before link training starts and
> > disable
> > after we are done training? Is that enough?
> That was my first idea too, but given the rest of the points I
> consider
> it a safer option to enable it for main link functionality.
> 
> > 
> > 
> > > 
> > > - On ICL MG PHY ports (TC) the AUX power well is needed also for
> > > main
> > >   link functionality (both in DP and HDMI modes).
> > > - Windows enables these power wells both for main and AUX lane
> > >   functionality.
> > > 
> > > Based on the above take an AUX power reference for main link
> > > functionality too. This makes a difference only on GEN10+ (GLK+)
> > > platforms, where we have separate port specific AUX power wells.
> > > 
> > > For PSR we still need to distinguish between port A and the other
> > > ports, since on port A DC states must stay enabled for main link
> > > functionality, but DC states must be disabled for driver
> > > initiated
> > > AUX transfers. So re-use the corresponding helper from
> > > intel_psr.c.
> > > 
> > > Since we take now a reference for main link functionality on all
> > > DP
> > > ports we can forgo taking the separate power ref for PSR
> > > functionality.
> > > 
> > > v2:
> > > - Make sure DC states stay enabled when taking the ref on port A.
> > >   (Ville)
> > > 
> > > v3: (Ville)
> > > - Fix comment about logic for encoders without a crtc state and
> > >   add FIXME note for a simplification to avoid calling
> > > get_power_domains
> > >   in such cases.
> > > - Use intel_crtc_has_dp_encoder() instead
> > > !intel_crtc_has_type(HDMI).
> > > 
> > > Cc: Ville Syrjälä 
> > > Cc: Dhinakaran Pandiyan 
> > > Cc: Paulo Zanoni 
> > > Signed-off-by: Imre Deak 
> > > ---
> > >  drivers/gpu/drm/i915/intel_ddi.c| 54
> > > ++---
> > >  drivers/gpu/drm/i915/intel_display.c| 12 +++-
> > >  drivers/gpu/drm/i915/intel_drv.h|  3 +-
> > >  drivers/gpu/drm/i915/intel_psr.c| 41 -
> > > 
> > > 
> > >  drivers/gpu/drm/i915/intel_runtime_pm.c |  1 +
> > >  5 files changed, 64 insertions(+), 47 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/i915/intel_ddi.c
> > > b/drivers/gpu/drm/i915/intel_ddi.c
> > > index 044fe1fb9872..0319825b725b 100644
> > > --- a/drivers/gpu/drm/i915/intel_ddi.c
> > > +++ b/drivers/gpu/drm/i915/intel_ddi.c
> > > @@ -1983,15 +1983,55 @@ bool intel_ddi_get_hw_state(struct
> > > intel_encoder *encoder,
> > >   return ret;
> > >  }
> > >  
> > > -static u64 intel_ddi_get_power_domains(struct intel_encoder
> > > *encoder)
> > > +static inline enum intel_display_power_domain
> > > +intel_ddi_main_link_aux_domain(struct intel_dp *intel_dp)
> > > +{
> > > + /* CNL HW requires corresponding AUX IOs to be powered
> > > up
> > > for PSR with
> > > +  * DC states enabled at the same time, while for driver
> > > initiated AUX
> > > +  * transfers we need the same AUX IOs to be powered but
> > > with
> > > DC states
> > > +  * disabled. Accordingly use the AUX power domain here
> > > which
> > > leaves DC
> > > +  * states enabled.
> > > +  * However, for non-A AUX ports the corresponding non-
> > > EDP
> > > transcoders
> > > +  * would have already enabled power well 2 and DC_OFF.
> > > This
> > > means we can
> > > +  * acquire a wider POWER_DOMAIN_AUX_{B,C,D,F} reference
> > > instead of a
> > > +  * specific AUX_IO reference without powering up any
> > > extra
> > > wells.
> > > +  * Note that PSR 

Re: [Intel-gfx] [PATCH v3] drm/i915/ddi: Get AUX power domain for DP main link too

2018-06-21 Thread Imre Deak
On Thu, Jun 21, 2018 at 01:14:30PM -0700, Dhinakaran Pandiyan wrote:
> On Thu, 2018-06-21 at 21:44 +0300, Imre Deak wrote:
> > So far we got an AUX power domain reference only for the duration of
> > DP
> > AUX transfers. However, the following suggests that we also need
> > these
> > for main link functionality:
> > - The specification doesn't state whether it's needed or not for main
> >   link functionality, but suggests that these power wells need to be
> >   enabled already during display core initialization (Sequences to
> >   Initialize Display).
> Hmm. The sequence also says "If an Aux channel will not be used, it
> does not need to be powered up."

Well, I consider that hints at not using the port at all for DP, since
for DP you will need AUX.

> 
> > - For PSR we need to keep the AUX power well enabled.
> > - On ICL combo PHY ports (non-TC) the AUX power well is needed for
> >   link training too: while the port is enabled with a DP link
> > training
> I don't see this in the spec, is this something you observed?

Yes.

> 
> >   test pattern trying to toggle the AUX power well will time out.
> 
> Can we enable AUX power well before link training starts and disable
> after we are done training? Is that enough?

That was my first idea too, but given the rest of the points I consider
it a safer option to enable it for main link functionality.

> 
> > - On ICL MG PHY ports (TC) the AUX power well is needed also for main
> >   link functionality (both in DP and HDMI modes).
> > - Windows enables these power wells both for main and AUX lane
> >   functionality.
> > 
> > Based on the above take an AUX power reference for main link
> > functionality too. This makes a difference only on GEN10+ (GLK+)
> > platforms, where we have separate port specific AUX power wells.
> > 
> > For PSR we still need to distinguish between port A and the other
> > ports, since on port A DC states must stay enabled for main link
> > functionality, but DC states must be disabled for driver initiated
> > AUX transfers. So re-use the corresponding helper from intel_psr.c.
> > 
> > Since we take now a reference for main link functionality on all DP
> > ports we can forgo taking the separate power ref for PSR
> > functionality.
> > 
> > v2:
> > - Make sure DC states stay enabled when taking the ref on port A.
> >   (Ville)
> > 
> > v3: (Ville)
> > - Fix comment about logic for encoders without a crtc state and
> >   add FIXME note for a simplification to avoid calling
> > get_power_domains
> >   in such cases.
> > - Use intel_crtc_has_dp_encoder() instead !intel_crtc_has_type(HDMI).
> > 
> > Cc: Ville Syrjälä 
> > Cc: Dhinakaran Pandiyan 
> > Cc: Paulo Zanoni 
> > Signed-off-by: Imre Deak 
> > ---
> >  drivers/gpu/drm/i915/intel_ddi.c| 54
> > ++---
> >  drivers/gpu/drm/i915/intel_display.c| 12 +++-
> >  drivers/gpu/drm/i915/intel_drv.h|  3 +-
> >  drivers/gpu/drm/i915/intel_psr.c| 41 -
> > 
> >  drivers/gpu/drm/i915/intel_runtime_pm.c |  1 +
> >  5 files changed, 64 insertions(+), 47 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/intel_ddi.c
> > b/drivers/gpu/drm/i915/intel_ddi.c
> > index 044fe1fb9872..0319825b725b 100644
> > --- a/drivers/gpu/drm/i915/intel_ddi.c
> > +++ b/drivers/gpu/drm/i915/intel_ddi.c
> > @@ -1983,15 +1983,55 @@ bool intel_ddi_get_hw_state(struct
> > intel_encoder *encoder,
> >     return ret;
> >  }
> >  
> > -static u64 intel_ddi_get_power_domains(struct intel_encoder
> > *encoder)
> > +static inline enum intel_display_power_domain
> > +intel_ddi_main_link_aux_domain(struct intel_dp *intel_dp)
> > +{
> > +   /* CNL HW requires corresponding AUX IOs to be powered up
> > for PSR with
> > +    * DC states enabled at the same time, while for driver
> > initiated AUX
> > +    * transfers we need the same AUX IOs to be powered but with
> > DC states
> > +    * disabled. Accordingly use the AUX power domain here which
> > leaves DC
> > +    * states enabled.
> > +    * However, for non-A AUX ports the corresponding non-EDP
> > transcoders
> > +    * would have already enabled power well 2 and DC_OFF. This
> > means we can
> > +    * acquire a wider POWER_DOMAIN_AUX_{B,C,D,F} reference
> > instead of a
> > +    * specific AUX_IO reference without powering up any extra
> > wells.
> > +    * Note that PSR is enabled only on Port A even though this
> > function
> > +    * returns the correct domain for other ports too.
> > +    */
> > +   return intel_dp->aux_ch == AUX_CH_A ? POWER_DOMAIN_AUX_IO_A
> > :
> > +     intel_dp-
> > >aux_power_domain;
> > +}
> > +
> > +static u64 intel_ddi_get_power_domains(struct intel_encoder
> > *encoder,
> > +      struct intel_crtc_state
> > *crtc_state)
> >  {
> >     struct intel_digital_port *dig_port =
> > enc_to_dig_port(>base);
> >     enum pipe pipe;
> > +   u64 domains;
> >  
> > -   if (intel_ddi_get_hw_state(encoder, 

Re: [Intel-gfx] [PATCH v3] drm/i915/ddi: Get AUX power domain for DP main link too

2018-06-21 Thread Dhinakaran Pandiyan
On Thu, 2018-06-21 at 21:44 +0300, Imre Deak wrote:
> So far we got an AUX power domain reference only for the duration of
> DP
> AUX transfers. However, the following suggests that we also need
> these
> for main link functionality:
> - The specification doesn't state whether it's needed or not for main
>   link functionality, but suggests that these power wells need to be
>   enabled already during display core initialization (Sequences to
>   Initialize Display).
Hmm. The sequence also says "If an Aux channel will not be used, it
does not need to be powered up."

> - For PSR we need to keep the AUX power well enabled.
> - On ICL combo PHY ports (non-TC) the AUX power well is needed for
>   link training too: while the port is enabled with a DP link
> training
I don't see this in the spec, is this something you observed?

>   test pattern trying to toggle the AUX power well will time out.

Can we enable AUX power well before link training starts and disable
after we are done training? Is that enough?

> - On ICL MG PHY ports (TC) the AUX power well is needed also for main
>   link functionality (both in DP and HDMI modes).
> - Windows enables these power wells both for main and AUX lane
>   functionality.
> 
> Based on the above take an AUX power reference for main link
> functionality too. This makes a difference only on GEN10+ (GLK+)
> platforms, where we have separate port specific AUX power wells.
> 
> For PSR we still need to distinguish between port A and the other
> ports, since on port A DC states must stay enabled for main link
> functionality, but DC states must be disabled for driver initiated
> AUX transfers. So re-use the corresponding helper from intel_psr.c.
> 
> Since we take now a reference for main link functionality on all DP
> ports we can forgo taking the separate power ref for PSR
> functionality.
> 
> v2:
> - Make sure DC states stay enabled when taking the ref on port A.
>   (Ville)
> 
> v3: (Ville)
> - Fix comment about logic for encoders without a crtc state and
>   add FIXME note for a simplification to avoid calling
> get_power_domains
>   in such cases.
> - Use intel_crtc_has_dp_encoder() instead !intel_crtc_has_type(HDMI).
> 
> Cc: Ville Syrjälä 
> Cc: Dhinakaran Pandiyan 
> Cc: Paulo Zanoni 
> Signed-off-by: Imre Deak 
> ---
>  drivers/gpu/drm/i915/intel_ddi.c| 54
> ++---
>  drivers/gpu/drm/i915/intel_display.c| 12 +++-
>  drivers/gpu/drm/i915/intel_drv.h|  3 +-
>  drivers/gpu/drm/i915/intel_psr.c| 41 -
> 
>  drivers/gpu/drm/i915/intel_runtime_pm.c |  1 +
>  5 files changed, 64 insertions(+), 47 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_ddi.c
> b/drivers/gpu/drm/i915/intel_ddi.c
> index 044fe1fb9872..0319825b725b 100644
> --- a/drivers/gpu/drm/i915/intel_ddi.c
> +++ b/drivers/gpu/drm/i915/intel_ddi.c
> @@ -1983,15 +1983,55 @@ bool intel_ddi_get_hw_state(struct
> intel_encoder *encoder,
>   return ret;
>  }
>  
> -static u64 intel_ddi_get_power_domains(struct intel_encoder
> *encoder)
> +static inline enum intel_display_power_domain
> +intel_ddi_main_link_aux_domain(struct intel_dp *intel_dp)
> +{
> + /* CNL HW requires corresponding AUX IOs to be powered up
> for PSR with
> +  * DC states enabled at the same time, while for driver
> initiated AUX
> +  * transfers we need the same AUX IOs to be powered but with
> DC states
> +  * disabled. Accordingly use the AUX power domain here which
> leaves DC
> +  * states enabled.
> +  * However, for non-A AUX ports the corresponding non-EDP
> transcoders
> +  * would have already enabled power well 2 and DC_OFF. This
> means we can
> +  * acquire a wider POWER_DOMAIN_AUX_{B,C,D,F} reference
> instead of a
> +  * specific AUX_IO reference without powering up any extra
> wells.
> +  * Note that PSR is enabled only on Port A even though this
> function
> +  * returns the correct domain for other ports too.
> +  */
> + return intel_dp->aux_ch == AUX_CH_A ? POWER_DOMAIN_AUX_IO_A
> :
> +   intel_dp-
> >aux_power_domain;
> +}
> +
> +static u64 intel_ddi_get_power_domains(struct intel_encoder
> *encoder,
> +    struct intel_crtc_state
> *crtc_state)
>  {
>   struct intel_digital_port *dig_port =
> enc_to_dig_port(>base);
>   enum pipe pipe;
> + u64 domains;
>  
> - if (intel_ddi_get_hw_state(encoder, ))
> - return BIT_ULL(dig_port->ddi_io_power_domain);
> + if (!intel_ddi_get_hw_state(encoder, ))
> + return 0;
>  
> - return 0;
> + domains = BIT_ULL(dig_port->ddi_io_power_domain);
> + if (!crtc_state)
> + return domains;
> +
> + /*
> +  * TODO: Add support for MST encoders. Atm, the following
> should never
> +  * happen since this function will be called only for the
> primary
> +  * encoder which doesn't have its own 

[Intel-gfx] [PATCH v3] drm/i915/ddi: Get AUX power domain for DP main link too

2018-06-21 Thread Imre Deak
So far we got an AUX power domain reference only for the duration of DP
AUX transfers. However, the following suggests that we also need these
for main link functionality:
- The specification doesn't state whether it's needed or not for main
  link functionality, but suggests that these power wells need to be
  enabled already during display core initialization (Sequences to
  Initialize Display).
- For PSR we need to keep the AUX power well enabled.
- On ICL combo PHY ports (non-TC) the AUX power well is needed for
  link training too: while the port is enabled with a DP link training
  test pattern trying to toggle the AUX power well will time out.
- On ICL MG PHY ports (TC) the AUX power well is needed also for main
  link functionality (both in DP and HDMI modes).
- Windows enables these power wells both for main and AUX lane
  functionality.

Based on the above take an AUX power reference for main link
functionality too. This makes a difference only on GEN10+ (GLK+)
platforms, where we have separate port specific AUX power wells.

For PSR we still need to distinguish between port A and the other
ports, since on port A DC states must stay enabled for main link
functionality, but DC states must be disabled for driver initiated
AUX transfers. So re-use the corresponding helper from intel_psr.c.

Since we take now a reference for main link functionality on all DP
ports we can forgo taking the separate power ref for PSR functionality.

v2:
- Make sure DC states stay enabled when taking the ref on port A.
  (Ville)

v3: (Ville)
- Fix comment about logic for encoders without a crtc state and
  add FIXME note for a simplification to avoid calling get_power_domains
  in such cases.
- Use intel_crtc_has_dp_encoder() instead !intel_crtc_has_type(HDMI).

Cc: Ville Syrjälä 
Cc: Dhinakaran Pandiyan 
Cc: Paulo Zanoni 
Signed-off-by: Imre Deak 
---
 drivers/gpu/drm/i915/intel_ddi.c| 54 ++---
 drivers/gpu/drm/i915/intel_display.c| 12 +++-
 drivers/gpu/drm/i915/intel_drv.h|  3 +-
 drivers/gpu/drm/i915/intel_psr.c| 41 -
 drivers/gpu/drm/i915/intel_runtime_pm.c |  1 +
 5 files changed, 64 insertions(+), 47 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index 044fe1fb9872..0319825b725b 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -1983,15 +1983,55 @@ bool intel_ddi_get_hw_state(struct intel_encoder 
*encoder,
return ret;
 }
 
-static u64 intel_ddi_get_power_domains(struct intel_encoder *encoder)
+static inline enum intel_display_power_domain
+intel_ddi_main_link_aux_domain(struct intel_dp *intel_dp)
+{
+   /* CNL HW requires corresponding AUX IOs to be powered up for PSR with
+* DC states enabled at the same time, while for driver initiated AUX
+* transfers we need the same AUX IOs to be powered but with DC states
+* disabled. Accordingly use the AUX power domain here which leaves DC
+* states enabled.
+* However, for non-A AUX ports the corresponding non-EDP transcoders
+* would have already enabled power well 2 and DC_OFF. This means we can
+* acquire a wider POWER_DOMAIN_AUX_{B,C,D,F} reference instead of a
+* specific AUX_IO reference without powering up any extra wells.
+* Note that PSR is enabled only on Port A even though this function
+* returns the correct domain for other ports too.
+*/
+   return intel_dp->aux_ch == AUX_CH_A ? POWER_DOMAIN_AUX_IO_A :
+ intel_dp->aux_power_domain;
+}
+
+static u64 intel_ddi_get_power_domains(struct intel_encoder *encoder,
+  struct intel_crtc_state *crtc_state)
 {
struct intel_digital_port *dig_port = enc_to_dig_port(>base);
enum pipe pipe;
+   u64 domains;
 
-   if (intel_ddi_get_hw_state(encoder, ))
-   return BIT_ULL(dig_port->ddi_io_power_domain);
+   if (!intel_ddi_get_hw_state(encoder, ))
+   return 0;
 
-   return 0;
+   domains = BIT_ULL(dig_port->ddi_io_power_domain);
+   if (!crtc_state)
+   return domains;
+
+   /*
+* TODO: Add support for MST encoders. Atm, the following should never
+* happen since this function will be called only for the primary
+* encoder which doesn't have its own pipe/crtc_state.
+*/
+   if (WARN_ON(intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DP_MST)))
+   return domains;
+
+   /* AUX power is only needed for (e)DP mode, not for HDMI. */
+   if (intel_crtc_has_dp_encoder(crtc_state)) {
+   struct intel_dp *intel_dp = _port->dp;
+
+   domains |= BIT_ULL(intel_ddi_main_link_aux_domain(intel_dp));
+   }
+
+   return domains;
 }
 
 void intel_ddi_enable_pipe_clock(const struct intel_crtc_state *crtc_state)
@@ -2631,6 +2671,9 @@