drm/i915/uc: Add pretty printer for uc firmware
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Tue, 17 Oct 2017 09:44:49 +0000 (09:44 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Tue, 17 Oct 2017 15:42:56 +0000 (16:42 +0100)
Debugfs for GuC and HuC load info have similar common part.
Move and update dump of uc_fw to separate helper for reuse.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20171017094449.22584-1-michal.wajdeczko@intel.com
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
drivers/gpu/drm/i915/i915_debugfs.c
drivers/gpu/drm/i915/intel_uc_fw.c
drivers/gpu/drm/i915/intel_uc_fw.h

index 40287e9f00d788720600c15880c30eddccbe4683..5dcc702942ece8a4150b0c1b9f6c33bc31127664 100644 (file)
@@ -2359,27 +2359,13 @@ static int i915_llc(struct seq_file *m, void *data)
 static int i915_huc_load_status_info(struct seq_file *m, void *data)
 {
        struct drm_i915_private *dev_priv = node_to_i915(m->private);
-       struct intel_uc_fw *huc_fw = &dev_priv->huc.fw;
+       struct drm_printer p;
 
        if (!HAS_HUC_UCODE(dev_priv))
                return 0;
 
-       seq_puts(m, "HuC firmware status:\n");
-       seq_printf(m, "\tpath: %s\n", huc_fw->path);
-       seq_printf(m, "\tfetch: %s\n",
-               intel_uc_fw_status_repr(huc_fw->fetch_status));
-       seq_printf(m, "\tload: %s\n",
-               intel_uc_fw_status_repr(huc_fw->load_status));
-       seq_printf(m, "\tversion wanted: %d.%d\n",
-               huc_fw->major_ver_wanted, huc_fw->minor_ver_wanted);
-       seq_printf(m, "\tversion found: %d.%d\n",
-               huc_fw->major_ver_found, huc_fw->minor_ver_found);
-       seq_printf(m, "\theader: offset is %d; size = %d\n",
-               huc_fw->header_offset, huc_fw->header_size);
-       seq_printf(m, "\tuCode: offset is %d; size = %d\n",
-               huc_fw->ucode_offset, huc_fw->ucode_size);
-       seq_printf(m, "\tRSA: offset is %d; size = %d\n",
-               huc_fw->rsa_offset, huc_fw->rsa_size);
+       p = drm_seq_file_printer(m);
+       intel_uc_fw_dump(&dev_priv->huc.fw, &p);
 
        intel_runtime_pm_get(dev_priv);
        seq_printf(m, "\nHuC status 0x%08x:\n", I915_READ(HUC_STATUS2));
@@ -2391,29 +2377,14 @@ static int i915_huc_load_status_info(struct seq_file *m, void *data)
 static int i915_guc_load_status_info(struct seq_file *m, void *data)
 {
        struct drm_i915_private *dev_priv = node_to_i915(m->private);
-       struct intel_uc_fw *guc_fw = &dev_priv->guc.fw;
+       struct drm_printer p;
        u32 tmp, i;
 
        if (!HAS_GUC_UCODE(dev_priv))
                return 0;
 
-       seq_printf(m, "GuC firmware status:\n");
-       seq_printf(m, "\tpath: %s\n",
-               guc_fw->path);
-       seq_printf(m, "\tfetch: %s\n",
-               intel_uc_fw_status_repr(guc_fw->fetch_status));
-       seq_printf(m, "\tload: %s\n",
-               intel_uc_fw_status_repr(guc_fw->load_status));
-       seq_printf(m, "\tversion wanted: %d.%d\n",
-               guc_fw->major_ver_wanted, guc_fw->minor_ver_wanted);
-       seq_printf(m, "\tversion found: %d.%d\n",
-               guc_fw->major_ver_found, guc_fw->minor_ver_found);
-       seq_printf(m, "\theader: offset is %d; size = %d\n",
-               guc_fw->header_offset, guc_fw->header_size);
-       seq_printf(m, "\tuCode: offset is %d; size = %d\n",
-               guc_fw->ucode_offset, guc_fw->ucode_size);
-       seq_printf(m, "\tRSA: offset is %d; size = %d\n",
-               guc_fw->rsa_offset, guc_fw->rsa_size);
+       p = drm_seq_file_printer(m);
+       intel_uc_fw_dump(&dev_priv->guc.fw, &p);
 
        intel_runtime_pm_get(dev_priv);
 
index 7bb0109bfbbdf294dd4eab5f9c09dfee6431d44d..973888e94cba69314d4f9170c76feb61144e8a2a 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include <linux/firmware.h>
+#include <drm/drm_print.h>
 
 #include "intel_uc_fw.h"
 #include "i915_drv.h"
@@ -290,3 +291,28 @@ void intel_uc_fw_fini(struct intel_uc_fw *uc_fw)
 
        uc_fw->fetch_status = INTEL_UC_FIRMWARE_NONE;
 }
+
+/**
+ * intel_uc_fw_dump - dump information about uC firmware
+ * @uc_fw: uC firmware
+ * @p: the &drm_printer
+ *
+ * Pretty printer for uC firmware.
+ */
+void intel_uc_fw_dump(struct intel_uc_fw *uc_fw, struct drm_printer *p)
+{
+       drm_printf(p, "%s firmware: %s\n",
+                  intel_uc_fw_type_repr(uc_fw->type), uc_fw->path);
+       drm_printf(p, "\tstatus: fetch %s, load %s\n",
+                  intel_uc_fw_status_repr(uc_fw->fetch_status),
+                  intel_uc_fw_status_repr(uc_fw->load_status));
+       drm_printf(p, "\tversion: wanted %u.%u, found %u.%u\n",
+                  uc_fw->major_ver_wanted, uc_fw->minor_ver_wanted,
+                  uc_fw->major_ver_found, uc_fw->minor_ver_found);
+       drm_printf(p, "\theader: offset %u, size %u\n",
+                  uc_fw->header_offset, uc_fw->header_size);
+       drm_printf(p, "\tuCode: offset %u, size %u\n",
+                  uc_fw->ucode_offset, uc_fw->ucode_size);
+       drm_printf(p, "\tRSA: offset %u, size %u\n",
+                  uc_fw->rsa_offset, uc_fw->rsa_size);
+}
index 412fbdc4db9333d58be4919afbc758aa84871a5e..1329036693918473734f931da7a05b903c3f00d3 100644 (file)
@@ -25,6 +25,7 @@
 #ifndef _INTEL_UC_FW_H_
 #define _INTEL_UC_FW_H_
 
+struct drm_printer;
 struct drm_i915_private;
 struct i915_vma;
 
@@ -115,5 +116,6 @@ int intel_uc_fw_upload(struct intel_uc_fw *uc_fw,
                       int (*xfer)(struct intel_uc_fw *uc_fw,
                                   struct i915_vma *vma));
 void intel_uc_fw_fini(struct intel_uc_fw *uc_fw);
+void intel_uc_fw_dump(struct intel_uc_fw *uc_fw, struct drm_printer *p);
 
 #endif