drm/i915/dg1: Wait for pcode/uncore handshake at startup
authorMatt Roper <matthew.d.roper@intel.com>
Thu, 1 Oct 2020 06:39:17 +0000 (23:39 -0700)
committerLucas De Marchi <lucas.demarchi@intel.com>
Mon, 5 Oct 2020 22:54:45 +0000 (15:54 -0700)
DG1 does some additional pcode/uncore handshaking at
boot time; this handshaking must complete before various other pcode
commands are effective and before general work is submitted to the GPU.
We need to poll a new pcode mailbox during startup until it reports that
this handshaking is complete.

The bspec doesn't give guidance on how long we may need to wait for this
handshaking to complete.  For now, let's just set a really long timeout;
if we still don't get a completion status by the end of that timeout,
we'll just continue on and hope for the best.

v2 (Lucas): Rename macros to make clear the relation between command and
   result (requested by José)

Bspec: 52065
Cc: Clinton Taylor <Clinton.A.Taylor@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201001063917.3133475-2-lucas.demarchi@intel.com
drivers/gpu/drm/i915/i915_drv.c
drivers/gpu/drm/i915/i915_reg.h
drivers/gpu/drm/i915/intel_sideband.c
drivers/gpu/drm/i915/intel_sideband.h

index 0a76df1a7d5168439a77fbaa93442de195e89571..f601f3ae0794abde456ddc5382dbd6264bac95f1 100644 (file)
@@ -84,6 +84,7 @@
 #include "intel_gvt.h"
 #include "intel_memory_region.h"
 #include "intel_pm.h"
+#include "intel_sideband.h"
 #include "vlv_suspend.h"
 
 static struct drm_driver driver;
@@ -616,6 +617,8 @@ static int i915_driver_hw_probe(struct drm_i915_private *dev_priv)
         */
        intel_dram_detect(dev_priv);
 
+       intel_pcode_init(dev_priv);
+
        intel_bw_init_hw(dev_priv);
 
        return 0;
index 88c215cf97d4c3018e098b20e26205223e5e42fb..ca97b360bab3b1f27e75c3a68368a826b6a22217 100644 (file)
@@ -9227,6 +9227,9 @@ enum {
 #define     GEN9_SAGV_DISABLE                  0x0
 #define     GEN9_SAGV_IS_DISABLED              0x1
 #define     GEN9_SAGV_ENABLE                   0x3
+#define   DG1_PCODE_STATUS                     0x7E
+#define     DG1_UNCORE_GET_INIT_STATUS         0x0
+#define     DG1_UNCORE_INIT_STATUS_COMPLETE    0x1
 #define GEN12_PCODE_READ_SAGV_BLOCK_TIME_US    0x23
 #define GEN6_PCODE_DATA                                _MMIO(0x138128)
 #define   GEN6_PCODE_FREQ_IA_RATIO_SHIFT       8
index 5b3279262123262d6d79ef167cafe4625ddfeb3a..02ebf5a04a9bc15fcd6e985e3b4c21e7df3a200e 100644 (file)
@@ -555,3 +555,18 @@ out:
        return ret ? ret : status;
 #undef COND
 }
+
+void intel_pcode_init(struct drm_i915_private *i915)
+{
+       int ret;
+
+       if (!IS_DGFX(i915))
+               return;
+
+       ret = skl_pcode_request(i915, DG1_PCODE_STATUS,
+                               DG1_UNCORE_GET_INIT_STATUS,
+                               DG1_UNCORE_INIT_STATUS_COMPLETE,
+                               DG1_UNCORE_INIT_STATUS_COMPLETE, 50);
+       if (ret)
+               drm_err(&i915->drm, "Pcode did not report uncore initialization completion!\n");
+}
index 7fb95745a444948c681cae095777660832d9a47a..094c7b19c5d42e7ebfbd107019a7915d63df2d75 100644 (file)
@@ -138,4 +138,6 @@ int sandybridge_pcode_write_timeout(struct drm_i915_private *i915, u32 mbox,
 int skl_pcode_request(struct drm_i915_private *i915, u32 mbox, u32 request,
                      u32 reply_mask, u32 reply, int timeout_base_ms);
 
+void intel_pcode_init(struct drm_i915_private *i915);
+
 #endif /* _INTEL_SIDEBAND_H */