Skip to contentSkip to conversation

drm/i915/uc: Move uC related types into dedicated header

RFC Superseded Michal Wajdeczko 4 participants 8 messages Sep 26, 2017 – Sep 27, 2017

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

RFC 1/2 drm/i915/uc: Move uC related types into dedicated header

In old header structure we were mixing type definitions and declarations that prevent us from exposing some functions as inline. Lets try to fix that.

Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Sagar Arun Kamble <[email protected]>
---
 drivers/gpu/drm/i915/i915_debugfs.c   |   1 +
 drivers/gpu/drm/i915/i915_drv.h       |   2 +-
 drivers/gpu/drm/i915/i915_gem.c       |   1 +
 drivers/gpu/drm/i915/intel_guc_ct.c   |   1 +
 drivers/gpu/drm/i915/intel_guc_log.c  |   1 +
 drivers/gpu/drm/i915/intel_uc.h       | 180 +++-------------------------------
 drivers/gpu/drm/i915/intel_uc_types.h | 172 ++++++++++++++++++++++++++++++++
 7 files changed, 193 insertions(+), 165 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_uc_types.h
drivers/gpu/drm/i915/i915_debugfs.c +1 -0
index b4a6ac6..8f85add 100644
@@ -30,6 +30,7 @@
 #include <linux/sort.h>
 #include <linux/sched/mm.h>
 #include "intel_drv.h"
+#include "intel_uc.h"
 
 static inline struct drm_i915_private *node_to_i915(struct drm_info_node *node)
 {
drivers/gpu/drm/i915/i915_drv.h +1 -1
index b7cba89..521af91 100644
@@ -58,7 +58,6 @@
 #include "intel_uncore.h"
 #include "intel_bios.h"
 #include "intel_dpll_mgr.h"
-#include "intel_uc.h"
 #include "intel_lrc.h"
 #include "intel_ringbuffer.h"
 
@@ -73,6 +72,7 @@
 
 #include "i915_vma.h"
 
+#include "intel_uc_types.h"
 #include "intel_gvt.h"
 
 /* General customization:
drivers/gpu/drm/i915/i915_gem.c +1 -0
index 73eeb6b..fa70b7c 100644
@@ -35,6 +35,7 @@
 #include "intel_drv.h"
 #include "intel_frontbuffer.h"
 #include "intel_mocs.h"
+#include "intel_uc.h"
 #include <linux/dma-fence-array.h>
 #include <linux/kthread.h>
 #include <linux/reservation.h>
drivers/gpu/drm/i915/intel_guc_ct.c +1 -0
index c4cbec1..cbeecd2 100644
@@ -23,6 +23,7 @@
 
 #include "i915_drv.h"
 #include "intel_guc_ct.h"
+#include "intel_uc.h"
 
 enum { CTB_SEND = 0, CTB_RECV = 1 };
 
drivers/gpu/drm/i915/intel_guc_log.c +1 -0
index 6571d96..024e3b1 100644
@@ -24,6 +24,7 @@
 #include <linux/debugfs.h>
 #include <linux/relay.h>
 #include "i915_drv.h"
+#include "intel_uc.h"
 
 static void guc_log_capture_logs(struct intel_guc *guc);
 
drivers/gpu/drm/i915/intel_uc.h +16 -164

213 lines not on this page · raw message

drivers/gpu/drm/i915/intel_uc_types.h new file +172 -0

172 lines not on this page · raw message

Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

RFC 2/2 drm/i915: Make intel_guc_wopcm_size() inline

It's small and we are using this function sporadically.

---
 drivers/gpu/drm/i915/intel_guc_loader.c | 11 -----------
 drivers/gpu/drm/i915/intel_uc.c         |  4 ++--
 drivers/gpu/drm/i915/intel_uc.h         | 13 ++++++++++++-
 3 files changed, 14 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/intel_guc_loader.c +0 -11
index c9e25be..387d105a 100644
@@ -250,17 +250,6 @@ static int guc_ucode_xfer_dma(struct drm_i915_private *dev_priv,
 	return ret;
 }
 
-u32 intel_guc_wopcm_size(struct drm_i915_private *dev_priv)
-{
-	u32 wopcm_size = GUC_WOPCM_TOP;
-
-	/* On BXT, the top of WOPCM is reserved for RC6 context */
-	if (IS_GEN9_LP(dev_priv))
-		wopcm_size -= BXT_GUC_WOPCM_RC6_RESERVED;
-
-	return wopcm_size;
-}
-
 /*
  * Load the GuC firmware blob into the MinuteIA.
  */
