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

Merge tag 'drm-intel-gt-next-2025-01-10' of https://gitlab.freedesktop.org/drm/i915/kernel into drm-next

Driver Changes:

- More robust engine resets on Haswell and older (Nitin)

- Dead code removal (David)
- Selftest, logging and tracing improvements (Sk, Nitin, Sebastian,
Apoorva)

Signed-off-by: Dave Airlie <airlied@redhat.com>
From: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/Z4DidoEACFu7D6iG@jlahtine-mobl.ger.corp.intel.com

+39 -101
-23
drivers/gpu/drm/i915/gem/i915_gem_lmem.c
··· 53 53 } 54 54 55 55 /** 56 - * __i915_gem_object_is_lmem - Whether the object is resident in 57 - * lmem while in the fence signaling critical path. 58 - * @obj: The object to check. 59 - * 60 - * This function is intended to be called from within the fence signaling 61 - * path where the fence, or a pin, keeps the object from being migrated. For 62 - * example during gpu reset or similar. 63 - * 64 - * Return: Whether the object is resident in lmem. 65 - */ 66 - bool __i915_gem_object_is_lmem(struct drm_i915_gem_object *obj) 67 - { 68 - struct intel_memory_region *mr = READ_ONCE(obj->mm.region); 69 - 70 - #ifdef CONFIG_LOCKDEP 71 - GEM_WARN_ON(dma_resv_test_signaled(obj->base.resv, DMA_RESV_USAGE_BOOKKEEP) && 72 - i915_gem_object_evictable(obj)); 73 - #endif 74 - return mr && (mr->type == INTEL_MEMORY_LOCAL || 75 - mr->type == INTEL_MEMORY_STOLEN_LOCAL); 76 - } 77 - 78 - /** 79 56 * __i915_gem_object_create_lmem_with_ps - Create lmem object and force the 80 57 * minimum page size for the backing pages. 81 58 * @i915: The i915 instance.
-2
drivers/gpu/drm/i915/gem/i915_gem_lmem.h
··· 19 19 20 20 bool i915_gem_object_is_lmem(struct drm_i915_gem_object *obj); 21 21 22 - bool __i915_gem_object_is_lmem(struct drm_i915_gem_object *obj); 23 - 24 22 struct drm_i915_gem_object * 25 23 i915_gem_object_create_lmem_from_data(struct drm_i915_private *i915, 26 24 const void *data, size_t size);
+5 -1
drivers/gpu/drm/i915/gt/intel_reset.c
··· 1113 1113 * Warn CI about the unrecoverable wedged condition. 1114 1114 * Time for a reboot. 1115 1115 */ 1116 + gt_err(gt, "Unrecoverable wedged condition\n"); 1116 1117 add_taint_for_CI(gt->i915, TAINT_WARN); 1117 1118 return false; 1118 1119 } ··· 1265 1264 } 1266 1265 1267 1266 ret = resume(gt); 1268 - if (ret) 1267 + if (ret) { 1268 + gt_err(gt, "Failed to resume (%d)\n", ret); 1269 1269 goto taint; 1270 + } 1270 1271 1271 1272 finish: 1272 1273 reset_finish(gt, awake); ··· 1611 1608 set_bit(I915_WEDGED_ON_INIT, &gt->reset.flags); 1612 1609 1613 1610 /* Wedged on init is non-recoverable */ 1611 + gt_err(gt, "Non-recoverable wedged on init\n"); 1614 1612 add_taint_for_CI(gt->i915, TAINT_WARN); 1615 1613 } 1616 1614
-24
drivers/gpu/drm/i915/gt/intel_ring.c
··· 308 308 return cs; 309 309 } 310 310 311 - /* Align the ring tail to a cacheline boundary */ 312 - int intel_ring_cacheline_align(struct i915_request *rq) 313 - { 314 - int num_dwords; 315 - void *cs; 316 - 317 - num_dwords = (rq->ring->emit & (CACHELINE_BYTES - 1)) / sizeof(u32); 318 - if (num_dwords == 0) 319 - return 0; 320 - 321 - num_dwords = CACHELINE_DWORDS - num_dwords; 322 - GEM_BUG_ON(num_dwords & 1); 323 - 324 - cs = intel_ring_begin(rq, num_dwords); 325 - if (IS_ERR(cs)) 326 - return PTR_ERR(cs); 327 - 328 - memset64(cs, (u64)MI_NOOP << 32 | MI_NOOP, num_dwords / 2); 329 - intel_ring_advance(rq, cs + num_dwords); 330 - 331 - GEM_BUG_ON(rq->ring->emit & (CACHELINE_BYTES - 1)); 332 - return 0; 333 - } 334 - 335 311 #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST) 336 312 #include "selftest_ring.c" 337 313 #endif
-1
drivers/gpu/drm/i915/gt/intel_ring.h
··· 16 16 intel_engine_create_ring(struct intel_engine_cs *engine, int size); 17 17 18 18 u32 *intel_ring_begin(struct i915_request *rq, unsigned int num_dwords); 19 - int intel_ring_cacheline_align(struct i915_request *rq); 20 19 21 20 unsigned int intel_ring_update_space(struct intel_ring *ring); 22 21
+18 -12
drivers/gpu/drm/i915/gt/intel_ring_submission.c
··· 26 26 #include "shmem_utils.h" 27 27 #include "intel_engine_heartbeat.h" 28 28 #include "intel_engine_pm.h" 29 + #include "intel_gt_print.h" 29 30 30 31 /* Rough estimate of the typical request size, performing a flush, 31 32 * set-context and then emitting the batch. ··· 231 230 232 231 set_pp_dir(engine); 233 232 234 - /* First wake the ring up to an empty/idle ring */ 235 - for ((kt) = ktime_get() + (2 * NSEC_PER_MSEC); 233 + /* 234 + * First wake the ring up to an empty/idle ring. 235 + * Use 50ms of delay to let the engine write successfully 236 + * for all platforms. Experimented with different values and 237 + * determined that 50ms works best based on testing. 238 + */ 239 + for ((kt) = ktime_get() + (50 * NSEC_PER_MSEC); 236 240 ktime_before(ktime_get(), (kt)); cpu_relax()) { 237 241 /* 238 242 * In case of resets fails because engine resumes from ··· 288 282 return 0; 289 283 290 284 err: 291 - drm_err(&engine->i915->drm, 292 - "%s initialization failed; " 293 - "ctl %08x (valid? %d) head %08x [%08x] tail %08x [%08x] start %08x [expected %08x]\n", 294 - engine->name, 295 - ENGINE_READ(engine, RING_CTL), 296 - ENGINE_READ(engine, RING_CTL) & RING_VALID, 297 - ENGINE_READ(engine, RING_HEAD), ring->head, 298 - ENGINE_READ(engine, RING_TAIL), ring->tail, 299 - ENGINE_READ(engine, RING_START), 300 - i915_ggtt_offset(ring->vma)); 285 + gt_err(engine->gt, "%s initialization failed\n", engine->name); 286 + ENGINE_TRACE(engine, 287 + "ctl %08x (valid? %d) head %08x [%08x] tail %08x [%08x] start %08x [expected %08x]\n", 288 + ENGINE_READ(engine, RING_CTL), 289 + ENGINE_READ(engine, RING_CTL) & RING_VALID, 290 + ENGINE_READ(engine, RING_HEAD), ring->head, 291 + ENGINE_READ(engine, RING_TAIL), ring->tail, 292 + ENGINE_READ(engine, RING_START), 293 + i915_ggtt_offset(ring->vma)); 294 + GEM_TRACE_DUMP(); 301 295 return -EIO; 302 296 } 303 297
+1 -1
drivers/gpu/drm/i915/gt/selftest_migrate.c
··· 262 262 { 263 263 struct drm_i915_private *i915 = migrate->context->engine->i915; 264 264 struct drm_i915_gem_object *obj; 265 - struct i915_request *rq; 265 + struct i915_request *rq = NULL; 266 266 struct i915_gem_ww_ctx ww; 267 267 u32 *vaddr, val = 0; 268 268 bool ccs_cap = false;
+14 -3
drivers/gpu/drm/i915/gt/selftest_rc6.c
··· 8 8 #include "intel_gpu_commands.h" 9 9 #include "intel_gt_requests.h" 10 10 #include "intel_ring.h" 11 + #include "intel_rps.h" 11 12 #include "selftest_rc6.h" 12 13 13 14 #include "selftests/i915_random.h" ··· 39 38 ktime_t dt; 40 39 u64 res[2]; 41 40 int err = 0; 41 + u32 rc0_freq = 0; 42 + u32 rc6_freq = 0; 43 + struct intel_rps *rps = &gt->rps; 42 44 43 45 /* 44 46 * Our claim is that we can "encourage" the GPU to enter rc6 at will. ··· 70 66 rc0_power = librapl_energy_uJ() - rc0_power; 71 67 dt = ktime_sub(ktime_get(), dt); 72 68 res[1] = rc6_residency(rc6); 69 + rc0_freq = intel_rps_read_actual_frequency_fw(rps); 73 70 if ((res[1] - res[0]) >> 10) { 74 71 pr_err("RC6 residency increased by %lldus while disabled for 1000ms!\n", 75 72 (res[1] - res[0]) >> 10); ··· 82 77 rc0_power = div64_u64(NSEC_PER_SEC * rc0_power, 83 78 ktime_to_ns(dt)); 84 79 if (!rc0_power) { 85 - pr_err("No power measured while in RC0\n"); 80 + if (rc0_freq) 81 + pr_debug("No power measured while in RC0! GPU Freq: %u in RC0\n", 82 + rc0_freq); 83 + else 84 + pr_err("No power and freq measured while in RC0\n"); 86 85 err = -EINVAL; 87 86 goto out_unlock; 88 87 } ··· 99 90 intel_uncore_forcewake_flush(rc6_to_uncore(rc6), FORCEWAKE_ALL); 100 91 dt = ktime_get(); 101 92 rc6_power = librapl_energy_uJ(); 102 - msleep(100); 93 + msleep(1000); 94 + rc6_freq = intel_rps_read_actual_frequency_fw(rps); 103 95 rc6_power = librapl_energy_uJ() - rc6_power; 104 96 dt = ktime_sub(ktime_get(), dt); 105 97 res[1] = rc6_residency(rc6); ··· 118 108 pr_info("GPU consumed %llduW in RC0 and %llduW in RC6\n", 119 109 rc0_power, rc6_power); 120 110 if (2 * rc6_power > rc0_power) { 121 - pr_err("GPU leaked energy while in RC6!\n"); 111 + pr_err("GPU leaked energy while in RC6! GPU Freq: %u in RC6 and %u in RC0\n", 112 + rc6_freq, rc0_freq); 122 113 err = -EINVAL; 123 114 goto out_unlock; 124 115 }
+1 -1
drivers/gpu/drm/i915/gt/uc/intel_guc_log.c
··· 18 18 #define GUC_LOG_DEFAULT_CRASH_BUFFER_SIZE SZ_2M 19 19 #define GUC_LOG_DEFAULT_DEBUG_BUFFER_SIZE SZ_16M 20 20 #define GUC_LOG_DEFAULT_CAPTURE_BUFFER_SIZE SZ_1M 21 - #elif defined(CONFIG_DRM_I915_DEBUG_GEM) 21 + #elif IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM) 22 22 #define GUC_LOG_DEFAULT_CRASH_BUFFER_SIZE SZ_1M 23 23 #define GUC_LOG_DEFAULT_DEBUG_BUFFER_SIZE SZ_2M 24 24 #define GUC_LOG_DEFAULT_CAPTURE_BUFFER_SIZE SZ_1M
-13
drivers/gpu/drm/i915/gt/uc/intel_huc.c
··· 427 427 intel_uc_fw_fini(&huc->fw); 428 428 } 429 429 430 - void intel_huc_suspend(struct intel_huc *huc) 431 - { 432 - if (!intel_uc_fw_is_loadable(&huc->fw)) 433 - return; 434 - 435 - /* 436 - * in the unlikely case that we're suspending before the GSC has 437 - * completed its loading sequence, just stop waiting. We'll restart 438 - * on resume. 439 - */ 440 - delayed_huc_load_complete(huc); 441 - } 442 - 443 430 static const char *auth_mode_string(struct intel_huc *huc, 444 431 enum intel_huc_authentication_type type) 445 432 {
-1
drivers/gpu/drm/i915/gt/uc/intel_huc.h
··· 57 57 void intel_huc_init_early(struct intel_huc *huc); 58 58 int intel_huc_init(struct intel_huc *huc); 59 59 void intel_huc_fini(struct intel_huc *huc); 60 - void intel_huc_suspend(struct intel_huc *huc); 61 60 int intel_huc_auth(struct intel_huc *huc, enum intel_huc_authentication_type type); 62 61 int intel_huc_wait_for_auth_complete(struct intel_huc *huc, 63 62 enum intel_huc_authentication_type type);
-18
drivers/gpu/drm/i915/i915_active.c
··· 527 527 return err; 528 528 } 529 529 530 - int i915_active_acquire_for_context(struct i915_active *ref, u64 idx) 531 - { 532 - struct i915_active_fence *active; 533 - int err; 534 - 535 - err = i915_active_acquire(ref); 536 - if (err) 537 - return err; 538 - 539 - active = active_instance(ref, idx); 540 - if (!active) { 541 - i915_active_release(ref); 542 - return -ENOMEM; 543 - } 544 - 545 - return 0; /* return with active ref */ 546 - } 547 - 548 530 void i915_active_release(struct i915_active *ref) 549 531 { 550 532 debug_active_assert(ref);
-1
drivers/gpu/drm/i915/i915_active.h
··· 186 186 #define I915_ACTIVE_AWAIT_BARRIER BIT(2) 187 187 188 188 int i915_active_acquire(struct i915_active *ref); 189 - int i915_active_acquire_for_context(struct i915_active *ref, u64 idx); 190 189 bool i915_active_acquire_if_busy(struct i915_active *ref); 191 190 192 191 void i915_active_release(struct i915_active *ref);