History

Merge tag 'drm-intel-next-2017-01-23' of git://anongit.freedesktop.org/git/drm-intel into drm-next

Final block of feature work for 4.11: - gen8 pd cleanup from Matthew Auld - more cleanups for view/vma (Chris) - dmc support on glk (Anusha Srivatsa) - use core crc api (Tomue) - track wedged requests using fence.error (Chris) - lots of psr fixes (Nagaraju, Vathsala) - dp mst support, acked for merging through drm-intel by Takashi (Libin) - huc loading support, including uapi for libva to use it (Anusha Srivatsa) * tag 'drm-intel-next-2017-01-23' of git://anongit.freedesktop.org/git/drm-intel: (111 commits) drm/i915: Update DRIVER_DATE to 20170123 drm/i915: reinstate call to trace_i915_vma_bind drm/i915: Assert that created vma has a whole number of pages drm/i915: Assert the drm_mm_node is allocated when on the VM lists drm/i915: Treat an error from i915_vma_instance() as unlikely drm/i915: Reject vma creation larger than address space drm/i915: Use common LRU inactive vma bumping for unpin_from_display drm/i915: Do an unlocked wait before set-cache-level ioctl drm/i915/huc: Assert that HuC vma is placed in GuC accessible range drm/i915/huc: Avoid attempting to authenticate non-existent fw drm/i915: Set adjustment to zero on Up/Down interrupts if freq is already max/min drm/i915: Remove the double handling of 'flags from intel_mode_from_pipe_config() drm/i915: Remove crtc->config usage from intel_modeset_readout_hw_state() drm/i915: Release temporary load-detect state upon switching drm/i915: Remove i915_gem_object_to_ggtt() drm/i915: Remove i915_vma_create from VMA API drm/i915: Add a check that the VMA instance we lookup matches the request drm/i915: Rename some warts in the VMA API drm/i915: Track pinned vma in intel_plane_state drm/i915/get_params: Add HuC status to getparams ...

Dave Airlie committed 9 years ago

Commit a7e26412 parents c4d79c2 add632958 files · +3257 −1891Browse files

Unified · Split

58 files
  1. Documentation/sound/hd-audio/dp-mst.rst +17 −0
  2. drivers/gpu/drm/i915/Makefile +2 −0
  3. drivers/gpu/drm/i915/gvt/aperture_gm.c +10 −23
  4. drivers/gpu/drm/i915/i915_debugfs.c +95 −8
  5. drivers/gpu/drm/i915/i915_drv.c +29 −31
  6. drivers/gpu/drm/i915/i915_drv.h +26 −44
  7. drivers/gpu/drm/i915/i915_gem.c +170 −165
  8. drivers/gpu/drm/i915/i915_gem_context.c +30 −25
  9. drivers/gpu/drm/i915/i915_gem_evict.c +21 −18
  10. drivers/gpu/drm/i915/i915_gem_execbuffer.c +3 −4
  11. drivers/gpu/drm/i915/i915_gem_fence_reg.c +26 −38
  12. drivers/gpu/drm/i915/i915_gem_fence_reg.h +2 −0
  13. drivers/gpu/drm/i915/i915_gem_gtt.c +304 −134
  14. drivers/gpu/drm/i915/i915_gem_gtt.h +57 −17
  15. drivers/gpu/drm/i915/i915_gem_internal.c +7 −1
  16. drivers/gpu/drm/i915/i915_gem_object.h +23 −0
  17. drivers/gpu/drm/i915/i915_gem_render_state.c +3 −3
  18. drivers/gpu/drm/i915/i915_gem_request.c +10 −25
  19. drivers/gpu/drm/i915/i915_gem_stolen.c +9 −7
  20. drivers/gpu/drm/i915/i915_gem_tiling.c +217 −130
  21. drivers/gpu/drm/i915/i915_gpu_error.c +1 −0
  22. drivers/gpu/drm/i915/i915_guc_reg.h +6 −0
  23. drivers/gpu/drm/i915/i915_guc_submission.c +9 −594
  24. drivers/gpu/drm/i915/i915_irq.c +60 −26
  25. drivers/gpu/drm/i915/i915_reg.h +17 −3
  26. drivers/gpu/drm/i915/i915_sw_fence.c +1 −0
  27. drivers/gpu/drm/i915/i915_sysfs.c +1 −1
  28. drivers/gpu/drm/i915/i915_trace.h +8 −8
  29. drivers/gpu/drm/i915/i915_vgpu.c +12 −21
  30. drivers/gpu/drm/i915/i915_vma.c +129 −92
  31. drivers/gpu/drm/i915/i915_vma.h +31 −10
  32. drivers/gpu/drm/i915/intel_atomic_plane.c +20 −0
  33. drivers/gpu/drm/i915/intel_csr.c +10 −2
  34. drivers/gpu/drm/i915/intel_device_info.c +1 −1
  35. drivers/gpu/drm/i915/intel_display.c +87 −116
  36. drivers/gpu/drm/i915/intel_dp.c +37 −1
  37. drivers/gpu/drm/i915/intel_drv.h +13 −2
  38. drivers/gpu/drm/i915/intel_engine_cs.c +1 −1
  39. drivers/gpu/drm/i915/intel_fbc.c +21 −33
  40. drivers/gpu/drm/i915/intel_fbdev.c +5 −2
  41. drivers/gpu/drm/i915/intel_guc_fwif.h +20 −4
  42. drivers/gpu/drm/i915/intel_guc_loader.c +114 −100
  43. drivers/gpu/drm/i915/intel_guc_log.c +658 −0
  44. drivers/gpu/drm/i915/intel_huc.c +338 −0
  45. drivers/gpu/drm/i915/intel_lrc.c +6 −18
  46. drivers/gpu/drm/i915/intel_lrc.h +1 −1
  47. drivers/gpu/drm/i915/intel_overlay.c +1 −2
  48. drivers/gpu/drm/i915/intel_pipe_crc.c +88 −16
  49. drivers/gpu/drm/i915/intel_psr.c +160 −43
  50. drivers/gpu/drm/i915/intel_ringbuffer.c +8 −8
  51. drivers/gpu/drm/i915/intel_sprite.c +4 −4
  52. drivers/gpu/drm/i915/intel_uc.c +0 −26
  53. drivers/gpu/drm/i915/intel_uc.h +47 −26
  54. include/drm/drm_dp_helper.h +12 −1
  55. include/uapi/drm/i915_drm.h +1 −0
  56. sound/pci/hda/hda_codec.c +72 −4
  57. sound/pci/hda/hda_codec.h +3 −0
  58. sound/pci/hda/patch_hdmi.c +193 −52
Documentation/sound/hd-audio/dp-mst.rst+17−0
@@ -19,6 +19,23 @@ PCM · 18 unmodified lines
1919 ===
2020 To be added
2121
22+Pin Initialization
23+==================
24+Each pin may have several device entries (virtual pins). On Intel platform,
25+the device entries number is dynamically changed. If DP MST hub is connected,
26+it is in DP MST mode, and the device entries number is 3. Otherwise, the
27+device entries number is 1.
28+
29+To simplify the implementation, all the device entries will be initialized
30+when bootup no matter whether it is in DP MST mode or not.
31+
32+Connection list
33+===============
34+DP MST reuses connection list code. The code can be reused because
35+device entries on the same pin have the same connection list.
36+
37+This means DP MST gets the device entry connection list without the
38+device entry setting.
2239
2340 Jack
2441 ====
drivers/gpu/drm/i915/Makefile+2−0
@@ -56,7 +56,9 @@ i915-y += i915_cmd_parser.o \ · 55 unmodified lines
5656
5757 # general-purpose microcontroller (GuC) support
5858 i915-y += intel_uc.o \
59+ intel_guc_log.o \
5960 intel_guc_loader.o \
61+ intel_huc.o \
6062 i915_guc_submission.o
6163
6264 # autogenerated null render state
drivers/gpu/drm/i915/gvt/aperture_gm.c+10−23
@@ -41,47 +41,34 @@ static int alloc_gm(struct intel_vgpu *vgpu, bool high_gm) · 40 unmodified lines
4141 {
4242 struct intel_gvt *gvt = vgpu->gvt;
4343 struct drm_i915_private *dev_priv = gvt->dev_priv;
44− u32 alloc_flag, search_flag;
44+ unsigned int flags;
4545 u64 start, end, size;
4646 struct drm_mm_node *node;
47− int retried = 0;
4847 int ret;
4948
5049 if (high_gm) {
51− search_flag = DRM_MM_SEARCH_BELOW;
52− alloc_flag = DRM_MM_CREATE_TOP;
5350 node = &vgpu->gm.high_gm_node;
5451 size = vgpu_hidden_sz(vgpu);
5552 start = gvt_hidden_gmadr_base(gvt);
5653 end = gvt_hidden_gmadr_end(gvt);
54+ flags = PIN_HIGH;
5755 } else {
58− search_flag = DRM_MM_SEARCH_DEFAULT;
59− alloc_flag = DRM_MM_CREATE_DEFAULT;
6056 node = &vgpu->gm.low_gm_node;
6157 size = vgpu_aperture_sz(vgpu);
6258 start = gvt_aperture_gmadr_base(gvt);
6359 end = gvt_aperture_gmadr_end(gvt);
60+ flags = PIN_MAPPABLE;
6461 }
6562
6663 mutex_lock(&dev_priv->drm.struct_mutex);
67−search_again:
68− ret = drm_mm_insert_node_in_range_generic(&dev_priv->ggtt.base.mm,
69− node, size, 4096,
70− I915_COLOR_UNEVICTABLE,
71− start, end, search_flag,
72− alloc_flag);
73− if (ret) {
74− ret = i915_gem_evict_something(&dev_priv->ggtt.base,
75− size, 4096,
76− I915_COLOR_UNEVICTABLE,
77− start, end, 0);
78− if (ret == 0 && ++retried < 3)
79− goto search_again;
80−
81− gvt_err("fail to alloc %s gm space from host, retried %d\n",
82− high_gm ? "high" : "low", retried);
83− }
64+ ret = i915_gem_gtt_insert(&dev_priv->ggtt.base, node,
65+ size, 4096, I915_COLOR_UNEVICTABLE,
66+ start, end, flags);
8467 mutex_unlock(&dev_priv->drm.struct_mutex);
68+ if (ret)
69+ gvt_err("fail to alloc %s gm space from host\n",
70+ high_gm ? "high" : "low");
71+
8572 return ret;
8673 }
8774
drivers/gpu/drm/i915/i915_debugfs.c+95−8
@@ -159,8 +159,35 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) · 158 unmodified lines
159159 seq_printf(m, " (%sgtt offset: %08llx, size: %08llx",
160160 i915_vma_is_ggtt(vma) ? "g" : "pp",
161161 vma->node.start, vma->node.size);
162− if (i915_vma_is_ggtt(vma))
163− seq_printf(m, ", type: %u", vma->ggtt_view.type);
162+ if (i915_vma_is_ggtt(vma)) {
163+ switch (vma->ggtt_view.type) {
164+ case I915_GGTT_VIEW_NORMAL:
165+ seq_puts(m, ", normal");
166+ break;
167+
168+ case I915_GGTT_VIEW_PARTIAL:
169+ seq_printf(m, ", partial [%08llx+%x]",
170+ vma->ggtt_view.partial.offset << PAGE_SHIFT,
171+ vma->ggtt_view.partial.size << PAGE_SHIFT);
172+ break;
173+
174+ case I915_GGTT_VIEW_ROTATED:
175+ seq_printf(m, ", rotated [(%ux%u, stride=%u, offset=%u), (%ux%u, stride=%u, offset=%u)]",
176+ vma->ggtt_view.rotated.plane[0].width,
177+ vma->ggtt_view.rotated.plane[0].height,
178+ vma->ggtt_view.rotated.plane[0].stride,
179+ vma->ggtt_view.rotated.plane[0].offset,
180+ vma->ggtt_view.rotated.plane[1].width,
181+ vma->ggtt_view.rotated.plane[1].height,
182+ vma->ggtt_view.rotated.plane[1].stride,
183+ vma->ggtt_view.rotated.plane[1].offset);
184+ break;
185+
186+ default:
187+ MISSING_CASE(vma->ggtt_view.type);
188+ break;
189+ }
190+ }
164191 if (vma->fence)
165192 seq_printf(m, " , fence: %d%s",
166193 vma->fence->id,
@@ -2325,10 +2352,40 @@ static int i915_llc(struct seq_file *m, void *data) · 2158 unmodified lines
23252352 return 0;
23262353 }
23272354
2355+static int i915_huc_load_status_info(struct seq_file *m, void *data)
2356+{
2357+ struct drm_i915_private *dev_priv = node_to_i915(m->private);
2358+ struct intel_uc_fw *huc_fw = &dev_priv->huc.fw;
2359+
2360+ if (!HAS_HUC_UCODE(dev_priv))
2361+ return 0;
2362+
2363+ seq_puts(m, "HuC firmware status:\n");
2364+ seq_printf(m, "\tpath: %s\n", huc_fw->path);
2365+ seq_printf(m, "\tfetch: %s\n",
2366+ intel_uc_fw_status_repr(huc_fw->fetch_status));
2367+ seq_printf(m, "\tload: %s\n",
2368+ intel_uc_fw_status_repr(huc_fw->load_status));
2369+ seq_printf(m, "\tversion wanted: %d.%d\n",
2370+ huc_fw->major_ver_wanted, huc_fw->minor_ver_wanted);
2371+ seq_printf(m, "\tversion found: %d.%d\n",
2372+ huc_fw->major_ver_found, huc_fw->minor_ver_found);
2373+ seq_printf(m, "\theader: offset is %d; size = %d\n",
2374+ huc_fw->header_offset, huc_fw->header_size);
2375+ seq_printf(m, "\tuCode: offset is %d; size = %d\n",
2376+ huc_fw->ucode_offset, huc_fw->ucode_size);
2377+ seq_printf(m, "\tRSA: offset is %d; size = %d\n",
2378+ huc_fw->rsa_offset, huc_fw->rsa_size);
2379+
2380+ seq_printf(m, "\nHuC status 0x%08x:\n", I915_READ(HUC_STATUS2));
2381+
2382+ return 0;
2383+}
2384+
23282385 static int i915_guc_load_status_info(struct seq_file *m, void *data)
23292386 {
23302387 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2331− struct intel_guc_fw *guc_fw = &dev_priv->guc.guc_fw;
2388+ struct intel_uc_fw *guc_fw = &dev_priv->guc.fw;
23322389 u32 tmp, i;
23332390
23342391 if (!HAS_GUC_UCODE(dev_priv))
@@ -2336,15 +2393,15 @@ static int i915_guc_load_status_info(struct seq_file *m, void *data) · 1 unmodified line
23362393
23372394 seq_printf(m, "GuC firmware status:\n");
23382395 seq_printf(m, "\tpath: %s\n",
2339− guc_fw->guc_fw_path);
2396+ guc_fw->path);
23402397 seq_printf(m, "\tfetch: %s\n",
2341− intel_guc_fw_status_repr(guc_fw->guc_fw_fetch_status));
2398+ intel_uc_fw_status_repr(guc_fw->fetch_status));
23422399 seq_printf(m, "\tload: %s\n",
2343− intel_guc_fw_status_repr(guc_fw->guc_fw_load_status));
2400+ intel_uc_fw_status_repr(guc_fw->load_status));
23442401 seq_printf(m, "\tversion wanted: %d.%d\n",
2345− guc_fw->guc_fw_major_wanted, guc_fw->guc_fw_minor_wanted);
2402+ guc_fw->major_ver_wanted, guc_fw->minor_ver_wanted);
23462403 seq_printf(m, "\tversion found: %d.%d\n",
2347− guc_fw->guc_fw_major_found, guc_fw->guc_fw_minor_found);
2404+ guc_fw->major_ver_found, guc_fw->minor_ver_found);
23482405 seq_printf(m, "\theader: offset is %d; size = %d\n",
23492406 guc_fw->header_offset, guc_fw->header_size);
23502407 seq_printf(m, "\tuCode: offset is %d; size = %d\n",
@@ -2532,6 +2589,29 @@ DEFINE_SIMPLE_ATTRIBUTE(i915_guc_log_control_fops, · 181 unmodified lines
25322589 i915_guc_log_control_get, i915_guc_log_control_set,
25332590 "%lld\n");
25342591
2592+static const char *psr2_live_status(u32 val)
2593+{
2594+ static const char * const live_status[] = {
2595+ "IDLE",
2596+ "CAPTURE",
2597+ "CAPTURE_FS",
2598+ "SLEEP",
2599+ "BUFON_FW",
2600+ "ML_UP",
2601+ "SU_STANDBY",
2602+ "FAST_SLEEP",
2603+ "DEEP_SLEEP",
2604+ "BUF_ON",
2605+ "TG_ON"
2606+ };
2607+
2608+ val = (val & EDP_PSR2_STATUS_STATE_MASK) >> EDP_PSR2_STATUS_STATE_SHIFT;
2609+ if (val < ARRAY_SIZE(live_status))
2610+ return live_status[val];
2611+
2612+ return "unknown";
2613+}
2614+
25352615 static int i915_edp_psr_status(struct seq_file *m, void *data)
25362616 {
25372617 struct drm_i915_private *dev_priv = node_to_i915(m->private);
@@ -2606,6 +2686,12 @@ static int i915_edp_psr_status(struct seq_file *m, void *data) · 68 unmodified lines
26062686
26072687 seq_printf(m, "Performance_Counter: %u\n", psrperf);
26082688 }
2689+ if (dev_priv->psr.psr2_support) {
2690+ u32 psr2 = I915_READ(EDP_PSR2_STATUS_CTL);
2691+
2692+ seq_printf(m, "EDP_PSR2_STATUS_CTL: %x [%s]\n",
2693+ psr2, psr2_live_status(psr2));
2694+ }
26092695 mutex_unlock(&dev_priv->psr.lock);
26102696
26112697 intel_runtime_pm_put(dev_priv);
@@ -4553,6 +4639,7 @@ static const struct drm_info_list i915_debugfs_list[] = { · 1941 unmodified lines
45534639 {"i915_guc_info", i915_guc_info, 0},
45544640 {"i915_guc_load_status", i915_guc_load_status_info, 0},
45554641 {"i915_guc_log_dump", i915_guc_log_dump, 0},
4642+ {"i915_huc_load_status", i915_huc_load_status_info, 0},
45564643 {"i915_frequency_info", i915_frequency_info, 0},
45574644 {"i915_hangcheck_info", i915_hangcheck_info, 0},
45584645 {"i915_drpc_info", i915_drpc_info, 0},
drivers/gpu/drm/i915/i915_drv.c+29−31
@@ -49,6 +49,7 @@ · 48 unmodified lines
4949 #include "i915_trace.h"
5050 #include "i915_vgpu.h"
5151 #include "intel_drv.h"
52+#include "intel_uc.h"
5253
5354 static struct drm_driver driver;
5455
@@ -315,6 +316,12 @@ static int i915_getparam(struct drm_device *dev, void *data, · 260 unmodified lines
315316 case I915_PARAM_MIN_EU_IN_POOL:
316317 value = INTEL_INFO(dev_priv)->sseu.min_eu_in_pool;
317318 break;
319+ case I915_PARAM_HUC_STATUS:
320+ /* The register is already force-woken. We dont need
321+ * any rpm here
322+ */
323+ value = I915_READ(HUC_STATUS2) & HUC_FW_VERIFIED;
324+ break;
318325 case I915_PARAM_MMAP_GTT_VERSION:
319326 /* Though we've started our numbering from 1, and so class all
320327 * earlier versions as 0, in effect their value is undefined as
@@ -599,6 +606,7 @@ static int i915_load_modeset_init(struct drm_device *dev) · 278 unmodified lines
599606 if (ret)
600607 goto cleanup_irq;
601608
609+ intel_huc_init(dev_priv);
602610 intel_guc_init(dev_priv);
603611
604612 ret = i915_gem_init(dev_priv);
@@ -627,6 +635,7 @@ cleanup_gem: · 22 unmodified lines
627635 i915_gem_fini(dev_priv);
628636 cleanup_irq:
629637 intel_guc_fini(dev_priv);
638+ intel_huc_fini(dev_priv);
630639 drm_irq_uninstall(dev);
631640 intel_teardown_gmbus(dev_priv);
632641 cleanup_csr:
@@ -1114,7 +1123,7 @@ static void i915_driver_register(struct drm_i915_private *dev_priv) · 481 unmodified lines
11141123 /* Reveal our presence to userspace */
11151124 if (drm_dev_register(dev, 0) == 0) {
11161125 i915_debugfs_register(dev_priv);
1117− i915_guc_register(dev_priv);
1126+ i915_guc_log_register(dev_priv);
11181127 i915_setup_sysfs(dev_priv);
11191128
11201129 /* Depends on sysfs having been initialized */
@@ -1158,7 +1167,7 @@ static void i915_driver_unregister(struct drm_i915_private *dev_priv) · 37 unmodified lines
11581167 i915_perf_unregister(dev_priv);
11591168
11601169 i915_teardown_sysfs(dev_priv);
1161− i915_guc_unregister(dev_priv);
1170+ i915_guc_log_unregister(dev_priv);
11621171 i915_debugfs_unregister(dev_priv);
11631172 drm_dev_unregister(&dev_priv->drm);
11641173
@@ -1314,6 +1323,7 @@ void i915_driver_unload(struct drm_device *dev) · 149 unmodified lines
13141323 drain_workqueue(dev_priv->wq);
13151324
13161325 intel_guc_fini(dev_priv);
1326+ intel_huc_fini(dev_priv);
13171327 i915_gem_fini(dev_priv);
13181328 intel_fbc_cleanup_cfb(dev_priv);
13191329
@@ -1471,7 +1481,7 @@ static int i915_drm_suspend_late(struct drm_device *dev, bool hibernation) · 151 unmodified lines
14711481
14721482 intel_display_set_init_power(dev_priv, false);
14731483
1474− fw_csr = !IS_BROXTON(dev_priv) &&
1484+ fw_csr = !IS_GEN9_LP(dev_priv) &&
14751485 suspend_to_idle(dev_priv) && dev_priv->csr.dmc_payload;
14761486 /*
14771487 * In case of firmware assisted context save/restore don't manually
@@ -1484,7 +1494,7 @@ static int i915_drm_suspend_late(struct drm_device *dev, bool hibernation) · 6 unmodified lines
14841494 intel_power_domains_suspend(dev_priv);
14851495
14861496 ret = 0;
1487− if (IS_BROXTON(dev_priv))
1497+ if (IS_GEN9_LP(dev_priv))
14881498 bxt_enable_dc9(dev_priv);
14891499 else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
14901500 hsw_enable_pc8(dev_priv);
@@ -1692,7 +1702,7 @@ static int i915_drm_resume_early(struct drm_device *dev) · 201 unmodified lines
16921702
16931703 intel_uncore_early_sanitize(dev_priv, true);
16941704
1695− if (IS_BROXTON(dev_priv)) {
1705+ if (IS_GEN9_LP(dev_priv)) {
16961706 if (!dev_priv->suspended_to_idle)
16971707 gen9_sanitize_dc_state(dev_priv);
16981708 bxt_disable_dc9(dev_priv);
@@ -1702,7 +1712,7 @@ static int i915_drm_resume_early(struct drm_device *dev) · 3 unmodified lines
17021712
17031713 intel_uncore_sanitize(dev_priv);
17041714
1705− if (IS_BROXTON(dev_priv) ||
1715+ if (IS_GEN9_LP(dev_priv) ||
17061716 !(dev_priv->suspended_to_idle && dev_priv->csr.dmc_payload))
17071717 intel_power_domains_init_hw(dev_priv, true);
17081718
@@ -1728,25 +1738,9 @@ static int i915_resume_switcheroo(struct drm_device *dev) · 19 unmodified lines
17281738 return i915_drm_resume(dev);
17291739 }
17301740
1731−static void disable_engines_irq(struct drm_i915_private *dev_priv)
1732−{
1733− struct intel_engine_cs *engine;
1734− enum intel_engine_id id;
1735−
1736− /* Ensure irq handler finishes, and not run again. */
1737− disable_irq(dev_priv->drm.irq);
1738− for_each_engine(engine, dev_priv, id)
1739− tasklet_kill(&engine->irq_tasklet);
1740−}
1741−
1742−static void enable_engines_irq(struct drm_i915_private *dev_priv)
1743−{
1744− enable_irq(dev_priv->drm.irq);
1745−}
1746−
17471741 /**
17481742 * i915_reset - reset chip after a hang
1749− * @dev: drm device to reset
1743+ * @dev_priv: device private to reset
17501744 *
17511745 * Reset the chip. Useful if a hang is detected. Marks the device as wedged
17521746 * on failure.
@@ -1776,12 +1770,15 @@ void i915_reset(struct drm_i915_private *dev_priv) · 23 unmodified lines
17761770 error->reset_count++;
17771771
17781772 pr_notice("drm/i915: Resetting chip after gpu hang\n");
1779− i915_gem_reset_prepare(dev_priv);
1773+ disable_irq(dev_priv->drm.irq);
1774+ ret = i915_gem_reset_prepare(dev_priv);
1775+ if (ret) {
1776+ DRM_ERROR("GPU recovery failed\n");
1777+ intel_gpu_reset(dev_priv, ALL_ENGINES);
1778+ goto error;
1779+ }
17801780
1781− disable_engines_irq(dev_priv);
17821781 ret = intel_gpu_reset(dev_priv, ALL_ENGINES);
1783− enable_engines_irq(dev_priv);
1784−
17851782 if (ret) {
17861783 if (ret != -ENODEV)
17871784 DRM_ERROR("Failed to reset chip: %i\n", ret);
@@ -1816,6 +1813,7 @@ void i915_reset(struct drm_i915_private *dev_priv) · 28 unmodified lines
18161813 i915_queue_hangcheck(dev_priv);
18171814
18181815 wakeup:
1816+ enable_irq(dev_priv->drm.irq);
18191817 wake_up_bit(&error->flags, I915_RESET_IN_PROGRESS);
18201818 return;
18211819
@@ -2326,7 +2324,7 @@ static int intel_runtime_suspend(struct device *kdev) · 504 unmodified lines
23262324 intel_runtime_pm_disable_interrupts(dev_priv);
23272325
23282326 ret = 0;
2329− if (IS_BROXTON(dev_priv)) {
2327+ if (IS_GEN9_LP(dev_priv)) {
23302328 bxt_display_core_uninit(dev_priv);
23312329 bxt_enable_dc9(dev_priv);
23322330 } else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) {
@@ -2411,7 +2409,7 @@ static int intel_runtime_resume(struct device *kdev) · 78 unmodified lines
24112409 if (IS_GEN6(dev_priv))
24122410 intel_init_pch_refclk(dev_priv);
24132411
2414− if (IS_BROXTON(dev_priv)) {
2412+ if (IS_GEN9_LP(dev_priv)) {
24152413 bxt_disable_dc9(dev_priv);
24162414 bxt_display_core_init(dev_priv, true);
24172415 if (dev_priv->csr.dmc_payload &&
@@ -2549,8 +2547,8 @@ static const struct drm_ioctl_desc i915_ioctls[] = { · 131 unmodified lines
25492547 DRM_IOCTL_DEF_DRV(I915_GEM_MMAP_GTT, i915_gem_mmap_gtt_ioctl, DRM_RENDER_ALLOW),
25502548 DRM_IOCTL_DEF_DRV(I915_GEM_SET_DOMAIN, i915_gem_set_domain_ioctl, DRM_RENDER_ALLOW),
25512549 DRM_IOCTL_DEF_DRV(I915_GEM_SW_FINISH, i915_gem_sw_finish_ioctl, DRM_RENDER_ALLOW),
2552− DRM_IOCTL_DEF_DRV(I915_GEM_SET_TILING, i915_gem_set_tiling, DRM_RENDER_ALLOW),
2553− DRM_IOCTL_DEF_DRV(I915_GEM_GET_TILING, i915_gem_get_tiling, DRM_RENDER_ALLOW),
2550+ DRM_IOCTL_DEF_DRV(I915_GEM_SET_TILING, i915_gem_set_tiling_ioctl, DRM_RENDER_ALLOW),
2551+ DRM_IOCTL_DEF_DRV(I915_GEM_GET_TILING, i915_gem_get_tiling_ioctl, DRM_RENDER_ALLOW),
25542552 DRM_IOCTL_DEF_DRV(I915_GEM_GET_APERTURE, i915_gem_get_aperture_ioctl, DRM_RENDER_ALLOW),
25552553 DRM_IOCTL_DEF_DRV(I915_GET_PIPE_FROM_CRTC_ID, intel_get_pipe_from_crtc_id, 0),
25562554 DRM_IOCTL_DEF_DRV(I915_GEM_MADVISE, i915_gem_madvise_ioctl, DRM_RENDER_ALLOW),
drivers/gpu/drm/i915/i915_drv.h+26−44
@@ -78,8 +78,8 @@ · 77 unmodified lines
7878
7979 #define DRIVER_NAME "i915"
8080 #define DRIVER_DESC "Intel Graphics"
81−#define DRIVER_DATE "20170109"
82−#define DRIVER_TIMESTAMP 1483953121
81+#define DRIVER_DATE "20170123"
82+#define DRIVER_TIMESTAMP 1485156432
8383
8484 #undef WARN_ON
8585 /* Many gcc seem to no see through this and fall over :( */
@@ -1069,6 +1069,8 @@ struct intel_fbc { · 983 unmodified lines
10691069 struct work_struct underrun_work;
10701070
10711071 struct intel_fbc_state_cache {
1072+ struct i915_vma *vma;
1073+
10721074 struct {
10731075 unsigned int mode_flags;
10741076 uint32_t hsw_bdw_pixel_rate;
@@ -1082,15 +1084,14 @@ struct intel_fbc { · 7 unmodified lines
10821084 } plane;
10831085
10841086 struct {
1085− u64 ilk_ggtt_offset;
10861087 const struct drm_format_info *format;
10871088 unsigned int stride;
1088− int fence_reg;
1089− unsigned int tiling_mode;
10901089 } fb;
10911090 } state_cache;
10921091
10931092 struct intel_fbc_reg_params {
1093+ struct i915_vma *vma;
1094+
10941095 struct {
10951096 enum pipe pipe;
10961097 enum plane plane;
@@ -1098,10 +1099,8 @@ struct intel_fbc { · 1 unmodified line
10981099 } crtc;
10991100
11001101 struct {
1101− u64 ggtt_offset;
11021102 const struct drm_format_info *format;
11031103 unsigned int stride;
1104− int fence_reg;
11051104 } fb;
11061105
11071106 int cfb_size;
@@ -1154,6 +1153,9 @@ struct i915_psr { · 46 unmodified lines
11541153 bool psr2_support;
11551154 bool aux_frame_sync;
11561155 bool link_standby;
1156+ bool y_cord_support;
1157+ bool colorimetry_support;
1158+ bool alpm;
11571159 };
11581160
11591161 enum intel_pch {
@@ -1809,6 +1811,7 @@ struct intel_pipe_crc { · 649 unmodified lines
18091811 enum intel_pipe_crc_source source;
18101812 int head, tail;
18111813 wait_queue_head_t wq;
1814+ int skipped;
18121815 };
18131816
18141817 struct i915_frontbuffer_tracking {
@@ -2069,6 +2072,7 @@ struct drm_i915_private { · 254 unmodified lines
20692072
20702073 struct intel_gvt *gvt;
20712074
2075+ struct intel_huc huc;
20722076 struct intel_guc guc;
20732077
20742078 struct intel_csr csr;
@@ -2843,6 +2847,7 @@ intel_info(const struct drm_i915_private *dev_priv) · 768 unmodified lines
28432847 #define HAS_GUC(dev_priv) ((dev_priv)->info.has_guc)
28442848 #define HAS_GUC_UCODE(dev_priv) (HAS_GUC(dev_priv))
28452849 #define HAS_GUC_SCHED(dev_priv) (HAS_GUC(dev_priv))
2850+#define HAS_HUC_UCODE(dev_priv) (HAS_GUC(dev_priv))
28462851
28472852 #define HAS_RESOURCE_STREAMER(dev_priv) ((dev_priv)->info.has_resource_streamer)
28482853
@@ -3101,10 +3106,10 @@ int i915_gem_throttle_ioctl(struct drm_device *dev, void *data, · 252 unmodified lines
31013106 struct drm_file *file_priv);
31023107 int i915_gem_madvise_ioctl(struct drm_device *dev, void *data,
31033108 struct drm_file *file_priv);
3104−int i915_gem_set_tiling(struct drm_device *dev, void *data,
3105− struct drm_file *file_priv);
3106−int i915_gem_get_tiling(struct drm_device *dev, void *data,
3107− struct drm_file *file_priv);
3109+int i915_gem_set_tiling_ioctl(struct drm_device *dev, void *data,
3110+ struct drm_file *file_priv);
3111+int i915_gem_get_tiling_ioctl(struct drm_device *dev, void *data,
3112+ struct drm_file *file_priv);
31083113 void i915_gem_init_userptr(struct drm_i915_private *dev_priv);
31093114 int i915_gem_userptr_ioctl(struct drm_device *dev, void *data,
31103115 struct drm_file *file);
@@ -3323,7 +3328,7 @@ static inline u32 i915_reset_count(struct i915_gpu_error *error) · 212 unmodified lines
33233328 return READ_ONCE(error->reset_count);
33243329 }
33253330
3326−void i915_gem_reset_prepare(struct drm_i915_private *dev_priv);
3331+int i915_gem_reset_prepare(struct drm_i915_private *dev_priv);
33273332 void i915_gem_reset_finish(struct drm_i915_private *dev_priv);
33283333 void i915_gem_set_wedged(struct drm_i915_private *dev_priv);
33293334 void i915_gem_clflush_object(struct drm_i915_gem_object *obj, bool force);
@@ -3360,11 +3365,6 @@ int i915_gem_object_attach_phys(struct drm_i915_gem_object *obj, · 30 unmodified lines
33603365 int i915_gem_open(struct drm_device *dev, struct drm_file *file);
33613366 void i915_gem_release(struct drm_device *dev, struct drm_file *file);
33623367
3363−u64 i915_gem_get_ggtt_size(struct drm_i915_private *dev_priv, u64 size,
3364− int tiling_mode);
3365−u64 i915_gem_get_ggtt_alignment(struct drm_i915_private *dev_priv, u64 size,
3366− int tiling_mode, bool fenced);
3367−
33683368 int i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj,
33693369 enum i915_cache_level cache_level);
33703370
@@ -3374,36 +3374,12 @@ struct drm_gem_object *i915_gem_prime_import(struct drm_device *dev, · 3 unmodified lines
33743374 struct dma_buf *i915_gem_prime_export(struct drm_device *dev,
33753375 struct drm_gem_object *gem_obj, int flags);
33763376
3377−struct i915_vma *
3378−i915_gem_obj_to_vma(struct drm_i915_gem_object *obj,
3379− struct i915_address_space *vm,
3380− const struct i915_ggtt_view *view);
3381−
3382−struct i915_vma *
3383−i915_gem_obj_lookup_or_create_vma(struct drm_i915_gem_object *obj,
3384− struct i915_address_space *vm,
3385− const struct i915_ggtt_view *view);
3386−
33873377 static inline struct i915_hw_ppgtt *
33883378 i915_vm_to_ppgtt(struct i915_address_space *vm)
33893379 {
33903380 return container_of(vm, struct i915_hw_ppgtt, base);
33913381 }
33923382
3393−static inline struct i915_vma *
3394−i915_gem_object_to_ggtt(struct drm_i915_gem_object *obj,
3395− const struct i915_ggtt_view *view)
3396−{
3397− return i915_gem_obj_to_vma(obj, &to_i915(obj->base.dev)->ggtt.base, view);
3398−}
3399−
3400−static inline unsigned long
3401−i915_gem_object_ggtt_offset(struct drm_i915_gem_object *o,
3402− const struct i915_ggtt_view *view)
3403−{
3404− return i915_ggtt_offset(i915_gem_object_to_ggtt(o, view));
3405−}
3406−
34073383 /* i915_gem_fence_reg.c */
34083384 int __must_check i915_vma_get_fence(struct i915_vma *vma);
34093385 int __must_check i915_vma_put_fence(struct i915_vma *vma);
@@ -3471,8 +3447,9 @@ int __must_check i915_gem_evict_something(struct i915_address_space *vm, · 61 unmodified lines
34713447 unsigned cache_level,
34723448 u64 start, u64 end,
34733449 unsigned flags);
3474−int __must_check i915_gem_evict_for_vma(struct i915_vma *vma,
3475− unsigned int flags);
3450+int __must_check i915_gem_evict_for_node(struct i915_address_space *vm,
3451+ struct drm_mm_node *node,
3452+ unsigned int flags);
34763453 int i915_gem_evict_vm(struct i915_address_space *vm, bool do_idle);
34773454
34783455 /* belongs in i915_gem_gtt.h */
@@ -3506,7 +3483,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_i915_private *dev_priv · 27 unmodified lines
35063483 /* i915_gem_internal.c */
35073484 struct drm_i915_gem_object *
35083485 i915_gem_object_create_internal(struct drm_i915_private *dev_priv,
3509− unsigned int size);
3486+ phys_addr_t size);
35103487
35113488 /* i915_gem_shrinker.c */
35123489 unsigned long i915_gem_shrink(struct drm_i915_private *dev_priv,
@@ -3531,6 +3508,11 @@ static inline bool i915_gem_object_needs_bit17_swizzle(struct drm_i915_gem_objec · 18 unmodified lines
35313508 i915_gem_object_is_tiled(obj);
35323509 }
35333510
3511+u32 i915_gem_fence_size(struct drm_i915_private *dev_priv, u32 size,
3512+ unsigned int tiling, unsigned int stride);
3513+u32 i915_gem_fence_alignment(struct drm_i915_private *dev_priv, u32 size,
3514+ unsigned int tiling, unsigned int stride);
3515+
35343516 /* i915_debugfs.c */
35353517 #ifdef CONFIG_DEBUG_FS
35363518 int i915_debugfs_register(struct drm_i915_private *dev_priv);
drivers/gpu/drm/i915/i915_gem.c+170−165
@@ -1696,12 +1696,7 @@ i915_gem_mmap_ioctl(struct drm_device *dev, void *data, · 1695 unmodified lines
16961696
16971697 static unsigned int tile_row_pages(struct drm_i915_gem_object *obj)
16981698 {
1699− u64 size;
1700−
1701− size = i915_gem_object_get_stride(obj);
1702− size *= i915_gem_object_get_tiling(obj) == I915_TILING_Y ? 32 : 8;
1703−
1704− return size >> PAGE_SHIFT;
1699+ return i915_gem_object_get_tile_row_size(obj) >> PAGE_SHIFT;
17051700 }
17061701
17071702 /**
@@ -1754,6 +1749,29 @@ int i915_gem_mmap_gtt_version(void) · 46 unmodified lines
17541749 return 1;
17551750 }
17561751
1752+static inline struct i915_ggtt_view
1753+compute_partial_view(struct drm_i915_gem_object *obj,
1754+ pgoff_t page_offset,
1755+ unsigned int chunk)
1756+{
1757+ struct i915_ggtt_view view;
1758+
1759+ if (i915_gem_object_is_tiled(obj))
1760+ chunk = roundup(chunk, tile_row_pages(obj));
1761+
1762+ view.type = I915_GGTT_VIEW_PARTIAL;
1763+ view.partial.offset = rounddown(page_offset, chunk);
1764+ view.partial.size =
1765+ min_t(unsigned int, chunk,
1766+ (obj->base.size >> PAGE_SHIFT) - view.partial.offset);
1767+
1768+ /* If the partial covers the entire object, just create a normal VMA. */
1769+ if (chunk >= obj->base.size >> PAGE_SHIFT)
1770+ view.type = I915_GGTT_VIEW_NORMAL;
1771+
1772+ return view;
1773+}
1774+
17571775 /**
17581776 * i915_gem_fault - fault a page into the GTT
17591777 * @area: CPU VMA in question
@@ -1830,26 +1848,9 @@ int i915_gem_fault(struct vm_area_struct *area, struct vm_fault *vmf) · 70 unmodified lines
18301848 /* Now pin it into the GTT as needed */
18311849 vma = i915_gem_object_ggtt_pin(obj, NULL, 0, 0, flags);
18321850 if (IS_ERR(vma)) {
1833− struct i915_ggtt_view view;
1834− unsigned int chunk_size;
1835−
18361851 /* Use a partial view if it is bigger than available space */
1837− chunk_size = MIN_CHUNK_PAGES;
1838− if (i915_gem_object_is_tiled(obj))
1839− chunk_size = roundup(chunk_size, tile_row_pages(obj));
1840−
1841− memset(&view, 0, sizeof(view));
1842− view.type = I915_GGTT_VIEW_PARTIAL;
1843− view.params.partial.offset = rounddown(page_offset, chunk_size);
1844− view.params.partial.size =
1845− min_t(unsigned int, chunk_size,
1846− vma_pages(area) - view.params.partial.offset);
1847−
1848− /* If the partial covers the entire object, just create a
1849− * normal VMA.
1850− */
1851− if (chunk_size >= obj->base.size >> PAGE_SHIFT)
1852− view.type = I915_GGTT_VIEW_NORMAL;
1852+ struct i915_ggtt_view view =
1853+ compute_partial_view(obj, page_offset, MIN_CHUNK_PAGES);
18531854
18541855 /* Userspace is now writing through an untracked VMA, abandon
18551856 * all hope that the hardware is able to track future writes.
@@ -1878,7 +1879,7 @@ int i915_gem_fault(struct vm_area_struct *area, struct vm_fault *vmf) · 22 unmodified lines
18781879
18791880 /* Finally, remap it using the new GTT offset */
18801881 ret = remap_io_mapping(area,
1881− area->vm_start + (vma->ggtt_view.params.partial.offset << PAGE_SHIFT),
1882+ area->vm_start + (vma->ggtt_view.partial.offset << PAGE_SHIFT),
18821883 (ggtt->mappable_base + vma->node.start) >> PAGE_SHIFT,
18831884 min_t(u64, vma->size, area->vm_end - area->vm_start),
18841885 &ggtt->mappable);
@@ -2021,69 +2022,6 @@ void i915_gem_runtime_suspend(struct drm_i915_private *dev_priv) · 136 unmodified lines
20212022 }
20222023 }
20232024
2024−/**
2025− * i915_gem_get_ggtt_size - return required global GTT size for an object
2026− * @dev_priv: i915 device
2027− * @size: object size
2028− * @tiling_mode: tiling mode
2029− *
2030− * Return the required global GTT size for an object, taking into account
2031− * potential fence register mapping.
2032− */
2033−u64 i915_gem_get_ggtt_size(struct drm_i915_private *dev_priv,
2034− u64 size, int tiling_mode)
2035−{
2036− u64 ggtt_size;
2037−
2038− GEM_BUG_ON(size == 0);
2039−
2040− if (INTEL_GEN(dev_priv) >= 4 ||
2041− tiling_mode == I915_TILING_NONE)
2042− return size;
2043−
2044− /* Previous chips need a power-of-two fence region when tiling */
2045− if (IS_GEN3(dev_priv))
2046− ggtt_size = 1024*1024;
2047− else
2048− ggtt_size = 512*1024;
2049−
2050− while (ggtt_size < size)
2051− ggtt_size <<= 1;
2052−
2053− return ggtt_size;
2054−}
2055−
2056−/**
2057− * i915_gem_get_ggtt_alignment - return required global GTT alignment
2058− * @dev_priv: i915 device
2059− * @size: object size
2060− * @tiling_mode: tiling mode
2061− * @fenced: is fenced alignment required or not
2062− *
2063− * Return the required global GTT alignment for an object, taking into account
2064− * potential fence register mapping.
2065− */
2066−u64 i915_gem_get_ggtt_alignment(struct drm_i915_private *dev_priv, u64 size,
2067− int tiling_mode, bool fenced)
2068−{
2069− GEM_BUG_ON(size == 0);
2070−
2071− /*
2072− * Minimum alignment is 4k (GTT page size), but might be greater
2073− * if a fence register is needed for the object.
2074− */
2075− if (INTEL_GEN(dev_priv) >= 4 ||
2076− (!fenced && (IS_G33(dev_priv) || IS_PINEVIEW(dev_priv))) ||
2077− tiling_mode == I915_TILING_NONE)
2078− return 4096;
2079−
2080− /*
2081− * Previous chips need to be aligned to the size of the smallest
2082− * fence register that can contain the object.
2083− */
2084− return i915_gem_get_ggtt_size(dev_priv, size, tiling_mode);
2085−}
2086−
20872025 static int i915_gem_object_create_mmap_offset(struct drm_i915_gem_object *obj)
20882026 {
20892027 struct drm_i915_private *dev_priv = to_i915(obj->base.dev);
@@ -2666,13 +2604,52 @@ i915_gem_find_active_request(struct intel_engine_cs *engine) · 576 unmodified lines
26662604 if (__i915_gem_request_completed(request))
26672605 continue;
26682606
2607+ GEM_BUG_ON(request->engine != engine);
26692608 return request;
26702609 }
26712610
26722611 return NULL;
26732612 }
26742613
2675−static void reset_request(struct drm_i915_gem_request *request)
2614+static bool engine_stalled(struct intel_engine_cs *engine)
2615+{
2616+ if (!engine->hangcheck.stalled)
2617+ return false;
2618+
2619+ /* Check for possible seqno movement after hang declaration */
2620+ if (engine->hangcheck.seqno != intel_engine_get_seqno(engine)) {
2621+ DRM_DEBUG_DRIVER("%s pardoned\n", engine->name);
2622+ return false;
2623+ }
2624+
2625+ return true;
2626+}
2627+
2628+int i915_gem_reset_prepare(struct drm_i915_private *dev_priv)
2629+{
2630+ struct intel_engine_cs *engine;
2631+ enum intel_engine_id id;
2632+ int err = 0;
2633+
2634+ /* Ensure irq handler finishes, and not run again. */
2635+ for_each_engine(engine, dev_priv, id) {
2636+ struct drm_i915_gem_request *request;
2637+
2638+ tasklet_kill(&engine->irq_tasklet);
2639+
2640+ if (engine_stalled(engine)) {
2641+ request = i915_gem_find_active_request(engine);
2642+ if (request && request->fence.error == -EIO)
2643+ err = -EIO; /* Previous reset failed! */
2644+ }
2645+ }
2646+
2647+ i915_gem_revoke_fences(dev_priv);
2648+
2649+ return err;
2650+}
2651+
2652+static void skip_request(struct drm_i915_gem_request *request)
26762653 {
26772654 void *vaddr = request->ring->vaddr;
26782655 u32 head;
@@ -2687,20 +2664,74 @@ static void reset_request(struct drm_i915_gem_request *request) · 8 unmodified lines
26872664 head = 0;
26882665 }
26892666 memset(vaddr + head, 0, request->postfix - head);
2667+
2668+ dma_fence_set_error(&request->fence, -EIO);
26902669 }
26912670
2692−void i915_gem_reset_prepare(struct drm_i915_private *dev_priv)
2671+static void engine_skip_context(struct drm_i915_gem_request *request)
26932672 {
2694− i915_gem_revoke_fences(dev_priv);
2673+ struct intel_engine_cs *engine = request->engine;
2674+ struct i915_gem_context *hung_ctx = request->ctx;
2675+ struct intel_timeline *timeline;
2676+ unsigned long flags;
2677+
2678+ timeline = i915_gem_context_lookup_timeline(hung_ctx, engine);
2679+
2680+ spin_lock_irqsave(&engine->timeline->lock, flags);
2681+ spin_lock(&timeline->lock);
2682+
2683+ list_for_each_entry_continue(request, &engine->timeline->requests, link)
2684+ if (request->ctx == hung_ctx)
2685+ skip_request(request);
2686+
2687+ list_for_each_entry(request, &timeline->requests, link)
2688+ skip_request(request);
2689+
2690+ spin_unlock(&timeline->lock);
2691+ spin_unlock_irqrestore(&engine->timeline->lock, flags);
2692+}
2693+
2694+/* Returns true if the request was guilty of hang */
2695+static bool i915_gem_reset_request(struct drm_i915_gem_request *request)
2696+{
2697+ /* Read once and return the resolution */
2698+ const bool guilty = engine_stalled(request->engine);
2699+
2700+ /* The guilty request will get skipped on a hung engine.
2701+ *
2702+ * Users of client default contexts do not rely on logical
2703+ * state preserved between batches so it is safe to execute
2704+ * queued requests following the hang. Non default contexts
2705+ * rely on preserved state, so skipping a batch loses the
2706+ * evolution of the state and it needs to be considered corrupted.
2707+ * Executing more queued batches on top of corrupted state is
2708+ * risky. But we take the risk by trying to advance through
2709+ * the queued requests in order to make the client behaviour
2710+ * more predictable around resets, by not throwing away random
2711+ * amount of batches it has prepared for execution. Sophisticated
2712+ * clients can use gem_reset_stats_ioctl and dma fence status
2713+ * (exported via sync_file info ioctl on explicit fences) to observe
2714+ * when it loses the context state and should rebuild accordingly.
2715+ *
2716+ * The context ban, and ultimately the client ban, mechanism are safety
2717+ * valves if client submission ends up resulting in nothing more than
2718+ * subsequent hangs.
2719+ */
2720+
2721+ if (guilty) {
2722+ i915_gem_context_mark_guilty(request->ctx);
2723+ skip_request(request);
2724+ } else {
2725+ i915_gem_context_mark_innocent(request->ctx);
2726+ dma_fence_set_error(&request->fence, -EAGAIN);
2727+ }
2728+
2729+ return guilty;
26952730 }
26962731
26972732 static void i915_gem_reset_engine(struct intel_engine_cs *engine)
26982733 {
26992734 struct drm_i915_gem_request *request;
2700− struct i915_gem_context *hung_ctx;
2701− struct intel_timeline *timeline;
2702− unsigned long flags;
2703− bool ring_hung;
27042735
27052736 if (engine->irq_seqno_barrier)
27062737 engine->irq_seqno_barrier(engine);
@@ -2709,22 +2740,7 @@ static void i915_gem_reset_engine(struct intel_engine_cs *engine) · 2 unmodified lines
27092740 if (!request)
27102741 return;
27112742
2712− hung_ctx = request->ctx;
2713−
2714− ring_hung = engine->hangcheck.stalled;
2715− if (engine->hangcheck.seqno != intel_engine_get_seqno(engine)) {
2716− DRM_DEBUG_DRIVER("%s pardoned, was guilty? %s\n",
2717− engine->name,
2718− yesno(ring_hung));
2719− ring_hung = false;
2720− }
2721−
2722− if (ring_hung)
2723− i915_gem_context_mark_guilty(hung_ctx);
2724− else
2725− i915_gem_context_mark_innocent(hung_ctx);
2726−
2727− if (!ring_hung)
2743+ if (!i915_gem_reset_request(request))
27282744 return;
27292745
27302746 DRM_DEBUG_DRIVER("resetting %s to restart from tail of request 0x%x\n",
@@ -2734,34 +2750,8 @@ static void i915_gem_reset_engine(struct intel_engine_cs *engine) · 3 unmodified lines
27342750 engine->reset_hw(engine, request);
27352751
27362752 /* If this context is now banned, skip all of its pending requests. */
2737− if (!i915_gem_context_is_banned(hung_ctx))
2738− return;
2739−
2740− /* Users of the default context do not rely on logical state
2741− * preserved between batches. They have to emit full state on
2742− * every batch and so it is safe to execute queued requests following
2743− * the hang.
2744− *
2745− * Other contexts preserve state, now corrupt. We want to skip all
2746− * queued requests that reference the corrupt context.
2747− */
2748− if (i915_gem_context_is_default(hung_ctx))
2749− return;
2750−
2751− timeline = i915_gem_context_lookup_timeline(hung_ctx, engine);
2752−
2753− spin_lock_irqsave(&engine->timeline->lock, flags);
2754− spin_lock(&timeline->lock);
2755−
2756− list_for_each_entry_continue(request, &engine->timeline->requests, link)
2757− if (request->ctx == hung_ctx)
2758− reset_request(request);
2759−
2760− list_for_each_entry(request, &timeline->requests, link)
2761− reset_request(request);
2762−
2763− spin_unlock(&timeline->lock);
2764− spin_unlock_irqrestore(&engine->timeline->lock, flags);
2753+ if (i915_gem_context_is_banned(request->ctx))
2754+ engine_skip_context(request);
27652755 }
27662756
27672757 void i915_gem_reset_finish(struct drm_i915_private *dev_priv)
@@ -2788,12 +2778,16 @@ void i915_gem_reset_finish(struct drm_i915_private *dev_priv) · 20 unmodified lines
27882778
27892779 static void nop_submit_request(struct drm_i915_gem_request *request)
27902780 {
2781+ dma_fence_set_error(&request->fence, -EIO);
27912782 i915_gem_request_submit(request);
27922783 intel_engine_init_global_seqno(request->engine, request->global_seqno);
27932784 }
27942785
2795−static void i915_gem_cleanup_engine(struct intel_engine_cs *engine)
2786+static void engine_set_wedged(struct intel_engine_cs *engine)
27962787 {
2788+ struct drm_i915_gem_request *request;
2789+ unsigned long flags;
2790+
27972791 /* We need to be sure that no thread is running the old callback as
27982792 * we install the nop handler (otherwise we would submit a request
27992793 * to hardware that will never complete). In order to prevent this
@@ -2802,6 +2796,12 @@ static void i915_gem_cleanup_engine(struct intel_engine_cs *engine) · 2 unmodified lines
28022796 */
28032797 engine->submit_request = nop_submit_request;
28042798
2799+ /* Mark all executing requests as skipped */
2800+ spin_lock_irqsave(&engine->timeline->lock, flags);
2801+ list_for_each_entry(request, &engine->timeline->requests, link)
2802+ dma_fence_set_error(&request->fence, -EIO);
2803+ spin_unlock_irqrestore(&engine->timeline->lock, flags);
2804+
28052805 /* Mark all pending requests as complete so that any concurrent
28062806 * (lockless) lookup doesn't try and wait upon the request as we
28072807 * reset it.
@@ -2837,7 +2837,7 @@ static int __i915_gem_set_wedged_BKL(void *data) · 29 unmodified lines
28372837 enum intel_engine_id id;
28382838
28392839 for_each_engine(engine, i915, id)
2840− i915_gem_cleanup_engine(engine);
2840+ engine_set_wedged(engine);
28412841
28422842 return 0;
28432843 }
@@ -3397,7 +3397,7 @@ int i915_gem_set_caching_ioctl(struct drm_device *dev, void *data, · 553 unmodified lines
33973397 struct drm_i915_gem_caching *args = data;
33983398 struct drm_i915_gem_object *obj;
33993399 enum i915_cache_level level;
3400− int ret;
3400+ int ret = 0;
34013401
34023402 switch (args->caching) {
34033403 case I915_CACHING_NONE:
@@ -3422,20 +3422,29 @@ int i915_gem_set_caching_ioctl(struct drm_device *dev, void *data, · 18 unmodified lines
34223422 return -EINVAL;
34233423 }
34243424
3425− ret = i915_mutex_lock_interruptible(dev);
3425+ obj = i915_gem_object_lookup(file, args->handle);
3426+ if (!obj)
3427+ return -ENOENT;
3428+
3429+ if (obj->cache_level == level)
3430+ goto out;
3431+
3432+ ret = i915_gem_object_wait(obj,
3433+ I915_WAIT_INTERRUPTIBLE,
3434+ MAX_SCHEDULE_TIMEOUT,
3435+ to_rps_client(file));
34263436 if (ret)
3427− return ret;
3437+ goto out;
34283438
3429− obj = i915_gem_object_lookup(file, args->handle);
3430− if (!obj) {
3431− ret = -ENOENT;
3432− goto unlock;
3433− }
3439+ ret = i915_mutex_lock_interruptible(dev);
3440+ if (ret)
3441+ goto out;
34343442
34353443 ret = i915_gem_object_set_cache_level(obj, level);
3436− i915_gem_object_put(obj);
3437−unlock:
34383444 mutex_unlock(&dev->struct_mutex);
3445+
3446+out:
3447+ i915_gem_object_put(obj);
34393448 return ret;
34403449 }
34413450
@@ -3485,7 +3494,7 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj, · 43 unmodified lines
34853494 * try to preserve the existing ABI).
34863495 */
34873496 vma = ERR_PTR(-ENOSPC);
3488− if (view->type == I915_GGTT_VIEW_NORMAL)
3497+ if (!view || view->type == I915_GGTT_VIEW_NORMAL)
34893498 vma = i915_gem_object_ggtt_pin(obj, view, 0, alignment,
34903499 PIN_MAPPABLE | PIN_NONBLOCK);
34913500 if (IS_ERR(vma)) {
@@ -3544,11 +3553,10 @@ i915_gem_object_unpin_from_display_plane(struct i915_vma *vma) · 52 unmodified lines
35443553 return;
35453554
35463555 if (--vma->obj->pin_display == 0)
3547− vma->display_alignment = 0;
3556+ vma->display_alignment = I915_GTT_MIN_ALIGNMENT;
35483557
35493558 /* Bump the LRU to try and avoid premature eviction whilst flipping */
3550− if (!i915_vma_is_active(vma))
3551− list_move_tail(&vma->vm_link, &vma->vm->inactive_list);
3559+ i915_gem_object_bump_inactive_ggtt(vma->obj);
35523560
35533561 i915_vma_unpin(vma);
35543562 }
@@ -3679,8 +3687,8 @@ i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj, · 124 unmodified lines
36793687
36803688 lockdep_assert_held(&obj->base.dev->struct_mutex);
36813689
3682− vma = i915_gem_obj_lookup_or_create_vma(obj, vm, view);
3683− if (IS_ERR(vma))
3690+ vma = i915_vma_instance(obj, vm, view);
3691+ if (unlikely(IS_ERR(vma)))
36843692 return vma;
36853693
36863694 if (i915_vma_misplaced(vma, size, alignment, flags)) {
@@ -3689,10 +3697,6 @@ i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj, · 2 unmodified lines
36893697 return ERR_PTR(-ENOSPC);
36903698
36913699 if (flags & PIN_MAPPABLE) {
3692− u32 fence_size;
3693−
3694− fence_size = i915_gem_get_ggtt_size(dev_priv, vma->size,
3695− i915_gem_object_get_tiling(obj));
36963700 /* If the required space is larger than the available
36973701 * aperture, we will not able to find a slot for the
36983702 * object and unbinding the object now will be in
@@ -3700,7 +3704,7 @@ i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj, · 1 unmodified line
37003704 * the object in and out of the Global GTT and
37013705 * waste a lot of cycles under the mutex.
37023706 */
3703− if (fence_size > dev_priv->ggtt.mappable_end)
3707+ if (vma->fence_size > dev_priv->ggtt.mappable_end)
37043708 return ERR_PTR(-E2BIG);
37053709
37063710 /* If NONBLOCK is set the caller is optimistically
@@ -3719,7 +3723,7 @@ i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj, · 12 unmodified lines
37193723 * we could try to minimise harm to others.
37203724 */
37213725 if (flags & PIN_NONBLOCK &&
3722− fence_size > dev_priv->ggtt.mappable_end / 2)
3726+ vma->fence_size > dev_priv->ggtt.mappable_end / 2)
37233727 return ERR_PTR(-ENOSPC);
37243728 }
37253729
@@ -4193,7 +4197,8 @@ static void assert_kernel_context_is_current(struct drm_i915_private *dev_priv) · 467 unmodified lines
41934197 enum intel_engine_id id;
41944198
41954199 for_each_engine(engine, dev_priv, id)
4196− GEM_BUG_ON(!i915_gem_context_is_kernel(engine->last_retired_context));
4200+ GEM_BUG_ON(engine->last_retired_context &&
4201+ !i915_gem_context_is_kernel(engine->last_retired_context));
41974202 }
41984203
41994204 int i915_gem_suspend(struct drm_i915_private *dev_priv)
drivers/gpu/drm/i915/i915_gem_context.c+30−25
@@ -97,7 +97,7 @@ · 96 unmodified lines
9797 * part. It should be safe to decrease this, but it's more future proof as is.
9898 */
9999 #define GEN6_CONTEXT_ALIGN (64<<10)
100−#define GEN7_CONTEXT_ALIGN 4096
100+#define GEN7_CONTEXT_ALIGN I915_GTT_MIN_ALIGNMENT
101101
102102 static size_t get_context_alignment(struct drm_i915_private *dev_priv)
103103 {
@@ -205,27 +205,6 @@ alloc_context_obj(struct drm_i915_private *dev_priv, u64 size) · 101 unmodified lines
205205 return obj;
206206 }
207207
208−static void i915_ppgtt_close(struct i915_address_space *vm)
209−{
210− struct list_head *phases[] = {
211− &vm->active_list,
212− &vm->inactive_list,
213− &vm->unbound_list,
214− NULL,
215− }, **phase;
216−
217− GEM_BUG_ON(vm->closed);
218− vm->closed = true;
219−
220− for (phase = phases; *phase; phase++) {
221− struct i915_vma *vma, *vn;
222−
223− list_for_each_entry_safe(vma, vn, *phase, vm_link)
224− if (!i915_vma_is_closed(vma))
225− i915_vma_close(vma);
226− }
227−}
228−
229208 static void context_close(struct i915_gem_context *ctx)
230209 {
231210 i915_gem_context_set_closed(ctx);
@@ -290,7 +269,7 @@ __create_hw_context(struct drm_i915_private *dev_priv, · 58 unmodified lines
290269 goto err_out;
291270 }
292271
293− vma = i915_vma_create(obj, &dev_priv->ggtt.base, NULL);
272+ vma = i915_vma_instance(obj, &dev_priv->ggtt.base, NULL);
294273 if (IS_ERR(vma)) {
295274 i915_gem_object_put(obj);
296275 ret = PTR_ERR(vma);
@@ -341,7 +320,7 @@ __create_hw_context(struct drm_i915_private *dev_priv, · 44 unmodified lines
341320 if (HAS_GUC(dev_priv) && i915.enable_guc_loading)
342321 ctx->ggtt_offset_bias = GUC_WOPCM_TOP;
343322 else
344− ctx->ggtt_offset_bias = 4096;
323+ ctx->ggtt_offset_bias = I915_GTT_PAGE_SIZE;
345324
346325 return ctx;
347326
@@ -456,7 +435,8 @@ int i915_gem_context_init(struct drm_i915_private *dev_priv) · 108 unmodified lines
456435 dev_priv->hw_context_size = 0;
457436 } else if (HAS_HW_CONTEXTS(dev_priv)) {
458437 dev_priv->hw_context_size =
459− round_up(get_context_size(dev_priv), 4096);
438+ round_up(get_context_size(dev_priv),
439+ I915_GTT_PAGE_SIZE);
460440 if (dev_priv->hw_context_size > (1<<20)) {
461441 DRM_DEBUG_DRIVER("Disabling HW Contexts; invalid size %d\n",
462442 dev_priv->hw_context_size);
@@ -897,6 +877,26 @@ int i915_switch_context(struct drm_i915_gem_request *req) · 434 unmodified lines
897877 return do_rcs_switch(req);
898878 }
899879
880+static bool engine_has_kernel_context(struct intel_engine_cs *engine)
881+{
882+ struct i915_gem_timeline *timeline;
883+
884+ list_for_each_entry(timeline, &engine->i915->gt.timelines, link) {
885+ struct intel_timeline *tl;
886+
887+ if (timeline == &engine->i915->gt.global_timeline)
888+ continue;
889+
890+ tl = &timeline->engine[engine->id];
891+ if (i915_gem_active_peek(&tl->last_request,
892+ &engine->i915->drm.struct_mutex))
893+ return false;
894+ }
895+
896+ return (!engine->last_retired_context ||
897+ i915_gem_context_is_kernel(engine->last_retired_context));
898+}
899+
900900 int i915_gem_switch_to_kernel_context(struct drm_i915_private *dev_priv)
901901 {
902902 struct intel_engine_cs *engine;
@@ -905,10 +905,15 @@ int i915_gem_switch_to_kernel_context(struct drm_i915_private *dev_priv) · 2 unmodified lines
905905
906906 lockdep_assert_held(&dev_priv->drm.struct_mutex);
907907
908+ i915_gem_retire_requests(dev_priv);
909+
908910 for_each_engine(engine, dev_priv, id) {
909911 struct drm_i915_gem_request *req;
910912 int ret;
911913
914+ if (engine_has_kernel_context(engine))
915+ continue;
916+
912917 req = i915_gem_request_alloc(engine, dev_priv->kernel_context);
913918 if (IS_ERR(req))
914919 return PTR_ERR(req);
drivers/gpu/drm/i915/i915_gem_evict.c+21−18
@@ -231,7 +231,8 @@ found: · 230 unmodified lines
231231
232232 /**
233233 * i915_gem_evict_for_vma - Evict vmas to make room for binding a new one
234− * @target: address space and range to evict for
234+ * @vm: address space to evict from
235+ * @target: range (and color) to evict for
235236 * @flags: additional flags to control the eviction algorithm
236237 *
237238 * This function will try to evict vmas that overlap the target node.
@@ -239,18 +240,20 @@ found: · 1 unmodified line
239240 * To clarify: This is for freeing up virtual address space, not for freeing
240241 * memory in e.g. the shrinker.
241242 */
242−int i915_gem_evict_for_vma(struct i915_vma *target, unsigned int flags)
243+int i915_gem_evict_for_node(struct i915_address_space *vm,
244+ struct drm_mm_node *target,
245+ unsigned int flags)
243246 {
244247 LIST_HEAD(eviction_list);
245248 struct drm_mm_node *node;
246− u64 start = target->node.start;
247− u64 end = start + target->node.size;
249+ u64 start = target->start;
250+ u64 end = start + target->size;
248251 struct i915_vma *vma, *next;
249252 bool check_color;
250253 int ret = 0;
251254
252− lockdep_assert_held(&target->vm->i915->drm.struct_mutex);
253− trace_i915_gem_evict_vma(target, flags);
255+ lockdep_assert_held(&vm->i915->drm.struct_mutex);
256+ trace_i915_gem_evict_node(vm, target, flags);
254257
255258 /* Retire before we search the active list. Although we have
256259 * reasonable accuracy in our retirement lists, we may have
@@ -258,18 +261,18 @@ int i915_gem_evict_for_vma(struct i915_vma *target, unsigned int flags) · 1 unmodified line
258261 * retiring.
259262 */
260263 if (!(flags & PIN_NONBLOCK))
261− i915_gem_retire_requests(target->vm->i915);
264+ i915_gem_retire_requests(vm->i915);
262265
263− check_color = target->vm->mm.color_adjust;
266+ check_color = vm->mm.color_adjust;
264267 if (check_color) {
265268 /* Expand search to cover neighbouring guard pages (or lack!) */
266− if (start > target->vm->start)
267− start -= 4096;
268− if (end < target->vm->start + target->vm->total)
269− end += 4096;
269+ if (start > vm->start)
270+ start -= I915_GTT_PAGE_SIZE;
271+ if (end < vm->start + vm->total)
272+ end += I915_GTT_PAGE_SIZE;
270273 }
271274
272− drm_mm_for_each_node_in_range(node, &target->vm->mm, start, end) {
275+ drm_mm_for_each_node_in_range(node, &vm->mm, start, end) {
273276 /* If we find any non-objects (!vma), we cannot evict them */
274277 if (node->color == I915_COLOR_UNEVICTABLE) {
275278 ret = -ENOSPC;
@@ -285,12 +288,12 @@ int i915_gem_evict_for_vma(struct i915_vma *target, unsigned int flags) · 9 unmodified lines
285288 * those as well to make room for our guard pages.
286289 */
287290 if (check_color) {
288− if (vma->node.start + vma->node.size == target->node.start) {
289− if (vma->node.color == target->node.color)
291+ if (vma->node.start + vma->node.size == node->start) {
292+ if (vma->node.color == node->color)
290293 continue;
291294 }
292− if (vma->node.start == target->node.start + target->node.size) {
293− if (vma->node.color == target->node.color)
295+ if (vma->node.start == node->start + node->size) {
296+ if (vma->node.color == node->color)
294297 continue;
295298 }
296299 }
@@ -302,7 +305,7 @@ int i915_gem_evict_for_vma(struct i915_vma *target, unsigned int flags) · 5 unmodified lines
302305 }
303306
304307 /* Overlap of objects in the same batch? */
305− if (i915_vma_is_pinned(vma)) {
308+ if (i915_vma_is_pinned(vma) || !list_empty(&vma->exec_list)) {
306309 ret = -ENOSPC;
307310 if (vma->exec_entry &&
308311 vma->exec_entry->flags & EXEC_OBJECT_PINNED)
drivers/gpu/drm/i915/i915_gem_execbuffer.c+3−4
@@ -184,7 +184,7 @@ eb_lookup_vmas(struct eb_vmas *eb, · 183 unmodified lines
184184 * from the (obj, vm) we don't run the risk of creating
185185 * duplicated vmas for the same vm.
186186 */
187− vma = i915_gem_obj_lookup_or_create_vma(obj, vm, NULL);
187+ vma = i915_vma_instance(obj, vm, NULL);
188188 if (unlikely(IS_ERR(vma))) {
189189 DRM_DEBUG("Failed to lookup VMA\n");
190190 ret = PTR_ERR(vma);
@@ -438,7 +438,7 @@ static void *reloc_iomap(struct drm_i915_gem_object *obj, · 247 unmodified lines
438438 memset(&cache->node, 0, sizeof(cache->node));
439439 ret = drm_mm_insert_node_in_range_generic
440440 (&ggtt->base.mm, &cache->node,
441− 4096, 0, I915_COLOR_UNEVICTABLE,
441+ PAGE_SIZE, 0, I915_COLOR_UNEVICTABLE,
442442 0, ggtt->mappable_end,
443443 DRM_MM_SEARCH_DEFAULT,
444444 DRM_MM_CREATE_DEFAULT);
@@ -851,8 +851,7 @@ eb_vma_misplaced(struct i915_vma *vma) · 406 unmodified lines
851851 WARN_ON(entry->flags & __EXEC_OBJECT_NEEDS_MAP &&
852852 !i915_vma_is_ggtt(vma));
853853
854− if (entry->alignment &&
855− vma->node.start & (entry->alignment - 1))
854+ if (entry->alignment && !IS_ALIGNED(vma->node.start, entry->alignment))
856855 return true;
857856
858857 if (vma->node.size < entry->pad_to_size)
drivers/gpu/drm/i915/i915_gem_fence_reg.c+26−38
@@ -77,16 +77,17 @@ static void i965_write_fence_reg(struct drm_i915_fence_reg *fence, · 76 unmodified lines
7777
7878 val = 0;
7979 if (vma) {
80− unsigned int tiling = i915_gem_object_get_tiling(vma->obj);
81− bool is_y_tiled = tiling == I915_TILING_Y;
8280 unsigned int stride = i915_gem_object_get_stride(vma->obj);
83− u32 row_size = stride * (is_y_tiled ? 32 : 8);
84− u32 size = rounddown((u32)vma->node.size, row_size);
8581
86− val = ((vma->node.start + size - 4096) & 0xfffff000) << 32;
87− val |= vma->node.start & 0xfffff000;
82+ GEM_BUG_ON(!i915_vma_is_map_and_fenceable(vma));
83+ GEM_BUG_ON(!IS_ALIGNED(vma->node.start, I965_FENCE_PAGE));
84+ GEM_BUG_ON(!IS_ALIGNED(vma->fence_size, I965_FENCE_PAGE));
85+ GEM_BUG_ON(!IS_ALIGNED(stride, 128));
86+
87+ val = (vma->node.start + vma->fence_size - I965_FENCE_PAGE) << 32;
88+ val |= vma->node.start;
8889 val |= (u64)((stride / 128) - 1) << fence_pitch_shift;
89− if (is_y_tiled)
90+ if (i915_gem_object_get_tiling(vma->obj) == I915_TILING_Y)
9091 val |= BIT(I965_FENCE_TILING_Y_SHIFT);
9192 val |= I965_FENCE_REG_VALID;
9293 }
@@ -122,31 +123,24 @@ static void i915_write_fence_reg(struct drm_i915_fence_reg *fence, · 29 unmodified lines
122123 unsigned int tiling = i915_gem_object_get_tiling(vma->obj);
123124 bool is_y_tiled = tiling == I915_TILING_Y;
124125 unsigned int stride = i915_gem_object_get_stride(vma->obj);
125− int pitch_val;
126− int tile_width;
127126
128− WARN((vma->node.start & ~I915_FENCE_START_MASK) ||
129− !is_power_of_2(vma->node.size) ||
130− (vma->node.start & (vma->node.size - 1)),
131− "object 0x%08llx [fenceable? %d] not 1M or pot-size (0x%08llx) aligned\n",
132− vma->node.start,
133− i915_vma_is_map_and_fenceable(vma),
134− vma->node.size);
127+ GEM_BUG_ON(!i915_vma_is_map_and_fenceable(vma));
128+ GEM_BUG_ON(vma->node.start & ~I915_FENCE_START_MASK);
129+ GEM_BUG_ON(!is_power_of_2(vma->fence_size));
130+ GEM_BUG_ON(!IS_ALIGNED(vma->node.start, vma->fence_size));
135131
136132 if (is_y_tiled && HAS_128_BYTE_Y_TILING(fence->i915))
137− tile_width = 128;
133+ stride /= 128;
138134 else
139− tile_width = 512;
140−
141− /* Note: pitch better be a power of two tile widths */
142− pitch_val = stride / tile_width;
143− pitch_val = ffs(pitch_val) - 1;
135+ stride /= 512;
136+ GEM_BUG_ON(!is_power_of_2(stride));
144137
145138 val = vma->node.start;
146139 if (is_y_tiled)
147140 val |= BIT(I830_FENCE_TILING_Y_SHIFT);
148− val |= I915_FENCE_SIZE_BITS(vma->node.size);
149− val |= pitch_val << I830_FENCE_PITCH_SHIFT;
141+ val |= I915_FENCE_SIZE_BITS(vma->fence_size);
142+ val |= ilog2(stride) << I830_FENCE_PITCH_SHIFT;
143+
150144 val |= I830_FENCE_REG_VALID;
151145 }
152146
@@ -166,25 +160,19 @@ static void i830_write_fence_reg(struct drm_i915_fence_reg *fence, · 13 unmodified lines
166160
167161 val = 0;
168162 if (vma) {
169− unsigned int tiling = i915_gem_object_get_tiling(vma->obj);
170− bool is_y_tiled = tiling == I915_TILING_Y;
171163 unsigned int stride = i915_gem_object_get_stride(vma->obj);
172− u32 pitch_val;
173164
174− WARN((vma->node.start & ~I830_FENCE_START_MASK) ||
175− !is_power_of_2(vma->node.size) ||
176− (vma->node.start & (vma->node.size - 1)),
177− "object 0x%08llx not 512K or pot-size 0x%08llx aligned\n",
178− vma->node.start, vma->node.size);
179−
180− pitch_val = stride / 128;
181− pitch_val = ffs(pitch_val) - 1;
165+ GEM_BUG_ON(!i915_vma_is_map_and_fenceable(vma));
166+ GEM_BUG_ON(vma->node.start & ~I830_FENCE_START_MASK);
167+ GEM_BUG_ON(!is_power_of_2(vma->fence_size));
168+ GEM_BUG_ON(!is_power_of_2(stride / 128));
169+ GEM_BUG_ON(!IS_ALIGNED(vma->node.start, vma->fence_size));
182170
183171 val = vma->node.start;
184− if (is_y_tiled)
172+ if (i915_gem_object_get_tiling(vma->obj) == I915_TILING_Y)
185173 val |= BIT(I830_FENCE_TILING_Y_SHIFT);
186− val |= I830_FENCE_SIZE_BITS(vma->node.size);
187− val |= pitch_val << I830_FENCE_PITCH_SHIFT;
174+ val |= I830_FENCE_SIZE_BITS(vma->fence_size);
175+ val |= ilog2(stride / 128) << I830_FENCE_PITCH_SHIFT;
188176 val |= I830_FENCE_REG_VALID;
189177 }
190178
drivers/gpu/drm/i915/i915_gem_fence_reg.h+2−0
@@ -30,6 +30,8 @@ · 29 unmodified lines
3030 struct drm_i915_private;
3131 struct i915_vma;
3232
33+#define I965_FENCE_PAGE 4096UL
34+
3335 struct drm_i915_fence_reg {
3436 struct list_head link;
3537 struct drm_i915_private *i915;
drivers/gpu/drm/i915/i915_gem_gtt.c+304−134
@@ -23,10 +23,14 @@ · 22 unmodified lines
2323 *
2424 */
2525
26+#include <linux/log2.h>
27+#include <linux/random.h>
2628 #include <linux/seq_file.h>
2729 #include <linux/stop_machine.h>
30+
2831 #include <drm/drmP.h>
2932 #include <drm/i915_drm.h>
33+
3034 #include "i915_drv.h"
3135 #include "i915_vgpu.h"
3236 #include "i915_trace.h"
@@ -99,12 +103,29 @@ · 66 unmodified lines
99103 static int
100104 i915_get_ggtt_vma_pages(struct i915_vma *vma);
101105
102−const struct i915_ggtt_view i915_ggtt_view_normal = {
103− .type = I915_GGTT_VIEW_NORMAL,
104−};
105−const struct i915_ggtt_view i915_ggtt_view_rotated = {
106− .type = I915_GGTT_VIEW_ROTATED,
107−};
106+static void gen6_ggtt_invalidate(struct drm_i915_private *dev_priv)
107+{
108+ /* Note that as an uncached mmio write, this should flush the
109+ * WCB of the writes into the GGTT before it triggers the invalidate.
110+ */
111+ I915_WRITE(GFX_FLSH_CNTL_GEN6, GFX_FLSH_CNTL_EN);
112+}
113+
114+static void guc_ggtt_invalidate(struct drm_i915_private *dev_priv)
115+{
116+ gen6_ggtt_invalidate(dev_priv);
117+ I915_WRITE(GEN8_GTCR, GEN8_GTCR_INVALIDATE);
118+}
119+
120+static void gmch_ggtt_invalidate(struct drm_i915_private *dev_priv)
121+{
122+ intel_gtt_chipset_flush();
123+}
124+
125+static inline void i915_ggtt_invalidate(struct drm_i915_private *i915)
126+{
127+ i915->ggtt.invalidate(i915);
128+}
108129
109130 int intel_sanitize_enable_ppgtt(struct drm_i915_private *dev_priv,
110131 int enable_ppgtt)
@@ -329,7 +350,7 @@ static int __setup_page_dma(struct drm_i915_private *dev_priv, · 218 unmodified lines
329350 return -ENOMEM;
330351
331352 p->daddr = dma_map_page(kdev,
332− p->page, 0, 4096, PCI_DMA_BIDIRECTIONAL);
353+ p->page, 0, PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
333354
334355 if (dma_mapping_error(kdev, p->daddr)) {
335356 __free_page(p->page);
@@ -353,7 +374,7 @@ static void cleanup_page_dma(struct drm_i915_private *dev_priv, · 17 unmodified lines
353374 if (WARN_ON(!p->page))
354375 return;
355376
356− dma_unmap_page(&pdev->dev, p->daddr, 4096, PCI_DMA_BIDIRECTIONAL);
377+ dma_unmap_page(&pdev->dev, p->daddr, PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
357378 __free_page(p->page);
358379 memset(p, 0, sizeof(*p));
359380 }
@@ -626,10 +647,10 @@ static void gen8_initialize_pml4(struct i915_address_space *vm, · 266 unmodified lines
626647 }
627648
628649 static void
629−gen8_setup_page_directory(struct i915_hw_ppgtt *ppgtt,
630− struct i915_page_directory_pointer *pdp,
631− struct i915_page_directory *pd,
632− int index)
650+gen8_setup_pdpe(struct i915_hw_ppgtt *ppgtt,
651+ struct i915_page_directory_pointer *pdp,
652+ struct i915_page_directory *pd,
653+ int index)
633654 {
634655 gen8_ppgtt_pdpe_t *page_directorypo;
635656
@@ -642,10 +663,10 @@ gen8_setup_page_directory(struct i915_hw_ppgtt *ppgtt, · 6 unmodified lines
642663 }
643664
644665 static void
645−gen8_setup_page_directory_pointer(struct i915_hw_ppgtt *ppgtt,
646− struct i915_pml4 *pml4,
647− struct i915_page_directory_pointer *pdp,
648− int index)
666+gen8_setup_pml4e(struct i915_hw_ppgtt *ppgtt,
667+ struct i915_pml4 *pml4,
668+ struct i915_page_directory_pointer *pdp,
669+ int index)
649670 {
650671 gen8_ppgtt_pml4e_t *pagemap = kmap_px(pml4);
651672
@@ -793,9 +814,6 @@ static bool gen8_ppgtt_clear_pdp(struct i915_address_space *vm, · 141 unmodified lines
793814 struct i915_hw_ppgtt *ppgtt = i915_vm_to_ppgtt(vm);
794815 struct i915_page_directory *pd;
795816 uint64_t pdpe;
796− gen8_ppgtt_pdpe_t *pdpe_vaddr;
797− gen8_ppgtt_pdpe_t scratch_pdpe =
798− gen8_pdpe_encode(px_dma(vm->scratch_pd), I915_CACHE_LLC);
799817
800818 gen8_for_each_pdpe(pd, pdp, start, length, pdpe) {
801819 if (WARN_ON(!pdp->page_directory[pdpe]))
@@ -803,11 +821,7 @@ static bool gen8_ppgtt_clear_pdp(struct i915_address_space *vm, · 1 unmodified line
803821
804822 if (gen8_ppgtt_clear_pd(vm, pd, start, length)) {
805823 __clear_bit(pdpe, pdp->used_pdpes);
806− if (USES_FULL_48BIT_PPGTT(dev_priv)) {
807− pdpe_vaddr = kmap_px(pdp);
808− pdpe_vaddr[pdpe] = scratch_pdpe;
809− kunmap_px(ppgtt, pdpe_vaddr);
810− }
824+ gen8_setup_pdpe(ppgtt, pdp, vm->scratch_pd, pdpe);
811825 free_pd(vm->i915, pd);
812826 }
813827 }
@@ -832,9 +846,6 @@ static void gen8_ppgtt_clear_pml4(struct i915_address_space *vm, · 18 unmodified lines
832846 struct i915_hw_ppgtt *ppgtt = i915_vm_to_ppgtt(vm);
833847 struct i915_page_directory_pointer *pdp;
834848 uint64_t pml4e;
835− gen8_ppgtt_pml4e_t *pml4e_vaddr;
836− gen8_ppgtt_pml4e_t scratch_pml4e =
837− gen8_pml4e_encode(px_dma(vm->scratch_pdp), I915_CACHE_LLC);
838849
839850 GEM_BUG_ON(!USES_FULL_48BIT_PPGTT(vm->i915));
840851
@@ -844,9 +855,7 @@ static void gen8_ppgtt_clear_pml4(struct i915_address_space *vm, · 3 unmodified lines
844855
845856 if (gen8_ppgtt_clear_pdp(vm, pdp, start, length)) {
846857 __clear_bit(pml4e, pml4->used_pml4es);
847− pml4e_vaddr = kmap_px(pml4);
848− pml4e_vaddr[pml4e] = scratch_pml4e;
849− kunmap_px(ppgtt, pml4e_vaddr);
858+ gen8_setup_pml4e(ppgtt, pml4, vm->scratch_pdp, pml4e);
850859 free_pdp(vm->i915, pdp);
851860 }
852861 }
@@ -1366,7 +1375,7 @@ static int gen8_alloc_va_range_3lvl(struct i915_address_space *vm, · 513 unmodified lines
13661375
13671376 kunmap_px(ppgtt, page_directory);
13681377 __set_bit(pdpe, pdp->used_pdpes);
1369− gen8_setup_page_directory(ppgtt, pdp, pd, pdpe);
1378+ gen8_setup_pdpe(ppgtt, pdp, pd, pdpe);
13701379 }
13711380
13721381 free_gen8_temp_bitmaps(new_page_dirs, new_page_tables);
@@ -1425,7 +1434,7 @@ static int gen8_alloc_va_range_4lvl(struct i915_address_space *vm, · 52 unmodified lines
14251434 if (ret)
14261435 goto err_out;
14271436
1428− gen8_setup_page_directory_pointer(ppgtt, pml4, pdp, pml4e);
1437+ gen8_setup_pml4e(ppgtt, pml4, pdp, pml4e);
14291438 }
14301439
14311440 bitmap_or(pml4->used_pml4es, new_pdps, pml4->used_pml4es,
@@ -2044,7 +2053,6 @@ static int gen6_ppgtt_allocate_page_directories(struct i915_hw_ppgtt *ppgtt) · 612 unmodified lines
20442053 struct i915_address_space *vm = &ppgtt->base;
20452054 struct drm_i915_private *dev_priv = ppgtt->base.i915;
20462055 struct i915_ggtt *ggtt = &dev_priv->ggtt;
2047− bool retried = false;
20482056 int ret;
20492057
20502058 /* PPGTT PDEs reside in the GGTT and consists of 512 entries. The
@@ -2057,29 +2065,14 @@ static int gen6_ppgtt_allocate_page_directories(struct i915_hw_ppgtt *ppgtt) · 6 unmodified lines
20572065 if (ret)
20582066 return ret;
20592067
2060−alloc:
2061− ret = drm_mm_insert_node_in_range_generic(&ggtt->base.mm, &ppgtt->node,
2062− GEN6_PD_SIZE, GEN6_PD_ALIGN,
2063− I915_COLOR_UNEVICTABLE,
2064− 0, ggtt->base.total,
2065− DRM_MM_TOPDOWN);
2066− if (ret == -ENOSPC && !retried) {
2067− ret = i915_gem_evict_something(&ggtt->base,
2068− GEN6_PD_SIZE, GEN6_PD_ALIGN,
2069− I915_COLOR_UNEVICTABLE,
2070− 0, ggtt->base.total,
2071− 0);
2072− if (ret)
2073− goto err_out;
2074−
2075− retried = true;
2076− goto alloc;
2077− }
2078−
2068+ ret = i915_gem_gtt_insert(&ggtt->base, &ppgtt->node,
2069+ GEN6_PD_SIZE, GEN6_PD_ALIGN,
2070+ I915_COLOR_UNEVICTABLE,
2071+ 0, ggtt->base.total,
2072+ PIN_HIGH);
20792073 if (ret)
20802074 goto err_out;
20812075
2082−
20832076 if (ppgtt->node.start < ggtt->mappable_end)
20842077 DRM_DEBUG("Forced to use aperture for PDEs\n");
20852078
@@ -2267,6 +2260,27 @@ i915_ppgtt_create(struct drm_i915_private *dev_priv, · 181 unmodified lines
22672260 return ppgtt;
22682261 }
22692262
2263+void i915_ppgtt_close(struct i915_address_space *vm)
2264+{
2265+ struct list_head *phases[] = {
2266+ &vm->active_list,
2267+ &vm->inactive_list,
2268+ &vm->unbound_list,
2269+ NULL,
2270+ }, **phase;
2271+
2272+ GEM_BUG_ON(vm->closed);
2273+ vm->closed = true;
2274+
2275+ for (phase = phases; *phase; phase++) {
2276+ struct i915_vma *vma, *vn;
2277+
2278+ list_for_each_entry_safe(vma, vn, *phase, vm_link)
2279+ if (!i915_vma_is_closed(vma))
2280+ i915_vma_close(vma);
2281+ }
2282+}
2283+
22702284 void i915_ppgtt_release(struct kref *kref)
22712285 {
22722286 struct i915_hw_ppgtt *ppgtt =
@@ -2331,16 +2345,6 @@ void i915_check_and_clear_faults(struct drm_i915_private *dev_priv) · 58 unmodified lines
23312345 POSTING_READ(RING_FAULT_REG(dev_priv->engine[RCS]));
23322346 }
23332347
2334−static void i915_ggtt_flush(struct drm_i915_private *dev_priv)
2335−{
2336− if (INTEL_INFO(dev_priv)->gen < 6) {
2337− intel_gtt_chipset_flush();
2338− } else {
2339− I915_WRITE(GFX_FLSH_CNTL_GEN6, GFX_FLSH_CNTL_EN);
2340− POSTING_READ(GFX_FLSH_CNTL_GEN6);
2341− }
2342−}
2343−
23442348 void i915_gem_suspend_gtt_mappings(struct drm_i915_private *dev_priv)
23452349 {
23462350 struct i915_ggtt *ggtt = &dev_priv->ggtt;
@@ -2355,7 +2359,7 @@ void i915_gem_suspend_gtt_mappings(struct drm_i915_private *dev_priv) · 8 unmodified lines
23552359
23562360 ggtt->base.clear_range(&ggtt->base, ggtt->base.start, ggtt->base.total);
23572361
2358− i915_ggtt_flush(dev_priv);
2362+ i915_ggtt_invalidate(dev_priv);
23592363 }
23602364
23612365 int i915_gem_gtt_prepare_pages(struct drm_i915_gem_object *obj,
@@ -2394,15 +2398,13 @@ static void gen8_ggtt_insert_page(struct i915_address_space *vm, · 32 unmodified lines
23942398 enum i915_cache_level level,
23952399 u32 unused)
23962400 {
2397− struct drm_i915_private *dev_priv = vm->i915;
2401+ struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm);
23982402 gen8_pte_t __iomem *pte =
2399− (gen8_pte_t __iomem *)dev_priv->ggtt.gsm +
2400− (offset >> PAGE_SHIFT);
2403+ (gen8_pte_t __iomem *)ggtt->gsm + (offset >> PAGE_SHIFT);
24012404
24022405 gen8_set_pte(pte, gen8_pte_encode(addr, level));
24032406
2404− I915_WRITE(GFX_FLSH_CNTL_GEN6, GFX_FLSH_CNTL_EN);
2405− POSTING_READ(GFX_FLSH_CNTL_GEN6);
2407+ ggtt->invalidate(vm->i915);
24062408 }
24072409
24082410 static void gen8_ggtt_insert_entries(struct i915_address_space *vm,
@@ -2410,7 +2412,6 @@ static void gen8_ggtt_insert_entries(struct i915_address_space *vm, · 1 unmodified line
24102412 uint64_t start,
24112413 enum i915_cache_level level, u32 unused)
24122414 {
2413− struct drm_i915_private *dev_priv = vm->i915;
24142415 struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm);
24152416 struct sgt_iter sgt_iter;
24162417 gen8_pte_t __iomem *gtt_entries;
@@ -2439,8 +2440,7 @@ static void gen8_ggtt_insert_entries(struct i915_address_space *vm, · 22 unmodified lines
24392440 * want to flush the TLBs only after we're certain all the PTE updates
24402441 * have finished.
24412442 */
2442− I915_WRITE(GFX_FLSH_CNTL_GEN6, GFX_FLSH_CNTL_EN);
2443− POSTING_READ(GFX_FLSH_CNTL_GEN6);
2443+ ggtt->invalidate(vm->i915);
24442444 }
24452445
24462446 struct insert_entries {
@@ -2475,15 +2475,13 @@ static void gen6_ggtt_insert_page(struct i915_address_space *vm, · 28 unmodified lines
24752475 enum i915_cache_level level,
24762476 u32 flags)
24772477 {
2478− struct drm_i915_private *dev_priv = vm->i915;
2478+ struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm);
24792479 gen6_pte_t __iomem *pte =
2480− (gen6_pte_t __iomem *)dev_priv->ggtt.gsm +
2481− (offset >> PAGE_SHIFT);
2480+ (gen6_pte_t __iomem *)ggtt->gsm + (offset >> PAGE_SHIFT);
24822481
24832482 iowrite32(vm->pte_encode(addr, level, flags), pte);
24842483
2485− I915_WRITE(GFX_FLSH_CNTL_GEN6, GFX_FLSH_CNTL_EN);
2486− POSTING_READ(GFX_FLSH_CNTL_GEN6);
2484+ ggtt->invalidate(vm->i915);
24872485 }
24882486
24892487 /*
@@ -2497,7 +2495,6 @@ static void gen6_ggtt_insert_entries(struct i915_address_space *vm, · 7 unmodified lines
24972495 uint64_t start,
24982496 enum i915_cache_level level, u32 flags)
24992497 {
2500− struct drm_i915_private *dev_priv = vm->i915;
25012498 struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm);
25022499 struct sgt_iter sgt_iter;
25032500 gen6_pte_t __iomem *gtt_entries;
@@ -2525,8 +2522,7 @@ static void gen6_ggtt_insert_entries(struct i915_address_space *vm, · 21 unmodified lines
25252522 * want to flush the TLBs only after we're certain all the PTE updates
25262523 * have finished.
25272524 */
2528− I915_WRITE(GFX_FLSH_CNTL_GEN6, GFX_FLSH_CNTL_EN);
2529− POSTING_READ(GFX_FLSH_CNTL_GEN6);
2525+ ggtt->invalidate(vm->i915);
25302526 }
25312527
25322528 static void nop_clear_range(struct i915_address_space *vm,
@@ -2723,11 +2719,11 @@ static void i915_gtt_color_adjust(const struct drm_mm_node *node, · 190 unmodified lines
27232719 u64 *end)
27242720 {
27252721 if (node->color != color)
2726− *start += 4096;
2722+ *start += I915_GTT_PAGE_SIZE;
27272723
27282724 node = list_next_entry(node, node_list);
27292725 if (node->allocated && node->color != color)
2730− *end -= 4096;
2726+ *end -= I915_GTT_PAGE_SIZE;
27312727 }
27322728
27332729 int i915_gem_init_ggtt(struct drm_i915_private *dev_priv)
@@ -2754,7 +2750,7 @@ int i915_gem_init_ggtt(struct drm_i915_private *dev_priv) · 20 unmodified lines
27542750 /* Reserve a mappable slot for our lockless error capture */
27552751 ret = drm_mm_insert_node_in_range_generic(&ggtt->base.mm,
27562752 &ggtt->error_capture,
2757− 4096, 0,
2753+ PAGE_SIZE, 0,
27582754 I915_COLOR_UNEVICTABLE,
27592755 0, ggtt->mappable_end,
27602756 0, 0);
@@ -3086,6 +3082,8 @@ static int gen8_gmch_probe(struct i915_ggtt *ggtt) · 325 unmodified lines
30863082 if (IS_CHERRYVIEW(dev_priv))
30873083 ggtt->base.insert_entries = gen8_ggtt_insert_entries__BKL;
30883084
3085+ ggtt->invalidate = gen6_ggtt_invalidate;
3086+
30893087 return ggtt_probe_common(ggtt, size);
30903088 }
30913089
@@ -3123,6 +3121,8 @@ static int gen6_gmch_probe(struct i915_ggtt *ggtt) · 31 unmodified lines
31233121 ggtt->base.unbind_vma = ggtt_unbind_vma;
31243122 ggtt->base.cleanup = gen6_gmch_remove;
31253123
3124+ ggtt->invalidate = gen6_ggtt_invalidate;
3125+
31263126 if (HAS_EDRAM(dev_priv))
31273127 ggtt->base.pte_encode = iris_pte_encode;
31283128 else if (IS_HASWELL(dev_priv))
@@ -3166,6 +3166,8 @@ static int i915_gmch_probe(struct i915_ggtt *ggtt) · 37 unmodified lines
31663166 ggtt->base.unbind_vma = ggtt_unbind_vma;
31673167 ggtt->base.cleanup = i915_gmch_remove;
31683168
3169+ ggtt->invalidate = gmch_ggtt_invalidate;
3170+
31693171 if (unlikely(ggtt->do_idle_maps))
31703172 DRM_INFO("applying Ironlake quirks for intel_iommu\n");
31713173
@@ -3284,6 +3286,16 @@ int i915_ggtt_enable_hw(struct drm_i915_private *dev_priv) · 112 unmodified lines
32843286 return 0;
32853287 }
32863288
3289+void i915_ggtt_enable_guc(struct drm_i915_private *i915)
3290+{
3291+ i915->ggtt.invalidate = guc_ggtt_invalidate;
3292+}
3293+
3294+void i915_ggtt_disable_guc(struct drm_i915_private *i915)
3295+{
3296+ i915->ggtt.invalidate = gen6_ggtt_invalidate;
3297+}
3298+
32873299 void i915_gem_restore_gtt_mappings(struct drm_i915_private *dev_priv)
32883300 {
32893301 struct i915_ggtt *ggtt = &dev_priv->ggtt;
@@ -3347,52 +3359,7 @@ void i915_gem_restore_gtt_mappings(struct drm_i915_private *dev_priv) · 57 unmodified lines
33473359 }
33483360 }
33493361
3350− i915_ggtt_flush(dev_priv);
3351−}
3352−
3353−struct i915_vma *
3354−i915_gem_obj_to_vma(struct drm_i915_gem_object *obj,
3355− struct i915_address_space *vm,
3356− const struct i915_ggtt_view *view)
3357−{
3358− struct rb_node *rb;
3359−
3360− rb = obj->vma_tree.rb_node;
3361− while (rb) {
3362− struct i915_vma *vma = rb_entry(rb, struct i915_vma, obj_node);
3363− long cmp;
3364−
3365− cmp = i915_vma_compare(vma, vm, view);
3366− if (cmp == 0)
3367− return vma;
3368−
3369− if (cmp < 0)
3370− rb = rb->rb_right;
3371− else
3372− rb = rb->rb_left;
3373− }
3374−
3375− return NULL;
3376−}
3377−
3378−struct i915_vma *
3379−i915_gem_obj_lookup_or_create_vma(struct drm_i915_gem_object *obj,
3380− struct i915_address_space *vm,
3381− const struct i915_ggtt_view *view)
3382−{
3383− struct i915_vma *vma;
3384−
3385− lockdep_assert_held(&obj->base.dev->struct_mutex);
3386− GEM_BUG_ON(view && !i915_is_ggtt(vm));
3387−
3388− vma = i915_gem_obj_to_vma(obj, vm, view);
3389− if (!vma) {
3390− vma = i915_vma_create(obj, vm, view);
3391− GEM_BUG_ON(vma != i915_gem_obj_to_vma(obj, vm, view));
3392− }
3393−
3394− GEM_BUG_ON(i915_vma_is_closed(vma));
3395− return vma;
3362+ i915_ggtt_invalidate(dev_priv);
33963363 }
33973364
33983365 static struct scatterlist *
@@ -3492,7 +3459,7 @@ intel_partial_pages(const struct i915_ggtt_view *view, · 93 unmodified lines
34923459 {
34933460 struct sg_table *st;
34943461 struct scatterlist *sg, *iter;
3495− unsigned int count = view->params.partial.size;
3462+ unsigned int count = view->partial.size;
34963463 unsigned int offset;
34973464 int ret = -ENOMEM;
34983465
@@ -3504,9 +3471,7 @@ intel_partial_pages(const struct i915_ggtt_view *view, · 5 unmodified lines
35043471 if (ret)
35053472 goto err_sg_alloc;
35063473
3507− iter = i915_gem_object_get_sg(obj,
3508− view->params.partial.offset,
3509− &offset);
3474+ iter = i915_gem_object_get_sg(obj, view->partial.offset, &offset);
35103475 GEM_BUG_ON(!iter);
35113476
35123477 sg = st->sgl;
@@ -3558,7 +3523,8 @@ i915_get_ggtt_vma_pages(struct i915_vma *vma) · 45 unmodified lines
35583523 vma->pages = vma->obj->mm.pages;
35593524 else if (vma->ggtt_view.type == I915_GGTT_VIEW_ROTATED)
35603525 vma->pages =
3561− intel_rotate_fb_obj_pages(&vma->ggtt_view.params.rotated, vma->obj);
3526+ intel_rotate_fb_obj_pages(&vma->ggtt_view.rotated,
3527+ vma->obj);
35623528 else if (vma->ggtt_view.type == I915_GGTT_VIEW_PARTIAL)
35633529 vma->pages = intel_partial_pages(&vma->ggtt_view, vma->obj);
35643530 else
@@ -3579,3 +3545,207 @@ i915_get_ggtt_vma_pages(struct i915_vma *vma) · 14 unmodified lines
35793545 return ret;
35803546 }
35813547
3548+/**
3549+ * i915_gem_gtt_reserve - reserve a node in an address_space (GTT)
3550+ * @vm: the &struct i915_address_space
3551+ * @node: the &struct drm_mm_node (typically i915_vma.mode)
3552+ * @size: how much space to allocate inside the GTT,
3553+ * must be #I915_GTT_PAGE_SIZE aligned
3554+ * @offset: where to insert inside the GTT,
3555+ * must be #I915_GTT_MIN_ALIGNMENT aligned, and the node
3556+ * (@offset + @size) must fit within the address space
3557+ * @color: color to apply to node, if this node is not from a VMA,
3558+ * color must be #I915_COLOR_UNEVICTABLE
3559+ * @flags: control search and eviction behaviour
3560+ *
3561+ * i915_gem_gtt_reserve() tries to insert the @node at the exact @offset inside
3562+ * the address space (using @size and @color). If the @node does not fit, it
3563+ * tries to evict any overlapping nodes from the GTT, including any
3564+ * neighbouring nodes if the colors do not match (to ensure guard pages between
3565+ * differing domains). See i915_gem_evict_for_node() for the gory details
3566+ * on the eviction algorithm. #PIN_NONBLOCK may used to prevent waiting on
3567+ * evicting active overlapping objects, and any overlapping node that is pinned
3568+ * or marked as unevictable will also result in failure.
3569+ *
3570+ * Returns: 0 on success, -ENOSPC if no suitable hole is found, -EINTR if
3571+ * asked to wait for eviction and interrupted.
3572+ */
3573+int i915_gem_gtt_reserve(struct i915_address_space *vm,
3574+ struct drm_mm_node *node,
3575+ u64 size, u64 offset, unsigned long color,
3576+ unsigned int flags)
3577+{
3578+ int err;
3579+
3580+ GEM_BUG_ON(!size);
3581+ GEM_BUG_ON(!IS_ALIGNED(size, I915_GTT_PAGE_SIZE));
3582+ GEM_BUG_ON(!IS_ALIGNED(offset, I915_GTT_MIN_ALIGNMENT));
3583+ GEM_BUG_ON(range_overflows(offset, size, vm->total));
3584+ GEM_BUG_ON(vm == &vm->i915->mm.aliasing_ppgtt->base);
3585+ GEM_BUG_ON(drm_mm_node_allocated(node));
3586+
3587+ node->size = size;
3588+ node->start = offset;
3589+ node->color = color;
3590+
3591+ err = drm_mm_reserve_node(&vm->mm, node);
3592+ if (err != -ENOSPC)
3593+ return err;
3594+
3595+ err = i915_gem_evict_for_node(vm, node, flags);
3596+ if (err == 0)
3597+ err = drm_mm_reserve_node(&vm->mm, node);
3598+
3599+ return err;
3600+}
3601+
3602+static u64 random_offset(u64 start, u64 end, u64 len, u64 align)
3603+{
3604+ u64 range, addr;
3605+
3606+ GEM_BUG_ON(range_overflows(start, len, end));
3607+ GEM_BUG_ON(round_up(start, align) > round_down(end - len, align));
3608+
3609+ range = round_down(end - len, align) - round_up(start, align);
3610+ if (range) {
3611+ if (sizeof(unsigned long) == sizeof(u64)) {
3612+ addr = get_random_long();
3613+ } else {
3614+ addr = get_random_int();
3615+ if (range > U32_MAX) {
3616+ addr <<= 32;
3617+ addr |= get_random_int();
3618+ }
3619+ }
3620+ div64_u64_rem(addr, range, &addr);
3621+ start += addr;
3622+ }
3623+
3624+ return round_up(start, align);
3625+}
3626+
3627+/**
3628+ * i915_gem_gtt_insert - insert a node into an address_space (GTT)
3629+ * @vm: the &struct i915_address_space
3630+ * @node: the &struct drm_mm_node (typically i915_vma.node)
3631+ * @size: how much space to allocate inside the GTT,
3632+ * must be #I915_GTT_PAGE_SIZE aligned
3633+ * @alignment: required alignment of starting offset, may be 0 but
3634+ * if specified, this must be a power-of-two and at least
3635+ * #I915_GTT_MIN_ALIGNMENT
3636+ * @color: color to apply to node
3637+ * @start: start of any range restriction inside GTT (0 for all),
3638+ * must be #I915_GTT_PAGE_SIZE aligned
3639+ * @end: end of any range restriction inside GTT (U64_MAX for all),
3640+ * must be #I915_GTT_PAGE_SIZE aligned if not U64_MAX
3641+ * @flags: control search and eviction behaviour
3642+ *
3643+ * i915_gem_gtt_insert() first searches for an available hole into which
3644+ * is can insert the node. The hole address is aligned to @alignment and
3645+ * its @size must then fit entirely within the [@start, @end] bounds. The
3646+ * nodes on either side of the hole must match @color, or else a guard page
3647+ * will be inserted between the two nodes (or the node evicted). If no
3648+ * suitable hole is found, first a victim is randomly selected and tested
3649+ * for eviction, otherwise then the LRU list of objects within the GTT
3650+ * is scanned to find the first set of replacement nodes to create the hole.
3651+ * Those old overlapping nodes are evicted from the GTT (and so must be
3652+ * rebound before any future use). Any node that is currently pinned cannot
3653+ * be evicted (see i915_vma_pin()). Similar if the node's VMA is currently
3654+ * active and #PIN_NONBLOCK is specified, that node is also skipped when
3655+ * searching for an eviction candidate. See i915_gem_evict_something() for
3656+ * the gory details on the eviction algorithm.
3657+ *
3658+ * Returns: 0 on success, -ENOSPC if no suitable hole is found, -EINTR if
3659+ * asked to wait for eviction and interrupted.
3660+ */
3661+int i915_gem_gtt_insert(struct i915_address_space *vm,
3662+ struct drm_mm_node *node,
3663+ u64 size, u64 alignment, unsigned long color,
3664+ u64 start, u64 end, unsigned int flags)
3665+{
3666+ u32 search_flag, alloc_flag;
3667+ u64 offset;
3668+ int err;
3669+
3670+ lockdep_assert_held(&vm->i915->drm.struct_mutex);
3671+ GEM_BUG_ON(!size);
3672+ GEM_BUG_ON(!IS_ALIGNED(size, I915_GTT_PAGE_SIZE));
3673+ GEM_BUG_ON(alignment && !is_power_of_2(alignment));
3674+ GEM_BUG_ON(alignment && !IS_ALIGNED(alignment, I915_GTT_MIN_ALIGNMENT));
3675+ GEM_BUG_ON(start >= end);
3676+ GEM_BUG_ON(start > 0 && !IS_ALIGNED(start, I915_GTT_PAGE_SIZE));
3677+ GEM_BUG_ON(end < U64_MAX && !IS_ALIGNED(end, I915_GTT_PAGE_SIZE));
3678+ GEM_BUG_ON(vm == &vm->i915->mm.aliasing_ppgtt->base);
3679+ GEM_BUG_ON(drm_mm_node_allocated(node));
3680+
3681+ if (unlikely(range_overflows(start, size, end)))
3682+ return -ENOSPC;
3683+
3684+ if (unlikely(round_up(start, alignment) > round_down(end - size, alignment)))
3685+ return -ENOSPC;
3686+
3687+ if (flags & PIN_HIGH) {
3688+ search_flag = DRM_MM_SEARCH_BELOW;
3689+ alloc_flag = DRM_MM_CREATE_TOP;
3690+ } else {
3691+ search_flag = DRM_MM_SEARCH_DEFAULT;
3692+ alloc_flag = DRM_MM_CREATE_DEFAULT;
3693+ }
3694+
3695+ /* We only allocate in PAGE_SIZE/GTT_PAGE_SIZE (4096) chunks,
3696+ * so we know that we always have a minimum alignment of 4096.
3697+ * The drm_mm range manager is optimised to return results
3698+ * with zero alignment, so where possible use the optimal
3699+ * path.
3700+ */
3701+ BUILD_BUG_ON(I915_GTT_MIN_ALIGNMENT > I915_GTT_PAGE_SIZE);
3702+ if (alignment <= I915_GTT_MIN_ALIGNMENT)
3703+ alignment = 0;
3704+
3705+ err = drm_mm_insert_node_in_range_generic(&vm->mm, node,
3706+ size, alignment, color,
3707+ start, end,
3708+ search_flag, alloc_flag);
3709+ if (err != -ENOSPC)
3710+ return err;
3711+
3712+ /* No free space, pick a slot at random.
3713+ *
3714+ * There is a pathological case here using a GTT shared between
3715+ * mmap and GPU (i.e. ggtt/aliasing_ppgtt but not full-ppgtt):
3716+ *
3717+ * |<-- 256 MiB aperture -->||<-- 1792 MiB unmappable -->|
3718+ * (64k objects) (448k objects)
3719+ *
3720+ * Now imagine that the eviction LRU is ordered top-down (just because
3721+ * pathology meets real life), and that we need to evict an object to
3722+ * make room inside the aperture. The eviction scan then has to walk
3723+ * the 448k list before it finds one within range. And now imagine that
3724+ * it has to search for a new hole between every byte inside the memcpy,
3725+ * for several simultaneous clients.
3726+ *
3727+ * On a full-ppgtt system, if we have run out of available space, there
3728+ * will be lots and lots of objects in the eviction list! Again,
3729+ * searching that LRU list may be slow if we are also applying any
3730+ * range restrictions (e.g. restriction to low 4GiB) and so, for
3731+ * simplicity and similarilty between different GTT, try the single
3732+ * random replacement first.
3733+ */
3734+ offset = random_offset(start, end,
3735+ size, alignment ?: I915_GTT_MIN_ALIGNMENT);
3736+ err = i915_gem_gtt_reserve(vm, node, size, offset, color, flags);
3737+ if (err != -ENOSPC)
3738+ return err;
3739+
3740+ /* Randomly selected placement is pinned, do a search */
3741+ err = i915_gem_evict_something(vm, size, alignment, color,
3742+ start, end, flags);
3743+ if (err)
3744+ return err;
3745+
3746+ search_flag = DRM_MM_SEARCH_DEFAULT;
3747+ return drm_mm_insert_node_in_range_generic(&vm->mm, node,
3748+ size, alignment, color,
3749+ start, end,
3750+ search_flag, alloc_flag);
3751+}
drivers/gpu/drm/i915/i915_gem_gtt.h+57−17
@@ -40,6 +40,9 @@ · 39 unmodified lines
4040 #include "i915_gem_timeline.h"
4141 #include "i915_gem_request.h"
4242
43+#define I915_GTT_PAGE_SIZE 4096UL
44+#define I915_GTT_MIN_ALIGNMENT I915_GTT_PAGE_SIZE
45+
4346 #define I915_FENCE_REG_NONE -1
4447 #define I915_MAX_NUM_FENCES 32
4548 /* 32 fences + sign bit for FENCE_REG_NONE */
@@ -142,34 +145,57 @@ typedef uint64_t gen8_ppgtt_pml4e_t; · 96 unmodified lines
142145
143146 struct sg_table;
144147
145−enum i915_ggtt_view_type {
146− I915_GGTT_VIEW_NORMAL = 0,
147− I915_GGTT_VIEW_ROTATED,
148− I915_GGTT_VIEW_PARTIAL,
149−};
150−
151148 struct intel_rotation_info {
152− struct {
149+ struct intel_rotation_plane_info {
153150 /* tiles */
154151 unsigned int width, height, stride, offset;
155152 } plane[2];
153+} __packed;
154+
155+static inline void assert_intel_rotation_info_is_packed(void)
156+{
157+ BUILD_BUG_ON(sizeof(struct intel_rotation_info) != 8*sizeof(unsigned int));
158+}
159+
160+struct intel_partial_info {
161+ u64 offset;
162+ unsigned int size;
163+} __packed;
164+
165+static inline void assert_intel_partial_info_is_packed(void)
166+{
167+ BUILD_BUG_ON(sizeof(struct intel_partial_info) != sizeof(u64) + sizeof(unsigned int));
168+}
169+
170+enum i915_ggtt_view_type {
171+ I915_GGTT_VIEW_NORMAL = 0,
172+ I915_GGTT_VIEW_ROTATED = sizeof(struct intel_rotation_info),
173+ I915_GGTT_VIEW_PARTIAL = sizeof(struct intel_partial_info),
156174 };
157175
176+static inline void assert_i915_ggtt_view_type_is_unique(void)
177+{
178+ /* As we encode the size of each branch inside the union into its type,
179+ * we have to be careful that each branch has a unique size.
180+ */
181+ switch ((enum i915_ggtt_view_type)0) {
182+ case I915_GGTT_VIEW_NORMAL:
183+ case I915_GGTT_VIEW_PARTIAL:
184+ case I915_GGTT_VIEW_ROTATED:
185+ /* gcc complains if these are identical cases */
186+ break;
187+ }
188+}
189+
158190 struct i915_ggtt_view {
159191 enum i915_ggtt_view_type type;
160−
161192 union {
162− struct {
163− u64 offset;
164− unsigned int size;
165− } partial;
193+ /* Members need to contain no holes/padding */
194+ struct intel_partial_info partial;
166195 struct intel_rotation_info rotated;
167− } params;
196+ };
168197 };
169198
170−extern const struct i915_ggtt_view i915_ggtt_view_normal;
171−extern const struct i915_ggtt_view i915_ggtt_view_rotated;
172−
173199 enum i915_cache_level;
174200
175201 struct i915_vma;
@@ -333,6 +359,7 @@ struct i915_ggtt { · 157 unmodified lines
333359
334360 /** "Graphics Stolen Memory" holds the global PTEs */
335361 void __iomem *gsm;
362+ void (*invalidate)(struct drm_i915_private *dev_priv);
336363
337364 bool do_idle_maps;
338365
@@ -501,6 +528,8 @@ i915_vm_to_ggtt(struct i915_address_space *vm) · 162 unmodified lines
501528 int i915_ggtt_probe_hw(struct drm_i915_private *dev_priv);
502529 int i915_ggtt_init_hw(struct drm_i915_private *dev_priv);
503530 int i915_ggtt_enable_hw(struct drm_i915_private *dev_priv);
531+void i915_ggtt_enable_guc(struct drm_i915_private *i915);
532+void i915_ggtt_disable_guc(struct drm_i915_private *i915);
504533 int i915_gem_init_ggtt(struct drm_i915_private *dev_priv);
505534 void i915_ggtt_cleanup_hw(struct drm_i915_private *dev_priv);
506535
@@ -509,6 +538,7 @@ void i915_ppgtt_release(struct kref *kref); · 2 unmodified lines
509538 struct i915_hw_ppgtt *i915_ppgtt_create(struct drm_i915_private *dev_priv,
510539 struct drm_i915_file_private *fpriv,
511540 const char *name);
541+void i915_ppgtt_close(struct i915_address_space *vm);
512542 static inline void i915_ppgtt_get(struct i915_hw_ppgtt *ppgtt)
513543 {
514544 if (ppgtt)
@@ -529,6 +559,16 @@ int __must_check i915_gem_gtt_prepare_pages(struct drm_i915_gem_object *obj, · 14 unmodified lines
529559 void i915_gem_gtt_finish_pages(struct drm_i915_gem_object *obj,
530560 struct sg_table *pages);
531561
562+int i915_gem_gtt_reserve(struct i915_address_space *vm,
563+ struct drm_mm_node *node,
564+ u64 size, u64 offset, unsigned long color,
565+ unsigned int flags);
566+
567+int i915_gem_gtt_insert(struct i915_address_space *vm,
568+ struct drm_mm_node *node,
569+ u64 size, u64 alignment, unsigned long color,
570+ u64 start, u64 end, unsigned int flags);
571+
532572 /* Flags used by pin/bind&friends. */
533573 #define PIN_NONBLOCK BIT(0)
534574 #define PIN_MAPPABLE BIT(1)
@@ -543,6 +583,6 @@ void i915_gem_gtt_finish_pages(struct drm_i915_gem_object *obj, · 8 unmodified lines
543583 #define PIN_HIGH BIT(9)
544584 #define PIN_OFFSET_BIAS BIT(10)
545585 #define PIN_OFFSET_FIXED BIT(11)
546−#define PIN_OFFSET_MASK (~4095)
586+#define PIN_OFFSET_MASK (-I915_GTT_PAGE_SIZE)
547587
548588 #endif
drivers/gpu/drm/i915/i915_gem_internal.c+7−1
@@ -151,10 +151,16 @@ static const struct drm_i915_gem_object_ops i915_gem_object_internal_ops = { · 150 unmodified lines
151151 */
152152 struct drm_i915_gem_object *
153153 i915_gem_object_create_internal(struct drm_i915_private *i915,
154− unsigned int size)
154+ phys_addr_t size)
155155 {
156156 struct drm_i915_gem_object *obj;
157157
158+ GEM_BUG_ON(!size);
159+ GEM_BUG_ON(!IS_ALIGNED(size, PAGE_SIZE));
160+
161+ if (overflows_type(size, obj->base.size))
162+ return ERR_PTR(-E2BIG);
163+
158164 obj = i915_gem_object_alloc(i915);
159165 if (!obj)
160166 return ERR_PTR(-ENOMEM);
drivers/gpu/drm/i915/i915_gem_object.h+23−0
@@ -317,6 +317,29 @@ i915_gem_object_get_stride(struct drm_i915_gem_object *obj) · 316 unmodified lines
317317 return obj->tiling_and_stride & STRIDE_MASK;
318318 }
319319
320+static inline unsigned int
321+i915_gem_tile_height(unsigned int tiling)
322+{
323+ GEM_BUG_ON(!tiling);
324+ return tiling == I915_TILING_Y ? 32 : 8;
325+}
326+
327+static inline unsigned int
328+i915_gem_object_get_tile_height(struct drm_i915_gem_object *obj)
329+{
330+ return i915_gem_tile_height(i915_gem_object_get_tiling(obj));
331+}
332+
333+static inline unsigned int
334+i915_gem_object_get_tile_row_size(struct drm_i915_gem_object *obj)
335+{
336+ return (i915_gem_object_get_stride(obj) *
337+ i915_gem_object_get_tile_height(obj));
338+}
339+
340+int i915_gem_object_set_tiling(struct drm_i915_gem_object *obj,
341+ unsigned int tiling, unsigned int stride);
342+
320343 static inline struct intel_engine_cs *
321344 i915_gem_object_last_write_engine(struct drm_i915_gem_object *obj)
322345 {
drivers/gpu/drm/i915/i915_gem_render_state.c+3−3
@@ -187,20 +187,20 @@ int i915_gem_render_state_init(struct intel_engine_cs *engine) · 186 unmodified lines
187187 if (!rodata)
188188 return 0;
189189
190− if (rodata->batch_items * 4 > 4096)
190+ if (rodata->batch_items * 4 > PAGE_SIZE)
191191 return -EINVAL;
192192
193193 so = kmalloc(sizeof(*so), GFP_KERNEL);
194194 if (!so)
195195 return -ENOMEM;
196196
197− obj = i915_gem_object_create_internal(engine->i915, 4096);
197+ obj = i915_gem_object_create_internal(engine->i915, PAGE_SIZE);
198198 if (IS_ERR(obj)) {
199199 ret = PTR_ERR(obj);
200200 goto err_free;
201201 }
202202
203− so->vma = i915_vma_create(obj, &engine->i915->ggtt.base, NULL);
203+ so->vma = i915_vma_instance(obj, &engine->i915->ggtt.base, NULL);
204204 if (IS_ERR(so->vma)) {
205205 ret = PTR_ERR(so->vma);
206206 goto err_obj;
drivers/gpu/drm/i915/i915_gem_request.c+10−25
@@ -307,26 +307,6 @@ void i915_gem_request_retire_upto(struct drm_i915_gem_request *req) · 306 unmodified lines
307307 } while (tmp != req);
308308 }
309309
310−static int i915_gem_check_wedge(struct drm_i915_private *dev_priv)
311−{
312− struct i915_gpu_error *error = &dev_priv->gpu_error;
313−
314− if (i915_terminally_wedged(error))
315− return -EIO;
316−
317− if (i915_reset_in_progress(error)) {
318− /* Non-interruptible callers can't handle -EAGAIN, hence return
319− * -EIO unconditionally for these.
320− */
321− if (!dev_priv->mm.interruptible)
322− return -EIO;
323−
324− return -EAGAIN;
325− }
326−
327− return 0;
328−}
329−
330310 static int i915_gem_init_global_seqno(struct drm_i915_private *i915, u32 seqno)
331311 {
332312 struct i915_gem_timeline *timeline = &i915->gt.global_timeline;
@@ -521,12 +501,10 @@ i915_gem_request_alloc(struct intel_engine_cs *engine, · 188 unmodified lines
521501 lockdep_assert_held(&dev_priv->drm.struct_mutex);
522502
523503 /* ABI: Before userspace accesses the GPU (e.g. execbuffer), report
524− * EIO if the GPU is already wedged, or EAGAIN to drop the struct_mutex
525− * and restart.
504+ * EIO if the GPU is already wedged.
526505 */
527− ret = i915_gem_check_wedge(dev_priv);
528− if (ret)
529− return ERR_PTR(ret);
506+ if (i915_terminally_wedged(&dev_priv->gpu_error))
507+ return ERR_PTR(-EIO);
530508
531509 /* Pinning the contexts may generate requests in order to acquire
532510 * GGTT space, so do this first before we reserve a seqno for
@@ -851,6 +829,13 @@ void __i915_add_request(struct drm_i915_gem_request *request, bool flush_caches) · 318 unmodified lines
851829 lockdep_assert_held(&request->i915->drm.struct_mutex);
852830 trace_i915_gem_request_add(request);
853831
832+ /* Make sure that no request gazumped us - if it was allocated after
833+ * our i915_gem_request_alloc() and called __i915_add_request() before
834+ * us, the timeline will hold its seqno which is later than ours.
835+ */
836+ GEM_BUG_ON(i915_seqno_passed(timeline->last_submitted_seqno,
837+ request->fence.seqno));
838+
854839 /*
855840 * To ensure that this call will not fail, space for its emissions
856841 * should already have been reserved in the ring buffer. Let the ring
drivers/gpu/drm/i915/i915_gem_stolen.c+9−7
@@ -647,8 +647,9 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_i915_private *dev_priv · 646 unmodified lines
647647 stolen_offset, gtt_offset, size);
648648
649649 /* KISS and expect everything to be page-aligned */
650− if (WARN_ON(size == 0) || WARN_ON(size & 4095) ||
651− WARN_ON(stolen_offset & 4095))
650+ if (WARN_ON(size == 0) ||
651+ WARN_ON(!IS_ALIGNED(size, I915_GTT_PAGE_SIZE)) ||
652+ WARN_ON(!IS_ALIGNED(stolen_offset, I915_GTT_MIN_ALIGNMENT)))
652653 return NULL;
653654
654655 stolen = kzalloc(sizeof(*stolen), GFP_KERNEL);
@@ -682,7 +683,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_i915_private *dev_priv · 27 unmodified lines
682683 if (ret)
683684 goto err;
684685
685− vma = i915_gem_obj_lookup_or_create_vma(obj, &ggtt->base, NULL);
686+ vma = i915_vma_instance(obj, &ggtt->base, NULL);
686687 if (IS_ERR(vma)) {
687688 ret = PTR_ERR(vma);
688689 goto err_pages;
@@ -693,15 +694,16 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_i915_private *dev_priv · 4 unmodified lines
693694 * setting up the GTT space. The actual reservation will occur
694695 * later.
695696 */
696− vma->node.start = gtt_offset;
697− vma->node.size = size;
698−
699− ret = drm_mm_reserve_node(&ggtt->base.mm, &vma->node);
697+ ret = i915_gem_gtt_reserve(&ggtt->base, &vma->node,
698+ size, gtt_offset, obj->cache_level,
699+ 0);
700700 if (ret) {
701701 DRM_DEBUG_KMS("failed to allocate stolen GTT space\n");
702702 goto err_pages;
703703 }
704704
705+ GEM_BUG_ON(!drm_mm_node_allocated(&vma->node));
706+
705707 vma->pages = obj->mm.pages;
706708 vma->flags |= I915_VMA_GLOBAL_BIND;
707709 __i915_vma_set_map_and_fenceable(vma);
drivers/gpu/drm/i915/i915_gem_tiling.c+217−130
@@ -34,8 +34,8 @@ · 33 unmodified lines
3434 /**
3535 * DOC: buffer object tiling
3636 *
37− * i915_gem_set_tiling() and i915_gem_get_tiling() is the userspace interface to
38− * declare fence register requirements.
37+ * i915_gem_set_tiling_ioctl() and i915_gem_get_tiling_ioctl() is the userspace
38+ * interface to declare fence register requirements.
3939 *
4040 * In principle GEM doesn't care at all about the internal data layout of an
4141 * object, and hence it also doesn't care about tiling or swizzling. There's two
@@ -58,86 +58,147 @@ · 16 unmodified lines
5858 * invovlement.
5959 */
6060
61+/**
62+ * i915_gem_fence_size - required global GTT size for a fence
63+ * @i915: i915 device
64+ * @size: object size
65+ * @tiling: tiling mode
66+ * @stride: tiling stride
67+ *
68+ * Return the required global GTT size for a fence (view of a tiled object),
69+ * taking into account potential fence register mapping.
70+ */
71+u32 i915_gem_fence_size(struct drm_i915_private *i915,
72+ u32 size, unsigned int tiling, unsigned int stride)
73+{
74+ u32 ggtt_size;
75+
76+ GEM_BUG_ON(!size);
77+
78+ if (tiling == I915_TILING_NONE)
79+ return size;
80+
81+ GEM_BUG_ON(!stride);
82+
83+ if (INTEL_GEN(i915) >= 4) {
84+ stride *= i915_gem_tile_height(tiling);
85+ GEM_BUG_ON(!IS_ALIGNED(stride, I965_FENCE_PAGE));
86+ return roundup(size, stride);
87+ }
88+
89+ /* Previous chips need a power-of-two fence region when tiling */
90+ if (IS_GEN3(i915))
91+ ggtt_size = 1024*1024;
92+ else
93+ ggtt_size = 512*1024;
94+
95+ while (ggtt_size < size)
96+ ggtt_size <<= 1;
97+
98+ return ggtt_size;
99+}
100+
101+/**
102+ * i915_gem_fence_alignment - required global GTT alignment for a fence
103+ * @i915: i915 device
104+ * @size: object size
105+ * @tiling: tiling mode
106+ * @stride: tiling stride
107+ *
108+ * Return the required global GTT alignment for a fence (a view of a tiled
109+ * object), taking into account potential fence register mapping.
110+ */
111+u32 i915_gem_fence_alignment(struct drm_i915_private *i915, u32 size,
112+ unsigned int tiling, unsigned int stride)
113+{
114+ GEM_BUG_ON(!size);
115+
116+ /*
117+ * Minimum alignment is 4k (GTT page size), but might be greater
118+ * if a fence register is needed for the object.
119+ */
120+ if (tiling == I915_TILING_NONE)
121+ return I915_GTT_MIN_ALIGNMENT;
122+
123+ if (INTEL_GEN(i915) >= 4)
124+ return I965_FENCE_PAGE;
125+
126+ /*
127+ * Previous chips need to be aligned to the size of the smallest
128+ * fence register that can contain the object.
129+ */
130+ return i915_gem_fence_size(i915, size, tiling, stride);
131+}
132+
61133 /* Check pitch constriants for all chips & tiling formats */
62134 static bool
63−i915_tiling_ok(struct drm_i915_private *dev_priv,
64− int stride, int size, int tiling_mode)
135+i915_tiling_ok(struct drm_i915_gem_object *obj,
136+ unsigned int tiling, unsigned int stride)
65137 {
66− int tile_width;
138+ struct drm_i915_private *i915 = to_i915(obj->base.dev);
139+ unsigned int tile_width;
67140
68141 /* Linear is always fine */
69− if (tiling_mode == I915_TILING_NONE)
142+ if (tiling == I915_TILING_NONE)
70143 return true;
71144
72− if (tiling_mode > I915_TILING_LAST)
145+ if (tiling > I915_TILING_LAST)
73146 return false;
74147
75− if (IS_GEN2(dev_priv) ||
76− (tiling_mode == I915_TILING_Y && HAS_128_BYTE_Y_TILING(dev_priv)))
77− tile_width = 128;
78− else
79− tile_width = 512;
80−
81148 /* check maximum stride & object size */
82149 /* i965+ stores the end address of the gtt mapping in the fence
83150 * reg, so dont bother to check the size */
84− if (INTEL_GEN(dev_priv) >= 7) {
151+ if (INTEL_GEN(i915) >= 7) {
85152 if (stride / 128 > GEN7_FENCE_MAX_PITCH_VAL)
86153 return false;
87− } else if (INTEL_GEN(dev_priv) >= 4) {
154+ } else if (INTEL_GEN(i915) >= 4) {
88155 if (stride / 128 > I965_FENCE_MAX_PITCH_VAL)
89156 return false;
90157 } else {
91158 if (stride > 8192)
92159 return false;
93160
94− if (IS_GEN3(dev_priv)) {
95− if (size > I830_FENCE_MAX_SIZE_VAL << 20)
161+ if (IS_GEN3(i915)) {
162+ if (obj->base.size > I830_FENCE_MAX_SIZE_VAL << 20)
96163 return false;
97164 } else {
98− if (size > I830_FENCE_MAX_SIZE_VAL << 19)
165+ if (obj->base.size > I830_FENCE_MAX_SIZE_VAL << 19)
99166 return false;
100167 }
101168 }
102169
103− if (stride < tile_width)
170+ if (IS_GEN2(i915) ||
171+ (tiling == I915_TILING_Y && HAS_128_BYTE_Y_TILING(i915)))
172+ tile_width = 128;
173+ else
174+ tile_width = 512;
175+
176+ if (!IS_ALIGNED(stride, tile_width))
104177 return false;
105178
106179 /* 965+ just needs multiples of tile width */
107− if (INTEL_GEN(dev_priv) >= 4) {
108− if (stride & (tile_width - 1))
109− return false;
180+ if (INTEL_GEN(i915) >= 4)
110181 return true;
111− }
112182
113183 /* Pre-965 needs power of two tile widths */
114− if (stride & (stride - 1))
115− return false;
116−
117− return true;
184+ return is_power_of_2(stride);
118185 }
119186
120−static bool i915_vma_fence_prepare(struct i915_vma *vma, int tiling_mode)
187+static bool i915_vma_fence_prepare(struct i915_vma *vma,
188+ int tiling_mode, unsigned int stride)
121189 {
122− struct drm_i915_private *dev_priv = vma->vm->i915;
123− u32 size;
190+ struct drm_i915_private *i915 = vma->vm->i915;
191+ u32 size, alignment;
124192
125193 if (!i915_vma_is_map_and_fenceable(vma))
126194 return true;
127195
128− if (INTEL_GEN(dev_priv) == 3) {
129− if (vma->node.start & ~I915_FENCE_START_MASK)
130− return false;
131− } else {
132− if (vma->node.start & ~I830_FENCE_START_MASK)
133− return false;
134− }
135−
136− size = i915_gem_get_ggtt_size(dev_priv, vma->size, tiling_mode);
196+ size = i915_gem_fence_size(i915, vma->size, tiling_mode, stride);
137197 if (vma->node.size < size)
138198 return false;
139199
140− if (vma->node.start & (size - 1))
200+ alignment = i915_gem_fence_alignment(i915, vma->size, tiling_mode, stride);
201+ if (!IS_ALIGNED(vma->node.start, alignment))
141202 return false;
142203
143204 return true;
@@ -145,20 +206,20 @@ static bool i915_vma_fence_prepare(struct i915_vma *vma, int tiling_mode) · 1 unmodified line
145206
146207 /* Make the current GTT allocation valid for the change in tiling. */
147208 static int
148−i915_gem_object_fence_prepare(struct drm_i915_gem_object *obj, int tiling_mode)
209+i915_gem_object_fence_prepare(struct drm_i915_gem_object *obj,
210+ int tiling_mode, unsigned int stride)
149211 {
150− struct drm_i915_private *dev_priv = to_i915(obj->base.dev);
151212 struct i915_vma *vma;
152213 int ret;
153214
154215 if (tiling_mode == I915_TILING_NONE)
155216 return 0;
156217
157− if (INTEL_GEN(dev_priv) >= 4)
158− return 0;
159−
160218 list_for_each_entry(vma, &obj->vma_list, obj_link) {
161− if (i915_vma_fence_prepare(vma, tiling_mode))
219+ if (!i915_vma_is_ggtt(vma))
220+ break;
221+
222+ if (i915_vma_fence_prepare(vma, tiling_mode, stride))
162223 continue;
163224
164225 ret = i915_vma_unbind(vma);
@@ -169,8 +230,100 @@ i915_gem_object_fence_prepare(struct drm_i915_gem_object *obj, int tiling_mode) · 4 unmodified lines
169230 return 0;
170231 }
171232
233+int
234+i915_gem_object_set_tiling(struct drm_i915_gem_object *obj,
235+ unsigned int tiling, unsigned int stride)
236+{
237+ struct drm_i915_private *i915 = to_i915(obj->base.dev);
238+ struct i915_vma *vma;
239+ int err;
240+
241+ /* Make sure we don't cross-contaminate obj->tiling_and_stride */
242+ BUILD_BUG_ON(I915_TILING_LAST & STRIDE_MASK);
243+
244+ GEM_BUG_ON(!i915_tiling_ok(obj, tiling, stride));
245+ GEM_BUG_ON(!stride ^ (tiling == I915_TILING_NONE));
246+ lockdep_assert_held(&i915->drm.struct_mutex);
247+
248+ if ((tiling | stride) == obj->tiling_and_stride)
249+ return 0;
250+
251+ if (obj->framebuffer_references)
252+ return -EBUSY;
253+
254+ /* We need to rebind the object if its current allocation
255+ * no longer meets the alignment restrictions for its new
256+ * tiling mode. Otherwise we can just leave it alone, but
257+ * need to ensure that any fence register is updated before
258+ * the next fenced (either through the GTT or by the BLT unit
259+ * on older GPUs) access.
260+ *
261+ * After updating the tiling parameters, we then flag whether
262+ * we need to update an associated fence register. Note this
263+ * has to also include the unfenced register the GPU uses
264+ * whilst executing a fenced command for an untiled object.
265+ */
266+
267+ err = i915_gem_object_fence_prepare(obj, tiling, stride);
268+ if (err)
269+ return err;
270+
271+ /* If the memory has unknown (i.e. varying) swizzling, we pin the
272+ * pages to prevent them being swapped out and causing corruption
273+ * due to the change in swizzling.
274+ */
275+ mutex_lock(&obj->mm.lock);
276+ if (obj->mm.pages &&
277+ obj->mm.madv == I915_MADV_WILLNEED &&
278+ i915->quirks & QUIRK_PIN_SWIZZLED_PAGES) {
279+ if (tiling == I915_TILING_NONE) {
280+ GEM_BUG_ON(!obj->mm.quirked);
281+ __i915_gem_object_unpin_pages(obj);
282+ obj->mm.quirked = false;
283+ }
284+ if (!i915_gem_object_is_tiled(obj)) {
285+ GEM_BUG_ON(!obj->mm.quirked);
286+ __i915_gem_object_pin_pages(obj);
287+ obj->mm.quirked = true;
288+ }
289+ }
290+ mutex_unlock(&obj->mm.lock);
291+
292+ list_for_each_entry(vma, &obj->vma_list, obj_link) {
293+ if (!i915_vma_is_ggtt(vma))
294+ break;
295+
296+ vma->fence_size =
297+ i915_gem_fence_size(i915, vma->size, tiling, stride);
298+ vma->fence_alignment =
299+ i915_gem_fence_alignment(i915,
300+ vma->size, tiling, stride);
301+
302+ if (vma->fence)
303+ vma->fence->dirty = true;
304+ }
305+
306+ obj->tiling_and_stride = tiling | stride;
307+
308+ /* Force the fence to be reacquired for GTT access */
309+ i915_gem_release_mmap(obj);
310+
311+ /* Try to preallocate memory required to save swizzling on put-pages */
312+ if (i915_gem_object_needs_bit17_swizzle(obj)) {
313+ if (!obj->bit_17) {
314+ obj->bit_17 = kcalloc(BITS_TO_LONGS(obj->base.size >> PAGE_SHIFT),
315+ sizeof(long), GFP_KERNEL);
316+ }
317+ } else {
318+ kfree(obj->bit_17);
319+ obj->bit_17 = NULL;
320+ }
321+
322+ return 0;
323+}
324+
172325 /**
173− * i915_gem_set_tiling - IOCTL handler to set tiling mode
326+ * i915_gem_set_tiling_ioctl - IOCTL handler to set tiling mode
174327 * @dev: DRM device
175328 * @data: data pointer for the ioctl
176329 * @file: DRM file for the ioctl call
@@ -184,30 +337,19 @@ i915_gem_object_fence_prepare(struct drm_i915_gem_object *obj, int tiling_mode) · 7 unmodified lines
184337 * Zero on success, negative errno on failure.
185338 */
186339 int
187−i915_gem_set_tiling(struct drm_device *dev, void *data,
188− struct drm_file *file)
340+i915_gem_set_tiling_ioctl(struct drm_device *dev, void *data,
341+ struct drm_file *file)
189342 {
190343 struct drm_i915_gem_set_tiling *args = data;
191− struct drm_i915_private *dev_priv = to_i915(dev);
192344 struct drm_i915_gem_object *obj;
193− int err = 0;
194−
195− /* Make sure we don't cross-contaminate obj->tiling_and_stride */
196− BUILD_BUG_ON(I915_TILING_LAST & STRIDE_MASK);
345+ int err;
197346
198347 obj = i915_gem_object_lookup(file, args->handle);
199348 if (!obj)
200349 return -ENOENT;
201350
202− if (!i915_tiling_ok(dev_priv,
203− args->stride, obj->base.size, args->tiling_mode)) {
204− i915_gem_object_put(obj);
205− return -EINVAL;
206− }
207−
208− mutex_lock(&dev->struct_mutex);
209− if (obj->pin_display || obj->framebuffer_references) {
210− err = -EBUSY;
351+ if (!i915_tiling_ok(obj, args->tiling_mode, args->stride)) {
352+ err = -EINVAL;
211353 goto err;
212354 }
213355
@@ -216,9 +358,9 @@ i915_gem_set_tiling(struct drm_device *dev, void *data, · 2 unmodified lines
216358 args->stride = 0;
217359 } else {
218360 if (args->tiling_mode == I915_TILING_X)
219− args->swizzle_mode = dev_priv->mm.bit_6_swizzle_x;
361+ args->swizzle_mode = to_i915(dev)->mm.bit_6_swizzle_x;
220362 else
221− args->swizzle_mode = dev_priv->mm.bit_6_swizzle_y;
363+ args->swizzle_mode = to_i915(dev)->mm.bit_6_swizzle_y;
222364
223365 /* Hide bit 17 swizzling from the user. This prevents old Mesa
224366 * from aborting the application on sw fallbacks to bit 17,
@@ -240,79 +382,24 @@ i915_gem_set_tiling(struct drm_device *dev, void *data, · 15 unmodified lines
240382 }
241383 }
242384
243− if (args->tiling_mode != i915_gem_object_get_tiling(obj) ||
244− args->stride != i915_gem_object_get_stride(obj)) {
245− /* We need to rebind the object if its current allocation
246− * no longer meets the alignment restrictions for its new
247− * tiling mode. Otherwise we can just leave it alone, but
248− * need to ensure that any fence register is updated before
249− * the next fenced (either through the GTT or by the BLT unit
250− * on older GPUs) access.
251− *
252− * After updating the tiling parameters, we then flag whether
253− * we need to update an associated fence register. Note this
254− * has to also include the unfenced register the GPU uses
255− * whilst executing a fenced command for an untiled object.
256− */
385+ err = mutex_lock_interruptible(&dev->struct_mutex);
386+ if (err)
387+ goto err;
257388
258− err = i915_gem_object_fence_prepare(obj, args->tiling_mode);
259− if (!err) {
260− struct i915_vma *vma;
261−
262− mutex_lock(&obj->mm.lock);
263− if (obj->mm.pages &&
264− obj->mm.madv == I915_MADV_WILLNEED &&
265− dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES) {
266− if (args->tiling_mode == I915_TILING_NONE) {
267− GEM_BUG_ON(!obj->mm.quirked);
268− __i915_gem_object_unpin_pages(obj);
269− obj->mm.quirked = false;
270− }
271− if (!i915_gem_object_is_tiled(obj)) {
272− GEM_BUG_ON(!obj->mm.quirked);
273− __i915_gem_object_pin_pages(obj);
274− obj->mm.quirked = true;
275− }
276− }
277− mutex_unlock(&obj->mm.lock);
278−
279− list_for_each_entry(vma, &obj->vma_list, obj_link) {
280− if (!vma->fence)
281− continue;
282−
283− vma->fence->dirty = true;
284− }
285− obj->tiling_and_stride =
286− args->stride | args->tiling_mode;
287−
288− /* Force the fence to be reacquired for GTT access */
289− i915_gem_release_mmap(obj);
290− }
291− }
292− /* we have to maintain this existing ABI... */
389+ err = i915_gem_object_set_tiling(obj, args->tiling_mode, args->stride);
390+ mutex_unlock(&dev->struct_mutex);
391+
392+ /* We have to maintain this existing ABI... */
293393 args->stride = i915_gem_object_get_stride(obj);
294394 args->tiling_mode = i915_gem_object_get_tiling(obj);
295395
296− /* Try to preallocate memory required to save swizzling on put-pages */
297− if (i915_gem_object_needs_bit17_swizzle(obj)) {
298− if (obj->bit_17 == NULL) {
299− obj->bit_17 = kcalloc(BITS_TO_LONGS(obj->base.size >> PAGE_SHIFT),
300− sizeof(long), GFP_KERNEL);
301− }
302− } else {
303− kfree(obj->bit_17);
304− obj->bit_17 = NULL;
305− }
306−
307396 err:
308397 i915_gem_object_put(obj);
309− mutex_unlock(&dev->struct_mutex);
310−
311398 return err;
312399 }
313400
314401 /**
315− * i915_gem_get_tiling - IOCTL handler to get tiling mode
402+ * i915_gem_get_tiling_ioctl - IOCTL handler to get tiling mode
316403 * @dev: DRM device
317404 * @data: data pointer for the ioctl
318405 * @file: DRM file for the ioctl call
@@ -325,8 +412,8 @@ err: · 6 unmodified lines
325412 * Zero on success, negative errno on failure.
326413 */
327414 int
328−i915_gem_get_tiling(struct drm_device *dev, void *data,
329− struct drm_file *file)
415+i915_gem_get_tiling_ioctl(struct drm_device *dev, void *data,
416+ struct drm_file *file)
330417 {
331418 struct drm_i915_gem_get_tiling *args = data;
332419 struct drm_i915_private *dev_priv = to_i915(dev);
drivers/gpu/drm/i915/i915_gpu_error.c+1−0
@@ -121,6 +121,7 @@ static void __i915_error_advance(struct drm_i915_error_state_buf *e, · 120 unmodified lines
121121 e->pos += len;
122122 }
123123
124+__printf(2, 0)
124125 static void i915_error_vprintf(struct drm_i915_error_state_buf *e,
125126 const char *f, va_list args)
126127 {
drivers/gpu/drm/i915/i915_guc_reg.h+6−0
@@ -61,12 +61,18 @@ · 60 unmodified lines
6161 #define DMA_ADDRESS_SPACE_GTT (8 << 16)
6262 #define DMA_COPY_SIZE _MMIO(0xc310)
6363 #define DMA_CTRL _MMIO(0xc314)
64+#define HUC_UKERNEL (1<<9)
6465 #define UOS_MOVE (1<<4)
6566 #define START_DMA (1<<0)
6667 #define DMA_GUC_WOPCM_OFFSET _MMIO(0xc340)
68+#define HUC_LOADING_AGENT_VCR (0<<1)
69+#define HUC_LOADING_AGENT_GUC (1<<1)
6770 #define GUC_WOPCM_OFFSET_VALUE 0x80000 /* 512KB */
6871 #define GUC_MAX_IDLE_COUNT _MMIO(0xC3E4)
6972
73+#define HUC_STATUS2 _MMIO(0xD3B0)
74+#define HUC_FW_VERIFIED (1<<7)
75+
7076 /* Defines WOPCM space available to GuC firmware */
7177 #define GUC_WOPCM_SIZE _MMIO(0xc050)
7278 /* GuC addresses below GUC_WOPCM_TOP don't map through the GTT */
drivers/gpu/drm/i915/i915_guc_submission.c+9−594
@@ -22,8 +22,6 @@ · 21 unmodified lines
2222 *
2323 */
2424 #include <linux/circ_buf.h>
25−#include <linux/debugfs.h>
26−#include <linux/relay.h>
2725 #include "i915_drv.h"
2826 #include "intel_uc.h"
2927
@@ -545,7 +543,7 @@ static void i915_guc_submit(struct drm_i915_gem_request *rq) · 515 unmodified lines
545543 */
546544
547545 /**
548− * guc_allocate_vma() - Allocate a GGTT VMA for GuC usage
546+ * intel_guc_allocate_vma() - Allocate a GGTT VMA for GuC usage
549547 * @guc: the guc
550548 * @size: size of area to allocate (both virtual space and memory)
551549 *
@@ -557,7 +555,7 @@ static void i915_guc_submit(struct drm_i915_gem_request *rq) · 5 unmodified lines
557555 *
558556 * Return: A i915_vma if successful, otherwise an ERR_PTR.
559557 */
560−static struct i915_vma *guc_allocate_vma(struct intel_guc *guc, u32 size)
558+struct i915_vma *intel_guc_allocate_vma(struct intel_guc *guc, u32 size)
561559 {
562560 struct drm_i915_private *dev_priv = guc_to_i915(guc);
563561 struct drm_i915_gem_object *obj;
@@ -568,7 +566,7 @@ static struct i915_vma *guc_allocate_vma(struct intel_guc *guc, u32 size) · 4 unmodified lines
568566 if (IS_ERR(obj))
569567 return ERR_CAST(obj);
570568
571− vma = i915_vma_create(obj, &dev_priv->ggtt.base, NULL);
569+ vma = i915_vma_instance(obj, &dev_priv->ggtt.base, NULL);
572570 if (IS_ERR(vma))
573571 goto err;
574572
@@ -579,9 +577,6 @@ static struct i915_vma *guc_allocate_vma(struct intel_guc *guc, u32 size) · 4 unmodified lines
579577 goto err;
580578 }
581579
582− /* Invalidate GuC TLB to let GuC take the latest updates to GTT. */
583− I915_WRITE(GEN8_GTCR, GEN8_GTCR_INVALIDATE);
584−
585580 return vma;
586581
587582 err:
@@ -721,7 +716,7 @@ guc_client_alloc(struct drm_i915_private *dev_priv, · 133 unmodified lines
721716 }
722717
723718 /* The first page is doorbell/proc_desc. Two followed pages are wq. */
724− vma = guc_allocate_vma(guc, GUC_DB_SIZE + GUC_WQ_SIZE);
719+ vma = intel_guc_allocate_vma(guc, GUC_DB_SIZE + GUC_WQ_SIZE);
725720 if (IS_ERR(vma))
726721 goto err;
727722
@@ -777,488 +772,7 @@ err: · 49 unmodified lines
777772 return NULL;
778773 }
779774
780−/*
781− * Sub buffer switch callback. Called whenever relay has to switch to a new
782− * sub buffer, relay stays on the same sub buffer if 0 is returned.
783− */
784−static int subbuf_start_callback(struct rchan_buf *buf,
785− void *subbuf,
786− void *prev_subbuf,
787− size_t prev_padding)
788−{
789− /* Use no-overwrite mode by default, where relay will stop accepting
790− * new data if there are no empty sub buffers left.
791− * There is no strict synchronization enforced by relay between Consumer
792− * and Producer. In overwrite mode, there is a possibility of getting
793− * inconsistent/garbled data, the producer could be writing on to the
794− * same sub buffer from which Consumer is reading. This can't be avoided
795− * unless Consumer is fast enough and can always run in tandem with
796− * Producer.
797− */
798− if (relay_buf_full(buf))
799− return 0;
800−
801− return 1;
802−}
803−
804−/*
805− * file_create() callback. Creates relay file in debugfs.
806− */
807−static struct dentry *create_buf_file_callback(const char *filename,
808− struct dentry *parent,
809− umode_t mode,
810− struct rchan_buf *buf,
811− int *is_global)
812−{
813− struct dentry *buf_file;
814−
815− /* This to enable the use of a single buffer for the relay channel and
816− * correspondingly have a single file exposed to User, through which
817− * it can collect the logs in order without any post-processing.
818− * Need to set 'is_global' even if parent is NULL for early logging.
819− */
820− *is_global = 1;
821−
822− if (!parent)
823− return NULL;
824−
825− /* Not using the channel filename passed as an argument, since for each
826− * channel relay appends the corresponding CPU number to the filename
827− * passed in relay_open(). This should be fine as relay just needs a
828− * dentry of the file associated with the channel buffer and that file's
829− * name need not be same as the filename passed as an argument.
830− */
831− buf_file = debugfs_create_file("guc_log", mode,
832− parent, buf, &relay_file_operations);
833− return buf_file;
834−}
835−
836−/*
837− * file_remove() default callback. Removes relay file in debugfs.
838− */
839−static int remove_buf_file_callback(struct dentry *dentry)
840−{
841− debugfs_remove(dentry);
842− return 0;
843−}
844−
845−/* relay channel callbacks */
846−static struct rchan_callbacks relay_callbacks = {
847− .subbuf_start = subbuf_start_callback,
848− .create_buf_file = create_buf_file_callback,
849− .remove_buf_file = remove_buf_file_callback,
850−};
851−
852−static void guc_log_remove_relay_file(struct intel_guc *guc)
853−{
854− relay_close(guc->log.relay_chan);
855−}
856−
857−static int guc_log_create_relay_channel(struct intel_guc *guc)
858−{
859− struct drm_i915_private *dev_priv = guc_to_i915(guc);
860− struct rchan *guc_log_relay_chan;
861− size_t n_subbufs, subbuf_size;
862−
863− /* Keep the size of sub buffers same as shared log buffer */
864− subbuf_size = guc->log.vma->obj->base.size;
865−
866− /* Store up to 8 snapshots, which is large enough to buffer sufficient
867− * boot time logs and provides enough leeway to User, in terms of
868− * latency, for consuming the logs from relay. Also doesn't take
869− * up too much memory.
870− */
871− n_subbufs = 8;
872−
873− guc_log_relay_chan = relay_open(NULL, NULL, subbuf_size,
874− n_subbufs, &relay_callbacks, dev_priv);
875− if (!guc_log_relay_chan) {
876− DRM_ERROR("Couldn't create relay chan for GuC logging\n");
877− return -ENOMEM;
878− }
879−
880− GEM_BUG_ON(guc_log_relay_chan->subbuf_size < subbuf_size);
881− guc->log.relay_chan = guc_log_relay_chan;
882− return 0;
883−}
884−
885−static int guc_log_create_relay_file(struct intel_guc *guc)
886−{
887− struct drm_i915_private *dev_priv = guc_to_i915(guc);
888− struct dentry *log_dir;
889− int ret;
890−
891− /* For now create the log file in /sys/kernel/debug/dri/0 dir */
892− log_dir = dev_priv->drm.primary->debugfs_root;
893−
894− /* If /sys/kernel/debug/dri/0 location do not exist, then debugfs is
895− * not mounted and so can't create the relay file.
896− * The relay API seems to fit well with debugfs only, for availing relay
897− * there are 3 requirements which can be met for debugfs file only in a
898− * straightforward/clean manner :-
899− * i) Need the associated dentry pointer of the file, while opening the
900− * relay channel.
901− * ii) Should be able to use 'relay_file_operations' fops for the file.
902− * iii) Set the 'i_private' field of file's inode to the pointer of
903− * relay channel buffer.
904− */
905− if (!log_dir) {
906− DRM_ERROR("Debugfs dir not available yet for GuC log file\n");
907− return -ENODEV;
908− }
909−
910− ret = relay_late_setup_files(guc->log.relay_chan, "guc_log", log_dir);
911− if (ret) {
912− DRM_ERROR("Couldn't associate relay chan with file %d\n", ret);
913− return ret;
914− }
915−
916− return 0;
917−}
918−
919−static void guc_move_to_next_buf(struct intel_guc *guc)
920−{
921− /* Make sure the updates made in the sub buffer are visible when
922− * Consumer sees the following update to offset inside the sub buffer.
923− */
924− smp_wmb();
925−
926− /* All data has been written, so now move the offset of sub buffer. */
927− relay_reserve(guc->log.relay_chan, guc->log.vma->obj->base.size);
928−
929− /* Switch to the next sub buffer */
930− relay_flush(guc->log.relay_chan);
931−}
932−
933−static void *guc_get_write_buffer(struct intel_guc *guc)
934−{
935− if (!guc->log.relay_chan)
936− return NULL;
937−
938− /* Just get the base address of a new sub buffer and copy data into it
939− * ourselves. NULL will be returned in no-overwrite mode, if all sub
940− * buffers are full. Could have used the relay_write() to indirectly
941− * copy the data, but that would have been bit convoluted, as we need to
942− * write to only certain locations inside a sub buffer which cannot be
943− * done without using relay_reserve() along with relay_write(). So its
944− * better to use relay_reserve() alone.
945− */
946− return relay_reserve(guc->log.relay_chan, 0);
947−}
948−
949−static bool
950−guc_check_log_buf_overflow(struct intel_guc *guc,
951− enum guc_log_buffer_type type, unsigned int full_cnt)
952−{
953− unsigned int prev_full_cnt = guc->log.prev_overflow_count[type];
954− bool overflow = false;
955−
956− if (full_cnt != prev_full_cnt) {
957− overflow = true;
958−
959− guc->log.prev_overflow_count[type] = full_cnt;
960− guc->log.total_overflow_count[type] += full_cnt - prev_full_cnt;
961−
962− if (full_cnt < prev_full_cnt) {
963− /* buffer_full_cnt is a 4 bit counter */
964− guc->log.total_overflow_count[type] += 16;
965− }
966− DRM_ERROR_RATELIMITED("GuC log buffer overflow\n");
967− }
968−
969− return overflow;
970−}
971−
972−static unsigned int guc_get_log_buffer_size(enum guc_log_buffer_type type)
973−{
974− switch (type) {
975− case GUC_ISR_LOG_BUFFER:
976− return (GUC_LOG_ISR_PAGES + 1) * PAGE_SIZE;
977− case GUC_DPC_LOG_BUFFER:
978− return (GUC_LOG_DPC_PAGES + 1) * PAGE_SIZE;
979− case GUC_CRASH_DUMP_LOG_BUFFER:
980− return (GUC_LOG_CRASH_PAGES + 1) * PAGE_SIZE;
981− default:
982− MISSING_CASE(type);
983− }
984−
985− return 0;
986−}
987−
988−static void guc_read_update_log_buffer(struct intel_guc *guc)
989−{
990− unsigned int buffer_size, read_offset, write_offset, bytes_to_copy, full_cnt;
991− struct guc_log_buffer_state *log_buf_state, *log_buf_snapshot_state;
992− struct guc_log_buffer_state log_buf_state_local;
993− enum guc_log_buffer_type type;
994− void *src_data, *dst_data;
995− bool new_overflow;
996−
997− if (WARN_ON(!guc->log.buf_addr))
998− return;
999−
1000− /* Get the pointer to shared GuC log buffer */
1001− log_buf_state = src_data = guc->log.buf_addr;
1002−
1003− /* Get the pointer to local buffer to store the logs */
1004− log_buf_snapshot_state = dst_data = guc_get_write_buffer(guc);
1005−
1006− /* Actual logs are present from the 2nd page */
1007− src_data += PAGE_SIZE;
1008− dst_data += PAGE_SIZE;
1009−
1010− for (type = GUC_ISR_LOG_BUFFER; type < GUC_MAX_LOG_BUFFER; type++) {
1011− /* Make a copy of the state structure, inside GuC log buffer
1012− * (which is uncached mapped), on the stack to avoid reading
1013− * from it multiple times.
1014− */
1015− memcpy(&log_buf_state_local, log_buf_state,
1016− sizeof(struct guc_log_buffer_state));
1017− buffer_size = guc_get_log_buffer_size(type);
1018− read_offset = log_buf_state_local.read_ptr;
1019− write_offset = log_buf_state_local.sampled_write_ptr;
1020− full_cnt = log_buf_state_local.buffer_full_cnt;
1021−
1022− /* Bookkeeping stuff */
1023− guc->log.flush_count[type] += log_buf_state_local.flush_to_file;
1024− new_overflow = guc_check_log_buf_overflow(guc, type, full_cnt);
1025−
1026− /* Update the state of shared log buffer */
1027− log_buf_state->read_ptr = write_offset;
1028− log_buf_state->flush_to_file = 0;
1029− log_buf_state++;
1030−
1031− if (unlikely(!log_buf_snapshot_state))
1032− continue;
1033−
1034− /* First copy the state structure in snapshot buffer */
1035− memcpy(log_buf_snapshot_state, &log_buf_state_local,
1036− sizeof(struct guc_log_buffer_state));
1037−
1038− /* The write pointer could have been updated by GuC firmware,
1039− * after sending the flush interrupt to Host, for consistency
1040− * set write pointer value to same value of sampled_write_ptr
1041− * in the snapshot buffer.
1042− */
1043− log_buf_snapshot_state->write_ptr = write_offset;
1044− log_buf_snapshot_state++;
1045−
1046− /* Now copy the actual logs. */
1047− if (unlikely(new_overflow)) {
1048− /* copy the whole buffer in case of overflow */
1049− read_offset = 0;
1050− write_offset = buffer_size;
1051− } else if (unlikely((read_offset > buffer_size) ||
1052− (write_offset > buffer_size))) {
1053− DRM_ERROR("invalid log buffer state\n");
1054− /* copy whole buffer as offsets are unreliable */
1055− read_offset = 0;
1056− write_offset = buffer_size;
1057− }
1058−
1059− /* Just copy the newly written data */
1060− if (read_offset > write_offset) {
1061− i915_memcpy_from_wc(dst_data, src_data, write_offset);
1062− bytes_to_copy = buffer_size - read_offset;
1063− } else {
1064− bytes_to_copy = write_offset - read_offset;
1065− }
1066− i915_memcpy_from_wc(dst_data + read_offset,
1067− src_data + read_offset, bytes_to_copy);
1068−
1069− src_data += buffer_size;
1070− dst_data += buffer_size;
1071− }
1072−
1073− if (log_buf_snapshot_state)
1074− guc_move_to_next_buf(guc);
1075− else {
1076− /* Used rate limited to avoid deluge of messages, logs might be
1077− * getting consumed by User at a slow rate.
1078− */
1079− DRM_ERROR_RATELIMITED("no sub-buffer to capture logs\n");
1080− guc->log.capture_miss_count++;
1081− }
1082−}
1083−
1084−static void guc_capture_logs_work(struct work_struct *work)
1085−{
1086− struct drm_i915_private *dev_priv =
1087− container_of(work, struct drm_i915_private, guc.log.flush_work);
1088−
1089− i915_guc_capture_logs(dev_priv);
1090−}
1091−
1092−static void guc_log_cleanup(struct intel_guc *guc)
1093−{
1094− struct drm_i915_private *dev_priv = guc_to_i915(guc);
1095−
1096− lockdep_assert_held(&dev_priv->drm.struct_mutex);
1097−
1098− /* First disable the flush interrupt */
1099− gen9_disable_guc_interrupts(dev_priv);
1100775
1101− if (guc->log.flush_wq)
1102− destroy_workqueue(guc->log.flush_wq);
1103−
1104− guc->log.flush_wq = NULL;
1105−
1106− if (guc->log.relay_chan)
1107− guc_log_remove_relay_file(guc);
1108−
1109− guc->log.relay_chan = NULL;
1110−
1111− if (guc->log.buf_addr)
1112− i915_gem_object_unpin_map(guc->log.vma->obj);
1113−
1114− guc->log.buf_addr = NULL;
1115−}
1116−
1117−static int guc_log_create_extras(struct intel_guc *guc)
1118−{
1119− struct drm_i915_private *dev_priv = guc_to_i915(guc);
1120− void *vaddr;
1121− int ret;
1122−
1123− lockdep_assert_held(&dev_priv->drm.struct_mutex);
1124−
1125− /* Nothing to do */
1126− if (i915.guc_log_level < 0)
1127− return 0;
1128−
1129− if (!guc->log.buf_addr) {
1130− /* Create a WC (Uncached for read) vmalloc mapping of log
1131− * buffer pages, so that we can directly get the data
1132− * (up-to-date) from memory.
1133− */
1134− vaddr = i915_gem_object_pin_map(guc->log.vma->obj, I915_MAP_WC);
1135− if (IS_ERR(vaddr)) {
1136− ret = PTR_ERR(vaddr);
1137− DRM_ERROR("Couldn't map log buffer pages %d\n", ret);
1138− return ret;
1139− }
1140−
1141− guc->log.buf_addr = vaddr;
1142− }
1143−
1144− if (!guc->log.relay_chan) {
1145− /* Create a relay channel, so that we have buffers for storing
1146− * the GuC firmware logs, the channel will be linked with a file
1147− * later on when debugfs is registered.
1148− */
1149− ret = guc_log_create_relay_channel(guc);
1150− if (ret)
1151− return ret;
1152− }
1153−
1154− if (!guc->log.flush_wq) {
1155− INIT_WORK(&guc->log.flush_work, guc_capture_logs_work);
1156−
1157− /*
1158− * GuC log buffer flush work item has to do register access to
1159− * send the ack to GuC and this work item, if not synced before
1160− * suspend, can potentially get executed after the GFX device is
1161− * suspended.
1162− * By marking the WQ as freezable, we don't have to bother about
1163− * flushing of this work item from the suspend hooks, the pending
1164− * work item if any will be either executed before the suspend
1165− * or scheduled later on resume. This way the handling of work
1166− * item can be kept same between system suspend & rpm suspend.
1167− */
1168− guc->log.flush_wq = alloc_ordered_workqueue("i915-guc_log",
1169− WQ_HIGHPRI | WQ_FREEZABLE);
1170− if (guc->log.flush_wq == NULL) {
1171− DRM_ERROR("Couldn't allocate the wq for GuC logging\n");
1172− return -ENOMEM;
1173− }
1174− }
1175−
1176− return 0;
1177−}
1178−
1179−static void guc_log_create(struct intel_guc *guc)
1180−{
1181− struct i915_vma *vma;
1182− unsigned long offset;
1183− uint32_t size, flags;
1184−
1185− if (i915.guc_log_level > GUC_LOG_VERBOSITY_MAX)
1186− i915.guc_log_level = GUC_LOG_VERBOSITY_MAX;
1187−
1188− /* The first page is to save log buffer state. Allocate one
1189− * extra page for others in case for overlap */
1190− size = (1 + GUC_LOG_DPC_PAGES + 1 +
1191− GUC_LOG_ISR_PAGES + 1 +
1192− GUC_LOG_CRASH_PAGES + 1) << PAGE_SHIFT;
1193−
1194− vma = guc->log.vma;
1195− if (!vma) {
1196− /* We require SSE 4.1 for fast reads from the GuC log buffer and
1197− * it should be present on the chipsets supporting GuC based
1198− * submisssions.
1199− */
1200− if (WARN_ON(!i915_has_memcpy_from_wc())) {
1201− /* logging will not be enabled */
1202− i915.guc_log_level = -1;
1203− return;
1204− }
1205−
1206− vma = guc_allocate_vma(guc, size);
1207− if (IS_ERR(vma)) {
1208− /* logging will be off */
1209− i915.guc_log_level = -1;
1210− return;
1211− }
1212−
1213− guc->log.vma = vma;
1214−
1215− if (guc_log_create_extras(guc)) {
1216− guc_log_cleanup(guc);
1217− i915_vma_unpin_and_release(&guc->log.vma);
1218− i915.guc_log_level = -1;
1219− return;
1220− }
1221− }
1222−
1223− /* each allocated unit is a page */
1224− flags = GUC_LOG_VALID | GUC_LOG_NOTIFY_ON_HALF_FULL |
1225− (GUC_LOG_DPC_PAGES << GUC_LOG_DPC_SHIFT) |
1226− (GUC_LOG_ISR_PAGES << GUC_LOG_ISR_SHIFT) |
1227− (GUC_LOG_CRASH_PAGES << GUC_LOG_CRASH_SHIFT);
1228−
1229− offset = guc_ggtt_offset(vma) >> PAGE_SHIFT; /* in pages */
1230− guc->log.flags = (offset << GUC_LOG_BUF_ADDR_SHIFT) | flags;
1231−}
1232−
1233−static int guc_log_late_setup(struct intel_guc *guc)
1234−{
1235− struct drm_i915_private *dev_priv = guc_to_i915(guc);
1236− int ret;
1237−
1238− lockdep_assert_held(&dev_priv->drm.struct_mutex);
1239−
1240− if (i915.guc_log_level < 0)
1241− return -EINVAL;
1242−
1243− /* If log_level was set as -1 at boot time, then setup needed to
1244− * handle log buffer flush interrupts would not have been done yet,
1245− * so do that now.
1246− */
1247− ret = guc_log_create_extras(guc);
1248− if (ret)
1249− goto err;
1250−
1251− ret = guc_log_create_relay_file(guc);
1252− if (ret)
1253− goto err;
1254−
1255− return 0;
1256−err:
1257− guc_log_cleanup(guc);
1258− /* logging will remain off */
1259− i915.guc_log_level = -1;
1260− return ret;
1261−}
1262776
1263777 static void guc_policies_init(struct guc_policies *policies)
1264778 {
@@ -1301,7 +815,7 @@ static void guc_addon_create(struct intel_guc *guc) · 36 unmodified lines
1301815
1302816 vma = guc->ads_vma;
1303817 if (!vma) {
1304− vma = guc_allocate_vma(guc, PAGE_ALIGN(size));
818+ vma = intel_guc_allocate_vma(guc, PAGE_ALIGN(size));
1305819 if (IS_ERR(vma))
1306820 return;
1307821
@@ -1376,13 +890,13 @@ int i915_guc_submission_init(struct drm_i915_private *dev_priv) · 68 unmodified lines
1376890 if (guc->ctx_pool_vma)
1377891 return 0; /* already allocated */
1378892
1379− vma = guc_allocate_vma(guc, gemsize);
893+ vma = intel_guc_allocate_vma(guc, gemsize);
1380894 if (IS_ERR(vma))
1381895 return PTR_ERR(vma);
1382896
1383897 guc->ctx_pool_vma = vma;
1384898 ida_init(&guc->ctx_ids);
1385− guc_log_create(guc);
899+ intel_guc_log_create(guc);
1386900 guc_addon_create(guc);
1387901
1388902 guc->execbuf_client = guc_client_alloc(dev_priv,
@@ -1484,7 +998,7 @@ int intel_guc_suspend(struct drm_i915_private *dev_priv) · 95 unmodified lines
1484998 struct i915_gem_context *ctx;
1485999 u32 data[3];
14861000
1487− if (guc->guc_fw.guc_fw_load_status != GUC_FIRMWARE_SUCCESS)
1001+ if (guc->fw.load_status != INTEL_UC_FIRMWARE_SUCCESS)
14881002 return 0;
14891003
14901004 gen9_disable_guc_interrupts(dev_priv);
@@ -1511,7 +1025,7 @@ int intel_guc_resume(struct drm_i915_private *dev_priv) · 20 unmodified lines
15111025 struct i915_gem_context *ctx;
15121026 u32 data[3];
15131027
1514− if (guc->guc_fw.guc_fw_load_status != GUC_FIRMWARE_SUCCESS)
1028+ if (guc->fw.load_status != INTEL_UC_FIRMWARE_SUCCESS)
15151029 return 0;
15161030
15171031 if (i915.guc_log_level >= 0)
@@ -1527,103 +1041,4 @@ int intel_guc_resume(struct drm_i915_private *dev_priv) · 9 unmodified lines
15271041 return intel_guc_send(guc, data, ARRAY_SIZE(data));
15281042 }
15291043
1530−void i915_guc_capture_logs(struct drm_i915_private *dev_priv)
1531−{
1532− guc_read_update_log_buffer(&dev_priv->guc);
1533−
1534− /* Generally device is expected to be active only at this
1535− * time, so get/put should be really quick.
1536− */
1537− intel_runtime_pm_get(dev_priv);
1538− intel_guc_log_flush_complete(&dev_priv->guc);
1539− intel_runtime_pm_put(dev_priv);
1540−}
1541−
1542−void i915_guc_flush_logs(struct drm_i915_private *dev_priv)
1543−{
1544− if (!i915.enable_guc_submission || (i915.guc_log_level < 0))
1545− return;
1546−
1547− /* First disable the interrupts, will be renabled afterwards */
1548− gen9_disable_guc_interrupts(dev_priv);
1549−
1550− /* Before initiating the forceful flush, wait for any pending/ongoing
1551− * flush to complete otherwise forceful flush may not actually happen.
1552− */
1553− flush_work(&dev_priv->guc.log.flush_work);
1554−
1555− /* Ask GuC to update the log buffer state */
1556− intel_guc_log_flush(&dev_priv->guc);
1557−
1558− /* GuC would have updated log buffer by now, so capture it */
1559− i915_guc_capture_logs(dev_priv);
1560−}
1561−
1562−void i915_guc_unregister(struct drm_i915_private *dev_priv)
1563−{
1564− if (!i915.enable_guc_submission)
1565− return;
15661044
1567− mutex_lock(&dev_priv->drm.struct_mutex);
1568− guc_log_cleanup(&dev_priv->guc);
1569− mutex_unlock(&dev_priv->drm.struct_mutex);
1570−}
1571−
1572−void i915_guc_register(struct drm_i915_private *dev_priv)
1573−{
1574− if (!i915.enable_guc_submission)
1575− return;
1576−
1577− mutex_lock(&dev_priv->drm.struct_mutex);
1578− guc_log_late_setup(&dev_priv->guc);
1579− mutex_unlock(&dev_priv->drm.struct_mutex);
1580−}
1581−
1582−int i915_guc_log_control(struct drm_i915_private *dev_priv, u64 control_val)
1583−{
1584− union guc_log_control log_param;
1585− int ret;
1586−
1587− log_param.value = control_val;
1588−
1589− if (log_param.verbosity < GUC_LOG_VERBOSITY_MIN ||
1590− log_param.verbosity > GUC_LOG_VERBOSITY_MAX)
1591− return -EINVAL;
1592−
1593− /* This combination doesn't make sense & won't have any effect */
1594− if (!log_param.logging_enabled && (i915.guc_log_level < 0))
1595− return 0;
1596−
1597− ret = intel_guc_log_control(&dev_priv->guc, log_param.value);
1598− if (ret < 0) {
1599− DRM_DEBUG_DRIVER("guc_logging_control action failed %d\n", ret);
1600− return ret;
1601− }
1602−
1603− i915.guc_log_level = log_param.verbosity;
1604−
1605− /* If log_level was set as -1 at boot time, then the relay channel file
1606− * wouldn't have been created by now and interrupts also would not have
1607− * been enabled.
1608− */
1609− if (!dev_priv->guc.log.relay_chan) {
1610− ret = guc_log_late_setup(&dev_priv->guc);
1611− if (!ret)
1612− gen9_enable_guc_interrupts(dev_priv);
1613− } else if (!log_param.logging_enabled) {
1614− /* Once logging is disabled, GuC won't generate logs & send an
1615− * interrupt. But there could be some data in the log buffer
1616− * which is yet to be captured. So request GuC to update the log
1617− * buffer state and then collect the left over logs.
1618− */
1619− i915_guc_flush_logs(dev_priv);
1620−
1621− /* As logging is disabled, update log level to reflect that */
1622− i915.guc_log_level = -1;
1623− } else {
1624− /* In case interrupts were disabled, enable them now */
1625− gen9_enable_guc_interrupts(dev_priv);
1626− }
1627−
1628− return ret;
1629−}
drivers/gpu/drm/i915/i915_irq.c+60−26
@@ -1170,6 +1170,9 @@ static void gen6_pm_rps_work(struct work_struct *work) · 1169 unmodified lines
11701170 adj *= 2;
11711171 else /* CHV needs even encode values */
11721172 adj = IS_CHERRYVIEW(dev_priv) ? 2 : 1;
1173+
1174+ if (new_delay >= dev_priv->rps.max_freq_softlimit)
1175+ adj = 0;
11731176 /*
11741177 * For better performance, jump directly
11751178 * to RPe if we're below it.
@@ -1191,6 +1194,9 @@ static void gen6_pm_rps_work(struct work_struct *work) · 15 unmodified lines
11911194 adj *= 2;
11921195 else /* CHV needs even encode values */
11931196 adj = IS_CHERRYVIEW(dev_priv) ? -2 : -1;
1197+
1198+ if (new_delay <= dev_priv->rps.min_freq_softlimit)
1199+ adj = 0;
11941200 } else { /* unknown event */
11951201 adj = 0;
11961202 }
@@ -1553,41 +1559,68 @@ static void display_pipe_crc_irq_handler(struct drm_i915_private *dev_priv, · 356 unmodified lines
15531559 {
15541560 struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
15551561 struct intel_pipe_crc_entry *entry;
1562+ struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
1563+ struct drm_driver *driver = dev_priv->drm.driver;
1564+ uint32_t crcs[5];
15561565 int head, tail;
15571566
15581567 spin_lock(&pipe_crc->lock);
1568+ if (pipe_crc->source) {
1569+ if (!pipe_crc->entries) {
1570+ spin_unlock(&pipe_crc->lock);
1571+ DRM_DEBUG_KMS("spurious interrupt\n");
1572+ return;
1573+ }
15591574
1560− if (!pipe_crc->entries) {
1561− spin_unlock(&pipe_crc->lock);
1562− DRM_DEBUG_KMS("spurious interrupt\n");
1563− return;
1564− }
1565−
1566− head = pipe_crc->head;
1567− tail = pipe_crc->tail;
1575+ head = pipe_crc->head;
1576+ tail = pipe_crc->tail;
15681577
1569− if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) {
1570− spin_unlock(&pipe_crc->lock);
1571− DRM_ERROR("CRC buffer overflowing\n");
1572− return;
1573− }
1578+ if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) {
1579+ spin_unlock(&pipe_crc->lock);
1580+ DRM_ERROR("CRC buffer overflowing\n");
1581+ return;
1582+ }
15741583
1575− entry = &pipe_crc->entries[head];
1584+ entry = &pipe_crc->entries[head];
15761585
1577− entry->frame = dev_priv->drm.driver->get_vblank_counter(&dev_priv->drm,
1578− pipe);
1579− entry->crc[0] = crc0;
1580− entry->crc[1] = crc1;
1581− entry->crc[2] = crc2;
1582− entry->crc[3] = crc3;
1583− entry->crc[4] = crc4;
1586+ entry->frame = driver->get_vblank_counter(&dev_priv->drm, pipe);
1587+ entry->crc[0] = crc0;
1588+ entry->crc[1] = crc1;
1589+ entry->crc[2] = crc2;
1590+ entry->crc[3] = crc3;
1591+ entry->crc[4] = crc4;
15841592
1585− head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
1586− pipe_crc->head = head;
1593+ head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
1594+ pipe_crc->head = head;
15871595
1588− spin_unlock(&pipe_crc->lock);
1596+ spin_unlock(&pipe_crc->lock);
15891597
1590− wake_up_interruptible(&pipe_crc->wq);
1598+ wake_up_interruptible(&pipe_crc->wq);
1599+ } else {
1600+ /*
1601+ * For some not yet identified reason, the first CRC is
1602+ * bonkers. So let's just wait for the next vblank and read
1603+ * out the buggy result.
1604+ *
1605+ * On CHV sometimes the second CRC is bonkers as well, so
1606+ * don't trust that one either.
1607+ */
1608+ if (pipe_crc->skipped == 0 ||
1609+ (IS_CHERRYVIEW(dev_priv) && pipe_crc->skipped == 1)) {
1610+ pipe_crc->skipped++;
1611+ spin_unlock(&pipe_crc->lock);
1612+ return;
1613+ }
1614+ spin_unlock(&pipe_crc->lock);
1615+ crcs[0] = crc0;
1616+ crcs[1] = crc1;
1617+ crcs[2] = crc2;
1618+ crcs[3] = crc3;
1619+ crcs[4] = crc4;
1620+ drm_crtc_add_crc_entry(&crtc->base, true,
1621+ drm_accurate_vblank_count(&crtc->base),
1622+ crcs);
1623+ }
15911624 }
15921625 #else
15931626 static inline void
@@ -2703,12 +2736,13 @@ static void i915_clear_error_registers(struct drm_i915_private *dev_priv) · 1109 unmodified lines
27032736 * i915_handle_error - handle a gpu error
27042737 * @dev_priv: i915 device private
27052738 * @engine_mask: mask representing engines that are hung
2739+ * @fmt: Error message format string
2740+ *
27062741 * Do some basic checking of register state at error time and
27072742 * dump it to the syslog. Also call i915_capture_error_state() to make
27082743 * sure we get a record and make it available in debugfs. Fire a uevent
27092744 * so userspace knows something bad happened (should trigger collection
27102745 * of a ring dump etc.).
2711− * @fmt: Error message format string
27122746 */
27132747 void i915_handle_error(struct drm_i915_private *dev_priv,
27142748 u32 engine_mask,
drivers/gpu/drm/i915/i915_reg.h+17−3
@@ -3597,9 +3597,12 @@ enum { · 3596 unmodified lines
35973597 #define EDP_PSR_PERF_CNT_MASK 0xffffff
35983598
35993599 #define EDP_PSR_DEBUG_CTL _MMIO(dev_priv->psr_mmio_base + 0x60)
3600−#define EDP_PSR_DEBUG_MASK_LPSP (1<<27)
3601−#define EDP_PSR_DEBUG_MASK_MEMUP (1<<26)
3602−#define EDP_PSR_DEBUG_MASK_HPD (1<<25)
3600+#define EDP_PSR_DEBUG_MASK_MAX_SLEEP (1<<28)
3601+#define EDP_PSR_DEBUG_MASK_LPSP (1<<27)
3602+#define EDP_PSR_DEBUG_MASK_MEMUP (1<<26)
3603+#define EDP_PSR_DEBUG_MASK_HPD (1<<25)
3604+#define EDP_PSR_DEBUG_MASK_DISP_REG_WRITE (1<<16)
3605+#define EDP_PSR_DEBUG_EXIT_ON_PIXEL_UNDERRUN (1<<15)
36033606
36043607 #define EDP_PSR2_CTL _MMIO(0x6f900)
36053608 #define EDP_PSR2_ENABLE (1<<31)
@@ -3614,6 +3617,11 @@ enum { · 8 unmodified lines
36143617 #define EDP_PSR2_FRAME_BEFORE_SU_SHIFT 4
36153618 #define EDP_PSR2_FRAME_BEFORE_SU_MASK (0xf<<4)
36163619 #define EDP_PSR2_IDLE_MASK 0xf
3620+#define EDP_FRAMES_BEFORE_SU_ENTRY (1<<4)
3621+
3622+#define EDP_PSR2_STATUS_CTL _MMIO(0x6f940)
3623+#define EDP_PSR2_STATUS_STATE_MASK (0xf<<28)
3624+#define EDP_PSR2_STATUS_STATE_SHIFT 28
36173625
36183626 /* VGA port control */
36193627 #define ADPA _MMIO(0x61100)
@@ -6446,6 +6454,12 @@ enum { · 2826 unmodified lines
64466454 #define BDW_DPRS_MASK_VBLANK_SRD (1 << 0)
64476455 #define CHICKEN_PIPESL_1(pipe) _MMIO_PIPE(pipe, _CHICKEN_PIPESL_1_A, _CHICKEN_PIPESL_1_B)
64486456
6457+#define CHICKEN_TRANS_A 0x420c0
6458+#define CHICKEN_TRANS_B 0x420c4
6459+#define CHICKEN_TRANS(trans) _MMIO_TRANS(trans, CHICKEN_TRANS_A, CHICKEN_TRANS_B)
6460+#define PSR2_VSC_ENABLE_PROG_HEADER (1<<12)
6461+#define PSR2_ADD_VERTICAL_LINE_COUNT (1<<15)
6462+
64496463 #define DISP_ARB_CTL _MMIO(0x45000)
64506464 #define DISP_FBC_MEMORY_WAKE (1<<31)
64516465 #define DISP_TILE_SURFACE_SWIZZLING (1<<13)
drivers/gpu/drm/i915/i915_sw_fence.c+1−0
@@ -63,6 +63,7 @@ static inline void debug_fence_destroy(struct i915_sw_fence *fence) · 62 unmodified lines
6363 static inline void debug_fence_free(struct i915_sw_fence *fence)
6464 {
6565 debug_object_free(fence, &i915_sw_fence_debug_descr);
66+ smp_wmb(); /* flush the change in state before reallocation */
6667 }
6768
6869 static inline void debug_fence_assert(struct i915_sw_fence *fence)
drivers/gpu/drm/i915/i915_sysfs.c+1−1
@@ -58,7 +58,7 @@ static u32 calc_residency(struct drm_i915_private *dev_priv, · 57 unmodified lines
5858
5959 if (I915_READ(VLV_COUNTER_CONTROL) & VLV_COUNT_RANGE_HIGH)
6060 units <<= 8;
61− } else if (IS_BROXTON(dev_priv)) {
61+ } else if (IS_GEN9_LP(dev_priv)) {
6262 units = 1;
6363 div = 1200; /* 833.33ns */
6464 }
drivers/gpu/drm/i915/i915_trace.h+8−8
@@ -450,9 +450,9 @@ TRACE_EVENT(i915_gem_evict_vm, · 449 unmodified lines
450450 TP_printk("dev=%d, vm=%p", __entry->dev, __entry->vm)
451451 );
452452
453−TRACE_EVENT(i915_gem_evict_vma,
454− TP_PROTO(struct i915_vma *vma, unsigned int flags),
455− TP_ARGS(vma, flags),
453+TRACE_EVENT(i915_gem_evict_node,
454+ TP_PROTO(struct i915_address_space *vm, struct drm_mm_node *node, unsigned int flags),
455+ TP_ARGS(vm, node, flags),
456456
457457 TP_STRUCT__entry(
458458 __field(u32, dev)
@@ -464,11 +464,11 @@ TRACE_EVENT(i915_gem_evict_vma, · 5 unmodified lines
464464 ),
465465
466466 TP_fast_assign(
467− __entry->dev = vma->vm->i915->drm.primary->index;
468− __entry->vm = vma->vm;
469− __entry->start = vma->node.start;
470− __entry->size = vma->node.size;
471− __entry->color = vma->node.color;
467+ __entry->dev = vm->i915->drm.primary->index;
468+ __entry->vm = vm;
469+ __entry->start = node->start;
470+ __entry->size = node->size;
471+ __entry->color = node->color;
472472 __entry->flags = flags;
473473 ),
474474
drivers/gpu/drm/i915/i915_vgpu.c+12−21
@@ -116,22 +116,20 @@ void intel_vgt_deballoon(struct drm_i915_private *dev_priv) · 115 unmodified lines
116116 memset(&bl_info, 0, sizeof(bl_info));
117117 }
118118
119−static int vgt_balloon_space(struct drm_mm *mm,
119+static int vgt_balloon_space(struct i915_ggtt *ggtt,
120120 struct drm_mm_node *node,
121121 unsigned long start, unsigned long end)
122122 {
123123 unsigned long size = end - start;
124124
125− if (start == end)
125+ if (start >= end)
126126 return -EINVAL;
127127
128128 DRM_INFO("balloon space: range [ 0x%lx - 0x%lx ] %lu KiB.\n",
129129 start, end, size / 1024);
130−
131− node->start = start;
132− node->size = size;
133−
134− return drm_mm_reserve_node(mm, node);
130+ return i915_gem_gtt_reserve(&ggtt->base, node,
131+ size, start, I915_COLOR_UNEVICTABLE,
132+ 0);
135133 }
136134
137135 /**
@@ -214,10 +212,8 @@ int intel_vgt_balloon(struct drm_i915_private *dev_priv) · 76 unmodified lines
214212
215213 /* Unmappable graphic memory ballooning */
216214 if (unmappable_base > ggtt->mappable_end) {
217− ret = vgt_balloon_space(&ggtt->base.mm,
218− &bl_info.space[2],
219− ggtt->mappable_end,
220− unmappable_base);
215+ ret = vgt_balloon_space(ggtt, &bl_info.space[2],
216+ ggtt->mappable_end, unmappable_base);
221217
222218 if (ret)
223219 goto err;
@@ -228,18 +224,15 @@ int intel_vgt_balloon(struct drm_i915_private *dev_priv) · 4 unmodified lines
228224 * because it is reserved to the guard page.
229225 */
230226 if (unmappable_end < ggtt_end - PAGE_SIZE) {
231− ret = vgt_balloon_space(&ggtt->base.mm,
232− &bl_info.space[3],
233− unmappable_end,
234− ggtt_end - PAGE_SIZE);
227+ ret = vgt_balloon_space(ggtt, &bl_info.space[3],
228+ unmappable_end, ggtt_end - PAGE_SIZE);
235229 if (ret)
236230 goto err;
237231 }
238232
239233 /* Mappable graphic memory ballooning */
240234 if (mappable_base > ggtt->base.start) {
241− ret = vgt_balloon_space(&ggtt->base.mm,
242− &bl_info.space[0],
235+ ret = vgt_balloon_space(ggtt, &bl_info.space[0],
243236 ggtt->base.start, mappable_base);
244237
245238 if (ret)
@@ -247,10 +240,8 @@ int intel_vgt_balloon(struct drm_i915_private *dev_priv) · 1 unmodified line
247240 }
248241
249242 if (mappable_end < ggtt->mappable_end) {
250− ret = vgt_balloon_space(&ggtt->base.mm,
251− &bl_info.space[1],
252− mappable_end,
253− ggtt->mappable_end);
243+ ret = vgt_balloon_space(ggtt, &bl_info.space[1],
244+ mappable_end, ggtt->mappable_end);
254245
255246 if (ret)
256247 goto err;
drivers/gpu/drm/i915/i915_vma.c+129−92
@@ -45,6 +45,7 @@ i915_vma_retire(struct i915_gem_active *active, · 44 unmodified lines
4545 if (i915_vma_is_active(vma))
4646 return;
4747
48+ GEM_BUG_ON(!drm_mm_node_allocated(&vma->node));
4849 list_move_tail(&vma->vm_link, &vma->vm->inactive_list);
4950 if (unlikely(i915_vma_is_closed(vma) && !i915_vma_is_pinned(vma)))
5051 WARN_ON(i915_vma_unbind(vma));
@@ -69,17 +70,15 @@ i915_vma_retire(struct i915_gem_active *active, · 18 unmodified lines
6970 }
7071
7172 static struct i915_vma *
72−__i915_vma_create(struct drm_i915_gem_object *obj,
73− struct i915_address_space *vm,
74− const struct i915_ggtt_view *view)
73+vma_create(struct drm_i915_gem_object *obj,
74+ struct i915_address_space *vm,
75+ const struct i915_ggtt_view *view)
7576 {
7677 struct i915_vma *vma;
7778 struct rb_node *rb, **p;
7879 int i;
7980
80− GEM_BUG_ON(vm->closed);
81−
82− vma = kmem_cache_zalloc(to_i915(obj->base.dev)->vmas, GFP_KERNEL);
81+ vma = kmem_cache_zalloc(vm->i915->vmas, GFP_KERNEL);
8382 if (vma == NULL)
8483 return ERR_PTR(-ENOMEM);
8584
@@ -87,29 +86,50 @@ __i915_vma_create(struct drm_i915_gem_object *obj, · 1 unmodified line
8786 for (i = 0; i < ARRAY_SIZE(vma->last_read); i++)
8887 init_request_active(&vma->last_read[i], i915_vma_retire);
8988 init_request_active(&vma->last_fence, NULL);
90− list_add(&vma->vm_link, &vm->unbound_list);
9189 vma->vm = vm;
9290 vma->obj = obj;
9391 vma->size = obj->base.size;
92+ vma->display_alignment = I915_GTT_MIN_ALIGNMENT;
9493
9594 if (view) {
9695 vma->ggtt_view = *view;
9796 if (view->type == I915_GGTT_VIEW_PARTIAL) {
9897 GEM_BUG_ON(range_overflows_t(u64,
99− view->params.partial.offset,
100− view->params.partial.size,
98+ view->partial.offset,
99+ view->partial.size,
101100 obj->base.size >> PAGE_SHIFT));
102− vma->size = view->params.partial.size;
101+ vma->size = view->partial.size;
103102 vma->size <<= PAGE_SHIFT;
104103 GEM_BUG_ON(vma->size >= obj->base.size);
105104 } else if (view->type == I915_GGTT_VIEW_ROTATED) {
106− vma->size =
107− intel_rotation_info_size(&view->params.rotated);
105+ vma->size = intel_rotation_info_size(&view->rotated);
108106 vma->size <<= PAGE_SHIFT;
109107 }
110108 }
111109
110+ if (unlikely(vma->size > vm->total))
111+ goto err_vma;
112+
113+ GEM_BUG_ON(!IS_ALIGNED(vma->size, I915_GTT_PAGE_SIZE));
114+
112115 if (i915_is_ggtt(vm)) {
116+ if (unlikely(overflows_type(vma->size, u32)))
117+ goto err_vma;
118+
119+ vma->fence_size = i915_gem_fence_size(vm->i915, vma->size,
120+ i915_gem_object_get_tiling(obj),
121+ i915_gem_object_get_stride(obj));
122+ if (unlikely(vma->fence_size < vma->size || /* overflow */
123+ vma->fence_size > vm->total))
124+ goto err_vma;
125+
126+ GEM_BUG_ON(!IS_ALIGNED(vma->fence_size, I915_GTT_MIN_ALIGNMENT));
127+
128+ vma->fence_alignment = i915_gem_fence_alignment(vm->i915, vma->size,
129+ i915_gem_object_get_tiling(obj),
130+ i915_gem_object_get_stride(obj));
131+ GEM_BUG_ON(!is_power_of_2(vma->fence_alignment));
132+
113133 vma->flags |= I915_VMA_GGTT;
114134 list_add(&vma->obj_link, &obj->vma_list);
115135 } else {
@@ -131,20 +151,74 @@ __i915_vma_create(struct drm_i915_gem_object *obj, · 15 unmodified lines
131151 }
132152 rb_link_node(&vma->obj_node, rb, p);
133153 rb_insert_color(&vma->obj_node, &obj->vma_tree);
154+ list_add(&vma->vm_link, &vm->unbound_list);
134155
135156 return vma;
157+
158+err_vma:
159+ kmem_cache_free(vm->i915->vmas, vma);
160+ return ERR_PTR(-E2BIG);
136161 }
137162
163+static struct i915_vma *
164+vma_lookup(struct drm_i915_gem_object *obj,
165+ struct i915_address_space *vm,
166+ const struct i915_ggtt_view *view)
167+{
168+ struct rb_node *rb;
169+
170+ rb = obj->vma_tree.rb_node;
171+ while (rb) {
172+ struct i915_vma *vma = rb_entry(rb, struct i915_vma, obj_node);
173+ long cmp;
174+
175+ cmp = i915_vma_compare(vma, vm, view);
176+ if (cmp == 0)
177+ return vma;
178+
179+ if (cmp < 0)
180+ rb = rb->rb_right;
181+ else
182+ rb = rb->rb_left;
183+ }
184+
185+ return NULL;
186+}
187+
188+/**
189+ * i915_vma_instance - return the singleton instance of the VMA
190+ * @obj: parent &struct drm_i915_gem_object to be mapped
191+ * @vm: address space in which the mapping is located
192+ * @view: additional mapping requirements
193+ *
194+ * i915_vma_instance() looks up an existing VMA of the @obj in the @vm with
195+ * the same @view characteristics. If a match is not found, one is created.
196+ * Once created, the VMA is kept until either the object is freed, or the
197+ * address space is closed.
198+ *
199+ * Must be called with struct_mutex held.
200+ *
201+ * Returns the vma, or an error pointer.
202+ */
138203 struct i915_vma *
139−i915_vma_create(struct drm_i915_gem_object *obj,
140− struct i915_address_space *vm,
141− const struct i915_ggtt_view *view)
204+i915_vma_instance(struct drm_i915_gem_object *obj,
205+ struct i915_address_space *vm,
206+ const struct i915_ggtt_view *view)
142207 {
208+ struct i915_vma *vma;
209+
143210 lockdep_assert_held(&obj->base.dev->struct_mutex);
144211 GEM_BUG_ON(view && !i915_is_ggtt(vm));
145− GEM_BUG_ON(i915_gem_obj_to_vma(obj, vm, view));
212+ GEM_BUG_ON(vm->closed);
213+
214+ vma = vma_lookup(obj, vm, view);
215+ if (!vma)
216+ vma = vma_create(obj, vm, view);
146217
147− return __i915_vma_create(obj, vm, view);
218+ GEM_BUG_ON(!IS_ERR(vma) && i915_vma_is_closed(vma));
219+ GEM_BUG_ON(!IS_ERR(vma) && i915_vma_compare(vma, vm, view));
220+ GEM_BUG_ON(!IS_ERR(vma) && vma_lookup(obj, vm, view) != vma);
221+ return vma;
148222 }
149223
150224 /**
@@ -195,6 +269,7 @@ int i915_vma_bind(struct i915_vma *vma, enum i915_cache_level cache_level, · 44 unmodified lines
195269 return ret;
196270 }
197271
272+ trace_i915_vma_bind(vma, bind_flags);
198273 ret = vma->vm->bind_vma(vma, cache_level, bind_flags);
199274 if (ret)
200275 return ret;
@@ -258,7 +333,8 @@ i915_vma_misplaced(struct i915_vma *vma, u64 size, u64 alignment, u64 flags) · 57 unmodified lines
258333 if (vma->node.size < size)
259334 return true;
260335
261− if (alignment && vma->node.start & (alignment - 1))
336+ GEM_BUG_ON(alignment && !is_power_of_2(alignment));
337+ if (alignment && !IS_ALIGNED(vma->node.start, alignment))
262338 return true;
263339
264340 if (flags & PIN_MAPPABLE && !i915_vma_is_map_and_fenceable(vma))
@@ -277,31 +353,24 @@ i915_vma_misplaced(struct i915_vma *vma, u64 size, u64 alignment, u64 flags) · 12 unmodified lines
277353
278354 void __i915_vma_set_map_and_fenceable(struct i915_vma *vma)
279355 {
280− struct drm_i915_gem_object *obj = vma->obj;
281− struct drm_i915_private *dev_priv = to_i915(obj->base.dev);
282356 bool mappable, fenceable;
283− u32 fence_size, fence_alignment;
284−
285− fence_size = i915_gem_get_ggtt_size(dev_priv,
286− vma->size,
287− i915_gem_object_get_tiling(obj));
288− fence_alignment = i915_gem_get_ggtt_alignment(dev_priv,
289− vma->size,
290− i915_gem_object_get_tiling(obj),
291− true);
292−
293− fenceable = (vma->node.size == fence_size &&
294− (vma->node.start & (fence_alignment - 1)) == 0);
295357
296− mappable = (vma->node.start + fence_size <=
297− dev_priv->ggtt.mappable_end);
358+ GEM_BUG_ON(!i915_vma_is_ggtt(vma));
359+ GEM_BUG_ON(!vma->fence_size);
298360
299361 /*
300362 * Explicitly disable for rotated VMA since the display does not
301363 * need the fence and the VMA is not accessible to other users.
302364 */
303− if (mappable && fenceable &&
304− vma->ggtt_view.type != I915_GGTT_VIEW_ROTATED)
365+ if (vma->ggtt_view.type == I915_GGTT_VIEW_ROTATED)
366+ return;
367+
368+ fenceable = (vma->node.size >= vma->fence_size &&
369+ IS_ALIGNED(vma->node.start, vma->fence_alignment));
370+
371+ mappable = vma->node.start + vma->fence_size <= i915_vm_to_ggtt(vma->vm)->mappable_end;
372+
373+ if (mappable && fenceable)
305374 vma->flags |= I915_VMA_CAN_FENCE;
306375 else
307376 vma->flags &= ~I915_VMA_CAN_FENCE;
@@ -368,22 +437,26 @@ i915_vma_insert(struct i915_vma *vma, u64 size, u64 alignment, u64 flags) · 60 unmodified lines
368437 GEM_BUG_ON(drm_mm_node_allocated(&vma->node));
369438
370439 size = max(size, vma->size);
371− if (flags & PIN_MAPPABLE)
372− size = i915_gem_get_ggtt_size(dev_priv, size,
373− i915_gem_object_get_tiling(obj));
440+ alignment = max(alignment, vma->display_alignment);
441+ if (flags & PIN_MAPPABLE) {
442+ size = max_t(typeof(size), size, vma->fence_size);
443+ alignment = max_t(typeof(alignment),
444+ alignment, vma->fence_alignment);
445+ }
374446
375− alignment = max(max(alignment, vma->display_alignment),
376− i915_gem_get_ggtt_alignment(dev_priv, size,
377− i915_gem_object_get_tiling(obj),
378− flags & PIN_MAPPABLE));
447+ GEM_BUG_ON(!IS_ALIGNED(size, I915_GTT_PAGE_SIZE));
448+ GEM_BUG_ON(!IS_ALIGNED(alignment, I915_GTT_MIN_ALIGNMENT));
449+ GEM_BUG_ON(!is_power_of_2(alignment));
379450
380451 start = flags & PIN_OFFSET_BIAS ? flags & PIN_OFFSET_MASK : 0;
452+ GEM_BUG_ON(!IS_ALIGNED(start, I915_GTT_PAGE_SIZE));
381453
382454 end = vma->vm->total;
383455 if (flags & PIN_MAPPABLE)
384456 end = min_t(u64, end, dev_priv->ggtt.mappable_end);
385457 if (flags & PIN_ZONE_4G)
386− end = min_t(u64, end, (1ULL << 32) - PAGE_SIZE);
458+ end = min_t(u64, end, (1ULL << 32) - I915_GTT_PAGE_SIZE);
459+ GEM_BUG_ON(!IS_ALIGNED(end, I915_GTT_PAGE_SIZE));
387460
388461 /* If binding the object/GGTT view requires more space than the entire
389462 * aperture has, reject it early before evicting everything in a vain
@@ -403,65 +476,28 @@ i915_vma_insert(struct i915_vma *vma, u64 size, u64 alignment, u64 flags) · 13 unmodified lines
403476
404477 if (flags & PIN_OFFSET_FIXED) {
405478 u64 offset = flags & PIN_OFFSET_MASK;
406− if (offset & (alignment - 1) ||
479+ if (!IS_ALIGNED(offset, alignment) ||
407480 range_overflows(offset, size, end)) {
408481 ret = -EINVAL;
409482 goto err_unpin;
410483 }
411484
412− vma->node.start = offset;
413− vma->node.size = size;
414− vma->node.color = obj->cache_level;
415− ret = drm_mm_reserve_node(&vma->vm->mm, &vma->node);
416− if (ret) {
417− ret = i915_gem_evict_for_vma(vma, flags);
418− if (ret == 0)
419− ret = drm_mm_reserve_node(&vma->vm->mm, &vma->node);
420− if (ret)
421− goto err_unpin;
422− }
485+ ret = i915_gem_gtt_reserve(vma->vm, &vma->node,
486+ size, offset, obj->cache_level,
487+ flags);
488+ if (ret)
489+ goto err_unpin;
423490 } else {
424− u32 search_flag, alloc_flag;
425−
426− if (flags & PIN_HIGH) {
427− search_flag = DRM_MM_SEARCH_BELOW;
428− alloc_flag = DRM_MM_CREATE_TOP;
429− } else {
430− search_flag = DRM_MM_SEARCH_DEFAULT;
431− alloc_flag = DRM_MM_CREATE_DEFAULT;
432− }
433−
434− /* We only allocate in PAGE_SIZE/GTT_PAGE_SIZE (4096) chunks,
435− * so we know that we always have a minimum alignment of 4096.
436− * The drm_mm range manager is optimised to return results
437− * with zero alignment, so where possible use the optimal
438− * path.
439− */
440− if (alignment <= 4096)
441− alignment = 0;
442−
443−search_free:
444− ret = drm_mm_insert_node_in_range_generic(&vma->vm->mm,
445− &vma->node,
446− size, alignment,
447− obj->cache_level,
448− start, end,
449− search_flag,
450− alloc_flag);
451− if (ret) {
452− ret = i915_gem_evict_something(vma->vm, size, alignment,
453− obj->cache_level,
454− start, end,
455− flags);
456− if (ret == 0)
457− goto search_free;
458−
491+ ret = i915_gem_gtt_insert(vma->vm, &vma->node,
492+ size, alignment, obj->cache_level,
493+ start, end, flags);
494+ if (ret)
459495 goto err_unpin;
460− }
461496
462497 GEM_BUG_ON(vma->node.start < start);
463498 GEM_BUG_ON(vma->node.start + vma->node.size > end);
464499 }
500+ GEM_BUG_ON(!drm_mm_node_allocated(&vma->node));
465501 GEM_BUG_ON(!i915_gem_valid_gtt_space(vma, obj->cache_level));
466502
467503 list_move_tail(&obj->global_link, &dev_priv->mm.bound_list);
@@ -504,6 +540,7 @@ int __i915_vma_do_pin(struct i915_vma *vma, · 36 unmodified lines
504540 if ((bound ^ vma->flags) & I915_VMA_GLOBAL_BIND)
505541 __i915_vma_set_map_and_fenceable(vma);
506542
543+ GEM_BUG_ON(!drm_mm_node_allocated(&vma->node));
507544 GEM_BUG_ON(i915_vma_misplaced(vma, size, alignment, flags));
508545 return 0;
509546
drivers/gpu/drm/i915/i915_vma.h+31−10
@@ -55,6 +55,9 @@ struct i915_vma { · 54 unmodified lines
5555 u64 size;
5656 u64 display_alignment;
5757
58+ u32 fence_size;
59+ u32 fence_alignment;
60+
5861 unsigned int flags;
5962 /**
6063 * How many users have pinned this object in GTT space. The following
@@ -109,9 +112,9 @@ struct i915_vma { · 48 unmodified lines
109112 };
110113
111114 struct i915_vma *
112−i915_vma_create(struct drm_i915_gem_object *obj,
113− struct i915_address_space *vm,
114− const struct i915_ggtt_view *view);
115+i915_vma_instance(struct drm_i915_gem_object *obj,
116+ struct i915_address_space *vm,
117+ const struct i915_ggtt_view *view);
115118
116119 void i915_vma_unpin_and_release(struct i915_vma **p_vma);
117120
@@ -196,15 +199,30 @@ i915_vma_compare(struct i915_vma *vma, · 78 unmodified lines
196199 if (cmp)
197200 return cmp;
198201
202+ BUILD_BUG_ON(I915_GGTT_VIEW_NORMAL != 0);
203+ cmp = vma->ggtt_view.type;
199204 if (!view)
200− return vma->ggtt_view.type;
205+ return cmp;
201206
202− if (vma->ggtt_view.type != view->type)
203− return vma->ggtt_view.type - view->type;
207+ cmp -= view->type;
208+ if (cmp)
209+ return cmp;
204210
205− return memcmp(&vma->ggtt_view.params,
206− &view->params,
207− sizeof(view->params));
211+ /* ggtt_view.type also encodes its size so that we both distinguish
212+ * different views using it as a "type" and also use a compact (no
213+ * accessing of uninitialised padding bytes) memcmp without storing
214+ * an extra parameter or adding more code.
215+ *
216+ * To ensure that the memcmp is valid for all branches of the union,
217+ * even though the code looks like it is just comparing one branch,
218+ * we assert above that all branches have the same address, and that
219+ * each branch has a unique type/size.
220+ */
221+ BUILD_BUG_ON(I915_GGTT_VIEW_NORMAL >= I915_GGTT_VIEW_PARTIAL);
222+ BUILD_BUG_ON(I915_GGTT_VIEW_PARTIAL >= I915_GGTT_VIEW_ROTATED);
223+ BUILD_BUG_ON(offsetof(typeof(*view), rotated) !=
224+ offsetof(typeof(*view), partial));
225+ return memcmp(&vma->ggtt_view.partial, &view->partial, view->type);
208226 }
209227
210228 int i915_vma_bind(struct i915_vma *vma, enum i915_cache_level cache_level,
@@ -229,8 +247,11 @@ i915_vma_pin(struct i915_vma *vma, u64 size, u64 alignment, u64 flags) · 18 unmodified lines
229247 /* Pin early to prevent the shrinker/eviction logic from destroying
230248 * our vma as we insert and bind.
231249 */
232− if (likely(((++vma->flags ^ flags) & I915_VMA_BIND_MASK) == 0))
250+ if (likely(((++vma->flags ^ flags) & I915_VMA_BIND_MASK) == 0)) {
251+ GEM_BUG_ON(!drm_mm_node_allocated(&vma->node));
252+ GEM_BUG_ON(i915_vma_misplaced(vma, size, alignment, flags));
233253 return 0;
254+ }
234255
235256 return __i915_vma_do_pin(vma, size, alignment, flags);
236257 }
drivers/gpu/drm/i915/intel_atomic_plane.c+20−0
@@ -85,6 +85,8 @@ intel_plane_duplicate_state(struct drm_plane *plane) · 84 unmodified lines
8585
8686 __drm_atomic_helper_plane_duplicate_state(plane, state);
8787
88+ intel_state->vma = NULL;
89+
8890 return state;
8991 }
9092
@@ -100,6 +102,24 @@ void · 9 unmodified lines
100102 intel_plane_destroy_state(struct drm_plane *plane,
101103 struct drm_plane_state *state)
102104 {
105+ struct i915_vma *vma;
106+
107+ vma = fetch_and_zero(&to_intel_plane_state(state)->vma);
108+
109+ /*
110+ * FIXME: Normally intel_cleanup_plane_fb handles destruction of vma.
111+ * We currently don't clear all planes during driver unload, so we have
112+ * to be able to unpin vma here for now.
113+ *
114+ * Normally this can only happen during unload when kmscon is disabled
115+ * and userspace doesn't attempt to set a framebuffer at all.
116+ */
117+ if (vma) {
118+ mutex_lock(&plane->dev->struct_mutex);
119+ intel_unpin_fb_vma(vma);
120+ mutex_unlock(&plane->dev->struct_mutex);
121+ }
122+
103123 drm_atomic_helper_plane_destroy_state(plane, state);
104124 }
105125
drivers/gpu/drm/i915/intel_csr.c+10−2
@@ -34,6 +34,10 @@ · 33 unmodified lines
3434 * low-power state and comes back to normal.
3535 */
3636
37+#define I915_CSR_GLK "i915/glk_dmc_ver1_01.bin"
38+MODULE_FIRMWARE(I915_CSR_GLK);
39+#define GLK_CSR_VERSION_REQUIRED CSR_VERSION(1, 1)
40+
3741 #define I915_CSR_KBL "i915/kbl_dmc_ver1_01.bin"
3842 MODULE_FIRMWARE(I915_CSR_KBL);
3943 #define KBL_CSR_VERSION_REQUIRED CSR_VERSION(1, 1)
@@ -286,7 +290,9 @@ static uint32_t *parse_csr_fw(struct drm_i915_private *dev_priv, · 246 unmodified lines
286290
287291 csr->version = css_header->version;
288292
289− if (IS_KABYLAKE(dev_priv)) {
293+ if (IS_GEMINILAKE(dev_priv)) {
294+ required_version = GLK_CSR_VERSION_REQUIRED;
295+ } else if (IS_KABYLAKE(dev_priv)) {
290296 required_version = KBL_CSR_VERSION_REQUIRED;
291297 } else if (IS_SKYLAKE(dev_priv)) {
292298 required_version = SKL_CSR_VERSION_REQUIRED;
@@ -435,7 +441,9 @@ void intel_csr_ucode_init(struct drm_i915_private *dev_priv) · 142 unmodified lines
435441 if (!HAS_CSR(dev_priv))
436442 return;
437443
438− if (IS_KABYLAKE(dev_priv))
444+ if (IS_GEMINILAKE(dev_priv))
445+ csr->fw_path = I915_CSR_GLK;
446+ else if (IS_KABYLAKE(dev_priv))
439447 csr->fw_path = I915_CSR_KBL;
440448 else if (IS_SKYLAKE(dev_priv))
441449 csr->fw_path = I915_CSR_SKL;
drivers/gpu/drm/i915/intel_device_info.c+1−1
@@ -192,7 +192,7 @@ static void gen9_sseu_info_init(struct drm_i915_private *dev_priv) · 191 unmodified lines
192192 (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) &&
193193 hweight8(sseu->slice_mask) > 1;
194194 sseu->has_subslice_pg =
195− IS_BROXTON(dev_priv) && sseu_subslice_total(sseu) > 1;
195+ IS_GEN9_LP(dev_priv) && sseu_subslice_total(sseu) > 1;
196196 sseu->has_eu_pg = sseu->eu_per_subslice > 2;
197197
198198 if (IS_BROXTON(dev_priv)) {
drivers/gpu/drm/i915/intel_display.c+87−116
@@ -2137,11 +2137,10 @@ intel_fill_fb_ggtt_view(struct i915_ggtt_view *view, · 2136 unmodified lines
21372137 const struct drm_framebuffer *fb,
21382138 unsigned int rotation)
21392139 {
2140+ view->type = I915_GGTT_VIEW_NORMAL;
21402141 if (drm_rotation_90_or_270(rotation)) {
2141− *view = i915_ggtt_view_rotated;
2142− view->params.rotated = to_intel_framebuffer(fb)->rot_info;
2143− } else {
2144− *view = i915_ggtt_view_normal;
2142+ view->type = I915_GGTT_VIEW_ROTATED;
2143+ view->rotated = to_intel_framebuffer(fb)->rot_info;
21452144 }
21462145 }
21472146
@@ -2235,24 +2234,19 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb, unsigned int rotation) · 87 unmodified lines
22352234 i915_vma_pin_fence(vma);
22362235 }
22372236
2237+ i915_vma_get(vma);
22382238 err:
22392239 intel_runtime_pm_put(dev_priv);
22402240 return vma;
22412241 }
22422242
2243−void intel_unpin_fb_obj(struct drm_framebuffer *fb, unsigned int rotation)
2243+void intel_unpin_fb_vma(struct i915_vma *vma)
22442244 {
2245− struct drm_i915_gem_object *obj = intel_fb_obj(fb);
2246− struct i915_ggtt_view view;
2247− struct i915_vma *vma;
2248−
2249− WARN_ON(!mutex_is_locked(&obj->base.dev->struct_mutex));
2250−
2251− intel_fill_fb_ggtt_view(&view, fb, rotation);
2252− vma = i915_gem_object_to_ggtt(obj, &view);
2245+ lockdep_assert_held(&vma->vm->i915->drm.struct_mutex);
22532246
22542247 i915_vma_unpin_fence(vma);
22552248 i915_gem_object_unpin_from_display_plane(vma);
2249+ i915_vma_put(vma);
22562250 }
22572251
22582252 static int intel_fb_pitch(const struct drm_framebuffer *fb, int plane,
@@ -2745,7 +2739,6 @@ intel_find_initial_plane_obj(struct intel_crtc *intel_crtc, · 486 unmodified lines
27452739 struct drm_device *dev = intel_crtc->base.dev;
27462740 struct drm_i915_private *dev_priv = to_i915(dev);
27472741 struct drm_crtc *c;
2748− struct intel_crtc *i;
27492742 struct drm_i915_gem_object *obj;
27502743 struct drm_plane *primary = intel_crtc->base.primary;
27512744 struct drm_plane_state *plane_state = primary->state;
@@ -2770,20 +2763,20 @@ intel_find_initial_plane_obj(struct intel_crtc *intel_crtc, · 18 unmodified lines
27702763 * an fb with another CRTC instead
27712764 */
27722765 for_each_crtc(dev, c) {
2773− i = to_intel_crtc(c);
2766+ struct intel_plane_state *state;
27742767
27752768 if (c == &intel_crtc->base)
27762769 continue;
27772770
2778− if (!i->active)
2771+ if (!to_intel_crtc(c)->active)
27792772 continue;
27802773
2781− fb = c->primary->fb;
2782− if (!fb)
2774+ state = to_intel_plane_state(c->primary->state);
2775+ if (!state->vma)
27832776 continue;
27842777
2785− obj = intel_fb_obj(fb);
2786− if (i915_gem_object_ggtt_offset(obj, NULL) == plane_config->base) {
2778+ if (intel_plane_ggtt_offset(state) == plane_config->base) {
2779+ fb = c->primary->fb;
27872780 drm_framebuffer_reference(fb);
27882781 goto valid_fb;
27892782 }
@@ -2796,7 +2789,7 @@ intel_find_initial_plane_obj(struct intel_crtc *intel_crtc, · 6 unmodified lines
27962789 * simplest solution is to just disable the primary plane now and
27972790 * pretend the BIOS never had it enabled.
27982791 */
2799− to_intel_plane_state(plane_state)->base.visible = false;
2792+ plane_state->visible = false;
28002793 crtc_state->plane_mask &= ~(1 << drm_plane_index(primary));
28012794 intel_pre_disable_primary_noatomic(&intel_crtc->base);
28022795 intel_plane->disable_plane(primary, &intel_crtc->base);
@@ -2804,6 +2797,19 @@ intel_find_initial_plane_obj(struct intel_crtc *intel_crtc, · 1 unmodified line
28042797 return;
28052798
28062799 valid_fb:
2800+ mutex_lock(&dev->struct_mutex);
2801+ intel_state->vma =
2802+ intel_pin_and_fence_fb_obj(fb, primary->state->rotation);
2803+ mutex_unlock(&dev->struct_mutex);
2804+ if (IS_ERR(intel_state->vma)) {
2805+ DRM_ERROR("failed to pin boot fb on pipe %d: %li\n",
2806+ intel_crtc->pipe, PTR_ERR(intel_state->vma));
2807+
2808+ intel_state->vma = NULL;
2809+ drm_framebuffer_unreference(fb);
2810+ return;
2811+ }
2812+
28072813 plane_state->src_x = 0;
28082814 plane_state->src_y = 0;
28092815 plane_state->src_w = fb->width << 16;
@@ -3099,13 +3105,13 @@ static void i9xx_update_primary_plane(struct drm_plane *primary, · 289 unmodified lines
30993105 I915_WRITE(DSPSTRIDE(plane), fb->pitches[0]);
31003106 if (INTEL_GEN(dev_priv) >= 4) {
31013107 I915_WRITE(DSPSURF(plane),
3102− intel_fb_gtt_offset(fb, rotation) +
3108+ intel_plane_ggtt_offset(plane_state) +
31033109 intel_crtc->dspaddr_offset);
31043110 I915_WRITE(DSPTILEOFF(plane), (y << 16) | x);
31053111 I915_WRITE(DSPLINOFF(plane), linear_offset);
31063112 } else {
31073113 I915_WRITE(DSPADDR(plane),
3108− intel_fb_gtt_offset(fb, rotation) +
3114+ intel_plane_ggtt_offset(plane_state) +
31093115 intel_crtc->dspaddr_offset);
31103116 }
31113117 POSTING_READ(reg);
@@ -3202,7 +3208,7 @@ static void ironlake_update_primary_plane(struct drm_plane *primary, · 90 unmodified lines
32023208
32033209 I915_WRITE(DSPSTRIDE(plane), fb->pitches[0]);
32043210 I915_WRITE(DSPSURF(plane),
3205− intel_fb_gtt_offset(fb, rotation) +
3211+ intel_plane_ggtt_offset(plane_state) +
32063212 intel_crtc->dspaddr_offset);
32073213 if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) {
32083214 I915_WRITE(DSPOFFSET(plane), (y << 16) | x);
@@ -3225,23 +3231,6 @@ u32 intel_fb_stride_alignment(const struct drm_i915_private *dev_priv, · 16 unmodified lines
32253231 }
32263232 }
32273233
3228−u32 intel_fb_gtt_offset(struct drm_framebuffer *fb,
3229− unsigned int rotation)
3230−{
3231− struct drm_i915_gem_object *obj = intel_fb_obj(fb);
3232− struct i915_ggtt_view view;
3233− struct i915_vma *vma;
3234−
3235− intel_fill_fb_ggtt_view(&view, fb, rotation);
3236−
3237− vma = i915_gem_object_to_ggtt(obj, &view);
3238− if (WARN(!vma, "ggtt vma for display object not found! (view=%u)\n",
3239− view.type))
3240− return -1;
3241−
3242− return i915_ggtt_offset(vma);
3243−}
3244−
32453234 static void skl_detach_scaler(struct intel_crtc *intel_crtc, int id)
32463235 {
32473236 struct drm_device *dev = intel_crtc->base.dev;
@@ -3437,7 +3426,7 @@ static void skylake_update_primary_plane(struct drm_plane *plane, · 189 unmodified lines
34373426 }
34383427
34393428 I915_WRITE(PLANE_SURF(pipe, plane_id),
3440− intel_fb_gtt_offset(fb, rotation) + surf_addr);
3429+ intel_plane_ggtt_offset(plane_state) + surf_addr);
34413430
34423431 POSTING_READ(PLANE_SURF(pipe, plane_id));
34433432 }
@@ -3561,23 +3550,19 @@ void intel_prepare_reset(struct drm_i915_private *dev_priv) · 117 unmodified lines
35613550 state = drm_atomic_helper_duplicate_state(dev, ctx);
35623551 if (IS_ERR(state)) {
35633552 ret = PTR_ERR(state);
3564− state = NULL;
35653553 DRM_ERROR("Duplicating state failed with %i\n", ret);
3566− goto err;
3554+ return;
35673555 }
35683556
35693557 ret = drm_atomic_helper_disable_all(dev, ctx);
35703558 if (ret) {
35713559 DRM_ERROR("Suspending crtc's failed with %i\n", ret);
3572− goto err;
3560+ drm_atomic_state_put(state);
3561+ return;
35733562 }
35743563
35753564 dev_priv->modeset_restore_state = state;
35763565 state->acquire_ctx = ctx;
3577− return;
3578−
3579−err:
3580− drm_atomic_state_put(state);
35813566 }
35823567
35833568 void intel_finish_reset(struct drm_i915_private *dev_priv)
@@ -6886,13 +6871,13 @@ static void intel_crtc_disable_noatomic(struct drm_crtc *crtc) · 3302 unmodified lines
68866871 if (!intel_crtc->active)
68876872 return;
68886873
6889− if (to_intel_plane_state(crtc->primary->state)->base.visible) {
6874+ if (crtc->primary->state->visible) {
68906875 WARN_ON(intel_crtc->flip_work);
68916876
68926877 intel_pre_disable_primary_noatomic(crtc);
68936878
68946879 intel_crtc_disable_planes(crtc, 1 << drm_plane_index(crtc->primary));
6895− to_intel_plane_state(crtc->primary->state)->base.visible = false;
6880+ crtc->primary->state->visible = false;
68966881 }
68976882
68986883 state = drm_atomic_state_alloc(crtc->dev);
@@ -8406,7 +8391,6 @@ void intel_mode_from_pipe_config(struct drm_display_mode *mode, · 1507 unmodified lines
84068391 mode->type = DRM_MODE_TYPE_DRIVER;
84078392
84088393 mode->clock = pipe_config->base.adjusted_mode.crtc_clock;
8409− mode->flags |= pipe_config->base.adjusted_mode.flags;
84108394
84118395 mode->hsync = drm_mode_hsync(mode);
84128396 mode->vrefresh = drm_mode_vrefresh(mode);
@@ -11291,6 +11275,7 @@ found: · 2878 unmodified lines
1129111275 }
1129211276
1129311277 old->restore_state = restore_state;
11278+ drm_atomic_state_put(state);
1129411279
1129511280 /* let the connector get through one full cycle before testing */
1129611281 intel_wait_for_vblank(dev_priv, intel_crtc->pipe);
@@ -11570,7 +11555,7 @@ static void intel_unpin_work_fn(struct work_struct *__work) · 273 unmodified lines
1157011555 flush_work(&work->mmio_work);
1157111556
1157211557 mutex_lock(&dev->struct_mutex);
11573− intel_unpin_fb_obj(work->old_fb, primary->state->rotation);
11558+ intel_unpin_fb_vma(work->old_vma);
1157411559 i915_gem_object_put(work->pending_flip_obj);
1157511560 mutex_unlock(&dev->struct_mutex);
1157611561
@@ -12280,8 +12265,10 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc, · 703 unmodified lines
1228012265 goto cleanup_pending;
1228112266 }
1228212267
12283− work->gtt_offset = intel_fb_gtt_offset(fb, primary->state->rotation);
12284− work->gtt_offset += intel_crtc->dspaddr_offset;
12268+ work->old_vma = to_intel_plane_state(primary->state)->vma;
12269+ to_intel_plane_state(primary->state)->vma = vma;
12270+
12271+ work->gtt_offset = i915_ggtt_offset(vma) + intel_crtc->dspaddr_offset;
1228512272 work->rotation = crtc->primary->state->rotation;
1228612273
1228712274 /*
@@ -12336,7 +12323,8 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc, · 48 unmodified lines
1233612323 cleanup_request:
1233712324 i915_add_request_no_flush(request);
1233812325 cleanup_unpin:
12339− intel_unpin_fb_obj(fb, crtc->primary->state->rotation);
12326+ to_intel_plane_state(primary->state)->vma = work->old_vma;
12327+ intel_unpin_fb_vma(vma);
1234012328 cleanup_pending:
1234112329 atomic_dec(&intel_crtc->unpin_work_count);
1234212330 unlock:
@@ -12466,7 +12454,7 @@ int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state, · 123 unmodified lines
1246612454 }
1246712455
1246812456 was_visible = old_plane_state->base.visible;
12469− visible = to_intel_plane_state(plane_state)->base.visible;
12457+ visible = plane_state->visible;
1247012458
1247112459 if (!was_crtc_enabled && WARN_ON(was_visible))
1247212460 was_visible = false;
@@ -12482,7 +12470,7 @@ int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state, · 9 unmodified lines
1248212470 * only combine the results from all planes in the current place?
1248312471 */
1248412472 if (!is_crtc_enabled)
12485− to_intel_plane_state(plane_state)->base.visible = visible = false;
12473+ plane_state->visible = visible = false;
1248612474
1248712475 if (!was_visible && !visible)
1248812476 return 0;
@@ -14740,6 +14728,7 @@ static const struct drm_crtc_funcs intel_crtc_funcs = { · 2251 unmodified lines
1474014728 .page_flip = intel_crtc_page_flip,
1474114729 .atomic_duplicate_state = intel_crtc_duplicate_state,
1474214730 .atomic_destroy_state = intel_crtc_destroy_state,
14731+ .set_crc_source = intel_crtc_set_crc_source,
1474314732 };
1474414733
1474514734 /**
@@ -14836,6 +14825,8 @@ intel_prepare_plane_fb(struct drm_plane *plane, · 90 unmodified lines
1483614825 DRM_DEBUG_KMS("failed to pin object\n");
1483714826 return PTR_ERR(vma);
1483814827 }
14828+
14829+ to_intel_plane_state(new_state)->vma = vma;
1483914830 }
1484014831
1484114832 return 0;
@@ -14854,19 +14845,12 @@ void · 12 unmodified lines
1485414845 intel_cleanup_plane_fb(struct drm_plane *plane,
1485514846 struct drm_plane_state *old_state)
1485614847 {
14857− struct drm_i915_private *dev_priv = to_i915(plane->dev);
14858− struct intel_plane_state *old_intel_state;
14859− struct drm_i915_gem_object *old_obj = intel_fb_obj(old_state->fb);
14860− struct drm_i915_gem_object *obj = intel_fb_obj(plane->state->fb);
14861−
14862− old_intel_state = to_intel_plane_state(old_state);
14863−
14864− if (!obj && !old_obj)
14865− return;
14848+ struct i915_vma *vma;
1486614849
14867− if (old_obj && (plane->type != DRM_PLANE_TYPE_CURSOR ||
14868− !INTEL_INFO(dev_priv)->cursor_needs_physical))
14869− intel_unpin_fb_obj(old_state->fb, old_state->rotation);
14850+ /* Should only be called after a successful intel_prepare_plane_fb()! */
14851+ vma = fetch_and_zero(&to_intel_plane_state(old_state)->vma);
14852+ if (vma)
14853+ intel_unpin_fb_vma(vma);
1487014854 }
1487114855
1487214856 int
@@ -15018,6 +15002,7 @@ intel_legacy_cursor_update(struct drm_plane *plane, · 145 unmodified lines
1501815002 struct intel_plane *intel_plane = to_intel_plane(plane);
1501915003 struct drm_framebuffer *old_fb;
1502015004 struct drm_crtc_state *crtc_state = crtc->state;
15005+ struct i915_vma *old_vma;
1502115006
1502215007 /*
1502315008 * When crtc is inactive or there is a modeset pending,
@@ -15089,9 +15074,12 @@ intel_legacy_cursor_update(struct drm_plane *plane, · 65 unmodified lines
1508915074 ret = PTR_ERR(vma);
1509015075 goto out_unlock;
1509115076 }
15077+
15078+ to_intel_plane_state(new_plane_state)->vma = vma;
1509215079 }
1509315080
1509415081 old_fb = old_plane_state->fb;
15082+ old_vma = to_intel_plane_state(old_plane_state)->vma;
1509515083
1509615084 i915_gem_track_fb(intel_fb_obj(old_fb), intel_fb_obj(fb),
1509715085 intel_plane->frontbuffer_bit);
@@ -15101,6 +15089,7 @@ intel_legacy_cursor_update(struct drm_plane *plane, · 3 unmodified lines
1510115089 *to_intel_plane_state(old_plane_state) = *to_intel_plane_state(new_plane_state);
1510215090 new_plane_state->fence = NULL;
1510315091 new_plane_state->fb = old_fb;
15092+ to_intel_plane_state(new_plane_state)->vma = old_vma;
1510415093
1510515094 intel_plane->update_plane(plane,
1510615095 to_intel_crtc_state(crtc->state),
@@ -15339,7 +15328,7 @@ intel_update_cursor_plane(struct drm_plane *plane, · 232 unmodified lines
1533915328 if (!obj)
1534015329 addr = 0;
1534115330 else if (!INTEL_INFO(dev_priv)->cursor_needs_physical)
15342− addr = i915_gem_object_ggtt_offset(obj, NULL);
15331+ addr = intel_plane_ggtt_offset(state);
1534315332 else
1534415333 addr = obj->phys_handle->busaddr;
1534515334
@@ -16843,7 +16832,7 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc) · 1497 unmodified lines
1684316832 * Temporarily change the plane mapping and disable everything
1684416833 * ... */
1684516834 plane = crtc->plane;
16846− to_intel_plane_state(crtc->base.primary->state)->base.visible = true;
16835+ crtc->base.primary->state->visible = true;
1684716836 crtc->plane = !plane;
1684816837 intel_crtc_disable_noatomic(&crtc->base);
1684916838 crtc->plane = plane;
@@ -16995,7 +16984,8 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev) · 145 unmodified lines
1699516984 dev_priv->active_crtcs = 0;
1699616985
1699716986 for_each_intel_crtc(dev, crtc) {
16998− struct intel_crtc_state *crtc_state = crtc->config;
16987+ struct intel_crtc_state *crtc_state =
16988+ to_intel_crtc_state(crtc->base.state);
1699916989
1700016990 __drm_atomic_helper_crtc_destroy_state(&crtc_state->base);
1700116991 memset(crtc_state, 0, sizeof(*crtc_state));
@@ -17014,7 +17004,7 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev) · 12 unmodified lines
1701417004
1701517005 DRM_DEBUG_KMS("[CRTC:%d:%s] hw state readout: %s\n",
1701617006 crtc->base.base.id, crtc->base.name,
17017− enableddisabled(crtc->active));
17007+ enableddisabled(crtc_state->base.active));
1701817008 }
1701917009
1702017010 for (i = 0; i < dev_priv->num_shared_dpll; i++) {
@@ -17024,7 +17014,11 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev) · 3 unmodified lines
1702417014 &pll->state.hw_state);
1702517015 pll->state.crtc_mask = 0;
1702617016 for_each_intel_crtc(dev, crtc) {
17027− if (crtc->active && crtc->config->shared_dpll == pll)
17017+ struct intel_crtc_state *crtc_state =
17018+ to_intel_crtc_state(crtc->base.state);
17019+
17020+ if (crtc_state->base.active &&
17021+ crtc_state->shared_dpll == pll)
1702817022 pll->state.crtc_mask |= 1 << crtc->pipe;
1702917023 }
1703017024 pll->active_mask = pll->state.crtc_mask;
@@ -17037,11 +17031,14 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev) · 6 unmodified lines
1703717031 pipe = 0;
1703817032
1703917033 if (encoder->get_hw_state(encoder, &pipe)) {
17034+ struct intel_crtc_state *crtc_state;
17035+
1704017036 crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
17037+ crtc_state = to_intel_crtc_state(crtc->base.state);
1704117038
1704217039 encoder->base.crtc = &crtc->base;
17043− crtc->config->output_types |= 1 << encoder->type;
17044− encoder->get_config(encoder, crtc->config);
17040+ crtc_state->output_types |= 1 << encoder->type;
17041+ encoder->get_config(encoder, crtc_state);
1704517042 } else {
1704617043 encoder->base.crtc = NULL;
1704717044 }
@@ -17082,14 +17079,16 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev) · 34 unmodified lines
1708217079 }
1708317080
1708417081 for_each_intel_crtc(dev, crtc) {
17082+ struct intel_crtc_state *crtc_state =
17083+ to_intel_crtc_state(crtc->base.state);
1708517084 int pixclk = 0;
1708617085
17087− crtc->base.hwmode = crtc->config->base.adjusted_mode;
17086+ crtc->base.hwmode = crtc_state->base.adjusted_mode;
1708817087
1708917088 memset(&crtc->base.mode, 0, sizeof(crtc->base.mode));
17090− if (crtc->base.state->active) {
17091− intel_mode_from_pipe_config(&crtc->base.mode, crtc->config);
17092− intel_mode_from_pipe_config(&crtc->base.state->adjusted_mode, crtc->config);
17089+ if (crtc_state->base.active) {
17090+ intel_mode_from_pipe_config(&crtc->base.mode, crtc_state);
17091+ intel_mode_from_pipe_config(&crtc_state->base.adjusted_mode, crtc_state);
1709317092 WARN_ON(drm_atomic_set_mode_for_crtc(crtc->base.state, &crtc->base.mode));
1709417093
1709517094 /*
@@ -17101,17 +17100,17 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev) · 5 unmodified lines
1710117100 * set a flag to indicate that a full recalculation is
1710217101 * needed on the next commit.
1710317102 */
17104− crtc->base.state->mode.private_flags = I915_MODE_FLAG_INHERITED;
17103+ crtc_state->base.mode.private_flags = I915_MODE_FLAG_INHERITED;
1710517104
1710617105 if (INTEL_GEN(dev_priv) >= 9 || IS_BROADWELL(dev_priv))
17107− pixclk = ilk_pipe_pixel_rate(crtc->config);
17106+ pixclk = ilk_pipe_pixel_rate(crtc_state);
1710817107 else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
17109− pixclk = crtc->config->base.adjusted_mode.crtc_clock;
17108+ pixclk = crtc_state->base.adjusted_mode.crtc_clock;
1711017109 else
1711117110 WARN_ON(dev_priv->display.modeset_calc_cdclk);
1711217111
1711317112 /* pixel rate mustn't exceed 95% of cdclk with IPS on BDW */
17114− if (IS_BROADWELL(dev_priv) && crtc->config->ips_enabled)
17113+ if (IS_BROADWELL(dev_priv) && crtc_state->ips_enabled)
1711517114 pixclk = DIV_ROUND_UP(pixclk * 100, 95);
1711617115
1711717116 drm_calc_timestamping_constants(&crtc->base, &crtc->base.hwmode);
@@ -17120,7 +17119,7 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev) · 2 unmodified lines
1712017119
1712117120 dev_priv->min_pixclk[crtc->pipe] = pixclk;
1712217121
17123− intel_pipe_config_sanity_check(dev_priv, crtc->config);
17122+ intel_pipe_config_sanity_check(dev_priv, crtc_state);
1712417123 }
1712517124 }
1712617125
@@ -17221,47 +17220,19 @@ void intel_display_resume(struct drm_device *dev) · 94 unmodified lines
1722117220
1722217221 if (ret)
1722317222 DRM_ERROR("Restoring old state failed with %i\n", ret);
17224− drm_atomic_state_put(state);
17223+ if (state)
17224+ drm_atomic_state_put(state);
1722517225 }
1722617226
1722717227 void intel_modeset_gem_init(struct drm_device *dev)
1722817228 {
1722917229 struct drm_i915_private *dev_priv = to_i915(dev);
17230− struct drm_crtc *c;
17231− struct drm_i915_gem_object *obj;
1723217230
1723317231 intel_init_gt_powersave(dev_priv);
1723417232
1723517233 intel_modeset_init_hw(dev);
1723617234
1723717235 intel_setup_overlay(dev_priv);
17238−
17239− /*
17240− * Make sure any fbs we allocated at startup are properly
17241− * pinned & fenced. When we do the allocation it's too early
17242− * for this.
17243− */
17244− for_each_crtc(dev, c) {
17245− struct i915_vma *vma;
17246−
17247− obj = intel_fb_obj(c->primary->fb);
17248− if (obj == NULL)
17249− continue;
17250−
17251− mutex_lock(&dev->struct_mutex);
17252− vma = intel_pin_and_fence_fb_obj(c->primary->fb,
17253− c->primary->state->rotation);
17254− mutex_unlock(&dev->struct_mutex);
17255− if (IS_ERR(vma)) {
17256− DRM_ERROR("failed to pin boot fb on pipe %d\n",
17257− to_intel_crtc(c)->pipe);
17258− drm_framebuffer_unreference(c->primary->fb);
17259− c->primary->fb = NULL;
17260− c->primary->crtc = c->primary->state->crtc = NULL;
17261− update_state_fb(c->primary);
17262− c->state->plane_mask &= ~(1 << drm_plane_index(c->primary));
17263− }
17264− }
1726517236 }
1726617237
1726717238 int intel_connector_register(struct drm_connector *connector)
drivers/gpu/drm/i915/intel_dp.c+37−1
@@ -3042,6 +3042,32 @@ intel_dp_get_link_status(struct intel_dp *intel_dp, uint8_t link_status[DP_LINK_ · 3041 unmodified lines
30423042 DP_LINK_STATUS_SIZE) == DP_LINK_STATUS_SIZE;
30433043 }
30443044
3045+static bool intel_dp_get_y_cord_status(struct intel_dp *intel_dp)
3046+{
3047+ uint8_t psr_caps = 0;
3048+
3049+ drm_dp_dpcd_readb(&intel_dp->aux, DP_PSR_CAPS, &psr_caps);
3050+ return psr_caps & DP_PSR2_SU_Y_COORDINATE_REQUIRED;
3051+}
3052+
3053+static bool intel_dp_get_colorimetry_status(struct intel_dp *intel_dp)
3054+{
3055+ uint8_t dprx = 0;
3056+
3057+ drm_dp_dpcd_readb(&intel_dp->aux,
3058+ DP_DPRX_FEATURE_ENUMERATION_LIST,
3059+ &dprx);
3060+ return dprx & DP_VSC_SDP_EXT_FOR_COLORIMETRY_SUPPORTED;
3061+}
3062+
3063+static bool intel_dp_get_alpm_status(struct intel_dp *intel_dp)
3064+{
3065+ uint8_t alpm_caps = 0;
3066+
3067+ drm_dp_dpcd_readb(&intel_dp->aux, DP_RECEIVER_ALPM_CAP, &alpm_caps);
3068+ return alpm_caps & DP_ALPM_CAP;
3069+}
3070+
30453071 /* These are source-specific values. */
30463072 uint8_t
30473073 intel_dp_voltage_max(struct intel_dp *intel_dp)
@@ -3412,7 +3438,7 @@ intel_dp_set_signal_levels(struct intel_dp *intel_dp) · 364 unmodified lines
34123438 if (HAS_DDI(dev_priv)) {
34133439 signal_levels = ddi_signal_levels(intel_dp);
34143440
3415− if (IS_BROXTON(dev_priv))
3441+ if (IS_GEN9_LP(dev_priv))
34163442 signal_levels = 0;
34173443 else
34183444 mask = DDI_BUF_EMP_MASK;
@@ -3620,6 +3646,16 @@ intel_edp_init_dpcd(struct intel_dp *intel_dp) · 201 unmodified lines
36203646 dev_priv->psr.psr2_support = dev_priv->psr.aux_frame_sync;
36213647 DRM_DEBUG_KMS("PSR2 %s on sink",
36223648 dev_priv->psr.psr2_support ? "supported" : "not supported");
3649+
3650+ if (dev_priv->psr.psr2_support) {
3651+ dev_priv->psr.y_cord_support =
3652+ intel_dp_get_y_cord_status(intel_dp);
3653+ dev_priv->psr.colorimetry_support =
3654+ intel_dp_get_colorimetry_status(intel_dp);
3655+ dev_priv->psr.alpm =
3656+ intel_dp_get_alpm_status(intel_dp);
3657+ }
3658+
36233659 }
36243660
36253661 /* Read the eDP Display control capabilities registers */
drivers/gpu/drm/i915/intel_drv.h+13−2
@@ -376,6 +376,7 @@ struct intel_atomic_state { · 375 unmodified lines
376376 struct intel_plane_state {
377377 struct drm_plane_state base;
378378 struct drm_rect clip;
379+ struct i915_vma *vma;
379380
380381 struct {
381382 u32 offset;
@@ -1067,6 +1068,7 @@ struct intel_flip_work { · 685 unmodified lines
10671068 struct work_struct mmio_work;
10681069
10691070 struct drm_crtc *crtc;
1071+ struct i915_vma *old_vma;
10701072 struct drm_framebuffer *old_fb;
10711073 struct drm_i915_gem_object *pending_flip_obj;
10721074 struct drm_pending_vblank_event *event;
@@ -1302,7 +1304,7 @@ void intel_release_load_detect_pipe(struct drm_connector *connector, · 229 unmodified lines
13021304 struct drm_modeset_acquire_ctx *ctx);
13031305 struct i915_vma *
13041306 intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb, unsigned int rotation);
1305−void intel_unpin_fb_obj(struct drm_framebuffer *fb, unsigned int rotation);
1307+void intel_unpin_fb_vma(struct i915_vma *vma);
13061308 struct drm_framebuffer *
13071309 __intel_framebuffer_create(struct drm_device *dev,
13081310 struct drm_mode_fb_cmd2 *mode_cmd,
@@ -1391,7 +1393,10 @@ void intel_mode_from_pipe_config(struct drm_display_mode *mode, · 82 unmodified lines
13911393 int skl_update_scaler_crtc(struct intel_crtc_state *crtc_state);
13921394 int skl_max_scale(struct intel_crtc *crtc, struct intel_crtc_state *crtc_state);
13931395
1394−u32 intel_fb_gtt_offset(struct drm_framebuffer *fb, unsigned int rotation);
1396+static inline u32 intel_plane_ggtt_offset(const struct intel_plane_state *state)
1397+{
1398+ return i915_ggtt_offset(state->vma);
1399+}
13951400
13961401 u32 skl_plane_ctl_format(uint32_t pixel_format);
13971402 u32 skl_plane_ctl_tiling(uint64_t fb_modifier);
@@ -1880,5 +1885,11 @@ void lspcon_wait_pcon_mode(struct intel_lspcon *lspcon); · 482 unmodified lines
18801885 /* intel_pipe_crc.c */
18811886 int intel_pipe_crc_create(struct drm_minor *minor);
18821887 void intel_pipe_crc_cleanup(struct drm_minor *minor);
1888+#ifdef CONFIG_DEBUG_FS
1889+int intel_crtc_set_crc_source(struct drm_crtc *crtc, const char *source_name,
1890+ size_t *values_cnt);
1891+#else
1892+#define intel_crtc_set_crc_source NULL
1893+#endif
18831894 extern const struct file_operations i915_display_crc_ctl_fops;
18841895 #endif /* __INTEL_DRV_H__ */
drivers/gpu/drm/i915/intel_engine_cs.c+1−1
@@ -264,7 +264,7 @@ int intel_engine_create_scratch(struct intel_engine_cs *engine, int size) · 263 unmodified lines
264264 return PTR_ERR(obj);
265265 }
266266
267− vma = i915_vma_create(obj, &engine->i915->ggtt.base, NULL);
267+ vma = i915_vma_instance(obj, &engine->i915->ggtt.base, NULL);
268268 if (IS_ERR(vma)) {
269269 ret = PTR_ERR(vma);
270270 goto err_unref;
drivers/gpu/drm/i915/intel_fbc.c+21−33
@@ -173,7 +173,7 @@ static void i8xx_fbc_activate(struct drm_i915_private *dev_priv) · 172 unmodified lines
173173 if (IS_I945GM(dev_priv))
174174 fbc_ctl |= FBC_CTL_C3_IDLE; /* 945 needs special SR handling */
175175 fbc_ctl |= (cfb_pitch & 0xff) << FBC_CTL_STRIDE_SHIFT;
176− fbc_ctl |= params->fb.fence_reg;
176+ fbc_ctl |= params->vma->fence->id;
177177 I915_WRITE(FBC_CONTROL, fbc_ctl);
178178 }
179179
@@ -193,8 +193,8 @@ static void g4x_fbc_activate(struct drm_i915_private *dev_priv) · 13 unmodified lines
193193 else
194194 dpfc_ctl |= DPFC_CTL_LIMIT_1X;
195195
196− if (params->fb.fence_reg != I915_FENCE_REG_NONE) {
197− dpfc_ctl |= DPFC_CTL_FENCE_EN | params->fb.fence_reg;
196+ if (params->vma->fence) {
197+ dpfc_ctl |= DPFC_CTL_FENCE_EN | params->vma->fence->id;
198198 I915_WRITE(DPFC_FENCE_YOFF, params->crtc.fence_y_offset);
199199 } else {
200200 I915_WRITE(DPFC_FENCE_YOFF, 0);
@@ -251,13 +251,14 @@ static void ilk_fbc_activate(struct drm_i915_private *dev_priv) · 50 unmodified lines
251251 break;
252252 }
253253
254− if (params->fb.fence_reg != I915_FENCE_REG_NONE) {
254+ if (params->vma->fence) {
255255 dpfc_ctl |= DPFC_CTL_FENCE_EN;
256256 if (IS_GEN5(dev_priv))
257− dpfc_ctl |= params->fb.fence_reg;
257+ dpfc_ctl |= params->vma->fence->id;
258258 if (IS_GEN6(dev_priv)) {
259259 I915_WRITE(SNB_DPFC_CTL_SA,
260− SNB_CPU_FENCE_ENABLE | params->fb.fence_reg);
260+ SNB_CPU_FENCE_ENABLE |
261+ params->vma->fence->id);
261262 I915_WRITE(DPFC_CPU_FENCE_OFFSET,
262263 params->crtc.fence_y_offset);
263264 }
@@ -269,7 +270,8 @@ static void ilk_fbc_activate(struct drm_i915_private *dev_priv) · 5 unmodified lines
269270 }
270271
271272 I915_WRITE(ILK_DPFC_FENCE_YOFF, params->crtc.fence_y_offset);
272− I915_WRITE(ILK_FBC_RT_BASE, params->fb.ggtt_offset | ILK_FBC_RT_VALID);
273+ I915_WRITE(ILK_FBC_RT_BASE,
274+ i915_ggtt_offset(params->vma) | ILK_FBC_RT_VALID);
273275 /* enable it... */
274276 I915_WRITE(ILK_DPFC_CONTROL, dpfc_ctl | DPFC_CTL_EN);
275277
@@ -319,10 +321,11 @@ static void gen7_fbc_activate(struct drm_i915_private *dev_priv) · 43 unmodified lines
319321 break;
320322 }
321323
322− if (params->fb.fence_reg != I915_FENCE_REG_NONE) {
324+ if (params->vma->fence) {
323325 dpfc_ctl |= IVB_DPFC_CTL_FENCE_EN;
324326 I915_WRITE(SNB_DPFC_CTL_SA,
325− SNB_CPU_FENCE_ENABLE | params->fb.fence_reg);
327+ SNB_CPU_FENCE_ENABLE |
328+ params->vma->fence->id);
326329 I915_WRITE(DPFC_CPU_FENCE_OFFSET, params->crtc.fence_y_offset);
327330 } else {
328331 I915_WRITE(SNB_DPFC_CTL_SA,0);
@@ -727,14 +730,6 @@ static bool intel_fbc_hw_tracking_covers_screen(struct intel_crtc *crtc) · 398 unmodified lines
727730 return effective_w <= max_w && effective_h <= max_h;
728731 }
729732
730−/* XXX replace me when we have VMA tracking for intel_plane_state */
731−static int get_fence_id(struct drm_framebuffer *fb)
732−{
733− struct i915_vma *vma = i915_gem_object_to_ggtt(intel_fb_obj(fb), NULL);
734−
735− return vma && vma->fence ? vma->fence->id : I915_FENCE_REG_NONE;
736−}
737−
738733 static void intel_fbc_update_state_cache(struct intel_crtc *crtc,
739734 struct intel_crtc_state *crtc_state,
740735 struct intel_plane_state *plane_state)
@@ -743,7 +738,8 @@ static void intel_fbc_update_state_cache(struct intel_crtc *crtc, · 2 unmodified lines
743738 struct intel_fbc *fbc = &dev_priv->fbc;
744739 struct intel_fbc_state_cache *cache = &fbc->state_cache;
745740 struct drm_framebuffer *fb = plane_state->base.fb;
746− struct drm_i915_gem_object *obj;
741+
742+ cache->vma = NULL;
747743
748744 cache->crtc.mode_flags = crtc_state->base.adjusted_mode.flags;
749745 if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
@@ -758,16 +754,10 @@ static void intel_fbc_update_state_cache(struct intel_crtc *crtc, · 8 unmodified lines
758754 if (!cache->plane.visible)
759755 return;
760756
761− obj = intel_fb_obj(fb);
762−
763− /* FIXME: We lack the proper locking here, so only run this on the
764− * platforms that need. */
765− if (IS_GEN(dev_priv, 5, 6))
766− cache->fb.ilk_ggtt_offset = i915_gem_object_ggtt_offset(obj, NULL);
767757 cache->fb.format = fb->format;
768758 cache->fb.stride = fb->pitches[0];
769− cache->fb.fence_reg = get_fence_id(fb);
770− cache->fb.tiling_mode = i915_gem_object_get_tiling(obj);
759+
760+ cache->vma = plane_state->vma;
771761 }
772762
773763 static bool intel_fbc_can_activate(struct intel_crtc *crtc)
@@ -784,7 +774,7 @@ static bool intel_fbc_can_activate(struct intel_crtc *crtc) · 10 unmodified lines
784774 return false;
785775 }
786776
787− if (!cache->plane.visible) {
777+ if (!cache->vma) {
788778 fbc->no_fbc_reason = "primary plane not visible";
789779 return false;
790780 }
@@ -807,8 +797,7 @@ static bool intel_fbc_can_activate(struct intel_crtc *crtc) · 16 unmodified lines
807797 * so have no fence associated with it) due to aperture constaints
808798 * at the time of pinning.
809799 */
810− if (cache->fb.tiling_mode != I915_TILING_X ||
811− cache->fb.fence_reg == I915_FENCE_REG_NONE) {
800+ if (!cache->vma->fence) {
812801 fbc->no_fbc_reason = "framebuffer not tiled or fenced";
813802 return false;
814803 }
@@ -888,17 +877,16 @@ static void intel_fbc_get_reg_params(struct intel_crtc *crtc, · 73 unmodified lines
888877 * zero. */
889878 memset(params, 0, sizeof(*params));
890879
880+ params->vma = cache->vma;
881+
891882 params->crtc.pipe = crtc->pipe;
892883 params->crtc.plane = crtc->plane;
893884 params->crtc.fence_y_offset = get_crtc_fence_y_offset(crtc);
894885
895886 params->fb.format = cache->fb.format;
896887 params->fb.stride = cache->fb.stride;
897− params->fb.fence_reg = cache->fb.fence_reg;
898888
899889 params->cfb_size = intel_fbc_calculate_cfb_size(dev_priv, cache);
900−
901− params->fb.ggtt_offset = cache->fb.ilk_ggtt_offset;
902890 }
903891
904892 static bool intel_fbc_reg_params_equal(struct intel_fbc_reg_params *params1,
@@ -1296,7 +1284,7 @@ void intel_fbc_init_pipe_state(struct drm_i915_private *dev_priv) · 391 unmodified lines
12961284
12971285 for_each_intel_crtc(&dev_priv->drm, crtc)
12981286 if (intel_crtc_active(crtc) &&
1299− to_intel_plane_state(crtc->base.primary->state)->base.visible)
1287+ crtc->base.primary->state->visible)
13001288 dev_priv->fbc.visible_pipes_mask |= (1 << crtc->pipe);
13011289 }
13021290
drivers/gpu/drm/i915/intel_fbdev.c+5−2
@@ -284,7 +284,7 @@ static int intelfb_create(struct drm_fb_helper *helper, · 283 unmodified lines
284284 out_destroy_fbi:
285285 drm_fb_helper_release_fbi(helper);
286286 out_unpin:
287− intel_unpin_fb_obj(&ifbdev->fb->base, DRM_ROTATE_0);
287+ intel_unpin_fb_vma(vma);
288288 out_unlock:
289289 mutex_unlock(&dev->struct_mutex);
290290 return ret;
@@ -549,7 +549,7 @@ static void intel_fbdev_destroy(struct intel_fbdev *ifbdev) · 258 unmodified lines
549549
550550 if (ifbdev->fb) {
551551 mutex_lock(&ifbdev->helper.dev->struct_mutex);
552− intel_unpin_fb_obj(&ifbdev->fb->base, DRM_ROTATE_0);
552+ intel_unpin_fb_vma(ifbdev->vma);
553553 mutex_unlock(&ifbdev->helper.dev->struct_mutex);
554554
555555 drm_framebuffer_remove(&ifbdev->fb->base);
@@ -742,6 +742,9 @@ void intel_fbdev_initial_config_async(struct drm_device *dev) · 186 unmodified lines
742742 {
743743 struct intel_fbdev *ifbdev = to_i915(dev)->fbdev;
744744
745+ if (!ifbdev)
746+ return;
747+
745748 ifbdev->cookie = async_schedule(intel_fbdev_initial_config, ifbdev);
746749 }
747750
drivers/gpu/drm/i915/intel_guc_fwif.h+20−4
@@ -145,7 +145,7 @@ · 144 unmodified lines
145145 * The GuC firmware layout looks like this:
146146 *
147147 * +-------------------------------+
148− * | guc_css_header |
148+ * | uc_css_header |
149149 * | |
150150 * | contains major/minor version |
151151 * +-------------------------------+
@@ -172,9 +172,16 @@ · 20 unmodified lines
172172 * 3. Length info of each component can be found in header, in dwords.
173173 * 4. Modulus and exponent key are not required by driver. They may not appear
174174 * in fw. So driver will load a truncated firmware in this case.
175+ *
176+ * HuC firmware layout is same as GuC firmware.
177+ *
178+ * HuC firmware css header is different. However, the only difference is where
179+ * the version information is saved. The uc_css_header is unified to support
180+ * both. Driver should get HuC version from uc_css_header.huc_sw_version, while
181+ * uc_css_header.guc_sw_version for GuC.
175182 */
176183
177−struct guc_css_header {
184+struct uc_css_header {
178185 uint32_t module_type;
179186 /* header_size includes all non-uCode bits, including css_header, rsa
180187 * key, modulus key and exponent data. */
@@ -205,8 +212,16 @@ struct guc_css_header { · 24 unmodified lines
205212
206213 char username[8];
207214 char buildnumber[12];
208− uint32_t device_id;
209− uint32_t guc_sw_version;
215+ union {
216+ struct {
217+ uint32_t branch_client_version;
218+ uint32_t sw_version;
219+ } guc;
220+ struct {
221+ uint32_t sw_version;
222+ uint32_t reserved;
223+ } huc;
224+ };
210225 uint32_t prod_preprod_fw;
211226 uint32_t reserved[12];
212227 uint32_t header_info;
@@ -490,6 +505,7 @@ enum intel_guc_action { · 277 unmodified lines
490505 INTEL_GUC_ACTION_ENTER_S_STATE = 0x501,
491506 INTEL_GUC_ACTION_EXIT_S_STATE = 0x502,
492507 INTEL_GUC_ACTION_SLPC_REQUEST = 0x3003,
508+ INTEL_GUC_ACTION_AUTHENTICATE_HUC = 0x4000,
493509 INTEL_GUC_ACTION_UK_LOG_ENABLE_LOGGING = 0x0E000,
494510 INTEL_GUC_ACTION_LIMIT
495511 };
drivers/gpu/drm/i915/intel_guc_loader.c+114−100
@@ -51,12 +51,6 @@ · 50 unmodified lines
5151 * 512K. In order to exclude 0-512K address space from GGTT, all gfx objects
5252 * used by GuC is pinned with PIN_OFFSET_BIAS along with size of WOPCM.
5353 *
54− * Firmware log:
55− * Firmware log is enabled by setting i915.guc_log_level to non-negative level.
56− * Log data is printed out via reading debugfs i915_guc_log_dump. Reading from
57− * i915_guc_load_status will print out firmware loading status and scratch
58− * registers value.
59− *
6054 */
6155
6256 #define SKL_FW_MAJOR 6
@@ -81,16 +75,16 @@ MODULE_FIRMWARE(I915_BXT_GUC_UCODE); · 18 unmodified lines
8175 MODULE_FIRMWARE(I915_KBL_GUC_UCODE);
8276
8377 /* User-friendly representation of an enum */
84−const char *intel_guc_fw_status_repr(enum intel_guc_fw_status status)
78+const char *intel_uc_fw_status_repr(enum intel_uc_fw_status status)
8579 {
8680 switch (status) {
87− case GUC_FIRMWARE_FAIL:
81+ case INTEL_UC_FIRMWARE_FAIL:
8882 return "FAIL";
89− case GUC_FIRMWARE_NONE:
83+ case INTEL_UC_FIRMWARE_NONE:
9084 return "NONE";
91− case GUC_FIRMWARE_PENDING:
85+ case INTEL_UC_FIRMWARE_PENDING:
9286 return "PENDING";
93− case GUC_FIRMWARE_SUCCESS:
87+ case INTEL_UC_FIRMWARE_SUCCESS:
9488 return "SUCCESS";
9589 default:
9690 return "UNKNOWN!";
@@ -278,7 +272,7 @@ static inline bool guc_ucode_response(struct drm_i915_private *dev_priv, · 181 unmodified lines
278272 static int guc_ucode_xfer_dma(struct drm_i915_private *dev_priv,
279273 struct i915_vma *vma)
280274 {
281− struct intel_guc_fw *guc_fw = &dev_priv->guc.guc_fw;
275+ struct intel_uc_fw *guc_fw = &dev_priv->guc.fw;
282276 unsigned long offset;
283277 struct sg_table *sg = vma->pages;
284278 u32 status, rsa[UOS_RSA_SCRATCH_MAX_COUNT];
@@ -334,12 +328,12 @@ static int guc_ucode_xfer_dma(struct drm_i915_private *dev_priv, · 49 unmodified lines
334328 return ret;
335329 }
336330
337−static u32 guc_wopcm_size(struct drm_i915_private *dev_priv)
331+u32 intel_guc_wopcm_size(struct drm_i915_private *dev_priv)
338332 {
339333 u32 wopcm_size = GUC_WOPCM_TOP;
340334
341335 /* On BXT, the top of WOPCM is reserved for RC6 context */
342− if (IS_BROXTON(dev_priv))
336+ if (IS_GEN9_LP(dev_priv))
343337 wopcm_size -= BXT_GUC_WOPCM_RC6_RESERVED;
344338
345339 return wopcm_size;
@@ -350,29 +344,27 @@ static u32 guc_wopcm_size(struct drm_i915_private *dev_priv) · 4 unmodified lines
350344 */
351345 static int guc_ucode_xfer(struct drm_i915_private *dev_priv)
352346 {
353− struct intel_guc_fw *guc_fw = &dev_priv->guc.guc_fw;
347+ struct intel_uc_fw *guc_fw = &dev_priv->guc.fw;
354348 struct i915_vma *vma;
355349 int ret;
356350
357− ret = i915_gem_object_set_to_gtt_domain(guc_fw->guc_fw_obj, false);
351+ ret = i915_gem_object_set_to_gtt_domain(guc_fw->obj, false);
358352 if (ret) {
359353 DRM_DEBUG_DRIVER("set-domain failed %d\n", ret);
360354 return ret;
361355 }
362356
363− vma = i915_gem_object_ggtt_pin(guc_fw->guc_fw_obj, NULL, 0, 0, 0);
357+ vma = i915_gem_object_ggtt_pin(guc_fw->obj, NULL, 0, 0,
358+ PIN_OFFSET_BIAS | GUC_WOPCM_TOP);
364359 if (IS_ERR(vma)) {
365360 DRM_DEBUG_DRIVER("pin failed %d\n", (int)PTR_ERR(vma));
366361 return PTR_ERR(vma);
367362 }
368363
369− /* Invalidate GuC TLB to let GuC take the latest updates to GTT. */
370− I915_WRITE(GEN8_GTCR, GEN8_GTCR_INVALIDATE);
371−
372364 intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
373365
374366 /* init WOPCM */
375− I915_WRITE(GUC_WOPCM_SIZE, guc_wopcm_size(dev_priv));
367+ I915_WRITE(GUC_WOPCM_SIZE, intel_guc_wopcm_size(dev_priv));
376368 I915_WRITE(DMA_GUC_WOPCM_OFFSET, GUC_WOPCM_OFFSET_VALUE);
377369
378370 /* Enable MIA caching. GuC clock gating is disabled. */
@@ -388,7 +380,7 @@ static int guc_ucode_xfer(struct drm_i915_private *dev_priv) · 9 unmodified lines
388380 if (IS_BXT_REVID(dev_priv, 0, BXT_REVID_B0))
389381 I915_WRITE(GEN6_GFXPAUSE, 0x30FFF);
390382
391− if (IS_BROXTON(dev_priv))
383+ if (IS_GEN9_LP(dev_priv))
392384 I915_WRITE(GEN9LP_GT_PM_CONFIG, GT_DOORBELL_ENABLE);
393385 else
394386 I915_WRITE(GEN9_GT_PM_CONFIG, GT_DOORBELL_ENABLE);
@@ -450,14 +442,14 @@ static int guc_hw_reset(struct drm_i915_private *dev_priv) · 55 unmodified lines
450442 */
451443 int intel_guc_setup(struct drm_i915_private *dev_priv)
452444 {
453− struct intel_guc_fw *guc_fw = &dev_priv->guc.guc_fw;
454− const char *fw_path = guc_fw->guc_fw_path;
445+ struct intel_uc_fw *guc_fw = &dev_priv->guc.fw;
446+ const char *fw_path = guc_fw->path;
455447 int retries, ret, err;
456448
457449 DRM_DEBUG_DRIVER("GuC fw status: path %s, fetch %s, load %s\n",
458450 fw_path,
459− intel_guc_fw_status_repr(guc_fw->guc_fw_fetch_status),
460− intel_guc_fw_status_repr(guc_fw->guc_fw_load_status));
451+ intel_uc_fw_status_repr(guc_fw->fetch_status),
452+ intel_uc_fw_status_repr(guc_fw->load_status));
461453
462454 /* Loading forbidden, or no firmware to load? */
463455 if (!i915.enable_guc_loading) {
@@ -475,10 +467,10 @@ int intel_guc_setup(struct drm_i915_private *dev_priv) · 11 unmodified lines
475467 }
476468
477469 /* Fetch failed, or already fetched but failed to load? */
478− if (guc_fw->guc_fw_fetch_status != GUC_FIRMWARE_SUCCESS) {
470+ if (guc_fw->fetch_status != INTEL_UC_FIRMWARE_SUCCESS) {
479471 err = -EIO;
480472 goto fail;
481− } else if (guc_fw->guc_fw_load_status == GUC_FIRMWARE_FAIL) {
473+ } else if (guc_fw->load_status == INTEL_UC_FIRMWARE_FAIL) {
482474 err = -ENOEXEC;
483475 goto fail;
484476 }
@@ -486,11 +478,14 @@ int intel_guc_setup(struct drm_i915_private *dev_priv) · 1 unmodified line
486478 guc_interrupts_release(dev_priv);
487479 gen9_reset_guc_interrupts(dev_priv);
488480
489− guc_fw->guc_fw_load_status = GUC_FIRMWARE_PENDING;
481+ /* We need to notify the guc whenever we change the GGTT */
482+ i915_ggtt_enable_guc(dev_priv);
483+
484+ guc_fw->load_status = INTEL_UC_FIRMWARE_PENDING;
490485
491486 DRM_DEBUG_DRIVER("GuC fw status: fetch %s, load %s\n",
492− intel_guc_fw_status_repr(guc_fw->guc_fw_fetch_status),
493− intel_guc_fw_status_repr(guc_fw->guc_fw_load_status));
487+ intel_uc_fw_status_repr(guc_fw->fetch_status),
488+ intel_uc_fw_status_repr(guc_fw->load_status));
494489
495490 err = i915_guc_submission_init(dev_priv);
496491 if (err)
@@ -511,6 +506,7 @@ int intel_guc_setup(struct drm_i915_private *dev_priv) · 14 unmodified lines
511506 if (err)
512507 goto fail;
513508
509+ intel_huc_load(dev_priv);
514510 err = guc_ucode_xfer(dev_priv);
515511 if (!err)
516512 break;
@@ -522,11 +518,13 @@ int intel_guc_setup(struct drm_i915_private *dev_priv) · 5 unmodified lines
522518 "retry %d more time(s)\n", err, retries);
523519 }
524520
525− guc_fw->guc_fw_load_status = GUC_FIRMWARE_SUCCESS;
521+ guc_fw->load_status = INTEL_UC_FIRMWARE_SUCCESS;
526522
527523 DRM_DEBUG_DRIVER("GuC fw status: fetch %s, load %s\n",
528− intel_guc_fw_status_repr(guc_fw->guc_fw_fetch_status),
529− intel_guc_fw_status_repr(guc_fw->guc_fw_load_status));
524+ intel_uc_fw_status_repr(guc_fw->fetch_status),
525+ intel_uc_fw_status_repr(guc_fw->load_status));
526+
527+ intel_guc_auth_huc(dev_priv);
530528
531529 if (i915.enable_guc_submission) {
532530 if (i915.guc_log_level >= 0)
@@ -541,12 +539,13 @@ int intel_guc_setup(struct drm_i915_private *dev_priv) · 8 unmodified lines
541539 return 0;
542540
543541 fail:
544− if (guc_fw->guc_fw_load_status == GUC_FIRMWARE_PENDING)
545− guc_fw->guc_fw_load_status = GUC_FIRMWARE_FAIL;
542+ if (guc_fw->load_status == INTEL_UC_FIRMWARE_PENDING)
543+ guc_fw->load_status = INTEL_UC_FIRMWARE_FAIL;
546544
547545 guc_interrupts_release(dev_priv);
548546 i915_guc_submission_disable(dev_priv);
549547 i915_guc_submission_fini(dev_priv);
548+ i915_ggtt_disable_guc(dev_priv);
550549
551550 /*
552551 * We've failed to load the firmware :(
@@ -587,93 +586,108 @@ fail: · 34 unmodified lines
587586 return ret;
588587 }
589588
590−static void guc_fw_fetch(struct drm_i915_private *dev_priv,
591− struct intel_guc_fw *guc_fw)
589+void intel_uc_fw_fetch(struct drm_i915_private *dev_priv,
590+ struct intel_uc_fw *uc_fw)
592591 {
593592 struct pci_dev *pdev = dev_priv->drm.pdev;
594593 struct drm_i915_gem_object *obj;
595594 const struct firmware *fw = NULL;
596− struct guc_css_header *css;
595+ struct uc_css_header *css;
597596 size_t size;
598597 int err;
599598
600− DRM_DEBUG_DRIVER("before requesting firmware: GuC fw fetch status %s\n",
601− intel_guc_fw_status_repr(guc_fw->guc_fw_fetch_status));
599+ DRM_DEBUG_DRIVER("before requesting firmware: uC fw fetch status %s\n",
600+ intel_uc_fw_status_repr(uc_fw->fetch_status));
602601
603− err = request_firmware(&fw, guc_fw->guc_fw_path, &pdev->dev);
602+ err = request_firmware(&fw, uc_fw->path, &pdev->dev);
604603 if (err)
605604 goto fail;
606605 if (!fw)
607606 goto fail;
608607
609− DRM_DEBUG_DRIVER("fetch GuC fw from %s succeeded, fw %p\n",
610− guc_fw->guc_fw_path, fw);
608+ DRM_DEBUG_DRIVER("fetch uC fw from %s succeeded, fw %p\n",
609+ uc_fw->path, fw);
611610
612611 /* Check the size of the blob before examining buffer contents */
613− if (fw->size < sizeof(struct guc_css_header)) {
612+ if (fw->size < sizeof(struct uc_css_header)) {
614613 DRM_NOTE("Firmware header is missing\n");
615614 goto fail;
616615 }
617616
618− css = (struct guc_css_header *)fw->data;
617+ css = (struct uc_css_header *)fw->data;
619618
620619 /* Firmware bits always start from header */
621− guc_fw->header_offset = 0;
622− guc_fw->header_size = (css->header_size_dw - css->modulus_size_dw -
620+ uc_fw->header_offset = 0;
621+ uc_fw->header_size = (css->header_size_dw - css->modulus_size_dw -
623622 css->key_size_dw - css->exponent_size_dw) * sizeof(u32);
624623
625− if (guc_fw->header_size != sizeof(struct guc_css_header)) {
624+ if (uc_fw->header_size != sizeof(struct uc_css_header)) {
626625 DRM_NOTE("CSS header definition mismatch\n");
627626 goto fail;
628627 }
629628
630629 /* then, uCode */
631− guc_fw->ucode_offset = guc_fw->header_offset + guc_fw->header_size;
632− guc_fw->ucode_size = (css->size_dw - css->header_size_dw) * sizeof(u32);
630+ uc_fw->ucode_offset = uc_fw->header_offset + uc_fw->header_size;
631+ uc_fw->ucode_size = (css->size_dw - css->header_size_dw) * sizeof(u32);
633632
634633 /* now RSA */
635634 if (css->key_size_dw != UOS_RSA_SCRATCH_MAX_COUNT) {
636635 DRM_NOTE("RSA key size is bad\n");
637636 goto fail;
638637 }
639− guc_fw->rsa_offset = guc_fw->ucode_offset + guc_fw->ucode_size;
640− guc_fw->rsa_size = css->key_size_dw * sizeof(u32);
638+ uc_fw->rsa_offset = uc_fw->ucode_offset + uc_fw->ucode_size;
639+ uc_fw->rsa_size = css->key_size_dw * sizeof(u32);
641640
642641 /* At least, it should have header, uCode and RSA. Size of all three. */
643− size = guc_fw->header_size + guc_fw->ucode_size + guc_fw->rsa_size;
642+ size = uc_fw->header_size + uc_fw->ucode_size + uc_fw->rsa_size;
644643 if (fw->size < size) {
645644 DRM_NOTE("Missing firmware components\n");
646645 goto fail;
647646 }
648647
649− /* Header and uCode will be loaded to WOPCM. Size of the two. */
650− size = guc_fw->header_size + guc_fw->ucode_size;
651− if (size > guc_wopcm_size(dev_priv)) {
652− DRM_NOTE("Firmware is too large to fit in WOPCM\n");
653− goto fail;
654− }
655−
656648 /*
657649 * The GuC firmware image has the version number embedded at a well-known
658650 * offset within the firmware blob; note that major / minor version are
659651 * TWO bytes each (i.e. u16), although all pointers and offsets are defined
660652 * in terms of bytes (u8).
661653 */
662− guc_fw->guc_fw_major_found = css->guc_sw_version >> 16;
663− guc_fw->guc_fw_minor_found = css->guc_sw_version & 0xFFFF;
664−
665− if (guc_fw->guc_fw_major_found != guc_fw->guc_fw_major_wanted ||
666− guc_fw->guc_fw_minor_found < guc_fw->guc_fw_minor_wanted) {
667− DRM_NOTE("GuC firmware version %d.%d, required %d.%d\n",
668− guc_fw->guc_fw_major_found, guc_fw->guc_fw_minor_found,
669− guc_fw->guc_fw_major_wanted, guc_fw->guc_fw_minor_wanted);
654+ switch (uc_fw->fw) {
655+ case INTEL_UC_FW_TYPE_GUC:
656+ /* Header and uCode will be loaded to WOPCM. Size of the two. */
657+ size = uc_fw->header_size + uc_fw->ucode_size;
658+
659+ /* Top 32k of WOPCM is reserved (8K stack + 24k RC6 context). */
660+ if (size > intel_guc_wopcm_size(dev_priv)) {
661+ DRM_ERROR("Firmware is too large to fit in WOPCM\n");
662+ goto fail;
663+ }
664+ uc_fw->major_ver_found = css->guc.sw_version >> 16;
665+ uc_fw->minor_ver_found = css->guc.sw_version & 0xFFFF;
666+ break;
667+
668+ case INTEL_UC_FW_TYPE_HUC:
669+ uc_fw->major_ver_found = css->huc.sw_version >> 16;
670+ uc_fw->minor_ver_found = css->huc.sw_version & 0xFFFF;
671+ break;
672+
673+ default:
674+ DRM_ERROR("Unknown firmware type %d\n", uc_fw->fw);
675+ err = -ENOEXEC;
676+ goto fail;
677+ }
678+
679+ if (uc_fw->major_ver_found != uc_fw->major_ver_wanted ||
680+ uc_fw->minor_ver_found < uc_fw->minor_ver_wanted) {
681+ DRM_NOTE("uC firmware version %d.%d, required %d.%d\n",
682+ uc_fw->major_ver_found, uc_fw->minor_ver_found,
683+ uc_fw->major_ver_wanted, uc_fw->minor_ver_wanted);
670684 err = -ENOEXEC;
671685 goto fail;
672686 }
673687
674688 DRM_DEBUG_DRIVER("firmware version %d.%d OK (minimum %d.%d)\n",
675− guc_fw->guc_fw_major_found, guc_fw->guc_fw_minor_found,
676− guc_fw->guc_fw_major_wanted, guc_fw->guc_fw_minor_wanted);
689+ uc_fw->major_ver_found, uc_fw->minor_ver_found,
690+ uc_fw->major_ver_wanted, uc_fw->minor_ver_wanted);
677691
678692 mutex_lock(&dev_priv->drm.struct_mutex);
679693 obj = i915_gem_object_create_from_data(dev_priv, fw->data, fw->size);
@@ -683,31 +697,31 @@ static void guc_fw_fetch(struct drm_i915_private *dev_priv, · 3 unmodified lines
683697 goto fail;
684698 }
685699
686− guc_fw->guc_fw_obj = obj;
687− guc_fw->guc_fw_size = fw->size;
700+ uc_fw->obj = obj;
701+ uc_fw->size = fw->size;
688702
689− DRM_DEBUG_DRIVER("GuC fw fetch status SUCCESS, obj %p\n",
690− guc_fw->guc_fw_obj);
703+ DRM_DEBUG_DRIVER("uC fw fetch status SUCCESS, obj %p\n",
704+ uc_fw->obj);
691705
692706 release_firmware(fw);
693− guc_fw->guc_fw_fetch_status = GUC_FIRMWARE_SUCCESS;
707+ uc_fw->fetch_status = INTEL_UC_FIRMWARE_SUCCESS;
694708 return;
695709
696710 fail:
697− DRM_WARN("Failed to fetch valid GuC firmware from %s (error %d)\n",
698− guc_fw->guc_fw_path, err);
699− DRM_DEBUG_DRIVER("GuC fw fetch status FAIL; err %d, fw %p, obj %p\n",
700− err, fw, guc_fw->guc_fw_obj);
711+ DRM_WARN("Failed to fetch valid uC firmware from %s (error %d)\n",
712+ uc_fw->path, err);
713+ DRM_DEBUG_DRIVER("uC fw fetch status FAIL; err %d, fw %p, obj %p\n",
714+ err, fw, uc_fw->obj);
701715
702716 mutex_lock(&dev_priv->drm.struct_mutex);
703− obj = guc_fw->guc_fw_obj;
717+ obj = uc_fw->obj;
704718 if (obj)
705719 i915_gem_object_put(obj);
706− guc_fw->guc_fw_obj = NULL;
720+ uc_fw->obj = NULL;
707721 mutex_unlock(&dev_priv->drm.struct_mutex);
708722
709723 release_firmware(fw); /* OK even if fw is NULL */
710− guc_fw->guc_fw_fetch_status = GUC_FIRMWARE_FAIL;
724+ uc_fw->fetch_status = INTEL_UC_FIRMWARE_FAIL;
711725 }
712726
713727 /**
@@ -721,7 +735,7 @@ fail: · 7 unmodified lines
721735 */
722736 void intel_guc_init(struct drm_i915_private *dev_priv)
723737 {
724− struct intel_guc_fw *guc_fw = &dev_priv->guc.guc_fw;
738+ struct intel_uc_fw *guc_fw = &dev_priv->guc.fw;
725739 const char *fw_path;
726740
727741 if (!HAS_GUC(dev_priv)) {
@@ -739,23 +753,23 @@ void intel_guc_init(struct drm_i915_private *dev_priv) · 11 unmodified lines
739753 fw_path = NULL;
740754 } else if (IS_SKYLAKE(dev_priv)) {
741755 fw_path = I915_SKL_GUC_UCODE;
742− guc_fw->guc_fw_major_wanted = SKL_FW_MAJOR;
743− guc_fw->guc_fw_minor_wanted = SKL_FW_MINOR;
756+ guc_fw->major_ver_wanted = SKL_FW_MAJOR;
757+ guc_fw->minor_ver_wanted = SKL_FW_MINOR;
744758 } else if (IS_BROXTON(dev_priv)) {
745759 fw_path = I915_BXT_GUC_UCODE;
746− guc_fw->guc_fw_major_wanted = BXT_FW_MAJOR;
747− guc_fw->guc_fw_minor_wanted = BXT_FW_MINOR;
760+ guc_fw->major_ver_wanted = BXT_FW_MAJOR;
761+ guc_fw->minor_ver_wanted = BXT_FW_MINOR;
748762 } else if (IS_KABYLAKE(dev_priv)) {
749763 fw_path = I915_KBL_GUC_UCODE;
750− guc_fw->guc_fw_major_wanted = KBL_FW_MAJOR;
751− guc_fw->guc_fw_minor_wanted = KBL_FW_MINOR;
764+ guc_fw->major_ver_wanted = KBL_FW_MAJOR;
765+ guc_fw->minor_ver_wanted = KBL_FW_MINOR;
752766 } else {
753767 fw_path = ""; /* unknown device */
754768 }
755769
756− guc_fw->guc_fw_path = fw_path;
757− guc_fw->guc_fw_fetch_status = GUC_FIRMWARE_NONE;
758− guc_fw->guc_fw_load_status = GUC_FIRMWARE_NONE;
770+ guc_fw->path = fw_path;
771+ guc_fw->fetch_status = INTEL_UC_FIRMWARE_NONE;
772+ guc_fw->load_status = INTEL_UC_FIRMWARE_NONE;
759773
760774 /* Early (and silent) return if GuC loading is disabled */
761775 if (!i915.enable_guc_loading)
@@ -765,9 +779,9 @@ void intel_guc_init(struct drm_i915_private *dev_priv) · 3 unmodified lines
765779 if (*fw_path == '\0')
766780 return;
767781
768− guc_fw->guc_fw_fetch_status = GUC_FIRMWARE_PENDING;
782+ guc_fw->fetch_status = INTEL_UC_FIRMWARE_PENDING;
769783 DRM_DEBUG_DRIVER("GuC firmware pending, path %s\n", fw_path);
770− guc_fw_fetch(dev_priv, guc_fw);
784+ intel_uc_fw_fetch(dev_priv, guc_fw);
771785 /* status must now be FAIL or SUCCESS */
772786 }
773787
@@ -777,17 +791,17 @@ void intel_guc_init(struct drm_i915_private *dev_priv) · 3 unmodified lines
777791 */
778792 void intel_guc_fini(struct drm_i915_private *dev_priv)
779793 {
780− struct intel_guc_fw *guc_fw = &dev_priv->guc.guc_fw;
794+ struct intel_uc_fw *guc_fw = &dev_priv->guc.fw;
781795
782796 mutex_lock(&dev_priv->drm.struct_mutex);
783797 guc_interrupts_release(dev_priv);
784798 i915_guc_submission_disable(dev_priv);
785799 i915_guc_submission_fini(dev_priv);
786800
787− if (guc_fw->guc_fw_obj)
788− i915_gem_object_put(guc_fw->guc_fw_obj);
789− guc_fw->guc_fw_obj = NULL;
801+ if (guc_fw->obj)
802+ i915_gem_object_put(guc_fw->obj);
803+ guc_fw->obj = NULL;
790804 mutex_unlock(&dev_priv->drm.struct_mutex);
791805
792− guc_fw->guc_fw_fetch_status = GUC_FIRMWARE_NONE;
806+ guc_fw->fetch_status = INTEL_UC_FIRMWARE_NONE;
793807 }
drivers/gpu/drm/i915/intel_guc_log.c+658−0
@@ -0,0 +1,658 @@
1+/*
2+ * Copyright © 2014-2017 Intel Corporation
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+ *
23+ */
24+#include <linux/debugfs.h>
25+#include <linux/relay.h>
26+#include "i915_drv.h"
27+
28+static void guc_log_capture_logs(struct intel_guc *guc);
29+
30+/**
31+ * DOC: GuC firmware log
32+ *
33+ * Firmware log is enabled by setting i915.guc_log_level to non-negative level.
34+ * Log data is printed out via reading debugfs i915_guc_log_dump. Reading from
35+ * i915_guc_load_status will print out firmware loading status and scratch
36+ * registers value.
37+ *
38+ */
39+
40+static int guc_log_flush_complete(struct intel_guc *guc)
41+{
42+ u32 action[] = {
43+ INTEL_GUC_ACTION_LOG_BUFFER_FILE_FLUSH_COMPLETE
44+ };
45+
46+ return intel_guc_send(guc, action, ARRAY_SIZE(action));
47+}
48+
49+static int guc_log_flush(struct intel_guc *guc)
50+{
51+ u32 action[] = {
52+ INTEL_GUC_ACTION_FORCE_LOG_BUFFER_FLUSH,
53+ 0
54+ };
55+
56+ return intel_guc_send(guc, action, ARRAY_SIZE(action));
57+}
58+
59+static int guc_log_control(struct intel_guc *guc, u32 control_val)
60+{
61+ u32 action[] = {
62+ INTEL_GUC_ACTION_UK_LOG_ENABLE_LOGGING,
63+ control_val
64+ };
65+
66+ return intel_guc_send(guc, action, ARRAY_SIZE(action));
67+}
68+
69+
70+/*
71+ * Sub buffer switch callback. Called whenever relay has to switch to a new
72+ * sub buffer, relay stays on the same sub buffer if 0 is returned.
73+ */
74+static int subbuf_start_callback(struct rchan_buf *buf,
75+ void *subbuf,
76+ void *prev_subbuf,
77+ size_t prev_padding)
78+{
79+ /* Use no-overwrite mode by default, where relay will stop accepting
80+ * new data if there are no empty sub buffers left.
81+ * There is no strict synchronization enforced by relay between Consumer
82+ * and Producer. In overwrite mode, there is a possibility of getting
83+ * inconsistent/garbled data, the producer could be writing on to the
84+ * same sub buffer from which Consumer is reading. This can't be avoided
85+ * unless Consumer is fast enough and can always run in tandem with
86+ * Producer.
87+ */
88+ if (relay_buf_full(buf))
89+ return 0;
90+
91+ return 1;
92+}
93+
94+/*
95+ * file_create() callback. Creates relay file in debugfs.
96+ */
97+static struct dentry *create_buf_file_callback(const char *filename,
98+ struct dentry *parent,
99+ umode_t mode,
100+ struct rchan_buf *buf,
101+ int *is_global)
102+{
103+ struct dentry *buf_file;
104+
105+ /* This to enable the use of a single buffer for the relay channel and
106+ * correspondingly have a single file exposed to User, through which
107+ * it can collect the logs in order without any post-processing.
108+ * Need to set 'is_global' even if parent is NULL for early logging.
109+ */
110+ *is_global = 1;
111+
112+ if (!parent)
113+ return NULL;
114+
115+ /* Not using the channel filename passed as an argument, since for each
116+ * channel relay appends the corresponding CPU number to the filename
117+ * passed in relay_open(). This should be fine as relay just needs a
118+ * dentry of the file associated with the channel buffer and that file's
119+ * name need not be same as the filename passed as an argument.
120+ */
121+ buf_file = debugfs_create_file("guc_log", mode,
122+ parent, buf, &relay_file_operations);
123+ return buf_file;
124+}
125+
126+/*
127+ * file_remove() default callback. Removes relay file in debugfs.
128+ */
129+static int remove_buf_file_callback(struct dentry *dentry)
130+{
131+ debugfs_remove(dentry);
132+ return 0;
133+}
134+
135+/* relay channel callbacks */
136+static struct rchan_callbacks relay_callbacks = {
137+ .subbuf_start = subbuf_start_callback,
138+ .create_buf_file = create_buf_file_callback,
139+ .remove_buf_file = remove_buf_file_callback,
140+};
141+
142+static void guc_log_remove_relay_file(struct intel_guc *guc)
143+{
144+ relay_close(guc->log.relay_chan);
145+}
146+
147+static int guc_log_create_relay_channel(struct intel_guc *guc)
148+{
149+ struct drm_i915_private *dev_priv = guc_to_i915(guc);
150+ struct rchan *guc_log_relay_chan;
151+ size_t n_subbufs, subbuf_size;
152+
153+ /* Keep the size of sub buffers same as shared log buffer */
154+ subbuf_size = guc->log.vma->obj->base.size;
155+
156+ /* Store up to 8 snapshots, which is large enough to buffer sufficient
157+ * boot time logs and provides enough leeway to User, in terms of
158+ * latency, for consuming the logs from relay. Also doesn't take
159+ * up too much memory.
160+ */
161+ n_subbufs = 8;
162+
163+ guc_log_relay_chan = relay_open(NULL, NULL, subbuf_size,
164+ n_subbufs, &relay_callbacks, dev_priv);
165+ if (!guc_log_relay_chan) {
166+ DRM_ERROR("Couldn't create relay chan for GuC logging\n");
167+ return -ENOMEM;
168+ }
169+
170+ GEM_BUG_ON(guc_log_relay_chan->subbuf_size < subbuf_size);
171+ guc->log.relay_chan = guc_log_relay_chan;
172+ return 0;
173+}
174+
175+static int guc_log_create_relay_file(struct intel_guc *guc)
176+{
177+ struct drm_i915_private *dev_priv = guc_to_i915(guc);
178+ struct dentry *log_dir;
179+ int ret;
180+
181+ /* For now create the log file in /sys/kernel/debug/dri/0 dir */
182+ log_dir = dev_priv->drm.primary->debugfs_root;
183+
184+ /* If /sys/kernel/debug/dri/0 location do not exist, then debugfs is
185+ * not mounted and so can't create the relay file.
186+ * The relay API seems to fit well with debugfs only, for availing relay
187+ * there are 3 requirements which can be met for debugfs file only in a
188+ * straightforward/clean manner :-
189+ * i) Need the associated dentry pointer of the file, while opening the
190+ * relay channel.
191+ * ii) Should be able to use 'relay_file_operations' fops for the file.
192+ * iii) Set the 'i_private' field of file's inode to the pointer of
193+ * relay channel buffer.
194+ */
195+ if (!log_dir) {
196+ DRM_ERROR("Debugfs dir not available yet for GuC log file\n");
197+ return -ENODEV;
198+ }
199+
200+ ret = relay_late_setup_files(guc->log.relay_chan, "guc_log", log_dir);
201+ if (ret) {
202+ DRM_ERROR("Couldn't associate relay chan with file %d\n", ret);
203+ return ret;
204+ }
205+
206+ return 0;
207+}
208+
209+static void guc_move_to_next_buf(struct intel_guc *guc)
210+{
211+ /* Make sure the updates made in the sub buffer are visible when
212+ * Consumer sees the following update to offset inside the sub buffer.
213+ */
214+ smp_wmb();
215+
216+ /* All data has been written, so now move the offset of sub buffer. */
217+ relay_reserve(guc->log.relay_chan, guc->log.vma->obj->base.size);
218+
219+ /* Switch to the next sub buffer */
220+ relay_flush(guc->log.relay_chan);
221+}
222+
223+static void *guc_get_write_buffer(struct intel_guc *guc)
224+{
225+ if (!guc->log.relay_chan)
226+ return NULL;
227+
228+ /* Just get the base address of a new sub buffer and copy data into it
229+ * ourselves. NULL will be returned in no-overwrite mode, if all sub
230+ * buffers are full. Could have used the relay_write() to indirectly
231+ * copy the data, but that would have been bit convoluted, as we need to
232+ * write to only certain locations inside a sub buffer which cannot be
233+ * done without using relay_reserve() along with relay_write(). So its
234+ * better to use relay_reserve() alone.
235+ */
236+ return relay_reserve(guc->log.relay_chan, 0);
237+}
238+
239+static bool guc_check_log_buf_overflow(struct intel_guc *guc,
240+ enum guc_log_buffer_type type,
241+ unsigned int full_cnt)
242+{
243+ unsigned int prev_full_cnt = guc->log.prev_overflow_count[type];
244+ bool overflow = false;
245+
246+ if (full_cnt != prev_full_cnt) {
247+ overflow = true;
248+
249+ guc->log.prev_overflow_count[type] = full_cnt;
250+ guc->log.total_overflow_count[type] += full_cnt - prev_full_cnt;
251+
252+ if (full_cnt < prev_full_cnt) {
253+ /* buffer_full_cnt is a 4 bit counter */
254+ guc->log.total_overflow_count[type] += 16;
255+ }
256+ DRM_ERROR_RATELIMITED("GuC log buffer overflow\n");
257+ }
258+
259+ return overflow;
260+}
261+
262+static unsigned int guc_get_log_buffer_size(enum guc_log_buffer_type type)
263+{
264+ switch (type) {
265+ case GUC_ISR_LOG_BUFFER:
266+ return (GUC_LOG_ISR_PAGES + 1) * PAGE_SIZE;
267+ case GUC_DPC_LOG_BUFFER:
268+ return (GUC_LOG_DPC_PAGES + 1) * PAGE_SIZE;
269+ case GUC_CRASH_DUMP_LOG_BUFFER:
270+ return (GUC_LOG_CRASH_PAGES + 1) * PAGE_SIZE;
271+ default:
272+ MISSING_CASE(type);
273+ }
274+
275+ return 0;
276+}
277+
278+static void guc_read_update_log_buffer(struct intel_guc *guc)
279+{
280+ unsigned int buffer_size, read_offset, write_offset, bytes_to_copy, full_cnt;
281+ struct guc_log_buffer_state *log_buf_state, *log_buf_snapshot_state;
282+ struct guc_log_buffer_state log_buf_state_local;
283+ enum guc_log_buffer_type type;
284+ void *src_data, *dst_data;
285+ bool new_overflow;
286+
287+ if (WARN_ON(!guc->log.buf_addr))
288+ return;
289+
290+ /* Get the pointer to shared GuC log buffer */
291+ log_buf_state = src_data = guc->log.buf_addr;
292+
293+ /* Get the pointer to local buffer to store the logs */
294+ log_buf_snapshot_state = dst_data = guc_get_write_buffer(guc);
295+
296+ /* Actual logs are present from the 2nd page */
297+ src_data += PAGE_SIZE;
298+ dst_data += PAGE_SIZE;
299+
300+ for (type = GUC_ISR_LOG_BUFFER; type < GUC_MAX_LOG_BUFFER; type++) {
301+ /* Make a copy of the state structure, inside GuC log buffer
302+ * (which is uncached mapped), on the stack to avoid reading
303+ * from it multiple times.
304+ */
305+ memcpy(&log_buf_state_local, log_buf_state,
306+ sizeof(struct guc_log_buffer_state));
307+ buffer_size = guc_get_log_buffer_size(type);
308+ read_offset = log_buf_state_local.read_ptr;
309+ write_offset = log_buf_state_local.sampled_write_ptr;
310+ full_cnt = log_buf_state_local.buffer_full_cnt;
311+
312+ /* Bookkeeping stuff */
313+ guc->log.flush_count[type] += log_buf_state_local.flush_to_file;
314+ new_overflow = guc_check_log_buf_overflow(guc, type, full_cnt);
315+
316+ /* Update the state of shared log buffer */
317+ log_buf_state->read_ptr = write_offset;
318+ log_buf_state->flush_to_file = 0;
319+ log_buf_state++;
320+
321+ if (unlikely(!log_buf_snapshot_state))
322+ continue;
323+
324+ /* First copy the state structure in snapshot buffer */
325+ memcpy(log_buf_snapshot_state, &log_buf_state_local,
326+ sizeof(struct guc_log_buffer_state));
327+
328+ /* The write pointer could have been updated by GuC firmware,
329+ * after sending the flush interrupt to Host, for consistency
330+ * set write pointer value to same value of sampled_write_ptr
331+ * in the snapshot buffer.
332+ */
333+ log_buf_snapshot_state->write_ptr = write_offset;
334+ log_buf_snapshot_state++;
335+
336+ /* Now copy the actual logs. */
337+ if (unlikely(new_overflow)) {
338+ /* copy the whole buffer in case of overflow */
339+ read_offset = 0;
340+ write_offset = buffer_size;
341+ } else if (unlikely((read_offset > buffer_size) ||
342+ (write_offset > buffer_size))) {
343+ DRM_ERROR("invalid log buffer state\n");
344+ /* copy whole buffer as offsets are unreliable */
345+ read_offset = 0;
346+ write_offset = buffer_size;
347+ }
348+
349+ /* Just copy the newly written data */
350+ if (read_offset > write_offset) {
351+ i915_memcpy_from_wc(dst_data, src_data, write_offset);
352+ bytes_to_copy = buffer_size - read_offset;
353+ } else {
354+ bytes_to_copy = write_offset - read_offset;
355+ }
356+ i915_memcpy_from_wc(dst_data + read_offset,
357+ src_data + read_offset, bytes_to_copy);
358+
359+ src_data += buffer_size;
360+ dst_data += buffer_size;
361+ }
362+
363+ if (log_buf_snapshot_state)
364+ guc_move_to_next_buf(guc);
365+ else {
366+ /* Used rate limited to avoid deluge of messages, logs might be
367+ * getting consumed by User at a slow rate.
368+ */
369+ DRM_ERROR_RATELIMITED("no sub-buffer to capture logs\n");
370+ guc->log.capture_miss_count++;
371+ }
372+}
373+
374+static void guc_log_cleanup(struct intel_guc *guc)
375+{
376+ struct drm_i915_private *dev_priv = guc_to_i915(guc);
377+
378+ lockdep_assert_held(&dev_priv->drm.struct_mutex);
379+
380+ /* First disable the flush interrupt */
381+ gen9_disable_guc_interrupts(dev_priv);
382+
383+ if (guc->log.flush_wq)
384+ destroy_workqueue(guc->log.flush_wq);
385+
386+ guc->log.flush_wq = NULL;
387+
388+ if (guc->log.relay_chan)
389+ guc_log_remove_relay_file(guc);
390+
391+ guc->log.relay_chan = NULL;
392+
393+ if (guc->log.buf_addr)
394+ i915_gem_object_unpin_map(guc->log.vma->obj);
395+
396+ guc->log.buf_addr = NULL;
397+}
398+
399+static void capture_logs_work(struct work_struct *work)
400+{
401+ struct intel_guc *guc =
402+ container_of(work, struct intel_guc, log.flush_work);
403+
404+ guc_log_capture_logs(guc);
405+}
406+
407+static int guc_log_create_extras(struct intel_guc *guc)
408+{
409+ struct drm_i915_private *dev_priv = guc_to_i915(guc);
410+ void *vaddr;
411+ int ret;
412+
413+ lockdep_assert_held(&dev_priv->drm.struct_mutex);
414+
415+ /* Nothing to do */
416+ if (i915.guc_log_level < 0)
417+ return 0;
418+
419+ if (!guc->log.buf_addr) {
420+ /* Create a WC (Uncached for read) vmalloc mapping of log
421+ * buffer pages, so that we can directly get the data
422+ * (up-to-date) from memory.
423+ */
424+ vaddr = i915_gem_object_pin_map(guc->log.vma->obj, I915_MAP_WC);
425+ if (IS_ERR(vaddr)) {
426+ ret = PTR_ERR(vaddr);
427+ DRM_ERROR("Couldn't map log buffer pages %d\n", ret);
428+ return ret;
429+ }
430+
431+ guc->log.buf_addr = vaddr;
432+ }
433+
434+ if (!guc->log.relay_chan) {
435+ /* Create a relay channel, so that we have buffers for storing
436+ * the GuC firmware logs, the channel will be linked with a file
437+ * later on when debugfs is registered.
438+ */
439+ ret = guc_log_create_relay_channel(guc);
440+ if (ret)
441+ return ret;
442+ }
443+
444+ if (!guc->log.flush_wq) {
445+ INIT_WORK(&guc->log.flush_work, capture_logs_work);
446+
447+ /*
448+ * GuC log buffer flush work item has to do register access to
449+ * send the ack to GuC and this work item, if not synced before
450+ * suspend, can potentially get executed after the GFX device is
451+ * suspended.
452+ * By marking the WQ as freezable, we don't have to bother about
453+ * flushing of this work item from the suspend hooks, the pending
454+ * work item if any will be either executed before the suspend
455+ * or scheduled later on resume. This way the handling of work
456+ * item can be kept same between system suspend & rpm suspend.
457+ */
458+ guc->log.flush_wq = alloc_ordered_workqueue("i915-guc_log",
459+ WQ_HIGHPRI | WQ_FREEZABLE);
460+ if (guc->log.flush_wq == NULL) {
461+ DRM_ERROR("Couldn't allocate the wq for GuC logging\n");
462+ return -ENOMEM;
463+ }
464+ }
465+
466+ return 0;
467+}
468+
469+void intel_guc_log_create(struct intel_guc *guc)
470+{
471+ struct i915_vma *vma;
472+ unsigned long offset;
473+ uint32_t size, flags;
474+
475+ if (i915.guc_log_level > GUC_LOG_VERBOSITY_MAX)
476+ i915.guc_log_level = GUC_LOG_VERBOSITY_MAX;
477+
478+ /* The first page is to save log buffer state. Allocate one
479+ * extra page for others in case for overlap */
480+ size = (1 + GUC_LOG_DPC_PAGES + 1 +
481+ GUC_LOG_ISR_PAGES + 1 +
482+ GUC_LOG_CRASH_PAGES + 1) << PAGE_SHIFT;
483+
484+ vma = guc->log.vma;
485+ if (!vma) {
486+ /* We require SSE 4.1 for fast reads from the GuC log buffer and
487+ * it should be present on the chipsets supporting GuC based
488+ * submisssions.
489+ */
490+ if (WARN_ON(!i915_has_memcpy_from_wc())) {
491+ /* logging will not be enabled */
492+ i915.guc_log_level = -1;
493+ return;
494+ }
495+
496+ vma = intel_guc_allocate_vma(guc, size);
497+ if (IS_ERR(vma)) {
498+ /* logging will be off */
499+ i915.guc_log_level = -1;
500+ return;
501+ }
502+
503+ guc->log.vma = vma;
504+
505+ if (guc_log_create_extras(guc)) {
506+ guc_log_cleanup(guc);
507+ i915_vma_unpin_and_release(&guc->log.vma);
508+ i915.guc_log_level = -1;
509+ return;
510+ }
511+ }
512+
513+ /* each allocated unit is a page */
514+ flags = GUC_LOG_VALID | GUC_LOG_NOTIFY_ON_HALF_FULL |
515+ (GUC_LOG_DPC_PAGES << GUC_LOG_DPC_SHIFT) |
516+ (GUC_LOG_ISR_PAGES << GUC_LOG_ISR_SHIFT) |
517+ (GUC_LOG_CRASH_PAGES << GUC_LOG_CRASH_SHIFT);
518+
519+ offset = guc_ggtt_offset(vma) >> PAGE_SHIFT; /* in pages */
520+ guc->log.flags = (offset << GUC_LOG_BUF_ADDR_SHIFT) | flags;
521+}
522+
523+static int guc_log_late_setup(struct intel_guc *guc)
524+{
525+ struct drm_i915_private *dev_priv = guc_to_i915(guc);
526+ int ret;
527+
528+ lockdep_assert_held(&dev_priv->drm.struct_mutex);
529+
530+ if (i915.guc_log_level < 0)
531+ return -EINVAL;
532+
533+ /* If log_level was set as -1 at boot time, then setup needed to
534+ * handle log buffer flush interrupts would not have been done yet,
535+ * so do that now.
536+ */
537+ ret = guc_log_create_extras(guc);
538+ if (ret)
539+ goto err;
540+
541+ ret = guc_log_create_relay_file(guc);
542+ if (ret)
543+ goto err;
544+
545+ return 0;
546+err:
547+ guc_log_cleanup(guc);
548+ /* logging will remain off */
549+ i915.guc_log_level = -1;
550+ return ret;
551+}
552+
553+static void guc_log_capture_logs(struct intel_guc *guc)
554+{
555+ struct drm_i915_private *dev_priv = guc_to_i915(guc);
556+
557+ guc_read_update_log_buffer(guc);
558+
559+ /* Generally device is expected to be active only at this
560+ * time, so get/put should be really quick.
561+ */
562+ intel_runtime_pm_get(dev_priv);
563+ guc_log_flush_complete(guc);
564+ intel_runtime_pm_put(dev_priv);
565+}
566+
567+static void guc_flush_logs(struct intel_guc *guc)
568+{
569+ struct drm_i915_private *dev_priv = guc_to_i915(guc);
570+
571+ if (!i915.enable_guc_submission || (i915.guc_log_level < 0))
572+ return;
573+
574+ /* First disable the interrupts, will be renabled afterwards */
575+ gen9_disable_guc_interrupts(dev_priv);
576+
577+ /* Before initiating the forceful flush, wait for any pending/ongoing
578+ * flush to complete otherwise forceful flush may not actually happen.
579+ */
580+ flush_work(&guc->log.flush_work);
581+
582+ /* Ask GuC to update the log buffer state */
583+ guc_log_flush(guc);
584+
585+ /* GuC would have updated log buffer by now, so capture it */
586+ guc_log_capture_logs(guc);
587+}
588+
589+int i915_guc_log_control(struct drm_i915_private *dev_priv, u64 control_val)
590+{
591+ struct intel_guc *guc = &dev_priv->guc;
592+
593+ union guc_log_control log_param;
594+ int ret;
595+
596+ log_param.value = control_val;
597+
598+ if (log_param.verbosity < GUC_LOG_VERBOSITY_MIN ||
599+ log_param.verbosity > GUC_LOG_VERBOSITY_MAX)
600+ return -EINVAL;
601+
602+ /* This combination doesn't make sense & won't have any effect */
603+ if (!log_param.logging_enabled && (i915.guc_log_level < 0))
604+ return 0;
605+
606+ ret = guc_log_control(guc, log_param.value);
607+ if (ret < 0) {
608+ DRM_DEBUG_DRIVER("guc_logging_control action failed %d\n", ret);
609+ return ret;
610+ }
611+
612+ i915.guc_log_level = log_param.verbosity;
613+
614+ /* If log_level was set as -1 at boot time, then the relay channel file
615+ * wouldn't have been created by now and interrupts also would not have
616+ * been enabled.
617+ */
618+ if (!dev_priv->guc.log.relay_chan) {
619+ ret = guc_log_late_setup(guc);
620+ if (!ret)
621+ gen9_enable_guc_interrupts(dev_priv);
622+ } else if (!log_param.logging_enabled) {
623+ /* Once logging is disabled, GuC won't generate logs & send an
624+ * interrupt. But there could be some data in the log buffer
625+ * which is yet to be captured. So request GuC to update the log
626+ * buffer state and then collect the left over logs.
627+ */
628+ guc_flush_logs(guc);
629+
630+ /* As logging is disabled, update log level to reflect that */
631+ i915.guc_log_level = -1;
632+ } else {
633+ /* In case interrupts were disabled, enable them now */
634+ gen9_enable_guc_interrupts(dev_priv);
635+ }
636+
637+ return ret;
638+}
639+
640+void i915_guc_log_register(struct drm_i915_private *dev_priv)
641+{
642+ if (!i915.enable_guc_submission)
643+ return;
644+
645+ mutex_lock(&dev_priv->drm.struct_mutex);
646+ guc_log_late_setup(&dev_priv->guc);
647+ mutex_unlock(&dev_priv->drm.struct_mutex);
648+}
649+
650+void i915_guc_log_unregister(struct drm_i915_private *dev_priv)
651+{
652+ if (!i915.enable_guc_submission)
653+ return;
654+
655+ mutex_lock(&dev_priv->drm.struct_mutex);
656+ guc_log_cleanup(&dev_priv->guc);
657+ mutex_unlock(&dev_priv->drm.struct_mutex);
658+}
drivers/gpu/drm/i915/intel_huc.c+338−0
@@ -0,0 +1,338 @@
1+/*
2+ * Copyright © 2016-2017 Intel Corporation
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+ *
23+ */
24+#include <linux/firmware.h>
25+#include "i915_drv.h"
26+#include "intel_uc.h"
27+
28+/**
29+ * DOC: HuC Firmware
30+ *
31+ * Motivation:
32+ * GEN9 introduces a new dedicated firmware for usage in media HEVC (High
33+ * Efficiency Video Coding) operations. Userspace can use the firmware
34+ * capabilities by adding HuC specific commands to batch buffers.
35+ *
36+ * Implementation:
37+ * The same firmware loader is used as the GuC. However, the actual
38+ * loading to HW is deferred until GEM initialization is done.
39+ *
40+ * Note that HuC firmware loading must be done before GuC loading.
41+ */
42+
43+#define BXT_HUC_FW_MAJOR 01
44+#define BXT_HUC_FW_MINOR 07
45+#define BXT_BLD_NUM 1398
46+
47+#define SKL_HUC_FW_MAJOR 01
48+#define SKL_HUC_FW_MINOR 07
49+#define SKL_BLD_NUM 1398
50+
51+#define KBL_HUC_FW_MAJOR 02
52+#define KBL_HUC_FW_MINOR 00
53+#define KBL_BLD_NUM 1810
54+
55+#define HUC_FW_PATH(platform, major, minor, bld_num) \
56+ "i915/" __stringify(platform) "_huc_ver" __stringify(major) "_" \
57+ __stringify(minor) "_" __stringify(bld_num) ".bin"
58+
59+#define I915_SKL_HUC_UCODE HUC_FW_PATH(skl, SKL_HUC_FW_MAJOR, \
60+ SKL_HUC_FW_MINOR, SKL_BLD_NUM)
61+MODULE_FIRMWARE(I915_SKL_HUC_UCODE);
62+
63+#define I915_BXT_HUC_UCODE HUC_FW_PATH(bxt, BXT_HUC_FW_MAJOR, \
64+ BXT_HUC_FW_MINOR, BXT_BLD_NUM)
65+MODULE_FIRMWARE(I915_BXT_HUC_UCODE);
66+
67+#define I915_KBL_HUC_UCODE HUC_FW_PATH(kbl, KBL_HUC_FW_MAJOR, \
68+ KBL_HUC_FW_MINOR, KBL_BLD_NUM)
69+MODULE_FIRMWARE(I915_KBL_HUC_UCODE);
70+
71+/**
72+ * huc_ucode_xfer() - DMA's the firmware
73+ * @dev_priv: the drm_i915_private device
74+ *
75+ * Transfer the firmware image to RAM for execution by the microcontroller.
76+ *
77+ * Return: 0 on success, non-zero on failure
78+ */
79+static int huc_ucode_xfer(struct drm_i915_private *dev_priv)
80+{
81+ struct intel_uc_fw *huc_fw = &dev_priv->huc.fw;
82+ struct i915_vma *vma;
83+ unsigned long offset = 0;
84+ u32 size;
85+ int ret;
86+
87+ ret = i915_gem_object_set_to_gtt_domain(huc_fw->obj, false);
88+ if (ret) {
89+ DRM_DEBUG_DRIVER("set-domain failed %d\n", ret);
90+ return ret;
91+ }
92+
93+ vma = i915_gem_object_ggtt_pin(huc_fw->obj, NULL, 0, 0,
94+ PIN_OFFSET_BIAS | GUC_WOPCM_TOP);
95+ if (IS_ERR(vma)) {
96+ DRM_DEBUG_DRIVER("pin failed %d\n", (int)PTR_ERR(vma));
97+ return PTR_ERR(vma);
98+ }
99+
100+ intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
101+
102+ /* init WOPCM */
103+ I915_WRITE(GUC_WOPCM_SIZE, intel_guc_wopcm_size(dev_priv));
104+ I915_WRITE(DMA_GUC_WOPCM_OFFSET, GUC_WOPCM_OFFSET_VALUE |
105+ HUC_LOADING_AGENT_GUC);
106+
107+ /* Set the source address for the uCode */
108+ offset = guc_ggtt_offset(vma) + huc_fw->header_offset;
109+ I915_WRITE(DMA_ADDR_0_LOW, lower_32_bits(offset));
110+ I915_WRITE(DMA_ADDR_0_HIGH, upper_32_bits(offset) & 0xFFFF);
111+
112+ /* Hardware doesn't look at destination address for HuC. Set it to 0,
113+ * but still program the correct address space.
114+ */
115+ I915_WRITE(DMA_ADDR_1_LOW, 0);
116+ I915_WRITE(DMA_ADDR_1_HIGH, DMA_ADDRESS_SPACE_WOPCM);
117+
118+ size = huc_fw->header_size + huc_fw->ucode_size;
119+ I915_WRITE(DMA_COPY_SIZE, size);
120+
121+ /* Start the DMA */
122+ I915_WRITE(DMA_CTRL, _MASKED_BIT_ENABLE(HUC_UKERNEL | START_DMA));
123+
124+ /* Wait for DMA to finish */
125+ ret = wait_for((I915_READ(DMA_CTRL) & START_DMA) == 0, 100);
126+
127+ DRM_DEBUG_DRIVER("HuC DMA transfer wait over with ret %d\n", ret);
128+
129+ /* Disable the bits once DMA is over */
130+ I915_WRITE(DMA_CTRL, _MASKED_BIT_DISABLE(HUC_UKERNEL));
131+
132+ intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
133+
134+ /*
135+ * We keep the object pages for reuse during resume. But we can unpin it
136+ * now that DMA has completed, so it doesn't continue to take up space.
137+ */
138+ i915_vma_unpin(vma);
139+
140+ return ret;
141+}
142+
143+/**
144+ * intel_huc_init() - initiate HuC firmware loading request
145+ * @dev_priv: the drm_i915_private device
146+ *
147+ * Called early during driver load, but after GEM is initialised. The loading
148+ * will continue only when driver explicitly specify firmware name and version.
149+ * All other cases are considered as INTEL_UC_FIRMWARE_NONE either because HW
150+ * is not capable or driver yet support it. And there will be no error message
151+ * for INTEL_UC_FIRMWARE_NONE cases.
152+ *
153+ * The DMA-copying to HW is done later when intel_huc_load() is called.
154+ */
155+void intel_huc_init(struct drm_i915_private *dev_priv)
156+{
157+ struct intel_huc *huc = &dev_priv->huc;
158+ struct intel_uc_fw *huc_fw = &huc->fw;
159+ const char *fw_path = NULL;
160+
161+ huc_fw->path = NULL;
162+ huc_fw->fetch_status = INTEL_UC_FIRMWARE_NONE;
163+ huc_fw->load_status = INTEL_UC_FIRMWARE_NONE;
164+ huc_fw->fw = INTEL_UC_FW_TYPE_HUC;
165+
166+ if (!HAS_HUC_UCODE(dev_priv))
167+ return;
168+
169+ if (IS_SKYLAKE(dev_priv)) {
170+ fw_path = I915_SKL_HUC_UCODE;
171+ huc_fw->major_ver_wanted = SKL_HUC_FW_MAJOR;
172+ huc_fw->minor_ver_wanted = SKL_HUC_FW_MINOR;
173+ } else if (IS_BROXTON(dev_priv)) {
174+ fw_path = I915_BXT_HUC_UCODE;
175+ huc_fw->major_ver_wanted = BXT_HUC_FW_MAJOR;
176+ huc_fw->minor_ver_wanted = BXT_HUC_FW_MINOR;
177+ } else if (IS_KABYLAKE(dev_priv)) {
178+ fw_path = I915_KBL_HUC_UCODE;
179+ huc_fw->major_ver_wanted = KBL_HUC_FW_MAJOR;
180+ huc_fw->minor_ver_wanted = KBL_HUC_FW_MINOR;
181+ }
182+
183+ huc_fw->path = fw_path;
184+ huc_fw->fetch_status = INTEL_UC_FIRMWARE_PENDING;
185+
186+ DRM_DEBUG_DRIVER("HuC firmware pending, path %s\n", fw_path);
187+
188+ WARN(huc_fw->path == NULL, "HuC present but no fw path\n");
189+
190+ intel_uc_fw_fetch(dev_priv, huc_fw);
191+}
192+
193+/**
194+ * intel_huc_load() - load HuC uCode to device
195+ * @dev_priv: the drm_i915_private device
196+ *
197+ * Called from guc_setup() during driver loading and also after a GPU reset.
198+ * Be note that HuC loading must be done before GuC loading.
199+ *
200+ * The firmware image should have already been fetched into memory by the
201+ * earlier call to intel_huc_init(), so here we need only check that
202+ * is succeeded, and then transfer the image to the h/w.
203+ *
204+ * Return: non-zero code on error
205+ */
206+int intel_huc_load(struct drm_i915_private *dev_priv)
207+{
208+ struct intel_uc_fw *huc_fw = &dev_priv->huc.fw;
209+ int err;
210+
211+ if (huc_fw->fetch_status == INTEL_UC_FIRMWARE_NONE)
212+ return 0;
213+
214+ DRM_DEBUG_DRIVER("%s fw status: fetch %s, load %s\n",
215+ huc_fw->path,
216+ intel_uc_fw_status_repr(huc_fw->fetch_status),
217+ intel_uc_fw_status_repr(huc_fw->load_status));
218+
219+ if (huc_fw->fetch_status == INTEL_UC_FIRMWARE_SUCCESS &&
220+ huc_fw->load_status == INTEL_UC_FIRMWARE_FAIL)
221+ return -ENOEXEC;
222+
223+ huc_fw->load_status = INTEL_UC_FIRMWARE_PENDING;
224+
225+ switch (huc_fw->fetch_status) {
226+ case INTEL_UC_FIRMWARE_FAIL:
227+ /* something went wrong :( */
228+ err = -EIO;
229+ goto fail;
230+
231+ case INTEL_UC_FIRMWARE_NONE:
232+ case INTEL_UC_FIRMWARE_PENDING:
233+ default:
234+ /* "can't happen" */
235+ WARN_ONCE(1, "HuC fw %s invalid fetch_status %s [%d]\n",
236+ huc_fw->path,
237+ intel_uc_fw_status_repr(huc_fw->fetch_status),
238+ huc_fw->fetch_status);
239+ err = -ENXIO;
240+ goto fail;
241+
242+ case INTEL_UC_FIRMWARE_SUCCESS:
243+ break;
244+ }
245+
246+ err = huc_ucode_xfer(dev_priv);
247+ if (err)
248+ goto fail;
249+
250+ huc_fw->load_status = INTEL_UC_FIRMWARE_SUCCESS;
251+
252+ DRM_DEBUG_DRIVER("%s fw status: fetch %s, load %s\n",
253+ huc_fw->path,
254+ intel_uc_fw_status_repr(huc_fw->fetch_status),
255+ intel_uc_fw_status_repr(huc_fw->load_status));
256+
257+ return 0;
258+
259+fail:
260+ if (huc_fw->load_status == INTEL_UC_FIRMWARE_PENDING)
261+ huc_fw->load_status = INTEL_UC_FIRMWARE_FAIL;
262+
263+ DRM_ERROR("Failed to complete HuC uCode load with ret %d\n", err);
264+
265+ return err;
266+}
267+
268+/**
269+ * intel_huc_fini() - clean up resources allocated for HuC
270+ * @dev_priv: the drm_i915_private device
271+ *
272+ * Cleans up by releasing the huc firmware GEM obj.
273+ */
274+void intel_huc_fini(struct drm_i915_private *dev_priv)
275+{
276+ struct intel_uc_fw *huc_fw = &dev_priv->huc.fw;
277+
278+ mutex_lock(&dev_priv->drm.struct_mutex);
279+ if (huc_fw->obj)
280+ i915_gem_object_put(huc_fw->obj);
281+ huc_fw->obj = NULL;
282+ mutex_unlock(&dev_priv->drm.struct_mutex);
283+
284+ huc_fw->fetch_status = INTEL_UC_FIRMWARE_NONE;
285+}
286+
287+/**
288+ * intel_guc_auth_huc() - authenticate ucode
289+ * @dev_priv: the drm_i915_device
290+ *
291+ * Triggers a HuC fw authentication request to the GuC via intel_guc_action_
292+ * authenticate_huc interface.
293+ */
294+void intel_guc_auth_huc(struct drm_i915_private *dev_priv)
295+{
296+ struct intel_guc *guc = &dev_priv->guc;
297+ struct intel_huc *huc = &dev_priv->huc;
298+ struct i915_vma *vma;
299+ int ret;
300+ u32 data[2];
301+
302+ if (huc->fw.load_status != INTEL_UC_FIRMWARE_SUCCESS)
303+ return;
304+
305+ vma = i915_gem_object_ggtt_pin(huc->fw.obj, NULL, 0, 0,
306+ PIN_OFFSET_BIAS | GUC_WOPCM_TOP);
307+ if (IS_ERR(vma)) {
308+ DRM_ERROR("failed to pin huc fw object %d\n",
309+ (int)PTR_ERR(vma));
310+ return;
311+ }
312+
313+ /* Specify auth action and where public signature is. */
314+ data[0] = INTEL_GUC_ACTION_AUTHENTICATE_HUC;
315+ data[1] = guc_ggtt_offset(vma) + huc->fw.rsa_offset;
316+
317+ ret = intel_guc_send(guc, data, ARRAY_SIZE(data));
318+ if (ret) {
319+ DRM_ERROR("HuC: GuC did not ack Auth request %d\n", ret);
320+ goto out;
321+ }
322+
323+ /* Check authentication status, it should be done by now */
324+ ret = intel_wait_for_register(dev_priv,
325+ HUC_STATUS2,
326+ HUC_FW_VERIFIED,
327+ HUC_FW_VERIFIED,
328+ 50);
329+
330+ if (ret) {
331+ DRM_ERROR("HuC: Authentication failed %d\n", ret);
332+ goto out;
333+ }
334+
335+out:
336+ i915_vma_unpin(vma);
337+}
338+
drivers/gpu/drm/i915/intel_lrc.c+6−18
@@ -811,12 +811,6 @@ static int execlists_context_pin(struct intel_engine_cs *engine, · 810 unmodified lines
811811
812812 ce->state->obj->mm.dirty = true;
813813
814− /* Invalidate GuC TLB. */
815− if (i915.enable_guc_submission) {
816− struct drm_i915_private *dev_priv = ctx->i915;
817− I915_WRITE(GEN8_GTCR, GEN8_GTCR_INVALIDATE);
818− }
819−
820814 i915_gem_context_get(ctx);
821815 return 0;
822816
@@ -1231,7 +1225,7 @@ static int lrc_setup_wa_ctx_obj(struct intel_engine_cs *engine, u32 size) · 408 unmodified lines
12311225 if (IS_ERR(obj))
12321226 return PTR_ERR(obj);
12331227
1234− vma = i915_vma_create(obj, &engine->i915->ggtt.base, NULL);
1228+ vma = i915_vma_instance(obj, &engine->i915->ggtt.base, NULL);
12351229 if (IS_ERR(vma)) {
12361230 err = PTR_ERR(vma);
12371231 goto err;
@@ -1917,7 +1911,7 @@ int logical_render_ring_init(struct intel_engine_cs *engine) · 679 unmodified lines
19171911 engine->emit_breadcrumb = gen8_emit_breadcrumb_render;
19181912 engine->emit_breadcrumb_sz = gen8_emit_breadcrumb_render_sz;
19191913
1920− ret = intel_engine_create_scratch(engine, 4096);
1914+ ret = intel_engine_create_scratch(engine, PAGE_SIZE);
19211915 if (ret)
19221916 return ret;
19231917
@@ -2093,19 +2087,12 @@ static void execlists_init_reg_state(u32 *reg_state, · 169 unmodified lines
20932087 ASSIGN_CTX_REG(reg_state, CTX_PDP0_LDW, GEN8_RING_PDP_LDW(engine, 0),
20942088 0);
20952089
2096− if (USES_FULL_48BIT_PPGTT(ppgtt->base.dev)) {
2090+ if (ppgtt && USES_FULL_48BIT_PPGTT(ppgtt->base.dev)) {
20972091 /* 64b PPGTT (48bit canonical)
20982092 * PDP0_DESCRIPTOR contains the base address to PML4 and
20992093 * other PDP Descriptors are ignored.
21002094 */
21012095 ASSIGN_CTX_PML4(ppgtt, reg_state);
2102− } else {
2103− /* 32b PPGTT
2104− * PDP*_DESCRIPTOR contains the base address of space supported.
2105− * With dynamic page allocation, PDPs may not be allocated at
2106− * this point. Point the unallocated PDPs to the scratch page
2107− */
2108− execlists_update_context_pdps(ppgtt, reg_state);
21092096 }
21102097
21112098 if (engine->id == RCS) {
@@ -2199,7 +2186,8 @@ static int execlists_context_deferred_alloc(struct i915_gem_context *ctx, · 87 unmodified lines
21992186
22002187 WARN_ON(ce->state);
22012188
2202− context_size = round_up(intel_lr_context_size(engine), 4096);
2189+ context_size = round_up(intel_lr_context_size(engine),
2190+ I915_GTT_PAGE_SIZE);
22032191
22042192 /* One extra page as the sharing data between driver and GuC */
22052193 context_size += PAGE_SIZE * LRC_PPHWSP_PN;
@@ -2210,7 +2198,7 @@ static int execlists_context_deferred_alloc(struct i915_gem_context *ctx, · 4 unmodified lines
22102198 return PTR_ERR(ctx_obj);
22112199 }
22122200
2213− vma = i915_vma_create(ctx_obj, &ctx->i915->ggtt.base, NULL);
2201+ vma = i915_vma_instance(ctx_obj, &ctx->i915->ggtt.base, NULL);
22142202 if (IS_ERR(vma)) {
22152203 ret = PTR_ERR(vma);
22162204 goto error_deref_obj;
drivers/gpu/drm/i915/intel_lrc.h+1−1
@@ -26,7 +26,7 @@ · 25 unmodified lines
2626
2727 #include "intel_ringbuffer.h"
2828
29−#define GEN8_LR_CONTEXT_ALIGN 4096
29+#define GEN8_LR_CONTEXT_ALIGN I915_GTT_MIN_ALIGNMENT
3030
3131 /* Execlists regs */
3232 #define RING_ELSP(engine) _MMIO((engine)->mmio_base + 0x230)
drivers/gpu/drm/i915/intel_overlay.c+1−2
@@ -811,8 +811,7 @@ static int intel_overlay_do_put_image(struct intel_overlay *overlay, · 810 unmodified lines
811811 if (ret != 0)
812812 return ret;
813813
814− vma = i915_gem_object_pin_to_display_plane(new_bo, 0,
815− &i915_ggtt_view_normal);
814+ vma = i915_gem_object_pin_to_display_plane(new_bo, 0, NULL);
816815 if (IS_ERR(vma))
817816 return PTR_ERR(vma);
818817
drivers/gpu/drm/i915/intel_pipe_crc.c+88−16
@@ -560,14 +560,14 @@ static void hsw_trans_edp_pipe_A_crc_wa(struct drm_i915_private *dev_priv, · 559 unmodified lines
560560 state = drm_atomic_state_alloc(dev);
561561 if (!state) {
562562 ret = -ENOMEM;
563− goto out;
563+ goto unlock;
564564 }
565565
566566 state->acquire_ctx = drm_modeset_legacy_acquire_ctx(&crtc->base);
567567 pipe_config = intel_atomic_get_crtc_state(state, crtc);
568568 if (IS_ERR(pipe_config)) {
569569 ret = PTR_ERR(pipe_config);
570− goto out;
570+ goto put_state;
571571 }
572572
573573 pipe_config->pch_pfit.force_thru = enable;
@@ -576,10 +576,12 @@ static void hsw_trans_edp_pipe_A_crc_wa(struct drm_i915_private *dev_priv, · 2 unmodified lines
576576 pipe_config->base.connectors_changed = true;
577577
578578 ret = drm_atomic_commit(state);
579−out:
579+
580+put_state:
581+ drm_atomic_state_put(state);
582+unlock:
580583 WARN(ret, "Toggling workaround to %i returns %i\n", enable, ret);
581584 drm_modeset_unlock_all(dev);
582− drm_atomic_state_put(state);
583585 }
584586
585587 static int ivb_pipe_crc_ctl_reg(struct drm_i915_private *dev_priv,
@@ -613,6 +615,22 @@ static int ivb_pipe_crc_ctl_reg(struct drm_i915_private *dev_priv, · 27 unmodified lines
613615 return 0;
614616 }
615617
618+static int get_new_crc_ctl_reg(struct drm_i915_private *dev_priv,
619+ enum pipe pipe,
620+ enum intel_pipe_crc_source *source, u32 *val)
621+{
622+ if (IS_GEN2(dev_priv))
623+ return i8xx_pipe_crc_ctl_reg(source, val);
624+ else if (INTEL_GEN(dev_priv) < 5)
625+ return i9xx_pipe_crc_ctl_reg(dev_priv, pipe, source, val);
626+ else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
627+ return vlv_pipe_crc_ctl_reg(dev_priv, pipe, source, val);
628+ else if (IS_GEN5(dev_priv) || IS_GEN6(dev_priv))
629+ return ilk_pipe_crc_ctl_reg(source, val);
630+ else
631+ return ivb_pipe_crc_ctl_reg(dev_priv, pipe, source, val);
632+}
633+
616634 static int pipe_crc_set_source(struct drm_i915_private *dev_priv,
617635 enum pipe pipe,
618636 enum intel_pipe_crc_source source)
@@ -636,17 +654,7 @@ static int pipe_crc_set_source(struct drm_i915_private *dev_priv, · 17 unmodified lines
636654 return -EIO;
637655 }
638656
639− if (IS_GEN2(dev_priv))
640− ret = i8xx_pipe_crc_ctl_reg(&source, &val);
641− else if (INTEL_GEN(dev_priv) < 5)
642− ret = i9xx_pipe_crc_ctl_reg(dev_priv, pipe, &source, &val);
643− else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
644− ret = vlv_pipe_crc_ctl_reg(dev_priv, pipe, &source, &val);
645− else if (IS_GEN5(dev_priv) || IS_GEN6(dev_priv))
646− ret = ilk_pipe_crc_ctl_reg(&source, &val);
647− else
648− ret = ivb_pipe_crc_ctl_reg(dev_priv, pipe, &source, &val);
649−
657+ ret = get_new_crc_ctl_reg(dev_priv, pipe, &source, &val);
650658 if (ret != 0)
651659 goto out;
652660
@@ -687,7 +695,7 @@ static int pipe_crc_set_source(struct drm_i915_private *dev_priv, · 34 unmodified lines
687695 POSTING_READ(PIPE_CRC_CTL(pipe));
688696
689697 /* real source -> none transition */
690− if (source == INTEL_PIPE_CRC_SOURCE_NONE) {
698+ if (!source) {
691699 struct intel_pipe_crc_entry *entries;
692700 struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv,
693701 pipe);
@@ -809,6 +817,11 @@ display_crc_ctl_parse_source(const char *buf, enum intel_pipe_crc_source *s) · 115 unmodified lines
809817 {
810818 int i;
811819
820+ if (!buf) {
821+ *s = INTEL_PIPE_CRC_SOURCE_NONE;
822+ return 0;
823+ }
824+
812825 for (i = 0; i < ARRAY_SIZE(pipe_crc_sources); i++)
813826 if (!strcmp(buf, pipe_crc_sources[i])) {
814827 *s = i;
@@ -937,3 +950,62 @@ void intel_pipe_crc_cleanup(struct drm_minor *minor) · 122 unmodified lines
937950 drm_debugfs_remove_files(info_list, 1, minor);
938951 }
939952 }
953+
954+int intel_crtc_set_crc_source(struct drm_crtc *crtc, const char *source_name,
955+ size_t *values_cnt)
956+{
957+ struct drm_i915_private *dev_priv = crtc->dev->dev_private;
958+ struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[crtc->index];
959+ struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
960+ enum intel_display_power_domain power_domain;
961+ enum intel_pipe_crc_source source;
962+ u32 val = 0; /* shut up gcc */
963+ int ret = 0;
964+
965+ if (display_crc_ctl_parse_source(source_name, &source) < 0) {
966+ DRM_DEBUG_DRIVER("unknown source %s\n", source_name);
967+ return -EINVAL;
968+ }
969+
970+ power_domain = POWER_DOMAIN_PIPE(crtc->index);
971+ if (!intel_display_power_get_if_enabled(dev_priv, power_domain)) {
972+ DRM_DEBUG_KMS("Trying to capture CRC while pipe is off\n");
973+ return -EIO;
974+ }
975+
976+ ret = get_new_crc_ctl_reg(dev_priv, crtc->index, &source, &val);
977+ if (ret != 0)
978+ goto out;
979+
980+ if (source) {
981+ /*
982+ * When IPS gets enabled, the pipe CRC changes. Since IPS gets
983+ * enabled and disabled dynamically based on package C states,
984+ * user space can't make reliable use of the CRCs, so let's just
985+ * completely disable it.
986+ */
987+ hsw_disable_ips(intel_crtc);
988+ }
989+
990+ I915_WRITE(PIPE_CRC_CTL(crtc->index), val);
991+ POSTING_READ(PIPE_CRC_CTL(crtc->index));
992+
993+ if (!source) {
994+ if (IS_G4X(dev_priv))
995+ g4x_undo_pipe_scramble_reset(dev_priv, crtc->index);
996+ else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
997+ vlv_undo_pipe_scramble_reset(dev_priv, crtc->index);
998+ else if (IS_HASWELL(dev_priv) && crtc->index == PIPE_A)
999+ hsw_trans_edp_pipe_A_crc_wa(dev_priv, false);
1000+
1001+ hsw_enable_ips(intel_crtc);
1002+ }
1003+
1004+ pipe_crc->skipped = 0;
1005+ *values_cnt = 5;
1006+
1007+out:
1008+ intel_display_power_put(dev_priv, power_domain);
1009+
1010+ return ret;
1011+}
drivers/gpu/drm/i915/intel_psr.c+160−43
@@ -122,13 +122,26 @@ static void vlv_psr_setup_vsc(struct intel_dp *intel_dp) · 121 unmodified lines
122122 static void skl_psr_setup_su_vsc(struct intel_dp *intel_dp)
123123 {
124124 struct edp_vsc_psr psr_vsc;
125+ struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
126+ struct drm_device *dev = intel_dig_port->base.base.dev;
127+ struct drm_i915_private *dev_priv = to_i915(dev);
125128
126129 /* Prepare VSC Header for SU as per EDP 1.4 spec, Table 6.11 */
127130 memset(&psr_vsc, 0, sizeof(psr_vsc));
128131 psr_vsc.sdp_header.HB0 = 0;
129132 psr_vsc.sdp_header.HB1 = 0x7;
130− psr_vsc.sdp_header.HB2 = 0x3;
131− psr_vsc.sdp_header.HB3 = 0xb;
133+ if (dev_priv->psr.colorimetry_support &&
134+ dev_priv->psr.y_cord_support) {
135+ psr_vsc.sdp_header.HB2 = 0x5;
136+ psr_vsc.sdp_header.HB3 = 0x13;
137+ } else if (dev_priv->psr.y_cord_support) {
138+ psr_vsc.sdp_header.HB2 = 0x4;
139+ psr_vsc.sdp_header.HB3 = 0xe;
140+ } else {
141+ psr_vsc.sdp_header.HB2 = 0x3;
142+ psr_vsc.sdp_header.HB3 = 0xc;
143+ }
144+
132145 intel_psr_write_vsc(intel_dp, &psr_vsc);
133146 }
134147
@@ -196,7 +209,11 @@ static void hsw_psr_enable_sink(struct intel_dp *intel_dp) · 61 unmodified lines
196209 drm_dp_dpcd_writeb(&intel_dp->aux,
197210 DP_SINK_DEVICE_AUX_FRAME_SYNC_CONF,
198211 DP_AUX_FRAME_SYNC_ENABLE);
199−
212+ /* Enable ALPM at sink for psr2 */
213+ if (dev_priv->psr.psr2_support && dev_priv->psr.alpm)
214+ drm_dp_dpcd_writeb(&intel_dp->aux,
215+ DP_RECEIVER_ALPM_CONFIG,
216+ DP_ALPM_ENABLE);
200217 if (dev_priv->psr.link_standby)
201218 drm_dp_dpcd_writeb(&intel_dp->aux, DP_PSR_EN_CFG,
202219 DP_PSR_ENABLE | DP_PSR_MAIN_LINK_ACTIVE);
@@ -248,7 +265,7 @@ static void vlv_psr_activate(struct intel_dp *intel_dp) · 45 unmodified lines
248265 VLV_EDP_PSR_ACTIVE_ENTRY);
249266 }
250267
251−static void hsw_psr_enable_source(struct intel_dp *intel_dp)
268+static void intel_enable_source_psr1(struct intel_dp *intel_dp)
252269 {
253270 struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
254271 struct drm_device *dev = dig_port->base.base.dev;
@@ -299,14 +316,31 @@ static void hsw_psr_enable_source(struct intel_dp *intel_dp) · 44 unmodified lines
299316 val |= EDP_PSR_TP1_TP2_SEL;
300317
301318 I915_WRITE(EDP_PSR_CTL, val);
319+}
302320
303− if (!dev_priv->psr.psr2_support)
304− return;
321+static void intel_enable_source_psr2(struct intel_dp *intel_dp)
322+{
323+ struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
324+ struct drm_device *dev = dig_port->base.base.dev;
325+ struct drm_i915_private *dev_priv = to_i915(dev);
326+ /*
327+ * Let's respect VBT in case VBT asks a higher idle_frame value.
328+ * Let's use 6 as the minimum to cover all known cases including
329+ * the off-by-one issue that HW has in some cases. Also there are
330+ * cases where sink should be able to train
331+ * with the 5 or 6 idle patterns.
332+ */
333+ uint32_t idle_frames = max(6, dev_priv->vbt.psr.idle_frames);
334+ uint32_t val;
335+
336+ val = idle_frames << EDP_PSR_IDLE_FRAME_SHIFT;
305337
306338 /* FIXME: selective update is probably totally broken because it doesn't
307339 * mesh at all with our frontbuffer tracking. And the hw alone isn't
308340 * good enough. */
309− val = EDP_PSR2_ENABLE | EDP_SU_TRACK_ENABLE;
341+ val |= EDP_PSR2_ENABLE |
342+ EDP_SU_TRACK_ENABLE |
343+ EDP_FRAMES_BEFORE_SU_ENTRY;
310344
311345 if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 5)
312346 val |= EDP_PSR2_TP2_TIME_2500;
@@ -320,6 +354,19 @@ static void hsw_psr_enable_source(struct intel_dp *intel_dp) · 7 unmodified lines
320354 I915_WRITE(EDP_PSR2_CTL, val);
321355 }
322356
357+static void hsw_psr_enable_source(struct intel_dp *intel_dp)
358+{
359+ struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
360+ struct drm_device *dev = dig_port->base.base.dev;
361+ struct drm_i915_private *dev_priv = to_i915(dev);
362+
363+ /* psr1 and psr2 are mutually exclusive.*/
364+ if (dev_priv->psr.psr2_support)
365+ intel_enable_source_psr2(intel_dp);
366+ else
367+ intel_enable_source_psr1(intel_dp);
368+}
369+
323370 static bool intel_psr_match_conditions(struct intel_dp *intel_dp)
324371 {
325372 struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
@@ -387,6 +434,22 @@ static bool intel_psr_match_conditions(struct intel_dp *intel_dp) · 61 unmodified lines
387434 return false;
388435 }
389436
437+ /* PSR2 is restricted to work with panel resolutions upto 3200x2000 */
438+ if (intel_crtc->config->pipe_src_w > 3200 ||
439+ intel_crtc->config->pipe_src_h > 2000) {
440+ dev_priv->psr.psr2_support = false;
441+ return false;
442+ }
443+
444+ /*
445+ * FIXME:enable psr2 only for y-cordinate psr2 panels
446+ * After gtc implementation , remove this restriction.
447+ */
448+ if (!dev_priv->psr.y_cord_support && dev_priv->psr.psr2_support) {
449+ DRM_DEBUG_KMS("PSR2 disabled, panel does not support Y coordinate\n");
450+ return false;
451+ }
452+
390453 dev_priv->psr.source_ok = true;
391454 return true;
392455 }
@@ -397,7 +460,10 @@ static void intel_psr_activate(struct intel_dp *intel_dp) · 4 unmodified lines
397460 struct drm_device *dev = intel_dig_port->base.base.dev;
398461 struct drm_i915_private *dev_priv = to_i915(dev);
399462
400− WARN_ON(I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE);
463+ if (dev_priv->psr.psr2_support)
464+ WARN_ON(I915_READ(EDP_PSR2_CTL) & EDP_PSR2_ENABLE);
465+ else
466+ WARN_ON(I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE);
401467 WARN_ON(dev_priv->psr.active);
402468 lockdep_assert_held(&dev_priv->psr.lock);
403469
@@ -426,6 +492,8 @@ void intel_psr_enable(struct intel_dp *intel_dp) · 22 unmodified lines
426492 struct drm_device *dev = intel_dig_port->base.base.dev;
427493 struct drm_i915_private *dev_priv = to_i915(dev);
428494 struct intel_crtc *crtc = to_intel_crtc(intel_dig_port->base.base.crtc);
495+ enum transcoder cpu_transcoder = crtc->config->cpu_transcoder;
496+ u32 chicken;
429497
430498 if (!HAS_PSR(dev_priv)) {
431499 DRM_DEBUG_KMS("PSR not supported on this platform\n");
@@ -449,26 +517,34 @@ void intel_psr_enable(struct intel_dp *intel_dp) · 17 unmodified lines
449517 dev_priv->psr.busy_frontbuffer_bits = 0;
450518
451519 if (HAS_DDI(dev_priv)) {
452− hsw_psr_setup_vsc(intel_dp);
453−
454520 if (dev_priv->psr.psr2_support) {
455− /* PSR2 is restricted to work with panel resolutions upto 3200x2000 */
456− if (crtc->config->pipe_src_w > 3200 ||
457− crtc->config->pipe_src_h > 2000)
458− dev_priv->psr.psr2_support = false;
459− else
460− skl_psr_setup_su_vsc(intel_dp);
521+ skl_psr_setup_su_vsc(intel_dp);
522+ chicken = PSR2_VSC_ENABLE_PROG_HEADER;
523+ if (dev_priv->psr.y_cord_support)
524+ chicken |= PSR2_ADD_VERTICAL_LINE_COUNT;
525+ I915_WRITE(CHICKEN_TRANS(cpu_transcoder), chicken);
526+ I915_WRITE(EDP_PSR_DEBUG_CTL,
527+ EDP_PSR_DEBUG_MASK_MEMUP |
528+ EDP_PSR_DEBUG_MASK_HPD |
529+ EDP_PSR_DEBUG_MASK_LPSP |
530+ EDP_PSR_DEBUG_MASK_MAX_SLEEP |
531+ EDP_PSR_DEBUG_MASK_DISP_REG_WRITE);
532+ } else {
533+ /* set up vsc header for psr1 */
534+ hsw_psr_setup_vsc(intel_dp);
535+ /*
536+ * Per Spec: Avoid continuous PSR exit by masking MEMUP
537+ * and HPD. also mask LPSP to avoid dependency on other
538+ * drivers that might block runtime_pm besides
539+ * preventing other hw tracking issues now we can rely
540+ * on frontbuffer tracking.
541+ */
542+ I915_WRITE(EDP_PSR_DEBUG_CTL,
543+ EDP_PSR_DEBUG_MASK_MEMUP |
544+ EDP_PSR_DEBUG_MASK_HPD |
545+ EDP_PSR_DEBUG_MASK_LPSP);
461546 }
462547
463− /*
464− * Per Spec: Avoid continuous PSR exit by masking MEMUP and HPD.
465− * Also mask LPSP to avoid dependency on other drivers that
466− * might block runtime_pm besides preventing other hw tracking
467− * issues now we can rely on frontbuffer tracking.
468− */
469− I915_WRITE(EDP_PSR_DEBUG_CTL, EDP_PSR_DEBUG_MASK_MEMUP |
470− EDP_PSR_DEBUG_MASK_HPD | EDP_PSR_DEBUG_MASK_LPSP);
471−
472548 /* Enable PSR on the panel */
473549 hsw_psr_enable_sink(intel_dp);
474550
@@ -544,20 +620,42 @@ static void hsw_psr_disable(struct intel_dp *intel_dp) · 69 unmodified lines
544620 struct drm_i915_private *dev_priv = to_i915(dev);
545621
546622 if (dev_priv->psr.active) {
547− I915_WRITE(EDP_PSR_CTL,
548− I915_READ(EDP_PSR_CTL) & ~EDP_PSR_ENABLE);
623+ i915_reg_t psr_ctl;
624+ u32 psr_status_mask;
625+
626+ if (dev_priv->psr.aux_frame_sync)
627+ drm_dp_dpcd_writeb(&intel_dp->aux,
628+ DP_SINK_DEVICE_AUX_FRAME_SYNC_CONF,
629+ 0);
630+
631+ if (dev_priv->psr.psr2_support) {
632+ psr_ctl = EDP_PSR2_CTL;
633+ psr_status_mask = EDP_PSR2_STATUS_STATE_MASK;
634+
635+ I915_WRITE(psr_ctl,
636+ I915_READ(psr_ctl) &
637+ ~(EDP_PSR2_ENABLE | EDP_SU_TRACK_ENABLE));
638+
639+ } else {
640+ psr_ctl = EDP_PSR_STATUS_CTL;
641+ psr_status_mask = EDP_PSR_STATUS_STATE_MASK;
642+
643+ I915_WRITE(psr_ctl,
644+ I915_READ(psr_ctl) & ~EDP_PSR_ENABLE);
645+ }
549646
550647 /* Wait till PSR is idle */
551648 if (intel_wait_for_register(dev_priv,
552− EDP_PSR_STATUS_CTL,
553− EDP_PSR_STATUS_STATE_MASK,
554− 0,
649+ psr_ctl, psr_status_mask, 0,
555650 2000))
556651 DRM_ERROR("Timed out waiting for PSR Idle State\n");
557652
558653 dev_priv->psr.active = false;
559654 } else {
560− WARN_ON(I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE);
655+ if (dev_priv->psr.psr2_support)
656+ WARN_ON(I915_READ(EDP_PSR2_CTL) & EDP_PSR2_ENABLE);
657+ else
658+ WARN_ON(I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE);
561659 }
562660 }
563661
@@ -608,13 +706,24 @@ static void intel_psr_work(struct work_struct *work) · 44 unmodified lines
608706 * and be ready for re-enable.
609707 */
610708 if (HAS_DDI(dev_priv)) {
611− if (intel_wait_for_register(dev_priv,
612− EDP_PSR_STATUS_CTL,
613− EDP_PSR_STATUS_STATE_MASK,
614− 0,
615− 50)) {
616− DRM_ERROR("Timed out waiting for PSR Idle for re-enable\n");
617− return;
709+ if (dev_priv->psr.psr2_support) {
710+ if (intel_wait_for_register(dev_priv,
711+ EDP_PSR2_STATUS_CTL,
712+ EDP_PSR2_STATUS_STATE_MASK,
713+ 0,
714+ 50)) {
715+ DRM_ERROR("Timed out waiting for PSR2 Idle for re-enable\n");
716+ return;
717+ }
718+ } else {
719+ if (intel_wait_for_register(dev_priv,
720+ EDP_PSR_STATUS_CTL,
721+ EDP_PSR_STATUS_STATE_MASK,
722+ 0,
723+ 50)) {
724+ DRM_ERROR("Timed out waiting for PSR Idle for re-enable\n");
725+ return;
726+ }
618727 }
619728 } else {
620729 if (intel_wait_for_register(dev_priv,
@@ -656,11 +765,19 @@ static void intel_psr_exit(struct drm_i915_private *dev_priv) · 35 unmodified lines
656765 return;
657766
658767 if (HAS_DDI(dev_priv)) {
659− val = I915_READ(EDP_PSR_CTL);
660−
661− WARN_ON(!(val & EDP_PSR_ENABLE));
662−
663− I915_WRITE(EDP_PSR_CTL, val & ~EDP_PSR_ENABLE);
768+ if (dev_priv->psr.aux_frame_sync)
769+ drm_dp_dpcd_writeb(&intel_dp->aux,
770+ DP_SINK_DEVICE_AUX_FRAME_SYNC_CONF,
771+ 0);
772+ if (dev_priv->psr.psr2_support) {
773+ val = I915_READ(EDP_PSR2_CTL);
774+ WARN_ON(!(val & EDP_PSR2_ENABLE));
775+ I915_WRITE(EDP_PSR2_CTL, val & ~EDP_PSR2_ENABLE);
776+ } else {
777+ val = I915_READ(EDP_PSR_CTL);
778+ WARN_ON(!(val & EDP_PSR_ENABLE));
779+ I915_WRITE(EDP_PSR_CTL, val & ~EDP_PSR_ENABLE);
780+ }
664781 } else {
665782 val = I915_READ(VLV_PSRCTL(pipe));
666783
drivers/gpu/drm/i915/intel_ringbuffer.c+8−8
@@ -1728,7 +1728,7 @@ static int init_status_page(struct intel_engine_cs *engine) · 1727 unmodified lines
17281728 void *vaddr;
17291729 int ret;
17301730
1731− obj = i915_gem_object_create_internal(engine->i915, 4096);
1731+ obj = i915_gem_object_create_internal(engine->i915, PAGE_SIZE);
17321732 if (IS_ERR(obj)) {
17331733 DRM_ERROR("Failed to allocate status page\n");
17341734 return PTR_ERR(obj);
@@ -1738,7 +1738,7 @@ static int init_status_page(struct intel_engine_cs *engine) · 3 unmodified lines
17381738 if (ret)
17391739 goto err;
17401740
1741− vma = i915_vma_create(obj, &engine->i915->ggtt.base, NULL);
1741+ vma = i915_vma_instance(obj, &engine->i915->ggtt.base, NULL);
17421742 if (IS_ERR(vma)) {
17431743 ret = PTR_ERR(vma);
17441744 goto err;
@@ -1769,7 +1769,7 @@ static int init_status_page(struct intel_engine_cs *engine) · 24 unmodified lines
17691769
17701770 engine->status_page.vma = vma;
17711771 engine->status_page.ggtt_offset = i915_ggtt_offset(vma);
1772− engine->status_page.page_addr = memset(vaddr, 0, 4096);
1772+ engine->status_page.page_addr = memset(vaddr, 0, PAGE_SIZE);
17731773
17741774 DRM_DEBUG_DRIVER("%s hws offset: 0x%08x\n",
17751775 engine->name, i915_ggtt_offset(vma));
@@ -1872,7 +1872,7 @@ intel_ring_create_vma(struct drm_i915_private *dev_priv, int size) · 96 unmodified lines
18721872 /* mark ring buffers as read-only from GPU side by default */
18731873 obj->gt_ro = 1;
18741874
1875− vma = i915_vma_create(obj, &dev_priv->ggtt.base, NULL);
1875+ vma = i915_vma_instance(obj, &dev_priv->ggtt.base, NULL);
18761876 if (IS_ERR(vma))
18771877 goto err;
18781878
@@ -2041,7 +2041,7 @@ static int intel_init_ring_buffer(struct intel_engine_cs *engine) · 162 unmodified lines
20412041 }
20422042
20432043 /* Ring wraparound at offset 0 sometimes hangs. No idea why. */
2044− ret = intel_ring_pin(ring, 4096);
2044+ ret = intel_ring_pin(ring, I915_GTT_PAGE_SIZE);
20452045 if (ret) {
20462046 intel_ring_free(ring);
20472047 goto error;
@@ -2458,11 +2458,11 @@ static void intel_ring_init_semaphores(struct drm_i915_private *dev_priv, · 410 unmodified lines
24582458 if (INTEL_GEN(dev_priv) >= 8 && !dev_priv->semaphore) {
24592459 struct i915_vma *vma;
24602460
2461− obj = i915_gem_object_create(dev_priv, 4096);
2461+ obj = i915_gem_object_create(dev_priv, PAGE_SIZE);
24622462 if (IS_ERR(obj))
24632463 goto err;
24642464
2465− vma = i915_vma_create(obj, &dev_priv->ggtt.base, NULL);
2465+ vma = i915_vma_instance(obj, &dev_priv->ggtt.base, NULL);
24662466 if (IS_ERR(vma))
24672467 goto err_obj;
24682468
@@ -2675,7 +2675,7 @@ int intel_init_render_ring_buffer(struct intel_engine_cs *engine) · 206 unmodified lines
26752675 return ret;
26762676
26772677 if (INTEL_GEN(dev_priv) >= 6) {
2678− ret = intel_engine_create_scratch(engine, 4096);
2678+ ret = intel_engine_create_scratch(engine, PAGE_SIZE);
26792679 if (ret)
26802680 return ret;
26812681 } else if (HAS_BROKEN_CS_TLB(dev_priv)) {
drivers/gpu/drm/i915/intel_sprite.c+4−4
@@ -273,7 +273,7 @@ skl_update_plane(struct drm_plane *drm_plane, · 272 unmodified lines
273273
274274 I915_WRITE(PLANE_CTL(pipe, plane_id), plane_ctl);
275275 I915_WRITE(PLANE_SURF(pipe, plane_id),
276− intel_fb_gtt_offset(fb, rotation) + surf_addr);
276+ intel_plane_ggtt_offset(plane_state) + surf_addr);
277277 POSTING_READ(PLANE_SURF(pipe, plane_id));
278278 }
279279
@@ -458,7 +458,7 @@ vlv_update_plane(struct drm_plane *dplane, · 178 unmodified lines
458458 I915_WRITE(SPSIZE(pipe, plane_id), (crtc_h << 16) | crtc_w);
459459 I915_WRITE(SPCNTR(pipe, plane_id), sprctl);
460460 I915_WRITE(SPSURF(pipe, plane_id),
461− intel_fb_gtt_offset(fb, rotation) + sprsurf_offset);
461+ intel_plane_ggtt_offset(plane_state) + sprsurf_offset);
462462 POSTING_READ(SPSURF(pipe, plane_id));
463463 }
464464
@@ -594,7 +594,7 @@ ivb_update_plane(struct drm_plane *plane, · 129 unmodified lines
594594 I915_WRITE(SPRSCALE(pipe), sprscale);
595595 I915_WRITE(SPRCTL(pipe), sprctl);
596596 I915_WRITE(SPRSURF(pipe),
597− intel_fb_gtt_offset(fb, rotation) + sprsurf_offset);
597+ intel_plane_ggtt_offset(plane_state) + sprsurf_offset);
598598 POSTING_READ(SPRSURF(pipe));
599599 }
600600
@@ -721,7 +721,7 @@ ilk_update_plane(struct drm_plane *plane, · 120 unmodified lines
721721 I915_WRITE(DVSSCALE(pipe), dvsscale);
722722 I915_WRITE(DVSCNTR(pipe), dvscntr);
723723 I915_WRITE(DVSSURF(pipe),
724− intel_fb_gtt_offset(fb, rotation) + dvssurf_offset);
724+ intel_plane_ggtt_offset(plane_state) + dvssurf_offset);
725725 POSTING_READ(DVSSURF(pipe));
726726 }
727727
drivers/gpu/drm/i915/intel_uc.c+0−26
@@ -114,29 +114,3 @@ int intel_guc_sample_forcewake(struct intel_guc *guc) · 113 unmodified lines
114114 return intel_guc_send(guc, action, ARRAY_SIZE(action));
115115 }
116116
117−int intel_guc_log_flush_complete(struct intel_guc *guc)
118−{
119− u32 action[] = { INTEL_GUC_ACTION_LOG_BUFFER_FILE_FLUSH_COMPLETE };
120−
121− return intel_guc_send(guc, action, ARRAY_SIZE(action));
122−}
123−
124−int intel_guc_log_flush(struct intel_guc *guc)
125−{
126− u32 action[] = {
127− INTEL_GUC_ACTION_FORCE_LOG_BUFFER_FLUSH,
128− 0
129− };
130−
131− return intel_guc_send(guc, action, ARRAY_SIZE(action));
132−}
133−
134−int intel_guc_log_control(struct intel_guc *guc, u32 control_val)
135−{
136− u32 action[] = {
137− INTEL_GUC_ACTION_UK_LOG_ENABLE_LOGGING,
138− control_val
139− };
140−
141− return intel_guc_send(guc, action, ARRAY_SIZE(action));
142−}
drivers/gpu/drm/i915/intel_uc.h+47−26
@@ -93,29 +93,35 @@ struct i915_guc_client { · 92 unmodified lines
9393 uint64_t submissions[I915_NUM_ENGINES];
9494 };
9595
96−enum intel_guc_fw_status {
97− GUC_FIRMWARE_FAIL = -1,
98− GUC_FIRMWARE_NONE = 0,
99− GUC_FIRMWARE_PENDING,
100− GUC_FIRMWARE_SUCCESS
96+enum intel_uc_fw_status {
97+ INTEL_UC_FIRMWARE_FAIL = -1,
98+ INTEL_UC_FIRMWARE_NONE = 0,
99+ INTEL_UC_FIRMWARE_PENDING,
100+ INTEL_UC_FIRMWARE_SUCCESS
101+};
102+
103+enum intel_uc_fw_type {
104+ INTEL_UC_FW_TYPE_GUC,
105+ INTEL_UC_FW_TYPE_HUC
101106 };
102107
103108 /*
104109 * This structure encapsulates all the data needed during the process
105110 * of fetching, caching, and loading the firmware image into the GuC.
106111 */
107−struct intel_guc_fw {
108− const char * guc_fw_path;
109− size_t guc_fw_size;
110− struct drm_i915_gem_object * guc_fw_obj;
111− enum intel_guc_fw_status guc_fw_fetch_status;
112− enum intel_guc_fw_status guc_fw_load_status;
113−
114− uint16_t guc_fw_major_wanted;
115− uint16_t guc_fw_minor_wanted;
116− uint16_t guc_fw_major_found;
117− uint16_t guc_fw_minor_found;
118−
112+struct intel_uc_fw {
113+ const char *path;
114+ size_t size;
115+ struct drm_i915_gem_object *obj;
116+ enum intel_uc_fw_status fetch_status;
117+ enum intel_uc_fw_status load_status;
118+
119+ uint16_t major_ver_wanted;
120+ uint16_t minor_ver_wanted;
121+ uint16_t major_ver_found;
122+ uint16_t minor_ver_found;
123+
124+ enum intel_uc_fw_type fw;
119125 uint32_t header_size;
120126 uint32_t header_offset;
121127 uint32_t rsa_size;
@@ -141,7 +147,7 @@ struct intel_guc_log { · 19 unmodified lines
141147 };
142148
143149 struct intel_guc {
144− struct intel_guc_fw guc_fw;
150+ struct intel_uc_fw fw;
145151 struct intel_guc_log log;
146152
147153 /* intel_guc_recv interrupt related state */
@@ -170,21 +176,28 @@ struct intel_guc { · 22 unmodified lines
170176 struct mutex send_mutex;
171177 };
172178
179+struct intel_huc {
180+ /* Generic uC firmware management */
181+ struct intel_uc_fw fw;
182+
183+ /* HuC-specific additions */
184+};
185+
173186 /* intel_uc.c */
174187 void intel_uc_init_early(struct drm_i915_private *dev_priv);
175188 int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 len);
176189 int intel_guc_sample_forcewake(struct intel_guc *guc);
177−int intel_guc_log_flush_complete(struct intel_guc *guc);
178−int intel_guc_log_flush(struct intel_guc *guc);
179−int intel_guc_log_control(struct intel_guc *guc, u32 control_val);
180190
181191 /* intel_guc_loader.c */
182192 extern void intel_guc_init(struct drm_i915_private *dev_priv);
183193 extern int intel_guc_setup(struct drm_i915_private *dev_priv);
184194 extern void intel_guc_fini(struct drm_i915_private *dev_priv);
185−extern const char *intel_guc_fw_status_repr(enum intel_guc_fw_status status);
195+extern const char *intel_uc_fw_status_repr(enum intel_uc_fw_status status);
186196 extern int intel_guc_suspend(struct drm_i915_private *dev_priv);
187197 extern int intel_guc_resume(struct drm_i915_private *dev_priv);
198+void intel_uc_fw_fetch(struct drm_i915_private *dev_priv,
199+ struct intel_uc_fw *uc_fw);
200+u32 intel_guc_wopcm_size(struct drm_i915_private *dev_priv);
188201
189202 /* i915_guc_submission.c */
190203 int i915_guc_submission_init(struct drm_i915_private *dev_priv);
@@ -193,10 +206,12 @@ int i915_guc_wq_reserve(struct drm_i915_gem_request *rq); · 2 unmodified lines
193206 void i915_guc_wq_unreserve(struct drm_i915_gem_request *request);
194207 void i915_guc_submission_disable(struct drm_i915_private *dev_priv);
195208 void i915_guc_submission_fini(struct drm_i915_private *dev_priv);
196−void i915_guc_capture_logs(struct drm_i915_private *dev_priv);
197−void i915_guc_flush_logs(struct drm_i915_private *dev_priv);
198−void i915_guc_register(struct drm_i915_private *dev_priv);
199−void i915_guc_unregister(struct drm_i915_private *dev_priv);
209+struct i915_vma *intel_guc_allocate_vma(struct intel_guc *guc, u32 size);
210+
211+/* intel_guc_log.c */
212+void intel_guc_log_create(struct intel_guc *guc);
213+void i915_guc_log_register(struct drm_i915_private *dev_priv);
214+void i915_guc_log_unregister(struct drm_i915_private *dev_priv);
200215 int i915_guc_log_control(struct drm_i915_private *dev_priv, u64 control_val);
201216
202217 static inline u32 guc_ggtt_offset(struct i915_vma *vma)
@@ -207,4 +222,10 @@ static inline u32 guc_ggtt_offset(struct i915_vma *vma) · 4 unmodified lines
207222 return offset;
208223 }
209224
225+/* intel_huc.c */
226+void intel_huc_init(struct drm_i915_private *dev_priv);
227+void intel_huc_fini(struct drm_i915_private *dev_priv);
228+int intel_huc_load(struct drm_i915_private *dev_priv);
229+void intel_guc_auth_huc(struct drm_i915_private *dev_priv);
230+
210231 #endif
include/drm/drm_dp_helper.h+12−1
@@ -194,7 +194,8 @@ · 193 unmodified lines
194194 # define DP_PSR_SETUP_TIME_0 (6 << 1)
195195 # define DP_PSR_SETUP_TIME_MASK (7 << 1)
196196 # define DP_PSR_SETUP_TIME_SHIFT 1
197−
197+# define DP_PSR2_SU_Y_COORDINATE_REQUIRED (1 << 4) /* eDP 1.4a */
198+# define DP_PSR2_SU_GRANULARITY_REQUIRED (1 << 5) /* eDP 1.4b */
198199 /*
199200 * 0x80-0x8f describe downstream port capabilities, but there are two layouts
200201 * based on whether DP_DETAILED_CAP_INFO_AVAILABLE was set. If it was not,
@@ -568,6 +569,16 @@ · 367 unmodified lines
568569 #define DP_RECEIVER_ALPM_STATUS 0x200b /* eDP 1.4 */
569570 # define DP_ALPM_LOCK_TIMEOUT_ERROR (1 << 0)
570571
572+#define DP_DPRX_FEATURE_ENUMERATION_LIST 0x2210 /* DP 1.3 */
573+# define DP_GTC_CAP (1 << 0) /* DP 1.3 */
574+# define DP_SST_SPLIT_SDP_CAP (1 << 1) /* DP 1.4 */
575+# define DP_AV_SYNC_CAP (1 << 2) /* DP 1.3 */
576+# define DP_VSC_SDP_EXT_FOR_COLORIMETRY_SUPPORTED (1 << 3) /* DP 1.3 */
577+# define DP_VSC_EXT_VESA_SDP_SUPPORTED (1 << 4) /* DP 1.4 */
578+# define DP_VSC_EXT_VESA_SDP_CHAINING_SUPPORTED (1 << 5) /* DP 1.4 */
579+# define DP_VSC_EXT_CEA_SDP_SUPPORTED (1 << 6) /* DP 1.4 */
580+# define DP_VSC_EXT_CEA_SDP_CHAINING_SUPPORTED (1 << 7) /* DP 1.4 */
581+
571582 /* DP 1.2 Sideband message defines */
572583 /* peer device type - DP 1.2a Table 2-92 */
573584 #define DP_PEER_DEVICE_NONE 0x0
include/uapi/drm/i915_drm.h+1−0
@@ -395,6 +395,7 @@ typedef struct drm_i915_irq_wait { · 394 unmodified lines
395395 * priorities and the driver will attempt to execute batches in priority order.
396396 */
397397 #define I915_PARAM_HAS_SCHEDULER 41
398+#define I915_PARAM_HUC_STATUS 42
398399
399400 typedef struct drm_i915_getparam {
400401 __s32 param;
sound/pci/hda/hda_codec.c+72−4
@@ -311,9 +311,15 @@ int snd_hda_get_conn_index(struct hda_codec *codec, hda_nid_t mux, · 310 unmodified lines
311311 }
312312 EXPORT_SYMBOL_GPL(snd_hda_get_conn_index);
313313
314−
315−/* return DEVLIST_LEN parameter of the given widget */
316−static unsigned int get_num_devices(struct hda_codec *codec, hda_nid_t nid)
314+/**
315+ * snd_hda_get_num_devices - get DEVLIST_LEN parameter of the given widget
316+ * @codec: the HDA codec
317+ * @nid: NID of the pin to parse
318+ *
319+ * Get the device entry number on the given widget. This is a feature of
320+ * DP MST audio. Each pin can have several device entries in it.
321+ */
322+unsigned int snd_hda_get_num_devices(struct hda_codec *codec, hda_nid_t nid)
317323 {
318324 unsigned int wcaps = get_wcaps(codec, nid);
319325 unsigned int parm;
@@ -327,6 +333,7 @@ static unsigned int get_num_devices(struct hda_codec *codec, hda_nid_t nid) · 7 unmodified lines
327333 parm = 0;
328334 return parm & AC_DEV_LIST_LEN_MASK;
329335 }
336+EXPORT_SYMBOL_GPL(snd_hda_get_num_devices);
330337
331338 /**
332339 * snd_hda_get_devices - copy device list without cache
@@ -344,7 +351,7 @@ int snd_hda_get_devices(struct hda_codec *codec, hda_nid_t nid, · 11 unmodified lines
344351 unsigned int parm;
345352 int i, dev_len, devices;
346353
347− parm = get_num_devices(codec, nid);
354+ parm = snd_hda_get_num_devices(codec, nid);
348355 if (!parm) /* not multi-stream capable */
349356 return 0;
350357
@@ -368,6 +375,63 @@ int snd_hda_get_devices(struct hda_codec *codec, hda_nid_t nid, · 17 unmodified lines
368375 return devices;
369376 }
370377
378+/**
379+ * snd_hda_get_dev_select - get device entry select on the pin
380+ * @codec: the HDA codec
381+ * @nid: NID of the pin to get device entry select
382+ *
383+ * Get the devcie entry select on the pin. Return the device entry
384+ * id selected on the pin. Return 0 means the first device entry
385+ * is selected or MST is not supported.
386+ */
387+int snd_hda_get_dev_select(struct hda_codec *codec, hda_nid_t nid)
388+{
389+ /* not support dp_mst will always return 0, using first dev_entry */
390+ if (!codec->dp_mst)
391+ return 0;
392+
393+ return snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DEVICE_SEL, 0);
394+}
395+EXPORT_SYMBOL_GPL(snd_hda_get_dev_select);
396+
397+/**
398+ * snd_hda_set_dev_select - set device entry select on the pin
399+ * @codec: the HDA codec
400+ * @nid: NID of the pin to set device entry select
401+ * @dev_id: device entry id to be set
402+ *
403+ * Set the device entry select on the pin nid.
404+ */
405+int snd_hda_set_dev_select(struct hda_codec *codec, hda_nid_t nid, int dev_id)
406+{
407+ int ret, num_devices;
408+
409+ /* not support dp_mst will always return 0, using first dev_entry */
410+ if (!codec->dp_mst)
411+ return 0;
412+
413+ /* AC_PAR_DEVLIST_LEN is 0 based. */
414+ num_devices = snd_hda_get_num_devices(codec, nid) + 1;
415+ /* If Device List Length is 0 (num_device = 1),
416+ * the pin is not multi stream capable.
417+ * Do nothing in this case.
418+ */
419+ if (num_devices == 1)
420+ return 0;
421+
422+ /* Behavior of setting index being equal to or greater than
423+ * Device List Length is not predictable
424+ */
425+ if (num_devices <= dev_id)
426+ return -EINVAL;
427+
428+ ret = snd_hda_codec_write(codec, nid, 0,
429+ AC_VERB_SET_DEVICE_SEL, dev_id);
430+
431+ return ret;
432+}
433+EXPORT_SYMBOL_GPL(snd_hda_set_dev_select);
434+
371435 /*
372436 * read widget caps for each widget and store in cache
373437 */
@@ -403,6 +467,10 @@ static int read_pin_defaults(struct hda_codec *codec) · 29 unmodified lines
403467 pin->nid = nid;
404468 pin->cfg = snd_hda_codec_read(codec, nid, 0,
405469 AC_VERB_GET_CONFIG_DEFAULT, 0);
470+ /*
471+ * all device entries are the same widget control so far
472+ * fixme: if any codec is different, need fix here
473+ */
406474 pin->ctrl = snd_hda_codec_read(codec, nid, 0,
407475 AC_VERB_GET_PIN_WIDGET_CONTROL,
408476 0);
sound/pci/hda/hda_codec.h+3−0
@@ -347,8 +347,11 @@ int snd_hda_override_conn_list(struct hda_codec *codec, hda_nid_t nid, int nums, · 346 unmodified lines
347347 const hda_nid_t *list);
348348 int snd_hda_get_conn_index(struct hda_codec *codec, hda_nid_t mux,
349349 hda_nid_t nid, int recursive);
350+unsigned int snd_hda_get_num_devices(struct hda_codec *codec, hda_nid_t nid);
350351 int snd_hda_get_devices(struct hda_codec *codec, hda_nid_t nid,
351352 u8 *dev_list, int max_devices);
353+int snd_hda_get_dev_select(struct hda_codec *codec, hda_nid_t nid);
354+int snd_hda_set_dev_select(struct hda_codec *codec, hda_nid_t nid, int dev_id);
352355
353356 struct hda_verb {
354357 hda_nid_t nid;
sound/pci/hda/patch_hdmi.c+193−52
@@ -76,6 +76,7 @@ struct hdmi_spec_per_cvt { · 75 unmodified lines
7676
7777 struct hdmi_spec_per_pin {
7878 hda_nid_t pin_nid;
79+ int dev_id;
7980 /* pin idx, different device entries on the same pin use the same idx */
8081 int pin_nid_idx;
8182 int num_mux_nids;
@@ -130,7 +131,23 @@ struct hdmi_spec { · 48 unmodified lines
130131 struct snd_array cvts; /* struct hdmi_spec_per_cvt */
131132 hda_nid_t cvt_nids[4]; /* only for haswell fix */
132133
134+ /*
135+ * num_pins is the number of virtual pins
136+ * for example, there are 3 pins, and each pin
137+ * has 4 device entries, then the num_pins is 12
138+ */
133139 int num_pins;
140+ /*
141+ * num_nids is the number of real pins
142+ * In the above example, num_nids is 3
143+ */
144+ int num_nids;
145+ /*
146+ * dev_num is the number of device entries
147+ * on each pin.
148+ * In the above example, dev_num is 4
149+ */
150+ int dev_num;
134151 struct snd_array pins; /* struct hdmi_spec_per_pin */
135152 struct hdmi_pcm pcm_rec[16];
136153 struct mutex pcm_lock;
@@ -217,14 +234,26 @@ union audio_infoframe { · 80 unmodified lines
217234 /* obtain hda_pcm object assigned to idx */
218235 #define get_pcm_rec(spec, idx) (get_hdmi_pcm(spec, idx)->pcm)
219236
220−static int pin_nid_to_pin_index(struct hda_codec *codec, hda_nid_t pin_nid)
237+static int pin_id_to_pin_index(struct hda_codec *codec,
238+ hda_nid_t pin_nid, int dev_id)
221239 {
222240 struct hdmi_spec *spec = codec->spec;
223241 int pin_idx;
242+ struct hdmi_spec_per_pin *per_pin;
243+
244+ /*
245+ * (dev_id == -1) means it is NON-MST pin
246+ * return the first virtual pin on this port
247+ */
248+ if (dev_id == -1)
249+ dev_id = 0;
224250
225− for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++)
226− if (get_pin(spec, pin_idx)->pin_nid == pin_nid)
251+ for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
252+ per_pin = get_pin(spec, pin_idx);
253+ if ((per_pin->pin_nid == pin_nid) &&
254+ (per_pin->dev_id == dev_id))
227255 return pin_idx;
256+ }
228257
229258 codec_warn(codec, "HDMI: pin nid %d not registered\n", pin_nid);
230259 return -EINVAL;
@@ -724,10 +753,11 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec, · 493 unmodified lines
724753
725754 static bool hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll);
726755
727−static void check_presence_and_report(struct hda_codec *codec, hda_nid_t nid)
756+static void check_presence_and_report(struct hda_codec *codec, hda_nid_t nid,
757+ int dev_id)
728758 {
729759 struct hdmi_spec *spec = codec->spec;
730− int pin_idx = pin_nid_to_pin_index(codec, nid);
760+ int pin_idx = pin_id_to_pin_index(codec, nid, dev_id);
731761
732762 if (pin_idx < 0)
733763 return;
@@ -738,7 +768,8 @@ static void check_presence_and_report(struct hda_codec *codec, hda_nid_t nid) · 4 unmodified lines
738768 static void jack_callback(struct hda_codec *codec,
739769 struct hda_jack_callback *jack)
740770 {
741− check_presence_and_report(codec, jack->nid);
771+ /* hda_jack don't support DP MST */
772+ check_presence_and_report(codec, jack->nid, 0);
742773 }
743774
744775 static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
@@ -747,6 +778,12 @@ static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res) · 2 unmodified lines
747778 struct hda_jack_tbl *jack;
748779 int dev_entry = (res & AC_UNSOL_RES_DE) >> AC_UNSOL_RES_DE_SHIFT;
749780
781+ /*
782+ * assume DP MST uses dyn_pcm_assign and acomp and
783+ * never comes here
784+ * if DP MST supports unsol event, below code need
785+ * consider dev_entry
786+ */
750787 jack = snd_hda_jack_tbl_get_from_tag(codec, tag);
751788 if (!jack)
752789 return;
@@ -757,7 +794,8 @@ static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res) · 4 unmodified lines
757794 codec->addr, jack->nid, dev_entry, !!(res & AC_UNSOL_RES_IA),
758795 !!(res & AC_UNSOL_RES_PD), !!(res & AC_UNSOL_RES_ELDV));
759796
760− check_presence_and_report(codec, jack->nid);
797+ /* hda_jack don't support DP MST */
798+ check_presence_and_report(codec, jack->nid, 0);
761799 }
762800
763801 static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res)
@@ -970,28 +1008,60 @@ static int intel_cvt_id_to_mux_idx(struct hdmi_spec *spec, · 206 unmodified lines
9701008 * by any other pins.
9711009 */
9721010 static void intel_not_share_assigned_cvt(struct hda_codec *codec,
973− hda_nid_t pin_nid, int mux_idx)
1011+ hda_nid_t pin_nid,
1012+ int dev_id, int mux_idx)
9741013 {
9751014 struct hdmi_spec *spec = codec->spec;
9761015 hda_nid_t nid;
9771016 int cvt_idx, curr;
9781017 struct hdmi_spec_per_cvt *per_cvt;
1018+ struct hdmi_spec_per_pin *per_pin;
1019+ int pin_idx;
1020+
1021+ /* configure the pins connections */
1022+ for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
1023+ int dev_id_saved;
1024+ int dev_num;
9791025
980− /* configure all pins, including "no physical connection" ones */
981− for_each_hda_codec_node(nid, codec) {
982− unsigned int wid_caps = get_wcaps(codec, nid);
983− unsigned int wid_type = get_wcaps_type(wid_caps);
1026+ per_pin = get_pin(spec, pin_idx);
1027+ /*
1028+ * pin not connected to monitor
1029+ * no need to operate on it
1030+ */
1031+ if (!per_pin->pcm)
1032+ continue;
9841033
985− if (wid_type != AC_WID_PIN)
1034+ if ((per_pin->pin_nid == pin_nid) &&
1035+ (per_pin->dev_id == dev_id))
9861036 continue;
9871037
988− if (nid == pin_nid)
1038+ /*
1039+ * if per_pin->dev_id >= dev_num,
1040+ * snd_hda_get_dev_select() will fail,
1041+ * and the following operation is unpredictable.
1042+ * So skip this situation.
1043+ */
1044+ dev_num = snd_hda_get_num_devices(codec, per_pin->pin_nid) + 1;
1045+ if (per_pin->dev_id >= dev_num)
9891046 continue;
9901047
1048+ nid = per_pin->pin_nid;
1049+
1050+ /*
1051+ * Calling this function should not impact
1052+ * on the device entry selection
1053+ * So let's save the dev id for each pin,
1054+ * and restore it when return
1055+ */
1056+ dev_id_saved = snd_hda_get_dev_select(codec, nid);
1057+ snd_hda_set_dev_select(codec, nid, per_pin->dev_id);
9911058 curr = snd_hda_codec_read(codec, nid, 0,
9921059 AC_VERB_GET_CONNECT_SEL, 0);
993− if (curr != mux_idx)
1060+ if (curr != mux_idx) {
1061+ snd_hda_set_dev_select(codec, nid, dev_id_saved);
9941062 continue;
1063+ }
1064+
9951065
9961066 /* choose an unassigned converter. The conveters in the
9971067 * connection list are in the same order as in the codec.
@@ -1008,12 +1078,13 @@ static void intel_not_share_assigned_cvt(struct hda_codec *codec, · 10 unmodified lines
10081078 break;
10091079 }
10101080 }
1081+ snd_hda_set_dev_select(codec, nid, dev_id_saved);
10111082 }
10121083 }
10131084
10141085 /* A wrapper of intel_not_share_asigned_cvt() */
10151086 static void intel_not_share_assigned_cvt_nid(struct hda_codec *codec,
1016− hda_nid_t pin_nid, hda_nid_t cvt_nid)
1087+ hda_nid_t pin_nid, int dev_id, hda_nid_t cvt_nid)
10171088 {
10181089 int mux_idx;
10191090 struct hdmi_spec *spec = codec->spec;
@@ -1025,7 +1096,7 @@ static void intel_not_share_assigned_cvt_nid(struct hda_codec *codec, · 5 unmodified lines
10251096 */
10261097 mux_idx = intel_cvt_id_to_mux_idx(spec, cvt_nid);
10271098 if (mux_idx >= 0)
1028− intel_not_share_assigned_cvt(codec, pin_nid, mux_idx);
1099+ intel_not_share_assigned_cvt(codec, pin_nid, dev_id, mux_idx);
10291100 }
10301101
10311102 /* skeleton caller of pin_cvt_fixup ops */
@@ -1140,6 +1211,7 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo, · 108 unmodified lines
11401211 per_pin->cvt_nid = per_cvt->cvt_nid;
11411212 hinfo->nid = per_cvt->cvt_nid;
11421213
1214+ snd_hda_set_dev_select(codec, per_pin->pin_nid, per_pin->dev_id);
11431215 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0,
11441216 AC_VERB_SET_CONNECT_SEL,
11451217 per_pin->mux_idx);
@@ -1198,6 +1270,7 @@ static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx) · 52 unmodified lines
11981270 return -EINVAL;
11991271 }
12001272
1273+ /* all the device entries on the same pin have the same conn list */
12011274 per_pin->num_mux_nids = snd_hda_get_connections(codec, pin_nid,
12021275 per_pin->mux_nids,
12031276 HDA_MAX_CONNECTIONS);
@@ -1215,13 +1288,13 @@ static int hdmi_find_pcm_slot(struct hdmi_spec *spec, · 11 unmodified lines
12151288 return per_pin->pin_nid_idx;
12161289
12171290 /* have a second try; check the "reserved area" over num_pins */
1218− for (i = spec->num_pins; i < spec->pcm_used; i++) {
1291+ for (i = spec->num_nids; i < spec->pcm_used; i++) {
12191292 if (!test_bit(i, &spec->pcm_bitmap))
12201293 return i;
12211294 }
12221295
12231296 /* the last try; check the empty slots in pins */
1224− for (i = 0; i < spec->num_pins; i++) {
1297+ for (i = 0; i < spec->num_nids; i++) {
12251298 if (!test_bit(i, &spec->pcm_bitmap))
12261299 return i;
12271300 }
@@ -1296,10 +1369,13 @@ static void hdmi_pcm_setup_pin(struct hdmi_spec *spec, · 68 unmodified lines
12961369 per_pin->cvt_nid = hinfo->nid;
12971370
12981371 mux_idx = hdmi_get_pin_cvt_mux(spec, per_pin, hinfo->nid);
1299− if (mux_idx < per_pin->num_mux_nids)
1372+ if (mux_idx < per_pin->num_mux_nids) {
1373+ snd_hda_set_dev_select(codec, per_pin->pin_nid,
1374+ per_pin->dev_id);
13001375 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0,
13011376 AC_VERB_SET_CONNECT_SEL,
13021377 mux_idx);
1378+ }
13031379 snd_hda_spdif_ctls_assign(codec, per_pin->pcm_idx, hinfo->nid);
13041380
13051381 non_pcm = check_non_pcm_per_cvt(codec, hinfo->nid);
@@ -1467,6 +1543,11 @@ static struct snd_jack *pin_idx_to_jack(struct hda_codec *codec, · 161 unmodified lines
14671543 if (per_pin->pcm_idx >= 0 && spec->dyn_pcm_assign)
14681544 jack = spec->pcm_rec[per_pin->pcm_idx].jack;
14691545 else if (!spec->dyn_pcm_assign) {
1546+ /*
1547+ * jack tbl doesn't support DP MST
1548+ * DP MST will use dyn_pcm_assign,
1549+ * so DP MST will never come here
1550+ */
14701551 jack_tbl = snd_hda_jack_tbl_get(codec, per_pin->pin_nid);
14711552 if (jack_tbl)
14721553 jack = jack_tbl->jack;
@@ -1485,9 +1566,9 @@ static void sync_eld_via_acomp(struct hda_codec *codec, · 12 unmodified lines
14851566
14861567 mutex_lock(&per_pin->lock);
14871568 eld->monitor_present = false;
1488− size = snd_hdac_acomp_get_eld(&codec->core, per_pin->pin_nid, -1,
1489− &eld->monitor_present, eld->eld_buffer,
1490− ELD_MAX_SIZE);
1569+ size = snd_hdac_acomp_get_eld(&codec->core, per_pin->pin_nid,
1570+ per_pin->dev_id, &eld->monitor_present,
1571+ eld->eld_buffer, ELD_MAX_SIZE);
14911572 if (size > 0) {
14921573 size = min(size, ELD_MAX_SIZE);
14931574 if (snd_hdmi_parse_eld(codec, &eld->info,
@@ -1565,38 +1646,81 @@ static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid) · 71 unmodified lines
15651646 int pin_idx;
15661647 struct hdmi_spec_per_pin *per_pin;
15671648 int err;
1649+ int dev_num, i;
15681650
15691651 caps = snd_hda_query_pin_caps(codec, pin_nid);
15701652 if (!(caps & (AC_PINCAP_HDMI | AC_PINCAP_DP)))
15711653 return 0;
15721654
1655+ /*
1656+ * For DP MST audio, Configuration Default is the same for
1657+ * all device entries on the same pin
1658+ */
15731659 config = snd_hda_codec_get_pincfg(codec, pin_nid);
15741660 if (get_defcfg_connect(config) == AC_JACK_PORT_NONE)
15751661 return 0;
15761662
1577− if (is_haswell_plus(codec))
1578− intel_haswell_fixup_connect_list(codec, pin_nid);
1579−
1580− pin_idx = spec->num_pins;
1581− per_pin = snd_array_new(&spec->pins);
1582− if (!per_pin)
1583− return -ENOMEM;
1584−
1585− per_pin->pin_nid = pin_nid;
1586− per_pin->non_pcm = false;
1587− if (spec->dyn_pcm_assign)
1588− per_pin->pcm_idx = -1;
1589− else {
1590− per_pin->pcm = get_hdmi_pcm(spec, pin_idx);
1591− per_pin->pcm_idx = pin_idx;
1663+ /*
1664+ * To simplify the implementation, malloc all
1665+ * the virtual pins in the initialization statically
1666+ */
1667+ if (is_haswell_plus(codec)) {
1668+ /*
1669+ * On Intel platforms, device entries number is
1670+ * changed dynamically. If there is a DP MST
1671+ * hub connected, the device entries number is 3.
1672+ * Otherwise, it is 1.
1673+ * Here we manually set dev_num to 3, so that
1674+ * we can initialize all the device entries when
1675+ * bootup statically.
1676+ */
1677+ dev_num = 3;
1678+ spec->dev_num = 3;
1679+ } else if (spec->dyn_pcm_assign && codec->dp_mst) {
1680+ dev_num = snd_hda_get_num_devices(codec, pin_nid) + 1;
1681+ /*
1682+ * spec->dev_num is the maxinum number of device entries
1683+ * among all the pins
1684+ */
1685+ spec->dev_num = (spec->dev_num > dev_num) ?
1686+ spec->dev_num : dev_num;
1687+ } else {
1688+ /*
1689+ * If the platform doesn't support DP MST,
1690+ * manually set dev_num to 1. This means
1691+ * the pin has only one device entry.
1692+ */
1693+ dev_num = 1;
1694+ spec->dev_num = 1;
15921695 }
1593− per_pin->pin_nid_idx = pin_idx;
15941696
1595− err = hdmi_read_pin_conn(codec, pin_idx);
1596− if (err < 0)
1597− return err;
1697+ for (i = 0; i < dev_num; i++) {
1698+ pin_idx = spec->num_pins;
1699+ per_pin = snd_array_new(&spec->pins);
15981700
1599− spec->num_pins++;
1701+ if (!per_pin)
1702+ return -ENOMEM;
1703+
1704+ if (spec->dyn_pcm_assign) {
1705+ per_pin->pcm = NULL;
1706+ per_pin->pcm_idx = -1;
1707+ } else {
1708+ per_pin->pcm = get_hdmi_pcm(spec, pin_idx);
1709+ per_pin->pcm_idx = pin_idx;
1710+ }
1711+ per_pin->pin_nid = pin_nid;
1712+ per_pin->pin_nid_idx = spec->num_nids;
1713+ per_pin->dev_id = i;
1714+ per_pin->non_pcm = false;
1715+ snd_hda_set_dev_select(codec, pin_nid, i);
1716+ if (is_haswell_plus(codec))
1717+ intel_haswell_fixup_connect_list(codec, pin_nid);
1718+ err = hdmi_read_pin_conn(codec, pin_idx);
1719+ if (err < 0)
1720+ return err;
1721+ spec->num_pins++;
1722+ }
1723+ spec->num_nids++;
16001724
16011725 return 0;
16021726 }
@@ -1744,7 +1868,7 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo, · 141 unmodified lines
17441868 /* Call sync_audio_rate to set the N/CTS/M manually if necessary */
17451869 /* Todo: add DP1.2 MST audio support later */
17461870 if (codec_has_acomp(codec))
1747− snd_hdac_sync_audio_rate(&codec->core, pin_nid, -1,
1871+ snd_hdac_sync_audio_rate(&codec->core, pin_nid, per_pin->dev_id,
17481872 runtime->rate);
17491873
17501874 non_pcm = check_non_pcm_per_cvt(codec, cvt_nid);
@@ -1762,6 +1886,7 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo, · 11 unmodified lines
17621886 pinctl | PIN_OUT);
17631887 }
17641888
1889+ /* snd_hda_set_dev_select() has been called before */
17651890 err = spec->ops.setup_stream(codec, cvt_nid, pin_nid,
17661891 stream_tag, format);
17671892 mutex_unlock(&spec->pcm_lock);
@@ -1897,17 +2022,23 @@ static bool is_hdmi_pcm_attached(struct hdac_device *hdac, int pcm_idx) · 129 unmodified lines
18972022 static int generic_hdmi_build_pcms(struct hda_codec *codec)
18982023 {
18992024 struct hdmi_spec *spec = codec->spec;
1900− int pin_idx;
2025+ int idx;
19012026
1902− for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
2027+ /*
2028+ * for non-mst mode, pcm number is the same as before
2029+ * for DP MST mode, pcm number is (nid number + dev_num - 1)
2030+ * dev_num is the device entry number in a pin
2031+ *
2032+ */
2033+ for (idx = 0; idx < spec->num_nids + spec->dev_num - 1; idx++) {
19032034 struct hda_pcm *info;
19042035 struct hda_pcm_stream *pstr;
19052036
1906− info = snd_hda_codec_pcm_new(codec, "HDMI %d", pin_idx);
2037+ info = snd_hda_codec_pcm_new(codec, "HDMI %d", idx);
19072038 if (!info)
19082039 return -ENOMEM;
19092040
1910− spec->pcm_rec[pin_idx].pcm = info;
2041+ spec->pcm_rec[idx].pcm = info;
19112042 spec->pcm_used++;
19122043 info->pcm_type = HDA_PCM_TYPE_HDMI;
19132044 info->own_chmap = true;
@@ -1915,6 +2046,9 @@ static int generic_hdmi_build_pcms(struct hda_codec *codec) · 1 unmodified line
19152046 pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK];
19162047 pstr->substreams = 1;
19172048 pstr->ops = generic_ops;
2049+ /* pcm number is less than 16 */
2050+ if (spec->pcm_used >= 16)
2051+ break;
19182052 /* other pstr fields are set in open */
19192053 }
19202054
@@ -2070,7 +2204,9 @@ static int generic_hdmi_init(struct hda_codec *codec) · 149 unmodified lines
20702204 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
20712205 struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
20722206 hda_nid_t pin_nid = per_pin->pin_nid;
2207+ int dev_id = per_pin->dev_id;
20732208
2209+ snd_hda_set_dev_select(codec, pin_nid, dev_id);
20742210 hdmi_init_pin(codec, pin_nid);
20752211 if (!codec_has_acomp(codec))
20762212 snd_hda_jack_detect_enable_callback(codec, pin_nid,
@@ -2178,6 +2314,7 @@ static int alloc_generic_hdmi(struct hda_codec *codec) · 101 unmodified lines
21782314 return -ENOMEM;
21792315
21802316 spec->ops = generic_standard_hdmi_ops;
2317+ spec->dev_num = 1; /* initialize to 1 */
21812318 mutex_init(&spec->pcm_lock);
21822319 snd_hdac_register_chmap_ops(&codec->core, &spec->chmap);
21832320
@@ -2295,6 +2432,7 @@ static void intel_pin_eld_notify(void *audio_ptr, int port, int pipe) · 111 unmodified lines
22952432 {
22962433 struct hda_codec *codec = audio_ptr;
22972434 int pin_nid;
2435+ int dev_id = pipe;
22982436
22992437 /* we assume only from port-B to port-D */
23002438 if (port < 1 || port > 3)
@@ -2321,7 +2459,7 @@ static void intel_pin_eld_notify(void *audio_ptr, int port, int pipe) · 20 unmodified lines
23212459 return;
23222460
23232461 snd_hdac_i915_set_bclk(&codec->bus->core);
2324− check_presence_and_report(codec, pin_nid);
2462+ check_presence_and_report(codec, pin_nid, dev_id);
23252463 }
23262464
23272465 /* register i915 component pin_eld_notify callback */
@@ -2354,11 +2492,13 @@ static void i915_pin_cvt_fixup(struct hda_codec *codec, · 26 unmodified lines
23542492 hda_nid_t cvt_nid)
23552493 {
23562494 if (per_pin) {
2495+ snd_hda_set_dev_select(codec, per_pin->pin_nid,
2496+ per_pin->dev_id);
23572497 intel_verify_pin_cvt_connect(codec, per_pin);
23582498 intel_not_share_assigned_cvt(codec, per_pin->pin_nid,
2359− per_pin->mux_idx);
2499+ per_pin->dev_id, per_pin->mux_idx);
23602500 } else {
2361− intel_not_share_assigned_cvt_nid(codec, 0, cvt_nid);
2501+ intel_not_share_assigned_cvt_nid(codec, 0, 0, cvt_nid);
23622502 }
23632503 }
23642504
@@ -2378,6 +2518,8 @@ static int patch_i915_hsw_hdmi(struct hda_codec *codec) · 13 unmodified lines
23782518 if (err < 0)
23792519 return err;
23802520 spec = codec->spec;
2521+ codec->dp_mst = true;
2522+ spec->dyn_pcm_assign = true;
23812523
23822524 intel_haswell_enable_all_pins(codec, true);
23832525 intel_haswell_fixup_enable_dp12(codec);
@@ -2389,7 +2531,6 @@ static int patch_i915_hsw_hdmi(struct hda_codec *codec) · 5 unmodified lines
23892531 codec->core.link_power_control = 1;
23902532
23912533 codec->patch_ops.set_power_state = haswell_set_power_state;
2392− codec->dp_mst = true;
23932534 codec->depop_delay = 0;
23942535 codec->auto_runtime_pm = 1;
23952536

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t