drivers/gpu/drm/i915/intel_uc.c +2 -2
index 2774778..1ef2de6 100644
@@ -188,7 +188,7 @@ static void fetch_uc_fw(struct drm_i915_private *dev_priv,
 		size = uc_fw->header_size + uc_fw->ucode_size;
 
 		/* Top 32k of WOPCM is reserved (8K stack + 24k RC6 context). */
-		if (size > intel_guc_wopcm_size(dev_priv)) {
+		if (size > intel_guc_wopcm_size(&dev_priv->guc)) {
 			DRM_ERROR("Firmware is too large to fit in WOPCM\n");
 			goto fail;
 		}
@@ -374,7 +374,7 @@ int intel_uc_init_hw(struct drm_i915_private *dev_priv)
 	}
 
 	/* init WOPCM */
-	I915_WRITE(GUC_WOPCM_SIZE, intel_guc_wopcm_size(dev_priv));
+	I915_WRITE(GUC_WOPCM_SIZE, intel_guc_wopcm_size(guc));
 	I915_WRITE(DMA_GUC_WOPCM_OFFSET,
 		   GUC_WOPCM_OFFSET_VALUE | HUC_LOADING_AGENT_GUC);
 
drivers/gpu/drm/i915/intel_uc.h +12 -1
index b0e8849..b65ba5c 100644
@@ -63,6 +63,18 @@ static inline void intel_guc_notify(struct intel_guc *guc)
 	guc->notify(guc);
 }
 
