drm/i915: Remove user pinning code
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / drm / i915 / i915_debugfs.c
index 319da61354b09831dc9beef2ed23a70bd20cb3a9..a47fc25e6bb446c56de0e4ae5c5ffb7b1c9c56d6 100644 (file)
@@ -96,9 +96,7 @@ static int i915_capabilities(struct seq_file *m, void *data)
 
 static const char *get_pin_flag(struct drm_i915_gem_object *obj)
 {
-       if (obj->user_pin_count > 0)
-               return "P";
-       else if (i915_gem_obj_is_pinned(obj))
+       if (i915_gem_obj_is_pinned(obj))
                return "p";
        else
                return " ";
@@ -1240,11 +1238,12 @@ static int vlv_drpc_info(struct seq_file *m)
        struct drm_info_node *node = m->private;
        struct drm_device *dev = node->minor->dev;
        struct drm_i915_private *dev_priv = dev->dev_private;
-       u32 rpmodectl1, rcctl1;
+       u32 rpmodectl1, rcctl1, pw_status;
        unsigned fw_rendercount = 0, fw_mediacount = 0;
 
        intel_runtime_pm_get(dev_priv);
 
+       pw_status = I915_READ(VLV_GTLC_PW_STATUS);
        rpmodectl1 = I915_READ(GEN6_RP_CONTROL);
        rcctl1 = I915_READ(GEN6_RC_CONTROL);
 
@@ -1263,11 +1262,9 @@ static int vlv_drpc_info(struct seq_file *m)
                   yesno(rcctl1 & (GEN7_RC_CTL_TO_MODE |
                                        GEN6_RC_CTL_EI_MODE(1))));
        seq_printf(m, "Render Power Well: %s\n",
-                       (I915_READ(VLV_GTLC_PW_STATUS) &
-                               VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down");
+                  (pw_status & VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down");
        seq_printf(m, "Media Power Well: %s\n",
-                       (I915_READ(VLV_GTLC_PW_STATUS) &
-                               VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down");
+                  (pw_status & VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down");
 
        seq_printf(m, "Render RC6 residency since boot: %u\n",
                   I915_READ(VLV_GT_RENDER_RC6));
@@ -1773,6 +1770,50 @@ static int i915_context_status(struct seq_file *m, void *unused)
        return 0;
 }
 
+static void i915_dump_lrc_obj(struct seq_file *m,
+                             struct intel_engine_cs *ring,
+                             struct drm_i915_gem_object *ctx_obj)
+{
+       struct page *page;
+       uint32_t *reg_state;
+       int j;
+       unsigned long ggtt_offset = 0;
+
+       if (ctx_obj == NULL) {
+               seq_printf(m, "Context on %s with no gem object\n",
+                          ring->name);
+               return;
+       }
+
+       seq_printf(m, "CONTEXT: %s %u\n", ring->name,
+                  intel_execlists_ctx_id(ctx_obj));
+
+       if (!i915_gem_obj_ggtt_bound(ctx_obj))
+               seq_puts(m, "\tNot bound in GGTT\n");
+       else
+               ggtt_offset = i915_gem_obj_ggtt_offset(ctx_obj);
+
+       if (i915_gem_object_get_pages(ctx_obj)) {
+               seq_puts(m, "\tFailed to get pages for context object\n");
+               return;
+       }
+
+       page = i915_gem_object_get_page(ctx_obj, 1);
+       if (!WARN_ON(page == NULL)) {
+               reg_state = kmap_atomic(page);
+
+               for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) {
+                       seq_printf(m, "\t[0x%08lx] 0x%08x 0x%08x 0x%08x 0x%08x\n",
+                                  ggtt_offset + 4096 + (j * 4),
+                                  reg_state[j], reg_state[j + 1],
+                                  reg_state[j + 2], reg_state[j + 3]);
+               }
+               kunmap_atomic(reg_state);
+       }
+
+       seq_putc(m, '\n');
+}
+
 static int i915_dump_lrc(struct seq_file *m, void *unused)
 {
        struct drm_info_node *node = (struct drm_info_node *) m->private;
@@ -1793,29 +1834,9 @@ static int i915_dump_lrc(struct seq_file *m, void *unused)
 
        list_for_each_entry(ctx, &dev_priv->context_list, link) {
                for_each_ring(ring, dev_priv, i) {
-                       struct drm_i915_gem_object *ctx_obj = ctx->engine[i].state;
-
-                       if (ring->default_context == ctx)
-                               continue;
-
-                       if (ctx_obj) {
-                               struct page *page = i915_gem_object_get_page(ctx_obj, 1);
-                               uint32_t *reg_state = kmap_atomic(page);
-                               int j;
-
-                               seq_printf(m, "CONTEXT: %s %u\n", ring->name,
-                                               intel_execlists_ctx_id(ctx_obj));
-
-                               for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) {
-                                       seq_printf(m, "\t[0x%08lx] 0x%08x 0x%08x 0x%08x 0x%08x\n",
-                                       i915_gem_obj_ggtt_offset(ctx_obj) + 4096 + (j * 4),
-                                       reg_state[j], reg_state[j + 1],
-                                       reg_state[j + 2], reg_state[j + 3]);
-                               }
-                               kunmap_atomic(reg_state);
-
-                               seq_putc(m, '\n');
-                       }
+                       if (ring->default_context != ctx)
+                               i915_dump_lrc_obj(m, ring,
+                                                 ctx->engine[i].state);
                }
        }
 
@@ -1975,6 +1996,8 @@ static int i915_swizzle_info(struct seq_file *m, void *data)
        if (IS_GEN3(dev) || IS_GEN4(dev)) {
                seq_printf(m, "DDC = 0x%08x\n",
                           I915_READ(DCC));
+               seq_printf(m, "DDC2 = 0x%08x\n",
+                          I915_READ(DCC2));
                seq_printf(m, "C0DRB3 = 0x%04x\n",
                           I915_READ16(C0DRB3));
                seq_printf(m, "C1DRB3 = 0x%04x\n",
@@ -1997,6 +2020,10 @@ static int i915_swizzle_info(struct seq_file *m, void *data)
                seq_printf(m, "DISP_ARB_CTL = 0x%08x\n",
                           I915_READ(DISP_ARB_CTL));
        }
+
+       if (dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES)
+               seq_puts(m, "L-shaped memory detected\n");
+
        intel_runtime_pm_put(dev_priv);
        mutex_unlock(&dev->struct_mutex);
 
@@ -2126,6 +2153,8 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)
        struct drm_device *dev = node->minor->dev;
        struct drm_i915_private *dev_priv = dev->dev_private;
        u32 psrperf = 0;
+       u32 stat[3];
+       enum pipe pipe;
        bool enabled = false;
 
        intel_runtime_pm_get(dev_priv);
@@ -2140,14 +2169,36 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)
        seq_printf(m, "Re-enable work scheduled: %s\n",
                   yesno(work_busy(&dev_priv->psr.work.work)));
 
-       enabled = HAS_PSR(dev) &&
-               I915_READ(EDP_PSR_CTL(dev)) & EDP_PSR_ENABLE;
-       seq_printf(m, "HW Enabled & Active bit: %s\n", yesno(enabled));
+       if (HAS_PSR(dev)) {
+               if (HAS_DDI(dev))
+                       enabled = I915_READ(EDP_PSR_CTL(dev)) & EDP_PSR_ENABLE;
+               else {
+                       for_each_pipe(dev_priv, pipe) {
+                               stat[pipe] = I915_READ(VLV_PSRSTAT(pipe)) &
+                                       VLV_EDP_PSR_CURR_STATE_MASK;
+                               if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) ||
+                                   (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE))
+                                       enabled = true;
+                       }
+               }
+       }
+       seq_printf(m, "HW Enabled & Active bit: %s", yesno(enabled));
+
+       if (!HAS_DDI(dev))
+               for_each_pipe(dev_priv, pipe) {
+                       if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) ||
+                           (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE))
+                               seq_printf(m, " pipe %c", pipe_name(pipe));
+               }
+       seq_puts(m, "\n");
 
-       if (HAS_PSR(dev))
+       /* CHV PSR has no kind of performance counter */
+       if (HAS_PSR(dev) && HAS_DDI(dev)) {
                psrperf = I915_READ(EDP_PSR_PERF_CNT(dev)) &
                        EDP_PSR_PERF_CNT_MASK;
-       seq_printf(m, "Performance_Counter: %u\n", psrperf);
+
+               seq_printf(m, "Performance_Counter: %u\n", psrperf);
+       }
        mutex_unlock(&dev_priv->psr.lock);
 
        intel_runtime_pm_put(dev_priv);
@@ -3309,6 +3360,11 @@ static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe,
        if (pipe_crc->source && source)
                return -EINVAL;
 
+       if (!intel_display_power_is_enabled(dev_priv, POWER_DOMAIN_PIPE(pipe))) {
+               DRM_DEBUG_KMS("Trying to capture CRC while pipe is off\n");
+               return -EIO;
+       }
+
        if (IS_GEN2(dev))
                ret = i8xx_pipe_crc_ctl_reg(&source, &val);
        else if (INTEL_INFO(dev)->gen < 5)