Re: [Intel-gfx] [PATCH v3 7/8] drm/i915/mtl: Add support for PM DEMAND

2023-05-22 Thread Govindapillai, Vinod
Hi Gustavo,

Thanks for the comments. Some inline responses are below!

On Fri, 2023-05-12 at 17:43 -0300, Gustavo Sousa wrote:
> Quoting Govindapillai, Vinod (2023-05-11 20:24:55)
> > Hello
> > 
> > Thanks for the comments. Pls see some inline replies..
> > 
> > On Thu, 2023-04-27 at 17:24 -0300, Gustavo Sousa wrote:
> > > Quoting Vinod Govindapillai (2023-04-27 12:00:15)
> > > > From: Mika Kahola 
> > > > 
> > > > Display14 introduces a new way to instruct the PUnit with
> > > > power and bandwidth requirements of DE. Add the functionality
> > > > to program the registers and handle waits using interrupts.
> > > > The current wait time for timeouts is programmed for 10 msecs to
> > > > factor in the worst case scenarios. Changes made to use REG_BIT
> > > > for a register that we touched(GEN8_DE_MISC_IER _MMIO).
> > > > 
> > > > Wa_14016740474 is added which applies to Xe_LPD+ display
> > > > 
> > > > v2: checkpatch warning fixes, simplify program pmdemand part
> > > > 
> > > > v3: update to dbufs and pipes values to pmdemand register(stan)
> > > >    Removed the macro usage in update_pmdemand_values()
> > > > 
> > > > Bspec: 66451, 64636, 64602, 64603
> > > > Cc: Matt Atwood 
> > > > Cc: Matt Roper 
> > > > Cc: Lucas De Marchi 
> > > > Cc: Gustavo Sousa 
> > > > Signed-off-by: José Roberto de Souza 
> > > > Signed-off-by: Radhakrishna Sripada 
> > > > Signed-off-by: Gustavo Sousa 
> > > > Signed-off-by: Mika Kahola 
> > > > Signed-off-by: Vinod Govindapillai 
> > > > ---
> > > > drivers/gpu/drm/i915/Makefile |   3 +-
> > > > drivers/gpu/drm/i915/display/intel_display.c  |   7 +
> > > > .../gpu/drm/i915/display/intel_display_core.h |   6 +
> > > > .../drm/i915/display/intel_display_driver.c   |   7 +
> > > > .../drm/i915/display/intel_display_power.c    |   8 +
> > > > drivers/gpu/drm/i915/display/intel_pmdemand.c | 455 ++
> > > > drivers/gpu/drm/i915/display/intel_pmdemand.h |  24 +
> > > > drivers/gpu/drm/i915/i915_irq.c   |  21 +-
> > > > drivers/gpu/drm/i915/i915_reg.h   |  36 +-
> > > > 9 files changed, 562 insertions(+), 5 deletions(-)
> > > > create mode 100644 drivers/gpu/drm/i915/display/intel_pmdemand.c
> > > > create mode 100644 drivers/gpu/drm/i915/display/intel_pmdemand.h
> > > > 
> > > > diff --git a/drivers/gpu/drm/i915/Makefile 
> > > > b/drivers/gpu/drm/i915/Makefile
> > > > index 9af76e376ca9..eb899fa86e51 100644
> > > > --- a/drivers/gpu/drm/i915/Makefile
> > > > +++ b/drivers/gpu/drm/i915/Makefile
> > > > @@ -281,7 +281,8 @@ i915-y += \
> > > >    display/i9xx_wm.o \
> > > >    display/skl_scaler.o \
> > > >    display/skl_universal_plane.o \
> > > > -  display/skl_watermark.o
> > > > +  display/skl_watermark.o \
> > > > +  display/intel_pmdemand.o
> > > > i915-$(CONFIG_ACPI) += \
> > > >    display/intel_acpi.o \
> > > >    display/intel_opregion.o
> > > > diff --git a/drivers/gpu/drm/i915/display/intel_display.c
> > > > b/drivers/gpu/drm/i915/display/intel_display.c
> > > > index bf391a6cd8d6..f98e235fadc6 100644
> > > > --- a/drivers/gpu/drm/i915/display/intel_display.c
> > > > +++ b/drivers/gpu/drm/i915/display/intel_display.c
> > > > @@ -99,6 +99,7 @@
> > > > #include "intel_pcode.h"
> > > > #include "intel_pipe_crc.h"
> > > > #include "intel_plane_initial.h"
> > > > +#include "intel_pmdemand.h"
> > > > #include "intel_pps.h"
> > > > #include "intel_psr.h"
> > > > #include "intel_sdvo.h"
> > > > @@ -6306,6 +6307,10 @@ int intel_atomic_check(struct drm_device *dev,
> > > >    return ret;
> > > >    }
> > > > 
> > > > +  ret = intel_pmdemand_atomic_check(state);
> > > > +  if (ret)
> > > > +  goto fail;
> > > > +
> > > >    ret = intel_atomic_check_crtcs(state);
> > > >    if (ret)
> > > >    goto fail;
> > > > @@ -6960,6 +6965,7 @@ static void intel_atomic_commit_tail(struct 
> > > > intel_atomic_state *state)
> > > >    }
> > > > 
> > > >    intel_sagv_pre_plane_update(state);
> > > > +  intel_pmdemand_pre_plane_update(state);
> > > > 
> > > >    /* Complete the events for pipes that have now been disabled */
> > > >    for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i) 
> > > > {
> > > > @@ -7070,6 +7076,7 @@ static void intel_atomic_commit_tail(struct 
> > > > intel_atomic_state *state)
> > > >    intel_verify_planes(state);
> > > > 
> > > >    intel_sagv_post_plane_update(state);
> > > > +  intel_pmdemand_post_plane_update(state);
> > > > 
> > > >    drm_atomic_helper_commit_hw_done(>base);
> > > > 
> > > > diff --git a/drivers/gpu/drm/i915/display/intel_display_core.h
> > > > b/drivers/gpu/drm/i915/display/intel_display_core.h
> > > > index 9f66d734edf6..9471a052aa57 100644
> > > > --- a/drivers/gpu/drm/i915/display/intel_display_core.h
> > > > +++ b/drivers/gpu/drm/i915/display/intel_display_core.h
> > > > @@ -345,6 +345,12 @@ struct intel_display {
> > > >    struct intel_global_obj obj;

Re: [Intel-gfx] [PATCH v3 7/8] drm/i915/mtl: Add support for PM DEMAND

2023-05-17 Thread Jani Nikula
On Thu, 27 Apr 2023, Vinod Govindapillai  wrote:
> From: Mika Kahola 
>
> Display14 introduces a new way to instruct the PUnit with
> power and bandwidth requirements of DE. Add the functionality
> to program the registers and handle waits using interrupts.
> The current wait time for timeouts is programmed for 10 msecs to
> factor in the worst case scenarios. Changes made to use REG_BIT
> for a register that we touched(GEN8_DE_MISC_IER _MMIO).
>
> Wa_14016740474 is added which applies to Xe_LPD+ display
>
> v2: checkpatch warning fixes, simplify program pmdemand part
>
> v3: update to dbufs and pipes values to pmdemand register(stan)
> Removed the macro usage in update_pmdemand_values()
>
> Bspec: 66451, 64636, 64602, 64603
> Cc: Matt Atwood 
> Cc: Matt Roper 
> Cc: Lucas De Marchi 
> Cc: Gustavo Sousa 
> Signed-off-by: José Roberto de Souza 
> Signed-off-by: Radhakrishna Sripada 
> Signed-off-by: Gustavo Sousa 
> Signed-off-by: Mika Kahola 
> Signed-off-by: Vinod Govindapillai 
> ---
>  drivers/gpu/drm/i915/Makefile |   3 +-
>  drivers/gpu/drm/i915/display/intel_display.c  |   7 +
>  .../gpu/drm/i915/display/intel_display_core.h |   6 +
>  .../drm/i915/display/intel_display_driver.c   |   7 +
>  .../drm/i915/display/intel_display_power.c|   8 +
>  drivers/gpu/drm/i915/display/intel_pmdemand.c | 455 ++
>  drivers/gpu/drm/i915/display/intel_pmdemand.h |  24 +
>  drivers/gpu/drm/i915/i915_irq.c   |  21 +-
>  drivers/gpu/drm/i915/i915_reg.h   |  36 +-
>  9 files changed, 562 insertions(+), 5 deletions(-)
>  create mode 100644 drivers/gpu/drm/i915/display/intel_pmdemand.c
>  create mode 100644 drivers/gpu/drm/i915/display/intel_pmdemand.h
>
> diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
> index 9af76e376ca9..eb899fa86e51 100644
> --- a/drivers/gpu/drm/i915/Makefile
> +++ b/drivers/gpu/drm/i915/Makefile
> @@ -281,7 +281,8 @@ i915-y += \
>   display/i9xx_wm.o \
>   display/skl_scaler.o \
>   display/skl_universal_plane.o \
> - display/skl_watermark.o
> + display/skl_watermark.o \
> + display/intel_pmdemand.o
>  i915-$(CONFIG_ACPI) += \
>   display/intel_acpi.o \
>   display/intel_opregion.o
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c 
> b/drivers/gpu/drm/i915/display/intel_display.c
> index bf391a6cd8d6..f98e235fadc6 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -99,6 +99,7 @@
>  #include "intel_pcode.h"
>  #include "intel_pipe_crc.h"
>  #include "intel_plane_initial.h"
> +#include "intel_pmdemand.h"
>  #include "intel_pps.h"
>  #include "intel_psr.h"
>  #include "intel_sdvo.h"
> @@ -6306,6 +6307,10 @@ int intel_atomic_check(struct drm_device *dev,
>   return ret;
>   }
>  
> + ret = intel_pmdemand_atomic_check(state);
> + if (ret)
> + goto fail;
> +
>   ret = intel_atomic_check_crtcs(state);
>   if (ret)
>   goto fail;
> @@ -6960,6 +6965,7 @@ static void intel_atomic_commit_tail(struct 
> intel_atomic_state *state)
>   }
>  
>   intel_sagv_pre_plane_update(state);
> + intel_pmdemand_pre_plane_update(state);
>  
>   /* Complete the events for pipes that have now been disabled */
>   for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i) {
> @@ -7070,6 +7076,7 @@ static void intel_atomic_commit_tail(struct 
> intel_atomic_state *state)
>   intel_verify_planes(state);
>  
>   intel_sagv_post_plane_update(state);
> + intel_pmdemand_post_plane_update(state);
>  
>   drm_atomic_helper_commit_hw_done(>base);
>  
> diff --git a/drivers/gpu/drm/i915/display/intel_display_core.h 
> b/drivers/gpu/drm/i915/display/intel_display_core.h
> index 9f66d734edf6..9471a052aa57 100644
> --- a/drivers/gpu/drm/i915/display/intel_display_core.h
> +++ b/drivers/gpu/drm/i915/display/intel_display_core.h
> @@ -345,6 +345,12 @@ struct intel_display {
>   struct intel_global_obj obj;
>   } dbuf;
>  
> + struct {
> + wait_queue_head_t waitqueue;
> + struct mutex lock;
> + struct intel_global_obj obj;
> + } pmdemand;
> +

See the comment a little higher up:

/* Grouping using anonymous structs. Keep sorted. */


>   struct {
>   /*
>* dkl.phy_lock protects against concurrent access of the
> diff --git a/drivers/gpu/drm/i915/display/intel_display_driver.c 
> b/drivers/gpu/drm/i915/display/intel_display_driver.c
> index 60ce10fc7205..79853d8c3240 100644
> --- a/drivers/gpu/drm/i915/display/intel_display_driver.c
> +++ b/drivers/gpu/drm/i915/display/intel_display_driver.c
> @@ -47,6 +47,7 @@
>  #include "intel_opregion.h"
>  #include "intel_overlay.h"
>  #include "intel_plane_initial.h"
> +#include "intel_pmdemand.h"
>  #include "intel_pps.h"
>  #include "intel_quirks.h"
>  #include "intel_vga.h"
> @@ -211,6 +212,8 @@ 

Re: [Intel-gfx] [PATCH v3 7/8] drm/i915/mtl: Add support for PM DEMAND

2023-05-12 Thread Gustavo Sousa
Quoting Govindapillai, Vinod (2023-05-11 20:24:55)
>Hello
>
>Thanks for the comments. Pls see some inline replies..
>
>On Thu, 2023-04-27 at 17:24 -0300, Gustavo Sousa wrote:
>> Quoting Vinod Govindapillai (2023-04-27 12:00:15)
>> > From: Mika Kahola 
>> > 
>> > Display14 introduces a new way to instruct the PUnit with
>> > power and bandwidth requirements of DE. Add the functionality
>> > to program the registers and handle waits using interrupts.
>> > The current wait time for timeouts is programmed for 10 msecs to
>> > factor in the worst case scenarios. Changes made to use REG_BIT
>> > for a register that we touched(GEN8_DE_MISC_IER _MMIO).
>> > 
>> > Wa_14016740474 is added which applies to Xe_LPD+ display
>> > 
>> > v2: checkpatch warning fixes, simplify program pmdemand part
>> > 
>> > v3: update to dbufs and pipes values to pmdemand register(stan)
>> >    Removed the macro usage in update_pmdemand_values()
>> > 
>> > Bspec: 66451, 64636, 64602, 64603
>> > Cc: Matt Atwood 
>> > Cc: Matt Roper 
>> > Cc: Lucas De Marchi 
>> > Cc: Gustavo Sousa 
>> > Signed-off-by: José Roberto de Souza 
>> > Signed-off-by: Radhakrishna Sripada 
>> > Signed-off-by: Gustavo Sousa 
>> > Signed-off-by: Mika Kahola 
>> > Signed-off-by: Vinod Govindapillai 
>> > ---
>> > drivers/gpu/drm/i915/Makefile |   3 +-
>> > drivers/gpu/drm/i915/display/intel_display.c  |   7 +
>> > .../gpu/drm/i915/display/intel_display_core.h |   6 +
>> > .../drm/i915/display/intel_display_driver.c   |   7 +
>> > .../drm/i915/display/intel_display_power.c    |   8 +
>> > drivers/gpu/drm/i915/display/intel_pmdemand.c | 455 ++
>> > drivers/gpu/drm/i915/display/intel_pmdemand.h |  24 +
>> > drivers/gpu/drm/i915/i915_irq.c   |  21 +-
>> > drivers/gpu/drm/i915/i915_reg.h   |  36 +-
>> > 9 files changed, 562 insertions(+), 5 deletions(-)
>> > create mode 100644 drivers/gpu/drm/i915/display/intel_pmdemand.c
>> > create mode 100644 drivers/gpu/drm/i915/display/intel_pmdemand.h
>> > 
>> > diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
>> > index 9af76e376ca9..eb899fa86e51 100644
>> > --- a/drivers/gpu/drm/i915/Makefile
>> > +++ b/drivers/gpu/drm/i915/Makefile
>> > @@ -281,7 +281,8 @@ i915-y += \
>> >    display/i9xx_wm.o \
>> >    display/skl_scaler.o \
>> >    display/skl_universal_plane.o \
>> > -  display/skl_watermark.o
>> > +  display/skl_watermark.o \
>> > +  display/intel_pmdemand.o
>> > i915-$(CONFIG_ACPI) += \
>> >    display/intel_acpi.o \
>> >    display/intel_opregion.o
>> > diff --git a/drivers/gpu/drm/i915/display/intel_display.c
>> > b/drivers/gpu/drm/i915/display/intel_display.c
>> > index bf391a6cd8d6..f98e235fadc6 100644
>> > --- a/drivers/gpu/drm/i915/display/intel_display.c
>> > +++ b/drivers/gpu/drm/i915/display/intel_display.c
>> > @@ -99,6 +99,7 @@
>> > #include "intel_pcode.h"
>> > #include "intel_pipe_crc.h"
>> > #include "intel_plane_initial.h"
>> > +#include "intel_pmdemand.h"
>> > #include "intel_pps.h"
>> > #include "intel_psr.h"
>> > #include "intel_sdvo.h"
>> > @@ -6306,6 +6307,10 @@ int intel_atomic_check(struct drm_device *dev,
>> >    return ret;
>> >    }
>> > 
>> > +  ret = intel_pmdemand_atomic_check(state);
>> > +  if (ret)
>> > +  goto fail;
>> > +
>> >    ret = intel_atomic_check_crtcs(state);
>> >    if (ret)
>> >    goto fail;
>> > @@ -6960,6 +6965,7 @@ static void intel_atomic_commit_tail(struct 
>> > intel_atomic_state *state)
>> >    }
>> > 
>> >    intel_sagv_pre_plane_update(state);
>> > +  intel_pmdemand_pre_plane_update(state);
>> > 
>> >    /* Complete the events for pipes that have now been disabled */
>> >    for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i) {
>> > @@ -7070,6 +7076,7 @@ static void intel_atomic_commit_tail(struct 
>> > intel_atomic_state *state)
>> >    intel_verify_planes(state);
>> > 
>> >    intel_sagv_post_plane_update(state);
>> > +  intel_pmdemand_post_plane_update(state);
>> > 
>> >    drm_atomic_helper_commit_hw_done(>base);
>> > 
>> > diff --git a/drivers/gpu/drm/i915/display/intel_display_core.h
>> > b/drivers/gpu/drm/i915/display/intel_display_core.h
>> > index 9f66d734edf6..9471a052aa57 100644
>> > --- a/drivers/gpu/drm/i915/display/intel_display_core.h
>> > +++ b/drivers/gpu/drm/i915/display/intel_display_core.h
>> > @@ -345,6 +345,12 @@ struct intel_display {
>> >    struct intel_global_obj obj;
>> >    } dbuf;
>> > 
>> > +  struct {
>> > +  wait_queue_head_t waitqueue;
>> > +  struct mutex lock;
>> > +  struct intel_global_obj obj;
>> > +  } pmdemand;
>> > +
>> >    struct {
>> >    /*
>> >     * dkl.phy_lock protects against concurrent access of the
>> > diff --git a/drivers/gpu/drm/i915/display/intel_display_driver.c
>> > b/drivers/gpu/drm/i915/display/intel_display_driver.c
>> > index 

Re: [Intel-gfx] [PATCH v3 7/8] drm/i915/mtl: Add support for PM DEMAND

2023-05-11 Thread Govindapillai, Vinod
Hello

Thanks for the comments. Pls see some inline replies..

On Thu, 2023-04-27 at 17:24 -0300, Gustavo Sousa wrote:
> Quoting Vinod Govindapillai (2023-04-27 12:00:15)
> > From: Mika Kahola 
> > 
> > Display14 introduces a new way to instruct the PUnit with
> > power and bandwidth requirements of DE. Add the functionality
> > to program the registers and handle waits using interrupts.
> > The current wait time for timeouts is programmed for 10 msecs to
> > factor in the worst case scenarios. Changes made to use REG_BIT
> > for a register that we touched(GEN8_DE_MISC_IER _MMIO).
> > 
> > Wa_14016740474 is added which applies to Xe_LPD+ display
> > 
> > v2: checkpatch warning fixes, simplify program pmdemand part
> > 
> > v3: update to dbufs and pipes values to pmdemand register(stan)
> >    Removed the macro usage in update_pmdemand_values()
> > 
> > Bspec: 66451, 64636, 64602, 64603
> > Cc: Matt Atwood 
> > Cc: Matt Roper 
> > Cc: Lucas De Marchi 
> > Cc: Gustavo Sousa 
> > Signed-off-by: José Roberto de Souza 
> > Signed-off-by: Radhakrishna Sripada 
> > Signed-off-by: Gustavo Sousa 
> > Signed-off-by: Mika Kahola 
> > Signed-off-by: Vinod Govindapillai 
> > ---
> > drivers/gpu/drm/i915/Makefile |   3 +-
> > drivers/gpu/drm/i915/display/intel_display.c  |   7 +
> > .../gpu/drm/i915/display/intel_display_core.h |   6 +
> > .../drm/i915/display/intel_display_driver.c   |   7 +
> > .../drm/i915/display/intel_display_power.c    |   8 +
> > drivers/gpu/drm/i915/display/intel_pmdemand.c | 455 ++
> > drivers/gpu/drm/i915/display/intel_pmdemand.h |  24 +
> > drivers/gpu/drm/i915/i915_irq.c   |  21 +-
> > drivers/gpu/drm/i915/i915_reg.h   |  36 +-
> > 9 files changed, 562 insertions(+), 5 deletions(-)
> > create mode 100644 drivers/gpu/drm/i915/display/intel_pmdemand.c
> > create mode 100644 drivers/gpu/drm/i915/display/intel_pmdemand.h
> > 
> > diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
> > index 9af76e376ca9..eb899fa86e51 100644
> > --- a/drivers/gpu/drm/i915/Makefile
> > +++ b/drivers/gpu/drm/i915/Makefile
> > @@ -281,7 +281,8 @@ i915-y += \
> >    display/i9xx_wm.o \
> >    display/skl_scaler.o \
> >    display/skl_universal_plane.o \
> > -  display/skl_watermark.o
> > +  display/skl_watermark.o \
> > +  display/intel_pmdemand.o
> > i915-$(CONFIG_ACPI) += \
> >    display/intel_acpi.o \
> >    display/intel_opregion.o
> > diff --git a/drivers/gpu/drm/i915/display/intel_display.c
> > b/drivers/gpu/drm/i915/display/intel_display.c
> > index bf391a6cd8d6..f98e235fadc6 100644
> > --- a/drivers/gpu/drm/i915/display/intel_display.c
> > +++ b/drivers/gpu/drm/i915/display/intel_display.c
> > @@ -99,6 +99,7 @@
> > #include "intel_pcode.h"
> > #include "intel_pipe_crc.h"
> > #include "intel_plane_initial.h"
> > +#include "intel_pmdemand.h"
> > #include "intel_pps.h"
> > #include "intel_psr.h"
> > #include "intel_sdvo.h"
> > @@ -6306,6 +6307,10 @@ int intel_atomic_check(struct drm_device *dev,
> >    return ret;
> >    }
> > 
> > +  ret = intel_pmdemand_atomic_check(state);
> > +  if (ret)
> > +  goto fail;
> > +
> >    ret = intel_atomic_check_crtcs(state);
> >    if (ret)
> >    goto fail;
> > @@ -6960,6 +6965,7 @@ static void intel_atomic_commit_tail(struct 
> > intel_atomic_state *state)
> >    }
> > 
> >    intel_sagv_pre_plane_update(state);
> > +  intel_pmdemand_pre_plane_update(state);
> > 
> >    /* Complete the events for pipes that have now been disabled */
> >    for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i) {
> > @@ -7070,6 +7076,7 @@ static void intel_atomic_commit_tail(struct 
> > intel_atomic_state *state)
> >    intel_verify_planes(state);
> > 
> >    intel_sagv_post_plane_update(state);
> > +  intel_pmdemand_post_plane_update(state);
> > 
> >    drm_atomic_helper_commit_hw_done(>base);
> > 
> > diff --git a/drivers/gpu/drm/i915/display/intel_display_core.h
> > b/drivers/gpu/drm/i915/display/intel_display_core.h
> > index 9f66d734edf6..9471a052aa57 100644
> > --- a/drivers/gpu/drm/i915/display/intel_display_core.h
> > +++ b/drivers/gpu/drm/i915/display/intel_display_core.h
> > @@ -345,6 +345,12 @@ struct intel_display {
> >    struct intel_global_obj obj;
> >    } dbuf;
> > 
> > +  struct {
> > +  wait_queue_head_t waitqueue;
> > +  struct mutex lock;
> > +  struct intel_global_obj obj;
> > +  } pmdemand;
> > +
> >    struct {
> >    /*
> >     * dkl.phy_lock protects against concurrent access of the
> > diff --git a/drivers/gpu/drm/i915/display/intel_display_driver.c
> > b/drivers/gpu/drm/i915/display/intel_display_driver.c
> > index 60ce10fc7205..79853d8c3240 100644
> > --- a/drivers/gpu/drm/i915/display/intel_display_driver.c
> > +++ b/drivers/gpu/drm/i915/display/intel_display_driver.c
> > @@ -47,6 +47,7 @@
> > 

Re: [Intel-gfx] [PATCH v3 7/8] drm/i915/mtl: Add support for PM DEMAND

2023-05-02 Thread Jani Nikula
On Thu, 27 Apr 2023, Vinod Govindapillai  wrote:
> From: Mika Kahola 
>
> Display14 introduces a new way to instruct the PUnit with
> power and bandwidth requirements of DE. Add the functionality
> to program the registers and handle waits using interrupts.
> The current wait time for timeouts is programmed for 10 msecs to
> factor in the worst case scenarios. Changes made to use REG_BIT
> for a register that we touched(GEN8_DE_MISC_IER _MMIO).
>
> Wa_14016740474 is added which applies to Xe_LPD+ display
>
> v2: checkpatch warning fixes, simplify program pmdemand part
>
> v3: update to dbufs and pipes values to pmdemand register(stan)
> Removed the macro usage in update_pmdemand_values()
>
> Bspec: 66451, 64636, 64602, 64603
> Cc: Matt Atwood 
> Cc: Matt Roper 
> Cc: Lucas De Marchi 
> Cc: Gustavo Sousa 
> Signed-off-by: José Roberto de Souza 
> Signed-off-by: Radhakrishna Sripada 
> Signed-off-by: Gustavo Sousa 
> Signed-off-by: Mika Kahola 
> Signed-off-by: Vinod Govindapillai 
> ---
>  drivers/gpu/drm/i915/Makefile |   3 +-
>  drivers/gpu/drm/i915/display/intel_display.c  |   7 +
>  .../gpu/drm/i915/display/intel_display_core.h |   6 +
>  .../drm/i915/display/intel_display_driver.c   |   7 +
>  .../drm/i915/display/intel_display_power.c|   8 +
>  drivers/gpu/drm/i915/display/intel_pmdemand.c | 455 ++
>  drivers/gpu/drm/i915/display/intel_pmdemand.h |  24 +
>  drivers/gpu/drm/i915/i915_irq.c   |  21 +-
>  drivers/gpu/drm/i915/i915_reg.h   |  36 +-
>  9 files changed, 562 insertions(+), 5 deletions(-)
>  create mode 100644 drivers/gpu/drm/i915/display/intel_pmdemand.c
>  create mode 100644 drivers/gpu/drm/i915/display/intel_pmdemand.h
>
> diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
> index 9af76e376ca9..eb899fa86e51 100644
> --- a/drivers/gpu/drm/i915/Makefile
> +++ b/drivers/gpu/drm/i915/Makefile
> @@ -281,7 +281,8 @@ i915-y += \
>   display/i9xx_wm.o \
>   display/skl_scaler.o \
>   display/skl_universal_plane.o \
> - display/skl_watermark.o
> + display/skl_watermark.o \
> + display/intel_pmdemand.o

Comment near the top of the file:

# Please keep these build lists sorted!


BR,
Jani.


>  i915-$(CONFIG_ACPI) += \
>   display/intel_acpi.o \
>   display/intel_opregion.o
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c 
> b/drivers/gpu/drm/i915/display/intel_display.c
> index bf391a6cd8d6..f98e235fadc6 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -99,6 +99,7 @@
>  #include "intel_pcode.h"
>  #include "intel_pipe_crc.h"
>  #include "intel_plane_initial.h"
> +#include "intel_pmdemand.h"
>  #include "intel_pps.h"
>  #include "intel_psr.h"
>  #include "intel_sdvo.h"
> @@ -6306,6 +6307,10 @@ int intel_atomic_check(struct drm_device *dev,
>   return ret;
>   }
>  
> + ret = intel_pmdemand_atomic_check(state);
> + if (ret)
> + goto fail;
> +
>   ret = intel_atomic_check_crtcs(state);
>   if (ret)
>   goto fail;
> @@ -6960,6 +6965,7 @@ static void intel_atomic_commit_tail(struct 
> intel_atomic_state *state)
>   }
>  
>   intel_sagv_pre_plane_update(state);
> + intel_pmdemand_pre_plane_update(state);
>  
>   /* Complete the events for pipes that have now been disabled */
>   for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i) {
> @@ -7070,6 +7076,7 @@ static void intel_atomic_commit_tail(struct 
> intel_atomic_state *state)
>   intel_verify_planes(state);
>  
>   intel_sagv_post_plane_update(state);
> + intel_pmdemand_post_plane_update(state);
>  
>   drm_atomic_helper_commit_hw_done(>base);
>  
> diff --git a/drivers/gpu/drm/i915/display/intel_display_core.h 
> b/drivers/gpu/drm/i915/display/intel_display_core.h
> index 9f66d734edf6..9471a052aa57 100644
> --- a/drivers/gpu/drm/i915/display/intel_display_core.h
> +++ b/drivers/gpu/drm/i915/display/intel_display_core.h
> @@ -345,6 +345,12 @@ struct intel_display {
>   struct intel_global_obj obj;
>   } dbuf;
>  
> + struct {
> + wait_queue_head_t waitqueue;
> + struct mutex lock;
> + struct intel_global_obj obj;
> + } pmdemand;
> +
>   struct {
>   /*
>* dkl.phy_lock protects against concurrent access of the
> diff --git a/drivers/gpu/drm/i915/display/intel_display_driver.c 
> b/drivers/gpu/drm/i915/display/intel_display_driver.c
> index 60ce10fc7205..79853d8c3240 100644
> --- a/drivers/gpu/drm/i915/display/intel_display_driver.c
> +++ b/drivers/gpu/drm/i915/display/intel_display_driver.c
> @@ -47,6 +47,7 @@
>  #include "intel_opregion.h"
>  #include "intel_overlay.h"
>  #include "intel_plane_initial.h"
> +#include "intel_pmdemand.h"
>  #include "intel_pps.h"
>  #include "intel_quirks.h"
>  #include "intel_vga.h"
> @@ -211,6 +212,8 @@ int 

Re: [Intel-gfx] [PATCH v3 7/8] drm/i915/mtl: Add support for PM DEMAND

2023-04-27 Thread Gustavo Sousa
Quoting Vinod Govindapillai (2023-04-27 12:00:15)
>From: Mika Kahola 
>
>Display14 introduces a new way to instruct the PUnit with
>power and bandwidth requirements of DE. Add the functionality
>to program the registers and handle waits using interrupts.
>The current wait time for timeouts is programmed for 10 msecs to
>factor in the worst case scenarios. Changes made to use REG_BIT
>for a register that we touched(GEN8_DE_MISC_IER _MMIO).
>
>Wa_14016740474 is added which applies to Xe_LPD+ display
>
>v2: checkpatch warning fixes, simplify program pmdemand part
>
>v3: update to dbufs and pipes values to pmdemand register(stan)
>Removed the macro usage in update_pmdemand_values()
>
>Bspec: 66451, 64636, 64602, 64603
>Cc: Matt Atwood 
>Cc: Matt Roper 
>Cc: Lucas De Marchi 
>Cc: Gustavo Sousa 
>Signed-off-by: José Roberto de Souza 
>Signed-off-by: Radhakrishna Sripada 
>Signed-off-by: Gustavo Sousa 
>Signed-off-by: Mika Kahola 
>Signed-off-by: Vinod Govindapillai 
>---
> drivers/gpu/drm/i915/Makefile |   3 +-
> drivers/gpu/drm/i915/display/intel_display.c  |   7 +
> .../gpu/drm/i915/display/intel_display_core.h |   6 +
> .../drm/i915/display/intel_display_driver.c   |   7 +
> .../drm/i915/display/intel_display_power.c|   8 +
> drivers/gpu/drm/i915/display/intel_pmdemand.c | 455 ++
> drivers/gpu/drm/i915/display/intel_pmdemand.h |  24 +
> drivers/gpu/drm/i915/i915_irq.c   |  21 +-
> drivers/gpu/drm/i915/i915_reg.h   |  36 +-
> 9 files changed, 562 insertions(+), 5 deletions(-)
> create mode 100644 drivers/gpu/drm/i915/display/intel_pmdemand.c
> create mode 100644 drivers/gpu/drm/i915/display/intel_pmdemand.h
>
>diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
>index 9af76e376ca9..eb899fa86e51 100644
>--- a/drivers/gpu/drm/i915/Makefile
>+++ b/drivers/gpu/drm/i915/Makefile
>@@ -281,7 +281,8 @@ i915-y += \
>display/i9xx_wm.o \
>display/skl_scaler.o \
>display/skl_universal_plane.o \
>-  display/skl_watermark.o
>+  display/skl_watermark.o \
>+  display/intel_pmdemand.o
> i915-$(CONFIG_ACPI) += \
>display/intel_acpi.o \
>display/intel_opregion.o
>diff --git a/drivers/gpu/drm/i915/display/intel_display.c 
>b/drivers/gpu/drm/i915/display/intel_display.c
>index bf391a6cd8d6..f98e235fadc6 100644
>--- a/drivers/gpu/drm/i915/display/intel_display.c
>+++ b/drivers/gpu/drm/i915/display/intel_display.c
>@@ -99,6 +99,7 @@
> #include "intel_pcode.h"
> #include "intel_pipe_crc.h"
> #include "intel_plane_initial.h"
>+#include "intel_pmdemand.h"
> #include "intel_pps.h"
> #include "intel_psr.h"
> #include "intel_sdvo.h"
>@@ -6306,6 +6307,10 @@ int intel_atomic_check(struct drm_device *dev,
>return ret;
>}
> 
>+  ret = intel_pmdemand_atomic_check(state);
>+  if (ret)
>+  goto fail;
>+
>ret = intel_atomic_check_crtcs(state);
>if (ret)
>goto fail;
>@@ -6960,6 +6965,7 @@ static void intel_atomic_commit_tail(struct 
>intel_atomic_state *state)
>}
> 
>intel_sagv_pre_plane_update(state);
>+  intel_pmdemand_pre_plane_update(state);
> 
>/* Complete the events for pipes that have now been disabled */
>for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i) {
>@@ -7070,6 +7076,7 @@ static void intel_atomic_commit_tail(struct 
>intel_atomic_state *state)
>intel_verify_planes(state);
> 
>intel_sagv_post_plane_update(state);
>+  intel_pmdemand_post_plane_update(state);
> 
>drm_atomic_helper_commit_hw_done(>base);
> 
>diff --git a/drivers/gpu/drm/i915/display/intel_display_core.h 
>b/drivers/gpu/drm/i915/display/intel_display_core.h
>index 9f66d734edf6..9471a052aa57 100644
>--- a/drivers/gpu/drm/i915/display/intel_display_core.h
>+++ b/drivers/gpu/drm/i915/display/intel_display_core.h
>@@ -345,6 +345,12 @@ struct intel_display {
>struct intel_global_obj obj;
>} dbuf;
> 
>+  struct {
>+  wait_queue_head_t waitqueue;
>+  struct mutex lock;
>+  struct intel_global_obj obj;
>+  } pmdemand;
>+
>struct {
>/*
> * dkl.phy_lock protects against concurrent access of the
>diff --git a/drivers/gpu/drm/i915/display/intel_display_driver.c 
>b/drivers/gpu/drm/i915/display/intel_display_driver.c
>index 60ce10fc7205..79853d8c3240 100644
>--- a/drivers/gpu/drm/i915/display/intel_display_driver.c
>+++ b/drivers/gpu/drm/i915/display/intel_display_driver.c
>@@ -47,6 +47,7 @@
> #include "intel_opregion.h"
> #include "intel_overlay.h"
> #include "intel_plane_initial.h"
>+#include "intel_pmdemand.h"
> #include "intel_pps.h"
> #include "intel_quirks.h"
> #include "intel_vga.h"
>@@ -211,6 +212,8 @@ int intel_display_driver_probe_noirq(struct 
>drm_i915_private *i915)
>if (ret < 0)
>goto cleanup_vga;
> 
>+  intel_pmdemand_init(i915);
>+
>intel_power_domains_init_hw(i915, false);
> 

[Intel-gfx] [PATCH v3 7/8] drm/i915/mtl: Add support for PM DEMAND

2023-04-27 Thread Vinod Govindapillai
From: Mika Kahola 

Display14 introduces a new way to instruct the PUnit with
power and bandwidth requirements of DE. Add the functionality
to program the registers and handle waits using interrupts.
The current wait time for timeouts is programmed for 10 msecs to
factor in the worst case scenarios. Changes made to use REG_BIT
for a register that we touched(GEN8_DE_MISC_IER _MMIO).

Wa_14016740474 is added which applies to Xe_LPD+ display

v2: checkpatch warning fixes, simplify program pmdemand part

v3: update to dbufs and pipes values to pmdemand register(stan)
Removed the macro usage in update_pmdemand_values()

Bspec: 66451, 64636, 64602, 64603
Cc: Matt Atwood 
Cc: Matt Roper 
Cc: Lucas De Marchi 
Cc: Gustavo Sousa 
Signed-off-by: José Roberto de Souza 
Signed-off-by: Radhakrishna Sripada 
Signed-off-by: Gustavo Sousa 
Signed-off-by: Mika Kahola 
Signed-off-by: Vinod Govindapillai 
---
 drivers/gpu/drm/i915/Makefile |   3 +-
 drivers/gpu/drm/i915/display/intel_display.c  |   7 +
 .../gpu/drm/i915/display/intel_display_core.h |   6 +
 .../drm/i915/display/intel_display_driver.c   |   7 +
 .../drm/i915/display/intel_display_power.c|   8 +
 drivers/gpu/drm/i915/display/intel_pmdemand.c | 455 ++
 drivers/gpu/drm/i915/display/intel_pmdemand.h |  24 +
 drivers/gpu/drm/i915/i915_irq.c   |  21 +-
 drivers/gpu/drm/i915/i915_reg.h   |  36 +-
 9 files changed, 562 insertions(+), 5 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/display/intel_pmdemand.c
 create mode 100644 drivers/gpu/drm/i915/display/intel_pmdemand.h

diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 9af76e376ca9..eb899fa86e51 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -281,7 +281,8 @@ i915-y += \
display/i9xx_wm.o \
display/skl_scaler.o \
display/skl_universal_plane.o \
-   display/skl_watermark.o
+   display/skl_watermark.o \
+   display/intel_pmdemand.o
 i915-$(CONFIG_ACPI) += \
display/intel_acpi.o \
display/intel_opregion.o
diff --git a/drivers/gpu/drm/i915/display/intel_display.c 
b/drivers/gpu/drm/i915/display/intel_display.c
index bf391a6cd8d6..f98e235fadc6 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -99,6 +99,7 @@
 #include "intel_pcode.h"
 #include "intel_pipe_crc.h"
 #include "intel_plane_initial.h"
+#include "intel_pmdemand.h"
 #include "intel_pps.h"
 #include "intel_psr.h"
 #include "intel_sdvo.h"
@@ -6306,6 +6307,10 @@ int intel_atomic_check(struct drm_device *dev,
return ret;
}
 
+   ret = intel_pmdemand_atomic_check(state);
+   if (ret)
+   goto fail;
+
ret = intel_atomic_check_crtcs(state);
if (ret)
goto fail;
@@ -6960,6 +6965,7 @@ static void intel_atomic_commit_tail(struct 
intel_atomic_state *state)
}
 
intel_sagv_pre_plane_update(state);
+   intel_pmdemand_pre_plane_update(state);
 
/* Complete the events for pipes that have now been disabled */
for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i) {
@@ -7070,6 +7076,7 @@ static void intel_atomic_commit_tail(struct 
intel_atomic_state *state)
intel_verify_planes(state);
 
intel_sagv_post_plane_update(state);
+   intel_pmdemand_post_plane_update(state);
 
drm_atomic_helper_commit_hw_done(>base);
 
diff --git a/drivers/gpu/drm/i915/display/intel_display_core.h 
b/drivers/gpu/drm/i915/display/intel_display_core.h
index 9f66d734edf6..9471a052aa57 100644
--- a/drivers/gpu/drm/i915/display/intel_display_core.h
+++ b/drivers/gpu/drm/i915/display/intel_display_core.h
@@ -345,6 +345,12 @@ struct intel_display {
struct intel_global_obj obj;
} dbuf;
 
+   struct {
+   wait_queue_head_t waitqueue;
+   struct mutex lock;
+   struct intel_global_obj obj;
+   } pmdemand;
+
struct {
/*
 * dkl.phy_lock protects against concurrent access of the
diff --git a/drivers/gpu/drm/i915/display/intel_display_driver.c 
b/drivers/gpu/drm/i915/display/intel_display_driver.c
index 60ce10fc7205..79853d8c3240 100644
--- a/drivers/gpu/drm/i915/display/intel_display_driver.c
+++ b/drivers/gpu/drm/i915/display/intel_display_driver.c
@@ -47,6 +47,7 @@
 #include "intel_opregion.h"
 #include "intel_overlay.h"
 #include "intel_plane_initial.h"
+#include "intel_pmdemand.h"
 #include "intel_pps.h"
 #include "intel_quirks.h"
 #include "intel_vga.h"
@@ -211,6 +212,8 @@ int intel_display_driver_probe_noirq(struct 
drm_i915_private *i915)
if (ret < 0)
goto cleanup_vga;
 
+   intel_pmdemand_init(i915);
+
intel_power_domains_init_hw(i915, false);
 
if (!HAS_DISPLAY(i915))
@@ -240,6 +243,10 @@ int intel_display_driver_probe_noirq(struct 
drm_i915_private 

[Intel-gfx] [PATCH v3 7/8] drm/i915/mtl: Add support for PM DEMAND

2023-04-27 Thread Vinod Govindapillai
From: Mika Kahola 

Display14 introduces a new way to instruct the PUnit with
power and bandwidth requirements of DE. Add the functionality
to program the registers and handle waits using interrupts.
The current wait time for timeouts is programmed for 10 msecs to
factor in the worst case scenarios. Changes made to use REG_BIT
for a register that we touched(GEN8_DE_MISC_IER _MMIO).

Wa_14016740474 is added which applies to Xe_LPD+ display

v2: checkpatch warning fixes, simplify program pmdemand part

v3: update to dbufs and pipes values to pmdemand register(stan)
Removed the macro usage in update_pmdemand_values()

Bspec: 66451, 64636, 64602, 64603
Cc: Matt Atwood 
Cc: Matt Roper 
Cc: Lucas De Marchi 
Cc: Gustavo Sousa 
Signed-off-by: José Roberto de Souza 
Signed-off-by: Radhakrishna Sripada 
Signed-off-by: Gustavo Sousa 
Signed-off-by: Mika Kahola 
Signed-off-by: Vinod Govindapillai 
---
 drivers/gpu/drm/i915/Makefile |   3 +-
 drivers/gpu/drm/i915/display/intel_display.c  |   7 +
 .../gpu/drm/i915/display/intel_display_core.h |   6 +
 .../drm/i915/display/intel_display_driver.c   |   7 +
 .../drm/i915/display/intel_display_power.c|   8 +
 drivers/gpu/drm/i915/display/intel_pmdemand.c | 455 ++
 drivers/gpu/drm/i915/display/intel_pmdemand.h |  24 +
 drivers/gpu/drm/i915/i915_irq.c   |  21 +-
 drivers/gpu/drm/i915/i915_reg.h   |  36 +-
 9 files changed, 562 insertions(+), 5 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/display/intel_pmdemand.c
 create mode 100644 drivers/gpu/drm/i915/display/intel_pmdemand.h

diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 9af76e376ca9..eb899fa86e51 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -281,7 +281,8 @@ i915-y += \
display/i9xx_wm.o \
display/skl_scaler.o \
display/skl_universal_plane.o \
-   display/skl_watermark.o
+   display/skl_watermark.o \
+   display/intel_pmdemand.o
 i915-$(CONFIG_ACPI) += \
display/intel_acpi.o \
display/intel_opregion.o
diff --git a/drivers/gpu/drm/i915/display/intel_display.c 
b/drivers/gpu/drm/i915/display/intel_display.c
index bf391a6cd8d6..f98e235fadc6 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -99,6 +99,7 @@
 #include "intel_pcode.h"
 #include "intel_pipe_crc.h"
 #include "intel_plane_initial.h"
+#include "intel_pmdemand.h"
 #include "intel_pps.h"
 #include "intel_psr.h"
 #include "intel_sdvo.h"
@@ -6306,6 +6307,10 @@ int intel_atomic_check(struct drm_device *dev,
return ret;
}
 
+   ret = intel_pmdemand_atomic_check(state);
+   if (ret)
+   goto fail;
+
ret = intel_atomic_check_crtcs(state);
if (ret)
goto fail;
@@ -6960,6 +6965,7 @@ static void intel_atomic_commit_tail(struct 
intel_atomic_state *state)
}
 
intel_sagv_pre_plane_update(state);
+   intel_pmdemand_pre_plane_update(state);
 
/* Complete the events for pipes that have now been disabled */
for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i) {
@@ -7070,6 +7076,7 @@ static void intel_atomic_commit_tail(struct 
intel_atomic_state *state)
intel_verify_planes(state);
 
intel_sagv_post_plane_update(state);
+   intel_pmdemand_post_plane_update(state);
 
drm_atomic_helper_commit_hw_done(>base);
 
diff --git a/drivers/gpu/drm/i915/display/intel_display_core.h 
b/drivers/gpu/drm/i915/display/intel_display_core.h
index 9f66d734edf6..9471a052aa57 100644
--- a/drivers/gpu/drm/i915/display/intel_display_core.h
+++ b/drivers/gpu/drm/i915/display/intel_display_core.h
@@ -345,6 +345,12 @@ struct intel_display {
struct intel_global_obj obj;
} dbuf;
 
+   struct {
+   wait_queue_head_t waitqueue;
+   struct mutex lock;
+   struct intel_global_obj obj;
+   } pmdemand;
+
struct {
/*
 * dkl.phy_lock protects against concurrent access of the
diff --git a/drivers/gpu/drm/i915/display/intel_display_driver.c 
b/drivers/gpu/drm/i915/display/intel_display_driver.c
index 60ce10fc7205..79853d8c3240 100644
--- a/drivers/gpu/drm/i915/display/intel_display_driver.c
+++ b/drivers/gpu/drm/i915/display/intel_display_driver.c
@@ -47,6 +47,7 @@
 #include "intel_opregion.h"
 #include "intel_overlay.h"
 #include "intel_plane_initial.h"
+#include "intel_pmdemand.h"
 #include "intel_pps.h"
 #include "intel_quirks.h"
 #include "intel_vga.h"
@@ -211,6 +212,8 @@ int intel_display_driver_probe_noirq(struct 
drm_i915_private *i915)
if (ret < 0)
goto cleanup_vga;
 
+   intel_pmdemand_init(i915);
+
intel_power_domains_init_hw(i915, false);
 
if (!HAS_DISPLAY(i915))
@@ -240,6 +243,10 @@ int intel_display_driver_probe_noirq(struct 
drm_i915_private 

[Intel-gfx] [PATCH v3 7/8] drm/i915/mtl: Add support for PM DEMAND

2023-04-26 Thread Vinod Govindapillai
From: Mika Kahola 

Display14 introduces a new way to instruct the PUnit with
power and bandwidth requirements of DE. Add the functionality
to program the registers and handle waits using interrupts.
The current wait time for timeouts is programmed for 10 msecs to
factor in the worst case scenarios. Changes made to use REG_BIT
for a register that we touched(GEN8_DE_MISC_IER _MMIO).

Wa_14016740474 is added which applies to Xe_LPD+ display

v2: checkpatch warning fixes, simplify program pmdemand part

Bspec: 66451, 64636, 64602, 64603
Cc: Matt Atwood 
Cc: Matt Roper 
Cc: Lucas De Marchi 
Cc: Gustavo Sousa 
Signed-off-by: José Roberto de Souza 
Signed-off-by: Radhakrishna Sripada 
Signed-off-by: Gustavo Sousa 
Signed-off-by: Mika Kahola 
Signed-off-by: Vinod Govindapillai 
---
 drivers/gpu/drm/i915/Makefile |   3 +-
 drivers/gpu/drm/i915/display/intel_display.c  |   7 +
 .../gpu/drm/i915/display/intel_display_core.h |   6 +
 .../drm/i915/display/intel_display_driver.c   |   7 +
 .../drm/i915/display/intel_display_power.c|   8 +
 drivers/gpu/drm/i915/display/intel_pmdemand.c | 450 ++
 drivers/gpu/drm/i915/display/intel_pmdemand.h |  24 +
 drivers/gpu/drm/i915/i915_irq.c   |  21 +-
 drivers/gpu/drm/i915/i915_reg.h   |  36 +-
 9 files changed, 557 insertions(+), 5 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/display/intel_pmdemand.c
 create mode 100644 drivers/gpu/drm/i915/display/intel_pmdemand.h

diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 9af76e376ca9..eb899fa86e51 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -281,7 +281,8 @@ i915-y += \
display/i9xx_wm.o \
display/skl_scaler.o \
display/skl_universal_plane.o \
-   display/skl_watermark.o
+   display/skl_watermark.o \
+   display/intel_pmdemand.o
 i915-$(CONFIG_ACPI) += \
display/intel_acpi.o \
display/intel_opregion.o
diff --git a/drivers/gpu/drm/i915/display/intel_display.c 
b/drivers/gpu/drm/i915/display/intel_display.c
index bf391a6cd8d6..f98e235fadc6 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -99,6 +99,7 @@
 #include "intel_pcode.h"
 #include "intel_pipe_crc.h"
 #include "intel_plane_initial.h"
+#include "intel_pmdemand.h"
 #include "intel_pps.h"
 #include "intel_psr.h"
 #include "intel_sdvo.h"
@@ -6306,6 +6307,10 @@ int intel_atomic_check(struct drm_device *dev,
return ret;
}
 
+   ret = intel_pmdemand_atomic_check(state);
+   if (ret)
+   goto fail;
+
ret = intel_atomic_check_crtcs(state);
if (ret)
goto fail;
@@ -6960,6 +6965,7 @@ static void intel_atomic_commit_tail(struct 
intel_atomic_state *state)
}
 
intel_sagv_pre_plane_update(state);
+   intel_pmdemand_pre_plane_update(state);
 
/* Complete the events for pipes that have now been disabled */
for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i) {
@@ -7070,6 +7076,7 @@ static void intel_atomic_commit_tail(struct 
intel_atomic_state *state)
intel_verify_planes(state);
 
intel_sagv_post_plane_update(state);
+   intel_pmdemand_post_plane_update(state);
 
drm_atomic_helper_commit_hw_done(>base);
 
diff --git a/drivers/gpu/drm/i915/display/intel_display_core.h 
b/drivers/gpu/drm/i915/display/intel_display_core.h
index 9f66d734edf6..9471a052aa57 100644
--- a/drivers/gpu/drm/i915/display/intel_display_core.h
+++ b/drivers/gpu/drm/i915/display/intel_display_core.h
@@ -345,6 +345,12 @@ struct intel_display {
struct intel_global_obj obj;
} dbuf;
 
+   struct {
+   wait_queue_head_t waitqueue;
+   struct mutex lock;
+   struct intel_global_obj obj;
+   } pmdemand;
+
struct {
/*
 * dkl.phy_lock protects against concurrent access of the
diff --git a/drivers/gpu/drm/i915/display/intel_display_driver.c 
b/drivers/gpu/drm/i915/display/intel_display_driver.c
index 60ce10fc7205..79853d8c3240 100644
--- a/drivers/gpu/drm/i915/display/intel_display_driver.c
+++ b/drivers/gpu/drm/i915/display/intel_display_driver.c
@@ -47,6 +47,7 @@
 #include "intel_opregion.h"
 #include "intel_overlay.h"
 #include "intel_plane_initial.h"
+#include "intel_pmdemand.h"
 #include "intel_pps.h"
 #include "intel_quirks.h"
 #include "intel_vga.h"
@@ -211,6 +212,8 @@ int intel_display_driver_probe_noirq(struct 
drm_i915_private *i915)
if (ret < 0)
goto cleanup_vga;
 
+   intel_pmdemand_init(i915);
+
intel_power_domains_init_hw(i915, false);
 
if (!HAS_DISPLAY(i915))
@@ -240,6 +243,10 @@ int intel_display_driver_probe_noirq(struct 
drm_i915_private *i915)
if (ret)
goto cleanup_vga_client_pw_domain_dmc;
 
+   ret =