Commit abddffdf authored by Joonas Lahtinen's avatar Joonas Lahtinen

drm/i915/guc: Sanitize GuC client initialization

Started adding proper teardown to guc_client_alloc, ended up removing
quite a few dead ends where errors communicating with the GuC were
silently ignored. There also seemed to be quite a few erronous
teardown actions performed in case of an error (ordering wrong).

v2:
  - Increase function symmetry/proximity (Michal/Daniele)
  - Fix __reserve_doorbell accounting for high priority (Daniele)
  - Call __update_doorbell_desc! (Daniele)
  - Isolate __guc_{,de}allocate_doorbell (Michal/Daniele)

v3:
  - "Select" a cacheline is a more accurate verb than "reserve" (Daniele).
  - We cannot update & create the doorbell without reserving it first, so
    move the whole doorbell creation for execbuf_client to the submission
    enable (Oscar).i
  - Add a fixme for ignoring possible doorbell destroy errors.

v4:
  - Remove comment about is_high_priority (Daniele)
  - Debug message typo (Daniele)
  - Reuse __get_doorbell in more places (Daniele)
  - Do not do arithmetic on void pointers (Daniele)
  - Add comment to __reset_doorbell (Daniele)

v5:
  - gccisms like arithmetic on void pointers are not frowned upon (Oscar)
Signed-off-by: default avatarJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarOscar Mateo <oscar.mateo@intel.com>
Reviewed-by: default avatarDaniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
parent d223760f
...@@ -2473,7 +2473,7 @@ static void i915_guc_client_info(struct seq_file *m, ...@@ -2473,7 +2473,7 @@ static void i915_guc_client_info(struct seq_file *m,
seq_printf(m, "\tPriority %d, GuC ctx index: %u, PD offset 0x%x\n", seq_printf(m, "\tPriority %d, GuC ctx index: %u, PD offset 0x%x\n",
client->priority, client->ctx_index, client->proc_desc_offset); client->priority, client->ctx_index, client->proc_desc_offset);
seq_printf(m, "\tDoorbell id %d, offset: 0x%x, cookie 0x%x\n", seq_printf(m, "\tDoorbell id %d, offset: 0x%lx, cookie 0x%x\n",
client->doorbell_id, client->doorbell_offset, client->doorbell_cookie); client->doorbell_id, client->doorbell_offset, client->doorbell_cookie);
seq_printf(m, "\tWQ size %d, offset: 0x%x, tail %d\n", seq_printf(m, "\tWQ size %d, offset: 0x%x, tail %d\n",
client->wq_size, client->wq_offset, client->wq_tail); client->wq_size, client->wq_offset, client->wq_tail);
...@@ -2508,7 +2508,7 @@ static int i915_guc_info(struct seq_file *m, void *data) ...@@ -2508,7 +2508,7 @@ static int i915_guc_info(struct seq_file *m, void *data)
} }
seq_printf(m, "Doorbell map:\n"); seq_printf(m, "Doorbell map:\n");
seq_printf(m, "\t%*pb\n", GUC_MAX_DOORBELLS, guc->doorbell_bitmap); seq_printf(m, "\t%*pb\n", GUC_NUM_DOORBELLS, guc->doorbell_bitmap);
seq_printf(m, "Doorbell next cacheline: 0x%x\n\n", guc->db_cacheline); seq_printf(m, "Doorbell next cacheline: 0x%x\n\n", guc->db_cacheline);
seq_printf(m, "GuC total action count: %llu\n", guc->action_count); seq_printf(m, "GuC total action count: %llu\n", guc->action_count);
......
This diff is collapsed.
...@@ -241,8 +241,8 @@ union guc_doorbell_qw { ...@@ -241,8 +241,8 @@ union guc_doorbell_qw {
u64 value_qw; u64 value_qw;
} __packed; } __packed;
#define GUC_MAX_DOORBELLS 256 #define GUC_NUM_DOORBELLS 256
#define GUC_INVALID_DOORBELL_ID (GUC_MAX_DOORBELLS) #define GUC_DOORBELL_INVALID (GUC_NUM_DOORBELLS)
#define GUC_DB_SIZE (PAGE_SIZE) #define GUC_DB_SIZE (PAGE_SIZE)
#define GUC_WQ_SIZE (PAGE_SIZE * 2) #define GUC_WQ_SIZE (PAGE_SIZE * 2)
......
...@@ -72,13 +72,12 @@ struct i915_guc_client { ...@@ -72,13 +72,12 @@ struct i915_guc_client {
uint32_t engines; /* bitmap of (host) engine ids */ uint32_t engines; /* bitmap of (host) engine ids */
uint32_t priority; uint32_t priority;
uint32_t ctx_index; u32 ctx_index;
uint32_t proc_desc_offset; uint32_t proc_desc_offset;
uint32_t doorbell_offset; u16 doorbell_id;
uint32_t doorbell_cookie; unsigned long doorbell_offset;
uint16_t doorbell_id; u32 doorbell_cookie;
uint16_t padding[3]; /* Maintain alignment */
spinlock_t wq_lock; spinlock_t wq_lock;
uint32_t wq_offset; uint32_t wq_offset;
...@@ -159,7 +158,7 @@ struct intel_guc { ...@@ -159,7 +158,7 @@ struct intel_guc {
struct i915_guc_client *execbuf_client; struct i915_guc_client *execbuf_client;
DECLARE_BITMAP(doorbell_bitmap, GUC_MAX_DOORBELLS); DECLARE_BITMAP(doorbell_bitmap, GUC_NUM_DOORBELLS);
uint32_t db_cacheline; /* Cyclic counter mod pagesize */ uint32_t db_cacheline; /* Cyclic counter mod pagesize */
/* Action status & statistics */ /* Action status & statistics */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment