<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jul 27, 2022 at 6:34 PM Radhakrishna Sripada <<a href="mailto:radhakrishna.sripada@intel.com">radhakrishna.sripada@intel.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">From Meteorlake, Latency Level, SAGV bloack time are read from<br>
LATENCY_SAGV register instead of the GT driver pcode mailbox. DDR type<br>
and QGV information are also tob read from Mem SS registers.<br>
<br>
Bspec: 49324, 64636<br>
<br>
Cc: Matt Roper <<a href="mailto:matthew.d.roper@intel.com" target="_blank">matthew.d.roper@intel.com</a>><br>
Original Author: Caz Yokoyama<br>
Signed-off-by: José Roberto de Souza <<a href="mailto:jose.souza@intel.com" target="_blank">jose.souza@intel.com</a>><br>
Signed-off-by: Radhakrishna Sripada <<a href="mailto:radhakrishna.sripada@intel.com" target="_blank">radhakrishna.sripada@intel.com</a>><br>
---<br>
 drivers/gpu/drm/i915/display/intel_bw.c | 49 +++++++++++++++++++------<br>
 drivers/gpu/drm/i915/display/intel_bw.h |  9 +++++<br>
 drivers/gpu/drm/i915/i915_reg.h         | 16 ++++++++<br>
 drivers/gpu/drm/i915/intel_dram.c       | 41 ++++++++++++++++++++-<br>
 drivers/gpu/drm/i915/intel_pm.c         |  8 +++-<br>
 5 files changed, 110 insertions(+), 13 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/i915/display/intel_bw.c b/drivers/gpu/drm/i915/display/intel_bw.c<br>
index 79269d2c476b..8bbf47da1716 100644<br>
--- a/drivers/gpu/drm/i915/display/intel_bw.c<br>
+++ b/drivers/gpu/drm/i915/display/intel_bw.c<br>
@@ -15,11 +15,6 @@<br>
 #include "intel_pcode.h"<br>
 #include "intel_pm.h"<br>
<br>
-/* Parameters for Qclk Geyserville (QGV) */<br>
-struct intel_qgv_point {<br>
-       u16 dclk, t_rp, t_rdpre, t_rc, t_ras, t_rcd;<br>
-};<br>
-<br>
 struct intel_psf_gv_point {<br>
        u8 clk; /* clock in multiples of 16.6666 MHz */<br>
 };<br>
@@ -137,6 +132,42 @@ int icl_pcode_restrict_qgv_points(struct drm_i915_private *dev_priv,<br>
        return 0;<br>
 }<br>