+static inline u32 intel_guc_wopcm_size(struct intel_guc *guc)
+{
+	struct drm_i915_private *dev_priv = guc_to_i915(guc);
+	u32 wopcm_size = GUC_WOPCM_TOP;
+
+	/* On BXT, the top of WOPCM is reserved for RC6 context */
+	if (IS_GEN9_LP(dev_priv))
+		wopcm_size -= BXT_GUC_WOPCM_RC6_RESERVED;
+
+	return wopcm_size;
+}
+
 static inline u32 guc_ggtt_offset(struct i915_vma *vma)
 {
 	u32 offset = i915_ggtt_offset(vma);
@@ -88,7 +100,6 @@ int intel_guc_select_fw(struct intel_guc *guc);
 int intel_guc_init_hw(struct intel_guc *guc);
 int intel_guc_suspend(struct drm_i915_private *dev_priv);
 int intel_guc_resume(struct drm_i915_private *dev_priv);
-u32 intel_guc_wopcm_size(struct drm_i915_private *dev_priv);
 
 /* i915_guc_submission.c */
 int i915_guc_submission_init(struct drm_i915_private *dev_priv);
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

Re: [RFC 2/2] drm/i915: Make intel_guc_wopcm_size() inline

Looks good to me.

Nitpicks:
1. s/dev_priv/i915 in intel_guc_wopcm_size
2. We are updating the parameter type of intel_guc_wopcm_size. Will it be necessary to update that change log and intent in the commit message?

Thanks
Sagar

Quoted 77 lines · Michal Wajdeczko

It's small and we are using this function sporadically.

---
  drivers/gpu/drm/i915/intel_guc_loader.c | 11 -----------
  drivers/gpu/drm/i915/intel_uc.c         |  4 ++--
  drivers/gpu/drm/i915/intel_uc.h         | 13 ++++++++++++-
  3 files changed, 14 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/intel_guc_loader.c +0 -11
index c9e25be..387d105a 100644
@@ -250,17 +250,6 @@ static int guc_ucode_xfer_dma(struct drm_i915_private *dev_priv,
  	return ret;
  }
 
-u32 intel_guc_wopcm_size(struct drm_i915_private *dev_priv)
-{
-	u32 wopcm_size = GUC_WOPCM_TOP;
-
-	/* On BXT, the top of WOPCM is reserved for RC6 context */
-	if (IS_GEN9_LP(dev_priv))
-		wopcm_size -= BXT_GUC_WOPCM_RC6_RESERVED;
-
-	return wopcm_size;
-}
-
  /*
   * Load the GuC firmware blob into the MinuteIA.
   */
drivers/gpu/drm/i915/intel_uc.c +2 -2
index 2774778..1ef2de6 100644
@@ -188,7 +188,7 @@ static void fetch_uc_fw(struct drm_i915_private *dev_priv,
  		size = uc_fw->header_size + uc_fw->ucode_size;
 
  		/* Top 32k of WOPCM is reserved (8K stack + 24k RC6 context). */
-		if (size > intel_guc_wopcm_size(dev_priv)) {
+		if (size > intel_guc_wopcm_size(&dev_priv->guc)) {
  			DRM_ERROR("Firmware is too large to fit in WOPCM\n");
  			goto fail;
  		}
@@ -374,7 +374,7 @@ int intel_uc_init_hw(struct drm_i915_private *dev_priv)
  	}
 
  	/* init WOPCM */
-	I915_WRITE(GUC_WOPCM_SIZE, intel_guc_wopcm_size(dev_priv));
+	I915_WRITE(GUC_WOPCM_SIZE, intel_guc_wopcm_size(guc));
  	I915_WRITE(DMA_GUC_WOPCM_OFFSET,
  		   GUC_WOPCM_OFFSET_VALUE | HUC_LOADING_AGENT_GUC);
 
drivers/gpu/drm/i915/intel_uc.h +12 -0
index b0e8849..b65ba5c 100644
@@ -63,6 +63,18 @@ static inline void intel_guc_notify(struct intel_guc *guc)
  	guc->notify(guc);
  }
 
+static inline u32 intel_guc_wopcm_size(struct intel_guc *guc)
+{
+	struct drm_i915_private *dev_priv = guc_to_i915(guc);
+	u32 wopcm_size = GUC_WOPCM_TOP;
+
+	/* On BXT, the top of WOPCM is reserved for RC6 context */
+	if (IS_GEN9_LP(dev_priv))
+		wopcm_size -= BXT_GUC_WOPCM_RC6_RESERVED;
+
+	return wopcm_size;
+}
+
  static inline u32 guc_ggtt_offset(struct i915_vma *vma)
  {
  	u32 offset = i915_ggtt_offset(vma);

drivers/gpu/drm/i915/intel_uc.h int intel_guc_select_fw(struct intel_guc *guc); · line 105

Quoted 7 lines
drivers/gpu/drm/i915/intel_uc.h +0 -1
@@ -88,7 +100,6 @@ int intel_guc_select_fw(struct intel_guc *guc);
  int intel_guc_init_hw(struct intel_guc *guc);
  int intel_guc_suspend(struct drm_i915_private *dev_priv);
  int intel_guc_resume(struct drm_i915_private *dev_priv);
-u32 intel_guc_wopcm_size(struct drm_i915_private *dev_priv);
 
  /* i915_guc_submission.c */
  int i915_guc_submission_init(struct drm_i915_private *dev_priv);

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw

✓ Fi.CI.BAT: success for series starting with [RFC,1/2] drm/i915/uc: Move uC related types into dedicated header

In reply to Michal Wajdeczko
== Series Details ==

== Series Details ==

Series: series starting with [RFC,1/2] drm/i915/uc: Move uC related types into dedicated header
URL : https://patchwork.freedesktop.org/series/30918/
State : success

== Summary ==

Series 30918v1 series starting with [RFC,1/2] drm/i915/uc: Move uC related types into dedicated header
https://patchwork.freedesktop.org/api/1.0/series/30918/revisions/1/mbox/

Test pm_rpm:

        Subgroup basic-rte:
                dmesg-warn -> PASS       (fi-cfl-s) fdo#102294

fdo#102294 https://bugs.freedesktop.org/show_bug.cgi?id=102294

fi-bdw-5557u     total:289  pass:268  dwarn:0   dfail:0   fail:0   skip:21  time:449s
fi-bdw-gvtdvm    total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:474s
fi-blb-e6850     total:289  pass:224  dwarn:1   dfail:0   fail:0   skip:64  time:416s
fi-bsw-n3050     total:289  pass:243  dwarn:0   dfail:0   fail:0   skip:46  time:513s
fi-bwr-2160      total:289  pass:184  dwarn:0   dfail:0   fail:0   skip:105 time:277s
fi-bxt-j4205     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:512s
fi-byt-j1900     total:289  pass:254  dwarn:1   dfail:0   fail:0   skip:34  time:489s
fi-byt-n2820     total:289  pass:250  dwarn:1   dfail:0   fail:0   skip:38  time:485s
fi-cfl-s         total:289  pass:223  dwarn:34  dfail:0   fail:0   skip:32  time:537s
fi-cnl-y         total:289  pass:257  dwarn:0   dfail:0   fail:5   skip:27  time:644s
fi-elk-e7500     total:289  pass:230  dwarn:0   dfail:0   fail:0   skip:59  time:421s
fi-glk-1         total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:567s
fi-hsw-4770      total:289  pass:263  dwarn:0   dfail:0   fail:0   skip:26  time:430s
fi-hsw-4770r     total:289  pass:263  dwarn:0   dfail:0   fail:0   skip:26  time:405s
fi-ilk-650       total:289  pass:229  dwarn:0   dfail:0   fail:0   skip:60  time:430s
fi-ivb-3520m     total:289  pass:261  dwarn:0   dfail:0   fail:0   skip:28  time:493s
fi-ivb-3770      total:289  pass:261  dwarn:0   dfail:0   fail:0   skip:28  time:473s
fi-kbl-7500u     total:289  pass:264  dwarn:1   dfail:0   fail:0   skip:24  time:468s
fi-kbl-7560u     total:289  pass:270  dwarn:0   dfail:0   fail:0   skip:19  time:579s
fi-kbl-r         total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:592s
fi-pnv-d510      total:289  pass:223  dwarn:1   dfail:0   fail:0   skip:65  time:548s
fi-skl-6260u     total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:453s
fi-skl-6700k     total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:748s
fi-skl-6770hq    total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:487s
fi-skl-gvtdvm    total:289  pass:266  dwarn:0   dfail:0   fail:0   skip:23  time:481s
fi-snb-2520m     total:289  pass:251  dwarn:0   dfail:0   fail:0   skip:38  time:574s
fi-snb-2600      total:289  pass:250  dwarn:0   dfail:0   fail:0   skip:39  time:416s

c4c623d58e38d49e692dc9141250b35e39170e6b drm-tip: 2017y-09m-26d-16h-37m-12s UTC integration manifest 8bcc49c080ce drm/i915: Make intel_guc_wopcm_size() inline
cb01c1b473e0 drm/i915/uc: Move uC related types into dedicated header

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_5822/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

✗ Fi.CI.IGT: failure for series starting with [RFC,1/2] drm/i915/uc: Move uC related types into dedicated header

In reply to Michal Wajdeczko
== Series Details ==

== Series Details ==

Series: series starting with [RFC,1/2] drm/i915/uc: Move uC related types into dedicated header
URL : https://patchwork.freedesktop.org/series/30918/
State : failure

== Summary ==

Test kms_flip:

        Subgroup flip-vs-expired-vblank:
                fail       -> PASS       (shard-hsw) fdo#102367
        Subgroup plain-flip-ts-check-interruptible:
                fail       -> PASS       (shard-hsw)
Test gem_exec_store:
        Subgroup pages-default:
                pass       -> FAIL       (shard-hsw)

fdo#102367 https://bugs.freedesktop.org/show_bug.cgi?id=102367

shard-hsw total:2429 pass:1334 dwarn:1 dfail:0 fail:11 skip:1083 time:9970s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_5822/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#5 lore raw
In reply to Michal Wajdeczko

Like this change as now headers becomes easy to read. Minor inputs suggested below.

Quoted 333 lines · Michal Wajdeczko

In old header structure we were mixing type definitions and declarations that prevent us from exposing some functions as inline. Lets try to fix that.

Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Sagar Arun Kamble <[email protected]>
---
  drivers/gpu/drm/i915/i915_debugfs.c   |   1 +
  drivers/gpu/drm/i915/i915_drv.h       |   2 +-
  drivers/gpu/drm/i915/i915_gem.c       |   1 +
  drivers/gpu/drm/i915/intel_guc_ct.c   |   1 +
  drivers/gpu/drm/i915/intel_guc_log.c  |   1 +
  drivers/gpu/drm/i915/intel_uc.h       | 180 +++-------------------------------
  drivers/gpu/drm/i915/intel_uc_types.h | 172 ++++++++++++++++++++++++++++++++
  7 files changed, 193 insertions(+), 165 deletions(-)

create mode 100644 drivers/gpu/drm/i915/intel_uc_types.h

drivers/gpu/drm/i915/i915_debugfs.c +1 -0
index b4a6ac6..8f85add 100644
@@ -30,6 +30,7 @@
  #include <linux/sort.h>
  #include <linux/sched/mm.h>
  #include "intel_drv.h"
+#include "intel_uc.h"
 
  static inline struct drm_i915_private *node_to_i915(struct drm_info_node *node)
  {
drivers/gpu/drm/i915/i915_drv.h +1 -1
index b7cba89..521af91 100644
@@ -58,7 +58,6 @@
  #include "intel_uncore.h"
  #include "intel_bios.h"
  #include "intel_dpll_mgr.h"
-#include "intel_uc.h"
  #include "intel_lrc.h"
  #include "intel_ringbuffer.h"
 
@@ -73,6 +72,7 @@
 
  #include "i915_vma.h"
 
+#include "intel_uc_types.h"
  #include "intel_gvt.h"
 
  /* General customization:
drivers/gpu/drm/i915/i915_gem.c +1 -0
index 73eeb6b..fa70b7c 100644
@@ -35,6 +35,7 @@
  #include "intel_drv.h"
  #include "intel_frontbuffer.h"
  #include "intel_mocs.h"
+#include "intel_uc.h"
  #include <linux/dma-fence-array.h>
  #include <linux/kthread.h>
  #include <linux/reservation.h>
drivers/gpu/drm/i915/intel_guc_ct.c +1 -0
index c4cbec1..cbeecd2 100644
@@ -23,6 +23,7 @@
 
  #include "i915_drv.h"
  #include "intel_guc_ct.h"
+#include "intel_uc.h"
 
  enum { CTB_SEND = 0, CTB_RECV = 1 };
 
drivers/gpu/drm/i915/intel_guc_log.c +1 -0
index 6571d96..024e3b1 100644
@@ -24,6 +24,7 @@
  #include <linux/debugfs.h>
  #include <linux/relay.h>
  #include "i915_drv.h"
+#include "intel_uc.h"
 
  static void guc_log_capture_logs(struct intel_guc *guc);
 
drivers/gpu/drm/i915/intel_uc.h +16 -164
index 6966349..b0e8849 100644
@@ -24,62 +24,8 @@
  #ifndef _INTEL_UC_H_
  #define _INTEL_UC_H_
 
-#include "intel_guc_fwif.h"
-#include "i915_guc_reg.h"
-#include "intel_ringbuffer.h"
-#include "intel_guc_ct.h"
-#include "i915_vma.h"
+#include "intel_uc_types.h"
 
-struct drm_i915_gem_request;
-
-/*
- * This structure primarily describes the GEM object shared with the GuC.
- * The specs sometimes refer to this object as a "GuC context", but we use
- * the term "client" to avoid confusion with hardware contexts. This
- * GEM object is held for the entire lifetime of our interaction with
- * the GuC, being allocated before the GuC is loaded with its firmware.
- * Because there's no way to update the address used by the GuC after
- * initialisation, the shared object must stay pinned into the GGTT as
- * long as the GuC is in use. We also keep the first page (only) mapped
- * into kernel address space, as it includes shared data that must be
- * updated on every request submission.
- *
- * The single GEM object described here is actually made up of several
- * separate areas, as far as the GuC is concerned. The first page (kept
- * kmap'd) includes the "process descriptor" which holds sequence data for
- * the doorbell, and one cacheline which actually *is* the doorbell; a
- * write to this will "ring the doorbell" (i.e. send an interrupt to the
- * GuC). The subsequent  pages of the client object constitute the work
- * queue (a circular array of work items), again described in the process
- * descriptor. Work queue pages are mapped momentarily as required.
- */
-struct i915_guc_client {
-	struct i915_vma *vma;
-	void *vaddr;
-	struct i915_gem_context *owner;
-	struct intel_guc *guc;
-
-	uint32_t engines;		/* bitmap of (host) engine ids	*/
-	uint32_t priority;
-	u32 stage_id;
-	uint32_t proc_desc_offset;
-
-	u16 doorbell_id;
-	unsigned long doorbell_offset;
-
-	spinlock_t wq_lock;
-	/* Per-engine counts of GuC submissions */
-	uint64_t submissions[I915_NUM_ENGINES];
-};
-
-enum intel_uc_fw_status {
-	INTEL_UC_FIRMWARE_FAIL = -1,
-	INTEL_UC_FIRMWARE_NONE = 0,
-	INTEL_UC_FIRMWARE_PENDING,
-	INTEL_UC_FIRMWARE_SUCCESS
-};
-
-/* User-friendly representation of an enum */
  static inline
  const char *intel_uc_fw_status_repr(enum intel_uc_fw_status status)
  {
@@ -96,12 +42,6 @@ const char *intel_uc_fw_status_repr(enum intel_uc_fw_status status)
  	return "<invalid>";
  }
 
-enum intel_uc_fw_type {
-	INTEL_UC_FW_TYPE_GUC,
-	INTEL_UC_FW_TYPE_HUC
-};
-
-/* User-friendly representation of an enum */
  static inline const char *intel_uc_fw_type_repr(enum intel_uc_fw_type type)
  {
  	switch (type) {
@@ -113,93 +53,23 @@ static inline const char *intel_uc_fw_type_repr(enum intel_uc_fw_type type)
  	return "uC";
  }
 
-/*
- * This structure encapsulates all the data needed during the process
- * of fetching, caching, and loading the firmware image into the GuC.
- */
-struct intel_uc_fw {
-	const char *path;
-	size_t size;
-	struct drm_i915_gem_object *obj;
-	enum intel_uc_fw_status fetch_status;
-	enum intel_uc_fw_status load_status;
-
-	uint16_t major_ver_wanted;
-	uint16_t minor_ver_wanted;
-	uint16_t major_ver_found;
-	uint16_t minor_ver_found;
-
-	enum intel_uc_fw_type type;
-	uint32_t header_size;
-	uint32_t header_offset;
-	uint32_t rsa_size;
-	uint32_t rsa_offset;
-	uint32_t ucode_size;
-	uint32_t ucode_offset;
-};
-
-struct intel_guc_log {
-	uint32_t flags;
-	struct i915_vma *vma;
-	/* The runtime stuff gets created only when GuC logging gets enabled */
-	struct {
-		void *buf_addr;
-		struct workqueue_struct *flush_wq;
-		struct work_struct flush_work;
-		struct rchan *relay_chan;
-	} runtime;
-	/* logging related stats */
-	u32 capture_miss_count;
-	u32 flush_interrupt_count;
-	u32 prev_overflow_count[GUC_MAX_LOG_BUFFER];
-	u32 total_overflow_count[GUC_MAX_LOG_BUFFER];
-	u32 flush_count[GUC_MAX_LOG_BUFFER];
-};
-
-struct intel_guc {
-	struct intel_uc_fw fw;
-	struct intel_guc_log log;
-	struct intel_guc_ct ct;
-
-	/* Log snapshot if GuC errors during load */
-	struct drm_i915_gem_object *load_err_log;
-
-	/* intel_guc_recv interrupt related state */
-	bool interrupts_enabled;
-
-	struct i915_vma *ads_vma;
-	struct i915_vma *stage_desc_pool;
-	void *stage_desc_pool_vaddr;
-	struct ida stage_ids;
-
-	struct i915_guc_client *execbuf_client;
-
-	DECLARE_BITMAP(doorbell_bitmap, GUC_NUM_DOORBELLS);
-	uint32_t db_cacheline;		/* Cyclic counter mod pagesize	*/
-
-	/* GuC's FW specific registers used in MMIO send */
-	struct {
-		u32 base;
-		unsigned int count;
-		enum forcewake_domains fw_domains;
-	} send_regs;
-
-	/* To serialize the intel_guc_send actions */
-	struct mutex send_mutex;
-
-	/* GuC's FW specific send function */
-	int (*send)(struct intel_guc *guc, const u32 *data, u32 len);
-
-	/* GuC's FW specific notify function */
-	void (*notify)(struct intel_guc *guc);
-};
+static inline int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 len)
+{
+	return guc->send(guc, action, len);
+}
 
-struct intel_huc {
-	/* Generic uC firmware management */
-	struct intel_uc_fw fw;
+static inline void intel_guc_notify(struct intel_guc *guc)
+{
+	guc->notify(guc);
+}
 
-	/* HuC-specific additions */
-};
+static inline u32 guc_ggtt_offset(struct i915_vma *vma)
+{
+	u32 offset = i915_ggtt_offset(vma);
+	GEM_BUG_ON(offset < GUC_WOPCM_TOP);
+	GEM_BUG_ON(range_overflows_t(u64, offset, vma->size, GUC_GGTT_TOP));
+	return offset;
+}
 
  /* intel_uc.c */
  void intel_uc_sanitize_options(struct drm_i915_private *dev_priv);
@@ -213,16 +83,6 @@ int intel_guc_send_nop(struct intel_guc *guc, const u32 *action, u32 len);
  int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len);
  int intel_guc_auth_huc(struct intel_guc *guc, u32 rsa_offset);
 
-static inline int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 len)
-{
-	return guc->send(guc, action, len);
-}
-
-static inline void intel_guc_notify(struct intel_guc *guc)
-{
-	guc->notify(guc);
-}
-
  /* intel_guc_loader.c */
  int intel_guc_select_fw(struct intel_guc *guc);
  int intel_guc_init_hw(struct intel_guc *guc);
@@ -244,14 +104,6 @@ int i915_guc_log_control(struct drm_i915_private *dev_priv, u64 control_val);
  void i915_guc_log_register(struct drm_i915_private *dev_priv);
  void i915_guc_log_unregister(struct drm_i915_private *dev_priv);
 
-static inline u32 guc_ggtt_offset(struct i915_vma *vma)
-{
-	u32 offset = i915_ggtt_offset(vma);
-	GEM_BUG_ON(offset < GUC_WOPCM_TOP);
-	GEM_BUG_ON(range_overflows_t(u64, offset, vma->size, GUC_GGTT_TOP));
-	return offset;
-}
-
  /* intel_huc.c */
  void intel_huc_select_fw(struct intel_huc *huc);
  void intel_huc_init_hw(struct intel_huc *huc);
drivers/gpu/drm/i915/intel_uc_types.h new file +17 -0
new file mode 100644
index 0000000..fe3b19d
@@ -0,0 +1,172 @@
+/*
+ * Copyright © 2014-2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL

drivers/gpu/drm/i915/intel_uc_types.h line 27

Quoted 10 lines
drivers/gpu/drm/i915/intel_uc_types.h new file +10 -0
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */
+#ifndef _INTEL_UC_TYPES_H_
+#define _INTEL_UC_TYPES_H_
+
+#include "i915_guc_reg.h"

How about pulling intel_guc_fwif.h from intel_guc_ct.h here? I feel it fits more here.

drivers/gpu/drm/i915/intel_uc_types.h line 30

Quoted 3 lines
drivers/gpu/drm/i915/intel_uc_types.h new file +3 -0
+#include "intel_guc_ct.h"
+
+struct i915_guc_client;

Can we skip this forward declaration and ...

Quoted 28 lines
drivers/gpu/drm/i915/intel_uc_types.h new file +28 -0
+
+enum intel_uc_fw_status {
+	INTEL_UC_FIRMWARE_FAIL = -1,
+	INTEL_UC_FIRMWARE_NONE = 0,
+	INTEL_UC_FIRMWARE_PENDING,
+	INTEL_UC_FIRMWARE_SUCCESS
+};
+
+enum intel_uc_fw_type {
+	INTEL_UC_FW_TYPE_GUC,
+	INTEL_UC_FW_TYPE_HUC
+};
+
+/*
+ * This structure encapsulates all the data needed during the process
+ * of fetching, caching, and loading the firmware image into the GuC.
+ */
+struct intel_uc_fw {
+	const char *path;
+	size_t size;
+	struct drm_i915_gem_object *obj;
+	enum intel_uc_fw_status fetch_status;
+	enum intel_uc_fw_status load_status;
+
+	uint16_t major_ver_wanted;
+	uint16_t minor_ver_wanted;
+	uint16_t major_ver_found;
+	uint16_t minor_ver_found;

drivers/gpu/drm/i915/intel_uc_types.h line 68

Quoted 10 lines
drivers/gpu/drm/i915/intel_uc_types.h new file +10 -0
+
+	enum intel_uc_fw_type type;
+	uint32_t header_size;
+	uint32_t header_offset;
+	uint32_t rsa_size;
+	uint32_t rsa_offset;
+	uint32_t ucode_size;
+	uint32_t ucode_offset;
+};
+

define struct i915_guc_client here .. that way it maintains the needs of intel_guc together.

Quoted 94 lines
drivers/gpu/drm/i915/intel_uc_types.h new file +94 -0
+struct intel_guc_log {
+	uint32_t flags;
+	struct i915_vma *vma;
+	/* The runtime stuff gets created only when GuC logging gets enabled */
+	struct {
+		void *buf_addr;
+		struct workqueue_struct *flush_wq;
+		struct work_struct flush_work;
+		struct rchan *relay_chan;
+	} runtime;
+	/* logging related stats */
+	u32 capture_miss_count;
+	u32 flush_interrupt_count;
+	u32 prev_overflow_count[GUC_MAX_LOG_BUFFER];
+	u32 total_overflow_count[GUC_MAX_LOG_BUFFER];
+	u32 flush_count[GUC_MAX_LOG_BUFFER];
+};
+
+struct intel_guc {
+	struct intel_uc_fw fw;
+	struct intel_guc_log log;
+	struct intel_guc_ct ct;
+
+	/* Log snapshot if GuC errors during load */
+	struct drm_i915_gem_object *load_err_log;
+
+	/* intel_guc_recv interrupt related state */
+	bool interrupts_enabled;
+
+	struct i915_vma *ads_vma;
+	struct i915_vma *stage_desc_pool;
+	void *stage_desc_pool_vaddr;
+	struct ida stage_ids;
+
+	struct i915_guc_client *execbuf_client;
+
+	DECLARE_BITMAP(doorbell_bitmap, GUC_NUM_DOORBELLS);
+	uint32_t db_cacheline;		/* Cyclic counter mod pagesize	*/
+
+	/* GuC's FW specific registers used in MMIO send */
+	struct {
+		u32 base;
+		unsigned int count;
+		enum forcewake_domains fw_domains;
+	} send_regs;
+
+	/* To serialize the intel_guc_send actions */
+	struct mutex send_mutex;
+
+	/* GuC's FW specific send function */
+	int (*send)(struct intel_guc *guc, const u32 *data, u32 len);
+
+	/* GuC's FW specific notify function */
+	void (*notify)(struct intel_guc *guc);
+};
+
+struct intel_huc {
+	/* Generic uC firmware management */
+	struct intel_uc_fw fw;
+
+	/* HuC-specific additions */
+};
+
+/*
+ * This structure primarily describes the GEM object shared with the GuC.
+ * The specs sometimes refer to this object as a "GuC context", but we use
+ * the term "client" to avoid confusion with hardware contexts. This
+ * GEM object is held for the entire lifetime of our interaction with
+ * the GuC, being allocated before the GuC is loaded with its firmware.
+ * Because there's no way to update the address used by the GuC after
+ * initialisation, the shared object must stay pinned into the GGTT as
+ * long as the GuC is in use. We also keep the first page (only) mapped
+ * into kernel address space, as it includes shared data that must be
+ * updated on every request submission.
+ *
+ * The single GEM object described here is actually made up of several
+ * separate areas, as far as the GuC is concerned. The first page (kept
+ * kmap'd) includes the "process descriptor" which holds sequence data for
+ * the doorbell, and one cacheline which actually *is* the doorbell; a
+ * write to this will "ring the doorbell" (i.e. send an interrupt to the
+ * GuC). The subsequent  pages of the client object constitute the work
+ * queue (a circular array of work items), again described in the process
+ * descriptor. Work queue pages are mapped momentarily as required.
+ */
+struct i915_guc_client {
+	struct i915_vma *vma;
+	void *vaddr;
+	struct i915_gem_context *owner;
+	struct intel_guc *guc;
+
+	uint32_t engines;		/* bitmap of (host) engine ids	*/
+	uint32_t priority;
+	u32 stage_id;
+	uint32_t proc_desc_offset;

drivers/gpu/drm/i915/intel_uc_types.h line 172

Quoted 10 lines
drivers/gpu/drm/i915/intel_uc_types.h new file +10 -0
+
+	u16 doorbell_id;
+	unsigned long doorbell_offset;
+
+	spinlock_t wq_lock;
+	/* Per-engine counts of GuC submissions */
+	uint64_t submissions[I915_NUM_ENGINES];
+};
+
+#endif

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#6 lore raw
Quoted 13 lines · Sagar Arun Kamble

Like this change as now headers becomes easy to read. Minor inputs suggested below.

Quoted 10 lines · Michal Wajdeczko

In old header structure we were mixing type definitions and declarations that prevent us from exposing some functions as inline. Lets try to fix that.

Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Sagar Arun Kamble <[email protected]>

---

<snip>

Quoted 5 lines

drivers/gpu/drm/i915/intel_uc_types.h line 27

Quoted 4 lines
drivers/gpu/drm/i915/intel_uc_types.h new file +4 -0
+#ifndef _INTEL_UC_TYPES_H_
+#define _INTEL_UC_TYPES_H_
+
+#include "i915_guc_reg.h"

How about pulling intel_guc_fwif.h from intel_guc_ct.h here? I feel it fits more here.

Sure. Previously I leaved it in ct header as it was required only there. But to simplify dependencies we can include fwif here.

Quoted 4 lines

drivers/gpu/drm/i915/intel_uc_types.h line 30

Quoted 3 lines
drivers/gpu/drm/i915/intel_uc_types.h new file +3 -0
+#include "intel_guc_ct.h"
+
+struct i915_guc_client;

Can we skip this forward declaration and ...

Well, it looks that this forward declaration was superfluous as we need it only for pointer definition inside intel_guc where compiler can still be happy without explicit declaration.

Quoted 1 line

define struct i915_guc_client here .. that way it maintains the needs of intel_guc together.

Ok, will reverse the order but will place it right before intel_guc.

Thanks,
Michal
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

maintainer Acked-by on v1 1/2
#7 lore raw
In reply to Michal Wajdeczko
Quoted 9 lines · Michal Wajdeczko

In old header structure we were mixing type definitions and declarations that prevent us from exposing some functions as inline. Lets try to fix that.

Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Sagar Arun Kamble <[email protected]>

This is a nice improvement. I see Sagar already provided detailed review, so please address that (it's always good idea to reduce the amount of forward declarations). Overall, this is:

Regards, Joonas

Signature · 7 lines
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx