Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915/guc: doorbell checking cleanup

A collection of very small cleanups/improvements around doorbell checking
that do not deserve their own patch:

- Move doorbell-related HW defs to intel_guc_reg.h

- use GUC_NUM_DOORBELLS instead of GUC_DOORBELL_INVALID where
appropriate

- do not stop on error in guc_verify_doorbells

- do not print drbreg on error: the only content of the register
apart from the valid bit is the lower part of the physical memory
address, which we can't use even if valid because we don't know
which descriptor it came from (since the doorbell is in an unexpected
state)

- Move the checking of doorbell valid bit to a common helper.

v2: add more cleanups (move defs, use GUC_NUM_DOORBELLS, don't stop in
guc_verify_doorbells) (Michal)

v3: move more things to intel_guc_reg, redefine
GUC_DOORBELL_INVALID (Michal), drop guc_doorbell_qw since it just
duplicates guc_doorbell_info

Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20181022230427.5616-3-daniele.ceraolospurio@intel.com

authored by

Daniele Ceraolo Spurio and committed by
Chris Wilson
fb0c37f6 bfeabcc8

+33 -34
+5 -23
drivers/gpu/drm/i915/intel_guc_fwif.h
··· 39 39 #define GUC_VIDEO_ENGINE2 4 40 40 #define GUC_MAX_ENGINES_NUM (GUC_VIDEO_ENGINE2 + 1) 41 41 42 + #define GUC_DOORBELL_INVALID 256 43 + 44 + #define GUC_DB_SIZE (PAGE_SIZE) 45 + #define GUC_WQ_SIZE (PAGE_SIZE * 2) 46 + 42 47 /* Work queue item header definitions */ 43 48 #define WQ_STATUS_ACTIVE 1 44 49 #define WQ_STATUS_SUSPENDED 2 ··· 63 58 #define WQ_RING_TAIL_SHIFT 20 64 59 #define WQ_RING_TAIL_MAX 0x7FF /* 2^11 QWords */ 65 60 #define WQ_RING_TAIL_MASK (WQ_RING_TAIL_MAX << WQ_RING_TAIL_SHIFT) 66 - 67 - #define GUC_DOORBELL_ENABLED 1 68 - #define GUC_DOORBELL_DISABLED 0 69 61 70 62 #define GUC_STAGE_DESC_ATTR_ACTIVE BIT(0) 71 63 #define GUC_STAGE_DESC_ATTR_PENDING_DB BIT(1) ··· 220 218 u32 reserved[12]; 221 219 u32 header_info; 222 220 } __packed; 223 - 224 - struct guc_doorbell_info { 225 - u32 db_status; 226 - u32 cookie; 227 - u32 reserved[14]; 228 - } __packed; 229 - 230 - union guc_doorbell_qw { 231 - struct { 232 - u32 db_status; 233 - u32 cookie; 234 - }; 235 - u64 value_qw; 236 - } __packed; 237 - 238 - #define GUC_NUM_DOORBELLS 256 239 - #define GUC_DOORBELL_INVALID (GUC_NUM_DOORBELLS) 240 - 241 - #define GUC_DB_SIZE (PAGE_SIZE) 242 - #define GUC_WQ_SIZE (PAGE_SIZE * 2) 243 221 244 222 /* Work item for submitting workloads into work queue of GuC. */ 245 223 struct guc_wq_item {
+12
drivers/gpu/drm/i915/intel_guc_reg.h
··· 104 104 #define GUC_SEND_INTERRUPT _MMIO(0xc4c8) 105 105 #define GUC_SEND_TRIGGER (1<<0) 106 106 107 + #define GUC_NUM_DOORBELLS 256 108 + 109 + /* format of the HW-monitored doorbell cacheline */ 110 + struct guc_doorbell_info { 111 + u32 db_status; 112 + #define GUC_DOORBELL_DISABLED 0 113 + #define GUC_DOORBELL_ENABLED 1 114 + 115 + u32 cookie; 116 + u32 reserved[14]; 117 + } __packed; 118 + 107 119 #define GEN8_DRBREGL(x) _MMIO(0x1000 + (x) * 8) 108 120 #define GEN8_DRB_VALID (1<<0) 109 121 #define GEN8_DRBREGU(x) _MMIO(0x1000 + (x) * 8 + 4)
+16 -11
drivers/gpu/drm/i915/intel_guc_submission.c
··· 192 192 return client->vaddr + client->doorbell_offset; 193 193 } 194 194 195 + static bool __doorbell_valid(struct intel_guc *guc, u16 db_id) 196 + { 197 + struct drm_i915_private *dev_priv = guc_to_i915(guc); 198 + 199 + GEM_BUG_ON(db_id >= GUC_NUM_DOORBELLS); 200 + return I915_READ(GEN8_DRBREGL(db_id)) & GEN8_DRB_VALID; 201 + } 202 + 195 203 static void __init_doorbell(struct intel_guc_client *client) 196 204 { 197 205 struct guc_doorbell_info *doorbell; ··· 211 203 212 204 static void __fini_doorbell(struct intel_guc_client *client) 213 205 { 214 - struct drm_i915_private *dev_priv = guc_to_i915(client->guc); 215 206 struct guc_doorbell_info *doorbell; 216 207 u16 db_id = client->doorbell_id; 217 208 ··· 221 214 * to go to zero after updating db_status before we call the GuC to 222 215 * release the doorbell 223 216 */ 224 - if (wait_for_us(!(I915_READ(GEN8_DRBREGL(db_id)) & GEN8_DRB_VALID), 10)) 217 + if (wait_for_us(!__doorbell_valid(client->guc, db_id), 10)) 225 218 WARN_ONCE(true, "Doorbell never became invalid after disable\n"); 226 219 } 227 220 ··· 873 866 /* Check that a doorbell register is in the expected state */ 874 867 static bool doorbell_ok(struct intel_guc *guc, u16 db_id) 875 868 { 876 - struct drm_i915_private *dev_priv = guc_to_i915(guc); 877 - u32 drbregl; 878 869 bool valid; 879 870 880 - GEM_BUG_ON(db_id >= GUC_DOORBELL_INVALID); 871 + GEM_BUG_ON(db_id >= GUC_NUM_DOORBELLS); 881 872 882 - drbregl = I915_READ(GEN8_DRBREGL(db_id)); 883 - valid = drbregl & GEN8_DRB_VALID; 873 + valid = __doorbell_valid(guc, db_id); 884 874 885 875 if (test_bit(db_id, guc->doorbell_bitmap) == valid) 886 876 return true; 887 877 888 - DRM_DEBUG_DRIVER("Doorbell %d has unexpected state (0x%x): valid=%s\n", 889 - db_id, drbregl, yesno(valid)); 878 + DRM_DEBUG_DRIVER("Doorbell %u has unexpected state: valid=%s\n", 879 + db_id, yesno(valid)); 890 880 891 881 return false; 892 882 } 893 883 894 884 static bool guc_verify_doorbells(struct intel_guc *guc) 895 885 { 886 + bool doorbells_ok = true; 896 887 u16 db_id; 897 888 898 889 for (db_id = 0; db_id < GUC_NUM_DOORBELLS; ++db_id) 899 890 if (!doorbell_ok(guc, db_id)) 900 - return false; 891 + doorbells_ok = false; 901 892 902 - return true; 893 + return doorbells_ok; 903 894 } 904 895 905 896 /**