<br>
+static int mtl_read_qgv_point_info(struct drm_i915_private *dev_priv,<br></blockquote><div>No need to return value. i.e.</div><div><br></div><div>static void</div><div>mtl_read_qgv_point_info(struct drm_i915_private *dev_priv,</div><div>-caz</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+                                  struct intel_qgv_point *sp, int point)<br>
+{<br>
+       u32 val, val2;<br>
+       u16 dclk;<br>
+<br>
+       val = intel_uncore_read(&dev_priv->uncore,<br>
+                               MTL_MEM_SS_INFO_QGV_POINT(point, 0));<br>
+       val2 = intel_uncore_read(&dev_priv->uncore,<br>
+                                MTL_MEM_SS_INFO_QGV_POINT(point, 1));<br>
+       dclk = REG_FIELD_GET(MTL_DCLK_MASK, val);<br>
+       sp->dclk = DIV_ROUND_UP((16667 * dclk) +  500, 1000);<br>
+       sp->t_rp = REG_FIELD_GET(MTL_TRP_MASK, val);<br>
+       sp->t_rcd = REG_FIELD_GET(MTL_TRCD_MASK, val);<br>
+<br>
+       sp->t_rdpre = REG_FIELD_GET(MTL_TRDPRE_MASK, val2);<br>
+       sp->t_ras = REG_FIELD_GET(MTL_TRAS_MASK, val2);<br>
+<br>
+       sp->t_rc = sp->t_rp + sp->t_ras;<br>
+<br>
+       return 0;<br>
+}<br>
+<br>
+int<br>
+intel_read_qgv_point_info(struct drm_i915_private *dev_priv,<br>
+                         struct intel_qgv_point *sp,<br>
+                         int point)<br>
+{<br>
+       if (DISPLAY_VER(dev_priv) >= 14)<br>
+               return mtl_read_qgv_point_info(dev_priv, sp, point);<br>
+       else if (IS_DG1(dev_priv))<br>
+               return dg1_mchbar_read_qgv_point_info(dev_priv, sp, point);<br>
+       else<br>
+               return icl_pcode_read_qgv_point_info(dev_priv, sp, point);<br>
+}<br>
+<br>
 static int icl_get_qgv_points(struct drm_i915_private *dev_priv,<br>
                              struct intel_qgv_info *qi,<br>
                              bool is_y_tile)<br>
@@ -193,11 +224,7 @@ static int icl_get_qgv_points(struct drm_i915_private *dev_priv,<br>
        for (i = 0; i < qi->num_points; i++) {<br>
                struct intel_qgv_point *sp = &qi->points[i];<br>
<br>
-               if (IS_DG1(dev_priv))<br>
-                       ret = dg1_mchbar_read_qgv_point_info(dev_priv, sp, i);<br>
-               else<br>
-                       ret = icl_pcode_read_qgv_point_info(dev_priv, sp, i);<br>
-<br>
+               ret = intel_read_qgv_point_info(dev_priv, sp, i);<br>
                if (ret)<br>
                        return ret;<br>
<br>
@@ -560,7 +587,7 @@ void intel_bw_init_hw(struct drm_i915_private *dev_priv)<br>
<br>
        if (IS_DG2(dev_priv))<br>
                dg2_get_bw_info(dev_priv);<br>
-       else if (IS_ALDERLAKE_P(dev_priv))<br>
+       else if (DISPLAY_VER(dev_priv) >= 13 || IS_ALDERLAKE_P(dev_priv))<br>
                tgl_get_bw_info(dev_priv, &adlp_sa_info);<br>
        else if (IS_ALDERLAKE_S(dev_priv))<br>
                tgl_get_bw_info(dev_priv, &adls_sa_info);<br>
diff --git a/drivers/gpu/drm/i915/display/intel_bw.h b/drivers/gpu/drm/i915/display/intel_bw.h<br>
index cb7ee3a24a58..b4c6665b0cf0 100644<br>
--- a/drivers/gpu/drm/i915/display/intel_bw.h<br>
+++ b/drivers/gpu/drm/i915/display/intel_bw.h<br>
@@ -46,6 +46,11 @@ struct intel_bw_state {<br>
        u8 num_active_planes[I915_MAX_PIPES];<br>
 };<br>
<br>
+/* Parameters for Qclk Geyserville (QGV) */<br>
+struct intel_qgv_point {<br>
+       u16 dclk, t_rp, t_rdpre, t_rc, t_ras, t_rcd;<br>
+};<br>
+<br>
 #define to_intel_bw_state(x) container_of((x), struct intel_bw_state, base)<br>
<br>
 struct intel_bw_state *<br>
@@ -69,4 +74,8 @@ int intel_bw_calc_min_cdclk(struct intel_atomic_state *state,<br>
 int intel_bw_min_cdclk(struct drm_i915_private *i915,<br>
                       const struct intel_bw_state *bw_state);<br>
<br>
+int intel_read_qgv_point_info(struct drm_i915_private *dev_priv,<br>
+                             struct intel_qgv_point *sp,<br>
+                             int point);<br>
+<br>
 #endif /* __INTEL_BW_H__ */<br>
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h<br>
index 23b50d671550..d37607109398 100644<br>
--- a/drivers/gpu/drm/i915/i915_reg.h<br>
+++ b/drivers/gpu/drm/i915/i915_reg.h<br>
@@ -8761,4 +8761,20 @@ enum skl_power_gate {<br>
 #define  MTL_LATENCY_LEVEL0_2_4_MASK   REG_GENMASK(12, 0)<br>
 #define  MTL_LATENCY_LEVEL1_3_5_MASK   REG_GENMASK(28, 16)<br>
<br>
+#define MTL_LATENCY_SAGV               _MMIO(0x4578c)<br>
+#define  MTL_LATENCY_QCLK_SAGV         REG_GENMASK(12, 0)<br>
+<br>
+#define MTL_MEM_SS_INFO_GLOBAL                 _MMIO(0x45700)<br>
+#define  MTL_DDR_TYPE_MASK                     REG_GENMASK(3, 0)<br>
+#define  MTL_N_OF_POPULATED_CH_MASK            REG_GENMASK(7, 4)<br>
+#define  MTL_N_OF_ENABLED_QGV_POINTS_MASK      REG_GENMASK(11, 8)<br>
+<br>
+#define MTL_MEM_SS_INFO_QGV_POINT(point, bitgroup) \<br>
+        _MMIO(0x45710 + ((point) * 2 + (bitgroup)) * sizeof(u32))<br>
+#define  MTL_TRDPRE_MASK               REG_GENMASK(7, 0)<br>
+#define  MTL_TRAS_MASK                 REG_GENMASK(16, 8)<br>
+#define  MTL_DCLK_MASK                 REG_GENMASK(15, 0)<br>
+#define  MTL_TRP_MASK                  REG_GENMASK(23, 16)<br>
+#define  MTL_TRCD_MASK                 REG_GENMASK(31, 24)<br>
+<br>
 #endif /* _I915_REG_H_ */<br>
diff --git a/drivers/gpu/drm/i915/intel_dram.c b/drivers/gpu/drm/i915/intel_dram.c<br>
index 437447119770..2403ccd52c74 100644<br>
--- a/drivers/gpu/drm/i915/intel_dram.c<br>
+++ b/drivers/gpu/drm/i915/intel_dram.c<br>
@@ -466,6 +466,43 @@ static int gen12_get_dram_info(struct drm_i915_private *i915)<br>
        return icl_pcode_read_mem_global_info(i915);<br>
 }<br>
<br>
+static int xelpdp_get_dram_info(struct drm_i915_private *i915)<br>
+{<br>
+       u32 val = intel_uncore_read(&i915->uncore, MTL_MEM_SS_INFO_GLOBAL);<br>
+       struct dram_info *dram_info = &i915->dram_info;<br>
+<br>
+       val = REG_FIELD_GET(MTL_DDR_TYPE_MASK, val);<br>
+       switch (val) {<br>
+       case 0:<br>
+               dram_info->type = INTEL_DRAM_DDR4;<br>
+               break;<br>
+       case 1:<br>
+               dram_info->type = INTEL_DRAM_DDR5;<br>
+               break;<br>
+       case 2:<br>
+               dram_info->type = INTEL_DRAM_LPDDR5;<br>
+               break;<br>
+       case 3:<br>
+               dram_info->type = INTEL_DRAM_LPDDR4;<br>
+               break;<br>
+       case 4:<br>
+               dram_info->type = INTEL_DRAM_DDR3;<br>
+               break;<br>
+       case 5:<br>
+               dram_info->type = INTEL_DRAM_LPDDR3;<br>
+               break;<br>
+       default:<br>
+               MISSING_CASE(val);<br>
+               return -EINVAL;<br>
+       }<br>
+<br>
+       dram_info->num_channels = REG_FIELD_GET(MTL_N_OF_POPULATED_CH_MASK, val);<br>
+       dram_info->num_qgv_points = REG_FIELD_GET(MTL_N_OF_ENABLED_QGV_POINTS_MASK, val);<br>
+       /* PSF GV points not supported in D14+ */<br>
+<br>
+       return 0;<br>
+}<br>
+<br>
 void intel_dram_detect(struct drm_i915_private *i915)<br>
 {<br>
        struct dram_info *dram_info = &i915->dram_info;<br>
@@ -480,7 +517,9 @@ void intel_dram_detect(struct drm_i915_private *i915)<br>
         */<br>
        dram_info->wm_lv_0_adjust_needed = !IS_GEN9_LP(i915);<br>
<br>
-       if (GRAPHICS_VER(i915) >= 12)<br>
+       if (DISPLAY_VER(i915) >= 14)<br>
+               ret = xelpdp_get_dram_info(i915);<br>
+       else if (GRAPHICS_VER(i915) >= 12)<br>
                ret = gen12_get_dram_info(i915);<br>
        else if (GRAPHICS_VER(i915) >= 11)<br>
                ret = gen11_get_dram_info(i915);<br>
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c<br>
index fac565d23d57..f71b3b8b590c 100644<br>
--- a/drivers/gpu/drm/i915/intel_pm.c<br>
+++ b/drivers/gpu/drm/i915/intel_pm.c<br>
@@ -3698,7 +3698,13 @@ intel_has_sagv(struct drm_i915_private *dev_priv)<br>
 static u32<br>
 intel_sagv_block_time(struct drm_i915_private *dev_priv)<br>
 {<br>
-       if (DISPLAY_VER(dev_priv) >= 12) {<br>
+       if (DISPLAY_VER(dev_priv) >= 14) {<br>
+               u32 val;<br>
+<br>
+               val = intel_uncore_read(&dev_priv->uncore, MTL_LATENCY_SAGV);<br>
+<br>
+               return REG_FIELD_GET(MTL_LATENCY_QCLK_SAGV, val);<br>
+       } else if (DISPLAY_VER(dev_priv) >= 12) {<br>
                u32 val = 0;<br>
                int ret;<br>
<br>
-- <br>
2.25.1<br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>-caz, caz at caztech dot com, 503-six one zero - five six nine nine(m)<br></div></div></div></div></div></div></div></div></div></div></div></div>