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

Merge tag 'drm-intel-next-2018-04-13' of git://anongit.freedesktop.org/drm/drm-intel into drm-next

First drm/i915 feature batch heading for v4.18:

- drm-next backmerge to fix build (Rodrigo)
- GPU documentation improvements (Kevin)
- GuC and HuC refactoring, host/GuC communication, logging, fixes, and more
(mostly Michal and Michał, also Jackie, Michel and Piotr)
- PSR and PSR2 enabling and fixes (DK, José, Rodrigo and Chris)
- Selftest updates (Chris, Daniele)
- DPLL management refactoring (Lucas)
- DP MST fixes (Lyude and DK)
- Watermark refactoring and changes to support NV12 (Mahesh)
- NV12 prep work (Chandra)
- Icelake Combo PHY enablers (Manasi)
- Perf OA refactoring and ICL enabling (Lionel)
- ICL enabling (Oscar, Paulo, Nabendu, Mika, Kelvin, Michel)
- Workarounds refactoring (Oscar)
- HDCP fixes and improvements (Ramalingam, Radhakrishna)
- Power management fixes (Imre)
- Various display fixes (Maarten, Ville, Vidya, Jani, Gaurav)
- debugfs for FIFO underrun clearing (Maarten)
- Execlist improvements (Chris)
- Reset improvements (Chris)
- Plenty of things here and there I overlooked and/or didn't understand... (Everyone)

Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/87lgd2cze8.fsf@intel.com

+7267 -3732
+121 -20
Documentation/gpu/i915.rst
··· 58 58 .. kernel-doc:: drivers/gpu/drm/i915/intel_gvt.c 59 59 :internal: 60 60 61 + Workarounds 62 + ----------- 63 + 64 + .. kernel-doc:: drivers/gpu/drm/i915/intel_workarounds.c 65 + :doc: Hardware workarounds 66 + 61 67 Display Hardware Handling 62 68 ========================= 63 69 ··· 255 249 This sections covers all things related to the GEM implementation in the 256 250 i915 driver. 257 251 252 + Intel GPU Basics 253 + ---------------- 254 + 255 + An Intel GPU has multiple engines. There are several engine types. 256 + 257 + - RCS engine is for rendering 3D and performing compute, this is named 258 + `I915_EXEC_RENDER` in user space. 259 + - BCS is a blitting (copy) engine, this is named `I915_EXEC_BLT` in user 260 + space. 261 + - VCS is a video encode and decode engine, this is named `I915_EXEC_BSD` 262 + in user space 263 + - VECS is video enhancement engine, this is named `I915_EXEC_VEBOX` in user 264 + space. 265 + - The enumeration `I915_EXEC_DEFAULT` does not refer to specific engine; 266 + instead it is to be used by user space to specify a default rendering 267 + engine (for 3D) that may or may not be the same as RCS. 268 + 269 + The Intel GPU family is a family of integrated GPU's using Unified 270 + Memory Access. For having the GPU "do work", user space will feed the 271 + GPU batch buffers via one of the ioctls `DRM_IOCTL_I915_GEM_EXECBUFFER2` 272 + or `DRM_IOCTL_I915_GEM_EXECBUFFER2_WR`. Most such batchbuffers will 273 + instruct the GPU to perform work (for example rendering) and that work 274 + needs memory from which to read and memory to which to write. All memory 275 + is encapsulated within GEM buffer objects (usually created with the ioctl 276 + `DRM_IOCTL_I915_GEM_CREATE`). An ioctl providing a batchbuffer for the GPU 277 + to create will also list all GEM buffer objects that the batchbuffer reads 278 + and/or writes. For implementation details of memory management see 279 + `GEM BO Management Implementation Details`_. 280 + 281 + The i915 driver allows user space to create a context via the ioctl 282 + `DRM_IOCTL_I915_GEM_CONTEXT_CREATE` which is identified by a 32-bit 283 + integer. Such a context should be viewed by user-space as -loosely- 284 + analogous to the idea of a CPU process of an operating system. The i915 285 + driver guarantees that commands issued to a fixed context are to be 286 + executed so that writes of a previously issued command are seen by 287 + reads of following commands. Actions issued between different contexts 288 + (even if from the same file descriptor) are NOT given that guarantee 289 + and the only way to synchronize across contexts (even from the same 290 + file descriptor) is through the use of fences. At least as far back as 291 + Gen4, also have that a context carries with it a GPU HW context; 292 + the HW context is essentially (most of atleast) the state of a GPU. 293 + In addition to the ordering guarantees, the kernel will restore GPU 294 + state via HW context when commands are issued to a context, this saves 295 + user space the need to restore (most of atleast) the GPU state at the 296 + start of each batchbuffer. The non-deprecated ioctls to submit batchbuffer 297 + work can pass that ID (in the lower bits of drm_i915_gem_execbuffer2::rsvd1) 298 + to identify what context to use with the command. 299 + 300 + The GPU has its own memory management and address space. The kernel 301 + driver maintains the memory translation table for the GPU. For older 302 + GPUs (i.e. those before Gen8), there is a single global such translation 303 + table, a global Graphics Translation Table (GTT). For newer generation 304 + GPUs each context has its own translation table, called Per-Process 305 + Graphics Translation Table (PPGTT). Of important note, is that although 306 + PPGTT is named per-process it is actually per context. When user space 307 + submits a batchbuffer, the kernel walks the list of GEM buffer objects 308 + used by the batchbuffer and guarantees that not only is the memory of 309 + each such GEM buffer object resident but it is also present in the 310 + (PP)GTT. If the GEM buffer object is not yet placed in the (PP)GTT, 311 + then it is given an address. Two consequences of this are: the kernel 312 + needs to edit the batchbuffer submitted to write the correct value of 313 + the GPU address when a GEM BO is assigned a GPU address and the kernel 314 + might evict a different GEM BO from the (PP)GTT to make address room 315 + for another GEM BO. Consequently, the ioctls submitting a batchbuffer 316 + for execution also include a list of all locations within buffers that 317 + refer to GPU-addresses so that the kernel can edit the buffer correctly. 318 + This process is dubbed relocation. 319 + 320 + GEM BO Management Implementation Details 321 + ---------------------------------------- 322 + 323 + .. kernel-doc:: drivers/gpu/drm/i915/i915_vma.h 324 + :doc: Virtual Memory Address 325 + 326 + Buffer Object Eviction 327 + ---------------------- 328 + 329 + This section documents the interface functions for evicting buffer 330 + objects to make space available in the virtual gpu address spaces. Note 331 + that this is mostly orthogonal to shrinking buffer objects caches, which 332 + has the goal to make main memory (shared with the gpu through the 333 + unified memory architecture) available. 334 + 335 + .. kernel-doc:: drivers/gpu/drm/i915/i915_gem_evict.c 336 + :internal: 337 + 338 + Buffer Object Memory Shrinking 339 + ------------------------------ 340 + 341 + This section documents the interface function for shrinking memory usage 342 + of buffer object caches. Shrinking is used to make main memory 343 + available. Note that this is mostly orthogonal to evicting buffer 344 + objects, which has the goal to make space in gpu virtual address spaces. 345 + 346 + .. kernel-doc:: drivers/gpu/drm/i915/i915_gem_shrinker.c 347 + :internal: 348 + 258 349 Batchbuffer Parsing 259 350 ------------------- 260 351 ··· 369 266 370 267 .. kernel-doc:: drivers/gpu/drm/i915/i915_gem_batch_pool.c 371 268 :internal: 269 + 270 + User Batchbuffer Execution 271 + -------------------------- 272 + 273 + .. kernel-doc:: drivers/gpu/drm/i915/i915_gem_execbuffer.c 274 + :doc: User command execution 372 275 373 276 Logical Rings, Logical Ring Contexts and Execlists 374 277 -------------------------------------------------- ··· 421 312 .. kernel-doc:: drivers/gpu/drm/i915/i915_gem_tiling.c 422 313 :doc: buffer object tiling 423 314 424 - Buffer Object Eviction 425 - ---------------------- 315 + WOPCM 316 + ===== 426 317 427 - This section documents the interface functions for evicting buffer 428 - objects to make space available in the virtual gpu address spaces. Note 429 - that this is mostly orthogonal to shrinking buffer objects caches, which 430 - has the goal to make main memory (shared with the gpu through the 431 - unified memory architecture) available. 318 + WOPCM Layout 319 + ------------ 432 320 433 - .. kernel-doc:: drivers/gpu/drm/i915/i915_gem_evict.c 434 - :internal: 435 - 436 - Buffer Object Memory Shrinking 437 - ------------------------------ 438 - 439 - This section documents the interface function for shrinking memory usage 440 - of buffer object caches. Shrinking is used to make main memory 441 - available. Note that this is mostly orthogonal to evicting buffer 442 - objects, which has the goal to make space in gpu virtual address spaces. 443 - 444 - .. kernel-doc:: drivers/gpu/drm/i915/i915_gem_shrinker.c 445 - :internal: 321 + .. kernel-doc:: drivers/gpu/drm/i915/intel_wopcm.c 322 + :doc: WOPCM Layout 446 323 447 324 GuC 448 325 === ··· 453 358 454 359 .. kernel-doc:: drivers/gpu/drm/i915/intel_guc_fwif.h 455 360 :doc: GuC Firmware Layout 361 + 362 + GuC Address Space 363 + ----------------- 364 + 365 + .. kernel-doc:: drivers/gpu/drm/i915/intel_guc.c 366 + :doc: GuC Address Space 456 367 457 368 Tracing 458 369 =======
+13
drivers/gpu/drm/i915/Kconfig.debug
··· 25 25 select X86_MSR # used by igt/pm_rpm 26 26 select DRM_VGEM # used by igt/prime_vgem (dmabuf interop checks) 27 27 select DRM_DEBUG_MM if DRM=y 28 + select STACKDEPOT if DRM=y # for DRM_DEBUG_MM 28 29 select DRM_DEBUG_MM_SELFTEST 29 30 select SW_SYNC # signaling validation framework (igt/syncobj*) 30 31 select DRM_I915_SW_FENCE_DEBUG_OBJECTS ··· 85 84 help 86 85 Choose this option to turn on extra driver debugging that may affect 87 86 performance but will catch some internal issues. 87 + 88 + Recommended for driver developers only. 89 + 90 + If in doubt, say "N". 91 + 92 + config DRM_I915_DEBUG_GUC 93 + bool "Enable additional driver debugging for GuC" 94 + depends on DRM_I915 95 + default n 96 + help 97 + Choose this option to turn on extra driver debugging that may affect 98 + performance but will help resolve GuC related issues. 88 99 89 100 Recommended for driver developers only. 90 101
+7 -4
drivers/gpu/drm/i915/Makefile
··· 12 12 # Note the danger in using -Wall -Wextra is that when CI updates gcc we 13 13 # will most likely get a sudden build breakage... Hopefully we will fix 14 14 # new warnings before CI updates! 15 - subdir-ccflags-y := -Wall -Wextra 15 + subdir-ccflags-y := -Wall -Wextra -Wvla 16 16 subdir-ccflags-y += $(call cc-disable-warning, unused-parameter) 17 17 subdir-ccflags-y += $(call cc-disable-warning, type-limits) 18 18 subdir-ccflags-y += $(call cc-disable-warning, missing-field-initializers) ··· 43 43 intel_csr.o \ 44 44 intel_device_info.o \ 45 45 intel_pm.o \ 46 - intel_runtime_pm.o 46 + intel_runtime_pm.o \ 47 + intel_workarounds.o 47 48 48 49 i915-$(CONFIG_COMPAT) += i915_ioc32.o 49 50 i915-$(CONFIG_DEBUG_FS) += i915_debugfs.o intel_pipe_crc.o ··· 80 79 intel_lrc.o \ 81 80 intel_mocs.o \ 82 81 intel_ringbuffer.o \ 83 - intel_uncore.o 82 + intel_uncore.o \ 83 + intel_wopcm.o 84 84 85 85 # general-purpose microcontroller (GuC) support 86 86 i915-y += intel_uc.o \ ··· 173 171 i915_oa_glk.o \ 174 172 i915_oa_cflgt2.o \ 175 173 i915_oa_cflgt3.o \ 176 - i915_oa_cnl.o 174 + i915_oa_cnl.o \ 175 + i915_oa_icl.o 177 176 178 177 ifeq ($(CONFIG_DRM_I915_GVT),y) 179 178 i915-y += intel_gvt.o
+1 -12
drivers/gpu/drm/i915/gvt/debugfs.c
··· 122 122 seq_printf(s, "Total: %d, Diff: %d\n", param.total, param.diff); 123 123 return 0; 124 124 } 125 - 126 - static int vgpu_mmio_diff_open(struct inode *inode, struct file *file) 127 - { 128 - return single_open(file, vgpu_mmio_diff_show, inode->i_private); 129 - } 130 - 131 - static const struct file_operations vgpu_mmio_diff_fops = { 132 - .open = vgpu_mmio_diff_open, 133 - .read = seq_read, 134 - .llseek = seq_lseek, 135 - .release = single_release, 136 - }; 125 + DEFINE_SHOW_ATTRIBUTE(vgpu_mmio_diff); 137 126 138 127 /** 139 128 * intel_gvt_debugfs_add_vgpu - register debugfs entries for a vGPU
+193 -125
drivers/gpu/drm/i915/i915_debugfs.c
··· 1215 1215 max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 0 : 1216 1216 rp_state_cap >> 16) & 0xff; 1217 1217 max_freq *= (IS_GEN9_BC(dev_priv) || 1218 - IS_CANNONLAKE(dev_priv) ? GEN9_FREQ_SCALER : 1); 1218 + INTEL_GEN(dev_priv) >= 10 ? GEN9_FREQ_SCALER : 1); 1219 1219 seq_printf(m, "Lowest (RPN) frequency: %dMHz\n", 1220 1220 intel_gpu_freq(dev_priv, max_freq)); 1221 1221 1222 1222 max_freq = (rp_state_cap & 0xff00) >> 8; 1223 1223 max_freq *= (IS_GEN9_BC(dev_priv) || 1224 - IS_CANNONLAKE(dev_priv) ? GEN9_FREQ_SCALER : 1); 1224 + INTEL_GEN(dev_priv) >= 10 ? GEN9_FREQ_SCALER : 1); 1225 1225 seq_printf(m, "Nominal (RP1) frequency: %dMHz\n", 1226 1226 intel_gpu_freq(dev_priv, max_freq)); 1227 1227 1228 1228 max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 16 : 1229 1229 rp_state_cap >> 0) & 0xff; 1230 1230 max_freq *= (IS_GEN9_BC(dev_priv) || 1231 - IS_CANNONLAKE(dev_priv) ? GEN9_FREQ_SCALER : 1); 1231 + INTEL_GEN(dev_priv) >= 10 ? GEN9_FREQ_SCALER : 1); 1232 1232 seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n", 1233 1233 intel_gpu_freq(dev_priv, max_freq)); 1234 1234 seq_printf(m, "Max overclocked frequency: %dMHz\n", ··· 1796 1796 { 1797 1797 struct drm_i915_private *dev_priv = node_to_i915(m->private); 1798 1798 struct intel_rps *rps = &dev_priv->gt_pm.rps; 1799 - int ret = 0; 1800 - int gpu_freq, ia_freq; 1801 1799 unsigned int max_gpu_freq, min_gpu_freq; 1800 + int gpu_freq, ia_freq; 1801 + int ret; 1802 1802 1803 1803 if (!HAS_LLC(dev_priv)) 1804 1804 return -ENODEV; ··· 1809 1809 if (ret) 1810 1810 goto out; 1811 1811 1812 - if (IS_GEN9_BC(dev_priv) || IS_CANNONLAKE(dev_priv)) { 1812 + min_gpu_freq = rps->min_freq; 1813 + max_gpu_freq = rps->max_freq; 1814 + if (IS_GEN9_BC(dev_priv) || INTEL_GEN(dev_priv) >= 10) { 1813 1815 /* Convert GT frequency to 50 HZ units */ 1814 - min_gpu_freq = rps->min_freq_softlimit / GEN9_FREQ_SCALER; 1815 - max_gpu_freq = rps->max_freq_softlimit / GEN9_FREQ_SCALER; 1816 - } else { 1817 - min_gpu_freq = rps->min_freq_softlimit; 1818 - max_gpu_freq = rps->max_freq_softlimit; 1816 + min_gpu_freq /= GEN9_FREQ_SCALER; 1817 + max_gpu_freq /= GEN9_FREQ_SCALER; 1819 1818 } 1820 1819 1821 1820 seq_puts(m, "GPU freq (MHz)\tEffective CPU freq (MHz)\tEffective Ring freq (MHz)\n"); ··· 1827 1828 seq_printf(m, "%d\t\t%d\t\t\t\t%d\n", 1828 1829 intel_gpu_freq(dev_priv, (gpu_freq * 1829 1830 (IS_GEN9_BC(dev_priv) || 1830 - IS_CANNONLAKE(dev_priv) ? 1831 + INTEL_GEN(dev_priv) >= 10 ? 1831 1832 GEN9_FREQ_SCALER : 1))), 1832 1833 ((ia_freq >> 0) & 0xff) * 100, 1833 1834 ((ia_freq >> 8) & 0xff) * 100); ··· 1922 1923 1923 1924 static void describe_ctx_ring(struct seq_file *m, struct intel_ring *ring) 1924 1925 { 1925 - seq_printf(m, " (ringbuffer, space: %d, head: %u, tail: %u)", 1926 - ring->space, ring->head, ring->tail); 1926 + seq_printf(m, " (ringbuffer, space: %d, head: %u, tail: %u, emit: %u)", 1927 + ring->space, ring->head, ring->tail, ring->emit); 1927 1928 } 1928 1929 1929 1930 static int i915_context_status(struct seq_file *m, void *unused) ··· 2325 2326 return 0; 2326 2327 } 2327 2328 2329 + static const char * 2330 + stringify_guc_log_type(enum guc_log_buffer_type type) 2331 + { 2332 + switch (type) { 2333 + case GUC_ISR_LOG_BUFFER: 2334 + return "ISR"; 2335 + case GUC_DPC_LOG_BUFFER: 2336 + return "DPC"; 2337 + case GUC_CRASH_DUMP_LOG_BUFFER: 2338 + return "CRASH"; 2339 + default: 2340 + MISSING_CASE(type); 2341 + } 2342 + 2343 + return ""; 2344 + } 2345 + 2328 2346 static void i915_guc_log_info(struct seq_file *m, 2329 2347 struct drm_i915_private *dev_priv) 2330 2348 { 2331 - struct intel_guc *guc = &dev_priv->guc; 2349 + struct intel_guc_log *log = &dev_priv->guc.log; 2350 + enum guc_log_buffer_type type; 2332 2351 2333 - seq_puts(m, "\nGuC logging stats:\n"); 2352 + if (!intel_guc_log_relay_enabled(log)) { 2353 + seq_puts(m, "GuC log relay disabled\n"); 2354 + return; 2355 + } 2334 2356 2335 - seq_printf(m, "\tISR: flush count %10u, overflow count %10u\n", 2336 - guc->log.flush_count[GUC_ISR_LOG_BUFFER], 2337 - guc->log.total_overflow_count[GUC_ISR_LOG_BUFFER]); 2357 + seq_puts(m, "GuC logging stats:\n"); 2338 2358 2339 - seq_printf(m, "\tDPC: flush count %10u, overflow count %10u\n", 2340 - guc->log.flush_count[GUC_DPC_LOG_BUFFER], 2341 - guc->log.total_overflow_count[GUC_DPC_LOG_BUFFER]); 2359 + seq_printf(m, "\tRelay full count: %u\n", 2360 + log->relay.full_count); 2342 2361 2343 - seq_printf(m, "\tCRASH: flush count %10u, overflow count %10u\n", 2344 - guc->log.flush_count[GUC_CRASH_DUMP_LOG_BUFFER], 2345 - guc->log.total_overflow_count[GUC_CRASH_DUMP_LOG_BUFFER]); 2346 - 2347 - seq_printf(m, "\tTotal flush interrupt count: %u\n", 2348 - guc->log.flush_interrupt_count); 2349 - 2350 - seq_printf(m, "\tCapture miss count: %u\n", 2351 - guc->log.capture_miss_count); 2362 + for (type = GUC_ISR_LOG_BUFFER; type < GUC_MAX_LOG_BUFFER; type++) { 2363 + seq_printf(m, "\t%s:\tflush count %10u, overflow count %10u\n", 2364 + stringify_guc_log_type(type), 2365 + log->stats[type].flush, 2366 + log->stats[type].sampled_overflow); 2367 + } 2352 2368 } 2353 2369 2354 2370 static void i915_guc_client_info(struct seq_file *m, ··· 2393 2379 struct drm_i915_private *dev_priv = node_to_i915(m->private); 2394 2380 const struct intel_guc *guc = &dev_priv->guc; 2395 2381 2396 - if (!USES_GUC_SUBMISSION(dev_priv)) 2382 + if (!USES_GUC(dev_priv)) 2397 2383 return -ENODEV; 2384 + 2385 + i915_guc_log_info(m, dev_priv); 2386 + 2387 + if (!USES_GUC_SUBMISSION(dev_priv)) 2388 + return 0; 2398 2389 2399 2390 GEM_BUG_ON(!guc->execbuf_client); 2400 2391 2401 - seq_printf(m, "Doorbell map:\n"); 2392 + seq_printf(m, "\nDoorbell map:\n"); 2402 2393 seq_printf(m, "\t%*pb\n", GUC_NUM_DOORBELLS, guc->doorbell_bitmap); 2403 - seq_printf(m, "Doorbell next cacheline: 0x%x\n\n", guc->db_cacheline); 2394 + seq_printf(m, "Doorbell next cacheline: 0x%x\n", guc->db_cacheline); 2404 2395 2405 2396 seq_printf(m, "\nGuC execbuf client @ %p:\n", guc->execbuf_client); 2406 2397 i915_guc_client_info(m, dev_priv, guc->execbuf_client); ··· 2414 2395 guc->preempt_client); 2415 2396 i915_guc_client_info(m, dev_priv, guc->preempt_client); 2416 2397 } 2417 - 2418 - i915_guc_log_info(m, dev_priv); 2419 2398 2420 2399 /* Add more as required ... */ 2421 2400 ··· 2513 2496 return 0; 2514 2497 } 2515 2498 2516 - static int i915_guc_log_control_get(void *data, u64 *val) 2499 + static int i915_guc_log_level_get(void *data, u64 *val) 2517 2500 { 2518 2501 struct drm_i915_private *dev_priv = data; 2519 2502 2520 - if (!HAS_GUC(dev_priv)) 2503 + if (!USES_GUC(dev_priv)) 2521 2504 return -ENODEV; 2522 2505 2523 - if (!dev_priv->guc.log.vma) 2524 - return -EINVAL; 2525 - 2526 - *val = i915_modparams.guc_log_level; 2506 + *val = intel_guc_log_level_get(&dev_priv->guc.log); 2527 2507 2528 2508 return 0; 2529 2509 } 2530 2510 2531 - static int i915_guc_log_control_set(void *data, u64 val) 2511 + static int i915_guc_log_level_set(void *data, u64 val) 2532 2512 { 2533 2513 struct drm_i915_private *dev_priv = data; 2534 2514 2535 - if (!HAS_GUC(dev_priv)) 2515 + if (!USES_GUC(dev_priv)) 2536 2516 return -ENODEV; 2537 2517 2538 - return intel_guc_log_control(&dev_priv->guc, val); 2518 + return intel_guc_log_level_set(&dev_priv->guc.log, val); 2539 2519 } 2540 2520 2541 - DEFINE_SIMPLE_ATTRIBUTE(i915_guc_log_control_fops, 2542 - i915_guc_log_control_get, i915_guc_log_control_set, 2521 + DEFINE_SIMPLE_ATTRIBUTE(i915_guc_log_level_fops, 2522 + i915_guc_log_level_get, i915_guc_log_level_set, 2543 2523 "%lld\n"); 2524 + 2525 + static int i915_guc_log_relay_open(struct inode *inode, struct file *file) 2526 + { 2527 + struct drm_i915_private *dev_priv = inode->i_private; 2528 + 2529 + if (!USES_GUC(dev_priv)) 2530 + return -ENODEV; 2531 + 2532 + file->private_data = &dev_priv->guc.log; 2533 + 2534 + return intel_guc_log_relay_open(&dev_priv->guc.log); 2535 + } 2536 + 2537 + static ssize_t 2538 + i915_guc_log_relay_write(struct file *filp, 2539 + const char __user *ubuf, 2540 + size_t cnt, 2541 + loff_t *ppos) 2542 + { 2543 + struct intel_guc_log *log = filp->private_data; 2544 + 2545 + intel_guc_log_relay_flush(log); 2546 + 2547 + return cnt; 2548 + } 2549 + 2550 + static int i915_guc_log_relay_release(struct inode *inode, struct file *file) 2551 + { 2552 + struct drm_i915_private *dev_priv = inode->i_private; 2553 + 2554 + intel_guc_log_relay_close(&dev_priv->guc.log); 2555 + 2556 + return 0; 2557 + } 2558 + 2559 + static const struct file_operations i915_guc_log_relay_fops = { 2560 + .owner = THIS_MODULE, 2561 + .open = i915_guc_log_relay_open, 2562 + .write = i915_guc_log_relay_write, 2563 + .release = i915_guc_log_relay_release, 2564 + }; 2544 2565 2545 2566 static const char *psr2_live_status(u32 val) 2546 2567 { ··· 2624 2569 2625 2570 mutex_lock(&dev_priv->psr.lock); 2626 2571 seq_printf(m, "Enabled: %s\n", yesno((bool)dev_priv->psr.enabled)); 2627 - seq_printf(m, "Active: %s\n", yesno(dev_priv->psr.active)); 2628 2572 seq_printf(m, "Busy frontbuffer bits: 0x%03x\n", 2629 2573 dev_priv->psr.busy_frontbuffer_bits); 2630 2574 seq_printf(m, "Re-enable work scheduled: %s\n", 2631 2575 yesno(work_busy(&dev_priv->psr.work.work))); 2632 2576 2633 2577 if (HAS_DDI(dev_priv)) { 2634 - if (dev_priv->psr.psr2_support) 2578 + if (dev_priv->psr.psr2_enabled) 2635 2579 enabled = I915_READ(EDP_PSR2_CTL) & EDP_PSR2_ENABLE; 2636 2580 else 2637 2581 enabled = I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE; ··· 2678 2624 2679 2625 seq_printf(m, "Performance_Counter: %u\n", psrperf); 2680 2626 } 2681 - if (dev_priv->psr.psr2_support) { 2627 + if (dev_priv->psr.psr2_enabled) { 2682 2628 u32 psr2 = I915_READ(EDP_PSR2_STATUS); 2683 2629 2684 2630 seq_printf(m, "EDP_PSR2_STATUS: %x [%s]\n", ··· 3285 3231 for (i = 0; i < dev_priv->num_shared_dpll; i++) { 3286 3232 struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i]; 3287 3233 3288 - seq_printf(m, "DPLL%i: %s, id: %i\n", i, pll->name, pll->id); 3234 + seq_printf(m, "DPLL%i: %s, id: %i\n", i, pll->info->name, 3235 + pll->info->id); 3289 3236 seq_printf(m, " crtc_mask: 0x%08x, active: 0x%x, on: %s\n", 3290 3237 pll->state.crtc_mask, pll->active_mask, yesno(pll->on)); 3291 3238 seq_printf(m, " tracked hardware state:\n"); ··· 3622 3567 3623 3568 static int i915_displayport_test_active_show(struct seq_file *m, void *data) 3624 3569 { 3625 - struct drm_device *dev = m->private; 3570 + struct drm_i915_private *dev_priv = m->private; 3571 + struct drm_device *dev = &dev_priv->drm; 3626 3572 struct drm_connector *connector; 3627 3573 struct drm_connector_list_iter conn_iter; 3628 3574 struct intel_dp *intel_dp; ··· 3657 3601 static int i915_displayport_test_active_open(struct inode *inode, 3658 3602 struct file *file) 3659 3603 { 3660 - struct drm_i915_private *dev_priv = inode->i_private; 3661 - 3662 3604 return single_open(file, i915_displayport_test_active_show, 3663 - &dev_priv->drm); 3605 + inode->i_private); 3664 3606 } 3665 3607 3666 3608 static const struct file_operations i915_displayport_test_active_fops = { ··· 3672 3618 3673 3619 static int i915_displayport_test_data_show(struct seq_file *m, void *data) 3674 3620 { 3675 - struct drm_device *dev = m->private; 3621 + struct drm_i915_private *dev_priv = m->private; 3622 + struct drm_device *dev = &dev_priv->drm; 3676 3623 struct drm_connector *connector; 3677 3624 struct drm_connector_list_iter conn_iter; 3678 3625 struct intel_dp *intel_dp; ··· 3712 3657 3713 3658 return 0; 3714 3659 } 3715 - static int i915_displayport_test_data_open(struct inode *inode, 3716 - struct file *file) 3717 - { 3718 - struct drm_i915_private *dev_priv = inode->i_private; 3719 - 3720 - return single_open(file, i915_displayport_test_data_show, 3721 - &dev_priv->drm); 3722 - } 3723 - 3724 - static const struct file_operations i915_displayport_test_data_fops = { 3725 - .owner = THIS_MODULE, 3726 - .open = i915_displayport_test_data_open, 3727 - .read = seq_read, 3728 - .llseek = seq_lseek, 3729 - .release = single_release 3730 - }; 3660 + DEFINE_SHOW_ATTRIBUTE(i915_displayport_test_data); 3731 3661 3732 3662 static int i915_displayport_test_type_show(struct seq_file *m, void *data) 3733 3663 { 3734 - struct drm_device *dev = m->private; 3664 + struct drm_i915_private *dev_priv = m->private; 3665 + struct drm_device *dev = &dev_priv->drm; 3735 3666 struct drm_connector *connector; 3736 3667 struct drm_connector_list_iter conn_iter; 3737 3668 struct intel_dp *intel_dp; ··· 3744 3703 3745 3704 return 0; 3746 3705 } 3747 - 3748 - static int i915_displayport_test_type_open(struct inode *inode, 3749 - struct file *file) 3750 - { 3751 - struct drm_i915_private *dev_priv = inode->i_private; 3752 - 3753 - return single_open(file, i915_displayport_test_type_show, 3754 - &dev_priv->drm); 3755 - } 3756 - 3757 - static const struct file_operations i915_displayport_test_type_fops = { 3758 - .owner = THIS_MODULE, 3759 - .open = i915_displayport_test_type_open, 3760 - .read = seq_read, 3761 - .llseek = seq_lseek, 3762 - .release = single_release 3763 - }; 3706 + DEFINE_SHOW_ATTRIBUTE(i915_displayport_test_type); 3764 3707 3765 3708 static void wm_latency_show(struct seq_file *m, const uint16_t wm[8]) 3766 3709 { ··· 4012 3987 engine->hangcheck.stalled = true; 4013 3988 } 4014 3989 4015 - i915_handle_error(i915, val, "Manually set wedged engine mask = %llx", 4016 - val); 3990 + i915_handle_error(i915, val, I915_ERROR_CAPTURE, 3991 + "Manually set wedged engine mask = %llx", val); 4017 3992 4018 3993 wait_on_bit(&i915->gpu_error.flags, 4019 3994 I915_RESET_HANDOFF, ··· 4341 4316 static void cherryview_sseu_device_status(struct drm_i915_private *dev_priv, 4342 4317 struct sseu_dev_info *sseu) 4343 4318 { 4344 - int ss_max = 2; 4319 + #define SS_MAX 2 4320 + const int ss_max = SS_MAX; 4321 + u32 sig1[SS_MAX], sig2[SS_MAX]; 4345 4322 int ss; 4346 - u32 sig1[ss_max], sig2[ss_max]; 4347 4323 4348 4324 sig1[0] = I915_READ(CHV_POWER_SS0_SIG1); 4349 4325 sig1[1] = I915_READ(CHV_POWER_SS1_SIG1); ··· 4368 4342 sseu->eu_per_subslice = max_t(unsigned int, 4369 4343 sseu->eu_per_subslice, eu_cnt); 4370 4344 } 4345 + #undef SS_MAX 4371 4346 } 4372 4347 4373 4348 static void gen10_sseu_device_status(struct drm_i915_private *dev_priv, 4374 4349 struct sseu_dev_info *sseu) 4375 4350 { 4351 + #define SS_MAX 6 4376 4352 const struct intel_device_info *info = INTEL_INFO(dev_priv); 4353 + u32 s_reg[SS_MAX], eu_reg[2 * SS_MAX], eu_mask[2]; 4377 4354 int s, ss; 4378 - u32 s_reg[info->sseu.max_slices]; 4379 - u32 eu_reg[2 * info->sseu.max_subslices], eu_mask[2]; 4380 4355 4381 4356 for (s = 0; s < info->sseu.max_slices; s++) { 4382 4357 /* ··· 4424 4397 eu_cnt); 4425 4398 } 4426 4399 } 4400 + #undef SS_MAX 4427 4401 } 4428 4402 4429 4403 static void gen9_sseu_device_status(struct drm_i915_private *dev_priv, 4430 4404 struct sseu_dev_info *sseu) 4431 4405 { 4406 + #define SS_MAX 3 4432 4407 const struct intel_device_info *info = INTEL_INFO(dev_priv); 4408 + u32 s_reg[SS_MAX], eu_reg[2 * SS_MAX], eu_mask[2]; 4433 4409 int s, ss; 4434 - u32 s_reg[info->sseu.max_slices]; 4435 - u32 eu_reg[2 * info->sseu.max_subslices], eu_mask[2]; 4436 4410 4437 4411 for (s = 0; s < info->sseu.max_slices; s++) { 4438 4412 s_reg[s] = I915_READ(GEN9_SLICE_PGCTL_ACK(s)); ··· 4480 4452 eu_cnt); 4481 4453 } 4482 4454 } 4455 + #undef SS_MAX 4483 4456 } 4484 4457 4485 4458 static void broadwell_sseu_device_status(struct drm_i915_private *dev_priv, ··· 4732 4703 4733 4704 DEFINE_SIMPLE_ATTRIBUTE(i915_drrs_ctl_fops, NULL, i915_drrs_ctl_set, "%llu\n"); 4734 4705 4706 + static ssize_t 4707 + i915_fifo_underrun_reset_write(struct file *filp, 4708 + const char __user *ubuf, 4709 + size_t cnt, loff_t *ppos) 4710 + { 4711 + struct drm_i915_private *dev_priv = filp->private_data; 4712 + struct intel_crtc *intel_crtc; 4713 + struct drm_device *dev = &dev_priv->drm; 4714 + int ret; 4715 + bool reset; 4716 + 4717 + ret = kstrtobool_from_user(ubuf, cnt, &reset); 4718 + if (ret) 4719 + return ret; 4720 + 4721 + if (!reset) 4722 + return cnt; 4723 + 4724 + for_each_intel_crtc(dev, intel_crtc) { 4725 + struct drm_crtc_commit *commit; 4726 + struct intel_crtc_state *crtc_state; 4727 + 4728 + ret = drm_modeset_lock_single_interruptible(&intel_crtc->base.mutex); 4729 + if (ret) 4730 + return ret; 4731 + 4732 + crtc_state = to_intel_crtc_state(intel_crtc->base.state); 4733 + commit = crtc_state->base.commit; 4734 + if (commit) { 4735 + ret = wait_for_completion_interruptible(&commit->hw_done); 4736 + if (!ret) 4737 + ret = wait_for_completion_interruptible(&commit->flip_done); 4738 + } 4739 + 4740 + if (!ret && crtc_state->base.active) { 4741 + DRM_DEBUG_KMS("Re-arming FIFO underruns on pipe %c\n", 4742 + pipe_name(intel_crtc->pipe)); 4743 + 4744 + intel_crtc_arm_fifo_underrun(intel_crtc, crtc_state); 4745 + } 4746 + 4747 + drm_modeset_unlock(&intel_crtc->base.mutex); 4748 + 4749 + if (ret) 4750 + return ret; 4751 + } 4752 + 4753 + ret = intel_fbc_reset_underrun(dev_priv); 4754 + if (ret) 4755 + return ret; 4756 + 4757 + return cnt; 4758 + } 4759 + 4760 + static const struct file_operations i915_fifo_underrun_reset_ops = { 4761 + .owner = THIS_MODULE, 4762 + .open = simple_open, 4763 + .write = i915_fifo_underrun_reset_write, 4764 + .llseek = default_llseek, 4765 + }; 4766 + 4735 4767 static const struct drm_info_list i915_debugfs_list[] = { 4736 4768 {"i915_capabilities", i915_capabilities, 0}, 4737 4769 {"i915_gem_objects", i915_gem_object_info, 0}, ··· 4860 4770 {"i915_error_state", &i915_error_state_fops}, 4861 4771 {"i915_gpu_info", &i915_gpu_info_fops}, 4862 4772 #endif 4773 + {"i915_fifo_underrun_reset", &i915_fifo_underrun_reset_ops}, 4863 4774 {"i915_next_seqno", &i915_next_seqno_fops}, 4864 4775 {"i915_display_crc_ctl", &i915_display_crc_ctl_fops}, 4865 4776 {"i915_pri_wm_latency", &i915_pri_wm_latency_fops}, ··· 4870 4779 {"i915_dp_test_data", &i915_displayport_test_data_fops}, 4871 4780 {"i915_dp_test_type", &i915_displayport_test_type_fops}, 4872 4781 {"i915_dp_test_active", &i915_displayport_test_active_fops}, 4873 - {"i915_guc_log_control", &i915_guc_log_control_fops}, 4782 + {"i915_guc_log_level", &i915_guc_log_level_fops}, 4783 + {"i915_guc_log_relay", &i915_guc_log_relay_fops}, 4874 4784 {"i915_hpd_storm_ctl", &i915_hpd_storm_ctl_fops}, 4875 4785 {"i915_ipc_status", &i915_ipc_status_fops}, 4876 4786 {"i915_drrs_ctl", &i915_drrs_ctl_fops} ··· 4968 4876 4969 4877 return 0; 4970 4878 } 4971 - 4972 - static int i915_dpcd_open(struct inode *inode, struct file *file) 4973 - { 4974 - return single_open(file, i915_dpcd_show, inode->i_private); 4975 - } 4976 - 4977 - static const struct file_operations i915_dpcd_fops = { 4978 - .owner = THIS_MODULE, 4979 - .open = i915_dpcd_open, 4980 - .read = seq_read, 4981 - .llseek = seq_lseek, 4982 - .release = single_release, 4983 - }; 4879 + DEFINE_SHOW_ATTRIBUTE(i915_dpcd); 4984 4880 4985 4881 static int i915_panel_show(struct seq_file *m, void *data) 4986 4882 { ··· 4990 4910 4991 4911 return 0; 4992 4912 } 4993 - 4994 - static int i915_panel_open(struct inode *inode, struct file *file) 4995 - { 4996 - return single_open(file, i915_panel_show, inode->i_private); 4997 - } 4998 - 4999 - static const struct file_operations i915_panel_fops = { 5000 - .owner = THIS_MODULE, 5001 - .open = i915_panel_open, 5002 - .read = seq_read, 5003 - .llseek = seq_lseek, 5004 - .release = single_release, 5005 - }; 4913 + DEFINE_SHOW_ATTRIBUTE(i915_panel); 5006 4914 5007 4915 /** 5008 4916 * i915_debugfs_connector_add - add i915 specific connector debugfs files
+33 -33
drivers/gpu/drm/i915/i915_drv.c
··· 377 377 value = INTEL_INFO(dev_priv)->sseu.min_eu_in_pool; 378 378 break; 379 379 case I915_PARAM_HUC_STATUS: 380 - intel_runtime_pm_get(dev_priv); 381 - value = I915_READ(HUC_STATUS2) & HUC_FW_VERIFIED; 382 - intel_runtime_pm_put(dev_priv); 380 + value = intel_huc_check_status(&dev_priv->huc); 381 + if (value < 0) 382 + return value; 383 383 break; 384 384 case I915_PARAM_MMAP_GTT_VERSION: 385 385 /* Though we've started our numbering from 1, and so class all ··· 695 695 if (ret) 696 696 goto cleanup_irq; 697 697 698 - intel_uc_init_fw(dev_priv); 699 - 700 698 ret = i915_gem_init(dev_priv); 701 699 if (ret) 702 - goto cleanup_uc; 700 + goto cleanup_irq; 703 701 704 702 intel_setup_overlay(dev_priv); 705 703 ··· 717 719 if (i915_gem_suspend(dev_priv)) 718 720 DRM_ERROR("failed to idle hardware; continuing to unload!\n"); 719 721 i915_gem_fini(dev_priv); 720 - cleanup_uc: 721 - intel_uc_fini_fw(dev_priv); 722 722 cleanup_irq: 723 723 drm_irq_uninstall(dev); 724 724 intel_teardown_gmbus(dev_priv); ··· 918 922 mutex_init(&dev_priv->wm.wm_mutex); 919 923 mutex_init(&dev_priv->pps_mutex); 920 924 921 - intel_uc_init_early(dev_priv); 922 925 i915_memcpy_init_early(dev_priv); 923 926 924 927 ret = i915_workqueues_init(dev_priv); 925 928 if (ret < 0) 926 929 goto err_engines; 927 930 931 + ret = i915_gem_init_early(dev_priv); 932 + if (ret < 0) 933 + goto err_workqueues; 934 + 928 935 /* This must be called before any calls to HAS_PCH_* */ 929 936 intel_detect_pch(dev_priv); 930 937 938 + intel_wopcm_init_early(&dev_priv->wopcm); 939 + intel_uc_init_early(dev_priv); 931 940 intel_pm_setup(dev_priv); 932 941 intel_init_dpio(dev_priv); 933 942 intel_power_domains_init(dev_priv); ··· 941 940 intel_init_display_hooks(dev_priv); 942 941 intel_init_clock_gating_hooks(dev_priv); 943 942 intel_init_audio_hooks(dev_priv); 944 - ret = i915_gem_load_init(dev_priv); 945 - if (ret < 0) 946 - goto err_irq; 947 - 948 943 intel_display_crc_init(dev_priv); 949 944 950 945 intel_detect_preproduction_hw(dev_priv); 951 946 952 947 return 0; 953 948 954 - err_irq: 955 - intel_irq_fini(dev_priv); 949 + err_workqueues: 956 950 i915_workqueues_cleanup(dev_priv); 957 951 err_engines: 958 952 i915_engines_cleanup(dev_priv); ··· 960 964 */ 961 965 static void i915_driver_cleanup_early(struct drm_i915_private *dev_priv) 962 966 { 963 - i915_gem_load_cleanup(dev_priv); 964 967 intel_irq_fini(dev_priv); 968 + intel_uc_cleanup_early(dev_priv); 969 + i915_gem_cleanup_early(dev_priv); 965 970 i915_workqueues_cleanup(dev_priv); 966 971 i915_engines_cleanup(dev_priv); 967 972 } ··· 1032 1035 1033 1036 intel_uncore_init(dev_priv); 1034 1037 1038 + intel_device_info_init_mmio(dev_priv); 1039 + 1040 + intel_uncore_prune(dev_priv); 1041 + 1035 1042 intel_uc_init_mmio(dev_priv); 1036 1043 1037 1044 ret = intel_engines_init_mmio(dev_priv); ··· 1077 1076 intel_sanitize_enable_ppgtt(dev_priv, 1078 1077 i915_modparams.enable_ppgtt); 1079 1078 DRM_DEBUG_DRIVER("ppgtt mode: %i\n", i915_modparams.enable_ppgtt); 1080 - 1081 - intel_uc_sanitize_options(dev_priv); 1082 1079 1083 1080 intel_gvt_sanitize_options(dev_priv); 1084 1081 } ··· 1243 1244 /* Reveal our presence to userspace */ 1244 1245 if (drm_dev_register(dev, 0) == 0) { 1245 1246 i915_debugfs_register(dev_priv); 1246 - i915_guc_log_register(dev_priv); 1247 1247 i915_setup_sysfs(dev_priv); 1248 1248 1249 1249 /* Depends on sysfs having been initialized */ ··· 1302 1304 i915_pmu_unregister(dev_priv); 1303 1305 1304 1306 i915_teardown_sysfs(dev_priv); 1305 - i915_guc_log_unregister(dev_priv); 1306 1307 drm_dev_unregister(&dev_priv->drm); 1307 1308 1308 1309 i915_gem_shrinker_unregister(dev_priv); ··· 1460 1463 i915_reset_error_state(dev_priv); 1461 1464 1462 1465 i915_gem_fini(dev_priv); 1463 - intel_uc_fini_fw(dev_priv); 1464 1466 intel_fbc_cleanup_cfb(dev_priv); 1465 1467 1466 1468 intel_power_domains_fini(dev_priv); ··· 1872 1876 /** 1873 1877 * i915_reset - reset chip after a hang 1874 1878 * @i915: #drm_i915_private to reset 1875 - * @flags: Instructions 1879 + * @stalled_mask: mask of the stalled engines with the guilty requests 1880 + * @reason: user error message for why we are resetting 1876 1881 * 1877 1882 * Reset the chip. Useful if a hang is detected. Marks the device as wedged 1878 1883 * on failure. ··· 1888 1891 * - re-init interrupt state 1889 1892 * - re-init display 1890 1893 */ 1891 - void i915_reset(struct drm_i915_private *i915, unsigned int flags) 1894 + void i915_reset(struct drm_i915_private *i915, 1895 + unsigned int stalled_mask, 1896 + const char *reason) 1892 1897 { 1893 1898 struct i915_gpu_error *error = &i915->gpu_error; 1894 1899 int ret; 1895 1900 int i; 1901 + 1902 + GEM_TRACE("flags=%lx\n", error->flags); 1896 1903 1897 1904 might_sleep(); 1898 1905 lockdep_assert_held(&i915->drm.struct_mutex); ··· 1909 1908 if (!i915_gem_unset_wedged(i915)) 1910 1909 goto wakeup; 1911 1910 1912 - if (!(flags & I915_RESET_QUIET)) 1913 - dev_notice(i915->drm.dev, "Resetting chip after gpu hang\n"); 1911 + if (reason) 1912 + dev_notice(i915->drm.dev, "Resetting chip for %s\n", reason); 1914 1913 error->reset_count++; 1915 1914 1916 1915 disable_irq(i915->drm.irq); ··· 1953 1952 goto error; 1954 1953 } 1955 1954 1956 - i915_gem_reset(i915); 1955 + i915_gem_reset(i915, stalled_mask); 1957 1956 intel_overlay_reset(i915); 1958 1957 1959 1958 /* ··· 1999 1998 error: 2000 1999 i915_gem_set_wedged(i915); 2001 2000 i915_retire_requests(i915); 2002 - intel_gpu_reset(i915, ALL_ENGINES); 2003 2001 goto finish; 2004 2002 } 2005 2003 ··· 2011 2011 /** 2012 2012 * i915_reset_engine - reset GPU engine to recover from a hang 2013 2013 * @engine: engine to reset 2014 - * @flags: options 2014 + * @msg: reason for GPU reset; or NULL for no dev_notice() 2015 2015 * 2016 2016 * Reset a specific GPU engine. Useful if a hang is detected. 2017 2017 * Returns zero on successful reset or otherwise an error code. ··· 2021 2021 * - reset engine (which will force the engine to idle) 2022 2022 * - re-init/configure engine 2023 2023 */ 2024 - int i915_reset_engine(struct intel_engine_cs *engine, unsigned int flags) 2024 + int i915_reset_engine(struct intel_engine_cs *engine, const char *msg) 2025 2025 { 2026 2026 struct i915_gpu_error *error = &engine->i915->gpu_error; 2027 2027 struct i915_request *active_request; 2028 2028 int ret; 2029 2029 2030 + GEM_TRACE("%s flags=%lx\n", engine->name, error->flags); 2030 2031 GEM_BUG_ON(!test_bit(I915_RESET_ENGINE + engine->id, &error->flags)); 2031 2032 2032 2033 active_request = i915_gem_reset_prepare_engine(engine); ··· 2037 2036 goto out; 2038 2037 } 2039 2038 2040 - if (!(flags & I915_RESET_QUIET)) { 2039 + if (msg) 2041 2040 dev_notice(engine->i915->drm.dev, 2042 - "Resetting %s after gpu hang\n", engine->name); 2043 - } 2041 + "Resetting %s for %s\n", engine->name, msg); 2044 2042 error->reset_engine_count[engine->id]++; 2045 2043 2046 2044 if (!engine->i915->guc.execbuf_client) ··· 2059 2059 * active request and can drop it, adjust head to skip the offending 2060 2060 * request to resume executing remaining requests in the queue. 2061 2061 */ 2062 - i915_gem_reset_engine(engine, active_request); 2062 + i915_gem_reset_engine(engine, active_request, true); 2063 2063 2064 2064 /* 2065 2065 * The engine and its registers (and workarounds in case of render)
+39 -350
drivers/gpu/drm/i915/i915_drv.h
··· 64 64 #include "intel_opregion.h" 65 65 #include "intel_ringbuffer.h" 66 66 #include "intel_uncore.h" 67 + #include "intel_wopcm.h" 67 68 #include "intel_uc.h" 68 69 69 70 #include "i915_gem.h" ··· 73 72 #include "i915_gem_object.h" 74 73 #include "i915_gem_gtt.h" 75 74 #include "i915_gem_timeline.h" 76 - 75 + #include "i915_gpu_error.h" 77 76 #include "i915_request.h" 78 77 #include "i915_vma.h" 79 78 ··· 84 83 85 84 #define DRIVER_NAME "i915" 86 85 #define DRIVER_DESC "Intel Graphics" 87 - #define DRIVER_DATE "20180308" 88 - #define DRIVER_TIMESTAMP 1520513379 86 + #define DRIVER_DATE "20180413" 87 + #define DRIVER_TIMESTAMP 1523611258 89 88 90 89 /* Use I915_STATE_WARN(x) and I915_STATE_WARN_ON() (rather than WARN() and 91 90 * WARN_ON()) for hw state sanity checks to check for unexpected conditions ··· 262 261 HPD_PORT_C, 263 262 HPD_PORT_D, 264 263 HPD_PORT_E, 264 + HPD_PORT_F, 265 265 HPD_NUM_PINS 266 266 }; 267 267 ··· 455 453 uint32_t allowed_dc_mask; 456 454 }; 457 455 458 - struct intel_display_error_state; 459 - 460 - struct i915_gpu_state { 461 - struct kref ref; 462 - ktime_t time; 463 - ktime_t boottime; 464 - ktime_t uptime; 465 - 466 - struct drm_i915_private *i915; 467 - 468 - char error_msg[128]; 469 - bool simulated; 470 - bool awake; 471 - bool wakelock; 472 - bool suspended; 473 - int iommu; 474 - u32 reset_count; 475 - u32 suspend_count; 476 - struct intel_device_info device_info; 477 - struct intel_driver_caps driver_caps; 478 - struct i915_params params; 479 - 480 - struct i915_error_uc { 481 - struct intel_uc_fw guc_fw; 482 - struct intel_uc_fw huc_fw; 483 - struct drm_i915_error_object *guc_log; 484 - } uc; 485 - 486 - /* Generic register state */ 487 - u32 eir; 488 - u32 pgtbl_er; 489 - u32 ier; 490 - u32 gtier[4], ngtier; 491 - u32 ccid; 492 - u32 derrmr; 493 - u32 forcewake; 494 - u32 error; /* gen6+ */ 495 - u32 err_int; /* gen7 */ 496 - u32 fault_data0; /* gen8, gen9 */ 497 - u32 fault_data1; /* gen8, gen9 */ 498 - u32 done_reg; 499 - u32 gac_eco; 500 - u32 gam_ecochk; 501 - u32 gab_ctl; 502 - u32 gfx_mode; 503 - 504 - u32 nfence; 505 - u64 fence[I915_MAX_NUM_FENCES]; 506 - struct intel_overlay_error_state *overlay; 507 - struct intel_display_error_state *display; 508 - 509 - struct drm_i915_error_engine { 510 - int engine_id; 511 - /* Software tracked state */ 512 - bool idle; 513 - bool waiting; 514 - int num_waiters; 515 - unsigned long hangcheck_timestamp; 516 - bool hangcheck_stalled; 517 - enum intel_engine_hangcheck_action hangcheck_action; 518 - struct i915_address_space *vm; 519 - int num_requests; 520 - u32 reset_count; 521 - 522 - /* position of active request inside the ring */ 523 - u32 rq_head, rq_post, rq_tail; 524 - 525 - /* our own tracking of ring head and tail */ 526 - u32 cpu_ring_head; 527 - u32 cpu_ring_tail; 528 - 529 - u32 last_seqno; 530 - 531 - /* Register state */ 532 - u32 start; 533 - u32 tail; 534 - u32 head; 535 - u32 ctl; 536 - u32 mode; 537 - u32 hws; 538 - u32 ipeir; 539 - u32 ipehr; 540 - u32 bbstate; 541 - u32 instpm; 542 - u32 instps; 543 - u32 seqno; 544 - u64 bbaddr; 545 - u64 acthd; 546 - u32 fault_reg; 547 - u64 faddr; 548 - u32 rc_psmi; /* sleep state */ 549 - u32 semaphore_mboxes[I915_NUM_ENGINES - 1]; 550 - struct intel_instdone instdone; 551 - 552 - struct drm_i915_error_context { 553 - char comm[TASK_COMM_LEN]; 554 - pid_t pid; 555 - u32 handle; 556 - u32 hw_id; 557 - int priority; 558 - int ban_score; 559 - int active; 560 - int guilty; 561 - bool bannable; 562 - } context; 563 - 564 - struct drm_i915_error_object { 565 - u64 gtt_offset; 566 - u64 gtt_size; 567 - int page_count; 568 - int unused; 569 - u32 *pages[0]; 570 - } *ringbuffer, *batchbuffer, *wa_batchbuffer, *ctx, *hws_page; 571 - 572 - struct drm_i915_error_object **user_bo; 573 - long user_bo_count; 574 - 575 - struct drm_i915_error_object *wa_ctx; 576 - struct drm_i915_error_object *default_state; 577 - 578 - struct drm_i915_error_request { 579 - long jiffies; 580 - pid_t pid; 581 - u32 context; 582 - int priority; 583 - int ban_score; 584 - u32 seqno; 585 - u32 head; 586 - u32 tail; 587 - } *requests, execlist[EXECLIST_MAX_PORTS]; 588 - unsigned int num_ports; 589 - 590 - struct drm_i915_error_waiter { 591 - char comm[TASK_COMM_LEN]; 592 - pid_t pid; 593 - u32 seqno; 594 - } *waiters; 595 - 596 - struct { 597 - u32 gfx_mode; 598 - union { 599 - u64 pdp[4]; 600 - u32 pp_dir_base; 601 - }; 602 - } vm_info; 603 - } engine[I915_NUM_ENGINES]; 604 - 605 - struct drm_i915_error_buffer { 606 - u32 size; 607 - u32 name; 608 - u32 rseqno[I915_NUM_ENGINES], wseqno; 609 - u64 gtt_offset; 610 - u32 read_domains; 611 - u32 write_domain; 612 - s32 fence_reg:I915_MAX_NUM_FENCE_BITS; 613 - u32 tiling:2; 614 - u32 dirty:1; 615 - u32 purgeable:1; 616 - u32 userptr:1; 617 - s32 engine:4; 618 - u32 cache_level:3; 619 - } *active_bo[I915_NUM_ENGINES], *pinned_bo; 620 - u32 active_bo_count[I915_NUM_ENGINES], pinned_bo_count; 621 - struct i915_address_space *active_vm[I915_NUM_ENGINES]; 622 - }; 623 - 624 456 enum i915_cache_level { 625 457 I915_CACHE_NONE = 0, 626 458 I915_CACHE_LLC, /* also used for snoopable memory on non-LLC */ ··· 602 766 bool active; 603 767 struct delayed_work work; 604 768 unsigned busy_frontbuffer_bits; 605 - bool psr2_support; 606 - bool aux_frame_sync; 769 + bool sink_psr2_support; 607 770 bool link_standby; 608 - bool y_cord_support; 609 771 bool colorimetry_support; 610 772 bool alpm; 773 + bool has_hw_tracking; 774 + bool psr2_enabled; 775 + u8 sink_sync_latency; 611 776 612 777 void (*enable_source)(struct intel_dp *, 613 778 const struct intel_crtc_state *); ··· 983 1146 u32 object_count; 984 1147 }; 985 1148 986 - struct drm_i915_error_state_buf { 987 - struct drm_i915_private *i915; 988 - unsigned bytes; 989 - unsigned size; 990 - int err; 991 - u8 *buf; 992 - loff_t start; 993 - loff_t pos; 994 - }; 995 - 996 1149 #define I915_IDLE_ENGINES_TIMEOUT (200) /* in ms */ 997 1150 998 1151 #define I915_RESET_TIMEOUT (10 * HZ) /* 10s */ ··· 990 1163 991 1164 #define I915_ENGINE_DEAD_TIMEOUT (4 * HZ) /* Seqno, head and subunits dead */ 992 1165 #define I915_SEQNO_DEAD_TIMEOUT (12 * HZ) /* Seqno dead with active head */ 993 - 994 - struct i915_gpu_error { 995 - /* For hangcheck timer */ 996 - #define DRM_I915_HANGCHECK_PERIOD 1500 /* in ms */ 997 - #define DRM_I915_HANGCHECK_JIFFIES msecs_to_jiffies(DRM_I915_HANGCHECK_PERIOD) 998 - 999 - struct delayed_work hangcheck_work; 1000 - 1001 - /* For reset and error_state handling. */ 1002 - spinlock_t lock; 1003 - /* Protected by the above dev->gpu_error.lock. */ 1004 - struct i915_gpu_state *first_error; 1005 - 1006 - atomic_t pending_fb_pin; 1007 - 1008 - unsigned long missed_irq_rings; 1009 - 1010 - /** 1011 - * State variable controlling the reset flow and count 1012 - * 1013 - * This is a counter which gets incremented when reset is triggered, 1014 - * 1015 - * Before the reset commences, the I915_RESET_BACKOFF bit is set 1016 - * meaning that any waiters holding onto the struct_mutex should 1017 - * relinquish the lock immediately in order for the reset to start. 1018 - * 1019 - * If reset is not completed succesfully, the I915_WEDGE bit is 1020 - * set meaning that hardware is terminally sour and there is no 1021 - * recovery. All waiters on the reset_queue will be woken when 1022 - * that happens. 1023 - * 1024 - * This counter is used by the wait_seqno code to notice that reset 1025 - * event happened and it needs to restart the entire ioctl (since most 1026 - * likely the seqno it waited for won't ever signal anytime soon). 1027 - * 1028 - * This is important for lock-free wait paths, where no contended lock 1029 - * naturally enforces the correct ordering between the bail-out of the 1030 - * waiter and the gpu reset work code. 1031 - */ 1032 - unsigned long reset_count; 1033 - 1034 - /** 1035 - * flags: Control various stages of the GPU reset 1036 - * 1037 - * #I915_RESET_BACKOFF - When we start a reset, we want to stop any 1038 - * other users acquiring the struct_mutex. To do this we set the 1039 - * #I915_RESET_BACKOFF bit in the error flags when we detect a reset 1040 - * and then check for that bit before acquiring the struct_mutex (in 1041 - * i915_mutex_lock_interruptible()?). I915_RESET_BACKOFF serves a 1042 - * secondary role in preventing two concurrent global reset attempts. 1043 - * 1044 - * #I915_RESET_HANDOFF - To perform the actual GPU reset, we need the 1045 - * struct_mutex. We try to acquire the struct_mutex in the reset worker, 1046 - * but it may be held by some long running waiter (that we cannot 1047 - * interrupt without causing trouble). Once we are ready to do the GPU 1048 - * reset, we set the I915_RESET_HANDOFF bit and wakeup any waiters. If 1049 - * they already hold the struct_mutex and want to participate they can 1050 - * inspect the bit and do the reset directly, otherwise the worker 1051 - * waits for the struct_mutex. 1052 - * 1053 - * #I915_RESET_ENGINE[num_engines] - Since the driver doesn't need to 1054 - * acquire the struct_mutex to reset an engine, we need an explicit 1055 - * flag to prevent two concurrent reset attempts in the same engine. 1056 - * As the number of engines continues to grow, allocate the flags from 1057 - * the most significant bits. 1058 - * 1059 - * #I915_WEDGED - If reset fails and we can no longer use the GPU, 1060 - * we set the #I915_WEDGED bit. Prior to command submission, e.g. 1061 - * i915_request_alloc(), this bit is checked and the sequence 1062 - * aborted (with -EIO reported to userspace) if set. 1063 - */ 1064 - unsigned long flags; 1065 - #define I915_RESET_BACKOFF 0 1066 - #define I915_RESET_HANDOFF 1 1067 - #define I915_RESET_MODESET 2 1068 - #define I915_WEDGED (BITS_PER_LONG - 1) 1069 - #define I915_RESET_ENGINE (I915_WEDGED - I915_NUM_ENGINES) 1070 - 1071 - /** Number of times an engine has been reset */ 1072 - u32 reset_engine_count[I915_NUM_ENGINES]; 1073 - 1074 - /** 1075 - * Waitqueue to signal when a hang is detected. Used to for waiters 1076 - * to release the struct_mutex for the reset to procede. 1077 - */ 1078 - wait_queue_head_t wait_queue; 1079 - 1080 - /** 1081 - * Waitqueue to signal when the reset has completed. Used by clients 1082 - * that wait for dev_priv->mm.wedged to settle. 1083 - */ 1084 - wait_queue_head_t reset_queue; 1085 - 1086 - /* For missed irq/seqno simulation. */ 1087 - unsigned long test_irq_rings; 1088 - }; 1089 1166 1090 1167 enum modeset_restore { 1091 1168 MODESET_ON_LID_OPEN, ··· 1182 1451 } 1183 1452 1184 1453 struct skl_ddb_allocation { 1185 - struct skl_ddb_entry plane[I915_MAX_PIPES][I915_MAX_PLANES]; /* packed/uv */ 1186 - struct skl_ddb_entry y_plane[I915_MAX_PIPES][I915_MAX_PLANES]; 1454 + /* packed/y */ 1455 + struct skl_ddb_entry plane[I915_MAX_PIPES][I915_MAX_PLANES]; 1456 + struct skl_ddb_entry uv_plane[I915_MAX_PIPES][I915_MAX_PLANES]; 1187 1457 }; 1188 1458 1189 - struct skl_wm_values { 1459 + struct skl_ddb_values { 1190 1460 unsigned dirty_pipes; 1191 1461 struct skl_ddb_allocation ddb; 1192 1462 }; ··· 1202 1470 struct skl_wm_params { 1203 1471 bool x_tiled, y_tiled; 1204 1472 bool rc_surface; 1473 + bool is_planar; 1205 1474 uint32_t width; 1206 1475 uint8_t cpp; 1207 1476 uint32_t plane_pixel_rate; ··· 1593 1860 1594 1861 struct intel_gvt *gvt; 1595 1862 1863 + struct intel_wopcm wopcm; 1864 + 1596 1865 struct intel_huc huc; 1597 1866 struct intel_guc guc; 1598 1867 ··· 1887 2152 /* current hardware state */ 1888 2153 union { 1889 2154 struct ilk_wm_values hw; 1890 - struct skl_wm_values skl_hw; 2155 + struct skl_ddb_values skl_hw; 1891 2156 struct vlv_wm_values vlv; 1892 2157 struct g4x_wm_values g4x; 1893 2158 }; ··· 2127 2392 return to_i915(dev_get_drvdata(kdev)); 2128 2393 } 2129 2394 2395 + static inline struct drm_i915_private *wopcm_to_i915(struct intel_wopcm *wopcm) 2396 + { 2397 + return container_of(wopcm, struct drm_i915_private, wopcm); 2398 + } 2399 + 2130 2400 static inline struct drm_i915_private *guc_to_i915(struct intel_guc *guc) 2131 2401 { 2132 2402 return container_of(guc, struct drm_i915_private, guc); ··· 2151 2411 2152 2412 /* Iterator over subset of engines selected by mask */ 2153 2413 #define for_each_engine_masked(engine__, dev_priv__, mask__, tmp__) \ 2154 - for (tmp__ = mask__ & INTEL_INFO(dev_priv__)->ring_mask; \ 2155 - tmp__ ? (engine__ = (dev_priv__)->engine[__mask_next_bit(tmp__)]), 1 : 0; ) 2414 + for ((tmp__) = (mask__) & INTEL_INFO(dev_priv__)->ring_mask; \ 2415 + (tmp__) ? \ 2416 + ((engine__) = (dev_priv__)->engine[__mask_next_bit(tmp__)]), 1 : \ 2417 + 0;) 2156 2418 2157 2419 enum hdmi_force_audio { 2158 2420 HDMI_AUDIO_OFF_DVI = -2, /* no aux data for HDMI-DVI converter */ ··· 2705 2963 extern int intel_gpu_reset(struct drm_i915_private *dev_priv, u32 engine_mask); 2706 2964 extern bool intel_has_gpu_reset(struct drm_i915_private *dev_priv); 2707 2965 2708 - #define I915_RESET_QUIET BIT(0) 2709 - extern void i915_reset(struct drm_i915_private *i915, unsigned int flags); 2966 + extern void i915_reset(struct drm_i915_private *i915, 2967 + unsigned int stalled_mask, 2968 + const char *reason); 2710 2969 extern int i915_reset_engine(struct intel_engine_cs *engine, 2711 - unsigned int flags); 2970 + const char *reason); 2712 2971 2713 2972 extern bool intel_has_reset_engine(struct drm_i915_private *dev_priv); 2714 2973 extern int intel_reset_guc(struct drm_i915_private *dev_priv); ··· 2757 3014 &dev_priv->gpu_error.hangcheck_work, delay); 2758 3015 } 2759 3016 2760 - __printf(3, 4) 3017 + __printf(4, 5) 2761 3018 void i915_handle_error(struct drm_i915_private *dev_priv, 2762 3019 u32 engine_mask, 3020 + unsigned long flags, 2763 3021 const char *fmt, ...); 3022 + #define I915_ERROR_CAPTURE BIT(0) 2764 3023 2765 3024 extern void intel_irq_init(struct drm_i915_private *dev_priv); 2766 3025 extern void intel_irq_fini(struct drm_i915_private *dev_priv); ··· 2877 3132 int i915_gem_wait_ioctl(struct drm_device *dev, void *data, 2878 3133 struct drm_file *file_priv); 2879 3134 void i915_gem_sanitize(struct drm_i915_private *i915); 2880 - int i915_gem_load_init(struct drm_i915_private *dev_priv); 2881 - void i915_gem_load_cleanup(struct drm_i915_private *dev_priv); 3135 + int i915_gem_init_early(struct drm_i915_private *dev_priv); 3136 + void i915_gem_cleanup_early(struct drm_i915_private *dev_priv); 2882 3137 void i915_gem_load_init_fences(struct drm_i915_private *dev_priv); 2883 3138 int i915_gem_freeze(struct drm_i915_private *dev_priv); 2884 3139 int i915_gem_freeze_late(struct drm_i915_private *dev_priv); ··· 3133 3388 struct i915_request * 3134 3389 i915_gem_reset_prepare_engine(struct intel_engine_cs *engine); 3135 3390 int i915_gem_reset_prepare(struct drm_i915_private *dev_priv); 3136 - void i915_gem_reset(struct drm_i915_private *dev_priv); 3391 + void i915_gem_reset(struct drm_i915_private *dev_priv, 3392 + unsigned int stalled_mask); 3137 3393 void i915_gem_reset_finish_engine(struct intel_engine_cs *engine); 3138 3394 void i915_gem_reset_finish(struct drm_i915_private *dev_priv); 3139 3395 void i915_gem_set_wedged(struct drm_i915_private *dev_priv); 3140 3396 bool i915_gem_unset_wedged(struct drm_i915_private *dev_priv); 3141 3397 void i915_gem_reset_engine(struct intel_engine_cs *engine, 3142 - struct i915_request *request); 3398 + struct i915_request *request, 3399 + bool stalled); 3143 3400 3144 3401 void i915_gem_init_mmio(struct drm_i915_private *i915); 3145 3402 int __must_check i915_gem_init(struct drm_i915_private *dev_priv); ··· 3334 3587 static inline int i915_debugfs_connector_add(struct drm_connector *connector) 3335 3588 { return 0; } 3336 3589 static inline void intel_display_crc_init(struct drm_i915_private *dev_priv) {} 3337 - #endif 3338 - 3339 - /* i915_gpu_error.c */ 3340 - #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) 3341 - 3342 - __printf(2, 3) 3343 - void i915_error_printf(struct drm_i915_error_state_buf *e, const char *f, ...); 3344 - int i915_error_state_to_str(struct drm_i915_error_state_buf *estr, 3345 - const struct i915_gpu_state *gpu); 3346 - int i915_error_state_buf_init(struct drm_i915_error_state_buf *eb, 3347 - struct drm_i915_private *i915, 3348 - size_t count, loff_t pos); 3349 - static inline void i915_error_state_buf_release( 3350 - struct drm_i915_error_state_buf *eb) 3351 - { 3352 - kfree(eb->buf); 3353 - } 3354 - 3355 - struct i915_gpu_state *i915_capture_gpu_state(struct drm_i915_private *i915); 3356 - void i915_capture_error_state(struct drm_i915_private *dev_priv, 3357 - u32 engine_mask, 3358 - const char *error_msg); 3359 - 3360 - static inline struct i915_gpu_state * 3361 - i915_gpu_state_get(struct i915_gpu_state *gpu) 3362 - { 3363 - kref_get(&gpu->ref); 3364 - return gpu; 3365 - } 3366 - 3367 - void __i915_gpu_state_free(struct kref *kref); 3368 - static inline void i915_gpu_state_put(struct i915_gpu_state *gpu) 3369 - { 3370 - if (gpu) 3371 - kref_put(&gpu->ref, __i915_gpu_state_free); 3372 - } 3373 - 3374 - struct i915_gpu_state *i915_first_error_state(struct drm_i915_private *i915); 3375 - void i915_reset_error_state(struct drm_i915_private *i915); 3376 - 3377 - #else 3378 - 3379 - static inline void i915_capture_error_state(struct drm_i915_private *dev_priv, 3380 - u32 engine_mask, 3381 - const char *error_msg) 3382 - { 3383 - } 3384 - 3385 - static inline struct i915_gpu_state * 3386 - i915_first_error_state(struct drm_i915_private *i915) 3387 - { 3388 - return NULL; 3389 - } 3390 - 3391 - static inline void i915_reset_error_state(struct drm_i915_private *i915) 3392 - { 3393 - } 3394 - 3395 3590 #endif 3396 3591 3397 3592 const char *i915_cache_level_str(struct drm_i915_private *i915, int type);
+161 -76
drivers/gpu/drm/i915/i915_gem.c
··· 35 35 #include "intel_drv.h" 36 36 #include "intel_frontbuffer.h" 37 37 #include "intel_mocs.h" 38 + #include "intel_workarounds.h" 38 39 #include "i915_gemfs.h" 39 40 #include <linux/dma-fence-array.h> 40 41 #include <linux/kthread.h> ··· 135 134 return ret; 136 135 137 136 return 0; 137 + } 138 + 139 + static u32 __i915_gem_park(struct drm_i915_private *i915) 140 + { 141 + lockdep_assert_held(&i915->drm.struct_mutex); 142 + GEM_BUG_ON(i915->gt.active_requests); 143 + 144 + if (!i915->gt.awake) 145 + return I915_EPOCH_INVALID; 146 + 147 + GEM_BUG_ON(i915->gt.epoch == I915_EPOCH_INVALID); 148 + 149 + /* 150 + * Be paranoid and flush a concurrent interrupt to make sure 151 + * we don't reactivate any irq tasklets after parking. 152 + * 153 + * FIXME: Note that even though we have waited for execlists to be idle, 154 + * there may still be an in-flight interrupt even though the CSB 155 + * is now empty. synchronize_irq() makes sure that a residual interrupt 156 + * is completed before we continue, but it doesn't prevent the HW from 157 + * raising a spurious interrupt later. To complete the shield we should 158 + * coordinate disabling the CS irq with flushing the interrupts. 159 + */ 160 + synchronize_irq(i915->drm.irq); 161 + 162 + intel_engines_park(i915); 163 + i915_gem_timelines_park(i915); 164 + 165 + i915_pmu_gt_parked(i915); 166 + 167 + i915->gt.awake = false; 168 + 169 + if (INTEL_GEN(i915) >= 6) 170 + gen6_rps_idle(i915); 171 + 172 + intel_display_power_put(i915, POWER_DOMAIN_GT_IRQ); 173 + 174 + intel_runtime_pm_put(i915); 175 + 176 + return i915->gt.epoch; 177 + } 178 + 179 + void i915_gem_park(struct drm_i915_private *i915) 180 + { 181 + lockdep_assert_held(&i915->drm.struct_mutex); 182 + GEM_BUG_ON(i915->gt.active_requests); 183 + 184 + if (!i915->gt.awake) 185 + return; 186 + 187 + /* Defer the actual call to __i915_gem_park() to prevent ping-pongs */ 188 + mod_delayed_work(i915->wq, &i915->gt.idle_work, msecs_to_jiffies(100)); 189 + } 190 + 191 + void i915_gem_unpark(struct drm_i915_private *i915) 192 + { 193 + lockdep_assert_held(&i915->drm.struct_mutex); 194 + GEM_BUG_ON(!i915->gt.active_requests); 195 + 196 + if (i915->gt.awake) 197 + return; 198 + 199 + intel_runtime_pm_get_noresume(i915); 200 + 201 + /* 202 + * It seems that the DMC likes to transition between the DC states a lot 203 + * when there are no connected displays (no active power domains) during 204 + * command submission. 205 + * 206 + * This activity has negative impact on the performance of the chip with 207 + * huge latencies observed in the interrupt handler and elsewhere. 208 + * 209 + * Work around it by grabbing a GT IRQ power domain whilst there is any 210 + * GT activity, preventing any DC state transitions. 211 + */ 212 + intel_display_power_get(i915, POWER_DOMAIN_GT_IRQ); 213 + 214 + i915->gt.awake = true; 215 + if (unlikely(++i915->gt.epoch == 0)) /* keep 0 as invalid */ 216 + i915->gt.epoch = 1; 217 + 218 + intel_enable_gt_powersave(i915); 219 + i915_update_gfx_val(i915); 220 + if (INTEL_GEN(i915) >= 6) 221 + gen6_rps_busy(i915); 222 + i915_pmu_gt_unparked(i915); 223 + 224 + intel_engines_unpark(i915); 225 + 226 + i915_queue_hangcheck(i915); 227 + 228 + queue_delayed_work(i915->wq, 229 + &i915->gt.retire_work, 230 + round_jiffies_up_relative(HZ)); 138 231 } 139 232 140 233 int ··· 2991 2896 return active; 2992 2897 } 2993 2898 2994 - static bool engine_stalled(struct intel_engine_cs *engine) 2995 - { 2996 - if (!engine->hangcheck.stalled) 2997 - return false; 2998 - 2999 - /* Check for possible seqno movement after hang declaration */ 3000 - if (engine->hangcheck.seqno != intel_engine_get_seqno(engine)) { 3001 - DRM_DEBUG_DRIVER("%s pardoned\n", engine->name); 3002 - return false; 3003 - } 3004 - 3005 - return true; 3006 - } 3007 - 3008 2899 /* 3009 2900 * Ensure irq handler finishes, and not run again. 3010 2901 * Also return the active request so that we only search for it once. ··· 3079 2998 } 3080 2999 3081 3000 i915_gem_revoke_fences(dev_priv); 3001 + intel_uc_sanitize(dev_priv); 3082 3002 3083 3003 return err; 3084 3004 } ··· 3129 3047 /* Returns the request if it was guilty of the hang */ 3130 3048 static struct i915_request * 3131 3049 i915_gem_reset_request(struct intel_engine_cs *engine, 3132 - struct i915_request *request) 3050 + struct i915_request *request, 3051 + bool stalled) 3133 3052 { 3134 3053 /* The guilty request will get skipped on a hung engine. 3135 3054 * ··· 3153 3070 * subsequent hangs. 3154 3071 */ 3155 3072 3156 - if (engine_stalled(engine)) { 3073 + if (i915_request_completed(request)) { 3074 + GEM_TRACE("%s pardoned global=%d (fence %llx:%d), current %d\n", 3075 + engine->name, request->global_seqno, 3076 + request->fence.context, request->fence.seqno, 3077 + intel_engine_get_seqno(engine)); 3078 + stalled = false; 3079 + } 3080 + 3081 + if (stalled) { 3157 3082 i915_gem_context_mark_guilty(request->ctx); 3158 3083 skip_request(request); 3159 3084 ··· 3192 3101 } 3193 3102 3194 3103 void i915_gem_reset_engine(struct intel_engine_cs *engine, 3195 - struct i915_request *request) 3104 + struct i915_request *request, 3105 + bool stalled) 3196 3106 { 3197 3107 /* 3198 3108 * Make sure this write is visible before we re-enable the interrupt ··· 3203 3111 smp_store_mb(engine->irq_posted, 0); 3204 3112 3205 3113 if (request) 3206 - request = i915_gem_reset_request(engine, request); 3114 + request = i915_gem_reset_request(engine, request, stalled); 3207 3115 3208 3116 if (request) { 3209 3117 DRM_DEBUG_DRIVER("resetting %s to restart from tail of request 0x%x\n", ··· 3214 3122 engine->reset_hw(engine, request); 3215 3123 } 3216 3124 3217 - void i915_gem_reset(struct drm_i915_private *dev_priv) 3125 + void i915_gem_reset(struct drm_i915_private *dev_priv, 3126 + unsigned int stalled_mask) 3218 3127 { 3219 3128 struct intel_engine_cs *engine; 3220 3129 enum intel_engine_id id; ··· 3227 3134 for_each_engine(engine, dev_priv, id) { 3228 3135 struct i915_gem_context *ctx; 3229 3136 3230 - i915_gem_reset_engine(engine, engine->hangcheck.active_request); 3137 + i915_gem_reset_engine(engine, 3138 + engine->hangcheck.active_request, 3139 + stalled_mask & ENGINE_MASK(id)); 3231 3140 ctx = fetch_and_zero(&engine->last_retired_context); 3232 3141 if (ctx) 3233 3142 engine->context_unpin(engine, ctx); ··· 3255 3160 } 3256 3161 3257 3162 i915_gem_restore_fences(dev_priv); 3258 - 3259 - if (dev_priv->gt.awake) { 3260 - intel_sanitize_gt_powersave(dev_priv); 3261 - intel_enable_gt_powersave(dev_priv); 3262 - if (INTEL_GEN(dev_priv) >= 6) 3263 - gen6_rps_busy(dev_priv); 3264 - } 3265 3163 } 3266 3164 3267 3165 void i915_gem_reset_finish_engine(struct intel_engine_cs *engine) ··· 3280 3192 3281 3193 static void nop_submit_request(struct i915_request *request) 3282 3194 { 3195 + GEM_TRACE("%s fence %llx:%d -> -EIO\n", 3196 + request->engine->name, 3197 + request->fence.context, request->fence.seqno); 3283 3198 dma_fence_set_error(&request->fence, -EIO); 3284 3199 3285 3200 i915_request_submit(request); ··· 3292 3201 { 3293 3202 unsigned long flags; 3294 3203 3204 + GEM_TRACE("%s fence %llx:%d -> -EIO\n", 3205 + request->engine->name, 3206 + request->fence.context, request->fence.seqno); 3295 3207 dma_fence_set_error(&request->fence, -EIO); 3296 3208 3297 3209 spin_lock_irqsave(&request->engine->timeline->lock, flags); ··· 3307 3213 { 3308 3214 struct intel_engine_cs *engine; 3309 3215 enum intel_engine_id id; 3216 + 3217 + GEM_TRACE("start\n"); 3310 3218 3311 3219 if (drm_debug & DRM_UT_DRIVER) { 3312 3220 struct drm_printer p = drm_debug_printer(__func__); ··· 3332 3236 engine->schedule = NULL; 3333 3237 } 3334 3238 i915->caps.scheduler = 0; 3239 + 3240 + /* Even if the GPU reset fails, it should still stop the engines */ 3241 + intel_gpu_reset(i915, ALL_ENGINES); 3335 3242 3336 3243 /* 3337 3244 * Make sure no one is running the old callback before we proceed with ··· 3377 3278 i915_gem_reset_finish_engine(engine); 3378 3279 } 3379 3280 3281 + GEM_TRACE("end\n"); 3282 + 3380 3283 wake_up_all(&i915->gpu_error.reset_queue); 3381 3284 } 3382 3285 ··· 3391 3290 if (!test_bit(I915_WEDGED, &i915->gpu_error.flags)) 3392 3291 return true; 3393 3292 3394 - /* Before unwedging, make sure that all pending operations 3293 + GEM_TRACE("start\n"); 3294 + 3295 + /* 3296 + * Before unwedging, make sure that all pending operations 3395 3297 * are flushed and errored out - we may have requests waiting upon 3396 3298 * third party fences. We marked all inflight requests as EIO, and 3397 3299 * every execbuf since returned EIO, for consistency we want all ··· 3412 3308 if (!rq) 3413 3309 continue; 3414 3310 3415 - /* We can't use our normal waiter as we want to 3311 + /* 3312 + * We can't use our normal waiter as we want to 3416 3313 * avoid recursively trying to handle the current 3417 3314 * reset. The basic dma_fence_default_wait() installs 3418 3315 * a callback for dma_fence_signal(), which is ··· 3428 3323 return false; 3429 3324 } 3430 3325 } 3326 + i915_retire_requests(i915); 3327 + GEM_BUG_ON(i915->gt.active_requests); 3431 3328 3432 - /* Undo nop_submit_request. We prevent all new i915 requests from 3329 + /* 3330 + * Undo nop_submit_request. We prevent all new i915 requests from 3433 3331 * being queued (by disallowing execbuf whilst wedged) so having 3434 3332 * waited for all active requests above, we know the system is idle 3435 3333 * and do not have to worry about a thread being inside ··· 3442 3334 */ 3443 3335 intel_engines_reset_default_submission(i915); 3444 3336 i915_gem_contexts_lost(i915); 3337 + 3338 + GEM_TRACE("end\n"); 3445 3339 3446 3340 smp_mb__before_atomic(); /* complete takeover before enabling execbuf */ 3447 3341 clear_bit(I915_WEDGED, &i915->gpu_error.flags); ··· 3583 3473 if (new_requests_since_last_retire(dev_priv)) 3584 3474 goto out_unlock; 3585 3475 3586 - /* 3587 - * Be paranoid and flush a concurrent interrupt to make sure 3588 - * we don't reactivate any irq tasklets after parking. 3589 - * 3590 - * FIXME: Note that even though we have waited for execlists to be idle, 3591 - * there may still be an in-flight interrupt even though the CSB 3592 - * is now empty. synchronize_irq() makes sure that a residual interrupt 3593 - * is completed before we continue, but it doesn't prevent the HW from 3594 - * raising a spurious interrupt later. To complete the shield we should 3595 - * coordinate disabling the CS irq with flushing the interrupts. 3596 - */ 3597 - synchronize_irq(dev_priv->drm.irq); 3476 + epoch = __i915_gem_park(dev_priv); 3598 3477 3599 - intel_engines_park(dev_priv); 3600 - i915_gem_timelines_park(dev_priv); 3601 - 3602 - i915_pmu_gt_parked(dev_priv); 3603 - 3604 - GEM_BUG_ON(!dev_priv->gt.awake); 3605 - dev_priv->gt.awake = false; 3606 - epoch = dev_priv->gt.epoch; 3607 - GEM_BUG_ON(epoch == I915_EPOCH_INVALID); 3608 3478 rearm_hangcheck = false; 3609 - 3610 - if (INTEL_GEN(dev_priv) >= 6) 3611 - gen6_rps_idle(dev_priv); 3612 - 3613 - intel_display_power_put(dev_priv, POWER_DOMAIN_GT_IRQ); 3614 - 3615 - intel_runtime_pm_put(dev_priv); 3616 3479 out_unlock: 3617 3480 mutex_unlock(&dev_priv->drm.struct_mutex); 3618 3481 ··· 3749 3666 if (wait_for(intel_engines_are_idle(i915), I915_IDLE_ENGINES_TIMEOUT)) { 3750 3667 dev_err(i915->drm.dev, 3751 3668 "Failed to idle engines, declaring wedged!\n"); 3752 - if (drm_debug & DRM_UT_DRIVER) { 3753 - struct drm_printer p = drm_debug_printer(__func__); 3754 - struct intel_engine_cs *engine; 3755 - enum intel_engine_id id; 3756 - 3757 - for_each_engine(engine, i915, id) 3758 - intel_engine_dump(engine, &p, 3759 - "%s\n", engine->name); 3760 - } 3761 - 3669 + GEM_TRACE_DUMP(); 3762 3670 i915_gem_set_wedged(i915); 3763 3671 return -EIO; 3764 3672 } ··· 4162 4088 } 4163 4089 4164 4090 /* 4165 - * Prepare buffer for display plane (scanout, cursors, etc). 4166 - * Can be called from an uninterruptible phase (modesetting) and allows 4167 - * any flushes to be pipelined (for pageflips). 4091 + * Prepare buffer for display plane (scanout, cursors, etc). Can be called from 4092 + * an uninterruptible phase (modesetting) and allows any flushes to be pipelined 4093 + * (for pageflips). We only flush the caches while preparing the buffer for 4094 + * display, the callers are responsible for frontbuffer flush. 4168 4095 */ 4169 4096 struct i915_vma * 4170 4097 i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj, ··· 4221 4146 4222 4147 vma->display_alignment = max_t(u64, vma->display_alignment, alignment); 4223 4148 4224 - /* Treat this as an end-of-frame, like intel_user_framebuffer_dirty() */ 4225 4149 __i915_gem_object_flush_for_display(obj); 4226 - intel_fb_obj_flush(obj, ORIGIN_DIRTYFB); 4227 4150 4228 4151 /* It should now be out of any other write domains, and we can update 4229 4152 * the domain values for our changes. ··· 5046 4973 * machines is a good idea, we don't - just in case it leaves the 5047 4974 * machine in an unusable condition. 5048 4975 */ 4976 + intel_uc_sanitize(dev_priv); 5049 4977 i915_gem_sanitize(dev_priv); 5050 4978 5051 4979 intel_runtime_pm_put(dev_priv); ··· 5192 5118 } 5193 5119 } 5194 5120 5121 + intel_gt_workarounds_apply(dev_priv); 5122 + 5195 5123 i915_gem_init_swizzling(dev_priv); 5196 5124 5197 5125 /* ··· 5213 5137 ret = i915_ppgtt_init_hw(dev_priv); 5214 5138 if (ret) { 5215 5139 DRM_ERROR("Enabling PPGTT failed (%d)\n", ret); 5140 + goto out; 5141 + } 5142 + 5143 + ret = intel_wopcm_init_hw(&dev_priv->wopcm); 5144 + if (ret) { 5145 + DRM_ERROR("Enabling WOPCM failed (%d)\n", ret); 5216 5146 goto out; 5217 5147 } 5218 5148 ··· 5376 5294 } 5377 5295 5378 5296 ret = i915_gem_init_userptr(dev_priv); 5297 + if (ret) 5298 + return ret; 5299 + 5300 + ret = intel_wopcm_init(&dev_priv->wopcm); 5379 5301 if (ret) 5380 5302 return ret; 5381 5303 ··· 5564 5478 INIT_WORK(&i915->mm.free_work, __i915_gem_free_work); 5565 5479 } 5566 5480 5567 - int 5568 - i915_gem_load_init(struct drm_i915_private *dev_priv) 5481 + int i915_gem_init_early(struct drm_i915_private *dev_priv) 5569 5482 { 5570 5483 int err = -ENOMEM; 5571 5484 ··· 5639 5554 return err; 5640 5555 } 5641 5556 5642 - void i915_gem_load_cleanup(struct drm_i915_private *dev_priv) 5557 + void i915_gem_cleanup_early(struct drm_i915_private *dev_priv) 5643 5558 { 5644 5559 i915_gem_drain_freed_objects(dev_priv); 5645 5560 GEM_BUG_ON(!llist_empty(&dev_priv->mm.free_list));
+7
drivers/gpu/drm/i915/i915_gem.h
··· 27 27 28 28 #include <linux/bug.h> 29 29 30 + struct drm_i915_private; 31 + 30 32 #ifdef CONFIG_DRM_I915_DEBUG_GEM 31 33 #define GEM_BUG_ON(condition) do { if (unlikely((condition))) { \ 32 34 pr_err("%s:%d GEM_BUG_ON(%s)\n", \ ··· 55 53 56 54 #if IS_ENABLED(CONFIG_DRM_I915_TRACE_GEM) 57 55 #define GEM_TRACE(...) trace_printk(__VA_ARGS__) 56 + #define GEM_TRACE_DUMP() ftrace_dump(DUMP_ALL) 58 57 #else 59 58 #define GEM_TRACE(...) do { } while (0) 59 + #define GEM_TRACE_DUMP() do { } while (0) 60 60 #endif 61 61 62 62 #define I915_NUM_ENGINES 8 63 + 64 + void i915_gem_park(struct drm_i915_private *i915); 65 + void i915_gem_unpark(struct drm_i915_private *i915); 63 66 64 67 #endif /* __I915_GEM_H__ */
+6 -24
drivers/gpu/drm/i915/i915_gem_batch_pool.c
··· 1 1 /* 2 - * Copyright © 2014 Intel Corporation 2 + * SPDX-License-Identifier: MIT 3 3 * 4 - * Permission is hereby granted, free of charge, to any person obtaining a 5 - * copy of this software and associated documentation files (the "Software"), 6 - * to deal in the Software without restriction, including without limitation 7 - * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 - * and/or sell copies of the Software, and to permit persons to whom the 9 - * Software is furnished to do so, subject to the following conditions: 10 - * 11 - * The above copyright notice and this permission notice (including the next 12 - * paragraph) shall be included in all copies or substantial portions of the 13 - * Software. 14 - * 15 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 - * IN THE SOFTWARE. 22 - * 4 + * Copyright © 2014-2018 Intel Corporation 23 5 */ 24 6 25 - #include "i915_drv.h" 26 7 #include "i915_gem_batch_pool.h" 8 + #include "i915_drv.h" 27 9 28 10 /** 29 11 * DOC: batch pool ··· 23 41 24 42 /** 25 43 * i915_gem_batch_pool_init() - initialize a batch buffer pool 26 - * @engine: the associated request submission engine 27 44 * @pool: the batch buffer pool 45 + * @engine: the associated request submission engine 28 46 */ 29 - void i915_gem_batch_pool_init(struct intel_engine_cs *engine, 30 - struct i915_gem_batch_pool *pool) 47 + void i915_gem_batch_pool_init(struct i915_gem_batch_pool *pool, 48 + struct intel_engine_cs *engine) 31 49 { 32 50 int n; 33 51
+5 -24
drivers/gpu/drm/i915/i915_gem_batch_pool.h
··· 1 1 /* 2 - * Copyright © 2014 Intel Corporation 2 + * SPDX-License-Identifier: MIT 3 3 * 4 - * Permission is hereby granted, free of charge, to any person obtaining a 5 - * copy of this software and associated documentation files (the "Software"), 6 - * to deal in the Software without restriction, including without limitation 7 - * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 - * and/or sell copies of the Software, and to permit persons to whom the 9 - * Software is furnished to do so, subject to the following conditions: 10 - * 11 - * The above copyright notice and this permission notice (including the next 12 - * paragraph) shall be included in all copies or substantial portions of the 13 - * Software. 14 - * 15 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 - * IN THE SOFTWARE. 22 - * 4 + * Copyright © 2014-2018 Intel Corporation 23 5 */ 24 6 25 7 #ifndef I915_GEM_BATCH_POOL_H 26 8 #define I915_GEM_BATCH_POOL_H 27 9 28 - #include "i915_drv.h" 10 + #include <linux/types.h> 29 11 30 12 struct intel_engine_cs; 31 13 ··· 16 34 struct list_head cache_list[4]; 17 35 }; 18 36 19 - /* i915_gem_batch_pool.c */ 20 - void i915_gem_batch_pool_init(struct intel_engine_cs *engine, 21 - struct i915_gem_batch_pool *pool); 37 + void i915_gem_batch_pool_init(struct i915_gem_batch_pool *pool, 38 + struct intel_engine_cs *engine); 22 39 void i915_gem_batch_pool_fini(struct i915_gem_batch_pool *pool); 23 40 struct drm_i915_gem_object* 24 41 i915_gem_batch_pool_get(struct i915_gem_batch_pool *pool, size_t size);
+9 -2
drivers/gpu/drm/i915/i915_gem_context.c
··· 90 90 #include <drm/i915_drm.h> 91 91 #include "i915_drv.h" 92 92 #include "i915_trace.h" 93 + #include "intel_workarounds.h" 93 94 94 95 #define ALL_L3_SLICES(dev) (1 << NUM_L3_SLICES(dev)) - 1 95 96 ··· 319 318 ctx->desc_template = 320 319 default_desc_template(dev_priv, dev_priv->mm.aliasing_ppgtt); 321 320 322 - /* GuC requires the ring to be placed above GUC_WOPCM_TOP. If GuC is not 321 + /* 322 + * GuC requires the ring to be placed in Non-WOPCM memory. If GuC is not 323 323 * present or not in use we still need a small bias as ring wraparound 324 324 * at offset 0 sometimes hangs. No idea why. 325 325 */ 326 326 if (USES_GUC(dev_priv)) 327 - ctx->ggtt_offset_bias = GUC_WOPCM_TOP; 327 + ctx->ggtt_offset_bias = dev_priv->guc.ggtt_pin_bias; 328 328 else 329 329 ctx->ggtt_offset_bias = I915_GTT_PAGE_SIZE; 330 330 ··· 460 458 int i915_gem_contexts_init(struct drm_i915_private *dev_priv) 461 459 { 462 460 struct i915_gem_context *ctx; 461 + int ret; 463 462 464 463 /* Reassure ourselves we are only called once */ 465 464 GEM_BUG_ON(dev_priv->kernel_context); 466 465 GEM_BUG_ON(dev_priv->preempt_context); 466 + 467 + ret = intel_ctx_workarounds_init(dev_priv); 468 + if (ret) 469 + return ret; 467 470 468 471 INIT_LIST_HEAD(&dev_priv->contexts.list); 469 472 INIT_WORK(&dev_priv->contexts.free_work, contexts_free_worker);
+29
drivers/gpu/drm/i915/i915_gem_execbuffer.c
··· 81 81 * but this remains just a hint as the kernel may choose a new location for 82 82 * any object in the future. 83 83 * 84 + * At the level of talking to the hardware, submitting a batchbuffer for the 85 + * GPU to execute is to add content to a buffer from which the HW 86 + * command streamer is reading. 87 + * 88 + * 1. Add a command to load the HW context. For Logical Ring Contexts, i.e. 89 + * Execlists, this command is not placed on the same buffer as the 90 + * remaining items. 91 + * 92 + * 2. Add a command to invalidate caches to the buffer. 93 + * 94 + * 3. Add a batchbuffer start command to the buffer; the start command is 95 + * essentially a token together with the GPU address of the batchbuffer 96 + * to be executed. 97 + * 98 + * 4. Add a pipeline flush to the buffer. 99 + * 100 + * 5. Add a memory write command to the buffer to record when the GPU 101 + * is done executing the batchbuffer. The memory write writes the 102 + * global sequence number of the request, ``i915_request::global_seqno``; 103 + * the i915 driver uses the current value in the register to determine 104 + * if the GPU has completed the batchbuffer. 105 + * 106 + * 6. Add a user interrupt command to the buffer. This command instructs 107 + * the GPU to issue an interrupt when the command, pipeline flush and 108 + * memory write are completed. 109 + * 110 + * 7. Inform the hardware of the additional commands added to the buffer 111 + * (by updating the tail pointer). 112 + * 84 113 * Processing an execbuf ioctl is conceptually split up into a few phases. 85 114 * 86 115 * 1. Validation - Ensure all the pointers, handles and flags are valid.
+94 -69
drivers/gpu/drm/i915/i915_gem_stolen.c
··· 121 121 122 122 if (stolen[0].start != stolen[1].start || 123 123 stolen[0].end != stolen[1].end) { 124 - DRM_DEBUG_KMS("GTT within stolen memory at %pR\n", &ggtt_res); 125 - DRM_DEBUG_KMS("Stolen memory adjusted to %pR\n", dsm); 124 + DRM_DEBUG_DRIVER("GTT within stolen memory at %pR\n", &ggtt_res); 125 + DRM_DEBUG_DRIVER("Stolen memory adjusted to %pR\n", dsm); 126 126 } 127 127 } 128 128 ··· 174 174 } 175 175 176 176 static void g4x_get_stolen_reserved(struct drm_i915_private *dev_priv, 177 - resource_size_t *base, resource_size_t *size) 177 + resource_size_t *base, 178 + resource_size_t *size) 178 179 { 179 - uint32_t reg_val = I915_READ(IS_GM45(dev_priv) ? 180 - CTG_STOLEN_RESERVED : 181 - ELK_STOLEN_RESERVED); 180 + u32 reg_val = I915_READ(IS_GM45(dev_priv) ? 181 + CTG_STOLEN_RESERVED : 182 + ELK_STOLEN_RESERVED); 182 183 resource_size_t stolen_top = dev_priv->dsm.end + 1; 183 184 184 - if ((reg_val & G4X_STOLEN_RESERVED_ENABLE) == 0) { 185 - *base = 0; 186 - *size = 0; 185 + DRM_DEBUG_DRIVER("%s_STOLEN_RESERVED = %08x\n", 186 + IS_GM45(dev_priv) ? "CTG" : "ELK", reg_val); 187 + 188 + if ((reg_val & G4X_STOLEN_RESERVED_ENABLE) == 0) 187 189 return; 188 - } 189 190 190 191 /* 191 192 * Whether ILK really reuses the ELK register for this is unclear. ··· 194 193 */ 195 194 WARN(IS_GEN5(dev_priv), "ILK stolen reserved found? 0x%08x\n", reg_val); 196 195 197 - *base = (reg_val & G4X_STOLEN_RESERVED_ADDR2_MASK) << 16; 196 + if (!(reg_val & G4X_STOLEN_RESERVED_ADDR2_MASK)) 197 + return; 198 198 199 + *base = (reg_val & G4X_STOLEN_RESERVED_ADDR2_MASK) << 16; 199 200 WARN_ON((reg_val & G4X_STOLEN_RESERVED_ADDR1_MASK) < *base); 200 201 201 - /* On these platforms, the register doesn't have a size field, so the 202 - * size is the distance between the base and the top of the stolen 203 - * memory. We also have the genuine case where base is zero and there's 204 - * nothing reserved. */ 205 - if (*base == 0) 206 - *size = 0; 207 - else 208 - *size = stolen_top - *base; 202 + *size = stolen_top - *base; 209 203 } 210 204 211 205 static void gen6_get_stolen_reserved(struct drm_i915_private *dev_priv, 212 - resource_size_t *base, resource_size_t *size) 206 + resource_size_t *base, 207 + resource_size_t *size) 213 208 { 214 - uint32_t reg_val = I915_READ(GEN6_STOLEN_RESERVED); 209 + u32 reg_val = I915_READ(GEN6_STOLEN_RESERVED); 215 210 216 - if ((reg_val & GEN6_STOLEN_RESERVED_ENABLE) == 0) { 217 - *base = 0; 218 - *size = 0; 211 + DRM_DEBUG_DRIVER("GEN6_STOLEN_RESERVED = %08x\n", reg_val); 212 + 213 + if (!(reg_val & GEN6_STOLEN_RESERVED_ENABLE)) 219 214 return; 220 - } 221 215 222 216 *base = reg_val & GEN6_STOLEN_RESERVED_ADDR_MASK; 223 217 ··· 235 239 } 236 240 } 237 241 238 - static void gen7_get_stolen_reserved(struct drm_i915_private *dev_priv, 239 - resource_size_t *base, resource_size_t *size) 242 + static void vlv_get_stolen_reserved(struct drm_i915_private *dev_priv, 243 + resource_size_t *base, 244 + resource_size_t *size) 240 245 { 241 - uint32_t reg_val = I915_READ(GEN6_STOLEN_RESERVED); 246 + u32 reg_val = I915_READ(GEN6_STOLEN_RESERVED); 247 + resource_size_t stolen_top = dev_priv->dsm.end + 1; 242 248 243 - if ((reg_val & GEN6_STOLEN_RESERVED_ENABLE) == 0) { 244 - *base = 0; 245 - *size = 0; 249 + DRM_DEBUG_DRIVER("GEN6_STOLEN_RESERVED = %08x\n", reg_val); 250 + 251 + if (!(reg_val & GEN6_STOLEN_RESERVED_ENABLE)) 246 252 return; 253 + 254 + switch (reg_val & GEN7_STOLEN_RESERVED_SIZE_MASK) { 255 + default: 256 + MISSING_CASE(reg_val & GEN7_STOLEN_RESERVED_SIZE_MASK); 257 + case GEN7_STOLEN_RESERVED_1M: 258 + *size = 1024 * 1024; 259 + break; 247 260 } 261 + 262 + /* 263 + * On vlv, the ADDR_MASK portion is left as 0 and HW deduces the 264 + * reserved location as (top - size). 265 + */ 266 + *base = stolen_top - *size; 267 + } 268 + 269 + static void gen7_get_stolen_reserved(struct drm_i915_private *dev_priv, 270 + resource_size_t *base, 271 + resource_size_t *size) 272 + { 273 + u32 reg_val = I915_READ(GEN6_STOLEN_RESERVED); 274 + 275 + DRM_DEBUG_DRIVER("GEN6_STOLEN_RESERVED = %08x\n", reg_val); 276 + 277 + if (!(reg_val & GEN6_STOLEN_RESERVED_ENABLE)) 278 + return; 248 279 249 280 *base = reg_val & GEN7_STOLEN_RESERVED_ADDR_MASK; 250 281 ··· 289 266 } 290 267 291 268 static void chv_get_stolen_reserved(struct drm_i915_private *dev_priv, 292 - resource_size_t *base, resource_size_t *size) 269 + resource_size_t *base, 270 + resource_size_t *size) 293 271 { 294 - uint32_t reg_val = I915_READ(GEN6_STOLEN_RESERVED); 272 + u32 reg_val = I915_READ(GEN6_STOLEN_RESERVED); 295 273 296 - if ((reg_val & GEN6_STOLEN_RESERVED_ENABLE) == 0) { 297 - *base = 0; 298 - *size = 0; 274 + DRM_DEBUG_DRIVER("GEN6_STOLEN_RESERVED = %08x\n", reg_val); 275 + 276 + if (!(reg_val & GEN6_STOLEN_RESERVED_ENABLE)) 299 277 return; 300 - } 301 278 302 279 *base = reg_val & GEN6_STOLEN_RESERVED_ADDR_MASK; 303 280 ··· 321 298 } 322 299 323 300 static void bdw_get_stolen_reserved(struct drm_i915_private *dev_priv, 324 - resource_size_t *base, resource_size_t *size) 301 + resource_size_t *base, 302 + resource_size_t *size) 325 303 { 326 - uint32_t reg_val = I915_READ(GEN6_STOLEN_RESERVED); 327 - resource_size_t stolen_top; 304 + u32 reg_val = I915_READ(GEN6_STOLEN_RESERVED); 305 + resource_size_t stolen_top = dev_priv->dsm.end + 1; 328 306 329 - if ((reg_val & GEN6_STOLEN_RESERVED_ENABLE) == 0) { 330 - *base = 0; 331 - *size = 0; 307 + DRM_DEBUG_DRIVER("GEN6_STOLEN_RESERVED = %08x\n", reg_val); 308 + 309 + if (!(reg_val & GEN6_STOLEN_RESERVED_ENABLE)) 332 310 return; 333 - } 334 311 335 - stolen_top = dev_priv->dsm.end + 1; 312 + if (!(reg_val & GEN6_STOLEN_RESERVED_ADDR_MASK)) 313 + return; 336 314 337 315 *base = reg_val & GEN6_STOLEN_RESERVED_ADDR_MASK; 338 - 339 - /* On these platforms, the register doesn't have a size field, so the 340 - * size is the distance between the base and the top of the stolen 341 - * memory. We also have the genuine case where base is zero and there's 342 - * nothing reserved. */ 343 - if (*base == 0) 344 - *size = 0; 345 - else 346 - *size = stolen_top - *base; 316 + *size = stolen_top - *base; 347 317 } 348 318 349 319 int i915_gem_init_stolen(struct drm_i915_private *dev_priv) ··· 369 353 GEM_BUG_ON(dev_priv->dsm.end <= dev_priv->dsm.start); 370 354 371 355 stolen_top = dev_priv->dsm.end + 1; 372 - reserved_base = 0; 356 + reserved_base = stolen_top; 373 357 reserved_size = 0; 374 358 375 359 switch (INTEL_GEN(dev_priv)) { ··· 389 373 &reserved_base, &reserved_size); 390 374 break; 391 375 case 7: 392 - gen7_get_stolen_reserved(dev_priv, 393 - &reserved_base, &reserved_size); 376 + if (IS_VALLEYVIEW(dev_priv)) 377 + vlv_get_stolen_reserved(dev_priv, 378 + &reserved_base, &reserved_size); 379 + else 380 + gen7_get_stolen_reserved(dev_priv, 381 + &reserved_base, &reserved_size); 394 382 break; 395 383 default: 396 384 if (IS_LP(dev_priv)) ··· 406 386 break; 407 387 } 408 388 409 - /* It is possible for the reserved base to be zero, but the register 410 - * field for size doesn't have a zero option. */ 411 - if (reserved_base == 0) { 412 - reserved_size = 0; 389 + /* 390 + * Our expectation is that the reserved space is at the top of the 391 + * stolen region and *never* at the bottom. If we see !reserved_base, 392 + * it likely means we failed to read the registers correctly. 393 + */ 394 + if (!reserved_base) { 395 + DRM_ERROR("inconsistent reservation %pa + %pa; ignoring\n", 396 + &reserved_base, &reserved_size); 413 397 reserved_base = stolen_top; 398 + reserved_size = 0; 414 399 } 415 400 416 401 dev_priv->dsm_reserved = ··· 431 406 * memory, so just consider the start. */ 432 407 reserved_total = stolen_top - reserved_base; 433 408 434 - DRM_DEBUG_KMS("Memory reserved for graphics device: %lluK, usable: %lluK\n", 435 - (u64)resource_size(&dev_priv->dsm) >> 10, 436 - ((u64)resource_size(&dev_priv->dsm) - reserved_total) >> 10); 409 + DRM_DEBUG_DRIVER("Memory reserved for graphics device: %lluK, usable: %lluK\n", 410 + (u64)resource_size(&dev_priv->dsm) >> 10, 411 + ((u64)resource_size(&dev_priv->dsm) - reserved_total) >> 10); 437 412 438 413 stolen_usable_start = 0; 439 414 /* WaSkipStolenMemoryFirstPage:bdw+ */ ··· 605 580 606 581 lockdep_assert_held(&dev_priv->drm.struct_mutex); 607 582 608 - DRM_DEBUG_KMS("creating preallocated stolen object: stolen_offset=%pa, gtt_offset=%pa, size=%pa\n", 609 - &stolen_offset, &gtt_offset, &size); 583 + DRM_DEBUG_DRIVER("creating preallocated stolen object: stolen_offset=%pa, gtt_offset=%pa, size=%pa\n", 584 + &stolen_offset, &gtt_offset, &size); 610 585 611 586 /* KISS and expect everything to be page-aligned */ 612 587 if (WARN_ON(size == 0) || ··· 624 599 ret = drm_mm_reserve_node(&dev_priv->mm.stolen, stolen); 625 600 mutex_unlock(&dev_priv->mm.stolen_lock); 626 601 if (ret) { 627 - DRM_DEBUG_KMS("failed to allocate stolen space\n"); 602 + DRM_DEBUG_DRIVER("failed to allocate stolen space\n"); 628 603 kfree(stolen); 629 604 return NULL; 630 605 } 631 606 632 607 obj = _i915_gem_object_create_stolen(dev_priv, stolen); 633 608 if (obj == NULL) { 634 - DRM_DEBUG_KMS("failed to allocate stolen object\n"); 609 + DRM_DEBUG_DRIVER("failed to allocate stolen object\n"); 635 610 i915_gem_stolen_remove_node(dev_priv, stolen); 636 611 kfree(stolen); 637 612 return NULL; ··· 660 635 size, gtt_offset, obj->cache_level, 661 636 0); 662 637 if (ret) { 663 - DRM_DEBUG_KMS("failed to allocate stolen GTT space\n"); 638 + DRM_DEBUG_DRIVER("failed to allocate stolen GTT space\n"); 664 639 goto err_pages; 665 640 } 666 641
+1
drivers/gpu/drm/i915/i915_gpu_error.c
··· 32 32 #include <linux/zlib.h> 33 33 #include <drm/drm_print.h> 34 34 35 + #include "i915_gpu_error.h" 35 36 #include "i915_drv.h" 36 37 37 38 static inline const struct intel_engine_cs *
+362
drivers/gpu/drm/i915/i915_gpu_error.h
··· 1 + /* 2 + * SPDX-License-Identifier: MIT 3 + * 4 + * Copyright � 2008-2018 Intel Corporation 5 + */ 6 + 7 + #ifndef _I915_GPU_ERROR_H_ 8 + #define _I915_GPU_ERROR_H_ 9 + 10 + #include <linux/kref.h> 11 + #include <linux/ktime.h> 12 + #include <linux/sched.h> 13 + 14 + #include <drm/drm_mm.h> 15 + 16 + #include "intel_device_info.h" 17 + #include "intel_ringbuffer.h" 18 + #include "intel_uc_fw.h" 19 + 20 + #include "i915_gem.h" 21 + #include "i915_gem_gtt.h" 22 + #include "i915_params.h" 23 + 24 + struct drm_i915_private; 25 + struct intel_overlay_error_state; 26 + struct intel_display_error_state; 27 + 28 + struct i915_gpu_state { 29 + struct kref ref; 30 + ktime_t time; 31 + ktime_t boottime; 32 + ktime_t uptime; 33 + 34 + struct drm_i915_private *i915; 35 + 36 + char error_msg[128]; 37 + bool simulated; 38 + bool awake; 39 + bool wakelock; 40 + bool suspended; 41 + int iommu; 42 + u32 reset_count; 43 + u32 suspend_count; 44 + struct intel_device_info device_info; 45 + struct intel_driver_caps driver_caps; 46 + struct i915_params params; 47 + 48 + struct i915_error_uc { 49 + struct intel_uc_fw guc_fw; 50 + struct intel_uc_fw huc_fw; 51 + struct drm_i915_error_object *guc_log; 52 + } uc; 53 + 54 + /* Generic register state */ 55 + u32 eir; 56 + u32 pgtbl_er; 57 + u32 ier; 58 + u32 gtier[4], ngtier; 59 + u32 ccid; 60 + u32 derrmr; 61 + u32 forcewake; 62 + u32 error; /* gen6+ */ 63 + u32 err_int; /* gen7 */ 64 + u32 fault_data0; /* gen8, gen9 */ 65 + u32 fault_data1; /* gen8, gen9 */ 66 + u32 done_reg; 67 + u32 gac_eco; 68 + u32 gam_ecochk; 69 + u32 gab_ctl; 70 + u32 gfx_mode; 71 + 72 + u32 nfence; 73 + u64 fence[I915_MAX_NUM_FENCES]; 74 + struct intel_overlay_error_state *overlay; 75 + struct intel_display_error_state *display; 76 + 77 + struct drm_i915_error_engine { 78 + int engine_id; 79 + /* Software tracked state */ 80 + bool idle; 81 + bool waiting; 82 + int num_waiters; 83 + unsigned long hangcheck_timestamp; 84 + bool hangcheck_stalled; 85 + enum intel_engine_hangcheck_action hangcheck_action; 86 + struct i915_address_space *vm; 87 + int num_requests; 88 + u32 reset_count; 89 + 90 + /* position of active request inside the ring */ 91 + u32 rq_head, rq_post, rq_tail; 92 + 93 + /* our own tracking of ring head and tail */ 94 + u32 cpu_ring_head; 95 + u32 cpu_ring_tail; 96 + 97 + u32 last_seqno; 98 + 99 + /* Register state */ 100 + u32 start; 101 + u32 tail; 102 + u32 head; 103 + u32 ctl; 104 + u32 mode; 105 + u32 hws; 106 + u32 ipeir; 107 + u32 ipehr; 108 + u32 bbstate; 109 + u32 instpm; 110 + u32 instps; 111 + u32 seqno; 112 + u64 bbaddr; 113 + u64 acthd; 114 + u32 fault_reg; 115 + u64 faddr; 116 + u32 rc_psmi; /* sleep state */ 117 + u32 semaphore_mboxes[I915_NUM_ENGINES - 1]; 118 + struct intel_instdone instdone; 119 + 120 + struct drm_i915_error_context { 121 + char comm[TASK_COMM_LEN]; 122 + pid_t pid; 123 + u32 handle; 124 + u32 hw_id; 125 + int priority; 126 + int ban_score; 127 + int active; 128 + int guilty; 129 + bool bannable; 130 + } context; 131 + 132 + struct drm_i915_error_object { 133 + u64 gtt_offset; 134 + u64 gtt_size; 135 + int page_count; 136 + int unused; 137 + u32 *pages[0]; 138 + } *ringbuffer, *batchbuffer, *wa_batchbuffer, *ctx, *hws_page; 139 + 140 + struct drm_i915_error_object **user_bo; 141 + long user_bo_count; 142 + 143 + struct drm_i915_error_object *wa_ctx; 144 + struct drm_i915_error_object *default_state; 145 + 146 + struct drm_i915_error_request { 147 + long jiffies; 148 + pid_t pid; 149 + u32 context; 150 + int priority; 151 + int ban_score; 152 + u32 seqno; 153 + u32 head; 154 + u32 tail; 155 + } *requests, execlist[EXECLIST_MAX_PORTS]; 156 + unsigned int num_ports; 157 + 158 + struct drm_i915_error_waiter { 159 + char comm[TASK_COMM_LEN]; 160 + pid_t pid; 161 + u32 seqno; 162 + } *waiters; 163 + 164 + struct { 165 + u32 gfx_mode; 166 + union { 167 + u64 pdp[4]; 168 + u32 pp_dir_base; 169 + }; 170 + } vm_info; 171 + } engine[I915_NUM_ENGINES]; 172 + 173 + struct drm_i915_error_buffer { 174 + u32 size; 175 + u32 name; 176 + u32 rseqno[I915_NUM_ENGINES], wseqno; 177 + u64 gtt_offset; 178 + u32 read_domains; 179 + u32 write_domain; 180 + s32 fence_reg:I915_MAX_NUM_FENCE_BITS; 181 + u32 tiling:2; 182 + u32 dirty:1; 183 + u32 purgeable:1; 184 + u32 userptr:1; 185 + s32 engine:4; 186 + u32 cache_level:3; 187 + } *active_bo[I915_NUM_ENGINES], *pinned_bo; 188 + u32 active_bo_count[I915_NUM_ENGINES], pinned_bo_count; 189 + struct i915_address_space *active_vm[I915_NUM_ENGINES]; 190 + }; 191 + 192 + struct i915_gpu_error { 193 + /* For hangcheck timer */ 194 + #define DRM_I915_HANGCHECK_PERIOD 1500 /* in ms */ 195 + #define DRM_I915_HANGCHECK_JIFFIES msecs_to_jiffies(DRM_I915_HANGCHECK_PERIOD) 196 + 197 + struct delayed_work hangcheck_work; 198 + 199 + /* For reset and error_state handling. */ 200 + spinlock_t lock; 201 + /* Protected by the above dev->gpu_error.lock. */ 202 + struct i915_gpu_state *first_error; 203 + 204 + atomic_t pending_fb_pin; 205 + 206 + unsigned long missed_irq_rings; 207 + 208 + /** 209 + * State variable controlling the reset flow and count 210 + * 211 + * This is a counter which gets incremented when reset is triggered, 212 + * 213 + * Before the reset commences, the I915_RESET_BACKOFF bit is set 214 + * meaning that any waiters holding onto the struct_mutex should 215 + * relinquish the lock immediately in order for the reset to start. 216 + * 217 + * If reset is not completed successfully, the I915_WEDGE bit is 218 + * set meaning that hardware is terminally sour and there is no 219 + * recovery. All waiters on the reset_queue will be woken when 220 + * that happens. 221 + * 222 + * This counter is used by the wait_seqno code to notice that reset 223 + * event happened and it needs to restart the entire ioctl (since most 224 + * likely the seqno it waited for won't ever signal anytime soon). 225 + * 226 + * This is important for lock-free wait paths, where no contended lock 227 + * naturally enforces the correct ordering between the bail-out of the 228 + * waiter and the gpu reset work code. 229 + */ 230 + unsigned long reset_count; 231 + 232 + /** 233 + * flags: Control various stages of the GPU reset 234 + * 235 + * #I915_RESET_BACKOFF - When we start a reset, we want to stop any 236 + * other users acquiring the struct_mutex. To do this we set the 237 + * #I915_RESET_BACKOFF bit in the error flags when we detect a reset 238 + * and then check for that bit before acquiring the struct_mutex (in 239 + * i915_mutex_lock_interruptible()?). I915_RESET_BACKOFF serves a 240 + * secondary role in preventing two concurrent global reset attempts. 241 + * 242 + * #I915_RESET_HANDOFF - To perform the actual GPU reset, we need the 243 + * struct_mutex. We try to acquire the struct_mutex in the reset worker, 244 + * but it may be held by some long running waiter (that we cannot 245 + * interrupt without causing trouble). Once we are ready to do the GPU 246 + * reset, we set the I915_RESET_HANDOFF bit and wakeup any waiters. If 247 + * they already hold the struct_mutex and want to participate they can 248 + * inspect the bit and do the reset directly, otherwise the worker 249 + * waits for the struct_mutex. 250 + * 251 + * #I915_RESET_ENGINE[num_engines] - Since the driver doesn't need to 252 + * acquire the struct_mutex to reset an engine, we need an explicit 253 + * flag to prevent two concurrent reset attempts in the same engine. 254 + * As the number of engines continues to grow, allocate the flags from 255 + * the most significant bits. 256 + * 257 + * #I915_WEDGED - If reset fails and we can no longer use the GPU, 258 + * we set the #I915_WEDGED bit. Prior to command submission, e.g. 259 + * i915_request_alloc(), this bit is checked and the sequence 260 + * aborted (with -EIO reported to userspace) if set. 261 + */ 262 + unsigned long flags; 263 + #define I915_RESET_BACKOFF 0 264 + #define I915_RESET_HANDOFF 1 265 + #define I915_RESET_MODESET 2 266 + #define I915_WEDGED (BITS_PER_LONG - 1) 267 + #define I915_RESET_ENGINE (I915_WEDGED - I915_NUM_ENGINES) 268 + 269 + /** Number of times an engine has been reset */ 270 + u32 reset_engine_count[I915_NUM_ENGINES]; 271 + 272 + /** Set of stalled engines with guilty requests, in the current reset */ 273 + u32 stalled_mask; 274 + 275 + /** Reason for the current *global* reset */ 276 + const char *reason; 277 + 278 + /** 279 + * Waitqueue to signal when a hang is detected. Used to for waiters 280 + * to release the struct_mutex for the reset to procede. 281 + */ 282 + wait_queue_head_t wait_queue; 283 + 284 + /** 285 + * Waitqueue to signal when the reset has completed. Used by clients 286 + * that wait for dev_priv->mm.wedged to settle. 287 + */ 288 + wait_queue_head_t reset_queue; 289 + 290 + /* For missed irq/seqno simulation. */ 291 + unsigned long test_irq_rings; 292 + }; 293 + 294 + struct drm_i915_error_state_buf { 295 + struct drm_i915_private *i915; 296 + unsigned int bytes; 297 + unsigned int size; 298 + int err; 299 + u8 *buf; 300 + loff_t start; 301 + loff_t pos; 302 + }; 303 + 304 + #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) 305 + 306 + __printf(2, 3) 307 + void i915_error_printf(struct drm_i915_error_state_buf *e, const char *f, ...); 308 + int i915_error_state_to_str(struct drm_i915_error_state_buf *estr, 309 + const struct i915_gpu_state *gpu); 310 + int i915_error_state_buf_init(struct drm_i915_error_state_buf *eb, 311 + struct drm_i915_private *i915, 312 + size_t count, loff_t pos); 313 + 314 + static inline void 315 + i915_error_state_buf_release(struct drm_i915_error_state_buf *eb) 316 + { 317 + kfree(eb->buf); 318 + } 319 + 320 + struct i915_gpu_state *i915_capture_gpu_state(struct drm_i915_private *i915); 321 + void i915_capture_error_state(struct drm_i915_private *dev_priv, 322 + u32 engine_mask, 323 + const char *error_msg); 324 + 325 + static inline struct i915_gpu_state * 326 + i915_gpu_state_get(struct i915_gpu_state *gpu) 327 + { 328 + kref_get(&gpu->ref); 329 + return gpu; 330 + } 331 + 332 + void __i915_gpu_state_free(struct kref *kref); 333 + static inline void i915_gpu_state_put(struct i915_gpu_state *gpu) 334 + { 335 + if (gpu) 336 + kref_put(&gpu->ref, __i915_gpu_state_free); 337 + } 338 + 339 + struct i915_gpu_state *i915_first_error_state(struct drm_i915_private *i915); 340 + void i915_reset_error_state(struct drm_i915_private *i915); 341 + 342 + #else 343 + 344 + static inline void i915_capture_error_state(struct drm_i915_private *dev_priv, 345 + u32 engine_mask, 346 + const char *error_msg) 347 + { 348 + } 349 + 350 + static inline struct i915_gpu_state * 351 + i915_first_error_state(struct drm_i915_private *i915) 352 + { 353 + return NULL; 354 + } 355 + 356 + static inline void i915_reset_error_state(struct drm_i915_private *i915) 357 + { 358 + } 359 + 360 + #endif /* IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) */ 361 + 362 + #endif /* _I915_GPU_ERROR_H_ */
+223 -151
drivers/gpu/drm/i915/i915_irq.c
··· 243 243 spin_unlock_irq(&dev_priv->irq_lock); 244 244 } 245 245 246 + static u32 247 + gen11_gt_engine_identity(struct drm_i915_private * const i915, 248 + const unsigned int bank, const unsigned int bit); 249 + 250 + static bool gen11_reset_one_iir(struct drm_i915_private * const i915, 251 + const unsigned int bank, 252 + const unsigned int bit) 253 + { 254 + void __iomem * const regs = i915->regs; 255 + u32 dw; 256 + 257 + lockdep_assert_held(&i915->irq_lock); 258 + 259 + dw = raw_reg_read(regs, GEN11_GT_INTR_DW(bank)); 260 + if (dw & BIT(bit)) { 261 + /* 262 + * According to the BSpec, DW_IIR bits cannot be cleared without 263 + * first servicing the Selector & Shared IIR registers. 264 + */ 265 + gen11_gt_engine_identity(i915, bank, bit); 266 + 267 + /* 268 + * We locked GT INT DW by reading it. If we want to (try 269 + * to) recover from this succesfully, we need to clear 270 + * our bit, otherwise we are locking the register for 271 + * everybody. 272 + */ 273 + raw_reg_write(regs, GEN11_GT_INTR_DW(bank), BIT(bit)); 274 + 275 + return true; 276 + } 277 + 278 + return false; 279 + } 280 + 246 281 /** 247 282 * ilk_update_display_irq - update DEIMR 248 283 * @dev_priv: driver private ··· 343 308 344 309 static i915_reg_t gen6_pm_iir(struct drm_i915_private *dev_priv) 345 310 { 311 + WARN_ON_ONCE(INTEL_GEN(dev_priv) >= 11); 312 + 346 313 return INTEL_GEN(dev_priv) >= 8 ? GEN8_GT_IIR(2) : GEN6_PMIIR; 347 314 } 348 315 349 316 static i915_reg_t gen6_pm_imr(struct drm_i915_private *dev_priv) 350 317 { 351 - return INTEL_GEN(dev_priv) >= 8 ? GEN8_GT_IMR(2) : GEN6_PMIMR; 318 + if (INTEL_GEN(dev_priv) >= 11) 319 + return GEN11_GPM_WGBOXPERF_INTR_MASK; 320 + else if (INTEL_GEN(dev_priv) >= 8) 321 + return GEN8_GT_IMR(2); 322 + else 323 + return GEN6_PMIMR; 352 324 } 353 325 354 326 static i915_reg_t gen6_pm_ier(struct drm_i915_private *dev_priv) 355 327 { 356 - return INTEL_GEN(dev_priv) >= 8 ? GEN8_GT_IER(2) : GEN6_PMIER; 328 + if (INTEL_GEN(dev_priv) >= 11) 329 + return GEN11_GPM_WGBOXPERF_INTR_ENABLE; 330 + else if (INTEL_GEN(dev_priv) >= 8) 331 + return GEN8_GT_IER(2); 332 + else 333 + return GEN6_PMIER; 357 334 } 358 335 359 336 /** ··· 447 400 /* though a barrier is missing here, but don't really need a one */ 448 401 } 449 402 403 + void gen11_reset_rps_interrupts(struct drm_i915_private *dev_priv) 404 + { 405 + spin_lock_irq(&dev_priv->irq_lock); 406 + 407 + while (gen11_reset_one_iir(dev_priv, 0, GEN11_GTPM)) 408 + ; 409 + 410 + dev_priv->gt_pm.rps.pm_iir = 0; 411 + 412 + spin_unlock_irq(&dev_priv->irq_lock); 413 + } 414 + 450 415 void gen6_reset_rps_interrupts(struct drm_i915_private *dev_priv) 451 416 { 452 417 spin_lock_irq(&dev_priv->irq_lock); ··· 474 415 if (READ_ONCE(rps->interrupts_enabled)) 475 416 return; 476 417 477 - if (WARN_ON_ONCE(IS_GEN11(dev_priv))) 478 - return; 479 - 480 418 spin_lock_irq(&dev_priv->irq_lock); 481 419 WARN_ON_ONCE(rps->pm_iir); 482 - WARN_ON_ONCE(I915_READ(gen6_pm_iir(dev_priv)) & dev_priv->pm_rps_events); 420 + 421 + if (INTEL_GEN(dev_priv) >= 11) 422 + WARN_ON_ONCE(gen11_reset_one_iir(dev_priv, 0, GEN11_GTPM)); 423 + else 424 + WARN_ON_ONCE(I915_READ(gen6_pm_iir(dev_priv)) & dev_priv->pm_rps_events); 425 + 483 426 rps->interrupts_enabled = true; 484 427 gen6_enable_pm_irq(dev_priv, dev_priv->pm_rps_events); 485 428 ··· 493 432 struct intel_rps *rps = &dev_priv->gt_pm.rps; 494 433 495 434 if (!READ_ONCE(rps->interrupts_enabled)) 496 - return; 497 - 498 - if (WARN_ON_ONCE(IS_GEN11(dev_priv))) 499 435 return; 500 436 501 437 spin_lock_irq(&dev_priv->irq_lock); ··· 511 453 * state of the worker can be discarded. 512 454 */ 513 455 cancel_work_sync(&rps->work); 514 - gen6_reset_rps_interrupts(dev_priv); 456 + if (INTEL_GEN(dev_priv) >= 11) 457 + gen11_reset_rps_interrupts(dev_priv); 458 + else 459 + gen6_reset_rps_interrupts(dev_priv); 515 460 } 516 461 517 462 void gen9_reset_guc_interrupts(struct drm_i915_private *dev_priv) ··· 1460 1399 } 1461 1400 1462 1401 static void 1463 - gen8_cs_irq_handler(struct intel_engine_cs *engine, u32 iir, int test_shift) 1402 + gen8_cs_irq_handler(struct intel_engine_cs *engine, u32 iir) 1464 1403 { 1465 1404 struct intel_engine_execlists * const execlists = &engine->execlists; 1466 1405 bool tasklet = false; 1467 1406 1468 - if (iir & (GT_CONTEXT_SWITCH_INTERRUPT << test_shift)) { 1469 - if (READ_ONCE(engine->execlists.active)) { 1470 - __set_bit(ENGINE_IRQ_EXECLIST, &engine->irq_posted); 1471 - tasklet = true; 1472 - } 1407 + if (iir & GT_CONTEXT_SWITCH_INTERRUPT) { 1408 + if (READ_ONCE(engine->execlists.active)) 1409 + tasklet = !test_and_set_bit(ENGINE_IRQ_EXECLIST, 1410 + &engine->irq_posted); 1473 1411 } 1474 1412 1475 - if (iir & (GT_RENDER_USER_INTERRUPT << test_shift)) { 1413 + if (iir & GT_RENDER_USER_INTERRUPT) { 1476 1414 notify_ring(engine); 1477 1415 tasklet |= USES_GUC_SUBMISSION(engine->i915); 1478 1416 } ··· 1526 1466 { 1527 1467 if (master_ctl & (GEN8_GT_RCS_IRQ | GEN8_GT_BCS_IRQ)) { 1528 1468 gen8_cs_irq_handler(i915->engine[RCS], 1529 - gt_iir[0], GEN8_RCS_IRQ_SHIFT); 1469 + gt_iir[0] >> GEN8_RCS_IRQ_SHIFT); 1530 1470 gen8_cs_irq_handler(i915->engine[BCS], 1531 - gt_iir[0], GEN8_BCS_IRQ_SHIFT); 1471 + gt_iir[0] >> GEN8_BCS_IRQ_SHIFT); 1532 1472 } 1533 1473 1534 1474 if (master_ctl & (GEN8_GT_VCS1_IRQ | GEN8_GT_VCS2_IRQ)) { 1535 1475 gen8_cs_irq_handler(i915->engine[VCS], 1536 - gt_iir[1], GEN8_VCS1_IRQ_SHIFT); 1476 + gt_iir[1] >> GEN8_VCS1_IRQ_SHIFT); 1537 1477 gen8_cs_irq_handler(i915->engine[VCS2], 1538 - gt_iir[1], GEN8_VCS2_IRQ_SHIFT); 1478 + gt_iir[1] >> GEN8_VCS2_IRQ_SHIFT); 1539 1479 } 1540 1480 1541 1481 if (master_ctl & GEN8_GT_VECS_IRQ) { 1542 1482 gen8_cs_irq_handler(i915->engine[VECS], 1543 - gt_iir[3], GEN8_VECS_IRQ_SHIFT); 1483 + gt_iir[3] >> GEN8_VECS_IRQ_SHIFT); 1544 1484 } 1545 1485 1546 1486 if (master_ctl & (GEN8_GT_PM_IRQ | GEN8_GT_GUC_IRQ)) { ··· 1687 1627 int head, tail; 1688 1628 1689 1629 spin_lock(&pipe_crc->lock); 1690 - if (pipe_crc->source) { 1630 + if (pipe_crc->source && !crtc->base.crc.opened) { 1691 1631 if (!pipe_crc->entries) { 1692 1632 spin_unlock(&pipe_crc->lock); 1693 1633 DRM_DEBUG_KMS("spurious interrupt\n"); ··· 1727 1667 * On GEN8+ sometimes the second CRC is bonkers as well, so 1728 1668 * don't trust that one either. 1729 1669 */ 1730 - if (pipe_crc->skipped == 0 || 1670 + if (pipe_crc->skipped <= 0 || 1731 1671 (INTEL_GEN(dev_priv) >= 8 && pipe_crc->skipped == 1)) { 1732 1672 pipe_crc->skipped++; 1733 1673 spin_unlock(&pipe_crc->lock); ··· 1826 1766 1827 1767 static void gen9_guc_irq_handler(struct drm_i915_private *dev_priv, u32 gt_iir) 1828 1768 { 1829 - if (gt_iir & GEN9_GUC_TO_HOST_INT_EVENT) { 1830 - /* Sample the log buffer flush related bits & clear them out now 1831 - * itself from the message identity register to minimize the 1832 - * probability of losing a flush interrupt, when there are back 1833 - * to back flush interrupts. 1834 - * There can be a new flush interrupt, for different log buffer 1835 - * type (like for ISR), whilst Host is handling one (for DPC). 1836 - * Since same bit is used in message register for ISR & DPC, it 1837 - * could happen that GuC sets the bit for 2nd interrupt but Host 1838 - * clears out the bit on handling the 1st interrupt. 1839 - */ 1840 - u32 msg, flush; 1841 - 1842 - msg = I915_READ(SOFT_SCRATCH(15)); 1843 - flush = msg & (INTEL_GUC_RECV_MSG_CRASH_DUMP_POSTED | 1844 - INTEL_GUC_RECV_MSG_FLUSH_LOG_BUFFER); 1845 - if (flush) { 1846 - /* Clear the message bits that are handled */ 1847 - I915_WRITE(SOFT_SCRATCH(15), msg & ~flush); 1848 - 1849 - /* Handle flush interrupt in bottom half */ 1850 - queue_work(dev_priv->guc.log.runtime.flush_wq, 1851 - &dev_priv->guc.log.runtime.flush_work); 1852 - 1853 - dev_priv->guc.log.flush_interrupt_count++; 1854 - } else { 1855 - /* Not clearing of unhandled event bits won't result in 1856 - * re-triggering of the interrupt. 1857 - */ 1858 - } 1859 - } 1769 + if (gt_iir & GEN9_GUC_TO_HOST_INT_EVENT) 1770 + intel_guc_to_host_event_handler(&dev_priv->guc); 1860 1771 } 1861 1772 1862 1773 static void i9xx_pipestat_irq_reset(struct drm_i915_private *dev_priv) ··· 2793 2762 (W)->i915; \ 2794 2763 __fini_wedge((W))) 2795 2764 2796 - static __always_inline void 2797 - gen11_cs_irq_handler(struct intel_engine_cs * const engine, const u32 iir) 2798 - { 2799 - gen8_cs_irq_handler(engine, iir, 0); 2800 - } 2801 - 2802 - static void 2803 - gen11_gt_engine_irq_handler(struct drm_i915_private * const i915, 2804 - const unsigned int bank, 2805 - const unsigned int engine_n, 2806 - const u16 iir) 2807 - { 2808 - struct intel_engine_cs ** const engine = i915->engine; 2809 - 2810 - switch (bank) { 2811 - case 0: 2812 - switch (engine_n) { 2813 - 2814 - case GEN11_RCS0: 2815 - return gen11_cs_irq_handler(engine[RCS], iir); 2816 - 2817 - case GEN11_BCS: 2818 - return gen11_cs_irq_handler(engine[BCS], iir); 2819 - } 2820 - case 1: 2821 - switch (engine_n) { 2822 - 2823 - case GEN11_VCS(0): 2824 - return gen11_cs_irq_handler(engine[_VCS(0)], iir); 2825 - case GEN11_VCS(1): 2826 - return gen11_cs_irq_handler(engine[_VCS(1)], iir); 2827 - case GEN11_VCS(2): 2828 - return gen11_cs_irq_handler(engine[_VCS(2)], iir); 2829 - case GEN11_VCS(3): 2830 - return gen11_cs_irq_handler(engine[_VCS(3)], iir); 2831 - 2832 - case GEN11_VECS(0): 2833 - return gen11_cs_irq_handler(engine[_VECS(0)], iir); 2834 - case GEN11_VECS(1): 2835 - return gen11_cs_irq_handler(engine[_VECS(1)], iir); 2836 - } 2837 - } 2838 - } 2839 - 2840 2765 static u32 2841 - gen11_gt_engine_intr(struct drm_i915_private * const i915, 2842 - const unsigned int bank, const unsigned int bit) 2766 + gen11_gt_engine_identity(struct drm_i915_private * const i915, 2767 + const unsigned int bank, const unsigned int bit) 2843 2768 { 2844 2769 void __iomem * const regs = i915->regs; 2845 2770 u32 timeout_ts; 2846 2771 u32 ident; 2772 + 2773 + lockdep_assert_held(&i915->irq_lock); 2847 2774 2848 2775 raw_reg_write(regs, GEN11_IIR_REG_SELECTOR(bank), BIT(bit)); 2849 2776 ··· 2824 2835 raw_reg_write(regs, GEN11_INTR_IDENTITY_REG(bank), 2825 2836 GEN11_INTR_DATA_VALID); 2826 2837 2827 - return ident & GEN11_INTR_ENGINE_MASK; 2838 + return ident; 2839 + } 2840 + 2841 + static void 2842 + gen11_other_irq_handler(struct drm_i915_private * const i915, 2843 + const u8 instance, const u16 iir) 2844 + { 2845 + if (instance == OTHER_GTPM_INSTANCE) 2846 + return gen6_rps_irq_handler(i915, iir); 2847 + 2848 + WARN_ONCE(1, "unhandled other interrupt instance=0x%x, iir=0x%x\n", 2849 + instance, iir); 2850 + } 2851 + 2852 + static void 2853 + gen11_engine_irq_handler(struct drm_i915_private * const i915, 2854 + const u8 class, const u8 instance, const u16 iir) 2855 + { 2856 + struct intel_engine_cs *engine; 2857 + 2858 + if (instance <= MAX_ENGINE_INSTANCE) 2859 + engine = i915->engine_class[class][instance]; 2860 + else 2861 + engine = NULL; 2862 + 2863 + if (likely(engine)) 2864 + return gen8_cs_irq_handler(engine, iir); 2865 + 2866 + WARN_ONCE(1, "unhandled engine interrupt class=0x%x, instance=0x%x\n", 2867 + class, instance); 2868 + } 2869 + 2870 + static void 2871 + gen11_gt_identity_handler(struct drm_i915_private * const i915, 2872 + const u32 identity) 2873 + { 2874 + const u8 class = GEN11_INTR_ENGINE_CLASS(identity); 2875 + const u8 instance = GEN11_INTR_ENGINE_INSTANCE(identity); 2876 + const u16 intr = GEN11_INTR_ENGINE_INTR(identity); 2877 + 2878 + if (unlikely(!intr)) 2879 + return; 2880 + 2881 + if (class <= COPY_ENGINE_CLASS) 2882 + return gen11_engine_irq_handler(i915, class, instance, intr); 2883 + 2884 + if (class == OTHER_CLASS) 2885 + return gen11_other_irq_handler(i915, instance, intr); 2886 + 2887 + WARN_ONCE(1, "unknown interrupt class=0x%x, instance=0x%x, intr=0x%x\n", 2888 + class, instance, intr); 2889 + } 2890 + 2891 + static void 2892 + gen11_gt_bank_handler(struct drm_i915_private * const i915, 2893 + const unsigned int bank) 2894 + { 2895 + void __iomem * const regs = i915->regs; 2896 + unsigned long intr_dw; 2897 + unsigned int bit; 2898 + 2899 + lockdep_assert_held(&i915->irq_lock); 2900 + 2901 + intr_dw = raw_reg_read(regs, GEN11_GT_INTR_DW(bank)); 2902 + 2903 + if (unlikely(!intr_dw)) { 2904 + DRM_ERROR("GT_INTR_DW%u blank!\n", bank); 2905 + return; 2906 + } 2907 + 2908 + for_each_set_bit(bit, &intr_dw, 32) { 2909 + const u32 ident = gen11_gt_engine_identity(i915, 2910 + bank, bit); 2911 + 2912 + gen11_gt_identity_handler(i915, ident); 2913 + } 2914 + 2915 + /* Clear must be after shared has been served for engine */ 2916 + raw_reg_write(regs, GEN11_GT_INTR_DW(bank), intr_dw); 2828 2917 } 2829 2918 2830 2919 static void 2831 2920 gen11_gt_irq_handler(struct drm_i915_private * const i915, 2832 2921 const u32 master_ctl) 2833 2922 { 2834 - void __iomem * const regs = i915->regs; 2835 2923 unsigned int bank; 2836 2924 2925 + spin_lock(&i915->irq_lock); 2926 + 2837 2927 for (bank = 0; bank < 2; bank++) { 2838 - unsigned long intr_dw; 2839 - unsigned int bit; 2840 - 2841 - if (!(master_ctl & GEN11_GT_DW_IRQ(bank))) 2842 - continue; 2843 - 2844 - intr_dw = raw_reg_read(regs, GEN11_GT_INTR_DW(bank)); 2845 - 2846 - if (unlikely(!intr_dw)) { 2847 - DRM_ERROR("GT_INTR_DW%u blank!\n", bank); 2848 - continue; 2849 - } 2850 - 2851 - for_each_set_bit(bit, &intr_dw, 32) { 2852 - const u16 iir = gen11_gt_engine_intr(i915, bank, bit); 2853 - 2854 - if (unlikely(!iir)) 2855 - continue; 2856 - 2857 - gen11_gt_engine_irq_handler(i915, bank, bit, iir); 2858 - } 2859 - 2860 - /* Clear must be after shared has been served for engine */ 2861 - raw_reg_write(regs, GEN11_GT_INTR_DW(bank), intr_dw); 2928 + if (master_ctl & GEN11_GT_DW_IRQ(bank)) 2929 + gen11_gt_bank_handler(i915, bank); 2862 2930 } 2931 + 2932 + spin_unlock(&i915->irq_lock); 2863 2933 } 2864 2934 2865 2935 static irqreturn_t gen11_irq_handler(int irq, void *arg) ··· 2960 2912 return IRQ_HANDLED; 2961 2913 } 2962 2914 2963 - /** 2964 - * i915_reset_device - do process context error handling work 2965 - * @dev_priv: i915 device private 2966 - * 2967 - * Fire an error uevent so userspace can see that a hang or error 2968 - * was detected. 2969 - */ 2970 - static void i915_reset_device(struct drm_i915_private *dev_priv) 2915 + static void i915_reset_device(struct drm_i915_private *dev_priv, 2916 + u32 engine_mask, 2917 + const char *reason) 2971 2918 { 2919 + struct i915_gpu_error *error = &dev_priv->gpu_error; 2972 2920 struct kobject *kobj = &dev_priv->drm.primary->kdev->kobj; 2973 2921 char *error_event[] = { I915_ERROR_UEVENT "=1", NULL }; 2974 2922 char *reset_event[] = { I915_RESET_UEVENT "=1", NULL }; ··· 2980 2936 i915_wedge_on_timeout(&w, dev_priv, 5*HZ) { 2981 2937 intel_prepare_reset(dev_priv); 2982 2938 2939 + error->reason = reason; 2940 + error->stalled_mask = engine_mask; 2941 + 2983 2942 /* Signal that locked waiters should reset the GPU */ 2984 - set_bit(I915_RESET_HANDOFF, &dev_priv->gpu_error.flags); 2985 - wake_up_all(&dev_priv->gpu_error.wait_queue); 2943 + smp_mb__before_atomic(); 2944 + set_bit(I915_RESET_HANDOFF, &error->flags); 2945 + wake_up_all(&error->wait_queue); 2986 2946 2987 2947 /* Wait for anyone holding the lock to wakeup, without 2988 2948 * blocking indefinitely on struct_mutex. 2989 2949 */ 2990 2950 do { 2991 2951 if (mutex_trylock(&dev_priv->drm.struct_mutex)) { 2992 - i915_reset(dev_priv, 0); 2952 + i915_reset(dev_priv, engine_mask, reason); 2993 2953 mutex_unlock(&dev_priv->drm.struct_mutex); 2994 2954 } 2995 - } while (wait_on_bit_timeout(&dev_priv->gpu_error.flags, 2955 + } while (wait_on_bit_timeout(&error->flags, 2996 2956 I915_RESET_HANDOFF, 2997 2957 TASK_UNINTERRUPTIBLE, 2998 2958 1)); 2999 2959 2960 + error->stalled_mask = 0; 2961 + error->reason = NULL; 2962 + 3000 2963 intel_finish_reset(dev_priv); 3001 2964 } 3002 2965 3003 - if (!test_bit(I915_WEDGED, &dev_priv->gpu_error.flags)) 3004 - kobject_uevent_env(kobj, 3005 - KOBJ_CHANGE, reset_done_event); 2966 + if (!test_bit(I915_WEDGED, &error->flags)) 2967 + kobject_uevent_env(kobj, KOBJ_CHANGE, reset_done_event); 3006 2968 } 3007 2969 3008 2970 static void i915_clear_error_registers(struct drm_i915_private *dev_priv) ··· 3040 2990 * i915_handle_error - handle a gpu error 3041 2991 * @dev_priv: i915 device private 3042 2992 * @engine_mask: mask representing engines that are hung 2993 + * @flags: control flags 3043 2994 * @fmt: Error message format string 3044 2995 * 3045 2996 * Do some basic checking of register state at error time and ··· 3051 3000 */ 3052 3001 void i915_handle_error(struct drm_i915_private *dev_priv, 3053 3002 u32 engine_mask, 3003 + unsigned long flags, 3054 3004 const char *fmt, ...) 3055 3005 { 3056 3006 struct intel_engine_cs *engine; 3057 3007 unsigned int tmp; 3058 - va_list args; 3059 3008 char error_msg[80]; 3009 + char *msg = NULL; 3060 3010 3061 - va_start(args, fmt); 3062 - vscnprintf(error_msg, sizeof(error_msg), fmt, args); 3063 - va_end(args); 3011 + if (fmt) { 3012 + va_list args; 3013 + 3014 + va_start(args, fmt); 3015 + vscnprintf(error_msg, sizeof(error_msg), fmt, args); 3016 + va_end(args); 3017 + 3018 + msg = error_msg; 3019 + } 3064 3020 3065 3021 /* 3066 3022 * In most cases it's guaranteed that we get here with an RPM ··· 3078 3020 */ 3079 3021 intel_runtime_pm_get(dev_priv); 3080 3022 3081 - i915_capture_error_state(dev_priv, engine_mask, error_msg); 3082 - i915_clear_error_registers(dev_priv); 3023 + engine_mask &= INTEL_INFO(dev_priv)->ring_mask; 3024 + 3025 + if (flags & I915_ERROR_CAPTURE) { 3026 + i915_capture_error_state(dev_priv, engine_mask, msg); 3027 + i915_clear_error_registers(dev_priv); 3028 + } 3083 3029 3084 3030 /* 3085 3031 * Try engine reset when available. We fall back to full reset if ··· 3096 3034 &dev_priv->gpu_error.flags)) 3097 3035 continue; 3098 3036 3099 - if (i915_reset_engine(engine, 0) == 0) 3037 + if (i915_reset_engine(engine, msg) == 0) 3100 3038 engine_mask &= ~intel_engine_flag(engine); 3101 3039 3102 3040 clear_bit(I915_RESET_ENGINE + engine->id, ··· 3126 3064 TASK_UNINTERRUPTIBLE); 3127 3065 } 3128 3066 3129 - i915_reset_device(dev_priv); 3067 + i915_reset_device(dev_priv, engine_mask, msg); 3130 3068 3131 3069 for_each_engine(engine, dev_priv, tmp) { 3132 3070 clear_bit(I915_RESET_ENGINE + engine->id, ··· 3411 3349 I915_WRITE(GEN11_VCS0_VCS1_INTR_MASK, ~0); 3412 3350 I915_WRITE(GEN11_VCS2_VCS3_INTR_MASK, ~0); 3413 3351 I915_WRITE(GEN11_VECS0_VECS1_INTR_MASK, ~0); 3352 + 3353 + I915_WRITE(GEN11_GPM_WGBOXPERF_INTR_ENABLE, 0); 3354 + I915_WRITE(GEN11_GPM_WGBOXPERF_INTR_MASK, ~0); 3414 3355 } 3415 3356 3416 3357 static void gen11_irq_reset(struct drm_device *dev) ··· 3952 3887 I915_WRITE(GEN11_VCS2_VCS3_INTR_MASK, ~(irqs | irqs << 16)); 3953 3888 I915_WRITE(GEN11_VECS0_VECS1_INTR_MASK, ~(irqs | irqs << 16)); 3954 3889 3955 - dev_priv->pm_imr = 0xffffffff; /* TODO */ 3890 + /* 3891 + * RPS interrupts will get enabled/disabled on demand when RPS itself 3892 + * is enabled/disabled. 3893 + */ 3894 + dev_priv->pm_ier = 0x0; 3895 + dev_priv->pm_imr = ~dev_priv->pm_ier; 3896 + I915_WRITE(GEN11_GPM_WGBOXPERF_INTR_ENABLE, 0); 3897 + I915_WRITE(GEN11_GPM_WGBOXPERF_INTR_MASK, ~0); 3956 3898 } 3957 3899 3958 3900 static int gen11_irq_postinstall(struct drm_device *dev)
+118
drivers/gpu/drm/i915/i915_oa_icl.c
··· 1 + /* 2 + * Autogenerated file by GPU Top : https://github.com/rib/gputop 3 + * DO NOT EDIT manually! 4 + * 5 + * 6 + * Copyright (c) 2015 Intel Corporation 7 + * 8 + * Permission is hereby granted, free of charge, to any person obtaining a 9 + * copy of this software and associated documentation files (the "Software"), 10 + * to deal in the Software without restriction, including without limitation 11 + * the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 + * and/or sell copies of the Software, and to permit persons to whom the 13 + * Software is furnished to do so, subject to the following conditions: 14 + * 15 + * The above copyright notice and this permission notice (including the next 16 + * paragraph) shall be included in all copies or substantial portions of the 17 + * Software. 18 + * 19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 22 + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 25 + * IN THE SOFTWARE. 26 + * 27 + */ 28 + 29 + #include <linux/sysfs.h> 30 + 31 + #include "i915_drv.h" 32 + #include "i915_oa_icl.h" 33 + 34 + static const struct i915_oa_reg b_counter_config_test_oa[] = { 35 + { _MMIO(0x2740), 0x00000000 }, 36 + { _MMIO(0x2710), 0x00000000 }, 37 + { _MMIO(0x2714), 0xf0800000 }, 38 + { _MMIO(0x2720), 0x00000000 }, 39 + { _MMIO(0x2724), 0xf0800000 }, 40 + { _MMIO(0x2770), 0x00000004 }, 41 + { _MMIO(0x2774), 0x0000ffff }, 42 + { _MMIO(0x2778), 0x00000003 }, 43 + { _MMIO(0x277c), 0x0000ffff }, 44 + { _MMIO(0x2780), 0x00000007 }, 45 + { _MMIO(0x2784), 0x0000ffff }, 46 + { _MMIO(0x2788), 0x00100002 }, 47 + { _MMIO(0x278c), 0x0000fff7 }, 48 + { _MMIO(0x2790), 0x00100002 }, 49 + { _MMIO(0x2794), 0x0000ffcf }, 50 + { _MMIO(0x2798), 0x00100082 }, 51 + { _MMIO(0x279c), 0x0000ffef }, 52 + { _MMIO(0x27a0), 0x001000c2 }, 53 + { _MMIO(0x27a4), 0x0000ffe7 }, 54 + { _MMIO(0x27a8), 0x00100001 }, 55 + { _MMIO(0x27ac), 0x0000ffe7 }, 56 + }; 57 + 58 + static const struct i915_oa_reg flex_eu_config_test_oa[] = { 59 + }; 60 + 61 + static const struct i915_oa_reg mux_config_test_oa[] = { 62 + { _MMIO(0xd04), 0x00000200 }, 63 + { _MMIO(0x9840), 0x00000000 }, 64 + { _MMIO(0x9884), 0x00000000 }, 65 + { _MMIO(0x9888), 0x10060000 }, 66 + { _MMIO(0x9888), 0x22060000 }, 67 + { _MMIO(0x9888), 0x16060000 }, 68 + { _MMIO(0x9888), 0x24060000 }, 69 + { _MMIO(0x9888), 0x18060000 }, 70 + { _MMIO(0x9888), 0x1a060000 }, 71 + { _MMIO(0x9888), 0x12060000 }, 72 + { _MMIO(0x9888), 0x14060000 }, 73 + { _MMIO(0x9888), 0x10060000 }, 74 + { _MMIO(0x9888), 0x22060000 }, 75 + { _MMIO(0x9884), 0x00000003 }, 76 + { _MMIO(0x9888), 0x16130000 }, 77 + { _MMIO(0x9888), 0x24000001 }, 78 + { _MMIO(0x9888), 0x0e130056 }, 79 + { _MMIO(0x9888), 0x10130000 }, 80 + { _MMIO(0x9888), 0x1a130000 }, 81 + { _MMIO(0x9888), 0x541f0001 }, 82 + { _MMIO(0x9888), 0x181f0000 }, 83 + { _MMIO(0x9888), 0x4c1f0000 }, 84 + { _MMIO(0x9888), 0x301f0000 }, 85 + }; 86 + 87 + static ssize_t 88 + show_test_oa_id(struct device *kdev, struct device_attribute *attr, char *buf) 89 + { 90 + return sprintf(buf, "1\n"); 91 + } 92 + 93 + void 94 + i915_perf_load_test_config_icl(struct drm_i915_private *dev_priv) 95 + { 96 + strlcpy(dev_priv->perf.oa.test_config.uuid, 97 + "a291665e-244b-4b76-9b9a-01de9d3c8068", 98 + sizeof(dev_priv->perf.oa.test_config.uuid)); 99 + dev_priv->perf.oa.test_config.id = 1; 100 + 101 + dev_priv->perf.oa.test_config.mux_regs = mux_config_test_oa; 102 + dev_priv->perf.oa.test_config.mux_regs_len = ARRAY_SIZE(mux_config_test_oa); 103 + 104 + dev_priv->perf.oa.test_config.b_counter_regs = b_counter_config_test_oa; 105 + dev_priv->perf.oa.test_config.b_counter_regs_len = ARRAY_SIZE(b_counter_config_test_oa); 106 + 107 + dev_priv->perf.oa.test_config.flex_regs = flex_eu_config_test_oa; 108 + dev_priv->perf.oa.test_config.flex_regs_len = ARRAY_SIZE(flex_eu_config_test_oa); 109 + 110 + dev_priv->perf.oa.test_config.sysfs_metric.name = "a291665e-244b-4b76-9b9a-01de9d3c8068"; 111 + dev_priv->perf.oa.test_config.sysfs_metric.attrs = dev_priv->perf.oa.test_config.attrs; 112 + 113 + dev_priv->perf.oa.test_config.attrs[0] = &dev_priv->perf.oa.test_config.sysfs_metric_id.attr; 114 + 115 + dev_priv->perf.oa.test_config.sysfs_metric_id.attr.name = "id"; 116 + dev_priv->perf.oa.test_config.sysfs_metric_id.attr.mode = 0444; 117 + dev_priv->perf.oa.test_config.sysfs_metric_id.show = show_test_oa_id; 118 + }
+34
drivers/gpu/drm/i915/i915_oa_icl.h
··· 1 + /* 2 + * Autogenerated file by GPU Top : https://github.com/rib/gputop 3 + * DO NOT EDIT manually! 4 + * 5 + * 6 + * Copyright (c) 2015 Intel Corporation 7 + * 8 + * Permission is hereby granted, free of charge, to any person obtaining a 9 + * copy of this software and associated documentation files (the "Software"), 10 + * to deal in the Software without restriction, including without limitation 11 + * the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 + * and/or sell copies of the Software, and to permit persons to whom the 13 + * Software is furnished to do so, subject to the following conditions: 14 + * 15 + * The above copyright notice and this permission notice (including the next 16 + * paragraph) shall be included in all copies or substantial portions of the 17 + * Software. 18 + * 19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 22 + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 25 + * IN THE SOFTWARE. 26 + * 27 + */ 28 + 29 + #ifndef __I915_OA_ICL_H__ 30 + #define __I915_OA_ICL_H__ 31 + 32 + extern void i915_perf_load_test_config_icl(struct drm_i915_private *dev_priv); 33 + 34 + #endif
+1 -1
drivers/gpu/drm/i915/i915_params.h
··· 48 48 param(int, enable_ips, 1) \ 49 49 param(int, invert_brightness, 0) \ 50 50 param(int, enable_guc, 0) \ 51 - param(int, guc_log_level, 0) \ 51 + param(int, guc_log_level, -1) \ 52 52 param(char *, guc_firmware_path, NULL) \ 53 53 param(char *, huc_firmware_path, NULL) \ 54 54 param(int, mmio_debug, 0) \
+1
drivers/gpu/drm/i915/i915_pci.c
··· 602 602 PLATFORM(INTEL_ICELAKE), 603 603 .is_alpha_support = 1, 604 604 .has_resource_streamer = 0, 605 + .ring_mask = RENDER_RING | BLT_RING | VEBOX_RING | BSD_RING | BSD3_RING, 605 606 }; 606 607 607 608 #undef GEN
+40 -29
drivers/gpu/drm/i915/i915_perf.c
··· 209 209 #include "i915_oa_cflgt2.h" 210 210 #include "i915_oa_cflgt3.h" 211 211 #include "i915_oa_cnl.h" 212 + #include "i915_oa_icl.h" 212 213 213 214 /* HW requires this to be a power of two, between 128k and 16M, though driver 214 215 * is currently generally designed assuming the largest 16M size is used such ··· 1043 1042 1044 1043 I915_WRITE(GEN7_OASTATUS2, 1045 1044 ((head & GEN7_OASTATUS2_HEAD_MASK) | 1046 - OA_MEM_SELECT_GGTT)); 1045 + GEN7_OASTATUS2_MEM_SELECT_GGTT)); 1047 1046 dev_priv->perf.oa.oa_buffer.head = head; 1048 1047 1049 1048 spin_unlock_irqrestore(&dev_priv->perf.oa.oa_buffer.ptr_lock, flags); ··· 1333 1332 /* Pre-DevBDW: OABUFFER must be set with counters off, 1334 1333 * before OASTATUS1, but after OASTATUS2 1335 1334 */ 1336 - I915_WRITE(GEN7_OASTATUS2, gtt_offset | OA_MEM_SELECT_GGTT); /* head */ 1335 + I915_WRITE(GEN7_OASTATUS2, 1336 + gtt_offset | GEN7_OASTATUS2_MEM_SELECT_GGTT); /* head */ 1337 1337 dev_priv->perf.oa.oa_buffer.head = gtt_offset; 1338 1338 1339 1339 I915_WRITE(GEN7_OABUFFER, gtt_offset); ··· 1394 1392 * bit." 1395 1393 */ 1396 1394 I915_WRITE(GEN8_OABUFFER, gtt_offset | 1397 - OABUFFER_SIZE_16M | OA_MEM_SELECT_GGTT); 1395 + OABUFFER_SIZE_16M | GEN8_OABUFFER_MEM_SELECT_GGTT); 1398 1396 I915_WRITE(GEN8_OATAILPTR, gtt_offset & GEN8_OATAILPTR_MASK); 1399 1397 1400 1398 /* Mark that we need updated tail pointers to read from... */ ··· 1842 1840 * be read back from automatically triggered reports, as part of the 1843 1841 * RPT_ID field. 1844 1842 */ 1845 - if (IS_GEN9(dev_priv) || IS_GEN10(dev_priv)) { 1843 + if (IS_GEN(dev_priv, 9, 11)) { 1846 1844 I915_WRITE(GEN8_OA_DEBUG, 1847 1845 _MASKED_BIT_ENABLE(GEN9_OA_DEBUG_DISABLE_CLK_RATIO_REPORTS | 1848 1846 GEN9_OA_DEBUG_INCLUDE_CLK_RATIO)); ··· 1872 1870 1873 1871 I915_WRITE(GDT_CHICKEN_BITS, (I915_READ(GDT_CHICKEN_BITS) & 1874 1872 ~GT_NOA_ENABLE)); 1875 - 1876 1873 } 1877 1874 1878 1875 static void gen10_disable_metric_set(struct drm_i915_private *dev_priv) ··· 1886 1885 1887 1886 static void gen7_oa_enable(struct drm_i915_private *dev_priv) 1888 1887 { 1888 + struct i915_gem_context *ctx = 1889 + dev_priv->perf.oa.exclusive_stream->ctx; 1890 + u32 ctx_id = dev_priv->perf.oa.specific_ctx_id; 1891 + bool periodic = dev_priv->perf.oa.periodic; 1892 + u32 period_exponent = dev_priv->perf.oa.period_exponent; 1893 + u32 report_format = dev_priv->perf.oa.oa_buffer.format; 1894 + 1889 1895 /* 1890 1896 * Reset buf pointers so we don't forward reports from before now. 1891 1897 * ··· 1904 1896 */ 1905 1897 gen7_init_oa_buffer(dev_priv); 1906 1898 1907 - if (dev_priv->perf.oa.exclusive_stream->enabled) { 1908 - struct i915_gem_context *ctx = 1909 - dev_priv->perf.oa.exclusive_stream->ctx; 1910 - u32 ctx_id = dev_priv->perf.oa.specific_ctx_id; 1911 - 1912 - bool periodic = dev_priv->perf.oa.periodic; 1913 - u32 period_exponent = dev_priv->perf.oa.period_exponent; 1914 - u32 report_format = dev_priv->perf.oa.oa_buffer.format; 1915 - 1916 - I915_WRITE(GEN7_OACONTROL, 1917 - (ctx_id & GEN7_OACONTROL_CTX_MASK) | 1918 - (period_exponent << 1919 - GEN7_OACONTROL_TIMER_PERIOD_SHIFT) | 1920 - (periodic ? GEN7_OACONTROL_TIMER_ENABLE : 0) | 1921 - (report_format << GEN7_OACONTROL_FORMAT_SHIFT) | 1922 - (ctx ? GEN7_OACONTROL_PER_CTX_ENABLE : 0) | 1923 - GEN7_OACONTROL_ENABLE); 1924 - } else 1925 - I915_WRITE(GEN7_OACONTROL, 0); 1899 + I915_WRITE(GEN7_OACONTROL, 1900 + (ctx_id & GEN7_OACONTROL_CTX_MASK) | 1901 + (period_exponent << 1902 + GEN7_OACONTROL_TIMER_PERIOD_SHIFT) | 1903 + (periodic ? GEN7_OACONTROL_TIMER_ENABLE : 0) | 1904 + (report_format << GEN7_OACONTROL_FORMAT_SHIFT) | 1905 + (ctx ? GEN7_OACONTROL_PER_CTX_ENABLE : 0) | 1906 + GEN7_OACONTROL_ENABLE); 1926 1907 } 1927 1908 1928 1909 static void gen8_oa_enable(struct drm_i915_private *dev_priv) ··· 2096 2099 2097 2100 if (stream->ctx) { 2098 2101 ret = oa_get_render_ctx_id(stream); 2099 - if (ret) 2102 + if (ret) { 2103 + DRM_DEBUG("Invalid context id to filter with\n"); 2100 2104 return ret; 2105 + } 2101 2106 } 2102 2107 2103 2108 ret = get_oa_config(dev_priv, props->metrics_set, &stream->oa_config); 2104 - if (ret) 2109 + if (ret) { 2110 + DRM_DEBUG("Invalid OA config id=%i\n", props->metrics_set); 2105 2111 goto err_config; 2112 + } 2106 2113 2107 2114 /* PRM - observability performance counters: 2108 2115 * ··· 2133 2132 2134 2133 ret = dev_priv->perf.oa.ops.enable_metric_set(dev_priv, 2135 2134 stream->oa_config); 2136 - if (ret) 2135 + if (ret) { 2136 + DRM_DEBUG("Unable to enable metric set\n"); 2137 2137 goto err_enable; 2138 + } 2138 2139 2139 2140 stream->ops = &i915_oa_stream_ops; 2140 2141 ··· 2748 2745 props->ctx_handle = value; 2749 2746 break; 2750 2747 case DRM_I915_PERF_PROP_SAMPLE_OA: 2751 - props->sample_flags |= SAMPLE_OA_REPORT; 2748 + if (value) 2749 + props->sample_flags |= SAMPLE_OA_REPORT; 2752 2750 break; 2753 2751 case DRM_I915_PERF_PROP_OA_METRICS_SET: 2754 2752 if (value == 0) { ··· 2939 2935 i915_perf_load_test_config_cflgt3(dev_priv); 2940 2936 } else if (IS_CANNONLAKE(dev_priv)) { 2941 2937 i915_perf_load_test_config_cnl(dev_priv); 2938 + } else if (IS_ICELAKE(dev_priv)) { 2939 + i915_perf_load_test_config_icl(dev_priv); 2942 2940 } 2943 2941 2944 2942 if (dev_priv->perf.oa.test_config.id == 0) ··· 3298 3292 3299 3293 mutex_unlock(&dev_priv->perf.metrics_lock); 3300 3294 3295 + DRM_DEBUG("Added config %s id=%i\n", oa_config->uuid, oa_config->id); 3296 + 3301 3297 return oa_config->id; 3302 3298 3303 3299 sysfs_err: ··· 3356 3348 &oa_config->sysfs_metric); 3357 3349 3358 3350 idr_remove(&dev_priv->perf.metrics_idr, *arg); 3351 + 3352 + DRM_DEBUG("Removed config %s id=%i\n", oa_config->uuid, oa_config->id); 3353 + 3359 3354 put_oa_config(dev_priv, oa_config); 3360 3355 3361 3356 config_err: ··· 3478 3467 3479 3468 dev_priv->perf.oa.gen8_valid_ctx_bit = (1<<16); 3480 3469 } 3481 - } else if (IS_GEN10(dev_priv)) { 3470 + } else if (IS_GEN(dev_priv, 10, 11)) { 3482 3471 dev_priv->perf.oa.ops.is_valid_b_counter_reg = 3483 3472 gen7_is_valid_b_counter_addr; 3484 3473 dev_priv->perf.oa.ops.is_valid_mux_reg =
+3 -24
drivers/gpu/drm/i915/i915_pmu.c
··· 1 1 /* 2 - * Copyright © 2017 Intel Corporation 2 + * SPDX-License-Identifier: MIT 3 3 * 4 - * Permission is hereby granted, free of charge, to any person obtaining a 5 - * copy of this software and associated documentation files (the "Software"), 6 - * to deal in the Software without restriction, including without limitation 7 - * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 - * and/or sell copies of the Software, and to permit persons to whom the 9 - * Software is furnished to do so, subject to the following conditions: 10 - * 11 - * The above copyright notice and this permission notice (including the next 12 - * paragraph) shall be included in all copies or substantial portions of the 13 - * Software. 14 - * 15 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 - * IN THE SOFTWARE. 22 - * 4 + * Copyright © 2017-2018 Intel Corporation 23 5 */ 24 6 25 - #include <linux/perf_event.h> 26 - #include <linux/pm_runtime.h> 27 - 28 - #include "i915_drv.h" 29 7 #include "i915_pmu.h" 30 8 #include "intel_ringbuffer.h" 9 + #include "i915_drv.h" 31 10 32 11 /* Frequency for the sampling timer for events which need it. */ 33 12 #define FREQUENCY 200
+10 -20
drivers/gpu/drm/i915/i915_pmu.h
··· 1 1 /* 2 - * Copyright © 2017 Intel Corporation 2 + * SPDX-License-Identifier: MIT 3 3 * 4 - * Permission is hereby granted, free of charge, to any person obtaining a 5 - * copy of this software and associated documentation files (the "Software"), 6 - * to deal in the Software without restriction, including without limitation 7 - * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 - * and/or sell copies of the Software, and to permit persons to whom the 9 - * Software is furnished to do so, subject to the following conditions: 10 - * 11 - * The above copyright notice and this permission notice (including the next 12 - * paragraph) shall be included in all copies or substantial portions of the 13 - * Software. 14 - * 15 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 - * IN THE SOFTWARE. 22 - * 4 + * Copyright © 2017-2018 Intel Corporation 23 5 */ 6 + 24 7 #ifndef __I915_PMU_H__ 25 8 #define __I915_PMU_H__ 9 + 10 + #include <linux/hrtimer.h> 11 + #include <linux/perf_event.h> 12 + #include <linux/spinlock_types.h> 13 + #include <drm/i915_drm.h> 14 + 15 + struct drm_i915_private; 26 16 27 17 enum { 28 18 __I915_SAMPLE_FREQ_ACT = 0,
+267 -377
drivers/gpu/drm/i915/i915_reg.h
··· 153 153 #define _MMIO_PORT3(pipe, a, b, c) _MMIO(_PICK(pipe, a, b, c)) 154 154 #define _PLL(pll, a, b) ((a) + (pll)*((b)-(a))) 155 155 #define _MMIO_PLL(pll, a, b) _MMIO(_PLL(pll, a, b)) 156 - #define _MMIO_PORT6(port, a, b, c, d, e, f) _MMIO(_PICK(port, a, b, c, d, e, f)) 157 - #define _MMIO_PORT6_LN(port, ln, a0, a1, b, c, d, e, f) \ 158 - _MMIO(_PICK(port, a0, b, c, d, e, f) + (ln * (a1 - a0))) 159 156 #define _PHY3(phy, ...) _PICK(phy, __VA_ARGS__) 160 157 #define _MMIO_PHY3(phy, a, b, c) _MMIO(_PHY3(phy, a, b, c)) 161 158 ··· 188 191 #define OTHER_CLASS 4 189 192 #define MAX_ENGINE_CLASS 4 190 193 194 + #define OTHER_GTPM_INSTANCE 1 191 195 #define MAX_ENGINE_INSTANCE 3 192 196 193 197 /* PCI config space */ ··· 302 304 #define GEN6_GRDOM_VECS (1 << 4) 303 305 #define GEN9_GRDOM_GUC (1 << 5) 304 306 #define GEN8_GRDOM_MEDIA2 (1 << 7) 307 + /* GEN11 changed all bit defs except for FULL & RENDER */ 308 + #define GEN11_GRDOM_FULL GEN6_GRDOM_FULL 309 + #define GEN11_GRDOM_RENDER GEN6_GRDOM_RENDER 310 + #define GEN11_GRDOM_BLT (1 << 2) 311 + #define GEN11_GRDOM_GUC (1 << 3) 312 + #define GEN11_GRDOM_MEDIA (1 << 5) 313 + #define GEN11_GRDOM_MEDIA2 (1 << 6) 314 + #define GEN11_GRDOM_MEDIA3 (1 << 7) 315 + #define GEN11_GRDOM_MEDIA4 (1 << 8) 316 + #define GEN11_GRDOM_VECS (1 << 13) 317 + #define GEN11_GRDOM_VECS2 (1 << 14) 305 318 306 319 #define RING_PP_DIR_BASE(engine) _MMIO((engine)->mmio_base+0x228) 307 320 #define RING_PP_DIR_BASE_READ(engine) _MMIO((engine)->mmio_base+0x518) ··· 439 430 #define VGA_CR_INDEX_CGA 0x3d4 440 431 #define VGA_CR_DATA_CGA 0x3d5 441 432 442 - /* 443 - * Instruction field definitions used by the command parser 444 - */ 445 - #define INSTR_CLIENT_SHIFT 29 446 - #define INSTR_MI_CLIENT 0x0 447 - #define INSTR_BC_CLIENT 0x2 448 - #define INSTR_RC_CLIENT 0x3 449 - #define INSTR_SUBCLIENT_SHIFT 27 450 - #define INSTR_SUBCLIENT_MASK 0x18000000 451 - #define INSTR_MEDIA_SUBCLIENT 0x2 452 - #define INSTR_26_TO_24_MASK 0x7000000 453 - #define INSTR_26_TO_24_SHIFT 24 454 - 455 - /* 456 - * Memory interface instructions used by the kernel 457 - */ 458 - #define MI_INSTR(opcode, flags) (((opcode) << 23) | (flags)) 459 - /* Many MI commands use bit 22 of the header dword for GGTT vs PPGTT */ 460 - #define MI_GLOBAL_GTT (1<<22) 461 - 462 - #define MI_NOOP MI_INSTR(0, 0) 463 - #define MI_USER_INTERRUPT MI_INSTR(0x02, 0) 464 - #define MI_WAIT_FOR_EVENT MI_INSTR(0x03, 0) 465 - #define MI_WAIT_FOR_OVERLAY_FLIP (1<<16) 466 - #define MI_WAIT_FOR_PLANE_B_FLIP (1<<6) 467 - #define MI_WAIT_FOR_PLANE_A_FLIP (1<<2) 468 - #define MI_WAIT_FOR_PLANE_A_SCANLINES (1<<1) 469 - #define MI_FLUSH MI_INSTR(0x04, 0) 470 - #define MI_READ_FLUSH (1 << 0) 471 - #define MI_EXE_FLUSH (1 << 1) 472 - #define MI_NO_WRITE_FLUSH (1 << 2) 473 - #define MI_SCENE_COUNT (1 << 3) /* just increment scene count */ 474 - #define MI_END_SCENE (1 << 4) /* flush binner and incr scene count */ 475 - #define MI_INVALIDATE_ISP (1 << 5) /* invalidate indirect state pointers */ 476 - #define MI_REPORT_HEAD MI_INSTR(0x07, 0) 477 - #define MI_ARB_ON_OFF MI_INSTR(0x08, 0) 478 - #define MI_ARB_ENABLE (1<<0) 479 - #define MI_ARB_DISABLE (0<<0) 480 - #define MI_BATCH_BUFFER_END MI_INSTR(0x0a, 0) 481 - #define MI_SUSPEND_FLUSH MI_INSTR(0x0b, 0) 482 - #define MI_SUSPEND_FLUSH_EN (1<<0) 483 - #define MI_SET_APPID MI_INSTR(0x0e, 0) 484 - #define MI_OVERLAY_FLIP MI_INSTR(0x11, 0) 485 - #define MI_OVERLAY_CONTINUE (0x0<<21) 486 - #define MI_OVERLAY_ON (0x1<<21) 487 - #define MI_OVERLAY_OFF (0x2<<21) 488 - #define MI_LOAD_SCAN_LINES_INCL MI_INSTR(0x12, 0) 489 - #define MI_DISPLAY_FLIP MI_INSTR(0x14, 2) 490 - #define MI_DISPLAY_FLIP_I915 MI_INSTR(0x14, 1) 491 - #define MI_DISPLAY_FLIP_PLANE(n) ((n) << 20) 492 - /* IVB has funny definitions for which plane to flip. */ 493 - #define MI_DISPLAY_FLIP_IVB_PLANE_A (0 << 19) 494 - #define MI_DISPLAY_FLIP_IVB_PLANE_B (1 << 19) 495 - #define MI_DISPLAY_FLIP_IVB_SPRITE_A (2 << 19) 496 - #define MI_DISPLAY_FLIP_IVB_SPRITE_B (3 << 19) 497 - #define MI_DISPLAY_FLIP_IVB_PLANE_C (4 << 19) 498 - #define MI_DISPLAY_FLIP_IVB_SPRITE_C (5 << 19) 499 - /* SKL ones */ 500 - #define MI_DISPLAY_FLIP_SKL_PLANE_1_A (0 << 8) 501 - #define MI_DISPLAY_FLIP_SKL_PLANE_1_B (1 << 8) 502 - #define MI_DISPLAY_FLIP_SKL_PLANE_1_C (2 << 8) 503 - #define MI_DISPLAY_FLIP_SKL_PLANE_2_A (4 << 8) 504 - #define MI_DISPLAY_FLIP_SKL_PLANE_2_B (5 << 8) 505 - #define MI_DISPLAY_FLIP_SKL_PLANE_2_C (6 << 8) 506 - #define MI_DISPLAY_FLIP_SKL_PLANE_3_A (7 << 8) 507 - #define MI_DISPLAY_FLIP_SKL_PLANE_3_B (8 << 8) 508 - #define MI_DISPLAY_FLIP_SKL_PLANE_3_C (9 << 8) 509 - #define MI_SEMAPHORE_MBOX MI_INSTR(0x16, 1) /* gen6, gen7 */ 510 - #define MI_SEMAPHORE_GLOBAL_GTT (1<<22) 511 - #define MI_SEMAPHORE_UPDATE (1<<21) 512 - #define MI_SEMAPHORE_COMPARE (1<<20) 513 - #define MI_SEMAPHORE_REGISTER (1<<18) 514 - #define MI_SEMAPHORE_SYNC_VR (0<<16) /* RCS wait for VCS (RVSYNC) */ 515 - #define MI_SEMAPHORE_SYNC_VER (1<<16) /* RCS wait for VECS (RVESYNC) */ 516 - #define MI_SEMAPHORE_SYNC_BR (2<<16) /* RCS wait for BCS (RBSYNC) */ 517 - #define MI_SEMAPHORE_SYNC_BV (0<<16) /* VCS wait for BCS (VBSYNC) */ 518 - #define MI_SEMAPHORE_SYNC_VEV (1<<16) /* VCS wait for VECS (VVESYNC) */ 519 - #define MI_SEMAPHORE_SYNC_RV (2<<16) /* VCS wait for RCS (VRSYNC) */ 520 - #define MI_SEMAPHORE_SYNC_RB (0<<16) /* BCS wait for RCS (BRSYNC) */ 521 - #define MI_SEMAPHORE_SYNC_VEB (1<<16) /* BCS wait for VECS (BVESYNC) */ 522 - #define MI_SEMAPHORE_SYNC_VB (2<<16) /* BCS wait for VCS (BVSYNC) */ 523 - #define MI_SEMAPHORE_SYNC_BVE (0<<16) /* VECS wait for BCS (VEBSYNC) */ 524 - #define MI_SEMAPHORE_SYNC_VVE (1<<16) /* VECS wait for VCS (VEVSYNC) */ 525 - #define MI_SEMAPHORE_SYNC_RVE (2<<16) /* VECS wait for RCS (VERSYNC) */ 526 - #define MI_SEMAPHORE_SYNC_INVALID (3<<16) 527 - #define MI_SEMAPHORE_SYNC_MASK (3<<16) 528 - #define MI_SET_CONTEXT MI_INSTR(0x18, 0) 529 - #define MI_MM_SPACE_GTT (1<<8) 530 - #define MI_MM_SPACE_PHYSICAL (0<<8) 531 - #define MI_SAVE_EXT_STATE_EN (1<<3) 532 - #define MI_RESTORE_EXT_STATE_EN (1<<2) 533 - #define MI_FORCE_RESTORE (1<<1) 534 - #define MI_RESTORE_INHIBIT (1<<0) 535 - #define HSW_MI_RS_SAVE_STATE_EN (1<<3) 536 - #define HSW_MI_RS_RESTORE_STATE_EN (1<<2) 537 - #define MI_SEMAPHORE_SIGNAL MI_INSTR(0x1b, 0) /* GEN8+ */ 538 - #define MI_SEMAPHORE_TARGET(engine) ((engine)<<15) 539 - #define MI_SEMAPHORE_WAIT MI_INSTR(0x1c, 2) /* GEN8+ */ 540 - #define MI_SEMAPHORE_POLL (1<<15) 541 - #define MI_SEMAPHORE_SAD_GTE_SDD (1<<12) 542 - #define MI_STORE_DWORD_IMM MI_INSTR(0x20, 1) 543 - #define MI_STORE_DWORD_IMM_GEN4 MI_INSTR(0x20, 2) 544 - #define MI_MEM_VIRTUAL (1 << 22) /* 945,g33,965 */ 545 - #define MI_USE_GGTT (1 << 22) /* g4x+ */ 546 - #define MI_STORE_DWORD_INDEX MI_INSTR(0x21, 1) 547 - #define MI_STORE_DWORD_INDEX_SHIFT 2 548 - /* Official intel docs are somewhat sloppy concerning MI_LOAD_REGISTER_IMM: 549 - * - Always issue a MI_NOOP _before_ the MI_LOAD_REGISTER_IMM - otherwise hw 550 - * simply ignores the register load under certain conditions. 551 - * - One can actually load arbitrary many arbitrary registers: Simply issue x 552 - * address/value pairs. Don't overdue it, though, x <= 2^4 must hold! 553 - */ 554 - #define MI_LOAD_REGISTER_IMM(x) MI_INSTR(0x22, 2*(x)-1) 555 - #define MI_LRI_FORCE_POSTED (1<<12) 556 - #define MI_STORE_REGISTER_MEM MI_INSTR(0x24, 1) 557 - #define MI_STORE_REGISTER_MEM_GEN8 MI_INSTR(0x24, 2) 558 - #define MI_SRM_LRM_GLOBAL_GTT (1<<22) 559 - #define MI_FLUSH_DW MI_INSTR(0x26, 1) /* for GEN6 */ 560 - #define MI_FLUSH_DW_STORE_INDEX (1<<21) 561 - #define MI_INVALIDATE_TLB (1<<18) 562 - #define MI_FLUSH_DW_OP_STOREDW (1<<14) 563 - #define MI_FLUSH_DW_OP_MASK (3<<14) 564 - #define MI_FLUSH_DW_NOTIFY (1<<8) 565 - #define MI_INVALIDATE_BSD (1<<7) 566 - #define MI_FLUSH_DW_USE_GTT (1<<2) 567 - #define MI_FLUSH_DW_USE_PPGTT (0<<2) 568 - #define MI_LOAD_REGISTER_MEM MI_INSTR(0x29, 1) 569 - #define MI_LOAD_REGISTER_MEM_GEN8 MI_INSTR(0x29, 2) 570 - #define MI_BATCH_BUFFER MI_INSTR(0x30, 1) 571 - #define MI_BATCH_NON_SECURE (1) 572 - /* for snb/ivb/vlv this also means "batch in ppgtt" when ppgtt is enabled. */ 573 - #define MI_BATCH_NON_SECURE_I965 (1<<8) 574 - #define MI_BATCH_PPGTT_HSW (1<<8) 575 - #define MI_BATCH_NON_SECURE_HSW (1<<13) 576 - #define MI_BATCH_BUFFER_START MI_INSTR(0x31, 0) 577 - #define MI_BATCH_GTT (2<<6) /* aliased with (1<<7) on gen4 */ 578 - #define MI_BATCH_BUFFER_START_GEN8 MI_INSTR(0x31, 1) 579 - #define MI_BATCH_RESOURCE_STREAMER (1<<10) 580 - 581 433 #define MI_PREDICATE_SRC0 _MMIO(0x2400) 582 434 #define MI_PREDICATE_SRC0_UDW _MMIO(0x2400 + 4) 583 435 #define MI_PREDICATE_SRC1 _MMIO(0x2408) ··· 447 577 #define MI_PREDICATE_RESULT_2 _MMIO(0x2214) 448 578 #define LOWER_SLICE_ENABLED (1<<0) 449 579 #define LOWER_SLICE_DISABLED (0<<0) 450 - 451 - /* 452 - * 3D instructions used by the kernel 453 - */ 454 - #define GFX_INSTR(opcode, flags) ((0x3 << 29) | ((opcode) << 24) | (flags)) 455 - 456 - #define GEN9_MEDIA_POOL_STATE ((0x3 << 29) | (0x2 << 27) | (0x5 << 16) | 4) 457 - #define GEN9_MEDIA_POOL_ENABLE (1 << 31) 458 - #define GFX_OP_RASTER_RULES ((0x3<<29)|(0x7<<24)) 459 - #define GFX_OP_SCISSOR ((0x3<<29)|(0x1c<<24)|(0x10<<19)) 460 - #define SC_UPDATE_SCISSOR (0x1<<1) 461 - #define SC_ENABLE_MASK (0x1<<0) 462 - #define SC_ENABLE (0x1<<0) 463 - #define GFX_OP_LOAD_INDIRECT ((0x3<<29)|(0x1d<<24)|(0x7<<16)) 464 - #define GFX_OP_SCISSOR_INFO ((0x3<<29)|(0x1d<<24)|(0x81<<16)|(0x1)) 465 - #define SCI_YMIN_MASK (0xffff<<16) 466 - #define SCI_XMIN_MASK (0xffff<<0) 467 - #define SCI_YMAX_MASK (0xffff<<16) 468 - #define SCI_XMAX_MASK (0xffff<<0) 469 - #define GFX_OP_SCISSOR_ENABLE ((0x3<<29)|(0x1c<<24)|(0x10<<19)) 470 - #define GFX_OP_SCISSOR_RECT ((0x3<<29)|(0x1d<<24)|(0x81<<16)|1) 471 - #define GFX_OP_COLOR_FACTOR ((0x3<<29)|(0x1d<<24)|(0x1<<16)|0x0) 472 - #define GFX_OP_STIPPLE ((0x3<<29)|(0x1d<<24)|(0x83<<16)) 473 - #define GFX_OP_MAP_INFO ((0x3<<29)|(0x1d<<24)|0x4) 474 - #define GFX_OP_DESTBUFFER_VARS ((0x3<<29)|(0x1d<<24)|(0x85<<16)|0x0) 475 - #define GFX_OP_DESTBUFFER_INFO ((0x3<<29)|(0x1d<<24)|(0x8e<<16)|1) 476 - #define GFX_OP_DRAWRECT_INFO ((0x3<<29)|(0x1d<<24)|(0x80<<16)|(0x3)) 477 - #define GFX_OP_DRAWRECT_INFO_I965 ((0x7900<<16)|0x2) 478 - 479 - #define COLOR_BLT_CMD (2<<29 | 0x40<<22 | (5-2)) 480 - #define SRC_COPY_BLT_CMD ((2<<29)|(0x43<<22)|4) 481 - #define XY_SRC_COPY_BLT_CMD ((2<<29)|(0x53<<22)|6) 482 - #define XY_MONO_SRC_COPY_IMM_BLT ((2<<29)|(0x71<<22)|5) 483 - #define BLT_WRITE_A (2<<20) 484 - #define BLT_WRITE_RGB (1<<20) 485 - #define BLT_WRITE_RGBA (BLT_WRITE_RGB | BLT_WRITE_A) 486 - #define BLT_DEPTH_8 (0<<24) 487 - #define BLT_DEPTH_16_565 (1<<24) 488 - #define BLT_DEPTH_16_1555 (2<<24) 489 - #define BLT_DEPTH_32 (3<<24) 490 - #define BLT_ROP_SRC_COPY (0xcc<<16) 491 - #define BLT_ROP_COLOR_COPY (0xf0<<16) 492 - #define XY_SRC_COPY_BLT_SRC_TILED (1<<15) /* 965+ only */ 493 - #define XY_SRC_COPY_BLT_DST_TILED (1<<11) /* 965+ only */ 494 - #define CMD_OP_DISPLAYBUFFER_INFO ((0x0<<29)|(0x14<<23)|2) 495 - #define ASYNC_FLIP (1<<22) 496 - #define DISPLAY_PLANE_A (0<<20) 497 - #define DISPLAY_PLANE_B (1<<20) 498 - #define GFX_OP_PIPE_CONTROL(len) ((0x3<<29)|(0x3<<27)|(0x2<<24)|((len)-2)) 499 - #define PIPE_CONTROL_FLUSH_L3 (1<<27) 500 - #define PIPE_CONTROL_GLOBAL_GTT_IVB (1<<24) /* gen7+ */ 501 - #define PIPE_CONTROL_MMIO_WRITE (1<<23) 502 - #define PIPE_CONTROL_STORE_DATA_INDEX (1<<21) 503 - #define PIPE_CONTROL_CS_STALL (1<<20) 504 - #define PIPE_CONTROL_TLB_INVALIDATE (1<<18) 505 - #define PIPE_CONTROL_MEDIA_STATE_CLEAR (1<<16) 506 - #define PIPE_CONTROL_QW_WRITE (1<<14) 507 - #define PIPE_CONTROL_POST_SYNC_OP_MASK (3<<14) 508 - #define PIPE_CONTROL_DEPTH_STALL (1<<13) 509 - #define PIPE_CONTROL_WRITE_FLUSH (1<<12) 510 - #define PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH (1<<12) /* gen6+ */ 511 - #define PIPE_CONTROL_INSTRUCTION_CACHE_INVALIDATE (1<<11) /* MBZ on Ironlake */ 512 - #define PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE (1<<10) /* GM45+ only */ 513 - #define PIPE_CONTROL_INDIRECT_STATE_DISABLE (1<<9) 514 - #define PIPE_CONTROL_NOTIFY (1<<8) 515 - #define PIPE_CONTROL_FLUSH_ENABLE (1<<7) /* gen7+ */ 516 - #define PIPE_CONTROL_DC_FLUSH_ENABLE (1<<5) 517 - #define PIPE_CONTROL_VF_CACHE_INVALIDATE (1<<4) 518 - #define PIPE_CONTROL_CONST_CACHE_INVALIDATE (1<<3) 519 - #define PIPE_CONTROL_STATE_CACHE_INVALIDATE (1<<2) 520 - #define PIPE_CONTROL_STALL_AT_SCOREBOARD (1<<1) 521 - #define PIPE_CONTROL_DEPTH_CACHE_FLUSH (1<<0) 522 - #define PIPE_CONTROL_GLOBAL_GTT (1<<2) /* in addr dword */ 523 - 524 - /* 525 - * Commands used only by the command parser 526 - */ 527 - #define MI_SET_PREDICATE MI_INSTR(0x01, 0) 528 - #define MI_ARB_CHECK MI_INSTR(0x05, 0) 529 - #define MI_RS_CONTROL MI_INSTR(0x06, 0) 530 - #define MI_URB_ATOMIC_ALLOC MI_INSTR(0x09, 0) 531 - #define MI_PREDICATE MI_INSTR(0x0C, 0) 532 - #define MI_RS_CONTEXT MI_INSTR(0x0F, 0) 533 - #define MI_TOPOLOGY_FILTER MI_INSTR(0x0D, 0) 534 - #define MI_LOAD_SCAN_LINES_EXCL MI_INSTR(0x13, 0) 535 - #define MI_URB_CLEAR MI_INSTR(0x19, 0) 536 - #define MI_UPDATE_GTT MI_INSTR(0x23, 0) 537 - #define MI_CLFLUSH MI_INSTR(0x27, 0) 538 - #define MI_REPORT_PERF_COUNT MI_INSTR(0x28, 0) 539 - #define MI_REPORT_PERF_COUNT_GGTT (1<<0) 540 - #define MI_LOAD_REGISTER_REG MI_INSTR(0x2A, 0) 541 - #define MI_RS_STORE_DATA_IMM MI_INSTR(0x2B, 0) 542 - #define MI_LOAD_URB_MEM MI_INSTR(0x2C, 0) 543 - #define MI_STORE_URB_MEM MI_INSTR(0x2D, 0) 544 - #define MI_CONDITIONAL_BATCH_BUFFER_END MI_INSTR(0x36, 0) 545 - 546 - #define PIPELINE_SELECT ((0x3<<29)|(0x1<<27)|(0x1<<24)|(0x4<<16)) 547 - #define GFX_OP_3DSTATE_VF_STATISTICS ((0x3<<29)|(0x1<<27)|(0x0<<24)|(0xB<<16)) 548 - #define MEDIA_VFE_STATE ((0x3<<29)|(0x2<<27)|(0x0<<24)|(0x0<<16)) 549 - #define MEDIA_VFE_STATE_MMIO_ACCESS_MASK (0x18) 550 - #define GPGPU_OBJECT ((0x3<<29)|(0x2<<27)|(0x1<<24)|(0x4<<16)) 551 - #define GPGPU_WALKER ((0x3<<29)|(0x2<<27)|(0x1<<24)|(0x5<<16)) 552 - #define GFX_OP_3DSTATE_DX9_CONSTANTF_VS \ 553 - ((0x3<<29)|(0x3<<27)|(0x0<<24)|(0x39<<16)) 554 - #define GFX_OP_3DSTATE_DX9_CONSTANTF_PS \ 555 - ((0x3<<29)|(0x3<<27)|(0x0<<24)|(0x3A<<16)) 556 - #define GFX_OP_3DSTATE_SO_DECL_LIST \ 557 - ((0x3<<29)|(0x3<<27)|(0x1<<24)|(0x17<<16)) 558 - 559 - #define GFX_OP_3DSTATE_BINDING_TABLE_EDIT_VS \ 560 - ((0x3<<29)|(0x3<<27)|(0x0<<24)|(0x43<<16)) 561 - #define GFX_OP_3DSTATE_BINDING_TABLE_EDIT_GS \ 562 - ((0x3<<29)|(0x3<<27)|(0x0<<24)|(0x44<<16)) 563 - #define GFX_OP_3DSTATE_BINDING_TABLE_EDIT_HS \ 564 - ((0x3<<29)|(0x3<<27)|(0x0<<24)|(0x45<<16)) 565 - #define GFX_OP_3DSTATE_BINDING_TABLE_EDIT_DS \ 566 - ((0x3<<29)|(0x3<<27)|(0x0<<24)|(0x46<<16)) 567 - #define GFX_OP_3DSTATE_BINDING_TABLE_EDIT_PS \ 568 - ((0x3<<29)|(0x3<<27)|(0x0<<24)|(0x47<<16)) 569 - 570 - #define MFX_WAIT ((0x3<<29)|(0x1<<27)|(0x0<<16)) 571 - 572 - #define COLOR_BLT ((0x2<<29)|(0x40<<22)) 573 - #define SRC_COPY_BLT ((0x2<<29)|(0x43<<22)) 574 580 575 581 /* 576 582 * Registers used only by the command parser ··· 548 802 549 803 #define GEN8_OABUFFER_UDW _MMIO(0x23b4) 550 804 #define GEN8_OABUFFER _MMIO(0x2b14) 805 + #define GEN8_OABUFFER_MEM_SELECT_GGTT (1 << 0) /* 0: PPGTT, 1: GGTT */ 551 806 552 807 #define GEN7_OASTATUS1 _MMIO(0x2364) 553 808 #define GEN7_OASTATUS1_TAIL_MASK 0xffffffc0 ··· 557 810 #define GEN7_OASTATUS1_REPORT_LOST (1<<0) 558 811 559 812 #define GEN7_OASTATUS2 _MMIO(0x2368) 560 - #define GEN7_OASTATUS2_HEAD_MASK 0xffffffc0 813 + #define GEN7_OASTATUS2_HEAD_MASK 0xffffffc0 814 + #define GEN7_OASTATUS2_MEM_SELECT_GGTT (1 << 0) /* 0: PPGTT, 1: GGTT */ 561 815 562 816 #define GEN8_OASTATUS _MMIO(0x2b08) 563 817 #define GEN8_OASTATUS_OVERRUN_STATUS (1<<3) ··· 579 831 #define OABUFFER_SIZE_4M (5<<3) 580 832 #define OABUFFER_SIZE_8M (6<<3) 581 833 #define OABUFFER_SIZE_16M (7<<3) 582 - 583 - #define OA_MEM_SELECT_GGTT (1<<0) 584 834 585 835 /* 586 836 * Flexible, Aggregate EU Counter Registers. ··· 873 1127 #define GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_MASK (1 << GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_SHIFT) 874 1128 #define GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_19_2_MHZ 0 875 1129 #define GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_24_MHZ 1 1130 + #define GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_SHIFT 3 1131 + #define GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_MASK (0x7 << GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_SHIFT) 1132 + #define GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_24_MHZ 0 1133 + #define GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_19_2_MHZ 1 1134 + #define GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_38_4_MHZ 2 1135 + #define GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_25_MHZ 3 876 1136 #define GEN10_RPM_CONFIG0_CTC_SHIFT_PARAMETER_SHIFT 1 877 1137 #define GEN10_RPM_CONFIG0_CTC_SHIFT_PARAMETER_MASK (0x3 << GEN10_RPM_CONFIG0_CTC_SHIFT_PARAMETER_SHIFT) 878 1138 ··· 1700 1948 #define _CNL_PORT_PCS_DW1_LN0_C 0x162C04 1701 1949 #define _CNL_PORT_PCS_DW1_LN0_D 0x162E04 1702 1950 #define _CNL_PORT_PCS_DW1_LN0_F 0x162804 1703 - #define CNL_PORT_PCS_DW1_GRP(port) _MMIO_PORT6(port, \ 1951 + #define CNL_PORT_PCS_DW1_GRP(port) _MMIO(_PICK(port, \ 1704 1952 _CNL_PORT_PCS_DW1_GRP_AE, \ 1705 1953 _CNL_PORT_PCS_DW1_GRP_B, \ 1706 1954 _CNL_PORT_PCS_DW1_GRP_C, \ 1707 1955 _CNL_PORT_PCS_DW1_GRP_D, \ 1708 1956 _CNL_PORT_PCS_DW1_GRP_AE, \ 1709 - _CNL_PORT_PCS_DW1_GRP_F) 1710 - #define CNL_PORT_PCS_DW1_LN0(port) _MMIO_PORT6(port, \ 1957 + _CNL_PORT_PCS_DW1_GRP_F)) 1958 + 1959 + #define CNL_PORT_PCS_DW1_LN0(port) _MMIO(_PICK(port, \ 1711 1960 _CNL_PORT_PCS_DW1_LN0_AE, \ 1712 1961 _CNL_PORT_PCS_DW1_LN0_B, \ 1713 1962 _CNL_PORT_PCS_DW1_LN0_C, \ 1714 1963 _CNL_PORT_PCS_DW1_LN0_D, \ 1715 1964 _CNL_PORT_PCS_DW1_LN0_AE, \ 1716 - _CNL_PORT_PCS_DW1_LN0_F) 1965 + _CNL_PORT_PCS_DW1_LN0_F)) 1966 + #define _ICL_PORT_PCS_DW1_GRP_A 0x162604 1967 + #define _ICL_PORT_PCS_DW1_GRP_B 0x6C604 1968 + #define _ICL_PORT_PCS_DW1_LN0_A 0x162804 1969 + #define _ICL_PORT_PCS_DW1_LN0_B 0x6C804 1970 + #define ICL_PORT_PCS_DW1_GRP(port) _MMIO_PORT(port,\ 1971 + _ICL_PORT_PCS_DW1_GRP_A, \ 1972 + _ICL_PORT_PCS_DW1_GRP_B) 1973 + #define ICL_PORT_PCS_DW1_LN0(port) _MMIO_PORT(port, \ 1974 + _ICL_PORT_PCS_DW1_LN0_A, \ 1975 + _ICL_PORT_PCS_DW1_LN0_B) 1717 1976 #define COMMON_KEEPER_EN (1 << 26) 1718 1977 1719 - #define _CNL_PORT_TX_DW2_GRP_AE 0x162348 1720 - #define _CNL_PORT_TX_DW2_GRP_B 0x1623C8 1721 - #define _CNL_PORT_TX_DW2_GRP_C 0x162B48 1722 - #define _CNL_PORT_TX_DW2_GRP_D 0x162BC8 1723 - #define _CNL_PORT_TX_DW2_GRP_F 0x162A48 1724 - #define _CNL_PORT_TX_DW2_LN0_AE 0x162448 1725 - #define _CNL_PORT_TX_DW2_LN0_B 0x162648 1726 - #define _CNL_PORT_TX_DW2_LN0_C 0x162C48 1727 - #define _CNL_PORT_TX_DW2_LN0_D 0x162E48 1728 - #define _CNL_PORT_TX_DW2_LN0_F 0x162848 1729 - #define CNL_PORT_TX_DW2_GRP(port) _MMIO_PORT6(port, \ 1730 - _CNL_PORT_TX_DW2_GRP_AE, \ 1731 - _CNL_PORT_TX_DW2_GRP_B, \ 1732 - _CNL_PORT_TX_DW2_GRP_C, \ 1733 - _CNL_PORT_TX_DW2_GRP_D, \ 1734 - _CNL_PORT_TX_DW2_GRP_AE, \ 1735 - _CNL_PORT_TX_DW2_GRP_F) 1736 - #define CNL_PORT_TX_DW2_LN0(port) _MMIO_PORT6(port, \ 1737 - _CNL_PORT_TX_DW2_LN0_AE, \ 1738 - _CNL_PORT_TX_DW2_LN0_B, \ 1739 - _CNL_PORT_TX_DW2_LN0_C, \ 1740 - _CNL_PORT_TX_DW2_LN0_D, \ 1741 - _CNL_PORT_TX_DW2_LN0_AE, \ 1742 - _CNL_PORT_TX_DW2_LN0_F) 1743 - #define SWING_SEL_UPPER(x) ((x >> 3) << 15) 1978 + /* CNL Port TX registers */ 1979 + #define _CNL_PORT_TX_AE_GRP_OFFSET 0x162340 1980 + #define _CNL_PORT_TX_B_GRP_OFFSET 0x1623C0 1981 + #define _CNL_PORT_TX_C_GRP_OFFSET 0x162B40 1982 + #define _CNL_PORT_TX_D_GRP_OFFSET 0x162BC0 1983 + #define _CNL_PORT_TX_F_GRP_OFFSET 0x162A40 1984 + #define _CNL_PORT_TX_AE_LN0_OFFSET 0x162440 1985 + #define _CNL_PORT_TX_B_LN0_OFFSET 0x162640 1986 + #define _CNL_PORT_TX_C_LN0_OFFSET 0x162C40 1987 + #define _CNL_PORT_TX_D_LN0_OFFSET 0x162E40 1988 + #define _CNL_PORT_TX_F_LN0_OFFSET 0x162840 1989 + #define _CNL_PORT_TX_DW_GRP(port, dw) (_PICK((port), \ 1990 + _CNL_PORT_TX_AE_GRP_OFFSET, \ 1991 + _CNL_PORT_TX_B_GRP_OFFSET, \ 1992 + _CNL_PORT_TX_B_GRP_OFFSET, \ 1993 + _CNL_PORT_TX_D_GRP_OFFSET, \ 1994 + _CNL_PORT_TX_AE_GRP_OFFSET, \ 1995 + _CNL_PORT_TX_F_GRP_OFFSET) + \ 1996 + 4*(dw)) 1997 + #define _CNL_PORT_TX_DW_LN0(port, dw) (_PICK((port), \ 1998 + _CNL_PORT_TX_AE_LN0_OFFSET, \ 1999 + _CNL_PORT_TX_B_LN0_OFFSET, \ 2000 + _CNL_PORT_TX_B_LN0_OFFSET, \ 2001 + _CNL_PORT_TX_D_LN0_OFFSET, \ 2002 + _CNL_PORT_TX_AE_LN0_OFFSET, \ 2003 + _CNL_PORT_TX_F_LN0_OFFSET) + \ 2004 + 4*(dw)) 2005 + 2006 + #define CNL_PORT_TX_DW2_GRP(port) _MMIO(_CNL_PORT_TX_DW_GRP((port), 2)) 2007 + #define CNL_PORT_TX_DW2_LN0(port) _MMIO(_CNL_PORT_TX_DW_LN0((port), 2)) 2008 + #define _ICL_PORT_TX_DW2_GRP_A 0x162688 2009 + #define _ICL_PORT_TX_DW2_GRP_B 0x6C688 2010 + #define _ICL_PORT_TX_DW2_LN0_A 0x162888 2011 + #define _ICL_PORT_TX_DW2_LN0_B 0x6C888 2012 + #define ICL_PORT_TX_DW2_GRP(port) _MMIO_PORT(port, \ 2013 + _ICL_PORT_TX_DW2_GRP_A, \ 2014 + _ICL_PORT_TX_DW2_GRP_B) 2015 + #define ICL_PORT_TX_DW2_LN0(port) _MMIO_PORT(port, \ 2016 + _ICL_PORT_TX_DW2_LN0_A, \ 2017 + _ICL_PORT_TX_DW2_LN0_B) 2018 + #define SWING_SEL_UPPER(x) (((x) >> 3) << 15) 1744 2019 #define SWING_SEL_UPPER_MASK (1 << 15) 1745 - #define SWING_SEL_LOWER(x) ((x & 0x7) << 11) 2020 + #define SWING_SEL_LOWER(x) (((x) & 0x7) << 11) 1746 2021 #define SWING_SEL_LOWER_MASK (0x7 << 11) 1747 2022 #define RCOMP_SCALAR(x) ((x) << 0) 1748 2023 #define RCOMP_SCALAR_MASK (0xFF << 0) 1749 2024 1750 - #define _CNL_PORT_TX_DW4_GRP_AE 0x162350 1751 - #define _CNL_PORT_TX_DW4_GRP_B 0x1623D0 1752 - #define _CNL_PORT_TX_DW4_GRP_C 0x162B50 1753 - #define _CNL_PORT_TX_DW4_GRP_D 0x162BD0 1754 - #define _CNL_PORT_TX_DW4_GRP_F 0x162A50 1755 2025 #define _CNL_PORT_TX_DW4_LN0_AE 0x162450 1756 2026 #define _CNL_PORT_TX_DW4_LN1_AE 0x1624D0 1757 - #define _CNL_PORT_TX_DW4_LN0_B 0x162650 1758 - #define _CNL_PORT_TX_DW4_LN0_C 0x162C50 1759 - #define _CNL_PORT_TX_DW4_LN0_D 0x162E50 1760 - #define _CNL_PORT_TX_DW4_LN0_F 0x162850 1761 - #define CNL_PORT_TX_DW4_GRP(port) _MMIO_PORT6(port, \ 1762 - _CNL_PORT_TX_DW4_GRP_AE, \ 1763 - _CNL_PORT_TX_DW4_GRP_B, \ 1764 - _CNL_PORT_TX_DW4_GRP_C, \ 1765 - _CNL_PORT_TX_DW4_GRP_D, \ 1766 - _CNL_PORT_TX_DW4_GRP_AE, \ 1767 - _CNL_PORT_TX_DW4_GRP_F) 1768 - #define CNL_PORT_TX_DW4_LN(port, ln) _MMIO_PORT6_LN(port, ln, \ 1769 - _CNL_PORT_TX_DW4_LN0_AE, \ 1770 - _CNL_PORT_TX_DW4_LN1_AE, \ 1771 - _CNL_PORT_TX_DW4_LN0_B, \ 1772 - _CNL_PORT_TX_DW4_LN0_C, \ 1773 - _CNL_PORT_TX_DW4_LN0_D, \ 1774 - _CNL_PORT_TX_DW4_LN0_AE, \ 1775 - _CNL_PORT_TX_DW4_LN0_F) 2027 + #define CNL_PORT_TX_DW4_GRP(port) _MMIO(_CNL_PORT_TX_DW_GRP((port), 4)) 2028 + #define CNL_PORT_TX_DW4_LN0(port) _MMIO(_CNL_PORT_TX_DW_LN0((port), 4)) 2029 + #define CNL_PORT_TX_DW4_LN(port, ln) _MMIO(_CNL_PORT_TX_DW_LN0((port), 4) + \ 2030 + (ln * (_CNL_PORT_TX_DW4_LN1_AE - \ 2031 + _CNL_PORT_TX_DW4_LN0_AE))) 2032 + #define _ICL_PORT_TX_DW4_GRP_A 0x162690 2033 + #define _ICL_PORT_TX_DW4_GRP_B 0x6C690 2034 + #define _ICL_PORT_TX_DW4_LN0_A 0x162890 2035 + #define _ICL_PORT_TX_DW4_LN1_A 0x162990 2036 + #define _ICL_PORT_TX_DW4_LN0_B 0x6C890 2037 + #define ICL_PORT_TX_DW4_GRP(port) _MMIO_PORT(port, \ 2038 + _ICL_PORT_TX_DW4_GRP_A, \ 2039 + _ICL_PORT_TX_DW4_GRP_B) 2040 + #define ICL_PORT_TX_DW4_LN(port, ln) _MMIO(_PORT(port, \ 2041 + _ICL_PORT_TX_DW4_LN0_A, \ 2042 + _ICL_PORT_TX_DW4_LN0_B) + \ 2043 + (ln * (_ICL_PORT_TX_DW4_LN1_A - \ 2044 + _ICL_PORT_TX_DW4_LN0_A))) 1776 2045 #define LOADGEN_SELECT (1 << 31) 1777 2046 #define POST_CURSOR_1(x) ((x) << 12) 1778 2047 #define POST_CURSOR_1_MASK (0x3F << 12) ··· 1802 2029 #define CURSOR_COEFF(x) ((x) << 0) 1803 2030 #define CURSOR_COEFF_MASK (0x3F << 0) 1804 2031 1805 - #define _CNL_PORT_TX_DW5_GRP_AE 0x162354 1806 - #define _CNL_PORT_TX_DW5_GRP_B 0x1623D4 1807 - #define _CNL_PORT_TX_DW5_GRP_C 0x162B54 1808 - #define _CNL_PORT_TX_DW5_GRP_D 0x162BD4 1809 - #define _CNL_PORT_TX_DW5_GRP_F 0x162A54 1810 - #define _CNL_PORT_TX_DW5_LN0_AE 0x162454 1811 - #define _CNL_PORT_TX_DW5_LN0_B 0x162654 1812 - #define _CNL_PORT_TX_DW5_LN0_C 0x162C54 1813 - #define _CNL_PORT_TX_DW5_LN0_D 0x162E54 1814 - #define _CNL_PORT_TX_DW5_LN0_F 0x162854 1815 - #define CNL_PORT_TX_DW5_GRP(port) _MMIO_PORT6(port, \ 1816 - _CNL_PORT_TX_DW5_GRP_AE, \ 1817 - _CNL_PORT_TX_DW5_GRP_B, \ 1818 - _CNL_PORT_TX_DW5_GRP_C, \ 1819 - _CNL_PORT_TX_DW5_GRP_D, \ 1820 - _CNL_PORT_TX_DW5_GRP_AE, \ 1821 - _CNL_PORT_TX_DW5_GRP_F) 1822 - #define CNL_PORT_TX_DW5_LN0(port) _MMIO_PORT6(port, \ 1823 - _CNL_PORT_TX_DW5_LN0_AE, \ 1824 - _CNL_PORT_TX_DW5_LN0_B, \ 1825 - _CNL_PORT_TX_DW5_LN0_C, \ 1826 - _CNL_PORT_TX_DW5_LN0_D, \ 1827 - _CNL_PORT_TX_DW5_LN0_AE, \ 1828 - _CNL_PORT_TX_DW5_LN0_F) 2032 + #define CNL_PORT_TX_DW5_GRP(port) _MMIO(_CNL_PORT_TX_DW_GRP((port), 5)) 2033 + #define CNL_PORT_TX_DW5_LN0(port) _MMIO(_CNL_PORT_TX_DW_LN0((port), 5)) 2034 + #define _ICL_PORT_TX_DW5_GRP_A 0x162694 2035 + #define _ICL_PORT_TX_DW5_GRP_B 0x6C694 2036 + #define _ICL_PORT_TX_DW5_LN0_A 0x162894 2037 + #define _ICL_PORT_TX_DW5_LN0_B 0x6C894 2038 + #define ICL_PORT_TX_DW5_GRP(port) _MMIO_PORT(port, \ 2039 + _ICL_PORT_TX_DW5_GRP_A, \ 2040 + _ICL_PORT_TX_DW5_GRP_B) 2041 + #define ICL_PORT_TX_DW5_LN0(port) _MMIO_PORT(port, \ 2042 + _ICL_PORT_TX_DW5_LN0_A, \ 2043 + _ICL_PORT_TX_DW5_LN0_B) 1829 2044 #define TX_TRAINING_EN (1 << 31) 2045 + #define TAP2_DISABLE (1 << 30) 1830 2046 #define TAP3_DISABLE (1 << 29) 1831 2047 #define SCALING_MODE_SEL(x) ((x) << 18) 1832 2048 #define SCALING_MODE_SEL_MASK (0x7 << 18) 1833 2049 #define RTERM_SELECT(x) ((x) << 3) 1834 2050 #define RTERM_SELECT_MASK (0x7 << 3) 1835 2051 1836 - #define _CNL_PORT_TX_DW7_GRP_AE 0x16235C 1837 - #define _CNL_PORT_TX_DW7_GRP_B 0x1623DC 1838 - #define _CNL_PORT_TX_DW7_GRP_C 0x162B5C 1839 - #define _CNL_PORT_TX_DW7_GRP_D 0x162BDC 1840 - #define _CNL_PORT_TX_DW7_GRP_F 0x162A5C 1841 - #define _CNL_PORT_TX_DW7_LN0_AE 0x16245C 1842 - #define _CNL_PORT_TX_DW7_LN0_B 0x16265C 1843 - #define _CNL_PORT_TX_DW7_LN0_C 0x162C5C 1844 - #define _CNL_PORT_TX_DW7_LN0_D 0x162E5C 1845 - #define _CNL_PORT_TX_DW7_LN0_F 0x16285C 1846 - #define CNL_PORT_TX_DW7_GRP(port) _MMIO_PORT6(port, \ 1847 - _CNL_PORT_TX_DW7_GRP_AE, \ 1848 - _CNL_PORT_TX_DW7_GRP_B, \ 1849 - _CNL_PORT_TX_DW7_GRP_C, \ 1850 - _CNL_PORT_TX_DW7_GRP_D, \ 1851 - _CNL_PORT_TX_DW7_GRP_AE, \ 1852 - _CNL_PORT_TX_DW7_GRP_F) 1853 - #define CNL_PORT_TX_DW7_LN0(port) _MMIO_PORT6(port, \ 1854 - _CNL_PORT_TX_DW7_LN0_AE, \ 1855 - _CNL_PORT_TX_DW7_LN0_B, \ 1856 - _CNL_PORT_TX_DW7_LN0_C, \ 1857 - _CNL_PORT_TX_DW7_LN0_D, \ 1858 - _CNL_PORT_TX_DW7_LN0_AE, \ 1859 - _CNL_PORT_TX_DW7_LN0_F) 2052 + #define CNL_PORT_TX_DW7_GRP(port) _MMIO(_CNL_PORT_TX_DW_GRP((port), 7)) 2053 + #define CNL_PORT_TX_DW7_LN0(port) _MMIO(_CNL_PORT_TX_DW_LN0((port), 7)) 1860 2054 #define N_SCALAR(x) ((x) << 24) 1861 2055 #define N_SCALAR_MASK (0x7F << 24) 2056 + 2057 + #define _ICL_MG_PHY_PORT_LN(port, ln, ln0p1, ln0p2, ln1p1) \ 2058 + _MMIO(_PORT((port) - PORT_C, ln0p1, ln0p2) + (ln) * ((ln1p1) - (ln0p1))) 2059 + 2060 + #define _ICL_MG_TX_LINK_PARAMS_TX1LN0_PORT1 0x16812C 2061 + #define _ICL_MG_TX_LINK_PARAMS_TX1LN1_PORT1 0x16852C 2062 + #define _ICL_MG_TX_LINK_PARAMS_TX1LN0_PORT2 0x16912C 2063 + #define _ICL_MG_TX_LINK_PARAMS_TX1LN1_PORT2 0x16952C 2064 + #define _ICL_MG_TX_LINK_PARAMS_TX1LN0_PORT3 0x16A12C 2065 + #define _ICL_MG_TX_LINK_PARAMS_TX1LN1_PORT3 0x16A52C 2066 + #define _ICL_MG_TX_LINK_PARAMS_TX1LN0_PORT4 0x16B12C 2067 + #define _ICL_MG_TX_LINK_PARAMS_TX1LN1_PORT4 0x16B52C 2068 + #define ICL_PORT_MG_TX1_LINK_PARAMS(port, ln) \ 2069 + _ICL_MG_PHY_PORT_LN(port, ln, _ICL_MG_TX_LINK_PARAMS_TX1LN0_PORT1, \ 2070 + _ICL_MG_TX_LINK_PARAMS_TX1LN0_PORT2, \ 2071 + _ICL_MG_TX_LINK_PARAMS_TX1LN1_PORT1) 2072 + 2073 + #define _ICL_MG_TX_LINK_PARAMS_TX2LN0_PORT1 0x1680AC 2074 + #define _ICL_MG_TX_LINK_PARAMS_TX2LN1_PORT1 0x1684AC 2075 + #define _ICL_MG_TX_LINK_PARAMS_TX2LN0_PORT2 0x1690AC 2076 + #define _ICL_MG_TX_LINK_PARAMS_TX2LN1_PORT2 0x1694AC 2077 + #define _ICL_MG_TX_LINK_PARAMS_TX2LN0_PORT3 0x16A0AC 2078 + #define _ICL_MG_TX_LINK_PARAMS_TX2LN1_PORT3 0x16A4AC 2079 + #define _ICL_MG_TX_LINK_PARAMS_TX2LN0_PORT4 0x16B0AC 2080 + #define _ICL_MG_TX_LINK_PARAMS_TX2LN1_PORT4 0x16B4AC 2081 + #define ICL_PORT_MG_TX2_LINK_PARAMS(port, ln) \ 2082 + _ICL_MG_PHY_PORT_LN(port, ln, _ICL_MG_TX_LINK_PARAMS_TX2LN0_PORT1, \ 2083 + _ICL_MG_TX_LINK_PARAMS_TX2LN0_PORT2, \ 2084 + _ICL_MG_TX_LINK_PARAMS_TX2LN1_PORT1) 2085 + #define CRI_USE_FS32 (1 << 5) 2086 + 2087 + #define _ICL_MG_TX_PISO_READLOAD_TX1LN0_PORT1 0x16814C 2088 + #define _ICL_MG_TX_PISO_READLOAD_TX1LN1_PORT1 0x16854C 2089 + #define _ICL_MG_TX_PISO_READLOAD_TX1LN0_PORT2 0x16914C 2090 + #define _ICL_MG_TX_PISO_READLOAD_TX1LN1_PORT2 0x16954C 2091 + #define _ICL_MG_TX_PISO_READLOAD_TX1LN0_PORT3 0x16A14C 2092 + #define _ICL_MG_TX_PISO_READLOAD_TX1LN1_PORT3 0x16A54C 2093 + #define _ICL_MG_TX_PISO_READLOAD_TX1LN0_PORT4 0x16B14C 2094 + #define _ICL_MG_TX_PISO_READLOAD_TX1LN1_PORT4 0x16B54C 2095 + #define ICL_PORT_MG_TX1_PISO_READLOAD(port, ln) \ 2096 + _ICL_MG_PHY_PORT_LN(port, ln, _ICL_MG_TX_PISO_READLOAD_TX1LN0_PORT1, \ 2097 + _ICL_MG_TX_PISO_READLOAD_TX1LN0_PORT2, \ 2098 + _ICL_MG_TX_PISO_READLOAD_TX1LN1_PORT1) 2099 + 2100 + #define _ICL_MG_TX_PISO_READLOAD_TX2LN0_PORT1 0x1680CC 2101 + #define _ICL_MG_TX_PISO_READLOAD_TX2LN1_PORT1 0x1684CC 2102 + #define _ICL_MG_TX_PISO_READLOAD_TX2LN0_PORT2 0x1690CC 2103 + #define _ICL_MG_TX_PISO_READLOAD_TX2LN1_PORT2 0x1694CC 2104 + #define _ICL_MG_TX_PISO_READLOAD_TX2LN0_PORT3 0x16A0CC 2105 + #define _ICL_MG_TX_PISO_READLOAD_TX2LN1_PORT3 0x16A4CC 2106 + #define _ICL_MG_TX_PISO_READLOAD_TX2LN0_PORT4 0x16B0CC 2107 + #define _ICL_MG_TX_PISO_READLOAD_TX2LN1_PORT4 0x16B4CC 2108 + #define ICL_PORT_MG_TX2_PISO_READLOAD(port, ln) \ 2109 + _ICL_MG_PHY_PORT_LN(port, ln, _ICL_MG_TX_PISO_READLOAD_TX2LN0_PORT1, \ 2110 + _ICL_MG_TX_PISO_READLOAD_TX2LN0_PORT2, \ 2111 + _ICL_MG_TX_PISO_READLOAD_TX2LN1_PORT1) 2112 + #define CRI_CALCINIT (1 << 1) 2113 + 2114 + #define _ICL_MG_TX_SWINGCTRL_TX1LN0_PORT1 0x168148 2115 + #define _ICL_MG_TX_SWINGCTRL_TX1LN1_PORT1 0x168548 2116 + #define _ICL_MG_TX_SWINGCTRL_TX1LN0_PORT2 0x169148 2117 + #define _ICL_MG_TX_SWINGCTRL_TX1LN1_PORT2 0x169548 2118 + #define _ICL_MG_TX_SWINGCTRL_TX1LN0_PORT3 0x16A148 2119 + #define _ICL_MG_TX_SWINGCTRL_TX1LN1_PORT3 0x16A548 2120 + #define _ICL_MG_TX_SWINGCTRL_TX1LN0_PORT4 0x16B148 2121 + #define _ICL_MG_TX_SWINGCTRL_TX1LN1_PORT4 0x16B548 2122 + #define ICL_PORT_MG_TX1_SWINGCTRL(port, ln) \ 2123 + _ICL_MG_PHY_PORT_LN(port, ln, _ICL_MG_TX_SWINGCTRL_TX1LN0_PORT1, \ 2124 + _ICL_MG_TX_SWINGCTRL_TX1LN0_PORT2, \ 2125 + _ICL_MG_TX_SWINGCTRL_TX1LN1_PORT1) 2126 + 2127 + #define _ICL_MG_TX_SWINGCTRL_TX2LN0_PORT1 0x1680C8 2128 + #define _ICL_MG_TX_SWINGCTRL_TX2LN1_PORT1 0x1684C8 2129 + #define _ICL_MG_TX_SWINGCTRL_TX2LN0_PORT2 0x1690C8 2130 + #define _ICL_MG_TX_SWINGCTRL_TX2LN1_PORT2 0x1694C8 2131 + #define _ICL_MG_TX_SWINGCTRL_TX2LN0_PORT3 0x16A0C8 2132 + #define _ICL_MG_TX_SWINGCTRL_TX2LN1_PORT3 0x16A4C8 2133 + #define _ICL_MG_TX_SWINGCTRL_TX2LN0_PORT4 0x16B0C8 2134 + #define _ICL_MG_TX_SWINGCTRL_TX2LN1_PORT4 0x16B4C8 2135 + #define ICL_PORT_MG_TX2_SWINGCTRL(port, ln) \ 2136 + _ICL_MG_PHY_PORT_LN(port, ln, _ICL_MG_TX_SWINGCTRL_TX2LN0_PORT1, \ 2137 + _ICL_MG_TX_SWINGCTRL_TX2LN0_PORT2, \ 2138 + _ICL_MG_TX_SWINGCTRL_TX2LN1_PORT1) 2139 + #define CRI_TXDEEMPH_OVERRIDE_17_12(x) ((x) << 0) 2140 + #define CRI_TXDEEMPH_OVERRIDE_17_12_MASK (0x3F << 0) 2141 + 2142 + #define _ICL_MG_TX_DRVCTRL_TX1LN0_PORT1 0x168144 2143 + #define _ICL_MG_TX_DRVCTRL_TX1LN1_PORT1 0x168544 2144 + #define _ICL_MG_TX_DRVCTRL_TX1LN0_PORT2 0x169144 2145 + #define _ICL_MG_TX_DRVCTRL_TX1LN1_PORT2 0x169544 2146 + #define _ICL_MG_TX_DRVCTRL_TX1LN0_PORT3 0x16A144 2147 + #define _ICL_MG_TX_DRVCTRL_TX1LN1_PORT3 0x16A544 2148 + #define _ICL_MG_TX_DRVCTRL_TX1LN0_PORT4 0x16B144 2149 + #define _ICL_MG_TX_DRVCTRL_TX1LN1_PORT4 0x16B544 2150 + #define ICL_PORT_MG_TX1_DRVCTRL(port, ln) \ 2151 + _ICL_MG_PHY_PORT_LN(port, ln, _ICL_MG_TX_DRVCTRL_TX1LN0_PORT1, \ 2152 + _ICL_MG_TX_DRVCTRL_TX1LN0_PORT2, \ 2153 + _ICL_MG_TX_DRVCTRL_TX1LN1_PORT1) 2154 + 2155 + #define _ICL_MG_TX_DRVCTRL_TX2LN0_PORT1 0x1680C4 2156 + #define _ICL_MG_TX_DRVCTRL_TX2LN1_PORT1 0x1684C4 2157 + #define _ICL_MG_TX_DRVCTRL_TX2LN0_PORT2 0x1690C4 2158 + #define _ICL_MG_TX_DRVCTRL_TX2LN1_PORT2 0x1694C4 2159 + #define _ICL_MG_TX_DRVCTRL_TX2LN0_PORT3 0x16A0C4 2160 + #define _ICL_MG_TX_DRVCTRL_TX2LN1_PORT3 0x16A4C4 2161 + #define _ICL_MG_TX_DRVCTRL_TX2LN0_PORT4 0x16B0C4 2162 + #define _ICL_MG_TX_DRVCTRL_TX2LN1_PORT4 0x16B4C4 2163 + #define ICL_PORT_MG_TX2_DRVCTRL(port, ln) \ 2164 + _ICL_MG_PHY_PORT_LN(port, ln, _ICL_MG_TX_DRVCTRL_TX2LN0_PORT1, \ 2165 + _ICL_MG_TX_DRVCTRL_TX2LN0_PORT2, \ 2166 + _ICL_MG_TX_DRVCTRL_TX2LN1_PORT1) 2167 + #define CRI_TXDEEMPH_OVERRIDE_11_6(x) ((x) << 24) 2168 + #define CRI_TXDEEMPH_OVERRIDE_11_6_MASK (0x3F << 24) 2169 + #define CRI_TXDEEMPH_OVERRIDE_EN (1 << 22) 2170 + #define CRI_TXDEEMPH_OVERRIDE_5_0(x) ((x) << 16) 2171 + #define CRI_TXDEEMPH_OVERRIDE_5_0_MASK (0x3F << 16) 1862 2172 1863 2173 /* The spec defines this only for BXT PHY0, but lets assume that this 1864 2174 * would exist for PHY1 too if it had a second channel. ··· 2329 2473 #define GEN8_MCR_SLICE_MASK GEN8_MCR_SLICE(3) 2330 2474 #define GEN8_MCR_SUBSLICE(subslice) (((subslice) & 3) << 24) 2331 2475 #define GEN8_MCR_SUBSLICE_MASK GEN8_MCR_SUBSLICE(3) 2476 + #define GEN11_MCR_SLICE(slice) (((slice) & 0xf) << 27) 2477 + #define GEN11_MCR_SLICE_MASK GEN11_MCR_SLICE(0xf) 2478 + #define GEN11_MCR_SUBSLICE(subslice) (((subslice) & 0x7) << 24) 2479 + #define GEN11_MCR_SUBSLICE_MASK GEN11_MCR_SUBSLICE(0x7) 2332 2480 #define RING_IPEIR(base) _MMIO((base)+0x64) 2333 2481 #define RING_IPEHR(base) _MMIO((base)+0x68) 2334 2482 /* ··· 2726 2866 2727 2867 #define GEN10_EU_DISABLE3 _MMIO(0x9140) 2728 2868 #define GEN10_EU_DIS_SS_MASK 0xff 2869 + 2870 + #define GEN11_GT_VEBOX_VDBOX_DISABLE _MMIO(0x9140) 2871 + #define GEN11_GT_VDBOX_DISABLE_MASK 0xff 2872 + #define GEN11_GT_VEBOX_DISABLE_SHIFT 16 2873 + #define GEN11_GT_VEBOX_DISABLE_MASK (0xff << GEN11_GT_VEBOX_DISABLE_SHIFT) 2874 + 2875 + #define GEN11_EU_DISABLE _MMIO(0x9134) 2876 + #define GEN11_EU_DIS_MASK 0xFF 2877 + 2878 + #define GEN11_GT_SLICE_ENABLE _MMIO(0x9138) 2879 + #define GEN11_GT_S_ENA_MASK 0xFF 2880 + 2881 + #define GEN11_GT_SUBSLICE_DISABLE _MMIO(0x913C) 2729 2882 2730 2883 #define GEN6_BSD_SLEEP_PSMI_CONTROL _MMIO(0x12050) 2731 2884 #define GEN6_BSD_SLEEP_MSG_DISABLE (1 << 0) ··· 3824 3951 #define _CLKGATE_DIS_PSL_A 0x46520 3825 3952 #define _CLKGATE_DIS_PSL_B 0x46524 3826 3953 #define _CLKGATE_DIS_PSL_C 0x46528 3954 + #define DUPS1_GATING_DIS (1 << 15) 3955 + #define DUPS2_GATING_DIS (1 << 19) 3956 + #define DUPS3_GATING_DIS (1 << 23) 3827 3957 #define DPF_GATING_DIS (1 << 10) 3828 3958 #define DPF_RAM_GATING_DIS (1 << 9) 3829 3959 #define DPFR_GATING_DIS (1 << 8) ··· 4027 4151 #define EDP_PSR_IDLE_FRAME_SHIFT 0 4028 4152 4029 4153 #define EDP_PSR_AUX_CTL _MMIO(dev_priv->psr_mmio_base + 0x10) 4154 + #define EDP_PSR_AUX_CTL_TIME_OUT_MASK (3 << 26) 4155 + #define EDP_PSR_AUX_CTL_MESSAGE_SIZE_MASK (0x1f << 20) 4156 + #define EDP_PSR_AUX_CTL_PRECHARGE_2US_MASK (0xf << 16) 4157 + #define EDP_PSR_AUX_CTL_ERROR_INTERRUPT (1 << 11) 4158 + #define EDP_PSR_AUX_CTL_BIT_CLOCK_2X_MASK (0x7ff) 4159 + 4030 4160 #define EDP_PSR_AUX_DATA(i) _MMIO(dev_priv->psr_mmio_base + 0x14 + (i) * 4) /* 5 registers */ 4031 4161 4032 4162 #define EDP_PSR_STATUS _MMIO(dev_priv->psr_mmio_base + 0x40) ··· 4062 4180 #define EDP_PSR_PERF_CNT _MMIO(dev_priv->psr_mmio_base + 0x44) 4063 4181 #define EDP_PSR_PERF_CNT_MASK 0xffffff 4064 4182 4065 - #define EDP_PSR_DEBUG _MMIO(dev_priv->psr_mmio_base + 0x60) 4183 + #define EDP_PSR_DEBUG _MMIO(dev_priv->psr_mmio_base + 0x60) /* PSR_MASK on SKL+ */ 4066 4184 #define EDP_PSR_DEBUG_MASK_MAX_SLEEP (1<<28) 4067 4185 #define EDP_PSR_DEBUG_MASK_LPSP (1<<27) 4068 4186 #define EDP_PSR_DEBUG_MASK_MEMUP (1<<26) 4069 4187 #define EDP_PSR_DEBUG_MASK_HPD (1<<25) 4070 4188 #define EDP_PSR_DEBUG_MASK_DISP_REG_WRITE (1<<16) 4071 - #define EDP_PSR_DEBUG_EXIT_ON_PIXEL_UNDERRUN (1<<15) 4189 + #define EDP_PSR_DEBUG_EXIT_ON_PIXEL_UNDERRUN (1<<15) /* SKL+ */ 4072 4190 4073 4191 #define EDP_PSR2_CTL _MMIO(0x6f900) 4074 4192 #define EDP_PSR2_ENABLE (1<<31) 4075 4193 #define EDP_SU_TRACK_ENABLE (1<<30) 4194 + #define EDP_Y_COORDINATE_VALID (1<<26) /* GLK and CNL+ */ 4195 + #define EDP_Y_COORDINATE_ENABLE (1<<25) /* GLK and CNL+ */ 4076 4196 #define EDP_MAX_SU_DISABLE_TIME(t) ((t)<<20) 4077 4197 #define EDP_MAX_SU_DISABLE_TIME_MASK (0x1f<<20) 4078 4198 #define EDP_PSR2_TP2_TIME_500 (0<<8) ··· 4084 4200 #define EDP_PSR2_TP2_TIME_MASK (3<<8) 4085 4201 #define EDP_PSR2_FRAME_BEFORE_SU_SHIFT 4 4086 4202 #define EDP_PSR2_FRAME_BEFORE_SU_MASK (0xf<<4) 4087 - #define EDP_PSR2_IDLE_MASK 0xf 4088 4203 #define EDP_PSR2_FRAME_BEFORE_SU(a) ((a)<<4) 4204 + #define EDP_PSR2_IDLE_FRAME_MASK 0xf 4205 + #define EDP_PSR2_IDLE_FRAME_SHIFT 0 4089 4206 4090 4207 #define EDP_PSR2_STATUS _MMIO(0x6f940) 4091 4208 #define EDP_PSR2_STATUS_STATE_MASK (0xf<<28) ··· 5150 5265 #define DP_LINK_TRAIN_OFF (3 << 28) 5151 5266 #define DP_LINK_TRAIN_MASK (3 << 28) 5152 5267 #define DP_LINK_TRAIN_SHIFT 28 5153 - #define DP_LINK_TRAIN_PAT_3_CHV (1 << 14) 5154 - #define DP_LINK_TRAIN_MASK_CHV ((3 << 28)|(1<<14)) 5155 5268 5156 5269 /* CPT Link training mode */ 5157 5270 #define DP_LINK_TRAIN_PAT_1_CPT (0 << 8) ··· 5892 6009 #define CURSIZE _MMIO(0x700a0) /* 845/865 */ 5893 6010 #define _CUR_FBC_CTL_A 0x700a0 /* ivb+ */ 5894 6011 #define CUR_FBC_CTL_EN (1 << 31) 6012 + #define _CURASURFLIVE 0x700ac /* g4x+ */ 5895 6013 #define _CURBCNTR 0x700c0 5896 6014 #define _CURBBASE 0x700c4 5897 6015 #define _CURBPOS 0x700c8 ··· 5909 6025 #define CURBASE(pipe) _CURSOR2(pipe, _CURABASE) 5910 6026 #define CURPOS(pipe) _CURSOR2(pipe, _CURAPOS) 5911 6027 #define CUR_FBC_CTL(pipe) _CURSOR2(pipe, _CUR_FBC_CTL_A) 6028 + #define CURSURFLIVE(pipe) _CURSOR2(pipe, _CURASURFLIVE) 5912 6029 5913 6030 #define CURSOR_A_OFFSET 0x70080 5914 6031 #define CURSOR_B_OFFSET 0x700c0 ··· 6664 6779 #define PS_SCALER_MODE_MASK (3 << 28) 6665 6780 #define PS_SCALER_MODE_DYN (0 << 28) 6666 6781 #define PS_SCALER_MODE_HQ (1 << 28) 6782 + #define SKL_PS_SCALER_MODE_NV12 (2 << 28) 6783 + #define PS_SCALER_MODE_PLANAR (1 << 29) 6667 6784 #define PS_PLANE_SEL_MASK (7 << 25) 6668 6785 #define PS_PLANE_SEL(plane) (((plane) + 1) << 25) 6669 6786 #define PS_FILTER_MASK (3 << 23) ··· 7004 7117 #define GEN11_INTR_IDENTITY_REG0 _MMIO(0x190060) 7005 7118 #define GEN11_INTR_IDENTITY_REG1 _MMIO(0x190064) 7006 7119 #define GEN11_INTR_DATA_VALID (1 << 31) 7007 - #define GEN11_INTR_ENGINE_MASK (0xffff) 7120 + #define GEN11_INTR_ENGINE_CLASS(x) (((x) & GENMASK(18, 16)) >> 16) 7121 + #define GEN11_INTR_ENGINE_INSTANCE(x) (((x) & GENMASK(25, 20)) >> 20) 7122 + #define GEN11_INTR_ENGINE_INTR(x) ((x) & 0xffff) 7008 7123 7009 7124 #define GEN11_INTR_IDENTITY_REG(x) _MMIO(0x190060 + (x * 4)) 7010 7125 ··· 7086 7197 #define CHICKEN_TRANS_A 0x420c0 7087 7198 #define CHICKEN_TRANS_B 0x420c4 7088 7199 #define CHICKEN_TRANS(trans) _MMIO_TRANS(trans, CHICKEN_TRANS_A, CHICKEN_TRANS_B) 7200 + #define VSC_DATA_SEL_SOFTWARE_CONTROL (1<<25) /* GLK and CNL+ */ 7089 7201 #define DDI_TRAINING_OVERRIDE_ENABLE (1<<19) 7090 7202 #define DDI_TRAINING_OVERRIDE_VALUE (1<<18) 7091 7203 #define DDIE_TRAINING_OVERRIDE_ENABLE (1<<17) /* CHICKEN_TRANS_A only */
+53 -72
drivers/gpu/drm/i915/i915_request.c
··· 59 59 60 60 static bool i915_fence_enable_signaling(struct dma_fence *fence) 61 61 { 62 - if (i915_fence_signaled(fence)) 63 - return false; 64 - 65 - intel_engine_enable_signaling(to_request(fence), true); 66 - return !i915_fence_signaled(fence); 62 + return intel_engine_enable_signaling(to_request(fence), true); 67 63 } 68 64 69 65 static signed long i915_fence_wait(struct dma_fence *fence, ··· 207 211 if (ret) 208 212 return ret; 209 213 214 + GEM_BUG_ON(i915->gt.active_requests); 215 + 210 216 /* If the seqno wraps around, we need to clear the breadcrumb rbtree */ 211 217 for_each_engine(engine, i915, id) { 212 218 struct i915_gem_timeline *timeline; 213 219 struct intel_timeline *tl = engine->timeline; 220 + 221 + GEM_TRACE("%s seqno %d (current %d) -> %d\n", 222 + engine->name, 223 + tl->seqno, 224 + intel_engine_get_seqno(engine), 225 + seqno); 214 226 215 227 if (!i915_seqno_passed(seqno, tl->seqno)) { 216 228 /* Flush any waiters before we reuse the seqno */ ··· 255 251 return reset_all_global_seqno(i915, seqno - 1); 256 252 } 257 253 258 - static void mark_busy(struct drm_i915_private *i915) 259 - { 260 - if (i915->gt.awake) 261 - return; 262 - 263 - GEM_BUG_ON(!i915->gt.active_requests); 264 - 265 - intel_runtime_pm_get_noresume(i915); 266 - 267 - /* 268 - * It seems that the DMC likes to transition between the DC states a lot 269 - * when there are no connected displays (no active power domains) during 270 - * command submission. 271 - * 272 - * This activity has negative impact on the performance of the chip with 273 - * huge latencies observed in the interrupt handler and elsewhere. 274 - * 275 - * Work around it by grabbing a GT IRQ power domain whilst there is any 276 - * GT activity, preventing any DC state transitions. 277 - */ 278 - intel_display_power_get(i915, POWER_DOMAIN_GT_IRQ); 279 - 280 - i915->gt.awake = true; 281 - if (unlikely(++i915->gt.epoch == 0)) /* keep 0 as invalid */ 282 - i915->gt.epoch = 1; 283 - 284 - intel_enable_gt_powersave(i915); 285 - i915_update_gfx_val(i915); 286 - if (INTEL_GEN(i915) >= 6) 287 - gen6_rps_busy(i915); 288 - i915_pmu_gt_unparked(i915); 289 - 290 - intel_engines_unpark(i915); 291 - 292 - i915_queue_hangcheck(i915); 293 - 294 - queue_delayed_work(i915->wq, 295 - &i915->gt.retire_work, 296 - round_jiffies_up_relative(HZ)); 297 - } 298 - 299 254 static int reserve_engine(struct intel_engine_cs *engine) 300 255 { 301 256 struct drm_i915_private *i915 = engine->i915; ··· 272 309 } 273 310 274 311 if (!i915->gt.active_requests++) 275 - mark_busy(i915); 312 + i915_gem_unpark(i915); 276 313 277 314 return 0; 278 315 } ··· 281 318 { 282 319 struct drm_i915_private *i915 = engine->i915; 283 320 284 - if (!--i915->gt.active_requests) { 285 - /* Cancel the mark_busy() from our reserve_engine() */ 286 - GEM_BUG_ON(!i915->gt.awake); 287 - mod_delayed_work(i915->wq, 288 - &i915->gt.idle_work, 289 - msecs_to_jiffies(100)); 290 - } 321 + if (!--i915->gt.active_requests) 322 + i915_gem_park(i915); 291 323 292 324 GEM_BUG_ON(!engine->timeline->inflight_seqnos); 293 325 engine->timeline->inflight_seqnos--; ··· 316 358 * is just about to be. Either works, if we miss the last two 317 359 * noops - they are safe to be replayed on a reset. 318 360 */ 319 - tail = READ_ONCE(request->ring->tail); 361 + tail = READ_ONCE(request->tail); 320 362 } else { 321 363 tail = request->postfix; 322 364 } ··· 342 384 { 343 385 struct intel_engine_cs *engine = request->engine; 344 386 struct i915_gem_active *active, *next; 387 + 388 + GEM_TRACE("%s fence %llx:%d, global=%d, current %d\n", 389 + engine->name, 390 + request->fence.context, request->fence.seqno, 391 + request->global_seqno, 392 + intel_engine_get_seqno(engine)); 345 393 346 394 lockdep_assert_held(&request->i915->drm.struct_mutex); 347 395 GEM_BUG_ON(!i915_sw_fence_signaled(&request->submit)); ··· 450 486 return ++tl->seqno; 451 487 } 452 488 489 + static void move_to_timeline(struct i915_request *request, 490 + struct intel_timeline *timeline) 491 + { 492 + GEM_BUG_ON(request->timeline == request->engine->timeline); 493 + lockdep_assert_held(&request->engine->timeline->lock); 494 + 495 + spin_lock(&request->timeline->lock); 496 + list_move_tail(&request->link, &timeline->requests); 497 + spin_unlock(&request->timeline->lock); 498 + } 499 + 453 500 void __i915_request_submit(struct i915_request *request) 454 501 { 455 502 struct intel_engine_cs *engine = request->engine; 456 - struct intel_timeline *timeline; 457 503 u32 seqno; 504 + 505 + GEM_TRACE("%s fence %llx:%d -> global=%d, current %d\n", 506 + engine->name, 507 + request->fence.context, request->fence.seqno, 508 + engine->timeline->seqno + 1, 509 + intel_engine_get_seqno(engine)); 458 510 459 511 GEM_BUG_ON(!irqs_disabled()); 460 512 lockdep_assert_held(&engine->timeline->lock); 461 513 462 - /* Transfer from per-context onto the global per-engine timeline */ 463 - timeline = engine->timeline; 464 - GEM_BUG_ON(timeline == request->timeline); 465 514 GEM_BUG_ON(request->global_seqno); 466 515 467 - seqno = timeline_get_seqno(timeline); 516 + seqno = timeline_get_seqno(engine->timeline); 468 517 GEM_BUG_ON(!seqno); 469 518 GEM_BUG_ON(i915_seqno_passed(intel_engine_get_seqno(engine), seqno)); 470 519 ··· 491 514 engine->emit_breadcrumb(request, 492 515 request->ring->vaddr + request->postfix); 493 516 494 - spin_lock(&request->timeline->lock); 495 - list_move_tail(&request->link, &timeline->requests); 496 - spin_unlock(&request->timeline->lock); 517 + /* Transfer from per-context onto the global per-engine timeline */ 518 + move_to_timeline(request, engine->timeline); 497 519 498 520 trace_i915_request_execute(request); 499 521 ··· 515 539 void __i915_request_unsubmit(struct i915_request *request) 516 540 { 517 541 struct intel_engine_cs *engine = request->engine; 518 - struct intel_timeline *timeline; 542 + 543 + GEM_TRACE("%s fence %llx:%d <- global=%d, current %d\n", 544 + engine->name, 545 + request->fence.context, request->fence.seqno, 546 + request->global_seqno, 547 + intel_engine_get_seqno(engine)); 519 548 520 549 GEM_BUG_ON(!irqs_disabled()); 521 550 lockdep_assert_held(&engine->timeline->lock); ··· 543 562 spin_unlock(&request->lock); 544 563 545 564 /* Transfer back from the global per-engine timeline to per-context */ 546 - timeline = request->timeline; 547 - GEM_BUG_ON(timeline == engine->timeline); 548 - 549 - spin_lock(&timeline->lock); 550 - list_move(&request->link, &timeline->requests); 551 - spin_unlock(&timeline->lock); 565 + move_to_timeline(request, request->timeline); 552 566 553 567 /* 554 568 * We don't need to wake_up any waiters on request->execute, they ··· 976 1000 u32 *cs; 977 1001 int err; 978 1002 1003 + GEM_TRACE("%s fence %llx:%d\n", 1004 + engine->name, request->fence.context, request->fence.seqno); 1005 + 979 1006 lockdep_assert_held(&request->i915->drm.struct_mutex); 980 1007 trace_i915_request_add(request); 981 1008 ··· 1185 1206 1186 1207 static bool __i915_wait_request_check_and_reset(struct i915_request *request) 1187 1208 { 1188 - if (likely(!i915_reset_handoff(&request->i915->gpu_error))) 1209 + struct i915_gpu_error *error = &request->i915->gpu_error; 1210 + 1211 + if (likely(!i915_reset_handoff(error))) 1189 1212 return false; 1190 1213 1191 1214 __set_current_state(TASK_RUNNING); 1192 - i915_reset(request->i915, 0); 1215 + i915_reset(request->i915, error->stalled_mask, error->reason); 1193 1216 return true; 1194 1217 } 1195 1218
+2 -2
drivers/gpu/drm/i915/i915_utils.h
··· 40 40 #undef WARN_ON_ONCE 41 41 #define WARN_ON_ONCE(x) WARN_ONCE((x), "%s", "WARN_ON_ONCE(" __stringify(x) ")") 42 42 43 - #define MISSING_CASE(x) WARN(1, "Missing switch case (%lu) in %s\n", \ 44 - (long)(x), __func__) 43 + #define MISSING_CASE(x) WARN(1, "Missing case (%s == %ld)\n", \ 44 + __stringify(x), (long)(x)) 45 45 46 46 #if GCC_VERSION >= 70000 47 47 #define add_overflows(A, B) \
+15 -4
drivers/gpu/drm/i915/intel_atomic.c
··· 227 227 struct intel_crtc_scaler_state *scaler_state = 228 228 &crtc_state->scaler_state; 229 229 struct drm_atomic_state *drm_state = crtc_state->base.state; 230 + struct intel_atomic_state *intel_state = to_intel_atomic_state(drm_state); 230 231 int num_scalers_need; 231 232 int i, j; 232 233 ··· 305 304 continue; 306 305 } 307 306 308 - plane_state = intel_atomic_get_existing_plane_state(drm_state, 309 - intel_plane); 307 + plane_state = intel_atomic_get_new_plane_state(intel_state, 308 + intel_plane); 310 309 scaler_id = &plane_state->scaler_id; 311 310 } 312 311 ··· 329 328 } 330 329 331 330 /* set scaler mode */ 332 - if (IS_GEMINILAKE(dev_priv) || IS_CANNONLAKE(dev_priv)) { 333 - scaler_state->scalers[*scaler_id].mode = 0; 331 + if ((INTEL_GEN(dev_priv) >= 9) && 332 + plane_state && plane_state->base.fb && 333 + plane_state->base.fb->format->format == 334 + DRM_FORMAT_NV12) { 335 + if (INTEL_GEN(dev_priv) == 9 && 336 + !IS_GEMINILAKE(dev_priv) && 337 + !IS_SKYLAKE(dev_priv)) 338 + scaler_state->scalers[*scaler_id].mode = 339 + SKL_PS_SCALER_MODE_NV12; 340 + else 341 + scaler_state->scalers[*scaler_id].mode = 342 + PS_SCALER_MODE_PLANAR; 334 343 } else if (num_scalers_need == 1 && intel_crtc->pipe != PIPE_C) { 335 344 /* 336 345 * when only 1 scaler is in use on either pipe A or B,
+4 -13
drivers/gpu/drm/i915/intel_bios.c
··· 1215 1215 { 1216 1216 struct child_device_config *it, *child = NULL; 1217 1217 struct ddi_vbt_port_info *info = &dev_priv->vbt.ddi_port_info[port]; 1218 - uint8_t hdmi_level_shift; 1219 1218 int i, j; 1220 1219 bool is_dvi, is_hdmi, is_dp, is_edp, is_crt; 1221 - uint8_t aux_channel, ddc_pin; 1222 1220 /* Each DDI port can have more than one value on the "DVO Port" field, 1223 1221 * so look for all the possible values for each port. 1224 1222 */ ··· 1253 1255 if (!child) 1254 1256 return; 1255 1257 1256 - aux_channel = child->aux_channel; 1257 - 1258 1258 is_dvi = child->device_type & DEVICE_TYPE_TMDS_DVI_SIGNALING; 1259 1259 is_dp = child->device_type & DEVICE_TYPE_DISPLAYPORT_OUTPUT; 1260 1260 is_crt = child->device_type & DEVICE_TYPE_ANALOG_OUTPUT; 1261 1261 is_hdmi = is_dvi && (child->device_type & DEVICE_TYPE_NOT_HDMI_OUTPUT) == 0; 1262 1262 is_edp = is_dp && (child->device_type & DEVICE_TYPE_INTERNAL_CONNECTOR); 1263 - 1264 - if (port == PORT_A && is_dvi) { 1265 - DRM_DEBUG_KMS("VBT claims port A supports DVI%s, ignoring\n", 1266 - is_hdmi ? "/HDMI" : ""); 1267 - is_dvi = false; 1268 - is_hdmi = false; 1269 - } 1270 1263 1271 1264 if (port == PORT_A && is_dvi) { 1272 1265 DRM_DEBUG_KMS("VBT claims port A supports DVI%s, ignoring\n", ··· 1291 1302 DRM_DEBUG_KMS("Port %c is internal DP\n", port_name(port)); 1292 1303 1293 1304 if (is_dvi) { 1305 + u8 ddc_pin; 1306 + 1294 1307 ddc_pin = map_ddc_pin(dev_priv, child->ddc_pin); 1295 1308 if (intel_gmbus_is_valid_pin(dev_priv, ddc_pin)) { 1296 1309 info->alternate_ddc_pin = ddc_pin; ··· 1305 1314 } 1306 1315 1307 1316 if (is_dp) { 1308 - info->alternate_aux_channel = aux_channel; 1317 + info->alternate_aux_channel = child->aux_channel; 1309 1318 1310 1319 sanitize_aux_ch(dev_priv, port); 1311 1320 } 1312 1321 1313 1322 if (bdb_version >= 158) { 1314 1323 /* The VBT HDMI level shift values match the table we have. */ 1315 - hdmi_level_shift = child->hdmi_level_shifter_value; 1324 + u8 hdmi_level_shift = child->hdmi_level_shifter_value; 1316 1325 DRM_DEBUG_KMS("VBT HDMI level shift for port %c: %d\n", 1317 1326 port_name(port), 1318 1327 hdmi_level_shift);
+13 -8
drivers/gpu/drm/i915/intel_breadcrumbs.c
··· 730 730 list_add(&request->signaling.link, &iter->signaling.link); 731 731 } 732 732 733 - void intel_engine_enable_signaling(struct i915_request *request, bool wakeup) 733 + bool intel_engine_enable_signaling(struct i915_request *request, bool wakeup) 734 734 { 735 735 struct intel_engine_cs *engine = request->engine; 736 736 struct intel_breadcrumbs *b = &engine->breadcrumbs; 737 + struct intel_wait *wait = &request->signaling.wait; 737 738 u32 seqno; 738 739 739 740 /* ··· 751 750 752 751 seqno = i915_request_global_seqno(request); 753 752 if (!seqno) /* will be enabled later upon execution */ 754 - return; 753 + return true; 755 754 756 - GEM_BUG_ON(request->signaling.wait.seqno); 757 - request->signaling.wait.tsk = b->signaler; 758 - request->signaling.wait.request = request; 759 - request->signaling.wait.seqno = seqno; 755 + GEM_BUG_ON(wait->seqno); 756 + wait->tsk = b->signaler; 757 + wait->request = request; 758 + wait->seqno = seqno; 760 759 761 760 /* 762 761 * Add ourselves into the list of waiters, but registering our ··· 769 768 */ 770 769 spin_lock(&b->rb_lock); 771 770 insert_signal(b, request, seqno); 772 - wakeup &= __intel_engine_add_wait(engine, &request->signaling.wait); 771 + wakeup &= __intel_engine_add_wait(engine, wait); 773 772 spin_unlock(&b->rb_lock); 774 773 775 - if (wakeup) 774 + if (wakeup) { 776 775 wake_up_process(b->signaler); 776 + return !intel_wait_complete(wait); 777 + } 778 + 779 + return true; 777 780 } 778 781 779 782 void intel_engine_cancel_signaling(struct i915_request *request)
+141 -13
drivers/gpu/drm/i915/intel_ddi.c
··· 493 493 { 0x2, 0x7F, 0x3F, 0x00, 0x00 }, /* 400 400 0.0 */ 494 494 }; 495 495 496 + struct icl_combo_phy_ddi_buf_trans { 497 + u32 dw2_swing_select; 498 + u32 dw2_swing_scalar; 499 + u32 dw4_scaling; 500 + }; 501 + 502 + /* Voltage Swing Programming for VccIO 0.85V for DP */ 503 + static const struct icl_combo_phy_ddi_buf_trans icl_combo_phy_ddi_translations_dp_hdmi_0_85V[] = { 504 + /* Voltage mV db */ 505 + { 0x2, 0x98, 0x0018 }, /* 400 0.0 */ 506 + { 0x2, 0x98, 0x3015 }, /* 400 3.5 */ 507 + { 0x2, 0x98, 0x6012 }, /* 400 6.0 */ 508 + { 0x2, 0x98, 0x900F }, /* 400 9.5 */ 509 + { 0xB, 0x70, 0x0018 }, /* 600 0.0 */ 510 + { 0xB, 0x70, 0x3015 }, /* 600 3.5 */ 511 + { 0xB, 0x70, 0x6012 }, /* 600 6.0 */ 512 + { 0x5, 0x00, 0x0018 }, /* 800 0.0 */ 513 + { 0x5, 0x00, 0x3015 }, /* 800 3.5 */ 514 + { 0x6, 0x98, 0x0018 }, /* 1200 0.0 */ 515 + }; 516 + 517 + /* FIXME - After table is updated in Bspec */ 518 + /* Voltage Swing Programming for VccIO 0.85V for eDP */ 519 + static const struct icl_combo_phy_ddi_buf_trans icl_combo_phy_ddi_translations_edp_0_85V[] = { 520 + /* Voltage mV db */ 521 + { 0x0, 0x00, 0x00 }, /* 200 0.0 */ 522 + { 0x0, 0x00, 0x00 }, /* 200 1.5 */ 523 + { 0x0, 0x00, 0x00 }, /* 200 4.0 */ 524 + { 0x0, 0x00, 0x00 }, /* 200 6.0 */ 525 + { 0x0, 0x00, 0x00 }, /* 250 0.0 */ 526 + { 0x0, 0x00, 0x00 }, /* 250 1.5 */ 527 + { 0x0, 0x00, 0x00 }, /* 250 4.0 */ 528 + { 0x0, 0x00, 0x00 }, /* 300 0.0 */ 529 + { 0x0, 0x00, 0x00 }, /* 300 1.5 */ 530 + { 0x0, 0x00, 0x00 }, /* 350 0.0 */ 531 + }; 532 + 533 + /* Voltage Swing Programming for VccIO 0.95V for DP */ 534 + static const struct icl_combo_phy_ddi_buf_trans icl_combo_phy_ddi_translations_dp_hdmi_0_95V[] = { 535 + /* Voltage mV db */ 536 + { 0x2, 0x98, 0x0018 }, /* 400 0.0 */ 537 + { 0x2, 0x98, 0x3015 }, /* 400 3.5 */ 538 + { 0x2, 0x98, 0x6012 }, /* 400 6.0 */ 539 + { 0x2, 0x98, 0x900F }, /* 400 9.5 */ 540 + { 0x4, 0x98, 0x0018 }, /* 600 0.0 */ 541 + { 0x4, 0x98, 0x3015 }, /* 600 3.5 */ 542 + { 0x4, 0x98, 0x6012 }, /* 600 6.0 */ 543 + { 0x5, 0x76, 0x0018 }, /* 800 0.0 */ 544 + { 0x5, 0x76, 0x3015 }, /* 800 3.5 */ 545 + { 0x6, 0x98, 0x0018 }, /* 1200 0.0 */ 546 + }; 547 + 548 + /* FIXME - After table is updated in Bspec */ 549 + /* Voltage Swing Programming for VccIO 0.95V for eDP */ 550 + static const struct icl_combo_phy_ddi_buf_trans icl_combo_phy_ddi_translations_edp_0_95V[] = { 551 + /* Voltage mV db */ 552 + { 0x0, 0x00, 0x00 }, /* 200 0.0 */ 553 + { 0x0, 0x00, 0x00 }, /* 200 1.5 */ 554 + { 0x0, 0x00, 0x00 }, /* 200 4.0 */ 555 + { 0x0, 0x00, 0x00 }, /* 200 6.0 */ 556 + { 0x0, 0x00, 0x00 }, /* 250 0.0 */ 557 + { 0x0, 0x00, 0x00 }, /* 250 1.5 */ 558 + { 0x0, 0x00, 0x00 }, /* 250 4.0 */ 559 + { 0x0, 0x00, 0x00 }, /* 300 0.0 */ 560 + { 0x0, 0x00, 0x00 }, /* 300 1.5 */ 561 + { 0x0, 0x00, 0x00 }, /* 350 0.0 */ 562 + }; 563 + 564 + /* Voltage Swing Programming for VccIO 1.05V for DP */ 565 + static const struct icl_combo_phy_ddi_buf_trans icl_combo_phy_ddi_translations_dp_hdmi_1_05V[] = { 566 + /* Voltage mV db */ 567 + { 0x2, 0x98, 0x0018 }, /* 400 0.0 */ 568 + { 0x2, 0x98, 0x3015 }, /* 400 3.5 */ 569 + { 0x2, 0x98, 0x6012 }, /* 400 6.0 */ 570 + { 0x2, 0x98, 0x900F }, /* 400 9.5 */ 571 + { 0x4, 0x98, 0x0018 }, /* 600 0.0 */ 572 + { 0x4, 0x98, 0x3015 }, /* 600 3.5 */ 573 + { 0x4, 0x98, 0x6012 }, /* 600 6.0 */ 574 + { 0x5, 0x71, 0x0018 }, /* 800 0.0 */ 575 + { 0x5, 0x71, 0x3015 }, /* 800 3.5 */ 576 + { 0x6, 0x98, 0x0018 }, /* 1200 0.0 */ 577 + }; 578 + 579 + /* FIXME - After table is updated in Bspec */ 580 + /* Voltage Swing Programming for VccIO 1.05V for eDP */ 581 + static const struct icl_combo_phy_ddi_buf_trans icl_combo_phy_ddi_translations_edp_1_05V[] = { 582 + /* Voltage mV db */ 583 + { 0x0, 0x00, 0x00 }, /* 200 0.0 */ 584 + { 0x0, 0x00, 0x00 }, /* 200 1.5 */ 585 + { 0x0, 0x00, 0x00 }, /* 200 4.0 */ 586 + { 0x0, 0x00, 0x00 }, /* 200 6.0 */ 587 + { 0x0, 0x00, 0x00 }, /* 250 0.0 */ 588 + { 0x0, 0x00, 0x00 }, /* 250 1.5 */ 589 + { 0x0, 0x00, 0x00 }, /* 250 4.0 */ 590 + { 0x0, 0x00, 0x00 }, /* 300 0.0 */ 591 + { 0x0, 0x00, 0x00 }, /* 300 1.5 */ 592 + { 0x0, 0x00, 0x00 }, /* 350 0.0 */ 593 + }; 594 + 595 + struct icl_mg_phy_ddi_buf_trans { 596 + u32 cri_txdeemph_override_5_0; 597 + u32 cri_txdeemph_override_11_6; 598 + u32 cri_txdeemph_override_17_12; 599 + }; 600 + 601 + static const struct icl_mg_phy_ddi_buf_trans icl_mg_phy_ddi_translations[] = { 602 + /* Voltage swing pre-emphasis */ 603 + { 0x0, 0x1B, 0x00 }, /* 0 0 */ 604 + { 0x0, 0x23, 0x08 }, /* 0 1 */ 605 + { 0x0, 0x2D, 0x12 }, /* 0 2 */ 606 + { 0x0, 0x00, 0x00 }, /* 0 3 */ 607 + { 0x0, 0x23, 0x00 }, /* 1 0 */ 608 + { 0x0, 0x2B, 0x09 }, /* 1 1 */ 609 + { 0x0, 0x2E, 0x11 }, /* 1 2 */ 610 + { 0x0, 0x2F, 0x00 }, /* 2 0 */ 611 + { 0x0, 0x33, 0x0C }, /* 2 1 */ 612 + { 0x0, 0x00, 0x00 }, /* 3 0 */ 613 + }; 614 + 496 615 static const struct ddi_buf_trans * 497 616 bdw_get_buf_trans_edp(struct drm_i915_private *dev_priv, int *n_entries) 498 617 { ··· 994 875 995 876 static uint32_t hsw_pll_to_ddi_pll_sel(const struct intel_shared_dpll *pll) 996 877 { 997 - switch (pll->id) { 878 + switch (pll->info->id) { 998 879 case DPLL_ID_WRPLL1: 999 880 return PORT_CLK_SEL_WRPLL1; 1000 881 case DPLL_ID_WRPLL2: ··· 1008 889 case DPLL_ID_LCPLL_2700: 1009 890 return PORT_CLK_SEL_LCPLL_2700; 1010 891 default: 1011 - MISSING_CASE(pll->id); 892 + MISSING_CASE(pll->info->id); 1012 893 return PORT_CLK_SEL_NONE; 1013 894 } 1014 895 } ··· 2250 2131 /* Configure DPCLKA_CFGCR0 to map the DPLL to the DDI. */ 2251 2132 val = I915_READ(DPCLKA_CFGCR0); 2252 2133 val &= ~DPCLKA_CFGCR0_DDI_CLK_SEL_MASK(port); 2253 - val |= DPCLKA_CFGCR0_DDI_CLK_SEL(pll->id, port); 2134 + val |= DPCLKA_CFGCR0_DDI_CLK_SEL(pll->info->id, port); 2254 2135 I915_WRITE(DPCLKA_CFGCR0, val); 2255 2136 2256 2137 /* ··· 2267 2148 2268 2149 val &= ~(DPLL_CTRL2_DDI_CLK_OFF(port) | 2269 2150 DPLL_CTRL2_DDI_CLK_SEL_MASK(port)); 2270 - val |= (DPLL_CTRL2_DDI_CLK_SEL(pll->id, port) | 2151 + val |= (DPLL_CTRL2_DDI_CLK_SEL(pll->info->id, port) | 2271 2152 DPLL_CTRL2_DDI_SEL_OVERRIDE(port)); 2272 2153 2273 2154 I915_WRITE(DPLL_CTRL2, val); ··· 2324 2205 intel_prepare_dp_ddi_buffers(encoder, crtc_state); 2325 2206 2326 2207 intel_ddi_init_dp_buf_reg(encoder); 2327 - intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON); 2208 + if (!is_mst) 2209 + intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON); 2328 2210 intel_dp_start_link_train(intel_dp); 2329 2211 if (port != PORT_A || INTEL_GEN(dev_priv) >= 9) 2330 2212 intel_dp_stop_link_train(intel_dp); ··· 2423 2303 struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); 2424 2304 struct intel_digital_port *dig_port = enc_to_dig_port(&encoder->base); 2425 2305 struct intel_dp *intel_dp = &dig_port->dp; 2306 + bool is_mst = intel_crtc_has_type(old_crtc_state, 2307 + INTEL_OUTPUT_DP_MST); 2426 2308 2427 2309 /* 2428 2310 * Power down sink before disabling the port, otherwise we end 2429 2311 * up getting interrupts from the sink on detecting link loss. 2430 2312 */ 2431 - intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF); 2313 + if (!is_mst) 2314 + intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF); 2432 2315 2433 2316 intel_disable_ddi_buf(encoder); 2434 2317 ··· 2547 2424 { 2548 2425 struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); 2549 2426 struct intel_digital_port *dig_port = enc_to_dig_port(&encoder->base); 2427 + struct drm_connector *connector = conn_state->connector; 2550 2428 enum port port = encoder->port; 2551 2429 2552 - intel_hdmi_handle_sink_scrambling(encoder, 2553 - conn_state->connector, 2554 - crtc_state->hdmi_high_tmds_clock_ratio, 2555 - crtc_state->hdmi_scrambling); 2430 + if (!intel_hdmi_handle_sink_scrambling(encoder, connector, 2431 + crtc_state->hdmi_high_tmds_clock_ratio, 2432 + crtc_state->hdmi_scrambling)) 2433 + DRM_ERROR("[CONNECTOR:%d:%s] Failed to configure sink scrambling/TMDS bit clock ratio\n", 2434 + connector->base.id, connector->name); 2556 2435 2557 2436 /* Display WA #1143: skl,kbl,cfl */ 2558 2437 if (IS_GEN9_BC(dev_priv)) { ··· 2645 2520 const struct intel_crtc_state *old_crtc_state, 2646 2521 const struct drm_connector_state *old_conn_state) 2647 2522 { 2523 + struct drm_connector *connector = old_conn_state->connector; 2524 + 2648 2525 if (old_crtc_state->has_audio) 2649 2526 intel_audio_codec_disable(encoder, 2650 2527 old_crtc_state, old_conn_state); 2651 2528 2652 - intel_hdmi_handle_sink_scrambling(encoder, 2653 - old_conn_state->connector, 2654 - false, false); 2529 + if (!intel_hdmi_handle_sink_scrambling(encoder, connector, 2530 + false, false)) 2531 + DRM_DEBUG_KMS("[CONNECTOR:%d:%s] Failed to reset sink scrambling/TMDS bit clock ratio\n", 2532 + connector->base.id, connector->name); 2655 2533 } 2656 2534 2657 2535 static void intel_disable_ddi(struct intel_encoder *encoder,
+147 -20
drivers/gpu/drm/i915/intel_device_info.c
··· 83 83 { 84 84 int s; 85 85 86 - drm_printf(p, "slice mask: %04x\n", sseu->slice_mask); 87 - drm_printf(p, "slice total: %u\n", hweight8(sseu->slice_mask)); 86 + drm_printf(p, "slice total: %u, mask=%04x\n", 87 + hweight8(sseu->slice_mask), sseu->slice_mask); 88 88 drm_printf(p, "subslice total: %u\n", sseu_subslice_total(sseu)); 89 - for (s = 0; s < ARRAY_SIZE(sseu->subslice_mask); s++) { 90 - drm_printf(p, "slice%d %u subslices mask=%04x\n", 89 + for (s = 0; s < sseu->max_slices; s++) { 90 + drm_printf(p, "slice%d: %u subslices, mask=%04x\n", 91 91 s, hweight8(sseu->subslice_mask[s]), 92 92 sseu->subslice_mask[s]); 93 93 } ··· 156 156 total += hweight8(sseu->eu_mask[i]); 157 157 158 158 return total; 159 + } 160 + 161 + static void gen11_sseu_info_init(struct drm_i915_private *dev_priv) 162 + { 163 + struct sseu_dev_info *sseu = &mkwrite_device_info(dev_priv)->sseu; 164 + u8 s_en; 165 + u32 ss_en, ss_en_mask; 166 + u8 eu_en; 167 + int s; 168 + 169 + sseu->max_slices = 1; 170 + sseu->max_subslices = 8; 171 + sseu->max_eus_per_subslice = 8; 172 + 173 + s_en = I915_READ(GEN11_GT_SLICE_ENABLE) & GEN11_GT_S_ENA_MASK; 174 + ss_en = ~I915_READ(GEN11_GT_SUBSLICE_DISABLE); 175 + ss_en_mask = BIT(sseu->max_subslices) - 1; 176 + eu_en = ~(I915_READ(GEN11_EU_DISABLE) & GEN11_EU_DIS_MASK); 177 + 178 + for (s = 0; s < sseu->max_slices; s++) { 179 + if (s_en & BIT(s)) { 180 + int ss_idx = sseu->max_subslices * s; 181 + int ss; 182 + 183 + sseu->slice_mask |= BIT(s); 184 + sseu->subslice_mask[s] = (ss_en >> ss_idx) & ss_en_mask; 185 + for (ss = 0; ss < sseu->max_subslices; ss++) { 186 + if (sseu->subslice_mask[s] & BIT(ss)) 187 + sseu_set_eus(sseu, s, ss, eu_en); 188 + } 189 + } 190 + } 191 + sseu->eu_per_subslice = hweight8(eu_en); 192 + sseu->eu_total = compute_eu_total(sseu); 193 + 194 + /* ICL has no power gating restrictions. */ 195 + sseu->has_slice_pg = 1; 196 + sseu->has_subslice_pg = 1; 197 + sseu->has_eu_pg = 1; 159 198 } 160 199 161 200 static void gen10_sseu_info_init(struct drm_i915_private *dev_priv) ··· 596 557 return base_freq + frac_freq; 597 558 } 598 559 560 + static u32 gen10_get_crystal_clock_freq(struct drm_i915_private *dev_priv, 561 + u32 rpm_config_reg) 562 + { 563 + u32 f19_2_mhz = 19200; 564 + u32 f24_mhz = 24000; 565 + u32 crystal_clock = (rpm_config_reg & 566 + GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_MASK) >> 567 + GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_SHIFT; 568 + 569 + switch (crystal_clock) { 570 + case GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_19_2_MHZ: 571 + return f19_2_mhz; 572 + case GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_24_MHZ: 573 + return f24_mhz; 574 + default: 575 + MISSING_CASE(crystal_clock); 576 + return 0; 577 + } 578 + } 579 + 580 + static u32 gen11_get_crystal_clock_freq(struct drm_i915_private *dev_priv, 581 + u32 rpm_config_reg) 582 + { 583 + u32 f19_2_mhz = 19200; 584 + u32 f24_mhz = 24000; 585 + u32 f25_mhz = 25000; 586 + u32 f38_4_mhz = 38400; 587 + u32 crystal_clock = (rpm_config_reg & 588 + GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_MASK) >> 589 + GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_SHIFT; 590 + 591 + switch (crystal_clock) { 592 + case GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_24_MHZ: 593 + return f24_mhz; 594 + case GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_19_2_MHZ: 595 + return f19_2_mhz; 596 + case GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_38_4_MHZ: 597 + return f38_4_mhz; 598 + case GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_25_MHZ: 599 + return f25_mhz; 600 + default: 601 + MISSING_CASE(crystal_clock); 602 + return 0; 603 + } 604 + } 605 + 599 606 static u32 read_timestamp_frequency(struct drm_i915_private *dev_priv) 600 607 { 601 608 u32 f12_5_mhz = 12500; ··· 682 597 } 683 598 684 599 return freq; 685 - } else if (INTEL_GEN(dev_priv) <= 10) { 600 + } else if (INTEL_GEN(dev_priv) <= 11) { 686 601 u32 ctc_reg = I915_READ(CTC_MODE); 687 602 u32 freq = 0; 688 - u32 rpm_config_reg = 0; 689 603 690 604 /* First figure out the reference frequency. There are 2 ways 691 605 * we can compute the frequency, either through the ··· 694 610 if ((ctc_reg & CTC_SOURCE_PARAMETER_MASK) == CTC_SOURCE_DIVIDE_LOGIC) { 695 611 freq = read_reference_ts_freq(dev_priv); 696 612 } else { 697 - u32 crystal_clock; 613 + u32 rpm_config_reg = I915_READ(RPM_CONFIG0); 698 614 699 - rpm_config_reg = I915_READ(RPM_CONFIG0); 700 - crystal_clock = (rpm_config_reg & 701 - GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_MASK) >> 702 - GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_SHIFT; 703 - switch (crystal_clock) { 704 - case GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_19_2_MHZ: 705 - freq = f19_2_mhz; 706 - break; 707 - case GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_24_MHZ: 708 - freq = f24_mhz; 709 - break; 710 - } 615 + if (INTEL_GEN(dev_priv) <= 10) 616 + freq = gen10_get_crystal_clock_freq(dev_priv, 617 + rpm_config_reg); 618 + else 619 + freq = gen11_get_crystal_clock_freq(dev_priv, 620 + rpm_config_reg); 711 621 712 622 /* Now figure out how the command stream's timestamp 713 623 * register increments from this frequency (it might ··· 846 768 broadwell_sseu_info_init(dev_priv); 847 769 else if (INTEL_GEN(dev_priv) == 9) 848 770 gen9_sseu_info_init(dev_priv); 849 - else if (INTEL_GEN(dev_priv) >= 10) 771 + else if (INTEL_GEN(dev_priv) == 10) 850 772 gen10_sseu_info_init(dev_priv); 773 + else if (INTEL_INFO(dev_priv)->gen >= 11) 774 + gen11_sseu_info_init(dev_priv); 851 775 852 776 /* Initialize command stream timestamp frequency */ 853 777 info->cs_timestamp_frequency_khz = read_timestamp_frequency(dev_priv); ··· 859 779 struct drm_printer *p) 860 780 { 861 781 drm_printf(p, "scheduler: %x\n", caps->scheduler); 782 + } 783 + 784 + /* 785 + * Determine which engines are fused off in our particular hardware. Since the 786 + * fuse register is in the blitter powerwell, we need forcewake to be ready at 787 + * this point (but later we need to prune the forcewake domains for engines that 788 + * are indeed fused off). 789 + */ 790 + void intel_device_info_init_mmio(struct drm_i915_private *dev_priv) 791 + { 792 + struct intel_device_info *info = mkwrite_device_info(dev_priv); 793 + u8 vdbox_disable, vebox_disable; 794 + u32 media_fuse; 795 + int i; 796 + 797 + if (INTEL_GEN(dev_priv) < 11) 798 + return; 799 + 800 + media_fuse = I915_READ(GEN11_GT_VEBOX_VDBOX_DISABLE); 801 + 802 + vdbox_disable = media_fuse & GEN11_GT_VDBOX_DISABLE_MASK; 803 + vebox_disable = (media_fuse & GEN11_GT_VEBOX_DISABLE_MASK) >> 804 + GEN11_GT_VEBOX_DISABLE_SHIFT; 805 + 806 + DRM_DEBUG_DRIVER("vdbox disable: %04x\n", vdbox_disable); 807 + for (i = 0; i < I915_MAX_VCS; i++) { 808 + if (!HAS_ENGINE(dev_priv, _VCS(i))) 809 + continue; 810 + 811 + if (!(BIT(i) & vdbox_disable)) 812 + continue; 813 + 814 + info->ring_mask &= ~ENGINE_MASK(_VCS(i)); 815 + DRM_DEBUG_DRIVER("vcs%u fused off\n", i); 816 + } 817 + 818 + DRM_DEBUG_DRIVER("vebox disable: %04x\n", vebox_disable); 819 + for (i = 0; i < I915_MAX_VECS; i++) { 820 + if (!HAS_ENGINE(dev_priv, _VECS(i))) 821 + continue; 822 + 823 + if (!(BIT(i) & vebox_disable)) 824 + continue; 825 + 826 + info->ring_mask &= ~ENGINE_MASK(_VECS(i)); 827 + DRM_DEBUG_DRIVER("vecs%u fused off\n", i); 828 + } 862 829 }
+3 -1
drivers/gpu/drm/i915/intel_device_info.h
··· 114 114 func(has_ipc); 115 115 116 116 #define GEN_MAX_SLICES (6) /* CNL upper bound */ 117 - #define GEN_MAX_SUBSLICES (7) 117 + #define GEN_MAX_SUBSLICES (8) /* ICL upper bound */ 118 118 119 119 struct sseu_dev_info { 120 120 u8 slice_mask; ··· 246 246 struct drm_printer *p); 247 247 void intel_device_info_dump_topology(const struct sseu_dev_info *sseu, 248 248 struct drm_printer *p); 249 + 250 + void intel_device_info_init_mmio(struct drm_i915_private *dev_priv); 249 251 250 252 void intel_driver_caps_print(const struct intel_driver_caps *caps, 251 253 struct drm_printer *p);
+171 -80
drivers/gpu/drm/i915/intel_display.c
··· 488 488 .p2 = { .p2_slow = 1, .p2_fast = 20 }, 489 489 }; 490 490 491 + static void 492 + skl_wa_clkgate(struct drm_i915_private *dev_priv, int pipe, bool enable) 493 + { 494 + if (IS_SKYLAKE(dev_priv)) 495 + return; 496 + 497 + if (enable) 498 + I915_WRITE(CLKGATE_DIS_PSL(pipe), 499 + DUPS1_GATING_DIS | DUPS2_GATING_DIS); 500 + else 501 + I915_WRITE(CLKGATE_DIS_PSL(pipe), 502 + I915_READ(CLKGATE_DIS_PSL(pipe)) & 503 + ~(DUPS1_GATING_DIS | DUPS2_GATING_DIS)); 504 + } 505 + 491 506 static bool 492 507 needs_modeset(const struct drm_crtc_state *state) 493 508 { ··· 2672 2657 } 2673 2658 } 2674 2659 2675 - static int skl_format_to_fourcc(int format, bool rgb_order, bool alpha) 2660 + int skl_format_to_fourcc(int format, bool rgb_order, bool alpha) 2676 2661 { 2677 2662 switch (format) { 2678 2663 case PLANE_CTL_FORMAT_RGB_565: 2679 2664 return DRM_FORMAT_RGB565; 2665 + case PLANE_CTL_FORMAT_NV12: 2666 + return DRM_FORMAT_NV12; 2680 2667 default: 2681 2668 case PLANE_CTL_FORMAT_XRGB_8888: 2682 2669 if (rgb_order) { ··· 2875 2858 return; 2876 2859 } 2877 2860 2861 + obj = intel_fb_obj(fb); 2862 + intel_fb_obj_flush(obj, ORIGIN_DIRTYFB); 2863 + 2878 2864 plane_state->src_x = 0; 2879 2865 plane_state->src_y = 0; 2880 2866 plane_state->src_w = fb->width << 16; ··· 2891 2871 intel_state->base.src = drm_plane_state_src(plane_state); 2892 2872 intel_state->base.dst = drm_plane_state_dest(plane_state); 2893 2873 2894 - obj = intel_fb_obj(fb); 2895 2874 if (i915_gem_object_is_tiled(obj)) 2896 2875 dev_priv->preserve_bios_swizzle = true; 2897 2876 ··· 3483 3464 return PLANE_CTL_FORMAT_YUV422 | PLANE_CTL_YUV422_UYVY; 3484 3465 case DRM_FORMAT_VYUY: 3485 3466 return PLANE_CTL_FORMAT_YUV422 | PLANE_CTL_YUV422_VYUY; 3467 + case DRM_FORMAT_NV12: 3468 + return PLANE_CTL_FORMAT_NV12; 3486 3469 default: 3487 3470 MISSING_CASE(pixel_format); 3488 3471 } ··· 3632 3611 plane_color_ctl |= glk_plane_color_ctl_alpha(fb->format->format); 3633 3612 3634 3613 if (intel_format_is_yuv(fb->format->format)) { 3614 + if (fb->format->format == DRM_FORMAT_NV12) { 3615 + plane_color_ctl |= 3616 + PLANE_COLOR_CSC_MODE_YUV709_TO_RGB709; 3617 + goto out; 3618 + } 3635 3619 if (plane_state->base.color_encoding == DRM_COLOR_YCBCR_BT709) 3636 3620 plane_color_ctl |= PLANE_COLOR_CSC_MODE_YUV709_TO_RGB709; 3637 3621 else ··· 3645 3619 if (plane_state->base.color_range == DRM_COLOR_YCBCR_FULL_RANGE) 3646 3620 plane_color_ctl |= PLANE_COLOR_YUV_RANGE_CORRECTION_DISABLE; 3647 3621 } 3648 - 3622 + out: 3649 3623 return plane_color_ctl; 3650 3624 } 3651 3625 ··· 3701 3675 struct drm_atomic_state *state; 3702 3676 int ret; 3703 3677 3704 - 3705 3678 /* reset doesn't touch the display */ 3706 3679 if (!i915_modparams.force_reset_modeset_test && 3707 3680 !gpu_reset_clobbers_display(dev_priv)) ··· 3754 3729 { 3755 3730 struct drm_device *dev = &dev_priv->drm; 3756 3731 struct drm_modeset_acquire_ctx *ctx = &dev_priv->reset_ctx; 3757 - struct drm_atomic_state *state = dev_priv->modeset_restore_state; 3732 + struct drm_atomic_state *state; 3758 3733 int ret; 3759 3734 3760 3735 /* reset doesn't touch the display */ 3761 - if (!i915_modparams.force_reset_modeset_test && 3762 - !gpu_reset_clobbers_display(dev_priv)) 3736 + if (!test_bit(I915_RESET_MODESET, &dev_priv->gpu_error.flags)) 3763 3737 return; 3764 3738 3739 + state = fetch_and_zero(&dev_priv->modeset_restore_state); 3765 3740 if (!state) 3766 3741 goto unlock; 3767 - 3768 - dev_priv->modeset_restore_state = NULL; 3769 3742 3770 3743 /* reset doesn't touch the display */ 3771 3744 if (!gpu_reset_clobbers_display(dev_priv)) { ··· 4726 4703 static int 4727 4704 skl_update_scaler(struct intel_crtc_state *crtc_state, bool force_detach, 4728 4705 unsigned int scaler_user, int *scaler_id, 4729 - int src_w, int src_h, int dst_w, int dst_h) 4706 + int src_w, int src_h, int dst_w, int dst_h, 4707 + bool plane_scaler_check, 4708 + uint32_t pixel_format) 4730 4709 { 4731 4710 struct intel_crtc_scaler_state *scaler_state = 4732 4711 &crtc_state->scaler_state; ··· 4745 4720 * GTT mapping), hence no need to account for rotation here. 4746 4721 */ 4747 4722 need_scaling = src_w != dst_w || src_h != dst_h; 4723 + 4724 + if (plane_scaler_check) 4725 + if (pixel_format == DRM_FORMAT_NV12) 4726 + need_scaling = true; 4748 4727 4749 4728 if (crtc_state->ycbcr420 && scaler_user == SKL_CRTC_INDEX) 4750 4729 need_scaling = true; ··· 4789 4760 return 0; 4790 4761 } 4791 4762 4763 + if (plane_scaler_check && pixel_format == DRM_FORMAT_NV12 && 4764 + (src_h < SKL_MIN_YUV_420_SRC_H || (src_w % 4) != 0 || 4765 + (src_h % 4) != 0)) { 4766 + DRM_DEBUG_KMS("NV12: src dimensions not met\n"); 4767 + return -EINVAL; 4768 + } 4769 + 4792 4770 /* range checks */ 4793 4771 if (src_w < SKL_MIN_SRC_W || src_h < SKL_MIN_SRC_H || 4794 - dst_w < SKL_MIN_DST_W || dst_h < SKL_MIN_DST_H || 4795 - 4796 - src_w > SKL_MAX_SRC_W || src_h > SKL_MAX_SRC_H || 4797 - dst_w > SKL_MAX_DST_W || dst_h > SKL_MAX_DST_H) { 4772 + dst_w < SKL_MIN_DST_W || dst_h < SKL_MIN_DST_H || 4773 + (IS_GEN11(dev_priv) && 4774 + (src_w > ICL_MAX_SRC_W || src_h > ICL_MAX_SRC_H || 4775 + dst_w > ICL_MAX_DST_W || dst_h > ICL_MAX_DST_H)) || 4776 + (!IS_GEN11(dev_priv) && 4777 + (src_w > SKL_MAX_SRC_W || src_h > SKL_MAX_SRC_H || 4778 + dst_w > SKL_MAX_DST_W || dst_h > SKL_MAX_DST_H))) { 4798 4779 DRM_DEBUG_KMS("scaler_user index %u.%u: src %ux%u dst %ux%u " 4799 4780 "size is out of scaler range\n", 4800 4781 intel_crtc->pipe, scaler_user, src_w, src_h, dst_w, dst_h); ··· 4835 4796 const struct drm_display_mode *adjusted_mode = &state->base.adjusted_mode; 4836 4797 4837 4798 return skl_update_scaler(state, !state->base.active, SKL_CRTC_INDEX, 4838 - &state->scaler_state.scaler_id, 4839 - state->pipe_src_w, state->pipe_src_h, 4840 - adjusted_mode->crtc_hdisplay, adjusted_mode->crtc_vdisplay); 4799 + &state->scaler_state.scaler_id, 4800 + state->pipe_src_w, state->pipe_src_h, 4801 + adjusted_mode->crtc_hdisplay, 4802 + adjusted_mode->crtc_vdisplay, false, 0); 4841 4803 } 4842 4804 4843 4805 /** ··· 4867 4827 drm_rect_width(&plane_state->base.src) >> 16, 4868 4828 drm_rect_height(&plane_state->base.src) >> 16, 4869 4829 drm_rect_width(&plane_state->base.dst), 4870 - drm_rect_height(&plane_state->base.dst)); 4830 + drm_rect_height(&plane_state->base.dst), 4831 + fb ? true : false, fb ? fb->format->format : 0); 4871 4832 4872 4833 if (ret || plane_state->scaler_id < 0) 4873 4834 return ret; ··· 4894 4853 case DRM_FORMAT_YVYU: 4895 4854 case DRM_FORMAT_UYVY: 4896 4855 case DRM_FORMAT_VYUY: 4856 + case DRM_FORMAT_NV12: 4897 4857 break; 4898 4858 default: 4899 4859 DRM_DEBUG_KMS("[PLANE:%d:%s] FB:%d unsupported scaling format 0x%x\n", ··· 5141 5099 static void intel_post_plane_update(struct intel_crtc_state *old_crtc_state) 5142 5100 { 5143 5101 struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->base.crtc); 5102 + struct drm_device *dev = crtc->base.dev; 5103 + struct drm_i915_private *dev_priv = to_i915(dev); 5144 5104 struct drm_atomic_state *old_state = old_crtc_state->base.state; 5145 5105 struct intel_crtc_state *pipe_config = 5146 5106 intel_atomic_get_new_crtc_state(to_intel_atomic_state(old_state), 5147 5107 crtc); 5148 5108 struct drm_plane *primary = crtc->base.primary; 5149 - struct drm_plane_state *old_pri_state = 5150 - drm_atomic_get_existing_plane_state(old_state, primary); 5109 + struct drm_plane_state *old_primary_state = 5110 + drm_atomic_get_old_plane_state(old_state, primary); 5151 5111 5152 5112 intel_frontbuffer_flip(to_i915(crtc->base.dev), pipe_config->fb_bits); 5153 5113 ··· 5159 5115 if (hsw_post_update_enable_ips(old_crtc_state, pipe_config)) 5160 5116 hsw_enable_ips(pipe_config); 5161 5117 5162 - if (old_pri_state) { 5163 - struct intel_plane_state *primary_state = 5164 - intel_atomic_get_new_plane_state(to_intel_atomic_state(old_state), 5165 - to_intel_plane(primary)); 5166 - struct intel_plane_state *old_primary_state = 5167 - to_intel_plane_state(old_pri_state); 5118 + if (old_primary_state) { 5119 + struct drm_plane_state *new_primary_state = 5120 + drm_atomic_get_new_plane_state(old_state, primary); 5121 + struct drm_framebuffer *fb = new_primary_state->fb; 5168 5122 5169 5123 intel_fbc_post_update(crtc); 5170 5124 5171 - if (primary_state->base.visible && 5125 + if (new_primary_state->visible && 5172 5126 (needs_modeset(&pipe_config->base) || 5173 - !old_primary_state->base.visible)) 5127 + !old_primary_state->visible)) 5174 5128 intel_post_enable_primary(&crtc->base, pipe_config); 5129 + 5130 + /* Display WA 827 */ 5131 + if ((INTEL_GEN(dev_priv) == 9 && !IS_GEMINILAKE(dev_priv)) || 5132 + IS_CANNONLAKE(dev_priv)) { 5133 + if (fb && fb->format->format == DRM_FORMAT_NV12) 5134 + skl_wa_clkgate(dev_priv, crtc->pipe, false); 5135 + } 5136 + 5175 5137 } 5176 5138 } 5177 5139 ··· 5189 5139 struct drm_i915_private *dev_priv = to_i915(dev); 5190 5140 struct drm_atomic_state *old_state = old_crtc_state->base.state; 5191 5141 struct drm_plane *primary = crtc->base.primary; 5192 - struct drm_plane_state *old_pri_state = 5193 - drm_atomic_get_existing_plane_state(old_state, primary); 5142 + struct drm_plane_state *old_primary_state = 5143 + drm_atomic_get_old_plane_state(old_state, primary); 5194 5144 bool modeset = needs_modeset(&pipe_config->base); 5195 5145 struct intel_atomic_state *old_intel_state = 5196 5146 to_intel_atomic_state(old_state); ··· 5198 5148 if (hsw_pre_update_disable_ips(old_crtc_state, pipe_config)) 5199 5149 hsw_disable_ips(old_crtc_state); 5200 5150 5201 - if (old_pri_state) { 5202 - struct intel_plane_state *primary_state = 5151 + if (old_primary_state) { 5152 + struct intel_plane_state *new_primary_state = 5203 5153 intel_atomic_get_new_plane_state(old_intel_state, 5204 5154 to_intel_plane(primary)); 5205 - struct intel_plane_state *old_primary_state = 5206 - to_intel_plane_state(old_pri_state); 5155 + struct drm_framebuffer *fb = new_primary_state->base.fb; 5207 5156 5208 - intel_fbc_pre_update(crtc, pipe_config, primary_state); 5157 + /* Display WA 827 */ 5158 + if ((INTEL_GEN(dev_priv) == 9 && !IS_GEMINILAKE(dev_priv)) || 5159 + IS_CANNONLAKE(dev_priv)) { 5160 + if (fb && fb->format->format == DRM_FORMAT_NV12) 5161 + skl_wa_clkgate(dev_priv, crtc->pipe, true); 5162 + } 5163 + 5164 + intel_fbc_pre_update(crtc, pipe_config, new_primary_state); 5209 5165 /* 5210 5166 * Gen2 reports pipe underruns whenever all planes are disabled. 5211 5167 * So disable underrun reporting before all the planes get disabled. 5212 5168 */ 5213 - if (IS_GEN2(dev_priv) && old_primary_state->base.visible && 5214 - (modeset || !primary_state->base.visible)) 5169 + if (IS_GEN2(dev_priv) && old_primary_state->visible && 5170 + (modeset || !new_primary_state->base.visible)) 5215 5171 intel_set_cpu_fifo_underrun_reporting(dev_priv, crtc->pipe, false); 5216 5172 } 5217 5173 ··· 8822 8766 intel_get_shared_dpll_by_id(dev_priv, pll_id); 8823 8767 pll = pipe_config->shared_dpll; 8824 8768 8825 - WARN_ON(!pll->funcs.get_hw_state(dev_priv, pll, 8826 - &pipe_config->dpll_hw_state)); 8769 + WARN_ON(!pll->info->funcs->get_hw_state(dev_priv, pll, 8770 + &pipe_config->dpll_hw_state)); 8827 8771 8828 8772 tmp = pipe_config->dpll_hw_state.dpll; 8829 8773 pipe_config->pixel_multiplier = ··· 9299 9243 9300 9244 pll = pipe_config->shared_dpll; 9301 9245 if (pll) { 9302 - WARN_ON(!pll->funcs.get_hw_state(dev_priv, pll, 9303 - &pipe_config->dpll_hw_state)); 9246 + WARN_ON(!pll->info->funcs->get_hw_state(dev_priv, pll, 9247 + &pipe_config->dpll_hw_state)); 9304 9248 } 9305 9249 9306 9250 /* ··· 10831 10775 struct drm_connector_state *connector_state; 10832 10776 struct intel_encoder *encoder; 10833 10777 10834 - connector_state = drm_atomic_get_existing_connector_state(state, connector); 10778 + connector_state = drm_atomic_get_new_connector_state(state, connector); 10835 10779 if (!connector_state) 10836 10780 connector_state = connector->state; 10837 10781 ··· 11701 11645 11702 11646 memset(&dpll_hw_state, 0, sizeof(dpll_hw_state)); 11703 11647 11704 - DRM_DEBUG_KMS("%s\n", pll->name); 11648 + DRM_DEBUG_KMS("%s\n", pll->info->name); 11705 11649 11706 - active = pll->funcs.get_hw_state(dev_priv, pll, &dpll_hw_state); 11650 + active = pll->info->funcs->get_hw_state(dev_priv, pll, &dpll_hw_state); 11707 11651 11708 - if (!(pll->flags & INTEL_DPLL_ALWAYS_ON)) { 11652 + if (!(pll->info->flags & INTEL_DPLL_ALWAYS_ON)) { 11709 11653 I915_STATE_WARN(!pll->on && pll->active_mask, 11710 11654 "pll in active use but not on in sw tracking\n"); 11711 11655 I915_STATE_WARN(pll->on && !pll->active_mask, ··· 12194 12138 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 12195 12139 struct intel_crtc_state *pipe_config = to_intel_crtc_state(new_crtc_state); 12196 12140 bool modeset = needs_modeset(new_crtc_state); 12141 + struct intel_plane_state *new_plane_state = 12142 + intel_atomic_get_new_plane_state(to_intel_atomic_state(state), 12143 + to_intel_plane(crtc->primary)); 12197 12144 12198 12145 if (modeset) { 12199 12146 update_scanline_offset(intel_crtc); 12200 12147 dev_priv->display.crtc_enable(pipe_config, state); 12148 + 12149 + /* vblanks work again, re-enable pipe CRC. */ 12150 + intel_crtc_enable_pipe_crc(intel_crtc); 12201 12151 } else { 12202 12152 intel_pre_plane_update(to_intel_crtc_state(old_crtc_state), 12203 12153 pipe_config); 12204 12154 } 12205 12155 12206 - if (drm_atomic_get_existing_plane_state(state, crtc->primary)) { 12207 - intel_fbc_enable( 12208 - intel_crtc, pipe_config, 12209 - to_intel_plane_state(crtc->primary->state)); 12210 - } 12156 + if (new_plane_state) 12157 + intel_fbc_enable(intel_crtc, pipe_config, new_plane_state); 12211 12158 12212 12159 drm_atomic_helper_commit_planes_on_crtc(old_crtc_state); 12213 12160 } ··· 12381 12322 12382 12323 if (old_crtc_state->active) { 12383 12324 intel_crtc_disable_planes(crtc, old_crtc_state->plane_mask); 12325 + 12326 + /* 12327 + * We need to disable pipe CRC before disabling the pipe, 12328 + * or we race against vblank off. 12329 + */ 12330 + intel_crtc_disable_pipe_crc(intel_crtc); 12331 + 12384 12332 dev_priv->display.crtc_disable(to_intel_crtc_state(old_crtc_state), state); 12385 12333 intel_crtc->active = false; 12386 12334 intel_fbc_disable(intel_crtc); ··· 12791 12725 12792 12726 if (old_obj) { 12793 12727 struct drm_crtc_state *crtc_state = 12794 - drm_atomic_get_existing_crtc_state(new_state->state, 12795 - plane->state->crtc); 12728 + drm_atomic_get_new_crtc_state(new_state->state, 12729 + plane->state->crtc); 12796 12730 12797 12731 /* Big Hammer, we also need to ensure that any pending 12798 12732 * MI_WAIT_FOR_EVENT inside a user batch buffer on the ··· 12846 12780 if (ret) 12847 12781 return ret; 12848 12782 12783 + intel_fb_obj_flush(obj, ORIGIN_DIRTYFB); 12784 + 12849 12785 if (!new_state->fence) { /* implicit fencing */ 12850 12786 struct dma_fence *fence; 12851 12787 ··· 12892 12824 } 12893 12825 12894 12826 int 12895 - skl_max_scale(struct intel_crtc *intel_crtc, struct intel_crtc_state *crtc_state) 12827 + skl_max_scale(struct intel_crtc *intel_crtc, 12828 + struct intel_crtc_state *crtc_state, 12829 + uint32_t pixel_format) 12896 12830 { 12897 12831 struct drm_i915_private *dev_priv; 12898 - int max_scale; 12899 - int crtc_clock, max_dotclk; 12832 + int max_scale, mult; 12833 + int crtc_clock, max_dotclk, tmpclk1, tmpclk2; 12900 12834 12901 12835 if (!intel_crtc || !crtc_state->base.enable) 12902 12836 return DRM_PLANE_HELPER_NO_SCALING; ··· 12920 12850 * or 12921 12851 * cdclk/crtc_clock 12922 12852 */ 12923 - max_scale = min((1 << 16) * 3 - 1, 12924 - (1 << 8) * ((max_dotclk << 8) / crtc_clock)); 12853 + mult = pixel_format == DRM_FORMAT_NV12 ? 2 : 3; 12854 + tmpclk1 = (1 << 16) * mult - 1; 12855 + tmpclk2 = (1 << 8) * ((max_dotclk << 8) / crtc_clock); 12856 + max_scale = min(tmpclk1, tmpclk2); 12925 12857 12926 12858 return max_scale; 12927 12859 } ··· 12939 12867 int max_scale = DRM_PLANE_HELPER_NO_SCALING; 12940 12868 bool can_position = false; 12941 12869 int ret; 12870 + uint32_t pixel_format = 0; 12942 12871 12943 12872 if (INTEL_GEN(dev_priv) >= 9) { 12944 12873 /* use scaler when colorkey is not required */ 12945 12874 if (!state->ckey.flags) { 12946 12875 min_scale = 1; 12947 - max_scale = skl_max_scale(to_intel_crtc(crtc), crtc_state); 12876 + if (state->base.fb) 12877 + pixel_format = state->base.fb->format->format; 12878 + max_scale = skl_max_scale(to_intel_crtc(crtc), 12879 + crtc_state, pixel_format); 12948 12880 } 12949 12881 can_position = true; 12950 12882 } ··· 13021 12945 intel_cstate); 13022 12946 } 13023 12947 12948 + void intel_crtc_arm_fifo_underrun(struct intel_crtc *crtc, 12949 + struct intel_crtc_state *crtc_state) 12950 + { 12951 + struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); 12952 + 12953 + if (!IS_GEN2(dev_priv)) 12954 + intel_set_cpu_fifo_underrun_reporting(dev_priv, crtc->pipe, true); 12955 + 12956 + if (crtc_state->has_pch_encoder) { 12957 + enum pipe pch_transcoder = 12958 + intel_crtc_pch_transcoder(crtc); 12959 + 12960 + intel_set_pch_fifo_underrun_reporting(dev_priv, pch_transcoder, true); 12961 + } 12962 + } 12963 + 13024 12964 static void intel_finish_crtc_commit(struct drm_crtc *crtc, 13025 12965 struct drm_crtc_state *old_crtc_state) 13026 12966 { 13027 - struct drm_i915_private *dev_priv = to_i915(crtc->dev); 13028 12967 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 13029 12968 struct intel_atomic_state *old_intel_state = 13030 12969 to_intel_atomic_state(old_crtc_state->state); ··· 13050 12959 13051 12960 if (new_crtc_state->update_pipe && 13052 12961 !needs_modeset(&new_crtc_state->base) && 13053 - old_crtc_state->mode.private_flags & I915_MODE_FLAG_INHERITED) { 13054 - if (!IS_GEN2(dev_priv)) 13055 - intel_set_cpu_fifo_underrun_reporting(dev_priv, intel_crtc->pipe, true); 13056 - 13057 - if (new_crtc_state->has_pch_encoder) { 13058 - enum pipe pch_transcoder = 13059 - intel_crtc_pch_transcoder(intel_crtc); 13060 - 13061 - intel_set_pch_fifo_underrun_reporting(dev_priv, pch_transcoder, true); 13062 - } 13063 - } 12962 + old_crtc_state->mode.private_flags & I915_MODE_FLAG_INHERITED) 12963 + intel_crtc_arm_fifo_underrun(intel_crtc, new_crtc_state); 13064 12964 } 13065 12965 13066 12966 /** ··· 13249 13167 if (ret) 13250 13168 goto out_unlock; 13251 13169 13252 - old_fb = old_plane_state->fb; 13170 + intel_fb_obj_flush(intel_fb_obj(fb), ORIGIN_FLIP); 13253 13171 13172 + old_fb = old_plane_state->fb; 13254 13173 i915_gem_track_fb(intel_fb_obj(old_fb), intel_fb_obj(fb), 13255 13174 intel_plane->frontbuffer_bit); 13256 13175 ··· 13638 13555 /* initialize shared scalers */ 13639 13556 intel_crtc_init_scalers(intel_crtc, crtc_state); 13640 13557 13641 - BUG_ON(pipe >= ARRAY_SIZE(dev_priv->plane_to_crtc_mapping) || 13642 - dev_priv->plane_to_crtc_mapping[primary->i9xx_plane] != NULL); 13643 - dev_priv->plane_to_crtc_mapping[primary->i9xx_plane] = intel_crtc; 13644 - dev_priv->pipe_to_crtc_mapping[intel_crtc->pipe] = intel_crtc; 13558 + BUG_ON(pipe >= ARRAY_SIZE(dev_priv->pipe_to_crtc_mapping) || 13559 + dev_priv->pipe_to_crtc_mapping[pipe] != NULL); 13560 + dev_priv->pipe_to_crtc_mapping[pipe] = intel_crtc; 13561 + 13562 + if (INTEL_GEN(dev_priv) < 9) { 13563 + enum i9xx_plane_id i9xx_plane = primary->i9xx_plane; 13564 + 13565 + BUG_ON(i9xx_plane >= ARRAY_SIZE(dev_priv->plane_to_crtc_mapping) || 13566 + dev_priv->plane_to_crtc_mapping[i9xx_plane] != NULL); 13567 + dev_priv->plane_to_crtc_mapping[i9xx_plane] = intel_crtc; 13568 + } 13645 13569 13646 13570 drm_crtc_helper_add(&intel_crtc->base, &intel_helper_funcs); 13647 13571 ··· 15193 15103 for (i = 0; i < dev_priv->num_shared_dpll; i++) { 15194 15104 struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i]; 15195 15105 15196 - pll->on = pll->funcs.get_hw_state(dev_priv, pll, 15197 - &pll->state.hw_state); 15106 + pll->on = pll->info->funcs->get_hw_state(dev_priv, pll, 15107 + &pll->state.hw_state); 15198 15108 pll->state.crtc_mask = 0; 15199 15109 for_each_intel_crtc(dev, crtc) { 15200 15110 struct intel_crtc_state *crtc_state = ··· 15207 15117 pll->active_mask = pll->state.crtc_mask; 15208 15118 15209 15119 DRM_DEBUG_KMS("%s hw state readout: crtc_mask 0x%08x, on %i\n", 15210 - pll->name, pll->state.crtc_mask, pll->on); 15120 + pll->info->name, pll->state.crtc_mask, pll->on); 15211 15121 } 15212 15122 15213 15123 for_each_intel_encoder(dev, encoder) { ··· 15381 15291 if (!pll->on || pll->active_mask) 15382 15292 continue; 15383 15293 15384 - DRM_DEBUG_KMS("%s enabled but not in use, disabling\n", pll->name); 15294 + DRM_DEBUG_KMS("%s enabled but not in use, disabling\n", 15295 + pll->info->name); 15385 15296 15386 - pll->funcs.disable(dev_priv, pll); 15297 + pll->info->funcs->disable(dev_priv, pll); 15387 15298 pll->on = false; 15388 15299 } 15389 15300
+4 -17
drivers/gpu/drm/i915/intel_dp.c
··· 43 43 #include <drm/i915_drm.h> 44 44 #include "i915_drv.h" 45 45 46 - #define DP_LINK_CHECK_TIMEOUT (10 * 1000) 47 46 #define DP_DPRX_ESI_LEN 14 48 47 49 48 /* Compliance test status bits */ ··· 91 92 { .p1 = 4, .p2 = 2, .n = 1, .m1 = 2, .m2 = 0x819999a } }, 92 93 { 270000, /* m2_int = 27, m2_fraction = 0 */ 93 94 { .p1 = 4, .p2 = 1, .n = 1, .m1 = 2, .m2 = 0x6c00000 } }, 94 - { 540000, /* m2_int = 27, m2_fraction = 0 */ 95 - { .p1 = 2, .p2 = 1, .n = 1, .m1 = 2, .m2 = 0x6c00000 } } 96 95 }; 97 96 98 97 /** ··· 2898 2901 } 2899 2902 2900 2903 } else { 2901 - if (IS_CHERRYVIEW(dev_priv)) 2902 - *DP &= ~DP_LINK_TRAIN_MASK_CHV; 2903 - else 2904 - *DP &= ~DP_LINK_TRAIN_MASK; 2904 + *DP &= ~DP_LINK_TRAIN_MASK; 2905 2905 2906 2906 switch (dp_train_pat & DP_TRAINING_PATTERN_MASK) { 2907 2907 case DP_TRAINING_PATTERN_DISABLE: ··· 2911 2917 *DP |= DP_LINK_TRAIN_PAT_2; 2912 2918 break; 2913 2919 case DP_TRAINING_PATTERN_3: 2914 - if (IS_CHERRYVIEW(dev_priv)) { 2915 - *DP |= DP_LINK_TRAIN_PAT_3_CHV; 2916 - } else { 2917 - DRM_DEBUG_KMS("TPS3 not supported, using TPS2 instead\n"); 2918 - *DP |= DP_LINK_TRAIN_PAT_2; 2919 - } 2920 + DRM_DEBUG_KMS("TPS3 not supported, using TPS2 instead\n"); 2921 + *DP |= DP_LINK_TRAIN_PAT_2; 2920 2922 break; 2921 2923 } 2922 2924 } ··· 3651 3661 DP &= ~DP_LINK_TRAIN_MASK_CPT; 3652 3662 DP |= DP_LINK_TRAIN_PAT_IDLE_CPT; 3653 3663 } else { 3654 - if (IS_CHERRYVIEW(dev_priv)) 3655 - DP &= ~DP_LINK_TRAIN_MASK_CHV; 3656 - else 3657 - DP &= ~DP_LINK_TRAIN_MASK; 3664 + DP &= ~DP_LINK_TRAIN_MASK; 3658 3665 DP |= DP_LINK_TRAIN_PAT_IDLE; 3659 3666 } 3660 3667 I915_WRITE(intel_dp->output_reg, DP);
+7 -1
drivers/gpu/drm/i915/intel_dp_mst.c
··· 180 180 intel_dp->active_mst_links--; 181 181 182 182 intel_mst->connector = NULL; 183 - if (intel_dp->active_mst_links == 0) 183 + if (intel_dp->active_mst_links == 0) { 184 + intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF); 184 185 intel_dig_port->base.post_disable(&intel_dig_port->base, 185 186 old_crtc_state, NULL); 187 + } 186 188 187 189 DRM_DEBUG_KMS("active links %d\n", intel_dp->active_mst_links); 188 190 } ··· 225 223 226 224 DRM_DEBUG_KMS("active links %d\n", intel_dp->active_mst_links); 227 225 226 + if (intel_dp->active_mst_links == 0) 227 + intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON); 228 + 228 229 drm_dp_send_power_updown_phy(&intel_dp->mst_mgr, connector->port, true); 230 + 229 231 if (intel_dp->active_mst_links == 0) 230 232 intel_dig_port->base.pre_enable(&intel_dig_port->base, 231 233 pipe_config, NULL);
+6 -5
drivers/gpu/drm/i915/intel_dpio_phy.c
··· 380 380 * all 1s. Eventually they become accessible as they power up, then 381 381 * the reserved bit will give the default 0. Poll on the reserved bit 382 382 * becoming 0 to find when the PHY is accessible. 383 - * HW team confirmed that the time to reach phypowergood status is 384 - * anywhere between 50 us and 100us. 383 + * The flag should get set in 100us according to the HW team, but 384 + * use 1ms due to occasional timeouts observed with that. 385 385 */ 386 - if (wait_for_us(((I915_READ(BXT_PORT_CL1CM_DW0(phy)) & 387 - (PHY_RESERVED | PHY_POWER_GOOD)) == PHY_POWER_GOOD), 100)) { 386 + if (intel_wait_for_register_fw(dev_priv, BXT_PORT_CL1CM_DW0(phy), 387 + PHY_RESERVED | PHY_POWER_GOOD, 388 + PHY_POWER_GOOD, 389 + 1)) 388 390 DRM_ERROR("timeout during PHY%d power on\n", phy); 389 - } 390 391 391 392 /* Program PLL Rcomp code offset */ 392 393 val = I915_READ(BXT_PORT_CL1CM_DW9(phy));
+132 -121
drivers/gpu/drm/i915/intel_dpll_mgr.c
··· 118 118 if (WARN(!pll, "asserting DPLL %s with no DPLL\n", onoff(state))) 119 119 return; 120 120 121 - cur_state = pll->funcs.get_hw_state(dev_priv, pll, &hw_state); 121 + cur_state = pll->info->funcs->get_hw_state(dev_priv, pll, &hw_state); 122 122 I915_STATE_WARN(cur_state != state, 123 123 "%s assertion failure (expected %s, current %s)\n", 124 - pll->name, onoff(state), onoff(cur_state)); 124 + pll->info->name, onoff(state), onoff(cur_state)); 125 125 } 126 126 127 127 /** ··· 143 143 mutex_lock(&dev_priv->dpll_lock); 144 144 WARN_ON(!pll->state.crtc_mask); 145 145 if (!pll->active_mask) { 146 - DRM_DEBUG_DRIVER("setting up %s\n", pll->name); 146 + DRM_DEBUG_DRIVER("setting up %s\n", pll->info->name); 147 147 WARN_ON(pll->on); 148 148 assert_shared_dpll_disabled(dev_priv, pll); 149 149 150 - pll->funcs.prepare(dev_priv, pll); 150 + pll->info->funcs->prepare(dev_priv, pll); 151 151 } 152 152 mutex_unlock(&dev_priv->dpll_lock); 153 153 } ··· 179 179 pll->active_mask |= crtc_mask; 180 180 181 181 DRM_DEBUG_KMS("enable %s (active %x, on? %d) for crtc %d\n", 182 - pll->name, pll->active_mask, pll->on, 182 + pll->info->name, pll->active_mask, pll->on, 183 183 crtc->base.base.id); 184 184 185 185 if (old_mask) { ··· 189 189 } 190 190 WARN_ON(pll->on); 191 191 192 - DRM_DEBUG_KMS("enabling %s\n", pll->name); 193 - pll->funcs.enable(dev_priv, pll); 192 + DRM_DEBUG_KMS("enabling %s\n", pll->info->name); 193 + pll->info->funcs->enable(dev_priv, pll); 194 194 pll->on = true; 195 195 196 196 out: ··· 221 221 goto out; 222 222 223 223 DRM_DEBUG_KMS("disable %s (active %x, on? %d) for crtc %d\n", 224 - pll->name, pll->active_mask, pll->on, 224 + pll->info->name, pll->active_mask, pll->on, 225 225 crtc->base.base.id); 226 226 227 227 assert_shared_dpll_enabled(dev_priv, pll); ··· 231 231 if (pll->active_mask) 232 232 goto out; 233 233 234 - DRM_DEBUG_KMS("disabling %s\n", pll->name); 235 - pll->funcs.disable(dev_priv, pll); 234 + DRM_DEBUG_KMS("disabling %s\n", pll->info->name); 235 + pll->info->funcs->disable(dev_priv, pll); 236 236 pll->on = false; 237 237 238 238 out: ··· 263 263 &shared_dpll[i].hw_state, 264 264 sizeof(crtc_state->dpll_hw_state)) == 0) { 265 265 DRM_DEBUG_KMS("[CRTC:%d:%s] sharing existing %s (crtc mask 0x%08x, active %x)\n", 266 - crtc->base.base.id, crtc->base.name, pll->name, 266 + crtc->base.base.id, crtc->base.name, 267 + pll->info->name, 267 268 shared_dpll[i].crtc_mask, 268 269 pll->active_mask); 269 270 return pll; ··· 276 275 pll = &dev_priv->shared_dplls[i]; 277 276 if (shared_dpll[i].crtc_mask == 0) { 278 277 DRM_DEBUG_KMS("[CRTC:%d:%s] allocated %s\n", 279 - crtc->base.base.id, crtc->base.name, pll->name); 278 + crtc->base.base.id, crtc->base.name, 279 + pll->info->name); 280 280 return pll; 281 281 } 282 282 } ··· 291 289 { 292 290 struct intel_shared_dpll_state *shared_dpll; 293 291 struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc); 294 - enum intel_dpll_id i = pll->id; 292 + const enum intel_dpll_id id = pll->info->id; 295 293 296 294 shared_dpll = intel_atomic_get_shared_dpll_state(crtc_state->base.state); 297 295 298 - if (shared_dpll[i].crtc_mask == 0) 299 - shared_dpll[i].hw_state = 296 + if (shared_dpll[id].crtc_mask == 0) 297 + shared_dpll[id].hw_state = 300 298 crtc_state->dpll_hw_state; 301 299 302 300 crtc_state->shared_dpll = pll; 303 - DRM_DEBUG_DRIVER("using %s for pipe %c\n", pll->name, 301 + DRM_DEBUG_DRIVER("using %s for pipe %c\n", pll->info->name, 304 302 pipe_name(crtc->pipe)); 305 303 306 - shared_dpll[pll->id].crtc_mask |= 1 << crtc->pipe; 304 + shared_dpll[id].crtc_mask |= 1 << crtc->pipe; 307 305 } 308 306 309 307 /** ··· 343 341 struct intel_shared_dpll *pll, 344 342 struct intel_dpll_hw_state *hw_state) 345 343 { 344 + const enum intel_dpll_id id = pll->info->id; 346 345 uint32_t val; 347 346 348 347 if (!intel_display_power_get_if_enabled(dev_priv, POWER_DOMAIN_PLLS)) 349 348 return false; 350 349 351 - val = I915_READ(PCH_DPLL(pll->id)); 350 + val = I915_READ(PCH_DPLL(id)); 352 351 hw_state->dpll = val; 353 - hw_state->fp0 = I915_READ(PCH_FP0(pll->id)); 354 - hw_state->fp1 = I915_READ(PCH_FP1(pll->id)); 352 + hw_state->fp0 = I915_READ(PCH_FP0(id)); 353 + hw_state->fp1 = I915_READ(PCH_FP1(id)); 355 354 356 355 intel_display_power_put(dev_priv, POWER_DOMAIN_PLLS); 357 356 ··· 362 359 static void ibx_pch_dpll_prepare(struct drm_i915_private *dev_priv, 363 360 struct intel_shared_dpll *pll) 364 361 { 365 - I915_WRITE(PCH_FP0(pll->id), pll->state.hw_state.fp0); 366 - I915_WRITE(PCH_FP1(pll->id), pll->state.hw_state.fp1); 362 + const enum intel_dpll_id id = pll->info->id; 363 + 364 + I915_WRITE(PCH_FP0(id), pll->state.hw_state.fp0); 365 + I915_WRITE(PCH_FP1(id), pll->state.hw_state.fp1); 367 366 } 368 367 369 368 static void ibx_assert_pch_refclk_enabled(struct drm_i915_private *dev_priv) ··· 384 379 static void ibx_pch_dpll_enable(struct drm_i915_private *dev_priv, 385 380 struct intel_shared_dpll *pll) 386 381 { 382 + const enum intel_dpll_id id = pll->info->id; 383 + 387 384 /* PCH refclock must be enabled first */ 388 385 ibx_assert_pch_refclk_enabled(dev_priv); 389 386 390 - I915_WRITE(PCH_DPLL(pll->id), pll->state.hw_state.dpll); 387 + I915_WRITE(PCH_DPLL(id), pll->state.hw_state.dpll); 391 388 392 389 /* Wait for the clocks to stabilize. */ 393 - POSTING_READ(PCH_DPLL(pll->id)); 390 + POSTING_READ(PCH_DPLL(id)); 394 391 udelay(150); 395 392 396 393 /* The pixel multiplier can only be updated once the ··· 400 393 * 401 394 * So write it again. 402 395 */ 403 - I915_WRITE(PCH_DPLL(pll->id), pll->state.hw_state.dpll); 404 - POSTING_READ(PCH_DPLL(pll->id)); 396 + I915_WRITE(PCH_DPLL(id), pll->state.hw_state.dpll); 397 + POSTING_READ(PCH_DPLL(id)); 405 398 udelay(200); 406 399 } 407 400 408 401 static void ibx_pch_dpll_disable(struct drm_i915_private *dev_priv, 409 402 struct intel_shared_dpll *pll) 410 403 { 404 + const enum intel_dpll_id id = pll->info->id; 411 405 struct drm_device *dev = &dev_priv->drm; 412 406 struct intel_crtc *crtc; 413 407 ··· 418 410 assert_pch_transcoder_disabled(dev_priv, crtc->pipe); 419 411 } 420 412 421 - I915_WRITE(PCH_DPLL(pll->id), 0); 422 - POSTING_READ(PCH_DPLL(pll->id)); 413 + I915_WRITE(PCH_DPLL(id), 0); 414 + POSTING_READ(PCH_DPLL(id)); 423 415 udelay(200); 424 416 } 425 417 ··· 437 429 pll = &dev_priv->shared_dplls[i]; 438 430 439 431 DRM_DEBUG_KMS("[CRTC:%d:%s] using pre-allocated %s\n", 440 - crtc->base.base.id, crtc->base.name, pll->name); 432 + crtc->base.base.id, crtc->base.name, 433 + pll->info->name); 441 434 } else { 442 435 pll = intel_find_shared_dpll(crtc, crtc_state, 443 436 DPLL_ID_PCH_PLL_A, ··· 475 466 static void hsw_ddi_wrpll_enable(struct drm_i915_private *dev_priv, 476 467 struct intel_shared_dpll *pll) 477 468 { 478 - I915_WRITE(WRPLL_CTL(pll->id), pll->state.hw_state.wrpll); 479 - POSTING_READ(WRPLL_CTL(pll->id)); 469 + const enum intel_dpll_id id = pll->info->id; 470 + 471 + I915_WRITE(WRPLL_CTL(id), pll->state.hw_state.wrpll); 472 + POSTING_READ(WRPLL_CTL(id)); 480 473 udelay(20); 481 474 } 482 475 ··· 493 482 static void hsw_ddi_wrpll_disable(struct drm_i915_private *dev_priv, 494 483 struct intel_shared_dpll *pll) 495 484 { 485 + const enum intel_dpll_id id = pll->info->id; 496 486 uint32_t val; 497 487 498 - val = I915_READ(WRPLL_CTL(pll->id)); 499 - I915_WRITE(WRPLL_CTL(pll->id), val & ~WRPLL_PLL_ENABLE); 500 - POSTING_READ(WRPLL_CTL(pll->id)); 488 + val = I915_READ(WRPLL_CTL(id)); 489 + I915_WRITE(WRPLL_CTL(id), val & ~WRPLL_PLL_ENABLE); 490 + POSTING_READ(WRPLL_CTL(id)); 501 491 } 502 492 503 493 static void hsw_ddi_spll_disable(struct drm_i915_private *dev_priv, ··· 515 503 struct intel_shared_dpll *pll, 516 504 struct intel_dpll_hw_state *hw_state) 517 505 { 506 + const enum intel_dpll_id id = pll->info->id; 518 507 uint32_t val; 519 508 520 509 if (!intel_display_power_get_if_enabled(dev_priv, POWER_DOMAIN_PLLS)) 521 510 return false; 522 511 523 - val = I915_READ(WRPLL_CTL(pll->id)); 512 + val = I915_READ(WRPLL_CTL(id)); 524 513 hw_state->wrpll = val; 525 514 526 515 intel_display_power_put(dev_priv, POWER_DOMAIN_PLLS); ··· 927 914 static void skl_ddi_pll_write_ctrl1(struct drm_i915_private *dev_priv, 928 915 struct intel_shared_dpll *pll) 929 916 { 917 + const enum intel_dpll_id id = pll->info->id; 930 918 uint32_t val; 931 919 932 920 val = I915_READ(DPLL_CTRL1); 933 921 934 - val &= ~(DPLL_CTRL1_HDMI_MODE(pll->id) | DPLL_CTRL1_SSC(pll->id) | 935 - DPLL_CTRL1_LINK_RATE_MASK(pll->id)); 936 - val |= pll->state.hw_state.ctrl1 << (pll->id * 6); 922 + val &= ~(DPLL_CTRL1_HDMI_MODE(id) | 923 + DPLL_CTRL1_SSC(id) | 924 + DPLL_CTRL1_LINK_RATE_MASK(id)); 925 + val |= pll->state.hw_state.ctrl1 << (id * 6); 937 926 938 927 I915_WRITE(DPLL_CTRL1, val); 939 928 POSTING_READ(DPLL_CTRL1); ··· 945 930 struct intel_shared_dpll *pll) 946 931 { 947 932 const struct skl_dpll_regs *regs = skl_dpll_regs; 933 + const enum intel_dpll_id id = pll->info->id; 948 934 949 935 skl_ddi_pll_write_ctrl1(dev_priv, pll); 950 936 951 - I915_WRITE(regs[pll->id].cfgcr1, pll->state.hw_state.cfgcr1); 952 - I915_WRITE(regs[pll->id].cfgcr2, pll->state.hw_state.cfgcr2); 953 - POSTING_READ(regs[pll->id].cfgcr1); 954 - POSTING_READ(regs[pll->id].cfgcr2); 937 + I915_WRITE(regs[id].cfgcr1, pll->state.hw_state.cfgcr1); 938 + I915_WRITE(regs[id].cfgcr2, pll->state.hw_state.cfgcr2); 939 + POSTING_READ(regs[id].cfgcr1); 940 + POSTING_READ(regs[id].cfgcr2); 955 941 956 942 /* the enable bit is always bit 31 */ 957 - I915_WRITE(regs[pll->id].ctl, 958 - I915_READ(regs[pll->id].ctl) | LCPLL_PLL_ENABLE); 943 + I915_WRITE(regs[id].ctl, 944 + I915_READ(regs[id].ctl) | LCPLL_PLL_ENABLE); 959 945 960 946 if (intel_wait_for_register(dev_priv, 961 947 DPLL_STATUS, 962 - DPLL_LOCK(pll->id), 963 - DPLL_LOCK(pll->id), 948 + DPLL_LOCK(id), 949 + DPLL_LOCK(id), 964 950 5)) 965 - DRM_ERROR("DPLL %d not locked\n", pll->id); 951 + DRM_ERROR("DPLL %d not locked\n", id); 966 952 } 967 953 968 954 static void skl_ddi_dpll0_enable(struct drm_i915_private *dev_priv, ··· 976 960 struct intel_shared_dpll *pll) 977 961 { 978 962 const struct skl_dpll_regs *regs = skl_dpll_regs; 963 + const enum intel_dpll_id id = pll->info->id; 979 964 980 965 /* the enable bit is always bit 31 */ 981 - I915_WRITE(regs[pll->id].ctl, 982 - I915_READ(regs[pll->id].ctl) & ~LCPLL_PLL_ENABLE); 983 - POSTING_READ(regs[pll->id].ctl); 966 + I915_WRITE(regs[id].ctl, 967 + I915_READ(regs[id].ctl) & ~LCPLL_PLL_ENABLE); 968 + POSTING_READ(regs[id].ctl); 984 969 } 985 970 986 971 static void skl_ddi_dpll0_disable(struct drm_i915_private *dev_priv, ··· 995 978 { 996 979 uint32_t val; 997 980 const struct skl_dpll_regs *regs = skl_dpll_regs; 981 + const enum intel_dpll_id id = pll->info->id; 998 982 bool ret; 999 983 1000 984 if (!intel_display_power_get_if_enabled(dev_priv, POWER_DOMAIN_PLLS)) ··· 1003 985 1004 986 ret = false; 1005 987 1006 - val = I915_READ(regs[pll->id].ctl); 988 + val = I915_READ(regs[id].ctl); 1007 989 if (!(val & LCPLL_PLL_ENABLE)) 1008 990 goto out; 1009 991 1010 992 val = I915_READ(DPLL_CTRL1); 1011 - hw_state->ctrl1 = (val >> (pll->id * 6)) & 0x3f; 993 + hw_state->ctrl1 = (val >> (id * 6)) & 0x3f; 1012 994 1013 995 /* avoid reading back stale values if HDMI mode is not enabled */ 1014 - if (val & DPLL_CTRL1_HDMI_MODE(pll->id)) { 1015 - hw_state->cfgcr1 = I915_READ(regs[pll->id].cfgcr1); 1016 - hw_state->cfgcr2 = I915_READ(regs[pll->id].cfgcr2); 996 + if (val & DPLL_CTRL1_HDMI_MODE(id)) { 997 + hw_state->cfgcr1 = I915_READ(regs[id].cfgcr1); 998 + hw_state->cfgcr2 = I915_READ(regs[id].cfgcr2); 1017 999 } 1018 1000 ret = true; 1019 1001 ··· 1029 1011 { 1030 1012 uint32_t val; 1031 1013 const struct skl_dpll_regs *regs = skl_dpll_regs; 1014 + const enum intel_dpll_id id = pll->info->id; 1032 1015 bool ret; 1033 1016 1034 1017 if (!intel_display_power_get_if_enabled(dev_priv, POWER_DOMAIN_PLLS)) ··· 1038 1019 ret = false; 1039 1020 1040 1021 /* DPLL0 is always enabled since it drives CDCLK */ 1041 - val = I915_READ(regs[pll->id].ctl); 1022 + val = I915_READ(regs[id].ctl); 1042 1023 if (WARN_ON(!(val & LCPLL_PLL_ENABLE))) 1043 1024 goto out; 1044 1025 1045 1026 val = I915_READ(DPLL_CTRL1); 1046 - hw_state->ctrl1 = (val >> (pll->id * 6)) & 0x3f; 1027 + hw_state->ctrl1 = (val >> (id * 6)) & 0x3f; 1047 1028 1048 1029 ret = true; 1049 1030 ··· 1443 1424 struct intel_shared_dpll *pll) 1444 1425 { 1445 1426 uint32_t temp; 1446 - enum port port = (enum port)pll->id; /* 1:1 port->PLL mapping */ 1427 + enum port port = (enum port)pll->info->id; /* 1:1 port->PLL mapping */ 1447 1428 enum dpio_phy phy; 1448 1429 enum dpio_channel ch; 1449 1430 ··· 1562 1543 static void bxt_ddi_pll_disable(struct drm_i915_private *dev_priv, 1563 1544 struct intel_shared_dpll *pll) 1564 1545 { 1565 - enum port port = (enum port)pll->id; /* 1:1 port->PLL mapping */ 1546 + enum port port = (enum port)pll->info->id; /* 1:1 port->PLL mapping */ 1566 1547 uint32_t temp; 1567 1548 1568 1549 temp = I915_READ(BXT_PORT_PLL_ENABLE(port)); ··· 1585 1566 struct intel_shared_dpll *pll, 1586 1567 struct intel_dpll_hw_state *hw_state) 1587 1568 { 1588 - enum port port = (enum port)pll->id; /* 1:1 port->PLL mapping */ 1569 + enum port port = (enum port)pll->info->id; /* 1:1 port->PLL mapping */ 1589 1570 uint32_t val; 1590 1571 bool ret; 1591 1572 enum dpio_phy phy; ··· 1843 1824 pll = intel_get_shared_dpll_by_id(dev_priv, i); 1844 1825 1845 1826 DRM_DEBUG_KMS("[CRTC:%d:%s] using pre-allocated %s\n", 1846 - crtc->base.base.id, crtc->base.name, pll->name); 1827 + crtc->base.base.id, crtc->base.name, pll->info->name); 1847 1828 1848 1829 intel_reference_shared_dpll(pll, crtc_state); 1849 1830 ··· 1896 1877 } 1897 1878 } 1898 1879 1899 - struct dpll_info { 1900 - const char *name; 1901 - const int id; 1902 - const struct intel_shared_dpll_funcs *funcs; 1903 - uint32_t flags; 1904 - }; 1905 - 1906 1880 struct intel_dpll_mgr { 1907 1881 const struct dpll_info *dpll_info; 1908 1882 ··· 1908 1896 }; 1909 1897 1910 1898 static const struct dpll_info pch_plls[] = { 1911 - { "PCH DPLL A", DPLL_ID_PCH_PLL_A, &ibx_pch_dpll_funcs, 0 }, 1912 - { "PCH DPLL B", DPLL_ID_PCH_PLL_B, &ibx_pch_dpll_funcs, 0 }, 1913 - { NULL, -1, NULL, 0 }, 1899 + { "PCH DPLL A", &ibx_pch_dpll_funcs, DPLL_ID_PCH_PLL_A, 0 }, 1900 + { "PCH DPLL B", &ibx_pch_dpll_funcs, DPLL_ID_PCH_PLL_B, 0 }, 1901 + { }, 1914 1902 }; 1915 1903 1916 1904 static const struct intel_dpll_mgr pch_pll_mgr = { ··· 1920 1908 }; 1921 1909 1922 1910 static const struct dpll_info hsw_plls[] = { 1923 - { "WRPLL 1", DPLL_ID_WRPLL1, &hsw_ddi_wrpll_funcs, 0 }, 1924 - { "WRPLL 2", DPLL_ID_WRPLL2, &hsw_ddi_wrpll_funcs, 0 }, 1925 - { "SPLL", DPLL_ID_SPLL, &hsw_ddi_spll_funcs, 0 }, 1926 - { "LCPLL 810", DPLL_ID_LCPLL_810, &hsw_ddi_lcpll_funcs, INTEL_DPLL_ALWAYS_ON }, 1927 - { "LCPLL 1350", DPLL_ID_LCPLL_1350, &hsw_ddi_lcpll_funcs, INTEL_DPLL_ALWAYS_ON }, 1928 - { "LCPLL 2700", DPLL_ID_LCPLL_2700, &hsw_ddi_lcpll_funcs, INTEL_DPLL_ALWAYS_ON }, 1929 - { NULL, -1, NULL, }, 1911 + { "WRPLL 1", &hsw_ddi_wrpll_funcs, DPLL_ID_WRPLL1, 0 }, 1912 + { "WRPLL 2", &hsw_ddi_wrpll_funcs, DPLL_ID_WRPLL2, 0 }, 1913 + { "SPLL", &hsw_ddi_spll_funcs, DPLL_ID_SPLL, 0 }, 1914 + { "LCPLL 810", &hsw_ddi_lcpll_funcs, DPLL_ID_LCPLL_810, INTEL_DPLL_ALWAYS_ON }, 1915 + { "LCPLL 1350", &hsw_ddi_lcpll_funcs, DPLL_ID_LCPLL_1350, INTEL_DPLL_ALWAYS_ON }, 1916 + { "LCPLL 2700", &hsw_ddi_lcpll_funcs, DPLL_ID_LCPLL_2700, INTEL_DPLL_ALWAYS_ON }, 1917 + { }, 1930 1918 }; 1931 1919 1932 1920 static const struct intel_dpll_mgr hsw_pll_mgr = { ··· 1936 1924 }; 1937 1925 1938 1926 static const struct dpll_info skl_plls[] = { 1939 - { "DPLL 0", DPLL_ID_SKL_DPLL0, &skl_ddi_dpll0_funcs, INTEL_DPLL_ALWAYS_ON }, 1940 - { "DPLL 1", DPLL_ID_SKL_DPLL1, &skl_ddi_pll_funcs, 0 }, 1941 - { "DPLL 2", DPLL_ID_SKL_DPLL2, &skl_ddi_pll_funcs, 0 }, 1942 - { "DPLL 3", DPLL_ID_SKL_DPLL3, &skl_ddi_pll_funcs, 0 }, 1943 - { NULL, -1, NULL, }, 1927 + { "DPLL 0", &skl_ddi_dpll0_funcs, DPLL_ID_SKL_DPLL0, INTEL_DPLL_ALWAYS_ON }, 1928 + { "DPLL 1", &skl_ddi_pll_funcs, DPLL_ID_SKL_DPLL1, 0 }, 1929 + { "DPLL 2", &skl_ddi_pll_funcs, DPLL_ID_SKL_DPLL2, 0 }, 1930 + { "DPLL 3", &skl_ddi_pll_funcs, DPLL_ID_SKL_DPLL3, 0 }, 1931 + { }, 1944 1932 }; 1945 1933 1946 1934 static const struct intel_dpll_mgr skl_pll_mgr = { ··· 1950 1938 }; 1951 1939 1952 1940 static const struct dpll_info bxt_plls[] = { 1953 - { "PORT PLL A", DPLL_ID_SKL_DPLL0, &bxt_ddi_pll_funcs, 0 }, 1954 - { "PORT PLL B", DPLL_ID_SKL_DPLL1, &bxt_ddi_pll_funcs, 0 }, 1955 - { "PORT PLL C", DPLL_ID_SKL_DPLL2, &bxt_ddi_pll_funcs, 0 }, 1956 - { NULL, -1, NULL, }, 1941 + { "PORT PLL A", &bxt_ddi_pll_funcs, DPLL_ID_SKL_DPLL0, 0 }, 1942 + { "PORT PLL B", &bxt_ddi_pll_funcs, DPLL_ID_SKL_DPLL1, 0 }, 1943 + { "PORT PLL C", &bxt_ddi_pll_funcs, DPLL_ID_SKL_DPLL2, 0 }, 1944 + { }, 1957 1945 }; 1958 1946 1959 1947 static const struct intel_dpll_mgr bxt_pll_mgr = { ··· 1965 1953 static void cnl_ddi_pll_enable(struct drm_i915_private *dev_priv, 1966 1954 struct intel_shared_dpll *pll) 1967 1955 { 1956 + const enum intel_dpll_id id = pll->info->id; 1968 1957 uint32_t val; 1969 1958 1970 1959 /* 1. Enable DPLL power in DPLL_ENABLE. */ 1971 - val = I915_READ(CNL_DPLL_ENABLE(pll->id)); 1960 + val = I915_READ(CNL_DPLL_ENABLE(id)); 1972 1961 val |= PLL_POWER_ENABLE; 1973 - I915_WRITE(CNL_DPLL_ENABLE(pll->id), val); 1962 + I915_WRITE(CNL_DPLL_ENABLE(id), val); 1974 1963 1975 1964 /* 2. Wait for DPLL power state enabled in DPLL_ENABLE. */ 1976 1965 if (intel_wait_for_register(dev_priv, 1977 - CNL_DPLL_ENABLE(pll->id), 1966 + CNL_DPLL_ENABLE(id), 1978 1967 PLL_POWER_STATE, 1979 1968 PLL_POWER_STATE, 1980 1969 5)) 1981 - DRM_ERROR("PLL %d Power not enabled\n", pll->id); 1970 + DRM_ERROR("PLL %d Power not enabled\n", id); 1982 1971 1983 1972 /* 1984 1973 * 3. Configure DPLL_CFGCR0 to set SSC enable/disable, 1985 1974 * select DP mode, and set DP link rate. 1986 1975 */ 1987 1976 val = pll->state.hw_state.cfgcr0; 1988 - I915_WRITE(CNL_DPLL_CFGCR0(pll->id), val); 1977 + I915_WRITE(CNL_DPLL_CFGCR0(id), val); 1989 1978 1990 1979 /* 4. Reab back to ensure writes completed */ 1991 - POSTING_READ(CNL_DPLL_CFGCR0(pll->id)); 1980 + POSTING_READ(CNL_DPLL_CFGCR0(id)); 1992 1981 1993 1982 /* 3. Configure DPLL_CFGCR0 */ 1994 1983 /* Avoid touch CFGCR1 if HDMI mode is not enabled */ 1995 1984 if (pll->state.hw_state.cfgcr0 & DPLL_CFGCR0_HDMI_MODE) { 1996 1985 val = pll->state.hw_state.cfgcr1; 1997 - I915_WRITE(CNL_DPLL_CFGCR1(pll->id), val); 1986 + I915_WRITE(CNL_DPLL_CFGCR1(id), val); 1998 1987 /* 4. Reab back to ensure writes completed */ 1999 - POSTING_READ(CNL_DPLL_CFGCR1(pll->id)); 1988 + POSTING_READ(CNL_DPLL_CFGCR1(id)); 2000 1989 } 2001 1990 2002 1991 /* ··· 2010 1997 */ 2011 1998 2012 1999 /* 6. Enable DPLL in DPLL_ENABLE. */ 2013 - val = I915_READ(CNL_DPLL_ENABLE(pll->id)); 2000 + val = I915_READ(CNL_DPLL_ENABLE(id)); 2014 2001 val |= PLL_ENABLE; 2015 - I915_WRITE(CNL_DPLL_ENABLE(pll->id), val); 2002 + I915_WRITE(CNL_DPLL_ENABLE(id), val); 2016 2003 2017 2004 /* 7. Wait for PLL lock status in DPLL_ENABLE. */ 2018 2005 if (intel_wait_for_register(dev_priv, 2019 - CNL_DPLL_ENABLE(pll->id), 2006 + CNL_DPLL_ENABLE(id), 2020 2007 PLL_LOCK, 2021 2008 PLL_LOCK, 2022 2009 5)) 2023 - DRM_ERROR("PLL %d not locked\n", pll->id); 2010 + DRM_ERROR("PLL %d not locked\n", id); 2024 2011 2025 2012 /* 2026 2013 * 8. If the frequency will result in a change to the voltage ··· 2040 2027 static void cnl_ddi_pll_disable(struct drm_i915_private *dev_priv, 2041 2028 struct intel_shared_dpll *pll) 2042 2029 { 2030 + const enum intel_dpll_id id = pll->info->id; 2043 2031 uint32_t val; 2044 2032 2045 2033 /* ··· 2058 2044 */ 2059 2045 2060 2046 /* 3. Disable DPLL through DPLL_ENABLE. */ 2061 - val = I915_READ(CNL_DPLL_ENABLE(pll->id)); 2047 + val = I915_READ(CNL_DPLL_ENABLE(id)); 2062 2048 val &= ~PLL_ENABLE; 2063 - I915_WRITE(CNL_DPLL_ENABLE(pll->id), val); 2049 + I915_WRITE(CNL_DPLL_ENABLE(id), val); 2064 2050 2065 2051 /* 4. Wait for PLL not locked status in DPLL_ENABLE. */ 2066 2052 if (intel_wait_for_register(dev_priv, 2067 - CNL_DPLL_ENABLE(pll->id), 2053 + CNL_DPLL_ENABLE(id), 2068 2054 PLL_LOCK, 2069 2055 0, 2070 2056 5)) 2071 - DRM_ERROR("PLL %d locked\n", pll->id); 2057 + DRM_ERROR("PLL %d locked\n", id); 2072 2058 2073 2059 /* 2074 2060 * 5. If the frequency will result in a change to the voltage ··· 2080 2066 */ 2081 2067 2082 2068 /* 6. Disable DPLL power in DPLL_ENABLE. */ 2083 - val = I915_READ(CNL_DPLL_ENABLE(pll->id)); 2069 + val = I915_READ(CNL_DPLL_ENABLE(id)); 2084 2070 val &= ~PLL_POWER_ENABLE; 2085 - I915_WRITE(CNL_DPLL_ENABLE(pll->id), val); 2071 + I915_WRITE(CNL_DPLL_ENABLE(id), val); 2086 2072 2087 2073 /* 7. Wait for DPLL power state disabled in DPLL_ENABLE. */ 2088 2074 if (intel_wait_for_register(dev_priv, 2089 - CNL_DPLL_ENABLE(pll->id), 2075 + CNL_DPLL_ENABLE(id), 2090 2076 PLL_POWER_STATE, 2091 2077 0, 2092 2078 5)) 2093 - DRM_ERROR("PLL %d Power not disabled\n", pll->id); 2079 + DRM_ERROR("PLL %d Power not disabled\n", id); 2094 2080 } 2095 2081 2096 2082 static bool cnl_ddi_pll_get_hw_state(struct drm_i915_private *dev_priv, 2097 2083 struct intel_shared_dpll *pll, 2098 2084 struct intel_dpll_hw_state *hw_state) 2099 2085 { 2086 + const enum intel_dpll_id id = pll->info->id; 2100 2087 uint32_t val; 2101 2088 bool ret; 2102 2089 ··· 2106 2091 2107 2092 ret = false; 2108 2093 2109 - val = I915_READ(CNL_DPLL_ENABLE(pll->id)); 2094 + val = I915_READ(CNL_DPLL_ENABLE(id)); 2110 2095 if (!(val & PLL_ENABLE)) 2111 2096 goto out; 2112 2097 2113 - val = I915_READ(CNL_DPLL_CFGCR0(pll->id)); 2098 + val = I915_READ(CNL_DPLL_CFGCR0(id)); 2114 2099 hw_state->cfgcr0 = val; 2115 2100 2116 2101 /* avoid reading back stale values if HDMI mode is not enabled */ 2117 2102 if (val & DPLL_CFGCR0_HDMI_MODE) { 2118 - hw_state->cfgcr1 = I915_READ(CNL_DPLL_CFGCR1(pll->id)); 2103 + hw_state->cfgcr1 = I915_READ(CNL_DPLL_CFGCR1(id)); 2119 2104 } 2120 2105 ret = true; 2121 2106 ··· 2387 2372 }; 2388 2373 2389 2374 static const struct dpll_info cnl_plls[] = { 2390 - { "DPLL 0", DPLL_ID_SKL_DPLL0, &cnl_ddi_pll_funcs, 0 }, 2391 - { "DPLL 1", DPLL_ID_SKL_DPLL1, &cnl_ddi_pll_funcs, 0 }, 2392 - { "DPLL 2", DPLL_ID_SKL_DPLL2, &cnl_ddi_pll_funcs, 0 }, 2393 - { NULL, -1, NULL, }, 2375 + { "DPLL 0", &cnl_ddi_pll_funcs, DPLL_ID_SKL_DPLL0, 0 }, 2376 + { "DPLL 1", &cnl_ddi_pll_funcs, DPLL_ID_SKL_DPLL1, 0 }, 2377 + { "DPLL 2", &cnl_ddi_pll_funcs, DPLL_ID_SKL_DPLL2, 0 }, 2378 + { }, 2394 2379 }; 2395 2380 2396 2381 static const struct intel_dpll_mgr cnl_pll_mgr = { ··· 2430 2415 2431 2416 dpll_info = dpll_mgr->dpll_info; 2432 2417 2433 - for (i = 0; dpll_info[i].id >= 0; i++) { 2418 + for (i = 0; dpll_info[i].name; i++) { 2434 2419 WARN_ON(i != dpll_info[i].id); 2435 - 2436 - dev_priv->shared_dplls[i].id = dpll_info[i].id; 2437 - dev_priv->shared_dplls[i].name = dpll_info[i].name; 2438 - dev_priv->shared_dplls[i].funcs = *dpll_info[i].funcs; 2439 - dev_priv->shared_dplls[i].flags = dpll_info[i].flags; 2420 + dev_priv->shared_dplls[i].info = &dpll_info[i]; 2440 2421 } 2441 2422 2442 2423 dev_priv->dpll_mgr = dpll_mgr; ··· 2492 2481 struct intel_shared_dpll_state *shared_dpll_state; 2493 2482 2494 2483 shared_dpll_state = intel_atomic_get_shared_dpll_state(state); 2495 - shared_dpll_state[dpll->id].crtc_mask &= ~(1 << crtc->pipe); 2484 + shared_dpll_state[dpll->info->id].crtc_mask &= ~(1 << crtc->pipe); 2496 2485 } 2497 2486 2498 2487 /**
+33 -23
drivers/gpu/drm/i915/intel_dpll_mgr.h
··· 206 206 }; 207 207 208 208 /** 209 + * struct dpll_info - display PLL platform specific info 210 + */ 211 + struct dpll_info { 212 + /** 213 + * @name: DPLL name; used for logging 214 + */ 215 + const char *name; 216 + 217 + /** 218 + * @funcs: platform specific hooks 219 + */ 220 + const struct intel_shared_dpll_funcs *funcs; 221 + 222 + /** 223 + * @id: unique indentifier for this DPLL; should match the index in the 224 + * dev_priv->shared_dplls array 225 + */ 226 + enum intel_dpll_id id; 227 + 228 + #define INTEL_DPLL_ALWAYS_ON (1 << 0) 229 + /** 230 + * @flags: 231 + * 232 + * INTEL_DPLL_ALWAYS_ON 233 + * Inform the state checker that the DPLL is kept enabled even if 234 + * not in use by any CRTC. 235 + */ 236 + uint32_t flags; 237 + }; 238 + 239 + /** 209 240 * struct intel_shared_dpll - display PLL with tracked state and users 210 241 */ 211 242 struct intel_shared_dpll { ··· 259 228 bool on; 260 229 261 230 /** 262 - * @name: DPLL name; used for logging 231 + * @info: platform specific info 263 232 */ 264 - const char *name; 265 - 266 - /** 267 - * @id: unique indentifier for this DPLL; should match the index in the 268 - * dev_priv->shared_dplls array 269 - */ 270 - enum intel_dpll_id id; 271 - 272 - /** 273 - * @funcs: platform specific hooks 274 - */ 275 - struct intel_shared_dpll_funcs funcs; 276 - 277 - #define INTEL_DPLL_ALWAYS_ON (1 << 0) 278 - /** 279 - * @flags: 280 - * 281 - * INTEL_DPLL_ALWAYS_ON 282 - * Inform the state checker that the DPLL is kept enabled even if 283 - * not in use by any CRTC. 284 - */ 285 - uint32_t flags; 233 + const struct dpll_info *info; 286 234 }; 287 235 288 236 #define SKL_DPLL0 0
+29 -29
drivers/gpu/drm/i915/intel_drv.h
··· 482 482 bool skip_intermediate_wm; 483 483 484 484 /* Gen9+ only */ 485 - struct skl_wm_values wm_results; 485 + struct skl_ddb_values wm_results; 486 486 487 487 struct i915_sw_fence commit_ready; 488 488 ··· 548 548 #define SKL_MAX_DST_W 4096 549 549 #define SKL_MIN_DST_H 8 550 550 #define SKL_MAX_DST_H 4096 551 + #define ICL_MAX_SRC_W 5120 552 + #define ICL_MAX_SRC_H 4096 553 + #define ICL_MAX_DST_W 5120 554 + #define ICL_MAX_DST_H 4096 555 + #define SKL_MIN_YUV_420_SRC_W 16 556 + #define SKL_MIN_YUV_420_SRC_H 16 551 557 552 558 struct intel_scaler { 553 559 int in_use; ··· 604 598 605 599 struct skl_plane_wm { 606 600 struct skl_wm_level wm[8]; 601 + struct skl_wm_level uv_wm[8]; 607 602 struct skl_wm_level trans_wm; 603 + bool is_planar; 608 604 }; 609 605 610 606 struct skl_pipe_wm { ··· 1333 1325 void gen5_disable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask); 1334 1326 void gen6_mask_pm_irq(struct drm_i915_private *dev_priv, u32 mask); 1335 1327 void gen6_unmask_pm_irq(struct drm_i915_private *dev_priv, u32 mask); 1328 + void gen11_reset_rps_interrupts(struct drm_i915_private *dev_priv); 1336 1329 void gen6_reset_rps_interrupts(struct drm_i915_private *dev_priv); 1337 1330 void gen6_enable_rps_interrupts(struct drm_i915_private *dev_priv); 1338 1331 void gen6_disable_rps_interrupts(struct drm_i915_private *dev_priv); ··· 1597 1588 enum intel_display_power_domain intel_port_to_power_domain(enum port port); 1598 1589 void intel_mode_from_pipe_config(struct drm_display_mode *mode, 1599 1590 struct intel_crtc_state *pipe_config); 1591 + void intel_crtc_arm_fifo_underrun(struct intel_crtc *crtc, 1592 + struct intel_crtc_state *crtc_state); 1600 1593 1601 1594 int skl_update_scaler_crtc(struct intel_crtc_state *crtc_state); 1602 - int skl_max_scale(struct intel_crtc *crtc, struct intel_crtc_state *crtc_state); 1595 + int skl_max_scale(struct intel_crtc *crtc, struct intel_crtc_state *crtc_state, 1596 + uint32_t pixel_format); 1603 1597 1604 1598 static inline u32 intel_plane_ggtt_offset(const struct intel_plane_state *state) 1605 1599 { ··· 1619 1607 int skl_check_plane_surface(const struct intel_crtc_state *crtc_state, 1620 1608 struct intel_plane_state *plane_state); 1621 1609 int i9xx_check_plane_surface(struct intel_plane_state *plane_state); 1610 + int skl_format_to_fourcc(int format, bool rgb_order, bool alpha); 1622 1611 1623 1612 /* intel_csr.c */ 1624 1613 void intel_csr_ucode_init(struct drm_i915_private *); ··· 1786 1773 unsigned int frontbuffer_bits, enum fb_op_origin origin); 1787 1774 void intel_fbc_cleanup_cfb(struct drm_i915_private *dev_priv); 1788 1775 void intel_fbc_handle_fifo_underrun_irq(struct drm_i915_private *dev_priv); 1776 + int intel_fbc_reset_underrun(struct drm_i915_private *dev_priv); 1789 1777 1790 1778 /* intel_hdmi.c */ 1791 1779 void intel_hdmi_init(struct drm_i915_private *dev_priv, i915_reg_t hdmi_reg, ··· 1797 1783 bool intel_hdmi_compute_config(struct intel_encoder *encoder, 1798 1784 struct intel_crtc_state *pipe_config, 1799 1785 struct drm_connector_state *conn_state); 1800 - void intel_hdmi_handle_sink_scrambling(struct intel_encoder *intel_encoder, 1786 + bool intel_hdmi_handle_sink_scrambling(struct intel_encoder *encoder, 1801 1787 struct drm_connector *connector, 1802 1788 bool high_tmds_clock_ratio, 1803 1789 bool scrambling); ··· 1891 1877 void intel_psr_disable(struct intel_dp *intel_dp, 1892 1878 const struct intel_crtc_state *old_crtc_state); 1893 1879 void intel_psr_invalidate(struct drm_i915_private *dev_priv, 1894 - unsigned frontbuffer_bits); 1880 + unsigned frontbuffer_bits, 1881 + enum fb_op_origin origin); 1895 1882 void intel_psr_flush(struct drm_i915_private *dev_priv, 1896 1883 unsigned frontbuffer_bits, 1897 1884 enum fb_op_origin origin); ··· 2061 2046 bool skl_plane_get_hw_state(struct intel_plane *plane); 2062 2047 bool skl_plane_has_ccs(struct drm_i915_private *dev_priv, 2063 2048 enum pipe pipe, enum plane_id plane_id); 2049 + bool intel_format_is_yuv(uint32_t format); 2064 2050 2065 2051 /* intel_tv.c */ 2066 2052 void intel_tv_init(struct drm_i915_private *dev_priv); ··· 2098 2082 return to_intel_crtc_state(crtc_state); 2099 2083 } 2100 2084 2101 - static inline struct intel_crtc_state * 2102 - intel_atomic_get_existing_crtc_state(struct drm_atomic_state *state, 2103 - struct intel_crtc *crtc) 2104 - { 2105 - struct drm_crtc_state *crtc_state; 2106 - 2107 - crtc_state = drm_atomic_get_existing_crtc_state(state, &crtc->base); 2108 - 2109 - if (crtc_state) 2110 - return to_intel_crtc_state(crtc_state); 2111 - else 2112 - return NULL; 2113 - } 2114 - 2115 - static inline struct intel_plane_state * 2116 - intel_atomic_get_existing_plane_state(struct drm_atomic_state *state, 2117 - struct intel_plane *plane) 2118 - { 2119 - struct drm_plane_state *plane_state; 2120 - 2121 - plane_state = drm_atomic_get_existing_plane_state(state, &plane->base); 2122 - 2123 - return to_intel_plane_state(plane_state); 2124 - } 2125 - 2126 2085 int intel_atomic_setup_scalers(struct drm_i915_private *dev_priv, 2127 2086 struct intel_crtc *intel_crtc, 2128 2087 struct intel_crtc_state *crtc_state); ··· 2129 2138 #ifdef CONFIG_DEBUG_FS 2130 2139 int intel_crtc_set_crc_source(struct drm_crtc *crtc, const char *source_name, 2131 2140 size_t *values_cnt); 2141 + void intel_crtc_disable_pipe_crc(struct intel_crtc *crtc); 2142 + void intel_crtc_enable_pipe_crc(struct intel_crtc *crtc); 2132 2143 #else 2133 2144 #define intel_crtc_set_crc_source NULL 2145 + static inline void intel_crtc_disable_pipe_crc(struct intel_crtc *crtc) 2146 + { 2147 + } 2148 + 2149 + static inline void intel_crtc_enable_pipe_crc(struct intel_crtc *crtc) 2150 + { 2151 + } 2134 2152 #endif 2135 2153 extern const struct file_operations i915_display_crc_ctl_fops; 2136 2154 #endif /* __INTEL_DRV_H__ */
+105 -691
drivers/gpu/drm/i915/intel_engine_cs.c
··· 81 81 }, 82 82 }; 83 83 84 + #define MAX_MMIO_BASES 3 84 85 struct engine_info { 85 86 unsigned int hw_id; 86 87 unsigned int uabi_id; 87 88 u8 class; 88 89 u8 instance; 89 - u32 mmio_base; 90 - unsigned irq_shift; 90 + /* mmio bases table *must* be sorted in reverse gen order */ 91 + struct engine_mmio_base { 92 + u32 gen : 8; 93 + u32 base : 24; 94 + } mmio_bases[MAX_MMIO_BASES]; 91 95 }; 92 96 93 97 static const struct engine_info intel_engines[] = { ··· 100 96 .uabi_id = I915_EXEC_RENDER, 101 97 .class = RENDER_CLASS, 102 98 .instance = 0, 103 - .mmio_base = RENDER_RING_BASE, 104 - .irq_shift = GEN8_RCS_IRQ_SHIFT, 99 + .mmio_bases = { 100 + { .gen = 1, .base = RENDER_RING_BASE } 101 + }, 105 102 }, 106 103 [BCS] = { 107 104 .hw_id = BCS_HW, 108 105 .uabi_id = I915_EXEC_BLT, 109 106 .class = COPY_ENGINE_CLASS, 110 107 .instance = 0, 111 - .mmio_base = BLT_RING_BASE, 112 - .irq_shift = GEN8_BCS_IRQ_SHIFT, 108 + .mmio_bases = { 109 + { .gen = 6, .base = BLT_RING_BASE } 110 + }, 113 111 }, 114 112 [VCS] = { 115 113 .hw_id = VCS_HW, 116 114 .uabi_id = I915_EXEC_BSD, 117 115 .class = VIDEO_DECODE_CLASS, 118 116 .instance = 0, 119 - .mmio_base = GEN6_BSD_RING_BASE, 120 - .irq_shift = GEN8_VCS1_IRQ_SHIFT, 117 + .mmio_bases = { 118 + { .gen = 11, .base = GEN11_BSD_RING_BASE }, 119 + { .gen = 6, .base = GEN6_BSD_RING_BASE }, 120 + { .gen = 4, .base = BSD_RING_BASE } 121 + }, 121 122 }, 122 123 [VCS2] = { 123 124 .hw_id = VCS2_HW, 124 125 .uabi_id = I915_EXEC_BSD, 125 126 .class = VIDEO_DECODE_CLASS, 126 127 .instance = 1, 127 - .mmio_base = GEN8_BSD2_RING_BASE, 128 - .irq_shift = GEN8_VCS2_IRQ_SHIFT, 128 + .mmio_bases = { 129 + { .gen = 11, .base = GEN11_BSD2_RING_BASE }, 130 + { .gen = 8, .base = GEN8_BSD2_RING_BASE } 131 + }, 129 132 }, 130 133 [VCS3] = { 131 134 .hw_id = VCS3_HW, 132 135 .uabi_id = I915_EXEC_BSD, 133 136 .class = VIDEO_DECODE_CLASS, 134 137 .instance = 2, 135 - .mmio_base = GEN11_BSD3_RING_BASE, 136 - .irq_shift = 0, /* not used */ 138 + .mmio_bases = { 139 + { .gen = 11, .base = GEN11_BSD3_RING_BASE } 140 + }, 137 141 }, 138 142 [VCS4] = { 139 143 .hw_id = VCS4_HW, 140 144 .uabi_id = I915_EXEC_BSD, 141 145 .class = VIDEO_DECODE_CLASS, 142 146 .instance = 3, 143 - .mmio_base = GEN11_BSD4_RING_BASE, 144 - .irq_shift = 0, /* not used */ 147 + .mmio_bases = { 148 + { .gen = 11, .base = GEN11_BSD4_RING_BASE } 149 + }, 145 150 }, 146 151 [VECS] = { 147 152 .hw_id = VECS_HW, 148 153 .uabi_id = I915_EXEC_VEBOX, 149 154 .class = VIDEO_ENHANCEMENT_CLASS, 150 155 .instance = 0, 151 - .mmio_base = VEBOX_RING_BASE, 152 - .irq_shift = GEN8_VECS_IRQ_SHIFT, 156 + .mmio_bases = { 157 + { .gen = 11, .base = GEN11_VEBOX_RING_BASE }, 158 + { .gen = 7, .base = VEBOX_RING_BASE } 159 + }, 153 160 }, 154 161 [VECS2] = { 155 162 .hw_id = VECS2_HW, 156 163 .uabi_id = I915_EXEC_VEBOX, 157 164 .class = VIDEO_ENHANCEMENT_CLASS, 158 165 .instance = 1, 159 - .mmio_base = GEN11_VEBOX2_RING_BASE, 160 - .irq_shift = 0, /* not used */ 166 + .mmio_bases = { 167 + { .gen = 11, .base = GEN11_VEBOX2_RING_BASE } 168 + }, 161 169 }, 162 170 }; 163 171 ··· 239 223 } 240 224 } 241 225 226 + static u32 __engine_mmio_base(struct drm_i915_private *i915, 227 + const struct engine_mmio_base *bases) 228 + { 229 + int i; 230 + 231 + for (i = 0; i < MAX_MMIO_BASES; i++) 232 + if (INTEL_GEN(i915) >= bases[i].gen) 233 + break; 234 + 235 + GEM_BUG_ON(i == MAX_MMIO_BASES); 236 + GEM_BUG_ON(!bases[i].base); 237 + 238 + return bases[i].base; 239 + } 240 + 241 + static void __sprint_engine_name(char *name, const struct engine_info *info) 242 + { 243 + WARN_ON(snprintf(name, INTEL_ENGINE_CS_MAX_NAME, "%s%u", 244 + intel_engine_classes[info->class].name, 245 + info->instance) >= INTEL_ENGINE_CS_MAX_NAME); 246 + } 247 + 242 248 static int 243 249 intel_engine_setup(struct drm_i915_private *dev_priv, 244 250 enum intel_engine_id id) 245 251 { 246 252 const struct engine_info *info = &intel_engines[id]; 247 - const struct engine_class_info *class_info; 248 253 struct intel_engine_cs *engine; 249 254 250 255 GEM_BUG_ON(info->class >= ARRAY_SIZE(intel_engine_classes)); 251 - class_info = &intel_engine_classes[info->class]; 252 256 253 257 BUILD_BUG_ON(MAX_ENGINE_CLASS >= BIT(GEN11_ENGINE_CLASS_WIDTH)); 254 258 BUILD_BUG_ON(MAX_ENGINE_INSTANCE >= BIT(GEN11_ENGINE_INSTANCE_WIDTH)); ··· 289 253 290 254 engine->id = id; 291 255 engine->i915 = dev_priv; 292 - WARN_ON(snprintf(engine->name, sizeof(engine->name), "%s%u", 293 - class_info->name, info->instance) >= 294 - sizeof(engine->name)); 256 + __sprint_engine_name(engine->name, info); 295 257 engine->hw_id = engine->guc_id = info->hw_id; 296 - if (INTEL_GEN(dev_priv) >= 11) { 297 - switch (engine->id) { 298 - case VCS: 299 - engine->mmio_base = GEN11_BSD_RING_BASE; 300 - break; 301 - case VCS2: 302 - engine->mmio_base = GEN11_BSD2_RING_BASE; 303 - break; 304 - case VECS: 305 - engine->mmio_base = GEN11_VEBOX_RING_BASE; 306 - break; 307 - default: 308 - /* take the original value for all other engines */ 309 - engine->mmio_base = info->mmio_base; 310 - break; 311 - } 312 - } else { 313 - engine->mmio_base = info->mmio_base; 314 - } 315 - engine->irq_shift = info->irq_shift; 258 + engine->mmio_base = __engine_mmio_base(dev_priv, info->mmio_bases); 316 259 engine->class = info->class; 317 260 engine->instance = info->instance; 318 261 319 262 engine->uabi_id = info->uabi_id; 320 - engine->uabi_class = class_info->uabi_class; 263 + engine->uabi_class = intel_engine_classes[info->class].uabi_class; 321 264 322 265 engine->context_size = __intel_engine_context_size(dev_priv, 323 266 engine->class); ··· 456 441 engine->timeline = &engine->i915->gt.global_timeline.engine[engine->id]; 457 442 } 458 443 444 + static void intel_engine_init_batch_pool(struct intel_engine_cs *engine) 445 + { 446 + i915_gem_batch_pool_init(&engine->batch_pool, engine); 447 + } 448 + 459 449 static bool csb_force_mmio(struct drm_i915_private *i915) 460 450 { 461 451 /* ··· 473 453 474 454 /* Older GVT emulation depends upon intercepting CSB mmio */ 475 455 if (intel_vgpu_active(i915) && !intel_vgpu_has_hwsp_emulation(i915)) 456 + return true; 457 + 458 + if (IS_CANNONLAKE(i915)) 476 459 return true; 477 460 478 461 return false; ··· 508 485 void intel_engine_setup_common(struct intel_engine_cs *engine) 509 486 { 510 487 intel_engine_init_execlist(engine); 511 - 512 488 intel_engine_init_timeline(engine); 513 489 intel_engine_init_hangcheck(engine); 514 - i915_gem_batch_pool_init(engine, &engine->batch_pool); 515 - 490 + intel_engine_init_batch_pool(engine); 516 491 intel_engine_init_cmd_parser(engine); 517 492 } 518 493 ··· 803 782 read_subslice_reg(struct drm_i915_private *dev_priv, int slice, 804 783 int subslice, i915_reg_t reg) 805 784 { 785 + uint32_t mcr_slice_subslice_mask; 786 + uint32_t mcr_slice_subslice_select; 806 787 uint32_t mcr; 807 788 uint32_t ret; 808 789 enum forcewake_domains fw_domains; 790 + 791 + if (INTEL_GEN(dev_priv) >= 11) { 792 + mcr_slice_subslice_mask = GEN11_MCR_SLICE_MASK | 793 + GEN11_MCR_SUBSLICE_MASK; 794 + mcr_slice_subslice_select = GEN11_MCR_SLICE(slice) | 795 + GEN11_MCR_SUBSLICE(subslice); 796 + } else { 797 + mcr_slice_subslice_mask = GEN8_MCR_SLICE_MASK | 798 + GEN8_MCR_SUBSLICE_MASK; 799 + mcr_slice_subslice_select = GEN8_MCR_SLICE(slice) | 800 + GEN8_MCR_SUBSLICE(subslice); 801 + } 809 802 810 803 fw_domains = intel_uncore_forcewake_for_reg(dev_priv, reg, 811 804 FW_REG_READ); ··· 835 800 * The HW expects the slice and sublice selectors to be reset to 0 836 801 * after reading out the registers. 837 802 */ 838 - WARN_ON_ONCE(mcr & (GEN8_MCR_SLICE_MASK | GEN8_MCR_SUBSLICE_MASK)); 839 - mcr &= ~(GEN8_MCR_SLICE_MASK | GEN8_MCR_SUBSLICE_MASK); 840 - mcr |= GEN8_MCR_SLICE(slice) | GEN8_MCR_SUBSLICE(subslice); 803 + WARN_ON_ONCE(mcr & mcr_slice_subslice_mask); 804 + mcr &= ~mcr_slice_subslice_mask; 805 + mcr |= mcr_slice_subslice_select; 841 806 I915_WRITE_FW(GEN8_MCR_SELECTOR, mcr); 842 807 843 808 ret = I915_READ_FW(reg); 844 809 845 - mcr &= ~(GEN8_MCR_SLICE_MASK | GEN8_MCR_SUBSLICE_MASK); 810 + mcr &= ~mcr_slice_subslice_mask; 846 811 I915_WRITE_FW(GEN8_MCR_SELECTOR, mcr); 847 812 848 813 intel_uncore_forcewake_put__locked(dev_priv, fw_domains); ··· 904 869 instdone->instdone = I915_READ(GEN2_INSTDONE); 905 870 break; 906 871 } 907 - } 908 - 909 - static int wa_add(struct drm_i915_private *dev_priv, 910 - i915_reg_t addr, 911 - const u32 mask, const u32 val) 912 - { 913 - const u32 idx = dev_priv->workarounds.count; 914 - 915 - if (WARN_ON(idx >= I915_MAX_WA_REGS)) 916 - return -ENOSPC; 917 - 918 - dev_priv->workarounds.reg[idx].addr = addr; 919 - dev_priv->workarounds.reg[idx].value = val; 920 - dev_priv->workarounds.reg[idx].mask = mask; 921 - 922 - dev_priv->workarounds.count++; 923 - 924 - return 0; 925 - } 926 - 927 - #define WA_REG(addr, mask, val) do { \ 928 - const int r = wa_add(dev_priv, (addr), (mask), (val)); \ 929 - if (r) \ 930 - return r; \ 931 - } while (0) 932 - 933 - #define WA_SET_BIT_MASKED(addr, mask) \ 934 - WA_REG(addr, (mask), _MASKED_BIT_ENABLE(mask)) 935 - 936 - #define WA_CLR_BIT_MASKED(addr, mask) \ 937 - WA_REG(addr, (mask), _MASKED_BIT_DISABLE(mask)) 938 - 939 - #define WA_SET_FIELD_MASKED(addr, mask, value) \ 940 - WA_REG(addr, mask, _MASKED_FIELD(mask, value)) 941 - 942 - static int wa_ring_whitelist_reg(struct intel_engine_cs *engine, 943 - i915_reg_t reg) 944 - { 945 - struct drm_i915_private *dev_priv = engine->i915; 946 - struct i915_workarounds *wa = &dev_priv->workarounds; 947 - const uint32_t index = wa->hw_whitelist_count[engine->id]; 948 - 949 - if (WARN_ON(index >= RING_MAX_NONPRIV_SLOTS)) 950 - return -EINVAL; 951 - 952 - I915_WRITE(RING_FORCE_TO_NONPRIV(engine->mmio_base, index), 953 - i915_mmio_reg_offset(reg)); 954 - wa->hw_whitelist_count[engine->id]++; 955 - 956 - return 0; 957 - } 958 - 959 - static int gen8_init_workarounds(struct intel_engine_cs *engine) 960 - { 961 - struct drm_i915_private *dev_priv = engine->i915; 962 - 963 - WA_SET_BIT_MASKED(INSTPM, INSTPM_FORCE_ORDERING); 964 - 965 - /* WaDisableAsyncFlipPerfMode:bdw,chv */ 966 - WA_SET_BIT_MASKED(MI_MODE, ASYNC_FLIP_PERF_DISABLE); 967 - 968 - /* WaDisablePartialInstShootdown:bdw,chv */ 969 - WA_SET_BIT_MASKED(GEN8_ROW_CHICKEN, 970 - PARTIAL_INSTRUCTION_SHOOTDOWN_DISABLE); 971 - 972 - /* Use Force Non-Coherent whenever executing a 3D context. This is a 973 - * workaround for for a possible hang in the unlikely event a TLB 974 - * invalidation occurs during a PSD flush. 975 - */ 976 - /* WaForceEnableNonCoherent:bdw,chv */ 977 - /* WaHdcDisableFetchWhenMasked:bdw,chv */ 978 - WA_SET_BIT_MASKED(HDC_CHICKEN0, 979 - HDC_DONOT_FETCH_MEM_WHEN_MASKED | 980 - HDC_FORCE_NON_COHERENT); 981 - 982 - /* From the Haswell PRM, Command Reference: Registers, CACHE_MODE_0: 983 - * "The Hierarchical Z RAW Stall Optimization allows non-overlapping 984 - * polygons in the same 8x4 pixel/sample area to be processed without 985 - * stalling waiting for the earlier ones to write to Hierarchical Z 986 - * buffer." 987 - * 988 - * This optimization is off by default for BDW and CHV; turn it on. 989 - */ 990 - WA_CLR_BIT_MASKED(CACHE_MODE_0_GEN7, HIZ_RAW_STALL_OPT_DISABLE); 991 - 992 - /* Wa4x4STCOptimizationDisable:bdw,chv */ 993 - WA_SET_BIT_MASKED(CACHE_MODE_1, GEN8_4x4_STC_OPTIMIZATION_DISABLE); 994 - 995 - /* 996 - * BSpec recommends 8x4 when MSAA is used, 997 - * however in practice 16x4 seems fastest. 998 - * 999 - * Note that PS/WM thread counts depend on the WIZ hashing 1000 - * disable bit, which we don't touch here, but it's good 1001 - * to keep in mind (see 3DSTATE_PS and 3DSTATE_WM). 1002 - */ 1003 - WA_SET_FIELD_MASKED(GEN7_GT_MODE, 1004 - GEN6_WIZ_HASHING_MASK, 1005 - GEN6_WIZ_HASHING_16x4); 1006 - 1007 - return 0; 1008 - } 1009 - 1010 - static int bdw_init_workarounds(struct intel_engine_cs *engine) 1011 - { 1012 - struct drm_i915_private *dev_priv = engine->i915; 1013 - int ret; 1014 - 1015 - ret = gen8_init_workarounds(engine); 1016 - if (ret) 1017 - return ret; 1018 - 1019 - /* WaDisableThreadStallDopClockGating:bdw (pre-production) */ 1020 - WA_SET_BIT_MASKED(GEN8_ROW_CHICKEN, STALL_DOP_GATING_DISABLE); 1021 - 1022 - /* WaDisableDopClockGating:bdw 1023 - * 1024 - * Also see the related UCGTCL1 write in broadwell_init_clock_gating() 1025 - * to disable EUTC clock gating. 1026 - */ 1027 - WA_SET_BIT_MASKED(GEN7_ROW_CHICKEN2, 1028 - DOP_CLOCK_GATING_DISABLE); 1029 - 1030 - WA_SET_BIT_MASKED(HALF_SLICE_CHICKEN3, 1031 - GEN8_SAMPLER_POWER_BYPASS_DIS); 1032 - 1033 - WA_SET_BIT_MASKED(HDC_CHICKEN0, 1034 - /* WaForceContextSaveRestoreNonCoherent:bdw */ 1035 - HDC_FORCE_CONTEXT_SAVE_RESTORE_NON_COHERENT | 1036 - /* WaDisableFenceDestinationToSLM:bdw (pre-prod) */ 1037 - (IS_BDW_GT3(dev_priv) ? HDC_FENCE_DEST_SLM_DISABLE : 0)); 1038 - 1039 - return 0; 1040 - } 1041 - 1042 - static int chv_init_workarounds(struct intel_engine_cs *engine) 1043 - { 1044 - struct drm_i915_private *dev_priv = engine->i915; 1045 - int ret; 1046 - 1047 - ret = gen8_init_workarounds(engine); 1048 - if (ret) 1049 - return ret; 1050 - 1051 - /* WaDisableThreadStallDopClockGating:chv */ 1052 - WA_SET_BIT_MASKED(GEN8_ROW_CHICKEN, STALL_DOP_GATING_DISABLE); 1053 - 1054 - /* Improve HiZ throughput on CHV. */ 1055 - WA_SET_BIT_MASKED(HIZ_CHICKEN, CHV_HZ_8X8_MODE_IN_1X); 1056 - 1057 - return 0; 1058 - } 1059 - 1060 - static int gen9_init_workarounds(struct intel_engine_cs *engine) 1061 - { 1062 - struct drm_i915_private *dev_priv = engine->i915; 1063 - int ret; 1064 - 1065 - /* WaConextSwitchWithConcurrentTLBInvalidate:skl,bxt,kbl,glk,cfl */ 1066 - I915_WRITE(GEN9_CSFE_CHICKEN1_RCS, _MASKED_BIT_ENABLE(GEN9_PREEMPT_GPGPU_SYNC_SWITCH_DISABLE)); 1067 - 1068 - /* WaEnableLbsSlaRetryTimerDecrement:skl,bxt,kbl,glk,cfl */ 1069 - I915_WRITE(BDW_SCRATCH1, I915_READ(BDW_SCRATCH1) | 1070 - GEN9_LBS_SLA_RETRY_TIMER_DECREMENT_ENABLE); 1071 - 1072 - /* WaDisableKillLogic:bxt,skl,kbl */ 1073 - if (!IS_COFFEELAKE(dev_priv)) 1074 - I915_WRITE(GAM_ECOCHK, I915_READ(GAM_ECOCHK) | 1075 - ECOCHK_DIS_TLB); 1076 - 1077 - if (HAS_LLC(dev_priv)) { 1078 - /* WaCompressedResourceSamplerPbeMediaNewHashMode:skl,kbl 1079 - * 1080 - * Must match Display Engine. See 1081 - * WaCompressedResourceDisplayNewHashMode. 1082 - */ 1083 - WA_SET_BIT_MASKED(COMMON_SLICE_CHICKEN2, 1084 - GEN9_PBE_COMPRESSED_HASH_SELECTION); 1085 - WA_SET_BIT_MASKED(GEN9_HALF_SLICE_CHICKEN7, 1086 - GEN9_SAMPLER_HASH_COMPRESSED_READ_ADDR); 1087 - 1088 - I915_WRITE(MMCD_MISC_CTRL, 1089 - I915_READ(MMCD_MISC_CTRL) | 1090 - MMCD_PCLA | 1091 - MMCD_HOTSPOT_EN); 1092 - } 1093 - 1094 - /* WaClearFlowControlGpgpuContextSave:skl,bxt,kbl,glk,cfl */ 1095 - /* WaDisablePartialInstShootdown:skl,bxt,kbl,glk,cfl */ 1096 - WA_SET_BIT_MASKED(GEN8_ROW_CHICKEN, 1097 - FLOW_CONTROL_ENABLE | 1098 - PARTIAL_INSTRUCTION_SHOOTDOWN_DISABLE); 1099 - 1100 - /* Syncing dependencies between camera and graphics:skl,bxt,kbl */ 1101 - if (!IS_COFFEELAKE(dev_priv)) 1102 - WA_SET_BIT_MASKED(HALF_SLICE_CHICKEN3, 1103 - GEN9_DISABLE_OCL_OOB_SUPPRESS_LOGIC); 1104 - 1105 - /* WaEnableYV12BugFixInHalfSliceChicken7:skl,bxt,kbl,glk,cfl */ 1106 - /* WaEnableSamplerGPGPUPreemptionSupport:skl,bxt,kbl,cfl */ 1107 - WA_SET_BIT_MASKED(GEN9_HALF_SLICE_CHICKEN7, 1108 - GEN9_ENABLE_YV12_BUGFIX | 1109 - GEN9_ENABLE_GPGPU_PREEMPTION); 1110 - 1111 - /* Wa4x4STCOptimizationDisable:skl,bxt,kbl,glk,cfl */ 1112 - /* WaDisablePartialResolveInVc:skl,bxt,kbl,cfl */ 1113 - WA_SET_BIT_MASKED(CACHE_MODE_1, (GEN8_4x4_STC_OPTIMIZATION_DISABLE | 1114 - GEN9_PARTIAL_RESOLVE_IN_VC_DISABLE)); 1115 - 1116 - /* WaCcsTlbPrefetchDisable:skl,bxt,kbl,glk,cfl */ 1117 - WA_CLR_BIT_MASKED(GEN9_HALF_SLICE_CHICKEN5, 1118 - GEN9_CCS_TLB_PREFETCH_ENABLE); 1119 - 1120 - /* WaForceContextSaveRestoreNonCoherent:skl,bxt,kbl,cfl */ 1121 - WA_SET_BIT_MASKED(HDC_CHICKEN0, 1122 - HDC_FORCE_CONTEXT_SAVE_RESTORE_NON_COHERENT | 1123 - HDC_FORCE_CSR_NON_COHERENT_OVR_DISABLE); 1124 - 1125 - /* WaForceEnableNonCoherent and WaDisableHDCInvalidation are 1126 - * both tied to WaForceContextSaveRestoreNonCoherent 1127 - * in some hsds for skl. We keep the tie for all gen9. The 1128 - * documentation is a bit hazy and so we want to get common behaviour, 1129 - * even though there is no clear evidence we would need both on kbl/bxt. 1130 - * This area has been source of system hangs so we play it safe 1131 - * and mimic the skl regardless of what bspec says. 1132 - * 1133 - * Use Force Non-Coherent whenever executing a 3D context. This 1134 - * is a workaround for a possible hang in the unlikely event 1135 - * a TLB invalidation occurs during a PSD flush. 1136 - */ 1137 - 1138 - /* WaForceEnableNonCoherent:skl,bxt,kbl,cfl */ 1139 - WA_SET_BIT_MASKED(HDC_CHICKEN0, 1140 - HDC_FORCE_NON_COHERENT); 1141 - 1142 - /* WaDisableHDCInvalidation:skl,bxt,kbl,cfl */ 1143 - I915_WRITE(GAM_ECOCHK, I915_READ(GAM_ECOCHK) | 1144 - BDW_DISABLE_HDC_INVALIDATION); 1145 - 1146 - /* WaDisableSamplerPowerBypassForSOPingPong:skl,bxt,kbl,cfl */ 1147 - if (IS_SKYLAKE(dev_priv) || 1148 - IS_KABYLAKE(dev_priv) || 1149 - IS_COFFEELAKE(dev_priv)) 1150 - WA_SET_BIT_MASKED(HALF_SLICE_CHICKEN3, 1151 - GEN8_SAMPLER_POWER_BYPASS_DIS); 1152 - 1153 - /* WaDisableSTUnitPowerOptimization:skl,bxt,kbl,glk,cfl */ 1154 - WA_SET_BIT_MASKED(HALF_SLICE_CHICKEN2, GEN8_ST_PO_DISABLE); 1155 - 1156 - /* WaProgramL3SqcReg1DefaultForPerf:bxt,glk */ 1157 - if (IS_GEN9_LP(dev_priv)) { 1158 - u32 val = I915_READ(GEN8_L3SQCREG1); 1159 - 1160 - val &= ~L3_PRIO_CREDITS_MASK; 1161 - val |= L3_GENERAL_PRIO_CREDITS(62) | L3_HIGH_PRIO_CREDITS(2); 1162 - I915_WRITE(GEN8_L3SQCREG1, val); 1163 - } 1164 - 1165 - /* WaOCLCoherentLineFlush:skl,bxt,kbl,cfl */ 1166 - I915_WRITE(GEN8_L3SQCREG4, (I915_READ(GEN8_L3SQCREG4) | 1167 - GEN8_LQSC_FLUSH_COHERENT_LINES)); 1168 - 1169 - /* 1170 - * Supporting preemption with fine-granularity requires changes in the 1171 - * batch buffer programming. Since we can't break old userspace, we 1172 - * need to set our default preemption level to safe value. Userspace is 1173 - * still able to use more fine-grained preemption levels, since in 1174 - * WaEnablePreemptionGranularityControlByUMD we're whitelisting the 1175 - * per-ctx register. As such, WaDisable{3D,GPGPU}MidCmdPreemption are 1176 - * not real HW workarounds, but merely a way to start using preemption 1177 - * while maintaining old contract with userspace. 1178 - */ 1179 - 1180 - /* WaDisable3DMidCmdPreemption:skl,bxt,glk,cfl,[cnl] */ 1181 - WA_CLR_BIT_MASKED(GEN8_CS_CHICKEN1, GEN9_PREEMPT_3D_OBJECT_LEVEL); 1182 - 1183 - /* WaDisableGPGPUMidCmdPreemption:skl,bxt,blk,cfl,[cnl] */ 1184 - WA_SET_FIELD_MASKED(GEN8_CS_CHICKEN1, GEN9_PREEMPT_GPGPU_LEVEL_MASK, 1185 - GEN9_PREEMPT_GPGPU_COMMAND_LEVEL); 1186 - 1187 - /* WaVFEStateAfterPipeControlwithMediaStateClear:skl,bxt,glk,cfl */ 1188 - ret = wa_ring_whitelist_reg(engine, GEN9_CTX_PREEMPT_REG); 1189 - if (ret) 1190 - return ret; 1191 - 1192 - /* WaEnablePreemptionGranularityControlByUMD:skl,bxt,kbl,cfl,[cnl] */ 1193 - I915_WRITE(GEN7_FF_SLICE_CS_CHICKEN1, 1194 - _MASKED_BIT_ENABLE(GEN9_FFSC_PERCTX_PREEMPT_CTRL)); 1195 - ret = wa_ring_whitelist_reg(engine, GEN8_CS_CHICKEN1); 1196 - if (ret) 1197 - return ret; 1198 - 1199 - /* WaAllowUMDToModifyHDCChicken1:skl,bxt,kbl,glk,cfl */ 1200 - ret = wa_ring_whitelist_reg(engine, GEN8_HDC_CHICKEN1); 1201 - if (ret) 1202 - return ret; 1203 - 1204 - return 0; 1205 - } 1206 - 1207 - static int skl_tune_iz_hashing(struct intel_engine_cs *engine) 1208 - { 1209 - struct drm_i915_private *dev_priv = engine->i915; 1210 - u8 vals[3] = { 0, 0, 0 }; 1211 - unsigned int i; 1212 - 1213 - for (i = 0; i < 3; i++) { 1214 - u8 ss; 1215 - 1216 - /* 1217 - * Only consider slices where one, and only one, subslice has 7 1218 - * EUs 1219 - */ 1220 - if (!is_power_of_2(INTEL_INFO(dev_priv)->sseu.subslice_7eu[i])) 1221 - continue; 1222 - 1223 - /* 1224 - * subslice_7eu[i] != 0 (because of the check above) and 1225 - * ss_max == 4 (maximum number of subslices possible per slice) 1226 - * 1227 - * -> 0 <= ss <= 3; 1228 - */ 1229 - ss = ffs(INTEL_INFO(dev_priv)->sseu.subslice_7eu[i]) - 1; 1230 - vals[i] = 3 - ss; 1231 - } 1232 - 1233 - if (vals[0] == 0 && vals[1] == 0 && vals[2] == 0) 1234 - return 0; 1235 - 1236 - /* Tune IZ hashing. See intel_device_info_runtime_init() */ 1237 - WA_SET_FIELD_MASKED(GEN7_GT_MODE, 1238 - GEN9_IZ_HASHING_MASK(2) | 1239 - GEN9_IZ_HASHING_MASK(1) | 1240 - GEN9_IZ_HASHING_MASK(0), 1241 - GEN9_IZ_HASHING(2, vals[2]) | 1242 - GEN9_IZ_HASHING(1, vals[1]) | 1243 - GEN9_IZ_HASHING(0, vals[0])); 1244 - 1245 - return 0; 1246 - } 1247 - 1248 - static int skl_init_workarounds(struct intel_engine_cs *engine) 1249 - { 1250 - struct drm_i915_private *dev_priv = engine->i915; 1251 - int ret; 1252 - 1253 - ret = gen9_init_workarounds(engine); 1254 - if (ret) 1255 - return ret; 1256 - 1257 - /* WaEnableGapsTsvCreditFix:skl */ 1258 - I915_WRITE(GEN8_GARBCNTL, (I915_READ(GEN8_GARBCNTL) | 1259 - GEN9_GAPS_TSV_CREDIT_DISABLE)); 1260 - 1261 - /* WaDisableGafsUnitClkGating:skl */ 1262 - I915_WRITE(GEN7_UCGCTL4, (I915_READ(GEN7_UCGCTL4) | 1263 - GEN8_EU_GAUNIT_CLOCK_GATE_DISABLE)); 1264 - 1265 - /* WaInPlaceDecompressionHang:skl */ 1266 - if (IS_SKL_REVID(dev_priv, SKL_REVID_H0, REVID_FOREVER)) 1267 - I915_WRITE(GEN9_GAMT_ECO_REG_RW_IA, 1268 - (I915_READ(GEN9_GAMT_ECO_REG_RW_IA) | 1269 - GAMT_ECO_ENABLE_IN_PLACE_DECOMPRESS)); 1270 - 1271 - /* WaDisableLSQCROPERFforOCL:skl */ 1272 - ret = wa_ring_whitelist_reg(engine, GEN8_L3SQCREG4); 1273 - if (ret) 1274 - return ret; 1275 - 1276 - return skl_tune_iz_hashing(engine); 1277 - } 1278 - 1279 - static int bxt_init_workarounds(struct intel_engine_cs *engine) 1280 - { 1281 - struct drm_i915_private *dev_priv = engine->i915; 1282 - int ret; 1283 - 1284 - ret = gen9_init_workarounds(engine); 1285 - if (ret) 1286 - return ret; 1287 - 1288 - /* WaDisableThreadStallDopClockGating:bxt */ 1289 - WA_SET_BIT_MASKED(GEN8_ROW_CHICKEN, 1290 - STALL_DOP_GATING_DISABLE); 1291 - 1292 - /* WaDisablePooledEuLoadBalancingFix:bxt */ 1293 - I915_WRITE(FF_SLICE_CS_CHICKEN2, 1294 - _MASKED_BIT_ENABLE(GEN9_POOLED_EU_LOAD_BALANCING_FIX_DISABLE)); 1295 - 1296 - /* WaToEnableHwFixForPushConstHWBug:bxt */ 1297 - WA_SET_BIT_MASKED(COMMON_SLICE_CHICKEN2, 1298 - GEN8_SBE_DISABLE_REPLAY_BUF_OPTIMIZATION); 1299 - 1300 - /* WaInPlaceDecompressionHang:bxt */ 1301 - I915_WRITE(GEN9_GAMT_ECO_REG_RW_IA, 1302 - (I915_READ(GEN9_GAMT_ECO_REG_RW_IA) | 1303 - GAMT_ECO_ENABLE_IN_PLACE_DECOMPRESS)); 1304 - 1305 - return 0; 1306 - } 1307 - 1308 - static int cnl_init_workarounds(struct intel_engine_cs *engine) 1309 - { 1310 - struct drm_i915_private *dev_priv = engine->i915; 1311 - int ret; 1312 - 1313 - /* WaDisableI2mCycleOnWRPort:cnl (pre-prod) */ 1314 - if (IS_CNL_REVID(dev_priv, CNL_REVID_B0, CNL_REVID_B0)) 1315 - I915_WRITE(GAMT_CHKN_BIT_REG, 1316 - (I915_READ(GAMT_CHKN_BIT_REG) | 1317 - GAMT_CHKN_DISABLE_I2M_CYCLE_ON_WR_PORT)); 1318 - 1319 - /* WaForceContextSaveRestoreNonCoherent:cnl */ 1320 - WA_SET_BIT_MASKED(CNL_HDC_CHICKEN0, 1321 - HDC_FORCE_CONTEXT_SAVE_RESTORE_NON_COHERENT); 1322 - 1323 - /* WaThrottleEUPerfToAvoidTDBackPressure:cnl(pre-prod) */ 1324 - if (IS_CNL_REVID(dev_priv, CNL_REVID_B0, CNL_REVID_B0)) 1325 - WA_SET_BIT_MASKED(GEN8_ROW_CHICKEN, THROTTLE_12_5); 1326 - 1327 - /* WaDisableReplayBufferBankArbitrationOptimization:cnl */ 1328 - WA_SET_BIT_MASKED(COMMON_SLICE_CHICKEN2, 1329 - GEN8_SBE_DISABLE_REPLAY_BUF_OPTIMIZATION); 1330 - 1331 - /* WaDisableEnhancedSBEVertexCaching:cnl (pre-prod) */ 1332 - if (IS_CNL_REVID(dev_priv, 0, CNL_REVID_B0)) 1333 - WA_SET_BIT_MASKED(COMMON_SLICE_CHICKEN2, 1334 - GEN8_CSC2_SBE_VUE_CACHE_CONSERVATIVE); 1335 - 1336 - /* WaInPlaceDecompressionHang:cnl */ 1337 - I915_WRITE(GEN9_GAMT_ECO_REG_RW_IA, 1338 - (I915_READ(GEN9_GAMT_ECO_REG_RW_IA) | 1339 - GAMT_ECO_ENABLE_IN_PLACE_DECOMPRESS)); 1340 - 1341 - /* WaPushConstantDereferenceHoldDisable:cnl */ 1342 - WA_SET_BIT_MASKED(GEN7_ROW_CHICKEN2, PUSH_CONSTANT_DEREF_DISABLE); 1343 - 1344 - /* FtrEnableFastAnisoL1BankingFix: cnl */ 1345 - WA_SET_BIT_MASKED(HALF_SLICE_CHICKEN3, CNL_FAST_ANISO_L1_BANKING_FIX); 1346 - 1347 - /* WaDisable3DMidCmdPreemption:cnl */ 1348 - WA_CLR_BIT_MASKED(GEN8_CS_CHICKEN1, GEN9_PREEMPT_3D_OBJECT_LEVEL); 1349 - 1350 - /* WaDisableGPGPUMidCmdPreemption:cnl */ 1351 - WA_SET_FIELD_MASKED(GEN8_CS_CHICKEN1, GEN9_PREEMPT_GPGPU_LEVEL_MASK, 1352 - GEN9_PREEMPT_GPGPU_COMMAND_LEVEL); 1353 - 1354 - /* WaEnablePreemptionGranularityControlByUMD:cnl */ 1355 - I915_WRITE(GEN7_FF_SLICE_CS_CHICKEN1, 1356 - _MASKED_BIT_ENABLE(GEN9_FFSC_PERCTX_PREEMPT_CTRL)); 1357 - ret= wa_ring_whitelist_reg(engine, GEN8_CS_CHICKEN1); 1358 - if (ret) 1359 - return ret; 1360 - 1361 - /* WaDisableEarlyEOT:cnl */ 1362 - WA_SET_BIT_MASKED(GEN8_ROW_CHICKEN, DISABLE_EARLY_EOT); 1363 - 1364 - return 0; 1365 - } 1366 - 1367 - static int kbl_init_workarounds(struct intel_engine_cs *engine) 1368 - { 1369 - struct drm_i915_private *dev_priv = engine->i915; 1370 - int ret; 1371 - 1372 - ret = gen9_init_workarounds(engine); 1373 - if (ret) 1374 - return ret; 1375 - 1376 - /* WaEnableGapsTsvCreditFix:kbl */ 1377 - I915_WRITE(GEN8_GARBCNTL, (I915_READ(GEN8_GARBCNTL) | 1378 - GEN9_GAPS_TSV_CREDIT_DISABLE)); 1379 - 1380 - /* WaDisableDynamicCreditSharing:kbl */ 1381 - if (IS_KBL_REVID(dev_priv, 0, KBL_REVID_B0)) 1382 - I915_WRITE(GAMT_CHKN_BIT_REG, 1383 - (I915_READ(GAMT_CHKN_BIT_REG) | 1384 - GAMT_CHKN_DISABLE_DYNAMIC_CREDIT_SHARING)); 1385 - 1386 - /* WaDisableFenceDestinationToSLM:kbl (pre-prod) */ 1387 - if (IS_KBL_REVID(dev_priv, KBL_REVID_A0, KBL_REVID_A0)) 1388 - WA_SET_BIT_MASKED(HDC_CHICKEN0, 1389 - HDC_FENCE_DEST_SLM_DISABLE); 1390 - 1391 - /* WaToEnableHwFixForPushConstHWBug:kbl */ 1392 - if (IS_KBL_REVID(dev_priv, KBL_REVID_C0, REVID_FOREVER)) 1393 - WA_SET_BIT_MASKED(COMMON_SLICE_CHICKEN2, 1394 - GEN8_SBE_DISABLE_REPLAY_BUF_OPTIMIZATION); 1395 - 1396 - /* WaDisableGafsUnitClkGating:kbl */ 1397 - I915_WRITE(GEN7_UCGCTL4, (I915_READ(GEN7_UCGCTL4) | 1398 - GEN8_EU_GAUNIT_CLOCK_GATE_DISABLE)); 1399 - 1400 - /* WaDisableSbeCacheDispatchPortSharing:kbl */ 1401 - WA_SET_BIT_MASKED( 1402 - GEN7_HALF_SLICE_CHICKEN1, 1403 - GEN7_SBE_SS_CACHE_DISPATCH_PORT_SHARING_DISABLE); 1404 - 1405 - /* WaInPlaceDecompressionHang:kbl */ 1406 - I915_WRITE(GEN9_GAMT_ECO_REG_RW_IA, 1407 - (I915_READ(GEN9_GAMT_ECO_REG_RW_IA) | 1408 - GAMT_ECO_ENABLE_IN_PLACE_DECOMPRESS)); 1409 - 1410 - /* WaDisableLSQCROPERFforOCL:kbl */ 1411 - ret = wa_ring_whitelist_reg(engine, GEN8_L3SQCREG4); 1412 - if (ret) 1413 - return ret; 1414 - 1415 - return 0; 1416 - } 1417 - 1418 - static int glk_init_workarounds(struct intel_engine_cs *engine) 1419 - { 1420 - struct drm_i915_private *dev_priv = engine->i915; 1421 - int ret; 1422 - 1423 - ret = gen9_init_workarounds(engine); 1424 - if (ret) 1425 - return ret; 1426 - 1427 - /* WA #0862: Userspace has to set "Barrier Mode" to avoid hangs. */ 1428 - ret = wa_ring_whitelist_reg(engine, GEN9_SLICE_COMMON_ECO_CHICKEN1); 1429 - if (ret) 1430 - return ret; 1431 - 1432 - /* WaToEnableHwFixForPushConstHWBug:glk */ 1433 - WA_SET_BIT_MASKED(COMMON_SLICE_CHICKEN2, 1434 - GEN8_SBE_DISABLE_REPLAY_BUF_OPTIMIZATION); 1435 - 1436 - return 0; 1437 - } 1438 - 1439 - static int cfl_init_workarounds(struct intel_engine_cs *engine) 1440 - { 1441 - struct drm_i915_private *dev_priv = engine->i915; 1442 - int ret; 1443 - 1444 - ret = gen9_init_workarounds(engine); 1445 - if (ret) 1446 - return ret; 1447 - 1448 - /* WaEnableGapsTsvCreditFix:cfl */ 1449 - I915_WRITE(GEN8_GARBCNTL, (I915_READ(GEN8_GARBCNTL) | 1450 - GEN9_GAPS_TSV_CREDIT_DISABLE)); 1451 - 1452 - /* WaToEnableHwFixForPushConstHWBug:cfl */ 1453 - WA_SET_BIT_MASKED(COMMON_SLICE_CHICKEN2, 1454 - GEN8_SBE_DISABLE_REPLAY_BUF_OPTIMIZATION); 1455 - 1456 - /* WaDisableGafsUnitClkGating:cfl */ 1457 - I915_WRITE(GEN7_UCGCTL4, (I915_READ(GEN7_UCGCTL4) | 1458 - GEN8_EU_GAUNIT_CLOCK_GATE_DISABLE)); 1459 - 1460 - /* WaDisableSbeCacheDispatchPortSharing:cfl */ 1461 - WA_SET_BIT_MASKED( 1462 - GEN7_HALF_SLICE_CHICKEN1, 1463 - GEN7_SBE_SS_CACHE_DISPATCH_PORT_SHARING_DISABLE); 1464 - 1465 - /* WaInPlaceDecompressionHang:cfl */ 1466 - I915_WRITE(GEN9_GAMT_ECO_REG_RW_IA, 1467 - (I915_READ(GEN9_GAMT_ECO_REG_RW_IA) | 1468 - GAMT_ECO_ENABLE_IN_PLACE_DECOMPRESS)); 1469 - 1470 - return 0; 1471 - } 1472 - 1473 - int init_workarounds_ring(struct intel_engine_cs *engine) 1474 - { 1475 - struct drm_i915_private *dev_priv = engine->i915; 1476 - int err; 1477 - 1478 - if (GEM_WARN_ON(engine->id != RCS)) 1479 - return -EINVAL; 1480 - 1481 - dev_priv->workarounds.count = 0; 1482 - dev_priv->workarounds.hw_whitelist_count[engine->id] = 0; 1483 - 1484 - if (IS_BROADWELL(dev_priv)) 1485 - err = bdw_init_workarounds(engine); 1486 - else if (IS_CHERRYVIEW(dev_priv)) 1487 - err = chv_init_workarounds(engine); 1488 - else if (IS_SKYLAKE(dev_priv)) 1489 - err = skl_init_workarounds(engine); 1490 - else if (IS_BROXTON(dev_priv)) 1491 - err = bxt_init_workarounds(engine); 1492 - else if (IS_KABYLAKE(dev_priv)) 1493 - err = kbl_init_workarounds(engine); 1494 - else if (IS_GEMINILAKE(dev_priv)) 1495 - err = glk_init_workarounds(engine); 1496 - else if (IS_COFFEELAKE(dev_priv)) 1497 - err = cfl_init_workarounds(engine); 1498 - else if (IS_CANNONLAKE(dev_priv)) 1499 - err = cnl_init_workarounds(engine); 1500 - else 1501 - err = 0; 1502 - if (err) 1503 - return err; 1504 - 1505 - DRM_DEBUG_DRIVER("%s: Number of context specific w/a: %d\n", 1506 - engine->name, dev_priv->workarounds.count); 1507 - return 0; 1508 - } 1509 - 1510 - int intel_ring_workarounds_emit(struct i915_request *rq) 1511 - { 1512 - struct i915_workarounds *w = &rq->i915->workarounds; 1513 - u32 *cs; 1514 - int ret, i; 1515 - 1516 - if (w->count == 0) 1517 - return 0; 1518 - 1519 - ret = rq->engine->emit_flush(rq, EMIT_BARRIER); 1520 - if (ret) 1521 - return ret; 1522 - 1523 - cs = intel_ring_begin(rq, w->count * 2 + 2); 1524 - if (IS_ERR(cs)) 1525 - return PTR_ERR(cs); 1526 - 1527 - *cs++ = MI_LOAD_REGISTER_IMM(w->count); 1528 - for (i = 0; i < w->count; i++) { 1529 - *cs++ = i915_mmio_reg_offset(w->reg[i].addr); 1530 - *cs++ = w->reg[i].value; 1531 - } 1532 - *cs++ = MI_NOOP; 1533 - 1534 - intel_ring_advance(rq, cs); 1535 - 1536 - ret = rq->engine->emit_flush(rq, EMIT_BARRIER); 1537 - if (ret) 1538 - return ret; 1539 - 1540 - return 0; 1541 872 } 1542 873 1543 874 static bool ring_is_idle(struct intel_engine_cs *engine) ··· 1056 1655 intel_engine_dump(engine, &p, NULL); 1057 1656 } 1058 1657 1658 + /* Must be reset upon idling, or we may miss the busy wakeup. */ 1659 + GEM_BUG_ON(engine->execlists.queue_priority != INT_MIN); 1660 + 1059 1661 if (engine->park) 1060 1662 engine->park(engine); 1061 1663 ··· 1117 1713 struct i915_request *rq, 1118 1714 const char *prefix) 1119 1715 { 1716 + const char *name = rq->fence.ops->get_timeline_name(&rq->fence); 1717 + 1120 1718 drm_printf(m, "%s%x%s [%llx:%x] prio=%d @ %dms: %s\n", prefix, 1121 1719 rq->global_seqno, 1122 1720 i915_request_completed(rq) ? "!" : "", 1123 1721 rq->fence.context, rq->fence.seqno, 1124 1722 rq->priotree.priority, 1125 1723 jiffies_to_msecs(jiffies - rq->emitted_jiffies), 1126 - rq->timeline->common->name); 1724 + name); 1127 1725 } 1128 1726 1129 1727 static void hexdump(struct drm_printer *m, const void *buf, size_t len) ··· 1231 1825 ptr = I915_READ(RING_CONTEXT_STATUS_PTR(engine)); 1232 1826 read = GEN8_CSB_READ_PTR(ptr); 1233 1827 write = GEN8_CSB_WRITE_PTR(ptr); 1234 - drm_printf(m, "\tExeclist CSB read %d [%d cached], write %d [%d from hws], interrupt posted? %s\n", 1828 + drm_printf(m, "\tExeclist CSB read %d [%d cached], write %d [%d from hws], interrupt posted? %s, tasklet queued? %s (%s)\n", 1235 1829 read, execlists->csb_head, 1236 1830 write, 1237 1831 intel_read_status_page(engine, intel_hws_csb_write_index(engine->i915)), 1238 1832 yesno(test_bit(ENGINE_IRQ_EXECLIST, 1239 - &engine->irq_posted))); 1833 + &engine->irq_posted)), 1834 + yesno(test_bit(TASKLET_STATE_SCHED, 1835 + &engine->execlists.tasklet.state)), 1836 + enableddisabled(!atomic_read(&engine->execlists.tasklet.count))); 1240 1837 if (read >= GEN8_CSB_ENTRIES) 1241 1838 read = 0; 1242 1839 if (write >= GEN8_CSB_ENTRIES) ··· 1338 1929 rq->head, rq->postfix, rq->tail, 1339 1930 rq->batch ? upper_32_bits(rq->batch->node.start) : ~0u, 1340 1931 rq->batch ? lower_32_bits(rq->batch->node.start) : ~0u); 1341 - drm_printf(m, "\t\tring->start: 0x%08x\n", 1932 + drm_printf(m, "\t\tring->start: 0x%08x\n", 1342 1933 i915_ggtt_offset(rq->ring->vma)); 1343 - drm_printf(m, "\t\tring->head: 0x%08x\n", 1934 + drm_printf(m, "\t\tring->head: 0x%08x\n", 1344 1935 rq->ring->head); 1345 - drm_printf(m, "\t\tring->tail: 0x%08x\n", 1936 + drm_printf(m, "\t\tring->tail: 0x%08x\n", 1346 1937 rq->ring->tail); 1938 + drm_printf(m, "\t\tring->emit: 0x%08x\n", 1939 + rq->ring->emit); 1940 + drm_printf(m, "\t\tring->space: 0x%08x\n", 1941 + rq->ring->space); 1347 1942 } 1348 1943 1349 1944 rcu_read_unlock(); ··· 1522 2109 1523 2110 #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST) 1524 2111 #include "selftests/mock_engine.c" 2112 + #include "selftests/intel_engine_cs.c" 1525 2113 #endif
+28
drivers/gpu/drm/i915/intel_fbc.c
··· 1272 1272 mutex_unlock(&fbc->lock); 1273 1273 } 1274 1274 1275 + /* 1276 + * intel_fbc_reset_underrun - reset FBC fifo underrun status. 1277 + * @dev_priv: i915 device instance 1278 + * 1279 + * See intel_fbc_handle_fifo_underrun_irq(). For automated testing we 1280 + * want to re-enable FBC after an underrun to increase test coverage. 1281 + */ 1282 + int intel_fbc_reset_underrun(struct drm_i915_private *dev_priv) 1283 + { 1284 + int ret; 1285 + 1286 + cancel_work_sync(&dev_priv->fbc.underrun_work); 1287 + 1288 + ret = mutex_lock_interruptible(&dev_priv->fbc.lock); 1289 + if (ret) 1290 + return ret; 1291 + 1292 + if (dev_priv->fbc.underrun_detected) { 1293 + DRM_DEBUG_KMS("Re-allowing FBC after fifo underrun\n"); 1294 + dev_priv->fbc.no_fbc_reason = "FIFO underrun cleared"; 1295 + } 1296 + 1297 + dev_priv->fbc.underrun_detected = false; 1298 + mutex_unlock(&dev_priv->fbc.lock); 1299 + 1300 + return 0; 1301 + } 1302 + 1275 1303 /** 1276 1304 * intel_fbc_handle_fifo_underrun_irq - disable FBC when we get a FIFO underrun 1277 1305 * @dev_priv: i915 device instance
+3 -2
drivers/gpu/drm/i915/intel_fbdev.c
··· 221 221 goto out_unlock; 222 222 } 223 223 224 + fb = &ifbdev->fb->base; 225 + intel_fb_obj_flush(intel_fb_obj(fb), ORIGIN_DIRTYFB); 226 + 224 227 info = drm_fb_helper_alloc_fbi(helper); 225 228 if (IS_ERR(info)) { 226 229 DRM_ERROR("Failed to allocate fb_info\n"); ··· 232 229 } 233 230 234 231 info->par = helper; 235 - 236 - fb = &ifbdev->fb->base; 237 232 238 233 ifbdev->helper.fb = fb; 239 234
+1 -1
drivers/gpu/drm/i915/intel_frontbuffer.c
··· 80 80 } 81 81 82 82 might_sleep(); 83 - intel_psr_invalidate(dev_priv, frontbuffer_bits); 83 + intel_psr_invalidate(dev_priv, frontbuffer_bits, origin); 84 84 intel_edp_drrs_invalidate(dev_priv, frontbuffer_bits); 85 85 intel_fbc_invalidate(dev_priv, frontbuffer_bits, origin); 86 86 }
+274
drivers/gpu/drm/i915/intel_gpu_commands.h
··· 1 + /* 2 + * SPDX-License-Identifier: MIT 3 + * 4 + * Copyright � 2003-2018 Intel Corporation 5 + */ 6 + 7 + #ifndef _INTEL_GPU_COMMANDS_H_ 8 + #define _INTEL_GPU_COMMANDS_H_ 9 + 10 + /* 11 + * Instruction field definitions used by the command parser 12 + */ 13 + #define INSTR_CLIENT_SHIFT 29 14 + #define INSTR_MI_CLIENT 0x0 15 + #define INSTR_BC_CLIENT 0x2 16 + #define INSTR_RC_CLIENT 0x3 17 + #define INSTR_SUBCLIENT_SHIFT 27 18 + #define INSTR_SUBCLIENT_MASK 0x18000000 19 + #define INSTR_MEDIA_SUBCLIENT 0x2 20 + #define INSTR_26_TO_24_MASK 0x7000000 21 + #define INSTR_26_TO_24_SHIFT 24 22 + 23 + /* 24 + * Memory interface instructions used by the kernel 25 + */ 26 + #define MI_INSTR(opcode, flags) (((opcode) << 23) | (flags)) 27 + /* Many MI commands use bit 22 of the header dword for GGTT vs PPGTT */ 28 + #define MI_GLOBAL_GTT (1<<22) 29 + 30 + #define MI_NOOP MI_INSTR(0, 0) 31 + #define MI_USER_INTERRUPT MI_INSTR(0x02, 0) 32 + #define MI_WAIT_FOR_EVENT MI_INSTR(0x03, 0) 33 + #define MI_WAIT_FOR_OVERLAY_FLIP (1<<16) 34 + #define MI_WAIT_FOR_PLANE_B_FLIP (1<<6) 35 + #define MI_WAIT_FOR_PLANE_A_FLIP (1<<2) 36 + #define MI_WAIT_FOR_PLANE_A_SCANLINES (1<<1) 37 + #define MI_FLUSH MI_INSTR(0x04, 0) 38 + #define MI_READ_FLUSH (1 << 0) 39 + #define MI_EXE_FLUSH (1 << 1) 40 + #define MI_NO_WRITE_FLUSH (1 << 2) 41 + #define MI_SCENE_COUNT (1 << 3) /* just increment scene count */ 42 + #define MI_END_SCENE (1 << 4) /* flush binner and incr scene count */ 43 + #define MI_INVALIDATE_ISP (1 << 5) /* invalidate indirect state pointers */ 44 + #define MI_REPORT_HEAD MI_INSTR(0x07, 0) 45 + #define MI_ARB_ON_OFF MI_INSTR(0x08, 0) 46 + #define MI_ARB_ENABLE (1<<0) 47 + #define MI_ARB_DISABLE (0<<0) 48 + #define MI_BATCH_BUFFER_END MI_INSTR(0x0a, 0) 49 + #define MI_SUSPEND_FLUSH MI_INSTR(0x0b, 0) 50 + #define MI_SUSPEND_FLUSH_EN (1<<0) 51 + #define MI_SET_APPID MI_INSTR(0x0e, 0) 52 + #define MI_OVERLAY_FLIP MI_INSTR(0x11, 0) 53 + #define MI_OVERLAY_CONTINUE (0x0<<21) 54 + #define MI_OVERLAY_ON (0x1<<21) 55 + #define MI_OVERLAY_OFF (0x2<<21) 56 + #define MI_LOAD_SCAN_LINES_INCL MI_INSTR(0x12, 0) 57 + #define MI_DISPLAY_FLIP MI_INSTR(0x14, 2) 58 + #define MI_DISPLAY_FLIP_I915 MI_INSTR(0x14, 1) 59 + #define MI_DISPLAY_FLIP_PLANE(n) ((n) << 20) 60 + /* IVB has funny definitions for which plane to flip. */ 61 + #define MI_DISPLAY_FLIP_IVB_PLANE_A (0 << 19) 62 + #define MI_DISPLAY_FLIP_IVB_PLANE_B (1 << 19) 63 + #define MI_DISPLAY_FLIP_IVB_SPRITE_A (2 << 19) 64 + #define MI_DISPLAY_FLIP_IVB_SPRITE_B (3 << 19) 65 + #define MI_DISPLAY_FLIP_IVB_PLANE_C (4 << 19) 66 + #define MI_DISPLAY_FLIP_IVB_SPRITE_C (5 << 19) 67 + /* SKL ones */ 68 + #define MI_DISPLAY_FLIP_SKL_PLANE_1_A (0 << 8) 69 + #define MI_DISPLAY_FLIP_SKL_PLANE_1_B (1 << 8) 70 + #define MI_DISPLAY_FLIP_SKL_PLANE_1_C (2 << 8) 71 + #define MI_DISPLAY_FLIP_SKL_PLANE_2_A (4 << 8) 72 + #define MI_DISPLAY_FLIP_SKL_PLANE_2_B (5 << 8) 73 + #define MI_DISPLAY_FLIP_SKL_PLANE_2_C (6 << 8) 74 + #define MI_DISPLAY_FLIP_SKL_PLANE_3_A (7 << 8) 75 + #define MI_DISPLAY_FLIP_SKL_PLANE_3_B (8 << 8) 76 + #define MI_DISPLAY_FLIP_SKL_PLANE_3_C (9 << 8) 77 + #define MI_SEMAPHORE_MBOX MI_INSTR(0x16, 1) /* gen6, gen7 */ 78 + #define MI_SEMAPHORE_GLOBAL_GTT (1<<22) 79 + #define MI_SEMAPHORE_UPDATE (1<<21) 80 + #define MI_SEMAPHORE_COMPARE (1<<20) 81 + #define MI_SEMAPHORE_REGISTER (1<<18) 82 + #define MI_SEMAPHORE_SYNC_VR (0<<16) /* RCS wait for VCS (RVSYNC) */ 83 + #define MI_SEMAPHORE_SYNC_VER (1<<16) /* RCS wait for VECS (RVESYNC) */ 84 + #define MI_SEMAPHORE_SYNC_BR (2<<16) /* RCS wait for BCS (RBSYNC) */ 85 + #define MI_SEMAPHORE_SYNC_BV (0<<16) /* VCS wait for BCS (VBSYNC) */ 86 + #define MI_SEMAPHORE_SYNC_VEV (1<<16) /* VCS wait for VECS (VVESYNC) */ 87 + #define MI_SEMAPHORE_SYNC_RV (2<<16) /* VCS wait for RCS (VRSYNC) */ 88 + #define MI_SEMAPHORE_SYNC_RB (0<<16) /* BCS wait for RCS (BRSYNC) */ 89 + #define MI_SEMAPHORE_SYNC_VEB (1<<16) /* BCS wait for VECS (BVESYNC) */ 90 + #define MI_SEMAPHORE_SYNC_VB (2<<16) /* BCS wait for VCS (BVSYNC) */ 91 + #define MI_SEMAPHORE_SYNC_BVE (0<<16) /* VECS wait for BCS (VEBSYNC) */ 92 + #define MI_SEMAPHORE_SYNC_VVE (1<<16) /* VECS wait for VCS (VEVSYNC) */ 93 + #define MI_SEMAPHORE_SYNC_RVE (2<<16) /* VECS wait for RCS (VERSYNC) */ 94 + #define MI_SEMAPHORE_SYNC_INVALID (3<<16) 95 + #define MI_SEMAPHORE_SYNC_MASK (3<<16) 96 + #define MI_SET_CONTEXT MI_INSTR(0x18, 0) 97 + #define MI_MM_SPACE_GTT (1<<8) 98 + #define MI_MM_SPACE_PHYSICAL (0<<8) 99 + #define MI_SAVE_EXT_STATE_EN (1<<3) 100 + #define MI_RESTORE_EXT_STATE_EN (1<<2) 101 + #define MI_FORCE_RESTORE (1<<1) 102 + #define MI_RESTORE_INHIBIT (1<<0) 103 + #define HSW_MI_RS_SAVE_STATE_EN (1<<3) 104 + #define HSW_MI_RS_RESTORE_STATE_EN (1<<2) 105 + #define MI_SEMAPHORE_SIGNAL MI_INSTR(0x1b, 0) /* GEN8+ */ 106 + #define MI_SEMAPHORE_TARGET(engine) ((engine)<<15) 107 + #define MI_SEMAPHORE_WAIT MI_INSTR(0x1c, 2) /* GEN8+ */ 108 + #define MI_SEMAPHORE_POLL (1<<15) 109 + #define MI_SEMAPHORE_SAD_GTE_SDD (1<<12) 110 + #define MI_STORE_DWORD_IMM MI_INSTR(0x20, 1) 111 + #define MI_STORE_DWORD_IMM_GEN4 MI_INSTR(0x20, 2) 112 + #define MI_MEM_VIRTUAL (1 << 22) /* 945,g33,965 */ 113 + #define MI_USE_GGTT (1 << 22) /* g4x+ */ 114 + #define MI_STORE_DWORD_INDEX MI_INSTR(0x21, 1) 115 + #define MI_STORE_DWORD_INDEX_SHIFT 2 116 + /* 117 + * Official intel docs are somewhat sloppy concerning MI_LOAD_REGISTER_IMM: 118 + * - Always issue a MI_NOOP _before_ the MI_LOAD_REGISTER_IMM - otherwise hw 119 + * simply ignores the register load under certain conditions. 120 + * - One can actually load arbitrary many arbitrary registers: Simply issue x 121 + * address/value pairs. Don't overdue it, though, x <= 2^4 must hold! 122 + */ 123 + #define MI_LOAD_REGISTER_IMM(x) MI_INSTR(0x22, 2*(x)-1) 124 + #define MI_LRI_FORCE_POSTED (1<<12) 125 + #define MI_STORE_REGISTER_MEM MI_INSTR(0x24, 1) 126 + #define MI_STORE_REGISTER_MEM_GEN8 MI_INSTR(0x24, 2) 127 + #define MI_SRM_LRM_GLOBAL_GTT (1<<22) 128 + #define MI_FLUSH_DW MI_INSTR(0x26, 1) /* for GEN6 */ 129 + #define MI_FLUSH_DW_STORE_INDEX (1<<21) 130 + #define MI_INVALIDATE_TLB (1<<18) 131 + #define MI_FLUSH_DW_OP_STOREDW (1<<14) 132 + #define MI_FLUSH_DW_OP_MASK (3<<14) 133 + #define MI_FLUSH_DW_NOTIFY (1<<8) 134 + #define MI_INVALIDATE_BSD (1<<7) 135 + #define MI_FLUSH_DW_USE_GTT (1<<2) 136 + #define MI_FLUSH_DW_USE_PPGTT (0<<2) 137 + #define MI_LOAD_REGISTER_MEM MI_INSTR(0x29, 1) 138 + #define MI_LOAD_REGISTER_MEM_GEN8 MI_INSTR(0x29, 2) 139 + #define MI_BATCH_BUFFER MI_INSTR(0x30, 1) 140 + #define MI_BATCH_NON_SECURE (1) 141 + /* for snb/ivb/vlv this also means "batch in ppgtt" when ppgtt is enabled. */ 142 + #define MI_BATCH_NON_SECURE_I965 (1<<8) 143 + #define MI_BATCH_PPGTT_HSW (1<<8) 144 + #define MI_BATCH_NON_SECURE_HSW (1<<13) 145 + #define MI_BATCH_BUFFER_START MI_INSTR(0x31, 0) 146 + #define MI_BATCH_GTT (2<<6) /* aliased with (1<<7) on gen4 */ 147 + #define MI_BATCH_BUFFER_START_GEN8 MI_INSTR(0x31, 1) 148 + #define MI_BATCH_RESOURCE_STREAMER (1<<10) 149 + 150 + /* 151 + * 3D instructions used by the kernel 152 + */ 153 + #define GFX_INSTR(opcode, flags) ((0x3 << 29) | ((opcode) << 24) | (flags)) 154 + 155 + #define GEN9_MEDIA_POOL_STATE ((0x3 << 29) | (0x2 << 27) | (0x5 << 16) | 4) 156 + #define GEN9_MEDIA_POOL_ENABLE (1 << 31) 157 + #define GFX_OP_RASTER_RULES ((0x3<<29)|(0x7<<24)) 158 + #define GFX_OP_SCISSOR ((0x3<<29)|(0x1c<<24)|(0x10<<19)) 159 + #define SC_UPDATE_SCISSOR (0x1<<1) 160 + #define SC_ENABLE_MASK (0x1<<0) 161 + #define SC_ENABLE (0x1<<0) 162 + #define GFX_OP_LOAD_INDIRECT ((0x3<<29)|(0x1d<<24)|(0x7<<16)) 163 + #define GFX_OP_SCISSOR_INFO ((0x3<<29)|(0x1d<<24)|(0x81<<16)|(0x1)) 164 + #define SCI_YMIN_MASK (0xffff<<16) 165 + #define SCI_XMIN_MASK (0xffff<<0) 166 + #define SCI_YMAX_MASK (0xffff<<16) 167 + #define SCI_XMAX_MASK (0xffff<<0) 168 + #define GFX_OP_SCISSOR_ENABLE ((0x3<<29)|(0x1c<<24)|(0x10<<19)) 169 + #define GFX_OP_SCISSOR_RECT ((0x3<<29)|(0x1d<<24)|(0x81<<16)|1) 170 + #define GFX_OP_COLOR_FACTOR ((0x3<<29)|(0x1d<<24)|(0x1<<16)|0x0) 171 + #define GFX_OP_STIPPLE ((0x3<<29)|(0x1d<<24)|(0x83<<16)) 172 + #define GFX_OP_MAP_INFO ((0x3<<29)|(0x1d<<24)|0x4) 173 + #define GFX_OP_DESTBUFFER_VARS ((0x3<<29)|(0x1d<<24)|(0x85<<16)|0x0) 174 + #define GFX_OP_DESTBUFFER_INFO ((0x3<<29)|(0x1d<<24)|(0x8e<<16)|1) 175 + #define GFX_OP_DRAWRECT_INFO ((0x3<<29)|(0x1d<<24)|(0x80<<16)|(0x3)) 176 + #define GFX_OP_DRAWRECT_INFO_I965 ((0x7900<<16)|0x2) 177 + 178 + #define COLOR_BLT_CMD (2<<29 | 0x40<<22 | (5-2)) 179 + #define SRC_COPY_BLT_CMD ((2<<29)|(0x43<<22)|4) 180 + #define XY_SRC_COPY_BLT_CMD ((2<<29)|(0x53<<22)|6) 181 + #define XY_MONO_SRC_COPY_IMM_BLT ((2<<29)|(0x71<<22)|5) 182 + #define BLT_WRITE_A (2<<20) 183 + #define BLT_WRITE_RGB (1<<20) 184 + #define BLT_WRITE_RGBA (BLT_WRITE_RGB | BLT_WRITE_A) 185 + #define BLT_DEPTH_8 (0<<24) 186 + #define BLT_DEPTH_16_565 (1<<24) 187 + #define BLT_DEPTH_16_1555 (2<<24) 188 + #define BLT_DEPTH_32 (3<<24) 189 + #define BLT_ROP_SRC_COPY (0xcc<<16) 190 + #define BLT_ROP_COLOR_COPY (0xf0<<16) 191 + #define XY_SRC_COPY_BLT_SRC_TILED (1<<15) /* 965+ only */ 192 + #define XY_SRC_COPY_BLT_DST_TILED (1<<11) /* 965+ only */ 193 + #define CMD_OP_DISPLAYBUFFER_INFO ((0x0<<29)|(0x14<<23)|2) 194 + #define ASYNC_FLIP (1<<22) 195 + #define DISPLAY_PLANE_A (0<<20) 196 + #define DISPLAY_PLANE_B (1<<20) 197 + #define GFX_OP_PIPE_CONTROL(len) ((0x3<<29)|(0x3<<27)|(0x2<<24)|((len)-2)) 198 + #define PIPE_CONTROL_FLUSH_L3 (1<<27) 199 + #define PIPE_CONTROL_GLOBAL_GTT_IVB (1<<24) /* gen7+ */ 200 + #define PIPE_CONTROL_MMIO_WRITE (1<<23) 201 + #define PIPE_CONTROL_STORE_DATA_INDEX (1<<21) 202 + #define PIPE_CONTROL_CS_STALL (1<<20) 203 + #define PIPE_CONTROL_TLB_INVALIDATE (1<<18) 204 + #define PIPE_CONTROL_MEDIA_STATE_CLEAR (1<<16) 205 + #define PIPE_CONTROL_QW_WRITE (1<<14) 206 + #define PIPE_CONTROL_POST_SYNC_OP_MASK (3<<14) 207 + #define PIPE_CONTROL_DEPTH_STALL (1<<13) 208 + #define PIPE_CONTROL_WRITE_FLUSH (1<<12) 209 + #define PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH (1<<12) /* gen6+ */ 210 + #define PIPE_CONTROL_INSTRUCTION_CACHE_INVALIDATE (1<<11) /* MBZ on ILK */ 211 + #define PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE (1<<10) /* GM45+ only */ 212 + #define PIPE_CONTROL_INDIRECT_STATE_DISABLE (1<<9) 213 + #define PIPE_CONTROL_NOTIFY (1<<8) 214 + #define PIPE_CONTROL_FLUSH_ENABLE (1<<7) /* gen7+ */ 215 + #define PIPE_CONTROL_DC_FLUSH_ENABLE (1<<5) 216 + #define PIPE_CONTROL_VF_CACHE_INVALIDATE (1<<4) 217 + #define PIPE_CONTROL_CONST_CACHE_INVALIDATE (1<<3) 218 + #define PIPE_CONTROL_STATE_CACHE_INVALIDATE (1<<2) 219 + #define PIPE_CONTROL_STALL_AT_SCOREBOARD (1<<1) 220 + #define PIPE_CONTROL_DEPTH_CACHE_FLUSH (1<<0) 221 + #define PIPE_CONTROL_GLOBAL_GTT (1<<2) /* in addr dword */ 222 + 223 + /* 224 + * Commands used only by the command parser 225 + */ 226 + #define MI_SET_PREDICATE MI_INSTR(0x01, 0) 227 + #define MI_ARB_CHECK MI_INSTR(0x05, 0) 228 + #define MI_RS_CONTROL MI_INSTR(0x06, 0) 229 + #define MI_URB_ATOMIC_ALLOC MI_INSTR(0x09, 0) 230 + #define MI_PREDICATE MI_INSTR(0x0C, 0) 231 + #define MI_RS_CONTEXT MI_INSTR(0x0F, 0) 232 + #define MI_TOPOLOGY_FILTER MI_INSTR(0x0D, 0) 233 + #define MI_LOAD_SCAN_LINES_EXCL MI_INSTR(0x13, 0) 234 + #define MI_URB_CLEAR MI_INSTR(0x19, 0) 235 + #define MI_UPDATE_GTT MI_INSTR(0x23, 0) 236 + #define MI_CLFLUSH MI_INSTR(0x27, 0) 237 + #define MI_REPORT_PERF_COUNT MI_INSTR(0x28, 0) 238 + #define MI_REPORT_PERF_COUNT_GGTT (1<<0) 239 + #define MI_LOAD_REGISTER_REG MI_INSTR(0x2A, 0) 240 + #define MI_RS_STORE_DATA_IMM MI_INSTR(0x2B, 0) 241 + #define MI_LOAD_URB_MEM MI_INSTR(0x2C, 0) 242 + #define MI_STORE_URB_MEM MI_INSTR(0x2D, 0) 243 + #define MI_CONDITIONAL_BATCH_BUFFER_END MI_INSTR(0x36, 0) 244 + 245 + #define PIPELINE_SELECT ((0x3<<29)|(0x1<<27)|(0x1<<24)|(0x4<<16)) 246 + #define GFX_OP_3DSTATE_VF_STATISTICS ((0x3<<29)|(0x1<<27)|(0x0<<24)|(0xB<<16)) 247 + #define MEDIA_VFE_STATE ((0x3<<29)|(0x2<<27)|(0x0<<24)|(0x0<<16)) 248 + #define MEDIA_VFE_STATE_MMIO_ACCESS_MASK (0x18) 249 + #define GPGPU_OBJECT ((0x3<<29)|(0x2<<27)|(0x1<<24)|(0x4<<16)) 250 + #define GPGPU_WALKER ((0x3<<29)|(0x2<<27)|(0x1<<24)|(0x5<<16)) 251 + #define GFX_OP_3DSTATE_DX9_CONSTANTF_VS \ 252 + ((0x3<<29)|(0x3<<27)|(0x0<<24)|(0x39<<16)) 253 + #define GFX_OP_3DSTATE_DX9_CONSTANTF_PS \ 254 + ((0x3<<29)|(0x3<<27)|(0x0<<24)|(0x3A<<16)) 255 + #define GFX_OP_3DSTATE_SO_DECL_LIST \ 256 + ((0x3<<29)|(0x3<<27)|(0x1<<24)|(0x17<<16)) 257 + 258 + #define GFX_OP_3DSTATE_BINDING_TABLE_EDIT_VS \ 259 + ((0x3<<29)|(0x3<<27)|(0x0<<24)|(0x43<<16)) 260 + #define GFX_OP_3DSTATE_BINDING_TABLE_EDIT_GS \ 261 + ((0x3<<29)|(0x3<<27)|(0x0<<24)|(0x44<<16)) 262 + #define GFX_OP_3DSTATE_BINDING_TABLE_EDIT_HS \ 263 + ((0x3<<29)|(0x3<<27)|(0x0<<24)|(0x45<<16)) 264 + #define GFX_OP_3DSTATE_BINDING_TABLE_EDIT_DS \ 265 + ((0x3<<29)|(0x3<<27)|(0x0<<24)|(0x46<<16)) 266 + #define GFX_OP_3DSTATE_BINDING_TABLE_EDIT_PS \ 267 + ((0x3<<29)|(0x3<<27)|(0x0<<24)|(0x47<<16)) 268 + 269 + #define MFX_WAIT ((0x3<<29)|(0x1<<27)|(0x0<<16)) 270 + 271 + #define COLOR_BLT ((0x2<<29)|(0x40<<22)) 272 + #define SRC_COPY_BLT ((0x2<<29)|(0x43<<22)) 273 + 274 + #endif /* _INTEL_GPU_COMMANDS_H_ */
+158 -51
drivers/gpu/drm/i915/intel_guc.c
··· 64 64 { 65 65 intel_guc_fw_init_early(guc); 66 66 intel_guc_ct_init_early(&guc->ct); 67 - intel_guc_log_init_early(guc); 67 + intel_guc_log_init_early(&guc->log); 68 68 69 69 mutex_init(&guc->send_mutex); 70 + spin_lock_init(&guc->irq_lock); 70 71 guc->send = intel_guc_send_nop; 72 + guc->handler = intel_guc_to_host_event_handler_nop; 71 73 guc->notify = gen8_guc_raise_irq; 72 74 } 73 75 ··· 88 86 * or scheduled later on resume. This way the handling of work 89 87 * item can be kept same between system suspend & rpm suspend. 90 88 */ 91 - guc->log.runtime.flush_wq = alloc_ordered_workqueue("i915-guc_log", 92 - WQ_HIGHPRI | WQ_FREEZABLE); 93 - if (!guc->log.runtime.flush_wq) { 89 + guc->log.relay.flush_wq = 90 + alloc_ordered_workqueue("i915-guc_log", 91 + WQ_HIGHPRI | WQ_FREEZABLE); 92 + if (!guc->log.relay.flush_wq) { 94 93 DRM_ERROR("Couldn't allocate workqueue for GuC log\n"); 95 94 return -ENOMEM; 96 95 } ··· 114 111 guc->preempt_wq = alloc_ordered_workqueue("i915-guc_preempt", 115 112 WQ_HIGHPRI); 116 113 if (!guc->preempt_wq) { 117 - destroy_workqueue(guc->log.runtime.flush_wq); 114 + destroy_workqueue(guc->log.relay.flush_wq); 118 115 DRM_ERROR("Couldn't allocate workqueue for GuC " 119 116 "preemption\n"); 120 117 return -ENOMEM; ··· 132 129 USES_GUC_SUBMISSION(dev_priv)) 133 130 destroy_workqueue(guc->preempt_wq); 134 131 135 - destroy_workqueue(guc->log.runtime.flush_wq); 132 + destroy_workqueue(guc->log.relay.flush_wq); 136 133 } 137 134 138 135 static int guc_shared_data_create(struct intel_guc *guc) ··· 172 169 return ret; 173 170 GEM_BUG_ON(!guc->shared_data); 174 171 175 - ret = intel_guc_log_create(guc); 172 + ret = intel_guc_log_create(&guc->log); 176 173 if (ret) 177 174 goto err_shared; 178 175 ··· 187 184 return 0; 188 185 189 186 err_log: 190 - intel_guc_log_destroy(guc); 187 + intel_guc_log_destroy(&guc->log); 191 188 err_shared: 192 189 guc_shared_data_destroy(guc); 193 190 return ret; ··· 199 196 200 197 i915_ggtt_disable_guc(dev_priv); 201 198 intel_guc_ads_destroy(guc); 202 - intel_guc_log_destroy(guc); 199 + intel_guc_log_destroy(&guc->log); 203 200 guc_shared_data_destroy(guc); 204 201 } 205 202 ··· 223 220 } 224 221 } 225 222 226 - static u32 get_log_verbosity_flags(void) 223 + static u32 get_log_control_flags(void) 227 224 { 228 - if (i915_modparams.guc_log_level > 0) { 229 - u32 verbosity = i915_modparams.guc_log_level - 1; 225 + u32 level = i915_modparams.guc_log_level; 226 + u32 flags = 0; 230 227 231 - GEM_BUG_ON(verbosity > GUC_LOG_VERBOSITY_MAX); 232 - return verbosity << GUC_LOG_VERBOSITY_SHIFT; 233 - } 228 + GEM_BUG_ON(level < 0); 234 229 235 - GEM_BUG_ON(i915_modparams.enable_guc < 0); 236 - return GUC_LOG_DISABLED; 230 + if (!GUC_LOG_LEVEL_IS_ENABLED(level)) 231 + flags |= GUC_LOG_DEFAULT_DISABLED; 232 + 233 + if (!GUC_LOG_LEVEL_IS_VERBOSE(level)) 234 + flags |= GUC_LOG_DISABLED; 235 + else 236 + flags |= GUC_LOG_LEVEL_TO_VERBOSITY(level) << 237 + GUC_LOG_VERBOSITY_SHIFT; 238 + 239 + return flags; 237 240 } 238 241 239 242 /* ··· 274 265 275 266 params[GUC_CTL_LOG_PARAMS] = guc->log.flags; 276 267 277 - params[GUC_CTL_DEBUG] = get_log_verbosity_flags(); 268 + params[GUC_CTL_DEBUG] = get_log_control_flags(); 278 269 279 270 /* If GuC submission is enabled, set up additional parameters here */ 280 271 if (USES_GUC_SUBMISSION(dev_priv)) { 281 - u32 ads = guc_ggtt_offset(guc->ads_vma) >> PAGE_SHIFT; 282 - u32 pgs = guc_ggtt_offset(dev_priv->guc.stage_desc_pool); 272 + u32 ads = intel_guc_ggtt_offset(guc, 273 + guc->ads_vma) >> PAGE_SHIFT; 274 + u32 pgs = intel_guc_ggtt_offset(guc, guc->stage_desc_pool); 283 275 u32 ctx_in_16 = GUC_MAX_STAGE_DESCRIPTORS / 16; 284 276 285 277 params[GUC_CTL_DEBUG] |= ads << GUC_ADS_ADDR_SHIFT; ··· 311 301 intel_uncore_forcewake_put(dev_priv, FORCEWAKE_BLITTER); 312 302 } 313 303 314 - int intel_guc_send_nop(struct intel_guc *guc, const u32 *action, u32 len) 304 + int intel_guc_send_nop(struct intel_guc *guc, const u32 *action, u32 len, 305 + u32 *response_buf, u32 response_buf_size) 315 306 { 316 307 WARN(1, "Unexpected send: action=%#x\n", *action); 317 308 return -ENODEV; 318 309 } 319 310 311 + void intel_guc_to_host_event_handler_nop(struct intel_guc *guc) 312 + { 313 + WARN(1, "Unexpected event: no suitable handler\n"); 314 + } 315 + 320 316 /* 321 317 * This function implements the MMIO based host to GuC interface. 322 318 */ 323 - int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len) 319 + int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len, 320 + u32 *response_buf, u32 response_buf_size) 324 321 { 325 322 struct drm_i915_private *dev_priv = guc_to_i915(guc); 326 323 u32 status; ··· 336 319 337 320 GEM_BUG_ON(!len); 338 321 GEM_BUG_ON(len > guc->send_regs.count); 322 + 323 + /* We expect only action code */ 324 + GEM_BUG_ON(*action & ~INTEL_GUC_MSG_CODE_MASK); 339 325 340 326 /* If CT is available, we expect to use MMIO only during init/fini */ 341 327 GEM_BUG_ON(HAS_GUC_CT(dev_priv) && ··· 361 341 */ 362 342 ret = __intel_wait_for_register_fw(dev_priv, 363 343 guc_send_reg(guc, 0), 364 - INTEL_GUC_RECV_MASK, 365 - INTEL_GUC_RECV_MASK, 344 + INTEL_GUC_MSG_TYPE_MASK, 345 + INTEL_GUC_MSG_TYPE_RESPONSE << 346 + INTEL_GUC_MSG_TYPE_SHIFT, 366 347 10, 10, &status); 367 - if (status != INTEL_GUC_STATUS_SUCCESS) { 368 - /* 369 - * Either the GuC explicitly returned an error (which 370 - * we convert to -EIO here) or no response at all was 371 - * received within the timeout limit (-ETIMEDOUT) 372 - */ 373 - if (ret != -ETIMEDOUT) 374 - ret = -EIO; 348 + /* If GuC explicitly returned an error, convert it to -EIO */ 349 + if (!ret && !INTEL_GUC_MSG_IS_RESPONSE_SUCCESS(status)) 350 + ret = -EIO; 375 351 376 - DRM_WARN("INTEL_GUC_SEND: Action 0x%X failed;" 377 - " ret=%d status=0x%08X response=0x%08X\n", 378 - action[0], ret, status, I915_READ(SOFT_SCRATCH(15))); 352 + if (ret) { 353 + DRM_DEBUG_DRIVER("INTEL_GUC_SEND: Action 0x%X failed;" 354 + " ret=%d status=0x%08X response=0x%08X\n", 355 + action[0], ret, status, 356 + I915_READ(SOFT_SCRATCH(15))); 357 + goto out; 379 358 } 380 359 360 + if (response_buf) { 361 + int count = min(response_buf_size, guc->send_regs.count - 1); 362 + 363 + for (i = 0; i < count; i++) 364 + response_buf[i] = I915_READ(guc_send_reg(guc, i + 1)); 365 + } 366 + 367 + /* Use data from the GuC response as our return value */ 368 + ret = INTEL_GUC_MSG_TO_DATA(status); 369 + 370 + out: 381 371 intel_uncore_forcewake_put(dev_priv, guc->send_regs.fw_domains); 382 372 mutex_unlock(&guc->send_mutex); 383 373 384 374 return ret; 375 + } 376 + 377 + void intel_guc_to_host_event_handler_mmio(struct intel_guc *guc) 378 + { 379 + struct drm_i915_private *dev_priv = guc_to_i915(guc); 380 + u32 msg, val; 381 + 382 + /* 383 + * Sample the log buffer flush related bits & clear them out now 384 + * itself from the message identity register to minimize the 385 + * probability of losing a flush interrupt, when there are back 386 + * to back flush interrupts. 387 + * There can be a new flush interrupt, for different log buffer 388 + * type (like for ISR), whilst Host is handling one (for DPC). 389 + * Since same bit is used in message register for ISR & DPC, it 390 + * could happen that GuC sets the bit for 2nd interrupt but Host 391 + * clears out the bit on handling the 1st interrupt. 392 + */ 393 + spin_lock(&guc->irq_lock); 394 + val = I915_READ(SOFT_SCRATCH(15)); 395 + msg = val & guc->msg_enabled_mask; 396 + I915_WRITE(SOFT_SCRATCH(15), val & ~msg); 397 + spin_unlock(&guc->irq_lock); 398 + 399 + intel_guc_to_host_process_recv_msg(guc, msg); 400 + } 401 + 402 + void intel_guc_to_host_process_recv_msg(struct intel_guc *guc, u32 msg) 403 + { 404 + /* Make sure to handle only enabled messages */ 405 + msg &= guc->msg_enabled_mask; 406 + 407 + if (msg & (INTEL_GUC_RECV_MSG_FLUSH_LOG_BUFFER | 408 + INTEL_GUC_RECV_MSG_CRASH_DUMP_POSTED)) 409 + intel_guc_log_handle_flush_event(&guc->log); 385 410 } 386 411 387 412 int intel_guc_sample_forcewake(struct intel_guc *guc) ··· 475 410 u32 data[] = { 476 411 INTEL_GUC_ACTION_ENTER_S_STATE, 477 412 GUC_POWER_D1, /* any value greater than GUC_POWER_D0 */ 478 - guc_ggtt_offset(guc->shared_data) 413 + intel_guc_ggtt_offset(guc, guc->shared_data) 479 414 }; 480 415 481 416 return intel_guc_send(guc, data, ARRAY_SIZE(data)); ··· 499 434 data[3] = 0; 500 435 data[4] = 0; 501 436 data[5] = guc->execbuf_client->stage_id; 502 - data[6] = guc_ggtt_offset(guc->shared_data); 437 + data[6] = intel_guc_ggtt_offset(guc, guc->shared_data); 503 438 504 439 return intel_guc_send(guc, data, ARRAY_SIZE(data)); 505 440 } ··· 513 448 u32 data[] = { 514 449 INTEL_GUC_ACTION_EXIT_S_STATE, 515 450 GUC_POWER_D0, 516 - guc_ggtt_offset(guc->shared_data) 451 + intel_guc_ggtt_offset(guc, guc->shared_data) 517 452 }; 518 453 519 454 return intel_guc_send(guc, data, ARRAY_SIZE(data)); 455 + } 456 + 457 + /** 458 + * DOC: GuC Address Space 459 + * 460 + * The layout of GuC address space is shown below: 461 + * 462 + * :: 463 + * 464 + * +==============> +====================+ <== GUC_GGTT_TOP 465 + * ^ | | 466 + * | | | 467 + * | | DRAM | 468 + * | | Memory | 469 + * | | | 470 + * GuC | | 471 + * Address +========> +====================+ <== WOPCM Top 472 + * Space ^ | HW contexts RSVD | 473 + * | | | WOPCM | 474 + * | | +==> +--------------------+ <== GuC WOPCM Top 475 + * | GuC ^ | | 476 + * | GGTT | | | 477 + * | Pin GuC | GuC | 478 + * | Bias WOPCM | WOPCM | 479 + * | | Size | | 480 + * | | | | | 481 + * v v v | | 482 + * +=====+=====+==> +====================+ <== GuC WOPCM Base 483 + * | Non-GuC WOPCM | 484 + * | (HuC/Reserved) | 485 + * +====================+ <== WOPCM Base 486 + * 487 + * The lower part of GuC Address Space [0, ggtt_pin_bias) is mapped to WOPCM 488 + * while upper part of GuC Address Space [ggtt_pin_bias, GUC_GGTT_TOP) is mapped 489 + * to DRAM. The value of the GuC ggtt_pin_bias is determined by WOPCM size and 490 + * actual GuC WOPCM size. 491 + */ 492 + 493 + /** 494 + * intel_guc_init_ggtt_pin_bias() - Initialize the GuC ggtt_pin_bias value. 495 + * @guc: intel_guc structure. 496 + * 497 + * This function will calculate and initialize the ggtt_pin_bias value based on 498 + * overall WOPCM size and GuC WOPCM size. 499 + */ 500 + void intel_guc_init_ggtt_pin_bias(struct intel_guc *guc) 501 + { 502 + struct drm_i915_private *i915 = guc_to_i915(guc); 503 + 504 + GEM_BUG_ON(!i915->wopcm.size); 505 + GEM_BUG_ON(i915->wopcm.size < i915->wopcm.guc.base); 506 + 507 + guc->ggtt_pin_bias = i915->wopcm.size - i915->wopcm.guc.base; 520 508 } 521 509 522 510 /** ··· 580 462 * This is a wrapper to create an object for use with the GuC. In order to 581 463 * use it inside the GuC, an object needs to be pinned lifetime, so we allocate 582 464 * both some backing storage and a range inside the Global GTT. We must pin 583 - * it in the GGTT somewhere other than than [0, GUC_WOPCM_TOP) because that 465 + * it in the GGTT somewhere other than than [0, GUC ggtt_pin_bias) because that 584 466 * range is reserved inside GuC. 585 467 * 586 468 * Return: A i915_vma if successful, otherwise an ERR_PTR. ··· 601 483 goto err; 602 484 603 485 ret = i915_vma_pin(vma, 0, PAGE_SIZE, 604 - PIN_GLOBAL | PIN_OFFSET_BIAS | GUC_WOPCM_TOP); 486 + PIN_GLOBAL | PIN_OFFSET_BIAS | guc->ggtt_pin_bias); 605 487 if (ret) { 606 488 vma = ERR_PTR(ret); 607 489 goto err; ··· 612 494 err: 613 495 i915_gem_object_put(obj); 614 496 return vma; 615 - } 616 - 617 - u32 intel_guc_wopcm_size(struct drm_i915_private *dev_priv) 618 - { 619 - u32 wopcm_size = GUC_WOPCM_TOP; 620 - 621 - /* On BXT, the top of WOPCM is reserved for RC6 context */ 622 - if (IS_GEN9_LP(dev_priv)) 623 - wopcm_size -= BXT_GUC_WOPCM_RC6_RESERVED; 624 - 625 - return wopcm_size; 626 497 }
+70 -12
drivers/gpu/drm/i915/intel_guc.h
··· 49 49 struct intel_guc_log log; 50 50 struct intel_guc_ct ct; 51 51 52 + /* Offset where Non-WOPCM memory starts. */ 53 + u32 ggtt_pin_bias; 54 + 52 55 /* Log snapshot if GuC errors during load */ 53 56 struct drm_i915_gem_object *load_err_log; 54 57 55 58 /* intel_guc_recv interrupt related state */ 59 + spinlock_t irq_lock; 56 60 bool interrupts_enabled; 61 + unsigned int msg_enabled_mask; 57 62 58 63 struct i915_vma *ads_vma; 59 64 struct i915_vma *stage_desc_pool; ··· 88 83 struct mutex send_mutex; 89 84 90 85 /* GuC's FW specific send function */ 91 - int (*send)(struct intel_guc *guc, const u32 *data, u32 len); 86 + int (*send)(struct intel_guc *guc, const u32 *data, u32 len, 87 + u32 *response_buf, u32 response_buf_size); 88 + 89 + /* GuC's FW specific event handler function */ 90 + void (*handler)(struct intel_guc *guc); 92 91 93 92 /* GuC's FW specific notify function */ 94 93 void (*notify)(struct intel_guc *guc); ··· 101 92 static 102 93 inline int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 len) 103 94 { 104 - return guc->send(guc, action, len); 95 + return guc->send(guc, action, len, NULL, 0); 96 + } 97 + 98 + static inline int 99 + intel_guc_send_and_receive(struct intel_guc *guc, const u32 *action, u32 len, 100 + u32 *response_buf, u32 response_buf_size) 101 + { 102 + return guc->send(guc, action, len, response_buf, response_buf_size); 105 103 } 106 104 107 105 static inline void intel_guc_notify(struct intel_guc *guc) ··· 116 100 guc->notify(guc); 117 101 } 118 102 119 - /* 120 - * GuC does not allow any gfx GGTT address that falls into range [0, WOPCM_TOP), 121 - * which is reserved for Boot ROM, SRAM and WOPCM. Currently this top address is 122 - * 512K. In order to exclude 0-512K address space from GGTT, all gfx objects 123 - * used by GuC is pinned with PIN_OFFSET_BIAS along with size of WOPCM. 103 + static inline void intel_guc_to_host_event_handler(struct intel_guc *guc) 104 + { 105 + guc->handler(guc); 106 + } 107 + 108 + /* GuC addresses above GUC_GGTT_TOP also don't map through the GTT */ 109 + #define GUC_GGTT_TOP 0xFEE00000 110 + 111 + /** 112 + * intel_guc_ggtt_offset() - Get and validate the GGTT offset of @vma 113 + * @guc: intel_guc structure. 114 + * @vma: i915 graphics virtual memory area. 115 + * 116 + * GuC does not allow any gfx GGTT address that falls into range 117 + * [0, GuC ggtt_pin_bias), which is reserved for Boot ROM, SRAM and WOPCM. 118 + * Currently, in order to exclude [0, GuC ggtt_pin_bias) address space from 119 + * GGTT, all gfx objects used by GuC are allocated with intel_guc_allocate_vma() 120 + * and pinned with PIN_OFFSET_BIAS along with the value of GuC ggtt_pin_bias. 121 + * 122 + * Return: GGTT offset of the @vma. 124 123 */ 125 - static inline u32 guc_ggtt_offset(struct i915_vma *vma) 124 + static inline u32 intel_guc_ggtt_offset(struct intel_guc *guc, 125 + struct i915_vma *vma) 126 126 { 127 127 u32 offset = i915_ggtt_offset(vma); 128 128 129 - GEM_BUG_ON(offset < GUC_WOPCM_TOP); 129 + GEM_BUG_ON(offset < guc->ggtt_pin_bias); 130 130 GEM_BUG_ON(range_overflows_t(u64, offset, vma->size, GUC_GGTT_TOP)); 131 131 132 132 return offset; ··· 151 119 void intel_guc_init_early(struct intel_guc *guc); 152 120 void intel_guc_init_send_regs(struct intel_guc *guc); 153 121 void intel_guc_init_params(struct intel_guc *guc); 122 + void intel_guc_init_ggtt_pin_bias(struct intel_guc *guc); 154 123 int intel_guc_init_wq(struct intel_guc *guc); 155 124 void intel_guc_fini_wq(struct intel_guc *guc); 156 125 int intel_guc_init(struct intel_guc *guc); 157 126 void intel_guc_fini(struct intel_guc *guc); 158 - int intel_guc_send_nop(struct intel_guc *guc, const u32 *action, u32 len); 159 - int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len); 127 + int intel_guc_send_nop(struct intel_guc *guc, const u32 *action, u32 len, 128 + u32 *response_buf, u32 response_buf_size); 129 + int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len, 130 + u32 *response_buf, u32 response_buf_size); 131 + void intel_guc_to_host_event_handler(struct intel_guc *guc); 132 + void intel_guc_to_host_event_handler_nop(struct intel_guc *guc); 133 + void intel_guc_to_host_event_handler_mmio(struct intel_guc *guc); 134 + void intel_guc_to_host_process_recv_msg(struct intel_guc *guc, u32 msg); 160 135 int intel_guc_sample_forcewake(struct intel_guc *guc); 161 136 int intel_guc_auth_huc(struct intel_guc *guc, u32 rsa_offset); 162 137 int intel_guc_suspend(struct intel_guc *guc); 163 138 int intel_guc_resume(struct intel_guc *guc); 164 139 struct i915_vma *intel_guc_allocate_vma(struct intel_guc *guc, u32 size); 165 - u32 intel_guc_wopcm_size(struct drm_i915_private *dev_priv); 140 + 141 + static inline int intel_guc_sanitize(struct intel_guc *guc) 142 + { 143 + intel_uc_fw_sanitize(&guc->fw); 144 + return 0; 145 + } 146 + 147 + static inline void intel_guc_enable_msg(struct intel_guc *guc, u32 mask) 148 + { 149 + spin_lock_irq(&guc->irq_lock); 150 + guc->msg_enabled_mask |= mask; 151 + spin_unlock_irq(&guc->irq_lock); 152 + } 153 + 154 + static inline void intel_guc_disable_msg(struct intel_guc *guc, u32 mask) 155 + { 156 + spin_lock_irq(&guc->irq_lock); 157 + guc->msg_enabled_mask &= ~mask; 158 + spin_unlock_irq(&guc->irq_lock); 159 + } 166 160 167 161 #endif
+4 -4
drivers/gpu/drm/i915/intel_guc_ads.c
··· 75 75 int intel_guc_ads_create(struct intel_guc *guc) 76 76 { 77 77 struct drm_i915_private *dev_priv = guc_to_i915(guc); 78 - struct i915_vma *vma; 78 + struct i915_vma *vma, *kernel_ctx_vma; 79 79 struct page *page; 80 80 /* The ads obj includes the struct itself and buffers passed to GuC */ 81 81 struct { ··· 121 121 * to find it. Note that we have to skip our header (1 page), 122 122 * because our GuC shared data is there. 123 123 */ 124 + kernel_ctx_vma = dev_priv->kernel_context->engine[RCS].state; 124 125 blob->ads.golden_context_lrca = 125 - guc_ggtt_offset(dev_priv->kernel_context->engine[RCS].state) + 126 - skipped_offset; 126 + intel_guc_ggtt_offset(guc, kernel_ctx_vma) + skipped_offset; 127 127 128 128 /* 129 129 * The GuC expects us to exclude the portion of the context image that ··· 135 135 blob->ads.eng_state_size[engine->guc_id] = 136 136 engine->context_size - skipped_size; 137 137 138 - base = guc_ggtt_offset(vma); 138 + base = intel_guc_ggtt_offset(guc, vma); 139 139 blob->ads.scheduler_policies = base + ptr_offset(blob, policies); 140 140 blob->ads.reg_state_buffer = base + ptr_offset(blob, reg_state_buffer); 141 141 blob->ads.reg_state_addr = base + ptr_offset(blob, reg_state);
+496 -53
drivers/gpu/drm/i915/intel_guc_ct.c
··· 24 24 #include "i915_drv.h" 25 25 #include "intel_guc_ct.h" 26 26 27 + #ifdef CONFIG_DRM_I915_DEBUG_GUC 28 + #define CT_DEBUG_DRIVER(...) DRM_DEBUG_DRIVER(__VA_ARGS__) 29 + #else 30 + #define CT_DEBUG_DRIVER(...) do { } while (0) 31 + #endif 32 + 33 + struct ct_request { 34 + struct list_head link; 35 + u32 fence; 36 + u32 status; 37 + u32 response_len; 38 + u32 *response_buf; 39 + }; 40 + 41 + struct ct_incoming_request { 42 + struct list_head link; 43 + u32 msg[]; 44 + }; 45 + 27 46 enum { CTB_SEND = 0, CTB_RECV = 1 }; 28 47 29 48 enum { CTB_OWNER_HOST = 0 }; 30 49 50 + static void ct_incoming_request_worker_func(struct work_struct *w); 51 + 52 + /** 53 + * intel_guc_ct_init_early - Initialize CT state without requiring device access 54 + * @ct: pointer to CT struct 55 + */ 31 56 void intel_guc_ct_init_early(struct intel_guc_ct *ct) 32 57 { 33 58 /* we're using static channel owners */ 34 59 ct->host_channel.owner = CTB_OWNER_HOST; 60 + 61 + spin_lock_init(&ct->lock); 62 + INIT_LIST_HEAD(&ct->pending_requests); 63 + INIT_LIST_HEAD(&ct->incoming_requests); 64 + INIT_WORK(&ct->worker, ct_incoming_request_worker_func); 65 + } 66 + 67 + static inline struct intel_guc *ct_to_guc(struct intel_guc_ct *ct) 68 + { 69 + return container_of(ct, struct intel_guc, ct); 35 70 } 36 71 37 72 static inline const char *guc_ct_buffer_type_to_str(u32 type) ··· 84 49 static void guc_ct_buffer_desc_init(struct guc_ct_buffer_desc *desc, 85 50 u32 cmds_addr, u32 size, u32 owner) 86 51 { 87 - DRM_DEBUG_DRIVER("CT: desc %p init addr=%#x size=%u owner=%u\n", 88 - desc, cmds_addr, size, owner); 52 + CT_DEBUG_DRIVER("CT: desc %p init addr=%#x size=%u owner=%u\n", 53 + desc, cmds_addr, size, owner); 89 54 memset(desc, 0, sizeof(*desc)); 90 55 desc->addr = cmds_addr; 91 56 desc->size = size; ··· 94 59 95 60 static void guc_ct_buffer_desc_reset(struct guc_ct_buffer_desc *desc) 96 61 { 97 - DRM_DEBUG_DRIVER("CT: desc %p reset head=%u tail=%u\n", 98 - desc, desc->head, desc->tail); 62 + CT_DEBUG_DRIVER("CT: desc %p reset head=%u tail=%u\n", 63 + desc, desc->head, desc->tail); 99 64 desc->head = 0; 100 65 desc->tail = 0; 101 66 desc->is_in_error = 0; ··· 114 79 int err; 115 80 116 81 /* Can't use generic send(), CT registration must go over MMIO */ 117 - err = intel_guc_send_mmio(guc, action, ARRAY_SIZE(action)); 82 + err = intel_guc_send_mmio(guc, action, ARRAY_SIZE(action), NULL, 0); 118 83 if (err) 119 84 DRM_ERROR("CT: register %s buffer failed; err=%d\n", 120 85 guc_ct_buffer_type_to_str(type), err); ··· 133 98 int err; 134 99 135 100 /* Can't use generic send(), CT deregistration must go over MMIO */ 136 - err = intel_guc_send_mmio(guc, action, ARRAY_SIZE(action)); 101 + err = intel_guc_send_mmio(guc, action, ARRAY_SIZE(action), NULL, 0); 137 102 if (err) 138 103 DRM_ERROR("CT: deregister %s buffer failed; owner=%d err=%d\n", 139 104 guc_ct_buffer_type_to_str(type), owner, err); ··· 191 156 err = PTR_ERR(blob); 192 157 goto err_vma; 193 158 } 194 - DRM_DEBUG_DRIVER("CT: vma base=%#x\n", guc_ggtt_offset(ctch->vma)); 159 + CT_DEBUG_DRIVER("CT: vma base=%#x\n", 160 + intel_guc_ggtt_offset(guc, ctch->vma)); 195 161 196 162 /* store pointers to desc and cmds */ 197 163 for (i = 0; i < ARRAY_SIZE(ctch->ctbs); i++) { ··· 206 170 err_vma: 207 171 i915_vma_unpin_and_release(&ctch->vma); 208 172 err_out: 209 - DRM_DEBUG_DRIVER("CT: channel %d initialization failed; err=%d\n", 210 - ctch->owner, err); 173 + CT_DEBUG_DRIVER("CT: channel %d initialization failed; err=%d\n", 174 + ctch->owner, err); 211 175 return err; 212 176 } 213 177 ··· 227 191 int err; 228 192 int i; 229 193 230 - DRM_DEBUG_DRIVER("CT: channel %d reopen=%s\n", 231 - ctch->owner, yesno(ctch_is_open(ctch))); 194 + CT_DEBUG_DRIVER("CT: channel %d reopen=%s\n", 195 + ctch->owner, yesno(ctch_is_open(ctch))); 232 196 233 197 if (!ctch->vma) { 234 198 err = ctch_init(guc, ctch); ··· 238 202 } 239 203 240 204 /* vma should be already allocated and map'ed */ 241 - base = guc_ggtt_offset(ctch->vma); 205 + base = intel_guc_ggtt_offset(guc, ctch->vma); 242 206 243 207 /* (re)initialize descriptors 244 208 * cmds buffers are in the second half of the blob page ··· 299 263 return ++ctch->next_fence; 300 264 } 301 265 266 + /** 267 + * DOC: CTB Host to GuC request 268 + * 269 + * Format of the CTB Host to GuC request message is as follows:: 270 + * 271 + * +------------+---------+---------+---------+---------+ 272 + * | msg[0] | [1] | [2] | ... | [n-1] | 273 + * +------------+---------+---------+---------+---------+ 274 + * | MESSAGE | MESSAGE PAYLOAD | 275 + * + HEADER +---------+---------+---------+---------+ 276 + * | | 0 | 1 | ... | n | 277 + * +============+=========+=========+=========+=========+ 278 + * | len >= 1 | FENCE | request specific data | 279 + * +------+-----+---------+---------+---------+---------+ 280 + * 281 + * ^-----------------len-------------------^ 282 + */ 283 + 302 284 static int ctb_write(struct intel_guc_ct_buffer *ctb, 303 285 const u32 *action, 304 286 u32 len /* in dwords */, 305 - u32 fence) 287 + u32 fence, 288 + bool want_response) 306 289 { 307 290 struct guc_ct_buffer_desc *desc = ctb->desc; 308 291 u32 head = desc->head / 4; /* in dwords */ ··· 350 295 if (unlikely(used + len + 1 >= size)) 351 296 return -ENOSPC; 352 297 353 - /* Write the message. The format is the following: 298 + /* 299 + * Write the message. The format is the following: 354 300 * DW0: header (including action code) 355 301 * DW1: fence 356 302 * DW2+: action data 357 303 */ 358 304 header = (len << GUC_CT_MSG_LEN_SHIFT) | 359 305 (GUC_CT_MSG_WRITE_FENCE_TO_DESC) | 306 + (want_response ? GUC_CT_MSG_SEND_STATUS : 0) | 360 307 (action[0] << GUC_CT_MSG_ACTION_SHIFT); 308 + 309 + CT_DEBUG_DRIVER("CT: writing %*ph %*ph %*ph\n", 310 + 4, &header, 4, &fence, 311 + 4 * (len - 1), &action[1]); 361 312 362 313 cmds[tail] = header; 363 314 tail = (tail + 1) % size; ··· 383 322 return 0; 384 323 } 385 324 386 - /* Wait for the response from the GuC. 325 + /** 326 + * wait_for_ctb_desc_update - Wait for the CT buffer descriptor update. 327 + * @desc: buffer descriptor 387 328 * @fence: response fence 388 329 * @status: placeholder for status 389 - * return: 0 response received (status is valid) 390 - * -ETIMEDOUT no response within hardcoded timeout 391 - * -EPROTO no response, ct buffer was in error 330 + * 331 + * Guc will update CT buffer descriptor with new fence and status 332 + * after processing the command identified by the fence. Wait for 333 + * specified fence and then read from the descriptor status of the 334 + * command. 335 + * 336 + * Return: 337 + * * 0 response received (status is valid) 338 + * * -ETIMEDOUT no response within hardcoded timeout 339 + * * -EPROTO no response, CT buffer is in error 392 340 */ 393 - static int wait_for_response(struct guc_ct_buffer_desc *desc, 394 - u32 fence, 395 - u32 *status) 341 + static int wait_for_ctb_desc_update(struct guc_ct_buffer_desc *desc, 342 + u32 fence, 343 + u32 *status) 396 344 { 397 345 int err; 398 346 ··· 433 363 return err; 434 364 } 435 365 436 - static int ctch_send(struct intel_guc *guc, 366 + /** 367 + * wait_for_ct_request_update - Wait for CT request state update. 368 + * @req: pointer to pending request 369 + * @status: placeholder for status 370 + * 371 + * For each sent request, Guc shall send bac CT response message. 372 + * Our message handler will update status of tracked request once 373 + * response message with given fence is received. Wait here and 374 + * check for valid response status value. 375 + * 376 + * Return: 377 + * * 0 response received (status is valid) 378 + * * -ETIMEDOUT no response within hardcoded timeout 379 + */ 380 + static int wait_for_ct_request_update(struct ct_request *req, u32 *status) 381 + { 382 + int err; 383 + 384 + /* 385 + * Fast commands should complete in less than 10us, so sample quickly 386 + * up to that length of time, then switch to a slower sleep-wait loop. 387 + * No GuC command should ever take longer than 10ms. 388 + */ 389 + #define done INTEL_GUC_MSG_IS_RESPONSE(READ_ONCE(req->status)) 390 + err = wait_for_us(done, 10); 391 + if (err) 392 + err = wait_for(done, 10); 393 + #undef done 394 + 395 + if (unlikely(err)) 396 + DRM_ERROR("CT: fence %u err %d\n", req->fence, err); 397 + 398 + *status = req->status; 399 + return err; 400 + } 401 + 402 + static int ctch_send(struct intel_guc_ct *ct, 437 403 struct intel_guc_ct_channel *ctch, 438 404 const u32 *action, 439 405 u32 len, 406 + u32 *response_buf, 407 + u32 response_buf_size, 440 408 u32 *status) 441 409 { 442 410 struct intel_guc_ct_buffer *ctb = &ctch->ctbs[CTB_SEND]; 443 411 struct guc_ct_buffer_desc *desc = ctb->desc; 412 + struct ct_request request; 413 + unsigned long flags; 444 414 u32 fence; 445 415 int err; 446 416 447 417 GEM_BUG_ON(!ctch_is_open(ctch)); 448 418 GEM_BUG_ON(!len); 449 419 GEM_BUG_ON(len & ~GUC_CT_MSG_LEN_MASK); 420 + GEM_BUG_ON(!response_buf && response_buf_size); 450 421 451 422 fence = ctch_get_next_fence(ctch); 452 - err = ctb_write(ctb, action, len, fence); 453 - if (unlikely(err)) 454 - return err; 423 + request.fence = fence; 424 + request.status = 0; 425 + request.response_len = response_buf_size; 426 + request.response_buf = response_buf; 455 427 456 - intel_guc_notify(guc); 428 + spin_lock_irqsave(&ct->lock, flags); 429 + list_add_tail(&request.link, &ct->pending_requests); 430 + spin_unlock_irqrestore(&ct->lock, flags); 457 431 458 - err = wait_for_response(desc, fence, status); 432 + err = ctb_write(ctb, action, len, fence, !!response_buf); 459 433 if (unlikely(err)) 460 - return err; 461 - if (*status != INTEL_GUC_STATUS_SUCCESS) 462 - return -EIO; 463 - return 0; 434 + goto unlink; 435 + 436 + intel_guc_notify(ct_to_guc(ct)); 437 + 438 + if (response_buf) 439 + err = wait_for_ct_request_update(&request, status); 440 + else 441 + err = wait_for_ctb_desc_update(desc, fence, status); 442 + if (unlikely(err)) 443 + goto unlink; 444 + 445 + if (!INTEL_GUC_MSG_IS_RESPONSE_SUCCESS(*status)) { 446 + err = -EIO; 447 + goto unlink; 448 + } 449 + 450 + if (response_buf) { 451 + /* There shall be no data in the status */ 452 + WARN_ON(INTEL_GUC_MSG_TO_DATA(request.status)); 453 + /* Return actual response len */ 454 + err = request.response_len; 455 + } else { 456 + /* There shall be no response payload */ 457 + WARN_ON(request.response_len); 458 + /* Return data decoded from the status dword */ 459 + err = INTEL_GUC_MSG_TO_DATA(*status); 460 + } 461 + 462 + unlink: 463 + spin_lock_irqsave(&ct->lock, flags); 464 + list_del(&request.link); 465 + spin_unlock_irqrestore(&ct->lock, flags); 466 + 467 + return err; 464 468 } 465 469 466 470 /* 467 471 * Command Transport (CT) buffer based GuC send function. 468 472 */ 469 - static int intel_guc_send_ct(struct intel_guc *guc, const u32 *action, u32 len) 473 + static int intel_guc_send_ct(struct intel_guc *guc, const u32 *action, u32 len, 474 + u32 *response_buf, u32 response_buf_size) 470 475 { 471 - struct intel_guc_ct_channel *ctch = &guc->ct.host_channel; 476 + struct intel_guc_ct *ct = &guc->ct; 477 + struct intel_guc_ct_channel *ctch = &ct->host_channel; 472 478 u32 status = ~0; /* undefined */ 473 - int err; 479 + int ret; 474 480 475 481 mutex_lock(&guc->send_mutex); 476 482 477 - err = ctch_send(guc, ctch, action, len, &status); 478 - if (unlikely(err)) { 483 + ret = ctch_send(ct, ctch, action, len, response_buf, response_buf_size, 484 + &status); 485 + if (unlikely(ret < 0)) { 479 486 DRM_ERROR("CT: send action %#X failed; err=%d status=%#X\n", 480 - action[0], err, status); 487 + action[0], ret, status); 488 + } else if (unlikely(ret)) { 489 + CT_DEBUG_DRIVER("CT: send action %#x returned %d (%#x)\n", 490 + action[0], ret, ret); 481 491 } 482 492 483 493 mutex_unlock(&guc->send_mutex); 484 - return err; 494 + return ret; 495 + } 496 + 497 + static inline unsigned int ct_header_get_len(u32 header) 498 + { 499 + return (header >> GUC_CT_MSG_LEN_SHIFT) & GUC_CT_MSG_LEN_MASK; 500 + } 501 + 502 + static inline unsigned int ct_header_get_action(u32 header) 503 + { 504 + return (header >> GUC_CT_MSG_ACTION_SHIFT) & GUC_CT_MSG_ACTION_MASK; 505 + } 506 + 507 + static inline bool ct_header_is_response(u32 header) 508 + { 509 + return ct_header_get_action(header) == INTEL_GUC_ACTION_DEFAULT; 510 + } 511 + 512 + static int ctb_read(struct intel_guc_ct_buffer *ctb, u32 *data) 513 + { 514 + struct guc_ct_buffer_desc *desc = ctb->desc; 515 + u32 head = desc->head / 4; /* in dwords */ 516 + u32 tail = desc->tail / 4; /* in dwords */ 517 + u32 size = desc->size / 4; /* in dwords */ 518 + u32 *cmds = ctb->cmds; 519 + s32 available; /* in dwords */ 520 + unsigned int len; 521 + unsigned int i; 522 + 523 + GEM_BUG_ON(desc->size % 4); 524 + GEM_BUG_ON(desc->head % 4); 525 + GEM_BUG_ON(desc->tail % 4); 526 + GEM_BUG_ON(tail >= size); 527 + GEM_BUG_ON(head >= size); 528 + 529 + /* tail == head condition indicates empty */ 530 + available = tail - head; 531 + if (unlikely(available == 0)) 532 + return -ENODATA; 533 + 534 + /* beware of buffer wrap case */ 535 + if (unlikely(available < 0)) 536 + available += size; 537 + CT_DEBUG_DRIVER("CT: available %d (%u:%u)\n", available, head, tail); 538 + GEM_BUG_ON(available < 0); 539 + 540 + data[0] = cmds[head]; 541 + head = (head + 1) % size; 542 + 543 + /* message len with header */ 544 + len = ct_header_get_len(data[0]) + 1; 545 + if (unlikely(len > (u32)available)) { 546 + DRM_ERROR("CT: incomplete message %*ph %*ph %*ph\n", 547 + 4, data, 548 + 4 * (head + available - 1 > size ? 549 + size - head : available - 1), &cmds[head], 550 + 4 * (head + available - 1 > size ? 551 + available - 1 - size + head : 0), &cmds[0]); 552 + return -EPROTO; 553 + } 554 + 555 + for (i = 1; i < len; i++) { 556 + data[i] = cmds[head]; 557 + head = (head + 1) % size; 558 + } 559 + CT_DEBUG_DRIVER("CT: received %*ph\n", 4 * len, data); 560 + 561 + desc->head = head * 4; 562 + return 0; 485 563 } 486 564 487 565 /** 488 - * Enable buffer based command transport 489 - * Shall only be called for platforms with HAS_GUC_CT. 490 - * @guc: the guc 491 - * return: 0 on success 492 - * non-zero on failure 566 + * DOC: CTB GuC to Host response 567 + * 568 + * Format of the CTB GuC to Host response message is as follows:: 569 + * 570 + * +------------+---------+---------+---------+---------+---------+ 571 + * | msg[0] | [1] | [2] | [3] | ... | [n-1] | 572 + * +------------+---------+---------+---------+---------+---------+ 573 + * | MESSAGE | MESSAGE PAYLOAD | 574 + * + HEADER +---------+---------+---------+---------+---------+ 575 + * | | 0 | 1 | 2 | ... | n | 576 + * +============+=========+=========+=========+=========+=========+ 577 + * | len >= 2 | FENCE | STATUS | response specific data | 578 + * +------+-----+---------+---------+---------+---------+---------+ 579 + * 580 + * ^-----------------------len-----------------------^ 493 581 */ 494 - int intel_guc_enable_ct(struct intel_guc *guc) 582 + 583 + static int ct_handle_response(struct intel_guc_ct *ct, const u32 *msg) 495 584 { 496 - struct drm_i915_private *dev_priv = guc_to_i915(guc); 497 - struct intel_guc_ct_channel *ctch = &guc->ct.host_channel; 585 + u32 header = msg[0]; 586 + u32 len = ct_header_get_len(header); 587 + u32 msglen = len + 1; /* total message length including header */ 588 + u32 fence; 589 + u32 status; 590 + u32 datalen; 591 + struct ct_request *req; 592 + bool found = false; 593 + 594 + GEM_BUG_ON(!ct_header_is_response(header)); 595 + GEM_BUG_ON(!in_irq()); 596 + 597 + /* Response payload shall at least include fence and status */ 598 + if (unlikely(len < 2)) { 599 + DRM_ERROR("CT: corrupted response %*ph\n", 4 * msglen, msg); 600 + return -EPROTO; 601 + } 602 + 603 + fence = msg[1]; 604 + status = msg[2]; 605 + datalen = len - 2; 606 + 607 + /* Format of the status follows RESPONSE message */ 608 + if (unlikely(!INTEL_GUC_MSG_IS_RESPONSE(status))) { 609 + DRM_ERROR("CT: corrupted response %*ph\n", 4 * msglen, msg); 610 + return -EPROTO; 611 + } 612 + 613 + CT_DEBUG_DRIVER("CT: response fence %u status %#x\n", fence, status); 614 + 615 + spin_lock(&ct->lock); 616 + list_for_each_entry(req, &ct->pending_requests, link) { 617 + if (unlikely(fence != req->fence)) { 618 + CT_DEBUG_DRIVER("CT: request %u awaits response\n", 619 + req->fence); 620 + continue; 621 + } 622 + if (unlikely(datalen > req->response_len)) { 623 + DRM_ERROR("CT: response %u too long %*ph\n", 624 + req->fence, 4 * msglen, msg); 625 + datalen = 0; 626 + } 627 + if (datalen) 628 + memcpy(req->response_buf, msg + 3, 4 * datalen); 629 + req->response_len = datalen; 630 + WRITE_ONCE(req->status, status); 631 + found = true; 632 + break; 633 + } 634 + spin_unlock(&ct->lock); 635 + 636 + if (!found) 637 + DRM_ERROR("CT: unsolicited response %*ph\n", 4 * msglen, msg); 638 + return 0; 639 + } 640 + 641 + static void ct_process_request(struct intel_guc_ct *ct, 642 + u32 action, u32 len, const u32 *payload) 643 + { 644 + struct intel_guc *guc = ct_to_guc(ct); 645 + 646 + CT_DEBUG_DRIVER("CT: request %x %*ph\n", action, 4 * len, payload); 647 + 648 + switch (action) { 649 + case INTEL_GUC_ACTION_DEFAULT: 650 + if (unlikely(len < 1)) 651 + goto fail_unexpected; 652 + intel_guc_to_host_process_recv_msg(guc, *payload); 653 + break; 654 + 655 + default: 656 + fail_unexpected: 657 + DRM_ERROR("CT: unexpected request %x %*ph\n", 658 + action, 4 * len, payload); 659 + break; 660 + } 661 + } 662 + 663 + static bool ct_process_incoming_requests(struct intel_guc_ct *ct) 664 + { 665 + unsigned long flags; 666 + struct ct_incoming_request *request; 667 + u32 header; 668 + u32 *payload; 669 + bool done; 670 + 671 + spin_lock_irqsave(&ct->lock, flags); 672 + request = list_first_entry_or_null(&ct->incoming_requests, 673 + struct ct_incoming_request, link); 674 + if (request) 675 + list_del(&request->link); 676 + done = !!list_empty(&ct->incoming_requests); 677 + spin_unlock_irqrestore(&ct->lock, flags); 678 + 679 + if (!request) 680 + return true; 681 + 682 + header = request->msg[0]; 683 + payload = &request->msg[1]; 684 + ct_process_request(ct, 685 + ct_header_get_action(header), 686 + ct_header_get_len(header), 687 + payload); 688 + 689 + kfree(request); 690 + return done; 691 + } 692 + 693 + static void ct_incoming_request_worker_func(struct work_struct *w) 694 + { 695 + struct intel_guc_ct *ct = container_of(w, struct intel_guc_ct, worker); 696 + bool done; 697 + 698 + done = ct_process_incoming_requests(ct); 699 + if (!done) 700 + queue_work(system_unbound_wq, &ct->worker); 701 + } 702 + 703 + /** 704 + * DOC: CTB GuC to Host request 705 + * 706 + * Format of the CTB GuC to Host request message is as follows:: 707 + * 708 + * +------------+---------+---------+---------+---------+---------+ 709 + * | msg[0] | [1] | [2] | [3] | ... | [n-1] | 710 + * +------------+---------+---------+---------+---------+---------+ 711 + * | MESSAGE | MESSAGE PAYLOAD | 712 + * + HEADER +---------+---------+---------+---------+---------+ 713 + * | | 0 | 1 | 2 | ... | n | 714 + * +============+=========+=========+=========+=========+=========+ 715 + * | len | request specific data | 716 + * +------+-----+---------+---------+---------+---------+---------+ 717 + * 718 + * ^-----------------------len-----------------------^ 719 + */ 720 + 721 + static int ct_handle_request(struct intel_guc_ct *ct, const u32 *msg) 722 + { 723 + u32 header = msg[0]; 724 + u32 len = ct_header_get_len(header); 725 + u32 msglen = len + 1; /* total message length including header */ 726 + struct ct_incoming_request *request; 727 + unsigned long flags; 728 + 729 + GEM_BUG_ON(ct_header_is_response(header)); 730 + 731 + request = kmalloc(sizeof(*request) + 4 * msglen, GFP_ATOMIC); 732 + if (unlikely(!request)) { 733 + DRM_ERROR("CT: dropping request %*ph\n", 4 * msglen, msg); 734 + return 0; /* XXX: -ENOMEM ? */ 735 + } 736 + memcpy(request->msg, msg, 4 * msglen); 737 + 738 + spin_lock_irqsave(&ct->lock, flags); 739 + list_add_tail(&request->link, &ct->incoming_requests); 740 + spin_unlock_irqrestore(&ct->lock, flags); 741 + 742 + queue_work(system_unbound_wq, &ct->worker); 743 + return 0; 744 + } 745 + 746 + static void ct_process_host_channel(struct intel_guc_ct *ct) 747 + { 748 + struct intel_guc_ct_channel *ctch = &ct->host_channel; 749 + struct intel_guc_ct_buffer *ctb = &ctch->ctbs[CTB_RECV]; 750 + u32 msg[GUC_CT_MSG_LEN_MASK + 1]; /* one extra dw for the header */ 751 + int err = 0; 752 + 753 + if (!ctch_is_open(ctch)) 754 + return; 755 + 756 + do { 757 + err = ctb_read(ctb, msg); 758 + if (err) 759 + break; 760 + 761 + if (ct_header_is_response(msg[0])) 762 + err = ct_handle_response(ct, msg); 763 + else 764 + err = ct_handle_request(ct, msg); 765 + } while (!err); 766 + 767 + if (GEM_WARN_ON(err == -EPROTO)) { 768 + DRM_ERROR("CT: corrupted message detected!\n"); 769 + ctb->desc->is_in_error = 1; 770 + } 771 + } 772 + 773 + /* 774 + * When we're communicating with the GuC over CT, GuC uses events 775 + * to notify us about new messages being posted on the RECV buffer. 776 + */ 777 + static void intel_guc_to_host_event_handler_ct(struct intel_guc *guc) 778 + { 779 + struct intel_guc_ct *ct = &guc->ct; 780 + 781 + ct_process_host_channel(ct); 782 + } 783 + 784 + /** 785 + * intel_guc_ct_enable - Enable buffer based command transport. 786 + * @ct: pointer to CT struct 787 + * 788 + * Shall only be called for platforms with HAS_GUC_CT. 789 + * 790 + * Return: 0 on success, a negative errno code on failure. 791 + */ 792 + int intel_guc_ct_enable(struct intel_guc_ct *ct) 793 + { 794 + struct intel_guc *guc = ct_to_guc(ct); 795 + struct drm_i915_private *i915 = guc_to_i915(guc); 796 + struct intel_guc_ct_channel *ctch = &ct->host_channel; 498 797 int err; 499 798 500 - GEM_BUG_ON(!HAS_GUC_CT(dev_priv)); 799 + GEM_BUG_ON(!HAS_GUC_CT(i915)); 501 800 502 801 err = ctch_open(guc, ctch); 503 802 if (unlikely(err)) ··· 874 435 875 436 /* Switch into cmd transport buffer based send() */ 876 437 guc->send = intel_guc_send_ct; 438 + guc->handler = intel_guc_to_host_event_handler_ct; 877 439 DRM_INFO("CT: %s\n", enableddisabled(true)); 878 440 return 0; 879 441 } 880 442 881 443 /** 882 - * Disable buffer based command transport. 444 + * intel_guc_ct_disable - Disable buffer based command transport. 445 + * @ct: pointer to CT struct 446 + * 883 447 * Shall only be called for platforms with HAS_GUC_CT. 884 - * @guc: the guc 885 448 */ 886 - void intel_guc_disable_ct(struct intel_guc *guc) 449 + void intel_guc_ct_disable(struct intel_guc_ct *ct) 887 450 { 888 - struct drm_i915_private *dev_priv = guc_to_i915(guc); 889 - struct intel_guc_ct_channel *ctch = &guc->ct.host_channel; 451 + struct intel_guc *guc = ct_to_guc(ct); 452 + struct drm_i915_private *i915 = guc_to_i915(guc); 453 + struct intel_guc_ct_channel *ctch = &ct->host_channel; 890 454 891 - GEM_BUG_ON(!HAS_GUC_CT(dev_priv)); 455 + GEM_BUG_ON(!HAS_GUC_CT(i915)); 892 456 893 457 if (!ctch_is_open(ctch)) 894 458 return; ··· 900 458 901 459 /* Disable send */ 902 460 guc->send = intel_guc_send_nop; 461 + guc->handler = intel_guc_to_host_event_handler_nop; 903 462 DRM_INFO("CT: %s\n", enableddisabled(false)); 904 463 }
+14 -4
drivers/gpu/drm/i915/intel_guc_ct.h
··· 75 75 struct intel_guc_ct { 76 76 struct intel_guc_ct_channel host_channel; 77 77 /* other channels are tbd */ 78 + 79 + /** @lock: protects pending requests list */ 80 + spinlock_t lock; 81 + 82 + /** @pending_requests: list of requests waiting for response */ 83 + struct list_head pending_requests; 84 + 85 + /** @incoming_requests: list of incoming requests */ 86 + struct list_head incoming_requests; 87 + 88 + /** @worker: worker for handling incoming requests */ 89 + struct work_struct worker; 78 90 }; 79 91 80 92 void intel_guc_ct_init_early(struct intel_guc_ct *ct); 81 - 82 - /* XXX: move to intel_uc.h ? don't fit there either */ 83 - int intel_guc_enable_ct(struct intel_guc *guc); 84 - void intel_guc_disable_ct(struct intel_guc *guc); 93 + int intel_guc_ct_enable(struct intel_guc_ct *ct); 94 + void intel_guc_ct_disable(struct intel_guc_ct *ct); 85 95 86 96 #endif /* _INTEL_GUC_CT_H_ */
+3 -4
drivers/gpu/drm/i915/intel_guc_fw.c
··· 165 165 I915_WRITE(DMA_COPY_SIZE, guc_fw->header_size + guc_fw->ucode_size); 166 166 167 167 /* Set the source address for the new blob */ 168 - offset = guc_ggtt_offset(vma) + guc_fw->header_offset; 168 + offset = intel_guc_ggtt_offset(guc, vma) + guc_fw->header_offset; 169 169 I915_WRITE(DMA_ADDR_0_LOW, lower_32_bits(offset)); 170 170 I915_WRITE(DMA_ADDR_0_HIGH, upper_32_bits(offset) & 0xFFFF); 171 171 ··· 275 275 * Called from intel_uc_init_hw() during driver load, resume from sleep and 276 276 * after a GPU reset. 277 277 * 278 - * The firmware image should have already been fetched into memory by the 279 - * earlier call to intel_uc_init_fw(), so here we need to only check that 280 - * fetch succeeded, and then transfer the image to the h/w. 278 + * The firmware image should have already been fetched into memory, so only 279 + * check that fetch succeeded, and then transfer the image to the h/w. 281 280 * 282 281 * Return: non-zero code on error 283 282 */
+128 -27
drivers/gpu/drm/i915/intel_guc_fwif.h
··· 127 127 #define GUC_PROFILE_ENABLED (1 << 7) 128 128 #define GUC_WQ_TRACK_ENABLED (1 << 8) 129 129 #define GUC_ADS_ENABLED (1 << 9) 130 - #define GUC_DEBUG_RESERVED (1 << 10) 130 + #define GUC_LOG_DEFAULT_DISABLED (1 << 10) 131 131 #define GUC_ADS_ADDR_SHIFT 11 132 132 #define GUC_ADS_ADDR_MASK 0xfffff800 133 133 ··· 326 326 327 327 u64 desc_private; 328 328 } __packed; 329 + 330 + /** 331 + * DOC: CTB based communication 332 + * 333 + * The CTB (command transport buffer) communication between Host and GuC 334 + * is based on u32 data stream written to the shared buffer. One buffer can 335 + * be used to transmit data only in one direction (one-directional channel). 336 + * 337 + * Current status of the each buffer is stored in the buffer descriptor. 338 + * Buffer descriptor holds tail and head fields that represents active data 339 + * stream. The tail field is updated by the data producer (sender), and head 340 + * field is updated by the data consumer (receiver):: 341 + * 342 + * +------------+ 343 + * | DESCRIPTOR | +=================+============+========+ 344 + * +============+ | | MESSAGE(s) | | 345 + * | address |--------->+=================+============+========+ 346 + * +------------+ 347 + * | head | ^-----head--------^ 348 + * +------------+ 349 + * | tail | ^---------tail-----------------^ 350 + * +------------+ 351 + * | size | ^---------------size--------------------^ 352 + * +------------+ 353 + * 354 + * Each message in data stream starts with the single u32 treated as a header, 355 + * followed by optional set of u32 data that makes message specific payload:: 356 + * 357 + * +------------+---------+---------+---------+ 358 + * | MESSAGE | 359 + * +------------+---------+---------+---------+ 360 + * | msg[0] | [1] | ... | [n-1] | 361 + * +------------+---------+---------+---------+ 362 + * | MESSAGE | MESSAGE PAYLOAD | 363 + * + HEADER +---------+---------+---------+ 364 + * | | 0 | ... | n | 365 + * +======+=====+=========+=========+=========+ 366 + * | 31:16| code| | | | 367 + * +------+-----+ | | | 368 + * | 15:5|flags| | | | 369 + * +------+-----+ | | | 370 + * | 4:0| len| | | | 371 + * +------+-----+---------+---------+---------+ 372 + * 373 + * ^-------------len-------------^ 374 + * 375 + * The message header consists of: 376 + * 377 + * - **len**, indicates length of the message payload (in u32) 378 + * - **code**, indicates message code 379 + * - **flags**, holds various bits to control message handling 380 + */ 329 381 330 382 /* 331 383 * Describes single command transport buffer. ··· 586 534 u32 version; 587 535 } __packed; 588 536 589 - union guc_log_control { 590 - struct { 591 - u32 logging_enabled:1; 592 - u32 reserved1:3; 593 - u32 verbosity:4; 594 - u32 reserved2:24; 595 - }; 596 - u32 value; 597 - } __packed; 598 - 599 537 struct guc_ctx_report { 600 538 u32 report_return_status; 601 539 u32 reserved1[64]; ··· 612 570 struct guc_ctx_report preempt_ctx_report[GUC_MAX_ENGINES_NUM]; 613 571 } __packed; 614 572 615 - /* This Action will be programmed in C180 - SOFT_SCRATCH_O_REG */ 573 + /** 574 + * DOC: MMIO based communication 575 + * 576 + * The MMIO based communication between Host and GuC uses software scratch 577 + * registers, where first register holds data treated as message header, 578 + * and other registers are used to hold message payload. 579 + * 580 + * For Gen9+, GuC uses software scratch registers 0xC180-0xC1B8 581 + * 582 + * +-----------+---------+---------+---------+ 583 + * | MMIO[0] | MMIO[1] | ... | MMIO[n] | 584 + * +-----------+---------+---------+---------+ 585 + * | header | optional payload | 586 + * +======+====+=========+=========+=========+ 587 + * | 31:28|type| | | | 588 + * +------+----+ | | | 589 + * | 27:16|data| | | | 590 + * +------+----+ | | | 591 + * | 15:0|code| | | | 592 + * +------+----+---------+---------+---------+ 593 + * 594 + * The message header consists of: 595 + * 596 + * - **type**, indicates message type 597 + * - **code**, indicates message code, is specific for **type** 598 + * - **data**, indicates message data, optional, depends on **code** 599 + * 600 + * The following message **types** are supported: 601 + * 602 + * - **REQUEST**, indicates Host-to-GuC request, requested GuC action code 603 + * must be priovided in **code** field. Optional action specific parameters 604 + * can be provided in remaining payload registers or **data** field. 605 + * 606 + * - **RESPONSE**, indicates GuC-to-Host response from earlier GuC request, 607 + * action response status will be provided in **code** field. Optional 608 + * response data can be returned in remaining payload registers or **data** 609 + * field. 610 + */ 611 + 612 + #define INTEL_GUC_MSG_TYPE_SHIFT 28 613 + #define INTEL_GUC_MSG_TYPE_MASK (0xF << INTEL_GUC_MSG_TYPE_SHIFT) 614 + #define INTEL_GUC_MSG_DATA_SHIFT 16 615 + #define INTEL_GUC_MSG_DATA_MASK (0xFFF << INTEL_GUC_MSG_DATA_SHIFT) 616 + #define INTEL_GUC_MSG_CODE_SHIFT 0 617 + #define INTEL_GUC_MSG_CODE_MASK (0xFFFF << INTEL_GUC_MSG_CODE_SHIFT) 618 + 619 + #define __INTEL_GUC_MSG_GET(T, m) \ 620 + (((m) & INTEL_GUC_MSG_ ## T ## _MASK) >> INTEL_GUC_MSG_ ## T ## _SHIFT) 621 + #define INTEL_GUC_MSG_TO_TYPE(m) __INTEL_GUC_MSG_GET(TYPE, m) 622 + #define INTEL_GUC_MSG_TO_DATA(m) __INTEL_GUC_MSG_GET(DATA, m) 623 + #define INTEL_GUC_MSG_TO_CODE(m) __INTEL_GUC_MSG_GET(CODE, m) 624 + 625 + enum intel_guc_msg_type { 626 + INTEL_GUC_MSG_TYPE_REQUEST = 0x0, 627 + INTEL_GUC_MSG_TYPE_RESPONSE = 0xF, 628 + }; 629 + 630 + #define __INTEL_GUC_MSG_TYPE_IS(T, m) \ 631 + (INTEL_GUC_MSG_TO_TYPE(m) == INTEL_GUC_MSG_TYPE_ ## T) 632 + #define INTEL_GUC_MSG_IS_REQUEST(m) __INTEL_GUC_MSG_TYPE_IS(REQUEST, m) 633 + #define INTEL_GUC_MSG_IS_RESPONSE(m) __INTEL_GUC_MSG_TYPE_IS(RESPONSE, m) 634 + 616 635 enum intel_guc_action { 617 636 INTEL_GUC_ACTION_DEFAULT = 0x0, 618 637 INTEL_GUC_ACTION_REQUEST_PREEMPTION = 0x2, ··· 705 602 INTEL_GUC_REPORT_STATUS_COMPLETE = 0x4, 706 603 }; 707 604 708 - /* 709 - * The GuC sends its response to a command by overwriting the 710 - * command in SS0. The response is distinguishable from a command 711 - * by the fact that all the MASK bits are set. The remaining bits 712 - * give more detail. 713 - */ 714 - #define INTEL_GUC_RECV_MASK ((u32)0xF0000000) 715 - #define INTEL_GUC_RECV_IS_RESPONSE(x) ((u32)(x) >= INTEL_GUC_RECV_MASK) 716 - #define INTEL_GUC_RECV_STATUS(x) (INTEL_GUC_RECV_MASK | (x)) 605 + #define GUC_LOG_CONTROL_LOGGING_ENABLED (1 << 0) 606 + #define GUC_LOG_CONTROL_VERBOSITY_SHIFT 4 607 + #define GUC_LOG_CONTROL_VERBOSITY_MASK (0xF << GUC_LOG_CONTROL_VERBOSITY_SHIFT) 608 + #define GUC_LOG_CONTROL_DEFAULT_LOGGING (1 << 8) 717 609 718 - /* GUC will return status back to SOFT_SCRATCH_O_REG */ 719 - enum intel_guc_status { 720 - INTEL_GUC_STATUS_SUCCESS = INTEL_GUC_RECV_STATUS(0x0), 721 - INTEL_GUC_STATUS_ALLOCATE_DOORBELL_FAIL = INTEL_GUC_RECV_STATUS(0x10), 722 - INTEL_GUC_STATUS_DEALLOCATE_DOORBELL_FAIL = INTEL_GUC_RECV_STATUS(0x20), 723 - INTEL_GUC_STATUS_GENERIC_FAIL = INTEL_GUC_RECV_STATUS(0x0000F000) 610 + enum intel_guc_response_status { 611 + INTEL_GUC_RESPONSE_STATUS_SUCCESS = 0x0, 612 + INTEL_GUC_RESPONSE_STATUS_GENERIC_FAIL = 0xF000, 724 613 }; 614 + 615 + #define INTEL_GUC_MSG_IS_RESPONSE_SUCCESS(m) \ 616 + (typecheck(u32, (m)) && \ 617 + ((m) & (INTEL_GUC_MSG_TYPE_MASK | INTEL_GUC_MSG_CODE_MASK)) == \ 618 + ((INTEL_GUC_MSG_TYPE_RESPONSE << INTEL_GUC_MSG_TYPE_SHIFT) | \ 619 + (INTEL_GUC_RESPONSE_STATUS_SUCCESS << INTEL_GUC_MSG_CODE_SHIFT))) 725 620 726 621 /* This action will be programmed in C1BC - SOFT_SCRATCH_15_REG */ 727 622 enum intel_guc_recv_message {
+213 -339
drivers/gpu/drm/i915/intel_guc_log.c
··· 23 23 */ 24 24 25 25 #include <linux/debugfs.h> 26 - #include <linux/relay.h> 27 26 28 27 #include "intel_guc_log.h" 29 28 #include "i915_drv.h" 30 29 31 - static void guc_log_capture_logs(struct intel_guc *guc); 30 + static void guc_log_capture_logs(struct intel_guc_log *log); 32 31 33 32 /** 34 33 * DOC: GuC firmware log ··· 38 39 * registers value. 39 40 */ 40 41 41 - static int guc_log_flush_complete(struct intel_guc *guc) 42 + static int guc_action_flush_log_complete(struct intel_guc *guc) 42 43 { 43 44 u32 action[] = { 44 45 INTEL_GUC_ACTION_LOG_BUFFER_FILE_FLUSH_COMPLETE ··· 47 48 return intel_guc_send(guc, action, ARRAY_SIZE(action)); 48 49 } 49 50 50 - static int guc_log_flush(struct intel_guc *guc) 51 + static int guc_action_flush_log(struct intel_guc *guc) 51 52 { 52 53 u32 action[] = { 53 54 INTEL_GUC_ACTION_FORCE_LOG_BUFFER_FLUSH, ··· 57 58 return intel_guc_send(guc, action, ARRAY_SIZE(action)); 58 59 } 59 60 60 - static int guc_log_control(struct intel_guc *guc, bool enable, u32 verbosity) 61 + static int guc_action_control_log(struct intel_guc *guc, bool enable, 62 + bool default_logging, u32 verbosity) 61 63 { 62 - union guc_log_control control_val = { 63 - { 64 - .logging_enabled = enable, 65 - .verbosity = verbosity, 66 - }, 67 - }; 68 64 u32 action[] = { 69 65 INTEL_GUC_ACTION_UK_LOG_ENABLE_LOGGING, 70 - control_val.value 66 + (enable ? GUC_LOG_CONTROL_LOGGING_ENABLED : 0) | 67 + (verbosity << GUC_LOG_CONTROL_VERBOSITY_SHIFT) | 68 + (default_logging ? GUC_LOG_CONTROL_DEFAULT_LOGGING : 0) 71 69 }; 72 70 71 + GEM_BUG_ON(verbosity > GUC_LOG_VERBOSITY_MAX); 72 + 73 73 return intel_guc_send(guc, action, ARRAY_SIZE(action)); 74 + } 75 + 76 + static inline struct intel_guc *log_to_guc(struct intel_guc_log *log) 77 + { 78 + return container_of(log, struct intel_guc, log); 79 + } 80 + 81 + static void guc_log_enable_flush_events(struct intel_guc_log *log) 82 + { 83 + intel_guc_enable_msg(log_to_guc(log), 84 + INTEL_GUC_RECV_MSG_FLUSH_LOG_BUFFER | 85 + INTEL_GUC_RECV_MSG_CRASH_DUMP_POSTED); 86 + } 87 + 88 + static void guc_log_disable_flush_events(struct intel_guc_log *log) 89 + { 90 + intel_guc_disable_msg(log_to_guc(log), 91 + INTEL_GUC_RECV_MSG_FLUSH_LOG_BUFFER | 92 + INTEL_GUC_RECV_MSG_CRASH_DUMP_POSTED); 74 93 } 75 94 76 95 /* ··· 138 121 if (!parent) 139 122 return NULL; 140 123 141 - /* 142 - * Not using the channel filename passed as an argument, since for each 143 - * channel relay appends the corresponding CPU number to the filename 144 - * passed in relay_open(). This should be fine as relay just needs a 145 - * dentry of the file associated with the channel buffer and that file's 146 - * name need not be same as the filename passed as an argument. 147 - */ 148 - buf_file = debugfs_create_file("guc_log", mode, 124 + buf_file = debugfs_create_file(filename, mode, 149 125 parent, buf, &relay_file_operations); 150 126 return buf_file; 151 127 } ··· 159 149 .remove_buf_file = remove_buf_file_callback, 160 150 }; 161 151 162 - static int guc_log_relay_file_create(struct intel_guc *guc) 163 - { 164 - struct drm_i915_private *dev_priv = guc_to_i915(guc); 165 - struct dentry *log_dir; 166 - int ret; 167 - 168 - if (!i915_modparams.guc_log_level) 169 - return 0; 170 - 171 - mutex_lock(&guc->log.runtime.relay_lock); 172 - 173 - /* For now create the log file in /sys/kernel/debug/dri/0 dir */ 174 - log_dir = dev_priv->drm.primary->debugfs_root; 175 - 176 - /* 177 - * If /sys/kernel/debug/dri/0 location do not exist, then debugfs is 178 - * not mounted and so can't create the relay file. 179 - * The relay API seems to fit well with debugfs only, for availing relay 180 - * there are 3 requirements which can be met for debugfs file only in a 181 - * straightforward/clean manner :- 182 - * i) Need the associated dentry pointer of the file, while opening the 183 - * relay channel. 184 - * ii) Should be able to use 'relay_file_operations' fops for the file. 185 - * iii) Set the 'i_private' field of file's inode to the pointer of 186 - * relay channel buffer. 187 - */ 188 - if (!log_dir) { 189 - DRM_ERROR("Debugfs dir not available yet for GuC log file\n"); 190 - ret = -ENODEV; 191 - goto out_unlock; 192 - } 193 - 194 - ret = relay_late_setup_files(guc->log.runtime.relay_chan, "guc_log", log_dir); 195 - if (ret < 0 && ret != -EEXIST) { 196 - DRM_ERROR("Couldn't associate relay chan with file %d\n", ret); 197 - goto out_unlock; 198 - } 199 - 200 - ret = 0; 201 - 202 - out_unlock: 203 - mutex_unlock(&guc->log.runtime.relay_lock); 204 - return ret; 205 - } 206 - 207 - static bool guc_log_has_relay(struct intel_guc *guc) 208 - { 209 - lockdep_assert_held(&guc->log.runtime.relay_lock); 210 - 211 - return guc->log.runtime.relay_chan != NULL; 212 - } 213 - 214 - static void guc_move_to_next_buf(struct intel_guc *guc) 152 + static void guc_move_to_next_buf(struct intel_guc_log *log) 215 153 { 216 154 /* 217 155 * Make sure the updates made in the sub buffer are visible when ··· 167 209 */ 168 210 smp_wmb(); 169 211 170 - if (!guc_log_has_relay(guc)) 171 - return; 172 - 173 212 /* All data has been written, so now move the offset of sub buffer. */ 174 - relay_reserve(guc->log.runtime.relay_chan, guc->log.vma->obj->base.size); 213 + relay_reserve(log->relay.channel, log->vma->obj->base.size); 175 214 176 215 /* Switch to the next sub buffer */ 177 - relay_flush(guc->log.runtime.relay_chan); 216 + relay_flush(log->relay.channel); 178 217 } 179 218 180 - static void *guc_get_write_buffer(struct intel_guc *guc) 219 + static void *guc_get_write_buffer(struct intel_guc_log *log) 181 220 { 182 - if (!guc_log_has_relay(guc)) 183 - return NULL; 184 - 185 221 /* 186 222 * Just get the base address of a new sub buffer and copy data into it 187 223 * ourselves. NULL will be returned in no-overwrite mode, if all sub ··· 185 233 * done without using relay_reserve() along with relay_write(). So its 186 234 * better to use relay_reserve() alone. 187 235 */ 188 - return relay_reserve(guc->log.runtime.relay_chan, 0); 236 + return relay_reserve(log->relay.channel, 0); 189 237 } 190 238 191 - static bool guc_check_log_buf_overflow(struct intel_guc *guc, 239 + static bool guc_check_log_buf_overflow(struct intel_guc_log *log, 192 240 enum guc_log_buffer_type type, 193 241 unsigned int full_cnt) 194 242 { 195 - unsigned int prev_full_cnt = guc->log.prev_overflow_count[type]; 243 + unsigned int prev_full_cnt = log->stats[type].sampled_overflow; 196 244 bool overflow = false; 197 245 198 246 if (full_cnt != prev_full_cnt) { 199 247 overflow = true; 200 248 201 - guc->log.prev_overflow_count[type] = full_cnt; 202 - guc->log.total_overflow_count[type] += full_cnt - prev_full_cnt; 249 + log->stats[type].overflow = full_cnt; 250 + log->stats[type].sampled_overflow += full_cnt - prev_full_cnt; 203 251 204 252 if (full_cnt < prev_full_cnt) { 205 253 /* buffer_full_cnt is a 4 bit counter */ 206 - guc->log.total_overflow_count[type] += 16; 254 + log->stats[type].sampled_overflow += 16; 207 255 } 208 256 DRM_ERROR_RATELIMITED("GuC log buffer overflow\n"); 209 257 } ··· 227 275 return 0; 228 276 } 229 277 230 - static void guc_read_update_log_buffer(struct intel_guc *guc) 278 + static void guc_read_update_log_buffer(struct intel_guc_log *log) 231 279 { 232 280 unsigned int buffer_size, read_offset, write_offset, bytes_to_copy, full_cnt; 233 281 struct guc_log_buffer_state *log_buf_state, *log_buf_snapshot_state; ··· 236 284 void *src_data, *dst_data; 237 285 bool new_overflow; 238 286 239 - if (WARN_ON(!guc->log.runtime.buf_addr)) 240 - return; 287 + mutex_lock(&log->relay.lock); 288 + 289 + if (WARN_ON(!intel_guc_log_relay_enabled(log))) 290 + goto out_unlock; 241 291 242 292 /* Get the pointer to shared GuC log buffer */ 243 - log_buf_state = src_data = guc->log.runtime.buf_addr; 244 - 245 - mutex_lock(&guc->log.runtime.relay_lock); 293 + log_buf_state = src_data = log->relay.buf_addr; 246 294 247 295 /* Get the pointer to local buffer to store the logs */ 248 - log_buf_snapshot_state = dst_data = guc_get_write_buffer(guc); 296 + log_buf_snapshot_state = dst_data = guc_get_write_buffer(log); 249 297 250 298 if (unlikely(!log_buf_snapshot_state)) { 251 299 /* ··· 253 301 * getting consumed by User at a slow rate. 254 302 */ 255 303 DRM_ERROR_RATELIMITED("no sub-buffer to capture logs\n"); 256 - guc->log.capture_miss_count++; 257 - mutex_unlock(&guc->log.runtime.relay_lock); 304 + log->relay.full_count++; 258 305 259 - return; 306 + goto out_unlock; 260 307 } 261 308 262 309 /* Actual logs are present from the 2nd page */ ··· 276 325 full_cnt = log_buf_state_local.buffer_full_cnt; 277 326 278 327 /* Bookkeeping stuff */ 279 - guc->log.flush_count[type] += log_buf_state_local.flush_to_file; 280 - new_overflow = guc_check_log_buf_overflow(guc, type, full_cnt); 328 + log->stats[type].flush += log_buf_state_local.flush_to_file; 329 + new_overflow = guc_check_log_buf_overflow(log, type, full_cnt); 281 330 282 331 /* Update the state of shared log buffer */ 283 332 log_buf_state->read_ptr = write_offset; ··· 324 373 dst_data += buffer_size; 325 374 } 326 375 327 - guc_move_to_next_buf(guc); 376 + guc_move_to_next_buf(log); 328 377 329 - mutex_unlock(&guc->log.runtime.relay_lock); 378 + out_unlock: 379 + mutex_unlock(&log->relay.lock); 330 380 } 331 381 332 382 static void capture_logs_work(struct work_struct *work) 333 383 { 334 - struct intel_guc *guc = 335 - container_of(work, struct intel_guc, log.runtime.flush_work); 384 + struct intel_guc_log *log = 385 + container_of(work, struct intel_guc_log, relay.flush_work); 336 386 337 - guc_log_capture_logs(guc); 387 + guc_log_capture_logs(log); 338 388 } 339 389 340 - static bool guc_log_has_runtime(struct intel_guc *guc) 390 + static int guc_log_map(struct intel_guc_log *log) 341 391 { 342 - return guc->log.runtime.buf_addr != NULL; 343 - } 344 - 345 - static int guc_log_runtime_create(struct intel_guc *guc) 346 - { 392 + struct intel_guc *guc = log_to_guc(log); 347 393 struct drm_i915_private *dev_priv = guc_to_i915(guc); 348 394 void *vaddr; 349 395 int ret; 350 396 351 - lockdep_assert_held(&dev_priv->drm.struct_mutex); 397 + lockdep_assert_held(&log->relay.lock); 352 398 353 - if (!guc->log.vma) 399 + if (!log->vma) 354 400 return -ENODEV; 355 401 356 - GEM_BUG_ON(guc_log_has_runtime(guc)); 357 - 358 - ret = i915_gem_object_set_to_wc_domain(guc->log.vma->obj, true); 402 + mutex_lock(&dev_priv->drm.struct_mutex); 403 + ret = i915_gem_object_set_to_wc_domain(log->vma->obj, true); 404 + mutex_unlock(&dev_priv->drm.struct_mutex); 359 405 if (ret) 360 406 return ret; 361 407 ··· 361 413 * buffer pages, so that we can directly get the data 362 414 * (up-to-date) from memory. 363 415 */ 364 - vaddr = i915_gem_object_pin_map(guc->log.vma->obj, I915_MAP_WC); 416 + vaddr = i915_gem_object_pin_map(log->vma->obj, I915_MAP_WC); 365 417 if (IS_ERR(vaddr)) { 366 418 DRM_ERROR("Couldn't map log buffer pages %d\n", ret); 367 419 return PTR_ERR(vaddr); 368 420 } 369 421 370 - guc->log.runtime.buf_addr = vaddr; 422 + log->relay.buf_addr = vaddr; 371 423 372 424 return 0; 373 425 } 374 426 375 - static void guc_log_runtime_destroy(struct intel_guc *guc) 427 + static void guc_log_unmap(struct intel_guc_log *log) 376 428 { 377 - /* 378 - * It's possible that the runtime stuff was never allocated because 379 - * GuC log was disabled at the boot time. 380 - */ 381 - if (!guc_log_has_runtime(guc)) 382 - return; 429 + lockdep_assert_held(&log->relay.lock); 383 430 384 - i915_gem_object_unpin_map(guc->log.vma->obj); 385 - guc->log.runtime.buf_addr = NULL; 431 + i915_gem_object_unpin_map(log->vma->obj); 432 + log->relay.buf_addr = NULL; 386 433 } 387 434 388 - void intel_guc_log_init_early(struct intel_guc *guc) 435 + void intel_guc_log_init_early(struct intel_guc_log *log) 389 436 { 390 - mutex_init(&guc->log.runtime.relay_lock); 391 - INIT_WORK(&guc->log.runtime.flush_work, capture_logs_work); 437 + mutex_init(&log->relay.lock); 438 + INIT_WORK(&log->relay.flush_work, capture_logs_work); 392 439 } 393 440 394 - int intel_guc_log_relay_create(struct intel_guc *guc) 441 + static int guc_log_relay_create(struct intel_guc_log *log) 395 442 { 443 + struct intel_guc *guc = log_to_guc(log); 396 444 struct drm_i915_private *dev_priv = guc_to_i915(guc); 397 445 struct rchan *guc_log_relay_chan; 398 446 size_t n_subbufs, subbuf_size; 399 447 int ret; 400 448 401 - if (!i915_modparams.guc_log_level) 402 - return 0; 403 - 404 - mutex_lock(&guc->log.runtime.relay_lock); 405 - 406 - GEM_BUG_ON(guc_log_has_relay(guc)); 449 + lockdep_assert_held(&log->relay.lock); 407 450 408 451 /* Keep the size of sub buffers same as shared log buffer */ 409 452 subbuf_size = GUC_LOG_SIZE; ··· 407 468 */ 408 469 n_subbufs = 8; 409 470 410 - /* 411 - * Create a relay channel, so that we have buffers for storing 412 - * the GuC firmware logs, the channel will be linked with a file 413 - * later on when debugfs is registered. 414 - */ 415 - guc_log_relay_chan = relay_open(NULL, NULL, subbuf_size, 416 - n_subbufs, &relay_callbacks, dev_priv); 471 + guc_log_relay_chan = relay_open("guc_log", 472 + dev_priv->drm.primary->debugfs_root, 473 + subbuf_size, n_subbufs, 474 + &relay_callbacks, dev_priv); 417 475 if (!guc_log_relay_chan) { 418 476 DRM_ERROR("Couldn't create relay chan for GuC logging\n"); 419 477 420 478 ret = -ENOMEM; 421 - goto err; 479 + return ret; 422 480 } 423 481 424 482 GEM_BUG_ON(guc_log_relay_chan->subbuf_size < subbuf_size); 425 - guc->log.runtime.relay_chan = guc_log_relay_chan; 426 - 427 - mutex_unlock(&guc->log.runtime.relay_lock); 483 + log->relay.channel = guc_log_relay_chan; 428 484 429 485 return 0; 430 - 431 - err: 432 - mutex_unlock(&guc->log.runtime.relay_lock); 433 - /* logging will be off */ 434 - i915_modparams.guc_log_level = 0; 435 - return ret; 436 486 } 437 487 438 - void intel_guc_log_relay_destroy(struct intel_guc *guc) 488 + static void guc_log_relay_destroy(struct intel_guc_log *log) 439 489 { 440 - mutex_lock(&guc->log.runtime.relay_lock); 490 + lockdep_assert_held(&log->relay.lock); 441 491 442 - /* 443 - * It's possible that the relay was never allocated because 444 - * GuC log was disabled at the boot time. 445 - */ 446 - if (!guc_log_has_relay(guc)) 447 - goto out_unlock; 448 - 449 - relay_close(guc->log.runtime.relay_chan); 450 - guc->log.runtime.relay_chan = NULL; 451 - 452 - out_unlock: 453 - mutex_unlock(&guc->log.runtime.relay_lock); 492 + relay_close(log->relay.channel); 493 + log->relay.channel = NULL; 454 494 } 455 495 456 - static int guc_log_late_setup(struct intel_guc *guc) 496 + static void guc_log_capture_logs(struct intel_guc_log *log) 457 497 { 458 - struct drm_i915_private *dev_priv = guc_to_i915(guc); 459 - int ret; 460 - 461 - if (!guc_log_has_runtime(guc)) { 462 - /* 463 - * If log was disabled at boot time, then setup needed to handle 464 - * log buffer flush interrupts would not have been done yet, so 465 - * do that now. 466 - */ 467 - ret = intel_guc_log_relay_create(guc); 468 - if (ret) 469 - goto err; 470 - 471 - mutex_lock(&dev_priv->drm.struct_mutex); 472 - intel_runtime_pm_get(dev_priv); 473 - ret = guc_log_runtime_create(guc); 474 - intel_runtime_pm_put(dev_priv); 475 - mutex_unlock(&dev_priv->drm.struct_mutex); 476 - 477 - if (ret) 478 - goto err_relay; 479 - } 480 - 481 - ret = guc_log_relay_file_create(guc); 482 - if (ret) 483 - goto err_runtime; 484 - 485 - return 0; 486 - 487 - err_runtime: 488 - mutex_lock(&dev_priv->drm.struct_mutex); 489 - guc_log_runtime_destroy(guc); 490 - mutex_unlock(&dev_priv->drm.struct_mutex); 491 - err_relay: 492 - intel_guc_log_relay_destroy(guc); 493 - err: 494 - /* logging will remain off */ 495 - i915_modparams.guc_log_level = 0; 496 - return ret; 497 - } 498 - 499 - static void guc_log_capture_logs(struct intel_guc *guc) 500 - { 498 + struct intel_guc *guc = log_to_guc(log); 501 499 struct drm_i915_private *dev_priv = guc_to_i915(guc); 502 500 503 - guc_read_update_log_buffer(guc); 501 + guc_read_update_log_buffer(log); 504 502 505 503 /* 506 504 * Generally device is expected to be active only at this 507 505 * time, so get/put should be really quick. 508 506 */ 509 507 intel_runtime_pm_get(dev_priv); 510 - guc_log_flush_complete(guc); 508 + guc_action_flush_log_complete(guc); 511 509 intel_runtime_pm_put(dev_priv); 512 510 } 513 511 514 - static void guc_flush_logs(struct intel_guc *guc) 512 + int intel_guc_log_create(struct intel_guc_log *log) 515 513 { 516 - struct drm_i915_private *dev_priv = guc_to_i915(guc); 517 - 518 - if (!USES_GUC_SUBMISSION(dev_priv) || !i915_modparams.guc_log_level) 519 - return; 520 - 521 - /* First disable the interrupts, will be renabled afterwards */ 522 - mutex_lock(&dev_priv->drm.struct_mutex); 523 - intel_runtime_pm_get(dev_priv); 524 - gen9_disable_guc_interrupts(dev_priv); 525 - intel_runtime_pm_put(dev_priv); 526 - mutex_unlock(&dev_priv->drm.struct_mutex); 527 - 528 - /* 529 - * Before initiating the forceful flush, wait for any pending/ongoing 530 - * flush to complete otherwise forceful flush may not actually happen. 531 - */ 532 - flush_work(&guc->log.runtime.flush_work); 533 - 534 - /* Ask GuC to update the log buffer state */ 535 - intel_runtime_pm_get(dev_priv); 536 - guc_log_flush(guc); 537 - intel_runtime_pm_put(dev_priv); 538 - 539 - /* GuC would have updated log buffer by now, so capture it */ 540 - guc_log_capture_logs(guc); 541 - } 542 - 543 - int intel_guc_log_create(struct intel_guc *guc) 544 - { 514 + struct intel_guc *guc = log_to_guc(log); 545 515 struct i915_vma *vma; 546 516 unsigned long offset; 547 517 u32 flags; 548 518 int ret; 549 519 550 - GEM_BUG_ON(guc->log.vma); 551 - 552 - /* 553 - * We require SSE 4.1 for fast reads from the GuC log buffer and 554 - * it should be present on the chipsets supporting GuC based 555 - * submisssions. 556 - */ 557 - if (WARN_ON(!i915_has_memcpy_from_wc())) { 558 - ret = -EINVAL; 559 - goto err; 560 - } 520 + GEM_BUG_ON(log->vma); 561 521 562 522 vma = intel_guc_allocate_vma(guc, GUC_LOG_SIZE); 563 523 if (IS_ERR(vma)) { ··· 464 626 goto err; 465 627 } 466 628 467 - guc->log.vma = vma; 468 - 469 - if (i915_modparams.guc_log_level) { 470 - ret = guc_log_runtime_create(guc); 471 - if (ret < 0) 472 - goto err_vma; 473 - } 629 + log->vma = vma; 474 630 475 631 /* each allocated unit is a page */ 476 632 flags = GUC_LOG_VALID | GUC_LOG_NOTIFY_ON_HALF_FULL | ··· 472 640 (GUC_LOG_ISR_PAGES << GUC_LOG_ISR_SHIFT) | 473 641 (GUC_LOG_CRASH_PAGES << GUC_LOG_CRASH_SHIFT); 474 642 475 - offset = guc_ggtt_offset(vma) >> PAGE_SHIFT; /* in pages */ 476 - guc->log.flags = (offset << GUC_LOG_BUF_ADDR_SHIFT) | flags; 643 + offset = intel_guc_ggtt_offset(guc, vma) >> PAGE_SHIFT; 644 + log->flags = (offset << GUC_LOG_BUF_ADDR_SHIFT) | flags; 477 645 478 646 return 0; 479 647 480 - err_vma: 481 - i915_vma_unpin_and_release(&guc->log.vma); 482 648 err: 483 649 /* logging will be off */ 484 650 i915_modparams.guc_log_level = 0; 485 651 return ret; 486 652 } 487 653 488 - void intel_guc_log_destroy(struct intel_guc *guc) 654 + void intel_guc_log_destroy(struct intel_guc_log *log) 489 655 { 490 - guc_log_runtime_destroy(guc); 491 - i915_vma_unpin_and_release(&guc->log.vma); 656 + i915_vma_unpin_and_release(&log->vma); 492 657 } 493 658 494 - int intel_guc_log_control(struct intel_guc *guc, u64 control_val) 659 + int intel_guc_log_level_get(struct intel_guc_log *log) 495 660 { 661 + GEM_BUG_ON(!log->vma); 662 + GEM_BUG_ON(i915_modparams.guc_log_level < 0); 663 + 664 + return i915_modparams.guc_log_level; 665 + } 666 + 667 + int intel_guc_log_level_set(struct intel_guc_log *log, u64 val) 668 + { 669 + struct intel_guc *guc = log_to_guc(log); 496 670 struct drm_i915_private *dev_priv = guc_to_i915(guc); 497 - bool enable_logging = control_val > 0; 498 - u32 verbosity; 499 671 int ret; 500 672 501 - if (!guc->log.vma) 502 - return -ENODEV; 673 + BUILD_BUG_ON(GUC_LOG_VERBOSITY_MIN != 0); 674 + GEM_BUG_ON(!log->vma); 675 + GEM_BUG_ON(i915_modparams.guc_log_level < 0); 503 676 504 - BUILD_BUG_ON(GUC_LOG_VERBOSITY_MIN); 505 - if (control_val > 1 + GUC_LOG_VERBOSITY_MAX) 677 + /* 678 + * GuC is recognizing log levels starting from 0 to max, we're using 0 679 + * as indication that logging should be disabled. 680 + */ 681 + if (val < GUC_LOG_LEVEL_DISABLED || val > GUC_LOG_LEVEL_MAX) 506 682 return -EINVAL; 507 683 508 - /* This combination doesn't make sense & won't have any effect */ 509 - if (!enable_logging && !i915_modparams.guc_log_level) 510 - return 0; 684 + mutex_lock(&dev_priv->drm.struct_mutex); 511 685 512 - verbosity = enable_logging ? control_val - 1 : 0; 686 + if (i915_modparams.guc_log_level == val) { 687 + ret = 0; 688 + goto out_unlock; 689 + } 513 690 514 - ret = mutex_lock_interruptible(&dev_priv->drm.struct_mutex); 515 - if (ret) 516 - return ret; 517 691 intel_runtime_pm_get(dev_priv); 518 - ret = guc_log_control(guc, enable_logging, verbosity); 692 + ret = guc_action_control_log(guc, GUC_LOG_LEVEL_IS_VERBOSE(val), 693 + GUC_LOG_LEVEL_IS_ENABLED(val), 694 + GUC_LOG_LEVEL_TO_VERBOSITY(val)); 519 695 intel_runtime_pm_put(dev_priv); 696 + if (ret) { 697 + DRM_DEBUG_DRIVER("guc_log_control action failed %d\n", ret); 698 + goto out_unlock; 699 + } 700 + 701 + i915_modparams.guc_log_level = val; 702 + 703 + out_unlock: 520 704 mutex_unlock(&dev_priv->drm.struct_mutex); 521 - 522 - if (ret < 0) { 523 - DRM_DEBUG_DRIVER("guc_logging_control action failed %d\n", ret); 524 - return ret; 525 - } 526 - 527 - if (enable_logging) { 528 - i915_modparams.guc_log_level = 1 + verbosity; 529 - 530 - /* 531 - * If log was disabled at boot time, then the relay channel file 532 - * wouldn't have been created by now and interrupts also would 533 - * not have been enabled. Try again now, just in case. 534 - */ 535 - ret = guc_log_late_setup(guc); 536 - if (ret < 0) { 537 - DRM_DEBUG_DRIVER("GuC log late setup failed %d\n", ret); 538 - return ret; 539 - } 540 - 541 - /* GuC logging is currently the only user of Guc2Host interrupts */ 542 - mutex_lock(&dev_priv->drm.struct_mutex); 543 - intel_runtime_pm_get(dev_priv); 544 - gen9_enable_guc_interrupts(dev_priv); 545 - intel_runtime_pm_put(dev_priv); 546 - mutex_unlock(&dev_priv->drm.struct_mutex); 547 - } else { 548 - /* 549 - * Once logging is disabled, GuC won't generate logs & send an 550 - * interrupt. But there could be some data in the log buffer 551 - * which is yet to be captured. So request GuC to update the log 552 - * buffer state and then collect the left over logs. 553 - */ 554 - guc_flush_logs(guc); 555 - 556 - /* As logging is disabled, update log level to reflect that */ 557 - i915_modparams.guc_log_level = 0; 558 - } 559 705 560 706 return ret; 561 707 } 562 708 563 - void i915_guc_log_register(struct drm_i915_private *dev_priv) 709 + bool intel_guc_log_relay_enabled(const struct intel_guc_log *log) 564 710 { 565 - if (!USES_GUC_SUBMISSION(dev_priv) || !i915_modparams.guc_log_level) 566 - return; 567 - 568 - guc_log_late_setup(&dev_priv->guc); 711 + return log->relay.buf_addr; 569 712 } 570 713 571 - void i915_guc_log_unregister(struct drm_i915_private *dev_priv) 714 + int intel_guc_log_relay_open(struct intel_guc_log *log) 572 715 { 573 - struct intel_guc *guc = &dev_priv->guc; 716 + int ret; 574 717 575 - if (!USES_GUC_SUBMISSION(dev_priv)) 576 - return; 718 + mutex_lock(&log->relay.lock); 577 719 578 - mutex_lock(&dev_priv->drm.struct_mutex); 579 - /* GuC logging is currently the only user of Guc2Host interrupts */ 580 - intel_runtime_pm_get(dev_priv); 581 - gen9_disable_guc_interrupts(dev_priv); 582 - intel_runtime_pm_put(dev_priv); 720 + if (intel_guc_log_relay_enabled(log)) { 721 + ret = -EEXIST; 722 + goto out_unlock; 723 + } 583 724 584 - guc_log_runtime_destroy(guc); 585 - mutex_unlock(&dev_priv->drm.struct_mutex); 725 + /* 726 + * We require SSE 4.1 for fast reads from the GuC log buffer and 727 + * it should be present on the chipsets supporting GuC based 728 + * submisssions. 729 + */ 730 + if (!i915_has_memcpy_from_wc()) { 731 + ret = -ENXIO; 732 + goto out_unlock; 733 + } 586 734 587 - intel_guc_log_relay_destroy(guc); 735 + ret = guc_log_relay_create(log); 736 + if (ret) 737 + goto out_unlock; 738 + 739 + ret = guc_log_map(log); 740 + if (ret) 741 + goto out_relay; 742 + 743 + mutex_unlock(&log->relay.lock); 744 + 745 + guc_log_enable_flush_events(log); 746 + 747 + /* 748 + * When GuC is logging without us relaying to userspace, we're ignoring 749 + * the flush notification. This means that we need to unconditionally 750 + * flush on relay enabling, since GuC only notifies us once. 751 + */ 752 + queue_work(log->relay.flush_wq, &log->relay.flush_work); 753 + 754 + return 0; 755 + 756 + out_relay: 757 + guc_log_relay_destroy(log); 758 + out_unlock: 759 + mutex_unlock(&log->relay.lock); 760 + 761 + return ret; 762 + } 763 + 764 + void intel_guc_log_relay_flush(struct intel_guc_log *log) 765 + { 766 + struct intel_guc *guc = log_to_guc(log); 767 + struct drm_i915_private *i915 = guc_to_i915(guc); 768 + 769 + /* 770 + * Before initiating the forceful flush, wait for any pending/ongoing 771 + * flush to complete otherwise forceful flush may not actually happen. 772 + */ 773 + flush_work(&log->relay.flush_work); 774 + 775 + intel_runtime_pm_get(i915); 776 + guc_action_flush_log(guc); 777 + intel_runtime_pm_put(i915); 778 + 779 + /* GuC would have updated log buffer by now, so capture it */ 780 + guc_log_capture_logs(log); 781 + } 782 + 783 + void intel_guc_log_relay_close(struct intel_guc_log *log) 784 + { 785 + guc_log_disable_flush_events(log); 786 + flush_work(&log->relay.flush_work); 787 + 788 + mutex_lock(&log->relay.lock); 789 + GEM_BUG_ON(!intel_guc_log_relay_enabled(log)); 790 + guc_log_unmap(log); 791 + guc_log_relay_destroy(log); 792 + mutex_unlock(&log->relay.lock); 793 + } 794 + 795 + void intel_guc_log_handle_flush_event(struct intel_guc_log *log) 796 + { 797 + queue_work(log->relay.flush_wq, &log->relay.flush_work); 588 798 }
+40 -19
drivers/gpu/drm/i915/intel_guc_log.h
··· 25 25 #ifndef _INTEL_GUC_LOG_H_ 26 26 #define _INTEL_GUC_LOG_H_ 27 27 28 + #include <linux/mutex.h> 29 + #include <linux/relay.h> 28 30 #include <linux/workqueue.h> 29 31 30 32 #include "intel_guc_fwif.h" 31 33 32 - struct drm_i915_private; 33 34 struct intel_guc; 34 35 35 36 /* ··· 40 39 #define GUC_LOG_SIZE ((1 + GUC_LOG_DPC_PAGES + 1 + GUC_LOG_ISR_PAGES + \ 41 40 1 + GUC_LOG_CRASH_PAGES + 1) << PAGE_SHIFT) 42 41 42 + /* 43 + * While we're using plain log level in i915, GuC controls are much more... 44 + * "elaborate"? We have a couple of bits for verbosity, separate bit for actual 45 + * log enabling, and separate bit for default logging - which "conveniently" 46 + * ignores the enable bit. 47 + */ 48 + #define GUC_LOG_LEVEL_DISABLED 0 49 + #define GUC_LOG_LEVEL_NON_VERBOSE 1 50 + #define GUC_LOG_LEVEL_IS_ENABLED(x) ((x) > GUC_LOG_LEVEL_DISABLED) 51 + #define GUC_LOG_LEVEL_IS_VERBOSE(x) ((x) > GUC_LOG_LEVEL_NON_VERBOSE) 52 + #define GUC_LOG_LEVEL_TO_VERBOSITY(x) ({ \ 53 + typeof(x) _x = (x); \ 54 + GUC_LOG_LEVEL_IS_VERBOSE(_x) ? _x - 2 : 0; \ 55 + }) 56 + #define GUC_VERBOSITY_TO_LOG_LEVEL(x) ((x) + 2) 57 + #define GUC_LOG_LEVEL_MAX GUC_VERBOSITY_TO_LOG_LEVEL(GUC_LOG_VERBOSITY_MAX) 58 + 43 59 struct intel_guc_log { 44 60 u32 flags; 45 61 struct i915_vma *vma; 46 - /* The runtime stuff gets created only when GuC logging gets enabled */ 47 62 struct { 48 63 void *buf_addr; 49 64 struct workqueue_struct *flush_wq; 50 65 struct work_struct flush_work; 51 - struct rchan *relay_chan; 52 - /* To serialize the access to relay_chan */ 53 - struct mutex relay_lock; 54 - } runtime; 66 + struct rchan *channel; 67 + struct mutex lock; 68 + u32 full_count; 69 + } relay; 55 70 /* logging related stats */ 56 - u32 capture_miss_count; 57 - u32 flush_interrupt_count; 58 - u32 prev_overflow_count[GUC_MAX_LOG_BUFFER]; 59 - u32 total_overflow_count[GUC_MAX_LOG_BUFFER]; 60 - u32 flush_count[GUC_MAX_LOG_BUFFER]; 71 + struct { 72 + u32 sampled_overflow; 73 + u32 overflow; 74 + u32 flush; 75 + } stats[GUC_MAX_LOG_BUFFER]; 61 76 }; 62 77 63 - int intel_guc_log_create(struct intel_guc *guc); 64 - void intel_guc_log_destroy(struct intel_guc *guc); 65 - void intel_guc_log_init_early(struct intel_guc *guc); 66 - int intel_guc_log_relay_create(struct intel_guc *guc); 67 - void intel_guc_log_relay_destroy(struct intel_guc *guc); 68 - int intel_guc_log_control(struct intel_guc *guc, u64 control_val); 69 - void i915_guc_log_register(struct drm_i915_private *dev_priv); 70 - void i915_guc_log_unregister(struct drm_i915_private *dev_priv); 78 + void intel_guc_log_init_early(struct intel_guc_log *log); 79 + int intel_guc_log_create(struct intel_guc_log *log); 80 + void intel_guc_log_destroy(struct intel_guc_log *log); 81 + 82 + int intel_guc_log_level_get(struct intel_guc_log *log); 83 + int intel_guc_log_level_set(struct intel_guc_log *log, u64 control_val); 84 + bool intel_guc_log_relay_enabled(const struct intel_guc_log *log); 85 + int intel_guc_log_relay_open(struct intel_guc_log *log); 86 + void intel_guc_log_relay_flush(struct intel_guc_log *log); 87 + void intel_guc_log_relay_close(struct intel_guc_log *log); 88 + 89 + void intel_guc_log_handle_flush_event(struct intel_guc_log *log); 71 90 72 91 #endif
+6 -8
drivers/gpu/drm/i915/intel_guc_reg.h
··· 66 66 #define UOS_MOVE (1<<4) 67 67 #define START_DMA (1<<0) 68 68 #define DMA_GUC_WOPCM_OFFSET _MMIO(0xc340) 69 + #define GUC_WOPCM_OFFSET_VALID (1<<0) 69 70 #define HUC_LOADING_AGENT_VCR (0<<1) 70 71 #define HUC_LOADING_AGENT_GUC (1<<1) 71 - #define GUC_WOPCM_OFFSET_VALUE 0x80000 /* 512KB */ 72 + #define GUC_WOPCM_OFFSET_SHIFT 14 73 + #define GUC_WOPCM_OFFSET_MASK (0x3ffff << GUC_WOPCM_OFFSET_SHIFT) 72 74 #define GUC_MAX_IDLE_COUNT _MMIO(0xC3E4) 73 75 74 76 #define HUC_STATUS2 _MMIO(0xD3B0) 75 77 #define HUC_FW_VERIFIED (1<<7) 76 78 77 - /* Defines WOPCM space available to GuC firmware */ 78 79 #define GUC_WOPCM_SIZE _MMIO(0xc050) 79 - /* GuC addresses below GUC_WOPCM_TOP don't map through the GTT */ 80 - #define GUC_WOPCM_TOP (0x80 << 12) /* 512KB */ 81 - #define BXT_GUC_WOPCM_RC6_RESERVED (0x10 << 12) /* 64KB */ 82 - 83 - /* GuC addresses above GUC_GGTT_TOP also don't map through the GTT */ 84 - #define GUC_GGTT_TOP 0xFEE00000 80 + #define GUC_WOPCM_SIZE_LOCKED (1<<0) 81 + #define GUC_WOPCM_SIZE_SHIFT 12 82 + #define GUC_WOPCM_SIZE_MASK (0xfffff << GUC_WOPCM_SIZE_SHIFT) 85 83 86 84 #define GEN8_GT_PM_CONFIG _MMIO(0x138140) 87 85 #define GEN9LP_GT_PM_CONFIG _MMIO(0x138140)
+30 -17
drivers/gpu/drm/i915/intel_guc_submission.c
··· 231 231 if (ret) { 232 232 __destroy_doorbell(client); 233 233 __update_doorbell_desc(client, GUC_DOORBELL_INVALID); 234 - DRM_ERROR("Couldn't create client %u doorbell: %d\n", 235 - client->stage_id, ret); 234 + DRM_DEBUG_DRIVER("Couldn't create client %u doorbell: %d\n", 235 + client->stage_id, ret); 236 236 return ret; 237 237 } 238 238 ··· 386 386 lrc->context_desc = lower_32_bits(ce->lrc_desc); 387 387 388 388 /* The state page is after PPHWSP */ 389 - lrc->ring_lrca = 390 - guc_ggtt_offset(ce->state) + LRC_STATE_PN * PAGE_SIZE; 389 + lrc->ring_lrca = intel_guc_ggtt_offset(guc, ce->state) + 390 + LRC_STATE_PN * PAGE_SIZE; 391 391 392 392 /* XXX: In direct submission, the GuC wants the HW context id 393 393 * here. In proxy submission, it wants the stage id ··· 395 395 lrc->context_id = (client->stage_id << GUC_ELC_CTXID_OFFSET) | 396 396 (guc_engine_id << GUC_ELC_ENGINE_OFFSET); 397 397 398 - lrc->ring_begin = guc_ggtt_offset(ce->ring->vma); 398 + lrc->ring_begin = intel_guc_ggtt_offset(guc, ce->ring->vma); 399 399 lrc->ring_end = lrc->ring_begin + ce->ring->size - 1; 400 400 lrc->ring_next_free_location = lrc->ring_begin; 401 401 lrc->ring_current_tail_pointer_value = 0; ··· 411 411 * The doorbell, process descriptor, and workqueue are all parts 412 412 * of the client object, which the GuC will reference via the GGTT 413 413 */ 414 - gfx_addr = guc_ggtt_offset(client->vma); 414 + gfx_addr = intel_guc_ggtt_offset(guc, client->vma); 415 415 desc->db_trigger_phy = sg_dma_address(client->vma->pages->sgl) + 416 416 client->doorbell_offset; 417 417 desc->db_trigger_cpu = ptr_to_u64(__get_doorbell(client)); ··· 584 584 data[3] = engine->guc_id; 585 585 data[4] = guc->execbuf_client->priority; 586 586 data[5] = guc->execbuf_client->stage_id; 587 - data[6] = guc_ggtt_offset(guc->shared_data); 587 + data[6] = intel_guc_ggtt_offset(guc, guc->shared_data); 588 588 589 589 if (WARN_ON(intel_guc_send(guc, data, ARRAY_SIZE(data)))) { 590 590 execlists_clear_active(&engine->execlists, ··· 657 657 port_set(port, i915_request_get(rq)); 658 658 } 659 659 660 + static inline int rq_prio(const struct i915_request *rq) 661 + { 662 + return rq->priotree.priority; 663 + } 664 + 665 + static inline int port_prio(const struct execlist_port *port) 666 + { 667 + return rq_prio(port_request(port)); 668 + } 669 + 660 670 static void guc_dequeue(struct intel_engine_cs *engine) 661 671 { 662 672 struct intel_engine_execlists * const execlists = &engine->execlists; ··· 682 672 GEM_BUG_ON(rb_first(&execlists->queue) != rb); 683 673 684 674 if (port_isset(port)) { 685 - if (engine->i915->preempt_context) { 675 + if (intel_engine_has_preemption(engine)) { 686 676 struct guc_preempt_work *preempt_work = 687 677 &engine->i915->guc.preempt_work[engine->id]; 678 + int prio = execlists->queue_priority; 688 679 689 - if (execlists->queue_priority > 690 - max(port_request(port)->priotree.priority, 0)) { 680 + if (__execlists_need_preempt(prio, port_prio(port))) { 691 681 execlists_set_active(execlists, 692 682 EXECLISTS_ACTIVE_PREEMPT); 693 683 queue_work(engine->i915->guc.preempt_wq, ··· 738 728 execlists->first = rb; 739 729 if (submit) { 740 730 port_assign(port, last); 741 - execlists_set_active(execlists, EXECLISTS_ACTIVE_USER); 731 + execlists_user_begin(execlists, execlists->port); 742 732 guc_submit(engine); 743 733 } 744 734 ··· 758 748 struct execlist_port *port = execlists->port; 759 749 struct i915_request *rq; 760 750 761 - rq = port_request(&port[0]); 751 + rq = port_request(port); 762 752 while (rq && i915_request_completed(rq)) { 763 753 trace_i915_request_out(rq); 764 754 i915_request_put(rq); 765 755 766 - execlists_port_complete(execlists, port); 767 - 768 - rq = port_request(&port[0]); 756 + port = execlists_port_complete(execlists, port); 757 + if (port_isset(port)) { 758 + execlists_user_begin(execlists, port); 759 + rq = port_request(port); 760 + } else { 761 + execlists_user_end(execlists); 762 + rq = NULL; 763 + } 769 764 } 770 - if (!rq) 771 - execlists_clear_active(execlists, EXECLISTS_ACTIVE_USER); 772 765 773 766 if (execlists_is_active(execlists, EXECLISTS_ACTIVE_PREEMPT) && 774 767 intel_read_status_page(engine, I915_GEM_HWS_PREEMPT_INDEX) ==
+6 -7
drivers/gpu/drm/i915/intel_hangcheck.c
··· 246 246 */ 247 247 tmp = I915_READ_CTL(engine); 248 248 if (tmp & RING_WAIT) { 249 - i915_handle_error(dev_priv, BIT(engine->id), 250 - "Kicking stuck wait on %s", 251 - engine->name); 249 + i915_handle_error(dev_priv, BIT(engine->id), 0, 250 + "stuck wait on %s", engine->name); 252 251 I915_WRITE_CTL(engine, tmp); 253 252 return ENGINE_WAIT_KICK; 254 253 } ··· 257 258 default: 258 259 return ENGINE_DEAD; 259 260 case 1: 260 - i915_handle_error(dev_priv, ALL_ENGINES, 261 - "Kicking stuck semaphore on %s", 261 + i915_handle_error(dev_priv, ALL_ENGINES, 0, 262 + "stuck semaphore on %s", 262 263 engine->name); 263 264 I915_WRITE_CTL(engine, tmp); 264 265 return ENGINE_WAIT_KICK; ··· 385 386 if (stuck != hung) 386 387 hung &= ~stuck; 387 388 len = scnprintf(msg, sizeof(msg), 388 - "%s on ", stuck == hung ? "No progress" : "Hang"); 389 + "%s on ", stuck == hung ? "no progress" : "hang"); 389 390 for_each_engine_masked(engine, i915, hung, tmp) 390 391 len += scnprintf(msg + len, sizeof(msg) - len, 391 392 "%s, ", engine->name); 392 393 msg[len-2] = '\0'; 393 394 394 - return i915_handle_error(i915, hung, "%s", msg); 395 + return i915_handle_error(i915, hung, I915_ERROR_CAPTURE, "%s", msg); 395 396 } 396 397 397 398 /*
+132 -53
drivers/gpu/drm/i915/intel_hdcp.c
··· 37 37 return 0; 38 38 } 39 39 40 + static bool hdcp_key_loadable(struct drm_i915_private *dev_priv) 41 + { 42 + struct i915_power_domains *power_domains = &dev_priv->power_domains; 43 + struct i915_power_well *power_well; 44 + enum i915_power_well_id id; 45 + bool enabled = false; 46 + 47 + /* 48 + * On HSW and BDW, Display HW loads the Key as soon as Display resumes. 49 + * On all BXT+, SW can load the keys only when the PW#1 is turned on. 50 + */ 51 + if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) 52 + id = HSW_DISP_PW_GLOBAL; 53 + else 54 + id = SKL_DISP_PW_1; 55 + 56 + mutex_lock(&power_domains->lock); 57 + 58 + /* PG1 (power well #1) needs to be enabled */ 59 + for_each_power_well(dev_priv, power_well) { 60 + if (power_well->id == id) { 61 + enabled = power_well->ops->is_enabled(dev_priv, 62 + power_well); 63 + break; 64 + } 65 + } 66 + mutex_unlock(&power_domains->lock); 67 + 68 + /* 69 + * Another req for hdcp key loadability is enabled state of pll for 70 + * cdclk. Without active crtc we wont land here. So we are assuming that 71 + * cdclk is already on. 72 + */ 73 + 74 + return enabled; 75 + } 76 + 40 77 static void intel_hdcp_clear_keys(struct drm_i915_private *dev_priv) 41 78 { 42 79 I915_WRITE(HDCP_KEY_CONF, HDCP_CLEAR_KEYS_TRIGGER); ··· 179 142 return true; 180 143 } 181 144 182 - /* Implements Part 2 of the HDCP authorization procedure */ 183 145 static 184 - int intel_hdcp_auth_downstream(struct intel_digital_port *intel_dig_port, 185 - const struct intel_hdcp_shim *shim) 146 + int intel_hdcp_validate_v_prime(struct intel_digital_port *intel_dig_port, 147 + const struct intel_hdcp_shim *shim, 148 + u8 *ksv_fifo, u8 num_downstream, u8 *bstatus) 186 149 { 187 150 struct drm_i915_private *dev_priv; 188 151 u32 vprime, sha_text, sha_leftovers, rep_ctl; 189 - u8 bstatus[2], num_downstream, *ksv_fifo; 190 152 int ret, i, j, sha_idx; 191 153 192 154 dev_priv = intel_dig_port->base.base.dev->dev_private; 193 - 194 - ret = intel_hdcp_poll_ksv_fifo(intel_dig_port, shim); 195 - if (ret) { 196 - DRM_ERROR("KSV list failed to become ready (%d)\n", ret); 197 - return ret; 198 - } 199 - 200 - ret = shim->read_bstatus(intel_dig_port, bstatus); 201 - if (ret) 202 - return ret; 203 - 204 - if (DRM_HDCP_MAX_DEVICE_EXCEEDED(bstatus[0]) || 205 - DRM_HDCP_MAX_CASCADE_EXCEEDED(bstatus[1])) { 206 - DRM_ERROR("Max Topology Limit Exceeded\n"); 207 - return -EPERM; 208 - } 209 - 210 - /* 211 - * When repeater reports 0 device count, HDCP1.4 spec allows disabling 212 - * the HDCP encryption. That implies that repeater can't have its own 213 - * display. As there is no consumption of encrypted content in the 214 - * repeater with 0 downstream devices, we are failing the 215 - * authentication. 216 - */ 217 - num_downstream = DRM_HDCP_NUM_DOWNSTREAM(bstatus[0]); 218 - if (num_downstream == 0) 219 - return -EINVAL; 220 - 221 - ksv_fifo = kzalloc(num_downstream * DRM_HDCP_KSV_LEN, GFP_KERNEL); 222 - if (!ksv_fifo) 223 - return -ENOMEM; 224 - 225 - ret = shim->read_ksv_fifo(intel_dig_port, num_downstream, ksv_fifo); 226 - if (ret) 227 - return ret; 228 155 229 156 /* Process V' values from the receiver */ 230 157 for (i = 0; i < DRM_HDCP_V_PRIME_NUM_PARTS; i++) { ··· 354 353 return ret; 355 354 sha_idx += sizeof(sha_text); 356 355 } else { 357 - DRM_ERROR("Invalid number of leftovers %d\n", sha_leftovers); 356 + DRM_DEBUG_KMS("Invalid number of leftovers %d\n", 357 + sha_leftovers); 358 358 return -EINVAL; 359 359 } 360 360 ··· 383 381 if (intel_wait_for_register(dev_priv, HDCP_REP_CTL, 384 382 HDCP_SHA1_COMPLETE, 385 383 HDCP_SHA1_COMPLETE, 1)) { 386 - DRM_ERROR("Timed out waiting for SHA1 complete\n"); 384 + DRM_DEBUG_KMS("Timed out waiting for SHA1 complete\n"); 387 385 return -ETIMEDOUT; 388 386 } 389 387 if (!(I915_READ(HDCP_REP_CTL) & HDCP_SHA1_V_MATCH)) { 390 - DRM_ERROR("SHA-1 mismatch, HDCP failed\n"); 388 + DRM_DEBUG_KMS("SHA-1 mismatch, HDCP failed\n"); 391 389 return -ENXIO; 390 + } 391 + 392 + return 0; 393 + } 394 + 395 + /* Implements Part 2 of the HDCP authorization procedure */ 396 + static 397 + int intel_hdcp_auth_downstream(struct intel_digital_port *intel_dig_port, 398 + const struct intel_hdcp_shim *shim) 399 + { 400 + u8 bstatus[2], num_downstream, *ksv_fifo; 401 + int ret, i, tries = 3; 402 + 403 + ret = intel_hdcp_poll_ksv_fifo(intel_dig_port, shim); 404 + if (ret) { 405 + DRM_ERROR("KSV list failed to become ready (%d)\n", ret); 406 + return ret; 407 + } 408 + 409 + ret = shim->read_bstatus(intel_dig_port, bstatus); 410 + if (ret) 411 + return ret; 412 + 413 + if (DRM_HDCP_MAX_DEVICE_EXCEEDED(bstatus[0]) || 414 + DRM_HDCP_MAX_CASCADE_EXCEEDED(bstatus[1])) { 415 + DRM_ERROR("Max Topology Limit Exceeded\n"); 416 + return -EPERM; 417 + } 418 + 419 + /* 420 + * When repeater reports 0 device count, HDCP1.4 spec allows disabling 421 + * the HDCP encryption. That implies that repeater can't have its own 422 + * display. As there is no consumption of encrypted content in the 423 + * repeater with 0 downstream devices, we are failing the 424 + * authentication. 425 + */ 426 + num_downstream = DRM_HDCP_NUM_DOWNSTREAM(bstatus[0]); 427 + if (num_downstream == 0) 428 + return -EINVAL; 429 + 430 + ksv_fifo = kzalloc(num_downstream * DRM_HDCP_KSV_LEN, GFP_KERNEL); 431 + if (!ksv_fifo) 432 + return -ENOMEM; 433 + 434 + ret = shim->read_ksv_fifo(intel_dig_port, num_downstream, ksv_fifo); 435 + if (ret) 436 + goto err; 437 + 438 + /* 439 + * When V prime mismatches, DP Spec mandates re-read of 440 + * V prime atleast twice. 441 + */ 442 + for (i = 0; i < tries; i++) { 443 + ret = intel_hdcp_validate_v_prime(intel_dig_port, shim, 444 + ksv_fifo, num_downstream, 445 + bstatus); 446 + if (!ret) 447 + break; 448 + } 449 + 450 + if (i == tries) { 451 + DRM_ERROR("V Prime validation failed.(%d)\n", ret); 452 + goto err; 392 453 } 393 454 394 455 DRM_DEBUG_KMS("HDCP is enabled (%d downstream devices)\n", 395 456 num_downstream); 396 - return 0; 457 + ret = 0; 458 + err: 459 + kfree(ksv_fifo); 460 + return ret; 397 461 } 398 462 399 463 /* Implements Part 1 of the HDCP authorization procedure */ ··· 574 506 */ 575 507 wait_remaining_ms_from_jiffies(r0_prime_gen_start, 300); 576 508 577 - ri.reg = 0; 578 - ret = shim->read_ri_prime(intel_dig_port, ri.shim); 579 - if (ret) 580 - return ret; 581 - I915_WRITE(PORT_HDCP_RPRIME(port), ri.reg); 509 + tries = 3; 582 510 583 - /* Wait for Ri prime match */ 584 - if (wait_for(I915_READ(PORT_HDCP_STATUS(port)) & 585 - (HDCP_STATUS_RI_MATCH | HDCP_STATUS_ENC), 1)) { 511 + /* 512 + * DP HDCP Spec mandates the two more reattempt to read R0, incase 513 + * of R0 mismatch. 514 + */ 515 + for (i = 0; i < tries; i++) { 516 + ri.reg = 0; 517 + ret = shim->read_ri_prime(intel_dig_port, ri.shim); 518 + if (ret) 519 + return ret; 520 + I915_WRITE(PORT_HDCP_RPRIME(port), ri.reg); 521 + 522 + /* Wait for Ri prime match */ 523 + if (!wait_for(I915_READ(PORT_HDCP_STATUS(port)) & 524 + (HDCP_STATUS_RI_MATCH | HDCP_STATUS_ENC), 1)) 525 + break; 526 + } 527 + 528 + if (i == tries) { 586 529 DRM_ERROR("Timed out waiting for Ri prime match (%x)\n", 587 530 I915_READ(PORT_HDCP_STATUS(port))); 588 531 return -ETIMEDOUT; ··· 659 580 DRM_DEBUG_KMS("[%s:%d] HDCP is being enabled...\n", 660 581 connector->base.name, connector->base.base.id); 661 582 662 - if (!(I915_READ(SKL_FUSE_STATUS) & SKL_FUSE_PG_DIST_STATUS(1))) { 663 - DRM_ERROR("PG1 is disabled, cannot load keys\n"); 583 + if (!hdcp_key_loadable(dev_priv)) { 584 + DRM_ERROR("HDCP key Load is not possible\n"); 664 585 return -ENXIO; 665 586 } 666 587
+16 -24
drivers/gpu/drm/i915/intel_hdmi.c
··· 2082 2082 * it enables scrambling. This should be called before enabling the HDMI 2083 2083 * 2.0 port, as the sink can choose to disable the scrambling if it doesn't 2084 2084 * detect a scrambled clock within 100 ms. 2085 + * 2086 + * Returns: 2087 + * True on success, false on failure. 2085 2088 */ 2086 - void intel_hdmi_handle_sink_scrambling(struct intel_encoder *encoder, 2089 + bool intel_hdmi_handle_sink_scrambling(struct intel_encoder *encoder, 2087 2090 struct drm_connector *connector, 2088 2091 bool high_tmds_clock_ratio, 2089 2092 bool scrambling) 2090 2093 { 2094 + struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); 2091 2095 struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); 2092 - struct drm_i915_private *dev_priv = connector->dev->dev_private; 2093 2096 struct drm_scrambling *sink_scrambling = 2094 - &connector->display_info.hdmi.scdc.scrambling; 2095 - struct i2c_adapter *adptr = intel_gmbus_get_adapter(dev_priv, 2096 - intel_hdmi->ddc_bus); 2097 - bool ret; 2097 + &connector->display_info.hdmi.scdc.scrambling; 2098 + struct i2c_adapter *adapter = 2099 + intel_gmbus_get_adapter(dev_priv, intel_hdmi->ddc_bus); 2098 2100 2099 2101 if (!sink_scrambling->supported) 2100 - return; 2102 + return true; 2101 2103 2102 - DRM_DEBUG_KMS("Setting sink scrambling for enc:%s connector:%s\n", 2103 - encoder->base.name, connector->name); 2104 + DRM_DEBUG_KMS("[CONNECTOR:%d:%s] scrambling=%s, TMDS bit clock ratio=1/%d\n", 2105 + connector->base.id, connector->name, 2106 + yesno(scrambling), high_tmds_clock_ratio ? 40 : 10); 2104 2107 2105 - /* Set TMDS bit clock ratio to 1/40 or 1/10 */ 2106 - ret = drm_scdc_set_high_tmds_clock_ratio(adptr, high_tmds_clock_ratio); 2107 - if (!ret) { 2108 - DRM_ERROR("Set TMDS ratio failed\n"); 2109 - return; 2110 - } 2111 - 2112 - /* Enable/disable sink scrambling */ 2113 - ret = drm_scdc_set_scrambling(adptr, scrambling); 2114 - if (!ret) { 2115 - DRM_ERROR("Set sink scrambling failed\n"); 2116 - return; 2117 - } 2118 - 2119 - DRM_DEBUG_KMS("sink scrambling handled\n"); 2108 + /* Set TMDS bit clock ratio to 1/40 or 1/10, and enable/disable scrambling */ 2109 + return drm_scdc_set_high_tmds_clock_ratio(adapter, 2110 + high_tmds_clock_ratio) && 2111 + drm_scdc_set_scrambling(adapter, scrambling); 2120 2112 } 2121 2113 2122 2114 static u8 chv_port_to_ddc_pin(struct drm_i915_private *dev_priv, enum port port)
+3
drivers/gpu/drm/i915/intel_hotplug.c
··· 100 100 if (IS_CNL_WITH_PORT_F(dev_priv)) 101 101 return PORT_F; 102 102 return PORT_E; 103 + case HPD_PORT_F: 104 + return PORT_F; 103 105 default: 104 106 return PORT_NONE; /* no port for this pin */ 105 107 } ··· 134 132 case PORT_F: 135 133 if (IS_CNL_WITH_PORT_F(dev_priv)) 136 134 return HPD_PORT_E; 135 + return HPD_PORT_F; 137 136 default: 138 137 MISSING_CASE(port); 139 138 return HPD_NONE;
+28 -2
drivers/gpu/drm/i915/intel_huc.c
··· 55 55 return -ENOEXEC; 56 56 57 57 vma = i915_gem_object_ggtt_pin(huc->fw.obj, NULL, 0, 0, 58 - PIN_OFFSET_BIAS | GUC_WOPCM_TOP); 58 + PIN_OFFSET_BIAS | guc->ggtt_pin_bias); 59 59 if (IS_ERR(vma)) { 60 60 ret = PTR_ERR(vma); 61 61 DRM_ERROR("HuC: Failed to pin huc fw object %d\n", ret); ··· 63 63 } 64 64 65 65 ret = intel_guc_auth_huc(guc, 66 - guc_ggtt_offset(vma) + huc->fw.rsa_offset); 66 + intel_guc_ggtt_offset(guc, vma) + 67 + huc->fw.rsa_offset); 67 68 if (ret) { 68 69 DRM_ERROR("HuC: GuC did not ack Auth request %d\n", ret); 69 70 goto fail_unpin; ··· 91 90 92 91 DRM_ERROR("HuC: Authentication failed %d\n", ret); 93 92 return ret; 93 + } 94 + 95 + /** 96 + * intel_huc_check_status() - check HuC status 97 + * @huc: intel_huc structure 98 + * 99 + * This function reads status register to verify if HuC 100 + * firmware was successfully loaded. 101 + * 102 + * Returns positive value if HuC firmware is loaded and verified 103 + * and -ENODEV if HuC is not present. 104 + */ 105 + int intel_huc_check_status(struct intel_huc *huc) 106 + { 107 + struct drm_i915_private *dev_priv = huc_to_i915(huc); 108 + u32 status; 109 + 110 + if (!HAS_HUC(dev_priv)) 111 + return -ENODEV; 112 + 113 + intel_runtime_pm_get(dev_priv); 114 + status = I915_READ(HUC_STATUS2) & HUC_FW_VERIFIED; 115 + intel_runtime_pm_put(dev_priv); 116 + 117 + return status; 94 118 }
+7
drivers/gpu/drm/i915/intel_huc.h
··· 37 37 38 38 void intel_huc_init_early(struct intel_huc *huc); 39 39 int intel_huc_auth(struct intel_huc *huc); 40 + int intel_huc_check_status(struct intel_huc *huc); 41 + 42 + static inline int intel_huc_sanitize(struct intel_huc *huc) 43 + { 44 + intel_uc_fw_sanitize(&huc->fw); 45 + return 0; 46 + } 40 47 41 48 #endif
+4 -4
drivers/gpu/drm/i915/intel_huc_fw.c
··· 118 118 intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); 119 119 120 120 /* Set the source address for the uCode */ 121 - offset = guc_ggtt_offset(vma) + huc_fw->header_offset; 121 + offset = intel_guc_ggtt_offset(&dev_priv->guc, vma) + 122 + huc_fw->header_offset; 122 123 I915_WRITE(DMA_ADDR_0_LOW, lower_32_bits(offset)); 123 124 I915_WRITE(DMA_ADDR_0_HIGH, upper_32_bits(offset) & 0xFFFF); 124 125 ··· 155 154 * Called from intel_uc_init_hw() during driver load, resume from sleep and 156 155 * after a GPU reset. Note that HuC must be loaded before GuC. 157 156 * 158 - * The firmware image should have already been fetched into memory by the 159 - * earlier call to intel_uc_init_fw(), so here we need to only check that 160 - * fetch succeeded, and then transfer the image to the h/w. 157 + * The firmware image should have already been fetched into memory, so only 158 + * check that fetch succeeded, and then transfer the image to the h/w. 161 159 * 162 160 * Return: non-zero code on error 163 161 */
+178 -76
drivers/gpu/drm/i915/intel_lrc.c
··· 139 139 #include "i915_gem_render_state.h" 140 140 #include "intel_lrc_reg.h" 141 141 #include "intel_mocs.h" 142 + #include "intel_workarounds.h" 142 143 143 144 #define RING_EXECLIST_QFULL (1 << 0x2) 144 145 #define RING_EXECLIST1_VALID (1 << 0x3) ··· 184 183 const struct i915_request *last, 185 184 int prio) 186 185 { 187 - return engine->i915->preempt_context && prio > max(rq_prio(last), 0); 186 + return (intel_engine_has_preemption(engine) && 187 + __execlists_need_preempt(prio, rq_prio(last))); 188 188 } 189 189 190 190 /** ··· 376 374 status, rq); 377 375 } 378 376 377 + inline void 378 + execlists_user_begin(struct intel_engine_execlists *execlists, 379 + const struct execlist_port *port) 380 + { 381 + execlists_set_active_once(execlists, EXECLISTS_ACTIVE_USER); 382 + } 383 + 384 + inline void 385 + execlists_user_end(struct intel_engine_execlists *execlists) 386 + { 387 + execlists_clear_active(execlists, EXECLISTS_ACTIVE_USER); 388 + } 389 + 379 390 static inline void 380 391 execlists_context_schedule_in(struct i915_request *rq) 381 392 { ··· 469 454 desc = execlists_update_context(rq); 470 455 GEM_DEBUG_EXEC(port[n].context_id = upper_32_bits(desc)); 471 456 472 - GEM_TRACE("%s in[%d]: ctx=%d.%d, seqno=%x, prio=%d\n", 457 + GEM_TRACE("%s in[%d]: ctx=%d.%d, global=%d (fence %llx:%d) (current %d), prio=%d\n", 473 458 engine->name, n, 474 459 port[n].context_id, count, 475 460 rq->global_seqno, 461 + rq->fence.context, rq->fence.seqno, 462 + intel_engine_get_seqno(engine), 476 463 rq_prio(rq)); 477 464 } else { 478 465 GEM_BUG_ON(!n); ··· 714 697 if (p->priority != I915_PRIORITY_NORMAL) 715 698 kmem_cache_free(engine->i915->priorities, p); 716 699 } 700 + 717 701 done: 718 - execlists->queue_priority = rb ? to_priolist(rb)->priority : INT_MIN; 702 + /* 703 + * Here be a bit of magic! Or sleight-of-hand, whichever you prefer. 704 + * 705 + * We choose queue_priority such that if we add a request of greater 706 + * priority than this, we kick the submission tasklet to decide on 707 + * the right order of submitting the requests to hardware. We must 708 + * also be prepared to reorder requests as they are in-flight on the 709 + * HW. We derive the queue_priority then as the first "hole" in 710 + * the HW submission ports and if there are no available slots, 711 + * the priority of the lowest executing request, i.e. last. 712 + * 713 + * When we do receive a higher priority request ready to run from the 714 + * user, see queue_request(), the queue_priority is bumped to that 715 + * request triggering preemption on the next dequeue (or subsequent 716 + * interrupt for secondary ports). 717 + */ 718 + execlists->queue_priority = 719 + port != execlists->port ? rq_prio(last) : INT_MIN; 720 + 719 721 execlists->first = rb; 720 722 if (submit) 721 723 port_assign(port, last); ··· 746 710 spin_unlock_irq(&engine->timeline->lock); 747 711 748 712 if (submit) { 749 - execlists_set_active(execlists, EXECLISTS_ACTIVE_USER); 713 + execlists_user_begin(execlists, execlists->port); 750 714 execlists_submit_ports(engine); 751 715 } 752 716 ··· 763 727 while (num_ports-- && port_isset(port)) { 764 728 struct i915_request *rq = port_request(port); 765 729 730 + GEM_TRACE("%s:port%u global=%d (fence %llx:%d), (current %d)\n", 731 + rq->engine->name, 732 + (unsigned int)(port - execlists->port), 733 + rq->global_seqno, 734 + rq->fence.context, rq->fence.seqno, 735 + intel_engine_get_seqno(rq->engine)); 736 + 766 737 GEM_BUG_ON(!execlists->active); 767 738 intel_engine_context_out(rq->engine); 768 739 ··· 784 741 port++; 785 742 } 786 743 787 - execlists_clear_active(execlists, EXECLISTS_ACTIVE_USER); 744 + execlists_user_end(execlists); 745 + } 746 + 747 + static void clear_gtiir(struct intel_engine_cs *engine) 748 + { 749 + static const u8 gtiir[] = { 750 + [RCS] = 0, 751 + [BCS] = 0, 752 + [VCS] = 1, 753 + [VCS2] = 1, 754 + [VECS] = 3, 755 + }; 756 + struct drm_i915_private *dev_priv = engine->i915; 757 + int i; 758 + 759 + /* TODO: correctly reset irqs for gen11 */ 760 + if (WARN_ON_ONCE(INTEL_GEN(engine->i915) >= 11)) 761 + return; 762 + 763 + GEM_BUG_ON(engine->id >= ARRAY_SIZE(gtiir)); 764 + 765 + /* 766 + * Clear any pending interrupt state. 767 + * 768 + * We do it twice out of paranoia that some of the IIR are 769 + * double buffered, and so if we only reset it once there may 770 + * still be an interrupt pending. 771 + */ 772 + for (i = 0; i < 2; i++) { 773 + I915_WRITE(GEN8_GT_IIR(gtiir[engine->id]), 774 + engine->irq_keep_mask); 775 + POSTING_READ(GEN8_GT_IIR(gtiir[engine->id])); 776 + } 777 + GEM_BUG_ON(I915_READ(GEN8_GT_IIR(gtiir[engine->id])) & 778 + engine->irq_keep_mask); 779 + } 780 + 781 + static void reset_irq(struct intel_engine_cs *engine) 782 + { 783 + /* Mark all CS interrupts as complete */ 784 + smp_store_mb(engine->execlists.active, 0); 785 + synchronize_hardirq(engine->i915->drm.irq); 786 + 787 + clear_gtiir(engine); 788 + 789 + /* 790 + * The port is checked prior to scheduling a tasklet, but 791 + * just in case we have suspended the tasklet to do the 792 + * wedging make sure that when it wakes, it decides there 793 + * is no work to do by clearing the irq_posted bit. 794 + */ 795 + clear_bit(ENGINE_IRQ_EXECLIST, &engine->irq_posted); 788 796 } 789 797 790 798 static void execlists_cancel_requests(struct intel_engine_cs *engine) ··· 845 751 struct rb_node *rb; 846 752 unsigned long flags; 847 753 848 - GEM_TRACE("%s\n", engine->name); 754 + GEM_TRACE("%s current %d\n", 755 + engine->name, intel_engine_get_seqno(engine)); 849 756 850 757 /* 851 758 * Before we call engine->cancel_requests(), we should have exclusive ··· 866 771 867 772 /* Cancel the requests on the HW and clear the ELSP tracker. */ 868 773 execlists_cancel_port_requests(execlists); 774 + reset_irq(engine); 869 775 870 776 spin_lock(&engine->timeline->lock); 871 777 ··· 905 809 906 810 spin_unlock(&engine->timeline->lock); 907 811 908 - /* 909 - * The port is checked prior to scheduling a tasklet, but 910 - * just in case we have suspended the tasklet to do the 911 - * wedging make sure that when it wakes, it decides there 912 - * is no work to do by clearing the irq_posted bit. 913 - */ 914 - clear_bit(ENGINE_IRQ_EXECLIST, &engine->irq_posted); 915 - 916 - /* Mark all CS interrupts as complete */ 917 - execlists->active = 0; 918 - 919 812 local_irq_restore(flags); 920 813 } 921 814 ··· 916 831 { 917 832 struct intel_engine_cs * const engine = (struct intel_engine_cs *)data; 918 833 struct intel_engine_execlists * const execlists = &engine->execlists; 919 - struct execlist_port * const port = execlists->port; 834 + struct execlist_port *port = execlists->port; 920 835 struct drm_i915_private *dev_priv = engine->i915; 921 836 bool fw = false; 922 837 ··· 1043 958 EXECLISTS_ACTIVE_USER)); 1044 959 1045 960 rq = port_unpack(port, &count); 1046 - GEM_TRACE("%s out[0]: ctx=%d.%d, seqno=%x, prio=%d\n", 961 + GEM_TRACE("%s out[0]: ctx=%d.%d, global=%d (fence %llx:%d) (current %d), prio=%d\n", 1047 962 engine->name, 1048 963 port->context_id, count, 1049 964 rq ? rq->global_seqno : 0, 965 + rq ? rq->fence.context : 0, 966 + rq ? rq->fence.seqno : 0, 967 + intel_engine_get_seqno(engine), 1050 968 rq ? rq_prio(rq) : 0); 1051 969 1052 970 /* Check the context/desc id for this event matches */ ··· 1057 969 1058 970 GEM_BUG_ON(count == 0); 1059 971 if (--count == 0) { 972 + /* 973 + * On the final event corresponding to the 974 + * submission of this context, we expect either 975 + * an element-switch event or a completion 976 + * event (and on completion, the active-idle 977 + * marker). No more preemptions, lite-restore 978 + * or otherwise. 979 + */ 1060 980 GEM_BUG_ON(status & GEN8_CTX_STATUS_PREEMPTED); 1061 981 GEM_BUG_ON(port_isset(&port[1]) && 1062 982 !(status & GEN8_CTX_STATUS_ELEMENT_SWITCH)); 983 + GEM_BUG_ON(!port_isset(&port[1]) && 984 + !(status & GEN8_CTX_STATUS_ACTIVE_IDLE)); 985 + 986 + /* 987 + * We rely on the hardware being strongly 988 + * ordered, that the breadcrumb write is 989 + * coherent (visible from the CPU) before the 990 + * user interrupt and CSB is processed. 991 + */ 1063 992 GEM_BUG_ON(!i915_request_completed(rq)); 993 + 1064 994 execlists_context_schedule_out(rq); 1065 995 trace_i915_request_out(rq); 1066 996 i915_request_put(rq); ··· 1086 980 GEM_TRACE("%s completed ctx=%d\n", 1087 981 engine->name, port->context_id); 1088 982 1089 - execlists_port_complete(execlists, port); 983 + port = execlists_port_complete(execlists, port); 984 + if (port_isset(port)) 985 + execlists_user_begin(execlists, port); 986 + else 987 + execlists_user_end(execlists); 1090 988 } else { 1091 989 port_set(port, port_pack(rq, count)); 1092 990 } 1093 - 1094 - /* After the final element, the hw should be idle */ 1095 - GEM_BUG_ON(port_count(port) == 0 && 1096 - !(status & GEN8_CTX_STATUS_ACTIVE_IDLE)); 1097 - if (port_count(port) == 0) 1098 - execlists_clear_active(execlists, 1099 - EXECLISTS_ACTIVE_USER); 1100 991 } 1101 992 1102 993 if (head != execlists->csb_head) { ··· 1122 1019 list_add_tail(&pt->link, &lookup_priolist(engine, pt, prio)->requests); 1123 1020 } 1124 1021 1022 + static void __submit_queue(struct intel_engine_cs *engine, int prio) 1023 + { 1024 + engine->execlists.queue_priority = prio; 1025 + tasklet_hi_schedule(&engine->execlists.tasklet); 1026 + } 1027 + 1125 1028 static void submit_queue(struct intel_engine_cs *engine, int prio) 1126 1029 { 1127 - if (prio > engine->execlists.queue_priority) { 1128 - engine->execlists.queue_priority = prio; 1129 - tasklet_hi_schedule(&engine->execlists.tasklet); 1130 - } 1030 + if (prio > engine->execlists.queue_priority) 1031 + __submit_queue(engine, prio); 1131 1032 } 1132 1033 1133 1034 static void execlists_submit_request(struct i915_request *request) ··· 1264 1157 __list_del_entry(&pt->link); 1265 1158 queue_request(engine, pt, prio); 1266 1159 } 1267 - submit_queue(engine, prio); 1160 + 1161 + if (prio > engine->execlists.queue_priority && 1162 + i915_sw_fence_done(&pt_to_request(pt)->submit)) 1163 + __submit_queue(engine, prio); 1268 1164 } 1269 1165 1270 1166 spin_unlock_irq(&engine->timeline->lock); ··· 1334 1224 ce->lrc_reg_state = vaddr + LRC_STATE_PN * PAGE_SIZE; 1335 1225 ce->lrc_reg_state[CTX_RING_BUFFER_START+1] = 1336 1226 i915_ggtt_offset(ce->ring->vma); 1227 + ce->lrc_reg_state[CTX_RING_HEAD+1] = ce->ring->head; 1337 1228 1338 1229 ce->state->obj->pin_global++; 1339 1230 i915_gem_context_get(ctx); ··· 1685 1574 return ret; 1686 1575 } 1687 1576 1688 - static u8 gtiir[] = { 1689 - [RCS] = 0, 1690 - [BCS] = 0, 1691 - [VCS] = 1, 1692 - [VCS2] = 1, 1693 - [VECS] = 3, 1694 - }; 1695 - 1696 1577 static void enable_execlists(struct intel_engine_cs *engine) 1697 1578 { 1698 1579 struct drm_i915_private *dev_priv = engine->i915; ··· 1744 1641 if (ret) 1745 1642 return ret; 1746 1643 1644 + ret = intel_whitelist_workarounds_apply(engine); 1645 + if (ret) 1646 + return ret; 1647 + 1747 1648 /* We need to disable the AsyncFlip performance optimisations in order 1748 1649 * to use MI_WAIT_FOR_EVENT within the CS. It should already be 1749 1650 * programmed to '1' on all products. ··· 1758 1651 1759 1652 I915_WRITE(INSTPM, _MASKED_BIT_ENABLE(INSTPM_FORCE_ORDERING)); 1760 1653 1761 - return init_workarounds_ring(engine); 1654 + return 0; 1762 1655 } 1763 1656 1764 1657 static int gen9_init_render_ring(struct intel_engine_cs *engine) ··· 1769 1662 if (ret) 1770 1663 return ret; 1771 1664 1772 - return init_workarounds_ring(engine); 1773 - } 1665 + ret = intel_whitelist_workarounds_apply(engine); 1666 + if (ret) 1667 + return ret; 1774 1668 1775 - static void reset_irq(struct intel_engine_cs *engine) 1776 - { 1777 - struct drm_i915_private *dev_priv = engine->i915; 1778 - int i; 1779 - 1780 - GEM_BUG_ON(engine->id >= ARRAY_SIZE(gtiir)); 1781 - 1782 - /* 1783 - * Clear any pending interrupt state. 1784 - * 1785 - * We do it twice out of paranoia that some of the IIR are double 1786 - * buffered, and if we only reset it once there may still be 1787 - * an interrupt pending. 1788 - */ 1789 - for (i = 0; i < 2; i++) { 1790 - I915_WRITE(GEN8_GT_IIR(gtiir[engine->id]), 1791 - GT_CONTEXT_SWITCH_INTERRUPT << engine->irq_shift); 1792 - POSTING_READ(GEN8_GT_IIR(gtiir[engine->id])); 1793 - } 1794 - GEM_BUG_ON(I915_READ(GEN8_GT_IIR(gtiir[engine->id])) & 1795 - (GT_CONTEXT_SWITCH_INTERRUPT << engine->irq_shift)); 1796 - 1797 - clear_bit(ENGINE_IRQ_EXECLIST, &engine->irq_posted); 1669 + return 0; 1798 1670 } 1799 1671 1800 1672 static void reset_common_ring(struct intel_engine_cs *engine, ··· 1783 1697 struct intel_context *ce; 1784 1698 unsigned long flags; 1785 1699 1786 - GEM_TRACE("%s seqno=%x\n", 1787 - engine->name, request ? request->global_seqno : 0); 1700 + GEM_TRACE("%s request global=%x, current=%d\n", 1701 + engine->name, request ? request->global_seqno : 0, 1702 + intel_engine_get_seqno(engine)); 1788 1703 1789 1704 /* See execlists_cancel_requests() for the irq/spinlock split. */ 1790 1705 local_irq_save(flags); 1791 - 1792 - reset_irq(engine); 1793 1706 1794 1707 /* 1795 1708 * Catch up with any missed context-switch interrupts. ··· 1800 1715 * requests were completed. 1801 1716 */ 1802 1717 execlists_cancel_port_requests(execlists); 1718 + reset_irq(engine); 1803 1719 1804 1720 /* Push back any incomplete requests for replay after the reset. */ 1805 1721 spin_lock(&engine->timeline->lock); 1806 1722 __unwind_incomplete_requests(engine); 1807 1723 spin_unlock(&engine->timeline->lock); 1808 - 1809 - /* Mark all CS interrupts as complete */ 1810 - execlists->active = 0; 1811 1724 1812 1725 local_irq_restore(flags); 1813 1726 ··· 2098 2015 { 2099 2016 int ret; 2100 2017 2101 - ret = intel_ring_workarounds_emit(rq); 2018 + ret = intel_ctx_workarounds_emit(rq); 2102 2019 if (ret) 2103 2020 return ret; 2104 2021 ··· 2158 2075 engine->unpark = NULL; 2159 2076 2160 2077 engine->flags |= I915_ENGINE_SUPPORTS_STATS; 2078 + if (engine->i915->preempt_context) 2079 + engine->flags |= I915_ENGINE_HAS_PREEMPTION; 2161 2080 2162 2081 engine->i915->caps.scheduler = 2163 2082 I915_SCHEDULER_CAP_ENABLED | 2164 2083 I915_SCHEDULER_CAP_PRIORITY; 2165 - if (engine->i915->preempt_context) 2084 + if (intel_engine_has_preemption(engine)) 2166 2085 engine->i915->caps.scheduler |= I915_SCHEDULER_CAP_PREEMPTION; 2167 2086 } 2168 2087 ··· 2203 2118 static inline void 2204 2119 logical_ring_default_irqs(struct intel_engine_cs *engine) 2205 2120 { 2206 - unsigned shift = engine->irq_shift; 2121 + unsigned int shift = 0; 2122 + 2123 + if (INTEL_GEN(engine->i915) < 11) { 2124 + const u8 irq_shifts[] = { 2125 + [RCS] = GEN8_RCS_IRQ_SHIFT, 2126 + [BCS] = GEN8_BCS_IRQ_SHIFT, 2127 + [VCS] = GEN8_VCS1_IRQ_SHIFT, 2128 + [VCS2] = GEN8_VCS2_IRQ_SHIFT, 2129 + [VECS] = GEN8_VECS_IRQ_SHIFT, 2130 + }; 2131 + 2132 + shift = irq_shifts[engine->id]; 2133 + } 2134 + 2207 2135 engine->irq_enable_mask = GT_RENDER_USER_INTERRUPT << shift; 2208 2136 engine->irq_keep_mask = GT_CONTEXT_SWITCH_INTERRUPT << shift; 2209 2137 } ··· 2649 2551 } 2650 2552 } 2651 2553 } 2554 + 2555 + #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST) 2556 + #include "selftests/intel_lrc.c" 2557 + #endif
+1
drivers/gpu/drm/i915/intel_overlay.c
··· 807 807 ret = PTR_ERR(vma); 808 808 goto out_pin_section; 809 809 } 810 + intel_fb_obj_flush(new_bo, ORIGIN_DIRTYFB); 810 811 811 812 ret = i915_vma_put_fence(vma); 812 813 if (ret)
+46 -7
drivers/gpu/drm/i915/intel_pipe_crc.c
··· 569 569 static int ivb_pipe_crc_ctl_reg(struct drm_i915_private *dev_priv, 570 570 enum pipe pipe, 571 571 enum intel_pipe_crc_source *source, 572 - uint32_t *val) 572 + uint32_t *val, 573 + bool set_wa) 573 574 { 574 575 if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) 575 576 *source = INTEL_PIPE_CRC_SOURCE_PF; ··· 583 582 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_IVB; 584 583 break; 585 584 case INTEL_PIPE_CRC_SOURCE_PF: 586 - if ((IS_HASWELL(dev_priv) || 585 + if (set_wa && (IS_HASWELL(dev_priv) || 587 586 IS_BROADWELL(dev_priv)) && pipe == PIPE_A) 588 587 hsw_pipe_A_crc_wa(dev_priv, true); 589 588 ··· 601 600 602 601 static int get_new_crc_ctl_reg(struct drm_i915_private *dev_priv, 603 602 enum pipe pipe, 604 - enum intel_pipe_crc_source *source, u32 *val) 603 + enum intel_pipe_crc_source *source, u32 *val, 604 + bool set_wa) 605 605 { 606 606 if (IS_GEN2(dev_priv)) 607 607 return i8xx_pipe_crc_ctl_reg(source, val); ··· 613 611 else if (IS_GEN5(dev_priv) || IS_GEN6(dev_priv)) 614 612 return ilk_pipe_crc_ctl_reg(source, val); 615 613 else 616 - return ivb_pipe_crc_ctl_reg(dev_priv, pipe, source, val); 614 + return ivb_pipe_crc_ctl_reg(dev_priv, pipe, source, val, set_wa); 617 615 } 618 616 619 617 static int pipe_crc_set_source(struct drm_i915_private *dev_priv, ··· 638 636 return -EIO; 639 637 } 640 638 641 - ret = get_new_crc_ctl_reg(dev_priv, pipe, &source, &val); 639 + ret = get_new_crc_ctl_reg(dev_priv, pipe, &source, &val, true); 642 640 if (ret != 0) 643 641 goto out; 644 642 ··· 918 916 int intel_crtc_set_crc_source(struct drm_crtc *crtc, const char *source_name, 919 917 size_t *values_cnt) 920 918 { 921 - struct drm_i915_private *dev_priv = crtc->dev->dev_private; 919 + struct drm_i915_private *dev_priv = to_i915(crtc->dev); 922 920 struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[crtc->index]; 923 921 enum intel_display_power_domain power_domain; 924 922 enum intel_pipe_crc_source source; ··· 936 934 return -EIO; 937 935 } 938 936 939 - ret = get_new_crc_ctl_reg(dev_priv, crtc->index, &source, &val); 937 + ret = get_new_crc_ctl_reg(dev_priv, crtc->index, &source, &val, true); 940 938 if (ret != 0) 941 939 goto out; 942 940 941 + pipe_crc->source = source; 943 942 I915_WRITE(PIPE_CRC_CTL(crtc->index), val); 944 943 POSTING_READ(PIPE_CRC_CTL(crtc->index)); 945 944 ··· 961 958 intel_display_power_put(dev_priv, power_domain); 962 959 963 960 return ret; 961 + } 962 + 963 + void intel_crtc_enable_pipe_crc(struct intel_crtc *intel_crtc) 964 + { 965 + struct drm_crtc *crtc = &intel_crtc->base; 966 + struct drm_i915_private *dev_priv = to_i915(crtc->dev); 967 + struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[crtc->index]; 968 + u32 val = 0; 969 + 970 + if (!crtc->crc.opened) 971 + return; 972 + 973 + if (get_new_crc_ctl_reg(dev_priv, crtc->index, &pipe_crc->source, &val, false) < 0) 974 + return; 975 + 976 + /* Don't need pipe_crc->lock here, IRQs are not generated. */ 977 + pipe_crc->skipped = 0; 978 + 979 + I915_WRITE(PIPE_CRC_CTL(crtc->index), val); 980 + POSTING_READ(PIPE_CRC_CTL(crtc->index)); 981 + } 982 + 983 + void intel_crtc_disable_pipe_crc(struct intel_crtc *intel_crtc) 984 + { 985 + struct drm_crtc *crtc = &intel_crtc->base; 986 + struct drm_i915_private *dev_priv = to_i915(crtc->dev); 987 + struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[crtc->index]; 988 + 989 + /* Swallow crc's until we stop generating them. */ 990 + spin_lock_irq(&pipe_crc->lock); 991 + pipe_crc->skipped = INT_MIN; 992 + spin_unlock_irq(&pipe_crc->lock); 993 + 994 + I915_WRITE(PIPE_CRC_CTL(crtc->index), 0); 995 + POSTING_READ(PIPE_CRC_CTL(crtc->index)); 996 + synchronize_irq(dev_priv->drm.irq); 964 997 }
+303 -193
drivers/gpu/drm/i915/intel_pm.c
··· 3825 3825 entry->end += 1; 3826 3826 } 3827 3827 3828 + static void 3829 + skl_ddb_get_hw_plane_state(struct drm_i915_private *dev_priv, 3830 + const enum pipe pipe, 3831 + const enum plane_id plane_id, 3832 + struct skl_ddb_allocation *ddb /* out */) 3833 + { 3834 + u32 val, val2 = 0; 3835 + int fourcc, pixel_format; 3836 + 3837 + /* Cursor doesn't support NV12/planar, so no extra calculation needed */ 3838 + if (plane_id == PLANE_CURSOR) { 3839 + val = I915_READ(CUR_BUF_CFG(pipe)); 3840 + skl_ddb_entry_init_from_hw(&ddb->plane[pipe][plane_id], val); 3841 + return; 3842 + } 3843 + 3844 + val = I915_READ(PLANE_CTL(pipe, plane_id)); 3845 + 3846 + /* No DDB allocated for disabled planes */ 3847 + if (!(val & PLANE_CTL_ENABLE)) 3848 + return; 3849 + 3850 + pixel_format = val & PLANE_CTL_FORMAT_MASK; 3851 + fourcc = skl_format_to_fourcc(pixel_format, 3852 + val & PLANE_CTL_ORDER_RGBX, 3853 + val & PLANE_CTL_ALPHA_MASK); 3854 + 3855 + val = I915_READ(PLANE_BUF_CFG(pipe, plane_id)); 3856 + val2 = I915_READ(PLANE_NV12_BUF_CFG(pipe, plane_id)); 3857 + 3858 + if (fourcc == DRM_FORMAT_NV12) { 3859 + skl_ddb_entry_init_from_hw(&ddb->plane[pipe][plane_id], val2); 3860 + skl_ddb_entry_init_from_hw(&ddb->uv_plane[pipe][plane_id], val); 3861 + } else { 3862 + skl_ddb_entry_init_from_hw(&ddb->plane[pipe][plane_id], val); 3863 + } 3864 + } 3865 + 3828 3866 void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv, 3829 3867 struct skl_ddb_allocation *ddb /* out */) 3830 3868 { ··· 3879 3841 if (!intel_display_power_get_if_enabled(dev_priv, power_domain)) 3880 3842 continue; 3881 3843 3882 - for_each_plane_id_on_crtc(crtc, plane_id) { 3883 - u32 val; 3884 - 3885 - if (plane_id != PLANE_CURSOR) 3886 - val = I915_READ(PLANE_BUF_CFG(pipe, plane_id)); 3887 - else 3888 - val = I915_READ(CUR_BUF_CFG(pipe)); 3889 - 3890 - skl_ddb_entry_init_from_hw(&ddb->plane[pipe][plane_id], val); 3891 - } 3844 + for_each_plane_id_on_crtc(crtc, plane_id) 3845 + skl_ddb_get_hw_plane_state(dev_priv, pipe, 3846 + plane_id, ddb); 3892 3847 3893 3848 intel_display_power_put(dev_priv, power_domain); 3894 3849 } ··· 4040 4009 static unsigned int 4041 4010 skl_plane_relative_data_rate(const struct intel_crtc_state *cstate, 4042 4011 const struct drm_plane_state *pstate, 4043 - int y) 4012 + const int plane) 4044 4013 { 4045 - struct intel_plane *plane = to_intel_plane(pstate->plane); 4014 + struct intel_plane *intel_plane = to_intel_plane(pstate->plane); 4046 4015 struct intel_plane_state *intel_pstate = to_intel_plane_state(pstate); 4047 4016 uint32_t data_rate; 4048 4017 uint32_t width = 0, height = 0; ··· 4056 4025 fb = pstate->fb; 4057 4026 format = fb->format->format; 4058 4027 4059 - if (plane->id == PLANE_CURSOR) 4028 + if (intel_plane->id == PLANE_CURSOR) 4060 4029 return 0; 4061 - if (y && format != DRM_FORMAT_NV12) 4030 + if (plane == 1 && format != DRM_FORMAT_NV12) 4062 4031 return 0; 4063 4032 4064 4033 /* ··· 4069 4038 width = drm_rect_width(&intel_pstate->base.src) >> 16; 4070 4039 height = drm_rect_height(&intel_pstate->base.src) >> 16; 4071 4040 4072 - /* for planar format */ 4073 - if (format == DRM_FORMAT_NV12) { 4074 - if (y) /* y-plane data rate */ 4075 - data_rate = width * height * 4076 - fb->format->cpp[0]; 4077 - else /* uv-plane data rate */ 4078 - data_rate = (width / 2) * (height / 2) * 4079 - fb->format->cpp[1]; 4080 - } else { 4081 - /* for packed formats */ 4082 - data_rate = width * height * fb->format->cpp[0]; 4041 + /* UV plane does 1/2 pixel sub-sampling */ 4042 + if (plane == 1 && format == DRM_FORMAT_NV12) { 4043 + width /= 2; 4044 + height /= 2; 4083 4045 } 4046 + 4047 + data_rate = width * height * fb->format->cpp[plane]; 4084 4048 4085 4049 down_scale_amount = skl_plane_downscale_amount(cstate, intel_pstate); 4086 4050 ··· 4089 4063 */ 4090 4064 static unsigned int 4091 4065 skl_get_total_relative_data_rate(struct intel_crtc_state *intel_cstate, 4092 - unsigned *plane_data_rate, 4093 - unsigned *plane_y_data_rate) 4066 + unsigned int *plane_data_rate, 4067 + unsigned int *uv_plane_data_rate) 4094 4068 { 4095 4069 struct drm_crtc_state *cstate = &intel_cstate->base; 4096 4070 struct drm_atomic_state *state = cstate->state; ··· 4106 4080 enum plane_id plane_id = to_intel_plane(plane)->id; 4107 4081 unsigned int rate; 4108 4082 4109 - /* packed/uv */ 4083 + /* packed/y */ 4110 4084 rate = skl_plane_relative_data_rate(intel_cstate, 4111 4085 pstate, 0); 4112 4086 plane_data_rate[plane_id] = rate; 4113 4087 4114 4088 total_data_rate += rate; 4115 4089 4116 - /* y-plane */ 4090 + /* uv-plane */ 4117 4091 rate = skl_plane_relative_data_rate(intel_cstate, 4118 4092 pstate, 1); 4119 - plane_y_data_rate[plane_id] = rate; 4093 + uv_plane_data_rate[plane_id] = rate; 4120 4094 4121 4095 total_data_rate += rate; 4122 4096 } ··· 4125 4099 } 4126 4100 4127 4101 static uint16_t 4128 - skl_ddb_min_alloc(const struct drm_plane_state *pstate, 4129 - const int y) 4102 + skl_ddb_min_alloc(const struct drm_plane_state *pstate, const int plane) 4130 4103 { 4131 4104 struct drm_framebuffer *fb = pstate->fb; 4132 4105 struct intel_plane_state *intel_pstate = to_intel_plane_state(pstate); ··· 4136 4111 if (WARN_ON(!fb)) 4137 4112 return 0; 4138 4113 4139 - /* For packed formats, no y-plane, return 0 */ 4140 - if (y && fb->format->format != DRM_FORMAT_NV12) 4114 + /* For packed formats, and uv-plane, return 0 */ 4115 + if (plane == 1 && fb->format->format != DRM_FORMAT_NV12) 4141 4116 return 0; 4142 4117 4143 4118 /* For Non Y-tile return 8-blocks */ ··· 4156 4131 src_h = drm_rect_height(&intel_pstate->base.src) >> 16; 4157 4132 4158 4133 /* Halve UV plane width and height for NV12 */ 4159 - if (fb->format->format == DRM_FORMAT_NV12 && !y) { 4134 + if (plane == 1) { 4160 4135 src_w /= 2; 4161 4136 src_h /= 2; 4162 4137 } 4163 4138 4164 - if (fb->format->format == DRM_FORMAT_NV12 && !y) 4165 - plane_bpp = fb->format->cpp[1]; 4166 - else 4167 - plane_bpp = fb->format->cpp[0]; 4139 + plane_bpp = fb->format->cpp[plane]; 4168 4140 4169 4141 if (drm_rotation_90_or_270(pstate->rotation)) { 4170 4142 switch (plane_bpp) { ··· 4189 4167 4190 4168 static void 4191 4169 skl_ddb_calc_min(const struct intel_crtc_state *cstate, int num_active, 4192 - uint16_t *minimum, uint16_t *y_minimum) 4170 + uint16_t *minimum, uint16_t *uv_minimum) 4193 4171 { 4194 4172 const struct drm_plane_state *pstate; 4195 4173 struct drm_plane *plane; ··· 4204 4182 continue; 4205 4183 4206 4184 minimum[plane_id] = skl_ddb_min_alloc(pstate, 0); 4207 - y_minimum[plane_id] = skl_ddb_min_alloc(pstate, 1); 4185 + uv_minimum[plane_id] = skl_ddb_min_alloc(pstate, 1); 4208 4186 } 4209 4187 4210 4188 minimum[PLANE_CURSOR] = skl_cursor_allocation(num_active); ··· 4222 4200 struct skl_ddb_entry *alloc = &cstate->wm.skl.ddb; 4223 4201 uint16_t alloc_size, start; 4224 4202 uint16_t minimum[I915_MAX_PLANES] = {}; 4225 - uint16_t y_minimum[I915_MAX_PLANES] = {}; 4203 + uint16_t uv_minimum[I915_MAX_PLANES] = {}; 4226 4204 unsigned int total_data_rate; 4227 4205 enum plane_id plane_id; 4228 4206 int num_active; 4229 - unsigned plane_data_rate[I915_MAX_PLANES] = {}; 4230 - unsigned plane_y_data_rate[I915_MAX_PLANES] = {}; 4207 + unsigned int plane_data_rate[I915_MAX_PLANES] = {}; 4208 + unsigned int uv_plane_data_rate[I915_MAX_PLANES] = {}; 4231 4209 uint16_t total_min_blocks = 0; 4232 4210 4233 4211 /* Clear the partitioning for disabled planes. */ 4234 4212 memset(ddb->plane[pipe], 0, sizeof(ddb->plane[pipe])); 4235 - memset(ddb->y_plane[pipe], 0, sizeof(ddb->y_plane[pipe])); 4213 + memset(ddb->uv_plane[pipe], 0, sizeof(ddb->uv_plane[pipe])); 4236 4214 4237 4215 if (WARN_ON(!state)) 4238 4216 return 0; ··· 4247 4225 if (alloc_size == 0) 4248 4226 return 0; 4249 4227 4250 - skl_ddb_calc_min(cstate, num_active, minimum, y_minimum); 4228 + skl_ddb_calc_min(cstate, num_active, minimum, uv_minimum); 4251 4229 4252 4230 /* 4253 4231 * 1. Allocate the mininum required blocks for each active plane ··· 4257 4235 4258 4236 for_each_plane_id_on_crtc(intel_crtc, plane_id) { 4259 4237 total_min_blocks += minimum[plane_id]; 4260 - total_min_blocks += y_minimum[plane_id]; 4238 + total_min_blocks += uv_minimum[plane_id]; 4261 4239 } 4262 4240 4263 4241 if (total_min_blocks > alloc_size) { ··· 4279 4257 */ 4280 4258 total_data_rate = skl_get_total_relative_data_rate(cstate, 4281 4259 plane_data_rate, 4282 - plane_y_data_rate); 4260 + uv_plane_data_rate); 4283 4261 if (total_data_rate == 0) 4284 4262 return 0; 4285 4263 4286 4264 start = alloc->start; 4287 4265 for_each_plane_id_on_crtc(intel_crtc, plane_id) { 4288 - unsigned int data_rate, y_data_rate; 4289 - uint16_t plane_blocks, y_plane_blocks = 0; 4266 + unsigned int data_rate, uv_data_rate; 4267 + uint16_t plane_blocks, uv_plane_blocks; 4290 4268 4291 4269 if (plane_id == PLANE_CURSOR) 4292 4270 continue; ··· 4310 4288 4311 4289 start += plane_blocks; 4312 4290 4313 - /* 4314 - * allocation for y_plane part of planar format: 4315 - */ 4316 - y_data_rate = plane_y_data_rate[plane_id]; 4291 + /* Allocate DDB for UV plane for planar format/NV12 */ 4292 + uv_data_rate = uv_plane_data_rate[plane_id]; 4317 4293 4318 - y_plane_blocks = y_minimum[plane_id]; 4319 - y_plane_blocks += div_u64((uint64_t)alloc_size * y_data_rate, 4320 - total_data_rate); 4294 + uv_plane_blocks = uv_minimum[plane_id]; 4295 + uv_plane_blocks += div_u64((uint64_t)alloc_size * uv_data_rate, 4296 + total_data_rate); 4321 4297 4322 - if (y_data_rate) { 4323 - ddb->y_plane[pipe][plane_id].start = start; 4324 - ddb->y_plane[pipe][plane_id].end = start + y_plane_blocks; 4298 + if (uv_data_rate) { 4299 + ddb->uv_plane[pipe][plane_id].start = start; 4300 + ddb->uv_plane[pipe][plane_id].end = 4301 + start + uv_plane_blocks; 4325 4302 } 4326 4303 4327 - start += y_plane_blocks; 4304 + start += uv_plane_blocks; 4328 4305 } 4329 4306 4330 4307 return 0; ··· 4419 4398 skl_compute_plane_wm_params(const struct drm_i915_private *dev_priv, 4420 4399 struct intel_crtc_state *cstate, 4421 4400 const struct intel_plane_state *intel_pstate, 4422 - struct skl_wm_params *wp) 4401 + struct skl_wm_params *wp, int plane_id) 4423 4402 { 4424 4403 struct intel_plane *plane = to_intel_plane(intel_pstate->base.plane); 4425 4404 const struct drm_plane_state *pstate = &intel_pstate->base; ··· 4432 4411 if (!intel_wm_plane_visible(cstate, intel_pstate)) 4433 4412 return 0; 4434 4413 4414 + /* only NV12 format has two planes */ 4415 + if (plane_id == 1 && fb->format->format != DRM_FORMAT_NV12) { 4416 + DRM_DEBUG_KMS("Non NV12 format have single plane\n"); 4417 + return -EINVAL; 4418 + } 4419 + 4435 4420 wp->y_tiled = fb->modifier == I915_FORMAT_MOD_Y_TILED || 4436 4421 fb->modifier == I915_FORMAT_MOD_Yf_TILED || 4437 4422 fb->modifier == I915_FORMAT_MOD_Y_TILED_CCS || ··· 4445 4418 wp->x_tiled = fb->modifier == I915_FORMAT_MOD_X_TILED; 4446 4419 wp->rc_surface = fb->modifier == I915_FORMAT_MOD_Y_TILED_CCS || 4447 4420 fb->modifier == I915_FORMAT_MOD_Yf_TILED_CCS; 4421 + wp->is_planar = fb->format->format == DRM_FORMAT_NV12; 4448 4422 4449 4423 if (plane->id == PLANE_CURSOR) { 4450 4424 wp->width = intel_pstate->base.crtc_w; ··· 4458 4430 wp->width = drm_rect_width(&intel_pstate->base.src) >> 16; 4459 4431 } 4460 4432 4461 - wp->cpp = (fb->format->format == DRM_FORMAT_NV12) ? fb->format->cpp[1] : 4462 - fb->format->cpp[0]; 4433 + if (plane_id == 1 && wp->is_planar) 4434 + wp->width /= 2; 4435 + 4436 + wp->cpp = fb->format->cpp[plane_id]; 4463 4437 wp->plane_pixel_rate = skl_adjusted_plane_pixel_rate(cstate, 4464 4438 intel_pstate); 4465 4439 ··· 4529 4499 uint16_t ddb_allocation, 4530 4500 int level, 4531 4501 const struct skl_wm_params *wp, 4532 - uint16_t *out_blocks, /* out */ 4533 - uint8_t *out_lines, /* out */ 4534 - bool *enabled /* out */) 4502 + const struct skl_wm_level *result_prev, 4503 + struct skl_wm_level *result /* out */) 4535 4504 { 4536 4505 const struct drm_plane_state *pstate = &intel_pstate->base; 4537 4506 uint32_t latency = dev_priv->wm.skl_latency[level]; ··· 4544 4515 4545 4516 if (latency == 0 || 4546 4517 !intel_wm_plane_visible(cstate, intel_pstate)) { 4547 - *enabled = false; 4518 + result->plane_en = false; 4548 4519 return 0; 4549 4520 } 4550 4521 ··· 4597 4568 } else { 4598 4569 res_blocks++; 4599 4570 } 4571 + 4572 + /* 4573 + * Make sure result blocks for higher latency levels are atleast 4574 + * as high as level below the current level. 4575 + * Assumption in DDB algorithm optimization for special cases. 4576 + * Also covers Display WA #1125 for RC. 4577 + */ 4578 + if (result_prev->plane_res_b > res_blocks) 4579 + res_blocks = result_prev->plane_res_b; 4600 4580 } 4601 4581 4602 4582 if (INTEL_GEN(dev_priv) >= 11) { ··· 4634 4596 if ((level > 0 && res_lines > 31) || 4635 4597 res_blocks >= ddb_allocation || 4636 4598 min_disp_buf_needed >= ddb_allocation) { 4637 - *enabled = false; 4599 + result->plane_en = false; 4638 4600 4639 4601 /* 4640 4602 * If there are no valid level 0 watermarks, then we can't ··· 4653 4615 } 4654 4616 } 4655 4617 4618 + /* 4619 + * Display WA #826 (SKL:ALL, BXT:ALL) & #1059 (CNL:A) 4620 + * disable wm level 1-7 on NV12 planes 4621 + */ 4622 + if (wp->is_planar && level >= 1 && 4623 + (IS_SKYLAKE(dev_priv) || IS_BROXTON(dev_priv) || 4624 + IS_CNL_REVID(dev_priv, CNL_REVID_A0, CNL_REVID_A0))) { 4625 + result->plane_en = false; 4626 + return 0; 4627 + } 4628 + 4656 4629 /* The number of lines are ignored for the level 0 watermark. */ 4657 - *out_lines = level ? res_lines : 0; 4658 - *out_blocks = res_blocks; 4659 - *enabled = true; 4630 + result->plane_res_b = res_blocks; 4631 + result->plane_res_l = res_lines; 4632 + result->plane_en = true; 4660 4633 4661 4634 return 0; 4662 4635 } ··· 4678 4629 struct intel_crtc_state *cstate, 4679 4630 const struct intel_plane_state *intel_pstate, 4680 4631 const struct skl_wm_params *wm_params, 4681 - struct skl_plane_wm *wm) 4632 + struct skl_plane_wm *wm, 4633 + int plane_id) 4682 4634 { 4683 4635 struct intel_crtc *intel_crtc = to_intel_crtc(cstate->base.crtc); 4684 4636 struct drm_plane *plane = intel_pstate->base.plane; ··· 4687 4637 uint16_t ddb_blocks; 4688 4638 enum pipe pipe = intel_crtc->pipe; 4689 4639 int level, max_level = ilk_wm_max_level(dev_priv); 4640 + enum plane_id intel_plane_id = intel_plane->id; 4690 4641 int ret; 4691 4642 4692 4643 if (WARN_ON(!intel_pstate->base.fb)) 4693 4644 return -EINVAL; 4694 4645 4695 - ddb_blocks = skl_ddb_entry_size(&ddb->plane[pipe][intel_plane->id]); 4646 + ddb_blocks = plane_id ? 4647 + skl_ddb_entry_size(&ddb->uv_plane[pipe][intel_plane_id]) : 4648 + skl_ddb_entry_size(&ddb->plane[pipe][intel_plane_id]); 4696 4649 4697 4650 for (level = 0; level <= max_level; level++) { 4698 - struct skl_wm_level *result = &wm->wm[level]; 4651 + struct skl_wm_level *result = plane_id ? &wm->uv_wm[level] : 4652 + &wm->wm[level]; 4653 + struct skl_wm_level *result_prev; 4654 + 4655 + if (level) 4656 + result_prev = plane_id ? &wm->uv_wm[level - 1] : 4657 + &wm->wm[level - 1]; 4658 + else 4659 + result_prev = plane_id ? &wm->uv_wm[0] : &wm->wm[0]; 4699 4660 4700 4661 ret = skl_compute_plane_wm(dev_priv, 4701 4662 cstate, ··· 4714 4653 ddb_blocks, 4715 4654 level, 4716 4655 wm_params, 4717 - &result->plane_res_b, 4718 - &result->plane_res_l, 4719 - &result->plane_en); 4656 + result_prev, 4657 + result); 4720 4658 if (ret) 4721 4659 return ret; 4722 4660 } 4661 + 4662 + if (intel_pstate->base.fb->format->format == DRM_FORMAT_NV12) 4663 + wm->is_planar = true; 4723 4664 4724 4665 return 0; 4725 4666 } ··· 4832 4769 4833 4770 wm = &pipe_wm->planes[plane_id]; 4834 4771 ddb_blocks = skl_ddb_entry_size(&ddb->plane[pipe][plane_id]); 4835 - memset(&wm_params, 0, sizeof(struct skl_wm_params)); 4836 4772 4837 4773 ret = skl_compute_plane_wm_params(dev_priv, cstate, 4838 - intel_pstate, &wm_params); 4774 + intel_pstate, &wm_params, 0); 4839 4775 if (ret) 4840 4776 return ret; 4841 4777 4842 4778 ret = skl_compute_wm_levels(dev_priv, ddb, cstate, 4843 - intel_pstate, &wm_params, wm); 4779 + intel_pstate, &wm_params, wm, 0); 4844 4780 if (ret) 4845 4781 return ret; 4782 + 4846 4783 skl_compute_transition_wm(cstate, &wm_params, &wm->wm[0], 4847 4784 ddb_blocks, &wm->trans_wm); 4785 + 4786 + /* uv plane watermarks must also be validated for NV12/Planar */ 4787 + if (wm_params.is_planar) { 4788 + memset(&wm_params, 0, sizeof(struct skl_wm_params)); 4789 + wm->is_planar = true; 4790 + 4791 + ret = skl_compute_plane_wm_params(dev_priv, cstate, 4792 + intel_pstate, 4793 + &wm_params, 1); 4794 + if (ret) 4795 + return ret; 4796 + 4797 + ret = skl_compute_wm_levels(dev_priv, ddb, cstate, 4798 + intel_pstate, &wm_params, 4799 + wm, 1); 4800 + if (ret) 4801 + return ret; 4802 + } 4848 4803 } 4804 + 4849 4805 pipe_wm->linetime = skl_compute_linetime_wm(cstate); 4850 4806 4851 4807 return 0; ··· 4915 4833 4916 4834 skl_ddb_entry_write(dev_priv, PLANE_BUF_CFG(pipe, plane_id), 4917 4835 &ddb->plane[pipe][plane_id]); 4918 - if (INTEL_GEN(dev_priv) < 11) 4836 + if (INTEL_GEN(dev_priv) >= 11) 4837 + return skl_ddb_entry_write(dev_priv, 4838 + PLANE_BUF_CFG(pipe, plane_id), 4839 + &ddb->plane[pipe][plane_id]); 4840 + if (wm->is_planar) { 4841 + skl_ddb_entry_write(dev_priv, PLANE_BUF_CFG(pipe, plane_id), 4842 + &ddb->uv_plane[pipe][plane_id]); 4919 4843 skl_ddb_entry_write(dev_priv, 4920 4844 PLANE_NV12_BUF_CFG(pipe, plane_id), 4921 - &ddb->y_plane[pipe][plane_id]); 4845 + &ddb->plane[pipe][plane_id]); 4846 + } else { 4847 + skl_ddb_entry_write(dev_priv, PLANE_BUF_CFG(pipe, plane_id), 4848 + &ddb->plane[pipe][plane_id]); 4849 + I915_WRITE(PLANE_NV12_BUF_CFG(pipe, plane_id), 0x0); 4850 + } 4922 4851 } 4923 4852 4924 4853 static void skl_write_cursor_wm(struct intel_crtc *intel_crtc, ··· 5037 4944 struct drm_plane *plane; 5038 4945 enum pipe pipe = intel_crtc->pipe; 5039 4946 5040 - WARN_ON(!drm_atomic_get_existing_crtc_state(state, crtc)); 5041 - 5042 4947 drm_for_each_plane_mask(plane, dev, cstate->base.plane_mask) { 5043 4948 enum plane_id plane_id = to_intel_plane(plane)->id; 5044 4949 5045 4950 if (skl_ddb_entry_equal(&cur_ddb->plane[pipe][plane_id], 5046 4951 &new_ddb->plane[pipe][plane_id]) && 5047 - skl_ddb_entry_equal(&cur_ddb->y_plane[pipe][plane_id], 5048 - &new_ddb->y_plane[pipe][plane_id])) 4952 + skl_ddb_entry_equal(&cur_ddb->uv_plane[pipe][plane_id], 4953 + &new_ddb->uv_plane[pipe][plane_id])) 5049 4954 continue; 5050 4955 5051 4956 plane_state = drm_atomic_get_plane_state(state, plane); ··· 5057 4966 static int 5058 4967 skl_compute_ddb(struct drm_atomic_state *state) 5059 4968 { 5060 - struct drm_device *dev = state->dev; 5061 - struct drm_i915_private *dev_priv = to_i915(dev); 4969 + const struct drm_i915_private *dev_priv = to_i915(state->dev); 5062 4970 struct intel_atomic_state *intel_state = to_intel_atomic_state(state); 5063 - struct intel_crtc *intel_crtc; 5064 4971 struct skl_ddb_allocation *ddb = &intel_state->wm_results.ddb; 4972 + struct intel_crtc *crtc; 4973 + struct intel_crtc_state *cstate; 4974 + int ret, i; 4975 + 4976 + memcpy(ddb, &dev_priv->wm.skl_hw.ddb, sizeof(*ddb)); 4977 + 4978 + for_each_new_intel_crtc_in_state(intel_state, crtc, cstate, i) { 4979 + ret = skl_allocate_pipe_ddb(cstate, ddb); 4980 + if (ret) 4981 + return ret; 4982 + 4983 + ret = skl_ddb_add_affected_planes(cstate); 4984 + if (ret) 4985 + return ret; 4986 + } 4987 + 4988 + return 0; 4989 + } 4990 + 4991 + static void 4992 + skl_copy_ddb_for_pipe(struct skl_ddb_values *dst, 4993 + struct skl_ddb_values *src, 4994 + enum pipe pipe) 4995 + { 4996 + memcpy(dst->ddb.uv_plane[pipe], src->ddb.uv_plane[pipe], 4997 + sizeof(dst->ddb.uv_plane[pipe])); 4998 + memcpy(dst->ddb.plane[pipe], src->ddb.plane[pipe], 4999 + sizeof(dst->ddb.plane[pipe])); 5000 + } 5001 + 5002 + static void 5003 + skl_print_wm_changes(const struct drm_atomic_state *state) 5004 + { 5005 + const struct drm_device *dev = state->dev; 5006 + const struct drm_i915_private *dev_priv = to_i915(dev); 5007 + const struct intel_atomic_state *intel_state = 5008 + to_intel_atomic_state(state); 5009 + const struct drm_crtc *crtc; 5010 + const struct drm_crtc_state *cstate; 5011 + const struct intel_plane *intel_plane; 5012 + const struct skl_ddb_allocation *old_ddb = &dev_priv->wm.skl_hw.ddb; 5013 + const struct skl_ddb_allocation *new_ddb = &intel_state->wm_results.ddb; 5014 + int i; 5015 + 5016 + for_each_new_crtc_in_state(state, crtc, cstate, i) { 5017 + const struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 5018 + enum pipe pipe = intel_crtc->pipe; 5019 + 5020 + for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) { 5021 + enum plane_id plane_id = intel_plane->id; 5022 + const struct skl_ddb_entry *old, *new; 5023 + 5024 + old = &old_ddb->plane[pipe][plane_id]; 5025 + new = &new_ddb->plane[pipe][plane_id]; 5026 + 5027 + if (skl_ddb_entry_equal(old, new)) 5028 + continue; 5029 + 5030 + DRM_DEBUG_ATOMIC("[PLANE:%d:%s] ddb (%d - %d) -> (%d - %d)\n", 5031 + intel_plane->base.base.id, 5032 + intel_plane->base.name, 5033 + old->start, old->end, 5034 + new->start, new->end); 5035 + } 5036 + } 5037 + } 5038 + 5039 + static int 5040 + skl_ddb_add_affected_pipes(struct drm_atomic_state *state, bool *changed) 5041 + { 5042 + struct drm_device *dev = state->dev; 5043 + const struct drm_i915_private *dev_priv = to_i915(dev); 5044 + const struct drm_crtc *crtc; 5045 + const struct drm_crtc_state *cstate; 5046 + struct intel_crtc *intel_crtc; 5047 + struct intel_atomic_state *intel_state = to_intel_atomic_state(state); 5065 5048 uint32_t realloc_pipes = pipes_modified(state); 5066 - int ret; 5049 + int ret, i; 5050 + 5051 + /* 5052 + * When we distrust bios wm we always need to recompute to set the 5053 + * expected DDB allocations for each CRTC. 5054 + */ 5055 + if (dev_priv->wm.distrust_bios_wm) 5056 + (*changed) = true; 5057 + 5058 + /* 5059 + * If this transaction isn't actually touching any CRTC's, don't 5060 + * bother with watermark calculation. Note that if we pass this 5061 + * test, we're guaranteed to hold at least one CRTC state mutex, 5062 + * which means we can safely use values like dev_priv->active_crtcs 5063 + * since any racing commits that want to update them would need to 5064 + * hold _all_ CRTC state mutexes. 5065 + */ 5066 + for_each_new_crtc_in_state(state, crtc, cstate, i) 5067 + (*changed) = true; 5068 + 5069 + if (!*changed) 5070 + return 0; 5067 5071 5068 5072 /* 5069 5073 * If this is our first atomic update following hardware readout, ··· 5206 5020 * We're not recomputing for the pipes not included in the commit, so 5207 5021 * make sure we start with the current state. 5208 5022 */ 5209 - memcpy(ddb, &dev_priv->wm.skl_hw.ddb, sizeof(*ddb)); 5210 - 5211 5023 for_each_intel_crtc_mask(dev, intel_crtc, realloc_pipes) { 5212 5024 struct intel_crtc_state *cstate; 5213 5025 5214 5026 cstate = intel_atomic_get_crtc_state(state, intel_crtc); 5215 5027 if (IS_ERR(cstate)) 5216 5028 return PTR_ERR(cstate); 5217 - 5218 - ret = skl_allocate_pipe_ddb(cstate, ddb); 5219 - if (ret) 5220 - return ret; 5221 - 5222 - ret = skl_ddb_add_affected_planes(cstate); 5223 - if (ret) 5224 - return ret; 5225 5029 } 5226 5030 5227 5031 return 0; 5228 - } 5229 - 5230 - static void 5231 - skl_copy_wm_for_pipe(struct skl_wm_values *dst, 5232 - struct skl_wm_values *src, 5233 - enum pipe pipe) 5234 - { 5235 - memcpy(dst->ddb.y_plane[pipe], src->ddb.y_plane[pipe], 5236 - sizeof(dst->ddb.y_plane[pipe])); 5237 - memcpy(dst->ddb.plane[pipe], src->ddb.plane[pipe], 5238 - sizeof(dst->ddb.plane[pipe])); 5239 - } 5240 - 5241 - static void 5242 - skl_print_wm_changes(const struct drm_atomic_state *state) 5243 - { 5244 - const struct drm_device *dev = state->dev; 5245 - const struct drm_i915_private *dev_priv = to_i915(dev); 5246 - const struct intel_atomic_state *intel_state = 5247 - to_intel_atomic_state(state); 5248 - const struct drm_crtc *crtc; 5249 - const struct drm_crtc_state *cstate; 5250 - const struct intel_plane *intel_plane; 5251 - const struct skl_ddb_allocation *old_ddb = &dev_priv->wm.skl_hw.ddb; 5252 - const struct skl_ddb_allocation *new_ddb = &intel_state->wm_results.ddb; 5253 - int i; 5254 - 5255 - for_each_new_crtc_in_state(state, crtc, cstate, i) { 5256 - const struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 5257 - enum pipe pipe = intel_crtc->pipe; 5258 - 5259 - for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) { 5260 - enum plane_id plane_id = intel_plane->id; 5261 - const struct skl_ddb_entry *old, *new; 5262 - 5263 - old = &old_ddb->plane[pipe][plane_id]; 5264 - new = &new_ddb->plane[pipe][plane_id]; 5265 - 5266 - if (skl_ddb_entry_equal(old, new)) 5267 - continue; 5268 - 5269 - DRM_DEBUG_ATOMIC("[PLANE:%d:%s] ddb (%d - %d) -> (%d - %d)\n", 5270 - intel_plane->base.base.id, 5271 - intel_plane->base.name, 5272 - old->start, old->end, 5273 - new->start, new->end); 5274 - } 5275 - } 5276 5032 } 5277 5033 5278 5034 static int ··· 5223 5095 struct drm_crtc *crtc; 5224 5096 struct drm_crtc_state *cstate; 5225 5097 struct intel_atomic_state *intel_state = to_intel_atomic_state(state); 5226 - struct skl_wm_values *results = &intel_state->wm_results; 5227 - struct drm_device *dev = state->dev; 5098 + struct skl_ddb_values *results = &intel_state->wm_results; 5228 5099 struct skl_pipe_wm *pipe_wm; 5229 5100 bool changed = false; 5230 5101 int ret, i; 5231 5102 5232 - /* 5233 - * When we distrust bios wm we always need to recompute to set the 5234 - * expected DDB allocations for each CRTC. 5235 - */ 5236 - if (to_i915(dev)->wm.distrust_bios_wm) 5237 - changed = true; 5238 - 5239 - /* 5240 - * If this transaction isn't actually touching any CRTC's, don't 5241 - * bother with watermark calculation. Note that if we pass this 5242 - * test, we're guaranteed to hold at least one CRTC state mutex, 5243 - * which means we can safely use values like dev_priv->active_crtcs 5244 - * since any racing commits that want to update them would need to 5245 - * hold _all_ CRTC state mutexes. 5246 - */ 5247 - for_each_new_crtc_in_state(state, crtc, cstate, i) 5248 - changed = true; 5249 - 5250 - if (!changed) 5251 - return 0; 5252 - 5253 5103 /* Clear all dirty flags */ 5254 5104 results->dirty_pipes = 0; 5105 + 5106 + ret = skl_ddb_add_affected_pipes(state, &changed); 5107 + if (ret || !changed) 5108 + return ret; 5255 5109 5256 5110 ret = skl_compute_ddb(state); 5257 5111 if (ret) ··· 5307 5197 struct intel_crtc *intel_crtc = to_intel_crtc(cstate->base.crtc); 5308 5198 struct drm_device *dev = intel_crtc->base.dev; 5309 5199 struct drm_i915_private *dev_priv = to_i915(dev); 5310 - struct skl_wm_values *results = &state->wm_results; 5311 - struct skl_wm_values *hw_vals = &dev_priv->wm.skl_hw; 5200 + struct skl_ddb_values *results = &state->wm_results; 5201 + struct skl_ddb_values *hw_vals = &dev_priv->wm.skl_hw; 5312 5202 enum pipe pipe = intel_crtc->pipe; 5313 5203 5314 5204 if ((results->dirty_pipes & drm_crtc_mask(&intel_crtc->base)) == 0) ··· 5319 5209 if (cstate->base.active_changed) 5320 5210 skl_atomic_update_crtc_wm(state, cstate); 5321 5211 5322 - skl_copy_wm_for_pipe(hw_vals, results, pipe); 5212 + skl_copy_ddb_for_pipe(hw_vals, results, pipe); 5323 5213 5324 5214 mutex_unlock(&dev_priv->wm.wm_mutex); 5325 5215 } ··· 5451 5341 void skl_wm_get_hw_state(struct drm_device *dev) 5452 5342 { 5453 5343 struct drm_i915_private *dev_priv = to_i915(dev); 5454 - struct skl_wm_values *hw = &dev_priv->wm.skl_hw; 5344 + struct skl_ddb_values *hw = &dev_priv->wm.skl_hw; 5455 5345 struct skl_ddb_allocation *ddb = &dev_priv->wm.skl_hw.ddb; 5456 5346 struct drm_crtc *crtc; 5457 5347 struct intel_crtc *intel_crtc; ··· 6682 6572 6683 6573 rps->efficient_freq = rps->rp1_freq; 6684 6574 if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv) || 6685 - IS_GEN9_BC(dev_priv) || IS_CANNONLAKE(dev_priv)) { 6575 + IS_GEN9_BC(dev_priv) || INTEL_GEN(dev_priv) >= 10) { 6686 6576 u32 ddcc_status = 0; 6687 6577 6688 6578 if (sandybridge_pcode_read(dev_priv, ··· 6695 6585 rps->max_freq); 6696 6586 } 6697 6587 6698 - if (IS_GEN9_BC(dev_priv) || IS_CANNONLAKE(dev_priv)) { 6588 + if (IS_GEN9_BC(dev_priv) || INTEL_GEN(dev_priv) >= 10) { 6699 6589 /* Store the frequency values in 16.66 MHZ units, which is 6700 6590 * the natural hardware unit for SKL 6701 6591 */ ··· 7000 6890 static void gen6_update_ring_freq(struct drm_i915_private *dev_priv) 7001 6891 { 7002 6892 struct intel_rps *rps = &dev_priv->gt_pm.rps; 7003 - int min_freq = 15; 6893 + const int min_freq = 15; 6894 + const int scaling_factor = 180; 7004 6895 unsigned int gpu_freq; 7005 6896 unsigned int max_ia_freq, min_ring_freq; 7006 6897 unsigned int max_gpu_freq, min_gpu_freq; 7007 - int scaling_factor = 180; 7008 6898 struct cpufreq_policy *policy; 7009 6899 7010 6900 WARN_ON(!mutex_is_locked(&dev_priv->pcu_lock)); 6901 + 6902 + if (rps->max_freq <= rps->min_freq) 6903 + return; 7011 6904 7012 6905 policy = cpufreq_cpu_get(0); 7013 6906 if (policy) { ··· 7031 6918 /* convert DDR frequency from units of 266.6MHz to bandwidth */ 7032 6919 min_ring_freq = mult_frac(min_ring_freq, 8, 3); 7033 6920 7034 - if (IS_GEN9_BC(dev_priv) || IS_CANNONLAKE(dev_priv)) { 6921 + min_gpu_freq = rps->min_freq; 6922 + max_gpu_freq = rps->max_freq; 6923 + if (IS_GEN9_BC(dev_priv) || INTEL_GEN(dev_priv) >= 10) { 7035 6924 /* Convert GT frequency to 50 HZ units */ 7036 - min_gpu_freq = rps->min_freq / GEN9_FREQ_SCALER; 7037 - max_gpu_freq = rps->max_freq / GEN9_FREQ_SCALER; 7038 - } else { 7039 - min_gpu_freq = rps->min_freq; 7040 - max_gpu_freq = rps->max_freq; 6925 + min_gpu_freq /= GEN9_FREQ_SCALER; 6926 + max_gpu_freq /= GEN9_FREQ_SCALER; 7041 6927 } 7042 6928 7043 6929 /* ··· 7045 6933 * the PCU should use as a reference to determine the ring frequency. 7046 6934 */ 7047 6935 for (gpu_freq = max_gpu_freq; gpu_freq >= min_gpu_freq; gpu_freq--) { 7048 - int diff = max_gpu_freq - gpu_freq; 6936 + const int diff = max_gpu_freq - gpu_freq; 7049 6937 unsigned int ia_freq = 0, ring_freq = 0; 7050 6938 7051 - if (IS_GEN9_BC(dev_priv) || IS_CANNONLAKE(dev_priv)) { 6939 + if (IS_GEN9_BC(dev_priv) || INTEL_GEN(dev_priv) >= 10) { 7052 6940 /* 7053 6941 * ring_freq = 2 * GT. ring_freq is in 100MHz units 7054 6942 * No floor required for ring frequency on SKL. ··· 8138 8026 dev_priv->gt_pm.rc6.enabled = true; /* force RC6 disabling */ 8139 8027 intel_disable_gt_powersave(dev_priv); 8140 8028 8141 - if (INTEL_GEN(dev_priv) < 11) 8142 - gen6_reset_rps_interrupts(dev_priv); 8029 + if (INTEL_GEN(dev_priv) >= 11) 8030 + gen11_reset_rps_interrupts(dev_priv); 8143 8031 else 8144 - WARN_ON_ONCE(1); 8032 + gen6_reset_rps_interrupts(dev_priv); 8145 8033 } 8146 8034 8147 8035 static inline void intel_disable_llc_pstate(struct drm_i915_private *i915) ··· 8254 8142 cherryview_enable_rps(dev_priv); 8255 8143 } else if (IS_VALLEYVIEW(dev_priv)) { 8256 8144 valleyview_enable_rps(dev_priv); 8257 - } else if (WARN_ON_ONCE(INTEL_GEN(dev_priv) >= 11)) { 8258 - /* TODO */ 8259 8145 } else if (INTEL_GEN(dev_priv) >= 9) { 8260 8146 gen9_enable_rps(dev_priv); 8261 8147 } else if (IS_BROADWELL(dev_priv)) {
+169 -158
drivers/gpu/drm/i915/intel_psr.c
··· 93 93 intel_display_power_put(dev_priv, psr_aux_domain(intel_dp)); 94 94 } 95 95 96 - static bool intel_dp_get_y_cord_status(struct intel_dp *intel_dp) 96 + static bool intel_dp_get_y_coord_required(struct intel_dp *intel_dp) 97 97 { 98 98 uint8_t psr_caps = 0; 99 99 ··· 122 122 return alpm_caps & DP_ALPM_CAP; 123 123 } 124 124 125 + static u8 intel_dp_get_sink_sync_latency(struct intel_dp *intel_dp) 126 + { 127 + u8 val = 0; 128 + 129 + if (drm_dp_dpcd_readb(&intel_dp->aux, 130 + DP_SYNCHRONIZATION_LATENCY_IN_SINK, &val) == 1) 131 + val &= DP_MAX_RESYNC_FRAME_COUNT_MASK; 132 + else 133 + DRM_ERROR("Unable to get sink synchronization latency\n"); 134 + return val; 135 + } 136 + 125 137 void intel_psr_init_dpcd(struct intel_dp *intel_dp) 126 138 { 127 139 struct drm_i915_private *dev_priv = ··· 142 130 drm_dp_dpcd_read(&intel_dp->aux, DP_PSR_SUPPORT, intel_dp->psr_dpcd, 143 131 sizeof(intel_dp->psr_dpcd)); 144 132 145 - if (intel_dp->psr_dpcd[0] & DP_PSR_IS_SUPPORTED) { 133 + if (intel_dp->psr_dpcd[0]) { 146 134 dev_priv->psr.sink_support = true; 147 135 DRM_DEBUG_KMS("Detected EDP PSR Panel.\n"); 148 136 } 149 137 150 138 if (INTEL_GEN(dev_priv) >= 9 && 151 - (intel_dp->psr_dpcd[0] & DP_PSR2_IS_SUPPORTED)) { 152 - uint8_t frame_sync_cap; 139 + (intel_dp->psr_dpcd[0] == DP_PSR2_WITH_Y_COORD_IS_SUPPORTED)) { 140 + /* 141 + * All panels that supports PSR version 03h (PSR2 + 142 + * Y-coordinate) can handle Y-coordinates in VSC but we are 143 + * only sure that it is going to be used when required by the 144 + * panel. This way panel is capable to do selective update 145 + * without a aux frame sync. 146 + * 147 + * To support PSR version 02h and PSR version 03h without 148 + * Y-coordinate requirement panels we would need to enable 149 + * GTC first. 150 + */ 151 + dev_priv->psr.sink_psr2_support = 152 + intel_dp_get_y_coord_required(intel_dp); 153 + DRM_DEBUG_KMS("PSR2 %s on sink", dev_priv->psr.sink_psr2_support 154 + ? "supported" : "not supported"); 153 155 154 - dev_priv->psr.sink_support = true; 155 - if (drm_dp_dpcd_readb(&intel_dp->aux, 156 - DP_SINK_DEVICE_AUX_FRAME_SYNC_CAP, 157 - &frame_sync_cap) != 1) 158 - frame_sync_cap = 0; 159 - dev_priv->psr.aux_frame_sync = frame_sync_cap & DP_AUX_FRAME_SYNC_CAP; 160 - /* PSR2 needs frame sync as well */ 161 - dev_priv->psr.psr2_support = dev_priv->psr.aux_frame_sync; 162 - DRM_DEBUG_KMS("PSR2 %s on sink", 163 - dev_priv->psr.psr2_support ? "supported" : "not supported"); 164 - 165 - if (dev_priv->psr.psr2_support) { 166 - dev_priv->psr.y_cord_support = 167 - intel_dp_get_y_cord_status(intel_dp); 156 + if (dev_priv->psr.sink_psr2_support) { 168 157 dev_priv->psr.colorimetry_support = 169 158 intel_dp_get_colorimetry_status(intel_dp); 170 159 dev_priv->psr.alpm = 171 160 intel_dp_get_alpm_status(intel_dp); 161 + dev_priv->psr.sink_sync_latency = 162 + intel_dp_get_sink_sync_latency(intel_dp); 172 163 } 173 164 } 174 165 } ··· 208 193 struct drm_i915_private *dev_priv = to_i915(intel_dig_port->base.base.dev); 209 194 struct edp_vsc_psr psr_vsc; 210 195 211 - if (dev_priv->psr.psr2_support) { 196 + if (dev_priv->psr.psr2_enabled) { 212 197 /* Prepare VSC Header for SU as per EDP 1.4 spec, Table 6.11 */ 213 198 memset(&psr_vsc, 0, sizeof(psr_vsc)); 214 199 psr_vsc.sdp_header.HB0 = 0; 215 200 psr_vsc.sdp_header.HB1 = 0x7; 216 - if (dev_priv->psr.colorimetry_support && 217 - dev_priv->psr.y_cord_support) { 201 + if (dev_priv->psr.colorimetry_support) { 218 202 psr_vsc.sdp_header.HB2 = 0x5; 219 203 psr_vsc.sdp_header.HB3 = 0x13; 220 - } else if (dev_priv->psr.y_cord_support) { 204 + } else { 221 205 psr_vsc.sdp_header.HB2 = 0x4; 222 206 psr_vsc.sdp_header.HB3 = 0xe; 223 - } else { 224 - psr_vsc.sdp_header.HB2 = 0x3; 225 - psr_vsc.sdp_header.HB3 = 0xc; 226 207 } 227 208 } else { 228 209 /* Prepare VSC packet as per EDP 1.3 spec, Table 3.10 */ ··· 239 228 DP_PSR_ENABLE | DP_PSR_MAIN_LINK_ACTIVE); 240 229 } 241 230 242 - static i915_reg_t psr_aux_ctl_reg(struct drm_i915_private *dev_priv, 243 - enum port port) 244 - { 245 - if (INTEL_GEN(dev_priv) >= 9) 246 - return DP_AUX_CH_CTL(port); 247 - else 248 - return EDP_PSR_AUX_CTL; 249 - } 250 - 251 - static i915_reg_t psr_aux_data_reg(struct drm_i915_private *dev_priv, 252 - enum port port, int index) 253 - { 254 - if (INTEL_GEN(dev_priv) >= 9) 255 - return DP_AUX_CH_DATA(port, index); 256 - else 257 - return EDP_PSR_AUX_DATA(index); 258 - } 259 - 260 - static void hsw_psr_enable_sink(struct intel_dp *intel_dp) 231 + static void hsw_psr_setup_aux(struct intel_dp *intel_dp) 261 232 { 262 233 struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); 263 - struct drm_device *dev = dig_port->base.base.dev; 264 - struct drm_i915_private *dev_priv = to_i915(dev); 265 - uint32_t aux_clock_divider; 266 - i915_reg_t aux_ctl_reg; 234 + struct drm_i915_private *dev_priv = to_i915(dig_port->base.base.dev); 235 + u32 aux_clock_divider, aux_ctl; 236 + int i; 267 237 static const uint8_t aux_msg[] = { 268 238 [0] = DP_AUX_NATIVE_WRITE << 4, 269 239 [1] = DP_SET_POWER >> 8, ··· 252 260 [3] = 1 - 1, 253 261 [4] = DP_SET_POWER_D0, 254 262 }; 255 - enum port port = dig_port->base.port; 256 - u32 aux_ctl; 257 - int i; 263 + u32 psr_aux_mask = EDP_PSR_AUX_CTL_TIME_OUT_MASK | 264 + EDP_PSR_AUX_CTL_MESSAGE_SIZE_MASK | 265 + EDP_PSR_AUX_CTL_PRECHARGE_2US_MASK | 266 + EDP_PSR_AUX_CTL_BIT_CLOCK_2X_MASK; 258 267 259 268 BUILD_BUG_ON(sizeof(aux_msg) > 20); 269 + for (i = 0; i < sizeof(aux_msg); i += 4) 270 + I915_WRITE(EDP_PSR_AUX_DATA(i >> 2), 271 + intel_dp_pack_aux(&aux_msg[i], sizeof(aux_msg) - i)); 260 272 261 273 aux_clock_divider = intel_dp->get_aux_clock_divider(intel_dp, 0); 262 274 263 - /* Enable AUX frame sync at sink */ 264 - if (dev_priv->psr.aux_frame_sync) 265 - drm_dp_dpcd_writeb(&intel_dp->aux, 266 - DP_SINK_DEVICE_AUX_FRAME_SYNC_CONF, 267 - DP_AUX_FRAME_SYNC_ENABLE); 275 + /* Start with bits set for DDI_AUX_CTL register */ 276 + aux_ctl = intel_dp->get_aux_send_ctl(intel_dp, 0, sizeof(aux_msg), 277 + aux_clock_divider); 278 + 279 + /* Select only valid bits for SRD_AUX_CTL */ 280 + aux_ctl &= psr_aux_mask; 281 + I915_WRITE(EDP_PSR_AUX_CTL, aux_ctl); 282 + } 283 + 284 + static void hsw_psr_enable_sink(struct intel_dp *intel_dp) 285 + { 286 + struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); 287 + struct drm_device *dev = dig_port->base.base.dev; 288 + struct drm_i915_private *dev_priv = to_i915(dev); 289 + u8 dpcd_val = DP_PSR_ENABLE; 290 + 268 291 /* Enable ALPM at sink for psr2 */ 269 - if (dev_priv->psr.psr2_support && dev_priv->psr.alpm) 292 + if (dev_priv->psr.psr2_enabled && dev_priv->psr.alpm) 270 293 drm_dp_dpcd_writeb(&intel_dp->aux, 271 294 DP_RECEIVER_ALPM_CONFIG, 272 295 DP_ALPM_ENABLE); 296 + 297 + if (dev_priv->psr.psr2_enabled) 298 + dpcd_val |= DP_PSR_ENABLE_PSR2; 273 299 if (dev_priv->psr.link_standby) 274 - drm_dp_dpcd_writeb(&intel_dp->aux, DP_PSR_EN_CFG, 275 - DP_PSR_ENABLE | DP_PSR_MAIN_LINK_ACTIVE); 276 - else 277 - drm_dp_dpcd_writeb(&intel_dp->aux, DP_PSR_EN_CFG, 278 - DP_PSR_ENABLE); 300 + dpcd_val |= DP_PSR_MAIN_LINK_ACTIVE; 301 + drm_dp_dpcd_writeb(&intel_dp->aux, DP_PSR_EN_CFG, dpcd_val); 279 302 280 - aux_ctl_reg = psr_aux_ctl_reg(dev_priv, port); 281 - 282 - /* Setup AUX registers */ 283 - for (i = 0; i < sizeof(aux_msg); i += 4) 284 - I915_WRITE(psr_aux_data_reg(dev_priv, port, i >> 2), 285 - intel_dp_pack_aux(&aux_msg[i], sizeof(aux_msg) - i)); 286 - 287 - aux_ctl = intel_dp->get_aux_send_ctl(intel_dp, 0, sizeof(aux_msg), 288 - aux_clock_divider); 289 - I915_WRITE(aux_ctl_reg, aux_ctl); 303 + drm_dp_dpcd_writeb(&intel_dp->aux, DP_SET_POWER, DP_SET_POWER_D0); 290 304 } 291 305 292 306 static void vlv_psr_enable_source(struct intel_dp *intel_dp, ··· 394 396 * with the 5 or 6 idle patterns. 395 397 */ 396 398 uint32_t idle_frames = max(6, dev_priv->vbt.psr.idle_frames); 397 - uint32_t val; 398 - uint8_t sink_latency; 399 - 400 - val = idle_frames << EDP_PSR_IDLE_FRAME_SHIFT; 399 + u32 val = idle_frames << EDP_PSR2_IDLE_FRAME_SHIFT; 401 400 402 401 /* FIXME: selective update is probably totally broken because it doesn't 403 402 * mesh at all with our frontbuffer tracking. And the hw alone isn't 404 403 * good enough. */ 405 - val |= EDP_PSR2_ENABLE | 406 - EDP_SU_TRACK_ENABLE; 407 - 408 - if (drm_dp_dpcd_readb(&intel_dp->aux, 409 - DP_SYNCHRONIZATION_LATENCY_IN_SINK, 410 - &sink_latency) == 1) { 411 - sink_latency &= DP_MAX_RESYNC_FRAME_COUNT_MASK; 412 - } else { 413 - sink_latency = 0; 404 + val |= EDP_PSR2_ENABLE | EDP_SU_TRACK_ENABLE; 405 + if (INTEL_GEN(dev_priv) >= 10 || IS_GEMINILAKE(dev_priv)) { 406 + val |= EDP_Y_COORDINATE_VALID | EDP_Y_COORDINATE_ENABLE; 414 407 } 415 - val |= EDP_PSR2_FRAME_BEFORE_SU(sink_latency + 1); 408 + 409 + val |= EDP_PSR2_FRAME_BEFORE_SU(dev_priv->psr.sink_sync_latency + 1); 416 410 417 411 if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 5) 418 412 val |= EDP_PSR2_TP2_TIME_2500; ··· 430 440 */ 431 441 432 442 /* psr1 and psr2 are mutually exclusive.*/ 433 - if (dev_priv->psr.psr2_support) 443 + if (dev_priv->psr.psr2_enabled) 434 444 hsw_activate_psr2(intel_dp); 435 445 else 436 446 hsw_activate_psr1(intel_dp); ··· 450 460 * dynamically during PSR enable, and extracted from sink 451 461 * caps during eDP detection. 452 462 */ 453 - if (!dev_priv->psr.psr2_support) 463 + if (!dev_priv->psr.sink_psr2_support) 454 464 return false; 455 465 456 466 if (INTEL_GEN(dev_priv) >= 10 || IS_GEMINILAKE(dev_priv)) { ··· 465 475 DRM_DEBUG_KMS("PSR2 not enabled, resolution %dx%d > max supported %dx%d\n", 466 476 crtc_hdisplay, crtc_vdisplay, 467 477 psr_max_h, psr_max_v); 468 - return false; 469 - } 470 - 471 - /* 472 - * FIXME:enable psr2 only for y-cordinate psr2 panels 473 - * After gtc implementation , remove this restriction. 474 - */ 475 - if (!dev_priv->psr.y_cord_support) { 476 - DRM_DEBUG_KMS("PSR2 not enabled, panel does not support Y coordinate\n"); 477 478 return false; 478 479 } 479 480 ··· 549 568 struct drm_device *dev = intel_dig_port->base.base.dev; 550 569 struct drm_i915_private *dev_priv = to_i915(dev); 551 570 552 - if (dev_priv->psr.psr2_support) 571 + if (dev_priv->psr.psr2_enabled) 553 572 WARN_ON(I915_READ(EDP_PSR2_CTL) & EDP_PSR2_ENABLE); 554 573 else 555 574 WARN_ON(I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE); ··· 567 586 struct drm_device *dev = dig_port->base.base.dev; 568 587 struct drm_i915_private *dev_priv = to_i915(dev); 569 588 enum transcoder cpu_transcoder = crtc_state->cpu_transcoder; 570 - u32 chicken; 571 589 572 590 psr_aux_io_power_get(intel_dp); 573 591 574 - if (dev_priv->psr.psr2_support) { 575 - chicken = PSR2_VSC_ENABLE_PROG_HEADER; 576 - if (dev_priv->psr.y_cord_support) 577 - chicken |= PSR2_ADD_VERTICAL_LINE_COUNT; 592 + /* Only HSW and BDW have PSR AUX registers that need to be setup. SKL+ 593 + * use hardcoded values PSR AUX transactions 594 + */ 595 + if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) 596 + hsw_psr_setup_aux(intel_dp); 597 + 598 + if (dev_priv->psr.psr2_enabled) { 599 + u32 chicken = I915_READ(CHICKEN_TRANS(cpu_transcoder)); 600 + 601 + if (INTEL_GEN(dev_priv) == 9 && !IS_GEMINILAKE(dev_priv)) 602 + chicken |= (PSR2_VSC_ENABLE_PROG_HEADER 603 + | PSR2_ADD_VERTICAL_LINE_COUNT); 604 + 605 + else 606 + chicken &= ~VSC_DATA_SEL_SOFTWARE_CONTROL; 578 607 I915_WRITE(CHICKEN_TRANS(cpu_transcoder), chicken); 579 608 580 609 I915_WRITE(EDP_PSR_DEBUG, ··· 635 644 goto unlock; 636 645 } 637 646 638 - dev_priv->psr.psr2_support = crtc_state->has_psr2; 647 + dev_priv->psr.psr2_enabled = crtc_state->has_psr2; 639 648 dev_priv->psr.busy_frontbuffer_bits = 0; 640 649 641 650 dev_priv->psr.setup_vsc(intel_dp, crtc_state); ··· 705 714 i915_reg_t psr_status; 706 715 u32 psr_status_mask; 707 716 708 - if (dev_priv->psr.aux_frame_sync) 709 - drm_dp_dpcd_writeb(&intel_dp->aux, 710 - DP_SINK_DEVICE_AUX_FRAME_SYNC_CONF, 711 - 0); 712 - 713 - if (dev_priv->psr.psr2_support) { 717 + if (dev_priv->psr.psr2_enabled) { 714 718 psr_status = EDP_PSR2_STATUS; 715 719 psr_status_mask = EDP_PSR2_STATUS_STATE_MASK; 716 720 ··· 729 743 730 744 dev_priv->psr.active = false; 731 745 } else { 732 - if (dev_priv->psr.psr2_support) 746 + if (dev_priv->psr.psr2_enabled) 733 747 WARN_ON(I915_READ(EDP_PSR2_CTL) & EDP_PSR2_ENABLE); 734 748 else 735 749 WARN_ON(I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE); ··· 775 789 cancel_delayed_work_sync(&dev_priv->psr.work); 776 790 } 777 791 792 + static bool psr_wait_for_idle(struct drm_i915_private *dev_priv) 793 + { 794 + struct intel_dp *intel_dp; 795 + i915_reg_t reg; 796 + u32 mask; 797 + int err; 798 + 799 + intel_dp = dev_priv->psr.enabled; 800 + if (!intel_dp) 801 + return false; 802 + 803 + if (HAS_DDI(dev_priv)) { 804 + if (dev_priv->psr.psr2_enabled) { 805 + reg = EDP_PSR2_STATUS; 806 + mask = EDP_PSR2_STATUS_STATE_MASK; 807 + } else { 808 + reg = EDP_PSR_STATUS; 809 + mask = EDP_PSR_STATUS_STATE_MASK; 810 + } 811 + } else { 812 + struct drm_crtc *crtc = 813 + dp_to_dig_port(intel_dp)->base.base.crtc; 814 + enum pipe pipe = to_intel_crtc(crtc)->pipe; 815 + 816 + reg = VLV_PSRSTAT(pipe); 817 + mask = VLV_EDP_PSR_IN_TRANS; 818 + } 819 + 820 + mutex_unlock(&dev_priv->psr.lock); 821 + 822 + err = intel_wait_for_register(dev_priv, reg, mask, 0, 50); 823 + if (err) 824 + DRM_ERROR("Timed out waiting for PSR Idle for re-enable\n"); 825 + 826 + /* After the unlocked wait, verify that PSR is still wanted! */ 827 + mutex_lock(&dev_priv->psr.lock); 828 + return err == 0 && dev_priv->psr.enabled; 829 + } 830 + 778 831 static void intel_psr_work(struct work_struct *work) 779 832 { 780 833 struct drm_i915_private *dev_priv = 781 834 container_of(work, typeof(*dev_priv), psr.work.work); 782 - struct intel_dp *intel_dp = dev_priv->psr.enabled; 783 - struct drm_crtc *crtc = dp_to_dig_port(intel_dp)->base.base.crtc; 784 - enum pipe pipe = to_intel_crtc(crtc)->pipe; 785 835 786 - /* We have to make sure PSR is ready for re-enable 836 + mutex_lock(&dev_priv->psr.lock); 837 + 838 + /* 839 + * We have to make sure PSR is ready for re-enable 787 840 * otherwise it keeps disabled until next full enable/disable cycle. 788 841 * PSR might take some time to get fully disabled 789 842 * and be ready for re-enable. 790 843 */ 791 - if (HAS_DDI(dev_priv)) { 792 - if (dev_priv->psr.psr2_support) { 793 - if (intel_wait_for_register(dev_priv, 794 - EDP_PSR2_STATUS, 795 - EDP_PSR2_STATUS_STATE_MASK, 796 - 0, 797 - 50)) { 798 - DRM_ERROR("Timed out waiting for PSR2 Idle for re-enable\n"); 799 - return; 800 - } 801 - } else { 802 - if (intel_wait_for_register(dev_priv, 803 - EDP_PSR_STATUS, 804 - EDP_PSR_STATUS_STATE_MASK, 805 - 0, 806 - 50)) { 807 - DRM_ERROR("Timed out waiting for PSR Idle for re-enable\n"); 808 - return; 809 - } 810 - } 811 - } else { 812 - if (intel_wait_for_register(dev_priv, 813 - VLV_PSRSTAT(pipe), 814 - VLV_EDP_PSR_IN_TRANS, 815 - 0, 816 - 1)) { 817 - DRM_ERROR("Timed out waiting for PSR Idle for re-enable\n"); 818 - return; 819 - } 820 - } 821 - mutex_lock(&dev_priv->psr.lock); 822 - intel_dp = dev_priv->psr.enabled; 823 - 824 - if (!intel_dp) 844 + if (!psr_wait_for_idle(dev_priv)) 825 845 goto unlock; 826 846 827 847 /* ··· 838 846 if (dev_priv->psr.busy_frontbuffer_bits) 839 847 goto unlock; 840 848 841 - intel_psr_activate(intel_dp); 849 + intel_psr_activate(dev_priv->psr.enabled); 842 850 unlock: 843 851 mutex_unlock(&dev_priv->psr.lock); 844 852 } ··· 854 862 return; 855 863 856 864 if (HAS_DDI(dev_priv)) { 857 - if (dev_priv->psr.aux_frame_sync) 858 - drm_dp_dpcd_writeb(&intel_dp->aux, 859 - DP_SINK_DEVICE_AUX_FRAME_SYNC_CONF, 860 - 0); 861 - if (dev_priv->psr.psr2_support) { 865 + if (dev_priv->psr.psr2_enabled) { 862 866 val = I915_READ(EDP_PSR2_CTL); 863 867 WARN_ON(!(val & EDP_PSR2_ENABLE)); 864 868 I915_WRITE(EDP_PSR2_CTL, val & ~EDP_PSR2_ENABLE); ··· 945 957 * intel_psr_invalidate - Invalidade PSR 946 958 * @dev_priv: i915 device 947 959 * @frontbuffer_bits: frontbuffer plane tracking bits 960 + * @origin: which operation caused the invalidate 948 961 * 949 962 * Since the hardware frontbuffer tracking has gaps we need to integrate 950 963 * with the software frontbuffer tracking. This function gets called every ··· 955 966 * Dirty frontbuffers relevant to PSR are tracked in busy_frontbuffer_bits." 956 967 */ 957 968 void intel_psr_invalidate(struct drm_i915_private *dev_priv, 958 - unsigned frontbuffer_bits) 969 + unsigned frontbuffer_bits, enum fb_op_origin origin) 959 970 { 960 971 struct drm_crtc *crtc; 961 972 enum pipe pipe; 962 973 963 974 if (!CAN_PSR(dev_priv)) 975 + return; 976 + 977 + if (dev_priv->psr.has_hw_tracking && origin == ORIGIN_FLIP) 964 978 return; 965 979 966 980 mutex_lock(&dev_priv->psr.lock); ··· 1006 1014 if (!CAN_PSR(dev_priv)) 1007 1015 return; 1008 1016 1017 + if (dev_priv->psr.has_hw_tracking && origin == ORIGIN_FLIP) 1018 + return; 1019 + 1009 1020 mutex_lock(&dev_priv->psr.lock); 1010 1021 if (!dev_priv->psr.enabled) { 1011 1022 mutex_unlock(&dev_priv->psr.lock); ··· 1022 1027 dev_priv->psr.busy_frontbuffer_bits &= ~frontbuffer_bits; 1023 1028 1024 1029 /* By definition flush = invalidate + flush */ 1025 - if (frontbuffer_bits) 1026 - intel_psr_exit(dev_priv); 1030 + if (frontbuffer_bits) { 1031 + if (dev_priv->psr.psr2_enabled || 1032 + IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { 1033 + intel_psr_exit(dev_priv); 1034 + } else { 1035 + /* 1036 + * Display WA #0884: all 1037 + * This documented WA for bxt can be safely applied 1038 + * broadly so we can force HW tracking to exit PSR 1039 + * instead of disabling and re-enabling. 1040 + * Workaround tells us to write 0 to CUR_SURFLIVE_A, 1041 + * but it makes more sense write to the current active 1042 + * pipe. 1043 + */ 1044 + I915_WRITE(CURSURFLIVE(pipe), 0); 1045 + } 1046 + } 1027 1047 1028 1048 if (!dev_priv->psr.active && !dev_priv->psr.busy_frontbuffer_bits) 1029 1049 if (!work_busy(&dev_priv->psr.work.work)) ··· 1100 1090 dev_priv->psr.activate = vlv_psr_activate; 1101 1091 dev_priv->psr.setup_vsc = vlv_psr_setup_vsc; 1102 1092 } else { 1093 + dev_priv->psr.has_hw_tracking = true; 1103 1094 dev_priv->psr.enable_source = hsw_psr_enable_source; 1104 1095 dev_priv->psr.disable_source = hsw_psr_disable; 1105 1096 dev_priv->psr.enable_sink = hsw_psr_enable_sink;
+14 -8
drivers/gpu/drm/i915/intel_ringbuffer.c
··· 36 36 #include "i915_gem_render_state.h" 37 37 #include "i915_trace.h" 38 38 #include "intel_drv.h" 39 + #include "intel_workarounds.h" 39 40 40 41 /* Rough estimate of the typical request size, performing a flush, 41 42 * set-context and then emitting the batch. ··· 600 599 { 601 600 int ret; 602 601 603 - ret = intel_ring_workarounds_emit(rq); 602 + ret = intel_ctx_workarounds_emit(rq); 604 603 if (ret != 0) 605 604 return ret; 606 605 ··· 615 614 { 616 615 struct drm_i915_private *dev_priv = engine->i915; 617 616 int ret = init_ring_common(engine); 617 + if (ret) 618 + return ret; 619 + 620 + ret = intel_whitelist_workarounds_apply(engine); 618 621 if (ret) 619 622 return ret; 620 623 ··· 663 658 if (INTEL_GEN(dev_priv) >= 6) 664 659 I915_WRITE_IMR(engine, ~engine->irq_keep_mask); 665 660 666 - return init_workarounds_ring(engine); 661 + return 0; 667 662 } 668 663 669 664 static u32 *gen6_signal(struct i915_request *rq, u32 *cs) ··· 1598 1593 if (intel_ring_update_space(ring) >= bytes) 1599 1594 return 0; 1600 1595 1596 + GEM_BUG_ON(list_empty(&ring->request_list)); 1601 1597 list_for_each_entry(target, &ring->request_list, ring_link) { 1602 1598 /* Would completion of this request free enough space? */ 1603 1599 if (bytes <= __intel_ring_space(target->postfix, ··· 1698 1692 need_wrap &= ~1; 1699 1693 GEM_BUG_ON(need_wrap > ring->space); 1700 1694 GEM_BUG_ON(ring->emit + need_wrap > ring->size); 1695 + GEM_BUG_ON(!IS_ALIGNED(need_wrap, sizeof(u64))); 1701 1696 1702 1697 /* Fill the tail with MI_NOOP */ 1703 - memset(ring->vaddr + ring->emit, 0, need_wrap); 1704 - ring->emit = 0; 1698 + memset64(ring->vaddr + ring->emit, 0, need_wrap / sizeof(u64)); 1705 1699 ring->space -= need_wrap; 1700 + ring->emit = 0; 1706 1701 } 1707 1702 1708 1703 GEM_BUG_ON(ring->emit > ring->size - bytes); 1709 1704 GEM_BUG_ON(ring->space < bytes); 1710 1705 cs = ring->vaddr + ring->emit; 1711 - GEM_DEBUG_EXEC(memset(cs, POISON_INUSE, bytes)); 1706 + GEM_DEBUG_EXEC(memset32(cs, POISON_INUSE, bytes / sizeof(*cs))); 1712 1707 ring->emit += bytes; 1713 1708 ring->space -= bytes; 1714 1709 ··· 1950 1943 static void intel_ring_init_irq(struct drm_i915_private *dev_priv, 1951 1944 struct intel_engine_cs *engine) 1952 1945 { 1953 - engine->irq_enable_mask = GT_RENDER_USER_INTERRUPT << engine->irq_shift; 1954 - 1955 1946 if (INTEL_GEN(dev_priv) >= 6) { 1956 1947 engine->irq_enable = gen6_irq_enable; 1957 1948 engine->irq_disable = gen6_irq_disable; ··· 2034 2029 if (HAS_L3_DPF(dev_priv)) 2035 2030 engine->irq_keep_mask = GT_RENDER_L3_PARITY_ERROR_INTERRUPT; 2036 2031 2032 + engine->irq_enable_mask = GT_RENDER_USER_INTERRUPT; 2033 + 2037 2034 if (INTEL_GEN(dev_priv) >= 6) { 2038 2035 engine->init_context = intel_rcs_ctx_init; 2039 2036 engine->emit_flush = gen7_render_ring_flush; ··· 2086 2079 engine->emit_flush = gen6_bsd_ring_flush; 2087 2080 engine->irq_enable_mask = GT_BSD_USER_INTERRUPT; 2088 2081 } else { 2089 - engine->mmio_base = BSD_RING_BASE; 2090 2082 engine->emit_flush = bsd_ring_flush; 2091 2083 if (IS_GEN5(dev_priv)) 2092 2084 engine->irq_enable_mask = ILK_BSD_USER_INTERRUPT;
+34 -9
drivers/gpu/drm/i915/intel_ringbuffer.h
··· 7 7 #include "i915_gem_batch_pool.h" 8 8 #include "i915_gem_timeline.h" 9 9 10 + #include "i915_reg.h" 10 11 #include "i915_pmu.h" 11 12 #include "i915_request.h" 12 13 #include "i915_selftest.h" 14 + #include "intel_gpu_commands.h" 13 15 14 16 struct drm_printer; 15 17 ··· 86 84 } 87 85 88 86 #define I915_MAX_SLICES 3 89 - #define I915_MAX_SUBSLICES 3 87 + #define I915_MAX_SUBSLICES 8 90 88 91 89 #define instdone_slice_mask(dev_priv__) \ 92 90 (INTEL_GEN(dev_priv__) == 7 ? \ ··· 332 330 u8 instance; 333 331 u32 context_size; 334 332 u32 mmio_base; 335 - unsigned int irq_shift; 336 333 337 334 struct intel_ring *buffer; 338 335 struct intel_timeline *timeline; ··· 562 561 563 562 #define I915_ENGINE_NEEDS_CMD_PARSER BIT(0) 564 563 #define I915_ENGINE_SUPPORTS_STATS BIT(1) 564 + #define I915_ENGINE_HAS_PREEMPTION BIT(2) 565 565 unsigned int flags; 566 566 567 567 /* ··· 622 620 } stats; 623 621 }; 624 622 625 - static inline bool intel_engine_needs_cmd_parser(struct intel_engine_cs *engine) 623 + static inline bool 624 + intel_engine_needs_cmd_parser(const struct intel_engine_cs *engine) 626 625 { 627 626 return engine->flags & I915_ENGINE_NEEDS_CMD_PARSER; 628 627 } 629 628 630 - static inline bool intel_engine_supports_stats(struct intel_engine_cs *engine) 629 + static inline bool 630 + intel_engine_supports_stats(const struct intel_engine_cs *engine) 631 631 { 632 632 return engine->flags & I915_ENGINE_SUPPORTS_STATS; 633 + } 634 + 635 + static inline bool 636 + intel_engine_has_preemption(const struct intel_engine_cs *engine) 637 + { 638 + return engine->flags & I915_ENGINE_HAS_PREEMPTION; 639 + } 640 + 641 + static inline bool __execlists_need_preempt(int prio, int last) 642 + { 643 + return prio > max(0, last); 633 644 } 634 645 635 646 static inline void ··· 650 635 unsigned int bit) 651 636 { 652 637 __set_bit(bit, (unsigned long *)&execlists->active); 638 + } 639 + 640 + static inline bool 641 + execlists_set_active_once(struct intel_engine_execlists *execlists, 642 + unsigned int bit) 643 + { 644 + return !__test_and_set_bit(bit, (unsigned long *)&execlists->active); 653 645 } 654 646 655 647 static inline void ··· 673 651 return test_bit(bit, (unsigned long *)&execlists->active); 674 652 } 675 653 654 + void execlists_user_begin(struct intel_engine_execlists *execlists, 655 + const struct execlist_port *port); 656 + void execlists_user_end(struct intel_engine_execlists *execlists); 657 + 676 658 void 677 659 execlists_cancel_port_requests(struct intel_engine_execlists * const execlists); 678 660 ··· 689 663 return execlists->port_mask + 1; 690 664 } 691 665 692 - static inline void 666 + static inline struct execlist_port * 693 667 execlists_port_complete(struct intel_engine_execlists * const execlists, 694 668 struct execlist_port * const port) 695 669 { ··· 700 674 701 675 memmove(port, port + 1, m * sizeof(struct execlist_port)); 702 676 memset(port + m, 0, sizeof(struct execlist_port)); 677 + 678 + return port; 703 679 } 704 680 705 681 static inline unsigned int ··· 885 857 return READ_ONCE(engine->timeline->seqno); 886 858 } 887 859 888 - int init_workarounds_ring(struct intel_engine_cs *engine); 889 - int intel_ring_workarounds_emit(struct i915_request *rq); 890 - 891 860 void intel_engine_get_instdone(struct intel_engine_cs *engine, 892 861 struct intel_instdone *instdone); 893 862 ··· 964 939 struct intel_wait *wait); 965 940 void intel_engine_remove_wait(struct intel_engine_cs *engine, 966 941 struct intel_wait *wait); 967 - void intel_engine_enable_signaling(struct i915_request *request, bool wakeup); 942 + bool intel_engine_enable_signaling(struct i915_request *request, bool wakeup); 968 943 void intel_engine_cancel_signaling(struct i915_request *request); 969 944 970 945 static inline bool intel_engine_has_waiter(const struct intel_engine_cs *engine)
+6 -1
drivers/gpu/drm/i915/intel_sprite.c
··· 48 48 case DRM_FORMAT_UYVY: 49 49 case DRM_FORMAT_VYUY: 50 50 case DRM_FORMAT_YVYU: 51 + case DRM_FORMAT_NV12: 51 52 return true; 52 53 default: 53 54 return false; ··· 947 946 int max_scale, min_scale; 948 947 bool can_scale; 949 948 int ret; 949 + uint32_t pixel_format = 0; 950 950 951 951 *src = drm_plane_state_src(&state->base); 952 952 *dst = drm_plane_state_dest(&state->base); ··· 971 969 972 970 /* setup can_scale, min_scale, max_scale */ 973 971 if (INTEL_GEN(dev_priv) >= 9) { 972 + if (state->base.fb) 973 + pixel_format = state->base.fb->format->format; 974 974 /* use scaler when colorkey is not required */ 975 975 if (!state->ckey.flags) { 976 976 can_scale = 1; 977 977 min_scale = 1; 978 - max_scale = skl_max_scale(crtc, crtc_state); 978 + max_scale = 979 + skl_max_scale(crtc, crtc_state, pixel_format); 979 980 } else { 980 981 can_scale = 0; 981 982 min_scale = DRM_PLANE_HELPER_NO_SCALING;
+69 -69
drivers/gpu/drm/i915/intel_uc.c
··· 69 69 70 70 static int __get_default_guc_log_level(struct drm_i915_private *dev_priv) 71 71 { 72 - int guc_log_level = 0; /* disabled */ 72 + int guc_log_level; 73 73 74 - /* Enable if we're running on platform with GuC and debug config */ 75 - if (HAS_GUC(dev_priv) && intel_uc_is_using_guc() && 76 - (IS_ENABLED(CONFIG_DRM_I915_DEBUG) || 77 - IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM))) 78 - guc_log_level = 1 + GUC_LOG_VERBOSITY_MAX; 74 + if (!HAS_GUC(dev_priv) || !intel_uc_is_using_guc()) 75 + guc_log_level = GUC_LOG_LEVEL_DISABLED; 76 + else if (IS_ENABLED(CONFIG_DRM_I915_DEBUG) || 77 + IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM)) 78 + guc_log_level = GUC_LOG_LEVEL_MAX; 79 + else 80 + guc_log_level = GUC_LOG_LEVEL_NON_VERBOSE; 79 81 80 82 /* Any platform specific fine-tuning can be done here */ 81 83 ··· 85 83 } 86 84 87 85 /** 88 - * intel_uc_sanitize_options - sanitize uC related modparam options 86 + * sanitize_options_early - sanitize uC related modparam options 89 87 * @dev_priv: device private 90 88 * 91 89 * In case of "enable_guc" option this function will attempt to modify ··· 101 99 * unless GuC is enabled on given platform and the driver is compiled with 102 100 * debug config when this modparam will default to "enable(1..4)". 103 101 */ 104 - void intel_uc_sanitize_options(struct drm_i915_private *dev_priv) 102 + static void sanitize_options_early(struct drm_i915_private *dev_priv) 105 103 { 106 104 struct intel_uc_fw *guc_fw = &dev_priv->guc.fw; 107 105 struct intel_uc_fw *huc_fw = &dev_priv->huc.fw; ··· 144 142 i915_modparams.guc_log_level = 0; 145 143 } 146 144 147 - if (i915_modparams.guc_log_level > 1 + GUC_LOG_VERBOSITY_MAX) { 145 + if (i915_modparams.guc_log_level > GUC_LOG_LEVEL_MAX) { 148 146 DRM_WARN("Incompatible option detected: %s=%d, %s!\n", 149 147 "guc_log_level", i915_modparams.guc_log_level, 150 148 "verbosity too high"); 151 - i915_modparams.guc_log_level = 1 + GUC_LOG_VERBOSITY_MAX; 149 + i915_modparams.guc_log_level = GUC_LOG_LEVEL_MAX; 152 150 } 153 151 154 - DRM_DEBUG_DRIVER("guc_log_level=%d (enabled:%s verbosity:%d)\n", 152 + DRM_DEBUG_DRIVER("guc_log_level=%d (enabled:%s, verbose:%s, verbosity:%d)\n", 155 153 i915_modparams.guc_log_level, 156 154 yesno(i915_modparams.guc_log_level), 157 - i915_modparams.guc_log_level - 1); 155 + yesno(GUC_LOG_LEVEL_IS_VERBOSE(i915_modparams.guc_log_level)), 156 + GUC_LOG_LEVEL_TO_VERBOSITY(i915_modparams.guc_log_level)); 158 157 159 158 /* Make sure that sanitization was done */ 160 159 GEM_BUG_ON(i915_modparams.enable_guc < 0); 161 160 GEM_BUG_ON(i915_modparams.guc_log_level < 0); 162 161 } 163 162 164 - void intel_uc_init_early(struct drm_i915_private *dev_priv) 163 + void intel_uc_init_early(struct drm_i915_private *i915) 165 164 { 166 - intel_guc_init_early(&dev_priv->guc); 167 - intel_huc_init_early(&dev_priv->huc); 165 + struct intel_guc *guc = &i915->guc; 166 + struct intel_huc *huc = &i915->huc; 167 + 168 + intel_guc_init_early(guc); 169 + intel_huc_init_early(huc); 170 + 171 + sanitize_options_early(i915); 172 + 173 + if (USES_GUC(i915)) 174 + intel_uc_fw_fetch(i915, &guc->fw); 175 + 176 + if (USES_HUC(i915)) 177 + intel_uc_fw_fetch(i915, &huc->fw); 168 178 } 169 179 170 - void intel_uc_init_fw(struct drm_i915_private *dev_priv) 180 + void intel_uc_cleanup_early(struct drm_i915_private *i915) 171 181 { 172 - if (!USES_GUC(dev_priv)) 173 - return; 182 + struct intel_guc *guc = &i915->guc; 183 + struct intel_huc *huc = &i915->huc; 174 184 175 - if (USES_HUC(dev_priv)) 176 - intel_uc_fw_fetch(dev_priv, &dev_priv->huc.fw); 185 + if (USES_HUC(i915)) 186 + intel_uc_fw_fini(&huc->fw); 177 187 178 - intel_uc_fw_fetch(dev_priv, &dev_priv->guc.fw); 179 - } 188 + if (USES_GUC(i915)) 189 + intel_uc_fw_fini(&guc->fw); 180 190 181 - void intel_uc_fini_fw(struct drm_i915_private *dev_priv) 182 - { 183 - if (!USES_GUC(dev_priv)) 184 - return; 185 - 186 - intel_uc_fw_fini(&dev_priv->guc.fw); 187 - 188 - if (USES_HUC(dev_priv)) 189 - intel_uc_fw_fini(&dev_priv->huc.fw); 190 - 191 - guc_free_load_err_log(&dev_priv->guc); 191 + guc_free_load_err_log(guc); 192 192 } 193 193 194 194 /** ··· 227 223 { 228 224 struct drm_i915_private *dev_priv = guc_to_i915(guc); 229 225 226 + gen9_enable_guc_interrupts(dev_priv); 227 + 230 228 if (HAS_GUC_CT(dev_priv)) 231 - return intel_guc_enable_ct(guc); 229 + return intel_guc_ct_enable(&guc->ct); 232 230 233 231 guc->send = intel_guc_send_mmio; 232 + guc->handler = intel_guc_to_host_event_handler_mmio; 234 233 return 0; 235 234 } 236 235 ··· 242 235 struct drm_i915_private *dev_priv = guc_to_i915(guc); 243 236 244 237 if (HAS_GUC_CT(dev_priv)) 245 - intel_guc_disable_ct(guc); 238 + intel_guc_ct_disable(&guc->ct); 239 + 240 + gen9_disable_guc_interrupts(dev_priv); 246 241 247 242 guc->send = intel_guc_send_nop; 243 + guc->handler = intel_guc_to_host_event_handler_nop; 248 244 } 249 245 250 246 int intel_uc_init_misc(struct drm_i915_private *dev_priv) ··· 258 248 if (!USES_GUC(dev_priv)) 259 249 return 0; 260 250 261 - ret = intel_guc_init_wq(guc); 262 - if (ret) { 263 - DRM_ERROR("Couldn't allocate workqueues for GuC\n"); 264 - goto err; 265 - } 251 + intel_guc_init_ggtt_pin_bias(guc); 266 252 267 - ret = intel_guc_log_relay_create(guc); 268 - if (ret) { 269 - DRM_ERROR("Couldn't allocate relay for GuC log\n"); 270 - goto err_relay; 271 - } 253 + ret = intel_guc_init_wq(guc); 254 + if (ret) 255 + return ret; 272 256 273 257 return 0; 274 - 275 - err_relay: 276 - intel_guc_fini_wq(guc); 277 - err: 278 - return ret; 279 258 } 280 259 281 260 void intel_uc_fini_misc(struct drm_i915_private *dev_priv) ··· 275 276 return; 276 277 277 278 intel_guc_fini_wq(guc); 278 - 279 - intel_guc_log_relay_destroy(guc); 280 279 } 281 280 282 281 int intel_uc_init(struct drm_i915_private *dev_priv) ··· 322 325 intel_guc_fini(guc); 323 326 } 324 327 328 + void intel_uc_sanitize(struct drm_i915_private *i915) 329 + { 330 + struct intel_guc *guc = &i915->guc; 331 + struct intel_huc *huc = &i915->huc; 332 + 333 + if (!USES_GUC(i915)) 334 + return; 335 + 336 + GEM_BUG_ON(!HAS_GUC(i915)); 337 + 338 + guc_disable_communication(guc); 339 + 340 + intel_huc_sanitize(huc); 341 + intel_guc_sanitize(guc); 342 + 343 + __intel_uc_reset_hw(i915); 344 + } 345 + 325 346 int intel_uc_init_hw(struct drm_i915_private *dev_priv) 326 347 { 327 348 struct intel_guc *guc = &dev_priv->guc; ··· 351 336 352 337 GEM_BUG_ON(!HAS_GUC(dev_priv)); 353 338 354 - guc_disable_communication(guc); 355 339 gen9_reset_guc_interrupts(dev_priv); 356 - 357 - /* init WOPCM */ 358 - I915_WRITE(GUC_WOPCM_SIZE, intel_guc_wopcm_size(dev_priv)); 359 - I915_WRITE(DMA_GUC_WOPCM_OFFSET, 360 - GUC_WOPCM_OFFSET_VALUE | HUC_LOADING_AGENT_GUC); 361 340 362 341 /* WaEnableuKernelHeaderValidFix:skl */ 363 342 /* WaEnableGuCBootHashCheckNotSet:skl,bxt,kbl */ ··· 399 390 } 400 391 401 392 if (USES_GUC_SUBMISSION(dev_priv)) { 402 - if (i915_modparams.guc_log_level) 403 - gen9_enable_guc_interrupts(dev_priv); 404 - 405 393 ret = intel_guc_submission_enable(guc); 406 394 if (ret) 407 - goto err_interrupts; 395 + goto err_communication; 408 396 } 409 397 410 398 dev_info(dev_priv->drm.dev, "GuC firmware version %u.%u\n", ··· 416 410 /* 417 411 * We've failed to load the firmware :( 418 412 */ 419 - err_interrupts: 420 - gen9_disable_guc_interrupts(dev_priv); 421 413 err_communication: 422 414 guc_disable_communication(guc); 423 415 err_log_capture: ··· 445 441 intel_guc_submission_disable(guc); 446 442 447 443 guc_disable_communication(guc); 448 - 449 - if (USES_GUC_SUBMISSION(dev_priv)) 450 - gen9_disable_guc_interrupts(dev_priv); 451 444 } 452 445 453 446 int intel_uc_suspend(struct drm_i915_private *i915) ··· 480 479 if (guc->fw.load_status != INTEL_UC_FIRMWARE_SUCCESS) 481 480 return 0; 482 481 483 - if (i915_modparams.guc_log_level) 484 - gen9_enable_guc_interrupts(i915); 482 + gen9_enable_guc_interrupts(i915); 485 483 486 484 err = intel_guc_resume(guc); 487 485 if (err) {
+2 -3
drivers/gpu/drm/i915/intel_uc.h
··· 28 28 #include "intel_huc.h" 29 29 #include "i915_params.h" 30 30 31 - void intel_uc_sanitize_options(struct drm_i915_private *dev_priv); 32 31 void intel_uc_init_early(struct drm_i915_private *dev_priv); 32 + void intel_uc_cleanup_early(struct drm_i915_private *dev_priv); 33 33 void intel_uc_init_mmio(struct drm_i915_private *dev_priv); 34 - void intel_uc_init_fw(struct drm_i915_private *dev_priv); 35 - void intel_uc_fini_fw(struct drm_i915_private *dev_priv); 36 34 int intel_uc_init_misc(struct drm_i915_private *dev_priv); 37 35 void intel_uc_fini_misc(struct drm_i915_private *dev_priv); 36 + void intel_uc_sanitize(struct drm_i915_private *dev_priv); 38 37 int intel_uc_init_hw(struct drm_i915_private *dev_priv); 39 38 void intel_uc_fini_hw(struct drm_i915_private *dev_priv); 40 39 int intel_uc_init(struct drm_i915_private *dev_priv);
+3 -10
drivers/gpu/drm/i915/intel_uc_fw.c
··· 95 95 uc_fw->ucode_offset = uc_fw->header_offset + uc_fw->header_size; 96 96 uc_fw->ucode_size = (css->size_dw - css->header_size_dw) * sizeof(u32); 97 97 98 - /* Header and uCode will be loaded to WOPCM */ 99 - size = uc_fw->header_size + uc_fw->ucode_size; 100 - if (size > intel_guc_wopcm_size(dev_priv)) { 101 - DRM_WARN("%s: Firmware is too large to fit in WOPCM\n", 102 - intel_uc_fw_type_repr(uc_fw->type)); 103 - err = -E2BIG; 104 - goto fail; 105 - } 106 - 107 98 /* now RSA */ 108 99 if (css->key_size_dw != UOS_RSA_SCRATCH_COUNT) { 109 100 DRM_WARN("%s: Mismatched firmware RSA key size (%u)\n", ··· 200 209 struct i915_vma *vma)) 201 210 { 202 211 struct i915_vma *vma; 212 + u32 ggtt_pin_bias; 203 213 int err; 204 214 205 215 DRM_DEBUG_DRIVER("%s fw load %s\n", ··· 222 230 goto fail; 223 231 } 224 232 233 + ggtt_pin_bias = to_i915(uc_fw->obj->base.dev)->guc.ggtt_pin_bias; 225 234 vma = i915_gem_object_ggtt_pin(uc_fw->obj, NULL, 0, 0, 226 - PIN_OFFSET_BIAS | GUC_WOPCM_TOP); 235 + PIN_OFFSET_BIAS | ggtt_pin_bias); 227 236 if (IS_ERR(vma)) { 228 237 err = PTR_ERR(vma); 229 238 DRM_DEBUG_DRIVER("%s fw ggtt-pin err=%d\n",
+22
drivers/gpu/drm/i915/intel_uc_fw.h
··· 115 115 return uc_fw->path != NULL; 116 116 } 117 117 118 + static inline void intel_uc_fw_sanitize(struct intel_uc_fw *uc_fw) 119 + { 120 + if (uc_fw->load_status == INTEL_UC_FIRMWARE_SUCCESS) 121 + uc_fw->load_status = INTEL_UC_FIRMWARE_PENDING; 122 + } 123 + 124 + /** 125 + * intel_uc_fw_get_upload_size() - Get size of firmware needed to be uploaded. 126 + * @uc_fw: uC firmware. 127 + * 128 + * Get the size of the firmware and header that will be uploaded to WOPCM. 129 + * 130 + * Return: Upload firmware size, or zero on firmware fetch failure. 131 + */ 132 + static inline u32 intel_uc_fw_get_upload_size(struct intel_uc_fw *uc_fw) 133 + { 134 + if (uc_fw->fetch_status != INTEL_UC_FIRMWARE_SUCCESS) 135 + return 0; 136 + 137 + return uc_fw->header_size + uc_fw->ucode_size; 138 + } 139 + 118 140 void intel_uc_fw_fetch(struct drm_i915_private *dev_priv, 119 141 struct intel_uc_fw *uc_fw); 120 142 int intel_uc_fw_upload(struct intel_uc_fw *uc_fw,
+146 -22
drivers/gpu/drm/i915/intel_uncore.c
··· 62 62 fw_domain_reset(struct drm_i915_private *i915, 63 63 const struct intel_uncore_forcewake_domain *d) 64 64 { 65 + /* 66 + * We don't really know if the powerwell for the forcewake domain we are 67 + * trying to reset here does exist at this point (engines could be fused 68 + * off in ICL+), so no waiting for acks 69 + */ 65 70 __raw_i915_write32(i915, d->reg_set, i915->uncore.fw_reset); 66 71 } 67 72 ··· 1358 1353 fw_domain_reset(dev_priv, d); 1359 1354 } 1360 1355 1356 + static void fw_domain_fini(struct drm_i915_private *dev_priv, 1357 + enum forcewake_domain_id domain_id) 1358 + { 1359 + struct intel_uncore_forcewake_domain *d; 1360 + 1361 + if (WARN_ON(domain_id >= FW_DOMAIN_ID_COUNT)) 1362 + return; 1363 + 1364 + d = &dev_priv->uncore.fw_domain[domain_id]; 1365 + 1366 + WARN_ON(d->wake_count); 1367 + WARN_ON(hrtimer_cancel(&d->timer)); 1368 + memset(d, 0, sizeof(*d)); 1369 + 1370 + dev_priv->uncore.fw_domains &= ~BIT(domain_id); 1371 + } 1372 + 1361 1373 static void intel_uncore_fw_domains_init(struct drm_i915_private *dev_priv) 1362 1374 { 1363 1375 if (INTEL_GEN(dev_priv) <= 5 || intel_vgpu_active(dev_priv)) ··· 1587 1565 &dev_priv->uncore.pmic_bus_access_nb); 1588 1566 } 1589 1567 1568 + /* 1569 + * We might have detected that some engines are fused off after we initialized 1570 + * the forcewake domains. Prune them, to make sure they only reference existing 1571 + * engines. 1572 + */ 1573 + void intel_uncore_prune(struct drm_i915_private *dev_priv) 1574 + { 1575 + if (INTEL_GEN(dev_priv) >= 11) { 1576 + enum forcewake_domains fw_domains = dev_priv->uncore.fw_domains; 1577 + enum forcewake_domain_id domain_id; 1578 + int i; 1579 + 1580 + for (i = 0; i < I915_MAX_VCS; i++) { 1581 + domain_id = FW_DOMAIN_ID_MEDIA_VDBOX0 + i; 1582 + 1583 + if (HAS_ENGINE(dev_priv, _VCS(i))) 1584 + continue; 1585 + 1586 + if (fw_domains & BIT(domain_id)) 1587 + fw_domain_fini(dev_priv, domain_id); 1588 + } 1589 + 1590 + for (i = 0; i < I915_MAX_VECS; i++) { 1591 + domain_id = FW_DOMAIN_ID_MEDIA_VEBOX0 + i; 1592 + 1593 + if (HAS_ENGINE(dev_priv, _VECS(i))) 1594 + continue; 1595 + 1596 + if (fw_domains & BIT(domain_id)) 1597 + fw_domain_fini(dev_priv, domain_id); 1598 + } 1599 + } 1600 + } 1601 + 1590 1602 void intel_uncore_fini(struct drm_i915_private *dev_priv) 1591 1603 { 1592 1604 /* Paranoia: make sure we have disabled everything before we exit. */ ··· 1702 1646 const i915_reg_t mode = RING_MI_MODE(base); 1703 1647 1704 1648 I915_WRITE_FW(mode, _MASKED_BIT_ENABLE(STOP_RING)); 1705 - if (intel_wait_for_register_fw(dev_priv, 1706 - mode, 1707 - MODE_IDLE, 1708 - MODE_IDLE, 1709 - 500)) 1649 + if (__intel_wait_for_register_fw(dev_priv, 1650 + mode, MODE_IDLE, MODE_IDLE, 1651 + 500, 0, 1652 + NULL)) 1710 1653 DRM_DEBUG_DRIVER("%s: timed out on STOP_RING\n", 1711 1654 engine->name); 1712 1655 ··· 1859 1804 __raw_i915_write32(dev_priv, GEN6_GDRST, hw_domain_mask); 1860 1805 1861 1806 /* Wait for the device to ack the reset requests */ 1862 - err = intel_wait_for_register_fw(dev_priv, 1863 - GEN6_GDRST, hw_domain_mask, 0, 1864 - 500); 1807 + err = __intel_wait_for_register_fw(dev_priv, 1808 + GEN6_GDRST, hw_domain_mask, 0, 1809 + 500, 0, 1810 + NULL); 1865 1811 if (err) 1866 1812 DRM_DEBUG_DRIVER("Wait for 0x%08x engines reset failed\n", 1867 1813 hw_domain_mask); ··· 1898 1842 1899 1843 if (engine_mask == ALL_ENGINES) { 1900 1844 hw_mask = GEN6_GRDOM_FULL; 1845 + } else { 1846 + unsigned int tmp; 1847 + 1848 + hw_mask = 0; 1849 + for_each_engine_masked(engine, dev_priv, engine_mask, tmp) 1850 + hw_mask |= hw_engine_mask[engine->id]; 1851 + } 1852 + 1853 + return gen6_hw_domain_reset(dev_priv, hw_mask); 1854 + } 1855 + 1856 + /** 1857 + * gen11_reset_engines - reset individual engines 1858 + * @dev_priv: i915 device 1859 + * @engine_mask: mask of intel_ring_flag() engines or ALL_ENGINES for full reset 1860 + * 1861 + * This function will reset the individual engines that are set in engine_mask. 1862 + * If you provide ALL_ENGINES as mask, full global domain reset will be issued. 1863 + * 1864 + * Note: It is responsibility of the caller to handle the difference between 1865 + * asking full domain reset versus reset for all available individual engines. 1866 + * 1867 + * Returns 0 on success, nonzero on error. 1868 + */ 1869 + static int gen11_reset_engines(struct drm_i915_private *dev_priv, 1870 + unsigned engine_mask) 1871 + { 1872 + struct intel_engine_cs *engine; 1873 + const u32 hw_engine_mask[I915_NUM_ENGINES] = { 1874 + [RCS] = GEN11_GRDOM_RENDER, 1875 + [BCS] = GEN11_GRDOM_BLT, 1876 + [VCS] = GEN11_GRDOM_MEDIA, 1877 + [VCS2] = GEN11_GRDOM_MEDIA2, 1878 + [VCS3] = GEN11_GRDOM_MEDIA3, 1879 + [VCS4] = GEN11_GRDOM_MEDIA4, 1880 + [VECS] = GEN11_GRDOM_VECS, 1881 + [VECS2] = GEN11_GRDOM_VECS2, 1882 + }; 1883 + u32 hw_mask; 1884 + 1885 + BUILD_BUG_ON(VECS2 + 1 != I915_NUM_ENGINES); 1886 + 1887 + if (engine_mask == ALL_ENGINES) { 1888 + hw_mask = GEN11_GRDOM_FULL; 1901 1889 } else { 1902 1890 unsigned int tmp; 1903 1891 ··· 2040 1940 u32 reg_value; 2041 1941 int ret; 2042 1942 2043 - might_sleep(); 1943 + might_sleep_if(slow_timeout_ms); 2044 1944 2045 1945 spin_lock_irq(&dev_priv->uncore.lock); 2046 1946 intel_uncore_forcewake_get__locked(dev_priv, fw); ··· 2052 1952 intel_uncore_forcewake_put__locked(dev_priv, fw); 2053 1953 spin_unlock_irq(&dev_priv->uncore.lock); 2054 1954 2055 - if (ret) 1955 + if (ret && slow_timeout_ms) 2056 1956 ret = __wait_for(reg_value = I915_READ_NOTRACE(reg), 2057 1957 (reg_value & mask) == value, 2058 1958 slow_timeout_ms * 1000, 10, 1000); ··· 2071 1971 I915_WRITE_FW(RING_RESET_CTL(engine->mmio_base), 2072 1972 _MASKED_BIT_ENABLE(RESET_CTL_REQUEST_RESET)); 2073 1973 2074 - ret = intel_wait_for_register_fw(dev_priv, 2075 - RING_RESET_CTL(engine->mmio_base), 2076 - RESET_CTL_READY_TO_RESET, 2077 - RESET_CTL_READY_TO_RESET, 2078 - 700); 1974 + ret = __intel_wait_for_register_fw(dev_priv, 1975 + RING_RESET_CTL(engine->mmio_base), 1976 + RESET_CTL_READY_TO_RESET, 1977 + RESET_CTL_READY_TO_RESET, 1978 + 700, 0, 1979 + NULL); 2079 1980 if (ret) 2080 1981 DRM_ERROR("%s: reset request timeout\n", engine->name); 2081 1982 ··· 2101 2000 if (gen8_reset_engine_start(engine)) 2102 2001 goto not_ready; 2103 2002 2104 - return gen6_reset_engines(dev_priv, engine_mask); 2003 + if (INTEL_GEN(dev_priv) >= 11) 2004 + return gen11_reset_engines(dev_priv, engine_mask); 2005 + else 2006 + return gen6_reset_engines(dev_priv, engine_mask); 2105 2007 2106 2008 not_ready: 2107 2009 for_each_engine_masked(engine, dev_priv, engine_mask, tmp) ··· 2142 2038 int retry; 2143 2039 int ret; 2144 2040 2145 - might_sleep(); 2041 + /* 2042 + * We want to perform per-engine reset from atomic context (e.g. 2043 + * softirq), which imposes the constraint that we cannot sleep. 2044 + * However, experience suggests that spending a bit of time waiting 2045 + * for a reset helps in various cases, so for a full-device reset 2046 + * we apply the opposite rule and wait if we want to. As we should 2047 + * always follow up a failed per-engine reset with a full device reset, 2048 + * being a little faster, stricter and more error prone for the 2049 + * atomic case seems an acceptable compromise. 2050 + * 2051 + * Unfortunately this leads to a bimodal routine, when the goal was 2052 + * to have a single reset function that worked for resetting any 2053 + * number of engines simultaneously. 2054 + */ 2055 + might_sleep_if(engine_mask == ALL_ENGINES); 2146 2056 2147 - /* If the power well sleeps during the reset, the reset 2057 + /* 2058 + * If the power well sleeps during the reset, the reset 2148 2059 * request may be dropped and never completes (causing -EIO). 2149 2060 */ 2150 2061 intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); 2151 2062 for (retry = 0; retry < 3; retry++) { 2152 2063 2153 - /* We stop engines, otherwise we might get failed reset and a 2064 + /* 2065 + * We stop engines, otherwise we might get failed reset and a 2154 2066 * dead gpu (on elk). Also as modern gpu as kbl can suffer 2155 2067 * from system hang if batchbuffer is progressing when 2156 2068 * the reset is issued, regardless of READY_TO_RESET ack. ··· 2180 2060 i915_stop_engines(dev_priv, engine_mask); 2181 2061 2182 2062 ret = -ENODEV; 2183 - if (reset) 2063 + if (reset) { 2064 + GEM_TRACE("engine_mask=%x\n", engine_mask); 2184 2065 ret = reset(dev_priv, engine_mask); 2185 - if (ret != -ETIMEDOUT) 2066 + } 2067 + if (ret != -ETIMEDOUT || engine_mask != ALL_ENGINES) 2186 2068 break; 2187 2069 2188 2070 cond_resched(); ··· 2207 2085 2208 2086 int intel_reset_guc(struct drm_i915_private *dev_priv) 2209 2087 { 2088 + u32 guc_domain = INTEL_GEN(dev_priv) >= 11 ? GEN11_GRDOM_GUC : 2089 + GEN9_GRDOM_GUC; 2210 2090 int ret; 2211 2091 2212 2092 GEM_BUG_ON(!HAS_GUC(dev_priv)); 2213 2093 2214 2094 intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); 2215 - ret = gen6_hw_domain_reset(dev_priv, GEN9_GRDOM_GUC); 2095 + ret = gen6_hw_domain_reset(dev_priv, guc_domain); 2216 2096 intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); 2217 2097 2218 2098 return ret;
+1
drivers/gpu/drm/i915/intel_uncore.h
··· 140 140 141 141 void intel_uncore_sanitize(struct drm_i915_private *dev_priv); 142 142 void intel_uncore_init(struct drm_i915_private *dev_priv); 143 + void intel_uncore_prune(struct drm_i915_private *dev_priv); 143 144 bool intel_uncore_unclaimed_mmio(struct drm_i915_private *dev_priv); 144 145 bool intel_uncore_arm_unclaimed_mmio_detection(struct drm_i915_private *dev_priv); 145 146 void intel_uncore_fini(struct drm_i915_private *dev_priv);
+275
drivers/gpu/drm/i915/intel_wopcm.c
··· 1 + /* 2 + * SPDX-License-Identifier: MIT 3 + * 4 + * Copyright © 2017-2018 Intel Corporation 5 + */ 6 + 7 + #include "intel_wopcm.h" 8 + #include "i915_drv.h" 9 + 10 + /** 11 + * DOC: WOPCM Layout 12 + * 13 + * The layout of the WOPCM will be fixed after writing to GuC WOPCM size and 14 + * offset registers whose values are calculated and determined by HuC/GuC 15 + * firmware size and set of hardware requirements/restrictions as shown below: 16 + * 17 + * :: 18 + * 19 + * +=========> +====================+ <== WOPCM Top 20 + * ^ | HW contexts RSVD | 21 + * | +===> +====================+ <== GuC WOPCM Top 22 + * | ^ | | 23 + * | | | | 24 + * | | | | 25 + * | GuC | | 26 + * | WOPCM | | 27 + * | Size +--------------------+ 28 + * WOPCM | | GuC FW RSVD | 29 + * | | +--------------------+ 30 + * | | | GuC Stack RSVD | 31 + * | | +------------------- + 32 + * | v | GuC WOPCM RSVD | 33 + * | +===> +====================+ <== GuC WOPCM base 34 + * | | WOPCM RSVD | 35 + * | +------------------- + <== HuC Firmware Top 36 + * v | HuC FW | 37 + * +=========> +====================+ <== WOPCM Base 38 + * 39 + * GuC accessible WOPCM starts at GuC WOPCM base and ends at GuC WOPCM top. 40 + * The top part of the WOPCM is reserved for hardware contexts (e.g. RC6 41 + * context). 42 + */ 43 + 44 + /* Default WOPCM size 1MB. */ 45 + #define GEN9_WOPCM_SIZE (1024 * 1024) 46 + /* 16KB WOPCM (RSVD WOPCM) is reserved from HuC firmware top. */ 47 + #define WOPCM_RESERVED_SIZE (16 * 1024) 48 + 49 + /* 16KB reserved at the beginning of GuC WOPCM. */ 50 + #define GUC_WOPCM_RESERVED (16 * 1024) 51 + /* 8KB from GUC_WOPCM_RESERVED is reserved for GuC stack. */ 52 + #define GUC_WOPCM_STACK_RESERVED (8 * 1024) 53 + 54 + /* GuC WOPCM Offset value needs to be aligned to 16KB. */ 55 + #define GUC_WOPCM_OFFSET_ALIGNMENT (1UL << GUC_WOPCM_OFFSET_SHIFT) 56 + 57 + /* 24KB at the end of WOPCM is reserved for RC6 CTX on BXT. */ 58 + #define BXT_WOPCM_RC6_CTX_RESERVED (24 * 1024) 59 + /* 36KB WOPCM reserved at the end of WOPCM on CNL. */ 60 + #define CNL_WOPCM_HW_CTX_RESERVED (36 * 1024) 61 + 62 + /* 128KB from GUC_WOPCM_RESERVED is reserved for FW on Gen9. */ 63 + #define GEN9_GUC_FW_RESERVED (128 * 1024) 64 + #define GEN9_GUC_WOPCM_OFFSET (GUC_WOPCM_RESERVED + GEN9_GUC_FW_RESERVED) 65 + 66 + /** 67 + * intel_wopcm_init_early() - Early initialization of the WOPCM. 68 + * @wopcm: pointer to intel_wopcm. 69 + * 70 + * Setup the size of WOPCM which will be used by later on WOPCM partitioning. 71 + */ 72 + void intel_wopcm_init_early(struct intel_wopcm *wopcm) 73 + { 74 + wopcm->size = GEN9_WOPCM_SIZE; 75 + 76 + DRM_DEBUG_DRIVER("WOPCM size: %uKiB\n", wopcm->size / 1024); 77 + } 78 + 79 + static inline u32 context_reserved_size(struct drm_i915_private *i915) 80 + { 81 + if (IS_GEN9_LP(i915)) 82 + return BXT_WOPCM_RC6_CTX_RESERVED; 83 + else if (INTEL_GEN(i915) >= 10) 84 + return CNL_WOPCM_HW_CTX_RESERVED; 85 + else 86 + return 0; 87 + } 88 + 89 + static inline int gen9_check_dword_gap(u32 guc_wopcm_base, u32 guc_wopcm_size) 90 + { 91 + u32 offset; 92 + 93 + /* 94 + * GuC WOPCM size shall be at least a dword larger than the offset from 95 + * WOPCM base (GuC WOPCM offset from WOPCM base + GEN9_GUC_WOPCM_OFFSET) 96 + * due to hardware limitation on Gen9. 97 + */ 98 + offset = guc_wopcm_base + GEN9_GUC_WOPCM_OFFSET; 99 + if (offset > guc_wopcm_size || 100 + (guc_wopcm_size - offset) < sizeof(u32)) { 101 + DRM_ERROR("GuC WOPCM size %uKiB is too small. %uKiB needed.\n", 102 + guc_wopcm_size / 1024, 103 + (u32)(offset + sizeof(u32)) / 1024); 104 + return -E2BIG; 105 + } 106 + 107 + return 0; 108 + } 109 + 110 + static inline int gen9_check_huc_fw_fits(u32 guc_wopcm_size, u32 huc_fw_size) 111 + { 112 + /* 113 + * On Gen9 & CNL A0, hardware requires the total available GuC WOPCM 114 + * size to be larger than or equal to HuC firmware size. Otherwise, 115 + * firmware uploading would fail. 116 + */ 117 + if (huc_fw_size > guc_wopcm_size - GUC_WOPCM_RESERVED) { 118 + DRM_ERROR("HuC FW (%uKiB) won't fit in GuC WOPCM (%uKiB).\n", 119 + huc_fw_size / 1024, 120 + (guc_wopcm_size - GUC_WOPCM_RESERVED) / 1024); 121 + return -E2BIG; 122 + } 123 + 124 + return 0; 125 + } 126 + 127 + static inline int check_hw_restriction(struct drm_i915_private *i915, 128 + u32 guc_wopcm_base, u32 guc_wopcm_size, 129 + u32 huc_fw_size) 130 + { 131 + int err = 0; 132 + 133 + if (IS_GEN9(i915)) 134 + err = gen9_check_dword_gap(guc_wopcm_base, guc_wopcm_size); 135 + 136 + if (!err && 137 + (IS_GEN9(i915) || IS_CNL_REVID(i915, CNL_REVID_A0, CNL_REVID_A0))) 138 + err = gen9_check_huc_fw_fits(guc_wopcm_size, huc_fw_size); 139 + 140 + return err; 141 + } 142 + 143 + /** 144 + * intel_wopcm_init() - Initialize the WOPCM structure. 145 + * @wopcm: pointer to intel_wopcm. 146 + * 147 + * This function will partition WOPCM space based on GuC and HuC firmware sizes 148 + * and will allocate max remaining for use by GuC. This function will also 149 + * enforce platform dependent hardware restrictions on GuC WOPCM offset and 150 + * size. It will fail the WOPCM init if any of these checks were failed, so that 151 + * the following GuC firmware uploading would be aborted. 152 + * 153 + * Return: 0 on success, non-zero error code on failure. 154 + */ 155 + int intel_wopcm_init(struct intel_wopcm *wopcm) 156 + { 157 + struct drm_i915_private *i915 = wopcm_to_i915(wopcm); 158 + u32 guc_fw_size = intel_uc_fw_get_upload_size(&i915->guc.fw); 159 + u32 huc_fw_size = intel_uc_fw_get_upload_size(&i915->huc.fw); 160 + u32 ctx_rsvd = context_reserved_size(i915); 161 + u32 guc_wopcm_base; 162 + u32 guc_wopcm_size; 163 + u32 guc_wopcm_rsvd; 164 + int err; 165 + 166 + GEM_BUG_ON(!wopcm->size); 167 + 168 + if (guc_fw_size >= wopcm->size) { 169 + DRM_ERROR("GuC FW (%uKiB) is too big to fit in WOPCM.", 170 + guc_fw_size / 1024); 171 + return -E2BIG; 172 + } 173 + 174 + if (huc_fw_size >= wopcm->size) { 175 + DRM_ERROR("HuC FW (%uKiB) is too big to fit in WOPCM.", 176 + huc_fw_size / 1024); 177 + return -E2BIG; 178 + } 179 + 180 + guc_wopcm_base = ALIGN(huc_fw_size + WOPCM_RESERVED_SIZE, 181 + GUC_WOPCM_OFFSET_ALIGNMENT); 182 + if ((guc_wopcm_base + ctx_rsvd) >= wopcm->size) { 183 + DRM_ERROR("GuC WOPCM base (%uKiB) is too big.\n", 184 + guc_wopcm_base / 1024); 185 + return -E2BIG; 186 + } 187 + 188 + guc_wopcm_size = wopcm->size - guc_wopcm_base - ctx_rsvd; 189 + guc_wopcm_size &= GUC_WOPCM_SIZE_MASK; 190 + 191 + DRM_DEBUG_DRIVER("Calculated GuC WOPCM Region: [%uKiB, %uKiB)\n", 192 + guc_wopcm_base / 1024, guc_wopcm_size / 1024); 193 + 194 + guc_wopcm_rsvd = GUC_WOPCM_RESERVED + GUC_WOPCM_STACK_RESERVED; 195 + if ((guc_fw_size + guc_wopcm_rsvd) > guc_wopcm_size) { 196 + DRM_ERROR("Need %uKiB WOPCM for GuC, %uKiB available.\n", 197 + (guc_fw_size + guc_wopcm_rsvd) / 1024, 198 + guc_wopcm_size / 1024); 199 + return -E2BIG; 200 + } 201 + 202 + err = check_hw_restriction(i915, guc_wopcm_base, guc_wopcm_size, 203 + huc_fw_size); 204 + if (err) 205 + return err; 206 + 207 + wopcm->guc.base = guc_wopcm_base; 208 + wopcm->guc.size = guc_wopcm_size; 209 + 210 + return 0; 211 + } 212 + 213 + static inline int write_and_verify(struct drm_i915_private *dev_priv, 214 + i915_reg_t reg, u32 val, u32 mask, 215 + u32 locked_bit) 216 + { 217 + u32 reg_val; 218 + 219 + GEM_BUG_ON(val & ~mask); 220 + 221 + I915_WRITE(reg, val); 222 + 223 + reg_val = I915_READ(reg); 224 + 225 + return (reg_val & mask) != (val | locked_bit) ? -EIO : 0; 226 + } 227 + 228 + /** 229 + * intel_wopcm_init_hw() - Setup GuC WOPCM registers. 230 + * @wopcm: pointer to intel_wopcm. 231 + * 232 + * Setup the GuC WOPCM size and offset registers with the calculated values. It 233 + * will verify the register values to make sure the registers are locked with 234 + * correct values. 235 + * 236 + * Return: 0 on success. -EIO if registers were locked with incorrect values. 237 + */ 238 + int intel_wopcm_init_hw(struct intel_wopcm *wopcm) 239 + { 240 + struct drm_i915_private *dev_priv = wopcm_to_i915(wopcm); 241 + u32 huc_agent; 242 + u32 mask; 243 + int err; 244 + 245 + if (!USES_GUC(dev_priv)) 246 + return 0; 247 + 248 + GEM_BUG_ON(!HAS_GUC(dev_priv)); 249 + GEM_BUG_ON(!wopcm->guc.size); 250 + GEM_BUG_ON(!wopcm->guc.base); 251 + 252 + err = write_and_verify(dev_priv, GUC_WOPCM_SIZE, wopcm->guc.size, 253 + GUC_WOPCM_SIZE_MASK | GUC_WOPCM_SIZE_LOCKED, 254 + GUC_WOPCM_SIZE_LOCKED); 255 + if (err) 256 + goto err_out; 257 + 258 + huc_agent = USES_HUC(dev_priv) ? HUC_LOADING_AGENT_GUC : 0; 259 + mask = GUC_WOPCM_OFFSET_MASK | GUC_WOPCM_OFFSET_VALID | huc_agent; 260 + err = write_and_verify(dev_priv, DMA_GUC_WOPCM_OFFSET, 261 + wopcm->guc.base | huc_agent, mask, 262 + GUC_WOPCM_OFFSET_VALID); 263 + if (err) 264 + goto err_out; 265 + 266 + return 0; 267 + 268 + err_out: 269 + DRM_ERROR("Failed to init WOPCM registers:\n"); 270 + DRM_ERROR("DMA_GUC_WOPCM_OFFSET=%#x\n", 271 + I915_READ(DMA_GUC_WOPCM_OFFSET)); 272 + DRM_ERROR("GUC_WOPCM_SIZE=%#x\n", I915_READ(GUC_WOPCM_SIZE)); 273 + 274 + return err; 275 + }
+31
drivers/gpu/drm/i915/intel_wopcm.h
··· 1 + /* 2 + * SPDX-License-Identifier: MIT 3 + * 4 + * Copyright © 2017-2018 Intel Corporation 5 + */ 6 + 7 + #ifndef _INTEL_WOPCM_H_ 8 + #define _INTEL_WOPCM_H_ 9 + 10 + #include <linux/types.h> 11 + 12 + /** 13 + * struct intel_wopcm - Overall WOPCM info and WOPCM regions. 14 + * @size: Size of overall WOPCM. 15 + * @guc: GuC WOPCM Region info. 16 + * @guc.base: GuC WOPCM base which is offset from WOPCM base. 17 + * @guc.size: Size of the GuC WOPCM region. 18 + */ 19 + struct intel_wopcm { 20 + u32 size; 21 + struct { 22 + u32 base; 23 + u32 size; 24 + } guc; 25 + }; 26 + 27 + void intel_wopcm_init_early(struct intel_wopcm *wopcm); 28 + int intel_wopcm_init(struct intel_wopcm *wopcm); 29 + int intel_wopcm_init_hw(struct intel_wopcm *wopcm); 30 + 31 + #endif
+856
drivers/gpu/drm/i915/intel_workarounds.c
··· 1 + /* 2 + * SPDX-License-Identifier: MIT 3 + * 4 + * Copyright © 2014-2018 Intel Corporation 5 + */ 6 + 7 + #include "i915_drv.h" 8 + #include "intel_workarounds.h" 9 + 10 + /** 11 + * DOC: Hardware workarounds 12 + * 13 + * This file is intended as a central place to implement most [1]_ of the 14 + * required workarounds for hardware to work as originally intended. They fall 15 + * in five basic categories depending on how/when they are applied: 16 + * 17 + * - Workarounds that touch registers that are saved/restored to/from the HW 18 + * context image. The list is emitted (via Load Register Immediate commands) 19 + * everytime a new context is created. 20 + * - GT workarounds. The list of these WAs is applied whenever these registers 21 + * revert to default values (on GPU reset, suspend/resume [2]_, etc..). 22 + * - Display workarounds. The list is applied during display clock-gating 23 + * initialization. 24 + * - Workarounds that whitelist a privileged register, so that UMDs can manage 25 + * them directly. This is just a special case of a MMMIO workaround (as we 26 + * write the list of these to/be-whitelisted registers to some special HW 27 + * registers). 28 + * - Workaround batchbuffers, that get executed automatically by the hardware 29 + * on every HW context restore. 30 + * 31 + * .. [1] Please notice that there are other WAs that, due to their nature, 32 + * cannot be applied from a central place. Those are peppered around the rest 33 + * of the code, as needed. 34 + * 35 + * .. [2] Technically, some registers are powercontext saved & restored, so they 36 + * survive a suspend/resume. In practice, writing them again is not too 37 + * costly and simplifies things. We can revisit this in the future. 38 + * 39 + * Layout 40 + * '''''' 41 + * 42 + * Keep things in this file ordered by WA type, as per the above (context, GT, 43 + * display, register whitelist, batchbuffer). Then, inside each type, keep the 44 + * following order: 45 + * 46 + * - Infrastructure functions and macros 47 + * - WAs per platform in standard gen/chrono order 48 + * - Public functions to init or apply the given workaround type. 49 + */ 50 + 51 + static int wa_add(struct drm_i915_private *dev_priv, 52 + i915_reg_t addr, 53 + const u32 mask, const u32 val) 54 + { 55 + const unsigned int idx = dev_priv->workarounds.count; 56 + 57 + if (WARN_ON(idx >= I915_MAX_WA_REGS)) 58 + return -ENOSPC; 59 + 60 + dev_priv->workarounds.reg[idx].addr = addr; 61 + dev_priv->workarounds.reg[idx].value = val; 62 + dev_priv->workarounds.reg[idx].mask = mask; 63 + 64 + dev_priv->workarounds.count++; 65 + 66 + return 0; 67 + } 68 + 69 + #define WA_REG(addr, mask, val) do { \ 70 + const int r = wa_add(dev_priv, (addr), (mask), (val)); \ 71 + if (r) \ 72 + return r; \ 73 + } while (0) 74 + 75 + #define WA_SET_BIT_MASKED(addr, mask) \ 76 + WA_REG(addr, (mask), _MASKED_BIT_ENABLE(mask)) 77 + 78 + #define WA_CLR_BIT_MASKED(addr, mask) \ 79 + WA_REG(addr, (mask), _MASKED_BIT_DISABLE(mask)) 80 + 81 + #define WA_SET_FIELD_MASKED(addr, mask, value) \ 82 + WA_REG(addr, (mask), _MASKED_FIELD(mask, value)) 83 + 84 + static int gen8_ctx_workarounds_init(struct drm_i915_private *dev_priv) 85 + { 86 + WA_SET_BIT_MASKED(INSTPM, INSTPM_FORCE_ORDERING); 87 + 88 + /* WaDisableAsyncFlipPerfMode:bdw,chv */ 89 + WA_SET_BIT_MASKED(MI_MODE, ASYNC_FLIP_PERF_DISABLE); 90 + 91 + /* WaDisablePartialInstShootdown:bdw,chv */ 92 + WA_SET_BIT_MASKED(GEN8_ROW_CHICKEN, 93 + PARTIAL_INSTRUCTION_SHOOTDOWN_DISABLE); 94 + 95 + /* Use Force Non-Coherent whenever executing a 3D context. This is a 96 + * workaround for for a possible hang in the unlikely event a TLB 97 + * invalidation occurs during a PSD flush. 98 + */ 99 + /* WaForceEnableNonCoherent:bdw,chv */ 100 + /* WaHdcDisableFetchWhenMasked:bdw,chv */ 101 + WA_SET_BIT_MASKED(HDC_CHICKEN0, 102 + HDC_DONOT_FETCH_MEM_WHEN_MASKED | 103 + HDC_FORCE_NON_COHERENT); 104 + 105 + /* From the Haswell PRM, Command Reference: Registers, CACHE_MODE_0: 106 + * "The Hierarchical Z RAW Stall Optimization allows non-overlapping 107 + * polygons in the same 8x4 pixel/sample area to be processed without 108 + * stalling waiting for the earlier ones to write to Hierarchical Z 109 + * buffer." 110 + * 111 + * This optimization is off by default for BDW and CHV; turn it on. 112 + */ 113 + WA_CLR_BIT_MASKED(CACHE_MODE_0_GEN7, HIZ_RAW_STALL_OPT_DISABLE); 114 + 115 + /* Wa4x4STCOptimizationDisable:bdw,chv */ 116 + WA_SET_BIT_MASKED(CACHE_MODE_1, GEN8_4x4_STC_OPTIMIZATION_DISABLE); 117 + 118 + /* 119 + * BSpec recommends 8x4 when MSAA is used, 120 + * however in practice 16x4 seems fastest. 121 + * 122 + * Note that PS/WM thread counts depend on the WIZ hashing 123 + * disable bit, which we don't touch here, but it's good 124 + * to keep in mind (see 3DSTATE_PS and 3DSTATE_WM). 125 + */ 126 + WA_SET_FIELD_MASKED(GEN7_GT_MODE, 127 + GEN6_WIZ_HASHING_MASK, 128 + GEN6_WIZ_HASHING_16x4); 129 + 130 + return 0; 131 + } 132 + 133 + static int bdw_ctx_workarounds_init(struct drm_i915_private *dev_priv) 134 + { 135 + int ret; 136 + 137 + ret = gen8_ctx_workarounds_init(dev_priv); 138 + if (ret) 139 + return ret; 140 + 141 + /* WaDisableThreadStallDopClockGating:bdw (pre-production) */ 142 + WA_SET_BIT_MASKED(GEN8_ROW_CHICKEN, STALL_DOP_GATING_DISABLE); 143 + 144 + /* WaDisableDopClockGating:bdw 145 + * 146 + * Also see the related UCGTCL1 write in broadwell_init_clock_gating() 147 + * to disable EUTC clock gating. 148 + */ 149 + WA_SET_BIT_MASKED(GEN7_ROW_CHICKEN2, 150 + DOP_CLOCK_GATING_DISABLE); 151 + 152 + WA_SET_BIT_MASKED(HALF_SLICE_CHICKEN3, 153 + GEN8_SAMPLER_POWER_BYPASS_DIS); 154 + 155 + WA_SET_BIT_MASKED(HDC_CHICKEN0, 156 + /* WaForceContextSaveRestoreNonCoherent:bdw */ 157 + HDC_FORCE_CONTEXT_SAVE_RESTORE_NON_COHERENT | 158 + /* WaDisableFenceDestinationToSLM:bdw (pre-prod) */ 159 + (IS_BDW_GT3(dev_priv) ? HDC_FENCE_DEST_SLM_DISABLE : 0)); 160 + 161 + return 0; 162 + } 163 + 164 + static int chv_ctx_workarounds_init(struct drm_i915_private *dev_priv) 165 + { 166 + int ret; 167 + 168 + ret = gen8_ctx_workarounds_init(dev_priv); 169 + if (ret) 170 + return ret; 171 + 172 + /* WaDisableThreadStallDopClockGating:chv */ 173 + WA_SET_BIT_MASKED(GEN8_ROW_CHICKEN, STALL_DOP_GATING_DISABLE); 174 + 175 + /* Improve HiZ throughput on CHV. */ 176 + WA_SET_BIT_MASKED(HIZ_CHICKEN, CHV_HZ_8X8_MODE_IN_1X); 177 + 178 + return 0; 179 + } 180 + 181 + static int gen9_ctx_workarounds_init(struct drm_i915_private *dev_priv) 182 + { 183 + if (HAS_LLC(dev_priv)) { 184 + /* WaCompressedResourceSamplerPbeMediaNewHashMode:skl,kbl 185 + * 186 + * Must match Display Engine. See 187 + * WaCompressedResourceDisplayNewHashMode. 188 + */ 189 + WA_SET_BIT_MASKED(COMMON_SLICE_CHICKEN2, 190 + GEN9_PBE_COMPRESSED_HASH_SELECTION); 191 + WA_SET_BIT_MASKED(GEN9_HALF_SLICE_CHICKEN7, 192 + GEN9_SAMPLER_HASH_COMPRESSED_READ_ADDR); 193 + } 194 + 195 + /* WaClearFlowControlGpgpuContextSave:skl,bxt,kbl,glk,cfl */ 196 + /* WaDisablePartialInstShootdown:skl,bxt,kbl,glk,cfl */ 197 + WA_SET_BIT_MASKED(GEN8_ROW_CHICKEN, 198 + FLOW_CONTROL_ENABLE | 199 + PARTIAL_INSTRUCTION_SHOOTDOWN_DISABLE); 200 + 201 + /* Syncing dependencies between camera and graphics:skl,bxt,kbl */ 202 + if (!IS_COFFEELAKE(dev_priv)) 203 + WA_SET_BIT_MASKED(HALF_SLICE_CHICKEN3, 204 + GEN9_DISABLE_OCL_OOB_SUPPRESS_LOGIC); 205 + 206 + /* WaEnableYV12BugFixInHalfSliceChicken7:skl,bxt,kbl,glk,cfl */ 207 + /* WaEnableSamplerGPGPUPreemptionSupport:skl,bxt,kbl,cfl */ 208 + WA_SET_BIT_MASKED(GEN9_HALF_SLICE_CHICKEN7, 209 + GEN9_ENABLE_YV12_BUGFIX | 210 + GEN9_ENABLE_GPGPU_PREEMPTION); 211 + 212 + /* Wa4x4STCOptimizationDisable:skl,bxt,kbl,glk,cfl */ 213 + /* WaDisablePartialResolveInVc:skl,bxt,kbl,cfl */ 214 + WA_SET_BIT_MASKED(CACHE_MODE_1, 215 + GEN8_4x4_STC_OPTIMIZATION_DISABLE | 216 + GEN9_PARTIAL_RESOLVE_IN_VC_DISABLE); 217 + 218 + /* WaCcsTlbPrefetchDisable:skl,bxt,kbl,glk,cfl */ 219 + WA_CLR_BIT_MASKED(GEN9_HALF_SLICE_CHICKEN5, 220 + GEN9_CCS_TLB_PREFETCH_ENABLE); 221 + 222 + /* WaForceContextSaveRestoreNonCoherent:skl,bxt,kbl,cfl */ 223 + WA_SET_BIT_MASKED(HDC_CHICKEN0, 224 + HDC_FORCE_CONTEXT_SAVE_RESTORE_NON_COHERENT | 225 + HDC_FORCE_CSR_NON_COHERENT_OVR_DISABLE); 226 + 227 + /* WaForceEnableNonCoherent and WaDisableHDCInvalidation are 228 + * both tied to WaForceContextSaveRestoreNonCoherent 229 + * in some hsds for skl. We keep the tie for all gen9. The 230 + * documentation is a bit hazy and so we want to get common behaviour, 231 + * even though there is no clear evidence we would need both on kbl/bxt. 232 + * This area has been source of system hangs so we play it safe 233 + * and mimic the skl regardless of what bspec says. 234 + * 235 + * Use Force Non-Coherent whenever executing a 3D context. This 236 + * is a workaround for a possible hang in the unlikely event 237 + * a TLB invalidation occurs during a PSD flush. 238 + */ 239 + 240 + /* WaForceEnableNonCoherent:skl,bxt,kbl,cfl */ 241 + WA_SET_BIT_MASKED(HDC_CHICKEN0, 242 + HDC_FORCE_NON_COHERENT); 243 + 244 + /* WaDisableSamplerPowerBypassForSOPingPong:skl,bxt,kbl,cfl */ 245 + if (IS_SKYLAKE(dev_priv) || 246 + IS_KABYLAKE(dev_priv) || 247 + IS_COFFEELAKE(dev_priv)) 248 + WA_SET_BIT_MASKED(HALF_SLICE_CHICKEN3, 249 + GEN8_SAMPLER_POWER_BYPASS_DIS); 250 + 251 + /* WaDisableSTUnitPowerOptimization:skl,bxt,kbl,glk,cfl */ 252 + WA_SET_BIT_MASKED(HALF_SLICE_CHICKEN2, GEN8_ST_PO_DISABLE); 253 + 254 + /* 255 + * Supporting preemption with fine-granularity requires changes in the 256 + * batch buffer programming. Since we can't break old userspace, we 257 + * need to set our default preemption level to safe value. Userspace is 258 + * still able to use more fine-grained preemption levels, since in 259 + * WaEnablePreemptionGranularityControlByUMD we're whitelisting the 260 + * per-ctx register. As such, WaDisable{3D,GPGPU}MidCmdPreemption are 261 + * not real HW workarounds, but merely a way to start using preemption 262 + * while maintaining old contract with userspace. 263 + */ 264 + 265 + /* WaDisable3DMidCmdPreemption:skl,bxt,glk,cfl,[cnl] */ 266 + WA_CLR_BIT_MASKED(GEN8_CS_CHICKEN1, GEN9_PREEMPT_3D_OBJECT_LEVEL); 267 + 268 + /* WaDisableGPGPUMidCmdPreemption:skl,bxt,blk,cfl,[cnl] */ 269 + WA_SET_FIELD_MASKED(GEN8_CS_CHICKEN1, 270 + GEN9_PREEMPT_GPGPU_LEVEL_MASK, 271 + GEN9_PREEMPT_GPGPU_COMMAND_LEVEL); 272 + 273 + return 0; 274 + } 275 + 276 + static int skl_tune_iz_hashing(struct drm_i915_private *dev_priv) 277 + { 278 + u8 vals[3] = { 0, 0, 0 }; 279 + unsigned int i; 280 + 281 + for (i = 0; i < 3; i++) { 282 + u8 ss; 283 + 284 + /* 285 + * Only consider slices where one, and only one, subslice has 7 286 + * EUs 287 + */ 288 + if (!is_power_of_2(INTEL_INFO(dev_priv)->sseu.subslice_7eu[i])) 289 + continue; 290 + 291 + /* 292 + * subslice_7eu[i] != 0 (because of the check above) and 293 + * ss_max == 4 (maximum number of subslices possible per slice) 294 + * 295 + * -> 0 <= ss <= 3; 296 + */ 297 + ss = ffs(INTEL_INFO(dev_priv)->sseu.subslice_7eu[i]) - 1; 298 + vals[i] = 3 - ss; 299 + } 300 + 301 + if (vals[0] == 0 && vals[1] == 0 && vals[2] == 0) 302 + return 0; 303 + 304 + /* Tune IZ hashing. See intel_device_info_runtime_init() */ 305 + WA_SET_FIELD_MASKED(GEN7_GT_MODE, 306 + GEN9_IZ_HASHING_MASK(2) | 307 + GEN9_IZ_HASHING_MASK(1) | 308 + GEN9_IZ_HASHING_MASK(0), 309 + GEN9_IZ_HASHING(2, vals[2]) | 310 + GEN9_IZ_HASHING(1, vals[1]) | 311 + GEN9_IZ_HASHING(0, vals[0])); 312 + 313 + return 0; 314 + } 315 + 316 + static int skl_ctx_workarounds_init(struct drm_i915_private *dev_priv) 317 + { 318 + int ret; 319 + 320 + ret = gen9_ctx_workarounds_init(dev_priv); 321 + if (ret) 322 + return ret; 323 + 324 + return skl_tune_iz_hashing(dev_priv); 325 + } 326 + 327 + static int bxt_ctx_workarounds_init(struct drm_i915_private *dev_priv) 328 + { 329 + int ret; 330 + 331 + ret = gen9_ctx_workarounds_init(dev_priv); 332 + if (ret) 333 + return ret; 334 + 335 + /* WaDisableThreadStallDopClockGating:bxt */ 336 + WA_SET_BIT_MASKED(GEN8_ROW_CHICKEN, 337 + STALL_DOP_GATING_DISABLE); 338 + 339 + /* WaToEnableHwFixForPushConstHWBug:bxt */ 340 + WA_SET_BIT_MASKED(COMMON_SLICE_CHICKEN2, 341 + GEN8_SBE_DISABLE_REPLAY_BUF_OPTIMIZATION); 342 + 343 + return 0; 344 + } 345 + 346 + static int kbl_ctx_workarounds_init(struct drm_i915_private *dev_priv) 347 + { 348 + int ret; 349 + 350 + ret = gen9_ctx_workarounds_init(dev_priv); 351 + if (ret) 352 + return ret; 353 + 354 + /* WaDisableFenceDestinationToSLM:kbl (pre-prod) */ 355 + if (IS_KBL_REVID(dev_priv, KBL_REVID_A0, KBL_REVID_A0)) 356 + WA_SET_BIT_MASKED(HDC_CHICKEN0, 357 + HDC_FENCE_DEST_SLM_DISABLE); 358 + 359 + /* WaToEnableHwFixForPushConstHWBug:kbl */ 360 + if (IS_KBL_REVID(dev_priv, KBL_REVID_C0, REVID_FOREVER)) 361 + WA_SET_BIT_MASKED(COMMON_SLICE_CHICKEN2, 362 + GEN8_SBE_DISABLE_REPLAY_BUF_OPTIMIZATION); 363 + 364 + /* WaDisableSbeCacheDispatchPortSharing:kbl */ 365 + WA_SET_BIT_MASKED(GEN7_HALF_SLICE_CHICKEN1, 366 + GEN7_SBE_SS_CACHE_DISPATCH_PORT_SHARING_DISABLE); 367 + 368 + return 0; 369 + } 370 + 371 + static int glk_ctx_workarounds_init(struct drm_i915_private *dev_priv) 372 + { 373 + int ret; 374 + 375 + ret = gen9_ctx_workarounds_init(dev_priv); 376 + if (ret) 377 + return ret; 378 + 379 + /* WaToEnableHwFixForPushConstHWBug:glk */ 380 + WA_SET_BIT_MASKED(COMMON_SLICE_CHICKEN2, 381 + GEN8_SBE_DISABLE_REPLAY_BUF_OPTIMIZATION); 382 + 383 + return 0; 384 + } 385 + 386 + static int cfl_ctx_workarounds_init(struct drm_i915_private *dev_priv) 387 + { 388 + int ret; 389 + 390 + ret = gen9_ctx_workarounds_init(dev_priv); 391 + if (ret) 392 + return ret; 393 + 394 + /* WaToEnableHwFixForPushConstHWBug:cfl */ 395 + WA_SET_BIT_MASKED(COMMON_SLICE_CHICKEN2, 396 + GEN8_SBE_DISABLE_REPLAY_BUF_OPTIMIZATION); 397 + 398 + /* WaDisableSbeCacheDispatchPortSharing:cfl */ 399 + WA_SET_BIT_MASKED(GEN7_HALF_SLICE_CHICKEN1, 400 + GEN7_SBE_SS_CACHE_DISPATCH_PORT_SHARING_DISABLE); 401 + 402 + return 0; 403 + } 404 + 405 + static int cnl_ctx_workarounds_init(struct drm_i915_private *dev_priv) 406 + { 407 + /* WaForceContextSaveRestoreNonCoherent:cnl */ 408 + WA_SET_BIT_MASKED(CNL_HDC_CHICKEN0, 409 + HDC_FORCE_CONTEXT_SAVE_RESTORE_NON_COHERENT); 410 + 411 + /* WaThrottleEUPerfToAvoidTDBackPressure:cnl(pre-prod) */ 412 + if (IS_CNL_REVID(dev_priv, CNL_REVID_B0, CNL_REVID_B0)) 413 + WA_SET_BIT_MASKED(GEN8_ROW_CHICKEN, THROTTLE_12_5); 414 + 415 + /* WaDisableReplayBufferBankArbitrationOptimization:cnl */ 416 + WA_SET_BIT_MASKED(COMMON_SLICE_CHICKEN2, 417 + GEN8_SBE_DISABLE_REPLAY_BUF_OPTIMIZATION); 418 + 419 + /* WaDisableEnhancedSBEVertexCaching:cnl (pre-prod) */ 420 + if (IS_CNL_REVID(dev_priv, 0, CNL_REVID_B0)) 421 + WA_SET_BIT_MASKED(COMMON_SLICE_CHICKEN2, 422 + GEN8_CSC2_SBE_VUE_CACHE_CONSERVATIVE); 423 + 424 + /* WaPushConstantDereferenceHoldDisable:cnl */ 425 + WA_SET_BIT_MASKED(GEN7_ROW_CHICKEN2, PUSH_CONSTANT_DEREF_DISABLE); 426 + 427 + /* FtrEnableFastAnisoL1BankingFix:cnl */ 428 + WA_SET_BIT_MASKED(HALF_SLICE_CHICKEN3, CNL_FAST_ANISO_L1_BANKING_FIX); 429 + 430 + /* WaDisable3DMidCmdPreemption:cnl */ 431 + WA_CLR_BIT_MASKED(GEN8_CS_CHICKEN1, GEN9_PREEMPT_3D_OBJECT_LEVEL); 432 + 433 + /* WaDisableGPGPUMidCmdPreemption:cnl */ 434 + WA_SET_FIELD_MASKED(GEN8_CS_CHICKEN1, 435 + GEN9_PREEMPT_GPGPU_LEVEL_MASK, 436 + GEN9_PREEMPT_GPGPU_COMMAND_LEVEL); 437 + 438 + /* WaDisableEarlyEOT:cnl */ 439 + WA_SET_BIT_MASKED(GEN8_ROW_CHICKEN, DISABLE_EARLY_EOT); 440 + 441 + return 0; 442 + } 443 + 444 + int intel_ctx_workarounds_init(struct drm_i915_private *dev_priv) 445 + { 446 + int err = 0; 447 + 448 + dev_priv->workarounds.count = 0; 449 + 450 + if (INTEL_GEN(dev_priv) < 8) 451 + err = 0; 452 + else if (IS_BROADWELL(dev_priv)) 453 + err = bdw_ctx_workarounds_init(dev_priv); 454 + else if (IS_CHERRYVIEW(dev_priv)) 455 + err = chv_ctx_workarounds_init(dev_priv); 456 + else if (IS_SKYLAKE(dev_priv)) 457 + err = skl_ctx_workarounds_init(dev_priv); 458 + else if (IS_BROXTON(dev_priv)) 459 + err = bxt_ctx_workarounds_init(dev_priv); 460 + else if (IS_KABYLAKE(dev_priv)) 461 + err = kbl_ctx_workarounds_init(dev_priv); 462 + else if (IS_GEMINILAKE(dev_priv)) 463 + err = glk_ctx_workarounds_init(dev_priv); 464 + else if (IS_COFFEELAKE(dev_priv)) 465 + err = cfl_ctx_workarounds_init(dev_priv); 466 + else if (IS_CANNONLAKE(dev_priv)) 467 + err = cnl_ctx_workarounds_init(dev_priv); 468 + else 469 + MISSING_CASE(INTEL_GEN(dev_priv)); 470 + if (err) 471 + return err; 472 + 473 + DRM_DEBUG_DRIVER("Number of context specific w/a: %d\n", 474 + dev_priv->workarounds.count); 475 + return 0; 476 + } 477 + 478 + int intel_ctx_workarounds_emit(struct i915_request *rq) 479 + { 480 + struct i915_workarounds *w = &rq->i915->workarounds; 481 + u32 *cs; 482 + int ret, i; 483 + 484 + if (w->count == 0) 485 + return 0; 486 + 487 + ret = rq->engine->emit_flush(rq, EMIT_BARRIER); 488 + if (ret) 489 + return ret; 490 + 491 + cs = intel_ring_begin(rq, (w->count * 2 + 2)); 492 + if (IS_ERR(cs)) 493 + return PTR_ERR(cs); 494 + 495 + *cs++ = MI_LOAD_REGISTER_IMM(w->count); 496 + for (i = 0; i < w->count; i++) { 497 + *cs++ = i915_mmio_reg_offset(w->reg[i].addr); 498 + *cs++ = w->reg[i].value; 499 + } 500 + *cs++ = MI_NOOP; 501 + 502 + intel_ring_advance(rq, cs); 503 + 504 + ret = rq->engine->emit_flush(rq, EMIT_BARRIER); 505 + if (ret) 506 + return ret; 507 + 508 + return 0; 509 + } 510 + 511 + static void bdw_gt_workarounds_apply(struct drm_i915_private *dev_priv) 512 + { 513 + } 514 + 515 + static void chv_gt_workarounds_apply(struct drm_i915_private *dev_priv) 516 + { 517 + } 518 + 519 + static void gen9_gt_workarounds_apply(struct drm_i915_private *dev_priv) 520 + { 521 + /* WaContextSwitchWithConcurrentTLBInvalidate:skl,bxt,kbl,glk,cfl */ 522 + I915_WRITE(GEN9_CSFE_CHICKEN1_RCS, 523 + _MASKED_BIT_ENABLE(GEN9_PREEMPT_GPGPU_SYNC_SWITCH_DISABLE)); 524 + 525 + /* WaEnableLbsSlaRetryTimerDecrement:skl,bxt,kbl,glk,cfl */ 526 + I915_WRITE(BDW_SCRATCH1, I915_READ(BDW_SCRATCH1) | 527 + GEN9_LBS_SLA_RETRY_TIMER_DECREMENT_ENABLE); 528 + 529 + /* WaDisableKillLogic:bxt,skl,kbl */ 530 + if (!IS_COFFEELAKE(dev_priv)) 531 + I915_WRITE(GAM_ECOCHK, I915_READ(GAM_ECOCHK) | 532 + ECOCHK_DIS_TLB); 533 + 534 + if (HAS_LLC(dev_priv)) { 535 + /* WaCompressedResourceSamplerPbeMediaNewHashMode:skl,kbl 536 + * 537 + * Must match Display Engine. See 538 + * WaCompressedResourceDisplayNewHashMode. 539 + */ 540 + I915_WRITE(MMCD_MISC_CTRL, 541 + I915_READ(MMCD_MISC_CTRL) | 542 + MMCD_PCLA | 543 + MMCD_HOTSPOT_EN); 544 + } 545 + 546 + /* WaDisableHDCInvalidation:skl,bxt,kbl,cfl */ 547 + I915_WRITE(GAM_ECOCHK, I915_READ(GAM_ECOCHK) | 548 + BDW_DISABLE_HDC_INVALIDATION); 549 + 550 + /* WaProgramL3SqcReg1DefaultForPerf:bxt,glk */ 551 + if (IS_GEN9_LP(dev_priv)) { 552 + u32 val = I915_READ(GEN8_L3SQCREG1); 553 + 554 + val &= ~L3_PRIO_CREDITS_MASK; 555 + val |= L3_GENERAL_PRIO_CREDITS(62) | L3_HIGH_PRIO_CREDITS(2); 556 + I915_WRITE(GEN8_L3SQCREG1, val); 557 + } 558 + 559 + /* WaOCLCoherentLineFlush:skl,bxt,kbl,cfl */ 560 + I915_WRITE(GEN8_L3SQCREG4, 561 + I915_READ(GEN8_L3SQCREG4) | GEN8_LQSC_FLUSH_COHERENT_LINES); 562 + 563 + /* WaEnablePreemptionGranularityControlByUMD:skl,bxt,kbl,cfl,[cnl] */ 564 + I915_WRITE(GEN7_FF_SLICE_CS_CHICKEN1, 565 + _MASKED_BIT_ENABLE(GEN9_FFSC_PERCTX_PREEMPT_CTRL)); 566 + } 567 + 568 + static void skl_gt_workarounds_apply(struct drm_i915_private *dev_priv) 569 + { 570 + gen9_gt_workarounds_apply(dev_priv); 571 + 572 + /* WaEnableGapsTsvCreditFix:skl */ 573 + I915_WRITE(GEN8_GARBCNTL, 574 + I915_READ(GEN8_GARBCNTL) | GEN9_GAPS_TSV_CREDIT_DISABLE); 575 + 576 + /* WaDisableGafsUnitClkGating:skl */ 577 + I915_WRITE(GEN7_UCGCTL4, 578 + I915_READ(GEN7_UCGCTL4) | GEN8_EU_GAUNIT_CLOCK_GATE_DISABLE); 579 + 580 + /* WaInPlaceDecompressionHang:skl */ 581 + if (IS_SKL_REVID(dev_priv, SKL_REVID_H0, REVID_FOREVER)) 582 + I915_WRITE(GEN9_GAMT_ECO_REG_RW_IA, 583 + I915_READ(GEN9_GAMT_ECO_REG_RW_IA) | 584 + GAMT_ECO_ENABLE_IN_PLACE_DECOMPRESS); 585 + } 586 + 587 + static void bxt_gt_workarounds_apply(struct drm_i915_private *dev_priv) 588 + { 589 + gen9_gt_workarounds_apply(dev_priv); 590 + 591 + /* WaDisablePooledEuLoadBalancingFix:bxt */ 592 + I915_WRITE(FF_SLICE_CS_CHICKEN2, 593 + _MASKED_BIT_ENABLE(GEN9_POOLED_EU_LOAD_BALANCING_FIX_DISABLE)); 594 + 595 + /* WaInPlaceDecompressionHang:bxt */ 596 + I915_WRITE(GEN9_GAMT_ECO_REG_RW_IA, 597 + I915_READ(GEN9_GAMT_ECO_REG_RW_IA) | 598 + GAMT_ECO_ENABLE_IN_PLACE_DECOMPRESS); 599 + } 600 + 601 + static void kbl_gt_workarounds_apply(struct drm_i915_private *dev_priv) 602 + { 603 + gen9_gt_workarounds_apply(dev_priv); 604 + 605 + /* WaEnableGapsTsvCreditFix:kbl */ 606 + I915_WRITE(GEN8_GARBCNTL, 607 + I915_READ(GEN8_GARBCNTL) | GEN9_GAPS_TSV_CREDIT_DISABLE); 608 + 609 + /* WaDisableDynamicCreditSharing:kbl */ 610 + if (IS_KBL_REVID(dev_priv, 0, KBL_REVID_B0)) 611 + I915_WRITE(GAMT_CHKN_BIT_REG, 612 + I915_READ(GAMT_CHKN_BIT_REG) | 613 + GAMT_CHKN_DISABLE_DYNAMIC_CREDIT_SHARING); 614 + 615 + /* WaDisableGafsUnitClkGating:kbl */ 616 + I915_WRITE(GEN7_UCGCTL4, 617 + I915_READ(GEN7_UCGCTL4) | GEN8_EU_GAUNIT_CLOCK_GATE_DISABLE); 618 + 619 + /* WaInPlaceDecompressionHang:kbl */ 620 + I915_WRITE(GEN9_GAMT_ECO_REG_RW_IA, 621 + I915_READ(GEN9_GAMT_ECO_REG_RW_IA) | 622 + GAMT_ECO_ENABLE_IN_PLACE_DECOMPRESS); 623 + } 624 + 625 + static void glk_gt_workarounds_apply(struct drm_i915_private *dev_priv) 626 + { 627 + gen9_gt_workarounds_apply(dev_priv); 628 + } 629 + 630 + static void cfl_gt_workarounds_apply(struct drm_i915_private *dev_priv) 631 + { 632 + gen9_gt_workarounds_apply(dev_priv); 633 + 634 + /* WaEnableGapsTsvCreditFix:cfl */ 635 + I915_WRITE(GEN8_GARBCNTL, 636 + I915_READ(GEN8_GARBCNTL) | GEN9_GAPS_TSV_CREDIT_DISABLE); 637 + 638 + /* WaDisableGafsUnitClkGating:cfl */ 639 + I915_WRITE(GEN7_UCGCTL4, 640 + I915_READ(GEN7_UCGCTL4) | GEN8_EU_GAUNIT_CLOCK_GATE_DISABLE); 641 + 642 + /* WaInPlaceDecompressionHang:cfl */ 643 + I915_WRITE(GEN9_GAMT_ECO_REG_RW_IA, 644 + I915_READ(GEN9_GAMT_ECO_REG_RW_IA) | 645 + GAMT_ECO_ENABLE_IN_PLACE_DECOMPRESS); 646 + } 647 + 648 + static void cnl_gt_workarounds_apply(struct drm_i915_private *dev_priv) 649 + { 650 + /* WaDisableI2mCycleOnWRPort:cnl (pre-prod) */ 651 + if (IS_CNL_REVID(dev_priv, CNL_REVID_B0, CNL_REVID_B0)) 652 + I915_WRITE(GAMT_CHKN_BIT_REG, 653 + I915_READ(GAMT_CHKN_BIT_REG) | 654 + GAMT_CHKN_DISABLE_I2M_CYCLE_ON_WR_PORT); 655 + 656 + /* WaInPlaceDecompressionHang:cnl */ 657 + I915_WRITE(GEN9_GAMT_ECO_REG_RW_IA, 658 + I915_READ(GEN9_GAMT_ECO_REG_RW_IA) | 659 + GAMT_ECO_ENABLE_IN_PLACE_DECOMPRESS); 660 + 661 + /* WaEnablePreemptionGranularityControlByUMD:cnl */ 662 + I915_WRITE(GEN7_FF_SLICE_CS_CHICKEN1, 663 + _MASKED_BIT_ENABLE(GEN9_FFSC_PERCTX_PREEMPT_CTRL)); 664 + } 665 + 666 + void intel_gt_workarounds_apply(struct drm_i915_private *dev_priv) 667 + { 668 + if (INTEL_GEN(dev_priv) < 8) 669 + return; 670 + else if (IS_BROADWELL(dev_priv)) 671 + bdw_gt_workarounds_apply(dev_priv); 672 + else if (IS_CHERRYVIEW(dev_priv)) 673 + chv_gt_workarounds_apply(dev_priv); 674 + else if (IS_SKYLAKE(dev_priv)) 675 + skl_gt_workarounds_apply(dev_priv); 676 + else if (IS_BROXTON(dev_priv)) 677 + bxt_gt_workarounds_apply(dev_priv); 678 + else if (IS_KABYLAKE(dev_priv)) 679 + kbl_gt_workarounds_apply(dev_priv); 680 + else if (IS_GEMINILAKE(dev_priv)) 681 + glk_gt_workarounds_apply(dev_priv); 682 + else if (IS_COFFEELAKE(dev_priv)) 683 + cfl_gt_workarounds_apply(dev_priv); 684 + else if (IS_CANNONLAKE(dev_priv)) 685 + cnl_gt_workarounds_apply(dev_priv); 686 + else 687 + MISSING_CASE(INTEL_GEN(dev_priv)); 688 + } 689 + 690 + static int wa_ring_whitelist_reg(struct intel_engine_cs *engine, 691 + i915_reg_t reg) 692 + { 693 + struct drm_i915_private *dev_priv = engine->i915; 694 + struct i915_workarounds *wa = &dev_priv->workarounds; 695 + const unsigned int index = wa->hw_whitelist_count[engine->id]; 696 + 697 + if (WARN_ON(index >= RING_MAX_NONPRIV_SLOTS)) 698 + return -EINVAL; 699 + 700 + I915_WRITE(RING_FORCE_TO_NONPRIV(engine->mmio_base, index), 701 + i915_mmio_reg_offset(reg)); 702 + wa->hw_whitelist_count[engine->id]++; 703 + 704 + return 0; 705 + } 706 + 707 + static int bdw_whitelist_workarounds_apply(struct intel_engine_cs *engine) 708 + { 709 + return 0; 710 + } 711 + 712 + static int chv_whitelist_workarounds_apply(struct intel_engine_cs *engine) 713 + { 714 + return 0; 715 + } 716 + 717 + static int gen9_whitelist_workarounds_apply(struct intel_engine_cs *engine) 718 + { 719 + int ret; 720 + 721 + /* WaVFEStateAfterPipeControlwithMediaStateClear:skl,bxt,glk,cfl */ 722 + ret = wa_ring_whitelist_reg(engine, GEN9_CTX_PREEMPT_REG); 723 + if (ret) 724 + return ret; 725 + 726 + /* WaEnablePreemptionGranularityControlByUMD:skl,bxt,kbl,cfl,[cnl] */ 727 + ret = wa_ring_whitelist_reg(engine, GEN8_CS_CHICKEN1); 728 + if (ret) 729 + return ret; 730 + 731 + /* WaAllowUMDToModifyHDCChicken1:skl,bxt,kbl,glk,cfl */ 732 + ret = wa_ring_whitelist_reg(engine, GEN8_HDC_CHICKEN1); 733 + if (ret) 734 + return ret; 735 + 736 + return 0; 737 + } 738 + 739 + static int skl_whitelist_workarounds_apply(struct intel_engine_cs *engine) 740 + { 741 + int ret; 742 + 743 + ret = gen9_whitelist_workarounds_apply(engine); 744 + if (ret) 745 + return ret; 746 + 747 + /* WaDisableLSQCROPERFforOCL:skl */ 748 + ret = wa_ring_whitelist_reg(engine, GEN8_L3SQCREG4); 749 + if (ret) 750 + return ret; 751 + 752 + return 0; 753 + } 754 + 755 + static int bxt_whitelist_workarounds_apply(struct intel_engine_cs *engine) 756 + { 757 + int ret; 758 + 759 + ret = gen9_whitelist_workarounds_apply(engine); 760 + if (ret) 761 + return ret; 762 + 763 + return 0; 764 + } 765 + 766 + static int kbl_whitelist_workarounds_apply(struct intel_engine_cs *engine) 767 + { 768 + int ret; 769 + 770 + ret = gen9_whitelist_workarounds_apply(engine); 771 + if (ret) 772 + return ret; 773 + 774 + /* WaDisableLSQCROPERFforOCL:kbl */ 775 + ret = wa_ring_whitelist_reg(engine, GEN8_L3SQCREG4); 776 + if (ret) 777 + return ret; 778 + 779 + return 0; 780 + } 781 + 782 + static int glk_whitelist_workarounds_apply(struct intel_engine_cs *engine) 783 + { 784 + int ret; 785 + 786 + ret = gen9_whitelist_workarounds_apply(engine); 787 + if (ret) 788 + return ret; 789 + 790 + /* WA #0862: Userspace has to set "Barrier Mode" to avoid hangs. */ 791 + ret = wa_ring_whitelist_reg(engine, GEN9_SLICE_COMMON_ECO_CHICKEN1); 792 + if (ret) 793 + return ret; 794 + 795 + return 0; 796 + } 797 + 798 + static int cfl_whitelist_workarounds_apply(struct intel_engine_cs *engine) 799 + { 800 + int ret; 801 + 802 + ret = gen9_whitelist_workarounds_apply(engine); 803 + if (ret) 804 + return ret; 805 + 806 + return 0; 807 + } 808 + 809 + static int cnl_whitelist_workarounds_apply(struct intel_engine_cs *engine) 810 + { 811 + int ret; 812 + 813 + /* WaEnablePreemptionGranularityControlByUMD:cnl */ 814 + ret = wa_ring_whitelist_reg(engine, GEN8_CS_CHICKEN1); 815 + if (ret) 816 + return ret; 817 + 818 + return 0; 819 + } 820 + 821 + int intel_whitelist_workarounds_apply(struct intel_engine_cs *engine) 822 + { 823 + struct drm_i915_private *dev_priv = engine->i915; 824 + int err = 0; 825 + 826 + WARN_ON(engine->id != RCS); 827 + 828 + dev_priv->workarounds.hw_whitelist_count[engine->id] = 0; 829 + 830 + if (INTEL_GEN(dev_priv) < 8) 831 + err = 0; 832 + else if (IS_BROADWELL(dev_priv)) 833 + err = bdw_whitelist_workarounds_apply(engine); 834 + else if (IS_CHERRYVIEW(dev_priv)) 835 + err = chv_whitelist_workarounds_apply(engine); 836 + else if (IS_SKYLAKE(dev_priv)) 837 + err = skl_whitelist_workarounds_apply(engine); 838 + else if (IS_BROXTON(dev_priv)) 839 + err = bxt_whitelist_workarounds_apply(engine); 840 + else if (IS_KABYLAKE(dev_priv)) 841 + err = kbl_whitelist_workarounds_apply(engine); 842 + else if (IS_GEMINILAKE(dev_priv)) 843 + err = glk_whitelist_workarounds_apply(engine); 844 + else if (IS_COFFEELAKE(dev_priv)) 845 + err = cfl_whitelist_workarounds_apply(engine); 846 + else if (IS_CANNONLAKE(dev_priv)) 847 + err = cnl_whitelist_workarounds_apply(engine); 848 + else 849 + MISSING_CASE(INTEL_GEN(dev_priv)); 850 + if (err) 851 + return err; 852 + 853 + DRM_DEBUG_DRIVER("%s: Number of whitelist w/a: %d\n", engine->name, 854 + dev_priv->workarounds.hw_whitelist_count[engine->id]); 855 + return 0; 856 + }
+17
drivers/gpu/drm/i915/intel_workarounds.h
··· 1 + /* 2 + * SPDX-License-Identifier: MIT 3 + * 4 + * Copyright © 2014-2018 Intel Corporation 5 + */ 6 + 7 + #ifndef _I915_WORKAROUNDS_H_ 8 + #define _I915_WORKAROUNDS_H_ 9 + 10 + int intel_ctx_workarounds_init(struct drm_i915_private *dev_priv); 11 + int intel_ctx_workarounds_emit(struct i915_request *rq); 12 + 13 + void intel_gt_workarounds_apply(struct drm_i915_private *dev_priv); 14 + 15 + int intel_whitelist_workarounds_apply(struct intel_engine_cs *engine); 16 + 17 + #endif
+1
drivers/gpu/drm/i915/selftests/i915_live_selftests.h
··· 20 20 selftest(hugepages, i915_gem_huge_page_live_selftests) 21 21 selftest(contexts, i915_gem_context_live_selftests) 22 22 selftest(hangcheck, intel_hangcheck_live_selftests) 23 + selftest(execlists, intel_execlists_live_selftests) 23 24 selftest(guc, intel_guc_live_selftest)
+1
drivers/gpu/drm/i915/selftests/i915_mock_selftests.h
··· 14 14 selftest(scatterlist, scatterlist_mock_selftests) 15 15 selftest(syncmap, i915_syncmap_mock_selftests) 16 16 selftest(uncore, intel_uncore_mock_selftests) 17 + selftest(engine, intel_engine_cs_mock_selftests) 17 18 selftest(breadcrumbs, intel_breadcrumbs_mock_selftests) 18 19 selftest(timelines, i915_gem_timeline_mock_selftests) 19 20 selftest(requests, i915_request_mock_selftests)
+58
drivers/gpu/drm/i915/selftests/intel_engine_cs.c
··· 1 + /* 2 + * SPDX-License-Identifier: GPL-2.0 3 + * 4 + * Copyright © 2018 Intel Corporation 5 + */ 6 + 7 + #include "../i915_selftest.h" 8 + 9 + static int intel_mmio_bases_check(void *arg) 10 + { 11 + int i, j; 12 + 13 + for (i = 0; i < ARRAY_SIZE(intel_engines); i++) { 14 + const struct engine_info *info = &intel_engines[i]; 15 + char name[INTEL_ENGINE_CS_MAX_NAME]; 16 + u8 prev = U8_MAX; 17 + 18 + __sprint_engine_name(name, info); 19 + 20 + for (j = 0; j < MAX_MMIO_BASES; j++) { 21 + u8 gen = info->mmio_bases[j].gen; 22 + u32 base = info->mmio_bases[j].base; 23 + 24 + if (gen >= prev) { 25 + pr_err("%s: %s: mmio base for gen %x " 26 + "is before the one for gen %x\n", 27 + __func__, name, prev, gen); 28 + return -EINVAL; 29 + } 30 + 31 + if (gen == 0) 32 + break; 33 + 34 + if (!base) { 35 + pr_err("%s: %s: invalid mmio base (%x) " 36 + "for gen %x at entry %u\n", 37 + __func__, name, base, gen, j); 38 + return -EINVAL; 39 + } 40 + 41 + prev = gen; 42 + } 43 + 44 + pr_info("%s: min gen supported for %s = %d\n", 45 + __func__, name, prev); 46 + } 47 + 48 + return 0; 49 + } 50 + 51 + int intel_engine_cs_mock_selftests(void) 52 + { 53 + static const struct i915_subtest tests[] = { 54 + SUBTEST(intel_mmio_bases_check), 55 + }; 56 + 57 + return i915_subtests(tests, NULL); 58 + }
+210 -104
drivers/gpu/drm/i915/selftests/intel_hangcheck.c
··· 25 25 #include <linux/kthread.h> 26 26 27 27 #include "../i915_selftest.h" 28 + #include "i915_random.h" 28 29 29 30 #include "mock_context.h" 30 31 #include "mock_drm.h" ··· 261 260 { 262 261 struct wedge_me *w = container_of(work, typeof(*w), work.work); 263 262 264 - pr_err("%pS timed out, cancelling all further testing.\n", 265 - w->symbol); 263 + pr_err("%pS timed out, cancelling all further testing.\n", w->symbol); 264 + 265 + GEM_TRACE("%pS timed out.\n", w->symbol); 266 + GEM_TRACE_DUMP(); 267 + 266 268 i915_gem_set_wedged(w->i915); 267 269 } 268 270 ··· 322 318 flush_test(h->i915, I915_WAIT_LOCKED); 323 319 } 324 320 325 - static bool wait_for_hang(struct hang *h, struct i915_request *rq) 321 + static bool wait_until_running(struct hang *h, struct i915_request *rq) 326 322 { 327 323 return !(wait_for_us(i915_seqno_passed(hws_seqno(h, rq), 328 324 rq->fence.seqno), ··· 437 433 mutex_lock(&i915->drm.struct_mutex); 438 434 reset_count = i915_reset_count(&i915->gpu_error); 439 435 440 - i915_reset(i915, I915_RESET_QUIET); 436 + i915_reset(i915, ALL_ENGINES, NULL); 441 437 442 438 if (i915_reset_count(&i915->gpu_error) == reset_count) { 443 439 pr_err("No GPU reset recorded!\n"); ··· 487 483 488 484 set_bit(I915_RESET_ENGINE + id, &i915->gpu_error.flags); 489 485 do { 486 + u32 seqno = intel_engine_get_seqno(engine); 487 + 490 488 if (active) { 491 489 struct i915_request *rq; 492 490 ··· 504 498 __i915_request_add(rq, true); 505 499 mutex_unlock(&i915->drm.struct_mutex); 506 500 507 - if (!wait_for_hang(&h, rq)) { 501 + if (!wait_until_running(&h, rq)) { 508 502 struct drm_printer p = drm_info_printer(i915->drm.dev); 509 503 510 504 pr_err("%s: Failed to start request %x, at %x\n", ··· 517 511 break; 518 512 } 519 513 514 + GEM_BUG_ON(!rq->global_seqno); 515 + seqno = rq->global_seqno - 1; 520 516 i915_request_put(rq); 521 517 } 522 518 523 - engine->hangcheck.stalled = true; 524 - engine->hangcheck.seqno = 525 - intel_engine_get_seqno(engine); 526 - 527 - err = i915_reset_engine(engine, I915_RESET_QUIET); 519 + err = i915_reset_engine(engine, NULL); 528 520 if (err) { 529 521 pr_err("i915_reset_engine failed\n"); 530 522 break; ··· 542 538 err = -EINVAL; 543 539 break; 544 540 } 545 - 546 - engine->hangcheck.stalled = false; 547 541 } while (time_before(jiffies, end_time)); 548 542 clear_bit(I915_RESET_ENGINE + id, &i915->gpu_error.flags); 549 543 ··· 575 573 return __igt_reset_engine(arg, true); 576 574 } 577 575 576 + struct active_engine { 577 + struct task_struct *task; 578 + struct intel_engine_cs *engine; 579 + unsigned long resets; 580 + unsigned int flags; 581 + }; 582 + 583 + #define TEST_ACTIVE BIT(0) 584 + #define TEST_OTHERS BIT(1) 585 + #define TEST_SELF BIT(2) 586 + #define TEST_PRIORITY BIT(3) 587 + 578 588 static int active_engine(void *data) 579 589 { 580 - struct intel_engine_cs *engine = data; 581 - struct i915_request *rq[2] = {}; 582 - struct i915_gem_context *ctx[2]; 590 + I915_RND_STATE(prng); 591 + struct active_engine *arg = data; 592 + struct intel_engine_cs *engine = arg->engine; 593 + struct i915_request *rq[8] = {}; 594 + struct i915_gem_context *ctx[ARRAY_SIZE(rq)]; 583 595 struct drm_file *file; 584 596 unsigned long count = 0; 585 597 int err = 0; ··· 602 586 if (IS_ERR(file)) 603 587 return PTR_ERR(file); 604 588 605 - mutex_lock(&engine->i915->drm.struct_mutex); 606 - ctx[0] = live_context(engine->i915, file); 607 - mutex_unlock(&engine->i915->drm.struct_mutex); 608 - if (IS_ERR(ctx[0])) { 609 - err = PTR_ERR(ctx[0]); 610 - goto err_file; 611 - } 612 - 613 - mutex_lock(&engine->i915->drm.struct_mutex); 614 - ctx[1] = live_context(engine->i915, file); 615 - mutex_unlock(&engine->i915->drm.struct_mutex); 616 - if (IS_ERR(ctx[1])) { 617 - err = PTR_ERR(ctx[1]); 618 - i915_gem_context_put(ctx[0]); 619 - goto err_file; 589 + for (count = 0; count < ARRAY_SIZE(ctx); count++) { 590 + mutex_lock(&engine->i915->drm.struct_mutex); 591 + ctx[count] = live_context(engine->i915, file); 592 + mutex_unlock(&engine->i915->drm.struct_mutex); 593 + if (IS_ERR(ctx[count])) { 594 + err = PTR_ERR(ctx[count]); 595 + while (--count) 596 + i915_gem_context_put(ctx[count]); 597 + goto err_file; 598 + } 620 599 } 621 600 622 601 while (!kthread_should_stop()) { 623 - unsigned int idx = count++ & 1; 602 + unsigned int idx = count++ & (ARRAY_SIZE(rq) - 1); 624 603 struct i915_request *old = rq[idx]; 625 604 struct i915_request *new; 626 605 ··· 627 616 break; 628 617 } 629 618 619 + if (arg->flags & TEST_PRIORITY) 620 + ctx[idx]->priority = 621 + i915_prandom_u32_max_state(512, &prng); 622 + 630 623 rq[idx] = i915_request_get(new); 631 624 i915_request_add(new); 632 625 mutex_unlock(&engine->i915->drm.struct_mutex); 633 626 634 627 if (old) { 635 - i915_request_wait(old, 0, MAX_SCHEDULE_TIMEOUT); 628 + if (i915_request_wait(old, 0, HZ) < 0) { 629 + GEM_TRACE("%s timed out.\n", engine->name); 630 + GEM_TRACE_DUMP(); 631 + 632 + i915_gem_set_wedged(engine->i915); 633 + i915_request_put(old); 634 + err = -EIO; 635 + break; 636 + } 636 637 i915_request_put(old); 637 638 } 639 + 640 + cond_resched(); 638 641 } 639 642 640 643 for (count = 0; count < ARRAY_SIZE(rq); count++) ··· 659 634 return err; 660 635 } 661 636 662 - static int __igt_reset_engine_others(struct drm_i915_private *i915, 663 - bool active) 637 + static int __igt_reset_engines(struct drm_i915_private *i915, 638 + const char *test_name, 639 + unsigned int flags) 664 640 { 665 641 struct intel_engine_cs *engine, *other; 666 642 enum intel_engine_id id, tmp; ··· 675 649 if (!intel_has_reset_engine(i915)) 676 650 return 0; 677 651 678 - if (active) { 652 + if (flags & TEST_ACTIVE) { 679 653 mutex_lock(&i915->drm.struct_mutex); 680 654 err = hang_init(&h, i915); 681 655 mutex_unlock(&i915->drm.struct_mutex); 682 656 if (err) 683 657 return err; 658 + 659 + if (flags & TEST_PRIORITY) 660 + h.ctx->priority = 1024; 684 661 } 685 662 686 663 for_each_engine(engine, i915, id) { 687 - struct task_struct *threads[I915_NUM_ENGINES] = {}; 688 - unsigned long resets[I915_NUM_ENGINES]; 664 + struct active_engine threads[I915_NUM_ENGINES] = {}; 689 665 unsigned long global = i915_reset_count(&i915->gpu_error); 690 - unsigned long count = 0; 666 + unsigned long count = 0, reported; 691 667 IGT_TIMEOUT(end_time); 692 668 693 - if (active && !intel_engine_can_store_dword(engine)) 669 + if (flags & TEST_ACTIVE && 670 + !intel_engine_can_store_dword(engine)) 694 671 continue; 695 672 696 673 memset(threads, 0, sizeof(threads)); 697 674 for_each_engine(other, i915, tmp) { 698 675 struct task_struct *tsk; 699 676 700 - resets[tmp] = i915_reset_engine_count(&i915->gpu_error, 701 - other); 677 + threads[tmp].resets = 678 + i915_reset_engine_count(&i915->gpu_error, 679 + other); 702 680 703 - if (other == engine) 681 + if (!(flags & TEST_OTHERS)) 704 682 continue; 705 683 706 - tsk = kthread_run(active_engine, other, 684 + if (other == engine && !(flags & TEST_SELF)) 685 + continue; 686 + 687 + threads[tmp].engine = other; 688 + threads[tmp].flags = flags; 689 + 690 + tsk = kthread_run(active_engine, &threads[tmp], 707 691 "igt/%s", other->name); 708 692 if (IS_ERR(tsk)) { 709 693 err = PTR_ERR(tsk); 710 694 goto unwind; 711 695 } 712 696 713 - threads[tmp] = tsk; 697 + threads[tmp].task = tsk; 714 698 get_task_struct(tsk); 715 699 } 716 700 717 701 set_bit(I915_RESET_ENGINE + id, &i915->gpu_error.flags); 718 702 do { 719 - if (active) { 720 - struct i915_request *rq; 703 + u32 seqno = intel_engine_get_seqno(engine); 704 + struct i915_request *rq = NULL; 721 705 706 + if (flags & TEST_ACTIVE) { 722 707 mutex_lock(&i915->drm.struct_mutex); 723 708 rq = hang_create_request(&h, engine); 724 709 if (IS_ERR(rq)) { ··· 742 705 __i915_request_add(rq, true); 743 706 mutex_unlock(&i915->drm.struct_mutex); 744 707 745 - if (!wait_for_hang(&h, rq)) { 708 + if (!wait_until_running(&h, rq)) { 746 709 struct drm_printer p = drm_info_printer(i915->drm.dev); 747 710 748 711 pr_err("%s: Failed to start request %x, at %x\n", ··· 755 718 break; 756 719 } 757 720 758 - i915_request_put(rq); 721 + GEM_BUG_ON(!rq->global_seqno); 722 + seqno = rq->global_seqno - 1; 759 723 } 760 724 761 - engine->hangcheck.stalled = true; 762 - engine->hangcheck.seqno = 763 - intel_engine_get_seqno(engine); 764 - 765 - err = i915_reset_engine(engine, I915_RESET_QUIET); 725 + err = i915_reset_engine(engine, NULL); 766 726 if (err) { 767 - pr_err("i915_reset_engine(%s:%s) failed, err=%d\n", 768 - engine->name, active ? "active" : "idle", err); 727 + pr_err("i915_reset_engine(%s:%s): failed, err=%d\n", 728 + engine->name, test_name, err); 769 729 break; 770 730 } 771 731 772 - engine->hangcheck.stalled = false; 773 732 count++; 733 + 734 + if (rq) { 735 + i915_request_wait(rq, 0, MAX_SCHEDULE_TIMEOUT); 736 + i915_request_put(rq); 737 + } 774 738 } while (time_before(jiffies, end_time)); 775 739 clear_bit(I915_RESET_ENGINE + id, &i915->gpu_error.flags); 776 740 pr_info("i915_reset_engine(%s:%s): %lu resets\n", 777 - engine->name, active ? "active" : "idle", count); 741 + engine->name, test_name, count); 778 742 779 - if (i915_reset_engine_count(&i915->gpu_error, engine) - 780 - resets[engine->id] != (active ? count : 0)) { 781 - pr_err("i915_reset_engine(%s:%s): reset %lu times, but reported %lu\n", 782 - engine->name, active ? "active" : "idle", count, 783 - i915_reset_engine_count(&i915->gpu_error, 784 - engine) - resets[engine->id]); 743 + reported = i915_reset_engine_count(&i915->gpu_error, engine); 744 + reported -= threads[engine->id].resets; 745 + if (reported != (flags & TEST_ACTIVE ? count : 0)) { 746 + pr_err("i915_reset_engine(%s:%s): reset %lu times, but reported %lu, expected %lu reported\n", 747 + engine->name, test_name, count, reported, 748 + (flags & TEST_ACTIVE ? count : 0)); 785 749 if (!err) 786 750 err = -EINVAL; 787 751 } ··· 791 753 for_each_engine(other, i915, tmp) { 792 754 int ret; 793 755 794 - if (!threads[tmp]) 756 + if (!threads[tmp].task) 795 757 continue; 796 758 797 - ret = kthread_stop(threads[tmp]); 759 + ret = kthread_stop(threads[tmp].task); 798 760 if (ret) { 799 761 pr_err("kthread for other engine %s failed, err=%d\n", 800 762 other->name, ret); 801 763 if (!err) 802 764 err = ret; 803 765 } 804 - put_task_struct(threads[tmp]); 766 + put_task_struct(threads[tmp].task); 805 767 806 - if (resets[tmp] != i915_reset_engine_count(&i915->gpu_error, 807 - other)) { 768 + if (other != engine && 769 + threads[tmp].resets != 770 + i915_reset_engine_count(&i915->gpu_error, other)) { 808 771 pr_err("Innocent engine %s was reset (count=%ld)\n", 809 772 other->name, 810 773 i915_reset_engine_count(&i915->gpu_error, 811 - other) - resets[tmp]); 774 + other) - 775 + threads[tmp].resets); 812 776 if (!err) 813 777 err = -EINVAL; 814 778 } ··· 834 794 if (i915_terminally_wedged(&i915->gpu_error)) 835 795 err = -EIO; 836 796 837 - if (active) { 797 + if (flags & TEST_ACTIVE) { 838 798 mutex_lock(&i915->drm.struct_mutex); 839 799 hang_fini(&h); 840 800 mutex_unlock(&i915->drm.struct_mutex); ··· 843 803 return err; 844 804 } 845 805 846 - static int igt_reset_idle_engine_others(void *arg) 806 + static int igt_reset_engines(void *arg) 847 807 { 848 - return __igt_reset_engine_others(arg, false); 808 + static const struct { 809 + const char *name; 810 + unsigned int flags; 811 + } phases[] = { 812 + { "idle", 0 }, 813 + { "active", TEST_ACTIVE }, 814 + { "others-idle", TEST_OTHERS }, 815 + { "others-active", TEST_OTHERS | TEST_ACTIVE }, 816 + { 817 + "others-priority", 818 + TEST_OTHERS | TEST_ACTIVE | TEST_PRIORITY 819 + }, 820 + { 821 + "self-priority", 822 + TEST_OTHERS | TEST_ACTIVE | TEST_PRIORITY | TEST_SELF, 823 + }, 824 + { } 825 + }; 826 + struct drm_i915_private *i915 = arg; 827 + typeof(*phases) *p; 828 + int err; 829 + 830 + for (p = phases; p->name; p++) { 831 + if (p->flags & TEST_PRIORITY) { 832 + if (!(i915->caps.scheduler & I915_SCHEDULER_CAP_PRIORITY)) 833 + continue; 834 + } 835 + 836 + err = __igt_reset_engines(arg, p->name, p->flags); 837 + if (err) 838 + return err; 839 + } 840 + 841 + return 0; 849 842 } 850 843 851 - static int igt_reset_active_engine_others(void *arg) 844 + static u32 fake_hangcheck(struct i915_request *rq, u32 mask) 852 845 { 853 - return __igt_reset_engine_others(arg, true); 854 - } 846 + struct i915_gpu_error *error = &rq->i915->gpu_error; 847 + u32 reset_count = i915_reset_count(error); 855 848 856 - static u32 fake_hangcheck(struct i915_request *rq) 857 - { 858 - u32 reset_count; 849 + error->stalled_mask = mask; 859 850 860 - rq->engine->hangcheck.stalled = true; 861 - rq->engine->hangcheck.seqno = intel_engine_get_seqno(rq->engine); 851 + /* set_bit() must be after we have setup the backchannel (mask) */ 852 + smp_mb__before_atomic(); 853 + set_bit(I915_RESET_HANDOFF, &error->flags); 862 854 863 - reset_count = i915_reset_count(&rq->i915->gpu_error); 864 - 865 - set_bit(I915_RESET_HANDOFF, &rq->i915->gpu_error.flags); 866 - wake_up_all(&rq->i915->gpu_error.wait_queue); 855 + wake_up_all(&error->wait_queue); 867 856 868 857 return reset_count; 869 858 } ··· 927 858 i915_request_get(rq); 928 859 __i915_request_add(rq, true); 929 860 930 - if (!wait_for_hang(&h, rq)) { 861 + if (!wait_until_running(&h, rq)) { 931 862 struct drm_printer p = drm_info_printer(i915->drm.dev); 932 863 933 864 pr_err("%s: Failed to start request %x, at %x\n", 934 865 __func__, rq->fence.seqno, hws_seqno(&h, rq)); 935 866 intel_engine_dump(rq->engine, &p, "%s\n", rq->engine->name); 936 867 937 - i915_reset(i915, 0); 938 868 i915_gem_set_wedged(i915); 939 869 940 870 err = -EIO; 941 871 goto out_rq; 942 872 } 943 873 944 - reset_count = fake_hangcheck(rq); 874 + reset_count = fake_hangcheck(rq, ALL_ENGINES); 945 875 946 876 timeout = i915_request_wait(rq, I915_WAIT_LOCKED, 10); 947 877 if (timeout < 0) { ··· 969 901 return -EIO; 970 902 971 903 return err; 904 + } 905 + 906 + static int wait_for_others(struct drm_i915_private *i915, 907 + struct intel_engine_cs *exclude) 908 + { 909 + struct intel_engine_cs *engine; 910 + enum intel_engine_id id; 911 + 912 + for_each_engine(engine, i915, id) { 913 + if (engine == exclude) 914 + continue; 915 + 916 + if (wait_for(intel_engine_is_idle(engine), 10)) 917 + return -EIO; 918 + } 919 + 920 + return 0; 972 921 } 973 922 974 923 static int igt_reset_queue(void *arg) ··· 1036 951 i915_request_get(rq); 1037 952 __i915_request_add(rq, true); 1038 953 1039 - if (!wait_for_hang(&h, prev)) { 954 + /* 955 + * XXX We don't handle resetting the kernel context 956 + * very well. If we trigger a device reset twice in 957 + * quick succession while the kernel context is 958 + * executing, we may end up skipping the breadcrumb. 959 + * This is really only a problem for the selftest as 960 + * normally there is a large interlude between resets 961 + * (hangcheck), or we focus on resetting just one 962 + * engine and so avoid repeatedly resetting innocents. 963 + */ 964 + err = wait_for_others(i915, engine); 965 + if (err) { 966 + pr_err("%s(%s): Failed to idle other inactive engines after device reset\n", 967 + __func__, engine->name); 968 + i915_request_put(rq); 969 + i915_request_put(prev); 970 + 971 + GEM_TRACE_DUMP(); 972 + i915_gem_set_wedged(i915); 973 + goto fini; 974 + } 975 + 976 + if (!wait_until_running(&h, prev)) { 1040 977 struct drm_printer p = drm_info_printer(i915->drm.dev); 1041 978 1042 - pr_err("%s: Failed to start request %x, at %x\n", 1043 - __func__, prev->fence.seqno, hws_seqno(&h, prev)); 1044 - intel_engine_dump(prev->engine, &p, 1045 - "%s\n", prev->engine->name); 979 + pr_err("%s(%s): Failed to start request %x, at %x\n", 980 + __func__, engine->name, 981 + prev->fence.seqno, hws_seqno(&h, prev)); 982 + intel_engine_dump(engine, &p, 983 + "%s\n", engine->name); 1046 984 1047 985 i915_request_put(rq); 1048 986 i915_request_put(prev); 1049 987 1050 - i915_reset(i915, 0); 1051 988 i915_gem_set_wedged(i915); 1052 989 1053 990 err = -EIO; 1054 991 goto fini; 1055 992 } 1056 993 1057 - reset_count = fake_hangcheck(prev); 994 + reset_count = fake_hangcheck(prev, ENGINE_MASK(id)); 1058 995 1059 - i915_reset(i915, I915_RESET_QUIET); 996 + i915_reset(i915, ENGINE_MASK(id), NULL); 1060 997 1061 998 GEM_BUG_ON(test_bit(I915_RESET_HANDOFF, 1062 999 &i915->gpu_error.flags)); ··· 1151 1044 if (!intel_has_reset_engine(i915)) 1152 1045 return 0; 1153 1046 1154 - if (!intel_engine_can_store_dword(i915->engine[RCS])) 1047 + if (!engine || !intel_engine_can_store_dword(engine)) 1155 1048 return 0; 1156 1049 1157 1050 mutex_lock(&i915->drm.struct_mutex); ··· 1169 1062 i915_request_get(rq); 1170 1063 __i915_request_add(rq, true); 1171 1064 1172 - if (!wait_for_hang(&h, rq)) { 1065 + if (!wait_until_running(&h, rq)) { 1173 1066 struct drm_printer p = drm_info_printer(i915->drm.dev); 1174 1067 1175 1068 pr_err("%s: Failed to start request %x, at %x\n", 1176 1069 __func__, rq->fence.seqno, hws_seqno(&h, rq)); 1177 1070 intel_engine_dump(rq->engine, &p, "%s\n", rq->engine->name); 1178 1071 1179 - i915_reset(i915, 0); 1180 1072 i915_gem_set_wedged(i915); 1181 1073 1182 1074 err = -EIO; ··· 1187 1081 /* Temporarily disable error capture */ 1188 1082 error = xchg(&i915->gpu_error.first_error, (void *)-1); 1189 1083 1190 - engine->hangcheck.stalled = true; 1191 - engine->hangcheck.seqno = intel_engine_get_seqno(engine); 1192 - 1193 - i915_handle_error(i915, intel_engine_flag(engine), "%s", __func__); 1084 + i915_handle_error(i915, ENGINE_MASK(engine->id), 0, NULL); 1194 1085 1195 1086 xchg(&i915->gpu_error.first_error, error); 1196 1087 ··· 1215 1112 SUBTEST(igt_hang_sanitycheck), 1216 1113 SUBTEST(igt_reset_idle_engine), 1217 1114 SUBTEST(igt_reset_active_engine), 1218 - SUBTEST(igt_reset_idle_engine_others), 1219 - SUBTEST(igt_reset_active_engine_others), 1115 + SUBTEST(igt_reset_engines), 1220 1116 SUBTEST(igt_wait_reset), 1221 1117 SUBTEST(igt_reset_queue), 1222 1118 SUBTEST(igt_handle_error), ··· 1230 1128 saved_hangcheck = fetch_and_zero(&i915_modparams.enable_hangcheck); 1231 1129 1232 1130 err = i915_subtests(tests, i915); 1131 + 1132 + mutex_lock(&i915->drm.struct_mutex); 1133 + flush_test(i915, I915_WAIT_LOCKED); 1134 + mutex_unlock(&i915->drm.struct_mutex); 1233 1135 1234 1136 i915_modparams.enable_hangcheck = saved_hangcheck; 1235 1137 intel_runtime_pm_put(i915);
+507
drivers/gpu/drm/i915/selftests/intel_lrc.c
··· 1 + /* 2 + * SPDX-License-Identifier: MIT 3 + * 4 + * Copyright © 2018 Intel Corporation 5 + */ 6 + 7 + #include "../i915_selftest.h" 8 + 9 + #include "mock_context.h" 10 + 11 + struct spinner { 12 + struct drm_i915_private *i915; 13 + struct drm_i915_gem_object *hws; 14 + struct drm_i915_gem_object *obj; 15 + u32 *batch; 16 + void *seqno; 17 + }; 18 + 19 + static int spinner_init(struct spinner *spin, struct drm_i915_private *i915) 20 + { 21 + unsigned int mode; 22 + void *vaddr; 23 + int err; 24 + 25 + GEM_BUG_ON(INTEL_GEN(i915) < 8); 26 + 27 + memset(spin, 0, sizeof(*spin)); 28 + spin->i915 = i915; 29 + 30 + spin->hws = i915_gem_object_create_internal(i915, PAGE_SIZE); 31 + if (IS_ERR(spin->hws)) { 32 + err = PTR_ERR(spin->hws); 33 + goto err; 34 + } 35 + 36 + spin->obj = i915_gem_object_create_internal(i915, PAGE_SIZE); 37 + if (IS_ERR(spin->obj)) { 38 + err = PTR_ERR(spin->obj); 39 + goto err_hws; 40 + } 41 + 42 + i915_gem_object_set_cache_level(spin->hws, I915_CACHE_LLC); 43 + vaddr = i915_gem_object_pin_map(spin->hws, I915_MAP_WB); 44 + if (IS_ERR(vaddr)) { 45 + err = PTR_ERR(vaddr); 46 + goto err_obj; 47 + } 48 + spin->seqno = memset(vaddr, 0xff, PAGE_SIZE); 49 + 50 + mode = HAS_LLC(i915) ? I915_MAP_WB : I915_MAP_WC; 51 + vaddr = i915_gem_object_pin_map(spin->obj, mode); 52 + if (IS_ERR(vaddr)) { 53 + err = PTR_ERR(vaddr); 54 + goto err_unpin_hws; 55 + } 56 + spin->batch = vaddr; 57 + 58 + return 0; 59 + 60 + err_unpin_hws: 61 + i915_gem_object_unpin_map(spin->hws); 62 + err_obj: 63 + i915_gem_object_put(spin->obj); 64 + err_hws: 65 + i915_gem_object_put(spin->hws); 66 + err: 67 + return err; 68 + } 69 + 70 + static unsigned int seqno_offset(u64 fence) 71 + { 72 + return offset_in_page(sizeof(u32) * fence); 73 + } 74 + 75 + static u64 hws_address(const struct i915_vma *hws, 76 + const struct i915_request *rq) 77 + { 78 + return hws->node.start + seqno_offset(rq->fence.context); 79 + } 80 + 81 + static int emit_recurse_batch(struct spinner *spin, 82 + struct i915_request *rq, 83 + u32 arbitration_command) 84 + { 85 + struct i915_address_space *vm = &rq->ctx->ppgtt->base; 86 + struct i915_vma *hws, *vma; 87 + u32 *batch; 88 + int err; 89 + 90 + vma = i915_vma_instance(spin->obj, vm, NULL); 91 + if (IS_ERR(vma)) 92 + return PTR_ERR(vma); 93 + 94 + hws = i915_vma_instance(spin->hws, vm, NULL); 95 + if (IS_ERR(hws)) 96 + return PTR_ERR(hws); 97 + 98 + err = i915_vma_pin(vma, 0, 0, PIN_USER); 99 + if (err) 100 + return err; 101 + 102 + err = i915_vma_pin(hws, 0, 0, PIN_USER); 103 + if (err) 104 + goto unpin_vma; 105 + 106 + i915_vma_move_to_active(vma, rq, 0); 107 + if (!i915_gem_object_has_active_reference(vma->obj)) { 108 + i915_gem_object_get(vma->obj); 109 + i915_gem_object_set_active_reference(vma->obj); 110 + } 111 + 112 + i915_vma_move_to_active(hws, rq, 0); 113 + if (!i915_gem_object_has_active_reference(hws->obj)) { 114 + i915_gem_object_get(hws->obj); 115 + i915_gem_object_set_active_reference(hws->obj); 116 + } 117 + 118 + batch = spin->batch; 119 + 120 + *batch++ = MI_STORE_DWORD_IMM_GEN4; 121 + *batch++ = lower_32_bits(hws_address(hws, rq)); 122 + *batch++ = upper_32_bits(hws_address(hws, rq)); 123 + *batch++ = rq->fence.seqno; 124 + 125 + *batch++ = arbitration_command; 126 + 127 + *batch++ = MI_BATCH_BUFFER_START | 1 << 8 | 1; 128 + *batch++ = lower_32_bits(vma->node.start); 129 + *batch++ = upper_32_bits(vma->node.start); 130 + *batch++ = MI_BATCH_BUFFER_END; /* not reached */ 131 + 132 + i915_gem_chipset_flush(spin->i915); 133 + 134 + err = rq->engine->emit_bb_start(rq, vma->node.start, PAGE_SIZE, 0); 135 + 136 + i915_vma_unpin(hws); 137 + unpin_vma: 138 + i915_vma_unpin(vma); 139 + return err; 140 + } 141 + 142 + static struct i915_request * 143 + spinner_create_request(struct spinner *spin, 144 + struct i915_gem_context *ctx, 145 + struct intel_engine_cs *engine, 146 + u32 arbitration_command) 147 + { 148 + struct i915_request *rq; 149 + int err; 150 + 151 + rq = i915_request_alloc(engine, ctx); 152 + if (IS_ERR(rq)) 153 + return rq; 154 + 155 + err = emit_recurse_batch(spin, rq, arbitration_command); 156 + if (err) { 157 + __i915_request_add(rq, false); 158 + return ERR_PTR(err); 159 + } 160 + 161 + return rq; 162 + } 163 + 164 + static u32 hws_seqno(const struct spinner *spin, const struct i915_request *rq) 165 + { 166 + u32 *seqno = spin->seqno + seqno_offset(rq->fence.context); 167 + 168 + return READ_ONCE(*seqno); 169 + } 170 + 171 + struct wedge_me { 172 + struct delayed_work work; 173 + struct drm_i915_private *i915; 174 + const void *symbol; 175 + }; 176 + 177 + static void wedge_me(struct work_struct *work) 178 + { 179 + struct wedge_me *w = container_of(work, typeof(*w), work.work); 180 + 181 + pr_err("%pS timed out, cancelling all further testing.\n", w->symbol); 182 + 183 + GEM_TRACE("%pS timed out.\n", w->symbol); 184 + GEM_TRACE_DUMP(); 185 + 186 + i915_gem_set_wedged(w->i915); 187 + } 188 + 189 + static void __init_wedge(struct wedge_me *w, 190 + struct drm_i915_private *i915, 191 + long timeout, 192 + const void *symbol) 193 + { 194 + w->i915 = i915; 195 + w->symbol = symbol; 196 + 197 + INIT_DELAYED_WORK_ONSTACK(&w->work, wedge_me); 198 + schedule_delayed_work(&w->work, timeout); 199 + } 200 + 201 + static void __fini_wedge(struct wedge_me *w) 202 + { 203 + cancel_delayed_work_sync(&w->work); 204 + destroy_delayed_work_on_stack(&w->work); 205 + w->i915 = NULL; 206 + } 207 + 208 + #define wedge_on_timeout(W, DEV, TIMEOUT) \ 209 + for (__init_wedge((W), (DEV), (TIMEOUT), __builtin_return_address(0)); \ 210 + (W)->i915; \ 211 + __fini_wedge((W))) 212 + 213 + static noinline int 214 + flush_test(struct drm_i915_private *i915, unsigned int flags) 215 + { 216 + struct wedge_me w; 217 + 218 + cond_resched(); 219 + 220 + wedge_on_timeout(&w, i915, HZ) 221 + i915_gem_wait_for_idle(i915, flags); 222 + 223 + return i915_terminally_wedged(&i915->gpu_error) ? -EIO : 0; 224 + } 225 + 226 + static void spinner_end(struct spinner *spin) 227 + { 228 + *spin->batch = MI_BATCH_BUFFER_END; 229 + i915_gem_chipset_flush(spin->i915); 230 + } 231 + 232 + static void spinner_fini(struct spinner *spin) 233 + { 234 + spinner_end(spin); 235 + 236 + i915_gem_object_unpin_map(spin->obj); 237 + i915_gem_object_put(spin->obj); 238 + 239 + i915_gem_object_unpin_map(spin->hws); 240 + i915_gem_object_put(spin->hws); 241 + } 242 + 243 + static bool wait_for_spinner(struct spinner *spin, struct i915_request *rq) 244 + { 245 + if (!wait_event_timeout(rq->execute, 246 + READ_ONCE(rq->global_seqno), 247 + msecs_to_jiffies(10))) 248 + return false; 249 + 250 + return !(wait_for_us(i915_seqno_passed(hws_seqno(spin, rq), 251 + rq->fence.seqno), 252 + 10) && 253 + wait_for(i915_seqno_passed(hws_seqno(spin, rq), 254 + rq->fence.seqno), 255 + 1000)); 256 + } 257 + 258 + static int live_sanitycheck(void *arg) 259 + { 260 + struct drm_i915_private *i915 = arg; 261 + struct intel_engine_cs *engine; 262 + struct i915_gem_context *ctx; 263 + enum intel_engine_id id; 264 + struct spinner spin; 265 + int err = -ENOMEM; 266 + 267 + if (!HAS_LOGICAL_RING_CONTEXTS(i915)) 268 + return 0; 269 + 270 + mutex_lock(&i915->drm.struct_mutex); 271 + 272 + if (spinner_init(&spin, i915)) 273 + goto err_unlock; 274 + 275 + ctx = kernel_context(i915); 276 + if (!ctx) 277 + goto err_spin; 278 + 279 + for_each_engine(engine, i915, id) { 280 + struct i915_request *rq; 281 + 282 + rq = spinner_create_request(&spin, ctx, engine, MI_NOOP); 283 + if (IS_ERR(rq)) { 284 + err = PTR_ERR(rq); 285 + goto err_ctx; 286 + } 287 + 288 + i915_request_add(rq); 289 + if (!wait_for_spinner(&spin, rq)) { 290 + GEM_TRACE("spinner failed to start\n"); 291 + GEM_TRACE_DUMP(); 292 + i915_gem_set_wedged(i915); 293 + err = -EIO; 294 + goto err_ctx; 295 + } 296 + 297 + spinner_end(&spin); 298 + if (flush_test(i915, I915_WAIT_LOCKED)) { 299 + err = -EIO; 300 + goto err_ctx; 301 + } 302 + } 303 + 304 + err = 0; 305 + err_ctx: 306 + kernel_context_close(ctx); 307 + err_spin: 308 + spinner_fini(&spin); 309 + err_unlock: 310 + flush_test(i915, I915_WAIT_LOCKED); 311 + mutex_unlock(&i915->drm.struct_mutex); 312 + return err; 313 + } 314 + 315 + static int live_preempt(void *arg) 316 + { 317 + struct drm_i915_private *i915 = arg; 318 + struct i915_gem_context *ctx_hi, *ctx_lo; 319 + struct spinner spin_hi, spin_lo; 320 + struct intel_engine_cs *engine; 321 + enum intel_engine_id id; 322 + int err = -ENOMEM; 323 + 324 + if (!HAS_LOGICAL_RING_PREEMPTION(i915)) 325 + return 0; 326 + 327 + mutex_lock(&i915->drm.struct_mutex); 328 + 329 + if (spinner_init(&spin_hi, i915)) 330 + goto err_unlock; 331 + 332 + if (spinner_init(&spin_lo, i915)) 333 + goto err_spin_hi; 334 + 335 + ctx_hi = kernel_context(i915); 336 + if (!ctx_hi) 337 + goto err_spin_lo; 338 + ctx_hi->priority = I915_CONTEXT_MAX_USER_PRIORITY; 339 + 340 + ctx_lo = kernel_context(i915); 341 + if (!ctx_lo) 342 + goto err_ctx_hi; 343 + ctx_lo->priority = I915_CONTEXT_MIN_USER_PRIORITY; 344 + 345 + for_each_engine(engine, i915, id) { 346 + struct i915_request *rq; 347 + 348 + rq = spinner_create_request(&spin_lo, ctx_lo, engine, 349 + MI_ARB_CHECK); 350 + if (IS_ERR(rq)) { 351 + err = PTR_ERR(rq); 352 + goto err_ctx_lo; 353 + } 354 + 355 + i915_request_add(rq); 356 + if (!wait_for_spinner(&spin_lo, rq)) { 357 + GEM_TRACE("lo spinner failed to start\n"); 358 + GEM_TRACE_DUMP(); 359 + i915_gem_set_wedged(i915); 360 + err = -EIO; 361 + goto err_ctx_lo; 362 + } 363 + 364 + rq = spinner_create_request(&spin_hi, ctx_hi, engine, 365 + MI_ARB_CHECK); 366 + if (IS_ERR(rq)) { 367 + spinner_end(&spin_lo); 368 + err = PTR_ERR(rq); 369 + goto err_ctx_lo; 370 + } 371 + 372 + i915_request_add(rq); 373 + if (!wait_for_spinner(&spin_hi, rq)) { 374 + GEM_TRACE("hi spinner failed to start\n"); 375 + GEM_TRACE_DUMP(); 376 + i915_gem_set_wedged(i915); 377 + err = -EIO; 378 + goto err_ctx_lo; 379 + } 380 + 381 + spinner_end(&spin_hi); 382 + spinner_end(&spin_lo); 383 + if (flush_test(i915, I915_WAIT_LOCKED)) { 384 + err = -EIO; 385 + goto err_ctx_lo; 386 + } 387 + } 388 + 389 + err = 0; 390 + err_ctx_lo: 391 + kernel_context_close(ctx_lo); 392 + err_ctx_hi: 393 + kernel_context_close(ctx_hi); 394 + err_spin_lo: 395 + spinner_fini(&spin_lo); 396 + err_spin_hi: 397 + spinner_fini(&spin_hi); 398 + err_unlock: 399 + flush_test(i915, I915_WAIT_LOCKED); 400 + mutex_unlock(&i915->drm.struct_mutex); 401 + return err; 402 + } 403 + 404 + static int live_late_preempt(void *arg) 405 + { 406 + struct drm_i915_private *i915 = arg; 407 + struct i915_gem_context *ctx_hi, *ctx_lo; 408 + struct spinner spin_hi, spin_lo; 409 + struct intel_engine_cs *engine; 410 + enum intel_engine_id id; 411 + int err = -ENOMEM; 412 + 413 + if (!HAS_LOGICAL_RING_PREEMPTION(i915)) 414 + return 0; 415 + 416 + mutex_lock(&i915->drm.struct_mutex); 417 + 418 + if (spinner_init(&spin_hi, i915)) 419 + goto err_unlock; 420 + 421 + if (spinner_init(&spin_lo, i915)) 422 + goto err_spin_hi; 423 + 424 + ctx_hi = kernel_context(i915); 425 + if (!ctx_hi) 426 + goto err_spin_lo; 427 + 428 + ctx_lo = kernel_context(i915); 429 + if (!ctx_lo) 430 + goto err_ctx_hi; 431 + 432 + for_each_engine(engine, i915, id) { 433 + struct i915_request *rq; 434 + 435 + rq = spinner_create_request(&spin_lo, ctx_lo, engine, 436 + MI_ARB_CHECK); 437 + if (IS_ERR(rq)) { 438 + err = PTR_ERR(rq); 439 + goto err_ctx_lo; 440 + } 441 + 442 + i915_request_add(rq); 443 + if (!wait_for_spinner(&spin_lo, rq)) { 444 + pr_err("First context failed to start\n"); 445 + goto err_wedged; 446 + } 447 + 448 + rq = spinner_create_request(&spin_hi, ctx_hi, engine, MI_NOOP); 449 + if (IS_ERR(rq)) { 450 + spinner_end(&spin_lo); 451 + err = PTR_ERR(rq); 452 + goto err_ctx_lo; 453 + } 454 + 455 + i915_request_add(rq); 456 + if (wait_for_spinner(&spin_hi, rq)) { 457 + pr_err("Second context overtook first?\n"); 458 + goto err_wedged; 459 + } 460 + 461 + engine->schedule(rq, I915_PRIORITY_MAX); 462 + 463 + if (!wait_for_spinner(&spin_hi, rq)) { 464 + pr_err("High priority context failed to preempt the low priority context\n"); 465 + GEM_TRACE_DUMP(); 466 + goto err_wedged; 467 + } 468 + 469 + spinner_end(&spin_hi); 470 + spinner_end(&spin_lo); 471 + if (flush_test(i915, I915_WAIT_LOCKED)) { 472 + err = -EIO; 473 + goto err_ctx_lo; 474 + } 475 + } 476 + 477 + err = 0; 478 + err_ctx_lo: 479 + kernel_context_close(ctx_lo); 480 + err_ctx_hi: 481 + kernel_context_close(ctx_hi); 482 + err_spin_lo: 483 + spinner_fini(&spin_lo); 484 + err_spin_hi: 485 + spinner_fini(&spin_hi); 486 + err_unlock: 487 + flush_test(i915, I915_WAIT_LOCKED); 488 + mutex_unlock(&i915->drm.struct_mutex); 489 + return err; 490 + 491 + err_wedged: 492 + spinner_end(&spin_hi); 493 + spinner_end(&spin_lo); 494 + i915_gem_set_wedged(i915); 495 + err = -EIO; 496 + goto err_ctx_lo; 497 + } 498 + 499 + int intel_execlists_live_selftests(struct drm_i915_private *i915) 500 + { 501 + static const struct i915_subtest tests[] = { 502 + SUBTEST(live_sanitycheck), 503 + SUBTEST(live_preempt), 504 + SUBTEST(live_late_preempt), 505 + }; 506 + return i915_subtests(tests, i915); 507 + }
+10
include/drm/drm_dp_helper.h
··· 478 478 # define DP_PSR_FRAME_CAPTURE (1 << 3) 479 479 # define DP_PSR_SELECTIVE_UPDATE (1 << 4) 480 480 # define DP_PSR_IRQ_HPD_WITH_CRC_ERRORS (1 << 5) 481 + # define DP_PSR_ENABLE_PSR2 (1 << 6) /* eDP 1.4a */ 481 482 482 483 #define DP_ADAPTER_CTRL 0x1a0 483 484 # define DP_ADAPTER_CTRL_FORCE_LOAD_SENSE (1 << 0) ··· 794 793 # define DP_MAX_RESYNC_FRAME_COUNT_SHIFT 0 795 794 # define DP_LAST_ACTUAL_SYNCHRONIZATION_LATENCY_MASK (0xf << 4) 796 795 # define DP_LAST_ACTUAL_SYNCHRONIZATION_LATENCY_SHIFT 4 796 + 797 + #define DP_LAST_RECEIVED_PSR_SDP 0x200a /* eDP 1.2 */ 798 + # define DP_PSR_STATE_BIT (1 << 0) /* eDP 1.2 */ 799 + # define DP_UPDATE_RFB_BIT (1 << 1) /* eDP 1.2 */ 800 + # define DP_CRC_VALID_BIT (1 << 2) /* eDP 1.2 */ 801 + # define DP_SU_VALID (1 << 3) /* eDP 1.4 */ 802 + # define DP_FIRST_SCAN_LINE_SU_REGION (1 << 4) /* eDP 1.4 */ 803 + # define DP_LAST_SCAN_LINE_SU_REGION (1 << 5) /* eDP 1.4 */ 804 + # define DP_Y_COORDINATE_VALID (1 << 6) /* eDP 1.4a */ 797 805 798 806 #define DP_RECEIVER_ALPM_STATUS 0x200b /* eDP 1.4 */ 799 807 # define DP_ALPM_LOCK_TIMEOUT_ERROR (1 << 0)