History

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

Final drm/i915 changes for v4.21: - ICL DSI video mode enabling (Madhav, Vandita, Jani, Imre) - eDP sink count fix (José) - PSR fixes (José) - DRM DP helper and i915 DSC enabling (Manasi, Gaurav, Anusha) - DP FEC enabling (Anusha) - SKL+ watermark/ddb programming improvements (Ville) - Pixel format fixes (Ville) - Selftest updates (Chris, Tvrtko) - GT and engine workaround improvements (Tvrtko) Signed-off-by: Dave Airlie <airlied@redhat.com>

Dave Airlie committed 7 years ago

Commit 467e8a52 parents 818182d 4377d4e61 files · +5364 −1972Browse files

Unified · Split

61 files
  1. Documentation/gpu/drm-kms-helpers.rst +12 −0
  2. drivers/gpu/drm/Makefile +1 −1
  3. drivers/gpu/drm/drm_dp_helper.c +8 −6
  4. drivers/gpu/drm/drm_dsc.c +228 −0
  5. drivers/gpu/drm/i915/Makefile +5 −2
  6. drivers/gpu/drm/i915/i915_debugfs.c +39 −29
  7. drivers/gpu/drm/i915/i915_drv.c +22 −5
  8. drivers/gpu/drm/i915/i915_drv.h +31 −31
  9. drivers/gpu/drm/i915/i915_gem.c +65 −46
  10. drivers/gpu/drm/i915/i915_gem_context.c +1 −5
  11. drivers/gpu/drm/i915/i915_gpu_error.c +207 −130
  12. drivers/gpu/drm/i915/i915_gpu_error.h +12 −16
  13. drivers/gpu/drm/i915/i915_pci.c +64 −53
  14. drivers/gpu/drm/i915/i915_reg.h +15 −0
  15. drivers/gpu/drm/i915/i915_request.c +3 −0
  16. drivers/gpu/drm/i915/i915_sw_fence.c +2 −5
  17. drivers/gpu/drm/i915/i915_sw_fence.h +2 −3
  18. drivers/gpu/drm/i915/i915_sysfs.c +13 −18
  19. drivers/gpu/drm/i915/i915_utils.h +7 −4
  20. drivers/gpu/drm/i915/icl_dsi.c +482 −11
  21. drivers/gpu/drm/i915/intel_atomic.c +1 −0
  22. drivers/gpu/drm/i915/intel_atomic_plane.c +88 −14
  23. drivers/gpu/drm/i915/intel_bios.c +1 −1
  24. drivers/gpu/drm/i915/intel_breadcrumbs.c +1 −5
  25. drivers/gpu/drm/i915/intel_ddi.c +155 −73
  26. drivers/gpu/drm/i915/intel_device_info.c +6 −2
  27. drivers/gpu/drm/i915/intel_device_info.h +21 −11
  28. drivers/gpu/drm/i915/intel_display.c +157 −173
  29. drivers/gpu/drm/i915/intel_display.h +19 −2
  30. drivers/gpu/drm/i915/intel_dp.c +255 −48
  31. drivers/gpu/drm/i915/intel_dpll_mgr.c +2 −1
  32. drivers/gpu/drm/i915/intel_drv.h +41 −11
  33. drivers/gpu/drm/i915/intel_dsi.h +5 −0
  34. drivers/gpu/drm/i915/intel_dsi_vbt.c +21 −1
  35. drivers/gpu/drm/i915/intel_engine_cs.c +4 −42
  36. drivers/gpu/drm/i915/intel_fbc.c +1 −1
  37. drivers/gpu/drm/i915/intel_fbdev.c +1 −1
  38. drivers/gpu/drm/i915/intel_hdmi.c +19 −2
  39. drivers/gpu/drm/i915/intel_i2c.c +1 −1
  40. drivers/gpu/drm/i915/intel_lrc.c +30 −53
  41. drivers/gpu/drm/i915/intel_opregion.h +3 −3
  42. drivers/gpu/drm/i915/intel_pm.c +310 −279
  43. drivers/gpu/drm/i915/intel_psr.c +94 −24
  44. drivers/gpu/drm/i915/intel_ringbuffer.c +40 −32
  45. drivers/gpu/drm/i915/intel_ringbuffer.h +4 −21
  46. drivers/gpu/drm/i915/intel_runtime_pm.c +3 −1
  47. drivers/gpu/drm/i915/intel_sprite.c +82 −56
  48. drivers/gpu/drm/i915/intel_vdsc.c +1088 −0
  49. drivers/gpu/drm/i915/intel_workarounds.c +591 −408
  50. drivers/gpu/drm/i915/intel_workarounds.h +32 −4
  51. drivers/gpu/drm/i915/selftests/igt_reset.c +44 −0
  52. drivers/gpu/drm/i915/selftests/igt_reset.h +15 −0
  53. drivers/gpu/drm/i915/selftests/igt_spinner.c +199 −0
  54. drivers/gpu/drm/i915/selftests/igt_spinner.h +37 −0
  55. drivers/gpu/drm/i915/selftests/intel_hangcheck.c +18 −45
  56. drivers/gpu/drm/i915/selftests/intel_lrc.c +52 −249
  57. drivers/gpu/drm/i915/selftests/intel_workarounds.c +211 −36
  58. fs/sysfs/file.c +2 −2
  59. include/drm/drm_dp_helper.h +2 −1
  60. include/drm/drm_dsc.h +485 −0
  61. include/linux/sysfs.h +4 −4
Documentation/gpu/drm-kms-helpers.rst+12−0
@@ -232,6 +232,18 @@ MIPI DSI Helper Functions Reference · 231 unmodified lines
232232 .. kernel-doc:: drivers/gpu/drm/drm_mipi_dsi.c
233233 :export:
234234
235+Display Stream Compression Helper Functions Reference
236+=====================================================
237+
238+.. kernel-doc:: drivers/gpu/drm/drm_dsc.c
239+ :doc: dsc helpers
240+
241+.. kernel-doc:: include/drm/drm_dsc.h
242+ :internal:
243+
244+.. kernel-doc:: drivers/gpu/drm/drm_dsc.c
245+ :export:
246+
235247 Output Probing Helper Functions Reference
236248 =========================================
237249
drivers/gpu/drm/Makefile+1−1
@@ -32,7 +32,7 @@ drm-$(CONFIG_AGP) += drm_agpsupport.o · 31 unmodified lines
3232 drm-$(CONFIG_DEBUG_FS) += drm_debugfs.o drm_debugfs_crc.o
3333 drm-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o
3434
35−drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_probe_helper.o \
35+drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_dsc.o drm_probe_helper.o \
3636 drm_plane_helper.o drm_dp_mst_topology.o drm_atomic_helper.o \
3737 drm_kms_helper_common.o drm_dp_dual_mode_helper.o \
3838 drm_simple_kms_helper.o drm_modeset_helper.o \
drivers/gpu/drm/drm_dp_helper.c+8−6
@@ -1428,17 +1428,19 @@ u8 drm_dp_dsc_sink_line_buf_depth(const u8 dsc_dpcd[DP_DSC_RECEIVER_CAP_SIZE]) · 1427 unmodified lines
14281428 }
14291429 EXPORT_SYMBOL(drm_dp_dsc_sink_line_buf_depth);
14301430
1431−u8 drm_dp_dsc_sink_max_color_depth(const u8 dsc_dpcd[DP_DSC_RECEIVER_CAP_SIZE])
1431+int drm_dp_dsc_sink_supported_input_bpcs(const u8 dsc_dpcd[DP_DSC_RECEIVER_CAP_SIZE],
1432+ u8 dsc_bpc[3])
14321433 {
1434+ int num_bpc = 0;
14331435 u8 color_depth = dsc_dpcd[DP_DSC_DEC_COLOR_DEPTH_CAP - DP_DSC_SUPPORT];
14341436
14351437 if (color_depth & DP_DSC_12_BPC)
1436− return 12;
1438+ dsc_bpc[num_bpc++] = 12;
14371439 if (color_depth & DP_DSC_10_BPC)
1438− return 10;
1440+ dsc_bpc[num_bpc++] = 10;
14391441 if (color_depth & DP_DSC_8_BPC)
1440− return 8;
1442+ dsc_bpc[num_bpc++] = 8;
14411443
1442− return 0;
1444+ return num_bpc;
14431445 }
1444−EXPORT_SYMBOL(drm_dp_dsc_sink_max_color_depth);
1446+EXPORT_SYMBOL(drm_dp_dsc_sink_supported_input_bpcs);
drivers/gpu/drm/drm_dsc.c+228−0
@@ -0,0 +1,228 @@
1+// SPDX-License-Identifier: MIT
2+/*
3+ * Copyright © 2018 Intel Corp
4+ *
5+ * Author:
6+ * Manasi Navare <manasi.d.navare@intel.com>
7+ */
8+
9+#include <linux/kernel.h>
10+#include <linux/module.h>
11+#include <linux/init.h>
12+#include <linux/errno.h>
13+#include <linux/byteorder/generic.h>
14+#include <drm/drm_dp_helper.h>
15+#include <drm/drm_dsc.h>
16+
17+/**
18+ * DOC: dsc helpers
19+ *
20+ * These functions contain some common logic and helpers to deal with VESA
21+ * Display Stream Compression standard required for DSC on Display Port/eDP or
22+ * MIPI display interfaces.
23+ */
24+
25+/**
26+ * drm_dsc_dp_pps_header_init() - Initializes the PPS Header
27+ * for DisplayPort as per the DP 1.4 spec.
28+ * @pps_sdp: Secondary data packet for DSC Picture Parameter Set
29+ */
30+void drm_dsc_dp_pps_header_init(struct drm_dsc_pps_infoframe *pps_sdp)
31+{
32+ memset(&pps_sdp->pps_header, 0, sizeof(pps_sdp->pps_header));
33+
34+ pps_sdp->pps_header.HB1 = DP_SDP_PPS;
35+ pps_sdp->pps_header.HB2 = DP_SDP_PPS_HEADER_PAYLOAD_BYTES_MINUS_1;
36+}
37+EXPORT_SYMBOL(drm_dsc_dp_pps_header_init);
38+
39+/**
40+ * drm_dsc_pps_infoframe_pack() - Populates the DSC PPS infoframe
41+ * using the DSC configuration parameters in the order expected
42+ * by the DSC Display Sink device. For the DSC, the sink device
43+ * expects the PPS payload in the big endian format for the fields
44+ * that span more than 1 byte.
45+ *
46+ * @pps_sdp:
47+ * Secondary data packet for DSC Picture Parameter Set
48+ * @dsc_cfg:
49+ * DSC Configuration data filled by driver
50+ */
51+void drm_dsc_pps_infoframe_pack(struct drm_dsc_pps_infoframe *pps_sdp,
52+ const struct drm_dsc_config *dsc_cfg)
53+{
54+ int i;
55+
56+ /* Protect against someone accidently changing struct size */
57+ BUILD_BUG_ON(sizeof(pps_sdp->pps_payload) !=
58+ DP_SDP_PPS_HEADER_PAYLOAD_BYTES_MINUS_1 + 1);
59+
60+ memset(&pps_sdp->pps_payload, 0, sizeof(pps_sdp->pps_payload));
61+
62+ /* PPS 0 */
63+ pps_sdp->pps_payload.dsc_version =
64+ dsc_cfg->dsc_version_minor |
65+ dsc_cfg->dsc_version_major << DSC_PPS_VERSION_MAJOR_SHIFT;
66+
67+ /* PPS 1, 2 is 0 */
68+
69+ /* PPS 3 */
70+ pps_sdp->pps_payload.pps_3 =
71+ dsc_cfg->line_buf_depth |
72+ dsc_cfg->bits_per_component << DSC_PPS_BPC_SHIFT;
73+
74+ /* PPS 4 */
75+ pps_sdp->pps_payload.pps_4 =
76+ ((dsc_cfg->bits_per_pixel & DSC_PPS_BPP_HIGH_MASK) >>
77+ DSC_PPS_MSB_SHIFT) |
78+ dsc_cfg->vbr_enable << DSC_PPS_VBR_EN_SHIFT |
79+ dsc_cfg->enable422 << DSC_PPS_SIMPLE422_SHIFT |
80+ dsc_cfg->convert_rgb << DSC_PPS_CONVERT_RGB_SHIFT |
81+ dsc_cfg->block_pred_enable << DSC_PPS_BLOCK_PRED_EN_SHIFT;
82+
83+ /* PPS 5 */
84+ pps_sdp->pps_payload.bits_per_pixel_low =
85+ (dsc_cfg->bits_per_pixel & DSC_PPS_LSB_MASK);
86+
87+ /*
88+ * The DSC panel expects the PPS packet to have big endian format
89+ * for data spanning 2 bytes. Use a macro cpu_to_be16() to convert
90+ * to big endian format. If format is little endian, it will swap
91+ * bytes to convert to Big endian else keep it unchanged.
92+ */
93+
94+ /* PPS 6, 7 */
95+ pps_sdp->pps_payload.pic_height = cpu_to_be16(dsc_cfg->pic_height);
96+
97+ /* PPS 8, 9 */
98+ pps_sdp->pps_payload.pic_width = cpu_to_be16(dsc_cfg->pic_width);
99+
100+ /* PPS 10, 11 */
101+ pps_sdp->pps_payload.slice_height = cpu_to_be16(dsc_cfg->slice_height);
102+
103+ /* PPS 12, 13 */
104+ pps_sdp->pps_payload.slice_width = cpu_to_be16(dsc_cfg->slice_width);
105+
106+ /* PPS 14, 15 */
107+ pps_sdp->pps_payload.chunk_size = cpu_to_be16(dsc_cfg->slice_chunk_size);
108+
109+ /* PPS 16 */
110+ pps_sdp->pps_payload.initial_xmit_delay_high =
111+ ((dsc_cfg->initial_xmit_delay &
112+ DSC_PPS_INIT_XMIT_DELAY_HIGH_MASK) >>
113+ DSC_PPS_MSB_SHIFT);
114+
115+ /* PPS 17 */
116+ pps_sdp->pps_payload.initial_xmit_delay_low =
117+ (dsc_cfg->initial_xmit_delay & DSC_PPS_LSB_MASK);
118+
119+ /* PPS 18, 19 */
120+ pps_sdp->pps_payload.initial_dec_delay =
121+ cpu_to_be16(dsc_cfg->initial_dec_delay);
122+
123+ /* PPS 20 is 0 */
124+
125+ /* PPS 21 */
126+ pps_sdp->pps_payload.initial_scale_value =
127+ dsc_cfg->initial_scale_value;
128+
129+ /* PPS 22, 23 */
130+ pps_sdp->pps_payload.scale_increment_interval =
131+ cpu_to_be16(dsc_cfg->scale_increment_interval);
132+
133+ /* PPS 24 */
134+ pps_sdp->pps_payload.scale_decrement_interval_high =
135+ ((dsc_cfg->scale_decrement_interval &
136+ DSC_PPS_SCALE_DEC_INT_HIGH_MASK) >>
137+ DSC_PPS_MSB_SHIFT);
138+
139+ /* PPS 25 */
140+ pps_sdp->pps_payload.scale_decrement_interval_low =
141+ (dsc_cfg->scale_decrement_interval & DSC_PPS_LSB_MASK);
142+
143+ /* PPS 26[7:0], PPS 27[7:5] RESERVED */
144+
145+ /* PPS 27 */
146+ pps_sdp->pps_payload.first_line_bpg_offset =
147+ dsc_cfg->first_line_bpg_offset;
148+
149+ /* PPS 28, 29 */
150+ pps_sdp->pps_payload.nfl_bpg_offset =
151+ cpu_to_be16(dsc_cfg->nfl_bpg_offset);
152+
153+ /* PPS 30, 31 */
154+ pps_sdp->pps_payload.slice_bpg_offset =
155+ cpu_to_be16(dsc_cfg->slice_bpg_offset);
156+
157+ /* PPS 32, 33 */
158+ pps_sdp->pps_payload.initial_offset =
159+ cpu_to_be16(dsc_cfg->initial_offset);
160+
161+ /* PPS 34, 35 */
162+ pps_sdp->pps_payload.final_offset = cpu_to_be16(dsc_cfg->final_offset);
163+
164+ /* PPS 36 */
165+ pps_sdp->pps_payload.flatness_min_qp = dsc_cfg->flatness_min_qp;
166+
167+ /* PPS 37 */
168+ pps_sdp->pps_payload.flatness_max_qp = dsc_cfg->flatness_max_qp;
169+
170+ /* PPS 38, 39 */
171+ pps_sdp->pps_payload.rc_model_size =
172+ cpu_to_be16(DSC_RC_MODEL_SIZE_CONST);
173+
174+ /* PPS 40 */
175+ pps_sdp->pps_payload.rc_edge_factor = DSC_RC_EDGE_FACTOR_CONST;
176+
177+ /* PPS 41 */
178+ pps_sdp->pps_payload.rc_quant_incr_limit0 =
179+ dsc_cfg->rc_quant_incr_limit0;
180+
181+ /* PPS 42 */
182+ pps_sdp->pps_payload.rc_quant_incr_limit1 =
183+ dsc_cfg->rc_quant_incr_limit1;
184+
185+ /* PPS 43 */
186+ pps_sdp->pps_payload.rc_tgt_offset = DSC_RC_TGT_OFFSET_LO_CONST |
187+ DSC_RC_TGT_OFFSET_HI_CONST << DSC_PPS_RC_TGT_OFFSET_HI_SHIFT;
188+
189+ /* PPS 44 - 57 */
190+ for (i = 0; i < DSC_NUM_BUF_RANGES - 1; i++)
191+ pps_sdp->pps_payload.rc_buf_thresh[i] =
192+ dsc_cfg->rc_buf_thresh[i];
193+
194+ /* PPS 58 - 87 */
195+ /*
196+ * For DSC sink programming the RC Range parameter fields
197+ * are as follows: Min_qp[15:11], max_qp[10:6], offset[5:0]
198+ */
199+ for (i = 0; i < DSC_NUM_BUF_RANGES; i++) {
200+ pps_sdp->pps_payload.rc_range_parameters[i] =
201+ ((dsc_cfg->rc_range_params[i].range_min_qp <<
202+ DSC_PPS_RC_RANGE_MINQP_SHIFT) |
203+ (dsc_cfg->rc_range_params[i].range_max_qp <<
204+ DSC_PPS_RC_RANGE_MAXQP_SHIFT) |
205+ (dsc_cfg->rc_range_params[i].range_bpg_offset));
206+ pps_sdp->pps_payload.rc_range_parameters[i] =
207+ cpu_to_be16(pps_sdp->pps_payload.rc_range_parameters[i]);
208+ }
209+
210+ /* PPS 88 */
211+ pps_sdp->pps_payload.native_422_420 = dsc_cfg->native_422 |
212+ dsc_cfg->native_420 << DSC_PPS_NATIVE_420_SHIFT;
213+
214+ /* PPS 89 */
215+ pps_sdp->pps_payload.second_line_bpg_offset =
216+ dsc_cfg->second_line_bpg_offset;
217+
218+ /* PPS 90, 91 */
219+ pps_sdp->pps_payload.nsl_bpg_offset =
220+ cpu_to_be16(dsc_cfg->nsl_bpg_offset);
221+
222+ /* PPS 92, 93 */
223+ pps_sdp->pps_payload.second_line_offset_adj =
224+ cpu_to_be16(dsc_cfg->second_line_offset_adj);
225+
226+ /* PPS 94 - 127 are O */
227+}
228+EXPORT_SYMBOL(drm_dsc_pps_infoframe_pack);
drivers/gpu/drm/i915/Makefile+5−2
@@ -157,14 +157,17 @@ i915-y += dvo_ch7017.o \ · 156 unmodified lines
157157 intel_sdvo.o \
158158 intel_tv.o \
159159 vlv_dsi.o \
160− vlv_dsi_pll.o
160+ vlv_dsi_pll.o \
161+ intel_vdsc.o
161162
162163 # Post-mortem debug and GPU hang state capture
163164 i915-$(CONFIG_DRM_I915_CAPTURE_ERROR) += i915_gpu_error.o
164165 i915-$(CONFIG_DRM_I915_SELFTEST) += \
165166 selftests/i915_random.o \
166167 selftests/i915_selftest.o \
167− selftests/igt_flush_test.o
168+ selftests/igt_flush_test.o \
169+ selftests/igt_reset.o \
170+ selftests/igt_spinner.o
168171
169172 # virtual gpu code
170173 i915-y += i915_vgpu.o
drivers/gpu/drm/i915/i915_debugfs.c+39−29
@@ -943,30 +943,30 @@ static int i915_gem_fence_regs_info(struct seq_file *m, void *data) · 942 unmodified lines
943943 static ssize_t gpu_state_read(struct file *file, char __user *ubuf,
944944 size_t count, loff_t *pos)
945945 {
946− struct i915_gpu_state *error = file->private_data;
947− struct drm_i915_error_state_buf str;
946+ struct i915_gpu_state *error;
948947 ssize_t ret;
949− loff_t tmp;
948+ void *buf;
950949
950+ error = file->private_data;
951951 if (!error)
952952 return 0;
953953
954− ret = i915_error_state_buf_init(&str, error->i915, count, *pos);
955− if (ret)
956− return ret;
954+ /* Bounce buffer required because of kernfs __user API convenience. */
955+ buf = kmalloc(count, GFP_KERNEL);
956+ if (!buf)
957+ return -ENOMEM;
957958
958− ret = i915_error_state_to_str(&str, error);
959− if (ret)
959+ ret = i915_gpu_state_copy_to_buffer(error, buf, *pos, count);
960+ if (ret <= 0)
960961 goto out;
961962
962− tmp = 0;
963− ret = simple_read_from_buffer(ubuf, count, &tmp, str.buf, str.bytes);
964− if (ret < 0)
965− goto out;
963+ if (!copy_to_user(ubuf, buf, ret))
964+ *pos += ret;
965+ else
966+ ret = -EFAULT;
966967
967− *pos = str.start + ret;
968968 out:
969− i915_error_state_buf_release(&str);
969+ kfree(buf);
970970 return ret;
971971 }
972972
@@ -3375,13 +3375,15 @@ static int i915_shared_dplls_info(struct seq_file *m, void *unused) · 2402 unmodified lines
33753375
33763376 static int i915_wa_registers(struct seq_file *m, void *unused)
33773377 {
3378− struct i915_workarounds *wa = &node_to_i915(m->private)->workarounds;
3379− int i;
3378+ struct drm_i915_private *i915 = node_to_i915(m->private);
3379+ const struct i915_wa_list *wal = &i915->engine[RCS]->ctx_wa_list;
3380+ struct i915_wa *wa;
3381+ unsigned int i;
33803382
3381− seq_printf(m, "Workarounds applied: %d\n", wa->count);
3382− for (i = 0; i < wa->count; ++i)
3383+ seq_printf(m, "Workarounds applied: %u\n", wal->count);
3384+ for (i = 0, wa = wal->list; i < wal->count; i++, wa++)
33833385 seq_printf(m, "0x%X: 0x%08X, mask: 0x%08X\n",
3384− wa->reg[i].addr, wa->reg[i].value, wa->reg[i].mask);
3386+ i915_mmio_reg_offset(wa->reg), wa->val, wa->mask);
33853387
33863388 return 0;
33873389 }
@@ -3441,31 +3443,32 @@ static int i915_ddb_info(struct seq_file *m, void *unused) · 53 unmodified lines
34413443 {
34423444 struct drm_i915_private *dev_priv = node_to_i915(m->private);
34433445 struct drm_device *dev = &dev_priv->drm;
3444− struct skl_ddb_allocation *ddb;
34453446 struct skl_ddb_entry *entry;
3446− enum pipe pipe;
3447− int plane;
3447+ struct intel_crtc *crtc;
34483448
34493449 if (INTEL_GEN(dev_priv) < 9)
34503450 return -ENODEV;
34513451
34523452 drm_modeset_lock_all(dev);
34533453
3454− ddb = &dev_priv->wm.skl_hw.ddb;
3455−
34563454 seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size");
34573455
3458− for_each_pipe(dev_priv, pipe) {
3456+ for_each_intel_crtc(&dev_priv->drm, crtc) {
3457+ struct intel_crtc_state *crtc_state =
3458+ to_intel_crtc_state(crtc->base.state);
3459+ enum pipe pipe = crtc->pipe;
3460+ enum plane_id plane_id;
3461+
34593462 seq_printf(m, "Pipe %c\n", pipe_name(pipe));
34603463
3461− for_each_universal_plane(dev_priv, pipe, plane) {
3462− entry = &ddb->plane[pipe][plane];
3463− seq_printf(m, " Plane%-8d%8u%8u%8u\n", plane + 1,
3464+ for_each_plane_id_on_crtc(crtc, plane_id) {
3465+ entry = &crtc_state->wm.skl.plane_ddb_y[plane_id];
3466+ seq_printf(m, " Plane%-8d%8u%8u%8u\n", plane_id + 1,
34643467 entry->start, entry->end,
34653468 skl_ddb_entry_size(entry));
34663469 }
34673470
3468− entry = &ddb->plane[pipe][PLANE_CURSOR];
3471+ entry = &crtc_state->wm.skl.plane_ddb_y[PLANE_CURSOR];
34693472 seq_printf(m, " %-13s%8u%8u%8u\n", "Cursor", entry->start,
34703473 entry->end, skl_ddb_entry_size(entry));
34713474 }
@@ -4592,6 +4595,13 @@ static int i915_hpd_storm_ctl_show(struct seq_file *m, void *data) · 1120 unmodified lines
45924595 struct drm_i915_private *dev_priv = m->private;
45934596 struct i915_hotplug *hotplug = &dev_priv->hotplug;
45944597
4598+ /* Synchronize with everything first in case there's been an HPD
4599+ * storm, but we haven't finished handling it in the kernel yet
4600+ */
4601+ synchronize_irq(dev_priv->drm.irq);
4602+ flush_work(&dev_priv->hotplug.dig_port_work);
4603+ flush_work(&dev_priv->hotplug.hotplug_work);
4604+
45954605 seq_printf(m, "Threshold: %d\n", hotplug->hpd_storm_threshold);
45964606 seq_printf(m, "Detected: %s\n",
45974607 yesno(delayed_work_pending(&hotplug->reenable_work)));
drivers/gpu/drm/i915/i915_drv.c+22−5
@@ -53,6 +53,7 @@ · 52 unmodified lines
5353 #include "i915_vgpu.h"
5454 #include "intel_drv.h"
5555 #include "intel_uc.h"
56+#include "intel_workarounds.h"
5657
5758 static struct drm_driver driver;
5859
@@ -287,7 +288,7 @@ static void intel_detect_pch(struct drm_i915_private *dev_priv) · 228 unmodified lines
287288 * Use PCH_NOP (PCH but no South Display) for PCH platforms without
288289 * display.
289290 */
290− if (pch && INTEL_INFO(dev_priv)->num_pipes == 0) {
291+ if (pch && !HAS_DISPLAY(dev_priv)) {
291292 DRM_DEBUG_KMS("Display disabled, reverting to NOP PCH\n");
292293 dev_priv->pch_type = PCH_NOP;
293294 dev_priv->pch_id = 0;
@@ -645,7 +646,7 @@ static int i915_load_modeset_init(struct drm_device *dev) · 351 unmodified lines
645646 if (i915_inject_load_failure())
646647 return -ENODEV;
647648
648− if (INTEL_INFO(dev_priv)->num_pipes) {
649+ if (HAS_DISPLAY(dev_priv)) {
649650 ret = drm_vblank_init(&dev_priv->drm,
650651 INTEL_INFO(dev_priv)->num_pipes);
651652 if (ret)
@@ -696,7 +697,7 @@ static int i915_load_modeset_init(struct drm_device *dev) · 44 unmodified lines
696697
697698 intel_overlay_setup(dev_priv);
698699
699− if (INTEL_INFO(dev_priv)->num_pipes == 0)
700+ if (!HAS_DISPLAY(dev_priv))
700701 return 0;
701702
702703 ret = intel_fbdev_init(dev);
@@ -868,6 +869,7 @@ static void intel_detect_preproduction_hw(struct drm_i915_private *dev_priv) · 165 unmodified lines
868869 pre |= IS_HSW_EARLY_SDV(dev_priv);
869870 pre |= IS_SKL_REVID(dev_priv, 0, SKL_REVID_F0);
870871 pre |= IS_BXT_REVID(dev_priv, 0, BXT_REVID_B_LAST);
872+ pre |= IS_KBL_REVID(dev_priv, 0, KBL_REVID_A0);
871873
872874 if (pre) {
873875 DRM_ERROR("This is a pre-production stepping. "
@@ -1383,6 +1385,20 @@ static int i915_driver_init_hw(struct drm_i915_private *dev_priv) · 509 unmodified lines
13831385 }
13841386 }
13851387
1388+ if (HAS_EXECLISTS(dev_priv)) {
1389+ /*
1390+ * Older GVT emulation depends upon intercepting CSB mmio,
1391+ * which we no longer use, preferring to use the HWSP cache
1392+ * instead.
1393+ */
1394+ if (intel_vgpu_active(dev_priv) &&
1395+ !intel_vgpu_has_hwsp_emulation(dev_priv)) {
1396+ i915_report_error(dev_priv,
1397+ "old vGPU host found, support for HWSP emulation required\n");
1398+ return -ENXIO;
1399+ }
1400+ }
1401+
13861402 intel_sanitize_options(dev_priv);
13871403
13881404 i915_perf_init(dev_priv);
@@ -1452,6 +1468,7 @@ static int i915_driver_init_hw(struct drm_i915_private *dev_priv) · 63 unmodified lines
14521468
14531469 intel_uncore_sanitize(dev_priv);
14541470
1471+ intel_gt_init_workarounds(dev_priv);
14551472 i915_gem_load_init_fences(dev_priv);
14561473
14571474 /* On the 945G/GM, the chipset reports the MSI capability on the
@@ -1551,7 +1568,7 @@ static void i915_driver_register(struct drm_i915_private *dev_priv) · 93 unmodified lines
15511568 } else
15521569 DRM_ERROR("Failed to register driver for userspace access!\n");
15531570
1554− if (INTEL_INFO(dev_priv)->num_pipes) {
1571+ if (HAS_DISPLAY(dev_priv)) {
15551572 /* Must be done after probing outputs */
15561573 intel_opregion_register(dev_priv);
15571574 acpi_video_register();
@@ -1575,7 +1592,7 @@ static void i915_driver_register(struct drm_i915_private *dev_priv) · 17 unmodified lines
15751592 * We need to coordinate the hotplugs with the asynchronous fbdev
15761593 * configuration, for which we use the fbdev->async_cookie.
15771594 */
1578− if (INTEL_INFO(dev_priv)->num_pipes)
1595+ if (HAS_DISPLAY(dev_priv))
15791596 drm_kms_helper_poll_init(dev);
15801597
15811598 intel_power_domains_enable(dev_priv);
drivers/gpu/drm/i915/i915_drv.h+31−31
@@ -53,6 +53,7 @@ · 52 unmodified lines
5353 #include <drm/drm_auth.h>
5454 #include <drm/drm_cache.h>
5555 #include <drm/drm_util.h>
56+#include <drm/drm_dsc.h>
5657
5758 #include "i915_fixed.h"
5859 #include "i915_params.h"
@@ -68,6 +69,7 @@ · 9 unmodified lines
6869 #include "intel_ringbuffer.h"
6970 #include "intel_uncore.h"
7071 #include "intel_wopcm.h"
72+#include "intel_workarounds.h"
7173 #include "intel_uc.h"
7274
7375 #include "i915_gem.h"
@@ -88,8 +90,8 @@ · 14 unmodified lines
8890
8991 #define DRIVER_NAME "i915"
9092 #define DRIVER_DESC "Intel Graphics"
91−#define DRIVER_DATE "20181122"
92−#define DRIVER_TIMESTAMP 1542898187
93+#define DRIVER_DATE "20181204"
94+#define DRIVER_TIMESTAMP 1543944377
9395
9496 /* Use I915_STATE_WARN(x) and I915_STATE_WARN_ON() (rather than WARN() and
9597 * WARN_ON()) for hw state sanity checks to check for unexpected conditions
@@ -494,6 +496,7 @@ struct i915_psr { · 398 unmodified lines
494496 bool sink_support;
495497 bool prepared, enabled;
496498 struct intel_dp *dp;
499+ enum pipe pipe;
497500 bool active;
498501 struct work_struct work;
499502 unsigned busy_frontbuffer_bits;
@@ -504,6 +507,8 @@ struct i915_psr { · 4 unmodified lines
504507 u8 sink_sync_latency;
505508 ktime_t last_entry_attempt;
506509 ktime_t last_exit;
510+ bool sink_not_reliable;
511+ bool irq_aux_error;
507512 };
508513
509514 enum intel_pch {
@@ -1093,9 +1098,6 @@ static inline bool skl_ddb_entry_equal(const struct skl_ddb_entry *e1, · 583 unmodified lines
10931098 }
10941099
10951100 struct skl_ddb_allocation {
1096− /* packed/y */
1097− struct skl_ddb_entry plane[I915_MAX_PIPES][I915_MAX_PLANES];
1098− struct skl_ddb_entry uv_plane[I915_MAX_PIPES][I915_MAX_PLANES];
10991101 u8 enabled_slices; /* GEN11 has configurable 2 slices */
11001102 };
11011103
@@ -1188,20 +1190,6 @@ struct i915_frontbuffer_tracking { · 86 unmodified lines
11881190 unsigned flip_bits;
11891191 };
11901192
1191−struct i915_wa_reg {
1192− u32 addr;
1193− u32 value;
1194− /* bitmask representing WA bits */
1195− u32 mask;
1196−};
1197−
1198−#define I915_MAX_WA_REGS 16
1199−
1200−struct i915_workarounds {
1201− struct i915_wa_reg reg[I915_MAX_WA_REGS];
1202− u32 count;
1203−};
1204−
12051193 struct i915_virtual_gpu {
12061194 bool active;
12071195 u32 caps;
@@ -1651,7 +1639,7 @@ struct drm_i915_private { · 443 unmodified lines
16511639
16521640 int dpio_phy_iosf_port[I915_NUM_PHYS_VLV];
16531641
1654− struct i915_workarounds workarounds;
1642+ struct i915_wa_list gt_wa_list;
16551643
16561644 struct i915_frontbuffer_tracking fb_tracking;
16571645
@@ -1995,6 +1983,8 @@ struct drm_i915_private { · 337 unmodified lines
19951983 struct delayed_work idle_work;
19961984
19971985 ktime_t last_init_time;
1986+
1987+ struct i915_vma *scratch;
19981988 } gt;
19991989
20001990 /* perform PHY state sanity checks? */
@@ -2448,9 +2438,9 @@ intel_info(const struct drm_i915_private *dev_priv) · 447 unmodified lines
24482438 ((sizes) & ~(dev_priv)->info.page_sizes) == 0; \
24492439 })
24502440
2451−#define HAS_OVERLAY(dev_priv) ((dev_priv)->info.has_overlay)
2441+#define HAS_OVERLAY(dev_priv) ((dev_priv)->info.display.has_overlay)
24522442 #define OVERLAY_NEEDS_PHYSICAL(dev_priv) \
2453− ((dev_priv)->info.overlay_needs_physical)
2443+ ((dev_priv)->info.display.overlay_needs_physical)
24542444
24552445 /* Early gen2 have a totally busted CS tlb and require pinned batches. */
24562446 #define HAS_BROKEN_CS_TLB(dev_priv) (IS_I830(dev_priv) || IS_I845G(dev_priv))
@@ -2471,31 +2461,31 @@ intel_info(const struct drm_i915_private *dev_priv) · 14 unmodified lines
24712461 #define HAS_128_BYTE_Y_TILING(dev_priv) (!IS_GEN2(dev_priv) && \
24722462 !(IS_I915G(dev_priv) || \
24732463 IS_I915GM(dev_priv)))
2474−#define SUPPORTS_TV(dev_priv) ((dev_priv)->info.supports_tv)
2475−#define I915_HAS_HOTPLUG(dev_priv) ((dev_priv)->info.has_hotplug)
2464+#define SUPPORTS_TV(dev_priv) ((dev_priv)->info.display.supports_tv)
2465+#define I915_HAS_HOTPLUG(dev_priv) ((dev_priv)->info.display.has_hotplug)
24762466
24772467 #define HAS_FW_BLC(dev_priv) (INTEL_GEN(dev_priv) > 2)
2478−#define HAS_FBC(dev_priv) ((dev_priv)->info.has_fbc)
2468+#define HAS_FBC(dev_priv) ((dev_priv)->info.display.has_fbc)
24792469 #define HAS_CUR_FBC(dev_priv) (!HAS_GMCH_DISPLAY(dev_priv) && INTEL_GEN(dev_priv) >= 7)
24802470
24812471 #define HAS_IPS(dev_priv) (IS_HSW_ULT(dev_priv) || IS_BROADWELL(dev_priv))
24822472
2483−#define HAS_DP_MST(dev_priv) ((dev_priv)->info.has_dp_mst)
2473+#define HAS_DP_MST(dev_priv) ((dev_priv)->info.display.has_dp_mst)
24842474
2485−#define HAS_DDI(dev_priv) ((dev_priv)->info.has_ddi)
2475+#define HAS_DDI(dev_priv) ((dev_priv)->info.display.has_ddi)
24862476 #define HAS_FPGA_DBG_UNCLAIMED(dev_priv) ((dev_priv)->info.has_fpga_dbg)
2487−#define HAS_PSR(dev_priv) ((dev_priv)->info.has_psr)
2477+#define HAS_PSR(dev_priv) ((dev_priv)->info.display.has_psr)
24882478
24892479 #define HAS_RC6(dev_priv) ((dev_priv)->info.has_rc6)
24902480 #define HAS_RC6p(dev_priv) ((dev_priv)->info.has_rc6p)
24912481 #define HAS_RC6pp(dev_priv) (false) /* HW was never validated */
24922482
2493−#define HAS_CSR(dev_priv) ((dev_priv)->info.has_csr)
2483+#define HAS_CSR(dev_priv) ((dev_priv)->info.display.has_csr)
24942484
24952485 #define HAS_RUNTIME_PM(dev_priv) ((dev_priv)->info.has_runtime_pm)
24962486 #define HAS_64BIT_RELOC(dev_priv) ((dev_priv)->info.has_64bit_reloc)
24972487
2498−#define HAS_IPC(dev_priv) ((dev_priv)->info.has_ipc)
2488+#define HAS_IPC(dev_priv) ((dev_priv)->info.display.has_ipc)
24992489
25002490 /*
25012491 * For now, anything with a GuC requires uCode loading, and then supports
@@ -2556,7 +2546,7 @@ intel_info(const struct drm_i915_private *dev_priv) · 54 unmodified lines
25562546 #define HAS_PCH_NOP(dev_priv) (INTEL_PCH_TYPE(dev_priv) == PCH_NOP)
25572547 #define HAS_PCH_SPLIT(dev_priv) (INTEL_PCH_TYPE(dev_priv) != PCH_NONE)
25582548
2559−#define HAS_GMCH_DISPLAY(dev_priv) ((dev_priv)->info.has_gmch_display)
2549+#define HAS_GMCH_DISPLAY(dev_priv) ((dev_priv)->info.display.has_gmch_display)
25602550
25612551 #define HAS_LSPCON(dev_priv) (INTEL_GEN(dev_priv) >= 9)
25622552
@@ -2568,6 +2558,8 @@ intel_info(const struct drm_i915_private *dev_priv) · 5 unmodified lines
25682558 #define GT_FREQUENCY_MULTIPLIER 50
25692559 #define GEN9_FREQ_SCALER 3
25702560
2561+#define HAS_DISPLAY(dev_priv) (INTEL_INFO(dev_priv)->num_pipes > 0)
2562+
25712563 #include "i915_trace.h"
25722564
25732565 static inline bool intel_vtd_active(void)
@@ -3340,6 +3332,9 @@ extern void intel_rps_mark_interactive(struct drm_i915_private *i915, · 766 unmodified lines
33403332 bool interactive);
33413333 extern bool intel_set_memory_cxsr(struct drm_i915_private *dev_priv,
33423334 bool enable);
3335+void intel_dsc_enable(struct intel_encoder *encoder,
3336+ const struct intel_crtc_state *crtc_state);
3337+void intel_dsc_disable(const struct intel_crtc_state *crtc_state);
33433338
33443339 int i915_reg_read_ioctl(struct drm_device *dev, void *data,
33453340 struct drm_file *file);
@@ -3720,4 +3715,9 @@ static inline int intel_hws_csb_write_index(struct drm_i915_private *i915) · 374 unmodified lines
37203715 return I915_HWS_CSB_WRITE_INDEX;
37213716 }
37223717
3718+static inline u32 i915_scratch_offset(const struct drm_i915_private *i915)
3719+{
3720+ return i915_ggtt_offset(i915->gt.scratch);
3721+}
3722+
37233723 #endif
drivers/gpu/drm/i915/i915_gem.c+65−46
@@ -3308,16 +3308,6 @@ void i915_gem_reset_finish(struct drm_i915_private *dev_priv) · 3307 unmodified lines
33083308 }
33093309
33103310 static void nop_submit_request(struct i915_request *request)
3311−{
3312− GEM_TRACE("%s fence %llx:%d -> -EIO\n",
3313− request->engine->name,
3314− request->fence.context, request->fence.seqno);
3315− dma_fence_set_error(&request->fence, -EIO);
3316−
3317− i915_request_submit(request);
3318−}
3319−
3320−static void nop_complete_submit_request(struct i915_request *request)
33213311 {
33223312 unsigned long flags;
33233313
@@ -3354,57 +3344,33 @@ void i915_gem_set_wedged(struct drm_i915_private *i915) · 30 unmodified lines
33543344 * rolling the global seqno forward (since this would complete requests
33553345 * for which we haven't set the fence error to EIO yet).
33563346 */
3357− for_each_engine(engine, i915, id) {
3347+ for_each_engine(engine, i915, id)
33583348 i915_gem_reset_prepare_engine(engine);
33593349
3360− engine->submit_request = nop_submit_request;
3361− engine->schedule = NULL;
3362− }
3363− i915->caps.scheduler = 0;
3364−
33653350 /* Even if the GPU reset fails, it should still stop the engines */
33663351 if (INTEL_GEN(i915) >= 5)
33673352 intel_gpu_reset(i915, ALL_ENGINES);
33683353
3369− /*
3370− * Make sure no one is running the old callback before we proceed with
3371− * cancelling requests and resetting the completion tracking. Otherwise
3372− * we might submit a request to the hardware which never completes.
3373− */
3374− synchronize_rcu();
3375−
33763354 for_each_engine(engine, i915, id) {
3377− /* Mark all executing requests as skipped */
3378− engine->cancel_requests(engine);
3379−
3380− /*
3381− * Only once we've force-cancelled all in-flight requests can we
3382− * start to complete all requests.
3383− */
3384− engine->submit_request = nop_complete_submit_request;
3355+ engine->submit_request = nop_submit_request;
3356+ engine->schedule = NULL;
33853357 }
3358+ i915->caps.scheduler = 0;
33863359
33873360 /*
33883361 * Make sure no request can slip through without getting completed by
33893362 * either this call here to intel_engine_init_global_seqno, or the one
3390− * in nop_complete_submit_request.
3363+ * in nop_submit_request.
33913364 */
33923365 synchronize_rcu();
33933366
3394− for_each_engine(engine, i915, id) {
3395− unsigned long flags;
3396−
3397− /*
3398− * Mark all pending requests as complete so that any concurrent
3399− * (lockless) lookup doesn't try and wait upon the request as we
3400− * reset it.
3401− */
3402− spin_lock_irqsave(&engine->timeline.lock, flags);
3403− intel_engine_init_global_seqno(engine,
3404− intel_engine_last_submit(engine));
3405− spin_unlock_irqrestore(&engine->timeline.lock, flags);
3367+ /* Mark all executing requests as skipped */
3368+ for_each_engine(engine, i915, id)
3369+ engine->cancel_requests(engine);
34063370
3371+ for_each_engine(engine, i915, id) {
34073372 i915_gem_reset_finish_engine(engine);
3373+ intel_engine_wakeup(engine);
34083374 }
34093375
34103376 out:
@@ -5334,7 +5300,10 @@ int i915_gem_init_hw(struct drm_i915_private *dev_priv) · 1923 unmodified lines
53345300 I915_WRITE(MI_PREDICATE_RESULT_2, IS_HSW_GT3(dev_priv) ?
53355301 LOWER_SLICE_ENABLED : LOWER_SLICE_DISABLED);
53365302
5337− intel_gt_workarounds_apply(dev_priv);
5303+ /* Apply the GT workarounds... */
5304+ intel_gt_apply_workarounds(dev_priv);
5305+ /* ...and determine whether they are sticking. */
5306+ intel_gt_verify_workarounds(dev_priv, "init");
53385307
53395308 i915_gem_init_swizzling(dev_priv);
53405309
@@ -5529,6 +5498,44 @@ err_active: · 188 unmodified lines
55295498 goto out_ctx;
55305499 }
55315500
5501+static int
5502+i915_gem_init_scratch(struct drm_i915_private *i915, unsigned int size)
5503+{
5504+ struct drm_i915_gem_object *obj;
5505+ struct i915_vma *vma;
5506+ int ret;
5507+
5508+ obj = i915_gem_object_create_stolen(i915, size);
5509+ if (!obj)
5510+ obj = i915_gem_object_create_internal(i915, size);
5511+ if (IS_ERR(obj)) {
5512+ DRM_ERROR("Failed to allocate scratch page\n");
5513+ return PTR_ERR(obj);
5514+ }
5515+
5516+ vma = i915_vma_instance(obj, &i915->ggtt.vm, NULL);
5517+ if (IS_ERR(vma)) {
5518+ ret = PTR_ERR(vma);
5519+ goto err_unref;
5520+ }
5521+
5522+ ret = i915_vma_pin(vma, 0, 0, PIN_GLOBAL | PIN_HIGH);
5523+ if (ret)
5524+ goto err_unref;
5525+
5526+ i915->gt.scratch = vma;
5527+ return 0;
5528+
5529+err_unref:
5530+ i915_gem_object_put(obj);
5531+ return ret;
5532+}
5533+
5534+static void i915_gem_fini_scratch(struct drm_i915_private *i915)
5535+{
5536+ i915_vma_unpin_and_release(&i915->gt.scratch, 0);
5537+}
5538+
55325539 int i915_gem_init(struct drm_i915_private *dev_priv)
55335540 {
55345541 int ret;
@@ -5575,12 +5582,19 @@ int i915_gem_init(struct drm_i915_private *dev_priv) · 40 unmodified lines
55755582 goto err_unlock;
55765583 }
55775584
5578− ret = i915_gem_contexts_init(dev_priv);
5585+ ret = i915_gem_init_scratch(dev_priv,
5586+ IS_GEN2(dev_priv) ? SZ_256K : PAGE_SIZE);
55795587 if (ret) {
55805588 GEM_BUG_ON(ret == -EIO);
55815589 goto err_ggtt;
55825590 }
55835591
5592+ ret = i915_gem_contexts_init(dev_priv);
5593+ if (ret) {
5594+ GEM_BUG_ON(ret == -EIO);
5595+ goto err_scratch;
5596+ }
5597+
55845598 ret = intel_engines_init(dev_priv);
55855599 if (ret) {
55865600 GEM_BUG_ON(ret == -EIO);
@@ -5653,6 +5667,8 @@ err_pm: · 66 unmodified lines
56535667 err_context:
56545668 if (ret != -EIO)
56555669 i915_gem_contexts_fini(dev_priv);
5670+err_scratch:
5671+ i915_gem_fini_scratch(dev_priv);
56565672 err_ggtt:
56575673 err_unlock:
56585674 intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
@@ -5704,8 +5720,11 @@ void i915_gem_fini(struct drm_i915_private *dev_priv) · 45 unmodified lines
57045720 intel_uc_fini(dev_priv);
57055721 i915_gem_cleanup_engines(dev_priv);
57065722 i915_gem_contexts_fini(dev_priv);
5723+ i915_gem_fini_scratch(dev_priv);
57075724 mutex_unlock(&dev_priv->drm.struct_mutex);
57085725
5726+ intel_wa_list_free(&dev_priv->gt_wa_list);
5727+
57095728 intel_cleanup_gt_powersave(dev_priv);
57105729
57115730 intel_uc_fini_misc(dev_priv);
drivers/gpu/drm/i915/i915_gem_context.c+1−5
@@ -535,16 +535,12 @@ static bool needs_preempt_context(struct drm_i915_private *i915) · 534 unmodified lines
535535 int i915_gem_contexts_init(struct drm_i915_private *dev_priv)
536536 {
537537 struct i915_gem_context *ctx;
538− int ret;
539538
540539 /* Reassure ourselves we are only called once */
541540 GEM_BUG_ON(dev_priv->kernel_context);
542541 GEM_BUG_ON(dev_priv->preempt_context);
543542
544− ret = intel_ctx_workarounds_init(dev_priv);
545− if (ret)
546− return ret;
547−
543+ intel_engine_init_ctx_wa(dev_priv->engine[RCS]);
548544 init_contexts(dev_priv);
549545
550546 /* lowest priority; idle task */
drivers/gpu/drm/i915/i915_gpu_error.c+207−130
@@ -27,11 +27,14 @@ · 26 unmodified lines
2727 *
2828 */
2929
30−#include <linux/utsname.h>
30+#include <linux/ascii85.h>
31+#include <linux/nmi.h>
32+#include <linux/scatterlist.h>
3133 #include <linux/stop_machine.h>
34+#include <linux/utsname.h>
3235 #include <linux/zlib.h>
36+
3337 #include <drm/drm_print.h>
34−#include <linux/ascii85.h>
3538
3639 #include "i915_gpu_error.h"
3740 #include "i915_drv.h"
@@ -77,112 +80,110 @@ static const char *purgeable_flag(int purgeable) · 39 unmodified lines
7780 return purgeable ? " purgeable" : "";
7881 }
7982
80−static bool __i915_error_ok(struct drm_i915_error_state_buf *e)
83+static void __sg_set_buf(struct scatterlist *sg,
84+ void *addr, unsigned int len, loff_t it)
8185 {
82−
83− if (!e->err && WARN(e->bytes > (e->size - 1), "overflow")) {
84− e->err = -ENOSPC;
85− return false;
86− }
87−
88− if (e->bytes == e->size - 1 || e->err)
89− return false;
90−
91− return true;
86+ sg->page_link = (unsigned long)virt_to_page(addr);
87+ sg->offset = offset_in_page(addr);
88+ sg->length = len;
89+ sg->dma_address = it;
9290 }
9391
94−static bool __i915_error_seek(struct drm_i915_error_state_buf *e,
95− unsigned len)
92+static bool __i915_error_grow(struct drm_i915_error_state_buf *e, size_t len)
9693 {
97− if (e->pos + len <= e->start) {
98− e->pos += len;
94+ if (!len)
9995 return false;
100− }
10196
102− /* First vsnprintf needs to fit in its entirety for memmove */
103− if (len >= e->size) {
104− e->err = -EIO;
105− return false;
106− }
97+ if (e->bytes + len + 1 <= e->size)
98+ return true;
10799
108− return true;
109−}
100+ if (e->bytes) {
101+ __sg_set_buf(e->cur++, e->buf, e->bytes, e->iter);
102+ e->iter += e->bytes;
103+ e->buf = NULL;
104+ e->bytes = 0;
105+ }
110106
111−static void __i915_error_advance(struct drm_i915_error_state_buf *e,
112− unsigned len)
113−{
114− /* If this is first printf in this window, adjust it so that
115− * start position matches start of the buffer
116− */
107+ if (e->cur == e->end) {
108+ struct scatterlist *sgl;
117109
118− if (e->pos < e->start) {
119− const size_t off = e->start - e->pos;
110+ sgl = (typeof(sgl))__get_free_page(GFP_KERNEL);
111+ if (!sgl) {
112+ e->err = -ENOMEM;
113+ return false;
114+ }
120115
121− /* Should not happen but be paranoid */
122− if (off > len || e->bytes) {
123− e->err = -EIO;
124− return;
116+ if (e->cur) {
117+ e->cur->offset = 0;
118+ e->cur->length = 0;
119+ e->cur->page_link =
120+ (unsigned long)sgl | SG_CHAIN;
121+ } else {
122+ e->sgl = sgl;
125123 }
126124
127− memmove(e->buf, e->buf + off, len - off);
128− e->bytes = len - off;
129− e->pos = e->start;
130− return;
125+ e->cur = sgl;
126+ e->end = sgl + SG_MAX_SINGLE_ALLOC - 1;
131127 }
132128
133− e->bytes += len;
134− e->pos += len;
129+ e->size = ALIGN(len + 1, SZ_64K);
130+ e->buf = kmalloc(e->size, GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY);
131+ if (!e->buf) {
132+ e->size = PAGE_ALIGN(len + 1);
133+ e->buf = kmalloc(e->size, GFP_KERNEL);
134+ }
135+ if (!e->buf) {
136+ e->err = -ENOMEM;
137+ return false;
138+ }
139+
140+ return true;
135141 }
136142
137143 __printf(2, 0)
138144 static void i915_error_vprintf(struct drm_i915_error_state_buf *e,
139− const char *f, va_list args)
145+ const char *fmt, va_list args)
140146 {
141− unsigned len;
147+ va_list ap;
148+ int len;
142149
143− if (!__i915_error_ok(e))
150+ if (e->err)
144151 return;
145152
146− /* Seek the first printf which is hits start position */
147− if (e->pos < e->start) {
148− va_list tmp;
149−
150− va_copy(tmp, args);
151− len = vsnprintf(NULL, 0, f, tmp);
152− va_end(tmp);
153−
154− if (!__i915_error_seek(e, len))
155− return;
153+ va_copy(ap, args);
154+ len = vsnprintf(NULL, 0, fmt, ap);
155+ va_end(ap);
156+ if (len <= 0) {
157+ e->err = len;
158+ return;
156159 }
157160
158− len = vsnprintf(e->buf + e->bytes, e->size - e->bytes, f, args);
159− if (len >= e->size - e->bytes)
160− len = e->size - e->bytes - 1;
161+ if (!__i915_error_grow(e, len))
162+ return;
161163
162− __i915_error_advance(e, len);
164+ GEM_BUG_ON(e->bytes >= e->size);
165+ len = vscnprintf(e->buf + e->bytes, e->size - e->bytes, fmt, args);
166+ if (len < 0) {
167+ e->err = len;
168+ return;
169+ }
170+ e->bytes += len;
163171 }
164172
165−static void i915_error_puts(struct drm_i915_error_state_buf *e,
166− const char *str)
173+static void i915_error_puts(struct drm_i915_error_state_buf *e, const char *str)
167174 {
168175 unsigned len;
169176
170− if (!__i915_error_ok(e))
177+ if (e->err || !str)
171178 return;
172179
173180 len = strlen(str);
181+ if (!__i915_error_grow(e, len))
182+ return;
174183
175− /* Seek the first printf which is hits start position */
176− if (e->pos < e->start) {
177− if (!__i915_error_seek(e, len))
178− return;
179− }
180−
181− if (len >= e->size - e->bytes)
182− len = e->size - e->bytes - 1;
184+ GEM_BUG_ON(e->bytes + len > e->size);
183185 memcpy(e->buf + e->bytes, str, len);
184−
185− __i915_error_advance(e, len);
186+ e->bytes += len;
186187 }
187188
188189 #define err_printf(e, ...) i915_error_printf(e, __VA_ARGS__)
@@ -268,6 +269,8 @@ static int compress_page(struct compress *c, · 79 unmodified lines
268269
269270 if (zlib_deflate(zstream, Z_NO_FLUSH) != Z_OK)
270271 return -EIO;
272+
273+ touch_nmi_watchdog();
271274 } while (zstream->avail_in);
272275
273276 /* Fallback to uncompressed if we increase size? */
@@ -635,21 +638,29 @@ static void err_print_uc(struct drm_i915_error_state_buf *m, · 361 unmodified lines
635638 print_error_obj(m, NULL, "GuC log buffer", error_uc->guc_log);
636639 }
637640
638−int i915_error_state_to_str(struct drm_i915_error_state_buf *m,
639− const struct i915_gpu_state *error)
641+static void err_free_sgl(struct scatterlist *sgl)
640642 {
641− struct drm_i915_private *dev_priv = m->i915;
642− struct drm_i915_error_object *obj;
643− struct timespec64 ts;
644− int i, j;
643+ while (sgl) {
644+ struct scatterlist *sg;
645645
646− if (!error) {
647− err_printf(m, "No error state collected\n");
648− return 0;
646+ for (sg = sgl; !sg_is_chain(sg); sg++) {
647+ kfree(sg_virt(sg));
648+ if (sg_is_last(sg))
649+ break;
650+ }
651+
652+ sg = sg_is_last(sg) ? NULL : sg_chain_ptr(sg);
653+ free_page((unsigned long)sgl);
654+ sgl = sg;
649655 }
656+}
650657
651− if (IS_ERR(error))
652− return PTR_ERR(error);
658+static void __err_print_to_sgl(struct drm_i915_error_state_buf *m,
659+ struct i915_gpu_state *error)
660+{
661+ struct drm_i915_error_object *obj;
662+ struct timespec64 ts;
663+ int i, j;
653664
654665 if (*error->error_msg)
655666 err_printf(m, "%s\n", error->error_msg);
@@ -683,12 +694,12 @@ int i915_error_state_to_str(struct drm_i915_error_state_buf *m, · 27 unmodified lines
683694 err_printf(m, "Reset count: %u\n", error->reset_count);
684695 err_printf(m, "Suspend count: %u\n", error->suspend_count);
685696 err_printf(m, "Platform: %s\n", intel_platform_name(error->device_info.platform));
686− err_print_pciid(m, error->i915);
697+ err_print_pciid(m, m->i915);
687698
688699 err_printf(m, "IOMMU enabled?: %d\n", error->iommu);
689700
690− if (HAS_CSR(dev_priv)) {
691− struct intel_csr *csr = &dev_priv->csr;
701+ if (HAS_CSR(m->i915)) {
702+ struct intel_csr *csr = &m->i915->csr;
692703
693704 err_printf(m, "DMC loaded: %s\n",
694705 yesno(csr->dmc_payload != NULL));
@@ -708,22 +719,23 @@ int i915_error_state_to_str(struct drm_i915_error_state_buf *m, · 13 unmodified lines
708719 err_printf(m, "FORCEWAKE: 0x%08x\n", error->forcewake);
709720 err_printf(m, "DERRMR: 0x%08x\n", error->derrmr);
710721 err_printf(m, "CCID: 0x%08x\n", error->ccid);
711− err_printf(m, "Missed interrupts: 0x%08lx\n", dev_priv->gpu_error.missed_irq_rings);
722+ err_printf(m, "Missed interrupts: 0x%08lx\n",
723+ m->i915->gpu_error.missed_irq_rings);
712724
713725 for (i = 0; i < error->nfence; i++)
714726 err_printf(m, " fence[%d] = %08llx\n", i, error->fence[i]);
715727
716− if (INTEL_GEN(dev_priv) >= 6) {
728+ if (INTEL_GEN(m->i915) >= 6) {
717729 err_printf(m, "ERROR: 0x%08x\n", error->error);
718730
719− if (INTEL_GEN(dev_priv) >= 8)
731+ if (INTEL_GEN(m->i915) >= 8)
720732 err_printf(m, "FAULT_TLB_DATA: 0x%08x 0x%08x\n",
721733 error->fault_data1, error->fault_data0);
722734
723735 err_printf(m, "DONE_REG: 0x%08x\n", error->done_reg);
724736 }
725737
726− if (IS_GEN7(dev_priv))
738+ if (IS_GEN7(m->i915))
727739 err_printf(m, "ERR_INT: 0x%08x\n", error->err_int);
728740
729741 for (i = 0; i < ARRAY_SIZE(error->engine); i++) {
@@ -745,7 +757,7 @@ int i915_error_state_to_str(struct drm_i915_error_state_buf *m, · 15 unmodified lines
745757
746758 len += scnprintf(buf + len, sizeof(buf), "%s%s",
747759 first ? "" : ", ",
748− dev_priv->engine[j]->name);
760+ m->i915->engine[j]->name);
749761 first = 0;
750762 }
751763 scnprintf(buf + len, sizeof(buf), ")");
@@ -763,7 +775,7 @@ int i915_error_state_to_str(struct drm_i915_error_state_buf *m, · 11 unmodified lines
763775
764776 obj = ee->batchbuffer;
765777 if (obj) {
766− err_puts(m, dev_priv->engine[i]->name);
778+ err_puts(m, m->i915->engine[i]->name);
767779 if (ee->context.pid)
768780 err_printf(m, " (submitted by %s [%d], ctx %d [%d], score %d%s)",
769781 ee->context.comm,
@@ -775,16 +787,16 @@ int i915_error_state_to_str(struct drm_i915_error_state_buf *m, · 5 unmodified lines
775787 err_printf(m, " --- gtt_offset = 0x%08x %08x\n",
776788 upper_32_bits(obj->gtt_offset),
777789 lower_32_bits(obj->gtt_offset));
778− print_error_obj(m, dev_priv->engine[i], NULL, obj);
790+ print_error_obj(m, m->i915->engine[i], NULL, obj);
779791 }
780792
781793 for (j = 0; j < ee->user_bo_count; j++)
782− print_error_obj(m, dev_priv->engine[i],
794+ print_error_obj(m, m->i915->engine[i],
783795 "user", ee->user_bo[j]);
784796
785797 if (ee->num_requests) {
786798 err_printf(m, "%s --- %d requests\n",
787− dev_priv->engine[i]->name,
799+ m->i915->engine[i]->name,
788800 ee->num_requests);
789801 for (j = 0; j < ee->num_requests; j++)
790802 error_print_request(m, " ",
@@ -794,10 +806,10 @@ int i915_error_state_to_str(struct drm_i915_error_state_buf *m, · 3 unmodified lines
794806
795807 if (IS_ERR(ee->waiters)) {
796808 err_printf(m, "%s --- ? waiters [unable to acquire spinlock]\n",
797− dev_priv->engine[i]->name);
809+ m->i915->engine[i]->name);
798810 } else if (ee->num_waiters) {
799811 err_printf(m, "%s --- %d waiters\n",
800− dev_priv->engine[i]->name,
812+ m->i915->engine[i]->name,
801813 ee->num_waiters);
802814 for (j = 0; j < ee->num_waiters; j++) {
803815 err_printf(m, " seqno 0x%08x for %s [%d]\n",
@@ -807,22 +819,22 @@ int i915_error_state_to_str(struct drm_i915_error_state_buf *m, · 3 unmodified lines
807819 }
808820 }
809821
810− print_error_obj(m, dev_priv->engine[i],
822+ print_error_obj(m, m->i915->engine[i],
811823 "ringbuffer", ee->ringbuffer);
812824
813− print_error_obj(m, dev_priv->engine[i],
825+ print_error_obj(m, m->i915->engine[i],
814826 "HW Status", ee->hws_page);
815827
816− print_error_obj(m, dev_priv->engine[i],
828+ print_error_obj(m, m->i915->engine[i],
817829 "HW context", ee->ctx);
818830
819− print_error_obj(m, dev_priv->engine[i],
831+ print_error_obj(m, m->i915->engine[i],
820832 "WA context", ee->wa_ctx);
821833
822− print_error_obj(m, dev_priv->engine[i],
834+ print_error_obj(m, m->i915->engine[i],
823835 "WA batchbuffer", ee->wa_batchbuffer);
824836
825− print_error_obj(m, dev_priv->engine[i],
837+ print_error_obj(m, m->i915->engine[i],
826838 "NULL context", ee->default_state);
827839 }
828840
@@ -835,43 +847,107 @@ int i915_error_state_to_str(struct drm_i915_error_state_buf *m, · 6 unmodified lines
835847 err_print_capabilities(m, &error->device_info, &error->driver_caps);
836848 err_print_params(m, &error->params);
837849 err_print_uc(m, &error->uc);
850+}
851+
852+static int err_print_to_sgl(struct i915_gpu_state *error)
853+{
854+ struct drm_i915_error_state_buf m;
855+
856+ if (IS_ERR(error))
857+ return PTR_ERR(error);
858+
859+ if (READ_ONCE(error->sgl))
860+ return 0;
861+
862+ memset(&m, 0, sizeof(m));
863+ m.i915 = error->i915;
864+
865+ __err_print_to_sgl(&m, error);
866+
867+ if (m.buf) {
868+ __sg_set_buf(m.cur++, m.buf, m.bytes, m.iter);
869+ m.bytes = 0;
870+ m.buf = NULL;
871+ }
872+ if (m.cur) {
873+ GEM_BUG_ON(m.end < m.cur);
874+ sg_mark_end(m.cur - 1);
875+ }
876+ GEM_BUG_ON(m.sgl && !m.cur);
877+
878+ if (m.err) {
879+ err_free_sgl(m.sgl);
880+ return m.err;
881+ }
838882
839− if (m->bytes == 0 && m->err)
840− return m->err;
883+ if (cmpxchg(&error->sgl, NULL, m.sgl))
884+ err_free_sgl(m.sgl);
841885
842886 return 0;
843887 }
844888
845−int i915_error_state_buf_init(struct drm_i915_error_state_buf *ebuf,
846− struct drm_i915_private *i915,
847− size_t count, loff_t pos)
889+ssize_t i915_gpu_state_copy_to_buffer(struct i915_gpu_state *error,
890+ char *buf, loff_t off, size_t rem)
848891 {
849− memset(ebuf, 0, sizeof(*ebuf));
850− ebuf->i915 = i915;
892+ struct scatterlist *sg;
893+ size_t count;
894+ loff_t pos;
895+ int err;
851896
852− /* We need to have enough room to store any i915_error_state printf
853− * so that we can move it to start position.
854− */
855− ebuf->size = count + 1 > PAGE_SIZE ? count + 1 : PAGE_SIZE;
856− ebuf->buf = kmalloc(ebuf->size,
857− GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN);
897+ if (!error || !rem)
898+ return 0;
858899
859− if (ebuf->buf == NULL) {
860− ebuf->size = PAGE_SIZE;
861− ebuf->buf = kmalloc(ebuf->size, GFP_KERNEL);
862− }
900+ err = err_print_to_sgl(error);
901+ if (err)
902+ return err;
863903
864− if (ebuf->buf == NULL) {
865− ebuf->size = 128;
866− ebuf->buf = kmalloc(ebuf->size, GFP_KERNEL);
867− }
904+ sg = READ_ONCE(error->fit);
905+ if (!sg || off < sg->dma_address)
906+ sg = error->sgl;
907+ if (!sg)
908+ return 0;
868909
869− if (ebuf->buf == NULL)
870− return -ENOMEM;
910+ pos = sg->dma_address;
911+ count = 0;
912+ do {
913+ size_t len, start;
914+
915+ if (sg_is_chain(sg)) {
916+ sg = sg_chain_ptr(sg);
917+ GEM_BUG_ON(sg_is_chain(sg));
918+ }
919+
920+ len = sg->length;
921+ if (pos + len <= off) {
922+ pos += len;
923+ continue;
924+ }
871925
872− ebuf->start = pos;
926+ start = sg->offset;
927+ if (pos < off) {
928+ GEM_BUG_ON(off - pos > len);
929+ len -= off - pos;
930+ start += off - pos;
931+ pos = off;
932+ }
873933
874− return 0;
934+ len = min(len, rem);
935+ GEM_BUG_ON(!len || len > sg->length);
936+
937+ memcpy(buf, page_address(sg_page(sg)) + start, len);
938+
939+ count += len;
940+ pos += len;
941+
942+ buf += len;
943+ rem -= len;
944+ if (!rem) {
945+ WRITE_ONCE(error->fit, sg);
946+ break;
947+ }
948+ } while (!sg_is_last(sg++));
949+
950+ return count;
875951 }
876952
877953 static void i915_error_object_free(struct drm_i915_error_object *obj)
@@ -944,6 +1020,7 @@ void __i915_gpu_state_free(struct kref *error_ref) · 66 unmodified lines
9441020 cleanup_params(error);
9451021 cleanup_uc_state(error);
9461022
1023+ err_free_sgl(error->sgl);
9471024 kfree(error);
9481025 }
9491026
@@ -1494,7 +1571,7 @@ static void gem_record_rings(struct i915_gpu_state *error) · 544 unmodified lines
14941571 if (HAS_BROKEN_CS_TLB(i915))
14951572 ee->wa_batchbuffer =
14961573 i915_error_object_create(i915,
1497− engine->scratch);
1574+ i915->gt.scratch);
14981575 request_record_user_bo(request, ee);
14991576
15001577 ee->ctx =
drivers/gpu/drm/i915/i915_gpu_error.h+12−16
@@ -192,6 +192,8 @@ struct i915_gpu_state { · 191 unmodified lines
192192 } *active_bo[I915_NUM_ENGINES], *pinned_bo;
193193 u32 active_bo_count[I915_NUM_ENGINES], pinned_bo_count;
194194 struct i915_address_space *active_vm[I915_NUM_ENGINES];
195+
196+ struct scatterlist *sgl, *fit;
195197 };
196198
197199 struct i915_gpu_error {
@@ -298,29 +300,20 @@ struct i915_gpu_error { · 100 unmodified lines
298300
299301 struct drm_i915_error_state_buf {
300302 struct drm_i915_private *i915;
301− unsigned int bytes;
302− unsigned int size;
303+ struct scatterlist *sgl, *cur, *end;
304+
305+ char *buf;
306+ size_t bytes;
307+ size_t size;
308+ loff_t iter;
309+
303310 int err;
304− u8 *buf;
305− loff_t start;
306− loff_t pos;
307311 };
308312
309313 #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR)
310314
311315 __printf(2, 3)
312316 void i915_error_printf(struct drm_i915_error_state_buf *e, const char *f, ...);
313−int i915_error_state_to_str(struct drm_i915_error_state_buf *estr,
314− const struct i915_gpu_state *gpu);
315−int i915_error_state_buf_init(struct drm_i915_error_state_buf *eb,
316− struct drm_i915_private *i915,
317− size_t count, loff_t pos);
318−
319−static inline void
320−i915_error_state_buf_release(struct drm_i915_error_state_buf *eb)
321−{
322− kfree(eb->buf);
323−}
324317
325318 struct i915_gpu_state *i915_capture_gpu_state(struct drm_i915_private *i915);
326319 void i915_capture_error_state(struct drm_i915_private *dev_priv,
@@ -334,6 +327,9 @@ i915_gpu_state_get(struct i915_gpu_state *gpu) · 7 unmodified lines
334327 return gpu;
335328 }
336329
330+ssize_t i915_gpu_state_copy_to_buffer(struct i915_gpu_state *error,
331+ char *buf, loff_t offset, size_t count);
332+
337333 void __i915_gpu_state_free(struct kref *kref);
338334 static inline void i915_gpu_state_put(struct i915_gpu_state *gpu)
339335 {
drivers/gpu/drm/i915/i915_pci.c+64−53
@@ -79,8 +79,9 @@ · 78 unmodified lines
7979 #define GEN2_FEATURES \
8080 GEN(2), \
8181 .num_pipes = 1, \
82− .has_overlay = 1, .overlay_needs_physical = 1, \
83− .has_gmch_display = 1, \
82+ .display.has_overlay = 1, \
83+ .display.overlay_needs_physical = 1, \
84+ .display.has_gmch_display = 1, \
8485 .hws_needs_physical = 1, \
8586 .unfenced_needs_alignment = 1, \
8687 .ring_mask = RENDER_RING, \
@@ -93,7 +94,8 @@ · 6 unmodified lines
9394 static const struct intel_device_info intel_i830_info = {
9495 GEN2_FEATURES,
9596 PLATFORM(INTEL_I830),
96− .is_mobile = 1, .cursor_needs_physical = 1,
97+ .is_mobile = 1,
98+ .display.cursor_needs_physical = 1,
9799 .num_pipes = 2, /* legal, last one wins */
98100 };
99101
@@ -107,8 +109,8 @@ static const struct intel_device_info intel_i85x_info = { · 7 unmodified lines
107109 PLATFORM(INTEL_I85X),
108110 .is_mobile = 1,
109111 .num_pipes = 2, /* legal, last one wins */
110− .cursor_needs_physical = 1,
111− .has_fbc = 1,
112+ .display.cursor_needs_physical = 1,
113+ .display.has_fbc = 1,
112114 };
113115
114116 static const struct intel_device_info intel_i865g_info = {
@@ -119,7 +121,7 @@ static const struct intel_device_info intel_i865g_info = { · 4 unmodified lines
119121 #define GEN3_FEATURES \
120122 GEN(3), \
121123 .num_pipes = 2, \
122− .has_gmch_display = 1, \
124+ .display.has_gmch_display = 1, \
123125 .ring_mask = RENDER_RING, \
124126 .has_snoop = true, \
125127 .has_coherent_ggtt = true, \
@@ -131,8 +133,9 @@ static const struct intel_device_info intel_i915g_info = { · 5 unmodified lines
131133 GEN3_FEATURES,
132134 PLATFORM(INTEL_I915G),
133135 .has_coherent_ggtt = false,
134− .cursor_needs_physical = 1,
135− .has_overlay = 1, .overlay_needs_physical = 1,
136+ .display.cursor_needs_physical = 1,
137+ .display.has_overlay = 1,
138+ .display.overlay_needs_physical = 1,
136139 .hws_needs_physical = 1,
137140 .unfenced_needs_alignment = 1,
138141 };
@@ -141,10 +144,11 @@ static const struct intel_device_info intel_i915gm_info = { · 2 unmodified lines
141144 GEN3_FEATURES,
142145 PLATFORM(INTEL_I915GM),
143146 .is_mobile = 1,
144− .cursor_needs_physical = 1,
145− .has_overlay = 1, .overlay_needs_physical = 1,
146− .supports_tv = 1,
147− .has_fbc = 1,
147+ .display.cursor_needs_physical = 1,
148+ .display.has_overlay = 1,
149+ .display.overlay_needs_physical = 1,
150+ .display.supports_tv = 1,
151+ .display.has_fbc = 1,
148152 .hws_needs_physical = 1,
149153 .unfenced_needs_alignment = 1,
150154 };
@@ -152,8 +156,10 @@ static const struct intel_device_info intel_i915gm_info = { · 1 unmodified line
152156 static const struct intel_device_info intel_i945g_info = {
153157 GEN3_FEATURES,
154158 PLATFORM(INTEL_I945G),
155− .has_hotplug = 1, .cursor_needs_physical = 1,
156− .has_overlay = 1, .overlay_needs_physical = 1,
159+ .display.has_hotplug = 1,
160+ .display.cursor_needs_physical = 1,
161+ .display.has_overlay = 1,
162+ .display.overlay_needs_physical = 1,
157163 .hws_needs_physical = 1,
158164 .unfenced_needs_alignment = 1,
159165 };
@@ -162,10 +168,12 @@ static const struct intel_device_info intel_i945gm_info = { · 2 unmodified lines
162168 GEN3_FEATURES,
163169 PLATFORM(INTEL_I945GM),
164170 .is_mobile = 1,
165− .has_hotplug = 1, .cursor_needs_physical = 1,
166− .has_overlay = 1, .overlay_needs_physical = 1,
167− .supports_tv = 1,
168− .has_fbc = 1,
171+ .display.has_hotplug = 1,
172+ .display.cursor_needs_physical = 1,
173+ .display.has_overlay = 1,
174+ .display.overlay_needs_physical = 1,
175+ .display.supports_tv = 1,
176+ .display.has_fbc = 1,
169177 .hws_needs_physical = 1,
170178 .unfenced_needs_alignment = 1,
171179 };
@@ -173,23 +181,23 @@ static const struct intel_device_info intel_i945gm_info = { · 1 unmodified line
173181 static const struct intel_device_info intel_g33_info = {
174182 GEN3_FEATURES,
175183 PLATFORM(INTEL_G33),
176− .has_hotplug = 1,
177− .has_overlay = 1,
184+ .display.has_hotplug = 1,
185+ .display.has_overlay = 1,
178186 };
179187
180188 static const struct intel_device_info intel_pineview_info = {
181189 GEN3_FEATURES,
182190 PLATFORM(INTEL_PINEVIEW),
183191 .is_mobile = 1,
184− .has_hotplug = 1,
185− .has_overlay = 1,
192+ .display.has_hotplug = 1,
193+ .display.has_overlay = 1,
186194 };
187195
188196 #define GEN4_FEATURES \
189197 GEN(4), \
190198 .num_pipes = 2, \
191− .has_hotplug = 1, \
192− .has_gmch_display = 1, \
199+ .display.has_hotplug = 1, \
200+ .display.has_gmch_display = 1, \
193201 .ring_mask = RENDER_RING, \
194202 .has_snoop = true, \
195203 .has_coherent_ggtt = true, \
@@ -200,7 +208,7 @@ static const struct intel_device_info intel_pineview_info = { · 4 unmodified lines
200208 static const struct intel_device_info intel_i965g_info = {
201209 GEN4_FEATURES,
202210 PLATFORM(INTEL_I965G),
203− .has_overlay = 1,
211+ .display.has_overlay = 1,
204212 .hws_needs_physical = 1,
205213 .has_snoop = false,
206214 };
@@ -208,9 +216,10 @@ static const struct intel_device_info intel_i965g_info = { · 1 unmodified line
208216 static const struct intel_device_info intel_i965gm_info = {
209217 GEN4_FEATURES,
210218 PLATFORM(INTEL_I965GM),
211− .is_mobile = 1, .has_fbc = 1,
212− .has_overlay = 1,
213− .supports_tv = 1,
219+ .is_mobile = 1,
220+ .display.has_fbc = 1,
221+ .display.has_overlay = 1,
222+ .display.supports_tv = 1,
214223 .hws_needs_physical = 1,
215224 .has_snoop = false,
216225 };
@@ -224,15 +233,16 @@ static const struct intel_device_info intel_g45_info = { · 7 unmodified lines
224233 static const struct intel_device_info intel_gm45_info = {
225234 GEN4_FEATURES,
226235 PLATFORM(INTEL_GM45),
227− .is_mobile = 1, .has_fbc = 1,
228− .supports_tv = 1,
236+ .is_mobile = 1,
237+ .display.has_fbc = 1,
238+ .display.supports_tv = 1,
229239 .ring_mask = RENDER_RING | BSD_RING,
230240 };
231241
232242 #define GEN5_FEATURES \
233243 GEN(5), \
234244 .num_pipes = 2, \
235− .has_hotplug = 1, \
245+ .display.has_hotplug = 1, \
236246 .ring_mask = RENDER_RING | BSD_RING, \
237247 .has_snoop = true, \
238248 .has_coherent_ggtt = true, \
@@ -250,14 +260,15 @@ static const struct intel_device_info intel_ironlake_d_info = { · 11 unmodified lines
250260 static const struct intel_device_info intel_ironlake_m_info = {
251261 GEN5_FEATURES,
252262 PLATFORM(INTEL_IRONLAKE),
253− .is_mobile = 1, .has_fbc = 1,
263+ .is_mobile = 1,
264+ .display.has_fbc = 1,
254265 };
255266
256267 #define GEN6_FEATURES \
257268 GEN(6), \
258269 .num_pipes = 2, \
259− .has_hotplug = 1, \
260− .has_fbc = 1, \
270+ .display.has_hotplug = 1, \
271+ .display.has_fbc = 1, \
261272 .ring_mask = RENDER_RING | BSD_RING | BLT_RING, \
262273 .has_coherent_ggtt = true, \
263274 .has_llc = 1, \
@@ -301,8 +312,8 @@ static const struct intel_device_info intel_sandybridge_m_gt2_info = { · 37 unmodified lines
301312 #define GEN7_FEATURES \
302313 GEN(7), \
303314 .num_pipes = 3, \
304− .has_hotplug = 1, \
305− .has_fbc = 1, \
315+ .display.has_hotplug = 1, \
316+ .display.has_fbc = 1, \
306317 .ring_mask = RENDER_RING | BSD_RING | BLT_RING, \
307318 .has_coherent_ggtt = true, \
308319 .has_llc = 1, \
@@ -359,8 +370,8 @@ static const struct intel_device_info intel_valleyview_info = { · 50 unmodified lines
359370 .num_pipes = 2,
360371 .has_runtime_pm = 1,
361372 .has_rc6 = 1,
362− .has_gmch_display = 1,
363− .has_hotplug = 1,
373+ .display.has_gmch_display = 1,
374+ .display.has_hotplug = 1,
364375 .ppgtt = INTEL_PPGTT_FULL,
365376 .has_snoop = true,
366377 .has_coherent_ggtt = false,
@@ -374,10 +385,10 @@ static const struct intel_device_info intel_valleyview_info = { · 7 unmodified lines
374385 #define G75_FEATURES \
375386 GEN7_FEATURES, \
376387 .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING, \
377− .has_ddi = 1, \
388+ .display.has_ddi = 1, \
378389 .has_fpga_dbg = 1, \
379− .has_psr = 1, \
380− .has_dp_mst = 1, \
390+ .display.has_psr = 1, \
391+ .display.has_dp_mst = 1, \
381392 .has_rc6p = 0 /* RC6p removed-by HSW */, \
382393 .has_runtime_pm = 1
383394
@@ -444,14 +455,14 @@ static const struct intel_device_info intel_cherryview_info = { · 60 unmodified lines
444455 PLATFORM(INTEL_CHERRYVIEW),
445456 GEN(8),
446457 .num_pipes = 3,
447− .has_hotplug = 1,
458+ .display.has_hotplug = 1,
448459 .is_lp = 1,
449460 .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
450461 .has_64bit_reloc = 1,
451462 .has_runtime_pm = 1,
452463 .has_rc6 = 1,
453464 .has_logical_ring_contexts = 1,
454− .has_gmch_display = 1,
465+ .display.has_gmch_display = 1,
455466 .ppgtt = INTEL_PPGTT_FULL,
456467 .has_reset_engine = 1,
457468 .has_snoop = true,
@@ -473,15 +484,15 @@ static const struct intel_device_info intel_cherryview_info = { · 15 unmodified lines
473484 GEN(9), \
474485 GEN9_DEFAULT_PAGE_SIZES, \
475486 .has_logical_ring_preemption = 1, \
476− .has_csr = 1, \
487+ .display.has_csr = 1, \
477488 .has_guc = 1, \
478− .has_ipc = 1, \
489+ .display.has_ipc = 1, \
479490 .ddb_size = 896
480491
481492 #define SKL_PLATFORM \
482493 GEN9_FEATURES, \
483494 /* Display WA #0477 WaDisableIPC: skl */ \
484− .has_ipc = 0, \
495+ .display.has_ipc = 0, \
485496 PLATFORM(INTEL_SKYLAKE)
486497
487498 static const struct intel_device_info intel_skylake_gt1_info = {
@@ -512,19 +523,19 @@ static const struct intel_device_info intel_skylake_gt4_info = { · 24 unmodified lines
512523 #define GEN9_LP_FEATURES \
513524 GEN(9), \
514525 .is_lp = 1, \
515− .has_hotplug = 1, \
526+ .display.has_hotplug = 1, \
516527 .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING, \
517528 .num_pipes = 3, \
518529 .has_64bit_reloc = 1, \
519− .has_ddi = 1, \
530+ .display.has_ddi = 1, \
520531 .has_fpga_dbg = 1, \
521− .has_fbc = 1, \
522− .has_psr = 1, \
532+ .display.has_fbc = 1, \
533+ .display.has_psr = 1, \
523534 .has_runtime_pm = 1, \
524535 .has_pooled_eu = 0, \
525− .has_csr = 1, \
536+ .display.has_csr = 1, \
526537 .has_rc6 = 1, \
527− .has_dp_mst = 1, \
538+ .display.has_dp_mst = 1, \
528539 .has_logical_ring_contexts = 1, \
529540 .has_logical_ring_preemption = 1, \
530541 .has_guc = 1, \
@@ -532,7 +543,7 @@ static const struct intel_device_info intel_skylake_gt4_info = { · 1 unmodified line
532543 .has_reset_engine = 1, \
533544 .has_snoop = true, \
534545 .has_coherent_ggtt = false, \
535− .has_ipc = 1, \
546+ .display.has_ipc = 1, \
536547 GEN9_DEFAULT_PAGE_SIZES, \
537548 GEN_DEFAULT_PIPEOFFSETS, \
538549 IVB_CURSOR_OFFSETS, \
drivers/gpu/drm/i915/i915_reg.h+15−0
@@ -4570,6 +4570,7 @@ enum { · 4569 unmodified lines
45704570 * of the infoframe structure specified by CEA-861. */
45714571 #define VIDEO_DIP_DATA_SIZE 32
45724572 #define VIDEO_DIP_VSC_DATA_SIZE 36
4573+#define VIDEO_DIP_PPS_DATA_SIZE 132
45734574 #define VIDEO_DIP_CTL _MMIO(0x61170)
45744575 /* Pre HSW: */
45754576 #define VIDEO_DIP_ENABLE (1 << 31)
@@ -4617,6 +4618,17 @@ enum { · 41 unmodified lines
46174618 #define _PP_STATUS 0x61200
46184619 #define PP_STATUS(pps_idx) _MMIO_PPS(pps_idx, _PP_STATUS)
46194620 #define PP_ON (1 << 31)
4621+
4622+#define _PP_CONTROL_1 0xc7204
4623+#define _PP_CONTROL_2 0xc7304
4624+#define ICP_PP_CONTROL(x) _MMIO(((x) == 1) ? _PP_CONTROL_1 : \
4625+ _PP_CONTROL_2)
4626+#define POWER_CYCLE_DELAY_MASK (0x1f << 4)
4627+#define POWER_CYCLE_DELAY_SHIFT 4
4628+#define VDD_OVERRIDE_FORCE (1 << 3)
4629+#define BACKLIGHT_ENABLE (1 << 2)
4630+#define PWR_DOWN_ON_RESET (1 << 1)
4631+#define PWR_STATE_TARGET (1 << 0)
46204632 /*
46214633 * Indicates that all dependencies of the panel are on:
46224634 *
@@ -7750,6 +7762,7 @@ enum { · 3127 unmodified lines
77507762 #define ICP_DDIB_HPD_LONG_DETECT (2 << 4)
77517763 #define ICP_DDIB_HPD_SHORT_LONG_DETECT (3 << 4)
77527764 #define ICP_DDIA_HPD_ENABLE (1 << 3)
7765+#define ICP_DDIA_HPD_OP_DRIVE_1 (1 << 2)
77537766 #define ICP_DDIA_HPD_STATUS_MASK (3 << 0)
77547767 #define ICP_DDIA_HPD_NO_DETECT (0 << 0)
77557768 #define ICP_DDIA_HPD_SHORT_DETECT (1 << 0)
@@ -9197,6 +9210,7 @@ enum skl_power_gate { · 1441 unmodified lines
91979210 #define _DP_TP_CTL_B 0x64140
91989211 #define DP_TP_CTL(port) _MMIO_PORT(port, _DP_TP_CTL_A, _DP_TP_CTL_B)
91999212 #define DP_TP_CTL_ENABLE (1 << 31)
9213+#define DP_TP_CTL_FEC_ENABLE (1 << 30)
92009214 #define DP_TP_CTL_MODE_SST (0 << 27)
92019215 #define DP_TP_CTL_MODE_MST (1 << 27)
92029216 #define DP_TP_CTL_FORCE_ACT (1 << 25)
@@ -9215,6 +9229,7 @@ enum skl_power_gate { · 12 unmodified lines
92159229 #define _DP_TP_STATUS_A 0x64044
92169230 #define _DP_TP_STATUS_B 0x64144
92179231 #define DP_TP_STATUS(port) _MMIO_PORT(port, _DP_TP_STATUS_A, _DP_TP_STATUS_B)
9232+#define DP_TP_STATUS_FEC_ENABLE_LIVE (1 << 28)
92189233 #define DP_TP_STATUS_IDLE_DONE (1 << 25)
92199234 #define DP_TP_STATUS_ACT_SENT (1 << 24)
92209235 #define DP_TP_STATUS_MODE_STATUS_MST (1 << 23)
drivers/gpu/drm/i915/i915_request.c+3−0
@@ -136,6 +136,9 @@ static int reset_all_global_seqno(struct drm_i915_private *i915, u32 seqno) · 135 unmodified lines
136136 intel_engine_get_seqno(engine),
137137 seqno);
138138
139+ if (seqno == engine->timeline.seqno)
140+ continue;
141+
139142 kthread_park(engine->breadcrumbs.signaler);
140143
141144 if (!i915_seqno_passed(seqno, engine->timeline.seqno)) {
drivers/gpu/drm/i915/i915_sw_fence.c+2−5
@@ -1,10 +1,7 @@
11 /*
2− * (C) Copyright 2016 Intel Corporation
2+ * SPDX-License-Identifier: MIT
33 *
4− * This program is free software; you can redistribute it and/or
5− * modify it under the terms of the GNU General Public License
6− * as published by the Free Software Foundation; version 2
7− * of the License.
4+ * (C) Copyright 2016 Intel Corporation
85 */
96
107 #include <linux/slab.h>
drivers/gpu/drm/i915/i915_sw_fence.h+2−3
@@ -1,10 +1,9 @@
11 /*
2+ * SPDX-License-Identifier: MIT
3+ *
24 * i915_sw_fence.h - library routines for N:M synchronisation points
35 *
46 * Copyright (C) 2016 Intel Corporation
5− *
6− * This file is released under the GPLv2.
7− *
87 */
98
109 #ifndef _I915_SW_FENCE_H_
drivers/gpu/drm/i915/i915_sysfs.c+13−18
@@ -483,7 +483,7 @@ static ssize_t gt_rp_mhz_show(struct device *kdev, struct device_attribute *attr · 482 unmodified lines
483483 return snprintf(buf, PAGE_SIZE, "%d\n", val);
484484 }
485485
486−static const struct attribute *gen6_attrs[] = {
486+static const struct attribute * const gen6_attrs[] = {
487487 &dev_attr_gt_act_freq_mhz.attr,
488488 &dev_attr_gt_cur_freq_mhz.attr,
489489 &dev_attr_gt_boost_freq_mhz.attr,
@@ -495,7 +495,7 @@ static const struct attribute *gen6_attrs[] = { · 5 unmodified lines
495495 NULL,
496496 };
497497
498−static const struct attribute *vlv_attrs[] = {
498+static const struct attribute * const vlv_attrs[] = {
499499 &dev_attr_gt_act_freq_mhz.attr,
500500 &dev_attr_gt_cur_freq_mhz.attr,
501501 &dev_attr_gt_boost_freq_mhz.attr,
@@ -516,26 +516,21 @@ static ssize_t error_state_read(struct file *filp, struct kobject *kobj, · 14 unmodified lines
516516 {
517517
518518 struct device *kdev = kobj_to_dev(kobj);
519− struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev);
520− struct drm_i915_error_state_buf error_str;
519+ struct drm_i915_private *i915 = kdev_minor_to_i915(kdev);
521520 struct i915_gpu_state *gpu;
522521 ssize_t ret;
523522
524− ret = i915_error_state_buf_init(&error_str, dev_priv, count, off);
525− if (ret)
526− return ret;
527−
528− gpu = i915_first_error_state(dev_priv);
529− ret = i915_error_state_to_str(&error_str, gpu);
530− if (ret)
531− goto out;
532−
533− ret = count < error_str.bytes ? count : error_str.bytes;
534− memcpy(buf, error_str.buf, ret);
523+ gpu = i915_first_error_state(i915);
524+ if (gpu) {
525+ ret = i915_gpu_state_copy_to_buffer(gpu, buf, off, count);
526+ i915_gpu_state_put(gpu);
527+ } else {
528+ const char *str = "No error state collected\n";
529+ size_t len = strlen(str);
535530
536−out:
537− i915_gpu_state_put(gpu);
538− i915_error_state_buf_release(&error_str);
531+ ret = min_t(size_t, count, len - off);
532+ memcpy(buf, str + off, ret);
533+ }
539534
540535 return ret;
541536 }
drivers/gpu/drm/i915/i915_utils.h+7−4
@@ -44,16 +44,19 @@ · 43 unmodified lines
4444 __stringify(x), (long)(x))
4545
4646 #if defined(GCC_VERSION) && GCC_VERSION >= 70000
47−#define add_overflows(A, B) \
48− __builtin_add_overflow_p((A), (B), (typeof((A) + (B)))0)
47+#define add_overflows_t(T, A, B) \
48+ __builtin_add_overflow_p((A), (B), (T)0)
4949 #else
50−#define add_overflows(A, B) ({ \
50+#define add_overflows_t(T, A, B) ({ \
5151 typeof(A) a = (A); \
5252 typeof(B) b = (B); \
53− a + b < a; \
53+ (T)(a + b) < a; \
5454 })
5555 #endif
5656
57+#define add_overflows(A, B) \
58+ add_overflows_t(typeof((A) + (B)), (A), (B))
59+
5760 #define range_overflows(start, size, max) ({ \
5861 typeof(start) start__ = (start); \
5962 typeof(size) size__ = (size); \
drivers/gpu/drm/i915/icl_dsi.c+482−11
@@ -26,6 +26,7 @@ · 25 unmodified lines
2626 */
2727
2828 #include <drm/drm_mipi_dsi.h>
29+#include <drm/drm_atomic_helper.h>
2930 #include "intel_dsi.h"
3031
3132 static inline int header_credits_available(struct drm_i915_private *dev_priv,
@@ -107,6 +108,90 @@ static void wait_for_cmds_dispatched_to_panel(struct intel_encoder *encoder) · 75 unmodified lines
107108 }
108109 }
109110
111+static bool add_payld_to_queue(struct intel_dsi_host *host, const u8 *data,
112+ u32 len)
113+{
114+ struct intel_dsi *intel_dsi = host->intel_dsi;
115+ struct drm_i915_private *dev_priv = to_i915(intel_dsi->base.base.dev);
116+ enum transcoder dsi_trans = dsi_port_to_transcoder(host->port);
117+ int free_credits;
118+ int i, j;
119+
120+ for (i = 0; i < len; i += 4) {
121+ u32 tmp = 0;
122+
123+ free_credits = payload_credits_available(dev_priv, dsi_trans);
124+ if (free_credits < 1) {
125+ DRM_ERROR("Payload credit not available\n");
126+ return false;
127+ }
128+
129+ for (j = 0; j < min_t(u32, len - i, 4); j++)
130+ tmp |= *data++ << 8 * j;
131+
132+ I915_WRITE(DSI_CMD_TXPYLD(dsi_trans), tmp);
133+ }
134+
135+ return true;
136+}
137+
138+static int dsi_send_pkt_hdr(struct intel_dsi_host *host,
139+ struct mipi_dsi_packet pkt, bool enable_lpdt)
140+{
141+ struct intel_dsi *intel_dsi = host->intel_dsi;
142+ struct drm_i915_private *dev_priv = to_i915(intel_dsi->base.base.dev);
143+ enum transcoder dsi_trans = dsi_port_to_transcoder(host->port);
144+ u32 tmp;
145+ int free_credits;
146+
147+ /* check if header credit available */
148+ free_credits = header_credits_available(dev_priv, dsi_trans);
149+ if (free_credits < 1) {
150+ DRM_ERROR("send pkt header failed, not enough hdr credits\n");
151+ return -1;
152+ }
153+
154+ tmp = I915_READ(DSI_CMD_TXHDR(dsi_trans));
155+
156+ if (pkt.payload)
157+ tmp |= PAYLOAD_PRESENT;
158+ else
159+ tmp &= ~PAYLOAD_PRESENT;
160+
161+ tmp &= ~VBLANK_FENCE;
162+
163+ if (enable_lpdt)
164+ tmp |= LP_DATA_TRANSFER;
165+
166+ tmp &= ~(PARAM_WC_MASK | VC_MASK | DT_MASK);
167+ tmp |= ((pkt.header[0] & VC_MASK) << VC_SHIFT);
168+ tmp |= ((pkt.header[0] & DT_MASK) << DT_SHIFT);
169+ tmp |= (pkt.header[1] << PARAM_WC_LOWER_SHIFT);
170+ tmp |= (pkt.header[2] << PARAM_WC_UPPER_SHIFT);
171+ I915_WRITE(DSI_CMD_TXHDR(dsi_trans), tmp);
172+
173+ return 0;
174+}
175+
176+static int dsi_send_pkt_payld(struct intel_dsi_host *host,
177+ struct mipi_dsi_packet pkt)
178+{
179+ /* payload queue can accept *256 bytes*, check limit */
180+ if (pkt.payload_length > MAX_PLOAD_CREDIT * 4) {
181+ DRM_ERROR("payload size exceeds max queue limit\n");
182+ return -1;
183+ }
184+
185+ /* load data into command payload queue */
186+ if (!add_payld_to_queue(host, pkt.payload,
187+ pkt.payload_length)) {
188+ DRM_ERROR("adding payload to queue failed\n");
189+ return -1;
190+ }
191+
192+ return 0;
193+}
194+
110195 static void dsi_program_swing_and_deemphasis(struct intel_encoder *encoder)
111196 {
112197 struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
@@ -172,6 +257,45 @@ static void dsi_program_swing_and_deemphasis(struct intel_encoder *encoder) · 59 unmodified lines
172257 }
173258 }
174259
260+static void configure_dual_link_mode(struct intel_encoder *encoder,
261+ const struct intel_crtc_state *pipe_config)
262+{
263+ struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
264+ struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
265+ u32 dss_ctl1;
266+
267+ dss_ctl1 = I915_READ(DSS_CTL1);
268+ dss_ctl1 |= SPLITTER_ENABLE;
269+ dss_ctl1 &= ~OVERLAP_PIXELS_MASK;
270+ dss_ctl1 |= OVERLAP_PIXELS(intel_dsi->pixel_overlap);
271+
272+ if (intel_dsi->dual_link == DSI_DUAL_LINK_FRONT_BACK) {
273+ const struct drm_display_mode *adjusted_mode =
274+ &pipe_config->base.adjusted_mode;
275+ u32 dss_ctl2;
276+ u16 hactive = adjusted_mode->crtc_hdisplay;
277+ u16 dl_buffer_depth;
278+
279+ dss_ctl1 &= ~DUAL_LINK_MODE_INTERLEAVE;
280+ dl_buffer_depth = hactive / 2 + intel_dsi->pixel_overlap;
281+
282+ if (dl_buffer_depth > MAX_DL_BUFFER_TARGET_DEPTH)
283+ DRM_ERROR("DL buffer depth exceed max value\n");
284+
285+ dss_ctl1 &= ~LEFT_DL_BUF_TARGET_DEPTH_MASK;
286+ dss_ctl1 |= LEFT_DL_BUF_TARGET_DEPTH(dl_buffer_depth);
287+ dss_ctl2 = I915_READ(DSS_CTL2);
288+ dss_ctl2 &= ~RIGHT_DL_BUF_TARGET_DEPTH_MASK;
289+ dss_ctl2 |= RIGHT_DL_BUF_TARGET_DEPTH(dl_buffer_depth);
290+ I915_WRITE(DSS_CTL2, dss_ctl2);
291+ } else {
292+ /* Interleave */
293+ dss_ctl1 |= DUAL_LINK_MODE_INTERLEAVE;
294+ }
295+
296+ I915_WRITE(DSS_CTL1, dss_ctl1);
297+}
298+
175299 static void gen11_dsi_program_esc_clk_div(struct intel_encoder *encoder)
176300 {
177301 struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
@@ -412,6 +536,62 @@ static void gen11_dsi_setup_dphy_timings(struct intel_encoder *encoder) · 234 unmodified lines
412536 }
413537 }
414538
539+static void gen11_dsi_gate_clocks(struct intel_encoder *encoder)
540+{
541+ struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
542+ struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
543+ u32 tmp;
544+ enum port port;
545+
546+ mutex_lock(&dev_priv->dpll_lock);
547+ tmp = I915_READ(DPCLKA_CFGCR0_ICL);
548+ for_each_dsi_port(port, intel_dsi->ports) {
549+ tmp |= DPCLKA_CFGCR0_DDI_CLK_OFF(port);
550+ }
551+
552+ I915_WRITE(DPCLKA_CFGCR0_ICL, tmp);
553+ mutex_unlock(&dev_priv->dpll_lock);
554+}
555+
556+static void gen11_dsi_ungate_clocks(struct intel_encoder *encoder)
557+{
558+ struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
559+ struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
560+ u32 tmp;
561+ enum port port;
562+
563+ mutex_lock(&dev_priv->dpll_lock);
564+ tmp = I915_READ(DPCLKA_CFGCR0_ICL);
565+ for_each_dsi_port(port, intel_dsi->ports) {
566+ tmp &= ~DPCLKA_CFGCR0_DDI_CLK_OFF(port);
567+ }
568+
569+ I915_WRITE(DPCLKA_CFGCR0_ICL, tmp);
570+ mutex_unlock(&dev_priv->dpll_lock);
571+}
572+
573+static void gen11_dsi_map_pll(struct intel_encoder *encoder,
574+ const struct intel_crtc_state *crtc_state)
575+{
576+ struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
577+ struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
578+ struct intel_shared_dpll *pll = crtc_state->shared_dpll;
579+ enum port port;
580+ u32 val;
581+
582+ mutex_lock(&dev_priv->dpll_lock);
583+
584+ val = I915_READ(DPCLKA_CFGCR0_ICL);
585+ for_each_dsi_port(port, intel_dsi->ports) {
586+ val &= ~DPCLKA_CFGCR0_DDI_CLK_SEL_MASK(port);
587+ val |= DPCLKA_CFGCR0_DDI_CLK_SEL(pll->info->id, port);
588+ }
589+ I915_WRITE(DPCLKA_CFGCR0_ICL, val);
590+ POSTING_READ(DPCLKA_CFGCR0_ICL);
591+
592+ mutex_unlock(&dev_priv->dpll_lock);
593+}
594+
415595 static void
416596 gen11_dsi_configure_transcoder(struct intel_encoder *encoder,
417597 const struct intel_crtc_state *pipe_config)
@@ -506,7 +686,8 @@ gen11_dsi_configure_transcoder(struct intel_encoder *encoder, · 88 unmodified lines
506686 I915_WRITE(TRANS_DDI_FUNC_CTL2(dsi_trans), tmp);
507687 }
508688
509− //TODO: configure DSS_CTL1
689+ /* configure stream splitting */
690+ configure_dual_link_mode(encoder, pipe_config);
510691 }
511692
512693 for_each_dsi_port(port, intel_dsi->ports) {
@@ -758,6 +939,9 @@ gen11_dsi_enable_port_and_phy(struct intel_encoder *encoder, · 245 unmodified lines
758939
759940 /* Step (4h, 4i, 4j, 4k): Configure transcoder */
760941 gen11_dsi_configure_transcoder(encoder, pipe_config);
942+
943+ /* Step 4l: Gate DDI clocks */
944+ gen11_dsi_gate_clocks(encoder);
761945 }
762946
763947 static void gen11_dsi_powerup_panel(struct intel_encoder *encoder)
@@ -799,18 +983,25 @@ static void gen11_dsi_powerup_panel(struct intel_encoder *encoder) · 35 unmodified lines
799983 wait_for_cmds_dispatched_to_panel(encoder);
800984 }
801985
802−static void __attribute__((unused))
803−gen11_dsi_pre_enable(struct intel_encoder *encoder,
804− const struct intel_crtc_state *pipe_config,
805− const struct drm_connector_state *conn_state)
986+static void gen11_dsi_pre_pll_enable(struct intel_encoder *encoder,
987+ const struct intel_crtc_state *pipe_config,
988+ const struct drm_connector_state *conn_state)
806989 {
807− struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
808−
809990 /* step2: enable IO power */
810991 gen11_dsi_enable_io_power(encoder);
811992
812993 /* step3: enable DSI PLL */
813994 gen11_dsi_program_esc_clk_div(encoder);
995+}
996+
997+static void gen11_dsi_pre_enable(struct intel_encoder *encoder,
998+ const struct intel_crtc_state *pipe_config,
999+ const struct drm_connector_state *conn_state)
1000+{
1001+ struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
1002+
1003+ /* step3b */
1004+ gen11_dsi_map_pll(encoder, pipe_config);
8141005
8151006 /* step4: enable DSI port and DPHY */
8161007 gen11_dsi_enable_port_and_phy(encoder, pipe_config);
@@ -912,6 +1103,7 @@ static void gen11_dsi_disable_port(struct intel_encoder *encoder) · 95 unmodified lines
9121103 u32 tmp;
9131104 enum port port;
9141105
1106+ gen11_dsi_ungate_clocks(encoder);
9151107 for_each_dsi_port(port, intel_dsi->ports) {
9161108 tmp = I915_READ(DDI_BUF_CTL(port));
9171109 tmp &= ~DDI_BUF_CTL_ENABLE;
@@ -923,6 +1115,7 @@ static void gen11_dsi_disable_port(struct intel_encoder *encoder) · 5 unmodified lines
9231115 DRM_ERROR("DDI port:%c buffer not idle\n",
9241116 port_name(port));
9251117 }
1118+ gen11_dsi_ungate_clocks(encoder);
9261119 }
9271120
9281121 static void gen11_dsi_disable_io_power(struct intel_encoder *encoder)
@@ -945,10 +1138,9 @@ static void gen11_dsi_disable_io_power(struct intel_encoder *encoder) · 16 unmodified lines
9451138 }
9461139 }
9471140
948−static void __attribute__((unused)) gen11_dsi_disable(
949− struct intel_encoder *encoder,
950− const struct intel_crtc_state *old_crtc_state,
951− const struct drm_connector_state *old_conn_state)
1141+static void gen11_dsi_disable(struct intel_encoder *encoder,
1142+ const struct intel_crtc_state *old_crtc_state,
1143+ const struct drm_connector_state *old_conn_state)
9521144 {
9531145 struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
9541146
@@ -972,10 +1164,289 @@ static void __attribute__((unused)) gen11_dsi_disable( · 17 unmodified lines
9721164 gen11_dsi_disable_io_power(encoder);
9731165 }
9741166
1167+static void gen11_dsi_get_config(struct intel_encoder *encoder,
1168+ struct intel_crtc_state *pipe_config)
1169+{
1170+ struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
1171+ struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
1172+ u32 pll_id;
1173+
1174+ /* FIXME: adapt icl_ddi_clock_get() for DSI and use that? */
1175+ pll_id = intel_get_shared_dpll_id(dev_priv, pipe_config->shared_dpll);
1176+ pipe_config->port_clock = cnl_calc_wrpll_link(dev_priv, pll_id);
1177+ pipe_config->base.adjusted_mode.crtc_clock = intel_dsi->pclk;
1178+ pipe_config->output_types |= BIT(INTEL_OUTPUT_DSI);
1179+}
1180+
1181+static bool gen11_dsi_compute_config(struct intel_encoder *encoder,
1182+ struct intel_crtc_state *pipe_config,
1183+ struct drm_connector_state *conn_state)
1184+{
1185+ struct intel_dsi *intel_dsi = container_of(encoder, struct intel_dsi,
1186+ base);
1187+ struct intel_connector *intel_connector = intel_dsi->attached_connector;
1188+ struct intel_crtc *crtc = to_intel_crtc(pipe_config->base.crtc);
1189+ const struct drm_display_mode *fixed_mode =
1190+ intel_connector->panel.fixed_mode;
1191+ struct drm_display_mode *adjusted_mode =
1192+ &pipe_config->base.adjusted_mode;
1193+
1194+ intel_fixed_panel_mode(fixed_mode, adjusted_mode);
1195+ intel_pch_panel_fitting(crtc, pipe_config, conn_state->scaling_mode);
1196+
1197+ adjusted_mode->flags = 0;
1198+
1199+ /* Dual link goes to trancoder DSI'0' */
1200+ if (intel_dsi->ports == BIT(PORT_B))
1201+ pipe_config->cpu_transcoder = TRANSCODER_DSI_1;
1202+ else
1203+ pipe_config->cpu_transcoder = TRANSCODER_DSI_0;
1204+
1205+ pipe_config->clock_set = true;
1206+ pipe_config->port_clock = intel_dsi_bitrate(intel_dsi) / 5;
1207+
1208+ return true;
1209+}
1210+
1211+static u64 gen11_dsi_get_power_domains(struct intel_encoder *encoder,
1212+ struct intel_crtc_state *crtc_state)
1213+{
1214+ struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
1215+ u64 domains = 0;
1216+ enum port port;
1217+
1218+ for_each_dsi_port(port, intel_dsi->ports)
1219+ if (port == PORT_A)
1220+ domains |= BIT_ULL(POWER_DOMAIN_PORT_DDI_A_IO);
1221+ else
1222+ domains |= BIT_ULL(POWER_DOMAIN_PORT_DDI_B_IO);
1223+
1224+ return domains;
1225+}
1226+
1227+static bool gen11_dsi_get_hw_state(struct intel_encoder *encoder,
1228+ enum pipe *pipe)
1229+{
1230+ struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
1231+ struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
1232+ u32 tmp;
1233+ enum port port;
1234+ enum transcoder dsi_trans;
1235+ bool ret = false;
1236+
1237+ if (!intel_display_power_get_if_enabled(dev_priv,
1238+ encoder->power_domain))
1239+ return false;
1240+
1241+ for_each_dsi_port(port, intel_dsi->ports) {
1242+ dsi_trans = dsi_port_to_transcoder(port);
1243+ tmp = I915_READ(TRANS_DDI_FUNC_CTL(dsi_trans));
1244+ switch (tmp & TRANS_DDI_EDP_INPUT_MASK) {
1245+ case TRANS_DDI_EDP_INPUT_A_ON:
1246+ *pipe = PIPE_A;
1247+ break;
1248+ case TRANS_DDI_EDP_INPUT_B_ONOFF:
1249+ *pipe = PIPE_B;
1250+ break;
1251+ case TRANS_DDI_EDP_INPUT_C_ONOFF:
1252+ *pipe = PIPE_C;
1253+ break;
1254+ default:
1255+ DRM_ERROR("Invalid PIPE input\n");
1256+ goto out;
1257+ }
1258+
1259+ tmp = I915_READ(PIPECONF(dsi_trans));
1260+ ret = tmp & PIPECONF_ENABLE;
1261+ }
1262+out:
1263+ intel_display_power_put(dev_priv, encoder->power_domain);
1264+ return ret;
1265+}
1266+
1267+static void gen11_dsi_encoder_destroy(struct drm_encoder *encoder)
1268+{
1269+ intel_encoder_destroy(encoder);
1270+}
1271+
1272+static const struct drm_encoder_funcs gen11_dsi_encoder_funcs = {
1273+ .destroy = gen11_dsi_encoder_destroy,
1274+};
1275+
1276+static const struct drm_connector_funcs gen11_dsi_connector_funcs = {
1277+ .late_register = intel_connector_register,
1278+ .early_unregister = intel_connector_unregister,
1279+ .destroy = intel_connector_destroy,
1280+ .fill_modes = drm_helper_probe_single_connector_modes,
1281+ .atomic_get_property = intel_digital_connector_atomic_get_property,
1282+ .atomic_set_property = intel_digital_connector_atomic_set_property,
1283+ .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
1284+ .atomic_duplicate_state = intel_digital_connector_duplicate_state,
1285+};
1286+
1287+static const struct drm_connector_helper_funcs gen11_dsi_connector_helper_funcs = {
1288+ .get_modes = intel_dsi_get_modes,
1289+ .mode_valid = intel_dsi_mode_valid,
1290+ .atomic_check = intel_digital_connector_atomic_check,
1291+};
1292+
1293+static int gen11_dsi_host_attach(struct mipi_dsi_host *host,
1294+ struct mipi_dsi_device *dsi)
1295+{
1296+ return 0;
1297+}
1298+
1299+static int gen11_dsi_host_detach(struct mipi_dsi_host *host,
1300+ struct mipi_dsi_device *dsi)
1301+{
1302+ return 0;
1303+}
1304+
1305+static ssize_t gen11_dsi_host_transfer(struct mipi_dsi_host *host,
1306+ const struct mipi_dsi_msg *msg)
1307+{
1308+ struct intel_dsi_host *intel_dsi_host = to_intel_dsi_host(host);
1309+ struct mipi_dsi_packet dsi_pkt;
1310+ ssize_t ret;
1311+ bool enable_lpdt = false;
1312+
1313+ ret = mipi_dsi_create_packet(&dsi_pkt, msg);
1314+ if (ret < 0)
1315+ return ret;
1316+
1317+ if (msg->flags & MIPI_DSI_MSG_USE_LPM)
1318+ enable_lpdt = true;
1319+
1320+ /* send packet header */
1321+ ret = dsi_send_pkt_hdr(intel_dsi_host, dsi_pkt, enable_lpdt);
1322+ if (ret < 0)
1323+ return ret;
1324+
1325+ /* only long packet contains payload */
1326+ if (mipi_dsi_packet_format_is_long(msg->type)) {
1327+ ret = dsi_send_pkt_payld(intel_dsi_host, dsi_pkt);
1328+ if (ret < 0)
1329+ return ret;
1330+ }
1331+
1332+ //TODO: add payload receive code if needed
1333+
1334+ ret = sizeof(dsi_pkt.header) + dsi_pkt.payload_length;
1335+
1336+ return ret;
1337+}
1338+
1339+static const struct mipi_dsi_host_ops gen11_dsi_host_ops = {
1340+ .attach = gen11_dsi_host_attach,
1341+ .detach = gen11_dsi_host_detach,
1342+ .transfer = gen11_dsi_host_transfer,
1343+};
1344+
9751345 void icl_dsi_init(struct drm_i915_private *dev_priv)
9761346 {
1347+ struct drm_device *dev = &dev_priv->drm;
1348+ struct intel_dsi *intel_dsi;
1349+ struct intel_encoder *encoder;
1350+ struct intel_connector *intel_connector;
1351+ struct drm_connector *connector;
1352+ struct drm_display_mode *scan, *fixed_mode = NULL;
9771353 enum port port;
9781354
9791355 if (!intel_bios_is_dsi_present(dev_priv, &port))
9801356 return;
1357+
1358+ intel_dsi = kzalloc(sizeof(*intel_dsi), GFP_KERNEL);
1359+ if (!intel_dsi)
1360+ return;
1361+
1362+ intel_connector = intel_connector_alloc();
1363+ if (!intel_connector) {
1364+ kfree(intel_dsi);
1365+ return;
1366+ }
1367+
1368+ encoder = &intel_dsi->base;
1369+ intel_dsi->attached_connector = intel_connector;
1370+ connector = &intel_connector->base;
1371+
1372+ /* register DSI encoder with DRM subsystem */
1373+ drm_encoder_init(dev, &encoder->base, &gen11_dsi_encoder_funcs,
1374+ DRM_MODE_ENCODER_DSI, "DSI %c", port_name(port));
1375+
1376+ encoder->pre_pll_enable = gen11_dsi_pre_pll_enable;
1377+ encoder->pre_enable = gen11_dsi_pre_enable;
1378+ encoder->disable = gen11_dsi_disable;
1379+ encoder->port = port;
1380+ encoder->get_config = gen11_dsi_get_config;
1381+ encoder->compute_config = gen11_dsi_compute_config;
1382+ encoder->get_hw_state = gen11_dsi_get_hw_state;
1383+ encoder->type = INTEL_OUTPUT_DSI;
1384+ encoder->cloneable = 0;
1385+ encoder->crtc_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C);
1386+ encoder->power_domain = POWER_DOMAIN_PORT_DSI;
1387+ encoder->get_power_domains = gen11_dsi_get_power_domains;
1388+
1389+ /* register DSI connector with DRM subsystem */
1390+ drm_connector_init(dev, connector, &gen11_dsi_connector_funcs,
1391+ DRM_MODE_CONNECTOR_DSI);
1392+ drm_connector_helper_add(connector, &gen11_dsi_connector_helper_funcs);
1393+ connector->display_info.subpixel_order = SubPixelHorizontalRGB;
1394+ connector->interlace_allowed = false;
1395+ connector->doublescan_allowed = false;
1396+ intel_connector->get_hw_state = intel_connector_get_hw_state;
1397+
1398+ /* attach connector to encoder */
1399+ intel_connector_attach_encoder(intel_connector, encoder);
1400+
1401+ /* fill mode info from VBT */
1402+ mutex_lock(&dev->mode_config.mutex);
1403+ intel_dsi_vbt_get_modes(intel_dsi);
1404+ list_for_each_entry(scan, &connector->probed_modes, head) {
1405+ if (scan->type & DRM_MODE_TYPE_PREFERRED) {
1406+ fixed_mode = drm_mode_duplicate(dev, scan);
1407+ break;
1408+ }
1409+ }
1410+ mutex_unlock(&dev->mode_config.mutex);
1411+
1412+ if (!fixed_mode) {
1413+ DRM_ERROR("DSI fixed mode info missing\n");
1414+ goto err;
1415+ }
1416+
1417+ connector->display_info.width_mm = fixed_mode->width_mm;
1418+ connector->display_info.height_mm = fixed_mode->height_mm;
1419+ intel_panel_init(&intel_connector->panel, fixed_mode, NULL);
1420+ intel_panel_setup_backlight(connector, INVALID_PIPE);
1421+
1422+
1423+ if (dev_priv->vbt.dsi.config->dual_link)
1424+ intel_dsi->ports = BIT(PORT_A) | BIT(PORT_B);
1425+ else
1426+ intel_dsi->ports = BIT(port);
1427+
1428+ intel_dsi->dcs_backlight_ports = dev_priv->vbt.dsi.bl_ports;
1429+ intel_dsi->dcs_cabc_ports = dev_priv->vbt.dsi.cabc_ports;
1430+
1431+ for_each_dsi_port(port, intel_dsi->ports) {
1432+ struct intel_dsi_host *host;
1433+
1434+ host = intel_dsi_host_init(intel_dsi, &gen11_dsi_host_ops, port);
1435+ if (!host)
1436+ goto err;
1437+
1438+ intel_dsi->dsi_hosts[port] = host;
1439+ }
1440+
1441+ if (!intel_dsi_vbt_init(intel_dsi, MIPI_DSI_GENERIC_PANEL_ID)) {
1442+ DRM_DEBUG_KMS("no device found\n");
1443+ goto err;
1444+ }
1445+
1446+ return;
1447+
1448+err:
1449+ drm_encoder_cleanup(&encoder->base);
1450+ kfree(intel_dsi);
1451+ kfree(intel_connector);
9811452 }
drivers/gpu/drm/i915/intel_atomic.c+1−0
@@ -184,6 +184,7 @@ intel_crtc_duplicate_state(struct drm_crtc *crtc) · 183 unmodified lines
184184 crtc_state->fifo_changed = false;
185185 crtc_state->wm.need_postvbl_update = false;
186186 crtc_state->fb_bits = 0;
187+ crtc_state->update_planes = 0;
187188
188189 return &crtc_state->base;
189190 }
drivers/gpu/drm/i915/intel_atomic_plane.c+88−14
@@ -139,6 +139,9 @@ int intel_plane_atomic_check_with_state(const struct intel_crtc_state *old_crtc_ · 138 unmodified lines
139139 if (state->visible && state->fb->format->format == DRM_FORMAT_NV12)
140140 crtc_state->nv12_planes |= BIT(intel_plane->id);
141141
142+ if (state->visible || old_plane_state->base.visible)
143+ crtc_state->update_planes |= BIT(intel_plane->id);
144+
142145 return intel_plane_atomic_calc_changes(old_crtc_state,
143146 &crtc_state->base,
144147 old_plane_state,
@@ -168,27 +171,75 @@ static int intel_plane_atomic_check(struct drm_plane *plane, · 23 unmodified lines
168171 to_intel_plane_state(new_plane_state));
169172 }
170173
171−void intel_update_planes_on_crtc(struct intel_atomic_state *old_state,
172− struct intel_crtc *crtc,
173− struct intel_crtc_state *old_crtc_state,
174− struct intel_crtc_state *new_crtc_state)
174+static struct intel_plane *
175+skl_next_plane_to_commit(struct intel_atomic_state *state,
176+ struct intel_crtc *crtc,
177+ struct skl_ddb_entry entries_y[I915_MAX_PLANES],
178+ struct skl_ddb_entry entries_uv[I915_MAX_PLANES],
179+ unsigned int *update_mask)
175180 {
176− struct intel_plane_state *new_plane_state;
181+ struct intel_crtc_state *crtc_state =
182+ intel_atomic_get_new_crtc_state(state, crtc);
183+ struct intel_plane_state *plane_state;
177184 struct intel_plane *plane;
178− u32 update_mask;
179185 int i;
180186
181− update_mask = old_crtc_state->active_planes;
182− update_mask |= new_crtc_state->active_planes;
187+ if (*update_mask == 0)
188+ return NULL;
189+
190+ for_each_new_intel_plane_in_state(state, plane, plane_state, i) {
191+ enum plane_id plane_id = plane->id;
183192
184− for_each_new_intel_plane_in_state(old_state, plane, new_plane_state, i) {
185193 if (crtc->pipe != plane->pipe ||
186− !(update_mask & BIT(plane->id)))
194+ !(*update_mask & BIT(plane_id)))
195+ continue;
196+
197+ if (skl_ddb_allocation_overlaps(&crtc_state->wm.skl.plane_ddb_y[plane_id],
198+ entries_y,
199+ I915_MAX_PLANES, plane_id) ||
200+ skl_ddb_allocation_overlaps(&crtc_state->wm.skl.plane_ddb_uv[plane_id],
201+ entries_uv,
202+ I915_MAX_PLANES, plane_id))
187203 continue;
188204
205+ *update_mask &= ~BIT(plane_id);
206+ entries_y[plane_id] = crtc_state->wm.skl.plane_ddb_y[plane_id];
207+ entries_uv[plane_id] = crtc_state->wm.skl.plane_ddb_uv[plane_id];
208+
209+ return plane;
210+ }
211+
212+ /* should never happen */
213+ WARN_ON(1);
214+
215+ return NULL;
216+}
217+
218+void skl_update_planes_on_crtc(struct intel_atomic_state *state,
219+ struct intel_crtc *crtc)
220+{
221+ struct intel_crtc_state *old_crtc_state =
222+ intel_atomic_get_old_crtc_state(state, crtc);
223+ struct intel_crtc_state *new_crtc_state =
224+ intel_atomic_get_new_crtc_state(state, crtc);
225+ struct skl_ddb_entry entries_y[I915_MAX_PLANES];
226+ struct skl_ddb_entry entries_uv[I915_MAX_PLANES];
227+ u32 update_mask = new_crtc_state->update_planes;
228+ struct intel_plane *plane;
229+
230+ memcpy(entries_y, old_crtc_state->wm.skl.plane_ddb_y,
231+ sizeof(old_crtc_state->wm.skl.plane_ddb_y));
232+ memcpy(entries_uv, old_crtc_state->wm.skl.plane_ddb_uv,
233+ sizeof(old_crtc_state->wm.skl.plane_ddb_uv));
234+
235+ while ((plane = skl_next_plane_to_commit(state, crtc,
236+ entries_y, entries_uv,
237+ &update_mask))) {
238+ struct intel_plane_state *new_plane_state =
239+ intel_atomic_get_new_plane_state(state, plane);
240+
189241 if (new_plane_state->base.visible) {
190242 trace_intel_update_plane(&plane->base, crtc);
191−
192243 plane->update_plane(plane, new_crtc_state, new_plane_state);
193244 } else if (new_plane_state->slave) {
194245 struct intel_plane *master =
@@ -204,15 +255,38 @@ void intel_update_planes_on_crtc(struct intel_atomic_state *old_state, · 9 unmodified lines
204255 * plane_state.
205256 */
206257 new_plane_state =
207− intel_atomic_get_new_plane_state(old_state, master);
258+ intel_atomic_get_new_plane_state(state, master);
208259
209260 trace_intel_update_plane(&plane->base, crtc);
210−
211261 plane->update_slave(plane, new_crtc_state, new_plane_state);
212262 } else {
213263 trace_intel_disable_plane(&plane->base, crtc);
264+ plane->disable_plane(plane, new_crtc_state);
265+ }
266+ }
267+}
268+
269+void i9xx_update_planes_on_crtc(struct intel_atomic_state *state,
270+ struct intel_crtc *crtc)
271+{
272+ struct intel_crtc_state *new_crtc_state =
273+ intel_atomic_get_new_crtc_state(state, crtc);
274+ u32 update_mask = new_crtc_state->update_planes;
275+ struct intel_plane_state *new_plane_state;
276+ struct intel_plane *plane;
277+ int i;
214278
215− plane->disable_plane(plane, crtc);
279+ for_each_new_intel_plane_in_state(state, plane, new_plane_state, i) {
280+ if (crtc->pipe != plane->pipe ||
281+ !(update_mask & BIT(plane->id)))
282+ continue;
283+
284+ if (new_plane_state->base.visible) {
285+ trace_intel_update_plane(&plane->base, crtc);
286+ plane->update_plane(plane, new_crtc_state, new_plane_state);
287+ } else {
288+ trace_intel_disable_plane(&plane->base, crtc);
289+ plane->disable_plane(plane, new_crtc_state);
216290 }
217291 }
218292 }
drivers/gpu/drm/i915/intel_bios.c+1−1
@@ -1752,7 +1752,7 @@ void intel_bios_init(struct drm_i915_private *dev_priv) · 1751 unmodified lines
17521752 const struct bdb_header *bdb;
17531753 u8 __iomem *bios = NULL;
17541754
1755− if (INTEL_INFO(dev_priv)->num_pipes == 0) {
1755+ if (!HAS_DISPLAY(dev_priv)) {
17561756 DRM_DEBUG_KMS("Skipping VBT init due to disabled display.\n");
17571757 return;
17581758 }
drivers/gpu/drm/i915/intel_breadcrumbs.c+1−5
@@ -27,11 +27,7 @@ · 26 unmodified lines
2727
2828 #include "i915_drv.h"
2929
30−#ifdef CONFIG_SMP
31−#define task_asleep(tsk) ((tsk)->state & TASK_NORMAL && !(tsk)->on_cpu)
32−#else
33−#define task_asleep(tsk) ((tsk)->state & TASK_NORMAL)
34−#endif
30+#define task_asleep(tsk) ((tsk)->state & TASK_NORMAL && !(tsk)->on_rq)
3531
3632 static unsigned int __intel_breadcrumbs_wakeup(struct intel_breadcrumbs *b)
3733 {
drivers/gpu/drm/i915/intel_ddi.c+155−73
@@ -28,6 +28,7 @@ · 27 unmodified lines
2828 #include <drm/drm_scdc_helper.h>
2929 #include "i915_drv.h"
3030 #include "intel_drv.h"
31+#include "intel_dsi.h"
3132
3233 struct ddi_buf_trans {
3334 u32 trans1; /* balance leg enable, de-emph level */
@@ -1363,8 +1364,8 @@ static int skl_calc_wrpll_link(struct drm_i915_private *dev_priv, · 1329 unmodified lines
13631364 return dco_freq / (p0 * p1 * p2 * 5);
13641365 }
13651366
1366−static int cnl_calc_wrpll_link(struct drm_i915_private *dev_priv,
1367− enum intel_dpll_id pll_id)
1367+int cnl_calc_wrpll_link(struct drm_i915_private *dev_priv,
1368+ enum intel_dpll_id pll_id)
13681369 {
13691370 uint32_t cfgcr0, cfgcr1;
13701371 uint32_t p0, p1, p2, dco_freq, ref_clock;
@@ -2154,6 +2155,12 @@ static u64 intel_ddi_get_power_domains(struct intel_encoder *encoder, · 783 unmodified lines
21542155 intel_port_is_tc(dev_priv, encoder->port))
21552156 domains |= BIT_ULL(intel_ddi_main_link_aux_domain(dig_port));
21562157
2158+ /*
2159+ * VDSC power is needed when DSC is enabled
2160+ */
2161+ if (crtc_state->dsc_params.compression_enable)
2162+ domains |= BIT_ULL(intel_dsc_power_domain(crtc_state));
2163+
21572164 return domains;
21582165 }
21592166
@@ -2785,77 +2792,54 @@ uint32_t icl_dpclka_cfgcr0_clk_off(struct drm_i915_private *dev_priv, · 625 unmodified lines
27852792 return 0;
27862793 }
27872794
2788−void icl_map_plls_to_ports(struct drm_crtc *crtc,
2789− struct intel_crtc_state *crtc_state,
2790− struct drm_atomic_state *old_state)
2795+static void icl_map_plls_to_ports(struct intel_encoder *encoder,
2796+ const struct intel_crtc_state *crtc_state)
27912797 {
2798+ struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
27922799 struct intel_shared_dpll *pll = crtc_state->shared_dpll;
2793− struct drm_i915_private *dev_priv = to_i915(crtc->dev);
2794− struct drm_connector_state *conn_state;
2795− struct drm_connector *conn;
2796− int i;
2797−
2798− for_each_new_connector_in_state(old_state, conn, conn_state, i) {
2799− struct intel_encoder *encoder =
2800− to_intel_encoder(conn_state->best_encoder);
2801− enum port port;
2802− uint32_t val;
2803−
2804− if (conn_state->crtc != crtc)
2805− continue;
2806−
2807− port = encoder->port;
2808− mutex_lock(&dev_priv->dpll_lock);
2800+ enum port port = encoder->port;
2801+ u32 val;
28092802
2810− val = I915_READ(DPCLKA_CFGCR0_ICL);
2811− WARN_ON((val & icl_dpclka_cfgcr0_clk_off(dev_priv, port)) == 0);
2803+ mutex_lock(&dev_priv->dpll_lock);
28122804
2813− if (intel_port_is_combophy(dev_priv, port)) {
2814− val &= ~DPCLKA_CFGCR0_DDI_CLK_SEL_MASK(port);
2815− val |= DPCLKA_CFGCR0_DDI_CLK_SEL(pll->info->id, port);
2816− I915_WRITE(DPCLKA_CFGCR0_ICL, val);
2817− POSTING_READ(DPCLKA_CFGCR0_ICL);
2818− }
2805+ val = I915_READ(DPCLKA_CFGCR0_ICL);
2806+ WARN_ON((val & icl_dpclka_cfgcr0_clk_off(dev_priv, port)) == 0);
28192807
2820− val &= ~icl_dpclka_cfgcr0_clk_off(dev_priv, port);
2808+ if (intel_port_is_combophy(dev_priv, port)) {
2809+ val &= ~DPCLKA_CFGCR0_DDI_CLK_SEL_MASK(port);
2810+ val |= DPCLKA_CFGCR0_DDI_CLK_SEL(pll->info->id, port);
28212811 I915_WRITE(DPCLKA_CFGCR0_ICL, val);
2822−
2823− mutex_unlock(&dev_priv->dpll_lock);
2812+ POSTING_READ(DPCLKA_CFGCR0_ICL);
28242813 }
2814+
2815+ val &= ~icl_dpclka_cfgcr0_clk_off(dev_priv, port);
2816+ I915_WRITE(DPCLKA_CFGCR0_ICL, val);
2817+
2818+ mutex_unlock(&dev_priv->dpll_lock);
28252819 }
28262820
2827−void icl_unmap_plls_to_ports(struct drm_crtc *crtc,
2828− struct intel_crtc_state *crtc_state,
2829− struct drm_atomic_state *old_state)
2821+static void icl_unmap_plls_to_ports(struct intel_encoder *encoder)
28302822 {
2831− struct drm_i915_private *dev_priv = to_i915(crtc->dev);
2832− struct drm_connector_state *old_conn_state;
2833− struct drm_connector *conn;
2834− int i;
2823+ struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
2824+ enum port port = encoder->port;
2825+ u32 val;
28352826
2836− for_each_old_connector_in_state(old_state, conn, old_conn_state, i) {
2837− struct intel_encoder *encoder =
2838− to_intel_encoder(old_conn_state->best_encoder);
2839− enum port port;
2827+ mutex_lock(&dev_priv->dpll_lock);
28402828
2841− if (old_conn_state->crtc != crtc)
2842− continue;
2829+ val = I915_READ(DPCLKA_CFGCR0_ICL);
2830+ val |= icl_dpclka_cfgcr0_clk_off(dev_priv, port);
2831+ I915_WRITE(DPCLKA_CFGCR0_ICL, val);
28432832
2844− port = encoder->port;
2845− mutex_lock(&dev_priv->dpll_lock);
2846− I915_WRITE(DPCLKA_CFGCR0_ICL,
2847− I915_READ(DPCLKA_CFGCR0_ICL) |
2848− icl_dpclka_cfgcr0_clk_off(dev_priv, port));
2849− mutex_unlock(&dev_priv->dpll_lock);
2850− }
2833+ mutex_unlock(&dev_priv->dpll_lock);
28512834 }
28522835
28532836 void icl_sanitize_encoder_pll_mapping(struct intel_encoder *encoder)
28542837 {
28552838 struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
28562839 u32 val;
2857− enum port port = encoder->port;
2858− bool clk_enabled;
2840+ enum port port;
2841+ u32 port_mask;
2842+ bool ddi_clk_needed;
28592843
28602844 /*
28612845 * In case of DP MST, we sanitize the primary encoder only, not the
@@ -2864,9 +2848,6 @@ void icl_sanitize_encoder_pll_mapping(struct intel_encoder *encoder) · 2 unmodified lines
28642848 if (encoder->type == INTEL_OUTPUT_DP_MST)
28652849 return;
28662850
2867− val = I915_READ(DPCLKA_CFGCR0_ICL);
2868− clk_enabled = !(val & icl_dpclka_cfgcr0_clk_off(dev_priv, port));
2869−
28702851 if (!encoder->base.crtc && intel_encoder_is_dp(encoder)) {
28712852 u8 pipe_mask;
28722853 bool is_mst;
@@ -2880,20 +2861,52 @@ void icl_sanitize_encoder_pll_mapping(struct intel_encoder *encoder) · 7 unmodified lines
28802861 return;
28812862 }
28822863
2883− if (clk_enabled == !!encoder->base.crtc)
2884− return;
2864+ port_mask = BIT(encoder->port);
2865+ ddi_clk_needed = encoder->base.crtc;
28852866
2886− /*
2887− * Punt on the case now where clock is disabled, but the encoder is
2888− * enabled, something else is really broken then.
2889− */
2890− if (WARN_ON(!clk_enabled))
2891− return;
2867+ if (encoder->type == INTEL_OUTPUT_DSI) {
2868+ struct intel_encoder *other_encoder;
28922869
2893− DRM_NOTE("Port %c is disabled but it has a mapped PLL, unmap it\n",
2894− port_name(port));
2895− val |= icl_dpclka_cfgcr0_clk_off(dev_priv, port);
2896− I915_WRITE(DPCLKA_CFGCR0_ICL, val);
2870+ port_mask = intel_dsi_encoder_ports(encoder);
2871+ /*
2872+ * Sanity check that we haven't incorrectly registered another
2873+ * encoder using any of the ports of this DSI encoder.
2874+ */
2875+ for_each_intel_encoder(&dev_priv->drm, other_encoder) {
2876+ if (other_encoder == encoder)
2877+ continue;
2878+
2879+ if (WARN_ON(port_mask & BIT(other_encoder->port)))
2880+ return;
2881+ }
2882+ /*
2883+ * DSI ports should have their DDI clock ungated when disabled
2884+ * and gated when enabled.
2885+ */
2886+ ddi_clk_needed = !encoder->base.crtc;
2887+ }
2888+
2889+ val = I915_READ(DPCLKA_CFGCR0_ICL);
2890+ for_each_port_masked(port, port_mask) {
2891+ bool ddi_clk_ungated = !(val &
2892+ icl_dpclka_cfgcr0_clk_off(dev_priv,
2893+ port));
2894+
2895+ if (ddi_clk_needed == ddi_clk_ungated)
2896+ continue;
2897+
2898+ /*
2899+ * Punt on the case now where clock is gated, but it would
2900+ * be needed by the port. Something else is really broken then.
2901+ */
2902+ if (WARN_ON(ddi_clk_needed))
2903+ continue;
2904+
2905+ DRM_NOTE("Port %c is disabled/in DSI mode with an ungated DDI clock, gate it\n",
2906+ port_name(port));
2907+ val |= icl_dpclka_cfgcr0_clk_off(dev_priv, port);
2908+ I915_WRITE(DPCLKA_CFGCR0_ICL, val);
2909+ }
28972910 }
28982911
28992912 static void intel_ddi_clk_select(struct intel_encoder *encoder,
@@ -3096,6 +3109,53 @@ static void icl_program_mg_dp_mode(struct intel_digital_port *intel_dig_port) · 196 unmodified lines
30963109 I915_WRITE(MG_DP_MODE(port, 1), ln1);
30973110 }
30983111
3112+static void intel_dp_sink_set_fec_ready(struct intel_dp *intel_dp,
3113+ const struct intel_crtc_state *crtc_state)
3114+{
3115+ if (!crtc_state->fec_enable)
3116+ return;
3117+
3118+ if (drm_dp_dpcd_writeb(&intel_dp->aux, DP_FEC_CONFIGURATION, DP_FEC_READY) <= 0)
3119+ DRM_DEBUG_KMS("Failed to set FEC_READY in the sink\n");
3120+}
3121+
3122+static void intel_ddi_enable_fec(struct intel_encoder *encoder,
3123+ const struct intel_crtc_state *crtc_state)
3124+{
3125+ struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
3126+ enum port port = encoder->port;
3127+ u32 val;
3128+
3129+ if (!crtc_state->fec_enable)
3130+ return;
3131+
3132+ val = I915_READ(DP_TP_CTL(port));
3133+ val |= DP_TP_CTL_FEC_ENABLE;
3134+ I915_WRITE(DP_TP_CTL(port), val);
3135+
3136+ if (intel_wait_for_register(dev_priv, DP_TP_STATUS(port),
3137+ DP_TP_STATUS_FEC_ENABLE_LIVE,
3138+ DP_TP_STATUS_FEC_ENABLE_LIVE,
3139+ 1))
3140+ DRM_ERROR("Timed out waiting for FEC Enable Status\n");
3141+}
3142+
3143+static void intel_ddi_disable_fec_state(struct intel_encoder *encoder,
3144+ const struct intel_crtc_state *crtc_state)
3145+{
3146+ struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
3147+ enum port port = encoder->port;
3148+ u32 val;
3149+
3150+ if (!crtc_state->fec_enable)
3151+ return;
3152+
3153+ val = I915_READ(DP_TP_CTL(port));
3154+ val &= ~DP_TP_CTL_FEC_ENABLE;
3155+ I915_WRITE(DP_TP_CTL(port), val);
3156+ POSTING_READ(DP_TP_CTL(port));
3157+}
3158+
30993159 static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
31003160 const struct intel_crtc_state *crtc_state,
31013161 const struct drm_connector_state *conn_state)
@@ -3134,14 +3194,21 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder, · 32 unmodified lines
31343194 intel_ddi_init_dp_buf_reg(encoder);
31353195 if (!is_mst)
31363196 intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
3197+ intel_dp_sink_set_decompression_state(intel_dp, crtc_state,
3198+ true);
3199+ intel_dp_sink_set_fec_ready(intel_dp, crtc_state);
31373200 intel_dp_start_link_train(intel_dp);
31383201 if (port != PORT_A || INTEL_GEN(dev_priv) >= 9)
31393202 intel_dp_stop_link_train(intel_dp);
31403203
3204+ intel_ddi_enable_fec(encoder, crtc_state);
3205+
31413206 icl_enable_phy_clock_gating(dig_port);
31423207
31433208 if (!is_mst)
31443209 intel_ddi_enable_pipe_clock(crtc_state);
3210+
3211+ intel_dsc_enable(encoder, crtc_state);
31453212 }
31463213
31473214 static void intel_ddi_pre_enable_hdmi(struct intel_encoder *encoder,
@@ -3208,6 +3275,9 @@ static void intel_ddi_pre_enable(struct intel_encoder *encoder, · 60 unmodified lines
32083275
32093276 WARN_ON(crtc_state->has_pch_encoder);
32103277
3278+ if (INTEL_GEN(dev_priv) >= 11)
3279+ icl_map_plls_to_ports(encoder, crtc_state);
3280+
32113281 intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, true);
32123282
32133283 if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) {
@@ -3228,7 +3298,8 @@ static void intel_ddi_pre_enable(struct intel_encoder *encoder, · 14 unmodified lines
32283298 }
32293299 }
32303300
3231−static void intel_disable_ddi_buf(struct intel_encoder *encoder)
3301+static void intel_disable_ddi_buf(struct intel_encoder *encoder,
3302+ const struct intel_crtc_state *crtc_state)
32323303 {
32333304 struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
32343305 enum port port = encoder->port;
@@ -3247,6 +3318,9 @@ static void intel_disable_ddi_buf(struct intel_encoder *encoder) · 12 unmodified lines
32473318 val |= DP_TP_CTL_LINK_TRAIN_PAT1;
32483319 I915_WRITE(DP_TP_CTL(port), val);
32493320
3321+ /* Disable FEC in DP Sink */
3322+ intel_ddi_disable_fec_state(encoder, crtc_state);
3323+
32503324 if (wait)
32513325 intel_wait_ddi_buf_idle(dev_priv, port);
32523326 }
@@ -3270,7 +3344,7 @@ static void intel_ddi_post_disable_dp(struct intel_encoder *encoder, · 17 unmodified lines
32703344 intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
32713345 }
32723346
3273− intel_disable_ddi_buf(encoder);
3347+ intel_disable_ddi_buf(encoder, old_crtc_state);
32743348
32753349 intel_edp_panel_vdd_on(intel_dp);
32763350 intel_edp_panel_off(intel_dp);
@@ -3293,7 +3367,7 @@ static void intel_ddi_post_disable_hdmi(struct intel_encoder *encoder, · 16 unmodified lines
32933367
32943368 intel_ddi_disable_pipe_clock(old_crtc_state);
32953369
3296− intel_disable_ddi_buf(encoder);
3370+ intel_disable_ddi_buf(encoder, old_crtc_state);
32973371
32983372 intel_display_power_put(dev_priv, dig_port->ddi_io_power_domain);
32993373
@@ -3306,6 +3380,8 @@ static void intel_ddi_post_disable(struct intel_encoder *encoder, · 6 unmodified lines
33063380 const struct intel_crtc_state *old_crtc_state,
33073381 const struct drm_connector_state *old_conn_state)
33083382 {
3383+ struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
3384+
33093385 /*
33103386 * When called from DP MST code:
33113387 * - old_conn_state will be NULL
@@ -3325,6 +3401,9 @@ static void intel_ddi_post_disable(struct intel_encoder *encoder, · 13 unmodified lines
33253401 else
33263402 intel_ddi_post_disable_dp(encoder,
33273403 old_crtc_state, old_conn_state);
3404+
3405+ if (INTEL_GEN(dev_priv) >= 11)
3406+ icl_unmap_plls_to_ports(encoder);
33283407 }
33293408
33303409 void intel_ddi_fdi_post_disable(struct intel_encoder *encoder,
@@ -3344,7 +3423,7 @@ void intel_ddi_fdi_post_disable(struct intel_encoder *encoder, · 13 unmodified lines
33443423 val &= ~FDI_RX_ENABLE;
33453424 I915_WRITE(FDI_RX_CTL(PIPE_A), val);
33463425
3347− intel_disable_ddi_buf(encoder);
3426+ intel_disable_ddi_buf(encoder, old_crtc_state);
33483427 intel_ddi_clk_disable(encoder);
33493428
33503429 val = I915_READ(FDI_RX_MISC(PIPE_A));
@@ -3491,6 +3570,9 @@ static void intel_disable_ddi_dp(struct intel_encoder *encoder, · 140 unmodified lines
34913570 intel_edp_drrs_disable(intel_dp, old_crtc_state);
34923571 intel_psr_disable(intel_dp, old_crtc_state);
34933572 intel_edp_backlight_off(old_conn_state);
3573+ /* Disable the decompression in DP Sink */
3574+ intel_dp_sink_set_decompression_state(intel_dp, old_crtc_state,
3575+ false);
34943576 }
34953577
34963578 static void intel_disable_ddi_hdmi(struct intel_encoder *encoder,
drivers/gpu/drm/i915/intel_device_info.c+6−2
@@ -77,6 +77,10 @@ void intel_device_info_dump_flags(const struct intel_device_info *info, · 76 unmodified lines
7777 #define PRINT_FLAG(name) drm_printf(p, "%s: %s\n", #name, yesno(info->name));
7878 DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG);
7979 #undef PRINT_FLAG
80+
81+#define PRINT_FLAG(name) drm_printf(p, "%s: %s\n", #name, yesno(info->display.name));
82+ DEV_INFO_DISPLAY_FOR_EACH_FLAG(PRINT_FLAG);
83+#undef PRINT_FLAG
8084 }
8185
8286 static void sseu_dump(const struct sseu_dev_info *sseu, struct drm_printer *p)
@@ -782,7 +786,7 @@ void intel_device_info_runtime_init(struct intel_device_info *info) · 699 unmodified lines
782786 if (i915_modparams.disable_display) {
783787 DRM_INFO("Display disabled (module parameter)\n");
784788 info->num_pipes = 0;
785− } else if (info->num_pipes > 0 &&
789+ } else if (HAS_DISPLAY(dev_priv) &&
786790 (IS_GEN7(dev_priv) || IS_GEN8(dev_priv)) &&
787791 HAS_PCH_SPLIT(dev_priv)) {
788792 u32 fuse_strap = I915_READ(FUSE_STRAP);
@@ -807,7 +811,7 @@ void intel_device_info_runtime_init(struct intel_device_info *info) · 18 unmodified lines
807811 DRM_INFO("PipeC fused off\n");
808812 info->num_pipes -= 1;
809813 }
810− } else if (info->num_pipes > 0 && IS_GEN9(dev_priv)) {
814+ } else if (HAS_DISPLAY(dev_priv) && IS_GEN9(dev_priv)) {
811815 u32 dfsm = I915_READ(SKL_DFSM);
812816 u8 disabled_mask = 0;
813817 bool invalid;
drivers/gpu/drm/i915/intel_device_info.h+21−11
@@ -89,35 +89,38 @@ enum intel_ppgtt { · 88 unmodified lines
8989 func(is_alpha_support); \
9090 /* Keep has_* in alphabetical order */ \
9191 func(has_64bit_reloc); \
92− func(has_csr); \
93− func(has_ddi); \
94− func(has_dp_mst); \
9592 func(has_reset_engine); \
96− func(has_fbc); \
9793 func(has_fpga_dbg); \
98− func(has_gmch_display); \
9994 func(has_guc); \
10095 func(has_guc_ct); \
101− func(has_hotplug); \
10296 func(has_l3_dpf); \
10397 func(has_llc); \
10498 func(has_logical_ring_contexts); \
10599 func(has_logical_ring_elsq); \
106100 func(has_logical_ring_preemption); \
107− func(has_overlay); \
108101 func(has_pooled_eu); \
109− func(has_psr); \
110102 func(has_rc6); \
111103 func(has_rc6p); \
112104 func(has_runtime_pm); \
113105 func(has_snoop); \
114106 func(has_coherent_ggtt); \
115107 func(unfenced_needs_alignment); \
108+ func(hws_needs_physical);
109+
110+#define DEV_INFO_DISPLAY_FOR_EACH_FLAG(func) \
111+ /* Keep in alphabetical order */ \
116112 func(cursor_needs_physical); \
117− func(hws_needs_physical); \
113+ func(has_csr); \
114+ func(has_ddi); \
115+ func(has_dp_mst); \
116+ func(has_fbc); \
117+ func(has_gmch_display); \
118+ func(has_hotplug); \
119+ func(has_ipc); \
120+ func(has_overlay); \
121+ func(has_psr); \
118122 func(overlay_needs_physical); \
119− func(supports_tv); \
120− func(has_ipc);
123+ func(supports_tv);
121124
122125 #define GEN_MAX_SLICES (6) /* CNL upper bound */
123126 #define GEN_MAX_SUBSLICES (8) /* ICL upper bound */
@@ -172,6 +175,13 @@ struct intel_device_info { · 48 unmodified lines
172175 #define DEFINE_FLAG(name) u8 name:1
173176 DEV_INFO_FOR_EACH_FLAG(DEFINE_FLAG);
174177 #undef DEFINE_FLAG
178+
179+ struct {
180+#define DEFINE_FLAG(name) u8 name:1
181+ DEV_INFO_DISPLAY_FOR_EACH_FLAG(DEFINE_FLAG);
182+#undef DEFINE_FLAG
183+ } display;
184+
175185 u16 ddb_size; /* in blocks */
176186
177187 /* Register offsets for the various display pipes and transcoders */
drivers/gpu/drm/i915/intel_display.c+157−173
@@ -2341,10 +2341,26 @@ static int intel_fb_offset_to_xy(int *x, int *y, · 2340 unmodified lines
23412341 int color_plane)
23422342 {
23432343 struct drm_i915_private *dev_priv = to_i915(fb->dev);
2344+ unsigned int height;
23442345
23452346 if (fb->modifier != DRM_FORMAT_MOD_LINEAR &&
2346− fb->offsets[color_plane] % intel_tile_size(dev_priv))
2347+ fb->offsets[color_plane] % intel_tile_size(dev_priv)) {
2348+ DRM_DEBUG_KMS("Misaligned offset 0x%08x for color plane %d\n",
2349+ fb->offsets[color_plane], color_plane);
23472350 return -EINVAL;
2351+ }
2352+
2353+ height = drm_framebuffer_plane_height(fb->height, fb, color_plane);
2354+ height = ALIGN(height, intel_tile_height(fb, color_plane));
2355+
2356+ /* Catch potential overflows early */
2357+ if (add_overflows_t(u32, mul_u32_u32(height, fb->pitches[color_plane]),
2358+ fb->offsets[color_plane])) {
2359+ DRM_DEBUG_KMS("Bad offset 0x%08x or pitch %d for color plane %d\n",
2360+ fb->offsets[color_plane], fb->pitches[color_plane],
2361+ color_plane);
2362+ return -ERANGE;
2363+ }
23482364
23492365 *x = 0;
23502366 *y = 0;
@@ -2767,7 +2783,7 @@ static void intel_plane_disable_noatomic(struct intel_crtc *crtc, · 416 unmodified lines
27672783 intel_pre_disable_primary_noatomic(&crtc->base);
27682784
27692785 trace_intel_disable_plane(&plane->base, crtc);
2770− plane->disable_plane(plane, crtc);
2786+ plane->disable_plane(plane, crtc_state);
27712787 }
27722788
27732789 static void
@@ -3315,7 +3331,6 @@ static void i9xx_update_plane(struct intel_plane *plane, · 541 unmodified lines
33153331 enum i9xx_plane_id i9xx_plane = plane->i9xx_plane;
33163332 u32 linear_offset;
33173333 u32 dspcntr = plane_state->ctl;
3318− i915_reg_t reg = DSPCNTR(i9xx_plane);
33193334 int x = plane_state->color_plane[0].x;
33203335 int y = plane_state->color_plane[0].y;
33213336 unsigned long irqflags;
@@ -3330,47 +3345,51 @@ static void i9xx_update_plane(struct intel_plane *plane, · 8 unmodified lines
33303345
33313346 spin_lock_irqsave(&dev_priv->uncore.lock, irqflags);
33323347
3348+ I915_WRITE_FW(DSPSTRIDE(i9xx_plane), plane_state->color_plane[0].stride);
3349+
33333350 if (INTEL_GEN(dev_priv) < 4) {
33343351 /* pipesrc and dspsize control the size that is scaled from,
33353352 * which should always be the user's requested size.
33363353 */
3354+ I915_WRITE_FW(DSPPOS(i9xx_plane), 0);
33373355 I915_WRITE_FW(DSPSIZE(i9xx_plane),
33383356 ((crtc_state->pipe_src_h - 1) << 16) |
33393357 (crtc_state->pipe_src_w - 1));
3340− I915_WRITE_FW(DSPPOS(i9xx_plane), 0);
33413358 } else if (IS_CHERRYVIEW(dev_priv) && i9xx_plane == PLANE_B) {
3359+ I915_WRITE_FW(PRIMPOS(i9xx_plane), 0);
33423360 I915_WRITE_FW(PRIMSIZE(i9xx_plane),
33433361 ((crtc_state->pipe_src_h - 1) << 16) |
33443362 (crtc_state->pipe_src_w - 1));
3345− I915_WRITE_FW(PRIMPOS(i9xx_plane), 0);
33463363 I915_WRITE_FW(PRIMCNSTALPHA(i9xx_plane), 0);
33473364 }
33483365
3349− I915_WRITE_FW(reg, dspcntr);
3350−
3351− I915_WRITE_FW(DSPSTRIDE(i9xx_plane), plane_state->color_plane[0].stride);
33523366 if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) {
3353− I915_WRITE_FW(DSPSURF(i9xx_plane),
3354− intel_plane_ggtt_offset(plane_state) +
3355− dspaddr_offset);
33563367 I915_WRITE_FW(DSPOFFSET(i9xx_plane), (y << 16) | x);
33573368 } else if (INTEL_GEN(dev_priv) >= 4) {
3369+ I915_WRITE_FW(DSPLINOFF(i9xx_plane), linear_offset);
3370+ I915_WRITE_FW(DSPTILEOFF(i9xx_plane), (y << 16) | x);
3371+ }
3372+
3373+ /*
3374+ * The control register self-arms if the plane was previously
3375+ * disabled. Try to make the plane enable atomic by writing
3376+ * the control register just before the surface register.
3377+ */
3378+ I915_WRITE_FW(DSPCNTR(i9xx_plane), dspcntr);
3379+ if (INTEL_GEN(dev_priv) >= 4)
33583380 I915_WRITE_FW(DSPSURF(i9xx_plane),
33593381 intel_plane_ggtt_offset(plane_state) +
33603382 dspaddr_offset);
3361− I915_WRITE_FW(DSPTILEOFF(i9xx_plane), (y << 16) | x);
3362− I915_WRITE_FW(DSPLINOFF(i9xx_plane), linear_offset);
3363− } else {
3383+ else
33643384 I915_WRITE_FW(DSPADDR(i9xx_plane),
33653385 intel_plane_ggtt_offset(plane_state) +
33663386 dspaddr_offset);
3367− }
33683387
33693388 spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags);
33703389 }
33713390
33723391 static void i9xx_disable_plane(struct intel_plane *plane,
3373− struct intel_crtc *crtc)
3392+ const struct intel_crtc_state *crtc_state)
33743393 {
33753394 struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
33763395 enum i9xx_plane_id i9xx_plane = plane->i9xx_plane;
@@ -3456,6 +3475,21 @@ static void skl_detach_scalers(const struct intel_crtc_state *crtc_state) · 79 unmodified lines
34563475 }
34573476 }
34583477
3478+static unsigned int skl_plane_stride_mult(const struct drm_framebuffer *fb,
3479+ int color_plane, unsigned int rotation)
3480+{
3481+ /*
3482+ * The stride is either expressed as a multiple of 64 bytes chunks for
3483+ * linear buffers or in number of tiles for tiled buffers.
3484+ */
3485+ if (fb->modifier == DRM_FORMAT_MOD_LINEAR)
3486+ return 64;
3487+ else if (drm_rotation_90_or_270(rotation))
3488+ return intel_tile_height(fb, color_plane);
3489+ else
3490+ return intel_tile_width_bytes(fb, color_plane);
3491+}
3492+
34593493 u32 skl_plane_stride(const struct intel_plane_state *plane_state,
34603494 int color_plane)
34613495 {
@@ -3466,16 +3500,7 @@ u32 skl_plane_stride(const struct intel_plane_state *plane_state, · 4 unmodified lines
34663500 if (color_plane >= fb->format->num_planes)
34673501 return 0;
34683502
3469− /*
3470− * The stride is either expressed as a multiple of 64 bytes chunks for
3471− * linear buffers or in number of tiles for tiled buffers.
3472− */
3473− if (drm_rotation_90_or_270(rotation))
3474− stride /= intel_tile_height(fb, color_plane);
3475− else
3476− stride /= intel_fb_stride_alignment(fb, color_plane);
3477−
3478− return stride;
3503+ return stride / skl_plane_stride_mult(fb, color_plane, rotation);
34793504 }
34803505
34813506 static u32 skl_plane_ctl_format(uint32_t pixel_format)
@@ -5403,23 +5428,32 @@ static void intel_pre_plane_update(struct intel_crtc_state *old_crtc_state, · 1921 unmodified lines
54035428 intel_update_watermarks(crtc);
54045429 }
54055430
5406−static void intel_crtc_disable_planes(struct intel_crtc *crtc, unsigned plane_mask)
5431+static void intel_crtc_disable_planes(struct intel_atomic_state *state,
5432+ struct intel_crtc *crtc)
54075433 {
5408− struct drm_device *dev = crtc->base.dev;
5434+ struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
5435+ const struct intel_crtc_state *new_crtc_state =
5436+ intel_atomic_get_new_crtc_state(state, crtc);
5437+ unsigned int update_mask = new_crtc_state->update_planes;
5438+ const struct intel_plane_state *old_plane_state;
54095439 struct intel_plane *plane;
54105440 unsigned fb_bits = 0;
5441+ int i;
54115442
54125443 intel_crtc_dpms_overlay_disable(crtc);
54135444
5414− for_each_intel_plane_on_crtc(dev, crtc, plane) {
5415− if (plane_mask & BIT(plane->id)) {
5416− plane->disable_plane(plane, crtc);
5445+ for_each_old_intel_plane_in_state(state, plane, old_plane_state, i) {
5446+ if (crtc->pipe != plane->pipe ||
5447+ !(update_mask & BIT(plane->id)))
5448+ continue;
54175449
5450+ plane->disable_plane(plane, new_crtc_state);
5451+
5452+ if (old_plane_state->base.visible)
54185453 fb_bits |= plane->frontbuffer_bit;
5419− }
54205454 }
54215455
5422− intel_frontbuffer_flip(to_i915(dev), fb_bits);
5456+ intel_frontbuffer_flip(dev_priv, fb_bits);
54235457 }
54245458
54255459 static void intel_encoders_pre_pll_enable(struct drm_crtc *crtc,
@@ -5692,9 +5726,6 @@ static void haswell_crtc_enable(struct intel_crtc_state *pipe_config, · 266 unmodified lines
56925726 if (pipe_config->shared_dpll)
56935727 intel_enable_shared_dpll(pipe_config);
56945728
5695− if (INTEL_GEN(dev_priv) >= 11)
5696− icl_map_plls_to_ports(crtc, pipe_config, old_state);
5697−
56985729 intel_encoders_pre_enable(crtc, pipe_config, old_state);
56995730
57005731 if (intel_crtc_has_dp_encoder(pipe_config))
@@ -5889,6 +5920,8 @@ static void haswell_crtc_disable(struct intel_crtc_state *old_crtc_state, · 188 unmodified lines
58895920 if (!transcoder_is_dsi(cpu_transcoder))
58905921 intel_ddi_disable_transcoder_func(old_crtc_state);
58915922
5923+ intel_dsc_disable(old_crtc_state);
5924+
58925925 if (INTEL_GEN(dev_priv) >= 9)
58935926 skylake_scaler_disable(intel_crtc);
58945927 else
@@ -5896,9 +5929,6 @@ static void haswell_crtc_disable(struct intel_crtc_state *old_crtc_state, · 1 unmodified line
58965929
58975930 intel_encoders_post_disable(crtc, old_crtc_state, old_state);
58985931
5899− if (INTEL_GEN(dev_priv) >= 11)
5900− icl_unmap_plls_to_ports(crtc, old_crtc_state, old_state);
5901−
59025932 intel_encoders_post_pll_disable(crtc, old_crtc_state, old_state);
59035933 }
59045934
@@ -6724,7 +6754,7 @@ static void compute_m_n(unsigned int m, unsigned int n, · 819 unmodified lines
67246754 }
67256755
67266756 void
6727−intel_link_compute_m_n(int bits_per_pixel, int nlanes,
6757+intel_link_compute_m_n(u16 bits_per_pixel, int nlanes,
67286758 int pixel_clock, int link_clock,
67296759 struct intel_link_m_n *m_n,
67306760 bool constant_n)
@@ -8939,7 +8969,7 @@ skylake_get_initial_plane_config(struct intel_crtc *crtc, · 2208 unmodified lines
89398969 fb->width = ((val >> 0) & 0x1fff) + 1;
89408970
89418971 val = I915_READ(PLANE_STRIDE(pipe, plane_id));
8942− stride_mult = intel_fb_stride_alignment(fb, 0);
8972+ stride_mult = skl_plane_stride_mult(fb, 0, DRM_MODE_ROTATE_0);
89438973 fb->pitches[0] = (val & 0x3ff) * stride_mult;
89448974
89458975 aligned_height = intel_fb_align_height(fb, 0, fb->height);
@@ -9303,10 +9333,12 @@ void hsw_disable_pc8(struct drm_i915_private *dev_priv) · 357 unmodified lines
93039333 static int haswell_crtc_compute_clock(struct intel_crtc *crtc,
93049334 struct intel_crtc_state *crtc_state)
93059335 {
9336+ struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
93069337 struct intel_atomic_state *state =
93079338 to_intel_atomic_state(crtc_state->base.state);
93089339
9309− if (!intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DSI)) {
9340+ if (!intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DSI) ||
9341+ IS_ICELAKE(dev_priv)) {
93109342 struct intel_encoder *encoder =
93119343 intel_get_crtc_new_encoder(state, crtc_state);
93129344
@@ -9444,11 +9476,18 @@ static bool hsw_get_transcoder_state(struct intel_crtc *crtc, · 131 unmodified lines
94449476 struct drm_device *dev = crtc->base.dev;
94459477 struct drm_i915_private *dev_priv = to_i915(dev);
94469478 enum intel_display_power_domain power_domain;
9479+ unsigned long panel_transcoder_mask = BIT(TRANSCODER_EDP);
9480+ unsigned long enabled_panel_transcoders = 0;
9481+ enum transcoder panel_transcoder;
94479482 u32 tmp;
94489483
9484+ if (IS_ICELAKE(dev_priv))
9485+ panel_transcoder_mask |=
9486+ BIT(TRANSCODER_DSI_0) | BIT(TRANSCODER_DSI_1);
9487+
94499488 /*
94509489 * The pipe->transcoder mapping is fixed with the exception of the eDP
9451− * transcoder handled below.
9490+ * and DSI transcoders handled below.
94529491 */
94539492 pipe_config->cpu_transcoder = (enum transcoder) crtc->pipe;
94549493
@@ -9456,29 +9495,49 @@ static bool hsw_get_transcoder_state(struct intel_crtc *crtc, · 1 unmodified line
94569495 * XXX: Do intel_display_power_get_if_enabled before reading this (for
94579496 * consistency and less surprising code; it's in always on power).
94589497 */
9459− tmp = I915_READ(TRANS_DDI_FUNC_CTL(TRANSCODER_EDP));
9460− if (tmp & TRANS_DDI_FUNC_ENABLE) {
9461− enum pipe trans_edp_pipe;
9498+ for_each_set_bit(panel_transcoder, &panel_transcoder_mask, 32) {
9499+ enum pipe trans_pipe;
9500+
9501+ tmp = I915_READ(TRANS_DDI_FUNC_CTL(panel_transcoder));
9502+ if (!(tmp & TRANS_DDI_FUNC_ENABLE))
9503+ continue;
9504+
9505+ /*
9506+ * Log all enabled ones, only use the first one.
9507+ *
9508+ * FIXME: This won't work for two separate DSI displays.
9509+ */
9510+ enabled_panel_transcoders |= BIT(panel_transcoder);
9511+ if (enabled_panel_transcoders != BIT(panel_transcoder))
9512+ continue;
9513+
94629514 switch (tmp & TRANS_DDI_EDP_INPUT_MASK) {
94639515 default:
9464− WARN(1, "unknown pipe linked to edp transcoder\n");
9516+ WARN(1, "unknown pipe linked to transcoder %s\n",
9517+ transcoder_name(panel_transcoder));
94659518 /* fall through */
94669519 case TRANS_DDI_EDP_INPUT_A_ONOFF:
94679520 case TRANS_DDI_EDP_INPUT_A_ON:
9468− trans_edp_pipe = PIPE_A;
9521+ trans_pipe = PIPE_A;
94699522 break;
94709523 case TRANS_DDI_EDP_INPUT_B_ONOFF:
9471− trans_edp_pipe = PIPE_B;
9524+ trans_pipe = PIPE_B;
94729525 break;
94739526 case TRANS_DDI_EDP_INPUT_C_ONOFF:
9474− trans_edp_pipe = PIPE_C;
9527+ trans_pipe = PIPE_C;
94759528 break;
94769529 }
94779530
9478− if (trans_edp_pipe == crtc->pipe)
9479− pipe_config->cpu_transcoder = TRANSCODER_EDP;
9531+ if (trans_pipe == crtc->pipe)
9532+ pipe_config->cpu_transcoder = panel_transcoder;
94809533 }
94819534
9535+ /*
9536+ * Valid combos: none, eDP, DSI0, DSI1, DSI0+DSI1
9537+ */
9538+ WARN_ON((enabled_panel_transcoders & BIT(TRANSCODER_EDP)) &&
9539+ enabled_panel_transcoders != BIT(TRANSCODER_EDP));
9540+
94829541 power_domain = POWER_DOMAIN_TRANSCODER(pipe_config->cpu_transcoder);
94839542 if (!intel_display_power_get_if_enabled(dev_priv, power_domain))
94849543 return false;
@@ -9611,7 +9670,8 @@ static bool haswell_get_pipe_config(struct intel_crtc *crtc, · 126 unmodified lines
96119670 if (!active)
96129671 goto out;
96139672
9614− if (!transcoder_is_dsi(pipe_config->cpu_transcoder)) {
9673+ if (!transcoder_is_dsi(pipe_config->cpu_transcoder) ||
9674+ IS_ICELAKE(dev_priv)) {
96159675 haswell_get_ddi_port_state(crtc, pipe_config);
96169676 intel_get_pipe_timings(crtc, pipe_config);
96179677 }
@@ -9667,7 +9727,7 @@ static u32 intel_cursor_base(const struct intel_plane_state *plane_state) · 49 unmodified lines
96679727 const struct drm_i915_gem_object *obj = intel_fb_obj(fb);
96689728 u32 base;
96699729
9670− if (INTEL_INFO(dev_priv)->cursor_needs_physical)
9730+ if (INTEL_INFO(dev_priv)->display.cursor_needs_physical)
96719731 base = obj->phys_handle->busaddr;
96729732 else
96739733 base = intel_plane_ggtt_offset(plane_state);
@@ -9894,9 +9954,9 @@ static void i845_update_cursor(struct intel_plane *plane, · 220 unmodified lines
98949954 }
98959955
98969956 static void i845_disable_cursor(struct intel_plane *plane,
9897− struct intel_crtc *crtc)
9957+ const struct intel_crtc_state *crtc_state)
98989958 {
9899− i845_update_cursor(plane, NULL, NULL);
9959+ i845_update_cursor(plane, crtc_state, NULL);
99009960 }
99019961
99029962 static bool i845_cursor_get_hw_state(struct intel_plane *plane,
@@ -10087,8 +10147,8 @@ static void i9xx_update_cursor(struct intel_plane *plane, · 184 unmodified lines
1008710147 * On some platforms writing CURCNTR first will also
1008810148 * cause CURPOS to be armed by the CURBASE write.
1008910149 * Without the CURCNTR write the CURPOS write would
10090− * arm itself. Thus we always start the full update
10091− * with a CURCNTR write.
10150+ * arm itself. Thus we always update CURCNTR before
10151+ * CURPOS.
1009210152 *
1009310153 * On other platforms CURPOS always requires the
1009410154 * CURBASE write to arm the update. Additonally
@@ -10098,15 +10158,20 @@ static void i9xx_update_cursor(struct intel_plane *plane, · 3 unmodified lines
1009810158 * cursor that doesn't appear to move, or even change
1009910159 * shape. Thus we always write CURBASE.
1010010160 *
10101− * CURCNTR and CUR_FBC_CTL are always
10102− * armed by the CURBASE write only.
10161+ * The other registers are armed by by the CURBASE write
10162+ * except when the plane is getting enabled at which time
10163+ * the CURCNTR write arms the update.
1010310164 */
10165+
10166+ if (INTEL_GEN(dev_priv) >= 9)
10167+ skl_write_cursor_wm(plane, crtc_state);
10168+
1010410169 if (plane->cursor.base != base ||
1010510170 plane->cursor.size != fbc_ctl ||
1010610171 plane->cursor.cntl != cntl) {
10107− I915_WRITE_FW(CURCNTR(pipe), cntl);
1010810172 if (HAS_CUR_FBC(dev_priv))
1010910173 I915_WRITE_FW(CUR_FBC_CTL(pipe), fbc_ctl);
10174+ I915_WRITE_FW(CURCNTR(pipe), cntl);
1011010175 I915_WRITE_FW(CURPOS(pipe), pos);
1011110176 I915_WRITE_FW(CURBASE(pipe), base);
1011210177
@@ -10122,9 +10187,9 @@ static void i9xx_update_cursor(struct intel_plane *plane, · 9 unmodified lines
1012210187 }
1012310188
1012410189 static void i9xx_disable_cursor(struct intel_plane *plane,
10125− struct intel_crtc *crtc)
10190+ const struct intel_crtc_state *crtc_state)
1012610191 {
10127− i9xx_update_cursor(plane, NULL, NULL);
10192+ i9xx_update_cursor(plane, crtc_state, NULL);
1012810193 }
1012910194
1013010195 static bool i9xx_cursor_get_hw_state(struct intel_plane *plane,
@@ -10835,8 +10900,10 @@ static int icl_check_nv12_planes(struct intel_crtc_state *crtc_state) · 704 unmodified lines
1083510900 continue;
1083610901
1083710902 plane_state->linked_plane = NULL;
10838− if (plane_state->slave && !plane_state->base.visible)
10903+ if (plane_state->slave && !plane_state->base.visible) {
1083910904 crtc_state->active_planes &= ~BIT(plane->id);
10905+ crtc_state->update_planes |= BIT(plane->id);
10906+ }
1084010907
1084110908 plane_state->slave = false;
1084210909 }
@@ -10877,6 +10944,7 @@ static int icl_check_nv12_planes(struct intel_crtc_state *crtc_state) · 34 unmodified lines
1087710944 linked_state->slave = true;
1087810945 linked_state->linked_plane = plane;
1087910946 crtc_state->active_planes |= BIT(linked->id);
10947+ crtc_state->update_planes |= BIT(linked->id);
1088010948 DRM_DEBUG_KMS("Using %s as Y plane for %s\n", linked->base.name, plane->base.name);
1088110949 }
1088210950
@@ -11887,6 +11955,8 @@ static void verify_wm_state(struct drm_crtc *crtc, · 1004 unmodified lines
1188711955 struct skl_pipe_wm hw_wm, *sw_wm;
1188811956 struct skl_plane_wm *hw_plane_wm, *sw_plane_wm;
1188911957 struct skl_ddb_entry *hw_ddb_entry, *sw_ddb_entry;
11958+ struct skl_ddb_entry hw_ddb_y[I915_MAX_PLANES];
11959+ struct skl_ddb_entry hw_ddb_uv[I915_MAX_PLANES];
1189011960 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
1189111961 const enum pipe pipe = intel_crtc->pipe;
1189211962 int plane, level, max_level = ilk_wm_max_level(dev_priv);
@@ -11897,6 +11967,8 @@ static void verify_wm_state(struct drm_crtc *crtc, · 4 unmodified lines
1189711967 skl_pipe_wm_get_hw_state(crtc, &hw_wm);
1189811968 sw_wm = &to_intel_crtc_state(new_state)->wm.skl.optimal;
1189911969
11970+ skl_pipe_ddb_get_hw_state(intel_crtc, hw_ddb_y, hw_ddb_uv);
11971+
1190011972 skl_ddb_get_hw_state(dev_priv, &hw_ddb);
1190111973 sw_ddb = &dev_priv->wm.skl_hw.ddb;
1190211974
@@ -11939,8 +12011,8 @@ static void verify_wm_state(struct drm_crtc *crtc, · 36 unmodified lines
1193912011 }
1194012012
1194112013 /* DDB */
11942− hw_ddb_entry = &hw_ddb.plane[pipe][plane];
11943− sw_ddb_entry = &sw_ddb->plane[pipe][plane];
12014+ hw_ddb_entry = &hw_ddb_y[plane];
12015+ sw_ddb_entry = &to_intel_crtc_state(new_state)->wm.skl.plane_ddb_y[plane];
1194412016
1194512017 if (!skl_ddb_entry_equal(hw_ddb_entry, sw_ddb_entry)) {
1194612018 DRM_ERROR("mismatch in DDB state pipe %c plane %d (expected (%u,%u), found (%u,%u))\n",
@@ -11989,8 +12061,8 @@ static void verify_wm_state(struct drm_crtc *crtc, · 42 unmodified lines
1198912061 }
1199012062
1199112063 /* DDB */
11992− hw_ddb_entry = &hw_ddb.plane[pipe][PLANE_CURSOR];
11993− sw_ddb_entry = &sw_ddb->plane[pipe][PLANE_CURSOR];
12064+ hw_ddb_entry = &hw_ddb_y[PLANE_CURSOR];
12065+ sw_ddb_entry = &to_intel_crtc_state(new_state)->wm.skl.plane_ddb_y[PLANE_CURSOR];
1199412066
1199512067 if (!skl_ddb_entry_equal(hw_ddb_entry, sw_ddb_entry)) {
1199612068 DRM_ERROR("mismatch in DDB state pipe %c cursor (expected (%u,%u), found (%u,%u))\n",
@@ -12668,7 +12740,6 @@ static void intel_update_crtc(struct drm_crtc *crtc, · 671 unmodified lines
1266812740 struct drm_device *dev = crtc->dev;
1266912741 struct drm_i915_private *dev_priv = to_i915(dev);
1267012742 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
12671− struct intel_crtc_state *old_intel_cstate = to_intel_crtc_state(old_crtc_state);
1267212743 struct intel_crtc_state *pipe_config = to_intel_crtc_state(new_crtc_state);
1267312744 bool modeset = needs_modeset(new_crtc_state);
1267412745 struct intel_plane_state *new_plane_state =
@@ -12691,8 +12762,10 @@ static void intel_update_crtc(struct drm_crtc *crtc, · 16 unmodified lines
1269112762
1269212763 intel_begin_crtc_commit(crtc, old_crtc_state);
1269312764
12694− intel_update_planes_on_crtc(to_intel_atomic_state(state), intel_crtc,
12695− old_intel_cstate, pipe_config);
12765+ if (INTEL_GEN(dev_priv) >= 9)
12766+ skl_update_planes_on_crtc(to_intel_atomic_state(state), intel_crtc);
12767+ else
12768+ i9xx_update_planes_on_crtc(to_intel_atomic_state(state), intel_crtc);
1269612769
1269712770 intel_finish_crtc_commit(crtc, old_crtc_state);
1269812771 }
@@ -12885,7 +12958,7 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state) · 186 unmodified lines
1288512958 intel_pre_plane_update(old_intel_crtc_state, new_intel_crtc_state);
1288612959
1288712960 if (old_crtc_state->active) {
12888− intel_crtc_disable_planes(intel_crtc, old_intel_crtc_state->active_planes);
12961+ intel_crtc_disable_planes(intel_state, intel_crtc);
1288912962
1289012963 /*
1289112964 * We need to disable pipe CRC before disabling the pipe,
@@ -13240,7 +13313,7 @@ static int intel_plane_pin_fb(struct intel_plane_state *plane_state) · 348 unmodified lines
1324013313 struct i915_vma *vma;
1324113314
1324213315 if (plane->id == PLANE_CURSOR &&
13243− INTEL_INFO(dev_priv)->cursor_needs_physical) {
13316+ INTEL_INFO(dev_priv)->display.cursor_needs_physical) {
1324413317 struct drm_i915_gem_object *obj = intel_fb_obj(fb);
1324513318 const int align = intel_cursor_alignment(dev_priv);
1324613319 int err;
@@ -13735,7 +13808,7 @@ intel_legacy_cursor_update(struct drm_plane *plane, · 488 unmodified lines
1373513808 to_intel_plane_state(plane->state));
1373613809 } else {
1373713810 trace_intel_disable_plane(plane, to_intel_crtc(crtc));
13738− intel_plane->disable_plane(intel_plane, to_intel_crtc(crtc));
13811+ intel_plane->disable_plane(intel_plane, crtc_state);
1373913812 }
1374013813
1374113814 intel_plane_unpin_fb(to_intel_plane_state(old_plane_state));
@@ -14186,7 +14259,7 @@ static void intel_setup_outputs(struct drm_i915_private *dev_priv) · 444 unmodified lines
1418614259
1418714260 intel_pps_init(dev_priv);
1418814261
14189− if (INTEL_INFO(dev_priv)->num_pipes == 0)
14262+ if (!HAS_DISPLAY(dev_priv))
1419014263 return;
1419114264
1419214265 /*
@@ -14451,7 +14524,6 @@ static int intel_framebuffer_init(struct intel_framebuffer *intel_fb, · 258 unmodified lines
1445114524 {
1445214525 struct drm_i915_private *dev_priv = to_i915(obj->base.dev);
1445314526 struct drm_framebuffer *fb = &intel_fb->base;
14454− struct drm_format_name_buf format_name;
1445514527 u32 pitch_limit;
1445614528 unsigned int tiling, stride;
1445714529 int ret = -EINVAL;
@@ -14482,39 +14554,14 @@ static int intel_framebuffer_init(struct intel_framebuffer *intel_fb, · 24 unmodified lines
1448214554 }
1448314555 }
1448414556
14485− /* Passed in modifier sanity checking. */
14486− switch (mode_cmd->modifier[0]) {
14487− case I915_FORMAT_MOD_Y_TILED_CCS:
14488− case I915_FORMAT_MOD_Yf_TILED_CCS:
14489− switch (mode_cmd->pixel_format) {
14490− case DRM_FORMAT_XBGR8888:
14491− case DRM_FORMAT_ABGR8888:
14492− case DRM_FORMAT_XRGB8888:
14493− case DRM_FORMAT_ARGB8888:
14494− break;
14495− default:
14496− DRM_DEBUG_KMS("RC supported only with RGB8888 formats\n");
14497− goto err;
14498− }
14499− /* fall through */
14500− case I915_FORMAT_MOD_Yf_TILED:
14501− if (mode_cmd->pixel_format == DRM_FORMAT_C8) {
14502− DRM_DEBUG_KMS("Indexed format does not support Yf tiling\n");
14503− goto err;
14504− }
14505− /* fall through */
14506− case I915_FORMAT_MOD_Y_TILED:
14507− if (INTEL_GEN(dev_priv) < 9) {
14508− DRM_DEBUG_KMS("Unsupported tiling 0x%llx!\n",
14509− mode_cmd->modifier[0]);
14510− goto err;
14511− }
14512− break;
14513− case DRM_FORMAT_MOD_LINEAR:
14514− case I915_FORMAT_MOD_X_TILED:
14515− break;
14516− default:
14517− DRM_DEBUG_KMS("Unsupported fb modifier 0x%llx!\n",
14557+ if (!drm_any_plane_has_format(&dev_priv->drm,
14558+ mode_cmd->pixel_format,
14559+ mode_cmd->modifier[0])) {
14560+ struct drm_format_name_buf format_name;
14561+
14562+ DRM_DEBUG_KMS("unsupported pixel format %s / modifier 0x%llx\n",
14563+ drm_get_format_name(mode_cmd->pixel_format,
14564+ &format_name),
1451814565 mode_cmd->modifier[0]);
1451914566 goto err;
1452014567 }
@@ -14549,69 +14596,6 @@ static int intel_framebuffer_init(struct intel_framebuffer *intel_fb, · 28 unmodified lines
1454914596 goto err;
1455014597 }
1455114598
14552− /* Reject formats not supported by any plane early. */
14553− switch (mode_cmd->pixel_format) {
14554− case DRM_FORMAT_C8:
14555− case DRM_FORMAT_RGB565:
14556− case DRM_FORMAT_XRGB8888:
14557− case DRM_FORMAT_ARGB8888:
14558− break;
14559− case DRM_FORMAT_XRGB1555:
14560− if (INTEL_GEN(dev_priv) > 3) {
14561− DRM_DEBUG_KMS("unsupported pixel format: %s\n",
14562− drm_get_format_name(mode_cmd->pixel_format, &format_name));
14563− goto err;
14564− }
14565− break;
14566− case DRM_FORMAT_ABGR8888:
14567− if (!IS_VALLEYVIEW(dev_priv) && !IS_CHERRYVIEW(dev_priv) &&
14568− INTEL_GEN(dev_priv) < 9) {
14569− DRM_DEBUG_KMS("unsupported pixel format: %s\n",
14570− drm_get_format_name(mode_cmd->pixel_format, &format_name));
14571− goto err;
14572− }
14573− break;
14574− case DRM_FORMAT_XBGR8888:
14575− case DRM_FORMAT_XRGB2101010:
14576− case DRM_FORMAT_XBGR2101010:
14577− if (INTEL_GEN(dev_priv) < 4) {
14578− DRM_DEBUG_KMS("unsupported pixel format: %s\n",
14579− drm_get_format_name(mode_cmd->pixel_format, &format_name));
14580− goto err;
14581− }
14582− break;
14583− case DRM_FORMAT_ABGR2101010:
14584− if (!IS_VALLEYVIEW(dev_priv) && !IS_CHERRYVIEW(dev_priv)) {
14585− DRM_DEBUG_KMS("unsupported pixel format: %s\n",
14586− drm_get_format_name(mode_cmd->pixel_format, &format_name));
14587− goto err;
14588− }
14589− break;
14590− case DRM_FORMAT_YUYV:
14591− case DRM_FORMAT_UYVY:
14592− case DRM_FORMAT_YVYU:
14593− case DRM_FORMAT_VYUY:
14594− if (INTEL_GEN(dev_priv) < 5 && !IS_G4X(dev_priv)) {
14595− DRM_DEBUG_KMS("unsupported pixel format: %s\n",
14596− drm_get_format_name(mode_cmd->pixel_format, &format_name));
14597− goto err;
14598− }
14599− break;
14600− case DRM_FORMAT_NV12:
14601− if (INTEL_GEN(dev_priv) < 9 || IS_SKYLAKE(dev_priv) ||
14602− IS_BROXTON(dev_priv)) {
14603− DRM_DEBUG_KMS("unsupported pixel format: %s\n",
14604− drm_get_format_name(mode_cmd->pixel_format,
14605− &format_name));
14606− goto err;
14607− }
14608− break;
14609− default:
14610− DRM_DEBUG_KMS("unsupported pixel format: %s\n",
14611− drm_get_format_name(mode_cmd->pixel_format, &format_name));
14612− goto err;
14613− }
14614−
1461514599 /* FIXME need to adjust LINOFF/TILEOFF accordingly. */
1461614600 if (mode_cmd->offsets[0] != 0)
1461714601 goto err;
@@ -16066,7 +16050,7 @@ intel_display_capture_error_state(struct drm_i915_private *dev_priv) · 1448 unmodified lines
1606616050 };
1606716051 int i;
1606816052
16069− if (INTEL_INFO(dev_priv)->num_pipes == 0)
16053+ if (!HAS_DISPLAY(dev_priv))
1607016054 return NULL;
1607116055
1607216056 error = kzalloc(sizeof(*error), GFP_ATOMIC);
drivers/gpu/drm/i915/intel_display.h+19−2
@@ -242,6 +242,7 @@ enum intel_display_power_domain { · 241 unmodified lines
242242 POWER_DOMAIN_TRANSCODER_B,
243243 POWER_DOMAIN_TRANSCODER_C,
244244 POWER_DOMAIN_TRANSCODER_EDP,
245+ POWER_DOMAIN_TRANSCODER_EDP_VDSC,
245246 POWER_DOMAIN_TRANSCODER_DSI_A,
246247 POWER_DOMAIN_TRANSCODER_DSI_C,
247248 POWER_DOMAIN_PORT_DDI_A_LANES,
@@ -398,6 +399,14 @@ struct intel_link_m_n { · 150 unmodified lines
398399 for_each_power_well_reverse(__dev_priv, __power_well) \
399400 for_each_if((__power_well)->desc->domains & (__domain_mask))
400401
402+#define for_each_old_intel_plane_in_state(__state, plane, old_plane_state, __i) \
403+ for ((__i) = 0; \
404+ (__i) < (__state)->base.dev->mode_config.num_total_plane && \
405+ ((plane) = to_intel_plane((__state)->base.planes[__i].ptr), \
406+ (old_plane_state) = to_intel_plane_state((__state)->base.planes[__i].old_state), 1); \
407+ (__i)++) \
408+ for_each_if(plane)
409+
401410 #define for_each_new_intel_plane_in_state(__state, plane, new_plane_state, __i) \
402411 for ((__i) = 0; \
403412 (__i) < (__state)->base.dev->mode_config.num_total_plane && \
@@ -423,10 +432,18 @@ struct intel_link_m_n { · 19 unmodified lines
423432 (__i)++) \
424433 for_each_if(plane)
425434
426−void intel_link_compute_m_n(int bpp, int nlanes,
435+#define for_each_oldnew_intel_crtc_in_state(__state, crtc, old_crtc_state, new_crtc_state, __i) \
436+ for ((__i) = 0; \
437+ (__i) < (__state)->base.dev->mode_config.num_crtc && \
438+ ((crtc) = to_intel_crtc((__state)->base.crtcs[__i].ptr), \
439+ (old_crtc_state) = to_intel_crtc_state((__state)->base.crtcs[__i].old_state), \
440+ (new_crtc_state) = to_intel_crtc_state((__state)->base.crtcs[__i].new_state), 1); \
441+ (__i)++) \
442+ for_each_if(crtc)
443+
444+void intel_link_compute_m_n(u16 bpp, int nlanes,
427445 int pixel_clock, int link_clock,
428446 struct intel_link_m_n *m_n,
429447 bool constant_n);
430−
431448 bool is_ccs_modifier(u64 modifier);
432449 #endif
drivers/gpu/drm/i915/intel_dp.c+255−48
@@ -47,6 +47,8 @@ · 46 unmodified lines
4747
4848 /* DP DSC small joiner has 2 FIFOs each of 640 x 6 bytes */
4949 #define DP_DSC_MAX_SMALL_JOINER_RAM_BUFFER 61440
50+#define DP_DSC_MIN_SUPPORTED_BPC 8
51+#define DP_DSC_MAX_SUPPORTED_BPC 10
5052
5153 /* DP DSC throughput values used for slice count calculations KPixels/s */
5254 #define DP_DSC_PEAK_PIXEL_RATE 2720000
@@ -543,7 +545,7 @@ intel_dp_mode_valid(struct drm_connector *connector, · 490 unmodified lines
543545 dsc_slice_count =
544546 drm_dp_dsc_sink_max_slice_count(intel_dp->dsc_dpcd,
545547 true);
546− } else {
548+ } else if (drm_dp_sink_supports_fec(intel_dp->fec_capable)) {
547549 dsc_max_output_bpp =
548550 intel_dp_dsc_get_output_bpp(max_link_clock,
549551 max_lanes,
@@ -1708,6 +1710,41 @@ struct link_config_limits { · 1158 unmodified lines
17081710 int min_bpp, max_bpp;
17091711 };
17101712
1713+static bool intel_dp_source_supports_fec(struct intel_dp *intel_dp,
1714+ const struct intel_crtc_state *pipe_config)
1715+{
1716+ struct drm_i915_private *dev_priv = dp_to_i915(intel_dp);
1717+
1718+ return INTEL_GEN(dev_priv) >= 11 &&
1719+ pipe_config->cpu_transcoder != TRANSCODER_A;
1720+}
1721+
1722+static bool intel_dp_supports_fec(struct intel_dp *intel_dp,
1723+ const struct intel_crtc_state *pipe_config)
1724+{
1725+ return intel_dp_source_supports_fec(intel_dp, pipe_config) &&
1726+ drm_dp_sink_supports_fec(intel_dp->fec_capable);
1727+}
1728+
1729+static bool intel_dp_source_supports_dsc(struct intel_dp *intel_dp,
1730+ const struct intel_crtc_state *pipe_config)
1731+{
1732+ struct drm_i915_private *dev_priv = dp_to_i915(intel_dp);
1733+
1734+ return INTEL_GEN(dev_priv) >= 10 &&
1735+ pipe_config->cpu_transcoder != TRANSCODER_A;
1736+}
1737+
1738+static bool intel_dp_supports_dsc(struct intel_dp *intel_dp,
1739+ const struct intel_crtc_state *pipe_config)
1740+{
1741+ if (!intel_dp_is_edp(intel_dp) && !pipe_config->fec_enable)
1742+ return false;
1743+
1744+ return intel_dp_source_supports_dsc(intel_dp, pipe_config) &&
1745+ drm_dp_sink_supports_dsc(intel_dp->dsc_dpcd);
1746+}
1747+
17111748 static int intel_dp_compute_bpp(struct intel_dp *intel_dp,
17121749 struct intel_crtc_state *pipe_config)
17131750 {
@@ -1842,14 +1879,122 @@ intel_dp_compute_link_config_fast(struct intel_dp *intel_dp, · 128 unmodified lines
18421879 return false;
18431880 }
18441881
1882+static int intel_dp_dsc_compute_bpp(struct intel_dp *intel_dp, u8 dsc_max_bpc)
1883+{
1884+ int i, num_bpc;
1885+ u8 dsc_bpc[3] = {0};
1886+
1887+ num_bpc = drm_dp_dsc_sink_supported_input_bpcs(intel_dp->dsc_dpcd,
1888+ dsc_bpc);
1889+ for (i = 0; i < num_bpc; i++) {
1890+ if (dsc_max_bpc >= dsc_bpc[i])
1891+ return dsc_bpc[i] * 3;
1892+ }
1893+
1894+ return 0;
1895+}
1896+
1897+static bool intel_dp_dsc_compute_config(struct intel_dp *intel_dp,
1898+ struct intel_crtc_state *pipe_config,
1899+ struct drm_connector_state *conn_state,
1900+ struct link_config_limits *limits)
1901+{
1902+ struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
1903+ struct drm_i915_private *dev_priv = to_i915(dig_port->base.base.dev);
1904+ struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode;
1905+ u8 dsc_max_bpc;
1906+ int pipe_bpp;
1907+
1908+ if (!intel_dp_supports_dsc(intel_dp, pipe_config))
1909+ return false;
1910+
1911+ dsc_max_bpc = min_t(u8, DP_DSC_MAX_SUPPORTED_BPC,
1912+ conn_state->max_requested_bpc);
1913+
1914+ pipe_bpp = intel_dp_dsc_compute_bpp(intel_dp, dsc_max_bpc);
1915+ if (pipe_bpp < DP_DSC_MIN_SUPPORTED_BPC * 3) {
1916+ DRM_DEBUG_KMS("No DSC support for less than 8bpc\n");
1917+ return false;
1918+ }
1919+
1920+ /*
1921+ * For now enable DSC for max bpp, max link rate, max lane count.
1922+ * Optimize this later for the minimum possible link rate/lane count
1923+ * with DSC enabled for the requested mode.
1924+ */
1925+ pipe_config->pipe_bpp = pipe_bpp;
1926+ pipe_config->port_clock = intel_dp->common_rates[limits->max_clock];
1927+ pipe_config->lane_count = limits->max_lane_count;
1928+
1929+ if (intel_dp_is_edp(intel_dp)) {
1930+ pipe_config->dsc_params.compressed_bpp =
1931+ min_t(u16, drm_edp_dsc_sink_output_bpp(intel_dp->dsc_dpcd) >> 4,
1932+ pipe_config->pipe_bpp);
1933+ pipe_config->dsc_params.slice_count =
1934+ drm_dp_dsc_sink_max_slice_count(intel_dp->dsc_dpcd,
1935+ true);
1936+ } else {
1937+ u16 dsc_max_output_bpp;
1938+ u8 dsc_dp_slice_count;
1939+
1940+ dsc_max_output_bpp =
1941+ intel_dp_dsc_get_output_bpp(pipe_config->port_clock,
1942+ pipe_config->lane_count,
1943+ adjusted_mode->crtc_clock,
1944+ adjusted_mode->crtc_hdisplay);
1945+ dsc_dp_slice_count =
1946+ intel_dp_dsc_get_slice_count(intel_dp,
1947+ adjusted_mode->crtc_clock,
1948+ adjusted_mode->crtc_hdisplay);
1949+ if (!dsc_max_output_bpp || !dsc_dp_slice_count) {
1950+ DRM_DEBUG_KMS("Compressed BPP/Slice Count not supported\n");
1951+ return false;
1952+ }
1953+ pipe_config->dsc_params.compressed_bpp = min_t(u16,
1954+ dsc_max_output_bpp >> 4,
1955+ pipe_config->pipe_bpp);
1956+ pipe_config->dsc_params.slice_count = dsc_dp_slice_count;
1957+ }
1958+ /*
1959+ * VDSC engine operates at 1 Pixel per clock, so if peak pixel rate
1960+ * is greater than the maximum Cdclock and if slice count is even
1961+ * then we need to use 2 VDSC instances.
1962+ */
1963+ if (adjusted_mode->crtc_clock > dev_priv->max_cdclk_freq) {
1964+ if (pipe_config->dsc_params.slice_count > 1) {
1965+ pipe_config->dsc_params.dsc_split = true;
1966+ } else {
1967+ DRM_DEBUG_KMS("Cannot split stream to use 2 VDSC instances\n");
1968+ return false;
1969+ }
1970+ }
1971+ if (intel_dp_compute_dsc_params(intel_dp, pipe_config) < 0) {
1972+ DRM_DEBUG_KMS("Cannot compute valid DSC parameters for Input Bpp = %d "
1973+ "Compressed BPP = %d\n",
1974+ pipe_config->pipe_bpp,
1975+ pipe_config->dsc_params.compressed_bpp);
1976+ return false;
1977+ }
1978+ pipe_config->dsc_params.compression_enable = true;
1979+ DRM_DEBUG_KMS("DP DSC computed with Input Bpp = %d "
1980+ "Compressed Bpp = %d Slice Count = %d\n",
1981+ pipe_config->pipe_bpp,
1982+ pipe_config->dsc_params.compressed_bpp,
1983+ pipe_config->dsc_params.slice_count);
1984+
1985+ return true;
1986+}
1987+
18451988 static bool
18461989 intel_dp_compute_link_config(struct intel_encoder *encoder,
1847− struct intel_crtc_state *pipe_config)
1990+ struct intel_crtc_state *pipe_config,
1991+ struct drm_connector_state *conn_state)
18481992 {
18491993 struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode;
18501994 struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base);
18511995 struct link_config_limits limits;
18521996 int common_len;
1997+ bool ret;
18531998
18541999 common_len = intel_dp_common_len_rate_limit(intel_dp,
18552000 intel_dp->max_link_rate);
@@ -1888,7 +2033,7 @@ intel_dp_compute_link_config(struct intel_encoder *encoder, · 32 unmodified lines
18882033 intel_dp->common_rates[limits.max_clock],
18892034 limits.max_bpp, adjusted_mode->crtc_clock);
18902035
1891− if (intel_dp_is_edp(intel_dp)) {
2036+ if (intel_dp_is_edp(intel_dp))
18922037 /*
18932038 * Optimize for fast and narrow. eDP 1.3 section 3.3 and eDP 1.4
18942039 * section A.1: "It is recommended that the minimum number of
@@ -1898,26 +2043,42 @@ intel_dp_compute_link_config(struct intel_encoder *encoder, · 3 unmodified lines
18982043 * Note that we use the max clock and lane count for eDP 1.3 and
18992044 * earlier, and fast vs. wide is irrelevant.
19002045 */
1901− if (!intel_dp_compute_link_config_fast(intel_dp, pipe_config,
1902− &limits))
1903− return false;
1904− } else {
2046+ ret = intel_dp_compute_link_config_fast(intel_dp, pipe_config,
2047+ &limits);
2048+ else
19052049 /* Optimize for slow and wide. */
1906− if (!intel_dp_compute_link_config_wide(intel_dp, pipe_config,
1907− &limits))
2050+ ret = intel_dp_compute_link_config_wide(intel_dp, pipe_config,
2051+ &limits);
2052+
2053+ /* enable compression if the mode doesn't fit available BW */
2054+ if (!ret) {
2055+ if (!intel_dp_dsc_compute_config(intel_dp, pipe_config,
2056+ conn_state, &limits))
19082057 return false;
19092058 }
19102059
1911− DRM_DEBUG_KMS("DP lane count %d clock %d bpp %d\n",
1912− pipe_config->lane_count, pipe_config->port_clock,
1913− pipe_config->pipe_bpp);
2060+ if (pipe_config->dsc_params.compression_enable) {
2061+ DRM_DEBUG_KMS("DP lane count %d clock %d Input bpp %d Compressed bpp %d\n",
2062+ pipe_config->lane_count, pipe_config->port_clock,
2063+ pipe_config->pipe_bpp,
2064+ pipe_config->dsc_params.compressed_bpp);
19142065
1915− DRM_DEBUG_KMS("DP link rate required %i available %i\n",
1916− intel_dp_link_required(adjusted_mode->crtc_clock,
1917− pipe_config->pipe_bpp),
1918− intel_dp_max_data_rate(pipe_config->port_clock,
1919− pipe_config->lane_count));
2066+ DRM_DEBUG_KMS("DP link rate required %i available %i\n",
2067+ intel_dp_link_required(adjusted_mode->crtc_clock,
2068+ pipe_config->dsc_params.compressed_bpp),
2069+ intel_dp_max_data_rate(pipe_config->port_clock,
2070+ pipe_config->lane_count));
2071+ } else {
2072+ DRM_DEBUG_KMS("DP lane count %d clock %d bpp %d\n",
2073+ pipe_config->lane_count, pipe_config->port_clock,
2074+ pipe_config->pipe_bpp);
19202075
2076+ DRM_DEBUG_KMS("DP link rate required %i available %i\n",
2077+ intel_dp_link_required(adjusted_mode->crtc_clock,
2078+ pipe_config->pipe_bpp),
2079+ intel_dp_max_data_rate(pipe_config->port_clock,
2080+ pipe_config->lane_count));
2081+ }
19212082 return true;
19222083 }
19232084
@@ -1983,7 +2144,10 @@ intel_dp_compute_config(struct intel_encoder *encoder, · 59 unmodified lines
19832144 if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK)
19842145 return false;
19852146
1986− if (!intel_dp_compute_link_config(encoder, pipe_config))
2147+ pipe_config->fec_enable = !intel_dp_is_edp(intel_dp) &&
2148+ intel_dp_supports_fec(intel_dp, pipe_config);
2149+
2150+ if (!intel_dp_compute_link_config(encoder, pipe_config, conn_state))
19872151 return false;
19882152
19892153 if (intel_conn_state->broadcast_rgb == INTEL_BROADCAST_RGB_AUTO) {
@@ -2001,11 +2165,20 @@ intel_dp_compute_config(struct intel_encoder *encoder, · 11 unmodified lines
20012165 intel_conn_state->broadcast_rgb == INTEL_BROADCAST_RGB_LIMITED;
20022166 }
20032167
2004− intel_link_compute_m_n(pipe_config->pipe_bpp, pipe_config->lane_count,
2005− adjusted_mode->crtc_clock,
2006− pipe_config->port_clock,
2007− &pipe_config->dp_m_n,
2008− constant_n);
2168+ if (!pipe_config->dsc_params.compression_enable)
2169+ intel_link_compute_m_n(pipe_config->pipe_bpp,
2170+ pipe_config->lane_count,
2171+ adjusted_mode->crtc_clock,
2172+ pipe_config->port_clock,
2173+ &pipe_config->dp_m_n,
2174+ constant_n);
2175+ else
2176+ intel_link_compute_m_n(pipe_config->dsc_params.compressed_bpp,
2177+ pipe_config->lane_count,
2178+ adjusted_mode->crtc_clock,
2179+ pipe_config->port_clock,
2180+ &pipe_config->dp_m_n,
2181+ constant_n);
20092182
20102183 if (intel_connector->panel.downclock_mode != NULL &&
20112184 dev_priv->drrs.type == SEAMLESS_DRRS_SUPPORT) {
@@ -2702,6 +2875,22 @@ static bool downstream_hpd_needs_d0(struct intel_dp *intel_dp) · 690 unmodified lines
27022875 intel_dp->downstream_ports[0] & DP_DS_PORT_HPD;
27032876 }
27042877
2878+void intel_dp_sink_set_decompression_state(struct intel_dp *intel_dp,
2879+ const struct intel_crtc_state *crtc_state,
2880+ bool enable)
2881+{
2882+ int ret;
2883+
2884+ if (!crtc_state->dsc_params.compression_enable)
2885+ return;
2886+
2887+ ret = drm_dp_dpcd_writeb(&intel_dp->aux, DP_DSC_ENABLE,
2888+ enable ? DP_DECOMPRESSION_EN : 0);
2889+ if (ret < 0)
2890+ DRM_DEBUG_KMS("Failed to %s sink decompression state\n",
2891+ enable ? "enable" : "disable");
2892+}
2893+
27052894 /* If the sink supports it, try to set the power state appropriately */
27062895 void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode)
27072896 {
@@ -3837,15 +4026,14 @@ static void intel_dp_get_dsc_sink_cap(struct intel_dp *intel_dp) · 1129 unmodified lines
38374026 DRM_DEBUG_KMS("DSC DPCD: %*ph\n",
38384027 (int)sizeof(intel_dp->dsc_dpcd),
38394028 intel_dp->dsc_dpcd);
4029+
38404030 /* FEC is supported only on DP 1.4 */
3841− if (!intel_dp_is_edp(intel_dp)) {
3842− if (drm_dp_dpcd_readb(&intel_dp->aux, DP_FEC_CAPABILITY,
3843− &intel_dp->fec_capable) < 0)
3844− DRM_ERROR("Failed to read FEC DPCD register\n");
4031+ if (!intel_dp_is_edp(intel_dp) &&
4032+ drm_dp_dpcd_readb(&intel_dp->aux, DP_FEC_CAPABILITY,
4033+ &intel_dp->fec_capable) < 0)
4034+ DRM_ERROR("Failed to read FEC DPCD register\n");
38454035
3846− DRM_DEBUG_KMS("FEC CAPABILITY: %x\n",
3847− intel_dp->fec_capable);
3848− }
4036+ DRM_DEBUG_KMS("FEC CAPABILITY: %x\n", intel_dp->fec_capable);
38494037 }
38504038 }
38514039
@@ -3936,8 +4124,6 @@ intel_edp_init_dpcd(struct intel_dp *intel_dp) · 84 unmodified lines
39364124 static bool
39374125 intel_dp_get_dpcd(struct intel_dp *intel_dp)
39384126 {
3939− u8 sink_count;
3940−
39414127 if (!intel_dp_read_dpcd(intel_dp))
39424128 return false;
39434129
@@ -3947,25 +4133,35 @@ intel_dp_get_dpcd(struct intel_dp *intel_dp) · 3 unmodified lines
39474133 intel_dp_set_common_rates(intel_dp);
39484134 }
39494135
3950− if (drm_dp_dpcd_readb(&intel_dp->aux, DP_SINK_COUNT, &sink_count) <= 0)
3951− return false;
3952−
39534136 /*
3954− * Sink count can change between short pulse hpd hence
3955− * a member variable in intel_dp will track any changes
3956− * between short pulse interrupts.
4137+ * Some eDP panels do not set a valid value for sink count, that is why
4138+ * it don't care about read it here and in intel_edp_init_dpcd().
39574139 */
3958− intel_dp->sink_count = DP_GET_SINK_COUNT(sink_count);
4140+ if (!intel_dp_is_edp(intel_dp)) {
4141+ u8 count;
4142+ ssize_t r;
39594143
3960− /*
3961− * SINK_COUNT == 0 and DOWNSTREAM_PORT_PRESENT == 1 implies that
3962− * a dongle is present but no display. Unless we require to know
3963− * if a dongle is present or not, we don't need to update
3964− * downstream port information. So, an early return here saves
3965− * time from performing other operations which are not required.
3966− */
3967− if (!intel_dp_is_edp(intel_dp) && !intel_dp->sink_count)
3968− return false;
4144+ r = drm_dp_dpcd_readb(&intel_dp->aux, DP_SINK_COUNT, &count);
4145+ if (r < 1)
4146+ return false;
4147+
4148+ /*
4149+ * Sink count can change between short pulse hpd hence
4150+ * a member variable in intel_dp will track any changes
4151+ * between short pulse interrupts.
4152+ */
4153+ intel_dp->sink_count = DP_GET_SINK_COUNT(count);
4154+
4155+ /*
4156+ * SINK_COUNT == 0 and DOWNSTREAM_PORT_PRESENT == 1 implies that
4157+ * a dongle is present but no display. Unless we require to know
4158+ * if a dongle is present or not, we don't need to update
4159+ * downstream port information. So, an early return here saves
4160+ * time from performing other operations which are not required.
4161+ */
4162+ if (!intel_dp->sink_count)
4163+ return false;
4164+ }
39694165
39704166 if (!drm_dp_is_branch(intel_dp->dpcd))
39714167 return true; /* native DP sink */
@@ -4375,6 +4571,17 @@ intel_dp_needs_link_retrain(struct intel_dp *intel_dp) · 403 unmodified lines
43754571 if (!intel_dp->link_trained)
43764572 return false;
43774573
4574+ /*
4575+ * While PSR source HW is enabled, it will control main-link sending
4576+ * frames, enabling and disabling it so trying to do a retrain will fail
4577+ * as the link would or not be on or it could mix training patterns
4578+ * and frame data at the same time causing retrain to fail.
4579+ * Also when exiting PSR, HW will retrain the link anyways fixing
4580+ * any link status error.
4581+ */
4582+ if (intel_psr_enabled(intel_dp))
4583+ return false;
4584+
43784585 if (!intel_dp_get_link_status(intel_dp, link_status))
43794586 return false;
43804587
drivers/gpu/drm/i915/intel_dpll_mgr.c+2−1
@@ -2523,7 +2523,8 @@ static bool icl_calc_dpll_state(struct intel_crtc_state *crtc_state, · 2522 unmodified lines
25232523
25242524 if (intel_port_is_tc(dev_priv, encoder->port))
25252525 ret = icl_calc_tbt_pll(dev_priv, clock, &pll_params);
2526− else if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI))
2526+ else if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI) ||
2527+ intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DSI))
25272528 ret = cnl_ddi_calculate_wrpll(clock, dev_priv, &pll_params);
25282529 else
25292530 ret = icl_calc_dp_combo_pll(dev_priv, clock, &pll_params);
drivers/gpu/drm/i915/intel_drv.h+41−11
@@ -706,6 +706,8 @@ struct intel_crtc_wm_state { · 705 unmodified lines
706706 /* gen9+ only needs 1-step wm programming */
707707 struct skl_pipe_wm optimal;
708708 struct skl_ddb_entry ddb;
709+ struct skl_ddb_entry plane_ddb_y[I915_MAX_PLANES];
710+ struct skl_ddb_entry plane_ddb_uv[I915_MAX_PLANES];
709711 } skl;
710712
711713 struct {
@@ -926,6 +928,9 @@ struct intel_crtc_state { · 214 unmodified lines
926928 u8 active_planes;
927929 u8 nv12_planes;
928930
931+ /* bitmask of planes that will be updated during the commit */
932+ u8 update_planes;
933+
929934 /* HDMI scrambling status */
930935 bool hdmi_scrambling;
931936
@@ -937,6 +942,18 @@ struct intel_crtc_state { · 5 unmodified lines
937942
938943 /* Output down scaling is done in LSPCON device */
939944 bool lspcon_downsampling;
945+
946+ /* Display Stream compression state */
947+ struct {
948+ bool compression_enable;
949+ bool dsc_split;
950+ u16 compressed_bpp;
951+ u8 slice_count;
952+ } dsc_params;
953+ struct drm_dsc_config dp_dsc_cfg;
954+
955+ /* Forward Error correction State */
956+ bool fec_enable;
940957 };
941958
942959 struct intel_crtc {
@@ -1013,7 +1030,7 @@ struct intel_plane { · 70 unmodified lines
10131030 const struct intel_crtc_state *crtc_state,
10141031 const struct intel_plane_state *plane_state);
10151032 void (*disable_plane)(struct intel_plane *plane,
1016− struct intel_crtc *crtc);
1033+ const struct intel_crtc_state *crtc_state);
10171034 bool (*get_hw_state)(struct intel_plane *plane, enum pipe *pipe);
10181035 int (*check_plane)(struct intel_crtc_state *crtc_state,
10191036 struct intel_plane_state *plane_state);
@@ -1517,13 +1534,9 @@ u8 intel_ddi_dp_pre_emphasis_max(struct intel_encoder *encoder, · 497 unmodified lines
15171534 u8 voltage_swing);
15181535 int intel_ddi_toggle_hdcp_signalling(struct intel_encoder *intel_encoder,
15191536 bool enable);
1520−void icl_map_plls_to_ports(struct drm_crtc *crtc,
1521− struct intel_crtc_state *crtc_state,
1522− struct drm_atomic_state *old_state);
1523−void icl_unmap_plls_to_ports(struct drm_crtc *crtc,
1524− struct intel_crtc_state *crtc_state,
1525− struct drm_atomic_state *old_state);
15261537 void icl_sanitize_encoder_pll_mapping(struct intel_encoder *encoder);
1538+int cnl_calc_wrpll_link(struct drm_i915_private *dev_priv,
1539+ enum intel_dpll_id pll_id);
15271540
15281541 unsigned int intel_fb_align_height(const struct drm_framebuffer *fb,
15291542 int color_plane, unsigned int height);
@@ -1788,6 +1801,9 @@ void intel_dp_stop_link_train(struct intel_dp *intel_dp); · 258 unmodified lines
17881801 int intel_dp_retrain_link(struct intel_encoder *encoder,
17891802 struct drm_modeset_acquire_ctx *ctx);
17901803 void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
1804+void intel_dp_sink_set_decompression_state(struct intel_dp *intel_dp,
1805+ const struct intel_crtc_state *crtc_state,
1806+ bool enable);
17911807 void intel_dp_encoder_reset(struct drm_encoder *encoder);
17921808 void intel_dp_encoder_suspend(struct intel_encoder *intel_encoder);
17931809 void intel_dp_encoder_destroy(struct drm_encoder *encoder);
@@ -1843,6 +1859,12 @@ uint16_t intel_dp_dsc_get_output_bpp(int link_clock, uint8_t lane_count, · 49 unmodified lines
18431859 uint8_t intel_dp_dsc_get_slice_count(struct intel_dp *intel_dp, int mode_clock,
18441860 int mode_hdisplay);
18451861
1862+/* intel_vdsc.c */
1863+int intel_dp_compute_dsc_params(struct intel_dp *intel_dp,
1864+ struct intel_crtc_state *pipe_config);
1865+enum intel_display_power_domain
1866+intel_dsc_power_domain(const struct intel_crtc_state *crtc_state);
1867+
18461868 static inline unsigned int intel_dp_unused_lane_mask(int lane_count)
18471869 {
18481870 return ~((1 << lane_count) - 1) & 0xf;
@@ -2047,6 +2069,7 @@ void intel_psr_irq_handler(struct drm_i915_private *dev_priv, u32 psr_iir); · 198 unmodified lines
20472069 void intel_psr_short_pulse(struct intel_dp *intel_dp);
20482070 int intel_psr_wait_for_idle(const struct intel_crtc_state *new_crtc_state,
20492071 u32 *out_value);
2072+bool intel_psr_enabled(struct intel_dp *intel_dp);
20502073
20512074 /* intel_quirks.c */
20522075 void intel_init_quirks(struct drm_i915_private *dev_priv);
@@ -2181,6 +2204,9 @@ void g4x_wm_get_hw_state(struct drm_device *dev); · 128 unmodified lines
21812204 void vlv_wm_get_hw_state(struct drm_device *dev);
21822205 void ilk_wm_get_hw_state(struct drm_device *dev);
21832206 void skl_wm_get_hw_state(struct drm_device *dev);
2207+void skl_pipe_ddb_get_hw_state(struct intel_crtc *crtc,
2208+ struct skl_ddb_entry *ddb_y,
2209+ struct skl_ddb_entry *ddb_uv);
21842210 void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
21852211 struct skl_ddb_allocation *ddb /* out */);
21862212 void skl_pipe_wm_get_hw_state(struct drm_crtc *crtc,
@@ -2195,6 +2221,10 @@ bool skl_wm_level_equals(const struct skl_wm_level *l1, · 8 unmodified lines
21952221 bool skl_ddb_allocation_overlaps(const struct skl_ddb_entry *ddb,
21962222 const struct skl_ddb_entry entries[],
21972223 int num_entries, int ignore_idx);
2224+void skl_write_plane_wm(struct intel_plane *plane,
2225+ const struct intel_crtc_state *crtc_state);
2226+void skl_write_cursor_wm(struct intel_plane *plane,
2227+ const struct intel_crtc_state *crtc_state);
21982228 bool ilk_disable_lp_wm(struct drm_device *dev);
21992229 int skl_check_pipe_max_pixel_rate(struct intel_crtc *intel_crtc,
22002230 struct intel_crtc_state *cstate);
@@ -2287,10 +2317,10 @@ struct drm_plane_state *intel_plane_duplicate_state(struct drm_plane *plane); · 86 unmodified lines
22872317 void intel_plane_destroy_state(struct drm_plane *plane,
22882318 struct drm_plane_state *state);
22892319 extern const struct drm_plane_helper_funcs intel_plane_helper_funcs;
2290−void intel_update_planes_on_crtc(struct intel_atomic_state *old_state,
2291− struct intel_crtc *crtc,
2292− struct intel_crtc_state *old_crtc_state,
2293− struct intel_crtc_state *new_crtc_state);
2320+void skl_update_planes_on_crtc(struct intel_atomic_state *state,
2321+ struct intel_crtc *crtc);
2322+void i9xx_update_planes_on_crtc(struct intel_atomic_state *state,
2323+ struct intel_crtc *crtc);
22942324 int intel_plane_atomic_check_with_state(const struct intel_crtc_state *old_crtc_state,
22952325 struct intel_crtc_state *crtc_state,
22962326 const struct intel_plane_state *old_plane_state,
drivers/gpu/drm/i915/intel_dsi.h+5−0
@@ -146,6 +146,11 @@ static inline bool is_cmd_mode(struct intel_dsi *intel_dsi) · 145 unmodified lines
146146 return intel_dsi->operation_mode == INTEL_DSI_COMMAND_MODE;
147147 }
148148
149+static inline u16 intel_dsi_encoder_ports(struct intel_encoder *encoder)
150+{
151+ return enc_to_intel_dsi(&encoder->base)->ports;
152+}
153+
149154 /* intel_dsi.c */
150155 int intel_dsi_bitrate(const struct intel_dsi *intel_dsi);
151156 int intel_dsi_tlpx_ns(const struct intel_dsi *intel_dsi);
drivers/gpu/drm/i915/intel_dsi_vbt.c+21−1
@@ -103,6 +103,18 @@ static struct gpio_map vlv_gpio_table[] = { · 102 unmodified lines
103103 #define CHV_GPIO_PAD_CFG1(f, i) (0x4400 + (f) * 0x400 + (i) * 8 + 4)
104104 #define CHV_GPIO_CFGLOCK (1 << 31)
105105
106+/* ICL DSI Display GPIO Pins */
107+#define ICL_GPIO_DDSP_HPD_A 0
108+#define ICL_GPIO_L_VDDEN_1 1
109+#define ICL_GPIO_L_BKLTEN_1 2
110+#define ICL_GPIO_DDPA_CTRLCLK_1 3
111+#define ICL_GPIO_DDPA_CTRLDATA_1 4
112+#define ICL_GPIO_DDSP_HPD_B 5
113+#define ICL_GPIO_L_VDDEN_2 6
114+#define ICL_GPIO_L_BKLTEN_2 7
115+#define ICL_GPIO_DDPA_CTRLCLK_2 8
116+#define ICL_GPIO_DDPA_CTRLDATA_2 9
117+
106118 static inline enum port intel_dsi_seq_port_to_port(u8 port)
107119 {
108120 return port ? PORT_C : PORT_A;
@@ -324,6 +336,12 @@ static void bxt_exec_gpio(struct drm_i915_private *dev_priv, · 215 unmodified lines
324336 gpiod_set_value(gpio_desc, value);
325337 }
326338
339+static void icl_exec_gpio(struct drm_i915_private *dev_priv,
340+ u8 gpio_source, u8 gpio_index, bool value)
341+{
342+ DRM_DEBUG_KMS("Skipping ICL GPIO element execution\n");
343+}
344+
327345 static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)
328346 {
329347 struct drm_device *dev = intel_dsi->base.base.dev;
@@ -347,7 +365,9 @@ static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data) · 17 unmodified lines
347365 /* pull up/down */
348366 value = *data++ & 1;
349367
350− if (IS_VALLEYVIEW(dev_priv))
368+ if (IS_ICELAKE(dev_priv))
369+ icl_exec_gpio(dev_priv, gpio_source, gpio_index, value);
370+ else if (IS_VALLEYVIEW(dev_priv))
351371 vlv_exec_gpio(dev_priv, gpio_source, gpio_number, value);
352372 else if (IS_CHERRYVIEW(dev_priv))
353373 chv_exec_gpio(dev_priv, gpio_source, gpio_number, value);
drivers/gpu/drm/i915/intel_engine_cs.c+4−42
@@ -493,46 +493,6 @@ void intel_engine_setup_common(struct intel_engine_cs *engine) · 492 unmodified lines
493493 intel_engine_init_cmd_parser(engine);
494494 }
495495
496−int intel_engine_create_scratch(struct intel_engine_cs *engine,
497− unsigned int size)
498−{
499− struct drm_i915_gem_object *obj;
500− struct i915_vma *vma;
501− int ret;
502−
503− WARN_ON(engine->scratch);
504−
505− obj = i915_gem_object_create_stolen(engine->i915, size);
506− if (!obj)
507− obj = i915_gem_object_create_internal(engine->i915, size);
508− if (IS_ERR(obj)) {
509− DRM_ERROR("Failed to allocate scratch page\n");
510− return PTR_ERR(obj);
511− }
512−
513− vma = i915_vma_instance(obj, &engine->i915->ggtt.vm, NULL);
514− if (IS_ERR(vma)) {
515− ret = PTR_ERR(vma);
516− goto err_unref;
517− }
518−
519− ret = i915_vma_pin(vma, 0, 0, PIN_GLOBAL | PIN_HIGH);
520− if (ret)
521− goto err_unref;
522−
523− engine->scratch = vma;
524− return 0;
525−
526−err_unref:
527− i915_gem_object_put(obj);
528− return ret;
529−}
530−
531−void intel_engine_cleanup_scratch(struct intel_engine_cs *engine)
532−{
533− i915_vma_unpin_and_release(&engine->scratch, 0);
534−}
535−
536496 static void cleanup_status_page(struct intel_engine_cs *engine)
537497 {
538498 if (HWS_NEEDS_PHYSICAL(engine->i915)) {
@@ -707,8 +667,6 @@ void intel_engine_cleanup_common(struct intel_engine_cs *engine) · 168 unmodified lines
707667 {
708668 struct drm_i915_private *i915 = engine->i915;
709669
710− intel_engine_cleanup_scratch(engine);
711−
712670 cleanup_status_page(engine);
713671
714672 intel_engine_fini_breadcrumbs(engine);
@@ -723,6 +681,10 @@ void intel_engine_cleanup_common(struct intel_engine_cs *engine) · 8 unmodified lines
723681 __intel_context_unpin(i915->kernel_context, engine);
724682
725683 i915_timeline_fini(&engine->timeline);
684+
685+ intel_wa_list_free(&engine->ctx_wa_list);
686+ intel_wa_list_free(&engine->wa_list);
687+ intel_wa_list_free(&engine->whitelist);
726688 }
727689
728690 u64 intel_engine_get_active_head(const struct intel_engine_cs *engine)
drivers/gpu/drm/i915/intel_fbc.c+1−1
@@ -1309,7 +1309,7 @@ void intel_fbc_init(struct drm_i915_private *dev_priv) · 1308 unmodified lines
13091309 fbc->active = false;
13101310
13111311 if (need_fbc_vtd_wa(dev_priv))
1312− mkwrite_device_info(dev_priv)->has_fbc = false;
1312+ mkwrite_device_info(dev_priv)->display.has_fbc = false;
13131313
13141314 i915_modparams.enable_fbc = intel_sanitize_fbc_option(dev_priv);
13151315 DRM_DEBUG_KMS("Sanitized enable_fbc value: %d\n",
drivers/gpu/drm/i915/intel_fbdev.c+1−1
@@ -672,7 +672,7 @@ int intel_fbdev_init(struct drm_device *dev) · 671 unmodified lines
672672 struct intel_fbdev *ifbdev;
673673 int ret;
674674
675− if (WARN_ON(INTEL_INFO(dev_priv)->num_pipes == 0))
675+ if (WARN_ON(!HAS_DISPLAY(dev_priv)))
676676 return -ENODEV;
677677
678678 ifbdev = kzalloc(sizeof(struct intel_fbdev), GFP_KERNEL);
drivers/gpu/drm/i915/intel_hdmi.c+19−2
@@ -115,6 +115,8 @@ static u32 hsw_infoframe_enable(unsigned int type) · 114 unmodified lines
115115 switch (type) {
116116 case DP_SDP_VSC:
117117 return VIDEO_DIP_ENABLE_VSC_HSW;
118+ case DP_SDP_PPS:
119+ return VDIP_ENABLE_PPS;
118120 case HDMI_INFOFRAME_TYPE_AVI:
119121 return VIDEO_DIP_ENABLE_AVI_HSW;
120122 case HDMI_INFOFRAME_TYPE_SPD:
@@ -136,6 +138,8 @@ hsw_dip_data_reg(struct drm_i915_private *dev_priv, · 15 unmodified lines
136138 switch (type) {
137139 case DP_SDP_VSC:
138140 return HSW_TVIDEO_DIP_VSC_DATA(cpu_transcoder, i);
141+ case DP_SDP_PPS:
142+ return ICL_VIDEO_DIP_PPS_DATA(cpu_transcoder, i);
139143 case HDMI_INFOFRAME_TYPE_AVI:
140144 return HSW_TVIDEO_DIP_AVI_DATA(cpu_transcoder, i);
141145 case HDMI_INFOFRAME_TYPE_SPD:
@@ -148,6 +152,18 @@ hsw_dip_data_reg(struct drm_i915_private *dev_priv, · 6 unmodified lines
148152 }
149153 }
150154
155+static int hsw_dip_data_size(unsigned int type)
156+{
157+ switch (type) {
158+ case DP_SDP_VSC:
159+ return VIDEO_DIP_VSC_DATA_SIZE;
160+ case DP_SDP_PPS:
161+ return VIDEO_DIP_PPS_DATA_SIZE;
162+ default:
163+ return VIDEO_DIP_DATA_SIZE;
164+ }
165+}
166+
151167 static void g4x_write_infoframe(struct intel_encoder *encoder,
152168 const struct intel_crtc_state *crtc_state,
153169 unsigned int type,
@@ -382,11 +398,12 @@ static void hsw_write_infoframe(struct intel_encoder *encoder, · 228 unmodified lines
382398 struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
383399 enum transcoder cpu_transcoder = crtc_state->cpu_transcoder;
384400 i915_reg_t ctl_reg = HSW_TVIDEO_DIP_CTL(cpu_transcoder);
385− int data_size = type == DP_SDP_VSC ?
386− VIDEO_DIP_VSC_DATA_SIZE : VIDEO_DIP_DATA_SIZE;
401+ int data_size;
387402 int i;
388403 u32 val = I915_READ(ctl_reg);
389404
405+ data_size = hsw_dip_data_size(type);
406+
390407 val &= ~hsw_infoframe_enable(type);
391408 I915_WRITE(ctl_reg, val);
392409
drivers/gpu/drm/i915/intel_i2c.c+1−1
@@ -817,7 +817,7 @@ int intel_setup_gmbus(struct drm_i915_private *dev_priv) · 816 unmodified lines
817817 unsigned int pin;
818818 int ret;
819819
820− if (INTEL_INFO(dev_priv)->num_pipes == 0)
820+ if (!HAS_DISPLAY(dev_priv))
821821 return 0;
822822
823823 if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
drivers/gpu/drm/i915/intel_lrc.c+30−53
@@ -767,6 +767,8 @@ execlists_cancel_port_requests(struct intel_engine_execlists * const execlists) · 766 unmodified lines
767767
768768 static void reset_csb_pointers(struct intel_engine_execlists *execlists)
769769 {
770+ const unsigned int reset_value = GEN8_CSB_ENTRIES - 1;
771+
770772 /*
771773 * After a reset, the HW starts writing into CSB entry [0]. We
772774 * therefore have to set our HEAD pointer back one entry so that
@@ -776,8 +778,8 @@ static void reset_csb_pointers(struct intel_engine_execlists *execlists) · 3 unmodified lines
776778 * inline comparison of our cached head position against the last HW
777779 * write works even before the first interrupt.
778780 */
779− execlists->csb_head = execlists->csb_write_reset;
780− WRITE_ONCE(*execlists->csb_write, execlists->csb_write_reset);
781+ execlists->csb_head = reset_value;
782+ WRITE_ONCE(*execlists->csb_write, reset_value);
781783 }
782784
783785 static void nop_submission_tasklet(unsigned long data)
@@ -818,8 +820,11 @@ static void execlists_cancel_requests(struct intel_engine_cs *engine) · 34 unmodified lines
818820 /* Mark all executing requests as skipped. */
819821 list_for_each_entry(rq, &engine->timeline.requests, link) {
820822 GEM_BUG_ON(!rq->global_seqno);
821− if (!i915_request_completed(rq))
822− dma_fence_set_error(&rq->fence, -EIO);
823+
824+ if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &rq->fence.flags))
825+ continue;
826+
827+ dma_fence_set_error(&rq->fence, -EIO);
823828 }
824829
825830 /* Flush the queued requests to the timeline list (for retiring). */
@@ -839,6 +844,10 @@ static void execlists_cancel_requests(struct intel_engine_cs *engine) · 13 unmodified lines
839844 kmem_cache_free(engine->i915->priorities, p);
840845 }
841846
847+ intel_write_status_page(engine,
848+ I915_GEM_HWS_INDEX,
849+ intel_engine_last_submit(engine));
850+
842851 /* Remaining _unready_ requests will be nop'ed when submitted */
843852
844853 execlists->queue_priority = INT_MIN;
@@ -1279,9 +1288,10 @@ static int execlists_request_alloc(struct i915_request *request) · 434 unmodified lines
12791288 static u32 *
12801289 gen8_emit_flush_coherentl3_wa(struct intel_engine_cs *engine, u32 *batch)
12811290 {
1291+ /* NB no one else is allowed to scribble over scratch + 256! */
12821292 *batch++ = MI_STORE_REGISTER_MEM_GEN8 | MI_SRM_LRM_GLOBAL_GTT;
12831293 *batch++ = i915_mmio_reg_offset(GEN8_L3SQCREG4);
1284− *batch++ = i915_ggtt_offset(engine->scratch) + 256;
1294+ *batch++ = i915_scratch_offset(engine->i915) + 256;
12851295 *batch++ = 0;
12861296
12871297 *batch++ = MI_LOAD_REGISTER_IMM(1);
@@ -1295,7 +1305,7 @@ gen8_emit_flush_coherentl3_wa(struct intel_engine_cs *engine, u32 *batch) · 7 unmodified lines
12951305
12961306 *batch++ = MI_LOAD_REGISTER_MEM_GEN8 | MI_SRM_LRM_GLOBAL_GTT;
12971307 *batch++ = i915_mmio_reg_offset(GEN8_L3SQCREG4);
1298− *batch++ = i915_ggtt_offset(engine->scratch) + 256;
1308+ *batch++ = i915_scratch_offset(engine->i915) + 256;
12991309 *batch++ = 0;
13001310
13011311 return batch;
@@ -1332,7 +1342,7 @@ static u32 *gen8_init_indirectctx_bb(struct intel_engine_cs *engine, u32 *batch) · 30 unmodified lines
13321342 PIPE_CONTROL_GLOBAL_GTT_IVB |
13331343 PIPE_CONTROL_CS_STALL |
13341344 PIPE_CONTROL_QW_WRITE,
1335− i915_ggtt_offset(engine->scratch) +
1345+ i915_scratch_offset(engine->i915) +
13361346 2 * CACHELINE_BYTES);
13371347
13381348 *batch++ = MI_ARB_ON_OFF | MI_ARB_ENABLE;
@@ -1401,18 +1411,6 @@ static u32 *gen9_init_indirectctx_bb(struct intel_engine_cs *engine, u32 *batch) · 62 unmodified lines
14011411
14021412 batch = emit_lri(batch, lri, ARRAY_SIZE(lri));
14031413
1404− /* WaClearSlmSpaceAtContextSwitch:kbl */
1405− /* Actual scratch location is at 128 bytes offset */
1406− if (IS_KBL_REVID(engine->i915, 0, KBL_REVID_A0)) {
1407− batch = gen8_emit_pipe_control(batch,
1408− PIPE_CONTROL_FLUSH_L3 |
1409− PIPE_CONTROL_GLOBAL_GTT_IVB |
1410− PIPE_CONTROL_CS_STALL |
1411− PIPE_CONTROL_QW_WRITE,
1412− i915_ggtt_offset(engine->scratch)
1413− + 2 * CACHELINE_BYTES);
1414− }
1415−
14161414 /* WaMediaPoolStateCmdInWABB:bxt,glk */
14171415 if (HAS_POOLED_EU(engine->i915)) {
14181416 /*
@@ -1629,6 +1627,8 @@ static bool unexpected_starting_state(struct intel_engine_cs *engine) · 210 unmodified lines
16291627
16301628 static int gen8_init_common_ring(struct intel_engine_cs *engine)
16311629 {
1630+ intel_engine_apply_workarounds(engine);
1631+
16321632 intel_mocs_init_engine(engine);
16331633
16341634 intel_engine_reset_breadcrumbs(engine);
@@ -1653,7 +1653,7 @@ static int gen8_init_render_ring(struct intel_engine_cs *engine) · 18 unmodified lines
16531653 if (ret)
16541654 return ret;
16551655
1656− intel_whitelist_workarounds_apply(engine);
1656+ intel_engine_apply_whitelist(engine);
16571657
16581658 /* We need to disable the AsyncFlip performance optimisations in order
16591659 * to use MI_WAIT_FOR_EVENT within the CS. It should already be
@@ -1676,7 +1676,7 @@ static int gen9_init_render_ring(struct intel_engine_cs *engine) · 16 unmodified lines
16761676 if (ret)
16771677 return ret;
16781678
1679− intel_whitelist_workarounds_apply(engine);
1679+ intel_engine_apply_whitelist(engine);
16801680
16811681 return 0;
16821682 }
@@ -1974,7 +1974,7 @@ static int gen8_emit_flush_render(struct i915_request *request, · 291 unmodified lines
19741974 {
19751975 struct intel_engine_cs *engine = request->engine;
19761976 u32 scratch_addr =
1977− i915_ggtt_offset(engine->scratch) + 2 * CACHELINE_BYTES;
1977+ i915_scratch_offset(engine->i915) + 2 * CACHELINE_BYTES;
19781978 bool vf_flush_wa = false, dc_flush_wa = false;
19791979 u32 *cs, flags = 0;
19801980 int len;
@@ -2088,7 +2088,7 @@ static int gen8_init_rcs_context(struct i915_request *rq) · 107 unmodified lines
20882088 {
20892089 int ret;
20902090
2091− ret = intel_ctx_workarounds_emit(rq);
2091+ ret = intel_engine_emit_ctx_wa(rq);
20922092 if (ret)
20932093 return ret;
20942094
@@ -2229,12 +2229,6 @@ logical_ring_setup(struct intel_engine_cs *engine) · 134 unmodified lines
22292229 logical_ring_default_irqs(engine);
22302230 }
22312231
2232−static bool csb_force_mmio(struct drm_i915_private *i915)
2233−{
2234− /* Older GVT emulation depends upon intercepting CSB mmio */
2235− return intel_vgpu_active(i915) && !intel_vgpu_has_hwsp_emulation(i915);
2236−}
2237−
22382232 static int logical_ring_init(struct intel_engine_cs *engine)
22392233 {
22402234 struct drm_i915_private *i915 = engine->i915;
@@ -2264,24 +2258,12 @@ static int logical_ring_init(struct intel_engine_cs *engine) · 23 unmodified lines
22642258 upper_32_bits(ce->lrc_desc);
22652259 }
22662260
2267− execlists->csb_read =
2268− i915->regs + i915_mmio_reg_offset(RING_CONTEXT_STATUS_PTR(engine));
2269− if (csb_force_mmio(i915)) {
2270− execlists->csb_status = (u32 __force *)
2271− (i915->regs + i915_mmio_reg_offset(RING_CONTEXT_STATUS_BUF_LO(engine, 0)));
2261+ execlists->csb_status =
2262+ &engine->status_page.page_addr[I915_HWS_CSB_BUF0_INDEX];
22722263
2273− execlists->csb_write = (u32 __force *)execlists->csb_read;
2274− execlists->csb_write_reset =
2275− _MASKED_FIELD(GEN8_CSB_WRITE_PTR_MASK,
2276− GEN8_CSB_ENTRIES - 1);
2277− } else {
2278− execlists->csb_status =
2279− &engine->status_page.page_addr[I915_HWS_CSB_BUF0_INDEX];
2264+ execlists->csb_write =
2265+ &engine->status_page.page_addr[intel_hws_csb_write_index(i915)];
22802266
2281− execlists->csb_write =
2282− &engine->status_page.page_addr[intel_hws_csb_write_index(i915)];
2283− execlists->csb_write_reset = GEN8_CSB_ENTRIES - 1;
2284− }
22852267 reset_csb_pointers(execlists);
22862268
22872269 return 0;
@@ -2311,10 +2293,6 @@ int logical_render_ring_init(struct intel_engine_cs *engine) · 23 unmodified lines
23112293 if (ret)
23122294 return ret;
23132295
2314− ret = intel_engine_create_scratch(engine, PAGE_SIZE);
2315− if (ret)
2316− goto err_cleanup_common;
2317−
23182296 ret = intel_init_workaround_bb(engine);
23192297 if (ret) {
23202298 /*
@@ -2326,11 +2304,10 @@ int logical_render_ring_init(struct intel_engine_cs *engine) · 5 unmodified lines
23262304 ret);
23272305 }
23282306
2329− return 0;
2307+ intel_engine_init_whitelist(engine);
2308+ intel_engine_init_workarounds(engine);
23302309
2331−err_cleanup_common:
2332− intel_engine_cleanup_common(engine);
2333− return ret;
2310+ return 0;
23342311 }
23352312
23362313 int logical_xcs_ring_init(struct intel_engine_cs *engine)
drivers/gpu/drm/i915/intel_opregion.h+3−3
@@ -87,12 +87,12 @@ static inline void intel_opregion_unregister(struct drm_i915_private *dev_priv) · 86 unmodified lines
8787 {
8888 }
8989
90−void intel_opregion_resume(struct drm_i915_private *dev_priv)
90+static inline void intel_opregion_resume(struct drm_i915_private *dev_priv)
9191 {
9292 }
9393
94−void intel_opregion_suspend(struct drm_i915_private *dev_priv,
95− pci_power_t state)
94+static inline void intel_opregion_suspend(struct drm_i915_private *dev_priv,
95+ pci_power_t state)
9696 {
9797 }
9898
drivers/gpu/drm/i915/intel_pm.c+310−279
@@ -3951,68 +3951,68 @@ static void · 3950 unmodified lines
39513951 skl_ddb_get_hw_plane_state(struct drm_i915_private *dev_priv,
39523952 const enum pipe pipe,
39533953 const enum plane_id plane_id,
3954− struct skl_ddb_allocation *ddb /* out */)
3954+ struct skl_ddb_entry *ddb_y,
3955+ struct skl_ddb_entry *ddb_uv)
39553956 {
3956− u32 val, val2 = 0;
3957− int fourcc, pixel_format;
3957+ u32 val, val2;
3958+ u32 fourcc = 0;
39583959
39593960 /* Cursor doesn't support NV12/planar, so no extra calculation needed */
39603961 if (plane_id == PLANE_CURSOR) {
39613962 val = I915_READ(CUR_BUF_CFG(pipe));
3962− skl_ddb_entry_init_from_hw(dev_priv,
3963− &ddb->plane[pipe][plane_id], val);
3963+ skl_ddb_entry_init_from_hw(dev_priv, ddb_y, val);
39643964 return;
39653965 }
39663966
39673967 val = I915_READ(PLANE_CTL(pipe, plane_id));
39683968
39693969 /* No DDB allocated for disabled planes */
3970− if (!(val & PLANE_CTL_ENABLE))
3971− return;
3972−
3973− pixel_format = val & PLANE_CTL_FORMAT_MASK;
3974− fourcc = skl_format_to_fourcc(pixel_format,
3975− val & PLANE_CTL_ORDER_RGBX,
3976− val & PLANE_CTL_ALPHA_MASK);
3970+ if (val & PLANE_CTL_ENABLE)
3971+ fourcc = skl_format_to_fourcc(val & PLANE_CTL_FORMAT_MASK,
3972+ val & PLANE_CTL_ORDER_RGBX,
3973+ val & PLANE_CTL_ALPHA_MASK);
39773974
3978− val = I915_READ(PLANE_BUF_CFG(pipe, plane_id));
3979− if (fourcc == DRM_FORMAT_NV12 && INTEL_GEN(dev_priv) < 11) {
3975+ if (INTEL_GEN(dev_priv) >= 11) {
3976+ val = I915_READ(PLANE_BUF_CFG(pipe, plane_id));
3977+ skl_ddb_entry_init_from_hw(dev_priv, ddb_y, val);
3978+ } else {
3979+ val = I915_READ(PLANE_BUF_CFG(pipe, plane_id));
39803980 val2 = I915_READ(PLANE_NV12_BUF_CFG(pipe, plane_id));
39813981
3982− skl_ddb_entry_init_from_hw(dev_priv,
3983− &ddb->plane[pipe][plane_id], val2);
3984− skl_ddb_entry_init_from_hw(dev_priv,
3985− &ddb->uv_plane[pipe][plane_id], val);
3986− } else {
3987− skl_ddb_entry_init_from_hw(dev_priv,
3988− &ddb->plane[pipe][plane_id], val);
3982+ if (fourcc == DRM_FORMAT_NV12)
3983+ swap(val, val2);
3984+
3985+ skl_ddb_entry_init_from_hw(dev_priv, ddb_y, val);
3986+ skl_ddb_entry_init_from_hw(dev_priv, ddb_uv, val2);
39893987 }
39903988 }
39913989
3992−void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
3993− struct skl_ddb_allocation *ddb /* out */)
3990+void skl_pipe_ddb_get_hw_state(struct intel_crtc *crtc,
3991+ struct skl_ddb_entry *ddb_y,
3992+ struct skl_ddb_entry *ddb_uv)
39943993 {
3995− struct intel_crtc *crtc;
3996−
3997− memset(ddb, 0, sizeof(*ddb));
3998−
3999− ddb->enabled_slices = intel_enabled_dbuf_slices_num(dev_priv);
3994+ struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
3995+ enum intel_display_power_domain power_domain;
3996+ enum pipe pipe = crtc->pipe;
3997+ enum plane_id plane_id;
40003998
4001− for_each_intel_crtc(&dev_priv->drm, crtc) {
4002− enum intel_display_power_domain power_domain;
4003− enum plane_id plane_id;
4004− enum pipe pipe = crtc->pipe;
3999+ power_domain = POWER_DOMAIN_PIPE(pipe);
4000+ if (!intel_display_power_get_if_enabled(dev_priv, power_domain))
4001+ return;
40054002
4006− power_domain = POWER_DOMAIN_PIPE(pipe);
4007− if (!intel_display_power_get_if_enabled(dev_priv, power_domain))
4008− continue;
4003+ for_each_plane_id_on_crtc(crtc, plane_id)
4004+ skl_ddb_get_hw_plane_state(dev_priv, pipe,
4005+ plane_id,
4006+ &ddb_y[plane_id],
4007+ &ddb_uv[plane_id]);
40094008
4010− for_each_plane_id_on_crtc(crtc, plane_id)
4011− skl_ddb_get_hw_plane_state(dev_priv, pipe,
4012− plane_id, ddb);
4009+ intel_display_power_put(dev_priv, power_domain);
4010+}
40134011
4014− intel_display_power_put(dev_priv, power_domain);
4015− }
4012+void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
4013+ struct skl_ddb_allocation *ddb /* out */)
4014+{
4015+ ddb->enabled_slices = intel_enabled_dbuf_slices_num(dev_priv);
40164016 }
40174017
40184018 /*
@@ -4410,7 +4410,6 @@ skl_allocate_pipe_ddb(struct intel_crtc_state *cstate, · 391 unmodified lines
44104410 struct drm_crtc *crtc = cstate->base.crtc;
44114411 struct drm_i915_private *dev_priv = to_i915(crtc->dev);
44124412 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
4413− enum pipe pipe = intel_crtc->pipe;
44144413 struct skl_ddb_entry *alloc = &cstate->wm.skl.ddb;
44154414 uint16_t alloc_size, start;
44164415 uint16_t minimum[I915_MAX_PLANES] = {};
@@ -4423,8 +4422,8 @@ skl_allocate_pipe_ddb(struct intel_crtc_state *cstate, · 6 unmodified lines
44234422 uint16_t total_min_blocks = 0;
44244423
44254424 /* Clear the partitioning for disabled planes. */
4426− memset(ddb->plane[pipe], 0, sizeof(ddb->plane[pipe]));
4427− memset(ddb->uv_plane[pipe], 0, sizeof(ddb->uv_plane[pipe]));
4425+ memset(cstate->wm.skl.plane_ddb_y, 0, sizeof(cstate->wm.skl.plane_ddb_y));
4426+ memset(cstate->wm.skl.plane_ddb_uv, 0, sizeof(cstate->wm.skl.plane_ddb_uv));
44284427
44294428 if (WARN_ON(!state))
44304429 return 0;
@@ -4471,8 +4470,8 @@ skl_allocate_pipe_ddb(struct intel_crtc_state *cstate, · 40 unmodified lines
44714470 }
44724471
44734472 alloc_size -= total_min_blocks;
4474− ddb->plane[pipe][PLANE_CURSOR].start = alloc->end - minimum[PLANE_CURSOR];
4475− ddb->plane[pipe][PLANE_CURSOR].end = alloc->end;
4473+ cstate->wm.skl.plane_ddb_y[PLANE_CURSOR].start = alloc->end - minimum[PLANE_CURSOR];
4474+ cstate->wm.skl.plane_ddb_y[PLANE_CURSOR].end = alloc->end;
44764475
44774476 /*
44784477 * 2. Distribute the remaining space in proportion to the amount of
@@ -4503,8 +4502,8 @@ skl_allocate_pipe_ddb(struct intel_crtc_state *cstate, · 24 unmodified lines
45034502
45044503 /* Leave disabled planes at (0,0) */
45054504 if (data_rate) {
4506− ddb->plane[pipe][plane_id].start = start;
4507− ddb->plane[pipe][plane_id].end = start + plane_blocks;
4505+ cstate->wm.skl.plane_ddb_y[plane_id].start = start;
4506+ cstate->wm.skl.plane_ddb_y[plane_id].end = start + plane_blocks;
45084507 }
45094508
45104509 start += plane_blocks;
@@ -4519,8 +4518,8 @@ skl_allocate_pipe_ddb(struct intel_crtc_state *cstate, · 8 unmodified lines
45194518 WARN_ON(INTEL_GEN(dev_priv) >= 11 && uv_plane_blocks);
45204519
45214520 if (uv_data_rate) {
4522− ddb->uv_plane[pipe][plane_id].start = start;
4523− ddb->uv_plane[pipe][plane_id].end =
4521+ cstate->wm.skl.plane_ddb_uv[plane_id].start = start;
4522+ cstate->wm.skl.plane_ddb_uv[plane_id].end =
45244523 start + uv_plane_blocks;
45254524 }
45264525
@@ -4617,12 +4616,12 @@ skl_adjusted_plane_pixel_rate(const struct intel_crtc_state *cstate, · 90 unmodified lines
46174616 }
46184617
46194618 static int
4620−skl_compute_plane_wm_params(const struct drm_i915_private *dev_priv,
4621− const struct intel_crtc_state *cstate,
4619+skl_compute_plane_wm_params(const struct intel_crtc_state *cstate,
46224620 const struct intel_plane_state *intel_pstate,
4623− struct skl_wm_params *wp, int plane_id)
4621+ struct skl_wm_params *wp, int color_plane)
46244622 {
46254623 struct intel_plane *plane = to_intel_plane(intel_pstate->base.plane);
4624+ struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
46264625 const struct drm_plane_state *pstate = &intel_pstate->base;
46274626 const struct drm_framebuffer *fb = pstate->fb;
46284627 uint32_t interm_pbpl;
@@ -4630,11 +4629,8 @@ skl_compute_plane_wm_params(const struct drm_i915_private *dev_priv, · 1 unmodified line
46304629 to_intel_atomic_state(cstate->base.state);
46314630 bool apply_memory_bw_wa = skl_needs_memory_bw_wa(state);
46324631
4633− if (!intel_wm_plane_visible(cstate, intel_pstate))
4634− return 0;
4635−
46364632 /* only NV12 format has two planes */
4637− if (plane_id == 1 && fb->format->format != DRM_FORMAT_NV12) {
4633+ if (color_plane == 1 && fb->format->format != DRM_FORMAT_NV12) {
46384634 DRM_DEBUG_KMS("Non NV12 format have single plane\n");
46394635 return -EINVAL;
46404636 }
@@ -4659,10 +4655,10 @@ skl_compute_plane_wm_params(const struct drm_i915_private *dev_priv, · 18 unmodified lines
46594655 wp->width = drm_rect_width(&intel_pstate->base.src) >> 16;
46604656 }
46614657
4662− if (plane_id == 1 && wp->is_planar)
4658+ if (color_plane == 1 && wp->is_planar)
46634659 wp->width /= 2;
46644660
4665− wp->cpp = fb->format->cpp[plane_id];
4661+ wp->cpp = fb->format->cpp[color_plane];
46664662 wp->plane_pixel_rate = skl_adjusted_plane_pixel_rate(cstate,
46674663 intel_pstate);
46684664
@@ -4724,8 +4720,7 @@ skl_compute_plane_wm_params(const struct drm_i915_private *dev_priv, · 55 unmodified lines
47244720 return 0;
47254721 }
47264722
4727−static int skl_compute_plane_wm(const struct drm_i915_private *dev_priv,
4728− const struct intel_crtc_state *cstate,
4723+static int skl_compute_plane_wm(const struct intel_crtc_state *cstate,
47294724 const struct intel_plane_state *intel_pstate,
47304725 uint16_t ddb_allocation,
47314726 int level,
@@ -4733,6 +4728,8 @@ static int skl_compute_plane_wm(const struct drm_i915_private *dev_priv, · 1 unmodified line
47334728 const struct skl_wm_level *result_prev,
47344729 struct skl_wm_level *result /* out */)
47354730 {
4731+ struct drm_i915_private *dev_priv =
4732+ to_i915(intel_pstate->base.plane->dev);
47364733 const struct drm_plane_state *pstate = &intel_pstate->base;
47374734 uint32_t latency = dev_priv->wm.skl_latency[level];
47384735 uint_fixed_16_16_t method1, method2;
@@ -4743,11 +4740,8 @@ static int skl_compute_plane_wm(const struct drm_i915_private *dev_priv, · 4 unmodified lines
47434740 bool apply_memory_bw_wa = skl_needs_memory_bw_wa(state);
47444741 uint32_t min_disp_buf_needed;
47454742
4746− if (latency == 0 ||
4747− !intel_wm_plane_visible(cstate, intel_pstate)) {
4748− result->plane_en = false;
4749− return 0;
4750− }
4743+ if (latency == 0)
4744+ return level == 0 ? -EINVAL : 0;
47514745
47524746 /* Display WA #1141: kbl,cfl */
47534747 if ((IS_KABYLAKE(dev_priv) || IS_COFFEELAKE(dev_priv) ||
@@ -4844,8 +4838,6 @@ static int skl_compute_plane_wm(const struct drm_i915_private *dev_priv, · 90 unmodified lines
48444838 if ((level > 0 && res_lines > 31) ||
48454839 res_blocks >= ddb_allocation ||
48464840 min_disp_buf_needed >= ddb_allocation) {
4847− result->plane_en = false;
4848−
48494841 /*
48504842 * If there are no valid level 0 watermarks, then we can't
48514843 * support this display configuration.
@@ -4872,27 +4864,22 @@ static int skl_compute_plane_wm(const struct drm_i915_private *dev_priv, · 20 unmodified lines
48724864 }
48734865
48744866 static int
4875−skl_compute_wm_levels(const struct drm_i915_private *dev_priv,
4876− struct skl_ddb_allocation *ddb,
4877− const struct intel_crtc_state *cstate,
4867+skl_compute_wm_levels(const struct intel_crtc_state *cstate,
48784868 const struct intel_plane_state *intel_pstate,
48794869 uint16_t ddb_blocks,
48804870 const struct skl_wm_params *wm_params,
4881− struct skl_plane_wm *wm,
48824871 struct skl_wm_level *levels)
48834872 {
4873+ struct drm_i915_private *dev_priv =
4874+ to_i915(intel_pstate->base.plane->dev);
48844875 int level, max_level = ilk_wm_max_level(dev_priv);
48854876 struct skl_wm_level *result_prev = &levels[0];
48864877 int ret;
48874878
4888− if (WARN_ON(!intel_pstate->base.fb))
4889− return -EINVAL;
4890−
48914879 for (level = 0; level <= max_level; level++) {
48924880 struct skl_wm_level *result = &levels[level];
48934881
4894− ret = skl_compute_plane_wm(dev_priv,
4895− cstate,
4882+ ret = skl_compute_plane_wm(cstate,
48964883 intel_pstate,
48974884 ddb_blocks,
48984885 level,
@@ -4905,9 +4892,6 @@ skl_compute_wm_levels(const struct drm_i915_private *dev_priv, · 6 unmodified lines
49054892 result_prev = result;
49064893 }
49074894
4908− if (intel_pstate->base.fb->format->format == DRM_FORMAT_NV12)
4909− wm->is_planar = true;
4910−
49114895 return 0;
49124896 }
49134897
@@ -4935,10 +4919,9 @@ skl_compute_linetime_wm(const struct intel_crtc_state *cstate) · 21 unmodified lines
49354919 }
49364920
49374921 static void skl_compute_transition_wm(const struct intel_crtc_state *cstate,
4938− struct skl_wm_params *wp,
4939− struct skl_wm_level *wm_l0,
4940− uint16_t ddb_allocation,
4941− struct skl_wm_level *trans_wm /* out */)
4922+ const struct skl_wm_params *wp,
4923+ struct skl_plane_wm *wm,
4924+ uint16_t ddb_allocation)
49424925 {
49434926 struct drm_device *dev = cstate->base.crtc->dev;
49444927 const struct drm_i915_private *dev_priv = to_i915(dev);
@@ -4946,16 +4929,13 @@ static void skl_compute_transition_wm(const struct intel_crtc_state *cstate, · 1 unmodified line
49464929 const uint16_t trans_amount = 10; /* This is configurable amount */
49474930 uint16_t wm0_sel_res_b, trans_offset_b, res_blocks;
49484931
4949− if (!cstate->base.active)
4950− goto exit;
4951−
49524932 /* Transition WM are not recommended by HW team for GEN9 */
49534933 if (INTEL_GEN(dev_priv) <= 9)
4954− goto exit;
4934+ return;
49554935
49564936 /* Transition WM don't make any sense if ipc is disabled */
49574937 if (!dev_priv->ipc_enabled)
4958− goto exit;
4938+ return;
49594939
49604940 trans_min = 14;
49614941 if (INTEL_GEN(dev_priv) >= 11)
@@ -4973,7 +4953,7 @@ static void skl_compute_transition_wm(const struct intel_crtc_state *cstate, · 11 unmodified lines
49734953 * Result Blocks is Result Blocks minus 1 and it should work for the
49744954 * current platforms.
49754955 */
4976− wm0_sel_res_b = wm_l0->plane_res_b - 1;
4956+ wm0_sel_res_b = wm->wm[0].plane_res_b - 1;
49774957
49784958 if (wp->y_tiled) {
49794959 trans_y_tile_min = (uint16_t) mul_round_up_u32_fixed16(2,
@@ -4992,107 +4972,129 @@ static void skl_compute_transition_wm(const struct intel_crtc_state *cstate, · 12 unmodified lines
49924972 res_blocks += 1;
49934973
49944974 if (res_blocks < ddb_allocation) {
4995− trans_wm->plane_res_b = res_blocks;
4996− trans_wm->plane_en = true;
4997− return;
4975+ wm->trans_wm.plane_res_b = res_blocks;
4976+ wm->trans_wm.plane_en = true;
49984977 }
4999−
5000−exit:
5001− trans_wm->plane_en = false;
50024978 }
50034979
5004−static int __skl_build_plane_wm_single(struct skl_ddb_allocation *ddb,
5005− struct skl_pipe_wm *pipe_wm,
5006− enum plane_id plane_id,
5007− const struct intel_crtc_state *cstate,
5008− const struct intel_plane_state *pstate,
5009− int color_plane)
4980+static int skl_build_plane_wm_single(struct intel_crtc_state *crtc_state,
4981+ const struct intel_plane_state *plane_state,
4982+ enum plane_id plane_id, int color_plane)
50104983 {
5011− struct drm_i915_private *dev_priv = to_i915(pstate->base.plane->dev);
5012− struct skl_plane_wm *wm = &pipe_wm->planes[plane_id];
5013− enum pipe pipe = to_intel_plane(pstate->base.plane)->pipe;
4984+ struct skl_plane_wm *wm = &crtc_state->wm.skl.optimal.planes[plane_id];
4985+ u16 ddb_blocks = skl_ddb_entry_size(&crtc_state->wm.skl.plane_ddb_y[plane_id]);
50144986 struct skl_wm_params wm_params;
5015− uint16_t ddb_blocks = skl_ddb_entry_size(&ddb->plane[pipe][plane_id]);
50164987 int ret;
50174988
5018− ret = skl_compute_plane_wm_params(dev_priv, cstate, pstate,
4989+ ret = skl_compute_plane_wm_params(crtc_state, plane_state,
50194990 &wm_params, color_plane);
50204991 if (ret)
50214992 return ret;
50224993
5023− ret = skl_compute_wm_levels(dev_priv, ddb, cstate, pstate,
5024− ddb_blocks, &wm_params, wm, wm->wm);
5025−
4994+ ret = skl_compute_wm_levels(crtc_state, plane_state,
4995+ ddb_blocks, &wm_params, wm->wm);
50264996 if (ret)
50274997 return ret;
50284998
5029− skl_compute_transition_wm(cstate, &wm_params, &wm->wm[0],
5030− ddb_blocks, &wm->trans_wm);
4999+ skl_compute_transition_wm(crtc_state, &wm_params, wm, ddb_blocks);
50315000
50325001 return 0;
50335002 }
50345003
5035−static int skl_build_plane_wm_single(struct skl_ddb_allocation *ddb,
5036− struct skl_pipe_wm *pipe_wm,
5037− const struct intel_crtc_state *cstate,
5038− const struct intel_plane_state *pstate)
5039−{
5040− enum plane_id plane_id = to_intel_plane(pstate->base.plane)->id;
5041−
5042− return __skl_build_plane_wm_single(ddb, pipe_wm, plane_id, cstate, pstate, 0);
5043−}
5044−
5045−static int skl_build_plane_wm_planar(struct skl_ddb_allocation *ddb,
5046− struct skl_pipe_wm *pipe_wm,
5047− const struct intel_crtc_state *cstate,
5048− const struct intel_plane_state *pstate)
5004+static int skl_build_plane_wm_uv(struct intel_crtc_state *crtc_state,
5005+ const struct intel_plane_state *plane_state,
5006+ enum plane_id plane_id)
50495007 {
5050− struct intel_plane *plane = to_intel_plane(pstate->base.plane);
5051− struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
5052− enum plane_id plane_id = plane->id;
5053− struct skl_plane_wm *wm = &pipe_wm->planes[plane_id];
5008+ struct skl_plane_wm *wm = &crtc_state->wm.skl.optimal.planes[plane_id];
5009+ u16 ddb_blocks = skl_ddb_entry_size(&crtc_state->wm.skl.plane_ddb_uv[plane_id]);
50545010 struct skl_wm_params wm_params;
5055− enum pipe pipe = plane->pipe;
5056− uint16_t ddb_blocks = skl_ddb_entry_size(&ddb->plane[pipe][plane_id]);
50575011 int ret;
50585012
5059− ret = __skl_build_plane_wm_single(ddb, pipe_wm, plane_id, cstate, pstate, 0);
5060− if (ret)
5061− return ret;
5013+ wm->is_planar = true;
50625014
50635015 /* uv plane watermarks must also be validated for NV12/Planar */
5064− ddb_blocks = skl_ddb_entry_size(&ddb->uv_plane[pipe][plane_id]);
5016+ ret = skl_compute_plane_wm_params(crtc_state, plane_state,
5017+ &wm_params, 1);
5018+ if (ret)
5019+ return ret;
50655020
5066− ret = skl_compute_plane_wm_params(dev_priv, cstate, pstate, &wm_params, 1);
5021+ ret = skl_compute_wm_levels(crtc_state, plane_state,
5022+ ddb_blocks, &wm_params, wm->uv_wm);
50675023 if (ret)
50685024 return ret;
50695025
5070− return skl_compute_wm_levels(dev_priv, ddb, cstate, pstate,
5071− ddb_blocks, &wm_params, wm, wm->uv_wm);
5026+ return 0;
50725027 }
50735028
5074−static int icl_build_plane_wm_planar(struct skl_ddb_allocation *ddb,
5075− struct skl_pipe_wm *pipe_wm,
5076− const struct intel_crtc_state *cstate,
5077− const struct intel_plane_state *pstate)
5029+static int skl_build_plane_wm(struct skl_pipe_wm *pipe_wm,
5030+ struct intel_crtc_state *crtc_state,
5031+ const struct intel_plane_state *plane_state)
50785032 {
5033+ struct intel_plane *plane = to_intel_plane(plane_state->base.plane);
5034+ const struct drm_framebuffer *fb = plane_state->base.fb;
5035+ enum plane_id plane_id = plane->id;
50795036 int ret;
5080− enum plane_id y_plane_id = pstate->linked_plane->id;
5081− enum plane_id uv_plane_id = to_intel_plane(pstate->base.plane)->id;
50825037
5083− ret = __skl_build_plane_wm_single(ddb, pipe_wm, y_plane_id,
5084− cstate, pstate, 0);
5038+ if (!intel_wm_plane_visible(crtc_state, plane_state))
5039+ return 0;
5040+
5041+ ret = skl_build_plane_wm_single(crtc_state, plane_state,
5042+ plane_id, 0);
50855043 if (ret)
50865044 return ret;
50875045
5088− return __skl_build_plane_wm_single(ddb, pipe_wm, uv_plane_id,
5089− cstate, pstate, 1);
5046+ if (fb->format->is_yuv && fb->format->num_planes > 1) {
5047+ ret = skl_build_plane_wm_uv(crtc_state, plane_state,
5048+ plane_id);
5049+ if (ret)
5050+ return ret;
5051+ }
5052+
5053+ return 0;
5054+}
5055+
5056+static int icl_build_plane_wm(struct skl_pipe_wm *pipe_wm,
5057+ struct intel_crtc_state *crtc_state,
5058+ const struct intel_plane_state *plane_state)
5059+{
5060+ enum plane_id plane_id = to_intel_plane(plane_state->base.plane)->id;
5061+ int ret;
5062+
5063+ /* Watermarks calculated in master */
5064+ if (plane_state->slave)
5065+ return 0;
5066+
5067+ if (plane_state->linked_plane) {
5068+ const struct drm_framebuffer *fb = plane_state->base.fb;
5069+ enum plane_id y_plane_id = plane_state->linked_plane->id;
5070+
5071+ WARN_ON(!intel_wm_plane_visible(crtc_state, plane_state));
5072+ WARN_ON(!fb->format->is_yuv ||
5073+ fb->format->num_planes == 1);
5074+
5075+ ret = skl_build_plane_wm_single(crtc_state, plane_state,
5076+ y_plane_id, 0);
5077+ if (ret)
5078+ return ret;
5079+
5080+ ret = skl_build_plane_wm_single(crtc_state, plane_state,
5081+ plane_id, 1);
5082+ if (ret)
5083+ return ret;
5084+ } else if (intel_wm_plane_visible(crtc_state, plane_state)) {
5085+ ret = skl_build_plane_wm_single(crtc_state, plane_state,
5086+ plane_id, 0);
5087+ if (ret)
5088+ return ret;
5089+ }
5090+
5091+ return 0;
50905092 }
50915093
50925094 static int skl_build_pipe_wm(struct intel_crtc_state *cstate,
5093− struct skl_ddb_allocation *ddb,
50945095 struct skl_pipe_wm *pipe_wm)
50955096 {
5097+ struct drm_i915_private *dev_priv = to_i915(cstate->base.crtc->dev);
50965098 struct drm_crtc_state *crtc_state = &cstate->base;
50975099 struct drm_plane *plane;
50985100 const struct drm_plane_state *pstate;
@@ -5108,18 +5110,12 @@ static int skl_build_pipe_wm(struct intel_crtc_state *cstate, · 9 unmodified lines
51085110 const struct intel_plane_state *intel_pstate =
51095111 to_intel_plane_state(pstate);
51105112
5111− /* Watermarks calculated in master */
5112− if (intel_pstate->slave)
5113− continue;
5114−
5115− if (intel_pstate->linked_plane)
5116− ret = icl_build_plane_wm_planar(ddb, pipe_wm, cstate, intel_pstate);
5117− else if (intel_pstate->base.fb &&
5118− intel_pstate->base.fb->format->format == DRM_FORMAT_NV12)
5119− ret = skl_build_plane_wm_planar(ddb, pipe_wm, cstate, intel_pstate);
5113+ if (INTEL_GEN(dev_priv) >= 11)
5114+ ret = icl_build_plane_wm(pipe_wm,
5115+ cstate, intel_pstate);
51205116 else
5121− ret = skl_build_plane_wm_single(ddb, pipe_wm, cstate, intel_pstate);
5122−
5117+ ret = skl_build_plane_wm(pipe_wm,
5118+ cstate, intel_pstate);
51235119 if (ret)
51245120 return ret;
51255121 }
@@ -5134,9 +5130,9 @@ static void skl_ddb_entry_write(struct drm_i915_private *dev_priv, · 8 unmodified lines
51345130 const struct skl_ddb_entry *entry)
51355131 {
51365132 if (entry->end)
5137− I915_WRITE(reg, (entry->end - 1) << 16 | entry->start);
5133+ I915_WRITE_FW(reg, (entry->end - 1) << 16 | entry->start);
51385134 else
5139− I915_WRITE(reg, 0);
5135+ I915_WRITE_FW(reg, 0);
51405136 }
51415137
51425138 static void skl_write_wm_level(struct drm_i915_private *dev_priv,
@@ -5151,19 +5147,22 @@ static void skl_write_wm_level(struct drm_i915_private *dev_priv, · 8 unmodified lines
51515147 val |= level->plane_res_l << PLANE_WM_LINES_SHIFT;
51525148 }
51535149
5154− I915_WRITE(reg, val);
5150+ I915_WRITE_FW(reg, val);
51555151 }
51565152
5157−static void skl_write_plane_wm(struct intel_crtc *intel_crtc,
5158− const struct skl_plane_wm *wm,
5159− const struct skl_ddb_allocation *ddb,
5160− enum plane_id plane_id)
5153+void skl_write_plane_wm(struct intel_plane *plane,
5154+ const struct intel_crtc_state *crtc_state)
51615155 {
5162− struct drm_crtc *crtc = &intel_crtc->base;
5163− struct drm_device *dev = crtc->dev;
5164− struct drm_i915_private *dev_priv = to_i915(dev);
5156+ struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
51655157 int level, max_level = ilk_wm_max_level(dev_priv);
5166− enum pipe pipe = intel_crtc->pipe;
5158+ enum plane_id plane_id = plane->id;
5159+ enum pipe pipe = plane->pipe;
5160+ const struct skl_plane_wm *wm =
5161+ &crtc_state->wm.skl.optimal.planes[plane_id];
5162+ const struct skl_ddb_entry *ddb_y =
5163+ &crtc_state->wm.skl.plane_ddb_y[plane_id];
5164+ const struct skl_ddb_entry *ddb_uv =
5165+ &crtc_state->wm.skl.plane_ddb_uv[plane_id];
51675166
51685167 for (level = 0; level <= max_level; level++) {
51695168 skl_write_wm_level(dev_priv, PLANE_WM(pipe, plane_id, level),
@@ -5172,29 +5171,32 @@ static void skl_write_plane_wm(struct intel_crtc *intel_crtc, · 2 unmodified lines
51725171 skl_write_wm_level(dev_priv, PLANE_WM_TRANS(pipe, plane_id),
51735172 &wm->trans_wm);
51745173
5175− if (wm->is_planar && INTEL_GEN(dev_priv) < 11) {
5176− skl_ddb_entry_write(dev_priv, PLANE_BUF_CFG(pipe, plane_id),
5177− &ddb->uv_plane[pipe][plane_id]);
5174+ if (INTEL_GEN(dev_priv) >= 11) {
51785175 skl_ddb_entry_write(dev_priv,
5179− PLANE_NV12_BUF_CFG(pipe, plane_id),
5180− &ddb->plane[pipe][plane_id]);
5181− } else {
5182− skl_ddb_entry_write(dev_priv, PLANE_BUF_CFG(pipe, plane_id),
5183− &ddb->plane[pipe][plane_id]);
5184− if (INTEL_GEN(dev_priv) < 11)
5185− I915_WRITE(PLANE_NV12_BUF_CFG(pipe, plane_id), 0x0);
5176+ PLANE_BUF_CFG(pipe, plane_id), ddb_y);
5177+ return;
51865178 }
5179+
5180+ if (wm->is_planar)
5181+ swap(ddb_y, ddb_uv);
5182+
5183+ skl_ddb_entry_write(dev_priv,
5184+ PLANE_BUF_CFG(pipe, plane_id), ddb_y);
5185+ skl_ddb_entry_write(dev_priv,
5186+ PLANE_NV12_BUF_CFG(pipe, plane_id), ddb_uv);
51875187 }
51885188
5189−static void skl_write_cursor_wm(struct intel_crtc *intel_crtc,
5190− const struct skl_plane_wm *wm,
5191− const struct skl_ddb_allocation *ddb)
5189+void skl_write_cursor_wm(struct intel_plane *plane,
5190+ const struct intel_crtc_state *crtc_state)
51925191 {
5193− struct drm_crtc *crtc = &intel_crtc->base;
5194− struct drm_device *dev = crtc->dev;
5195− struct drm_i915_private *dev_priv = to_i915(dev);
5192+ struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
51965193 int level, max_level = ilk_wm_max_level(dev_priv);
5197− enum pipe pipe = intel_crtc->pipe;
5194+ enum plane_id plane_id = plane->id;
5195+ enum pipe pipe = plane->pipe;
5196+ const struct skl_plane_wm *wm =
5197+ &crtc_state->wm.skl.optimal.planes[plane_id];
5198+ const struct skl_ddb_entry *ddb =
5199+ &crtc_state->wm.skl.plane_ddb_y[plane_id];
51985200
51995201 for (level = 0; level <= max_level; level++) {
52005202 skl_write_wm_level(dev_priv, CUR_WM(pipe, level),
@@ -5202,22 +5204,30 @@ static void skl_write_cursor_wm(struct intel_crtc *intel_crtc, · 1 unmodified line
52025204 }
52035205 skl_write_wm_level(dev_priv, CUR_WM_TRANS(pipe), &wm->trans_wm);
52045206
5205− skl_ddb_entry_write(dev_priv, CUR_BUF_CFG(pipe),
5206− &ddb->plane[pipe][PLANE_CURSOR]);
5207+ skl_ddb_entry_write(dev_priv, CUR_BUF_CFG(pipe), ddb);
52075208 }
52085209
52095210 bool skl_wm_level_equals(const struct skl_wm_level *l1,
52105211 const struct skl_wm_level *l2)
52115212 {
5212− if (l1->plane_en != l2->plane_en)
5213− return false;
5213+ return l1->plane_en == l2->plane_en &&
5214+ l1->plane_res_l == l2->plane_res_l &&
5215+ l1->plane_res_b == l2->plane_res_b;
5216+}
52145217
5215− /* If both planes aren't enabled, the rest shouldn't matter */
5216− if (!l1->plane_en)
5217− return true;
5218+static bool skl_plane_wm_equals(struct drm_i915_private *dev_priv,
5219+ const struct skl_plane_wm *wm1,
5220+ const struct skl_plane_wm *wm2)
5221+{
5222+ int level, max_level = ilk_wm_max_level(dev_priv);
52185223
5219− return (l1->plane_res_l == l2->plane_res_l &&
5220− l1->plane_res_b == l2->plane_res_b);
5224+ for (level = 0; level <= max_level; level++) {
5225+ if (!skl_wm_level_equals(&wm1->wm[level], &wm2->wm[level]) ||
5226+ !skl_wm_level_equals(&wm1->uv_wm[level], &wm2->uv_wm[level]))
5227+ return false;
5228+ }
5229+
5230+ return skl_wm_level_equals(&wm1->trans_wm, &wm2->trans_wm);
52215231 }
52225232
52235233 static inline bool skl_ddb_entries_overlap(const struct skl_ddb_entry *a,
@@ -5244,13 +5254,12 @@ bool skl_ddb_allocation_overlaps(const struct skl_ddb_entry *ddb, · 20 unmodified lines
52445254 static int skl_update_pipe_wm(struct drm_crtc_state *cstate,
52455255 const struct skl_pipe_wm *old_pipe_wm,
52465256 struct skl_pipe_wm *pipe_wm, /* out */
5247− struct skl_ddb_allocation *ddb, /* out */
52485257 bool *changed /* out */)
52495258 {
52505259 struct intel_crtc_state *intel_cstate = to_intel_crtc_state(cstate);
52515260 int ret;
52525261
5253− ret = skl_build_pipe_wm(intel_cstate, ddb, pipe_wm);
5262+ ret = skl_build_pipe_wm(intel_cstate, pipe_wm);
52545263 if (ret)
52555264 return ret;
52565265
@@ -5276,42 +5285,29 @@ pipes_modified(struct drm_atomic_state *state) · 19 unmodified lines
52765285 }
52775286
52785287 static int
5279−skl_ddb_add_affected_planes(struct intel_crtc_state *cstate)
5288+skl_ddb_add_affected_planes(const struct intel_crtc_state *old_crtc_state,
5289+ struct intel_crtc_state *new_crtc_state)
52805290 {
5281− struct drm_atomic_state *state = cstate->base.state;
5282− struct drm_device *dev = state->dev;
5283− struct drm_crtc *crtc = cstate->base.crtc;
5284− struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
5285− struct drm_i915_private *dev_priv = to_i915(dev);
5286− struct intel_atomic_state *intel_state = to_intel_atomic_state(state);
5287− struct skl_ddb_allocation *new_ddb = &intel_state->wm_results.ddb;
5288− struct skl_ddb_allocation *cur_ddb = &dev_priv->wm.skl_hw.ddb;
5289− struct drm_plane *plane;
5290− enum pipe pipe = intel_crtc->pipe;
5291+ struct intel_atomic_state *state = to_intel_atomic_state(new_crtc_state->base.state);
5292+ struct intel_crtc *crtc = to_intel_crtc(new_crtc_state->base.crtc);
5293+ struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
5294+ struct intel_plane *plane;
52915295
5292− drm_for_each_plane_mask(plane, dev, cstate->base.plane_mask) {
5293− struct drm_plane_state *plane_state;
5294− struct intel_plane *linked;
5295− enum plane_id plane_id = to_intel_plane(plane)->id;
5296+ for_each_intel_plane_on_crtc(&dev_priv->drm, crtc, plane) {
5297+ struct intel_plane_state *plane_state;
5298+ enum plane_id plane_id = plane->id;
52965299
5297− if (skl_ddb_entry_equal(&cur_ddb->plane[pipe][plane_id],
5298− &new_ddb->plane[pipe][plane_id]) &&
5299− skl_ddb_entry_equal(&cur_ddb->uv_plane[pipe][plane_id],
5300− &new_ddb->uv_plane[pipe][plane_id]))
5300+ if (skl_ddb_entry_equal(&old_crtc_state->wm.skl.plane_ddb_y[plane_id],
5301+ &new_crtc_state->wm.skl.plane_ddb_y[plane_id]) &&
5302+ skl_ddb_entry_equal(&old_crtc_state->wm.skl.plane_ddb_uv[plane_id],
5303+ &new_crtc_state->wm.skl.plane_ddb_uv[plane_id]))
53015304 continue;
53025305
5303− plane_state = drm_atomic_get_plane_state(state, plane);
5306+ plane_state = intel_atomic_get_plane_state(state, plane);
53045307 if (IS_ERR(plane_state))
53055308 return PTR_ERR(plane_state);
53065309
5307− /* Make sure linked plane is updated too */
5308− linked = to_intel_plane_state(plane_state)->linked_plane;
5309− if (!linked)
5310− continue;
5311−
5312− plane_state = drm_atomic_get_plane_state(state, &linked->base);
5313− if (IS_ERR(plane_state))
5314− return PTR_ERR(plane_state);
5310+ new_crtc_state->update_planes |= BIT(plane_id);
53155311 }
53165312
53175313 return 0;
@@ -5323,18 +5319,21 @@ skl_compute_ddb(struct drm_atomic_state *state) · 5 unmodified lines
53235319 const struct drm_i915_private *dev_priv = to_i915(state->dev);
53245320 struct intel_atomic_state *intel_state = to_intel_atomic_state(state);
53255321 struct skl_ddb_allocation *ddb = &intel_state->wm_results.ddb;
5322+ struct intel_crtc_state *old_crtc_state;
5323+ struct intel_crtc_state *new_crtc_state;
53265324 struct intel_crtc *crtc;
5327− struct intel_crtc_state *cstate;
53285325 int ret, i;
53295326
53305327 memcpy(ddb, &dev_priv->wm.skl_hw.ddb, sizeof(*ddb));
53315328
5332− for_each_new_intel_crtc_in_state(intel_state, crtc, cstate, i) {
5333− ret = skl_allocate_pipe_ddb(cstate, ddb);
5329+ for_each_oldnew_intel_crtc_in_state(intel_state, crtc, old_crtc_state,
5330+ new_crtc_state, i) {
5331+ ret = skl_allocate_pipe_ddb(new_crtc_state, ddb);
53345332 if (ret)
53355333 return ret;
53365334
5337− ret = skl_ddb_add_affected_planes(cstate);
5335+ ret = skl_ddb_add_affected_planes(old_crtc_state,
5336+ new_crtc_state);
53385337 if (ret)
53395338 return ret;
53405339 }
@@ -5343,36 +5342,29 @@ skl_compute_ddb(struct drm_atomic_state *state) · 2 unmodified lines
53435342 }
53445343
53455344 static void
5346−skl_print_wm_changes(const struct drm_atomic_state *state)
5345+skl_print_wm_changes(struct intel_atomic_state *state)
53475346 {
5348− const struct drm_device *dev = state->dev;
5349− const struct drm_i915_private *dev_priv = to_i915(dev);
5350− const struct intel_atomic_state *intel_state =
5351− to_intel_atomic_state(state);
5352− const struct drm_crtc *crtc;
5353− const struct drm_crtc_state *cstate;
5354− const struct intel_plane *intel_plane;
5355− const struct skl_ddb_allocation *old_ddb = &dev_priv->wm.skl_hw.ddb;
5356− const struct skl_ddb_allocation *new_ddb = &intel_state->wm_results.ddb;
5347+ struct drm_i915_private *dev_priv = to_i915(state->base.dev);
5348+ const struct intel_crtc_state *old_crtc_state;
5349+ const struct intel_crtc_state *new_crtc_state;
5350+ struct intel_plane *plane;
5351+ struct intel_crtc *crtc;
53575352 int i;
53585353
5359− for_each_new_crtc_in_state(state, crtc, cstate, i) {
5360− const struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
5361− enum pipe pipe = intel_crtc->pipe;
5362−
5363− for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) {
5364− enum plane_id plane_id = intel_plane->id;
5354+ for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state,
5355+ new_crtc_state, i) {
5356+ for_each_intel_plane_on_crtc(&dev_priv->drm, crtc, plane) {
5357+ enum plane_id plane_id = plane->id;
53655358 const struct skl_ddb_entry *old, *new;
53665359
5367− old = &old_ddb->plane[pipe][plane_id];
5368− new = &new_ddb->plane[pipe][plane_id];
5360+ old = &old_crtc_state->wm.skl.plane_ddb_y[plane_id];
5361+ new = &new_crtc_state->wm.skl.plane_ddb_y[plane_id];
53695362
53705363 if (skl_ddb_entry_equal(old, new))
53715364 continue;
53725365
53735366 DRM_DEBUG_KMS("[PLANE:%d:%s] ddb (%d - %d) -> (%d - %d)\n",
5374− intel_plane->base.base.id,
5375− intel_plane->base.name,
5367+ plane->base.base.id, plane->base.name,
53765368 old->start, old->end,
53775369 new->start, new->end);
53785370 }
@@ -5469,6 +5461,66 @@ skl_ddb_add_affected_pipes(struct drm_atomic_state *state, bool *changed) · 90 unmodified lines
54695461 return 0;
54705462 }
54715463
5464+/*
5465+ * To make sure the cursor watermark registers are always consistent
5466+ * with our computed state the following scenario needs special
5467+ * treatment:
5468+ *
5469+ * 1. enable cursor
5470+ * 2. move cursor entirely offscreen
5471+ * 3. disable cursor
5472+ *
5473+ * Step 2. does call .disable_plane() but does not zero the watermarks
5474+ * (since we consider an offscreen cursor still active for the purposes
5475+ * of watermarks). Step 3. would not normally call .disable_plane()
5476+ * because the actual plane visibility isn't changing, and we don't
5477+ * deallocate the cursor ddb until the pipe gets disabled. So we must
5478+ * force step 3. to call .disable_plane() to update the watermark
5479+ * registers properly.
5480+ *
5481+ * Other planes do not suffer from this issues as their watermarks are
5482+ * calculated based on the actual plane visibility. The only time this
5483+ * can trigger for the other planes is during the initial readout as the
5484+ * default value of the watermarks registers is not zero.
5485+ */
5486+static int skl_wm_add_affected_planes(struct intel_atomic_state *state,
5487+ struct intel_crtc *crtc)
5488+{
5489+ struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
5490+ const struct intel_crtc_state *old_crtc_state =
5491+ intel_atomic_get_old_crtc_state(state, crtc);
5492+ struct intel_crtc_state *new_crtc_state =
5493+ intel_atomic_get_new_crtc_state(state, crtc);
5494+ struct intel_plane *plane;
5495+
5496+ for_each_intel_plane_on_crtc(&dev_priv->drm, crtc, plane) {
5497+ struct intel_plane_state *plane_state;
5498+ enum plane_id plane_id = plane->id;
5499+
5500+ /*
5501+ * Force a full wm update for every plane on modeset.
5502+ * Required because the reset value of the wm registers
5503+ * is non-zero, whereas we want all disabled planes to
5504+ * have zero watermarks. So if we turn off the relevant
5505+ * power well the hardware state will go out of sync
5506+ * with the software state.
5507+ */
5508+ if (!drm_atomic_crtc_needs_modeset(&new_crtc_state->base) &&
5509+ skl_plane_wm_equals(dev_priv,
5510+ &old_crtc_state->wm.skl.optimal.planes[plane_id],
5511+ &new_crtc_state->wm.skl.optimal.planes[plane_id]))
5512+ continue;
5513+
5514+ plane_state = intel_atomic_get_plane_state(state, plane);
5515+ if (IS_ERR(plane_state))
5516+ return PTR_ERR(plane_state);
5517+
5518+ new_crtc_state->update_planes |= BIT(plane_id);
5519+ }
5520+
5521+ return 0;
5522+}
5523+
54725524 static int
54735525 skl_compute_wm(struct drm_atomic_state *state)
54745526 {
@@ -5508,8 +5560,12 @@ skl_compute_wm(struct drm_atomic_state *state) · 33 unmodified lines
55085560 &to_intel_crtc_state(crtc->state)->wm.skl.optimal;
55095561
55105562 pipe_wm = &intel_cstate->wm.skl.optimal;
5511− ret = skl_update_pipe_wm(cstate, old_pipe_wm, pipe_wm,
5512− &results->ddb, &changed);
5563+ ret = skl_update_pipe_wm(cstate, old_pipe_wm, pipe_wm, &changed);
5564+ if (ret)
5565+ return ret;
5566+
5567+ ret = skl_wm_add_affected_planes(intel_state,
5568+ to_intel_crtc(crtc));
55135569 if (ret)
55145570 return ret;
55155571
@@ -5523,7 +5579,7 @@ skl_compute_wm(struct drm_atomic_state *state) · 7 unmodified lines
55235579 intel_cstate->update_wm_pre = true;
55245580 }
55255581
5526− skl_print_wm_changes(state);
5582+ skl_print_wm_changes(intel_state);
55275583
55285584 return 0;
55295585 }
@@ -5534,23 +5590,12 @@ static void skl_atomic_update_crtc_wm(struct intel_atomic_state *state, · 4 unmodified lines
55345590 struct intel_crtc *crtc = to_intel_crtc(cstate->base.crtc);
55355591 struct drm_i915_private *dev_priv = to_i915(state->base.dev);
55365592 struct skl_pipe_wm *pipe_wm = &cstate->wm.skl.optimal;
5537− const struct skl_ddb_allocation *ddb = &state->wm_results.ddb;
55385593 enum pipe pipe = crtc->pipe;
5539− enum plane_id plane_id;
55405594
55415595 if (!(state->wm_results.dirty_pipes & drm_crtc_mask(&crtc->base)))
55425596 return;
55435597
55445598 I915_WRITE(PIPE_WM_LINETIME(pipe), pipe_wm->linetime);
5545−
5546− for_each_plane_id_on_crtc(crtc, plane_id) {
5547− if (plane_id != PLANE_CURSOR)
5548− skl_write_plane_wm(crtc, &pipe_wm->planes[plane_id],
5549− ddb, plane_id);
5550− else
5551− skl_write_cursor_wm(crtc, &pipe_wm->planes[plane_id],
5552− ddb);
5553− }
55545599 }
55555600
55565601 static void skl_initial_wm(struct intel_atomic_state *state,
@@ -5560,8 +5605,6 @@ static void skl_initial_wm(struct intel_atomic_state *state, · 3 unmodified lines
55605605 struct drm_device *dev = intel_crtc->base.dev;
55615606 struct drm_i915_private *dev_priv = to_i915(dev);
55625607 struct skl_ddb_values *results = &state->wm_results;
5563− struct skl_ddb_values *hw_vals = &dev_priv->wm.skl_hw;
5564− enum pipe pipe = intel_crtc->pipe;
55655608
55665609 if ((results->dirty_pipes & drm_crtc_mask(&intel_crtc->base)) == 0)
55675610 return;
@@ -5571,11 +5614,6 @@ static void skl_initial_wm(struct intel_atomic_state *state, · 3 unmodified lines
55715614 if (cstate->base.active_changed)
55725615 skl_atomic_update_crtc_wm(state, cstate);
55735616
5574− memcpy(hw_vals->ddb.uv_plane[pipe], results->ddb.uv_plane[pipe],
5575− sizeof(hw_vals->ddb.uv_plane[pipe]));
5576− memcpy(hw_vals->ddb.plane[pipe], results->ddb.plane[pipe],
5577− sizeof(hw_vals->ddb.plane[pipe]));
5578−
55795617 mutex_unlock(&dev_priv->wm.wm_mutex);
55805618 }
55815619
@@ -5726,13 +5764,6 @@ void skl_wm_get_hw_state(struct drm_device *dev) · 144 unmodified lines
57265764 if (dev_priv->active_crtcs) {
57275765 /* Fully recompute DDB on first atomic commit */
57285766 dev_priv->wm.distrust_bios_wm = true;
5729− } else {
5730− /*
5731− * Easy/common case; just sanitize DDB now if everything off
5732− * Keep dbuf slice info intact
5733− */
5734− memset(ddb->plane, 0, sizeof(ddb->plane));
5735− memset(ddb->uv_plane, 0, sizeof(ddb->uv_plane));
57365767 }
57375768 }
57385769
drivers/gpu/drm/i915/intel_psr.c+94−24
@@ -75,6 +75,10 @@ static bool intel_psr2_enabled(struct drm_i915_private *dev_priv, · 74 unmodified lines
7575 if (i915_modparams.enable_psr == -1)
7676 return false;
7777
78+ /* Cannot enable DSC and PSR2 simultaneously */
79+ WARN_ON(crtc_state->dsc_params.compression_enable &&
80+ crtc_state->has_psr2);
81+
7882 switch (dev_priv->psr.debug & I915_PSR_DEBUG_MODE_MASK) {
7983 case I915_PSR_DEBUG_FORCE_PSR1:
8084 return false;
@@ -169,6 +173,7 @@ void intel_psr_irq_handler(struct drm_i915_private *dev_priv, u32 psr_iir) · 88 unmodified lines
169173 u32 transcoders = BIT(TRANSCODER_EDP);
170174 enum transcoder cpu_transcoder;
171175 ktime_t time_ns = ktime_get();
176+ u32 mask = 0;
172177
173178 if (INTEL_GEN(dev_priv) >= 8)
174179 transcoders |= BIT(TRANSCODER_A) |
@@ -178,10 +183,22 @@ void intel_psr_irq_handler(struct drm_i915_private *dev_priv, u32 psr_iir) · 3 unmodified lines
178183 for_each_cpu_transcoder_masked(dev_priv, cpu_transcoder, transcoders) {
179184 int shift = edp_psr_shift(cpu_transcoder);
180185
181− /* FIXME: Exit PSR and link train manually when this happens. */
182− if (psr_iir & EDP_PSR_ERROR(shift))
183− DRM_DEBUG_KMS("[transcoder %s] PSR aux error\n",
184− transcoder_name(cpu_transcoder));
186+ if (psr_iir & EDP_PSR_ERROR(shift)) {
187+ DRM_WARN("[transcoder %s] PSR aux error\n",
188+ transcoder_name(cpu_transcoder));
189+
190+ dev_priv->psr.irq_aux_error = true;
191+
192+ /*
193+ * If this interruption is not masked it will keep
194+ * interrupting so fast that it prevents the scheduled
195+ * work to run.
196+ * Also after a PSR error, we don't want to arm PSR
197+ * again so we don't care about unmask the interruption
198+ * or unset irq_aux_error.
199+ */
200+ mask |= EDP_PSR_ERROR(shift);
201+ }
185202
186203 if (psr_iir & EDP_PSR_PRE_ENTRY(shift)) {
187204 dev_priv->psr.last_entry_attempt = time_ns;
@@ -203,6 +220,13 @@ void intel_psr_irq_handler(struct drm_i915_private *dev_priv, u32 psr_iir) · 15 unmodified lines
203220 }
204221 }
205222 }
223+
224+ if (mask) {
225+ mask |= I915_READ(EDP_PSR_IMR);
226+ I915_WRITE(EDP_PSR_IMR, mask);
227+
228+ schedule_work(&dev_priv->psr.work);
229+ }
206230 }
207231
208232 static bool intel_dp_get_colorimetry_status(struct intel_dp *intel_dp)
@@ -482,6 +506,16 @@ static bool intel_psr2_config_valid(struct intel_dp *intel_dp, · 273 unmodified lines
482506 if (!dev_priv->psr.sink_psr2_support)
483507 return false;
484508
509+ /*
510+ * DSC and PSR2 cannot be enabled simultaneously. If a requested
511+ * resolution requires DSC to be enabled, priority is given to DSC
512+ * over PSR2.
513+ */
514+ if (crtc_state->dsc_params.compression_enable) {
515+ DRM_DEBUG_KMS("PSR2 cannot be enabled since DSC is enabled\n");
516+ return false;
517+ }
518+
485519 if (INTEL_GEN(dev_priv) >= 10 || IS_GEMINILAKE(dev_priv)) {
486520 psr_max_h = 4096;
487521 psr_max_v = 2304;
@@ -527,10 +561,8 @@ void intel_psr_compute_config(struct intel_dp *intel_dp, · 39 unmodified lines
527561 return;
528562 }
529563
530− if (IS_HASWELL(dev_priv) &&
531− I915_READ(HSW_STEREO_3D_CTL(crtc_state->cpu_transcoder)) &
532− S3D_ENABLE) {
533− DRM_DEBUG_KMS("PSR condition failed: Stereo 3D is Enabled\n");
564+ if (dev_priv->psr.sink_not_reliable) {
565+ DRM_DEBUG_KMS("PSR sink implementation is not reliable\n");
534566 return;
535567 }
536568
@@ -687,6 +719,7 @@ void intel_psr_enable(struct intel_dp *intel_dp, · 150 unmodified lines
687719 dev_priv->psr.psr2_enabled = intel_psr2_enabled(dev_priv, crtc_state);
688720 dev_priv->psr.busy_frontbuffer_bits = 0;
689721 dev_priv->psr.prepared = true;
722+ dev_priv->psr.pipe = to_intel_crtc(crtc_state->base.crtc)->pipe;
690723
691724 if (psr_global_enabled(dev_priv->psr.debug))
692725 intel_psr_enable_locked(dev_priv, crtc_state);
@@ -933,6 +966,16 @@ int intel_psr_set_debugfs_mode(struct drm_i915_private *dev_priv, · 240 unmodified lines
933966 return ret;
934967 }
935968
969+static void intel_psr_handle_irq(struct drm_i915_private *dev_priv)
970+{
971+ struct i915_psr *psr = &dev_priv->psr;
972+
973+ intel_psr_disable_locked(psr->dp);
974+ psr->sink_not_reliable = true;
975+ /* let's make sure that sink is awaken */
976+ drm_dp_dpcd_writeb(&psr->dp->aux, DP_SET_POWER, DP_SET_POWER_D0);
977+}
978+
936979 static void intel_psr_work(struct work_struct *work)
937980 {
938981 struct drm_i915_private *dev_priv =
@@ -943,6 +986,9 @@ static void intel_psr_work(struct work_struct *work) · 4 unmodified lines
943986 if (!dev_priv->psr.enabled)
944987 goto unlock;
945988
989+ if (READ_ONCE(dev_priv->psr.irq_aux_error))
990+ intel_psr_handle_irq(dev_priv);
991+
946992 /*
947993 * We have to make sure PSR is ready for re-enable
948994 * otherwise it keeps disabled until next full enable/disable cycle.
@@ -981,9 +1027,6 @@ unlock: · 32 unmodified lines
9811027 void intel_psr_invalidate(struct drm_i915_private *dev_priv,
9821028 unsigned frontbuffer_bits, enum fb_op_origin origin)
9831029 {
984− struct drm_crtc *crtc;
985− enum pipe pipe;
986−
9871030 if (!CAN_PSR(dev_priv))
9881031 return;
9891032
@@ -996,10 +1039,7 @@ void intel_psr_invalidate(struct drm_i915_private *dev_priv, · 6 unmodified lines
9961039 return;
9971040 }
9981041
999− crtc = dp_to_dig_port(dev_priv->psr.dp)->base.base.crtc;
1000− pipe = to_intel_crtc(crtc)->pipe;
1001−
1002− frontbuffer_bits &= INTEL_FRONTBUFFER_ALL_MASK(pipe);
1042+ frontbuffer_bits &= INTEL_FRONTBUFFER_ALL_MASK(dev_priv->psr.pipe);
10031043 dev_priv->psr.busy_frontbuffer_bits |= frontbuffer_bits;
10041044
10051045 if (frontbuffer_bits)
@@ -1024,9 +1064,6 @@ void intel_psr_invalidate(struct drm_i915_private *dev_priv, · 18 unmodified lines
10241064 void intel_psr_flush(struct drm_i915_private *dev_priv,
10251065 unsigned frontbuffer_bits, enum fb_op_origin origin)
10261066 {
1027− struct drm_crtc *crtc;
1028− enum pipe pipe;
1029−
10301067 if (!CAN_PSR(dev_priv))
10311068 return;
10321069
@@ -1039,10 +1076,7 @@ void intel_psr_flush(struct drm_i915_private *dev_priv, · 6 unmodified lines
10391076 return;
10401077 }
10411078
1042− crtc = dp_to_dig_port(dev_priv->psr.dp)->base.base.crtc;
1043− pipe = to_intel_crtc(crtc)->pipe;
1044−
1045− frontbuffer_bits &= INTEL_FRONTBUFFER_ALL_MASK(pipe);
1079+ frontbuffer_bits &= INTEL_FRONTBUFFER_ALL_MASK(dev_priv->psr.pipe);
10461080 dev_priv->psr.busy_frontbuffer_bits &= ~frontbuffer_bits;
10471081
10481082 /* By definition flush = invalidate + flush */
@@ -1056,7 +1090,7 @@ void intel_psr_flush(struct drm_i915_private *dev_priv, · 7 unmodified lines
10561090 * but it makes more sense write to the current active
10571091 * pipe.
10581092 */
1059− I915_WRITE(CURSURFLIVE(pipe), 0);
1093+ I915_WRITE(CURSURFLIVE(dev_priv->psr.pipe), 0);
10601094 }
10611095
10621096 if (!dev_priv->psr.active && !dev_priv->psr.busy_frontbuffer_bits)
@@ -1073,6 +1107,8 @@ void intel_psr_flush(struct drm_i915_private *dev_priv, · 10 unmodified lines
10731107 */
10741108 void intel_psr_init(struct drm_i915_private *dev_priv)
10751109 {
1110+ u32 val;
1111+
10761112 if (!HAS_PSR(dev_priv))
10771113 return;
10781114
@@ -1086,6 +1122,22 @@ void intel_psr_init(struct drm_i915_private *dev_priv) · 7 unmodified lines
10861122 if (INTEL_GEN(dev_priv) < 9 || !dev_priv->vbt.psr.enable)
10871123 i915_modparams.enable_psr = 0;
10881124
1125+ /*
1126+ * If a PSR error happened and the driver is reloaded, the EDP_PSR_IIR
1127+ * will still keep the error set even after the reset done in the
1128+ * irq_preinstall and irq_uninstall hooks.
1129+ * And enabling in this situation cause the screen to freeze in the
1130+ * first time that PSR HW tries to activate so lets keep PSR disabled
1131+ * to avoid any rendering problems.
1132+ */
1133+ val = I915_READ(EDP_PSR_IIR);
1134+ val &= EDP_PSR_ERROR(edp_psr_shift(TRANSCODER_EDP));
1135+ if (val) {
1136+ DRM_DEBUG_KMS("PSR interruption error set\n");
1137+ dev_priv->psr.sink_not_reliable = true;
1138+ return;
1139+ }
1140+
10891141 /* Set link_standby x link_off defaults */
10901142 if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
10911143 /* HSW and BDW require workarounds that we don't implement. */
@@ -1123,6 +1175,7 @@ void intel_psr_short_pulse(struct intel_dp *intel_dp) · 31 unmodified lines
11231175 if ((val & DP_PSR_SINK_STATE_MASK) == DP_PSR_SINK_INTERNAL_ERROR) {
11241176 DRM_DEBUG_KMS("PSR sink internal error, disabling PSR\n");
11251177 intel_psr_disable_locked(intel_dp);
1178+ psr->sink_not_reliable = true;
11261179 }
11271180
11281181 if (drm_dp_dpcd_readb(&intel_dp->aux, DP_PSR_ERROR_STATUS, &val) != 1) {
@@ -1140,10 +1193,27 @@ void intel_psr_short_pulse(struct intel_dp *intel_dp) · 11 unmodified lines
11401193 if (val & ~errors)
11411194 DRM_ERROR("PSR_ERROR_STATUS unhandled errors %x\n",
11421195 val & ~errors);
1143− if (val & errors)
1196+ if (val & errors) {
11441197 intel_psr_disable_locked(intel_dp);
1198+ psr->sink_not_reliable = true;
1199+ }
11451200 /* clear status register */
11461201 drm_dp_dpcd_writeb(&intel_dp->aux, DP_PSR_ERROR_STATUS, val);
11471202 exit:
11481203 mutex_unlock(&psr->lock);
11491204 }
1205+
1206+bool intel_psr_enabled(struct intel_dp *intel_dp)
1207+{
1208+ struct drm_i915_private *dev_priv = dp_to_i915(intel_dp);
1209+ bool ret;
1210+
1211+ if (!CAN_PSR(dev_priv) || !intel_dp_is_edp(intel_dp))
1212+ return false;
1213+
1214+ mutex_lock(&dev_priv->psr.lock);
1215+ ret = (dev_priv->psr.dp == intel_dp && dev_priv->psr.enabled);
1216+ mutex_unlock(&dev_priv->psr.lock);
1217+
1218+ return ret;
1219+}
drivers/gpu/drm/i915/intel_ringbuffer.c+40−32
@@ -150,8 +150,7 @@ gen4_render_ring_flush(struct i915_request *rq, u32 mode) · 149 unmodified lines
150150 */
151151 if (mode & EMIT_INVALIDATE) {
152152 *cs++ = GFX_OP_PIPE_CONTROL(4) | PIPE_CONTROL_QW_WRITE;
153− *cs++ = i915_ggtt_offset(rq->engine->scratch) |
154− PIPE_CONTROL_GLOBAL_GTT;
153+ *cs++ = i915_scratch_offset(rq->i915) | PIPE_CONTROL_GLOBAL_GTT;
155154 *cs++ = 0;
156155 *cs++ = 0;
157156
@@ -159,8 +158,7 @@ gen4_render_ring_flush(struct i915_request *rq, u32 mode) · 1 unmodified line
159158 *cs++ = MI_FLUSH;
160159
161160 *cs++ = GFX_OP_PIPE_CONTROL(4) | PIPE_CONTROL_QW_WRITE;
162− *cs++ = i915_ggtt_offset(rq->engine->scratch) |
163− PIPE_CONTROL_GLOBAL_GTT;
161+ *cs++ = i915_scratch_offset(rq->i915) | PIPE_CONTROL_GLOBAL_GTT;
164162 *cs++ = 0;
165163 *cs++ = 0;
166164 }
@@ -212,8 +210,7 @@ gen4_render_ring_flush(struct i915_request *rq, u32 mode) · 45 unmodified lines
212210 static int
213211 intel_emit_post_sync_nonzero_flush(struct i915_request *rq)
214212 {
215− u32 scratch_addr =
216− i915_ggtt_offset(rq->engine->scratch) + 2 * CACHELINE_BYTES;
213+ u32 scratch_addr = i915_scratch_offset(rq->i915) + 2 * CACHELINE_BYTES;
217214 u32 *cs;
218215
219216 cs = intel_ring_begin(rq, 6);
@@ -246,8 +243,7 @@ intel_emit_post_sync_nonzero_flush(struct i915_request *rq) · 26 unmodified lines
246243 static int
247244 gen6_render_ring_flush(struct i915_request *rq, u32 mode)
248245 {
249− u32 scratch_addr =
250− i915_ggtt_offset(rq->engine->scratch) + 2 * CACHELINE_BYTES;
246+ u32 scratch_addr = i915_scratch_offset(rq->i915) + 2 * CACHELINE_BYTES;
251247 u32 *cs, flags = 0;
252248 int ret;
253249
@@ -316,8 +312,7 @@ gen7_render_ring_cs_stall_wa(struct i915_request *rq) · 62 unmodified lines
316312 static int
317313 gen7_render_ring_flush(struct i915_request *rq, u32 mode)
318314 {
319− u32 scratch_addr =
320− i915_ggtt_offset(rq->engine->scratch) + 2 * CACHELINE_BYTES;
315+ u32 scratch_addr = i915_scratch_offset(rq->i915) + 2 * CACHELINE_BYTES;
321316 u32 *cs, flags = 0;
322317
323318 /*
@@ -529,6 +524,13 @@ static int init_ring_common(struct intel_engine_cs *engine) · 205 unmodified lines
529524
530525 intel_engine_reset_breadcrumbs(engine);
531526
527+ if (HAS_LEGACY_SEMAPHORES(engine->i915)) {
528+ I915_WRITE(RING_SYNC_0(engine->mmio_base), 0);
529+ I915_WRITE(RING_SYNC_1(engine->mmio_base), 0);
530+ if (HAS_VEBOX(dev_priv))
531+ I915_WRITE(RING_SYNC_2(engine->mmio_base), 0);
532+ }
533+
532534 /* Enforce ordering by reading HEAD register back */
533535 I915_READ_HEAD(engine);
534536
@@ -546,10 +548,11 @@ static int init_ring_common(struct intel_engine_cs *engine) · 11 unmodified lines
546548 /* Check that the ring offsets point within the ring! */
547549 GEM_BUG_ON(!intel_ring_offset_valid(ring, ring->head));
548550 GEM_BUG_ON(!intel_ring_offset_valid(ring, ring->tail));
549−
550551 intel_ring_update_space(ring);
552+
553+ /* First wake the ring up to an empty/idle ring */
551554 I915_WRITE_HEAD(engine, ring->head);
552− I915_WRITE_TAIL(engine, ring->tail);
555+ I915_WRITE_TAIL(engine, ring->head);
553556 (void)I915_READ_TAIL(engine);
554557
555558 I915_WRITE_CTL(engine, RING_CTL_SIZE(ring->size) | RING_VALID);
@@ -574,6 +577,12 @@ static int init_ring_common(struct intel_engine_cs *engine) · 18 unmodified lines
574577 if (INTEL_GEN(dev_priv) > 2)
575578 I915_WRITE_MODE(engine, _MASKED_BIT_DISABLE(STOP_RING));
576579
580+ /* Now awake, let it get started */
581+ if (ring->tail != ring->head) {
582+ I915_WRITE_TAIL(engine, ring->tail);
583+ (void)I915_READ_TAIL(engine);
584+ }
585+
577586 /* Papering over lost _interrupts_ immediately following the restart */
578587 intel_engine_wakeup(engine);
579588 out:
@@ -642,7 +651,7 @@ static int intel_rcs_ctx_init(struct i915_request *rq) · 62 unmodified lines
642651 {
643652 int ret;
644653
645− ret = intel_ctx_workarounds_emit(rq);
654+ ret = intel_engine_emit_ctx_wa(rq);
646655 if (ret != 0)
647656 return ret;
648657
@@ -660,8 +669,6 @@ static int init_render_ring(struct intel_engine_cs *engine) · 11 unmodified lines
660669 if (ret)
661670 return ret;
662671
663− intel_whitelist_workarounds_apply(engine);
664−
665672 /* WaTimedSingleVertexDispatch:cl,bw,ctg,elk,ilk,snb */
666673 if (IS_GEN(dev_priv, 4, 6))
667674 I915_WRITE(MI_MODE, _MASKED_BIT_ENABLE(VS_TIMER_DISPATCH));
@@ -743,9 +750,18 @@ static void cancel_requests(struct intel_engine_cs *engine) · 75 unmodified lines
743750 /* Mark all submitted requests as skipped. */
744751 list_for_each_entry(request, &engine->timeline.requests, link) {
745752 GEM_BUG_ON(!request->global_seqno);
746− if (!i915_request_completed(request))
747− dma_fence_set_error(&request->fence, -EIO);
753+
754+ if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT,
755+ &request->fence.flags))
756+ continue;
757+
758+ dma_fence_set_error(&request->fence, -EIO);
748759 }
760+
761+ intel_write_status_page(engine,
762+ I915_GEM_HWS_INDEX,
763+ intel_engine_last_submit(engine));
764+
749765 /* Remaining _unready_ requests will be nop'ed when submitted */
750766
751767 spin_unlock_irqrestore(&engine->timeline.lock, flags);
@@ -973,7 +989,7 @@ i965_emit_bb_start(struct i915_request *rq, · 221 unmodified lines
973989 }
974990
975991 /* Just userspace ABI convention to limit the wa batch bo to a resonable size */
976−#define I830_BATCH_LIMIT (256*1024)
992+#define I830_BATCH_LIMIT SZ_256K
977993 #define I830_TLB_ENTRIES (2)
978994 #define I830_WA_SIZE max(I830_TLB_ENTRIES*4096, I830_BATCH_LIMIT)
979995 static int
@@ -981,7 +997,9 @@ i830_emit_bb_start(struct i915_request *rq, · 1 unmodified line
981997 u64 offset, u32 len,
982998 unsigned int dispatch_flags)
983999 {
984− u32 *cs, cs_offset = i915_ggtt_offset(rq->engine->scratch);
1000+ u32 *cs, cs_offset = i915_scratch_offset(rq->i915);
1001+
1002+ GEM_BUG_ON(rq->i915->gt.scratch->size < I830_WA_SIZE);
9851003
9861004 cs = intel_ring_begin(rq, 6);
9871005 if (IS_ERR(cs))
@@ -1438,7 +1456,6 @@ static int intel_init_ring_buffer(struct intel_engine_cs *engine) · 450 unmodified lines
14381456 {
14391457 struct i915_timeline *timeline;
14401458 struct intel_ring *ring;
1441− unsigned int size;
14421459 int err;
14431460
14441461 intel_engine_setup_common(engine);
@@ -1463,21 +1480,12 @@ static int intel_init_ring_buffer(struct intel_engine_cs *engine) · 18 unmodified lines
14631480 GEM_BUG_ON(engine->buffer);
14641481 engine->buffer = ring;
14651482
1466− size = PAGE_SIZE;
1467− if (HAS_BROKEN_CS_TLB(engine->i915))
1468− size = I830_WA_SIZE;
1469− err = intel_engine_create_scratch(engine, size);
1470− if (err)
1471− goto err_unpin;
1472−
14731483 err = intel_engine_init_common(engine);
14741484 if (err)
1475− goto err_scratch;
1485+ goto err_unpin;
14761486
14771487 return 0;
14781488
1479−err_scratch:
1480− intel_engine_cleanup_scratch(engine);
14811489 err_unpin:
14821490 intel_ring_unpin(ring);
14831491 err_ring:
@@ -1551,7 +1559,7 @@ static int flush_pd_dir(struct i915_request *rq) · 67 unmodified lines
15511559 /* Stall until the page table load is complete */
15521560 *cs++ = MI_STORE_REGISTER_MEM | MI_SRM_LRM_GLOBAL_GTT;
15531561 *cs++ = i915_mmio_reg_offset(RING_PP_DIR_BASE(engine));
1554− *cs++ = i915_ggtt_offset(engine->scratch);
1562+ *cs++ = i915_scratch_offset(rq->i915);
15551563 *cs++ = MI_NOOP;
15561564
15571565 intel_ring_advance(rq, cs);
@@ -1660,7 +1668,7 @@ static inline int mi_set_context(struct i915_request *rq, u32 flags) · 102 unmodified lines
16601668 /* Insert a delay before the next switch! */
16611669 *cs++ = MI_STORE_REGISTER_MEM | MI_SRM_LRM_GLOBAL_GTT;
16621670 *cs++ = i915_mmio_reg_offset(last_reg);
1663− *cs++ = i915_ggtt_offset(engine->scratch);
1671+ *cs++ = i915_scratch_offset(rq->i915);
16641672 *cs++ = MI_NOOP;
16651673 }
16661674 *cs++ = MI_ARB_ON_OFF | MI_ARB_ENABLE;
drivers/gpu/drm/i915/intel_ringbuffer.h+4−21
@@ -15,6 +15,7 @@ · 14 unmodified lines
1515 #include "i915_selftest.h"
1616 #include "i915_timeline.h"
1717 #include "intel_gpu_commands.h"
18+#include "intel_workarounds.h"
1819
1920 struct drm_printer;
2021 struct i915_sched_attr;
@@ -312,13 +313,6 @@ struct intel_engine_execlists { · 291 unmodified lines
312313 */
313314 struct rb_root_cached queue;
314315
315− /**
316− * @csb_read: control register for Context Switch buffer
317− *
318− * Note this register is always in mmio.
319− */
320− u32 __iomem *csb_read;
321−
322316 /**
323317 * @csb_write: control register for Context Switch buffer
324318 *
@@ -338,15 +332,6 @@ struct intel_engine_execlists { · 13 unmodified lines
338332 */
339333 u32 preempt_complete_status;
340334
341− /**
342− * @csb_write_reset: reset value for CSB write pointer
343− *
344− * As the CSB write pointer maybe either in HWSP or as a field
345− * inside an mmio register, we want to reprogram it slightly
346− * differently to avoid later confusion.
347− */
348− u32 csb_write_reset;
349−
350335 /**
351336 * @csb_head: context status buffer head
352337 */
@@ -451,7 +436,9 @@ struct intel_engine_cs { · 98 unmodified lines
451436
452437 struct intel_hw_status_page status_page;
453438 struct i915_ctx_workarounds wa_ctx;
454− struct i915_vma *scratch;
439+ struct i915_wa_list ctx_wa_list;
440+ struct i915_wa_list wa_list;
441+ struct i915_wa_list whitelist;
455442
456443 u32 irq_keep_mask; /* always keep these interrupts */
457444 u32 irq_enable_mask; /* bitmask to enable ring interrupt */
@@ -908,10 +895,6 @@ void intel_engine_setup_common(struct intel_engine_cs *engine); · 450 unmodified lines
908895 int intel_engine_init_common(struct intel_engine_cs *engine);
909896 void intel_engine_cleanup_common(struct intel_engine_cs *engine);
910897
911−int intel_engine_create_scratch(struct intel_engine_cs *engine,
912− unsigned int size);
913−void intel_engine_cleanup_scratch(struct intel_engine_cs *engine);
914−
915898 int intel_init_render_ring_buffer(struct intel_engine_cs *engine);
916899 int intel_init_bsd_ring_buffer(struct intel_engine_cs *engine);
917900 int intel_init_blt_ring_buffer(struct intel_engine_cs *engine);
drivers/gpu/drm/i915/intel_runtime_pm.c+3−1
@@ -76,6 +76,8 @@ intel_display_power_domain_str(enum intel_display_power_domain domain) · 75 unmodified lines
7676 return "TRANSCODER_C";
7777 case POWER_DOMAIN_TRANSCODER_EDP:
7878 return "TRANSCODER_EDP";
79+ case POWER_DOMAIN_TRANSCODER_EDP_VDSC:
80+ return "TRANSCODER_EDP_VDSC";
7981 case POWER_DOMAIN_TRANSCODER_DSI_A:
8082 return "TRANSCODER_DSI_A";
8183 case POWER_DOMAIN_TRANSCODER_DSI_C:
@@ -2028,9 +2030,9 @@ void intel_display_power_put(struct drm_i915_private *dev_priv, · 1946 unmodified lines
20282030 */
20292031 #define ICL_PW_2_POWER_DOMAINS ( \
20302032 ICL_PW_3_POWER_DOMAINS | \
2033+ BIT_ULL(POWER_DOMAIN_TRANSCODER_EDP_VDSC) | \
20312034 BIT_ULL(POWER_DOMAIN_INIT))
20322035 /*
2033− * - eDP/DSI VDSC
20342036 * - KVMR (HW control)
20352037 */
20362038 #define ICL_DISPLAY_DC_OFF_POWER_DOMAINS ( \
drivers/gpu/drm/i915/intel_sprite.c+82−56
@@ -373,14 +373,12 @@ skl_program_scaler(struct intel_plane *plane, · 372 unmodified lines
373373 #define BOFF(x) (((x) & 0xffff) << 16)
374374
375375 static void
376−icl_program_input_csc_coeff(const struct intel_crtc_state *crtc_state,
377− const struct intel_plane_state *plane_state)
376+icl_program_input_csc(struct intel_plane *plane,
377+ const struct intel_crtc_state *crtc_state,
378+ const struct intel_plane_state *plane_state)
378379 {
379− struct drm_i915_private *dev_priv =
380− to_i915(plane_state->base.plane->dev);
381− struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
382− enum pipe pipe = crtc->pipe;
383− struct intel_plane *plane = to_intel_plane(plane_state->base.plane);
380+ struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
381+ enum pipe pipe = plane->pipe;
384382 enum plane_id plane_id = plane->id;
385383
386384 static const u16 input_csc_matrix[][9] = {
@@ -508,28 +506,12 @@ skl_program_plane(struct intel_plane *plane, · 121 unmodified lines
508506
509507 spin_lock_irqsave(&dev_priv->uncore.lock, irqflags);
510508
511− if (INTEL_GEN(dev_priv) >= 10 || IS_GEMINILAKE(dev_priv))
512− I915_WRITE_FW(PLANE_COLOR_CTL(pipe, plane_id),
513− plane_state->color_ctl);
514−
515− if (fb->format->is_yuv && icl_is_hdr_plane(plane))
516− icl_program_input_csc_coeff(crtc_state, plane_state);
517−
518− I915_WRITE_FW(PLANE_KEYVAL(pipe, plane_id), key->min_value);
519− I915_WRITE_FW(PLANE_KEYMAX(pipe, plane_id), keymax);
520− I915_WRITE_FW(PLANE_KEYMSK(pipe, plane_id), keymsk);
521−
522− I915_WRITE_FW(PLANE_OFFSET(pipe, plane_id), (y << 16) | x);
523509 I915_WRITE_FW(PLANE_STRIDE(pipe, plane_id), stride);
510+ I915_WRITE_FW(PLANE_POS(pipe, plane_id), (crtc_y << 16) | crtc_x);
524511 I915_WRITE_FW(PLANE_SIZE(pipe, plane_id), (src_h << 16) | src_w);
525512 I915_WRITE_FW(PLANE_AUX_DIST(pipe, plane_id),
526513 (plane_state->color_plane[1].offset - surf_addr) | aux_stride);
527514
528− if (INTEL_GEN(dev_priv) < 11)
529− I915_WRITE_FW(PLANE_AUX_OFFSET(pipe, plane_id),
530− (plane_state->color_plane[1].y << 16) |
531− plane_state->color_plane[1].x);
532−
533515 if (icl_is_hdr_plane(plane)) {
534516 u32 cus_ctl = 0;
535517
@@ -551,15 +533,38 @@ skl_program_plane(struct intel_plane *plane, · 15 unmodified lines
551533 I915_WRITE_FW(PLANE_CUS_CTL(pipe, plane_id), cus_ctl);
552534 }
553535
554− if (!slave && plane_state->scaler_id >= 0)
555− skl_program_scaler(plane, crtc_state, plane_state);
536+ if (INTEL_GEN(dev_priv) >= 10 || IS_GEMINILAKE(dev_priv))
537+ I915_WRITE_FW(PLANE_COLOR_CTL(pipe, plane_id),
538+ plane_state->color_ctl);
556539
557− I915_WRITE_FW(PLANE_POS(pipe, plane_id), (crtc_y << 16) | crtc_x);
540+ if (fb->format->is_yuv && icl_is_hdr_plane(plane))
541+ icl_program_input_csc(plane, crtc_state, plane_state);
542+
543+ skl_write_plane_wm(plane, crtc_state);
558544
545+ I915_WRITE_FW(PLANE_KEYVAL(pipe, plane_id), key->min_value);
546+ I915_WRITE_FW(PLANE_KEYMSK(pipe, plane_id), keymsk);
547+ I915_WRITE_FW(PLANE_KEYMAX(pipe, plane_id), keymax);
548+
549+ I915_WRITE_FW(PLANE_OFFSET(pipe, plane_id), (y << 16) | x);
550+
551+ if (INTEL_GEN(dev_priv) < 11)
552+ I915_WRITE_FW(PLANE_AUX_OFFSET(pipe, plane_id),
553+ (plane_state->color_plane[1].y << 16) |
554+ plane_state->color_plane[1].x);
555+
556+ /*
557+ * The control register self-arms if the plane was previously
558+ * disabled. Try to make the plane enable atomic by writing
559+ * the control register just before the surface register.
560+ */
559561 I915_WRITE_FW(PLANE_CTL(pipe, plane_id), plane_ctl);
560562 I915_WRITE_FW(PLANE_SURF(pipe, plane_id),
561563 intel_plane_ggtt_offset(plane_state) + surf_addr);
562564
565+ if (!slave && plane_state->scaler_id >= 0)
566+ skl_program_scaler(plane, crtc_state, plane_state);
567+
563568 spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags);
564569 }
565570
@@ -589,7 +594,8 @@ icl_update_slave(struct intel_plane *plane, · 23 unmodified lines
589594 }
590595
591596 static void
592−skl_disable_plane(struct intel_plane *plane, struct intel_crtc *crtc)
597+skl_disable_plane(struct intel_plane *plane,
598+ const struct intel_crtc_state *crtc_state)
593599 {
594600 struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
595601 enum plane_id plane_id = plane->id;
@@ -598,6 +604,8 @@ skl_disable_plane(struct intel_plane *plane, struct intel_crtc *crtc) · 2 unmodified lines
598604
599605 spin_lock_irqsave(&dev_priv->uncore.lock, irqflags);
600606
607+ skl_write_plane_wm(plane, crtc_state);
608+
601609 I915_WRITE_FW(PLANE_CTL(pipe, plane_id), 0);
602610 I915_WRITE_FW(PLANE_SURF(pipe, plane_id), 0);
603611
@@ -819,35 +827,41 @@ vlv_update_plane(struct intel_plane *plane, · 215 unmodified lines
819827
820828 spin_lock_irqsave(&dev_priv->uncore.lock, irqflags);
821829
822− vlv_update_clrc(plane_state);
830+ I915_WRITE_FW(SPSTRIDE(pipe, plane_id),
831+ plane_state->color_plane[0].stride);
832+ I915_WRITE_FW(SPPOS(pipe, plane_id), (crtc_y << 16) | crtc_x);
833+ I915_WRITE_FW(SPSIZE(pipe, plane_id), (crtc_h << 16) | crtc_w);
834+ I915_WRITE_FW(SPCONSTALPHA(pipe, plane_id), 0);
823835
824836 if (IS_CHERRYVIEW(dev_priv) && pipe == PIPE_B)
825837 chv_update_csc(plane_state);
826838
827839 if (key->flags) {
828840 I915_WRITE_FW(SPKEYMINVAL(pipe, plane_id), key->min_value);
829− I915_WRITE_FW(SPKEYMAXVAL(pipe, plane_id), key->max_value);
830841 I915_WRITE_FW(SPKEYMSK(pipe, plane_id), key->channel_mask);
842+ I915_WRITE_FW(SPKEYMAXVAL(pipe, plane_id), key->max_value);
831843 }
832− I915_WRITE_FW(SPSTRIDE(pipe, plane_id),
833− plane_state->color_plane[0].stride);
834− I915_WRITE_FW(SPPOS(pipe, plane_id), (crtc_y << 16) | crtc_x);
835844
836− I915_WRITE_FW(SPTILEOFF(pipe, plane_id), (y << 16) | x);
837845 I915_WRITE_FW(SPLINOFF(pipe, plane_id), linear_offset);
846+ I915_WRITE_FW(SPTILEOFF(pipe, plane_id), (y << 16) | x);
838847
839− I915_WRITE_FW(SPCONSTALPHA(pipe, plane_id), 0);
840−
841− I915_WRITE_FW(SPSIZE(pipe, plane_id), (crtc_h << 16) | crtc_w);
848+ /*
849+ * The control register self-arms if the plane was previously
850+ * disabled. Try to make the plane enable atomic by writing
851+ * the control register just before the surface register.
852+ */
842853 I915_WRITE_FW(SPCNTR(pipe, plane_id), sprctl);
843854 I915_WRITE_FW(SPSURF(pipe, plane_id),
844855 intel_plane_ggtt_offset(plane_state) + sprsurf_offset);
845856
857+ vlv_update_clrc(plane_state);
858+
846859 spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags);
847860 }
848861
849862 static void
850−vlv_disable_plane(struct intel_plane *plane, struct intel_crtc *crtc)
863+vlv_disable_plane(struct intel_plane *plane,
864+ const struct intel_crtc_state *crtc_state)
851865 {
852866 struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
853867 enum pipe pipe = plane->pipe;
@@ -980,27 +994,32 @@ ivb_update_plane(struct intel_plane *plane, · 126 unmodified lines
980994
981995 spin_lock_irqsave(&dev_priv->uncore.lock, irqflags);
982996
997+ I915_WRITE_FW(SPRSTRIDE(pipe), plane_state->color_plane[0].stride);
998+ I915_WRITE_FW(SPRPOS(pipe), (crtc_y << 16) | crtc_x);
999+ I915_WRITE_FW(SPRSIZE(pipe), (crtc_h << 16) | crtc_w);
1000+ if (IS_IVYBRIDGE(dev_priv))
1001+ I915_WRITE_FW(SPRSCALE(pipe), sprscale);
1002+
9831003 if (key->flags) {
9841004 I915_WRITE_FW(SPRKEYVAL(pipe), key->min_value);
985− I915_WRITE_FW(SPRKEYMAX(pipe), key->max_value);
9861005 I915_WRITE_FW(SPRKEYMSK(pipe), key->channel_mask);
1006+ I915_WRITE_FW(SPRKEYMAX(pipe), key->max_value);
9871007 }
9881008
989− I915_WRITE_FW(SPRSTRIDE(pipe), plane_state->color_plane[0].stride);
990− I915_WRITE_FW(SPRPOS(pipe), (crtc_y << 16) | crtc_x);
991−
9921009 /* HSW consolidates SPRTILEOFF and SPRLINOFF into a single SPROFFSET
9931010 * register */
9941011 if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) {
9951012 I915_WRITE_FW(SPROFFSET(pipe), (y << 16) | x);
9961013 } else {
997− I915_WRITE_FW(SPRTILEOFF(pipe), (y << 16) | x);
9981014 I915_WRITE_FW(SPRLINOFF(pipe), linear_offset);
1015+ I915_WRITE_FW(SPRTILEOFF(pipe), (y << 16) | x);
9991016 }
10001017
1001− I915_WRITE_FW(SPRSIZE(pipe), (crtc_h << 16) | crtc_w);
1002− if (IS_IVYBRIDGE(dev_priv))
1003− I915_WRITE_FW(SPRSCALE(pipe), sprscale);
1018+ /*
1019+ * The control register self-arms if the plane was previously
1020+ * disabled. Try to make the plane enable atomic by writing
1021+ * the control register just before the surface register.
1022+ */
10041023 I915_WRITE_FW(SPRCTL(pipe), sprctl);
10051024 I915_WRITE_FW(SPRSURF(pipe),
10061025 intel_plane_ggtt_offset(plane_state) + sprsurf_offset);
@@ -1009,7 +1028,8 @@ ivb_update_plane(struct intel_plane *plane, · 2 unmodified lines
10091028 }
10101029
10111030 static void
1012−ivb_disable_plane(struct intel_plane *plane, struct intel_crtc *crtc)
1031+ivb_disable_plane(struct intel_plane *plane,
1032+ const struct intel_crtc_state *crtc_state)
10131033 {
10141034 struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
10151035 enum pipe pipe = plane->pipe;
@@ -1018,7 +1038,7 @@ ivb_disable_plane(struct intel_plane *plane, struct intel_crtc *crtc) · 2 unmodified lines
10181038 spin_lock_irqsave(&dev_priv->uncore.lock, irqflags);
10191039
10201040 I915_WRITE_FW(SPRCTL(pipe), 0);
1021− /* Can't leave the scaler enabled... */
1041+ /* Disable the scaler */
10221042 if (IS_IVYBRIDGE(dev_priv))
10231043 I915_WRITE_FW(SPRSCALE(pipe), 0);
10241044 I915_WRITE_FW(SPRSURF(pipe), 0);
@@ -1148,20 +1168,25 @@ g4x_update_plane(struct intel_plane *plane, · 123 unmodified lines
11481168
11491169 spin_lock_irqsave(&dev_priv->uncore.lock, irqflags);
11501170
1171+ I915_WRITE_FW(DVSSTRIDE(pipe), plane_state->color_plane[0].stride);
1172+ I915_WRITE_FW(DVSPOS(pipe), (crtc_y << 16) | crtc_x);
1173+ I915_WRITE_FW(DVSSIZE(pipe), (crtc_h << 16) | crtc_w);
1174+ I915_WRITE_FW(DVSSCALE(pipe), dvsscale);
1175+
11511176 if (key->flags) {
11521177 I915_WRITE_FW(DVSKEYVAL(pipe), key->min_value);
1153− I915_WRITE_FW(DVSKEYMAX(pipe), key->max_value);
11541178 I915_WRITE_FW(DVSKEYMSK(pipe), key->channel_mask);
1179+ I915_WRITE_FW(DVSKEYMAX(pipe), key->max_value);
11551180 }
11561181
1157− I915_WRITE_FW(DVSSTRIDE(pipe), plane_state->color_plane[0].stride);
1158− I915_WRITE_FW(DVSPOS(pipe), (crtc_y << 16) | crtc_x);
1159−
1160− I915_WRITE_FW(DVSTILEOFF(pipe), (y << 16) | x);
11611182 I915_WRITE_FW(DVSLINOFF(pipe), linear_offset);
1183+ I915_WRITE_FW(DVSTILEOFF(pipe), (y << 16) | x);
11621184
1163− I915_WRITE_FW(DVSSIZE(pipe), (crtc_h << 16) | crtc_w);
1164− I915_WRITE_FW(DVSSCALE(pipe), dvsscale);
1185+ /*
1186+ * The control register self-arms if the plane was previously
1187+ * disabled. Try to make the plane enable atomic by writing
1188+ * the control register just before the surface register.
1189+ */
11651190 I915_WRITE_FW(DVSCNTR(pipe), dvscntr);
11661191 I915_WRITE_FW(DVSSURF(pipe),
11671192 intel_plane_ggtt_offset(plane_state) + dvssurf_offset);
@@ -1170,7 +1195,8 @@ g4x_update_plane(struct intel_plane *plane, · 2 unmodified lines
11701195 }
11711196
11721197 static void
1173−g4x_disable_plane(struct intel_plane *plane, struct intel_crtc *crtc)
1198+g4x_disable_plane(struct intel_plane *plane,
1199+ const struct intel_crtc_state *crtc_state)
11741200 {
11751201 struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
11761202 enum pipe pipe = plane->pipe;
drivers/gpu/drm/i915/intel_vdsc.c+1088−0
@@ -0,0 +1,1088 @@
1+// SPDX-License-Identifier: MIT
2+/*
3+ * Copyright © 2018 Intel Corporation
4+ *
5+ * Author: Gaurav K Singh <gaurav.k.singh@intel.com>
6+ * Manasi Navare <manasi.d.navare@intel.com>
7+ */
8+
9+#include <drm/drmP.h>
10+#include <drm/i915_drm.h>
11+#include "i915_drv.h"
12+#include "intel_drv.h"
13+
14+enum ROW_INDEX_BPP {
15+ ROW_INDEX_6BPP = 0,
16+ ROW_INDEX_8BPP,
17+ ROW_INDEX_10BPP,
18+ ROW_INDEX_12BPP,
19+ ROW_INDEX_15BPP,
20+ MAX_ROW_INDEX
21+};
22+
23+enum COLUMN_INDEX_BPC {
24+ COLUMN_INDEX_8BPC = 0,
25+ COLUMN_INDEX_10BPC,
26+ COLUMN_INDEX_12BPC,
27+ COLUMN_INDEX_14BPC,
28+ COLUMN_INDEX_16BPC,
29+ MAX_COLUMN_INDEX
30+};
31+
32+#define DSC_SUPPORTED_VERSION_MIN 1
33+
34+/* From DSC_v1.11 spec, rc_parameter_Set syntax element typically constant */
35+static u16 rc_buf_thresh[] = {
36+ 896, 1792, 2688, 3584, 4480, 5376, 6272, 6720, 7168, 7616,
37+ 7744, 7872, 8000, 8064
38+};
39+
40+struct rc_parameters {
41+ u16 initial_xmit_delay;
42+ u8 first_line_bpg_offset;
43+ u16 initial_offset;
44+ u8 flatness_min_qp;
45+ u8 flatness_max_qp;
46+ u8 rc_quant_incr_limit0;
47+ u8 rc_quant_incr_limit1;
48+ struct drm_dsc_rc_range_parameters rc_range_params[DSC_NUM_BUF_RANGES];
49+};
50+
51+/*
52+ * Selected Rate Control Related Parameter Recommended Values
53+ * from DSC_v1.11 spec & C Model release: DSC_model_20161212
54+ */
55+static struct rc_parameters rc_params[][MAX_COLUMN_INDEX] = {
56+{
57+ /* 6BPP/8BPC */
58+ { 768, 15, 6144, 3, 13, 11, 11, {
59+ { 0, 4, 0 }, { 1, 6, -2 }, { 3, 8, -2 }, { 4, 8, -4 },
60+ { 5, 9, -6 }, { 5, 9, -6 }, { 6, 9, -6 }, { 6, 10, -8 },
61+ { 7, 11, -8 }, { 8, 12, -10 }, { 9, 12, -10 }, { 10, 12, -12 },
62+ { 10, 12, -12 }, { 11, 12, -12 }, { 13, 14, -12 }
63+ }
64+ },
65+ /* 6BPP/10BPC */
66+ { 768, 15, 6144, 7, 17, 15, 15, {
67+ { 0, 8, 0 }, { 3, 10, -2 }, { 7, 12, -2 }, { 8, 12, -4 },
68+ { 9, 13, -6 }, { 9, 13, -6 }, { 10, 13, -6 }, { 10, 14, -8 },
69+ { 11, 15, -8 }, { 12, 16, -10 }, { 13, 16, -10 },
70+ { 14, 16, -12 }, { 14, 16, -12 }, { 15, 16, -12 },
71+ { 17, 18, -12 }
72+ }
73+ },
74+ /* 6BPP/12BPC */
75+ { 768, 15, 6144, 11, 21, 19, 19, {
76+ { 0, 12, 0 }, { 5, 14, -2 }, { 11, 16, -2 }, { 12, 16, -4 },
77+ { 13, 17, -6 }, { 13, 17, -6 }, { 14, 17, -6 }, { 14, 18, -8 },
78+ { 15, 19, -8 }, { 16, 20, -10 }, { 17, 20, -10 },
79+ { 18, 20, -12 }, { 18, 20, -12 }, { 19, 20, -12 },
80+ { 21, 22, -12 }
81+ }
82+ },
83+ /* 6BPP/14BPC */
84+ { 768, 15, 6144, 15, 25, 23, 27, {
85+ { 0, 16, 0 }, { 7, 18, -2 }, { 15, 20, -2 }, { 16, 20, -4 },
86+ { 17, 21, -6 }, { 17, 21, -6 }, { 18, 21, -6 }, { 18, 22, -8 },
87+ { 19, 23, -8 }, { 20, 24, -10 }, { 21, 24, -10 },
88+ { 22, 24, -12 }, { 22, 24, -12 }, { 23, 24, -12 },
89+ { 25, 26, -12 }
90+ }
91+ },
92+ /* 6BPP/16BPC */
93+ { 768, 15, 6144, 19, 29, 27, 27, {
94+ { 0, 20, 0 }, { 9, 22, -2 }, { 19, 24, -2 }, { 20, 24, -4 },
95+ { 21, 25, -6 }, { 21, 25, -6 }, { 22, 25, -6 }, { 22, 26, -8 },
96+ { 23, 27, -8 }, { 24, 28, -10 }, { 25, 28, -10 },
97+ { 26, 28, -12 }, { 26, 28, -12 }, { 27, 28, -12 },
98+ { 29, 30, -12 }
99+ }
100+ },
101+},
102+{
103+ /* 8BPP/8BPC */
104+ { 512, 12, 6144, 3, 12, 11, 11, {
105+ { 0, 4, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 },
106+ { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
107+ { 3, 9, -8 }, { 3, 10, -10 }, { 5, 11, -10 }, { 5, 12, -12 },
108+ { 5, 13, -12 }, { 7, 13, -12 }, { 13, 15, -12 }
109+ }
110+ },
111+ /* 8BPP/10BPC */
112+ { 512, 12, 6144, 7, 16, 15, 15, {
113+ { 0, 4, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 5, 10, -2 },
114+ { 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
115+ { 7, 13, -8 }, { 7, 14, -10 }, { 9, 15, -10 }, { 9, 16, -12 },
116+ { 9, 17, -12 }, { 11, 17, -12 }, { 17, 19, -12 }
117+ }
118+ },
119+ /* 8BPP/12BPC */
120+ { 512, 12, 6144, 11, 20, 19, 19, {
121+ { 0, 12, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 9, 14, -2 },
122+ { 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
123+ { 11, 17, -8 }, { 11, 18, -10 }, { 13, 19, -10 },
124+ { 13, 20, -12 }, { 13, 21, -12 }, { 15, 21, -12 },
125+ { 21, 23, -12 }
126+ }
127+ },
128+ /* 8BPP/14BPC */
129+ { 512, 12, 6144, 15, 24, 23, 23, {
130+ { 0, 12, 0 }, { 5, 13, 0 }, { 11, 15, 0 }, { 12, 17, -2 },
131+ { 15, 19, -4 }, { 15, 19, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
132+ { 15, 21, -8 }, { 15, 22, -10 }, { 17, 22, -10 },
133+ { 17, 23, -12 }, { 17, 23, -12 }, { 21, 24, -12 },
134+ { 24, 25, -12 }
135+ }
136+ },
137+ /* 8BPP/16BPC */
138+ { 512, 12, 6144, 19, 28, 27, 27, {
139+ { 0, 12, 2 }, { 6, 14, 0 }, { 13, 17, 0 }, { 15, 20, -2 },
140+ { 19, 23, -4 }, { 19, 23, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
141+ { 19, 25, -8 }, { 19, 26, -10 }, { 21, 26, -10 },
142+ { 21, 27, -12 }, { 21, 27, -12 }, { 25, 28, -12 },
143+ { 28, 29, -12 }
144+ }
145+ },
146+},
147+{
148+ /* 10BPP/8BPC */
149+ { 410, 15, 5632, 3, 12, 11, 11, {
150+ { 0, 3, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 2, 6, -2 },
151+ { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
152+ { 3, 9, -8 }, { 3, 9, -10 }, { 5, 10, -10 }, { 5, 10, -10 },
153+ { 5, 11, -12 }, { 7, 11, -12 }, { 11, 12, -12 }
154+ }
155+ },
156+ /* 10BPP/10BPC */
157+ { 410, 15, 5632, 7, 16, 15, 15, {
158+ { 0, 7, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 6, 10, -2 },
159+ { 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
160+ { 7, 13, -8 }, { 7, 13, -10 }, { 9, 14, -10 }, { 9, 14, -10 },
161+ { 9, 15, -12 }, { 11, 15, -12 }, { 15, 16, -12 }
162+ }
163+ },
164+ /* 10BPP/12BPC */
165+ { 410, 15, 5632, 11, 20, 19, 19, {
166+ { 0, 11, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 10, 14, -2 },
167+ { 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
168+ { 11, 17, -8 }, { 11, 17, -10 }, { 13, 18, -10 },
169+ { 13, 18, -10 }, { 13, 19, -12 }, { 15, 19, -12 },
170+ { 19, 20, -12 }
171+ }
172+ },
173+ /* 10BPP/14BPC */
174+ { 410, 15, 5632, 15, 24, 23, 23, {
175+ { 0, 11, 2 }, { 5, 13, 0 }, { 11, 15, 0 }, { 13, 18, -2 },
176+ { 15, 19, -4 }, { 15, 19, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
177+ { 15, 21, -8 }, { 15, 21, -10 }, { 17, 22, -10 },
178+ { 17, 22, -10 }, { 17, 23, -12 }, { 19, 23, -12 },
179+ { 23, 24, -12 }
180+ }
181+ },
182+ /* 10BPP/16BPC */
183+ { 410, 15, 5632, 19, 28, 27, 27, {
184+ { 0, 11, 2 }, { 6, 14, 0 }, { 13, 17, 0 }, { 16, 20, -2 },
185+ { 19, 23, -4 }, { 19, 23, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
186+ { 19, 25, -8 }, { 19, 25, -10 }, { 21, 26, -10 },
187+ { 21, 26, -10 }, { 21, 27, -12 }, { 23, 27, -12 },
188+ { 27, 28, -12 }
189+ }
190+ },
191+},
192+{
193+ /* 12BPP/8BPC */
194+ { 341, 15, 2048, 3, 12, 11, 11, {
195+ { 0, 2, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 },
196+ { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
197+ { 3, 9, -8 }, { 3, 10, -10 }, { 5, 11, -10 },
198+ { 5, 12, -12 }, { 5, 13, -12 }, { 7, 13, -12 }, { 13, 15, -12 }
199+ }
200+ },
201+ /* 12BPP/10BPC */
202+ { 341, 15, 2048, 7, 16, 15, 15, {
203+ { 0, 2, 2 }, { 2, 5, 0 }, { 3, 7, 0 }, { 4, 8, -2 },
204+ { 6, 9, -4 }, { 7, 10, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
205+ { 7, 13, -8 }, { 7, 14, -10 }, { 9, 15, -10 }, { 9, 16, -12 },
206+ { 9, 17, -12 }, { 11, 17, -12 }, { 17, 19, -12 }
207+ }
208+ },
209+ /* 12BPP/12BPC */
210+ { 341, 15, 2048, 11, 20, 19, 19, {
211+ { 0, 6, 2 }, { 4, 9, 0 }, { 7, 11, 0 }, { 8, 12, -2 },
212+ { 10, 13, -4 }, { 11, 14, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
213+ { 11, 17, -8 }, { 11, 18, -10 }, { 13, 19, -10 },
214+ { 13, 20, -12 }, { 13, 21, -12 }, { 15, 21, -12 },
215+ { 21, 23, -12 }
216+ }
217+ },
218+ /* 12BPP/14BPC */
219+ { 341, 15, 2048, 15, 24, 23, 23, {
220+ { 0, 6, 2 }, { 7, 10, 0 }, { 9, 13, 0 }, { 11, 16, -2 },
221+ { 14, 17, -4 }, { 15, 18, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
222+ { 15, 20, -8 }, { 15, 21, -10 }, { 17, 21, -10 },
223+ { 17, 21, -12 }, { 17, 21, -12 }, { 19, 22, -12 },
224+ { 22, 23, -12 }
225+ }
226+ },
227+ /* 12BPP/16BPC */
228+ { 341, 15, 2048, 19, 28, 27, 27, {
229+ { 0, 6, 2 }, { 6, 11, 0 }, { 11, 15, 0 }, { 14, 18, -2 },
230+ { 18, 21, -4 }, { 19, 22, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
231+ { 19, 24, -8 }, { 19, 25, -10 }, { 21, 25, -10 },
232+ { 21, 25, -12 }, { 21, 25, -12 }, { 23, 26, -12 },
233+ { 26, 27, -12 }
234+ }
235+ },
236+},
237+{
238+ /* 15BPP/8BPC */
239+ { 273, 15, 2048, 3, 12, 11, 11, {
240+ { 0, 0, 10 }, { 0, 1, 8 }, { 0, 1, 6 }, { 0, 2, 4 },
241+ { 1, 2, 2 }, { 1, 3, 0 }, { 1, 3, -2 }, { 2, 4, -4 },
242+ { 2, 5, -6 }, { 3, 5, -8 }, { 4, 6, -10 }, { 4, 7, -10 },
243+ { 5, 7, -12 }, { 7, 8, -12 }, { 8, 9, -12 }
244+ }
245+ },
246+ /* 15BPP/10BPC */
247+ { 273, 15, 2048, 7, 16, 15, 15, {
248+ { 0, 2, 10 }, { 2, 5, 8 }, { 3, 5, 6 }, { 4, 6, 4 },
249+ { 5, 6, 2 }, { 5, 7, 0 }, { 5, 7, -2 }, { 6, 8, -4 },
250+ { 6, 9, -6 }, { 7, 9, -8 }, { 8, 10, -10 }, { 8, 11, -10 },
251+ { 9, 11, -12 }, { 11, 12, -12 }, { 12, 13, -12 }
252+ }
253+ },
254+ /* 15BPP/12BPC */
255+ { 273, 15, 2048, 11, 20, 19, 19, {
256+ { 0, 4, 10 }, { 2, 7, 8 }, { 4, 9, 6 }, { 6, 11, 4 },
257+ { 9, 11, 2 }, { 9, 11, 0 }, { 9, 12, -2 }, { 10, 12, -4 },
258+ { 11, 13, -6 }, { 11, 13, -8 }, { 12, 14, -10 },
259+ { 13, 15, -10 }, { 13, 15, -12 }, { 15, 16, -12 },
260+ { 16, 17, -12 }
261+ }
262+ },
263+ /* 15BPP/14BPC */
264+ { 273, 15, 2048, 15, 24, 23, 23, {
265+ { 0, 4, 10 }, { 3, 8, 8 }, { 6, 11, 6 }, { 9, 14, 4 },
266+ { 13, 15, 2 }, { 13, 15, 0 }, { 13, 16, -2 }, { 14, 16, -4 },
267+ { 15, 17, -6 }, { 15, 17, -8 }, { 16, 18, -10 },
268+ { 17, 19, -10 }, { 17, 19, -12 }, { 19, 20, -12 },
269+ { 20, 21, -12 }
270+ }
271+ },
272+ /* 15BPP/16BPC */
273+ { 273, 15, 2048, 19, 28, 27, 27, {
274+ { 0, 4, 10 }, { 4, 9, 8 }, { 8, 13, 6 }, { 12, 17, 4 },
275+ { 17, 19, 2 }, { 17, 20, 0 }, { 17, 20, -2 }, { 18, 20, -4 },
276+ { 19, 21, -6 }, { 19, 21, -8 }, { 20, 22, -10 },
277+ { 21, 23, -10 }, { 21, 23, -12 }, { 23, 24, -12 },
278+ { 24, 25, -12 }
279+ }
280+ }
281+}
282+
283+};
284+
285+static int get_row_index_for_rc_params(u16 compressed_bpp)
286+{
287+ switch (compressed_bpp) {
288+ case 6:
289+ return ROW_INDEX_6BPP;
290+ case 8:
291+ return ROW_INDEX_8BPP;
292+ case 10:
293+ return ROW_INDEX_10BPP;
294+ case 12:
295+ return ROW_INDEX_12BPP;
296+ case 15:
297+ return ROW_INDEX_15BPP;
298+ default:
299+ return -EINVAL;
300+ }
301+}
302+
303+static int get_column_index_for_rc_params(u8 bits_per_component)
304+{
305+ switch (bits_per_component) {
306+ case 8:
307+ return COLUMN_INDEX_8BPC;
308+ case 10:
309+ return COLUMN_INDEX_10BPC;
310+ case 12:
311+ return COLUMN_INDEX_12BPC;
312+ case 14:
313+ return COLUMN_INDEX_14BPC;
314+ case 16:
315+ return COLUMN_INDEX_16BPC;
316+ default:
317+ return -EINVAL;
318+ }
319+}
320+
321+static int intel_compute_rc_parameters(struct drm_dsc_config *vdsc_cfg)
322+{
323+ unsigned long groups_per_line = 0;
324+ unsigned long groups_total = 0;
325+ unsigned long num_extra_mux_bits = 0;
326+ unsigned long slice_bits = 0;
327+ unsigned long hrd_delay = 0;
328+ unsigned long final_scale = 0;
329+ unsigned long rbs_min = 0;
330+
331+ /* Number of groups used to code each line of a slice */
332+ groups_per_line = DIV_ROUND_UP(vdsc_cfg->slice_width,
333+ DSC_RC_PIXELS_PER_GROUP);
334+
335+ /* chunksize in Bytes */
336+ vdsc_cfg->slice_chunk_size = DIV_ROUND_UP(vdsc_cfg->slice_width *
337+ vdsc_cfg->bits_per_pixel,
338+ (8 * 16));
339+
340+ if (vdsc_cfg->convert_rgb)
341+ num_extra_mux_bits = 3 * (vdsc_cfg->mux_word_size +
342+ (4 * vdsc_cfg->bits_per_component + 4)
343+ - 2);
344+ else
345+ num_extra_mux_bits = 3 * vdsc_cfg->mux_word_size +
346+ (4 * vdsc_cfg->bits_per_component + 4) +
347+ 2 * (4 * vdsc_cfg->bits_per_component) - 2;
348+ /* Number of bits in one Slice */
349+ slice_bits = 8 * vdsc_cfg->slice_chunk_size * vdsc_cfg->slice_height;
350+
351+ while ((num_extra_mux_bits > 0) &&
352+ ((slice_bits - num_extra_mux_bits) % vdsc_cfg->mux_word_size))
353+ num_extra_mux_bits--;
354+
355+ if (groups_per_line < vdsc_cfg->initial_scale_value - 8)
356+ vdsc_cfg->initial_scale_value = groups_per_line + 8;
357+
358+ /* scale_decrement_interval calculation according to DSC spec 1.11 */
359+ if (vdsc_cfg->initial_scale_value > 8)
360+ vdsc_cfg->scale_decrement_interval = groups_per_line /
361+ (vdsc_cfg->initial_scale_value - 8);
362+ else
363+ vdsc_cfg->scale_decrement_interval = DSC_SCALE_DECREMENT_INTERVAL_MAX;
364+
365+ vdsc_cfg->final_offset = vdsc_cfg->rc_model_size -
366+ (vdsc_cfg->initial_xmit_delay *
367+ vdsc_cfg->bits_per_pixel + 8) / 16 + num_extra_mux_bits;
368+
369+ if (vdsc_cfg->final_offset >= vdsc_cfg->rc_model_size) {
370+ DRM_DEBUG_KMS("FinalOfs < RcModelSze for this InitialXmitDelay\n");
371+ return -ERANGE;
372+ }
373+
374+ final_scale = (vdsc_cfg->rc_model_size * 8) /
375+ (vdsc_cfg->rc_model_size - vdsc_cfg->final_offset);
376+ if (vdsc_cfg->slice_height > 1)
377+ /*
378+ * NflBpgOffset is 16 bit value with 11 fractional bits
379+ * hence we multiply by 2^11 for preserving the
380+ * fractional part
381+ */
382+ vdsc_cfg->nfl_bpg_offset = DIV_ROUND_UP((vdsc_cfg->first_line_bpg_offset << 11),
383+ (vdsc_cfg->slice_height - 1));
384+ else
385+ vdsc_cfg->nfl_bpg_offset = 0;
386+
387+ /* 2^16 - 1 */
388+ if (vdsc_cfg->nfl_bpg_offset > 65535) {
389+ DRM_DEBUG_KMS("NflBpgOffset is too large for this slice height\n");
390+ return -ERANGE;
391+ }
392+
393+ /* Number of groups used to code the entire slice */
394+ groups_total = groups_per_line * vdsc_cfg->slice_height;
395+
396+ /* slice_bpg_offset is 16 bit value with 11 fractional bits */
397+ vdsc_cfg->slice_bpg_offset = DIV_ROUND_UP(((vdsc_cfg->rc_model_size -
398+ vdsc_cfg->initial_offset +
399+ num_extra_mux_bits) << 11),
400+ groups_total);
401+
402+ if (final_scale > 9) {
403+ /*
404+ * ScaleIncrementInterval =
405+ * finaloffset/((NflBpgOffset + SliceBpgOffset)*8(finalscale - 1.125))
406+ * as (NflBpgOffset + SliceBpgOffset) has 11 bit fractional value,
407+ * we need divide by 2^11 from pstDscCfg values
408+ */
409+ vdsc_cfg->scale_increment_interval =
410+ (vdsc_cfg->final_offset * (1 << 11)) /
411+ ((vdsc_cfg->nfl_bpg_offset +
412+ vdsc_cfg->slice_bpg_offset) *
413+ (final_scale - 9));
414+ } else {
415+ /*
416+ * If finalScaleValue is less than or equal to 9, a value of 0 should
417+ * be used to disable the scale increment at the end of the slice
418+ */
419+ vdsc_cfg->scale_increment_interval = 0;
420+ }
421+
422+ if (vdsc_cfg->scale_increment_interval > 65535) {
423+ DRM_DEBUG_KMS("ScaleIncrementInterval is large for slice height\n");
424+ return -ERANGE;
425+ }
426+
427+ /*
428+ * DSC spec mentions that bits_per_pixel specifies the target
429+ * bits/pixel (bpp) rate that is used by the encoder,
430+ * in steps of 1/16 of a bit per pixel
431+ */
432+ rbs_min = vdsc_cfg->rc_model_size - vdsc_cfg->initial_offset +
433+ DIV_ROUND_UP(vdsc_cfg->initial_xmit_delay *
434+ vdsc_cfg->bits_per_pixel, 16) +
435+ groups_per_line * vdsc_cfg->first_line_bpg_offset;
436+
437+ hrd_delay = DIV_ROUND_UP((rbs_min * 16), vdsc_cfg->bits_per_pixel);
438+ vdsc_cfg->rc_bits = (hrd_delay * vdsc_cfg->bits_per_pixel) / 16;
439+ vdsc_cfg->initial_dec_delay = hrd_delay - vdsc_cfg->initial_xmit_delay;
440+
441+ return 0;
442+}
443+
444+int intel_dp_compute_dsc_params(struct intel_dp *intel_dp,
445+ struct intel_crtc_state *pipe_config)
446+{
447+ struct drm_dsc_config *vdsc_cfg = &pipe_config->dp_dsc_cfg;
448+ u16 compressed_bpp = pipe_config->dsc_params.compressed_bpp;
449+ u8 i = 0;
450+ int row_index = 0;
451+ int column_index = 0;
452+ u8 line_buf_depth = 0;
453+
454+ vdsc_cfg->pic_width = pipe_config->base.adjusted_mode.crtc_hdisplay;
455+ vdsc_cfg->pic_height = pipe_config->base.adjusted_mode.crtc_vdisplay;
456+ vdsc_cfg->slice_width = DIV_ROUND_UP(vdsc_cfg->pic_width,
457+ pipe_config->dsc_params.slice_count);
458+ /*
459+ * Slice Height of 8 works for all currently available panels. So start
460+ * with that if pic_height is an integral multiple of 8.
461+ * Eventually add logic to try multiple slice heights.
462+ */
463+ if (vdsc_cfg->pic_height % 8 == 0)
464+ vdsc_cfg->slice_height = 8;
465+ else if (vdsc_cfg->pic_height % 4 == 0)
466+ vdsc_cfg->slice_height = 4;
467+ else
468+ vdsc_cfg->slice_height = 2;
469+
470+ /* Values filled from DSC Sink DPCD */
471+ vdsc_cfg->dsc_version_major =
472+ (intel_dp->dsc_dpcd[DP_DSC_REV - DP_DSC_SUPPORT] &
473+ DP_DSC_MAJOR_MASK) >> DP_DSC_MAJOR_SHIFT;
474+ vdsc_cfg->dsc_version_minor =
475+ min(DSC_SUPPORTED_VERSION_MIN,
476+ (intel_dp->dsc_dpcd[DP_DSC_REV - DP_DSC_SUPPORT] &
477+ DP_DSC_MINOR_MASK) >> DP_DSC_MINOR_SHIFT);
478+
479+ vdsc_cfg->convert_rgb = intel_dp->dsc_dpcd[DP_DSC_DEC_COLOR_FORMAT_CAP - DP_DSC_SUPPORT] &
480+ DP_DSC_RGB;
481+
482+ line_buf_depth = drm_dp_dsc_sink_line_buf_depth(intel_dp->dsc_dpcd);
483+ if (!line_buf_depth) {
484+ DRM_DEBUG_KMS("DSC Sink Line Buffer Depth invalid\n");
485+ return -EINVAL;
486+ }
487+ if (vdsc_cfg->dsc_version_minor == 2)
488+ vdsc_cfg->line_buf_depth = (line_buf_depth == DSC_1_2_MAX_LINEBUF_DEPTH_BITS) ?
489+ DSC_1_2_MAX_LINEBUF_DEPTH_VAL : line_buf_depth;
490+ else
491+ vdsc_cfg->line_buf_depth = (line_buf_depth > DSC_1_1_MAX_LINEBUF_DEPTH_BITS) ?
492+ DSC_1_1_MAX_LINEBUF_DEPTH_BITS : line_buf_depth;
493+
494+ /* Gen 11 does not support YCbCr */
495+ vdsc_cfg->enable422 = false;
496+ /* Gen 11 does not support VBR */
497+ vdsc_cfg->vbr_enable = false;
498+ vdsc_cfg->block_pred_enable =
499+ intel_dp->dsc_dpcd[DP_DSC_BLK_PREDICTION_SUPPORT - DP_DSC_SUPPORT] &
500+ DP_DSC_BLK_PREDICTION_IS_SUPPORTED;
501+
502+ /* Gen 11 only supports integral values of bpp */
503+ vdsc_cfg->bits_per_pixel = compressed_bpp << 4;
504+ vdsc_cfg->bits_per_component = pipe_config->pipe_bpp / 3;
505+
506+ for (i = 0; i < DSC_NUM_BUF_RANGES - 1; i++) {
507+ /*
508+ * six 0s are appended to the lsb of each threshold value
509+ * internally in h/w.
510+ * Only 8 bits are allowed for programming RcBufThreshold
511+ */
512+ vdsc_cfg->rc_buf_thresh[i] = rc_buf_thresh[i] >> 6;
513+ }
514+
515+ /*
516+ * For 6bpp, RC Buffer threshold 12 and 13 need a different value
517+ * as per C Model
518+ */
519+ if (compressed_bpp == 6) {
520+ vdsc_cfg->rc_buf_thresh[12] = 0x7C;
521+ vdsc_cfg->rc_buf_thresh[13] = 0x7D;
522+ }
523+
524+ row_index = get_row_index_for_rc_params(compressed_bpp);
525+ column_index =
526+ get_column_index_for_rc_params(vdsc_cfg->bits_per_component);
527+
528+ if (row_index < 0 || column_index < 0)
529+ return -EINVAL;
530+
531+ vdsc_cfg->first_line_bpg_offset =
532+ rc_params[row_index][column_index].first_line_bpg_offset;
533+ vdsc_cfg->initial_xmit_delay =
534+ rc_params[row_index][column_index].initial_xmit_delay;
535+ vdsc_cfg->initial_offset =
536+ rc_params[row_index][column_index].initial_offset;
537+ vdsc_cfg->flatness_min_qp =
538+ rc_params[row_index][column_index].flatness_min_qp;
539+ vdsc_cfg->flatness_max_qp =
540+ rc_params[row_index][column_index].flatness_max_qp;
541+ vdsc_cfg->rc_quant_incr_limit0 =
542+ rc_params[row_index][column_index].rc_quant_incr_limit0;
543+ vdsc_cfg->rc_quant_incr_limit1 =
544+ rc_params[row_index][column_index].rc_quant_incr_limit1;
545+
546+ for (i = 0; i < DSC_NUM_BUF_RANGES; i++) {
547+ vdsc_cfg->rc_range_params[i].range_min_qp =
548+ rc_params[row_index][column_index].rc_range_params[i].range_min_qp;
549+ vdsc_cfg->rc_range_params[i].range_max_qp =
550+ rc_params[row_index][column_index].rc_range_params[i].range_max_qp;
551+ /*
552+ * Range BPG Offset uses 2's complement and is only a 6 bits. So
553+ * mask it to get only 6 bits.
554+ */
555+ vdsc_cfg->rc_range_params[i].range_bpg_offset =
556+ rc_params[row_index][column_index].rc_range_params[i].range_bpg_offset &
557+ DSC_RANGE_BPG_OFFSET_MASK;
558+ }
559+
560+ /*
561+ * BitsPerComponent value determines mux_word_size:
562+ * When BitsPerComponent is 12bpc, muxWordSize will be equal to 64 bits
563+ * When BitsPerComponent is 8 or 10bpc, muxWordSize will be equal to
564+ * 48 bits
565+ */
566+ if (vdsc_cfg->bits_per_component == 8 ||
567+ vdsc_cfg->bits_per_component == 10)
568+ vdsc_cfg->mux_word_size = DSC_MUX_WORD_SIZE_8_10_BPC;
569+ else if (vdsc_cfg->bits_per_component == 12)
570+ vdsc_cfg->mux_word_size = DSC_MUX_WORD_SIZE_12_BPC;
571+
572+ /* RC_MODEL_SIZE is a constant across all configurations */
573+ vdsc_cfg->rc_model_size = DSC_RC_MODEL_SIZE_CONST;
574+ /* InitialScaleValue is a 6 bit value with 3 fractional bits (U3.3) */
575+ vdsc_cfg->initial_scale_value = (vdsc_cfg->rc_model_size << 3) /
576+ (vdsc_cfg->rc_model_size - vdsc_cfg->initial_offset);
577+
578+ return intel_compute_rc_parameters(vdsc_cfg);
579+}
580+
581+enum intel_display_power_domain
582+intel_dsc_power_domain(const struct intel_crtc_state *crtc_state)
583+{
584+ enum transcoder cpu_transcoder = crtc_state->cpu_transcoder;
585+
586+ /*
587+ * On ICL VDSC/joining for eDP transcoder uses a separate power well PW2
588+ * This requires POWER_DOMAIN_TRANSCODER_EDP_VDSC power domain.
589+ * For any other transcoder, VDSC/joining uses the power well associated
590+ * with the pipe/transcoder in use. Hence another reference on the
591+ * transcoder power domain will suffice.
592+ */
593+ if (cpu_transcoder == TRANSCODER_EDP)
594+ return POWER_DOMAIN_TRANSCODER_EDP_VDSC;
595+ else
596+ return POWER_DOMAIN_TRANSCODER(cpu_transcoder);
597+}
598+
599+static void intel_configure_pps_for_dsc_encoder(struct intel_encoder *encoder,
600+ const struct intel_crtc_state *crtc_state)
601+{
602+ struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
603+ struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
604+ const struct drm_dsc_config *vdsc_cfg = &crtc_state->dp_dsc_cfg;
605+ enum pipe pipe = crtc->pipe;
606+ enum transcoder cpu_transcoder = crtc_state->cpu_transcoder;
607+ u32 pps_val = 0;
608+ u32 rc_buf_thresh_dword[4];
609+ u32 rc_range_params_dword[8];
610+ u8 num_vdsc_instances = (crtc_state->dsc_params.dsc_split) ? 2 : 1;
611+ int i = 0;
612+
613+ /* Populate PICTURE_PARAMETER_SET_0 registers */
614+ pps_val = DSC_VER_MAJ | vdsc_cfg->dsc_version_minor <<
615+ DSC_VER_MIN_SHIFT |
616+ vdsc_cfg->bits_per_component << DSC_BPC_SHIFT |
617+ vdsc_cfg->line_buf_depth << DSC_LINE_BUF_DEPTH_SHIFT;
618+ if (vdsc_cfg->block_pred_enable)
619+ pps_val |= DSC_BLOCK_PREDICTION;
620+ if (vdsc_cfg->convert_rgb)
621+ pps_val |= DSC_COLOR_SPACE_CONVERSION;
622+ if (vdsc_cfg->enable422)
623+ pps_val |= DSC_422_ENABLE;
624+ if (vdsc_cfg->vbr_enable)
625+ pps_val |= DSC_VBR_ENABLE;
626+ DRM_INFO("PPS0 = 0x%08x\n", pps_val);
627+ if (cpu_transcoder == TRANSCODER_EDP) {
628+ I915_WRITE(DSCA_PICTURE_PARAMETER_SET_0, pps_val);
629+ /*
630+ * If 2 VDSC instances are needed, configure PPS for second
631+ * VDSC
632+ */
633+ if (crtc_state->dsc_params.dsc_split)
634+ I915_WRITE(DSCC_PICTURE_PARAMETER_SET_0, pps_val);
635+ } else {
636+ I915_WRITE(ICL_DSC0_PICTURE_PARAMETER_SET_0(pipe), pps_val);
637+ if (crtc_state->dsc_params.dsc_split)
638+ I915_WRITE(ICL_DSC1_PICTURE_PARAMETER_SET_0(pipe),
639+ pps_val);
640+ }
641+
642+ /* Populate PICTURE_PARAMETER_SET_1 registers */
643+ pps_val = 0;
644+ pps_val |= DSC_BPP(vdsc_cfg->bits_per_pixel);
645+ DRM_INFO("PPS1 = 0x%08x\n", pps_val);
646+ if (cpu_transcoder == TRANSCODER_EDP) {
647+ I915_WRITE(DSCA_PICTURE_PARAMETER_SET_1, pps_val);
648+ /*
649+ * If 2 VDSC instances are needed, configure PPS for second
650+ * VDSC
651+ */
652+ if (crtc_state->dsc_params.dsc_split)
653+ I915_WRITE(DSCC_PICTURE_PARAMETER_SET_1, pps_val);
654+ } else {
655+ I915_WRITE(ICL_DSC0_PICTURE_PARAMETER_SET_1(pipe), pps_val);
656+ if (crtc_state->dsc_params.dsc_split)
657+ I915_WRITE(ICL_DSC1_PICTURE_PARAMETER_SET_1(pipe),
658+ pps_val);
659+ }
660+
661+ /* Populate PICTURE_PARAMETER_SET_2 registers */
662+ pps_val = 0;
663+ pps_val |= DSC_PIC_HEIGHT(vdsc_cfg->pic_height) |
664+ DSC_PIC_WIDTH(vdsc_cfg->pic_width / num_vdsc_instances);
665+ DRM_INFO("PPS2 = 0x%08x\n", pps_val);
666+ if (encoder->type == INTEL_OUTPUT_EDP) {
667+ I915_WRITE(DSCA_PICTURE_PARAMETER_SET_2, pps_val);
668+ /*
669+ * If 2 VDSC instances are needed, configure PPS for second
670+ * VDSC
671+ */
672+ if (crtc_state->dsc_params.dsc_split)
673+ I915_WRITE(DSCC_PICTURE_PARAMETER_SET_2, pps_val);
674+ } else {
675+ I915_WRITE(ICL_DSC0_PICTURE_PARAMETER_SET_2(pipe), pps_val);
676+ if (crtc_state->dsc_params.dsc_split)
677+ I915_WRITE(ICL_DSC1_PICTURE_PARAMETER_SET_2(pipe),
678+ pps_val);
679+ }
680+
681+ /* Populate PICTURE_PARAMETER_SET_3 registers */
682+ pps_val = 0;
683+ pps_val |= DSC_SLICE_HEIGHT(vdsc_cfg->slice_height) |
684+ DSC_SLICE_WIDTH(vdsc_cfg->slice_width);
685+ DRM_INFO("PPS3 = 0x%08x\n", pps_val);
686+ if (cpu_transcoder == TRANSCODER_EDP) {
687+ I915_WRITE(DSCA_PICTURE_PARAMETER_SET_3, pps_val);
688+ /*
689+ * If 2 VDSC instances are needed, configure PPS for second
690+ * VDSC
691+ */
692+ if (crtc_state->dsc_params.dsc_split)
693+ I915_WRITE(DSCC_PICTURE_PARAMETER_SET_3, pps_val);
694+ } else {
695+ I915_WRITE(ICL_DSC0_PICTURE_PARAMETER_SET_3(pipe), pps_val);
696+ if (crtc_state->dsc_params.dsc_split)
697+ I915_WRITE(ICL_DSC1_PICTURE_PARAMETER_SET_3(pipe),
698+ pps_val);
699+ }
700+
701+ /* Populate PICTURE_PARAMETER_SET_4 registers */
702+ pps_val = 0;
703+ pps_val |= DSC_INITIAL_XMIT_DELAY(vdsc_cfg->initial_xmit_delay) |
704+ DSC_INITIAL_DEC_DELAY(vdsc_cfg->initial_dec_delay);
705+ DRM_INFO("PPS4 = 0x%08x\n", pps_val);
706+ if (cpu_transcoder == TRANSCODER_EDP) {
707+ I915_WRITE(DSCA_PICTURE_PARAMETER_SET_4, pps_val);
708+ /*
709+ * If 2 VDSC instances are needed, configure PPS for second
710+ * VDSC
711+ */
712+ if (crtc_state->dsc_params.dsc_split)
713+ I915_WRITE(DSCC_PICTURE_PARAMETER_SET_4, pps_val);
714+ } else {
715+ I915_WRITE(ICL_DSC0_PICTURE_PARAMETER_SET_4(pipe), pps_val);
716+ if (crtc_state->dsc_params.dsc_split)
717+ I915_WRITE(ICL_DSC1_PICTURE_PARAMETER_SET_4(pipe),
718+ pps_val);
719+ }
720+
721+ /* Populate PICTURE_PARAMETER_SET_5 registers */
722+ pps_val = 0;
723+ pps_val |= DSC_SCALE_INC_INT(vdsc_cfg->scale_increment_interval) |
724+ DSC_SCALE_DEC_INT(vdsc_cfg->scale_decrement_interval);
725+ DRM_INFO("PPS5 = 0x%08x\n", pps_val);
726+ if (cpu_transcoder == TRANSCODER_EDP) {
727+ I915_WRITE(DSCA_PICTURE_PARAMETER_SET_5, pps_val);
728+ /*
729+ * If 2 VDSC instances are needed, configure PPS for second
730+ * VDSC
731+ */
732+ if (crtc_state->dsc_params.dsc_split)
733+ I915_WRITE(DSCC_PICTURE_PARAMETER_SET_5, pps_val);
734+ } else {
735+ I915_WRITE(ICL_DSC0_PICTURE_PARAMETER_SET_5(pipe), pps_val);
736+ if (crtc_state->dsc_params.dsc_split)
737+ I915_WRITE(ICL_DSC1_PICTURE_PARAMETER_SET_5(pipe),
738+ pps_val);
739+ }
740+
741+ /* Populate PICTURE_PARAMETER_SET_6 registers */
742+ pps_val = 0;
743+ pps_val |= DSC_INITIAL_SCALE_VALUE(vdsc_cfg->initial_scale_value) |
744+ DSC_FIRST_LINE_BPG_OFFSET(vdsc_cfg->first_line_bpg_offset) |
745+ DSC_FLATNESS_MIN_QP(vdsc_cfg->flatness_min_qp) |
746+ DSC_FLATNESS_MAX_QP(vdsc_cfg->flatness_max_qp);
747+ DRM_INFO("PPS6 = 0x%08x\n", pps_val);
748+ if (cpu_transcoder == TRANSCODER_EDP) {
749+ I915_WRITE(DSCA_PICTURE_PARAMETER_SET_6, pps_val);
750+ /*
751+ * If 2 VDSC instances are needed, configure PPS for second
752+ * VDSC
753+ */
754+ if (crtc_state->dsc_params.dsc_split)
755+ I915_WRITE(DSCC_PICTURE_PARAMETER_SET_6, pps_val);
756+ } else {
757+ I915_WRITE(ICL_DSC0_PICTURE_PARAMETER_SET_6(pipe), pps_val);
758+ if (crtc_state->dsc_params.dsc_split)
759+ I915_WRITE(ICL_DSC1_PICTURE_PARAMETER_SET_6(pipe),
760+ pps_val);
761+ }
762+
763+ /* Populate PICTURE_PARAMETER_SET_7 registers */
764+ pps_val = 0;
765+ pps_val |= DSC_SLICE_BPG_OFFSET(vdsc_cfg->slice_bpg_offset) |
766+ DSC_NFL_BPG_OFFSET(vdsc_cfg->nfl_bpg_offset);
767+ DRM_INFO("PPS7 = 0x%08x\n", pps_val);
768+ if (cpu_transcoder == TRANSCODER_EDP) {
769+ I915_WRITE(DSCA_PICTURE_PARAMETER_SET_7, pps_val);
770+ /*
771+ * If 2 VDSC instances are needed, configure PPS for second
772+ * VDSC
773+ */
774+ if (crtc_state->dsc_params.dsc_split)
775+ I915_WRITE(DSCC_PICTURE_PARAMETER_SET_7, pps_val);
776+ } else {
777+ I915_WRITE(ICL_DSC0_PICTURE_PARAMETER_SET_7(pipe), pps_val);
778+ if (crtc_state->dsc_params.dsc_split)
779+ I915_WRITE(ICL_DSC1_PICTURE_PARAMETER_SET_7(pipe),
780+ pps_val);
781+ }
782+
783+ /* Populate PICTURE_PARAMETER_SET_8 registers */
784+ pps_val = 0;
785+ pps_val |= DSC_FINAL_OFFSET(vdsc_cfg->final_offset) |
786+ DSC_INITIAL_OFFSET(vdsc_cfg->initial_offset);
787+ DRM_INFO("PPS8 = 0x%08x\n", pps_val);
788+ if (cpu_transcoder == TRANSCODER_EDP) {
789+ I915_WRITE(DSCA_PICTURE_PARAMETER_SET_8, pps_val);
790+ /*
791+ * If 2 VDSC instances are needed, configure PPS for second
792+ * VDSC
793+ */
794+ if (crtc_state->dsc_params.dsc_split)
795+ I915_WRITE(DSCC_PICTURE_PARAMETER_SET_8, pps_val);
796+ } else {
797+ I915_WRITE(ICL_DSC0_PICTURE_PARAMETER_SET_8(pipe), pps_val);
798+ if (crtc_state->dsc_params.dsc_split)
799+ I915_WRITE(ICL_DSC1_PICTURE_PARAMETER_SET_8(pipe),
800+ pps_val);
801+ }
802+
803+ /* Populate PICTURE_PARAMETER_SET_9 registers */
804+ pps_val = 0;
805+ pps_val |= DSC_RC_MODEL_SIZE(DSC_RC_MODEL_SIZE_CONST) |
806+ DSC_RC_EDGE_FACTOR(DSC_RC_EDGE_FACTOR_CONST);
807+ DRM_INFO("PPS9 = 0x%08x\n", pps_val);
808+ if (cpu_transcoder == TRANSCODER_EDP) {
809+ I915_WRITE(DSCA_PICTURE_PARAMETER_SET_9, pps_val);
810+ /*
811+ * If 2 VDSC instances are needed, configure PPS for second
812+ * VDSC
813+ */
814+ if (crtc_state->dsc_params.dsc_split)
815+ I915_WRITE(DSCC_PICTURE_PARAMETER_SET_9, pps_val);
816+ } else {
817+ I915_WRITE(ICL_DSC0_PICTURE_PARAMETER_SET_9(pipe), pps_val);
818+ if (crtc_state->dsc_params.dsc_split)
819+ I915_WRITE(ICL_DSC1_PICTURE_PARAMETER_SET_9(pipe),
820+ pps_val);
821+ }
822+
823+ /* Populate PICTURE_PARAMETER_SET_10 registers */
824+ pps_val = 0;
825+ pps_val |= DSC_RC_QUANT_INC_LIMIT0(vdsc_cfg->rc_quant_incr_limit0) |
826+ DSC_RC_QUANT_INC_LIMIT1(vdsc_cfg->rc_quant_incr_limit1) |
827+ DSC_RC_TARGET_OFF_HIGH(DSC_RC_TGT_OFFSET_HI_CONST) |
828+ DSC_RC_TARGET_OFF_LOW(DSC_RC_TGT_OFFSET_LO_CONST);
829+ DRM_INFO("PPS10 = 0x%08x\n", pps_val);
830+ if (cpu_transcoder == TRANSCODER_EDP) {
831+ I915_WRITE(DSCA_PICTURE_PARAMETER_SET_10, pps_val);
832+ /*
833+ * If 2 VDSC instances are needed, configure PPS for second
834+ * VDSC
835+ */
836+ if (crtc_state->dsc_params.dsc_split)
837+ I915_WRITE(DSCC_PICTURE_PARAMETER_SET_10, pps_val);
838+ } else {
839+ I915_WRITE(ICL_DSC0_PICTURE_PARAMETER_SET_10(pipe), pps_val);
840+ if (crtc_state->dsc_params.dsc_split)
841+ I915_WRITE(ICL_DSC1_PICTURE_PARAMETER_SET_10(pipe),
842+ pps_val);
843+ }
844+
845+ /* Populate Picture parameter set 16 */
846+ pps_val = 0;
847+ pps_val |= DSC_SLICE_CHUNK_SIZE(vdsc_cfg->slice_chunk_size) |
848+ DSC_SLICE_PER_LINE((vdsc_cfg->pic_width / num_vdsc_instances) /
849+ vdsc_cfg->slice_width) |
850+ DSC_SLICE_ROW_PER_FRAME(vdsc_cfg->pic_height /
851+ vdsc_cfg->slice_height);
852+ DRM_INFO("PPS16 = 0x%08x\n", pps_val);
853+ if (cpu_transcoder == TRANSCODER_EDP) {
854+ I915_WRITE(DSCA_PICTURE_PARAMETER_SET_16, pps_val);
855+ /*
856+ * If 2 VDSC instances are needed, configure PPS for second
857+ * VDSC
858+ */
859+ if (crtc_state->dsc_params.dsc_split)
860+ I915_WRITE(DSCC_PICTURE_PARAMETER_SET_16, pps_val);
861+ } else {
862+ I915_WRITE(ICL_DSC0_PICTURE_PARAMETER_SET_16(pipe), pps_val);
863+ if (crtc_state->dsc_params.dsc_split)
864+ I915_WRITE(ICL_DSC1_PICTURE_PARAMETER_SET_16(pipe),
865+ pps_val);
866+ }
867+
868+ /* Populate the RC_BUF_THRESH registers */
869+ memset(rc_buf_thresh_dword, 0, sizeof(rc_buf_thresh_dword));
870+ for (i = 0; i < DSC_NUM_BUF_RANGES - 1; i++) {
871+ rc_buf_thresh_dword[i / 4] |=
872+ (u32)(vdsc_cfg->rc_buf_thresh[i] <<
873+ BITS_PER_BYTE * (i % 4));
874+ DRM_INFO(" RC_BUF_THRESH%d = 0x%08x\n", i,
875+ rc_buf_thresh_dword[i / 4]);
876+ }
877+ if (cpu_transcoder == TRANSCODER_EDP) {
878+ I915_WRITE(DSCA_RC_BUF_THRESH_0, rc_buf_thresh_dword[0]);
879+ I915_WRITE(DSCA_RC_BUF_THRESH_0_UDW, rc_buf_thresh_dword[1]);
880+ I915_WRITE(DSCA_RC_BUF_THRESH_1, rc_buf_thresh_dword[2]);
881+ I915_WRITE(DSCA_RC_BUF_THRESH_1_UDW, rc_buf_thresh_dword[3]);
882+ if (crtc_state->dsc_params.dsc_split) {
883+ I915_WRITE(DSCC_RC_BUF_THRESH_0,
884+ rc_buf_thresh_dword[0]);
885+ I915_WRITE(DSCC_RC_BUF_THRESH_0_UDW,
886+ rc_buf_thresh_dword[1]);
887+ I915_WRITE(DSCC_RC_BUF_THRESH_1,
888+ rc_buf_thresh_dword[2]);
889+ I915_WRITE(DSCC_RC_BUF_THRESH_1_UDW,
890+ rc_buf_thresh_dword[3]);
891+ }
892+ } else {
893+ I915_WRITE(ICL_DSC0_RC_BUF_THRESH_0(pipe),
894+ rc_buf_thresh_dword[0]);
895+ I915_WRITE(ICL_DSC0_RC_BUF_THRESH_0_UDW(pipe),
896+ rc_buf_thresh_dword[1]);
897+ I915_WRITE(ICL_DSC0_RC_BUF_THRESH_1(pipe),
898+ rc_buf_thresh_dword[2]);
899+ I915_WRITE(ICL_DSC0_RC_BUF_THRESH_1_UDW(pipe),
900+ rc_buf_thresh_dword[3]);
901+ if (crtc_state->dsc_params.dsc_split) {
902+ I915_WRITE(ICL_DSC1_RC_BUF_THRESH_0(pipe),
903+ rc_buf_thresh_dword[0]);
904+ I915_WRITE(ICL_DSC1_RC_BUF_THRESH_0_UDW(pipe),
905+ rc_buf_thresh_dword[1]);
906+ I915_WRITE(ICL_DSC1_RC_BUF_THRESH_1(pipe),
907+ rc_buf_thresh_dword[2]);
908+ I915_WRITE(ICL_DSC1_RC_BUF_THRESH_1_UDW(pipe),
909+ rc_buf_thresh_dword[3]);
910+ }
911+ }
912+
913+ /* Populate the RC_RANGE_PARAMETERS registers */
914+ memset(rc_range_params_dword, 0, sizeof(rc_range_params_dword));
915+ for (i = 0; i < DSC_NUM_BUF_RANGES; i++) {
916+ rc_range_params_dword[i / 2] |=
917+ (u32)(((vdsc_cfg->rc_range_params[i].range_bpg_offset <<
918+ RC_BPG_OFFSET_SHIFT) |
919+ (vdsc_cfg->rc_range_params[i].range_max_qp <<
920+ RC_MAX_QP_SHIFT) |
921+ (vdsc_cfg->rc_range_params[i].range_min_qp <<
922+ RC_MIN_QP_SHIFT)) << 16 * (i % 2));
923+ DRM_INFO(" RC_RANGE_PARAM_%d = 0x%08x\n", i,
924+ rc_range_params_dword[i / 2]);
925+ }
926+ if (cpu_transcoder == TRANSCODER_EDP) {
927+ I915_WRITE(DSCA_RC_RANGE_PARAMETERS_0,
928+ rc_range_params_dword[0]);
929+ I915_WRITE(DSCA_RC_RANGE_PARAMETERS_0_UDW,
930+ rc_range_params_dword[1]);
931+ I915_WRITE(DSCA_RC_RANGE_PARAMETERS_1,
932+ rc_range_params_dword[2]);
933+ I915_WRITE(DSCA_RC_RANGE_PARAMETERS_1_UDW,
934+ rc_range_params_dword[3]);
935+ I915_WRITE(DSCA_RC_RANGE_PARAMETERS_2,
936+ rc_range_params_dword[4]);
937+ I915_WRITE(DSCA_RC_RANGE_PARAMETERS_2_UDW,
938+ rc_range_params_dword[5]);
939+ I915_WRITE(DSCA_RC_RANGE_PARAMETERS_3,
940+ rc_range_params_dword[6]);
941+ I915_WRITE(DSCA_RC_RANGE_PARAMETERS_3_UDW,
942+ rc_range_params_dword[7]);
943+ if (crtc_state->dsc_params.dsc_split) {
944+ I915_WRITE(DSCC_RC_RANGE_PARAMETERS_0,
945+ rc_range_params_dword[0]);
946+ I915_WRITE(DSCC_RC_RANGE_PARAMETERS_0_UDW,
947+ rc_range_params_dword[1]);
948+ I915_WRITE(DSCC_RC_RANGE_PARAMETERS_1,
949+ rc_range_params_dword[2]);
950+ I915_WRITE(DSCC_RC_RANGE_PARAMETERS_1_UDW,
951+ rc_range_params_dword[3]);
952+ I915_WRITE(DSCC_RC_RANGE_PARAMETERS_2,
953+ rc_range_params_dword[4]);
954+ I915_WRITE(DSCC_RC_RANGE_PARAMETERS_2_UDW,
955+ rc_range_params_dword[5]);
956+ I915_WRITE(DSCC_RC_RANGE_PARAMETERS_3,
957+ rc_range_params_dword[6]);
958+ I915_WRITE(DSCC_RC_RANGE_PARAMETERS_3_UDW,
959+ rc_range_params_dword[7]);
960+ }
961+ } else {
962+ I915_WRITE(ICL_DSC0_RC_RANGE_PARAMETERS_0(pipe),
963+ rc_range_params_dword[0]);
964+ I915_WRITE(ICL_DSC0_RC_RANGE_PARAMETERS_0_UDW(pipe),
965+ rc_range_params_dword[1]);
966+ I915_WRITE(ICL_DSC0_RC_RANGE_PARAMETERS_1(pipe),
967+ rc_range_params_dword[2]);
968+ I915_WRITE(ICL_DSC0_RC_RANGE_PARAMETERS_1_UDW(pipe),
969+ rc_range_params_dword[3]);
970+ I915_WRITE(ICL_DSC0_RC_RANGE_PARAMETERS_2(pipe),
971+ rc_range_params_dword[4]);
972+ I915_WRITE(ICL_DSC0_RC_RANGE_PARAMETERS_2_UDW(pipe),
973+ rc_range_params_dword[5]);
974+ I915_WRITE(ICL_DSC0_RC_RANGE_PARAMETERS_3(pipe),
975+ rc_range_params_dword[6]);
976+ I915_WRITE(ICL_DSC0_RC_RANGE_PARAMETERS_3_UDW(pipe),
977+ rc_range_params_dword[7]);
978+ if (crtc_state->dsc_params.dsc_split) {
979+ I915_WRITE(ICL_DSC1_RC_RANGE_PARAMETERS_0(pipe),
980+ rc_range_params_dword[0]);
981+ I915_WRITE(ICL_DSC1_RC_RANGE_PARAMETERS_0_UDW(pipe),
982+ rc_range_params_dword[1]);
983+ I915_WRITE(ICL_DSC1_RC_RANGE_PARAMETERS_1(pipe),
984+ rc_range_params_dword[2]);
985+ I915_WRITE(ICL_DSC1_RC_RANGE_PARAMETERS_1_UDW(pipe),
986+ rc_range_params_dword[3]);
987+ I915_WRITE(ICL_DSC1_RC_RANGE_PARAMETERS_2(pipe),
988+ rc_range_params_dword[4]);
989+ I915_WRITE(ICL_DSC1_RC_RANGE_PARAMETERS_2_UDW(pipe),
990+ rc_range_params_dword[5]);
991+ I915_WRITE(ICL_DSC1_RC_RANGE_PARAMETERS_3(pipe),
992+ rc_range_params_dword[6]);
993+ I915_WRITE(ICL_DSC1_RC_RANGE_PARAMETERS_3_UDW(pipe),
994+ rc_range_params_dword[7]);
995+ }
996+ }
997+}
998+
999+static void intel_dp_write_dsc_pps_sdp(struct intel_encoder *encoder,
1000+ const struct intel_crtc_state *crtc_state)
1001+{
1002+ struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base);
1003+ struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
1004+ const struct drm_dsc_config *vdsc_cfg = &crtc_state->dp_dsc_cfg;
1005+ struct drm_dsc_pps_infoframe dp_dsc_pps_sdp;
1006+
1007+ /* Prepare DP SDP PPS header as per DP 1.4 spec, Table 2-123 */
1008+ drm_dsc_dp_pps_header_init(&dp_dsc_pps_sdp);
1009+
1010+ /* Fill the PPS payload bytes as per DSC spec 1.2 Table 4-1 */
1011+ drm_dsc_pps_infoframe_pack(&dp_dsc_pps_sdp, vdsc_cfg);
1012+
1013+ intel_dig_port->write_infoframe(encoder, crtc_state,
1014+ DP_SDP_PPS, &dp_dsc_pps_sdp,
1015+ sizeof(dp_dsc_pps_sdp));
1016+}
1017+
1018+void intel_dsc_enable(struct intel_encoder *encoder,
1019+ const struct intel_crtc_state *crtc_state)
1020+{
1021+ struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
1022+ struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
1023+ enum pipe pipe = crtc->pipe;
1024+ i915_reg_t dss_ctl1_reg, dss_ctl2_reg;
1025+ u32 dss_ctl1_val = 0;
1026+ u32 dss_ctl2_val = 0;
1027+
1028+ if (!crtc_state->dsc_params.compression_enable)
1029+ return;
1030+
1031+ /* Enable Power wells for VDSC/joining */
1032+ intel_display_power_get(dev_priv,
1033+ intel_dsc_power_domain(crtc_state));
1034+
1035+ intel_configure_pps_for_dsc_encoder(encoder, crtc_state);
1036+
1037+ intel_dp_write_dsc_pps_sdp(encoder, crtc_state);
1038+
1039+ if (crtc_state->cpu_transcoder == TRANSCODER_EDP) {
1040+ dss_ctl1_reg = DSS_CTL1;
1041+ dss_ctl2_reg = DSS_CTL2;
1042+ } else {
1043+ dss_ctl1_reg = ICL_PIPE_DSS_CTL1(pipe);
1044+ dss_ctl2_reg = ICL_PIPE_DSS_CTL2(pipe);
1045+ }
1046+ dss_ctl2_val |= LEFT_BRANCH_VDSC_ENABLE;
1047+ if (crtc_state->dsc_params.dsc_split) {
1048+ dss_ctl2_val |= RIGHT_BRANCH_VDSC_ENABLE;
1049+ dss_ctl1_val |= JOINER_ENABLE;
1050+ }
1051+ I915_WRITE(dss_ctl1_reg, dss_ctl1_val);
1052+ I915_WRITE(dss_ctl2_reg, dss_ctl2_val);
1053+}
1054+
1055+void intel_dsc_disable(const struct intel_crtc_state *old_crtc_state)
1056+{
1057+ struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->base.crtc);
1058+ struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
1059+ enum pipe pipe = crtc->pipe;
1060+ i915_reg_t dss_ctl1_reg, dss_ctl2_reg;
1061+ u32 dss_ctl1_val = 0, dss_ctl2_val = 0;
1062+
1063+ if (!old_crtc_state->dsc_params.compression_enable)
1064+ return;
1065+
1066+ if (old_crtc_state->cpu_transcoder == TRANSCODER_EDP) {
1067+ dss_ctl1_reg = DSS_CTL1;
1068+ dss_ctl2_reg = DSS_CTL2;
1069+ } else {
1070+ dss_ctl1_reg = ICL_PIPE_DSS_CTL1(pipe);
1071+ dss_ctl2_reg = ICL_PIPE_DSS_CTL2(pipe);
1072+ }
1073+ dss_ctl1_val = I915_READ(dss_ctl1_reg);
1074+ if (dss_ctl1_val & JOINER_ENABLE)
1075+ dss_ctl1_val &= ~JOINER_ENABLE;
1076+ I915_WRITE(dss_ctl1_reg, dss_ctl1_val);
1077+
1078+ dss_ctl2_val = I915_READ(dss_ctl2_reg);
1079+ if (dss_ctl2_val & LEFT_BRANCH_VDSC_ENABLE ||
1080+ dss_ctl2_val & RIGHT_BRANCH_VDSC_ENABLE)
1081+ dss_ctl2_val &= ~(LEFT_BRANCH_VDSC_ENABLE |
1082+ RIGHT_BRANCH_VDSC_ENABLE);
1083+ I915_WRITE(dss_ctl2_reg, dss_ctl2_val);
1084+
1085+ /* Disable Power wells for VDSC/joining */
1086+ intel_display_power_put(dev_priv,
1087+ intel_dsc_power_domain(old_crtc_state));
1088+}
drivers/gpu/drm/i915/intel_workarounds.c+591−408
@@ -48,58 +48,112 @@ · 47 unmodified lines
4848 * - Public functions to init or apply the given workaround type.
4949 */
5050
51−static void wa_add(struct drm_i915_private *i915,
52− i915_reg_t reg, const u32 mask, const u32 val)
51+static void wa_init_start(struct i915_wa_list *wal, const char *name)
5352 {
54− struct i915_workarounds *wa = &i915->workarounds;
55− unsigned int start = 0, end = wa->count;
56− unsigned int addr = i915_mmio_reg_offset(reg);
57− struct i915_wa_reg *r;
53+ wal->name = name;
54+}
55+
56+#define WA_LIST_CHUNK (1 << 4)
57+
58+static void wa_init_finish(struct i915_wa_list *wal)
59+{
60+ /* Trim unused entries. */
61+ if (!IS_ALIGNED(wal->count, WA_LIST_CHUNK)) {
62+ struct i915_wa *list = kmemdup(wal->list,
63+ wal->count * sizeof(*list),
64+ GFP_KERNEL);
65+
66+ if (list) {
67+ kfree(wal->list);
68+ wal->list = list;
69+ }
70+ }
71+
72+ if (!wal->count)
73+ return;
74+
75+ DRM_DEBUG_DRIVER("Initialized %u %s workarounds\n",
76+ wal->wa_count, wal->name);
77+}
78+
79+static void _wa_add(struct i915_wa_list *wal, const struct i915_wa *wa)
80+{
81+ unsigned int addr = i915_mmio_reg_offset(wa->reg);
82+ unsigned int start = 0, end = wal->count;
83+ const unsigned int grow = WA_LIST_CHUNK;
84+ struct i915_wa *wa_;
85+
86+ GEM_BUG_ON(!is_power_of_2(grow));
87+
88+ if (IS_ALIGNED(wal->count, grow)) { /* Either uninitialized or full. */
89+ struct i915_wa *list;
90+
91+ list = kmalloc_array(ALIGN(wal->count + 1, grow), sizeof(*wa),
92+ GFP_KERNEL);
93+ if (!list) {
94+ DRM_ERROR("No space for workaround init!\n");
95+ return;
96+ }
97+
98+ if (wal->list)
99+ memcpy(list, wal->list, sizeof(*wa) * wal->count);
100+
101+ wal->list = list;
102+ }
58103
59104 while (start < end) {
60105 unsigned int mid = start + (end - start) / 2;
61106
62− if (wa->reg[mid].addr < addr) {
107+ if (i915_mmio_reg_offset(wal->list[mid].reg) < addr) {
63108 start = mid + 1;
64− } else if (wa->reg[mid].addr > addr) {
109+ } else if (i915_mmio_reg_offset(wal->list[mid].reg) > addr) {
65110 end = mid;
66111 } else {
67− r = &wa->reg[mid];
112+ wa_ = &wal->list[mid];
68113
69− if ((mask & ~r->mask) == 0) {
114+ if ((wa->mask & ~wa_->mask) == 0) {
70115 DRM_ERROR("Discarding overwritten w/a for reg %04x (mask: %08x, value: %08x)\n",
71− addr, r->mask, r->value);
116+ i915_mmio_reg_offset(wa_->reg),
117+ wa_->mask, wa_->val);
72118
73− r->value &= ~mask;
119+ wa_->val &= ~wa->mask;
74120 }
75121
76− r->value |= val;
77− r->mask |= mask;
122+ wal->wa_count++;
123+ wa_->val |= wa->val;
124+ wa_->mask |= wa->mask;
78125 return;
79126 }
80127 }
81128
82− if (WARN_ON_ONCE(wa->count >= I915_MAX_WA_REGS)) {
83− DRM_ERROR("Dropping w/a for reg %04x (mask: %08x, value: %08x)\n",
84− addr, mask, val);
85− return;
86− }
87−
88− r = &wa->reg[wa->count++];
89− r->addr = addr;
90− r->value = val;
91− r->mask = mask;
129+ wal->wa_count++;
130+ wa_ = &wal->list[wal->count++];
131+ *wa_ = *wa;
92132
93− while (r-- > wa->reg) {
94− GEM_BUG_ON(r[0].addr == r[1].addr);
95− if (r[1].addr > r[0].addr)
133+ while (wa_-- > wal->list) {
134+ GEM_BUG_ON(i915_mmio_reg_offset(wa_[0].reg) ==
135+ i915_mmio_reg_offset(wa_[1].reg));
136+ if (i915_mmio_reg_offset(wa_[1].reg) >
137+ i915_mmio_reg_offset(wa_[0].reg))
96138 break;
97139
98− swap(r[1], r[0]);
140+ swap(wa_[1], wa_[0]);
99141 }
100142 }
101143
102−#define WA_REG(addr, mask, val) wa_add(dev_priv, (addr), (mask), (val))
144+static void
145+__wa_add(struct i915_wa_list *wal, i915_reg_t reg, u32 mask, u32 val)
146+{
147+ struct i915_wa wa = {
148+ .reg = reg,
149+ .mask = mask,
150+ .val = val
151+ };
152+
153+ _wa_add(wal, &wa);
154+}
155+
156+#define WA_REG(addr, mask, val) __wa_add(wal, (addr), (mask), (val))
103157
104158 #define WA_SET_BIT_MASKED(addr, mask) \
105159 WA_REG(addr, (mask), _MASKED_BIT_ENABLE(mask))
@@ -110,8 +164,10 @@ static void wa_add(struct drm_i915_private *i915, · 4 unmodified lines
110164 #define WA_SET_FIELD_MASKED(addr, mask, value) \
111165 WA_REG(addr, (mask), _MASKED_FIELD(mask, value))
112166
113−static int gen8_ctx_workarounds_init(struct drm_i915_private *dev_priv)
167+static void gen8_ctx_workarounds_init(struct intel_engine_cs *engine)
114168 {
169+ struct i915_wa_list *wal = &engine->ctx_wa_list;
170+
115171 WA_SET_BIT_MASKED(INSTPM, INSTPM_FORCE_ORDERING);
116172
117173 /* WaDisableAsyncFlipPerfMode:bdw,chv */
@@ -155,17 +211,14 @@ static int gen8_ctx_workarounds_init(struct drm_i915_private *dev_priv) · 37 unmodified lines
155211 WA_SET_FIELD_MASKED(GEN7_GT_MODE,
156212 GEN6_WIZ_HASHING_MASK,
157213 GEN6_WIZ_HASHING_16x4);
158−
159− return 0;
160214 }
161215
162−static int bdw_ctx_workarounds_init(struct drm_i915_private *dev_priv)
216+static void bdw_ctx_workarounds_init(struct intel_engine_cs *engine)
163217 {
164− int ret;
218+ struct drm_i915_private *i915 = engine->i915;
219+ struct i915_wa_list *wal = &engine->ctx_wa_list;
165220
166− ret = gen8_ctx_workarounds_init(dev_priv);
167− if (ret)
168− return ret;
221+ gen8_ctx_workarounds_init(engine);
169222
170223 /* WaDisableThreadStallDopClockGating:bdw (pre-production) */
171224 WA_SET_BIT_MASKED(GEN8_ROW_CHICKEN, STALL_DOP_GATING_DISABLE);
@@ -185,31 +238,28 @@ static int bdw_ctx_workarounds_init(struct drm_i915_private *dev_priv) · 13 unmodified lines
185238 /* WaForceContextSaveRestoreNonCoherent:bdw */
186239 HDC_FORCE_CONTEXT_SAVE_RESTORE_NON_COHERENT |
187240 /* WaDisableFenceDestinationToSLM:bdw (pre-prod) */
188− (IS_BDW_GT3(dev_priv) ? HDC_FENCE_DEST_SLM_DISABLE : 0));
189−
190− return 0;
241+ (IS_BDW_GT3(i915) ? HDC_FENCE_DEST_SLM_DISABLE : 0));
191242 }
192243
193−static int chv_ctx_workarounds_init(struct drm_i915_private *dev_priv)
244+static void chv_ctx_workarounds_init(struct intel_engine_cs *engine)
194245 {
195− int ret;
246+ struct i915_wa_list *wal = &engine->ctx_wa_list;
196247
197− ret = gen8_ctx_workarounds_init(dev_priv);
198− if (ret)
199− return ret;
248+ gen8_ctx_workarounds_init(engine);
200249
201250 /* WaDisableThreadStallDopClockGating:chv */
202251 WA_SET_BIT_MASKED(GEN8_ROW_CHICKEN, STALL_DOP_GATING_DISABLE);
203252
204253 /* Improve HiZ throughput on CHV. */
205254 WA_SET_BIT_MASKED(HIZ_CHICKEN, CHV_HZ_8X8_MODE_IN_1X);
206−
207− return 0;
208255 }
209256
210−static int gen9_ctx_workarounds_init(struct drm_i915_private *dev_priv)
257+static void gen9_ctx_workarounds_init(struct intel_engine_cs *engine)
211258 {
212− if (HAS_LLC(dev_priv)) {
259+ struct drm_i915_private *i915 = engine->i915;
260+ struct i915_wa_list *wal = &engine->ctx_wa_list;
261+
262+ if (HAS_LLC(i915)) {
213263 /* WaCompressedResourceSamplerPbeMediaNewHashMode:skl,kbl
214264 *
215265 * Must match Display Engine. See
@@ -228,7 +278,7 @@ static int gen9_ctx_workarounds_init(struct drm_i915_private *dev_priv) · 12 unmodified lines
228278 PARTIAL_INSTRUCTION_SHOOTDOWN_DISABLE);
229279
230280 /* Syncing dependencies between camera and graphics:skl,bxt,kbl */
231− if (!IS_COFFEELAKE(dev_priv))
281+ if (!IS_COFFEELAKE(i915))
232282 WA_SET_BIT_MASKED(HALF_SLICE_CHICKEN3,
233283 GEN9_DISABLE_OCL_OOB_SUPPRESS_LOGIC);
234284
@@ -271,9 +321,7 @@ static int gen9_ctx_workarounds_init(struct drm_i915_private *dev_priv) · 36 unmodified lines
271321 HDC_FORCE_NON_COHERENT);
272322
273323 /* WaDisableSamplerPowerBypassForSOPingPong:skl,bxt,kbl,cfl */
274− if (IS_SKYLAKE(dev_priv) ||
275− IS_KABYLAKE(dev_priv) ||
276− IS_COFFEELAKE(dev_priv))
324+ if (IS_SKYLAKE(i915) || IS_KABYLAKE(i915) || IS_COFFEELAKE(i915))
277325 WA_SET_BIT_MASKED(HALF_SLICE_CHICKEN3,
278326 GEN8_SAMPLER_POWER_BYPASS_DIS);
279327
@@ -300,14 +348,14 @@ static int gen9_ctx_workarounds_init(struct drm_i915_private *dev_priv) · 20 unmodified lines
300348 GEN9_PREEMPT_GPGPU_COMMAND_LEVEL);
301349
302350 /* WaClearHIZ_WM_CHICKEN3:bxt,glk */
303− if (IS_GEN9_LP(dev_priv))
351+ if (IS_GEN9_LP(i915))
304352 WA_SET_BIT_MASKED(GEN9_WM_CHICKEN3, GEN9_FACTOR_IN_CLR_VAL_HIZ);
305−
306− return 0;
307353 }
308354
309−static int skl_tune_iz_hashing(struct drm_i915_private *dev_priv)
355+static void skl_tune_iz_hashing(struct intel_engine_cs *engine)
310356 {
357+ struct drm_i915_private *i915 = engine->i915;
358+ struct i915_wa_list *wal = &engine->ctx_wa_list;
311359 u8 vals[3] = { 0, 0, 0 };
312360 unsigned int i;
313361
@@ -318,7 +366,7 @@ static int skl_tune_iz_hashing(struct drm_i915_private *dev_priv) · 4 unmodified lines
318366 * Only consider slices where one, and only one, subslice has 7
319367 * EUs
320368 */
321− if (!is_power_of_2(INTEL_INFO(dev_priv)->sseu.subslice_7eu[i]))
369+ if (!is_power_of_2(INTEL_INFO(i915)->sseu.subslice_7eu[i]))
322370 continue;
323371
324372 /*
@@ -327,12 +375,12 @@ static int skl_tune_iz_hashing(struct drm_i915_private *dev_priv) · 2 unmodified lines
327375 *
328376 * -> 0 <= ss <= 3;
329377 */
330− ss = ffs(INTEL_INFO(dev_priv)->sseu.subslice_7eu[i]) - 1;
378+ ss = ffs(INTEL_INFO(i915)->sseu.subslice_7eu[i]) - 1;
331379 vals[i] = 3 - ss;
332380 }
333381
334382 if (vals[0] == 0 && vals[1] == 0 && vals[2] == 0)
335− return 0;
383+ return;
336384
337385 /* Tune IZ hashing. See intel_device_info_runtime_init() */
338386 WA_SET_FIELD_MASKED(GEN7_GT_MODE,
@@ -342,28 +390,19 @@ static int skl_tune_iz_hashing(struct drm_i915_private *dev_priv) · 3 unmodified lines
342390 GEN9_IZ_HASHING(2, vals[2]) |
343391 GEN9_IZ_HASHING(1, vals[1]) |
344392 GEN9_IZ_HASHING(0, vals[0]));
345−
346− return 0;
347393 }
348394
349−static int skl_ctx_workarounds_init(struct drm_i915_private *dev_priv)
395+static void skl_ctx_workarounds_init(struct intel_engine_cs *engine)
350396 {
351− int ret;
352−
353− ret = gen9_ctx_workarounds_init(dev_priv);
354− if (ret)
355− return ret;
356−
357− return skl_tune_iz_hashing(dev_priv);
397+ gen9_ctx_workarounds_init(engine);
398+ skl_tune_iz_hashing(engine);
358399 }
359400
360−static int bxt_ctx_workarounds_init(struct drm_i915_private *dev_priv)
401+static void bxt_ctx_workarounds_init(struct intel_engine_cs *engine)
361402 {
362− int ret;
403+ struct i915_wa_list *wal = &engine->ctx_wa_list;
363404
364− ret = gen9_ctx_workarounds_init(dev_priv);
365− if (ret)
366− return ret;
405+ gen9_ctx_workarounds_init(engine);
367406
368407 /* WaDisableThreadStallDopClockGating:bxt */
369408 WA_SET_BIT_MASKED(GEN8_ROW_CHICKEN,
@@ -372,57 +411,41 @@ static int bxt_ctx_workarounds_init(struct drm_i915_private *dev_priv) · 2 unmodified lines
372411 /* WaToEnableHwFixForPushConstHWBug:bxt */
373412 WA_SET_BIT_MASKED(COMMON_SLICE_CHICKEN2,
374413 GEN8_SBE_DISABLE_REPLAY_BUF_OPTIMIZATION);
375−
376− return 0;
377414 }
378415
379−static int kbl_ctx_workarounds_init(struct drm_i915_private *dev_priv)
416+static void kbl_ctx_workarounds_init(struct intel_engine_cs *engine)
380417 {
381− int ret;
382−
383− ret = gen9_ctx_workarounds_init(dev_priv);
384− if (ret)
385− return ret;
418+ struct drm_i915_private *i915 = engine->i915;
419+ struct i915_wa_list *wal = &engine->ctx_wa_list;
386420
387− /* WaDisableFenceDestinationToSLM:kbl (pre-prod) */
388− if (IS_KBL_REVID(dev_priv, KBL_REVID_A0, KBL_REVID_A0))
389− WA_SET_BIT_MASKED(HDC_CHICKEN0,
390− HDC_FENCE_DEST_SLM_DISABLE);
421+ gen9_ctx_workarounds_init(engine);
391422
392423 /* WaToEnableHwFixForPushConstHWBug:kbl */
393− if (IS_KBL_REVID(dev_priv, KBL_REVID_C0, REVID_FOREVER))
424+ if (IS_KBL_REVID(i915, KBL_REVID_C0, REVID_FOREVER))
394425 WA_SET_BIT_MASKED(COMMON_SLICE_CHICKEN2,
395426 GEN8_SBE_DISABLE_REPLAY_BUF_OPTIMIZATION);
396427
397428 /* WaDisableSbeCacheDispatchPortSharing:kbl */
398429 WA_SET_BIT_MASKED(GEN7_HALF_SLICE_CHICKEN1,
399430 GEN7_SBE_SS_CACHE_DISPATCH_PORT_SHARING_DISABLE);
400−
401− return 0;
402431 }
403432
404−static int glk_ctx_workarounds_init(struct drm_i915_private *dev_priv)
433+static void glk_ctx_workarounds_init(struct intel_engine_cs *engine)
405434 {
406− int ret;
435+ struct i915_wa_list *wal = &engine->ctx_wa_list;
407436
408− ret = gen9_ctx_workarounds_init(dev_priv);
409− if (ret)
410− return ret;
437+ gen9_ctx_workarounds_init(engine);
411438
412439 /* WaToEnableHwFixForPushConstHWBug:glk */
413440 WA_SET_BIT_MASKED(COMMON_SLICE_CHICKEN2,
414441 GEN8_SBE_DISABLE_REPLAY_BUF_OPTIMIZATION);
415−
416− return 0;
417442 }
418443
419−static int cfl_ctx_workarounds_init(struct drm_i915_private *dev_priv)
444+static void cfl_ctx_workarounds_init(struct intel_engine_cs *engine)
420445 {
421− int ret;
446+ struct i915_wa_list *wal = &engine->ctx_wa_list;
422447
423− ret = gen9_ctx_workarounds_init(dev_priv);
424− if (ret)
425− return ret;
448+ gen9_ctx_workarounds_init(engine);
426449
427450 /* WaToEnableHwFixForPushConstHWBug:cfl */
428451 WA_SET_BIT_MASKED(COMMON_SLICE_CHICKEN2,
@@ -431,18 +454,19 @@ static int cfl_ctx_workarounds_init(struct drm_i915_private *dev_priv) · 2 unmodified lines
431454 /* WaDisableSbeCacheDispatchPortSharing:cfl */
432455 WA_SET_BIT_MASKED(GEN7_HALF_SLICE_CHICKEN1,
433456 GEN7_SBE_SS_CACHE_DISPATCH_PORT_SHARING_DISABLE);
434−
435− return 0;
436457 }
437458
438−static int cnl_ctx_workarounds_init(struct drm_i915_private *dev_priv)
459+static void cnl_ctx_workarounds_init(struct intel_engine_cs *engine)
439460 {
461+ struct drm_i915_private *i915 = engine->i915;
462+ struct i915_wa_list *wal = &engine->ctx_wa_list;
463+
440464 /* WaForceContextSaveRestoreNonCoherent:cnl */
441465 WA_SET_BIT_MASKED(CNL_HDC_CHICKEN0,
442466 HDC_FORCE_CONTEXT_SAVE_RESTORE_NON_COHERENT);
443467
444468 /* WaThrottleEUPerfToAvoidTDBackPressure:cnl(pre-prod) */
445− if (IS_CNL_REVID(dev_priv, CNL_REVID_B0, CNL_REVID_B0))
469+ if (IS_CNL_REVID(i915, CNL_REVID_B0, CNL_REVID_B0))
446470 WA_SET_BIT_MASKED(GEN8_ROW_CHICKEN, THROTTLE_12_5);
447471
448472 /* WaDisableReplayBufferBankArbitrationOptimization:cnl */
@@ -450,7 +474,7 @@ static int cnl_ctx_workarounds_init(struct drm_i915_private *dev_priv) · 1 unmodified line
450474 GEN8_SBE_DISABLE_REPLAY_BUF_OPTIMIZATION);
451475
452476 /* WaDisableEnhancedSBEVertexCaching:cnl (pre-prod) */
453− if (IS_CNL_REVID(dev_priv, 0, CNL_REVID_B0))
477+ if (IS_CNL_REVID(i915, 0, CNL_REVID_B0))
454478 WA_SET_BIT_MASKED(COMMON_SLICE_CHICKEN2,
455479 GEN8_CSC2_SBE_VUE_CACHE_CONSERVATIVE);
456480
@@ -470,16 +494,17 @@ static int cnl_ctx_workarounds_init(struct drm_i915_private *dev_priv) · 13 unmodified lines
470494
471495 /* WaDisableEarlyEOT:cnl */
472496 WA_SET_BIT_MASKED(GEN8_ROW_CHICKEN, DISABLE_EARLY_EOT);
473−
474− return 0;
475497 }
476498
477−static int icl_ctx_workarounds_init(struct drm_i915_private *dev_priv)
499+static void icl_ctx_workarounds_init(struct intel_engine_cs *engine)
478500 {
501+ struct drm_i915_private *i915 = engine->i915;
502+ struct i915_wa_list *wal = &engine->ctx_wa_list;
503+
479504 /* Wa_1604370585:icl (pre-prod)
480505 * Formerly known as WaPushConstantDereferenceHoldDisable
481506 */
482− if (IS_ICL_REVID(dev_priv, ICL_REVID_A0, ICL_REVID_B0))
507+ if (IS_ICL_REVID(i915, ICL_REVID_A0, ICL_REVID_B0))
483508 WA_SET_BIT_MASKED(GEN7_ROW_CHICKEN2,
484509 PUSH_CONSTANT_DEREF_DISABLE);
485510
@@ -495,7 +520,7 @@ static int icl_ctx_workarounds_init(struct drm_i915_private *dev_priv) · 9 unmodified lines
495520 /* Wa_2006611047:icl (pre-prod)
496521 * Formerly known as WaDisableImprovedTdlClkGating
497522 */
498− if (IS_ICL_REVID(dev_priv, ICL_REVID_A0, ICL_REVID_A0))
523+ if (IS_ICL_REVID(i915, ICL_REVID_A0, ICL_REVID_A0))
499524 WA_SET_BIT_MASKED(GEN7_ROW_CHICKEN2,
500525 GEN11_TDL_CLOCK_GATING_FIX_DISABLE);
501526
@@ -504,70 +529,67 @@ static int icl_ctx_workarounds_init(struct drm_i915_private *dev_priv) · 2 unmodified lines
504529 GEN11_STATE_CACHE_REDIRECT_TO_CS);
505530
506531 /* Wa_2006665173:icl (pre-prod) */
507− if (IS_ICL_REVID(dev_priv, ICL_REVID_A0, ICL_REVID_A0))
532+ if (IS_ICL_REVID(i915, ICL_REVID_A0, ICL_REVID_A0))
508533 WA_SET_BIT_MASKED(GEN11_COMMON_SLICE_CHICKEN3,
509534 GEN11_BLEND_EMB_FIX_DISABLE_IN_RCC);
510−
511− return 0;
512535 }
513536
514−int intel_ctx_workarounds_init(struct drm_i915_private *dev_priv)
537+void intel_engine_init_ctx_wa(struct intel_engine_cs *engine)
515538 {
516− int err = 0;
517−
518− dev_priv->workarounds.count = 0;
519−
520− if (INTEL_GEN(dev_priv) < 8)
521− err = 0;
522− else if (IS_BROADWELL(dev_priv))
523− err = bdw_ctx_workarounds_init(dev_priv);
524− else if (IS_CHERRYVIEW(dev_priv))
525− err = chv_ctx_workarounds_init(dev_priv);
526− else if (IS_SKYLAKE(dev_priv))
527− err = skl_ctx_workarounds_init(dev_priv);
528− else if (IS_BROXTON(dev_priv))
529− err = bxt_ctx_workarounds_init(dev_priv);
530− else if (IS_KABYLAKE(dev_priv))
531− err = kbl_ctx_workarounds_init(dev_priv);
532− else if (IS_GEMINILAKE(dev_priv))
533− err = glk_ctx_workarounds_init(dev_priv);
534− else if (IS_COFFEELAKE(dev_priv))
535− err = cfl_ctx_workarounds_init(dev_priv);
536− else if (IS_CANNONLAKE(dev_priv))
537− err = cnl_ctx_workarounds_init(dev_priv);
538− else if (IS_ICELAKE(dev_priv))
539− err = icl_ctx_workarounds_init(dev_priv);
539+ struct drm_i915_private *i915 = engine->i915;
540+ struct i915_wa_list *wal = &engine->ctx_wa_list;
541+
542+ wa_init_start(wal, "context");
543+
544+ if (INTEL_GEN(i915) < 8)
545+ return;
546+ else if (IS_BROADWELL(i915))
547+ bdw_ctx_workarounds_init(engine);
548+ else if (IS_CHERRYVIEW(i915))
549+ chv_ctx_workarounds_init(engine);
550+ else if (IS_SKYLAKE(i915))
551+ skl_ctx_workarounds_init(engine);
552+ else if (IS_BROXTON(i915))
553+ bxt_ctx_workarounds_init(engine);
554+ else if (IS_KABYLAKE(i915))
555+ kbl_ctx_workarounds_init(engine);
556+ else if (IS_GEMINILAKE(i915))
557+ glk_ctx_workarounds_init(engine);
558+ else if (IS_COFFEELAKE(i915))
559+ cfl_ctx_workarounds_init(engine);
560+ else if (IS_CANNONLAKE(i915))
561+ cnl_ctx_workarounds_init(engine);
562+ else if (IS_ICELAKE(i915))
563+ icl_ctx_workarounds_init(engine);
540564 else
541− MISSING_CASE(INTEL_GEN(dev_priv));
542− if (err)
543− return err;
565+ MISSING_CASE(INTEL_GEN(i915));
544566
545− DRM_DEBUG_DRIVER("Number of context specific w/a: %d\n",
546− dev_priv->workarounds.count);
547− return 0;
567+ wa_init_finish(wal);
548568 }
549569
550−int intel_ctx_workarounds_emit(struct i915_request *rq)
570+int intel_engine_emit_ctx_wa(struct i915_request *rq)
551571 {
552− struct i915_workarounds *w = &rq->i915->workarounds;
572+ struct i915_wa_list *wal = &rq->engine->ctx_wa_list;
573+ struct i915_wa *wa;
574+ unsigned int i;
553575 u32 *cs;
554− int ret, i;
576+ int ret;
555577
556− if (w->count == 0)
578+ if (wal->count == 0)
557579 return 0;
558580
559581 ret = rq->engine->emit_flush(rq, EMIT_BARRIER);
560582 if (ret)
561583 return ret;
562584
563− cs = intel_ring_begin(rq, (w->count * 2 + 2));
585+ cs = intel_ring_begin(rq, (wal->count * 2 + 2));
564586 if (IS_ERR(cs))
565587 return PTR_ERR(cs);
566588
567− *cs++ = MI_LOAD_REGISTER_IMM(w->count);
568− for (i = 0; i < w->count; i++) {
569− *cs++ = w->reg[i].addr;
570− *cs++ = w->reg[i].value;
589+ *cs++ = MI_LOAD_REGISTER_IMM(wal->count);
590+ for (i = 0, wa = wal->list; i < wal->count; i++, wa++) {
591+ *cs++ = i915_mmio_reg_offset(wa->reg);
592+ *cs++ = wa->val;
571593 }
572594 *cs++ = MI_NOOP;
573595
@@ -580,160 +602,149 @@ int intel_ctx_workarounds_emit(struct i915_request *rq) · 6 unmodified lines
580602 return 0;
581603 }
582604
583−static void bdw_gt_workarounds_apply(struct drm_i915_private *dev_priv)
605+static void
606+wa_masked_en(struct i915_wa_list *wal, i915_reg_t reg, u32 val)
607+{
608+ struct i915_wa wa = {
609+ .reg = reg,
610+ .mask = val,
611+ .val = _MASKED_BIT_ENABLE(val)
612+ };
613+
614+ _wa_add(wal, &wa);
615+}
616+
617+static void
618+wa_write_masked_or(struct i915_wa_list *wal, i915_reg_t reg, u32 mask,
619+ u32 val)
584620 {
621+ struct i915_wa wa = {
622+ .reg = reg,
623+ .mask = mask,
624+ .val = val
625+ };
626+
627+ _wa_add(wal, &wa);
585628 }
586629
587−static void chv_gt_workarounds_apply(struct drm_i915_private *dev_priv)
630+static void
631+wa_write(struct i915_wa_list *wal, i915_reg_t reg, u32 val)
588632 {
633+ wa_write_masked_or(wal, reg, ~0, val);
589634 }
590635
591−static void gen9_gt_workarounds_apply(struct drm_i915_private *dev_priv)
636+static void
637+wa_write_or(struct i915_wa_list *wal, i915_reg_t reg, u32 val)
592638 {
593− /* WaContextSwitchWithConcurrentTLBInvalidate:skl,bxt,kbl,glk,cfl */
594− I915_WRITE(GEN9_CSFE_CHICKEN1_RCS,
595− _MASKED_BIT_ENABLE(GEN9_PREEMPT_GPGPU_SYNC_SWITCH_DISABLE));
639+ wa_write_masked_or(wal, reg, val, val);
640+}
596641
597− /* WaEnableLbsSlaRetryTimerDecrement:skl,bxt,kbl,glk,cfl */
598− I915_WRITE(BDW_SCRATCH1, I915_READ(BDW_SCRATCH1) |
599− GEN9_LBS_SLA_RETRY_TIMER_DECREMENT_ENABLE);
642+static void gen9_gt_workarounds_init(struct drm_i915_private *i915)
643+{
644+ struct i915_wa_list *wal = &i915->gt_wa_list;
600645
601646 /* WaDisableKillLogic:bxt,skl,kbl */
602− if (!IS_COFFEELAKE(dev_priv))
603− I915_WRITE(GAM_ECOCHK, I915_READ(GAM_ECOCHK) |
604− ECOCHK_DIS_TLB);
647+ if (!IS_COFFEELAKE(i915))
648+ wa_write_or(wal,
649+ GAM_ECOCHK,
650+ ECOCHK_DIS_TLB);
605651
606− if (HAS_LLC(dev_priv)) {
652+ if (HAS_LLC(i915)) {
607653 /* WaCompressedResourceSamplerPbeMediaNewHashMode:skl,kbl
608654 *
609655 * Must match Display Engine. See
610656 * WaCompressedResourceDisplayNewHashMode.
611657 */
612− I915_WRITE(MMCD_MISC_CTRL,
613− I915_READ(MMCD_MISC_CTRL) |
614− MMCD_PCLA |
615− MMCD_HOTSPOT_EN);
658+ wa_write_or(wal,
659+ MMCD_MISC_CTRL,
660+ MMCD_PCLA | MMCD_HOTSPOT_EN);
616661 }
617662
618663 /* WaDisableHDCInvalidation:skl,bxt,kbl,cfl */
619− I915_WRITE(GAM_ECOCHK, I915_READ(GAM_ECOCHK) |
620− BDW_DISABLE_HDC_INVALIDATION);
621−
622− /* WaProgramL3SqcReg1DefaultForPerf:bxt,glk */
623− if (IS_GEN9_LP(dev_priv)) {
624− u32 val = I915_READ(GEN8_L3SQCREG1);
625−
626− val &= ~L3_PRIO_CREDITS_MASK;
627− val |= L3_GENERAL_PRIO_CREDITS(62) | L3_HIGH_PRIO_CREDITS(2);
628− I915_WRITE(GEN8_L3SQCREG1, val);
629− }
630−
631− /* WaOCLCoherentLineFlush:skl,bxt,kbl,cfl */
632− I915_WRITE(GEN8_L3SQCREG4,
633− I915_READ(GEN8_L3SQCREG4) | GEN8_LQSC_FLUSH_COHERENT_LINES);
634−
635− /* WaEnablePreemptionGranularityControlByUMD:skl,bxt,kbl,cfl,[cnl] */
636− I915_WRITE(GEN7_FF_SLICE_CS_CHICKEN1,
637− _MASKED_BIT_ENABLE(GEN9_FFSC_PERCTX_PREEMPT_CTRL));
664+ wa_write_or(wal,
665+ GAM_ECOCHK,
666+ BDW_DISABLE_HDC_INVALIDATION);
638667 }
639668
640−static void skl_gt_workarounds_apply(struct drm_i915_private *dev_priv)
669+static void skl_gt_workarounds_init(struct drm_i915_private *i915)
641670 {
642− gen9_gt_workarounds_apply(dev_priv);
671+ struct i915_wa_list *wal = &i915->gt_wa_list;
643672
644− /* WaEnableGapsTsvCreditFix:skl */
645− I915_WRITE(GEN8_GARBCNTL,
646− I915_READ(GEN8_GARBCNTL) | GEN9_GAPS_TSV_CREDIT_DISABLE);
673+ gen9_gt_workarounds_init(i915);
647674
648675 /* WaDisableGafsUnitClkGating:skl */
649− I915_WRITE(GEN7_UCGCTL4,
650− I915_READ(GEN7_UCGCTL4) | GEN8_EU_GAUNIT_CLOCK_GATE_DISABLE);
676+ wa_write_or(wal,
677+ GEN7_UCGCTL4,
678+ GEN8_EU_GAUNIT_CLOCK_GATE_DISABLE);
651679
652680 /* WaInPlaceDecompressionHang:skl */
653− if (IS_SKL_REVID(dev_priv, SKL_REVID_H0, REVID_FOREVER))
654− I915_WRITE(GEN9_GAMT_ECO_REG_RW_IA,
655− I915_READ(GEN9_GAMT_ECO_REG_RW_IA) |
656− GAMT_ECO_ENABLE_IN_PLACE_DECOMPRESS);
681+ if (IS_SKL_REVID(i915, SKL_REVID_H0, REVID_FOREVER))
682+ wa_write_or(wal,
683+ GEN9_GAMT_ECO_REG_RW_IA,
684+ GAMT_ECO_ENABLE_IN_PLACE_DECOMPRESS);
657685 }
658686
659−static void bxt_gt_workarounds_apply(struct drm_i915_private *dev_priv)
687+static void bxt_gt_workarounds_init(struct drm_i915_private *i915)
660688 {
661− gen9_gt_workarounds_apply(dev_priv);
689+ struct i915_wa_list *wal = &i915->gt_wa_list;
662690
663− /* WaDisablePooledEuLoadBalancingFix:bxt */
664− I915_WRITE(FF_SLICE_CS_CHICKEN2,
665− _MASKED_BIT_ENABLE(GEN9_POOLED_EU_LOAD_BALANCING_FIX_DISABLE));
691+ gen9_gt_workarounds_init(i915);
666692
667693 /* WaInPlaceDecompressionHang:bxt */
668− I915_WRITE(GEN9_GAMT_ECO_REG_RW_IA,
669− I915_READ(GEN9_GAMT_ECO_REG_RW_IA) |
670− GAMT_ECO_ENABLE_IN_PLACE_DECOMPRESS);
694+ wa_write_or(wal,
695+ GEN9_GAMT_ECO_REG_RW_IA,
696+ GAMT_ECO_ENABLE_IN_PLACE_DECOMPRESS);
671697 }
672698
673−static void kbl_gt_workarounds_apply(struct drm_i915_private *dev_priv)
699+static void kbl_gt_workarounds_init(struct drm_i915_private *i915)
674700 {
675− gen9_gt_workarounds_apply(dev_priv);
701+ struct i915_wa_list *wal = &i915->gt_wa_list;
676702
677− /* WaEnableGapsTsvCreditFix:kbl */
678− I915_WRITE(GEN8_GARBCNTL,
679− I915_READ(GEN8_GARBCNTL) | GEN9_GAPS_TSV_CREDIT_DISABLE);
703+ gen9_gt_workarounds_init(i915);
680704
681705 /* WaDisableDynamicCreditSharing:kbl */
682− if (IS_KBL_REVID(dev_priv, 0, KBL_REVID_B0))
683− I915_WRITE(GAMT_CHKN_BIT_REG,
684− I915_READ(GAMT_CHKN_BIT_REG) |
685− GAMT_CHKN_DISABLE_DYNAMIC_CREDIT_SHARING);
706+ if (IS_KBL_REVID(i915, 0, KBL_REVID_B0))
707+ wa_write_or(wal,
708+ GAMT_CHKN_BIT_REG,
709+ GAMT_CHKN_DISABLE_DYNAMIC_CREDIT_SHARING);
686710
687711 /* WaDisableGafsUnitClkGating:kbl */
688− I915_WRITE(GEN7_UCGCTL4,
689− I915_READ(GEN7_UCGCTL4) | GEN8_EU_GAUNIT_CLOCK_GATE_DISABLE);
712+ wa_write_or(wal,
713+ GEN7_UCGCTL4,
714+ GEN8_EU_GAUNIT_CLOCK_GATE_DISABLE);
690715
691716 /* WaInPlaceDecompressionHang:kbl */
692− I915_WRITE(GEN9_GAMT_ECO_REG_RW_IA,
693− I915_READ(GEN9_GAMT_ECO_REG_RW_IA) |
694− GAMT_ECO_ENABLE_IN_PLACE_DECOMPRESS);
695−
696− /* WaKBLVECSSemaphoreWaitPoll:kbl */
697− if (IS_KBL_REVID(dev_priv, KBL_REVID_A0, KBL_REVID_E0)) {
698− struct intel_engine_cs *engine;
699− unsigned int tmp;
700−
701− for_each_engine(engine, dev_priv, tmp) {
702− if (engine->id == RCS)
703− continue;
704−
705− I915_WRITE(RING_SEMA_WAIT_POLL(engine->mmio_base), 1);
706− }
707− }
717+ wa_write_or(wal,
718+ GEN9_GAMT_ECO_REG_RW_IA,
719+ GAMT_ECO_ENABLE_IN_PLACE_DECOMPRESS);
708720 }
709721
710−static void glk_gt_workarounds_apply(struct drm_i915_private *dev_priv)
722+static void glk_gt_workarounds_init(struct drm_i915_private *i915)
711723 {
712− gen9_gt_workarounds_apply(dev_priv);
724+ gen9_gt_workarounds_init(i915);
713725 }
714726
715−static void cfl_gt_workarounds_apply(struct drm_i915_private *dev_priv)
727+static void cfl_gt_workarounds_init(struct drm_i915_private *i915)
716728 {
717− gen9_gt_workarounds_apply(dev_priv);
729+ struct i915_wa_list *wal = &i915->gt_wa_list;
718730
719− /* WaEnableGapsTsvCreditFix:cfl */
720− I915_WRITE(GEN8_GARBCNTL,
721− I915_READ(GEN8_GARBCNTL) | GEN9_GAPS_TSV_CREDIT_DISABLE);
731+ gen9_gt_workarounds_init(i915);
722732
723733 /* WaDisableGafsUnitClkGating:cfl */
724− I915_WRITE(GEN7_UCGCTL4,
725− I915_READ(GEN7_UCGCTL4) | GEN8_EU_GAUNIT_CLOCK_GATE_DISABLE);
734+ wa_write_or(wal,
735+ GEN7_UCGCTL4,
736+ GEN8_EU_GAUNIT_CLOCK_GATE_DISABLE);
726737
727738 /* WaInPlaceDecompressionHang:cfl */
728− I915_WRITE(GEN9_GAMT_ECO_REG_RW_IA,
729− I915_READ(GEN9_GAMT_ECO_REG_RW_IA) |
730− GAMT_ECO_ENABLE_IN_PLACE_DECOMPRESS);
739+ wa_write_or(wal,
740+ GEN9_GAMT_ECO_REG_RW_IA,
741+ GAMT_ECO_ENABLE_IN_PLACE_DECOMPRESS);
731742 }
732743
733744 static void wa_init_mcr(struct drm_i915_private *dev_priv)
734745 {
735746 const struct sseu_dev_info *sseu = &(INTEL_INFO(dev_priv)->sseu);
736− u32 mcr;
747+ struct i915_wa_list *wal = &dev_priv->gt_wa_list;
737748 u32 mcr_slice_subslice_mask;
738749
739750 /*
@@ -770,8 +781,6 @@ static void wa_init_mcr(struct drm_i915_private *dev_priv) · 30 unmodified lines
770781 WARN_ON((enabled_mask & disabled_mask) != enabled_mask);
771782 }
772783
773− mcr = I915_READ(GEN8_MCR_SELECTOR);
774−
775784 if (INTEL_GEN(dev_priv) >= 11)
776785 mcr_slice_subslice_mask = GEN11_MCR_SLICE_MASK |
777786 GEN11_MCR_SUBSLICE_MASK;
@@ -789,186 +798,220 @@ static void wa_init_mcr(struct drm_i915_private *dev_priv) · 11 unmodified lines
789798 * occasions, such as INSTDONE, where this value is dependent
790799 * on s/ss combo, the read should be done with read_subslice_reg.
791800 */
792− mcr &= ~mcr_slice_subslice_mask;
793− mcr |= intel_calculate_mcr_s_ss_select(dev_priv);
794− I915_WRITE(GEN8_MCR_SELECTOR, mcr);
801+ wa_write_masked_or(wal,
802+ GEN8_MCR_SELECTOR,
803+ mcr_slice_subslice_mask,
804+ intel_calculate_mcr_s_ss_select(dev_priv));
795805 }
796806
797−static void cnl_gt_workarounds_apply(struct drm_i915_private *dev_priv)
807+static void cnl_gt_workarounds_init(struct drm_i915_private *i915)
798808 {
799− wa_init_mcr(dev_priv);
809+ struct i915_wa_list *wal = &i915->gt_wa_list;
810+
811+ wa_init_mcr(i915);
800812
801813 /* WaDisableI2mCycleOnWRPort:cnl (pre-prod) */
802− if (IS_CNL_REVID(dev_priv, CNL_REVID_B0, CNL_REVID_B0))
803− I915_WRITE(GAMT_CHKN_BIT_REG,
804− I915_READ(GAMT_CHKN_BIT_REG) |
805− GAMT_CHKN_DISABLE_I2M_CYCLE_ON_WR_PORT);
814+ if (IS_CNL_REVID(i915, CNL_REVID_B0, CNL_REVID_B0))
815+ wa_write_or(wal,
816+ GAMT_CHKN_BIT_REG,
817+ GAMT_CHKN_DISABLE_I2M_CYCLE_ON_WR_PORT);
806818
807819 /* WaInPlaceDecompressionHang:cnl */
808− I915_WRITE(GEN9_GAMT_ECO_REG_RW_IA,
809− I915_READ(GEN9_GAMT_ECO_REG_RW_IA) |
810− GAMT_ECO_ENABLE_IN_PLACE_DECOMPRESS);
811−
812− /* WaEnablePreemptionGranularityControlByUMD:cnl */
813− I915_WRITE(GEN7_FF_SLICE_CS_CHICKEN1,
814− _MASKED_BIT_ENABLE(GEN9_FFSC_PERCTX_PREEMPT_CTRL));
820+ wa_write_or(wal,
821+ GEN9_GAMT_ECO_REG_RW_IA,
822+ GAMT_ECO_ENABLE_IN_PLACE_DECOMPRESS);
815823 }
816824
817−static void icl_gt_workarounds_apply(struct drm_i915_private *dev_priv)
825+static void icl_gt_workarounds_init(struct drm_i915_private *i915)
818826 {
819− wa_init_mcr(dev_priv);
827+ struct i915_wa_list *wal = &i915->gt_wa_list;
820828
821− /* This is not an Wa. Enable for better image quality */
822− I915_WRITE(_3D_CHICKEN3,
823− _MASKED_BIT_ENABLE(_3D_CHICKEN3_AA_LINE_QUALITY_FIX_ENABLE));
829+ wa_init_mcr(i915);
824830
825831 /* WaInPlaceDecompressionHang:icl */
826− I915_WRITE(GEN9_GAMT_ECO_REG_RW_IA,
827− I915_READ(GEN9_GAMT_ECO_REG_RW_IA) |
828− GAMT_ECO_ENABLE_IN_PLACE_DECOMPRESS);
829−
830− /* WaPipelineFlushCoherentLines:icl */
831− I915_WRITE(GEN8_L3SQCREG4,
832− I915_READ(GEN8_L3SQCREG4) |
833− GEN8_LQSC_FLUSH_COHERENT_LINES);
834−
835− /* Wa_1405543622:icl
836− * Formerly known as WaGAPZPriorityScheme
837− */
838− I915_WRITE(GEN8_GARBCNTL,
839− I915_READ(GEN8_GARBCNTL) |
840− GEN11_ARBITRATION_PRIO_ORDER_MASK);
841−
842− /* Wa_1604223664:icl
843− * Formerly known as WaL3BankAddressHashing
844− */
845− I915_WRITE(GEN8_GARBCNTL,
846− (I915_READ(GEN8_GARBCNTL) & ~GEN11_HASH_CTRL_EXCL_MASK) |
847− GEN11_HASH_CTRL_EXCL_BIT0);
848− I915_WRITE(GEN11_GLBLINVL,
849− (I915_READ(GEN11_GLBLINVL) & ~GEN11_BANK_HASH_ADDR_EXCL_MASK) |
850− GEN11_BANK_HASH_ADDR_EXCL_BIT0);
832+ wa_write_or(wal,
833+ GEN9_GAMT_ECO_REG_RW_IA,
834+ GAMT_ECO_ENABLE_IN_PLACE_DECOMPRESS);
851835
852836 /* WaModifyGamTlbPartitioning:icl */
853− I915_WRITE(GEN11_GACB_PERF_CTRL,
854− (I915_READ(GEN11_GACB_PERF_CTRL) & ~GEN11_HASH_CTRL_MASK) |
855− GEN11_HASH_CTRL_BIT0 | GEN11_HASH_CTRL_BIT4);
856−
857− /* Wa_1405733216:icl
858− * Formerly known as WaDisableCleanEvicts
859− */
860− I915_WRITE(GEN8_L3SQCREG4,
861− I915_READ(GEN8_L3SQCREG4) |
862− GEN11_LQSC_CLEAN_EVICT_DISABLE);
837+ wa_write_masked_or(wal,
838+ GEN11_GACB_PERF_CTRL,
839+ GEN11_HASH_CTRL_MASK,
840+ GEN11_HASH_CTRL_BIT0 | GEN11_HASH_CTRL_BIT4);
863841
864842 /* Wa_1405766107:icl
865843 * Formerly known as WaCL2SFHalfMaxAlloc
866844 */
867− I915_WRITE(GEN11_LSN_UNSLCVC,
868− I915_READ(GEN11_LSN_UNSLCVC) |
869− GEN11_LSN_UNSLCVC_GAFS_HALF_SF_MAXALLOC |
870− GEN11_LSN_UNSLCVC_GAFS_HALF_CL2_MAXALLOC);
845+ wa_write_or(wal,
846+ GEN11_LSN_UNSLCVC,
847+ GEN11_LSN_UNSLCVC_GAFS_HALF_SF_MAXALLOC |
848+ GEN11_LSN_UNSLCVC_GAFS_HALF_CL2_MAXALLOC);
871849
872850 /* Wa_220166154:icl
873851 * Formerly known as WaDisCtxReload
874852 */
875− I915_WRITE(GEN8_GAMW_ECO_DEV_RW_IA,
876− I915_READ(GEN8_GAMW_ECO_DEV_RW_IA) |
877− GAMW_ECO_DEV_CTX_RELOAD_DISABLE);
853+ wa_write_or(wal,
854+ GEN8_GAMW_ECO_DEV_RW_IA,
855+ GAMW_ECO_DEV_CTX_RELOAD_DISABLE);
878856
879857 /* Wa_1405779004:icl (pre-prod) */
880− if (IS_ICL_REVID(dev_priv, ICL_REVID_A0, ICL_REVID_A0))
881− I915_WRITE(SLICE_UNIT_LEVEL_CLKGATE,
882− I915_READ(SLICE_UNIT_LEVEL_CLKGATE) |
883− MSCUNIT_CLKGATE_DIS);
858+ if (IS_ICL_REVID(i915, ICL_REVID_A0, ICL_REVID_A0))
859+ wa_write_or(wal,
860+ SLICE_UNIT_LEVEL_CLKGATE,
861+ MSCUNIT_CLKGATE_DIS);
884862
885863 /* Wa_1406680159:icl */
886− I915_WRITE(SUBSLICE_UNIT_LEVEL_CLKGATE,
887− I915_READ(SUBSLICE_UNIT_LEVEL_CLKGATE) |
888− GWUNIT_CLKGATE_DIS);
889−
890− /* Wa_1604302699:icl */
891− I915_WRITE(GEN10_L3_CHICKEN_MODE_REGISTER,
892− I915_READ(GEN10_L3_CHICKEN_MODE_REGISTER) |
893− GEN11_I2M_WRITE_DISABLE);
864+ wa_write_or(wal,
865+ SUBSLICE_UNIT_LEVEL_CLKGATE,
866+ GWUNIT_CLKGATE_DIS);
894867
895868 /* Wa_1406838659:icl (pre-prod) */
896− if (IS_ICL_REVID(dev_priv, ICL_REVID_A0, ICL_REVID_B0))
897− I915_WRITE(INF_UNIT_LEVEL_CLKGATE,
898− I915_READ(INF_UNIT_LEVEL_CLKGATE) |
899− CGPSF_CLKGATE_DIS);
900−
901− /* WaForwardProgressSoftReset:icl */
902− I915_WRITE(GEN10_SCRATCH_LNCF2,
903− I915_READ(GEN10_SCRATCH_LNCF2) |
904− PMFLUSHDONE_LNICRSDROP |
905− PMFLUSH_GAPL3UNBLOCK |
906− PMFLUSHDONE_LNEBLK);
869+ if (IS_ICL_REVID(i915, ICL_REVID_A0, ICL_REVID_B0))
870+ wa_write_or(wal,
871+ INF_UNIT_LEVEL_CLKGATE,
872+ CGPSF_CLKGATE_DIS);
907873
908874 /* Wa_1406463099:icl
909875 * Formerly known as WaGamTlbPendError
910876 */
911− I915_WRITE(GAMT_CHKN_BIT_REG,
912− I915_READ(GAMT_CHKN_BIT_REG) |
913− GAMT_CHKN_DISABLE_L3_COH_PIPE);
914−
915− /* Wa_1406609255:icl (pre-prod) */
916− if (IS_ICL_REVID(dev_priv, ICL_REVID_A0, ICL_REVID_B0))
917− I915_WRITE(GEN7_SARCHKMD,
918− I915_READ(GEN7_SARCHKMD) |
919− GEN7_DISABLE_DEMAND_PREFETCH |
920− GEN7_DISABLE_SAMPLER_PREFETCH);
877+ wa_write_or(wal,
878+ GAMT_CHKN_BIT_REG,
879+ GAMT_CHKN_DISABLE_L3_COH_PIPE);
921880 }
922881
923−void intel_gt_workarounds_apply(struct drm_i915_private *dev_priv)
882+void intel_gt_init_workarounds(struct drm_i915_private *i915)
924883 {
925− if (INTEL_GEN(dev_priv) < 8)
884+ struct i915_wa_list *wal = &i915->gt_wa_list;
885+
886+ wa_init_start(wal, "GT");
887+
888+ if (INTEL_GEN(i915) < 8)
889+ return;
890+ else if (IS_BROADWELL(i915))
926891 return;
927− else if (IS_BROADWELL(dev_priv))
928− bdw_gt_workarounds_apply(dev_priv);
929− else if (IS_CHERRYVIEW(dev_priv))
930− chv_gt_workarounds_apply(dev_priv);
931− else if (IS_SKYLAKE(dev_priv))
932− skl_gt_workarounds_apply(dev_priv);
933− else if (IS_BROXTON(dev_priv))
934− bxt_gt_workarounds_apply(dev_priv);
935− else if (IS_KABYLAKE(dev_priv))
936− kbl_gt_workarounds_apply(dev_priv);
937− else if (IS_GEMINILAKE(dev_priv))
938− glk_gt_workarounds_apply(dev_priv);
939− else if (IS_COFFEELAKE(dev_priv))
940− cfl_gt_workarounds_apply(dev_priv);
941− else if (IS_CANNONLAKE(dev_priv))
942− cnl_gt_workarounds_apply(dev_priv);
943− else if (IS_ICELAKE(dev_priv))
944− icl_gt_workarounds_apply(dev_priv);
892+ else if (IS_CHERRYVIEW(i915))
893+ return;
894+ else if (IS_SKYLAKE(i915))
895+ skl_gt_workarounds_init(i915);
896+ else if (IS_BROXTON(i915))
897+ bxt_gt_workarounds_init(i915);
898+ else if (IS_KABYLAKE(i915))
899+ kbl_gt_workarounds_init(i915);
900+ else if (IS_GEMINILAKE(i915))
901+ glk_gt_workarounds_init(i915);
902+ else if (IS_COFFEELAKE(i915))
903+ cfl_gt_workarounds_init(i915);
904+ else if (IS_CANNONLAKE(i915))
905+ cnl_gt_workarounds_init(i915);
906+ else if (IS_ICELAKE(i915))
907+ icl_gt_workarounds_init(i915);
945908 else
946− MISSING_CASE(INTEL_GEN(dev_priv));
909+ MISSING_CASE(INTEL_GEN(i915));
910+
911+ wa_init_finish(wal);
947912 }
948913
949−struct whitelist {
950− i915_reg_t reg[RING_MAX_NONPRIV_SLOTS];
951− unsigned int count;
952− u32 nopid;
953−};
914+static enum forcewake_domains
915+wal_get_fw_for_rmw(struct drm_i915_private *dev_priv,
916+ const struct i915_wa_list *wal)
917+{
918+ enum forcewake_domains fw = 0;
919+ struct i915_wa *wa;
920+ unsigned int i;
954921
955−static void whitelist_reg(struct whitelist *w, i915_reg_t reg)
922+ for (i = 0, wa = wal->list; i < wal->count; i++, wa++)
923+ fw |= intel_uncore_forcewake_for_reg(dev_priv,
924+ wa->reg,
925+ FW_REG_READ |
926+ FW_REG_WRITE);
927+
928+ return fw;
929+}
930+
931+static void
932+wa_list_apply(struct drm_i915_private *dev_priv, const struct i915_wa_list *wal)
956933 {
957− if (GEM_DEBUG_WARN_ON(w->count >= RING_MAX_NONPRIV_SLOTS))
934+ enum forcewake_domains fw;
935+ unsigned long flags;
936+ struct i915_wa *wa;
937+ unsigned int i;
938+
939+ if (!wal->count)
958940 return;
959941
960− w->reg[w->count++] = reg;
942+ fw = wal_get_fw_for_rmw(dev_priv, wal);
943+
944+ spin_lock_irqsave(&dev_priv->uncore.lock, flags);
945+ intel_uncore_forcewake_get__locked(dev_priv, fw);
946+
947+ for (i = 0, wa = wal->list; i < wal->count; i++, wa++) {
948+ u32 val = I915_READ_FW(wa->reg);
949+
950+ val &= ~wa->mask;
951+ val |= wa->val;
952+
953+ I915_WRITE_FW(wa->reg, val);
954+ }
955+
956+ intel_uncore_forcewake_put__locked(dev_priv, fw);
957+ spin_unlock_irqrestore(&dev_priv->uncore.lock, flags);
958+
959+ DRM_DEBUG_DRIVER("Applied %u %s workarounds\n", wal->count, wal->name);
960+}
961+
962+void intel_gt_apply_workarounds(struct drm_i915_private *dev_priv)
963+{
964+ wa_list_apply(dev_priv, &dev_priv->gt_wa_list);
965+}
966+
967+static bool
968+wa_verify(const struct i915_wa *wa, u32 cur, const char *name, const char *from)
969+{
970+ if ((cur ^ wa->val) & wa->mask) {
971+ DRM_ERROR("%s workaround lost on %s! (%x=%x/%x, expected %x, mask=%x)\n",
972+ name, from, i915_mmio_reg_offset(wa->reg), cur,
973+ cur & wa->mask, wa->val, wa->mask);
974+
975+ return false;
976+ }
977+
978+ return true;
961979 }
962980
963−static void bdw_whitelist_build(struct whitelist *w)
981+static bool wa_list_verify(struct drm_i915_private *dev_priv,
982+ const struct i915_wa_list *wal,
983+ const char *from)
964984 {
985+ struct i915_wa *wa;
986+ unsigned int i;
987+ bool ok = true;
988+
989+ for (i = 0, wa = wal->list; i < wal->count; i++, wa++)
990+ ok &= wa_verify(wa, I915_READ(wa->reg), wal->name, from);
991+
992+ return ok;
965993 }
966994
967−static void chv_whitelist_build(struct whitelist *w)
995+bool intel_gt_verify_workarounds(struct drm_i915_private *dev_priv,
996+ const char *from)
968997 {
998+ return wa_list_verify(dev_priv, &dev_priv->gt_wa_list, from);
969999 }
9701000
971−static void gen9_whitelist_build(struct whitelist *w)
1001+static void
1002+whitelist_reg(struct i915_wa_list *wal, i915_reg_t reg)
1003+{
1004+ struct i915_wa wa = {
1005+ .reg = reg
1006+ };
1007+
1008+ if (GEM_DEBUG_WARN_ON(wal->count >= RING_MAX_NONPRIV_SLOTS))
1009+ return;
1010+
1011+ _wa_add(wal, &wa);
1012+}
1013+
1014+static void gen9_whitelist_build(struct i915_wa_list *w)
9721015 {
9731016 /* WaVFEStateAfterPipeControlwithMediaStateClear:skl,bxt,glk,cfl */
9741017 whitelist_reg(w, GEN9_CTX_PREEMPT_REG);
@@ -980,7 +1023,7 @@ static void gen9_whitelist_build(struct whitelist *w) · 5 unmodified lines
9801023 whitelist_reg(w, GEN8_HDC_CHICKEN1);
9811024 }
9821025
983−static void skl_whitelist_build(struct whitelist *w)
1026+static void skl_whitelist_build(struct i915_wa_list *w)
9841027 {
9851028 gen9_whitelist_build(w);
9861029
@@ -988,12 +1031,12 @@ static void skl_whitelist_build(struct whitelist *w) · 1 unmodified line
9881031 whitelist_reg(w, GEN8_L3SQCREG4);
9891032 }
9901033
991−static void bxt_whitelist_build(struct whitelist *w)
1034+static void bxt_whitelist_build(struct i915_wa_list *w)
9921035 {
9931036 gen9_whitelist_build(w);
9941037 }
9951038
996−static void kbl_whitelist_build(struct whitelist *w)
1039+static void kbl_whitelist_build(struct i915_wa_list *w)
9971040 {
9981041 gen9_whitelist_build(w);
9991042
@@ -1001,7 +1044,7 @@ static void kbl_whitelist_build(struct whitelist *w) · 1 unmodified line
10011044 whitelist_reg(w, GEN8_L3SQCREG4);
10021045 }
10031046
1004−static void glk_whitelist_build(struct whitelist *w)
1047+static void glk_whitelist_build(struct i915_wa_list *w)
10051048 {
10061049 gen9_whitelist_build(w);
10071050
@@ -1009,18 +1052,18 @@ static void glk_whitelist_build(struct whitelist *w) · 1 unmodified line
10091052 whitelist_reg(w, GEN9_SLICE_COMMON_ECO_CHICKEN1);
10101053 }
10111054
1012−static void cfl_whitelist_build(struct whitelist *w)
1055+static void cfl_whitelist_build(struct i915_wa_list *w)
10131056 {
10141057 gen9_whitelist_build(w);
10151058 }
10161059
1017−static void cnl_whitelist_build(struct whitelist *w)
1060+static void cnl_whitelist_build(struct i915_wa_list *w)
10181061 {
10191062 /* WaEnablePreemptionGranularityControlByUMD:cnl */
10201063 whitelist_reg(w, GEN8_CS_CHICKEN1);
10211064 }
10221065
1023−static void icl_whitelist_build(struct whitelist *w)
1066+static void icl_whitelist_build(struct i915_wa_list *w)
10241067 {
10251068 /* WaAllowUMDToModifyHalfSliceChicken7:icl */
10261069 whitelist_reg(w, GEN9_HALF_SLICE_CHICKEN7);
@@ -1029,22 +1072,21 @@ static void icl_whitelist_build(struct whitelist *w) · 2 unmodified lines
10291072 whitelist_reg(w, GEN10_SAMPLER_MODE);
10301073 }
10311074
1032−static struct whitelist *whitelist_build(struct intel_engine_cs *engine,
1033− struct whitelist *w)
1075+void intel_engine_init_whitelist(struct intel_engine_cs *engine)
10341076 {
10351077 struct drm_i915_private *i915 = engine->i915;
1078+ struct i915_wa_list *w = &engine->whitelist;
10361079
10371080 GEM_BUG_ON(engine->id != RCS);
10381081
1039− w->count = 0;
1040− w->nopid = i915_mmio_reg_offset(RING_NOPID(engine->mmio_base));
1082+ wa_init_start(w, "whitelist");
10411083
10421084 if (INTEL_GEN(i915) < 8)
1043− return NULL;
1085+ return;
10441086 else if (IS_BROADWELL(i915))
1045− bdw_whitelist_build(w);
1087+ return;
10461088 else if (IS_CHERRYVIEW(i915))
1047− chv_whitelist_build(w);
1089+ return;
10481090 else if (IS_SKYLAKE(i915))
10491091 skl_whitelist_build(w);
10501092 else if (IS_BROXTON(i915))
@@ -1062,39 +1104,180 @@ static struct whitelist *whitelist_build(struct intel_engine_cs *engine, · 11 unmodified lines
10621104 else
10631105 MISSING_CASE(INTEL_GEN(i915));
10641106
1065− return w;
1107+ wa_init_finish(w);
10661108 }
10671109
1068−static void whitelist_apply(struct intel_engine_cs *engine,
1069− const struct whitelist *w)
1110+void intel_engine_apply_whitelist(struct intel_engine_cs *engine)
10701111 {
10711112 struct drm_i915_private *dev_priv = engine->i915;
1113+ const struct i915_wa_list *wal = &engine->whitelist;
10721114 const u32 base = engine->mmio_base;
1115+ struct i915_wa *wa;
10731116 unsigned int i;
10741117
1075− if (!w)
1118+ if (!wal->count)
10761119 return;
10771120
1078− intel_uncore_forcewake_get(engine->i915, FORCEWAKE_ALL);
1079−
1080− for (i = 0; i < w->count; i++)
1081− I915_WRITE_FW(RING_FORCE_TO_NONPRIV(base, i),
1082− i915_mmio_reg_offset(w->reg[i]));
1121+ for (i = 0, wa = wal->list; i < wal->count; i++, wa++)
1122+ I915_WRITE(RING_FORCE_TO_NONPRIV(base, i),
1123+ i915_mmio_reg_offset(wa->reg));
10831124
10841125 /* And clear the rest just in case of garbage */
10851126 for (; i < RING_MAX_NONPRIV_SLOTS; i++)
1086− I915_WRITE_FW(RING_FORCE_TO_NONPRIV(base, i), w->nopid);
1127+ I915_WRITE(RING_FORCE_TO_NONPRIV(base, i),
1128+ i915_mmio_reg_offset(RING_NOPID(base)));
10871129
1088− intel_uncore_forcewake_put(engine->i915, FORCEWAKE_ALL);
1130+ DRM_DEBUG_DRIVER("Applied %u %s workarounds\n", wal->count, wal->name);
10891131 }
10901132
1091−void intel_whitelist_workarounds_apply(struct intel_engine_cs *engine)
1133+static void rcs_engine_wa_init(struct intel_engine_cs *engine)
10921134 {
1093− struct whitelist w;
1135+ struct drm_i915_private *i915 = engine->i915;
1136+ struct i915_wa_list *wal = &engine->wa_list;
1137+
1138+ if (IS_ICELAKE(i915)) {
1139+ /* This is not an Wa. Enable for better image quality */
1140+ wa_masked_en(wal,
1141+ _3D_CHICKEN3,
1142+ _3D_CHICKEN3_AA_LINE_QUALITY_FIX_ENABLE);
1143+
1144+ /* WaPipelineFlushCoherentLines:icl */
1145+ wa_write_or(wal,
1146+ GEN8_L3SQCREG4,
1147+ GEN8_LQSC_FLUSH_COHERENT_LINES);
1148+
1149+ /*
1150+ * Wa_1405543622:icl
1151+ * Formerly known as WaGAPZPriorityScheme
1152+ */
1153+ wa_write_or(wal,
1154+ GEN8_GARBCNTL,
1155+ GEN11_ARBITRATION_PRIO_ORDER_MASK);
1156+
1157+ /*
1158+ * Wa_1604223664:icl
1159+ * Formerly known as WaL3BankAddressHashing
1160+ */
1161+ wa_write_masked_or(wal,
1162+ GEN8_GARBCNTL,
1163+ GEN11_HASH_CTRL_EXCL_MASK,
1164+ GEN11_HASH_CTRL_EXCL_BIT0);
1165+ wa_write_masked_or(wal,
1166+ GEN11_GLBLINVL,
1167+ GEN11_BANK_HASH_ADDR_EXCL_MASK,
1168+ GEN11_BANK_HASH_ADDR_EXCL_BIT0);
10941169
1095− whitelist_apply(engine, whitelist_build(engine, &w));
1170+ /*
1171+ * Wa_1405733216:icl
1172+ * Formerly known as WaDisableCleanEvicts
1173+ */
1174+ wa_write_or(wal,
1175+ GEN8_L3SQCREG4,
1176+ GEN11_LQSC_CLEAN_EVICT_DISABLE);
1177+
1178+ /* WaForwardProgressSoftReset:icl */
1179+ wa_write_or(wal,
1180+ GEN10_SCRATCH_LNCF2,
1181+ PMFLUSHDONE_LNICRSDROP |
1182+ PMFLUSH_GAPL3UNBLOCK |
1183+ PMFLUSHDONE_LNEBLK);
1184+
1185+ /* Wa_1406609255:icl (pre-prod) */
1186+ if (IS_ICL_REVID(i915, ICL_REVID_A0, ICL_REVID_B0))
1187+ wa_write_or(wal,
1188+ GEN7_SARCHKMD,
1189+ GEN7_DISABLE_DEMAND_PREFETCH |
1190+ GEN7_DISABLE_SAMPLER_PREFETCH);
1191+ }
1192+
1193+ if (IS_GEN9(i915) || IS_CANNONLAKE(i915)) {
1194+ /* WaEnablePreemptionGranularityControlByUMD:skl,bxt,kbl,cfl,cnl */
1195+ wa_masked_en(wal,
1196+ GEN7_FF_SLICE_CS_CHICKEN1,
1197+ GEN9_FFSC_PERCTX_PREEMPT_CTRL);
1198+ }
1199+
1200+ if (IS_SKYLAKE(i915) || IS_KABYLAKE(i915) || IS_COFFEELAKE(i915)) {
1201+ /* WaEnableGapsTsvCreditFix:skl,kbl,cfl */
1202+ wa_write_or(wal,
1203+ GEN8_GARBCNTL,
1204+ GEN9_GAPS_TSV_CREDIT_DISABLE);
1205+ }
1206+
1207+ if (IS_BROXTON(i915)) {
1208+ /* WaDisablePooledEuLoadBalancingFix:bxt */
1209+ wa_masked_en(wal,
1210+ FF_SLICE_CS_CHICKEN2,
1211+ GEN9_POOLED_EU_LOAD_BALANCING_FIX_DISABLE);
1212+ }
1213+
1214+ if (IS_GEN9(i915)) {
1215+ /* WaContextSwitchWithConcurrentTLBInvalidate:skl,bxt,kbl,glk,cfl */
1216+ wa_masked_en(wal,
1217+ GEN9_CSFE_CHICKEN1_RCS,
1218+ GEN9_PREEMPT_GPGPU_SYNC_SWITCH_DISABLE);
1219+
1220+ /* WaEnableLbsSlaRetryTimerDecrement:skl,bxt,kbl,glk,cfl */
1221+ wa_write_or(wal,
1222+ BDW_SCRATCH1,
1223+ GEN9_LBS_SLA_RETRY_TIMER_DECREMENT_ENABLE);
1224+
1225+ /* WaProgramL3SqcReg1DefaultForPerf:bxt,glk */
1226+ if (IS_GEN9_LP(i915))
1227+ wa_write_masked_or(wal,
1228+ GEN8_L3SQCREG1,
1229+ L3_PRIO_CREDITS_MASK,
1230+ L3_GENERAL_PRIO_CREDITS(62) |
1231+ L3_HIGH_PRIO_CREDITS(2));
1232+
1233+ /* WaOCLCoherentLineFlush:skl,bxt,kbl,cfl */
1234+ wa_write_or(wal,
1235+ GEN8_L3SQCREG4,
1236+ GEN8_LQSC_FLUSH_COHERENT_LINES);
1237+ }
1238+}
1239+
1240+static void xcs_engine_wa_init(struct intel_engine_cs *engine)
1241+{
1242+ struct drm_i915_private *i915 = engine->i915;
1243+ struct i915_wa_list *wal = &engine->wa_list;
1244+
1245+ /* WaKBLVECSSemaphoreWaitPoll:kbl */
1246+ if (IS_KBL_REVID(i915, KBL_REVID_A0, KBL_REVID_E0)) {
1247+ wa_write(wal,
1248+ RING_SEMA_WAIT_POLL(engine->mmio_base),
1249+ 1);
1250+ }
1251+}
1252+
1253+void intel_engine_init_workarounds(struct intel_engine_cs *engine)
1254+{
1255+ struct i915_wa_list *wal = &engine->wa_list;
1256+
1257+ if (GEM_WARN_ON(INTEL_GEN(engine->i915) < 8))
1258+ return;
1259+
1260+ wa_init_start(wal, engine->name);
1261+
1262+ if (engine->id == RCS)
1263+ rcs_engine_wa_init(engine);
1264+ else
1265+ xcs_engine_wa_init(engine);
1266+
1267+ wa_init_finish(wal);
1268+}
1269+
1270+void intel_engine_apply_workarounds(struct intel_engine_cs *engine)
1271+{
1272+ wa_list_apply(engine->i915, &engine->wa_list);
10961273 }
10971274
10981275 #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
1276+static bool intel_engine_verify_workarounds(struct intel_engine_cs *engine,
1277+ const char *from)
1278+{
1279+ return wa_list_verify(engine->i915, &engine->wa_list, from);
1280+}
1281+
10991282 #include "selftests/intel_workarounds.c"
11001283 #endif
drivers/gpu/drm/i915/intel_workarounds.h+32−4
@@ -7,11 +7,39 @@ · 6 unmodified lines
77 #ifndef _I915_WORKAROUNDS_H_
88 #define _I915_WORKAROUNDS_H_
99
10−int intel_ctx_workarounds_init(struct drm_i915_private *dev_priv);
11−int intel_ctx_workarounds_emit(struct i915_request *rq);
10+#include <linux/slab.h>
1211
13−void intel_gt_workarounds_apply(struct drm_i915_private *dev_priv);
12+struct i915_wa {
13+ i915_reg_t reg;
14+ u32 mask;
15+ u32 val;
16+};
1417
15−void intel_whitelist_workarounds_apply(struct intel_engine_cs *engine);
18+struct i915_wa_list {
19+ const char *name;
20+ struct i915_wa *list;
21+ unsigned int count;
22+ unsigned int wa_count;
23+};
24+
25+static inline void intel_wa_list_free(struct i915_wa_list *wal)
26+{
27+ kfree(wal->list);
28+ memset(wal, 0, sizeof(*wal));
29+}
30+
31+void intel_engine_init_ctx_wa(struct intel_engine_cs *engine);
32+int intel_engine_emit_ctx_wa(struct i915_request *rq);
33+
34+void intel_gt_init_workarounds(struct drm_i915_private *dev_priv);
35+void intel_gt_apply_workarounds(struct drm_i915_private *dev_priv);
36+bool intel_gt_verify_workarounds(struct drm_i915_private *dev_priv,
37+ const char *from);
38+
39+void intel_engine_init_whitelist(struct intel_engine_cs *engine);
40+void intel_engine_apply_whitelist(struct intel_engine_cs *engine);
41+
42+void intel_engine_init_workarounds(struct intel_engine_cs *engine);
43+void intel_engine_apply_workarounds(struct intel_engine_cs *engine);
1644
1745 #endif
drivers/gpu/drm/i915/selftests/igt_reset.c+44−0
@@ -0,0 +1,44 @@
1+/*
2+ * SPDX-License-Identifier: MIT
3+ *
4+ * Copyright © 2018 Intel Corporation
5+ */
6+
7+#include "igt_reset.h"
8+
9+#include "../i915_drv.h"
10+#include "../intel_ringbuffer.h"
11+
12+void igt_global_reset_lock(struct drm_i915_private *i915)
13+{
14+ struct intel_engine_cs *engine;
15+ enum intel_engine_id id;
16+
17+ pr_debug("%s: current gpu_error=%08lx\n",
18+ __func__, i915->gpu_error.flags);
19+
20+ while (test_and_set_bit(I915_RESET_BACKOFF, &i915->gpu_error.flags))
21+ wait_event(i915->gpu_error.reset_queue,
22+ !test_bit(I915_RESET_BACKOFF,
23+ &i915->gpu_error.flags));
24+
25+ for_each_engine(engine, i915, id) {
26+ while (test_and_set_bit(I915_RESET_ENGINE + id,
27+ &i915->gpu_error.flags))
28+ wait_on_bit(&i915->gpu_error.flags,
29+ I915_RESET_ENGINE + id,
30+ TASK_UNINTERRUPTIBLE);
31+ }
32+}
33+
34+void igt_global_reset_unlock(struct drm_i915_private *i915)
35+{
36+ struct intel_engine_cs *engine;
37+ enum intel_engine_id id;
38+
39+ for_each_engine(engine, i915, id)
40+ clear_bit(I915_RESET_ENGINE + id, &i915->gpu_error.flags);
41+
42+ clear_bit(I915_RESET_BACKOFF, &i915->gpu_error.flags);
43+ wake_up_all(&i915->gpu_error.reset_queue);
44+}
drivers/gpu/drm/i915/selftests/igt_reset.h+15−0
@@ -0,0 +1,15 @@
1+/*
2+ * SPDX-License-Identifier: MIT
3+ *
4+ * Copyright © 2018 Intel Corporation
5+ */
6+
7+#ifndef __I915_SELFTESTS_IGT_RESET_H__
8+#define __I915_SELFTESTS_IGT_RESET_H__
9+
10+#include "../i915_drv.h"
11+
12+void igt_global_reset_lock(struct drm_i915_private *i915);
13+void igt_global_reset_unlock(struct drm_i915_private *i915);
14+
15+#endif
drivers/gpu/drm/i915/selftests/igt_spinner.c+199−0
@@ -0,0 +1,199 @@
1+/*
2+ * SPDX-License-Identifier: MIT
3+ *
4+ * Copyright © 2018 Intel Corporation
5+ */
6+
7+#include "igt_spinner.h"
8+
9+int igt_spinner_init(struct igt_spinner *spin, struct drm_i915_private *i915)
10+{
11+ unsigned int mode;
12+ void *vaddr;
13+ int err;
14+
15+ GEM_BUG_ON(INTEL_GEN(i915) < 8);
16+
17+ memset(spin, 0, sizeof(*spin));
18+ spin->i915 = i915;
19+
20+ spin->hws = i915_gem_object_create_internal(i915, PAGE_SIZE);
21+ if (IS_ERR(spin->hws)) {
22+ err = PTR_ERR(spin->hws);
23+ goto err;
24+ }
25+
26+ spin->obj = i915_gem_object_create_internal(i915, PAGE_SIZE);
27+ if (IS_ERR(spin->obj)) {
28+ err = PTR_ERR(spin->obj);
29+ goto err_hws;
30+ }
31+
32+ i915_gem_object_set_cache_level(spin->hws, I915_CACHE_LLC);
33+ vaddr = i915_gem_object_pin_map(spin->hws, I915_MAP_WB);
34+ if (IS_ERR(vaddr)) {
35+ err = PTR_ERR(vaddr);
36+ goto err_obj;
37+ }
38+ spin->seqno = memset(vaddr, 0xff, PAGE_SIZE);
39+
40+ mode = i915_coherent_map_type(i915);
41+ vaddr = i915_gem_object_pin_map(spin->obj, mode);
42+ if (IS_ERR(vaddr)) {
43+ err = PTR_ERR(vaddr);
44+ goto err_unpin_hws;
45+ }
46+ spin->batch = vaddr;
47+
48+ return 0;
49+
50+err_unpin_hws:
51+ i915_gem_object_unpin_map(spin->hws);
52+err_obj:
53+ i915_gem_object_put(spin->obj);
54+err_hws:
55+ i915_gem_object_put(spin->hws);
56+err:
57+ return err;
58+}
59+
60+static unsigned int seqno_offset(u64 fence)
61+{
62+ return offset_in_page(sizeof(u32) * fence);
63+}
64+
65+static u64 hws_address(const struct i915_vma *hws,
66+ const struct i915_request *rq)
67+{
68+ return hws->node.start + seqno_offset(rq->fence.context);
69+}
70+
71+static int emit_recurse_batch(struct igt_spinner *spin,
72+ struct i915_request *rq,
73+ u32 arbitration_command)
74+{
75+ struct i915_address_space *vm = &rq->gem_context->ppgtt->vm;
76+ struct i915_vma *hws, *vma;
77+ u32 *batch;
78+ int err;
79+
80+ vma = i915_vma_instance(spin->obj, vm, NULL);
81+ if (IS_ERR(vma))
82+ return PTR_ERR(vma);
83+
84+ hws = i915_vma_instance(spin->hws, vm, NULL);
85+ if (IS_ERR(hws))
86+ return PTR_ERR(hws);
87+
88+ err = i915_vma_pin(vma, 0, 0, PIN_USER);
89+ if (err)
90+ return err;
91+
92+ err = i915_vma_pin(hws, 0, 0, PIN_USER);
93+ if (err)
94+ goto unpin_vma;
95+
96+ err = i915_vma_move_to_active(vma, rq, 0);
97+ if (err)
98+ goto unpin_hws;
99+
100+ if (!i915_gem_object_has_active_reference(vma->obj)) {
101+ i915_gem_object_get(vma->obj);
102+ i915_gem_object_set_active_reference(vma->obj);
103+ }
104+
105+ err = i915_vma_move_to_active(hws, rq, 0);
106+ if (err)
107+ goto unpin_hws;
108+
109+ if (!i915_gem_object_has_active_reference(hws->obj)) {
110+ i915_gem_object_get(hws->obj);
111+ i915_gem_object_set_active_reference(hws->obj);
112+ }
113+
114+ batch = spin->batch;
115+
116+ *batch++ = MI_STORE_DWORD_IMM_GEN4;
117+ *batch++ = lower_32_bits(hws_address(hws, rq));
118+ *batch++ = upper_32_bits(hws_address(hws, rq));
119+ *batch++ = rq->fence.seqno;
120+
121+ *batch++ = arbitration_command;
122+
123+ *batch++ = MI_BATCH_BUFFER_START | 1 << 8 | 1;
124+ *batch++ = lower_32_bits(vma->node.start);
125+ *batch++ = upper_32_bits(vma->node.start);
126+ *batch++ = MI_BATCH_BUFFER_END; /* not reached */
127+
128+ i915_gem_chipset_flush(spin->i915);
129+
130+ err = rq->engine->emit_bb_start(rq, vma->node.start, PAGE_SIZE, 0);
131+
132+unpin_hws:
133+ i915_vma_unpin(hws);
134+unpin_vma:
135+ i915_vma_unpin(vma);
136+ return err;
137+}
138+
139+struct i915_request *
140+igt_spinner_create_request(struct igt_spinner *spin,
141+ struct i915_gem_context *ctx,
142+ struct intel_engine_cs *engine,
143+ u32 arbitration_command)
144+{
145+ struct i915_request *rq;
146+ int err;
147+
148+ rq = i915_request_alloc(engine, ctx);
149+ if (IS_ERR(rq))
150+ return rq;
151+
152+ err = emit_recurse_batch(spin, rq, arbitration_command);
153+ if (err) {
154+ i915_request_add(rq);
155+ return ERR_PTR(err);
156+ }
157+
158+ return rq;
159+}
160+
161+static u32
162+hws_seqno(const struct igt_spinner *spin, const struct i915_request *rq)
163+{
164+ u32 *seqno = spin->seqno + seqno_offset(rq->fence.context);
165+
166+ return READ_ONCE(*seqno);
167+}
168+
169+void igt_spinner_end(struct igt_spinner *spin)
170+{
171+ *spin->batch = MI_BATCH_BUFFER_END;
172+ i915_gem_chipset_flush(spin->i915);
173+}
174+
175+void igt_spinner_fini(struct igt_spinner *spin)
176+{
177+ igt_spinner_end(spin);
178+
179+ i915_gem_object_unpin_map(spin->obj);
180+ i915_gem_object_put(spin->obj);
181+
182+ i915_gem_object_unpin_map(spin->hws);
183+ i915_gem_object_put(spin->hws);
184+}
185+
186+bool igt_wait_for_spinner(struct igt_spinner *spin, struct i915_request *rq)
187+{
188+ if (!wait_event_timeout(rq->execute,
189+ READ_ONCE(rq->global_seqno),
190+ msecs_to_jiffies(10)))
191+ return false;
192+
193+ return !(wait_for_us(i915_seqno_passed(hws_seqno(spin, rq),
194+ rq->fence.seqno),
195+ 10) &&
196+ wait_for(i915_seqno_passed(hws_seqno(spin, rq),
197+ rq->fence.seqno),
198+ 1000));
199+}
drivers/gpu/drm/i915/selftests/igt_spinner.h+37−0
@@ -0,0 +1,37 @@
1+/*
2+ * SPDX-License-Identifier: MIT
3+ *
4+ * Copyright © 2018 Intel Corporation
5+ */
6+
7+#ifndef __I915_SELFTESTS_IGT_SPINNER_H__
8+#define __I915_SELFTESTS_IGT_SPINNER_H__
9+
10+#include "../i915_selftest.h"
11+
12+#include "../i915_drv.h"
13+#include "../i915_request.h"
14+#include "../intel_ringbuffer.h"
15+#include "../i915_gem_context.h"
16+
17+struct igt_spinner {
18+ struct drm_i915_private *i915;
19+ struct drm_i915_gem_object *hws;
20+ struct drm_i915_gem_object *obj;
21+ u32 *batch;
22+ void *seqno;
23+};
24+
25+int igt_spinner_init(struct igt_spinner *spin, struct drm_i915_private *i915);
26+void igt_spinner_fini(struct igt_spinner *spin);
27+
28+struct i915_request *
29+igt_spinner_create_request(struct igt_spinner *spin,
30+ struct i915_gem_context *ctx,
31+ struct intel_engine_cs *engine,
32+ u32 arbitration_command);
33+void igt_spinner_end(struct igt_spinner *spin);
34+
35+bool igt_wait_for_spinner(struct igt_spinner *spin, struct i915_request *rq);
36+
37+#endif
drivers/gpu/drm/i915/selftests/intel_hangcheck.c+18−45
@@ -27,6 +27,7 @@ · 26 unmodified lines
2727 #include "../i915_selftest.h"
2828 #include "i915_random.h"
2929 #include "igt_flush_test.h"
30+#include "igt_reset.h"
3031 #include "igt_wedge_me.h"
3132
3233 #include "mock_context.h"
@@ -308,6 +309,7 @@ static int igt_hang_sanitycheck(void *arg) · 275 unmodified lines
308309 goto unlock;
309310
310311 for_each_engine(engine, i915, id) {
312+ struct igt_wedge_me w;
311313 long timeout;
312314
313315 if (!intel_engine_can_store_dword(engine))
@@ -328,9 +330,14 @@ static int igt_hang_sanitycheck(void *arg) · 14 unmodified lines
328330
329331 i915_request_add(rq);
330332
331− timeout = i915_request_wait(rq,
332− I915_WAIT_LOCKED,
333− MAX_SCHEDULE_TIMEOUT);
333+ timeout = 0;
334+ igt_wedge_on_timeout(&w, i915, HZ / 10 /* 100ms timeout*/)
335+ timeout = i915_request_wait(rq,
336+ I915_WAIT_LOCKED,
337+ MAX_SCHEDULE_TIMEOUT);
338+ if (i915_terminally_wedged(&i915->gpu_error))
339+ timeout = -EIO;
340+
334341 i915_request_put(rq);
335342
336343 if (timeout < 0) {
@@ -348,40 +355,6 @@ unlock: · 11 unmodified lines
348355 return err;
349356 }
350357
351−static void global_reset_lock(struct drm_i915_private *i915)
352−{
353− struct intel_engine_cs *engine;
354− enum intel_engine_id id;
355−
356− pr_debug("%s: current gpu_error=%08lx\n",
357− __func__, i915->gpu_error.flags);
358−
359− while (test_and_set_bit(I915_RESET_BACKOFF, &i915->gpu_error.flags))
360− wait_event(i915->gpu_error.reset_queue,
361− !test_bit(I915_RESET_BACKOFF,
362− &i915->gpu_error.flags));
363−
364− for_each_engine(engine, i915, id) {
365− while (test_and_set_bit(I915_RESET_ENGINE + id,
366− &i915->gpu_error.flags))
367− wait_on_bit(&i915->gpu_error.flags,
368− I915_RESET_ENGINE + id,
369− TASK_UNINTERRUPTIBLE);
370− }
371−}
372−
373−static void global_reset_unlock(struct drm_i915_private *i915)
374−{
375− struct intel_engine_cs *engine;
376− enum intel_engine_id id;
377−
378− for_each_engine(engine, i915, id)
379− clear_bit(I915_RESET_ENGINE + id, &i915->gpu_error.flags);
380−
381− clear_bit(I915_RESET_BACKOFF, &i915->gpu_error.flags);
382− wake_up_all(&i915->gpu_error.reset_queue);
383−}
384−
385358 static int igt_global_reset(void *arg)
386359 {
387360 struct drm_i915_private *i915 = arg;
@@ -390,7 +363,7 @@ static int igt_global_reset(void *arg) · 2 unmodified lines
390363
391364 /* Check that we can issue a global GPU reset */
392365
393− global_reset_lock(i915);
366+ igt_global_reset_lock(i915);
394367 set_bit(I915_RESET_HANDOFF, &i915->gpu_error.flags);
395368
396369 mutex_lock(&i915->drm.struct_mutex);
@@ -405,7 +378,7 @@ static int igt_global_reset(void *arg) · 8 unmodified lines
405378 mutex_unlock(&i915->drm.struct_mutex);
406379
407380 GEM_BUG_ON(test_bit(I915_RESET_HANDOFF, &i915->gpu_error.flags));
408− global_reset_unlock(i915);
381+ igt_global_reset_unlock(i915);
409382
410383 if (i915_terminally_wedged(&i915->gpu_error))
411384 err = -EIO;
@@ -936,7 +909,7 @@ static int igt_reset_wait(void *arg) · 524 unmodified lines
936909
937910 /* Check that we detect a stuck waiter and issue a reset */
938911
939− global_reset_lock(i915);
912+ igt_global_reset_lock(i915);
940913
941914 mutex_lock(&i915->drm.struct_mutex);
942915 err = hang_init(&h, i915);
@@ -988,7 +961,7 @@ fini: · 45 unmodified lines
988961 hang_fini(&h);
989962 unlock:
990963 mutex_unlock(&i915->drm.struct_mutex);
991− global_reset_unlock(i915);
964+ igt_global_reset_unlock(i915);
992965
993966 if (i915_terminally_wedged(&i915->gpu_error))
994967 return -EIO;
@@ -1066,7 +1039,7 @@ static int __igt_reset_evict_vma(struct drm_i915_private *i915, · 71 unmodified lines
10661039
10671040 /* Check that we can recover an unbind stuck on a hanging request */
10681041
1069− global_reset_lock(i915);
1042+ igt_global_reset_lock(i915);
10701043
10711044 mutex_lock(&i915->drm.struct_mutex);
10721045 err = hang_init(&h, i915);
@@ -1186,7 +1159,7 @@ fini: · 113 unmodified lines
11861159 hang_fini(&h);
11871160 unlock:
11881161 mutex_unlock(&i915->drm.struct_mutex);
1189− global_reset_unlock(i915);
1162+ igt_global_reset_unlock(i915);
11901163
11911164 if (i915_terminally_wedged(&i915->gpu_error))
11921165 return -EIO;
@@ -1266,7 +1239,7 @@ static int igt_reset_queue(void *arg) · 73 unmodified lines
12661239
12671240 /* Check that we replay pending requests following a hang */
12681241
1269− global_reset_lock(i915);
1242+ igt_global_reset_lock(i915);
12701243
12711244 mutex_lock(&i915->drm.struct_mutex);
12721245 err = hang_init(&h, i915);
@@ -1397,7 +1370,7 @@ fini: · 124 unmodified lines
13971370 hang_fini(&h);
13981371 unlock:
13991372 mutex_unlock(&i915->drm.struct_mutex);
1400− global_reset_unlock(i915);
1373+ igt_global_reset_unlock(i915);
14011374
14021375 if (i915_terminally_wedged(&i915->gpu_error))
14031376 return -EIO;
drivers/gpu/drm/i915/selftests/intel_lrc.c+52−249
@@ -6,216 +6,18 @@ · 5 unmodified lines
66
77 #include "../i915_selftest.h"
88 #include "igt_flush_test.h"
9+#include "igt_spinner.h"
910 #include "i915_random.h"
1011
1112 #include "mock_context.h"
1213
13−struct spinner {
14− struct drm_i915_private *i915;
15− struct drm_i915_gem_object *hws;
16− struct drm_i915_gem_object *obj;
17− u32 *batch;
18− void *seqno;
19−};
20−
21−static int spinner_init(struct spinner *spin, struct drm_i915_private *i915)
22−{
23− unsigned int mode;
24− void *vaddr;
25− int err;
26−
27− GEM_BUG_ON(INTEL_GEN(i915) < 8);
28−
29− memset(spin, 0, sizeof(*spin));
30− spin->i915 = i915;
31−
32− spin->hws = i915_gem_object_create_internal(i915, PAGE_SIZE);
33− if (IS_ERR(spin->hws)) {
34− err = PTR_ERR(spin->hws);
35− goto err;
36− }
37−
38− spin->obj = i915_gem_object_create_internal(i915, PAGE_SIZE);
39− if (IS_ERR(spin->obj)) {
40− err = PTR_ERR(spin->obj);
41− goto err_hws;
42− }
43−
44− i915_gem_object_set_cache_level(spin->hws, I915_CACHE_LLC);
45− vaddr = i915_gem_object_pin_map(spin->hws, I915_MAP_WB);
46− if (IS_ERR(vaddr)) {
47− err = PTR_ERR(vaddr);
48− goto err_obj;
49− }
50− spin->seqno = memset(vaddr, 0xff, PAGE_SIZE);
51−
52− mode = i915_coherent_map_type(i915);
53− vaddr = i915_gem_object_pin_map(spin->obj, mode);
54− if (IS_ERR(vaddr)) {
55− err = PTR_ERR(vaddr);
56− goto err_unpin_hws;
57− }
58− spin->batch = vaddr;
59−
60− return 0;
61−
62−err_unpin_hws:
63− i915_gem_object_unpin_map(spin->hws);
64−err_obj:
65− i915_gem_object_put(spin->obj);
66−err_hws:
67− i915_gem_object_put(spin->hws);
68−err:
69− return err;
70−}
71−
72−static unsigned int seqno_offset(u64 fence)
73−{
74− return offset_in_page(sizeof(u32) * fence);
75−}
76−
77−static u64 hws_address(const struct i915_vma *hws,
78− const struct i915_request *rq)
79−{
80− return hws->node.start + seqno_offset(rq->fence.context);
81−}
82−
83−static int emit_recurse_batch(struct spinner *spin,
84− struct i915_request *rq,
85− u32 arbitration_command)
86−{
87− struct i915_address_space *vm = &rq->gem_context->ppgtt->vm;
88− struct i915_vma *hws, *vma;
89− u32 *batch;
90− int err;
91−
92− vma = i915_vma_instance(spin->obj, vm, NULL);
93− if (IS_ERR(vma))
94− return PTR_ERR(vma);
95−
96− hws = i915_vma_instance(spin->hws, vm, NULL);
97− if (IS_ERR(hws))
98− return PTR_ERR(hws);
99−
100− err = i915_vma_pin(vma, 0, 0, PIN_USER);
101− if (err)
102− return err;
103−
104− err = i915_vma_pin(hws, 0, 0, PIN_USER);
105− if (err)
106− goto unpin_vma;
107−
108− err = i915_vma_move_to_active(vma, rq, 0);
109− if (err)
110− goto unpin_hws;
111−
112− if (!i915_gem_object_has_active_reference(vma->obj)) {
113− i915_gem_object_get(vma->obj);
114− i915_gem_object_set_active_reference(vma->obj);
115− }
116−
117− err = i915_vma_move_to_active(hws, rq, 0);
118− if (err)
119− goto unpin_hws;
120−
121− if (!i915_gem_object_has_active_reference(hws->obj)) {
122− i915_gem_object_get(hws->obj);
123− i915_gem_object_set_active_reference(hws->obj);
124− }
125−
126− batch = spin->batch;
127−
128− *batch++ = MI_STORE_DWORD_IMM_GEN4;
129− *batch++ = lower_32_bits(hws_address(hws, rq));
130− *batch++ = upper_32_bits(hws_address(hws, rq));
131− *batch++ = rq->fence.seqno;
132−
133− *batch++ = arbitration_command;
134−
135− *batch++ = MI_BATCH_BUFFER_START | 1 << 8 | 1;
136− *batch++ = lower_32_bits(vma->node.start);
137− *batch++ = upper_32_bits(vma->node.start);
138− *batch++ = MI_BATCH_BUFFER_END; /* not reached */
139−
140− i915_gem_chipset_flush(spin->i915);
141−
142− err = rq->engine->emit_bb_start(rq, vma->node.start, PAGE_SIZE, 0);
143−
144−unpin_hws:
145− i915_vma_unpin(hws);
146−unpin_vma:
147− i915_vma_unpin(vma);
148− return err;
149−}
150−
151−static struct i915_request *
152−spinner_create_request(struct spinner *spin,
153− struct i915_gem_context *ctx,
154− struct intel_engine_cs *engine,
155− u32 arbitration_command)
156−{
157− struct i915_request *rq;
158− int err;
159−
160− rq = i915_request_alloc(engine, ctx);
161− if (IS_ERR(rq))
162− return rq;
163−
164− err = emit_recurse_batch(spin, rq, arbitration_command);
165− if (err) {
166− i915_request_add(rq);
167− return ERR_PTR(err);
168− }
169−
170− return rq;
171−}
172−
173−static u32 hws_seqno(const struct spinner *spin, const struct i915_request *rq)
174−{
175− u32 *seqno = spin->seqno + seqno_offset(rq->fence.context);
176−
177− return READ_ONCE(*seqno);
178−}
179−
180−static void spinner_end(struct spinner *spin)
181−{
182− *spin->batch = MI_BATCH_BUFFER_END;
183− i915_gem_chipset_flush(spin->i915);
184−}
185−
186−static void spinner_fini(struct spinner *spin)
187−{
188− spinner_end(spin);
189−
190− i915_gem_object_unpin_map(spin->obj);
191− i915_gem_object_put(spin->obj);
192−
193− i915_gem_object_unpin_map(spin->hws);
194− i915_gem_object_put(spin->hws);
195−}
196−
197−static bool wait_for_spinner(struct spinner *spin, struct i915_request *rq)
198−{
199− if (!wait_event_timeout(rq->execute,
200− READ_ONCE(rq->global_seqno),
201− msecs_to_jiffies(10)))
202− return false;
203−
204− return !(wait_for_us(i915_seqno_passed(hws_seqno(spin, rq),
205− rq->fence.seqno),
206− 10) &&
207− wait_for(i915_seqno_passed(hws_seqno(spin, rq),
208− rq->fence.seqno),
209− 1000));
210−}
211−
21214 static int live_sanitycheck(void *arg)
21315 {
21416 struct drm_i915_private *i915 = arg;
21517 struct intel_engine_cs *engine;
21618 struct i915_gem_context *ctx;
21719 enum intel_engine_id id;
218− struct spinner spin;
20+ struct igt_spinner spin;
21921 int err = -ENOMEM;
22022
22123 if (!HAS_LOGICAL_RING_CONTEXTS(i915))
@@ -224,7 +26,7 @@ static int live_sanitycheck(void *arg) · 2 unmodified lines
22426 mutex_lock(&i915->drm.struct_mutex);
22527 intel_runtime_pm_get(i915);
22628
227− if (spinner_init(&spin, i915))
29+ if (igt_spinner_init(&spin, i915))
22830 goto err_unlock;
22931
23032 ctx = kernel_context(i915);
@@ -234,14 +36,14 @@ static int live_sanitycheck(void *arg) · 3 unmodified lines
23436 for_each_engine(engine, i915, id) {
23537 struct i915_request *rq;
23638
237− rq = spinner_create_request(&spin, ctx, engine, MI_NOOP);
39+ rq = igt_spinner_create_request(&spin, ctx, engine, MI_NOOP);
23840 if (IS_ERR(rq)) {
23941 err = PTR_ERR(rq);
24042 goto err_ctx;
24143 }
24244
24345 i915_request_add(rq);
244− if (!wait_for_spinner(&spin, rq)) {
46+ if (!igt_wait_for_spinner(&spin, rq)) {
24547 GEM_TRACE("spinner failed to start\n");
24648 GEM_TRACE_DUMP();
24749 i915_gem_set_wedged(i915);
@@ -249,7 +51,7 @@ static int live_sanitycheck(void *arg) · 1 unmodified line
24951 goto err_ctx;
25052 }
25153
252− spinner_end(&spin);
54+ igt_spinner_end(&spin);
25355 if (igt_flush_test(i915, I915_WAIT_LOCKED)) {
25456 err = -EIO;
25557 goto err_ctx;
@@ -260,7 +62,7 @@ static int live_sanitycheck(void *arg) · 4 unmodified lines
26062 err_ctx:
26163 kernel_context_close(ctx);
26264 err_spin:
263− spinner_fini(&spin);
65+ igt_spinner_fini(&spin);
26466 err_unlock:
26567 igt_flush_test(i915, I915_WAIT_LOCKED);
26668 intel_runtime_pm_put(i915);
@@ -272,7 +74,7 @@ static int live_preempt(void *arg) · 5 unmodified lines
27274 {
27375 struct drm_i915_private *i915 = arg;
27476 struct i915_gem_context *ctx_hi, *ctx_lo;
275− struct spinner spin_hi, spin_lo;
77+ struct igt_spinner spin_hi, spin_lo;
27678 struct intel_engine_cs *engine;
27779 enum intel_engine_id id;
27880 int err = -ENOMEM;
@@ -283,10 +85,10 @@ static int live_preempt(void *arg) · 4 unmodified lines
28385 mutex_lock(&i915->drm.struct_mutex);
28486 intel_runtime_pm_get(i915);
28587
286− if (spinner_init(&spin_hi, i915))
88+ if (igt_spinner_init(&spin_hi, i915))
28789 goto err_unlock;
28890
289− if (spinner_init(&spin_lo, i915))
91+ if (igt_spinner_init(&spin_lo, i915))
29092 goto err_spin_hi;
29193
29294 ctx_hi = kernel_context(i915);
@@ -304,15 +106,15 @@ static int live_preempt(void *arg) · 11 unmodified lines
304106 for_each_engine(engine, i915, id) {
305107 struct i915_request *rq;
306108
307− rq = spinner_create_request(&spin_lo, ctx_lo, engine,
308− MI_ARB_CHECK);
109+ rq = igt_spinner_create_request(&spin_lo, ctx_lo, engine,
110+ MI_ARB_CHECK);
309111 if (IS_ERR(rq)) {
310112 err = PTR_ERR(rq);
311113 goto err_ctx_lo;
312114 }
313115
314116 i915_request_add(rq);
315− if (!wait_for_spinner(&spin_lo, rq)) {
117+ if (!igt_wait_for_spinner(&spin_lo, rq)) {
316118 GEM_TRACE("lo spinner failed to start\n");
317119 GEM_TRACE_DUMP();
318120 i915_gem_set_wedged(i915);
@@ -320,16 +122,16 @@ static int live_preempt(void *arg) · 1 unmodified line
320122 goto err_ctx_lo;
321123 }
322124
323− rq = spinner_create_request(&spin_hi, ctx_hi, engine,
324− MI_ARB_CHECK);
125+ rq = igt_spinner_create_request(&spin_hi, ctx_hi, engine,
126+ MI_ARB_CHECK);
325127 if (IS_ERR(rq)) {
326− spinner_end(&spin_lo);
128+ igt_spinner_end(&spin_lo);
327129 err = PTR_ERR(rq);
328130 goto err_ctx_lo;
329131 }
330132
331133 i915_request_add(rq);
332− if (!wait_for_spinner(&spin_hi, rq)) {
134+ if (!igt_wait_for_spinner(&spin_hi, rq)) {
333135 GEM_TRACE("hi spinner failed to start\n");
334136 GEM_TRACE_DUMP();
335137 i915_gem_set_wedged(i915);
@@ -337,8 +139,8 @@ static int live_preempt(void *arg) · 1 unmodified line
337139 goto err_ctx_lo;
338140 }
339141
340− spinner_end(&spin_hi);
341− spinner_end(&spin_lo);
142+ igt_spinner_end(&spin_hi);
143+ igt_spinner_end(&spin_lo);
342144 if (igt_flush_test(i915, I915_WAIT_LOCKED)) {
343145 err = -EIO;
344146 goto err_ctx_lo;
@@ -351,9 +153,9 @@ err_ctx_lo: · 6 unmodified lines
351153 err_ctx_hi:
352154 kernel_context_close(ctx_hi);
353155 err_spin_lo:
354− spinner_fini(&spin_lo);
156+ igt_spinner_fini(&spin_lo);
355157 err_spin_hi:
356− spinner_fini(&spin_hi);
158+ igt_spinner_fini(&spin_hi);
357159 err_unlock:
358160 igt_flush_test(i915, I915_WAIT_LOCKED);
359161 intel_runtime_pm_put(i915);
@@ -365,7 +167,7 @@ static int live_late_preempt(void *arg) · 5 unmodified lines
365167 {
366168 struct drm_i915_private *i915 = arg;
367169 struct i915_gem_context *ctx_hi, *ctx_lo;
368− struct spinner spin_hi, spin_lo;
170+ struct igt_spinner spin_hi, spin_lo;
369171 struct intel_engine_cs *engine;
370172 struct i915_sched_attr attr = {};
371173 enum intel_engine_id id;
@@ -377,10 +179,10 @@ static int live_late_preempt(void *arg) · 5 unmodified lines
377179 mutex_lock(&i915->drm.struct_mutex);
378180 intel_runtime_pm_get(i915);
379181
380− if (spinner_init(&spin_hi, i915))
182+ if (igt_spinner_init(&spin_hi, i915))
381183 goto err_unlock;
382184
383− if (spinner_init(&spin_lo, i915))
185+ if (igt_spinner_init(&spin_lo, i915))
384186 goto err_spin_hi;
385187
386188 ctx_hi = kernel_context(i915);
@@ -394,28 +196,29 @@ static int live_late_preempt(void *arg) · 7 unmodified lines
394196 for_each_engine(engine, i915, id) {
395197 struct i915_request *rq;
396198
397− rq = spinner_create_request(&spin_lo, ctx_lo, engine,
398− MI_ARB_CHECK);
199+ rq = igt_spinner_create_request(&spin_lo, ctx_lo, engine,
200+ MI_ARB_CHECK);
399201 if (IS_ERR(rq)) {
400202 err = PTR_ERR(rq);
401203 goto err_ctx_lo;
402204 }
403205
404206 i915_request_add(rq);
405− if (!wait_for_spinner(&spin_lo, rq)) {
207+ if (!igt_wait_for_spinner(&spin_lo, rq)) {
406208 pr_err("First context failed to start\n");
407209 goto err_wedged;
408210 }
409211
410− rq = spinner_create_request(&spin_hi, ctx_hi, engine, MI_NOOP);
212+ rq = igt_spinner_create_request(&spin_hi, ctx_hi, engine,
213+ MI_NOOP);
411214 if (IS_ERR(rq)) {
412− spinner_end(&spin_lo);
215+ igt_spinner_end(&spin_lo);
413216 err = PTR_ERR(rq);
414217 goto err_ctx_lo;
415218 }
416219
417220 i915_request_add(rq);
418− if (wait_for_spinner(&spin_hi, rq)) {
221+ if (igt_wait_for_spinner(&spin_hi, rq)) {
419222 pr_err("Second context overtook first?\n");
420223 goto err_wedged;
421224 }
@@ -423,14 +226,14 @@ static int live_late_preempt(void *arg) · 1 unmodified line
423226 attr.priority = I915_USER_PRIORITY(I915_PRIORITY_MAX);
424227 engine->schedule(rq, &attr);
425228
426− if (!wait_for_spinner(&spin_hi, rq)) {
229+ if (!igt_wait_for_spinner(&spin_hi, rq)) {
427230 pr_err("High priority context failed to preempt the low priority context\n");
428231 GEM_TRACE_DUMP();
429232 goto err_wedged;
430233 }
431234
432− spinner_end(&spin_hi);
433− spinner_end(&spin_lo);
235+ igt_spinner_end(&spin_hi);
236+ igt_spinner_end(&spin_lo);
434237 if (igt_flush_test(i915, I915_WAIT_LOCKED)) {
435238 err = -EIO;
436239 goto err_ctx_lo;
@@ -443,9 +246,9 @@ err_ctx_lo: · 6 unmodified lines
443246 err_ctx_hi:
444247 kernel_context_close(ctx_hi);
445248 err_spin_lo:
446− spinner_fini(&spin_lo);
249+ igt_spinner_fini(&spin_lo);
447250 err_spin_hi:
448− spinner_fini(&spin_hi);
251+ igt_spinner_fini(&spin_hi);
449252 err_unlock:
450253 igt_flush_test(i915, I915_WAIT_LOCKED);
451254 intel_runtime_pm_put(i915);
@@ -453,8 +256,8 @@ err_unlock: · 1 unmodified line
453256 return err;
454257
455258 err_wedged:
456− spinner_end(&spin_hi);
457− spinner_end(&spin_lo);
259+ igt_spinner_end(&spin_hi);
260+ igt_spinner_end(&spin_lo);
458261 i915_gem_set_wedged(i915);
459262 err = -EIO;
460263 goto err_ctx_lo;
@@ -464,7 +267,7 @@ static int live_preempt_hang(void *arg) · 3 unmodified lines
464267 {
465268 struct drm_i915_private *i915 = arg;
466269 struct i915_gem_context *ctx_hi, *ctx_lo;
467− struct spinner spin_hi, spin_lo;
270+ struct igt_spinner spin_hi, spin_lo;
468271 struct intel_engine_cs *engine;
469272 enum intel_engine_id id;
470273 int err = -ENOMEM;
@@ -478,10 +281,10 @@ static int live_preempt_hang(void *arg) · 7 unmodified lines
478281 mutex_lock(&i915->drm.struct_mutex);
479282 intel_runtime_pm_get(i915);
480283
481− if (spinner_init(&spin_hi, i915))
284+ if (igt_spinner_init(&spin_hi, i915))
482285 goto err_unlock;
483286
484− if (spinner_init(&spin_lo, i915))
287+ if (igt_spinner_init(&spin_lo, i915))
485288 goto err_spin_hi;
486289
487290 ctx_hi = kernel_context(i915);
@@ -500,15 +303,15 @@ static int live_preempt_hang(void *arg) · 12 unmodified lines
500303 if (!intel_engine_has_preemption(engine))
501304 continue;
502305
503− rq = spinner_create_request(&spin_lo, ctx_lo, engine,
504− MI_ARB_CHECK);
306+ rq = igt_spinner_create_request(&spin_lo, ctx_lo, engine,
307+ MI_ARB_CHECK);
505308 if (IS_ERR(rq)) {
506309 err = PTR_ERR(rq);
507310 goto err_ctx_lo;
508311 }
509312
510313 i915_request_add(rq);
511− if (!wait_for_spinner(&spin_lo, rq)) {
314+ if (!igt_wait_for_spinner(&spin_lo, rq)) {
512315 GEM_TRACE("lo spinner failed to start\n");
513316 GEM_TRACE_DUMP();
514317 i915_gem_set_wedged(i915);
@@ -516,10 +319,10 @@ static int live_preempt_hang(void *arg) · 1 unmodified line
516319 goto err_ctx_lo;
517320 }
518321
519− rq = spinner_create_request(&spin_hi, ctx_hi, engine,
520− MI_ARB_CHECK);
322+ rq = igt_spinner_create_request(&spin_hi, ctx_hi, engine,
323+ MI_ARB_CHECK);
521324 if (IS_ERR(rq)) {
522− spinner_end(&spin_lo);
325+ igt_spinner_end(&spin_lo);
523326 err = PTR_ERR(rq);
524327 goto err_ctx_lo;
525328 }
@@ -544,7 +347,7 @@ static int live_preempt_hang(void *arg) · 18 unmodified lines
544347
545348 engine->execlists.preempt_hang.inject_hang = false;
546349
547− if (!wait_for_spinner(&spin_hi, rq)) {
350+ if (!igt_wait_for_spinner(&spin_hi, rq)) {
548351 GEM_TRACE("hi spinner failed to start\n");
549352 GEM_TRACE_DUMP();
550353 i915_gem_set_wedged(i915);
@@ -552,8 +355,8 @@ static int live_preempt_hang(void *arg) · 1 unmodified line
552355 goto err_ctx_lo;
553356 }
554357
555− spinner_end(&spin_hi);
556− spinner_end(&spin_lo);
358+ igt_spinner_end(&spin_hi);
359+ igt_spinner_end(&spin_lo);
557360 if (igt_flush_test(i915, I915_WAIT_LOCKED)) {
558361 err = -EIO;
559362 goto err_ctx_lo;
@@ -566,9 +369,9 @@ err_ctx_lo: · 6 unmodified lines
566369 err_ctx_hi:
567370 kernel_context_close(ctx_hi);
568371 err_spin_lo:
569− spinner_fini(&spin_lo);
372+ igt_spinner_fini(&spin_lo);
570373 err_spin_hi:
571− spinner_fini(&spin_hi);
374+ igt_spinner_fini(&spin_hi);
572375 err_unlock:
573376 igt_flush_test(i915, I915_WAIT_LOCKED);
574377 intel_runtime_pm_put(i915);
drivers/gpu/drm/i915/selftests/intel_workarounds.c+211−36
@@ -6,6 +6,9 @@ · 5 unmodified lines
66
77 #include "../i915_selftest.h"
88
9+#include "igt_flush_test.h"
10+#include "igt_reset.h"
11+#include "igt_spinner.h"
912 #include "igt_wedge_me.h"
1013 #include "mock_context.h"
1114
@@ -91,17 +94,23 @@ err_obj: · 79 unmodified lines
9194 return ERR_PTR(err);
9295 }
9396
94−static u32 get_whitelist_reg(const struct whitelist *w, unsigned int i)
97+static u32
98+get_whitelist_reg(const struct intel_engine_cs *engine, unsigned int i)
9599 {
96− return i < w->count ? i915_mmio_reg_offset(w->reg[i]) : w->nopid;
100+ i915_reg_t reg = i < engine->whitelist.count ?
101+ engine->whitelist.list[i].reg :
102+ RING_NOPID(engine->mmio_base);
103+
104+ return i915_mmio_reg_offset(reg);
97105 }
98106
99−static void print_results(const struct whitelist *w, const u32 *results)
107+static void
108+print_results(const struct intel_engine_cs *engine, const u32 *results)
100109 {
101110 unsigned int i;
102111
103112 for (i = 0; i < RING_MAX_NONPRIV_SLOTS; i++) {
104− u32 expected = get_whitelist_reg(w, i);
113+ u32 expected = get_whitelist_reg(engine, i);
105114 u32 actual = results[i];
106115
107116 pr_info("RING_NONPRIV[%d]: expected 0x%08x, found 0x%08x\n",
@@ -109,8 +118,7 @@ static void print_results(const struct whitelist *w, const u32 *results) · 1 unmodified line
109118 }
110119 }
111120
112−static int check_whitelist(const struct whitelist *w,
113− struct i915_gem_context *ctx,
121+static int check_whitelist(struct i915_gem_context *ctx,
114122 struct intel_engine_cs *engine)
115123 {
116124 struct drm_i915_gem_object *results;
@@ -138,11 +146,11 @@ static int check_whitelist(const struct whitelist *w, · 21 unmodified lines
138146 }
139147
140148 for (i = 0; i < RING_MAX_NONPRIV_SLOTS; i++) {
141− u32 expected = get_whitelist_reg(w, i);
149+ u32 expected = get_whitelist_reg(engine, i);
142150 u32 actual = vaddr[i];
143151
144152 if (expected != actual) {
145− print_results(w, vaddr);
153+ print_results(engine, vaddr);
146154 pr_err("Invalid RING_NONPRIV[%d], expected 0x%08x, found 0x%08x\n",
147155 i, expected, actual);
148156
@@ -159,66 +167,107 @@ out_put: · 10 unmodified lines
159167
160168 static int do_device_reset(struct intel_engine_cs *engine)
161169 {
162− i915_reset(engine->i915, ENGINE_MASK(engine->id), NULL);
170+ set_bit(I915_RESET_HANDOFF, &engine->i915->gpu_error.flags);
171+ i915_reset(engine->i915, ENGINE_MASK(engine->id), "live_workarounds");
163172 return 0;
164173 }
165174
166175 static int do_engine_reset(struct intel_engine_cs *engine)
167176 {
168− return i915_reset_engine(engine, NULL);
177+ return i915_reset_engine(engine, "live_workarounds");
169178 }
170179
171−static int switch_to_scratch_context(struct intel_engine_cs *engine)
180+static int
181+switch_to_scratch_context(struct intel_engine_cs *engine,
182+ struct igt_spinner *spin)
172183 {
173184 struct i915_gem_context *ctx;
174185 struct i915_request *rq;
186+ int err = 0;
175187
176188 ctx = kernel_context(engine->i915);
177189 if (IS_ERR(ctx))
178190 return PTR_ERR(ctx);
179191
180192 intel_runtime_pm_get(engine->i915);
181− rq = i915_request_alloc(engine, ctx);
193+
194+ if (spin)
195+ rq = igt_spinner_create_request(spin, ctx, engine, MI_NOOP);
196+ else
197+ rq = i915_request_alloc(engine, ctx);
198+
182199 intel_runtime_pm_put(engine->i915);
183200
184201 kernel_context_close(ctx);
185− if (IS_ERR(rq))
186− return PTR_ERR(rq);
202+
203+ if (IS_ERR(rq)) {
204+ spin = NULL;
205+ err = PTR_ERR(rq);
206+ goto err;
207+ }
187208
188209 i915_request_add(rq);
189210
190− return 0;
211+ if (spin && !igt_wait_for_spinner(spin, rq)) {
212+ pr_err("Spinner failed to start\n");
213+ err = -ETIMEDOUT;
214+ }
215+
216+err:
217+ if (err && spin)
218+ igt_spinner_end(spin);
219+
220+ return err;
191221 }
192222
193223 static int check_whitelist_across_reset(struct intel_engine_cs *engine,
194224 int (*reset)(struct intel_engine_cs *),
195− const struct whitelist *w,
196225 const char *name)
197226 {
227+ struct drm_i915_private *i915 = engine->i915;
228+ bool want_spin = reset == do_engine_reset;
198229 struct i915_gem_context *ctx;
230+ struct igt_spinner spin;
199231 int err;
200232
201− ctx = kernel_context(engine->i915);
233+ pr_info("Checking %d whitelisted registers (RING_NONPRIV) [%s]\n",
234+ engine->whitelist.count, name);
235+
236+ if (want_spin) {
237+ err = igt_spinner_init(&spin, i915);
238+ if (err)
239+ return err;
240+ }
241+
242+ ctx = kernel_context(i915);
202243 if (IS_ERR(ctx))
203244 return PTR_ERR(ctx);
204245
205− err = check_whitelist(w, ctx, engine);
246+ err = check_whitelist(ctx, engine);
206247 if (err) {
207248 pr_err("Invalid whitelist *before* %s reset!\n", name);
208249 goto out;
209250 }
210251
211− err = switch_to_scratch_context(engine);
252+ err = switch_to_scratch_context(engine, want_spin ? &spin : NULL);
212253 if (err)
213254 goto out;
214255
256+ intel_runtime_pm_get(i915);
215257 err = reset(engine);
258+ intel_runtime_pm_put(i915);
259+
260+ if (want_spin) {
261+ igt_spinner_end(&spin);
262+ igt_spinner_fini(&spin);
263+ }
264+
216265 if (err) {
217266 pr_err("%s reset failed\n", name);
218267 goto out;
219268 }
220269
221− err = check_whitelist(w, ctx, engine);
270+ err = check_whitelist(ctx, engine);
222271 if (err) {
223272 pr_err("Whitelist not preserved in context across %s reset!\n",
224273 name);
@@ -227,11 +276,11 @@ static int check_whitelist_across_reset(struct intel_engine_cs *engine, · 2 unmodified lines
227276
228277 kernel_context_close(ctx);
229278
230− ctx = kernel_context(engine->i915);
279+ ctx = kernel_context(i915);
231280 if (IS_ERR(ctx))
232281 return PTR_ERR(ctx);
233282
234− err = check_whitelist(w, ctx, engine);
283+ err = check_whitelist(ctx, engine);
235284 if (err) {
236285 pr_err("Invalid whitelist *after* %s reset in fresh context!\n",
237286 name);
@@ -247,26 +296,18 @@ static int live_reset_whitelist(void *arg) · 9 unmodified lines
247296 {
248297 struct drm_i915_private *i915 = arg;
249298 struct intel_engine_cs *engine = i915->engine[RCS];
250− struct i915_gpu_error *error = &i915->gpu_error;
251− struct whitelist w;
252299 int err = 0;
253300
254301 /* If we reset the gpu, we should not lose the RING_NONPRIV */
255302
256− if (!engine)
257− return 0;
258−
259− if (!whitelist_build(engine, &w))
303+ if (!engine || engine->whitelist.count == 0)
260304 return 0;
261305
262− pr_info("Checking %d whitelisted registers (RING_NONPRIV)\n", w.count);
263−
264− set_bit(I915_RESET_BACKOFF, &error->flags);
265− set_bit(I915_RESET_ENGINE + engine->id, &error->flags);
306+ igt_global_reset_lock(i915);
266307
267308 if (intel_has_reset_engine(i915)) {
268309 err = check_whitelist_across_reset(engine,
269− do_engine_reset, &w,
310+ do_engine_reset,
270311 "engine");
271312 if (err)
272313 goto out;
@@ -274,22 +315,156 @@ static int live_reset_whitelist(void *arg) · 1 unmodified line
274315
275316 if (intel_has_gpu_reset(i915)) {
276317 err = check_whitelist_across_reset(engine,
277− do_device_reset, &w,
318+ do_device_reset,
278319 "device");
279320 if (err)
280321 goto out;
281322 }
282323
283324 out:
284− clear_bit(I915_RESET_ENGINE + engine->id, &error->flags);
285− clear_bit(I915_RESET_BACKOFF, &error->flags);
325+ igt_global_reset_unlock(i915);
286326 return err;
287327 }
288328
329+static bool verify_gt_engine_wa(struct drm_i915_private *i915, const char *str)
330+{
331+ struct intel_engine_cs *engine;
332+ enum intel_engine_id id;
333+ bool ok = true;
334+
335+ ok &= intel_gt_verify_workarounds(i915, str);
336+
337+ for_each_engine(engine, i915, id)
338+ ok &= intel_engine_verify_workarounds(engine, str);
339+
340+ return ok;
341+}
342+
343+static int
344+live_gpu_reset_gt_engine_workarounds(void *arg)
345+{
346+ struct drm_i915_private *i915 = arg;
347+ struct i915_gpu_error *error = &i915->gpu_error;
348+ bool ok;
349+
350+ if (!intel_has_gpu_reset(i915))
351+ return 0;
352+
353+ pr_info("Verifying after GPU reset...\n");
354+
355+ igt_global_reset_lock(i915);
356+
357+ ok = verify_gt_engine_wa(i915, "before reset");
358+ if (!ok)
359+ goto out;
360+
361+ intel_runtime_pm_get(i915);
362+ set_bit(I915_RESET_HANDOFF, &error->flags);
363+ i915_reset(i915, ALL_ENGINES, "live_workarounds");
364+ intel_runtime_pm_put(i915);
365+
366+ ok = verify_gt_engine_wa(i915, "after reset");
367+
368+out:
369+ igt_global_reset_unlock(i915);
370+
371+ return ok ? 0 : -ESRCH;
372+}
373+
374+static int
375+live_engine_reset_gt_engine_workarounds(void *arg)
376+{
377+ struct drm_i915_private *i915 = arg;
378+ struct intel_engine_cs *engine;
379+ struct i915_gem_context *ctx;
380+ struct igt_spinner spin;
381+ enum intel_engine_id id;
382+ struct i915_request *rq;
383+ int ret = 0;
384+
385+ if (!intel_has_reset_engine(i915))
386+ return 0;
387+
388+ ctx = kernel_context(i915);
389+ if (IS_ERR(ctx))
390+ return PTR_ERR(ctx);
391+
392+ igt_global_reset_lock(i915);
393+
394+ for_each_engine(engine, i915, id) {
395+ bool ok;
396+
397+ pr_info("Verifying after %s reset...\n", engine->name);
398+
399+ ok = verify_gt_engine_wa(i915, "before reset");
400+ if (!ok) {
401+ ret = -ESRCH;
402+ goto err;
403+ }
404+
405+ intel_runtime_pm_get(i915);
406+ i915_reset_engine(engine, "live_workarounds");
407+ intel_runtime_pm_put(i915);
408+
409+ ok = verify_gt_engine_wa(i915, "after idle reset");
410+ if (!ok) {
411+ ret = -ESRCH;
412+ goto err;
413+ }
414+
415+ ret = igt_spinner_init(&spin, i915);
416+ if (ret)
417+ goto err;
418+
419+ intel_runtime_pm_get(i915);
420+
421+ rq = igt_spinner_create_request(&spin, ctx, engine, MI_NOOP);
422+ if (IS_ERR(rq)) {
423+ ret = PTR_ERR(rq);
424+ igt_spinner_fini(&spin);
425+ intel_runtime_pm_put(i915);
426+ goto err;
427+ }
428+
429+ i915_request_add(rq);
430+
431+ if (!igt_wait_for_spinner(&spin, rq)) {
432+ pr_err("Spinner failed to start\n");
433+ igt_spinner_fini(&spin);
434+ intel_runtime_pm_put(i915);
435+ ret = -ETIMEDOUT;
436+ goto err;
437+ }
438+
439+ i915_reset_engine(engine, "live_workarounds");
440+
441+ intel_runtime_pm_put(i915);
442+
443+ igt_spinner_end(&spin);
444+ igt_spinner_fini(&spin);
445+
446+ ok = verify_gt_engine_wa(i915, "after busy reset");
447+ if (!ok) {
448+ ret = -ESRCH;
449+ goto err;
450+ }
451+ }
452+
453+err:
454+ igt_global_reset_unlock(i915);
455+ kernel_context_close(ctx);
456+
457+ igt_flush_test(i915, I915_WAIT_LOCKED);
458+
459+ return ret;
460+}
461+
289462 int intel_workarounds_live_selftests(struct drm_i915_private *i915)
290463 {
291464 static const struct i915_subtest tests[] = {
292465 SUBTEST(live_reset_whitelist),
466+ SUBTEST(live_gpu_reset_gt_engine_workarounds),
467+ SUBTEST(live_engine_reset_gt_engine_workarounds),
293468 };
294469 int err;
295470
fs/sysfs/file.c+2−2
@@ -334,7 +334,7 @@ int sysfs_create_file_ns(struct kobject *kobj, const struct attribute *attr, · 333 unmodified lines
334334 }
335335 EXPORT_SYMBOL_GPL(sysfs_create_file_ns);
336336
337−int sysfs_create_files(struct kobject *kobj, const struct attribute **ptr)
337+int sysfs_create_files(struct kobject *kobj, const struct attribute * const *ptr)
338338 {
339339 int err = 0;
340340 int i;
@@ -493,7 +493,7 @@ bool sysfs_remove_file_self(struct kobject *kobj, const struct attribute *attr) · 152 unmodified lines
493493 return ret;
494494 }
495495
496−void sysfs_remove_files(struct kobject *kobj, const struct attribute **ptr)
496+void sysfs_remove_files(struct kobject *kobj, const struct attribute * const *ptr)
497497 {
498498 int i;
499499 for (i = 0; ptr[i]; i++)
include/drm/drm_dp_helper.h+2−1
@@ -1123,7 +1123,8 @@ drm_dp_is_branch(const u8 dpcd[DP_RECEIVER_CAP_SIZE]) · 1122 unmodified lines
11231123 u8 drm_dp_dsc_sink_max_slice_count(const u8 dsc_dpcd[DP_DSC_RECEIVER_CAP_SIZE],
11241124 bool is_edp);
11251125 u8 drm_dp_dsc_sink_line_buf_depth(const u8 dsc_dpcd[DP_DSC_RECEIVER_CAP_SIZE]);
1126−u8 drm_dp_dsc_sink_max_color_depth(const u8 dsc_dpc[DP_DSC_RECEIVER_CAP_SIZE]);
1126+int drm_dp_dsc_sink_supported_input_bpcs(const u8 dsc_dpc[DP_DSC_RECEIVER_CAP_SIZE],
1127+ u8 dsc_bpc[3]);
11271128
11281129 static inline bool
11291130 drm_dp_sink_supports_dsc(const u8 dsc_dpcd[DP_DSC_RECEIVER_CAP_SIZE])
include/drm/drm_dsc.h+485−0
@@ -0,0 +1,485 @@
1+/* SPDX-License-Identifier: MIT
2+ * Copyright (C) 2018 Intel Corp.
3+ *
4+ * Authors:
5+ * Manasi Navare <manasi.d.navare@intel.com>
6+ */
7+
8+#ifndef DRM_DSC_H_
9+#define DRM_DSC_H_
10+
11+#include <drm/drm_dp_helper.h>
12+
13+/* VESA Display Stream Compression DSC 1.2 constants */
14+#define DSC_NUM_BUF_RANGES 15
15+#define DSC_MUX_WORD_SIZE_8_10_BPC 48
16+#define DSC_MUX_WORD_SIZE_12_BPC 64
17+#define DSC_RC_PIXELS_PER_GROUP 3
18+#define DSC_SCALE_DECREMENT_INTERVAL_MAX 4095
19+#define DSC_RANGE_BPG_OFFSET_MASK 0x3f
20+
21+/* DSC Rate Control Constants */
22+#define DSC_RC_MODEL_SIZE_CONST 8192
23+#define DSC_RC_EDGE_FACTOR_CONST 6
24+#define DSC_RC_TGT_OFFSET_HI_CONST 3
25+#define DSC_RC_TGT_OFFSET_LO_CONST 3
26+
27+/* DSC PPS constants and macros */
28+#define DSC_PPS_VERSION_MAJOR_SHIFT 4
29+#define DSC_PPS_BPC_SHIFT 4
30+#define DSC_PPS_MSB_SHIFT 8
31+#define DSC_PPS_LSB_MASK (0xFF << 0)
32+#define DSC_PPS_BPP_HIGH_MASK (0x3 << 8)
33+#define DSC_PPS_VBR_EN_SHIFT 2
34+#define DSC_PPS_SIMPLE422_SHIFT 3
35+#define DSC_PPS_CONVERT_RGB_SHIFT 4
36+#define DSC_PPS_BLOCK_PRED_EN_SHIFT 5
37+#define DSC_PPS_INIT_XMIT_DELAY_HIGH_MASK (0x3 << 8)
38+#define DSC_PPS_SCALE_DEC_INT_HIGH_MASK (0xF << 8)
39+#define DSC_PPS_RC_TGT_OFFSET_HI_SHIFT 4
40+#define DSC_PPS_RC_RANGE_MINQP_SHIFT 11
41+#define DSC_PPS_RC_RANGE_MAXQP_SHIFT 6
42+#define DSC_PPS_NATIVE_420_SHIFT 1
43+#define DSC_1_2_MAX_LINEBUF_DEPTH_BITS 16
44+#define DSC_1_2_MAX_LINEBUF_DEPTH_VAL 0
45+#define DSC_1_1_MAX_LINEBUF_DEPTH_BITS 13
46+
47+/* Configuration for a single Rate Control model range */
48+struct drm_dsc_rc_range_parameters {
49+ /* Min Quantization Parameters allowed for this range */
50+ u8 range_min_qp;
51+ /* Max Quantization Parameters allowed for this range */
52+ u8 range_max_qp;
53+ /* Bits/group offset to apply to target for this group */
54+ u8 range_bpg_offset;
55+};
56+
57+struct drm_dsc_config {
58+ /* Bits / component for previous reconstructed line buffer */
59+ u8 line_buf_depth;
60+ /* Bits per component to code (must be 8, 10, or 12) */
61+ u8 bits_per_component;
62+ /*
63+ * Flag indicating to do RGB - YCoCg conversion
64+ * and back (should be 1 for RGB input)
65+ */
66+ bool convert_rgb;
67+ u8 slice_count;
68+ /* Slice Width */
69+ u16 slice_width;
70+ /* Slice Height */
71+ u16 slice_height;
72+ /*
73+ * 4:2:2 enable mode (from PPS, 4:2:2 conversion happens
74+ * outside of DSC encode/decode algorithm)
75+ */
76+ bool enable422;
77+ /* Picture Width */
78+ u16 pic_width;
79+ /* Picture Height */
80+ u16 pic_height;
81+ /* Offset to bits/group used by RC to determine QP adjustment */
82+ u8 rc_tgt_offset_high;
83+ /* Offset to bits/group used by RC to determine QP adjustment */
84+ u8 rc_tgt_offset_low;
85+ /* Bits/pixel target << 4 (ie., 4 fractional bits) */
86+ u16 bits_per_pixel;
87+ /*
88+ * Factor to determine if an edge is present based
89+ * on the bits produced
90+ */
91+ u8 rc_edge_factor;
92+ /* Slow down incrementing once the range reaches this value */
93+ u8 rc_quant_incr_limit1;
94+ /* Slow down incrementing once the range reaches this value */
95+ u8 rc_quant_incr_limit0;
96+ /* Number of pixels to delay the initial transmission */
97+ u16 initial_xmit_delay;
98+ /* Number of pixels to delay the VLD on the decoder,not including SSM */
99+ u16 initial_dec_delay;
100+ /* Block prediction enable */
101+ bool block_pred_enable;
102+ /* Bits/group offset to use for first line of the slice */
103+ u8 first_line_bpg_offset;
104+ /* Value to use for RC model offset at slice start */
105+ u16 initial_offset;
106+ /* Thresholds defining each of the buffer ranges */
107+ u16 rc_buf_thresh[DSC_NUM_BUF_RANGES - 1];
108+ /* Parameters for each of the RC ranges */
109+ struct drm_dsc_rc_range_parameters rc_range_params[DSC_NUM_BUF_RANGES];
110+ /* Total size of RC model */
111+ u16 rc_model_size;
112+ /* Minimum QP where flatness information is sent */
113+ u8 flatness_min_qp;
114+ /* Maximum QP where flatness information is sent */
115+ u8 flatness_max_qp;
116+ /* Initial value for scale factor */
117+ u8 initial_scale_value;
118+ /* Decrement scale factor every scale_decrement_interval groups */
119+ u16 scale_decrement_interval;
120+ /* Increment scale factor every scale_increment_interval groups */
121+ u16 scale_increment_interval;
122+ /* Non-first line BPG offset to use */
123+ u16 nfl_bpg_offset;
124+ /* BPG offset used to enforce slice bit */
125+ u16 slice_bpg_offset;
126+ /* Final RC linear transformation offset value */
127+ u16 final_offset;
128+ /* Enable on-off VBR (ie., disable stuffing bits) */
129+ bool vbr_enable;
130+ /* Mux word size (in bits) for SSM mode */
131+ u8 mux_word_size;
132+ /*
133+ * The (max) size in bytes of the "chunks" that are
134+ * used in slice multiplexing
135+ */
136+ u16 slice_chunk_size;
137+ /* Rate Control buffer siz in bits */
138+ u16 rc_bits;
139+ /* DSC Minor Version */
140+ u8 dsc_version_minor;
141+ /* DSC Major version */
142+ u8 dsc_version_major;
143+ /* Native 4:2:2 support */
144+ bool native_422;
145+ /* Native 4:2:0 support */
146+ bool native_420;
147+ /* Additional bits/grp for seconnd line of slice for native 4:2:0 */
148+ u8 second_line_bpg_offset;
149+ /* Num of bits deallocated for each grp that is not in second line of slice */
150+ u16 nsl_bpg_offset;
151+ /* Offset adj fr second line in Native 4:2:0 mode */
152+ u16 second_line_offset_adj;
153+};
154+
155+/**
156+ * struct picture_parameter_set - Represents 128 bytes of Picture Parameter Set
157+ *
158+ * The VESA DSC standard defines picture parameter set (PPS) which display
159+ * stream compression encoders must communicate to decoders.
160+ * The PPS is encapsulated in 128 bytes (PPS 0 through PPS 127). The fields in
161+ * this structure are as per Table 4.1 in Vesa DSC specification v1.1/v1.2.
162+ * The PPS fields that span over more than a byte should be stored in Big Endian
163+ * format.
164+ */
165+struct drm_dsc_picture_parameter_set {
166+ /**
167+ * @dsc_version:
168+ * PPS0[3:0] - dsc_version_minor: Contains Minor version of DSC
169+ * PPS0[7:4] - dsc_version_major: Contains major version of DSC
170+ */
171+ u8 dsc_version;
172+ /**
173+ * @pps_identifier:
174+ * PPS1[7:0] - Application specific identifier that can be
175+ * used to differentiate between different PPS tables.
176+ */
177+ u8 pps_identifier;
178+ /**
179+ * @pps_reserved:
180+ * PPS2[7:0]- RESERVED Byte
181+ */
182+ u8 pps_reserved;
183+ /**
184+ * @pps_3:
185+ * PPS3[3:0] - linebuf_depth: Contains linebuffer bit depth used to
186+ * generate the bitstream. (0x0 - 16 bits for DSC 1.2, 0x8 - 8 bits,
187+ * 0xA - 10 bits, 0xB - 11 bits, 0xC - 12 bits, 0xD - 13 bits,
188+ * 0xE - 14 bits for DSC1.2, 0xF - 14 bits for DSC 1.2.
189+ * PPS3[7:4] - bits_per_component: Bits per component for the original
190+ * pixels of the encoded picture.
191+ * 0x0 = 16bpc (allowed only when dsc_version_minor = 0x2)
192+ * 0x8 = 8bpc, 0xA = 10bpc, 0xC = 12bpc, 0xE = 14bpc (also
193+ * allowed only when dsc_minor_version = 0x2)
194+ */
195+ u8 pps_3;
196+ /**
197+ * @pps_4:
198+ * PPS4[1:0] -These are the most significant 2 bits of
199+ * compressed BPP bits_per_pixel[9:0] syntax element.
200+ * PPS4[2] - vbr_enable: 0 = VBR disabled, 1 = VBR enabled
201+ * PPS4[3] - simple_422: Indicates if decoder drops samples to
202+ * reconstruct the 4:2:2 picture.
203+ * PPS4[4] - Convert_rgb: Indicates if DSC color space conversion is
204+ * active.
205+ * PPS4[5] - blobk_pred_enable: Indicates if BP is used to code any
206+ * groups in picture
207+ * PPS4[7:6] - Reseved bits
208+ */
209+ u8 pps_4;
210+ /**
211+ * @bits_per_pixel_low:
212+ * PPS5[7:0] - This indicates the lower significant 8 bits of
213+ * the compressed BPP bits_per_pixel[9:0] element.
214+ */
215+ u8 bits_per_pixel_low;
216+ /**
217+ * @pic_height:
218+ * PPS6[7:0], PPS7[7:0] -pic_height: Specifies the number of pixel rows
219+ * within the raster.
220+ */
221+ __be16 pic_height;
222+ /**
223+ * @pic_width:
224+ * PPS8[7:0], PPS9[7:0] - pic_width: Number of pixel columns within
225+ * the raster.
226+ */
227+ __be16 pic_width;
228+ /**
229+ * @slice_height:
230+ * PPS10[7:0], PPS11[7:0] - Slice height in units of pixels.
231+ */
232+ __be16 slice_height;
233+ /**
234+ * @slice_width:
235+ * PPS12[7:0], PPS13[7:0] - Slice width in terms of pixels.
236+ */
237+ __be16 slice_width;
238+ /**
239+ * @chunk_size:
240+ * PPS14[7:0], PPS15[7:0] - Size in units of bytes of the chunks
241+ * that are used for slice multiplexing.
242+ */
243+ __be16 chunk_size;
244+ /**
245+ * @initial_xmit_delay_high:
246+ * PPS16[1:0] - Most Significant two bits of initial transmission delay.
247+ * It specifies the number of pixel times that the encoder waits before
248+ * transmitting data from its rate buffer.
249+ * PPS16[7:2] - Reserved
250+ */
251+ u8 initial_xmit_delay_high;
252+ /**
253+ * @initial_xmit_delay_low:
254+ * PPS17[7:0] - Least significant 8 bits of initial transmission delay.
255+ */
256+ u8 initial_xmit_delay_low;
257+ /**
258+ * @initial_dec_delay:
259+ *
260+ * PPS18[7:0], PPS19[7:0] - Initial decoding delay which is the number
261+ * of pixel times that the decoder accumulates data in its rate buffer
262+ * before starting to decode and output pixels.
263+ */
264+ __be16 initial_dec_delay;
265+ /**
266+ * @pps20_reserved:
267+ *
268+ * PPS20[7:0] - Reserved
269+ */
270+ u8 pps20_reserved;
271+ /**
272+ * @initial_scale_value:
273+ * PPS21[5:0] - Initial rcXformScale factor used at beginning
274+ * of a slice.
275+ * PPS21[7:6] - Reserved
276+ */
277+ u8 initial_scale_value;
278+ /**
279+ * @scale_increment_interval:
280+ * PPS22[7:0], PPS23[7:0] - Number of group times between incrementing
281+ * the rcXformScale factor at end of a slice.
282+ */
283+ __be16 scale_increment_interval;
284+ /**
285+ * @scale_decrement_interval_high:
286+ * PPS24[3:0] - Higher 4 bits indicating number of group times between
287+ * decrementing the rcXformScale factor at beginning of a slice.
288+ * PPS24[7:4] - Reserved
289+ */
290+ u8 scale_decrement_interval_high;
291+ /**
292+ * @scale_decrement_interval_low:
293+ * PPS25[7:0] - Lower 8 bits of scale decrement interval
294+ */
295+ u8 scale_decrement_interval_low;
296+ /**
297+ * @pps26_reserved:
298+ * PPS26[7:0]
299+ */
300+ u8 pps26_reserved;
301+ /**
302+ * @first_line_bpg_offset:
303+ * PPS27[4:0] - Number of additional bits that are allocated
304+ * for each group on first line of a slice.
305+ * PPS27[7:5] - Reserved
306+ */
307+ u8 first_line_bpg_offset;
308+ /**
309+ * @nfl_bpg_offset:
310+ * PPS28[7:0], PPS29[7:0] - Number of bits including frac bits
311+ * deallocated for each group for groups after the first line of slice.
312+ */
313+ __be16 nfl_bpg_offset;
314+ /**
315+ * @slice_bpg_offset:
316+ * PPS30, PPS31[7:0] - Number of bits that are deallocated for each
317+ * group to enforce the slice constraint.
318+ */
319+ __be16 slice_bpg_offset;
320+ /**
321+ * @initial_offset:
322+ * PPS32,33[7:0] - Initial value for rcXformOffset
323+ */
324+ __be16 initial_offset;
325+ /**
326+ * @final_offset:
327+ * PPS34,35[7:0] - Maximum end-of-slice value for rcXformOffset
328+ */
329+ __be16 final_offset;
330+ /**
331+ * @flatness_min_qp:
332+ * PPS36[4:0] - Minimum QP at which flatness is signaled and
333+ * flatness QP adjustment is made.
334+ * PPS36[7:5] - Reserved
335+ */
336+ u8 flatness_min_qp;
337+ /**
338+ * @flatness_max_qp:
339+ * PPS37[4:0] - Max QP at which flatness is signalled and
340+ * the flatness adjustment is made.
341+ * PPS37[7:5] - Reserved
342+ */
343+ u8 flatness_max_qp;
344+ /**
345+ * @rc_model_size:
346+ * PPS38,39[7:0] - Number of bits within RC Model.
347+ */
348+ __be16 rc_model_size;
349+ /**
350+ * @rc_edge_factor:
351+ * PPS40[3:0] - Ratio of current activity vs, previous
352+ * activity to determine presence of edge.
353+ * PPS40[7:4] - Reserved
354+ */
355+ u8 rc_edge_factor;
356+ /**
357+ * @rc_quant_incr_limit0:
358+ * PPS41[4:0] - QP threshold used in short term RC
359+ * PPS41[7:5] - Reserved
360+ */
361+ u8 rc_quant_incr_limit0;
362+ /**
363+ * @rc_quant_incr_limit1:
364+ * PPS42[4:0] - QP threshold used in short term RC
365+ * PPS42[7:5] - Reserved
366+ */
367+ u8 rc_quant_incr_limit1;
368+ /**
369+ * @rc_tgt_offset:
370+ * PPS43[3:0] - Lower end of the variability range around the target
371+ * bits per group that is allowed by short term RC.
372+ * PPS43[7:4]- Upper end of the variability range around the target
373+ * bits per group that i allowed by short term rc.
374+ */
375+ u8 rc_tgt_offset;
376+ /**
377+ * @rc_buf_thresh:
378+ * PPS44[7:0] - PPS57[7:0] - Specifies the thresholds in RC model for
379+ * the 15 ranges defined by 14 thresholds.
380+ */
381+ u8 rc_buf_thresh[DSC_NUM_BUF_RANGES - 1];
382+ /**
383+ * @rc_range_parameters:
384+ * PPS58[7:0] - PPS87[7:0]
385+ * Parameters that correspond to each of the 15 ranges.
386+ */
387+ __be16 rc_range_parameters[DSC_NUM_BUF_RANGES];
388+ /**
389+ * @native_422_420:
390+ * PPS88[0] - 0 = Native 4:2:2 not used
391+ * 1 = Native 4:2:2 used
392+ * PPS88[1] - 0 = Native 4:2:0 not use
393+ * 1 = Native 4:2:0 used
394+ * PPS88[7:2] - Reserved 6 bits
395+ */
396+ u8 native_422_420;
397+ /**
398+ * @second_line_bpg_offset:
399+ * PPS89[4:0] - Additional bits/group budget for the
400+ * second line of a slice in Native 4:2:0 mode.
401+ * Set to 0 if DSC minor version is 1 or native420 is 0.
402+ * PPS89[7:5] - Reserved
403+ */
404+ u8 second_line_bpg_offset;
405+ /**
406+ * @nsl_bpg_offset:
407+ * PPS90[7:0], PPS91[7:0] - Number of bits that are deallocated
408+ * for each group that is not in the second line of a slice.
409+ */
410+ __be16 nsl_bpg_offset;
411+ /**
412+ * @second_line_offset_adj:
413+ * PPS92[7:0], PPS93[7:0] - Used as offset adjustment for the second
414+ * line in Native 4:2:0 mode.
415+ */
416+ __be16 second_line_offset_adj;
417+ /**
418+ * @pps_long_94_reserved:
419+ * PPS 94, 95, 96, 97 - Reserved
420+ */
421+ u32 pps_long_94_reserved;
422+ /**
423+ * @pps_long_98_reserved:
424+ * PPS 98, 99, 100, 101 - Reserved
425+ */
426+ u32 pps_long_98_reserved;
427+ /**
428+ * @pps_long_102_reserved:
429+ * PPS 102, 103, 104, 105 - Reserved
430+ */
431+ u32 pps_long_102_reserved;
432+ /**
433+ * @pps_long_106_reserved:
434+ * PPS 106, 107, 108, 109 - reserved
435+ */
436+ u32 pps_long_106_reserved;
437+ /**
438+ * @pps_long_110_reserved:
439+ * PPS 110, 111, 112, 113 - reserved
440+ */
441+ u32 pps_long_110_reserved;
442+ /**
443+ * @pps_long_114_reserved:
444+ * PPS 114 - 117 - reserved
445+ */
446+ u32 pps_long_114_reserved;
447+ /**
448+ * @pps_long_118_reserved:
449+ * PPS 118 - 121 - reserved
450+ */
451+ u32 pps_long_118_reserved;
452+ /**
453+ * @pps_long_122_reserved:
454+ * PPS 122- 125 - reserved
455+ */
456+ u32 pps_long_122_reserved;
457+ /**
458+ * @pps_short_126_reserved:
459+ * PPS 126, 127 - reserved
460+ */
461+ __be16 pps_short_126_reserved;
462+} __packed;
463+
464+/**
465+ * struct drm_dsc_pps_infoframe - DSC infoframe carrying the Picture Parameter
466+ * Set Metadata
467+ *
468+ * This structure represents the DSC PPS infoframe required to send the Picture
469+ * Parameter Set metadata required before enabling VESA Display Stream
470+ * Compression. This is based on the DP Secondary Data Packet structure and
471+ * comprises of SDP Header as defined in drm_dp_helper.h and PPS payload.
472+ *
473+ * @pps_header: Header for PPS as per DP SDP header format
474+ * @pps_payload: PPS payload fields as per DSC specification Table 4-1
475+ */
476+struct drm_dsc_pps_infoframe {
477+ struct dp_sdp_header pps_header;
478+ struct drm_dsc_picture_parameter_set pps_payload;
479+} __packed;
480+
481+void drm_dsc_dp_pps_header_init(struct drm_dsc_pps_infoframe *pps_sdp);
482+void drm_dsc_pps_infoframe_pack(struct drm_dsc_pps_infoframe *pps_sdp,
483+ const struct drm_dsc_config *dsc_cfg);
484+
485+#endif /* _DRM_DSC_H_ */
include/linux/sysfs.h+4−4
@@ -234,7 +234,7 @@ int __must_check sysfs_create_file_ns(struct kobject *kobj, · 233 unmodified lines
234234 const struct attribute *attr,
235235 const void *ns);
236236 int __must_check sysfs_create_files(struct kobject *kobj,
237− const struct attribute **attr);
237+ const struct attribute * const *attr);
238238 int __must_check sysfs_chmod_file(struct kobject *kobj,
239239 const struct attribute *attr, umode_t mode);
240240 struct kernfs_node *sysfs_break_active_protection(struct kobject *kobj,
@@ -243,7 +243,7 @@ void sysfs_unbreak_active_protection(struct kernfs_node *kn); · 2 unmodified lines
243243 void sysfs_remove_file_ns(struct kobject *kobj, const struct attribute *attr,
244244 const void *ns);
245245 bool sysfs_remove_file_self(struct kobject *kobj, const struct attribute *attr);
246−void sysfs_remove_files(struct kobject *kobj, const struct attribute **attr);
246+void sysfs_remove_files(struct kobject *kobj, const struct attribute * const *attr);
247247
248248 int __must_check sysfs_create_bin_file(struct kobject *kobj,
249249 const struct bin_attribute *attr);
@@ -342,7 +342,7 @@ static inline int sysfs_create_file_ns(struct kobject *kobj, · 92 unmodified lines
342342 }
343343
344344 static inline int sysfs_create_files(struct kobject *kobj,
345− const struct attribute **attr)
345+ const struct attribute * const *attr)
346346 {
347347 return 0;
348348 }
@@ -377,7 +377,7 @@ static inline bool sysfs_remove_file_self(struct kobject *kobj, · 28 unmodified lines
377377 }
378378
379379 static inline void sysfs_remove_files(struct kobject *kobj,
380− const struct attribute **attr)
380+ const struct attribute * const *attr)
381381 {
382382 }
383383

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