Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Govindapillai, Vinod" <vinod.govindapillai@intel.com>
To: "Deak, Imre" <imre.deak@intel.com>
Cc: "intel-gfx@lists.freedesktop.org" <intel-gfx@lists.freedesktop.org>
Subject: Re: [Intel-gfx] [PATCH v12 6/7] drm/i915/mtl: find the best QGV point for the SAGV configuration
Date: Mon, 5 Jun 2023 09:59:47 +0000	[thread overview]
Message-ID: <60cb72d491c1466ed392b9be394369e84adb4714.camel@intel.com> (raw)
In-Reply-To: <ZH2vhnVeskAXdbPj@ideak-desk>

On Mon, 2023-06-05 at 12:49 +0300, Imre Deak wrote:
> On Thu, Jun 01, 2023 at 07:03:49PM +0300, Vinod Govindapillai wrote:
> > From MTL onwards, we need to find the best QGV point based on
> > the required data rate and pass the peak BW of that point to
> > the punit to lock the corresponding QGV point.
> > 
> > v1: Fix for warning from kernel test robot
> > 
> > Bspec: 64636
> > 
> > Reported-by: kernel test robot <lkp@intel.com>
> > Closes: https://lore.kernel.org/r/202305280253.Ab8bRV2w-lkp@intel.com/
> > Reported-by: Dan Carpenter <error27@gmail.com>
> > Closes: https://lore.kernel.org/r/202305280253.Ab8bRV2w-lkp@intel.com/
> > Signed-off-by: Vinod Govindapillai <vinod.govindapillai@intel.com>
> > Reviewed-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
> > ---
> >  drivers/gpu/drm/i915/display/intel_bw.c | 87 ++++++++++++++++++++++++-
> >  drivers/gpu/drm/i915/display/intel_bw.h |  6 ++
> >  2 files changed, 91 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/display/intel_bw.c b/drivers/gpu/drm/i915/display/intel_bw.c
> > index b1cbeda0b2e3..7672963dc49c 100644
> > --- a/drivers/gpu/drm/i915/display/intel_bw.c
> > +++ b/drivers/gpu/drm/i915/display/intel_bw.c
> > @@ -803,6 +803,85 @@ intel_atomic_get_bw_state(struct intel_atomic_state *state)
> >         return to_intel_bw_state(bw_state);
> >  }
> >  
> > +static int mtl_find_qgv_points(struct drm_i915_private *i915,
> > +                              unsigned int data_rate,
> > +                              unsigned int num_active_planes,
> > +                              const struct intel_bw_state *old_bw_state,
> > +                              struct intel_bw_state *new_bw_state)
> > +{
> > +       unsigned int best_rate = UINT_MAX;
> > +       unsigned int num_qgv_points = i915->display.bw.max[0].num_qgv_points;
> > +       unsigned int qgv_peak_bw  = 0;
> > +       int i;
> > +       int ret;
> > +
> > +       ret = intel_atomic_lock_global_state(&new_bw_state->base);
> > +       if (ret)
> > +               return ret;
> > +
> > +       /*
> > +        * If SAGV cannot be enabled, disable the pcode SAGV by passing all 1's
> > +        * for qgv peak bw in PM Demand request. So assign UINT_MAX if SAGV is
> > +        * not enabled. PM Demand code will clamp the value for the register
> > +        */
> > +       if (!intel_can_enable_sagv(i915, new_bw_state)) {
> > +               new_bw_state->qgv_point_peakbw = UINT_MAX;
> > +               drm_dbg_kms(&i915->drm, "No SAGV, use UINT_MAX as peak bw.");
> > +               goto out;
> > +       }
> > +
> > +       /*
> > +        * Find the best QGV point by comparing the data_rate with max data rate
> > +        * offered per plane group
> > +        */
> > +       for (i = 0; i < num_qgv_points; i++) {
> > +               unsigned int bw_index =
> > +                       tgl_max_bw_index(i915, num_active_planes, i);
> > +               unsigned int max_data_rate;
> > +
> > +               if (bw_index >= ARRAY_SIZE(i915->display.bw.max))
> > +                       continue;
> > +
> > +               max_data_rate = i915->display.bw.max[bw_index].deratedbw[i];
> > +
> > +               if (max_data_rate < data_rate)
> > +                       continue;
> > +
> > +               if (max_data_rate - data_rate < best_rate) {
> > +                       best_rate = max_data_rate - data_rate;
> > +                       qgv_peak_bw = i915->display.bw.max[bw_index].peakbw[i];
> > +               }
> > +
> > +               drm_dbg_kms(&i915->drm, "QGV point %d: max bw %d required %d qgv_peak_bw: %d\n",
> > +                           i, max_data_rate, data_rate, qgv_peak_bw);
> > +       }
> > +
> > +       drm_dbg_kms(&i915->drm, "Matching peaks QGV bw: %d for required data rate: %d\n",
> > +                   qgv_peak_bw, data_rate);
> > +
> > +       /*
> > +        * The display configuration cannot be supported if no QGV point
> > +        * satisfying the required data rate is found
> > +        */
> > +       if (qgv_peak_bw == 0) {
> > +               drm_dbg_kms(&i915->drm, "No QGV points for bw %d for display configuration(%d
> > active planes).\n",
> > +                           data_rate, num_active_planes);
> > +               return -EINVAL;
> > +       }
> > +
> > +       /* MTL PM DEMAND expects QGV BW parameter in multiples of 100 mbps */
> > +       new_bw_state->qgv_point_peakbw = DIV_ROUND_CLOSEST(qgv_peak_bw, 100);
> > +
> > +out:
> > +       if (new_bw_state->qgv_point_peakbw != old_bw_state->qgv_point_peakbw)  {
> > +               ret = intel_atomic_serialize_global_state(&new_bw_state->base);
> 
> qgv_point_beakbw is used as a parameter for the pmdemand command, for
> which there is a check later whether programming it is required or not.
> So why is global state serialized here?

Yes. good point. This need not to be serialized here. Will remove it.

Thanks
Vinod

> 
> > +               if (ret)
> > +                       return ret;
> > +       }
> > +
> > +       return 0;
> > +}
> > +
> >  static int icl_find_qgv_points(struct drm_i915_private *i915,
> >                                unsigned int data_rate,
> >                                unsigned int num_active_planes,
> > @@ -928,8 +1007,12 @@ static int intel_bw_check_qgv_points(struct drm_i915_private *i915,
> >  
> >         data_rate = DIV_ROUND_UP(data_rate, 1000);
> >  
> > -       return icl_find_qgv_points(i915, data_rate, num_active_planes,
> > -                                  old_bw_state, new_bw_state);
> > +       if (DISPLAY_VER(i915) >= 14)
> > +               return mtl_find_qgv_points(i915, data_rate, num_active_planes,
> > +                                          old_bw_state, new_bw_state);
> > +       else
> > +               return icl_find_qgv_points(i915, data_rate, num_active_planes,
> > +                                          old_bw_state, new_bw_state);
> >  }
> >  
> >  static bool intel_bw_state_changed(struct drm_i915_private *i915,
> > diff --git a/drivers/gpu/drm/i915/display/intel_bw.h b/drivers/gpu/drm/i915/display/intel_bw.h
> > index f20292143745..67ae66a3fcdd 100644
> > --- a/drivers/gpu/drm/i915/display/intel_bw.h
> > +++ b/drivers/gpu/drm/i915/display/intel_bw.h
> > @@ -34,6 +34,12 @@ struct intel_bw_state {
> >         /* bitmask of active pipes */
> >         u8 active_pipes;
> >  
> > +       /*
> > +        * From MTL onwards, to lock a QGV point, punit expects the peak BW of
> > +        * the selected QGV point as the parameter in multiples of 100MB/s
> > +        */
> > +       unsigned int qgv_point_peakbw;
> > +
> >         /*
> >          * Current QGV points mask, which restricts
> >          * some particular SAGV states, not to confuse
> > -- 
> > 2.34.1
> > 


  reply	other threads:[~2023-06-05  9:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-01 16:03 [Intel-gfx] [PATCH v12 0/7] mtl: add support for pmdemand Vinod Govindapillai
2023-06-01 16:03 ` [Intel-gfx] [PATCH v12 1/7] drm/i915: fix the derating percentage for MTL Vinod Govindapillai
2023-06-01 16:03 ` [Intel-gfx] [PATCH v12 2/7] drm/i915: update the QGV point frequency calculations Vinod Govindapillai
2023-06-01 16:03 ` [Intel-gfx] [PATCH v12 3/7] drm/i915: store the peak bw per QGV point Vinod Govindapillai
2023-06-01 16:03 ` [Intel-gfx] [PATCH v12 4/7] drm/i915: extract intel_bw_check_qgv_points() Vinod Govindapillai
2023-06-01 16:03 ` [Intel-gfx] [PATCH v12 5/7] drm/i915: modify max_bw to return index to intel_bw_info Vinod Govindapillai
2023-06-01 16:03 ` [Intel-gfx] [PATCH v12 6/7] drm/i915/mtl: find the best QGV point for the SAGV configuration Vinod Govindapillai
2023-06-05  9:49   ` Imre Deak
2023-06-05  9:59     ` Govindapillai, Vinod [this message]
2023-06-01 16:03 ` [Intel-gfx] [PATCH v12 7/7] drm/i915/mtl: Add support for PM DEMAND Vinod Govindapillai
2023-06-05 10:09   ` Imre Deak
2023-06-01 21:53 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for mtl: add support for pmdemand (rev12) Patchwork
2023-06-01 21:53 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2023-06-01 22:12 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2023-06-04  0:50 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=60cb72d491c1466ed392b9be394369e84adb4714.camel@intel.com \
    --to=vinod.govindapillai@intel.com \
    --cc=imre.deak@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox