History

Merge tag 'drm-intel-next-2014-11-07-fixups' of git://anongit.freedesktop.org/drm-intel into drm-next

- skl watermarks code (Damien, Vandana, Pradeep) - reworked audio codec /eld handling code (Jani) - rework the mmio_flip code to use the vblank evade logic and wait for rendering using the standard wait_seqno interface (Ander) - skl forcewake support (Zhe Wang) - refactor the chv interrupt code to use functions shared with vlv (Ville) - prep work for different global gtt views (Tvrtko Ursulin) - precompute the display PLL config before touching hw state (Ander) - completely reworked panel power sequencer code for chv/vlv (Ville) - pre work to split the plane update code into a prepare and commit phase (Gustavo Padovan) - golden context for skl (Armin Reese) - as usual tons of fixes and improvements all over * tag 'drm-intel-next-2014-11-07-fixups' of git://anongit.freedesktop.org/drm-intel: (135 commits) drm/i915: Use correct pipe config to update pll dividers. V2 drm/i915: Plug memory leak in intel_shared_dpll_start_config() drm/i915: Update DRIVER_DATE to 20141107 drm/i915: Add gen to the gpu hang ecode drm/i915: Cache HPLL frequency on VLV/CHV Revert "drm/i915/vlv: Remove check for Old Ack during forcewake" drm/i915: Make mmio flip wait for seqno in the work function drm/i915: Make __wait_seqno non-static and rename to __i915_wait_seqno drm/i915: Move the .global_resources() hook call into modeset_update_crtc_power_domains() drm/i915/audio: add DOC comment describing HDA over HDMI/DP drm/i915: make pipe/port based audio valid accessors easier to use drm/i915/audio: add audio codec enable debug log for g4x drm/i915/audio: add audio codec disable on g4x drm/i915: enable audio codec after port drm/i915/audio: add vlv/chv/gen5-7 audio codec disable sequence drm/i915/audio: rewrite vlv/chv and gen 5-7 audio codec enable sequence drm/i915/skl: Enable Gen9 RC6 drm/i915/skl: Gen9 Forcewake drm/i915/skl: Log the order in which we flush the pipes in the WM code drm/i915/skl: Flush the WM configuration ...

Dave Airlie committed 12 years ago

Commit fd172d02 parents b853fdb e1f234b35 files · +4970 −1464Browse files

Unified · Split

35 files
  1. Documentation/DocBook/drm.tmpl +5 −0
  2. drivers/gpu/drm/drm_plane_helper.c +5 −0
  3. drivers/gpu/drm/i915/Makefile +4 −2
  4. drivers/gpu/drm/i915/i915_cmd_parser.c +17 −1
  5. drivers/gpu/drm/i915/i915_debugfs.c +110 −22
  6. drivers/gpu/drm/i915/i915_drv.c +20 −55
  7. drivers/gpu/drm/i915/i915_drv.h +88 −17
  8. drivers/gpu/drm/i915/i915_gem.c +45 −30
  9. drivers/gpu/drm/i915/i915_gem_context.c +5 −5
  10. drivers/gpu/drm/i915/i915_gem_execbuffer.c +17 −18
  11. drivers/gpu/drm/i915/i915_gem_gtt.c +13 −13
  12. drivers/gpu/drm/i915/i915_gem_gtt.h +6 −2
  13. drivers/gpu/drm/i915/i915_gem_render_state.c +2 −0
  14. drivers/gpu/drm/i915/i915_gem_stolen.c +1 −1
  15. drivers/gpu/drm/i915/i915_gem_tiling.c +1 −0
  16. drivers/gpu/drm/i915/i915_gpu_error.c +8 −5
  17. drivers/gpu/drm/i915/i915_irq.c +60 −96
  18. drivers/gpu/drm/i915/i915_reg.h +208 −95
  19. drivers/gpu/drm/i915/intel_audio.c +462 −0
  20. drivers/gpu/drm/i915/intel_ddi.c +30 −31
  21. drivers/gpu/drm/i915/intel_display.c +503 −640
  22. drivers/gpu/drm/i915/intel_dp.c +283 −146
  23. drivers/gpu/drm/i915/intel_drv.h +44 −21
  24. drivers/gpu/drm/i915/intel_fbdev.c +10 −10
  25. drivers/gpu/drm/i915/intel_hdmi.c +11 −8
  26. drivers/gpu/drm/i915/intel_lrc.c +35 −17
  27. drivers/gpu/drm/i915/intel_pm.c +1027 −7
  28. drivers/gpu/drm/i915/intel_renderstate.h +1 −0
  29. drivers/gpu/drm/i915/intel_renderstate_gen8.c +640 −162
  30. drivers/gpu/drm/i915/intel_renderstate_gen9.c +974 −0
  31. drivers/gpu/drm/i915/intel_ringbuffer.c +5 −2
  32. drivers/gpu/drm/i915/intel_runtime_pm.c +14 −6
  33. drivers/gpu/drm/i915/intel_sprite.c +126 −44
  34. drivers/gpu/drm/i915/intel_uncore.c +184 −8
  35. include/uapi/drm/i915_drm.h +6 −0
Documentation/DocBook/drm.tmpl+5−0
@@ -3887,6 +3887,11 @@ int num_ioctls;</synopsis> · 3886 unmodified lines
38873887 probing, so those sections fully apply.
38883888 </para>
38893889 </sect2>
3890+ <sect2>
3891+ <title>High Definition Audio</title>
3892+!Pdrivers/gpu/drm/i915/intel_audio.c High Definition Audio over HDMI and Display Port
3893+!Idrivers/gpu/drm/i915/intel_audio.c
3894+ </sect2>
38903895 <sect2>
38913896 <title>DPIO</title>
38923897 !Pdrivers/gpu/drm/i915/i915_reg.h DPIO
drivers/gpu/drm/drm_plane_helper.c+5−0
@@ -155,6 +155,11 @@ int drm_plane_helper_check_update(struct drm_plane *plane, · 154 unmodified lines
155155 return -ERANGE;
156156 }
157157
158+ if (!fb) {
159+ *visible = false;
160+ return 0;
161+ }
162+
158163 *visible = drm_rect_clip_scaled(src, dest, clip, hscale, vscale);
159164 if (!*visible)
160165 /*
drivers/gpu/drm/i915/Makefile+4−2
@@ -40,10 +40,12 @@ i915-y += i915_cmd_parser.o \ · 39 unmodified lines
4040 # autogenerated null render state
4141 i915-y += intel_renderstate_gen6.o \
4242 intel_renderstate_gen7.o \
43− intel_renderstate_gen8.o
43+ intel_renderstate_gen8.o \
44+ intel_renderstate_gen9.o
4445
4546 # modesetting core code
46−i915-y += intel_bios.o \
47+i915-y += intel_audio.o \
48+ intel_bios.o \
4749 intel_display.o \
4850 intel_fifo_underrun.o \
4951 intel_frontbuffer.o \
drivers/gpu/drm/i915/i915_cmd_parser.c+17−1
@@ -138,6 +138,11 @@ static const struct drm_i915_cmd_descriptor common_cmds[] = { · 137 unmodified lines
138138 .mask = MI_GLOBAL_GTT,
139139 .expected = 0,
140140 }}, ),
141+ /*
142+ * MI_BATCH_BUFFER_START requires some special handling. It's not
143+ * really a 'skip' action but it doesn't seem like it's worth adding
144+ * a new action. See i915_parse_cmds().
145+ */
141146 CMD( MI_BATCH_BUFFER_START, SMI, !F, 0xFF, S ),
142147 };
143148
@@ -955,7 +960,8 @@ static bool check_cmd(const struct intel_engine_cs *ring, · 811 unmodified lines
955960 * Parses the specified batch buffer looking for privilege violations as
956961 * described in the overview.
957962 *
958− * Return: non-zero if the parser finds violations or otherwise fails
963+ * Return: non-zero if the parser finds violations or otherwise fails; -EACCES
964+ * if the batch appears legal but should use hardware parsing
959965 */
960966 int i915_parse_cmds(struct intel_engine_cs *ring,
961967 struct drm_i915_gem_object *batch_obj,
@@ -1002,6 +1008,16 @@ int i915_parse_cmds(struct intel_engine_cs *ring, · 40 unmodified lines
10021008 break;
10031009 }
10041010
1011+ /*
1012+ * If the batch buffer contains a chained batch, return an
1013+ * error that tells the caller to abort and dispatch the
1014+ * workload as a non-secure batch.
1015+ */
1016+ if (desc->cmd.value == MI_BATCH_BUFFER_START) {
1017+ ret = -EACCES;
1018+ break;
1019+ }
1020+
10051021 if (desc->flags & CMD_DESC_FIXED)
10061022 length = desc->length.fixed;
10071023 else
drivers/gpu/drm/i915/i915_debugfs.c+110−22
@@ -116,7 +116,7 @@ static const char *get_tiling_flag(struct drm_i915_gem_object *obj) · 115 unmodified lines
116116
117117 static inline const char *get_global_flag(struct drm_i915_gem_object *obj)
118118 {
119− return obj->has_global_gtt_mapping ? "g" : " ";
119+ return i915_gem_obj_to_ggtt(obj) ? "g" : " ";
120120 }
121121
122122 static void
@@ -2630,14 +2630,15 @@ static int i915_shared_dplls_info(struct seq_file *m, void *unused) · 2507 unmodified lines
26302630 struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i];
26312631
26322632 seq_printf(m, "DPLL%i: %s, id: %i\n", i, pll->name, pll->id);
2633− seq_printf(m, " refcount: %i, active: %i, on: %s\n", pll->refcount,
2634− pll->active, yesno(pll->on));
2633+ seq_printf(m, " crtc_mask: 0x%08x, active: %d, on: %s\n",
2634+ pll->config.crtc_mask, pll->active, yesno(pll->on));
26352635 seq_printf(m, " tracked hardware state:\n");
2636− seq_printf(m, " dpll: 0x%08x\n", pll->hw_state.dpll);
2637− seq_printf(m, " dpll_md: 0x%08x\n", pll->hw_state.dpll_md);
2638− seq_printf(m, " fp0: 0x%08x\n", pll->hw_state.fp0);
2639− seq_printf(m, " fp1: 0x%08x\n", pll->hw_state.fp1);
2640− seq_printf(m, " wrpll: 0x%08x\n", pll->hw_state.wrpll);
2636+ seq_printf(m, " dpll: 0x%08x\n", pll->config.hw_state.dpll);
2637+ seq_printf(m, " dpll_md: 0x%08x\n",
2638+ pll->config.hw_state.dpll_md);
2639+ seq_printf(m, " fp0: 0x%08x\n", pll->config.hw_state.fp0);
2640+ seq_printf(m, " fp1: 0x%08x\n", pll->config.hw_state.fp1);
2641+ seq_printf(m, " wrpll: 0x%08x\n", pll->config.hw_state.wrpll);
26412642 }
26422643 drm_modeset_unlock_all(dev);
26432644
@@ -2678,6 +2679,42 @@ static int i915_wa_registers(struct seq_file *m, void *unused) · 34 unmodified lines
26782679 return 0;
26792680 }
26802681
2682+static int i915_ddb_info(struct seq_file *m, void *unused)
2683+{
2684+ struct drm_info_node *node = m->private;
2685+ struct drm_device *dev = node->minor->dev;
2686+ struct drm_i915_private *dev_priv = dev->dev_private;
2687+ struct skl_ddb_allocation *ddb;
2688+ struct skl_ddb_entry *entry;
2689+ enum pipe pipe;
2690+ int plane;
2691+
2692+ drm_modeset_lock_all(dev);
2693+
2694+ ddb = &dev_priv->wm.skl_hw.ddb;
2695+
2696+ seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size");
2697+
2698+ for_each_pipe(dev_priv, pipe) {
2699+ seq_printf(m, "Pipe %c\n", pipe_name(pipe));
2700+
2701+ for_each_plane(pipe, plane) {
2702+ entry = &ddb->plane[pipe][plane];
2703+ seq_printf(m, " Plane%-8d%8u%8u%8u\n", plane + 1,
2704+ entry->start, entry->end,
2705+ skl_ddb_entry_size(entry));
2706+ }
2707+
2708+ entry = &ddb->cursor[pipe];
2709+ seq_printf(m, " %-13s%8u%8u%8u\n", "Cursor", entry->start,
2710+ entry->end, skl_ddb_entry_size(entry));
2711+ }
2712+
2713+ drm_modeset_unlock_all(dev);
2714+
2715+ return 0;
2716+}
2717+
26812718 struct pipe_crc_info {
26822719 const char *name;
26832720 struct drm_device *dev;
@@ -2971,6 +3008,8 @@ static int i9xx_pipe_crc_auto_source(struct drm_device *dev, enum pipe pipe, · 287 unmodified lines
29713008 break;
29723009 }
29733010 break;
3011+ default:
3012+ break;
29743013 }
29753014 }
29763015 drm_modeset_unlock_all(dev);
@@ -3520,7 +3559,7 @@ static const struct file_operations i915_display_crc_ctl_fops = { · 543 unmodified lines
35203559 .write = display_crc_ctl_write
35213560 };
35223561
3523−static void wm_latency_show(struct seq_file *m, const uint16_t wm[5])
3562+static void wm_latency_show(struct seq_file *m, const uint16_t wm[8])
35243563 {
35253564 struct drm_device *dev = m->private;
35263565 int num_levels = ilk_wm_max_level(dev) + 1;
@@ -3531,13 +3570,17 @@ static void wm_latency_show(struct seq_file *m, const uint16_t wm[5]) · 4 unmodified lines
35313570 for (level = 0; level < num_levels; level++) {
35323571 unsigned int latency = wm[level];
35333572
3534− /* WM1+ latency values in 0.5us units */
3535− if (level > 0)
3573+ /*
3574+ * - WM1+ latency values in 0.5us units
3575+ * - latencies are in us on gen9
3576+ */
3577+ if (INTEL_INFO(dev)->gen >= 9)
3578+ latency *= 10;
3579+ else if (level > 0)
35363580 latency *= 5;
35373581
35383582 seq_printf(m, "WM%d %u (%u.%u usec)\n",
3539− level, wm[level],
3540− latency / 10, latency % 10);
3583+ level, wm[level], latency / 10, latency % 10);
35413584 }
35423585
35433586 drm_modeset_unlock_all(dev);
@@ -3546,8 +3589,15 @@ static void wm_latency_show(struct seq_file *m, const uint16_t wm[5]) · 2 unmodified lines
35463589 static int pri_wm_latency_show(struct seq_file *m, void *data)
35473590 {
35483591 struct drm_device *dev = m->private;
3592+ struct drm_i915_private *dev_priv = dev->dev_private;
3593+ const uint16_t *latencies;
3594+
3595+ if (INTEL_INFO(dev)->gen >= 9)
3596+ latencies = dev_priv->wm.skl_latency;
3597+ else
3598+ latencies = to_i915(dev)->wm.pri_latency;
35493599
3550− wm_latency_show(m, to_i915(dev)->wm.pri_latency);
3600+ wm_latency_show(m, latencies);
35513601
35523602 return 0;
35533603 }
@@ -3555,8 +3605,15 @@ static int pri_wm_latency_show(struct seq_file *m, void *data) · 1 unmodified line
35553605 static int spr_wm_latency_show(struct seq_file *m, void *data)
35563606 {
35573607 struct drm_device *dev = m->private;
3608+ struct drm_i915_private *dev_priv = dev->dev_private;
3609+ const uint16_t *latencies;
3610+
3611+ if (INTEL_INFO(dev)->gen >= 9)
3612+ latencies = dev_priv->wm.skl_latency;
3613+ else
3614+ latencies = to_i915(dev)->wm.spr_latency;
35583615
3559− wm_latency_show(m, to_i915(dev)->wm.spr_latency);
3616+ wm_latency_show(m, latencies);
35603617
35613618 return 0;
35623619 }
@@ -3564,8 +3621,15 @@ static int spr_wm_latency_show(struct seq_file *m, void *data) · 1 unmodified line
35643621 static int cur_wm_latency_show(struct seq_file *m, void *data)
35653622 {
35663623 struct drm_device *dev = m->private;
3624+ struct drm_i915_private *dev_priv = dev->dev_private;
3625+ const uint16_t *latencies;
35673626
3568− wm_latency_show(m, to_i915(dev)->wm.cur_latency);
3627+ if (INTEL_INFO(dev)->gen >= 9)
3628+ latencies = dev_priv->wm.skl_latency;
3629+ else
3630+ latencies = to_i915(dev)->wm.cur_latency;
3631+
3632+ wm_latency_show(m, latencies);
35693633
35703634 return 0;
35713635 }
@@ -3601,11 +3665,11 @@ static int cur_wm_latency_open(struct inode *inode, struct file *file) · 29 unmodified lines
36013665 }
36023666
36033667 static ssize_t wm_latency_write(struct file *file, const char __user *ubuf,
3604− size_t len, loff_t *offp, uint16_t wm[5])
3668+ size_t len, loff_t *offp, uint16_t wm[8])
36053669 {
36063670 struct seq_file *m = file->private_data;
36073671 struct drm_device *dev = m->private;
3608− uint16_t new[5] = { 0 };
3672+ uint16_t new[8] = { 0 };
36093673 int num_levels = ilk_wm_max_level(dev) + 1;
36103674 int level;
36113675 int ret;
@@ -3619,7 +3683,9 @@ static ssize_t wm_latency_write(struct file *file, const char __user *ubuf, · 7 unmodified lines
36193683
36203684 tmp[len] = '\0';
36213685
3622− ret = sscanf(tmp, "%hu %hu %hu %hu %hu", &new[0], &new[1], &new[2], &new[3], &new[4]);
3686+ ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu",
3687+ &new[0], &new[1], &new[2], &new[3],
3688+ &new[4], &new[5], &new[6], &new[7]);
36233689 if (ret != num_levels)
36243690 return -EINVAL;
36253691
@@ -3639,8 +3705,15 @@ static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf, · 13 unmodified lines
36393705 {
36403706 struct seq_file *m = file->private_data;
36413707 struct drm_device *dev = m->private;
3708+ struct drm_i915_private *dev_priv = dev->dev_private;
3709+ uint16_t *latencies;
36423710
3643− return wm_latency_write(file, ubuf, len, offp, to_i915(dev)->wm.pri_latency);
3711+ if (INTEL_INFO(dev)->gen >= 9)
3712+ latencies = dev_priv->wm.skl_latency;
3713+ else
3714+ latencies = to_i915(dev)->wm.pri_latency;
3715+
3716+ return wm_latency_write(file, ubuf, len, offp, latencies);
36443717 }
36453718
36463719 static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf,
@@ -3648,8 +3721,15 @@ static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf, · 1 unmodified line
36483721 {
36493722 struct seq_file *m = file->private_data;
36503723 struct drm_device *dev = m->private;
3724+ struct drm_i915_private *dev_priv = dev->dev_private;
3725+ uint16_t *latencies;
36513726
3652− return wm_latency_write(file, ubuf, len, offp, to_i915(dev)->wm.spr_latency);
3727+ if (INTEL_INFO(dev)->gen >= 9)
3728+ latencies = dev_priv->wm.skl_latency;
3729+ else
3730+ latencies = to_i915(dev)->wm.spr_latency;
3731+
3732+ return wm_latency_write(file, ubuf, len, offp, latencies);
36533733 }
36543734
36553735 static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf,
@@ -3657,8 +3737,15 @@ static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf, · 1 unmodified line
36573737 {
36583738 struct seq_file *m = file->private_data;
36593739 struct drm_device *dev = m->private;
3740+ struct drm_i915_private *dev_priv = dev->dev_private;
3741+ uint16_t *latencies;
3742+
3743+ if (INTEL_INFO(dev)->gen >= 9)
3744+ latencies = dev_priv->wm.skl_latency;
3745+ else
3746+ latencies = to_i915(dev)->wm.cur_latency;
36603747
3661− return wm_latency_write(file, ubuf, len, offp, to_i915(dev)->wm.cur_latency);
3748+ return wm_latency_write(file, ubuf, len, offp, latencies);
36623749 }
36633750
36643751 static const struct file_operations i915_pri_wm_latency_fops = {
@@ -4201,6 +4288,7 @@ static const struct drm_info_list i915_debugfs_list[] = { · 536 unmodified lines
42014288 {"i915_shared_dplls_info", i915_shared_dplls_info, 0},
42024289 {"i915_dp_mst_info", i915_dp_mst_info, 0},
42034290 {"i915_wa_registers", i915_wa_registers, 0},
4291+ {"i915_ddb_info", i915_ddb_info, 0},
42044292 };
42054293 #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
42064294
drivers/gpu/drm/i915/i915_drv.c+20−55
@@ -551,8 +551,8 @@ static void intel_suspend_encoders(struct drm_i915_private *dev_priv) · 550 unmodified lines
551551 }
552552
553553 static int intel_suspend_complete(struct drm_i915_private *dev_priv);
554−static int intel_resume_prepare(struct drm_i915_private *dev_priv,
555− bool rpm_resume);
554+static int vlv_resume_prepare(struct drm_i915_private *dev_priv,
555+ bool rpm_resume);
556556
557557 static int i915_drm_suspend(struct drm_device *dev)
558558 {
@@ -744,7 +744,7 @@ static int i915_drm_resume(struct drm_device *dev) · 185 unmodified lines
744744 static int i915_drm_resume_early(struct drm_device *dev)
745745 {
746746 struct drm_i915_private *dev_priv = dev->dev_private;
747− int ret;
747+ int ret = 0;
748748
749749 /*
750750 * We have a resume ordering issue with the snd-hda driver also
@@ -760,11 +760,16 @@ static int i915_drm_resume_early(struct drm_device *dev) · 9 unmodified lines
760760
761761 pci_set_master(dev->pdev);
762762
763− ret = intel_resume_prepare(dev_priv, false);
763+ if (IS_VALLEYVIEW(dev_priv))
764+ ret = vlv_resume_prepare(dev_priv, false);
764765 if (ret)
765766 DRM_ERROR("Resume prepare failed: %d,Continuing resume\n", ret);
766767
767768 intel_uncore_early_sanitize(dev, true);
769+
770+ if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
771+ hsw_disable_pc8(dev_priv);
772+
768773 intel_uncore_sanitize(dev);
769774 intel_power_domains_init_hw(dev_priv);
770775
@@ -986,25 +991,6 @@ static int hsw_suspend_complete(struct drm_i915_private *dev_priv) · 215 unmodified lines
986991 return 0;
987992 }
988993
989−static int snb_resume_prepare(struct drm_i915_private *dev_priv,
990− bool rpm_resume)
991−{
992− struct drm_device *dev = dev_priv->dev;
993−
994− if (rpm_resume)
995− intel_init_pch_refclk(dev);
996−
997− return 0;
998−}
999−
1000−static int hsw_resume_prepare(struct drm_i915_private *dev_priv,
1001− bool rpm_resume)
1002−{
1003− hsw_disable_pc8(dev_priv);
1004−
1005− return 0;
1006−}
1007−
1008994 /*
1009995 * Save all Gunit registers that may be lost after a D3 and a subsequent
1010996 * S0i[R123] transition. The list of registers needing a save/restore is
@@ -1409,13 +1395,9 @@ static int intel_runtime_suspend(struct device *device) · 398 unmodified lines
14091395 i915_gem_release_all_mmaps(dev_priv);
14101396 mutex_unlock(&dev->struct_mutex);
14111397
1412− /*
1413− * rps.work can't be rearmed here, since we get here only after making
1414− * sure the GPU is idle and the RPS freq is set to the minimum. See
1415− * intel_mark_idle().
1416− */
1417− cancel_work_sync(&dev_priv->rps.work);
1398+ flush_delayed_work(&dev_priv->rps.delayed_resume_work);
14181399 intel_runtime_pm_disable_interrupts(dev_priv);
1400+ intel_suspend_gt_powersave(dev);
14191401
14201402 ret = intel_suspend_complete(dev_priv);
14211403 if (ret) {
@@ -1462,7 +1444,7 @@ static int intel_runtime_resume(struct device *device) · 40 unmodified lines
14621444 struct pci_dev *pdev = to_pci_dev(device);
14631445 struct drm_device *dev = pci_get_drvdata(pdev);
14641446 struct drm_i915_private *dev_priv = dev->dev_private;
1465− int ret;
1447+ int ret = 0;
14661448
14671449 if (WARN_ON_ONCE(!HAS_RUNTIME_PM(dev)))
14681450 return -ENODEV;
@@ -1472,7 +1454,13 @@ static int intel_runtime_resume(struct device *device) · 3 unmodified lines
14721454 intel_opregion_notify_adapter(dev, PCI_D0);
14731455 dev_priv->pm.suspended = false;
14741456
1475− ret = intel_resume_prepare(dev_priv, true);
1457+ if (IS_GEN6(dev_priv))
1458+ intel_init_pch_refclk(dev);
1459+ else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
1460+ hsw_disable_pc8(dev_priv);
1461+ else if (IS_VALLEYVIEW(dev_priv))
1462+ ret = vlv_resume_prepare(dev_priv, true);
1463+
14761464 /*
14771465 * No point of rolling back things in case of an error, as the best
14781466 * we can do is to hope that things will still work (and disable RPM).
@@ -1481,7 +1469,7 @@ static int intel_runtime_resume(struct device *device) · 2 unmodified lines
14811469 gen6_update_ring_freq(dev);
14821470
14831471 intel_runtime_pm_enable_interrupts(dev_priv);
1484− intel_reset_gt_powersave(dev);
1472+ intel_enable_gt_powersave(dev);
14851473
14861474 if (ret)
14871475 DRM_ERROR("Runtime resume failed, disabling it (%d)\n", ret);
@@ -1510,29 +1498,6 @@ static int intel_suspend_complete(struct drm_i915_private *dev_priv) · 22 unmodified lines
15101498 return ret;
15111499 }
15121500
1513−/*
1514− * This function implements common functionality of runtime and system
1515− * resume sequence. Variable rpm_resume used for implementing different
1516− * code paths.
1517− */
1518−static int intel_resume_prepare(struct drm_i915_private *dev_priv,
1519− bool rpm_resume)
1520−{
1521− struct drm_device *dev = dev_priv->dev;
1522− int ret;
1523−
1524− if (IS_GEN6(dev))
1525− ret = snb_resume_prepare(dev_priv, rpm_resume);
1526− else if (IS_HASWELL(dev) || IS_BROADWELL(dev))
1527− ret = hsw_resume_prepare(dev_priv, rpm_resume);
1528− else if (IS_VALLEYVIEW(dev))
1529− ret = vlv_resume_prepare(dev_priv, rpm_resume);
1530− else
1531− ret = 0;
1532−
1533− return ret;
1534−}
1535−
15361501 static const struct dev_pm_ops i915_pm_ops = {
15371502 /*
15381503 * S0ix (via system suspend) and S3 event handlers [PMSG_SUSPEND,
drivers/gpu/drm/i915/i915_drv.h+88−17
@@ -55,7 +55,10 @@ · 54 unmodified lines
5555
5656 #define DRIVER_NAME "i915"
5757 #define DRIVER_DESC "Intel Graphics"
58−#define DRIVER_DATE "20141024"
58+#define DRIVER_DATE "20141107"
59+
60+#undef WARN_ON
61+#define WARN_ON(x) WARN(x, "WARN_ON(" #x ")")
5962
6063 enum pipe {
6164 INVALID_PIPE = -1,
@@ -226,14 +229,20 @@ struct intel_dpll_hw_state { · 164 unmodified lines
226229 uint32_t wrpll;
227230 };
228231
232+struct intel_shared_dpll_config {
233+ unsigned crtc_mask; /* mask of CRTCs sharing this PLL */
234+ struct intel_dpll_hw_state hw_state;
235+};
236+
229237 struct intel_shared_dpll {
230− int refcount; /* count of number of CRTCs sharing this PLL */
238+ struct intel_shared_dpll_config config;
239+ struct intel_shared_dpll_config *new_config;
240+
231241 int active; /* count of number of active CRTCs (i.e. DPMS on) */
232242 bool on; /* is the PLL actually active? Disabled during modeset */
233243 const char *name;
234244 /* should match the index in the dev_priv->shared_dplls array */
235245 enum intel_dpll_id id;
236− struct intel_dpll_hw_state hw_state;
237246 /* The mode_set hook is optional and should be used together with the
238247 * intel_prepare_shared_dpll function. */
239248 void (*mode_set)(struct drm_i915_private *dev_priv,
@@ -275,7 +284,6 @@ void intel_link_compute_m_n(int bpp, int nlanes, · 35 unmodified lines
275284 #define DRIVER_PATCHLEVEL 0
276285
277286 #define WATCH_LISTS 0
278−#define WATCH_GTT 0
279287
280288 struct opregion_header;
281289 struct opregion_acpi;
@@ -434,6 +442,7 @@ struct drm_i915_error_state { · 152 unmodified lines
434442 };
435443
436444 struct intel_connector;
445+struct intel_encoder;
437446 struct intel_crtc_config;
438447 struct intel_plane_config;
439448 struct intel_crtc;
@@ -476,15 +485,14 @@ struct drm_i915_display_funcs { · 36 unmodified lines
476485 struct intel_crtc_config *);
477486 void (*get_plane_config)(struct intel_crtc *,
478487 struct intel_plane_config *);
479− int (*crtc_mode_set)(struct intel_crtc *crtc,
480− int x, int y,
481− struct drm_framebuffer *old_fb);
488+ int (*crtc_compute_clock)(struct intel_crtc *crtc);
482489 void (*crtc_enable)(struct drm_crtc *crtc);
483490 void (*crtc_disable)(struct drm_crtc *crtc);
484491 void (*off)(struct drm_crtc *crtc);
485− void (*write_eld)(struct drm_connector *connector,
486− struct drm_crtc *crtc,
487− struct drm_display_mode *mode);
492+ void (*audio_codec_enable)(struct drm_connector *connector,
493+ struct intel_encoder *encoder,
494+ struct drm_display_mode *mode);
495+ void (*audio_codec_disable)(struct intel_encoder *encoder);
488496 void (*fdi_link_train)(struct drm_crtc *crtc);
489497 void (*init_clock_gating)(struct drm_device *dev);
490498 int (*queue_flip)(struct drm_device *dev, struct drm_crtc *crtc,
@@ -541,6 +549,7 @@ struct intel_uncore { · 50 unmodified lines
541549
542550 unsigned fw_rendercount;
543551 unsigned fw_mediacount;
552+ unsigned fw_blittercount;
544553
545554 struct timer_list force_wake_timer;
546555 };
@@ -1379,6 +1388,49 @@ struct ilk_wm_values { · 832 unmodified lines
13791388 enum intel_ddb_partitioning partitioning;
13801389 };
13811390
1391+struct skl_ddb_entry {
1392+ uint16_t start, end; /* in number of blocks, 'end' is exclusive */
1393+};
1394+
1395+static inline uint16_t skl_ddb_entry_size(const struct skl_ddb_entry *entry)
1396+{
1397+ return entry->end - entry->start;
1398+}
1399+
1400+static inline bool skl_ddb_entry_equal(const struct skl_ddb_entry *e1,
1401+ const struct skl_ddb_entry *e2)
1402+{
1403+ if (e1->start == e2->start && e1->end == e2->end)
1404+ return true;
1405+
1406+ return false;
1407+}
1408+
1409+struct skl_ddb_allocation {
1410+ struct skl_ddb_entry pipe[I915_MAX_PIPES];
1411+ struct skl_ddb_entry plane[I915_MAX_PIPES][I915_MAX_PLANES];
1412+ struct skl_ddb_entry cursor[I915_MAX_PIPES];
1413+};
1414+
1415+struct skl_wm_values {
1416+ bool dirty[I915_MAX_PIPES];
1417+ struct skl_ddb_allocation ddb;
1418+ uint32_t wm_linetime[I915_MAX_PIPES];
1419+ uint32_t plane[I915_MAX_PIPES][I915_MAX_PLANES][8];
1420+ uint32_t cursor[I915_MAX_PIPES][8];
1421+ uint32_t plane_trans[I915_MAX_PIPES][I915_MAX_PLANES];
1422+ uint32_t cursor_trans[I915_MAX_PIPES];
1423+};
1424+
1425+struct skl_wm_level {
1426+ bool plane_en[I915_MAX_PLANES];
1427+ bool cursor_en;
1428+ uint16_t plane_res_b[I915_MAX_PLANES];
1429+ uint8_t plane_res_l[I915_MAX_PLANES];
1430+ uint16_t cursor_res_b;
1431+ uint8_t cursor_res_l;
1432+};
1433+
13821434 /*
13831435 * This struct helps tracking the state needed for runtime PM, which puts the
13841436 * device in PCI D3 state. Notice that when this happens, nothing on the
@@ -1561,6 +1613,7 @@ struct drm_i915_private { · 176 unmodified lines
15611613
15621614 unsigned int fsb_freq, mem_freq, is_ddr3;
15631615 unsigned int vlv_cdclk_freq;
1616+ unsigned int hpll_freq;
15641617
15651618 /**
15661619 * wq - Driver workqueue for GEM.
@@ -1670,9 +1723,25 @@ struct drm_i915_private { · 103 unmodified lines
16701723 uint16_t spr_latency[5];
16711724 /* cursor */
16721725 uint16_t cur_latency[5];
1726+ /*
1727+ * Raw watermark memory latency values
1728+ * for SKL for all 8 levels
1729+ * in 1us units.
1730+ */
1731+ uint16_t skl_latency[8];
1732+
1733+ /*
1734+ * The skl_wm_values structure is a bit too big for stack
1735+ * allocation, so we keep the staging struct where we store
1736+ * intermediate results here instead.
1737+ */
1738+ struct skl_wm_values skl_results;
16731739
16741740 /* current hardware state */
1675− struct ilk_wm_values hw;
1741+ union {
1742+ struct ilk_wm_values hw;
1743+ struct skl_wm_values skl_hw;
1744+ };
16761745 } wm;
16771746
16781747 struct i915_runtime_pm pm;
@@ -1856,8 +1925,6 @@ struct drm_i915_gem_object { · 177 unmodified lines
18561925 unsigned long gt_ro:1;
18571926 unsigned int cache_level:3;
18581927
1859− unsigned int has_aliasing_ppgtt_mapping:1;
1860− unsigned int has_global_gtt_mapping:1;
18611928 unsigned int has_dma_mapping:1;
18621929
18631930 unsigned int frontbuffer_bits:INTEL_FRONTBUFFER_BITS;
@@ -2292,8 +2359,6 @@ __printf(3, 4) · 428 unmodified lines
22922359 void i915_handle_error(struct drm_device *dev, bool wedged,
22932360 const char *fmt, ...);
22942361
2295−void gen6_set_pm_mask(struct drm_i915_private *dev_priv, u32 pm_iir,
2296− int new_delay);
22972362 extern void intel_irq_init(struct drm_i915_private *dev_priv);
22982363 extern void intel_hpd_init(struct drm_i915_private *dev_priv);
22992364 int intel_irq_install(struct drm_i915_private *dev_priv);
@@ -2531,6 +2596,11 @@ int __i915_add_request(struct intel_engine_cs *ring, · 231 unmodified lines
25312596 u32 *seqno);
25322597 #define i915_add_request(ring, seqno) \
25332598 __i915_add_request(ring, NULL, NULL, seqno)
2599+int __i915_wait_seqno(struct intel_engine_cs *ring, u32 seqno,
2600+ unsigned reset_counter,
2601+ bool interruptible,
2602+ s64 *timeout,
2603+ struct drm_i915_file_private *file_priv);
25342604 int __must_check i915_wait_seqno(struct intel_engine_cs *ring,
25352605 uint32_t seqno);
25362606 int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
@@ -2800,7 +2870,6 @@ static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter) · 263 unmodified lines
28002870 extern void intel_i2c_reset(struct drm_device *dev);
28012871
28022872 /* intel_opregion.c */
2803−struct intel_encoder;
28042873 #ifdef CONFIG_ACPI
28052874 extern int intel_opregion_setup(struct drm_device *dev);
28062875 extern void intel_opregion_init(struct drm_device *dev);
@@ -2917,7 +2986,9 @@ int vlv_freq_opcode(struct drm_i915_private *dev_priv, int val); · 110 unmodified lines
29172986
29182987 #define FORCEWAKE_RENDER (1 << 0)
29192988 #define FORCEWAKE_MEDIA (1 << 1)
2920−#define FORCEWAKE_ALL (FORCEWAKE_RENDER | FORCEWAKE_MEDIA)
2989+#define FORCEWAKE_BLITTER (1 << 2)
2990+#define FORCEWAKE_ALL (FORCEWAKE_RENDER | FORCEWAKE_MEDIA | \
2991+ FORCEWAKE_BLITTER)
29212992
29222993
29232994 #define I915_READ8(reg) dev_priv->uncore.funcs.mmio_readb(dev_priv, (reg), true)
drivers/gpu/drm/i915/i915_gem.c+45−30
@@ -1134,7 +1134,7 @@ static bool can_wait_boost(struct drm_i915_file_private *file_priv) · 1133 unmodified lines
11341134 }
11351135
11361136 /**
1137− * __wait_seqno - wait until execution of seqno has finished
1137+ * __i915_wait_seqno - wait until execution of seqno has finished
11381138 * @ring: the ring expected to report seqno
11391139 * @seqno: duh!
11401140 * @reset_counter: reset sequence associated with the given seqno
@@ -1151,7 +1151,7 @@ static bool can_wait_boost(struct drm_i915_file_private *file_priv) · 10 unmodified lines
11511151 * Returns 0 if the seqno was found within the alloted time. Else returns the
11521152 * errno with remaining time filled in timeout argument.
11531153 */
1154−static int __wait_seqno(struct intel_engine_cs *ring, u32 seqno,
1154+int __i915_wait_seqno(struct intel_engine_cs *ring, u32 seqno,
11551155 unsigned reset_counter,
11561156 bool interruptible,
11571157 s64 *timeout,
@@ -1262,6 +1262,7 @@ i915_wait_seqno(struct intel_engine_cs *ring, uint32_t seqno) · 104 unmodified lines
12621262 struct drm_device *dev = ring->dev;
12631263 struct drm_i915_private *dev_priv = dev->dev_private;
12641264 bool interruptible = dev_priv->mm.interruptible;
1265+ unsigned reset_counter;
12651266 int ret;
12661267
12671268 BUG_ON(!mutex_is_locked(&dev->struct_mutex));
@@ -1275,14 +1276,13 @@ i915_wait_seqno(struct intel_engine_cs *ring, uint32_t seqno) · 7 unmodified lines
12751276 if (ret)
12761277 return ret;
12771278
1278− return __wait_seqno(ring, seqno,
1279− atomic_read(&dev_priv->gpu_error.reset_counter),
1280− interruptible, NULL, NULL);
1279+ reset_counter = atomic_read(&dev_priv->gpu_error.reset_counter);
1280+ return __i915_wait_seqno(ring, seqno, reset_counter, interruptible,
1281+ NULL, NULL);
12811282 }
12821283
12831284 static int
1284−i915_gem_object_wait_rendering__tail(struct drm_i915_gem_object *obj,
1285− struct intel_engine_cs *ring)
1285+i915_gem_object_wait_rendering__tail(struct drm_i915_gem_object *obj)
12861286 {
12871287 if (!obj->active)
12881288 return 0;
@@ -1319,7 +1319,7 @@ i915_gem_object_wait_rendering(struct drm_i915_gem_object *obj, · 30 unmodified lines
13191319 if (ret)
13201320 return ret;
13211321
1322− return i915_gem_object_wait_rendering__tail(obj, ring);
1322+ return i915_gem_object_wait_rendering__tail(obj);
13231323 }
13241324
13251325 /* A nonblocking variant of the above wait. This is a highly dangerous routine
@@ -1354,12 +1354,13 @@ i915_gem_object_wait_rendering__nonblocking(struct drm_i915_gem_object *obj, · 28 unmodified lines
13541354
13551355 reset_counter = atomic_read(&dev_priv->gpu_error.reset_counter);
13561356 mutex_unlock(&dev->struct_mutex);
1357− ret = __wait_seqno(ring, seqno, reset_counter, true, NULL, file_priv);
1357+ ret = __i915_wait_seqno(ring, seqno, reset_counter, true, NULL,
1358+ file_priv);
13581359 mutex_lock(&dev->struct_mutex);
13591360 if (ret)
13601361 return ret;
13611362
1362− return i915_gem_object_wait_rendering__tail(obj, ring);
1363+ return i915_gem_object_wait_rendering__tail(obj);
13631364 }
13641365
13651366 /**
@@ -2848,8 +2849,8 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file) · 1482 unmodified lines
28482849 reset_counter = atomic_read(&dev_priv->gpu_error.reset_counter);
28492850 mutex_unlock(&dev->struct_mutex);
28502851
2851− return __wait_seqno(ring, seqno, reset_counter, true, &args->timeout_ns,
2852− file->driver_priv);
2852+ return __i915_wait_seqno(ring, seqno, reset_counter, true,
2853+ &args->timeout_ns, file->driver_priv);
28532854
28542855 out:
28552856 drm_gem_object_unreference(&obj->base);
@@ -3477,23 +3478,9 @@ search_free: · 621 unmodified lines
34773478 list_move_tail(&obj->global_list, &dev_priv->mm.bound_list);
34783479 list_add_tail(&vma->mm_list, &vm->inactive_list);
34793480
3480− if (i915_is_ggtt(vm)) {
3481− bool mappable, fenceable;
3482−
3483− fenceable = (vma->node.size == fence_size &&
3484− (vma->node.start & (fence_alignment - 1)) == 0);
3485−
3486− mappable = (vma->node.start + obj->base.size <=
3487− dev_priv->gtt.mappable_end);
3488−
3489− obj->map_and_fenceable = mappable && fenceable;
3490− }
3491−
3492− WARN_ON(flags & PIN_MAPPABLE && !obj->map_and_fenceable);
3493−
34943481 trace_i915_vma_bind(vma, flags);
34953482 vma->bind_vma(vma, obj->cache_level,
3496− flags & (PIN_MAPPABLE | PIN_GLOBAL) ? GLOBAL_BIND : 0);
3483+ flags & PIN_GLOBAL ? GLOBAL_BIND : 0);
34973484
34983485 return vma;
34993486
@@ -3701,7 +3688,7 @@ int i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj, · 201 unmodified lines
37013688 list_for_each_entry(vma, &obj->vma_list, vma_link)
37023689 if (drm_mm_node_allocated(&vma->node))
37033690 vma->bind_vma(vma, cache_level,
3704− obj->has_global_gtt_mapping ? GLOBAL_BIND : 0);
3691+ vma->bound & GLOBAL_BIND);
37053692 }
37063693
37073694 list_for_each_entry(vma, &obj->vma_list, vma_link)
@@ -4028,7 +4015,7 @@ i915_gem_ring_throttle(struct drm_device *dev, struct drm_file *file) · 320 unmodified lines
40284015 if (seqno == 0)
40294016 return 0;
40304017
4031− ret = __wait_seqno(ring, seqno, reset_counter, true, NULL, NULL);
4018+ ret = __i915_wait_seqno(ring, seqno, reset_counter, true, NULL, NULL);
40324019 if (ret == 0)
40334020 queue_delayed_work(dev_priv->wq, &dev_priv->mm.retire_work, 0);
40344021
@@ -4062,6 +4049,7 @@ i915_gem_object_pin(struct drm_i915_gem_object *obj, · 27 unmodified lines
40624049 {
40634050 struct drm_i915_private *dev_priv = obj->base.dev->dev_private;
40644051 struct i915_vma *vma;
4052+ unsigned bound;
40654053 int ret;
40664054
40674055 if (WARN_ON(vm == &dev_priv->mm.aliasing_ppgtt->base))
@@ -4070,6 +4058,9 @@ i915_gem_object_pin(struct drm_i915_gem_object *obj, · 2 unmodified lines
40704058 if (WARN_ON(flags & (PIN_GLOBAL | PIN_MAPPABLE) && !i915_is_ggtt(vm)))
40714059 return -EINVAL;
40724060
4061+ if (WARN_ON((flags & (PIN_MAPPABLE | PIN_GLOBAL)) == PIN_MAPPABLE))
4062+ return -EINVAL;
4063+
40734064 vma = i915_gem_obj_to_vma(obj, vm);
40744065 if (vma) {
40754066 if (WARN_ON(vma->pin_count == DRM_I915_GEM_OBJECT_MAX_PIN_COUNT))
@@ -4091,15 +4082,39 @@ i915_gem_object_pin(struct drm_i915_gem_object *obj, · 15 unmodified lines
40914082 }
40924083 }
40934084
4085+ bound = vma ? vma->bound : 0;
40944086 if (vma == NULL || !drm_mm_node_allocated(&vma->node)) {
40954087 vma = i915_gem_object_bind_to_vm(obj, vm, alignment, flags);
40964088 if (IS_ERR(vma))
40974089 return PTR_ERR(vma);
40984090 }
40994091
4100− if (flags & PIN_GLOBAL && !obj->has_global_gtt_mapping)
4092+ if (flags & PIN_GLOBAL && !(vma->bound & GLOBAL_BIND))
41014093 vma->bind_vma(vma, obj->cache_level, GLOBAL_BIND);
41024094
4095+ if ((bound ^ vma->bound) & GLOBAL_BIND) {
4096+ bool mappable, fenceable;
4097+ u32 fence_size, fence_alignment;
4098+
4099+ fence_size = i915_gem_get_gtt_size(obj->base.dev,
4100+ obj->base.size,
4101+ obj->tiling_mode);
4102+ fence_alignment = i915_gem_get_gtt_alignment(obj->base.dev,
4103+ obj->base.size,
4104+ obj->tiling_mode,
4105+ true);
4106+
4107+ fenceable = (vma->node.size == fence_size &&
4108+ (vma->node.start & (fence_alignment - 1)) == 0);
4109+
4110+ mappable = (vma->node.start + obj->base.size <=
4111+ dev_priv->gtt.mappable_end);
4112+
4113+ obj->map_and_fenceable = mappable && fenceable;
4114+ }
4115+
4116+ WARN_ON(flags & PIN_MAPPABLE && !obj->map_and_fenceable);
4117+
41034118 vma->pin_count++;
41044119 if (flags & PIN_MAPPABLE)
41054120 obj->pin_mappable |= true;
drivers/gpu/drm/i915/i915_gem_context.c+5−5
@@ -522,6 +522,7 @@ static int do_switch(struct intel_engine_cs *ring, · 521 unmodified lines
522522 struct intel_context *from = ring->last_context;
523523 u32 hw_flags = 0;
524524 bool uninitialized = false;
525+ struct i915_vma *vma;
525526 int ret, i;
526527
527528 if (from != NULL && ring == &dev_priv->ring[RCS]) {
@@ -571,11 +572,10 @@ static int do_switch(struct intel_engine_cs *ring, · 43 unmodified lines
571572 if (ret)
572573 goto unpin_out;
573574
574− if (!to->legacy_hw_ctx.rcs_state->has_global_gtt_mapping) {
575− struct i915_vma *vma = i915_gem_obj_to_vma(to->legacy_hw_ctx.rcs_state,
576− &dev_priv->gtt.base);
577− vma->bind_vma(vma, to->legacy_hw_ctx.rcs_state->cache_level, GLOBAL_BIND);
578− }
575+ vma = i915_gem_obj_to_ggtt(to->legacy_hw_ctx.rcs_state);
576+ if (!(vma->bound & GLOBAL_BIND))
577+ vma->bind_vma(vma, to->legacy_hw_ctx.rcs_state->cache_level,
578+ GLOBAL_BIND);
579579
580580 if (!to->legacy_hw_ctx.initialized || i915_gem_context_is_default(to))
581581 hw_flags |= MI_RESTORE_INHIBIT;
drivers/gpu/drm/i915/i915_gem_execbuffer.c+17−18
@@ -357,12 +357,9 @@ i915_gem_execbuffer_relocate_entry(struct drm_i915_gem_object *obj, · 356 unmodified lines
357357 * through the ppgtt for non_secure batchbuffers. */
358358 if (unlikely(IS_GEN6(dev) &&
359359 reloc->write_domain == I915_GEM_DOMAIN_INSTRUCTION &&
360− !target_i915_obj->has_global_gtt_mapping)) {
361− struct i915_vma *vma =
362− list_first_entry(&target_i915_obj->vma_list,
363− typeof(*vma), vma_link);
364− vma->bind_vma(vma, target_i915_obj->cache_level, GLOBAL_BIND);
365− }
360+ !(target_vma->bound & GLOBAL_BIND)))
361+ target_vma->bind_vma(target_vma, target_i915_obj->cache_level,
362+ GLOBAL_BIND);
366363
367364 /* Validate that the target is in a valid r/w GPU domain */
368365 if (unlikely(reloc->write_domain & (reloc->write_domain - 1))) {
@@ -531,7 +528,7 @@ i915_gem_execbuffer_reserve_vma(struct i915_vma *vma, · 162 unmodified lines
531528
532529 flags = 0;
533530 if (entry->flags & __EXEC_OBJECT_NEEDS_MAP)
534− flags |= PIN_MAPPABLE;
531+ flags |= PIN_GLOBAL | PIN_MAPPABLE;
535532 if (entry->flags & EXEC_OBJECT_NEEDS_GTT)
536533 flags |= PIN_GLOBAL;
537534 if (entry->flags & __EXEC_OBJECT_NEEDS_BIAS)
@@ -1368,17 +1365,19 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, · 830 unmodified lines
13681365 batch_obj,
13691366 args->batch_start_offset,
13701367 file->is_master);
1371− if (ret)
1372− goto err;
1373−
1374− /*
1375− * XXX: Actually do this when enabling batch copy...
1376− *
1377− * Set the DISPATCH_SECURE bit to remove the NON_SECURE bit
1378− * from MI_BATCH_BUFFER_START commands issued in the
1379− * dispatch_execbuffer implementations. We specifically don't
1380− * want that set when the command parser is enabled.
1381− */
1368+ if (ret) {
1369+ if (ret != -EACCES)
1370+ goto err;
1371+ } else {
1372+ /*
1373+ * XXX: Actually do this when enabling batch copy...
1374+ *
1375+ * Set the DISPATCH_SECURE bit to remove the NON_SECURE bit
1376+ * from MI_BATCH_BUFFER_START commands issued in the
1377+ * dispatch_execbuffer implementations. We specifically don't
1378+ * want that set when the command parser is enabled.
1379+ */
1380+ }
13821381 }
13831382
13841383 /* snb/ivb/vlv conflate the "batch in ppgtt" bit with the "non-secure
drivers/gpu/drm/i915/i915_gem_gtt.c+13−13
@@ -1266,7 +1266,7 @@ void i915_check_and_clear_faults(struct drm_device *dev) · 1265 unmodified lines
12661266 fault_reg = I915_READ(RING_FAULT_REG(ring));
12671267 if (fault_reg & RING_FAULT_VALID) {
12681268 DRM_DEBUG_DRIVER("Unexpected fault\n"
1269− "\tAddr: 0x%08lx\\n"
1269+ "\tAddr: 0x%08lx\n"
12701270 "\tAddress space: %s\n"
12711271 "\tSource ID: %d\n"
12721272 "\tType: %d\n",
@@ -1336,7 +1336,7 @@ void i915_gem_restore_gtt_mappings(struct drm_device *dev) · 63 unmodified lines
13361336 * Unfortunately above, we've just wiped out the mappings
13371337 * without telling our object about it. So we need to fake it.
13381338 */
1339− obj->has_global_gtt_mapping = 0;
1339+ vma->bound &= ~GLOBAL_BIND;
13401340 vma->bind_vma(vma, obj->cache_level, GLOBAL_BIND);
13411341 }
13421342
@@ -1533,7 +1533,7 @@ static void i915_ggtt_bind_vma(struct i915_vma *vma, · 190 unmodified lines
15331533
15341534 BUG_ON(!i915_is_ggtt(vma->vm));
15351535 intel_gtt_insert_sg_entries(vma->obj->pages, entry, flags);
1536− vma->obj->has_global_gtt_mapping = 1;
1536+ vma->bound = GLOBAL_BIND;
15371537 }
15381538
15391539 static void i915_ggtt_clear_range(struct i915_address_space *vm,
@@ -1552,7 +1552,7 @@ static void i915_ggtt_unbind_vma(struct i915_vma *vma) · 12 unmodified lines
15521552 const unsigned int size = vma->obj->base.size >> PAGE_SHIFT;
15531553
15541554 BUG_ON(!i915_is_ggtt(vma->vm));
1555− vma->obj->has_global_gtt_mapping = 0;
1555+ vma->bound = 0;
15561556 intel_gtt_clear_range(first, size);
15571557 }
15581558
@@ -1580,24 +1580,24 @@ static void ggtt_bind_vma(struct i915_vma *vma, · 21 unmodified lines
15801580 * flags. At all other times, the GPU will use the aliasing PPGTT.
15811581 */
15821582 if (!dev_priv->mm.aliasing_ppgtt || flags & GLOBAL_BIND) {
1583− if (!obj->has_global_gtt_mapping ||
1583+ if (!(vma->bound & GLOBAL_BIND) ||
15841584 (cache_level != obj->cache_level)) {
15851585 vma->vm->insert_entries(vma->vm, obj->pages,
15861586 vma->node.start,
15871587 cache_level, flags);
1588− obj->has_global_gtt_mapping = 1;
1588+ vma->bound |= GLOBAL_BIND;
15891589 }
15901590 }
15911591
15921592 if (dev_priv->mm.aliasing_ppgtt &&
1593− (!obj->has_aliasing_ppgtt_mapping ||
1593+ (!(vma->bound & LOCAL_BIND) ||
15941594 (cache_level != obj->cache_level))) {
15951595 struct i915_hw_ppgtt *appgtt = dev_priv->mm.aliasing_ppgtt;
15961596 appgtt->base.insert_entries(&appgtt->base,
15971597 vma->obj->pages,
15981598 vma->node.start,
15991599 cache_level, flags);
1600− vma->obj->has_aliasing_ppgtt_mapping = 1;
1600+ vma->bound |= LOCAL_BIND;
16011601 }
16021602 }
16031603
@@ -1607,21 +1607,21 @@ static void ggtt_unbind_vma(struct i915_vma *vma) · 3 unmodified lines
16071607 struct drm_i915_private *dev_priv = dev->dev_private;
16081608 struct drm_i915_gem_object *obj = vma->obj;
16091609
1610− if (obj->has_global_gtt_mapping) {
1610+ if (vma->bound & GLOBAL_BIND) {
16111611 vma->vm->clear_range(vma->vm,
16121612 vma->node.start,
16131613 obj->base.size,
16141614 true);
1615− obj->has_global_gtt_mapping = 0;
1615+ vma->bound &= ~GLOBAL_BIND;
16161616 }
16171617
1618− if (obj->has_aliasing_ppgtt_mapping) {
1618+ if (vma->bound & LOCAL_BIND) {
16191619 struct i915_hw_ppgtt *appgtt = dev_priv->mm.aliasing_ppgtt;
16201620 appgtt->base.clear_range(&appgtt->base,
16211621 vma->node.start,
16221622 obj->base.size,
16231623 true);
1624− obj->has_aliasing_ppgtt_mapping = 0;
1624+ vma->bound &= ~LOCAL_BIND;
16251625 }
16261626 }
16271627
@@ -1699,7 +1699,7 @@ int i915_gem_setup_global_gtt(struct drm_device *dev, · 71 unmodified lines
16991699 DRM_DEBUG_KMS("Reservation failed: %i\n", ret);
17001700 return ret;
17011701 }
1702− obj->has_global_gtt_mapping = 1;
1702+ vma->bound |= GLOBAL_BIND;
17031703 }
17041704
17051705 dev_priv->gtt.base.start = start;
drivers/gpu/drm/i915/i915_gem_gtt.h+6−2
@@ -123,6 +123,12 @@ struct i915_vma { · 122 unmodified lines
123123 struct drm_i915_gem_object *obj;
124124 struct i915_address_space *vm;
125125
126+ /** Flags and address space this VMA is bound to */
127+#define GLOBAL_BIND (1<<0)
128+#define LOCAL_BIND (1<<1)
129+#define PTE_READ_ONLY (1<<2)
130+ unsigned int bound : 4;
131+
126132 /** This object's place on the active/inactive lists */
127133 struct list_head mm_list;
128134
@@ -155,8 +161,6 @@ struct i915_vma { · 26 unmodified lines
155161 * setting the valid PTE entries to a reserved scratch page. */
156162 void (*unbind_vma)(struct i915_vma *vma);
157163 /* Map an object into an address space with the given cache flags. */
158−#define GLOBAL_BIND (1<<0)
159−#define PTE_READ_ONLY (1<<1)
160164 void (*bind_vma)(struct i915_vma *vma,
161165 enum i915_cache_level cache_level,
162166 u32 flags);
drivers/gpu/drm/i915/i915_gem_render_state.c+2−0
@@ -38,6 +38,8 @@ render_state_get_rodata(struct drm_device *dev, const int gen) · 37 unmodified lines
3838 return &gen7_null_state;
3939 case 8:
4040 return &gen8_null_state;
41+ case 9:
42+ return &gen9_null_state;
4143 }
4244
4345 return NULL;
drivers/gpu/drm/i915/i915_gem_stolen.c+1−1
@@ -533,7 +533,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev, · 532 unmodified lines
533533 }
534534 }
535535
536− obj->has_global_gtt_mapping = 1;
536+ vma->bound |= GLOBAL_BIND;
537537
538538 list_add_tail(&obj->global_list, &dev_priv->mm.bound_list);
539539 list_add_tail(&vma->mm_list, &ggtt->inactive_list);
drivers/gpu/drm/i915/i915_gem_tiling.c+1−0
@@ -458,6 +458,7 @@ i915_gem_get_tiling(struct drm_device *dev, void *data, · 457 unmodified lines
458458 }
459459
460460 /* Hide bit 17 from the user -- see comment in i915_gem_set_tiling */
461+ args->phys_swizzle_mode = args->swizzle_mode;
461462 if (args->swizzle_mode == I915_BIT_6_SWIZZLE_9_17)
462463 args->swizzle_mode = I915_BIT_6_SWIZZLE_9;
463464 if (args->swizzle_mode == I915_BIT_6_SWIZZLE_9_10_17)
drivers/gpu/drm/i915/i915_gpu_error.c+8−5
@@ -565,6 +565,7 @@ i915_error_object_create(struct drm_i915_private *dev_priv, · 564 unmodified lines
565565 struct i915_address_space *vm)
566566 {
567567 struct drm_i915_error_object *dst;
568+ struct i915_vma *vma = NULL;
568569 int num_pages;
569570 bool use_ggtt;
570571 int i = 0;
@@ -585,16 +586,17 @@ i915_error_object_create(struct drm_i915_private *dev_priv, · 14 unmodified lines
585586 dst->gtt_offset = -1;
586587
587588 reloc_offset = dst->gtt_offset;
589+ if (i915_is_ggtt(vm))
590+ vma = i915_gem_obj_to_ggtt(src);
588591 use_ggtt = (src->cache_level == I915_CACHE_NONE &&
589− i915_is_ggtt(vm) &&
590− src->has_global_gtt_mapping &&
591− reloc_offset + num_pages * PAGE_SIZE <= dev_priv->gtt.mappable_end);
592+ vma && (vma->bound & GLOBAL_BIND) &&
593+ reloc_offset + num_pages * PAGE_SIZE <= dev_priv->gtt.mappable_end);
592594
593595 /* Cannot access stolen address directly, try to use the aperture */
594596 if (src->stolen) {
595597 use_ggtt = true;
596598
597− if (!src->has_global_gtt_mapping)
599+ if (!(vma && vma->bound & GLOBAL_BIND))
598600 goto unwind;
599601
600602 reloc_offset = i915_gem_obj_ggtt_offset(src);
@@ -1240,7 +1242,8 @@ static void i915_error_capture_msg(struct drm_device *dev, · 639 unmodified lines
12401242 ecode = i915_error_generate_code(dev_priv, error, &ring_id);
12411243
12421244 len = scnprintf(error->error_msg, sizeof(error->error_msg),
1243− "GPU HANG: ecode %d:0x%08x", ring_id, ecode);
1245+ "GPU HANG: ecode %d:%d:0x%08x",
1246+ INTEL_INFO(dev)->gen, ring_id, ecode);
12441247
12451248 if (ring_id != -1 && error->ring[ring_id].pid != -1)
12461249 len += scnprintf(error->error_msg + len,
drivers/gpu/drm/i915/i915_irq.c+60−96
@@ -126,16 +126,16 @@ static const u32 hpd_status_i915[] = { /* i915 and valleyview are the same */ · 125 unmodified lines
126126
127127 #define GEN8_IRQ_INIT_NDX(type, which, imr_val, ier_val) do { \
128128 GEN5_ASSERT_IIR_IS_ZERO(GEN8_##type##_IIR(which)); \
129− I915_WRITE(GEN8_##type##_IMR(which), (imr_val)); \
130129 I915_WRITE(GEN8_##type##_IER(which), (ier_val)); \
131− POSTING_READ(GEN8_##type##_IER(which)); \
130+ I915_WRITE(GEN8_##type##_IMR(which), (imr_val)); \
131+ POSTING_READ(GEN8_##type##_IMR(which)); \
132132 } while (0)
133133
134134 #define GEN5_IRQ_INIT(type, imr_val, ier_val) do { \
135135 GEN5_ASSERT_IIR_IS_ZERO(type##IIR); \
136− I915_WRITE(type##IMR, (imr_val)); \
137136 I915_WRITE(type##IER, (ier_val)); \
138− POSTING_READ(type##IER); \
137+ I915_WRITE(type##IMR, (imr_val)); \
138+ POSTING_READ(type##IMR); \
139139 } while (0)
140140
141141 /* For display hotplug interrupt */
@@ -979,9 +979,6 @@ static void notify_ring(struct drm_device *dev, · 837 unmodified lines
979979
980980 trace_i915_gem_request_complete(ring);
981981
982− if (drm_core_check_feature(dev, DRIVER_MODESET))
983− intel_notify_mmio_flip(ring);
984−
985982 wake_up_all(&ring->irq_queue);
986983 i915_queue_hangcheck(dev);
987984 }
@@ -3105,10 +3102,22 @@ static void ironlake_irq_reset(struct drm_device *dev) · 2117 unmodified lines
31053102 ibx_irq_reset(dev);
31063103 }
31073104
3105+static void vlv_display_irq_reset(struct drm_i915_private *dev_priv)
3106+{
3107+ enum pipe pipe;
3108+
3109+ I915_WRITE(PORT_HOTPLUG_EN, 0);
3110+ I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
3111+
3112+ for_each_pipe(dev_priv, pipe)
3113+ I915_WRITE(PIPESTAT(pipe), 0xffff);
3114+
3115+ GEN5_IRQ_RESET(VLV_);
3116+}
3117+
31083118 static void valleyview_irq_preinstall(struct drm_device *dev)
31093119 {
31103120 struct drm_i915_private *dev_priv = dev->dev_private;
3111− int pipe;
31123121
31133122 /* VLV magic */
31143123 I915_WRITE(VLV_IMR, 0);
@@ -3116,22 +3125,11 @@ static void valleyview_irq_preinstall(struct drm_device *dev) · 1 unmodified line
31163125 I915_WRITE(RING_IMR(GEN6_BSD_RING_BASE), 0);
31173126 I915_WRITE(RING_IMR(BLT_RING_BASE), 0);
31183127
3119− /* and GT */
3120− I915_WRITE(GTIIR, I915_READ(GTIIR));
3121− I915_WRITE(GTIIR, I915_READ(GTIIR));
3122−
31233128 gen5_gt_irq_reset(dev);
31243129
3125− I915_WRITE(DPINVGTT, 0xff);
3130+ I915_WRITE(DPINVGTT, DPINVGTT_STATUS_MASK);
31263131
3127− I915_WRITE(PORT_HOTPLUG_EN, 0);
3128− I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
3129− for_each_pipe(dev_priv, pipe)
3130− I915_WRITE(PIPESTAT(pipe), 0xffff);
3131− I915_WRITE(VLV_IIR, 0xffffffff);
3132− I915_WRITE(VLV_IMR, 0xffffffff);
3133− I915_WRITE(VLV_IER, 0x0);
3134− POSTING_READ(VLV_IER);
3132+ vlv_display_irq_reset(dev_priv);
31353133 }
31363134
31373135 static void gen8_gt_irq_reset(struct drm_i915_private *dev_priv)
@@ -3179,7 +3177,6 @@ void gen8_irq_power_well_post_enable(struct drm_i915_private *dev_priv) · 41 unmodified lines
31793177 static void cherryview_irq_preinstall(struct drm_device *dev)
31803178 {
31813179 struct drm_i915_private *dev_priv = dev->dev_private;
3182− int pipe;
31833180
31843181 I915_WRITE(GEN8_MASTER_IRQ, 0);
31853182 POSTING_READ(GEN8_MASTER_IRQ);
@@ -3188,20 +3185,9 @@ static void cherryview_irq_preinstall(struct drm_device *dev) · 2 unmodified lines
31883185
31893186 GEN5_IRQ_RESET(GEN8_PCU_);
31903187
3191− POSTING_READ(GEN8_PCU_IIR);
3192−
31933188 I915_WRITE(DPINVGTT, DPINVGTT_STATUS_MASK_CHV);
31943189
3195− I915_WRITE(PORT_HOTPLUG_EN, 0);
3196− I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
3197−
3198− for_each_pipe(dev_priv, pipe)
3199− I915_WRITE(PIPESTAT(pipe), 0xffff);
3200−
3201− I915_WRITE(VLV_IMR, 0xffffffff);
3202− I915_WRITE(VLV_IER, 0x0);
3203− I915_WRITE(VLV_IIR, 0xffffffff);
3204− POSTING_READ(VLV_IIR);
3190+ vlv_display_irq_reset(dev_priv);
32053191 }
32063192
32073193 static void ibx_hpd_irq_setup(struct drm_device *dev)
@@ -3342,45 +3328,51 @@ static void valleyview_display_irqs_install(struct drm_i915_private *dev_priv) · 134 unmodified lines
33423328 {
33433329 u32 pipestat_mask;
33443330 u32 iir_mask;
3331+ enum pipe pipe;
33453332
33463333 pipestat_mask = PIPESTAT_INT_STATUS_MASK |
33473334 PIPE_FIFO_UNDERRUN_STATUS;
33483335
3349− I915_WRITE(PIPESTAT(PIPE_A), pipestat_mask);
3350− I915_WRITE(PIPESTAT(PIPE_B), pipestat_mask);
3336+ for_each_pipe(dev_priv, pipe)
3337+ I915_WRITE(PIPESTAT(pipe), pipestat_mask);
33513338 POSTING_READ(PIPESTAT(PIPE_A));
33523339
33533340 pipestat_mask = PLANE_FLIP_DONE_INT_STATUS_VLV |
33543341 PIPE_CRC_DONE_INTERRUPT_STATUS;
33553342
3356− i915_enable_pipestat(dev_priv, PIPE_A, pipestat_mask |
3357− PIPE_GMBUS_INTERRUPT_STATUS);
3358− i915_enable_pipestat(dev_priv, PIPE_B, pipestat_mask);
3343+ i915_enable_pipestat(dev_priv, PIPE_A, PIPE_GMBUS_INTERRUPT_STATUS);
3344+ for_each_pipe(dev_priv, pipe)
3345+ i915_enable_pipestat(dev_priv, pipe, pipestat_mask);
33593346
33603347 iir_mask = I915_DISPLAY_PORT_INTERRUPT |
33613348 I915_DISPLAY_PIPE_A_EVENT_INTERRUPT |
33623349 I915_DISPLAY_PIPE_B_EVENT_INTERRUPT;
3350+ if (IS_CHERRYVIEW(dev_priv))
3351+ iir_mask |= I915_DISPLAY_PIPE_C_EVENT_INTERRUPT;
33633352 dev_priv->irq_mask &= ~iir_mask;
33643353
33653354 I915_WRITE(VLV_IIR, iir_mask);
33663355 I915_WRITE(VLV_IIR, iir_mask);
3367− I915_WRITE(VLV_IMR, dev_priv->irq_mask);
33683356 I915_WRITE(VLV_IER, ~dev_priv->irq_mask);
3369− POSTING_READ(VLV_IER);
3357+ I915_WRITE(VLV_IMR, dev_priv->irq_mask);
3358+ POSTING_READ(VLV_IMR);
33703359 }
33713360
33723361 static void valleyview_display_irqs_uninstall(struct drm_i915_private *dev_priv)
33733362 {
33743363 u32 pipestat_mask;
33753364 u32 iir_mask;
3365+ enum pipe pipe;
33763366
33773367 iir_mask = I915_DISPLAY_PORT_INTERRUPT |
33783368 I915_DISPLAY_PIPE_A_EVENT_INTERRUPT |
33793369 I915_DISPLAY_PIPE_B_EVENT_INTERRUPT;
3370+ if (IS_CHERRYVIEW(dev_priv))
3371+ iir_mask |= I915_DISPLAY_PIPE_C_EVENT_INTERRUPT;
33803372
33813373 dev_priv->irq_mask |= iir_mask;
3382− I915_WRITE(VLV_IER, ~dev_priv->irq_mask);
33833374 I915_WRITE(VLV_IMR, dev_priv->irq_mask);
3375+ I915_WRITE(VLV_IER, ~dev_priv->irq_mask);
33843376 I915_WRITE(VLV_IIR, iir_mask);
33853377 I915_WRITE(VLV_IIR, iir_mask);
33863378 POSTING_READ(VLV_IIR);
@@ -3388,14 +3380,15 @@ static void valleyview_display_irqs_uninstall(struct drm_i915_private *dev_priv) · 1 unmodified line
33883380 pipestat_mask = PLANE_FLIP_DONE_INT_STATUS_VLV |
33893381 PIPE_CRC_DONE_INTERRUPT_STATUS;
33903382
3391− i915_disable_pipestat(dev_priv, PIPE_A, pipestat_mask |
3392− PIPE_GMBUS_INTERRUPT_STATUS);
3393− i915_disable_pipestat(dev_priv, PIPE_B, pipestat_mask);
3383+ i915_disable_pipestat(dev_priv, PIPE_A, PIPE_GMBUS_INTERRUPT_STATUS);
3384+ for_each_pipe(dev_priv, pipe)
3385+ i915_disable_pipestat(dev_priv, pipe, pipestat_mask);
33943386
33953387 pipestat_mask = PIPESTAT_INT_STATUS_MASK |
33963388 PIPE_FIFO_UNDERRUN_STATUS;
3397− I915_WRITE(PIPESTAT(PIPE_A), pipestat_mask);
3398− I915_WRITE(PIPESTAT(PIPE_B), pipestat_mask);
3389+
3390+ for_each_pipe(dev_priv, pipe)
3391+ I915_WRITE(PIPESTAT(pipe), pipestat_mask);
33993392 POSTING_READ(PIPESTAT(PIPE_A));
34003393 }
34013394
@@ -3425,19 +3418,18 @@ void valleyview_disable_display_irqs(struct drm_i915_private *dev_priv) · 23 unmodified lines
34253418 valleyview_display_irqs_uninstall(dev_priv);
34263419 }
34273420
3428−static int valleyview_irq_postinstall(struct drm_device *dev)
3421+static void vlv_display_irq_postinstall(struct drm_i915_private *dev_priv)
34293422 {
3430− struct drm_i915_private *dev_priv = dev->dev_private;
3431−
34323423 dev_priv->irq_mask = ~0;
34333424
34343425 I915_WRITE(PORT_HOTPLUG_EN, 0);
34353426 POSTING_READ(PORT_HOTPLUG_EN);
34363427
3437− I915_WRITE(VLV_IMR, dev_priv->irq_mask);
3438− I915_WRITE(VLV_IER, ~dev_priv->irq_mask);
34393428 I915_WRITE(VLV_IIR, 0xffffffff);
3440− POSTING_READ(VLV_IER);
3429+ I915_WRITE(VLV_IIR, 0xffffffff);
3430+ I915_WRITE(VLV_IER, ~dev_priv->irq_mask);
3431+ I915_WRITE(VLV_IMR, dev_priv->irq_mask);
3432+ POSTING_READ(VLV_IMR);
34413433
34423434 /* Interrupt setup is already guaranteed to be single-threaded, this is
34433435 * just to make the assert_spin_locked check happy. */
@@ -3445,9 +3437,13 @@ static int valleyview_irq_postinstall(struct drm_device *dev) · 1 unmodified line
34453437 if (dev_priv->display_irqs_enabled)
34463438 valleyview_display_irqs_install(dev_priv);
34473439 spin_unlock_irq(&dev_priv->irq_lock);
3440+}
34483441
3449− I915_WRITE(VLV_IIR, 0xffffffff);
3450− I915_WRITE(VLV_IIR, 0xffffffff);
3442+static int valleyview_irq_postinstall(struct drm_device *dev)
3443+{
3444+ struct drm_i915_private *dev_priv = dev->dev_private;
3445+
3446+ vlv_display_irq_postinstall(dev_priv);
34513447
34523448 gen5_gt_irq_postinstall(dev);
34533449
@@ -3561,8 +3557,10 @@ static int cherryview_irq_postinstall(struct drm_device *dev) · 107 unmodified lines
35613557 spin_unlock_irq(&dev_priv->irq_lock);
35623558
35633559 I915_WRITE(VLV_IIR, 0xffffffff);
3564− I915_WRITE(VLV_IMR, dev_priv->irq_mask);
3560+ I915_WRITE(VLV_IIR, 0xffffffff);
35653561 I915_WRITE(VLV_IER, enable_mask);
3562+ I915_WRITE(VLV_IMR, dev_priv->irq_mask);
3563+ POSTING_READ(VLV_IMR);
35663564
35673565 gen8_gt_irq_postinstall(dev_priv);
35683566
@@ -3585,19 +3583,15 @@ static void gen8_irq_uninstall(struct drm_device *dev) · 16 unmodified lines
35853583 static void valleyview_irq_uninstall(struct drm_device *dev)
35863584 {
35873585 struct drm_i915_private *dev_priv = dev->dev_private;
3588− int pipe;
35893586
35903587 if (!dev_priv)
35913588 return;
35923589
35933590 I915_WRITE(VLV_MASTER_IER, 0);
35943591
3595− for_each_pipe(dev_priv, pipe)
3596− I915_WRITE(PIPESTAT(pipe), 0xffff);
3592+ gen5_gt_irq_reset(dev);
35973593
35983594 I915_WRITE(HWSTAM, 0xffffffff);
3599− I915_WRITE(PORT_HOTPLUG_EN, 0);
3600− I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
36013595
36023596 /* Interrupt setup is already guaranteed to be single-threaded, this is
36033597 * just to make the assert_spin_locked check happy. */
@@ -3606,12 +3600,9 @@ static void valleyview_irq_uninstall(struct drm_device *dev) · 2 unmodified lines
36063600 valleyview_display_irqs_uninstall(dev_priv);
36073601 spin_unlock_irq(&dev_priv->irq_lock);
36083602
3609− dev_priv->irq_mask = 0;
3603+ vlv_display_irq_reset(dev_priv);
36103604
3611− I915_WRITE(VLV_IIR, 0xffffffff);
3612− I915_WRITE(VLV_IMR, 0xffffffff);
3613− I915_WRITE(VLV_IER, 0x0);
3614− POSTING_READ(VLV_IER);
3605+ dev_priv->irq_mask = 0;
36153606 }
36163607
36173608 static void cherryview_irq_uninstall(struct drm_device *dev)
@@ -3625,33 +3616,9 @@ static void cherryview_irq_uninstall(struct drm_device *dev) · 7 unmodified lines
36253616 I915_WRITE(GEN8_MASTER_IRQ, 0);
36263617 POSTING_READ(GEN8_MASTER_IRQ);
36273618
3628−#define GEN8_IRQ_FINI_NDX(type, which) \
3629−do { \
3630− I915_WRITE(GEN8_##type##_IMR(which), 0xffffffff); \
3631− I915_WRITE(GEN8_##type##_IER(which), 0); \
3632− I915_WRITE(GEN8_##type##_IIR(which), 0xffffffff); \
3633− POSTING_READ(GEN8_##type##_IIR(which)); \
3634− I915_WRITE(GEN8_##type##_IIR(which), 0xffffffff); \
3635−} while (0)
3636−
3637−#define GEN8_IRQ_FINI(type) \
3638−do { \
3639− I915_WRITE(GEN8_##type##_IMR, 0xffffffff); \
3640− I915_WRITE(GEN8_##type##_IER, 0); \
3641− I915_WRITE(GEN8_##type##_IIR, 0xffffffff); \
3642− POSTING_READ(GEN8_##type##_IIR); \
3643− I915_WRITE(GEN8_##type##_IIR, 0xffffffff); \
3644−} while (0)
3645−
3646− GEN8_IRQ_FINI_NDX(GT, 0);
3647− GEN8_IRQ_FINI_NDX(GT, 1);
3648− GEN8_IRQ_FINI_NDX(GT, 2);
3649− GEN8_IRQ_FINI_NDX(GT, 3);
3650−
3651− GEN8_IRQ_FINI(PCU);
3619+ gen8_gt_irq_reset(dev_priv);
36523620
3653−#undef GEN8_IRQ_FINI
3654−#undef GEN8_IRQ_FINI_NDX
3621+ GEN5_IRQ_RESET(GEN8_PCU_);
36553622
36563623 I915_WRITE(PORT_HOTPLUG_EN, 0);
36573624 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
@@ -3659,10 +3626,7 @@ do { \ · 1 unmodified line
36593626 for_each_pipe(dev_priv, pipe)
36603627 I915_WRITE(PIPESTAT(pipe), 0xffff);
36613628
3662− I915_WRITE(VLV_IMR, 0xffffffff);
3663− I915_WRITE(VLV_IER, 0x0);
3664− I915_WRITE(VLV_IIR, 0xffffffff);
3665− POSTING_READ(VLV_IIR);
3629+ GEN5_IRQ_RESET(VLV_);
36663630 }
36673631
36683632 static void ironlake_irq_uninstall(struct drm_device *dev)
drivers/gpu/drm/i915/i915_reg.h+208−95
@@ -4102,6 +4102,41 @@ enum punit_power_well { · 4101 unmodified lines
41024102 #define I965_CURSOR_MAX_WM 32
41034103 #define I965_CURSOR_DFT_WM 8
41044104
4105+/* Watermark register definitions for SKL */
4106+#define CUR_WM_A_0 0x70140
4107+#define CUR_WM_B_0 0x71140
4108+#define PLANE_WM_1_A_0 0x70240
4109+#define PLANE_WM_1_B_0 0x71240
4110+#define PLANE_WM_2_A_0 0x70340
4111+#define PLANE_WM_2_B_0 0x71340
4112+#define PLANE_WM_TRANS_1_A_0 0x70268
4113+#define PLANE_WM_TRANS_1_B_0 0x71268
4114+#define PLANE_WM_TRANS_2_A_0 0x70368
4115+#define PLANE_WM_TRANS_2_B_0 0x71368
4116+#define CUR_WM_TRANS_A_0 0x70168
4117+#define CUR_WM_TRANS_B_0 0x71168
4118+#define PLANE_WM_EN (1 << 31)
4119+#define PLANE_WM_LINES_SHIFT 14
4120+#define PLANE_WM_LINES_MASK 0x1f
4121+#define PLANE_WM_BLOCKS_MASK 0x3ff
4122+
4123+#define CUR_WM_0(pipe) _PIPE(pipe, CUR_WM_A_0, CUR_WM_B_0)
4124+#define CUR_WM(pipe, level) (CUR_WM_0(pipe) + ((4) * (level)))
4125+#define CUR_WM_TRANS(pipe) _PIPE(pipe, CUR_WM_TRANS_A_0, CUR_WM_TRANS_B_0)
4126+
4127+#define _PLANE_WM_1(pipe) _PIPE(pipe, PLANE_WM_1_A_0, PLANE_WM_1_B_0)
4128+#define _PLANE_WM_2(pipe) _PIPE(pipe, PLANE_WM_2_A_0, PLANE_WM_2_B_0)
4129+#define _PLANE_WM_BASE(pipe, plane) \
4130+ _PLANE(plane, _PLANE_WM_1(pipe), _PLANE_WM_2(pipe))
4131+#define PLANE_WM(pipe, plane, level) \
4132+ (_PLANE_WM_BASE(pipe, plane) + ((4) * (level)))
4133+#define _PLANE_WM_TRANS_1(pipe) \
4134+ _PIPE(pipe, PLANE_WM_TRANS_1_A_0, PLANE_WM_TRANS_1_B_0)
4135+#define _PLANE_WM_TRANS_2(pipe) \
4136+ _PIPE(pipe, PLANE_WM_TRANS_2_A_0, PLANE_WM_TRANS_2_B_0)
4137+#define PLANE_WM_TRANS(pipe, plane) \
4138+ _PLANE(plane, _PLANE_WM_TRANS_1(pipe), _PLANE_WM_TRANS_2(pipe))
4139+
41054140 /* define the Watermark register on Ironlake */
41064141 #define WM0_PIPEA_ILK 0x45100
41074142 #define WM0_PIPE_PLANE_MASK (0xffff<<16)
@@ -4272,9 +4307,11 @@ enum punit_power_well { · 164 unmodified lines
42724307 #define DISPPLANE_NO_LINE_DOUBLE 0
42734308 #define DISPPLANE_STEREO_POLARITY_FIRST 0
42744309 #define DISPPLANE_STEREO_POLARITY_SECOND (1<<18)
4275−#define DISPPLANE_ROTATE_180 (1<<15)
4310+#define DISPPLANE_ALPHA_PREMULTIPLY (1<<16) /* CHV pipe B */
4311+#define DISPPLANE_ROTATE_180 (1<<15)
42764312 #define DISPPLANE_TRICKLE_FEED_DISABLE (1<<14) /* Ironlake */
42774313 #define DISPPLANE_TILED (1<<10)
4314+#define DISPPLANE_MIRROR (1<<8) /* CHV pipe B */
42784315 #define _DSPAADDR 0x70184
42794316 #define _DSPASTRIDE 0x70188
42804317 #define _DSPAPOS 0x7018C /* reserved */
@@ -4295,6 +4332,24 @@ enum punit_power_well { · 14 unmodified lines
42954332 #define DSPOFFSET(plane) _PIPE2(plane, _DSPAOFFSET)
42964333 #define DSPSURFLIVE(plane) _PIPE2(plane, _DSPASURFLIVE)
42974334
4335+/* CHV pipe B blender and primary plane */
4336+#define _CHV_BLEND_A 0x60a00
4337+#define CHV_BLEND_LEGACY (0<<30)
4338+#define CHV_BLEND_ANDROID (1<<30)
4339+#define CHV_BLEND_MPO (2<<30)
4340+#define CHV_BLEND_MASK (3<<30)
4341+#define _CHV_CANVAS_A 0x60a04
4342+#define _PRIMPOS_A 0x60a08
4343+#define _PRIMSIZE_A 0x60a0c
4344+#define _PRIMCNSTALPHA_A 0x60a10
4345+#define PRIM_CONST_ALPHA_ENABLE (1<<31)
4346+
4347+#define CHV_BLEND(pipe) _TRANSCODER2(pipe, _CHV_BLEND_A)
4348+#define CHV_CANVAS(pipe) _TRANSCODER2(pipe, _CHV_CANVAS_A)
4349+#define PRIMPOS(plane) _TRANSCODER2(plane, _PRIMPOS_A)
4350+#define PRIMSIZE(plane) _TRANSCODER2(plane, _PRIMSIZE_A)
4351+#define PRIMCNSTALPHA(plane) _TRANSCODER2(plane, _PRIMCNSTALPHA_A)
4352+
42984353 /* Display/Sprite base address macros */
42994354 #define DISP_BASEADDR_MASK (0xfffff000)
43004355 #define I915_LO_DISPBASE(val) (val & ~DISP_BASEADDR_MASK)
@@ -4496,6 +4551,7 @@ enum punit_power_well { · 195 unmodified lines
44964551 #define SP_FORMAT_RGBA1010102 (9<<26)
44974552 #define SP_FORMAT_RGBX8888 (0xe<<26)
44984553 #define SP_FORMAT_RGBA8888 (0xf<<26)
4554+#define SP_ALPHA_PREMULTIPLY (1<<23) /* CHV pipe B */
44994555 #define SP_SOURCE_KEY (1<<22)
45004556 #define SP_YUV_BYTE_ORDER_MASK (3<<16)
45014557 #define SP_YUV_ORDER_YUYV (0<<16)
@@ -4504,6 +4560,7 @@ enum punit_power_well { · 2 unmodified lines
45044560 #define SP_YUV_ORDER_VYUY (3<<16)
45054561 #define SP_ROTATE_180 (1<<15)
45064562 #define SP_TILED (1<<10)
4563+#define SP_MIRROR (1<<8) /* CHV pipe B */
45074564 #define _SPALINOFF (VLV_DISPLAY_BASE + 0x72184)
45084565 #define _SPASTRIDE (VLV_DISPLAY_BASE + 0x72188)
45094566 #define _SPAPOS (VLV_DISPLAY_BASE + 0x7218c)
@@ -4514,6 +4571,7 @@ enum punit_power_well { · 4 unmodified lines
45144571 #define _SPAKEYMAXVAL (VLV_DISPLAY_BASE + 0x721a0)
45154572 #define _SPATILEOFF (VLV_DISPLAY_BASE + 0x721a4)
45164573 #define _SPACONSTALPHA (VLV_DISPLAY_BASE + 0x721a8)
4574+#define SP_CONST_ALPHA_ENABLE (1<<31)
45174575 #define _SPAGAMC (VLV_DISPLAY_BASE + 0x721f4)
45184576
45194577 #define _SPBCNTR (VLV_DISPLAY_BASE + 0x72280)
@@ -4542,6 +4600,39 @@ enum punit_power_well { · 22 unmodified lines
45424600 #define SPCONSTALPHA(pipe, plane) _PIPE(pipe * 2 + plane, _SPACONSTALPHA, _SPBCONSTALPHA)
45434601 #define SPGAMC(pipe, plane) _PIPE(pipe * 2 + plane, _SPAGAMC, _SPBGAMC)
45444602
4603+/*
4604+ * CHV pipe B sprite CSC
4605+ *
4606+ * |cr| |c0 c1 c2| |cr + cr_ioff| |cr_ooff|
4607+ * |yg| = |c3 c4 c5| x |yg + yg_ioff| + |yg_ooff|
4608+ * |cb| |c6 c7 c8| |cb + cr_ioff| |cb_ooff|
4609+ */
4610+#define SPCSCYGOFF(sprite) (VLV_DISPLAY_BASE + 0x6d900 + (sprite) * 0x1000)
4611+#define SPCSCCBOFF(sprite) (VLV_DISPLAY_BASE + 0x6d904 + (sprite) * 0x1000)
4612+#define SPCSCCROFF(sprite) (VLV_DISPLAY_BASE + 0x6d908 + (sprite) * 0x1000)
4613+#define SPCSC_OOFF(x) (((x) & 0x7ff) << 16) /* s11 */
4614+#define SPCSC_IOFF(x) (((x) & 0x7ff) << 0) /* s11 */
4615+
4616+#define SPCSCC01(sprite) (VLV_DISPLAY_BASE + 0x6d90c + (sprite) * 0x1000)
4617+#define SPCSCC23(sprite) (VLV_DISPLAY_BASE + 0x6d910 + (sprite) * 0x1000)
4618+#define SPCSCC45(sprite) (VLV_DISPLAY_BASE + 0x6d914 + (sprite) * 0x1000)
4619+#define SPCSCC67(sprite) (VLV_DISPLAY_BASE + 0x6d918 + (sprite) * 0x1000)
4620+#define SPCSCC8(sprite) (VLV_DISPLAY_BASE + 0x6d91c + (sprite) * 0x1000)
4621+#define SPCSC_C1(x) (((x) & 0x7fff) << 16) /* s3.12 */
4622+#define SPCSC_C0(x) (((x) & 0x7fff) << 0) /* s3.12 */
4623+
4624+#define SPCSCYGICLAMP(sprite) (VLV_DISPLAY_BASE + 0x6d920 + (sprite) * 0x1000)
4625+#define SPCSCCBICLAMP(sprite) (VLV_DISPLAY_BASE + 0x6d924 + (sprite) * 0x1000)
4626+#define SPCSCCRICLAMP(sprite) (VLV_DISPLAY_BASE + 0x6d928 + (sprite) * 0x1000)
4627+#define SPCSC_IMAX(x) (((x) & 0x7ff) << 16) /* s11 */
4628+#define SPCSC_IMIN(x) (((x) & 0x7ff) << 0) /* s11 */
4629+
4630+#define SPCSCYGOCLAMP(sprite) (VLV_DISPLAY_BASE + 0x6d92c + (sprite) * 0x1000)
4631+#define SPCSCCBOCLAMP(sprite) (VLV_DISPLAY_BASE + 0x6d930 + (sprite) * 0x1000)
4632+#define SPCSCCROCLAMP(sprite) (VLV_DISPLAY_BASE + 0x6d934 + (sprite) * 0x1000)
4633+#define SPCSC_OMAX(x) ((x) << 16) /* u10 */
4634+#define SPCSC_OMIN(x) ((x) << 0) /* u10 */
4635+
45454636 /* Skylake plane registers */
45464637
45474638 #define _PLANE_CTL_1_A 0x70180
@@ -4605,6 +4696,8 @@ enum punit_power_well { · 57 unmodified lines
46054696 #define _PLANE_KEYMSK_2_A 0x70298
46064697 #define _PLANE_KEYMAX_1_A 0x701a0
46074698 #define _PLANE_KEYMAX_2_A 0x702a0
4699+#define _PLANE_BUF_CFG_1_A 0x7027c
4700+#define _PLANE_BUF_CFG_2_A 0x7037c
46084701
46094702 #define _PLANE_CTL_1_B 0x71180
46104703 #define _PLANE_CTL_2_B 0x71280
@@ -4682,6 +4775,20 @@ enum punit_power_well { · 71 unmodified lines
46824775 #define PLANE_KEYMAX(pipe, plane) \
46834776 _PLANE(plane, _PLANE_KEYMAX_1(pipe), _PLANE_KEYMAX_2(pipe))
46844777
4778+#define _PLANE_BUF_CFG_1_B 0x7127c
4779+#define _PLANE_BUF_CFG_2_B 0x7137c
4780+#define _PLANE_BUF_CFG_1(pipe) \
4781+ _PIPE(pipe, _PLANE_BUF_CFG_1_A, _PLANE_BUF_CFG_1_B)
4782+#define _PLANE_BUF_CFG_2(pipe) \
4783+ _PIPE(pipe, _PLANE_BUF_CFG_2_A, _PLANE_BUF_CFG_2_B)
4784+#define PLANE_BUF_CFG(pipe, plane) \
4785+ _PLANE(plane, _PLANE_BUF_CFG_1(pipe), _PLANE_BUF_CFG_2(pipe))
4786+
4787+/* SKL new cursor registers */
4788+#define _CUR_BUF_CFG_A 0x7017c
4789+#define _CUR_BUF_CFG_B 0x7117c
4790+#define CUR_BUF_CFG(pipe) _PIPE(pipe, _CUR_BUF_CFG_A, _CUR_BUF_CFG_B)
4791+
46854792 /* VBIOS regs */
46864793 #define VGACNTRL 0x71400
46874794 # define VGA_DISP_DISABLE (1 << 31)
@@ -5726,6 +5833,12 @@ enum punit_power_well { · 1038 unmodified lines
57265833 #define VLV_GTLC_PW_MEDIA_STATUS_MASK (1 << 5)
57275834 #define VLV_GTLC_PW_RENDER_STATUS_MASK (1 << 7)
57285835 #define FORCEWAKE_MT 0xa188 /* multi-threaded */
5836+#define FORCEWAKE_MEDIA_GEN9 0xa270
5837+#define FORCEWAKE_RENDER_GEN9 0xa278
5838+#define FORCEWAKE_BLITTER_GEN9 0xa188
5839+#define FORCEWAKE_ACK_MEDIA_GEN9 0x0D88
5840+#define FORCEWAKE_ACK_RENDER_GEN9 0x0D84
5841+#define FORCEWAKE_ACK_BLITTER_GEN9 0x130044
57295842 #define FORCEWAKE_KERNEL 0x1
57305843 #define FORCEWAKE_USER 0x2
57315844 #define FORCEWAKE_MT_ACK 0x130040
@@ -5901,6 +6014,13 @@ enum punit_power_well { · 169 unmodified lines
59016014 #define GEN6_PCODE_FREQ_IA_RATIO_SHIFT 8
59026015 #define GEN6_PCODE_FREQ_RING_RATIO_SHIFT 16
59036016
6017+#define GEN9_PCODE_DATA1 0x13812C
6018+#define GEN9_PCODE_READ_MEM_LATENCY 0x6
6019+#define GEN9_MEM_LATENCY_LEVEL_MASK 0xFF
6020+#define GEN9_MEM_LATENCY_LEVEL_1_5_SHIFT 8
6021+#define GEN9_MEM_LATENCY_LEVEL_2_6_SHIFT 16
6022+#define GEN9_MEM_LATENCY_LEVEL_3_7_SHIFT 24
6023+
59046024 #define GEN6_GT_CORE_STATUS 0x138060
59056025 #define GEN6_CORE_CPD_STATE_MASK (7<<4)
59066026 #define GEN6_RCn_MASK 7
@@ -5955,57 +6075,58 @@ enum punit_power_well { · 48 unmodified lines
59556075 #define GEN8_CENTROID_PIXEL_OPT_DIS (1<<8)
59566076 #define GEN8_SAMPLER_POWER_BYPASS_DIS (1<<1)
59576077
6078+/* Audio */
59586079 #define G4X_AUD_VID_DID (dev_priv->info.display_mmio_offset + 0x62020)
5959−#define INTEL_AUDIO_DEVCL 0x808629FB
5960−#define INTEL_AUDIO_DEVBLC 0x80862801
5961−#define INTEL_AUDIO_DEVCTG 0x80862802
6080+#define INTEL_AUDIO_DEVCL 0x808629FB
6081+#define INTEL_AUDIO_DEVBLC 0x80862801
6082+#define INTEL_AUDIO_DEVCTG 0x80862802
59626083
59636084 #define G4X_AUD_CNTL_ST 0x620B4
5964−#define G4X_ELDV_DEVCL_DEVBLC (1 << 13)
5965−#define G4X_ELDV_DEVCTG (1 << 14)
5966−#define G4X_ELD_ADDR (0xf << 5)
5967−#define G4X_ELD_ACK (1 << 4)
6085+#define G4X_ELDV_DEVCL_DEVBLC (1 << 13)
6086+#define G4X_ELDV_DEVCTG (1 << 14)
6087+#define G4X_ELD_ADDR_MASK (0xf << 5)
6088+#define G4X_ELD_ACK (1 << 4)
59686089 #define G4X_HDMIW_HDMIEDID 0x6210C
59696090
5970−#define IBX_HDMIW_HDMIEDID_A 0xE2050
5971−#define IBX_HDMIW_HDMIEDID_B 0xE2150
6091+#define _IBX_HDMIW_HDMIEDID_A 0xE2050
6092+#define _IBX_HDMIW_HDMIEDID_B 0xE2150
59726093 #define IBX_HDMIW_HDMIEDID(pipe) _PIPE(pipe, \
5973− IBX_HDMIW_HDMIEDID_A, \
5974− IBX_HDMIW_HDMIEDID_B)
5975−#define IBX_AUD_CNTL_ST_A 0xE20B4
5976−#define IBX_AUD_CNTL_ST_B 0xE21B4
6094+ _IBX_HDMIW_HDMIEDID_A, \
6095+ _IBX_HDMIW_HDMIEDID_B)
6096+#define _IBX_AUD_CNTL_ST_A 0xE20B4
6097+#define _IBX_AUD_CNTL_ST_B 0xE21B4
59776098 #define IBX_AUD_CNTL_ST(pipe) _PIPE(pipe, \
5978− IBX_AUD_CNTL_ST_A, \
5979− IBX_AUD_CNTL_ST_B)
5980−#define IBX_ELD_BUFFER_SIZE (0x1f << 10)
5981−#define IBX_ELD_ADDRESS (0x1f << 5)
5982−#define IBX_ELD_ACK (1 << 4)
6099+ _IBX_AUD_CNTL_ST_A, \
6100+ _IBX_AUD_CNTL_ST_B)
6101+#define IBX_ELD_BUFFER_SIZE_MASK (0x1f << 10)
6102+#define IBX_ELD_ADDRESS_MASK (0x1f << 5)
6103+#define IBX_ELD_ACK (1 << 4)
59836104 #define IBX_AUD_CNTL_ST2 0xE20C0
5984−#define IBX_ELD_VALIDB (1 << 0)
5985−#define IBX_CP_READYB (1 << 1)
6105+#define IBX_CP_READY(port) ((1 << 1) << (((port) - 1) * 4))
6106+#define IBX_ELD_VALID(port) ((1 << 0) << (((port) - 1) * 4))
59866107
5987−#define CPT_HDMIW_HDMIEDID_A 0xE5050
5988−#define CPT_HDMIW_HDMIEDID_B 0xE5150
6108+#define _CPT_HDMIW_HDMIEDID_A 0xE5050
6109+#define _CPT_HDMIW_HDMIEDID_B 0xE5150
59896110 #define CPT_HDMIW_HDMIEDID(pipe) _PIPE(pipe, \
5990− CPT_HDMIW_HDMIEDID_A, \
5991− CPT_HDMIW_HDMIEDID_B)
5992−#define CPT_AUD_CNTL_ST_A 0xE50B4
5993−#define CPT_AUD_CNTL_ST_B 0xE51B4
6111+ _CPT_HDMIW_HDMIEDID_A, \
6112+ _CPT_HDMIW_HDMIEDID_B)
6113+#define _CPT_AUD_CNTL_ST_A 0xE50B4
6114+#define _CPT_AUD_CNTL_ST_B 0xE51B4
59946115 #define CPT_AUD_CNTL_ST(pipe) _PIPE(pipe, \
5995− CPT_AUD_CNTL_ST_A, \
5996− CPT_AUD_CNTL_ST_B)
6116+ _CPT_AUD_CNTL_ST_A, \
6117+ _CPT_AUD_CNTL_ST_B)
59976118 #define CPT_AUD_CNTRL_ST2 0xE50C0
59986119
5999−#define VLV_HDMIW_HDMIEDID_A (VLV_DISPLAY_BASE + 0x62050)
6000−#define VLV_HDMIW_HDMIEDID_B (VLV_DISPLAY_BASE + 0x62150)
6120+#define _VLV_HDMIW_HDMIEDID_A (VLV_DISPLAY_BASE + 0x62050)
6121+#define _VLV_HDMIW_HDMIEDID_B (VLV_DISPLAY_BASE + 0x62150)
60016122 #define VLV_HDMIW_HDMIEDID(pipe) _PIPE(pipe, \
6002− VLV_HDMIW_HDMIEDID_A, \
6003− VLV_HDMIW_HDMIEDID_B)
6004−#define VLV_AUD_CNTL_ST_A (VLV_DISPLAY_BASE + 0x620B4)
6005−#define VLV_AUD_CNTL_ST_B (VLV_DISPLAY_BASE + 0x621B4)
6123+ _VLV_HDMIW_HDMIEDID_A, \
6124+ _VLV_HDMIW_HDMIEDID_B)
6125+#define _VLV_AUD_CNTL_ST_A (VLV_DISPLAY_BASE + 0x620B4)
6126+#define _VLV_AUD_CNTL_ST_B (VLV_DISPLAY_BASE + 0x621B4)
60066127 #define VLV_AUD_CNTL_ST(pipe) _PIPE(pipe, \
6007− VLV_AUD_CNTL_ST_A, \
6008− VLV_AUD_CNTL_ST_B)
6128+ _VLV_AUD_CNTL_ST_A, \
6129+ _VLV_AUD_CNTL_ST_B)
60096130 #define VLV_AUD_CNTL_ST2 (VLV_DISPLAY_BASE + 0x620C0)
60106131
60116132 /* These are the 4 32-bit write offset registers for each stream
@@ -6014,28 +6135,28 @@ enum punit_power_well { · 2 unmodified lines
60146135 */
60156136 #define GEN7_SO_WRITE_OFFSET(n) (0x5280 + (n) * 4)
60166137
6017−#define IBX_AUD_CONFIG_A 0xe2000
6018−#define IBX_AUD_CONFIG_B 0xe2100
6138+#define _IBX_AUD_CONFIG_A 0xe2000
6139+#define _IBX_AUD_CONFIG_B 0xe2100
60196140 #define IBX_AUD_CFG(pipe) _PIPE(pipe, \
6020− IBX_AUD_CONFIG_A, \
6021− IBX_AUD_CONFIG_B)
6022−#define CPT_AUD_CONFIG_A 0xe5000
6023−#define CPT_AUD_CONFIG_B 0xe5100
6141+ _IBX_AUD_CONFIG_A, \
6142+ _IBX_AUD_CONFIG_B)
6143+#define _CPT_AUD_CONFIG_A 0xe5000
6144+#define _CPT_AUD_CONFIG_B 0xe5100
60246145 #define CPT_AUD_CFG(pipe) _PIPE(pipe, \
6025− CPT_AUD_CONFIG_A, \
6026− CPT_AUD_CONFIG_B)
6027−#define VLV_AUD_CONFIG_A (VLV_DISPLAY_BASE + 0x62000)
6028−#define VLV_AUD_CONFIG_B (VLV_DISPLAY_BASE + 0x62100)
6146+ _CPT_AUD_CONFIG_A, \
6147+ _CPT_AUD_CONFIG_B)
6148+#define _VLV_AUD_CONFIG_A (VLV_DISPLAY_BASE + 0x62000)
6149+#define _VLV_AUD_CONFIG_B (VLV_DISPLAY_BASE + 0x62100)
60296150 #define VLV_AUD_CFG(pipe) _PIPE(pipe, \
6030− VLV_AUD_CONFIG_A, \
6031− VLV_AUD_CONFIG_B)
6151+ _VLV_AUD_CONFIG_A, \
6152+ _VLV_AUD_CONFIG_B)
60326153
60336154 #define AUD_CONFIG_N_VALUE_INDEX (1 << 29)
60346155 #define AUD_CONFIG_N_PROG_ENABLE (1 << 28)
60356156 #define AUD_CONFIG_UPPER_N_SHIFT 20
6036−#define AUD_CONFIG_UPPER_N_VALUE (0xff << 20)
6157+#define AUD_CONFIG_UPPER_N_MASK (0xff << 20)
60376158 #define AUD_CONFIG_LOWER_N_SHIFT 4
6038−#define AUD_CONFIG_LOWER_N_VALUE (0xfff << 4)
6159+#define AUD_CONFIG_LOWER_N_MASK (0xfff << 4)
60396160 #define AUD_CONFIG_PIXEL_CLOCK_HDMI_SHIFT 16
60406161 #define AUD_CONFIG_PIXEL_CLOCK_HDMI_MASK (0xf << 16)
60416162 #define AUD_CONFIG_PIXEL_CLOCK_HDMI_25175 (0 << 16)
@@ -6051,52 +6172,44 @@ enum punit_power_well { · 9 unmodified lines
60516172 #define AUD_CONFIG_DISABLE_NCTS (1 << 3)
60526173
60536174 /* HSW Audio */
6054−#define HSW_AUD_CONFIG_A 0x65000 /* Audio Configuration Transcoder A */
6055−#define HSW_AUD_CONFIG_B 0x65100 /* Audio Configuration Transcoder B */
6056−#define HSW_AUD_CFG(pipe) _PIPE(pipe, \
6057− HSW_AUD_CONFIG_A, \
6058− HSW_AUD_CONFIG_B)
6059−
6060−#define HSW_AUD_MISC_CTRL_A 0x65010 /* Audio Misc Control Convert 1 */
6061−#define HSW_AUD_MISC_CTRL_B 0x65110 /* Audio Misc Control Convert 2 */
6062−#define HSW_AUD_MISC_CTRL(pipe) _PIPE(pipe, \
6063− HSW_AUD_MISC_CTRL_A, \
6064− HSW_AUD_MISC_CTRL_B)
6065−
6066−#define HSW_AUD_DIP_ELD_CTRL_ST_A 0x650b4 /* Audio DIP and ELD Control State Transcoder A */
6067−#define HSW_AUD_DIP_ELD_CTRL_ST_B 0x651b4 /* Audio DIP and ELD Control State Transcoder B */
6068−#define HSW_AUD_DIP_ELD_CTRL(pipe) _PIPE(pipe, \
6069− HSW_AUD_DIP_ELD_CTRL_ST_A, \
6070− HSW_AUD_DIP_ELD_CTRL_ST_B)
6175+#define _HSW_AUD_CONFIG_A 0x65000
6176+#define _HSW_AUD_CONFIG_B 0x65100
6177+#define HSW_AUD_CFG(pipe) _PIPE(pipe, \
6178+ _HSW_AUD_CONFIG_A, \
6179+ _HSW_AUD_CONFIG_B)
6180+
6181+#define _HSW_AUD_MISC_CTRL_A 0x65010
6182+#define _HSW_AUD_MISC_CTRL_B 0x65110
6183+#define HSW_AUD_MISC_CTRL(pipe) _PIPE(pipe, \
6184+ _HSW_AUD_MISC_CTRL_A, \
6185+ _HSW_AUD_MISC_CTRL_B)
6186+
6187+#define _HSW_AUD_DIP_ELD_CTRL_ST_A 0x650b4
6188+#define _HSW_AUD_DIP_ELD_CTRL_ST_B 0x651b4
6189+#define HSW_AUD_DIP_ELD_CTRL(pipe) _PIPE(pipe, \
6190+ _HSW_AUD_DIP_ELD_CTRL_ST_A, \
6191+ _HSW_AUD_DIP_ELD_CTRL_ST_B)
60716192
60726193 /* Audio Digital Converter */
6073−#define HSW_AUD_DIG_CNVT_1 0x65080 /* Audio Converter 1 */
6074−#define HSW_AUD_DIG_CNVT_2 0x65180 /* Audio Converter 1 */
6075−#define AUD_DIG_CNVT(pipe) _PIPE(pipe, \
6076− HSW_AUD_DIG_CNVT_1, \
6077− HSW_AUD_DIG_CNVT_2)
6078−#define DIP_PORT_SEL_MASK 0x3
6079−
6080−#define HSW_AUD_EDID_DATA_A 0x65050
6081−#define HSW_AUD_EDID_DATA_B 0x65150
6082−#define HSW_AUD_EDID_DATA(pipe) _PIPE(pipe, \
6083− HSW_AUD_EDID_DATA_A, \
6084− HSW_AUD_EDID_DATA_B)
6085−
6086−#define HSW_AUD_PIPE_CONV_CFG 0x6507c /* Audio pipe and converter configs */
6087−#define HSW_AUD_PIN_ELD_CP_VLD 0x650c0 /* Audio ELD and CP Ready Status */
6088−#define AUDIO_INACTIVE_C (1<<11)
6089−#define AUDIO_INACTIVE_B (1<<7)
6090−#define AUDIO_INACTIVE_A (1<<3)
6091−#define AUDIO_OUTPUT_ENABLE_A (1<<2)
6092−#define AUDIO_OUTPUT_ENABLE_B (1<<6)
6093−#define AUDIO_OUTPUT_ENABLE_C (1<<10)
6094−#define AUDIO_ELD_VALID_A (1<<0)
6095−#define AUDIO_ELD_VALID_B (1<<4)
6096−#define AUDIO_ELD_VALID_C (1<<8)
6097−#define AUDIO_CP_READY_A (1<<1)
6098−#define AUDIO_CP_READY_B (1<<5)
6099−#define AUDIO_CP_READY_C (1<<9)
6194+#define _HSW_AUD_DIG_CNVT_1 0x65080
6195+#define _HSW_AUD_DIG_CNVT_2 0x65180
6196+#define AUD_DIG_CNVT(pipe) _PIPE(pipe, \
6197+ _HSW_AUD_DIG_CNVT_1, \
6198+ _HSW_AUD_DIG_CNVT_2)
6199+#define DIP_PORT_SEL_MASK 0x3
6200+
6201+#define _HSW_AUD_EDID_DATA_A 0x65050
6202+#define _HSW_AUD_EDID_DATA_B 0x65150
6203+#define HSW_AUD_EDID_DATA(pipe) _PIPE(pipe, \
6204+ _HSW_AUD_EDID_DATA_A, \
6205+ _HSW_AUD_EDID_DATA_B)
6206+
6207+#define HSW_AUD_PIPE_CONV_CFG 0x6507c
6208+#define HSW_AUD_PIN_ELD_CP_VLD 0x650c0
6209+#define AUDIO_INACTIVE(trans) ((1 << 3) << ((trans) * 4))
6210+#define AUDIO_OUTPUT_ENABLE(trans) ((1 << 2) << ((trans) * 4))
6211+#define AUDIO_CP_READY(trans) ((1 << 1) << ((trans) * 4))
6212+#define AUDIO_ELD_VALID(trans) ((1 << 0) << ((trans) * 4))
61006213
61016214 /* HSW Power Wells */
61026215 #define HSW_PWR_WELL_BIOS 0x45400 /* CTL1 */
drivers/gpu/drm/i915/intel_audio.c+462−0
@@ -0,0 +1,462 @@
1+/*
2+ * Copyright © 2014 Intel Corporation
3+ *
4+ * Permission is hereby granted, free of charge, to any person obtaining a
5+ * copy of this software and associated documentation files (the "Software"),
6+ * to deal in the Software without restriction, including without limitation
7+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+ * and/or sell copies of the Software, and to permit persons to whom the
9+ * Software is furnished to do so, subject to the following conditions:
10+ *
11+ * The above copyright notice and this permission notice (including the next
12+ * paragraph) shall be included in all copies or substantial portions of the
13+ * Software.
14+ *
15+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21+ * DEALINGS IN THE SOFTWARE.
22+ */
23+
24+#include <linux/kernel.h>
25+
26+#include <drm/drmP.h>
27+#include <drm/drm_edid.h>
28+#include "intel_drv.h"
29+#include "i915_drv.h"
30+
31+/**
32+ * DOC: High Definition Audio over HDMI and Display Port
33+ *
34+ * The graphics and audio drivers together support High Definition Audio over
35+ * HDMI and Display Port. The audio programming sequences are divided into audio
36+ * codec and controller enable and disable sequences. The graphics driver
37+ * handles the audio codec sequences, while the audio driver handles the audio
38+ * controller sequences.
39+ *
40+ * The disable sequences must be performed before disabling the transcoder or
41+ * port. The enable sequences may only be performed after enabling the
42+ * transcoder and port, and after completed link training.
43+ *
44+ * The codec and controller sequences could be done either parallel or serial,
45+ * but generally the ELDV/PD change in the codec sequence indicates to the audio
46+ * driver that the controller sequence should start. Indeed, most of the
47+ * co-operation between the graphics and audio drivers is handled via audio
48+ * related registers. (The notable exception is the power management, not
49+ * covered here.)
50+ */
51+
52+static const struct {
53+ int clock;
54+ u32 config;
55+} hdmi_audio_clock[] = {
56+ { DIV_ROUND_UP(25200 * 1000, 1001), AUD_CONFIG_PIXEL_CLOCK_HDMI_25175 },
57+ { 25200, AUD_CONFIG_PIXEL_CLOCK_HDMI_25200 }, /* default per bspec */
58+ { 27000, AUD_CONFIG_PIXEL_CLOCK_HDMI_27000 },
59+ { 27000 * 1001 / 1000, AUD_CONFIG_PIXEL_CLOCK_HDMI_27027 },
60+ { 54000, AUD_CONFIG_PIXEL_CLOCK_HDMI_54000 },
61+ { 54000 * 1001 / 1000, AUD_CONFIG_PIXEL_CLOCK_HDMI_54054 },
62+ { DIV_ROUND_UP(74250 * 1000, 1001), AUD_CONFIG_PIXEL_CLOCK_HDMI_74176 },
63+ { 74250, AUD_CONFIG_PIXEL_CLOCK_HDMI_74250 },
64+ { DIV_ROUND_UP(148500 * 1000, 1001), AUD_CONFIG_PIXEL_CLOCK_HDMI_148352 },
65+ { 148500, AUD_CONFIG_PIXEL_CLOCK_HDMI_148500 },
66+};
67+
68+/* get AUD_CONFIG_PIXEL_CLOCK_HDMI_* value for mode */
69+static u32 audio_config_hdmi_pixel_clock(struct drm_display_mode *mode)
70+{
71+ int i;
72+
73+ for (i = 0; i < ARRAY_SIZE(hdmi_audio_clock); i++) {
74+ if (mode->clock == hdmi_audio_clock[i].clock)
75+ break;
76+ }
77+
78+ if (i == ARRAY_SIZE(hdmi_audio_clock)) {
79+ DRM_DEBUG_KMS("HDMI audio pixel clock setting for %d not found, falling back to defaults\n", mode->clock);
80+ i = 1;
81+ }
82+
83+ DRM_DEBUG_KMS("Configuring HDMI audio for pixel clock %d (0x%08x)\n",
84+ hdmi_audio_clock[i].clock,
85+ hdmi_audio_clock[i].config);
86+
87+ return hdmi_audio_clock[i].config;
88+}
89+
90+static bool intel_eld_uptodate(struct drm_connector *connector,
91+ int reg_eldv, uint32_t bits_eldv,
92+ int reg_elda, uint32_t bits_elda,
93+ int reg_edid)
94+{
95+ struct drm_i915_private *dev_priv = connector->dev->dev_private;
96+ uint8_t *eld = connector->eld;
97+ uint32_t tmp;
98+ int i;
99+
100+ tmp = I915_READ(reg_eldv);
101+ tmp &= bits_eldv;
102+
103+ if (!tmp)
104+ return false;
105+
106+ tmp = I915_READ(reg_elda);
107+ tmp &= ~bits_elda;
108+ I915_WRITE(reg_elda, tmp);
109+
110+ for (i = 0; i < eld[2]; i++)
111+ if (I915_READ(reg_edid) != *((uint32_t *)eld + i))
112+ return false;
113+
114+ return true;
115+}
116+
117+static void g4x_audio_codec_disable(struct intel_encoder *encoder)
118+{
119+ struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
120+ uint32_t eldv, tmp;
121+
122+ DRM_DEBUG_KMS("Disable audio codec\n");
123+
124+ tmp = I915_READ(G4X_AUD_VID_DID);
125+ if (tmp == INTEL_AUDIO_DEVBLC || tmp == INTEL_AUDIO_DEVCL)
126+ eldv = G4X_ELDV_DEVCL_DEVBLC;
127+ else
128+ eldv = G4X_ELDV_DEVCTG;
129+
130+ /* Invalidate ELD */
131+ tmp = I915_READ(G4X_AUD_CNTL_ST);
132+ tmp &= ~eldv;
133+ I915_WRITE(G4X_AUD_CNTL_ST, tmp);
134+}
135+
136+static void g4x_audio_codec_enable(struct drm_connector *connector,
137+ struct intel_encoder *encoder,
138+ struct drm_display_mode *mode)
139+{
140+ struct drm_i915_private *dev_priv = connector->dev->dev_private;
141+ uint8_t *eld = connector->eld;
142+ uint32_t eldv;
143+ uint32_t tmp;
144+ int len, i;
145+
146+ DRM_DEBUG_KMS("Enable audio codec, %u bytes ELD\n", eld[2]);
147+
148+ tmp = I915_READ(G4X_AUD_VID_DID);
149+ if (tmp == INTEL_AUDIO_DEVBLC || tmp == INTEL_AUDIO_DEVCL)
150+ eldv = G4X_ELDV_DEVCL_DEVBLC;
151+ else
152+ eldv = G4X_ELDV_DEVCTG;
153+
154+ if (intel_eld_uptodate(connector,
155+ G4X_AUD_CNTL_ST, eldv,
156+ G4X_AUD_CNTL_ST, G4X_ELD_ADDR_MASK,
157+ G4X_HDMIW_HDMIEDID))
158+ return;
159+
160+ tmp = I915_READ(G4X_AUD_CNTL_ST);
161+ tmp &= ~(eldv | G4X_ELD_ADDR_MASK);
162+ len = (tmp >> 9) & 0x1f; /* ELD buffer size */
163+ I915_WRITE(G4X_AUD_CNTL_ST, tmp);
164+
165+ len = min_t(int, eld[2], len);
166+ DRM_DEBUG_DRIVER("ELD size %d\n", len);
167+ for (i = 0; i < len; i++)
168+ I915_WRITE(G4X_HDMIW_HDMIEDID, *((uint32_t *)eld + i));
169+
170+ tmp = I915_READ(G4X_AUD_CNTL_ST);
171+ tmp |= eldv;
172+ I915_WRITE(G4X_AUD_CNTL_ST, tmp);
173+}
174+
175+static void hsw_audio_codec_disable(struct intel_encoder *encoder)
176+{
177+ struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
178+ struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
179+ enum pipe pipe = intel_crtc->pipe;
180+ uint32_t tmp;
181+
182+ DRM_DEBUG_KMS("Disable audio codec on pipe %c\n", pipe_name(pipe));
183+
184+ /* Disable timestamps */
185+ tmp = I915_READ(HSW_AUD_CFG(pipe));
186+ tmp &= ~AUD_CONFIG_N_VALUE_INDEX;
187+ tmp |= AUD_CONFIG_N_PROG_ENABLE;
188+ tmp &= ~AUD_CONFIG_UPPER_N_MASK;
189+ tmp &= ~AUD_CONFIG_LOWER_N_MASK;
190+ if (intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DISPLAYPORT))
191+ tmp |= AUD_CONFIG_N_VALUE_INDEX;
192+ I915_WRITE(HSW_AUD_CFG(pipe), tmp);
193+
194+ /* Invalidate ELD */
195+ tmp = I915_READ(HSW_AUD_PIN_ELD_CP_VLD);
196+ tmp &= ~AUDIO_ELD_VALID(pipe);
197+ I915_WRITE(HSW_AUD_PIN_ELD_CP_VLD, tmp);
198+}
199+
200+static void hsw_audio_codec_enable(struct drm_connector *connector,
201+ struct intel_encoder *encoder,
202+ struct drm_display_mode *mode)
203+{
204+ struct drm_i915_private *dev_priv = connector->dev->dev_private;
205+ struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
206+ enum pipe pipe = intel_crtc->pipe;
207+ const uint8_t *eld = connector->eld;
208+ uint32_t tmp;
209+ int len, i;
210+
211+ DRM_DEBUG_KMS("Enable audio codec on pipe %c, %u bytes ELD\n",
212+ pipe_name(pipe), eld[2]);
213+
214+ /* Enable audio presence detect, invalidate ELD */
215+ tmp = I915_READ(HSW_AUD_PIN_ELD_CP_VLD);
216+ tmp |= AUDIO_OUTPUT_ENABLE(pipe);
217+ tmp &= ~AUDIO_ELD_VALID(pipe);
218+ I915_WRITE(HSW_AUD_PIN_ELD_CP_VLD, tmp);
219+
220+ /*
221+ * FIXME: We're supposed to wait for vblank here, but we have vblanks
222+ * disabled during the mode set. The proper fix would be to push the
223+ * rest of the setup into a vblank work item, queued here, but the
224+ * infrastructure is not there yet.
225+ */
226+
227+ /* Reset ELD write address */
228+ tmp = I915_READ(HSW_AUD_DIP_ELD_CTRL(pipe));
229+ tmp &= ~IBX_ELD_ADDRESS_MASK;
230+ I915_WRITE(HSW_AUD_DIP_ELD_CTRL(pipe), tmp);
231+
232+ /* Up to 84 bytes of hw ELD buffer */
233+ len = min_t(int, eld[2], 21);
234+ for (i = 0; i < len; i++)
235+ I915_WRITE(HSW_AUD_EDID_DATA(pipe), *((uint32_t *)eld + i));
236+
237+ /* ELD valid */
238+ tmp = I915_READ(HSW_AUD_PIN_ELD_CP_VLD);
239+ tmp |= AUDIO_ELD_VALID(pipe);
240+ I915_WRITE(HSW_AUD_PIN_ELD_CP_VLD, tmp);
241+
242+ /* Enable timestamps */
243+ tmp = I915_READ(HSW_AUD_CFG(pipe));
244+ tmp &= ~AUD_CONFIG_N_VALUE_INDEX;
245+ tmp &= ~AUD_CONFIG_N_PROG_ENABLE;
246+ tmp &= ~AUD_CONFIG_PIXEL_CLOCK_HDMI_MASK;
247+ if (intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DISPLAYPORT))
248+ tmp |= AUD_CONFIG_N_VALUE_INDEX;
249+ else
250+ tmp |= audio_config_hdmi_pixel_clock(mode);
251+ I915_WRITE(HSW_AUD_CFG(pipe), tmp);
252+}
253+
254+static void ilk_audio_codec_disable(struct intel_encoder *encoder)
255+{
256+ struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
257+ struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
258+ struct intel_digital_port *intel_dig_port =
259+ enc_to_dig_port(&encoder->base);
260+ enum port port = intel_dig_port->port;
261+ enum pipe pipe = intel_crtc->pipe;
262+ uint32_t tmp, eldv;
263+ int aud_config;
264+ int aud_cntrl_st2;
265+
266+ DRM_DEBUG_KMS("Disable audio codec on port %c, pipe %c\n",
267+ port_name(port), pipe_name(pipe));
268+
269+ if (HAS_PCH_IBX(dev_priv->dev)) {
270+ aud_config = IBX_AUD_CFG(pipe);
271+ aud_cntrl_st2 = IBX_AUD_CNTL_ST2;
272+ } else if (IS_VALLEYVIEW(dev_priv)) {
273+ aud_config = VLV_AUD_CFG(pipe);
274+ aud_cntrl_st2 = VLV_AUD_CNTL_ST2;
275+ } else {
276+ aud_config = CPT_AUD_CFG(pipe);
277+ aud_cntrl_st2 = CPT_AUD_CNTRL_ST2;
278+ }
279+
280+ /* Disable timestamps */
281+ tmp = I915_READ(aud_config);
282+ tmp &= ~AUD_CONFIG_N_VALUE_INDEX;
283+ tmp |= AUD_CONFIG_N_PROG_ENABLE;
284+ tmp &= ~AUD_CONFIG_UPPER_N_MASK;
285+ tmp &= ~AUD_CONFIG_LOWER_N_MASK;
286+ if (intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DISPLAYPORT))
287+ tmp |= AUD_CONFIG_N_VALUE_INDEX;
288+ I915_WRITE(aud_config, tmp);
289+
290+ if (WARN_ON(!port)) {
291+ eldv = IBX_ELD_VALID(PORT_B) | IBX_ELD_VALID(PORT_C) |
292+ IBX_ELD_VALID(PORT_D);
293+ } else {
294+ eldv = IBX_ELD_VALID(port);
295+ }
296+
297+ /* Invalidate ELD */
298+ tmp = I915_READ(aud_cntrl_st2);
299+ tmp &= ~eldv;
300+ I915_WRITE(aud_cntrl_st2, tmp);
301+}
302+
303+static void ilk_audio_codec_enable(struct drm_connector *connector,
304+ struct intel_encoder *encoder,
305+ struct drm_display_mode *mode)
306+{
307+ struct drm_i915_private *dev_priv = connector->dev->dev_private;
308+ struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
309+ struct intel_digital_port *intel_dig_port =
310+ enc_to_dig_port(&encoder->base);
311+ enum port port = intel_dig_port->port;
312+ enum pipe pipe = intel_crtc->pipe;
313+ uint8_t *eld = connector->eld;
314+ uint32_t eldv;
315+ uint32_t tmp;
316+ int len, i;
317+ int hdmiw_hdmiedid;
318+ int aud_config;
319+ int aud_cntl_st;
320+ int aud_cntrl_st2;
321+
322+ DRM_DEBUG_KMS("Enable audio codec on port %c, pipe %c, %u bytes ELD\n",
323+ port_name(port), pipe_name(pipe), eld[2]);
324+
325+ /*
326+ * FIXME: We're supposed to wait for vblank here, but we have vblanks
327+ * disabled during the mode set. The proper fix would be to push the
328+ * rest of the setup into a vblank work item, queued here, but the
329+ * infrastructure is not there yet.
330+ */
331+
332+ if (HAS_PCH_IBX(connector->dev)) {
333+ hdmiw_hdmiedid = IBX_HDMIW_HDMIEDID(pipe);
334+ aud_config = IBX_AUD_CFG(pipe);
335+ aud_cntl_st = IBX_AUD_CNTL_ST(pipe);
336+ aud_cntrl_st2 = IBX_AUD_CNTL_ST2;
337+ } else if (IS_VALLEYVIEW(connector->dev)) {
338+ hdmiw_hdmiedid = VLV_HDMIW_HDMIEDID(pipe);
339+ aud_config = VLV_AUD_CFG(pipe);
340+ aud_cntl_st = VLV_AUD_CNTL_ST(pipe);
341+ aud_cntrl_st2 = VLV_AUD_CNTL_ST2;
342+ } else {
343+ hdmiw_hdmiedid = CPT_HDMIW_HDMIEDID(pipe);
344+ aud_config = CPT_AUD_CFG(pipe);
345+ aud_cntl_st = CPT_AUD_CNTL_ST(pipe);
346+ aud_cntrl_st2 = CPT_AUD_CNTRL_ST2;
347+ }
348+
349+ if (WARN_ON(!port)) {
350+ eldv = IBX_ELD_VALID(PORT_B) | IBX_ELD_VALID(PORT_C) |
351+ IBX_ELD_VALID(PORT_D);
352+ } else {
353+ eldv = IBX_ELD_VALID(port);
354+ }
355+
356+ /* Invalidate ELD */
357+ tmp = I915_READ(aud_cntrl_st2);
358+ tmp &= ~eldv;
359+ I915_WRITE(aud_cntrl_st2, tmp);
360+
361+ /* Reset ELD write address */
362+ tmp = I915_READ(aud_cntl_st);
363+ tmp &= ~IBX_ELD_ADDRESS_MASK;
364+ I915_WRITE(aud_cntl_st, tmp);
365+
366+ /* Up to 84 bytes of hw ELD buffer */
367+ len = min_t(int, eld[2], 21);
368+ for (i = 0; i < len; i++)
369+ I915_WRITE(hdmiw_hdmiedid, *((uint32_t *)eld + i));
370+
371+ /* ELD valid */
372+ tmp = I915_READ(aud_cntrl_st2);
373+ tmp |= eldv;
374+ I915_WRITE(aud_cntrl_st2, tmp);
375+
376+ /* Enable timestamps */
377+ tmp = I915_READ(aud_config);
378+ tmp &= ~AUD_CONFIG_N_VALUE_INDEX;
379+ tmp &= ~AUD_CONFIG_N_PROG_ENABLE;
380+ tmp &= ~AUD_CONFIG_PIXEL_CLOCK_HDMI_MASK;
381+ if (intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DISPLAYPORT))
382+ tmp |= AUD_CONFIG_N_VALUE_INDEX;
383+ else
384+ tmp |= audio_config_hdmi_pixel_clock(mode);
385+ I915_WRITE(aud_config, tmp);
386+}
387+
388+/**
389+ * intel_audio_codec_enable - Enable the audio codec for HD audio
390+ * @intel_encoder: encoder on which to enable audio
391+ *
392+ * The enable sequences may only be performed after enabling the transcoder and
393+ * port, and after completed link training.
394+ */
395+void intel_audio_codec_enable(struct intel_encoder *intel_encoder)
396+{
397+ struct drm_encoder *encoder = &intel_encoder->base;
398+ struct intel_crtc *crtc = to_intel_crtc(encoder->crtc);
399+ struct drm_display_mode *mode = &crtc->config.adjusted_mode;
400+ struct drm_connector *connector;
401+ struct drm_device *dev = encoder->dev;
402+ struct drm_i915_private *dev_priv = dev->dev_private;
403+
404+ connector = drm_select_eld(encoder, mode);
405+ if (!connector)
406+ return;
407+
408+ DRM_DEBUG_DRIVER("ELD on [CONNECTOR:%d:%s], [ENCODER:%d:%s]\n",
409+ connector->base.id,
410+ connector->name,
411+ connector->encoder->base.id,
412+ connector->encoder->name);
413+
414+ /* ELD Conn_Type */
415+ connector->eld[5] &= ~(3 << 2);
416+ if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT))
417+ connector->eld[5] |= (1 << 2);
418+
419+ connector->eld[6] = drm_av_sync_delay(connector, mode) / 2;
420+
421+ if (dev_priv->display.audio_codec_enable)
422+ dev_priv->display.audio_codec_enable(connector, intel_encoder, mode);
423+}
424+
425+/**
426+ * intel_audio_codec_disable - Disable the audio codec for HD audio
427+ * @encoder: encoder on which to disable audio
428+ *
429+ * The disable sequences must be performed before disabling the transcoder or
430+ * port.
431+ */
432+void intel_audio_codec_disable(struct intel_encoder *encoder)
433+{
434+ struct drm_device *dev = encoder->base.dev;
435+ struct drm_i915_private *dev_priv = dev->dev_private;
436+
437+ if (dev_priv->display.audio_codec_disable)
438+ dev_priv->display.audio_codec_disable(encoder);
439+}
440+
441+/**
442+ * intel_init_audio - Set up chip specific audio functions
443+ * @dev: drm device
444+ */
445+void intel_init_audio(struct drm_device *dev)
446+{
447+ struct drm_i915_private *dev_priv = dev->dev_private;
448+
449+ if (IS_G4X(dev)) {
450+ dev_priv->display.audio_codec_enable = g4x_audio_codec_enable;
451+ dev_priv->display.audio_codec_disable = g4x_audio_codec_disable;
452+ } else if (IS_VALLEYVIEW(dev)) {
453+ dev_priv->display.audio_codec_enable = ilk_audio_codec_enable;
454+ dev_priv->display.audio_codec_disable = ilk_audio_codec_disable;
455+ } else if (IS_HASWELL(dev) || INTEL_INFO(dev)->gen >= 8) {
456+ dev_priv->display.audio_codec_enable = hsw_audio_codec_enable;
457+ dev_priv->display.audio_codec_disable = hsw_audio_codec_disable;
458+ } else if (HAS_PCH_SPLIT(dev)) {
459+ dev_priv->display.audio_codec_enable = ilk_audio_codec_enable;
460+ dev_priv->display.audio_codec_disable = ilk_audio_codec_disable;
461+ }
462+}
drivers/gpu/drm/i915/intel_ddi.c+30−31
@@ -459,6 +459,27 @@ intel_ddi_get_crtc_encoder(struct drm_crtc *crtc) · 458 unmodified lines
459459 return ret;
460460 }
461461
462+static struct intel_encoder *
463+intel_ddi_get_crtc_new_encoder(struct intel_crtc *crtc)
464+{
465+ struct drm_device *dev = crtc->base.dev;
466+ struct intel_encoder *intel_encoder, *ret = NULL;
467+ int num_encoders = 0;
468+
469+ for_each_intel_encoder(dev, intel_encoder) {
470+ if (intel_encoder->new_crtc == crtc) {
471+ ret = intel_encoder;
472+ num_encoders++;
473+ }
474+ }
475+
476+ WARN(num_encoders != 1, "%d encoders on crtc for pipe %c\n", num_encoders,
477+ pipe_name(crtc->pipe));
478+
479+ BUG_ON(ret == NULL);
480+ return ret;
481+}
482+
462483 #define LC_FREQ 2700
463484 #define LC_FREQ_2K U64_C(LC_FREQ * 2000)
464485
@@ -792,7 +813,7 @@ hsw_ddi_pll_select(struct intel_crtc *intel_crtc, · 327 unmodified lines
792813 WRPLL_DIVIDER_REFERENCE(r2) | WRPLL_DIVIDER_FEEDBACK(n2) |
793814 WRPLL_DIVIDER_POST(p);
794815
795− intel_crtc->config.dpll_hw_state.wrpll = val;
816+ intel_crtc->new_config->dpll_hw_state.wrpll = val;
796817
797818 pll = intel_get_shared_dpll(intel_crtc);
798819 if (pll == NULL) {
@@ -801,7 +822,7 @@ hsw_ddi_pll_select(struct intel_crtc *intel_crtc, · 2 unmodified lines
801822 return false;
802823 }
803824
804− intel_crtc->config.ddi_pll_sel = PORT_CLK_SEL_WRPLL(pll->id);
825+ intel_crtc->new_config->ddi_pll_sel = PORT_CLK_SEL_WRPLL(pll->id);
805826 }
806827
807828 return true;
@@ -817,11 +838,9 @@ hsw_ddi_pll_select(struct intel_crtc *intel_crtc, · 9 unmodified lines
817838 */
818839 bool intel_ddi_pll_select(struct intel_crtc *intel_crtc)
819840 {
820− struct drm_crtc *crtc = &intel_crtc->base;
821− struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc);
822− int clock = intel_crtc->config.port_clock;
823−
824− intel_put_shared_dpll(intel_crtc);
841+ struct intel_encoder *intel_encoder =
842+ intel_ddi_get_crtc_new_encoder(intel_crtc);
843+ int clock = intel_crtc->new_config->port_clock;
825844
826845 return hsw_ddi_pll_select(intel_crtc, intel_encoder, clock);
827846 }
@@ -1120,15 +1139,6 @@ static void intel_ddi_pre_enable(struct intel_encoder *intel_encoder) · 292 unmodified lines
11201139 enum port port = intel_ddi_get_encoder_port(intel_encoder);
11211140 int type = intel_encoder->type;
11221141
1123− if (crtc->config.has_audio) {
1124− DRM_DEBUG_DRIVER("Audio on pipe %c on DDI\n",
1125− pipe_name(crtc->pipe));
1126−
1127− /* write eld */
1128− DRM_DEBUG_DRIVER("DDI audio: write eld information\n");
1129− intel_write_eld(encoder, &crtc->config.adjusted_mode);
1130− }
1131−
11321142 if (type == INTEL_OUTPUT_EDP) {
11331143 struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
11341144 intel_edp_panel_on(intel_dp);
@@ -1195,12 +1205,10 @@ static void intel_enable_ddi(struct intel_encoder *intel_encoder) · 60 unmodified lines
11951205 struct drm_encoder *encoder = &intel_encoder->base;
11961206 struct drm_crtc *crtc = encoder->crtc;
11971207 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
1198− int pipe = intel_crtc->pipe;
11991208 struct drm_device *dev = encoder->dev;
12001209 struct drm_i915_private *dev_priv = dev->dev_private;
12011210 enum port port = intel_ddi_get_encoder_port(intel_encoder);
12021211 int type = intel_encoder->type;
1203− uint32_t tmp;
12041212
12051213 if (type == INTEL_OUTPUT_HDMI) {
12061214 struct intel_digital_port *intel_dig_port =
@@ -1225,9 +1233,7 @@ static void intel_enable_ddi(struct intel_encoder *intel_encoder) · 18 unmodified lines
12251233
12261234 if (intel_crtc->config.has_audio) {
12271235 intel_display_power_get(dev_priv, POWER_DOMAIN_AUDIO);
1228− tmp = I915_READ(HSW_AUD_PIN_ELD_CP_VLD);
1229− tmp |= ((AUDIO_OUTPUT_ENABLE_A | AUDIO_ELD_VALID_A) << (pipe * 4));
1230− I915_WRITE(HSW_AUD_PIN_ELD_CP_VLD, tmp);
1236+ intel_audio_codec_enable(intel_encoder);
12311237 }
12321238 }
12331239
@@ -1236,19 +1242,12 @@ static void intel_disable_ddi(struct intel_encoder *intel_encoder) · 2 unmodified lines
12361242 struct drm_encoder *encoder = &intel_encoder->base;
12371243 struct drm_crtc *crtc = encoder->crtc;
12381244 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
1239− int pipe = intel_crtc->pipe;
12401245 int type = intel_encoder->type;
12411246 struct drm_device *dev = encoder->dev;
12421247 struct drm_i915_private *dev_priv = dev->dev_private;
1243− uint32_t tmp;
12441248
1245− /* We can't touch HSW_AUD_PIN_ELD_CP_VLD uncionditionally because this
1246− * register is part of the power well on Haswell. */
12471249 if (intel_crtc->config.has_audio) {
1248− tmp = I915_READ(HSW_AUD_PIN_ELD_CP_VLD);
1249− tmp &= ~((AUDIO_OUTPUT_ENABLE_A | AUDIO_ELD_VALID_A) <<
1250− (pipe * 4));
1251− I915_WRITE(HSW_AUD_PIN_ELD_CP_VLD, tmp);
1250+ intel_audio_codec_disable(intel_encoder);
12521251 intel_display_power_put(dev_priv, POWER_DOMAIN_AUDIO);
12531252 }
12541253
@@ -1311,7 +1310,7 @@ int intel_ddi_get_cdclk_freq(struct drm_i915_private *dev_priv) · 56 unmodified lines
13111310 static void hsw_ddi_pll_enable(struct drm_i915_private *dev_priv,
13121311 struct intel_shared_dpll *pll)
13131312 {
1314− I915_WRITE(WRPLL_CTL(pll->id), pll->hw_state.wrpll);
1313+ I915_WRITE(WRPLL_CTL(pll->id), pll->config.hw_state.wrpll);
13151314 POSTING_READ(WRPLL_CTL(pll->id));
13161315 udelay(20);
13171316 }
@@ -1524,7 +1523,7 @@ void intel_ddi_get_config(struct intel_encoder *encoder, · 206 unmodified lines
15241523
15251524 if (intel_display_power_is_enabled(dev_priv, POWER_DOMAIN_AUDIO)) {
15261525 temp = I915_READ(HSW_AUD_PIN_ELD_CP_VLD);
1527− if (temp & (AUDIO_OUTPUT_ENABLE_A << (intel_crtc->pipe * 4)))
1526+ if (temp & AUDIO_OUTPUT_ENABLE(intel_crtc->pipe))
15281527 pipe_config->has_audio = true;
15291528 }
15301529
drivers/gpu/drm/i915/intel_display.c+503−640
@@ -94,8 +94,10 @@ static void intel_cpu_transcoder_set_m_n(struct intel_crtc *crtc, · 93 unmodified lines
9494 static void ironlake_set_pipeconf(struct drm_crtc *crtc);
9595 static void haswell_set_pipeconf(struct drm_crtc *crtc);
9696 static void intel_set_pipe_csc(struct drm_crtc *crtc);
97−static void vlv_prepare_pll(struct intel_crtc *crtc);
98−static void chv_prepare_pll(struct intel_crtc *crtc);
97+static void vlv_prepare_pll(struct intel_crtc *crtc,
98+ const struct intel_crtc_config *pipe_config);
99+static void chv_prepare_pll(struct intel_crtc *crtc,
100+ const struct intel_crtc_config *pipe_config);
99101
100102 static struct intel_encoder *intel_find_encoder(struct intel_connector *connector, int pipe)
101103 {
@@ -406,7 +408,7 @@ static void vlv_clock(int refclk, intel_clock_t *clock) · 304 unmodified lines
406408 /**
407409 * Returns whether any output on the specified pipe is of the specified type
408410 */
409−static bool intel_pipe_has_type(struct intel_crtc *crtc, int type)
411+bool intel_pipe_has_type(struct intel_crtc *crtc, enum intel_output_type type)
410412 {
411413 struct drm_device *dev = crtc->base.dev;
412414 struct intel_encoder *encoder;
@@ -418,13 +420,31 @@ static bool intel_pipe_has_type(struct intel_crtc *crtc, int type) · 5 unmodified lines
418420 return false;
419421 }
420422
423+/**
424+ * Returns whether any output on the specified pipe will have the specified
425+ * type after a staged modeset is complete, i.e., the same as
426+ * intel_pipe_has_type() but looking at encoder->new_crtc instead of
427+ * encoder->crtc.
428+ */
429+static bool intel_pipe_will_have_type(struct intel_crtc *crtc, int type)
430+{
431+ struct drm_device *dev = crtc->base.dev;
432+ struct intel_encoder *encoder;
433+
434+ for_each_intel_encoder(dev, encoder)
435+ if (encoder->new_crtc == crtc && encoder->type == type)
436+ return true;
437+
438+ return false;
439+}
440+
421441 static const intel_limit_t *intel_ironlake_limit(struct intel_crtc *crtc,
422442 int refclk)
423443 {
424444 struct drm_device *dev = crtc->base.dev;
425445 const intel_limit_t *limit;
426446
427− if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) {
447+ if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_LVDS)) {
428448 if (intel_is_dual_link_lvds(dev)) {
429449 if (refclk == 100000)
430450 limit = &intel_limits_ironlake_dual_lvds_100m;
@@ -447,15 +467,15 @@ static const intel_limit_t *intel_g4x_limit(struct intel_crtc *crtc) · 16 unmodified lines
447467 struct drm_device *dev = crtc->base.dev;
448468 const intel_limit_t *limit;
449469
450− if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) {
470+ if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_LVDS)) {
451471 if (intel_is_dual_link_lvds(dev))
452472 limit = &intel_limits_g4x_dual_channel_lvds;
453473 else
454474 limit = &intel_limits_g4x_single_channel_lvds;
455− } else if (intel_pipe_has_type(crtc, INTEL_OUTPUT_HDMI) ||
456− intel_pipe_has_type(crtc, INTEL_OUTPUT_ANALOG)) {
475+ } else if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_HDMI) ||
476+ intel_pipe_will_have_type(crtc, INTEL_OUTPUT_ANALOG)) {
457477 limit = &intel_limits_g4x_hdmi;
458− } else if (intel_pipe_has_type(crtc, INTEL_OUTPUT_SDVO)) {
478+ } else if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_SDVO)) {
459479 limit = &intel_limits_g4x_sdvo;
460480 } else /* The option is for other outputs */
461481 limit = &intel_limits_i9xx_sdvo;
@@ -473,7 +493,7 @@ static const intel_limit_t *intel_limit(struct intel_crtc *crtc, int refclk) · 11 unmodified lines
473493 else if (IS_G4X(dev)) {
474494 limit = intel_g4x_limit(crtc);
475495 } else if (IS_PINEVIEW(dev)) {
476− if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS))
496+ if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_LVDS))
477497 limit = &intel_limits_pineview_lvds;
478498 else
479499 limit = &intel_limits_pineview_sdvo;
@@ -482,14 +502,14 @@ static const intel_limit_t *intel_limit(struct intel_crtc *crtc, int refclk) · 2 unmodified lines
482502 } else if (IS_VALLEYVIEW(dev)) {
483503 limit = &intel_limits_vlv;
484504 } else if (!IS_GEN2(dev)) {
485− if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS))
505+ if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_LVDS))
486506 limit = &intel_limits_i9xx_lvds;
487507 else
488508 limit = &intel_limits_i9xx_sdvo;
489509 } else {
490− if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS))
510+ if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_LVDS))
491511 limit = &intel_limits_i8xx_lvds;
492− else if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DVO))
512+ else if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_DVO))
493513 limit = &intel_limits_i8xx_dvo;
494514 else
495515 limit = &intel_limits_i8xx_dac;
@@ -584,7 +604,7 @@ i9xx_find_best_dpll(const intel_limit_t *limit, struct intel_crtc *crtc, · 88 unmodified lines
584604 intel_clock_t clock;
585605 int err = target;
586606
587− if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) {
607+ if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_LVDS)) {
588608 /*
589609 * For LVDS just rely on its current settings for dual-channel.
590610 * We haven't figured out how to reliably set up different
@@ -645,7 +665,7 @@ pnv_find_best_dpll(const intel_limit_t *limit, struct intel_crtc *crtc, · 54 unmodified lines
645665 intel_clock_t clock;
646666 int err = target;
647667
648− if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) {
668+ if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_LVDS)) {
649669 /*
650670 * For LVDS just rely on its current settings for dual-channel.
651671 * We haven't figured out how to reliably set up different
@@ -708,7 +728,7 @@ g4x_find_best_dpll(const intel_limit_t *limit, struct intel_crtc *crtc, · 56 unmodified lines
708728 int err_most = (target >> 8) + (target >> 9);
709729 found = false;
710730
711− if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) {
731+ if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_LVDS)) {
712732 if (intel_is_dual_link_lvds(dev))
713733 clock.p2 = limit->p2.p2_fast;
714734 else
@@ -1484,12 +1504,13 @@ static void intel_init_dpio(struct drm_device *dev) · 769 unmodified lines
14841504 }
14851505 }
14861506
1487−static void vlv_enable_pll(struct intel_crtc *crtc)
1507+static void vlv_enable_pll(struct intel_crtc *crtc,
1508+ const struct intel_crtc_config *pipe_config)
14881509 {
14891510 struct drm_device *dev = crtc->base.dev;
14901511 struct drm_i915_private *dev_priv = dev->dev_private;
14911512 int reg = DPLL(crtc->pipe);
1492− u32 dpll = crtc->config.dpll_hw_state.dpll;
1513+ u32 dpll = pipe_config->dpll_hw_state.dpll;
14931514
14941515 assert_pipe_disabled(dev_priv, crtc->pipe);
14951516
@@ -1507,7 +1528,7 @@ static void vlv_enable_pll(struct intel_crtc *crtc) · 11 unmodified lines
15071528 if (wait_for(((I915_READ(reg) & DPLL_LOCK_VLV) == DPLL_LOCK_VLV), 1))
15081529 DRM_ERROR("DPLL %d failed to lock\n", crtc->pipe);
15091530
1510− I915_WRITE(DPLL_MD(crtc->pipe), crtc->config.dpll_hw_state.dpll_md);
1531+ I915_WRITE(DPLL_MD(crtc->pipe), pipe_config->dpll_hw_state.dpll_md);
15111532 POSTING_READ(DPLL_MD(crtc->pipe));
15121533
15131534 /* We do this three times for luck */
@@ -1522,7 +1543,8 @@ static void vlv_enable_pll(struct intel_crtc *crtc) · 8 unmodified lines
15221543 udelay(150); /* wait for warmup */
15231544 }
15241545
1525−static void chv_enable_pll(struct intel_crtc *crtc)
1546+static void chv_enable_pll(struct intel_crtc *crtc,
1547+ const struct intel_crtc_config *pipe_config)
15261548 {
15271549 struct drm_device *dev = crtc->base.dev;
15281550 struct drm_i915_private *dev_priv = dev->dev_private;
@@ -1547,14 +1569,14 @@ static void chv_enable_pll(struct intel_crtc *crtc) · 18 unmodified lines
15471569 udelay(1);
15481570
15491571 /* Enable PLL */
1550− I915_WRITE(DPLL(pipe), crtc->config.dpll_hw_state.dpll);
1572+ I915_WRITE(DPLL(pipe), pipe_config->dpll_hw_state.dpll);
15511573
15521574 /* Check PLL is locked */
15531575 if (wait_for(((I915_READ(DPLL(pipe)) & DPLL_LOCK_VLV) == DPLL_LOCK_VLV), 1))
15541576 DRM_ERROR("PLL %d failed to lock\n", pipe);
15551577
15561578 /* not sure when this should be written */
1557− I915_WRITE(DPLL_MD(pipe), crtc->config.dpll_hw_state.dpll_md);
1579+ I915_WRITE(DPLL_MD(pipe), pipe_config->dpll_hw_state.dpll_md);
15581580 POSTING_READ(DPLL_MD(pipe));
15591581
15601582 mutex_unlock(&dev_priv->dpio_lock);
@@ -1757,7 +1779,7 @@ static void intel_prepare_shared_dpll(struct intel_crtc *crtc) · 196 unmodified lines
17571779 if (WARN_ON(pll == NULL))
17581780 return;
17591781
1760− WARN_ON(!pll->refcount);
1782+ WARN_ON(!pll->config.crtc_mask);
17611783 if (pll->active == 0) {
17621784 DRM_DEBUG_DRIVER("setting up %s\n", pll->name);
17631785 WARN_ON(pll->on);
@@ -1784,7 +1806,7 @@ static void intel_enable_shared_dpll(struct intel_crtc *crtc) · 20 unmodified lines
17841806 if (WARN_ON(pll == NULL))
17851807 return;
17861808
1787− if (WARN_ON(pll->refcount == 0))
1809+ if (WARN_ON(pll->config.crtc_mask == 0))
17881810 return;
17891811
17901812 DRM_DEBUG_KMS("enable %s (active %d, on? %d) for crtc %d\n",
@@ -1816,7 +1838,7 @@ static void intel_disable_shared_dpll(struct intel_crtc *crtc) · 25 unmodified lines
18161838 if (WARN_ON(pll == NULL))
18171839 return;
18181840
1819− if (WARN_ON(pll->refcount == 0))
1841+ if (WARN_ON(pll->config.crtc_mask == 0))
18201842 return;
18211843
18221844 DRM_DEBUG_KMS("disable %s (active %d, on? %d) for crtc %d\n",
@@ -2172,11 +2194,13 @@ static int intel_align_height(struct drm_device *dev, int height, bool tiled) · 349 unmodified lines
21722194 }
21732195
21742196 int
2175−intel_pin_and_fence_fb_obj(struct drm_device *dev,
2176− struct drm_i915_gem_object *obj,
2197+intel_pin_and_fence_fb_obj(struct drm_plane *plane,
2198+ struct drm_framebuffer *fb,
21772199 struct intel_engine_cs *pipelined)
21782200 {
2201+ struct drm_device *dev = fb->dev;
21792202 struct drm_i915_private *dev_priv = dev->dev_private;
2203+ struct drm_i915_gem_object *obj = intel_fb_obj(fb);
21802204 u32 alignment;
21812205 int ret;
21822206
@@ -2447,6 +2471,12 @@ static void i9xx_update_primary_plane(struct drm_crtc *crtc, · 264 unmodified lines
24472471 ((intel_crtc->config.pipe_src_h - 1) << 16) |
24482472 (intel_crtc->config.pipe_src_w - 1));
24492473 I915_WRITE(DSPPOS(plane), 0);
2474+ } else if (IS_CHERRYVIEW(dev) && plane == PLANE_B) {
2475+ I915_WRITE(PRIMSIZE(plane),
2476+ ((intel_crtc->config.pipe_src_h - 1) << 16) |
2477+ (intel_crtc->config.pipe_src_w - 1));
2478+ I915_WRITE(PRIMPOS(plane), 0);
2479+ I915_WRITE(PRIMCNSTALPHA(plane), 0);
24502480 }
24512481
24522482 switch (fb->pixel_format) {
@@ -2869,7 +2899,6 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, · 416 unmodified lines
28692899 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
28702900 enum pipe pipe = intel_crtc->pipe;
28712901 struct drm_framebuffer *old_fb = crtc->primary->fb;
2872− struct drm_i915_gem_object *obj = intel_fb_obj(fb);
28732902 struct drm_i915_gem_object *old_obj = intel_fb_obj(old_fb);
28742903 int ret;
28752904
@@ -2892,9 +2921,9 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, · 16 unmodified lines
28922921 }
28932922
28942923 mutex_lock(&dev->struct_mutex);
2895− ret = intel_pin_and_fence_fb_obj(dev, obj, NULL);
2924+ ret = intel_pin_and_fence_fb_obj(crtc->primary, fb, NULL);
28962925 if (ret == 0)
2897− i915_gem_track_fb(old_obj, obj,
2926+ i915_gem_track_fb(old_obj, intel_fb_obj(fb),
28982927 INTEL_FRONTBUFFER_PRIMARY(pipe));
28992928 mutex_unlock(&dev->struct_mutex);
29002929 if (ret != 0) {
@@ -3758,9 +3787,7 @@ static void ironlake_pch_enable(struct drm_crtc *crtc) · 857 unmodified lines
37583787 intel_fdi_normal_train(crtc);
37593788
37603789 /* For PCH DP, enable TRANS_DP_CTL */
3761− if (HAS_PCH_CPT(dev) &&
3762− (intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DISPLAYPORT) ||
3763− intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_EDP))) {
3790+ if (HAS_PCH_CPT(dev) && intel_crtc->config.has_dp_encoder) {
37643791 u32 bpc = (I915_READ(PIPECONF(pipe)) & PIPECONF_BPC_MASK) >> 5;
37653792 reg = TRANS_DP_CTL(pipe);
37663793 temp = I915_READ(reg);
@@ -3820,12 +3847,13 @@ void intel_put_shared_dpll(struct intel_crtc *crtc) · 53 unmodified lines
38203847 if (pll == NULL)
38213848 return;
38223849
3823− if (pll->refcount == 0) {
3824− WARN(1, "bad %s refcount\n", pll->name);
3850+ if (!(pll->config.crtc_mask & (1 << crtc->pipe))) {
3851+ WARN(1, "bad %s crtc mask\n", pll->name);
38253852 return;
38263853 }
38273854
3828− if (--pll->refcount == 0) {
3855+ pll->config.crtc_mask &= ~(1 << crtc->pipe);
3856+ if (pll->config.crtc_mask == 0) {
38293857 WARN_ON(pll->on);
38303858 WARN_ON(pll->active);
38313859 }
@@ -3836,15 +3864,9 @@ void intel_put_shared_dpll(struct intel_crtc *crtc) · 4 unmodified lines
38363864 struct intel_shared_dpll *intel_get_shared_dpll(struct intel_crtc *crtc)
38373865 {
38383866 struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
3839− struct intel_shared_dpll *pll = intel_crtc_to_shared_dpll(crtc);
3867+ struct intel_shared_dpll *pll;
38403868 enum intel_dpll_id i;
38413869
3842− if (pll) {
3843− DRM_DEBUG_KMS("CRTC:%d dropping existing %s\n",
3844− crtc->base.base.id, pll->name);
3845− intel_put_shared_dpll(crtc);
3846− }
3847−
38483870 if (HAS_PCH_IBX(dev_priv->dev)) {
38493871 /* Ironlake PCH has a fixed PLL->PCH pipe mapping. */
38503872 i = (enum intel_dpll_id) crtc->pipe;
@@ -3853,7 +3875,7 @@ struct intel_shared_dpll *intel_get_shared_dpll(struct intel_crtc *crtc) · 2 unmodified lines
38533875 DRM_DEBUG_KMS("CRTC:%d using pre-allocated %s\n",
38543876 crtc->base.base.id, pll->name);
38553877
3856− WARN_ON(pll->refcount);
3878+ WARN_ON(pll->new_config->crtc_mask);
38573879
38583880 goto found;
38593881 }
@@ -3862,15 +3884,16 @@ struct intel_shared_dpll *intel_get_shared_dpll(struct intel_crtc *crtc) · 2 unmodified lines
38623884 pll = &dev_priv->shared_dplls[i];
38633885
38643886 /* Only want to check enabled timings first */
3865− if (pll->refcount == 0)
3887+ if (pll->new_config->crtc_mask == 0)
38663888 continue;
38673889
3868− if (memcmp(&crtc->config.dpll_hw_state, &pll->hw_state,
3869− sizeof(pll->hw_state)) == 0) {
3870− DRM_DEBUG_KMS("CRTC:%d sharing existing %s (refcount %d, ative %d)\n",
3871− crtc->base.base.id,
3872− pll->name, pll->refcount, pll->active);
3873−
3890+ if (memcmp(&crtc->new_config->dpll_hw_state,
3891+ &pll->new_config->hw_state,
3892+ sizeof(pll->new_config->hw_state)) == 0) {
3893+ DRM_DEBUG_KMS("CRTC:%d sharing existing %s (crtc mask 0x%08x, ative %d)\n",
3894+ crtc->base.base.id, pll->name,
3895+ pll->new_config->crtc_mask,
3896+ pll->active);
38743897 goto found;
38753898 }
38763899 }
@@ -3878,7 +3901,7 @@ struct intel_shared_dpll *intel_get_shared_dpll(struct intel_crtc *crtc) · 1 unmodified line
38783901 /* Ok no matching timings, maybe there's a free one? */
38793902 for (i = 0; i < dev_priv->num_shared_dpll; i++) {
38803903 pll = &dev_priv->shared_dplls[i];
3881− if (pll->refcount == 0) {
3904+ if (pll->new_config->crtc_mask == 0) {
38823905 DRM_DEBUG_KMS("CRTC:%d allocated %s\n",
38833906 crtc->base.base.id, pll->name);
38843907 goto found;
@@ -3888,18 +3911,86 @@ struct intel_shared_dpll *intel_get_shared_dpll(struct intel_crtc *crtc) · 3 unmodified lines
38883911 return NULL;
38893912
38903913 found:
3891− if (pll->refcount == 0)
3892− pll->hw_state = crtc->config.dpll_hw_state;
3914+ if (pll->new_config->crtc_mask == 0)
3915+ pll->new_config->hw_state = crtc->new_config->dpll_hw_state;
38933916
3894− crtc->config.shared_dpll = i;
3917+ crtc->new_config->shared_dpll = i;
38953918 DRM_DEBUG_DRIVER("using %s for pipe %c\n", pll->name,
38963919 pipe_name(crtc->pipe));
38973920
3898− pll->refcount++;
3921+ pll->new_config->crtc_mask |= 1 << crtc->pipe;
38993922
39003923 return pll;
39013924 }
39023925
3926+/**
3927+ * intel_shared_dpll_start_config - start a new PLL staged config
3928+ * @dev_priv: DRM device
3929+ * @clear_pipes: mask of pipes that will have their PLLs freed
3930+ *
3931+ * Starts a new PLL staged config, copying the current config but
3932+ * releasing the references of pipes specified in clear_pipes.
3933+ */
3934+static int intel_shared_dpll_start_config(struct drm_i915_private *dev_priv,
3935+ unsigned clear_pipes)
3936+{
3937+ struct intel_shared_dpll *pll;
3938+ enum intel_dpll_id i;
3939+
3940+ for (i = 0; i < dev_priv->num_shared_dpll; i++) {
3941+ pll = &dev_priv->shared_dplls[i];
3942+
3943+ pll->new_config = kmemdup(&pll->config, sizeof pll->config,
3944+ GFP_KERNEL);
3945+ if (!pll->new_config)
3946+ goto cleanup;
3947+
3948+ pll->new_config->crtc_mask &= ~clear_pipes;
3949+ }
3950+
3951+ return 0;
3952+
3953+cleanup:
3954+ while (--i >= 0) {
3955+ pll = &dev_priv->shared_dplls[i];
3956+ kfree(pll->new_config);
3957+ pll->new_config = NULL;
3958+ }
3959+
3960+ return -ENOMEM;
3961+}
3962+
3963+static void intel_shared_dpll_commit(struct drm_i915_private *dev_priv)
3964+{
3965+ struct intel_shared_dpll *pll;
3966+ enum intel_dpll_id i;
3967+
3968+ for (i = 0; i < dev_priv->num_shared_dpll; i++) {
3969+ pll = &dev_priv->shared_dplls[i];
3970+
3971+ WARN_ON(pll->new_config == &pll->config);
3972+
3973+ pll->config = *pll->new_config;
3974+ kfree(pll->new_config);
3975+ pll->new_config = NULL;
3976+ }
3977+}
3978+
3979+static void intel_shared_dpll_abort_config(struct drm_i915_private *dev_priv)
3980+{
3981+ struct intel_shared_dpll *pll;
3982+ enum intel_dpll_id i;
3983+
3984+ for (i = 0; i < dev_priv->num_shared_dpll; i++) {
3985+ pll = &dev_priv->shared_dplls[i];
3986+
3987+ WARN_ON(pll->new_config == &pll->config);
3988+
3989+ kfree(pll->new_config);
3990+ pll->new_config = NULL;
3991+ }
3992+}
3993+
39033994 static void cpt_verify_modeset(struct drm_device *dev, int pipe)
39043995 {
39053996 struct drm_i915_private *dev_priv = dev->dev_private;
@@ -4593,6 +4684,9 @@ static void modeset_update_crtc_power_domains(struct drm_device *dev) · 687 unmodified lines
45934684 intel_display_power_get(dev_priv, domain);
45944685 }
45954686
4687+ if (dev_priv->display.modeset_global_resources)
4688+ dev_priv->display.modeset_global_resources(dev);
4689+
45964690 for_each_intel_crtc(dev, crtc) {
45974691 enum intel_display_power_domain domain;
45984692
@@ -4663,10 +4757,9 @@ static void valleyview_set_cdclk(struct drm_device *dev, int cdclk) · 64 unmodified lines
46634757 mutex_unlock(&dev_priv->rps.hw_lock);
46644758
46654759 if (cdclk == 400000) {
4666− u32 divider, vco;
4760+ u32 divider;
46674761
4668− vco = valleyview_get_vco(dev_priv);
4669− divider = DIV_ROUND_CLOSEST(vco << 1, cdclk) - 1;
4762+ divider = DIV_ROUND_CLOSEST(dev_priv->hpll_freq << 1, cdclk) - 1;
46704763
46714764 mutex_lock(&dev_priv->dpio_lock);
46724765 /* adjust cdclk divider */
@@ -4745,8 +4838,7 @@ static void cherryview_set_cdclk(struct drm_device *dev, int cdclk) · 72 unmodified lines
47454838 static int valleyview_calc_cdclk(struct drm_i915_private *dev_priv,
47464839 int max_pixclk)
47474840 {
4748− int vco = valleyview_get_vco(dev_priv);
4749− int freq_320 = (vco << 1) % 320000 != 0 ? 333333 : 320000;
4841+ int freq_320 = (dev_priv->hpll_freq << 1) % 320000 != 0 ? 333333 : 320000;
47504842
47514843 /* FIXME: Punit isn't quite ready yet */
47524844 if (IS_CHERRYVIEW(dev_priv->dev))
@@ -4820,8 +4912,6 @@ static void valleyview_modeset_global_resources(struct drm_device *dev) · 67 unmodified lines
48204912 else
48214913 valleyview_set_cdclk(dev, req_cdclk);
48224914 }
4823−
4824− modeset_update_crtc_power_domains(dev);
48254915 }
48264916
48274917 static void valleyview_crtc_enable(struct drm_crtc *crtc)
@@ -4842,9 +4932,9 @@ static void valleyview_crtc_enable(struct drm_crtc *crtc) · 14 unmodified lines
48424932
48434933 if (!is_dsi) {
48444934 if (IS_CHERRYVIEW(dev))
4845− chv_prepare_pll(intel_crtc);
4935+ chv_prepare_pll(intel_crtc, &intel_crtc->config);
48464936 else
4847− vlv_prepare_pll(intel_crtc);
4937+ vlv_prepare_pll(intel_crtc, &intel_crtc->config);
48484938 }
48494939
48504940 if (intel_crtc->config.has_dp_encoder)
@@ -4852,6 +4942,13 @@ static void valleyview_crtc_enable(struct drm_crtc *crtc) · 1 unmodified line
48524942
48534943 intel_set_pipe_timings(intel_crtc);
48544944
4945+ if (IS_CHERRYVIEW(dev) && pipe == PIPE_B) {
4946+ struct drm_i915_private *dev_priv = dev->dev_private;
4947+
4948+ I915_WRITE(CHV_BLEND(pipe), CHV_BLEND_LEGACY);
4949+ I915_WRITE(CHV_CANVAS(pipe), 0);
4950+ }
4951+
48554952 i9xx_set_pipeconf(intel_crtc);
48564953
48574954 intel_crtc->active = true;
@@ -4864,9 +4961,9 @@ static void valleyview_crtc_enable(struct drm_crtc *crtc) · 6 unmodified lines
48644961
48654962 if (!is_dsi) {
48664963 if (IS_CHERRYVIEW(dev))
4867− chv_enable_pll(intel_crtc);
4964+ chv_enable_pll(intel_crtc, &intel_crtc->config);
48684965 else
4869− vlv_enable_pll(intel_crtc);
4966+ vlv_enable_pll(intel_crtc, &intel_crtc->config);
48704967 }
48714968
48724969 for_each_encoder_on_crtc(dev, crtc, encoder)
@@ -5384,11 +5481,11 @@ static int intel_crtc_compute_config(struct intel_crtc *crtc, · 511 unmodified lines
53845481 struct intel_crtc_config *pipe_config)
53855482 {
53865483 struct drm_device *dev = crtc->base.dev;
5484+ struct drm_i915_private *dev_priv = dev->dev_private;
53875485 struct drm_display_mode *adjusted_mode = &pipe_config->adjusted_mode;
53885486
53895487 /* FIXME should check pixel clock limits on all platforms */
53905488 if (INTEL_INFO(dev)->gen < 4) {
5391− struct drm_i915_private *dev_priv = dev->dev_private;
53925489 int clock_limit =
53935490 dev_priv->display.get_display_clock_speed(dev);
53945491
@@ -5437,13 +5534,6 @@ static int intel_crtc_compute_config(struct intel_crtc *crtc, · 42 unmodified lines
54375534 if (HAS_IPS(dev))
54385535 hsw_compute_ips_config(crtc, pipe_config);
54395536
5440− /*
5441− * XXX: PCH/WRPLL clock sharing is done in ->mode_set, so make sure the
5442− * old clock survives for now.
5443− */
5444− if (HAS_PCH_IBX(dev) || HAS_PCH_CPT(dev) || HAS_DDI(dev))
5445− pipe_config->shared_dpll = crtc->config.shared_dpll;
5446−
54475537 if (pipe_config->has_pch_encoder)
54485538 return ironlake_fdi_compute_config(crtc, pipe_config);
54495539
@@ -5453,7 +5543,6 @@ static int intel_crtc_compute_config(struct intel_crtc *crtc, · 3 unmodified lines
54535543 static int valleyview_get_display_clock_speed(struct drm_device *dev)
54545544 {
54555545 struct drm_i915_private *dev_priv = dev->dev_private;
5456− int vco = valleyview_get_vco(dev_priv);
54575546 u32 val;
54585547 int divider;
54595548
@@ -5461,6 +5550,9 @@ static int valleyview_get_display_clock_speed(struct drm_device *dev) · 1 unmodified line
54615550 if (IS_CHERRYVIEW(dev))
54625551 return 400000;
54635552
5553+ if (dev_priv->hpll_freq == 0)
5554+ dev_priv->hpll_freq = valleyview_get_vco(dev_priv);
5555+
54645556 mutex_lock(&dev_priv->dpio_lock);
54655557 val = vlv_cck_read(dev_priv, CCK_DISPLAY_CLOCK_CONTROL);
54665558 mutex_unlock(&dev_priv->dpio_lock);
@@ -5471,7 +5563,7 @@ static int valleyview_get_display_clock_speed(struct drm_device *dev) · 4 unmodified lines
54715563 (divider << DISPLAY_FREQUENCY_STATUS_SHIFT),
54725564 "cdclk change in progress\n");
54735565
5474− return DIV_ROUND_CLOSEST(vco << 1, divider + 1);
5566+ return DIV_ROUND_CLOSEST(dev_priv->hpll_freq << 1, divider + 1);
54755567 }
54765568
54775569 static int i945_get_display_clock_speed(struct drm_device *dev)
@@ -5611,7 +5703,7 @@ static int i9xx_get_refclk(struct intel_crtc *crtc, int num_connectors) · 133 unmodified lines
56115703
56125704 if (IS_VALLEYVIEW(dev)) {
56135705 refclk = 100000;
5614− } else if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS) &&
5706+ } else if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_LVDS) &&
56155707 intel_panel_use_ssc(dev_priv) && num_connectors < 2) {
56165708 refclk = dev_priv->vbt.lvds_ssc_freq;
56175709 DRM_DEBUG_KMS("using SSC reference clock of %d kHz\n", refclk);
@@ -5641,24 +5733,24 @@ static void i9xx_update_pll_dividers(struct intel_crtc *crtc, · 23 unmodified lines
56415733 u32 fp, fp2 = 0;
56425734
56435735 if (IS_PINEVIEW(dev)) {
5644− fp = pnv_dpll_compute_fp(&crtc->config.dpll);
5736+ fp = pnv_dpll_compute_fp(&crtc->new_config->dpll);
56455737 if (reduced_clock)
56465738 fp2 = pnv_dpll_compute_fp(reduced_clock);
56475739 } else {
5648− fp = i9xx_dpll_compute_fp(&crtc->config.dpll);
5740+ fp = i9xx_dpll_compute_fp(&crtc->new_config->dpll);
56495741 if (reduced_clock)
56505742 fp2 = i9xx_dpll_compute_fp(reduced_clock);
56515743 }
56525744
5653− crtc->config.dpll_hw_state.fp0 = fp;
5745+ crtc->new_config->dpll_hw_state.fp0 = fp;
56545746
56555747 crtc->lowfreq_avail = false;
5656− if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS) &&
5748+ if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_LVDS) &&
56575749 reduced_clock && i915.powersave) {
5658− crtc->config.dpll_hw_state.fp1 = fp2;
5750+ crtc->new_config->dpll_hw_state.fp1 = fp2;
56595751 crtc->lowfreq_avail = true;
56605752 } else {
5661− crtc->config.dpll_hw_state.fp1 = fp;
5753+ crtc->new_config->dpll_hw_state.fp1 = fp;
56625754 }
56635755 }
56645756
@@ -5747,7 +5839,8 @@ void intel_dp_set_m_n(struct intel_crtc *crtc) · 82 unmodified lines
57475839 &crtc->config.dp_m2_n2);
57485840 }
57495841
5750−static void vlv_update_pll(struct intel_crtc *crtc)
5842+static void vlv_update_pll(struct intel_crtc *crtc,
5843+ struct intel_crtc_config *pipe_config)
57515844 {
57525845 u32 dpll, dpll_md;
57535846
@@ -5762,14 +5855,15 @@ static void vlv_update_pll(struct intel_crtc *crtc) · 8 unmodified lines
57625855 if (crtc->pipe == PIPE_B)
57635856 dpll |= DPLL_INTEGRATED_CRI_CLK_VLV;
57645857 dpll |= DPLL_VCO_ENABLE;
5765− crtc->config.dpll_hw_state.dpll = dpll;
5858+ pipe_config->dpll_hw_state.dpll = dpll;
57665859
5767− dpll_md = (crtc->config.pixel_multiplier - 1)
5860+ dpll_md = (pipe_config->pixel_multiplier - 1)
57685861 << DPLL_MD_UDI_MULTIPLIER_SHIFT;
5769− crtc->config.dpll_hw_state.dpll_md = dpll_md;
5862+ pipe_config->dpll_hw_state.dpll_md = dpll_md;
57705863 }
57715864
5772−static void vlv_prepare_pll(struct intel_crtc *crtc)
5865+static void vlv_prepare_pll(struct intel_crtc *crtc,
5866+ const struct intel_crtc_config *pipe_config)
57735867 {
57745868 struct drm_device *dev = crtc->base.dev;
57755869 struct drm_i915_private *dev_priv = dev->dev_private;
@@ -5780,11 +5874,11 @@ static void vlv_prepare_pll(struct intel_crtc *crtc) · 4 unmodified lines
57805874
57815875 mutex_lock(&dev_priv->dpio_lock);
57825876
5783− bestn = crtc->config.dpll.n;
5784− bestm1 = crtc->config.dpll.m1;
5785− bestm2 = crtc->config.dpll.m2;
5786− bestp1 = crtc->config.dpll.p1;
5787− bestp2 = crtc->config.dpll.p2;
5877+ bestn = pipe_config->dpll.n;
5878+ bestm1 = pipe_config->dpll.m1;
5879+ bestm2 = pipe_config->dpll.m2;
5880+ bestp1 = pipe_config->dpll.p1;
5881+ bestp2 = pipe_config->dpll.p2;
57885882
57895883 /* See eDP HDMI DPIO driver vbios notes doc */
57905884
@@ -5821,7 +5915,7 @@ static void vlv_prepare_pll(struct intel_crtc *crtc) · 30 unmodified lines
58215915 vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW3(pipe), mdiv);
58225916
58235917 /* Set HBR and RBR LPF coefficients */
5824− if (crtc->config.port_clock == 162000 ||
5918+ if (pipe_config->port_clock == 162000 ||
58255919 intel_pipe_has_type(crtc, INTEL_OUTPUT_ANALOG) ||
58265920 intel_pipe_has_type(crtc, INTEL_OUTPUT_HDMI))
58275921 vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW10(pipe),
@@ -5830,8 +5924,7 @@ static void vlv_prepare_pll(struct intel_crtc *crtc) · 2 unmodified lines
58305924 vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW10(pipe),
58315925 0x00d0000f);
58325926
5833− if (intel_pipe_has_type(crtc, INTEL_OUTPUT_EDP) ||
5834− intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT)) {
5927+ if (crtc->config.has_dp_encoder) {
58355928 /* Use SSC source */
58365929 if (pipe == PIPE_A)
58375930 vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW5(pipe),
@@ -5860,19 +5953,21 @@ static void vlv_prepare_pll(struct intel_crtc *crtc) · 22 unmodified lines
58605953 mutex_unlock(&dev_priv->dpio_lock);
58615954 }
58625955
5863−static void chv_update_pll(struct intel_crtc *crtc)
5956+static void chv_update_pll(struct intel_crtc *crtc,
5957+ struct intel_crtc_config *pipe_config)
58645958 {
5865− crtc->config.dpll_hw_state.dpll = DPLL_SSC_REF_CLOCK_CHV |
5959+ pipe_config->dpll_hw_state.dpll = DPLL_SSC_REF_CLOCK_CHV |
58665960 DPLL_REFA_CLK_ENABLE_VLV | DPLL_VGA_MODE_DIS |
58675961 DPLL_VCO_ENABLE;
58685962 if (crtc->pipe != PIPE_A)
5869− crtc->config.dpll_hw_state.dpll |= DPLL_INTEGRATED_CRI_CLK_VLV;
5963+ pipe_config->dpll_hw_state.dpll |= DPLL_INTEGRATED_CRI_CLK_VLV;
58705964
5871− crtc->config.dpll_hw_state.dpll_md =
5872− (crtc->config.pixel_multiplier - 1) << DPLL_MD_UDI_MULTIPLIER_SHIFT;
5965+ pipe_config->dpll_hw_state.dpll_md =
5966+ (pipe_config->pixel_multiplier - 1) << DPLL_MD_UDI_MULTIPLIER_SHIFT;
58735967 }
58745968
5875−static void chv_prepare_pll(struct intel_crtc *crtc)
5969+static void chv_prepare_pll(struct intel_crtc *crtc,
5970+ const struct intel_crtc_config *pipe_config)
58765971 {
58775972 struct drm_device *dev = crtc->base.dev;
58785973 struct drm_i915_private *dev_priv = dev->dev_private;
@@ -5883,18 +5978,18 @@ static void chv_prepare_pll(struct intel_crtc *crtc) · 4 unmodified lines
58835978 u32 bestn, bestm1, bestm2, bestp1, bestp2, bestm2_frac;
58845979 int refclk;
58855980
5886− bestn = crtc->config.dpll.n;
5887− bestm2_frac = crtc->config.dpll.m2 & 0x3fffff;
5888− bestm1 = crtc->config.dpll.m1;
5889− bestm2 = crtc->config.dpll.m2 >> 22;
5890− bestp1 = crtc->config.dpll.p1;
5891− bestp2 = crtc->config.dpll.p2;
5981+ bestn = pipe_config->dpll.n;
5982+ bestm2_frac = pipe_config->dpll.m2 & 0x3fffff;
5983+ bestm1 = pipe_config->dpll.m1;
5984+ bestm2 = pipe_config->dpll.m2 >> 22;
5985+ bestp1 = pipe_config->dpll.p1;
5986+ bestp2 = pipe_config->dpll.p2;
58925987
58935988 /*
58945989 * Enable Refclk and SSC
58955990 */
58965991 I915_WRITE(dpll_reg,
5897− crtc->config.dpll_hw_state.dpll & ~DPLL_VCO_ENABLE);
5992+ pipe_config->dpll_hw_state.dpll & ~DPLL_VCO_ENABLE);
58985993
58995994 mutex_lock(&dev_priv->dpio_lock);
59005995
@@ -5942,6 +6037,53 @@ static void chv_prepare_pll(struct intel_crtc *crtc) · 41 unmodified lines
59426037 mutex_unlock(&dev_priv->dpio_lock);
59436038 }
59446039
6040+/**
6041+ * vlv_force_pll_on - forcibly enable just the PLL
6042+ * @dev_priv: i915 private structure
6043+ * @pipe: pipe PLL to enable
6044+ * @dpll: PLL configuration
6045+ *
6046+ * Enable the PLL for @pipe using the supplied @dpll config. To be used
6047+ * in cases where we need the PLL enabled even when @pipe is not going to
6048+ * be enabled.
6049+ */
6050+void vlv_force_pll_on(struct drm_device *dev, enum pipe pipe,
6051+ const struct dpll *dpll)
6052+{
6053+ struct intel_crtc *crtc =
6054+ to_intel_crtc(intel_get_crtc_for_pipe(dev, pipe));
6055+ struct intel_crtc_config pipe_config = {
6056+ .pixel_multiplier = 1,
6057+ .dpll = *dpll,
6058+ };
6059+
6060+ if (IS_CHERRYVIEW(dev)) {
6061+ chv_update_pll(crtc, &pipe_config);
6062+ chv_prepare_pll(crtc, &pipe_config);
6063+ chv_enable_pll(crtc, &pipe_config);
6064+ } else {
6065+ vlv_update_pll(crtc, &pipe_config);
6066+ vlv_prepare_pll(crtc, &pipe_config);
6067+ vlv_enable_pll(crtc, &pipe_config);
6068+ }
6069+}
6070+
6071+/**
6072+ * vlv_force_pll_off - forcibly disable just the PLL
6073+ * @dev_priv: i915 private structure
6074+ * @pipe: pipe PLL to disable
6075+ *
6076+ * Disable the PLL for @pipe. To be used in cases where we need
6077+ * the PLL enabled even when @pipe is not going to be enabled.
6078+ */
6079+void vlv_force_pll_off(struct drm_device *dev, enum pipe pipe)
6080+{
6081+ if (IS_CHERRYVIEW(dev))
6082+ chv_disable_pll(to_i915(dev), pipe);
6083+ else
6084+ vlv_disable_pll(to_i915(dev), pipe);
6085+}
6086+
59456087 static void i9xx_update_pll(struct intel_crtc *crtc,
59466088 intel_clock_t *reduced_clock,
59476089 int num_connectors)
@@ -5950,29 +6092,29 @@ static void i9xx_update_pll(struct intel_crtc *crtc, · 2 unmodified lines
59506092 struct drm_i915_private *dev_priv = dev->dev_private;
59516093 u32 dpll;
59526094 bool is_sdvo;
5953− struct dpll *clock = &crtc->config.dpll;
6095+ struct dpll *clock = &crtc->new_config->dpll;
59546096
59556097 i9xx_update_pll_dividers(crtc, reduced_clock);
59566098
5957− is_sdvo = intel_pipe_has_type(crtc, INTEL_OUTPUT_SDVO) ||
5958− intel_pipe_has_type(crtc, INTEL_OUTPUT_HDMI);
6099+ is_sdvo = intel_pipe_will_have_type(crtc, INTEL_OUTPUT_SDVO) ||
6100+ intel_pipe_will_have_type(crtc, INTEL_OUTPUT_HDMI);
59596101
59606102 dpll = DPLL_VGA_MODE_DIS;
59616103
5962− if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS))
6104+ if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_LVDS))
59636105 dpll |= DPLLB_MODE_LVDS;
59646106 else
59656107 dpll |= DPLLB_MODE_DAC_SERIAL;
59666108
59676109 if (IS_I945G(dev) || IS_I945GM(dev) || IS_G33(dev)) {
5968− dpll |= (crtc->config.pixel_multiplier - 1)
6110+ dpll |= (crtc->new_config->pixel_multiplier - 1)
59696111 << SDVO_MULTIPLIER_SHIFT_HIRES;
59706112 }
59716113
59726114 if (is_sdvo)
59736115 dpll |= DPLL_SDVO_HIGH_SPEED;
59746116
5975− if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT))
6117+ if (crtc->new_config->has_dp_encoder)
59766118 dpll |= DPLL_SDVO_HIGH_SPEED;
59776119
59786120 /* compute bitmask from p1 value */
@@ -6000,21 +6142,21 @@ static void i9xx_update_pll(struct intel_crtc *crtc, · 21 unmodified lines
60006142 if (INTEL_INFO(dev)->gen >= 4)
60016143 dpll |= (6 << PLL_LOAD_PULSE_PHASE_SHIFT);
60026144
6003− if (crtc->config.sdvo_tv_clock)
6145+ if (crtc->new_config->sdvo_tv_clock)
60046146 dpll |= PLL_REF_INPUT_TVCLKINBC;
6005− else if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS) &&
6147+ else if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_LVDS) &&
60066148 intel_panel_use_ssc(dev_priv) && num_connectors < 2)
60076149 dpll |= PLLB_REF_INPUT_SPREADSPECTRUMIN;
60086150 else
60096151 dpll |= PLL_REF_INPUT_DREFCLK;
60106152
60116153 dpll |= DPLL_VCO_ENABLE;
6012− crtc->config.dpll_hw_state.dpll = dpll;
6154+ crtc->new_config->dpll_hw_state.dpll = dpll;
60136155
60146156 if (INTEL_INFO(dev)->gen >= 4) {
6015− u32 dpll_md = (crtc->config.pixel_multiplier - 1)
6157+ u32 dpll_md = (crtc->new_config->pixel_multiplier - 1)
60166158 << DPLL_MD_UDI_MULTIPLIER_SHIFT;
6017− crtc->config.dpll_hw_state.dpll_md = dpll_md;
6159+ crtc->new_config->dpll_hw_state.dpll_md = dpll_md;
60186160 }
60196161 }
60206162
@@ -6025,13 +6167,13 @@ static void i8xx_update_pll(struct intel_crtc *crtc, · 4 unmodified lines
60256167 struct drm_device *dev = crtc->base.dev;
60266168 struct drm_i915_private *dev_priv = dev->dev_private;
60276169 u32 dpll;
6028− struct dpll *clock = &crtc->config.dpll;
6170+ struct dpll *clock = &crtc->new_config->dpll;
60296171
60306172 i9xx_update_pll_dividers(crtc, reduced_clock);
60316173
60326174 dpll = DPLL_VGA_MODE_DIS;
60336175
6034− if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) {
6176+ if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_LVDS)) {
60356177 dpll |= (1 << (clock->p1 - 1)) << DPLL_FPA01_P1_POST_DIV_SHIFT;
60366178 } else {
60376179 if (clock->p1 == 2)
@@ -6042,17 +6184,17 @@ static void i8xx_update_pll(struct intel_crtc *crtc, · 4 unmodified lines
60426184 dpll |= PLL_P2_DIVIDE_BY_4;
60436185 }
60446186
6045− if (!IS_I830(dev) && intel_pipe_has_type(crtc, INTEL_OUTPUT_DVO))
6187+ if (!IS_I830(dev) && intel_pipe_will_have_type(crtc, INTEL_OUTPUT_DVO))
60466188 dpll |= DPLL_DVO_2X_MODE;
60476189
6048− if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS) &&
6190+ if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_LVDS) &&
60496191 intel_panel_use_ssc(dev_priv) && num_connectors < 2)
60506192 dpll |= PLLB_REF_INPUT_SPREADSPECTRUMIN;
60516193 else
60526194 dpll |= PLL_REF_INPUT_DREFCLK;
60536195
60546196 dpll |= DPLL_VCO_ENABLE;
6055− crtc->config.dpll_hw_state.dpll = dpll;
6197+ crtc->new_config->dpll_hw_state.dpll = dpll;
60566198 }
60576199
60586200 static void intel_set_pipe_timings(struct intel_crtc *intel_crtc)
@@ -6248,9 +6390,7 @@ static void i9xx_set_pipeconf(struct intel_crtc *intel_crtc) · 189 unmodified lines
62486390 POSTING_READ(PIPECONF(intel_crtc->pipe));
62496391 }
62506392
6251−static int i9xx_crtc_mode_set(struct intel_crtc *crtc,
6252− int x, int y,
6253− struct drm_framebuffer *fb)
6393+static int i9xx_crtc_compute_clock(struct intel_crtc *crtc)
62546394 {
62556395 struct drm_device *dev = crtc->base.dev;
62566396 struct drm_i915_private *dev_priv = dev->dev_private;
@@ -6261,7 +6401,10 @@ static int i9xx_crtc_mode_set(struct intel_crtc *crtc, · 4 unmodified lines
62616401 struct intel_encoder *encoder;
62626402 const intel_limit_t *limit;
62636403
6264− for_each_encoder_on_crtc(dev, &crtc->base, encoder) {
6404+ for_each_intel_encoder(dev, encoder) {
6405+ if (encoder->new_crtc != crtc)
6406+ continue;
6407+
62656408 switch (encoder->type) {
62666409 case INTEL_OUTPUT_LVDS:
62676410 is_lvds = true;
@@ -6269,6 +6412,8 @@ static int i9xx_crtc_mode_set(struct intel_crtc *crtc, · 1 unmodified line
62696412 case INTEL_OUTPUT_DSI:
62706413 is_dsi = true;
62716414 break;
6415+ default:
6416+ break;
62726417 }
62736418
62746419 num_connectors++;
@@ -6277,7 +6422,7 @@ static int i9xx_crtc_mode_set(struct intel_crtc *crtc, · 2 unmodified lines
62776422 if (is_dsi)
62786423 return 0;
62796424
6280− if (!crtc->config.clock_set) {
6425+ if (!crtc->new_config->clock_set) {
62816426 refclk = i9xx_get_refclk(crtc, num_connectors);
62826427
62836428 /*
@@ -6288,7 +6433,7 @@ static int i9xx_crtc_mode_set(struct intel_crtc *crtc, · 4 unmodified lines
62886433 */
62896434 limit = intel_limit(crtc, refclk);
62906435 ok = dev_priv->display.find_dpll(limit, crtc,
6291− crtc->config.port_clock,
6436+ crtc->new_config->port_clock,
62926437 refclk, NULL, &clock);
62936438 if (!ok) {
62946439 DRM_ERROR("Couldn't find PLL settings for mode!\n");
@@ -6309,11 +6454,11 @@ static int i9xx_crtc_mode_set(struct intel_crtc *crtc, · 14 unmodified lines
63096454 &reduced_clock);
63106455 }
63116456 /* Compat-code for transition, will disappear. */
6312− crtc->config.dpll.n = clock.n;
6313− crtc->config.dpll.m1 = clock.m1;
6314− crtc->config.dpll.m2 = clock.m2;
6315− crtc->config.dpll.p1 = clock.p1;
6316− crtc->config.dpll.p2 = clock.p2;
6457+ crtc->new_config->dpll.n = clock.n;
6458+ crtc->new_config->dpll.m1 = clock.m1;
6459+ crtc->new_config->dpll.m2 = clock.m2;
6460+ crtc->new_config->dpll.p1 = clock.p1;
6461+ crtc->new_config->dpll.p2 = clock.p2;
63176462 }
63186463
63196464 if (IS_GEN2(dev)) {
@@ -6321,9 +6466,9 @@ static int i9xx_crtc_mode_set(struct intel_crtc *crtc, · 1 unmodified line
63216466 has_reduced_clock ? &reduced_clock : NULL,
63226467 num_connectors);
63236468 } else if (IS_CHERRYVIEW(dev)) {
6324− chv_update_pll(crtc);
6469+ chv_update_pll(crtc, crtc->new_config);
63256470 } else if (IS_VALLEYVIEW(dev)) {
6326− vlv_update_pll(crtc);
6471+ vlv_update_pll(crtc, crtc->new_config);
63276472 } else {
63286473 i9xx_update_pll(crtc,
63296474 has_reduced_clock ? &reduced_clock : NULL,
@@ -6597,6 +6742,8 @@ static void ironlake_init_pch_refclk(struct drm_device *dev) · 267 unmodified lines
65976742 if (enc_to_dig_port(&encoder->base)->port == PORT_A)
65986743 has_cpu_edp = true;
65996744 break;
6745+ default:
6746+ break;
66006747 }
66016748 }
66026749
@@ -6901,6 +7048,8 @@ static void lpt_init_pch_refclk(struct drm_device *dev) · 298 unmodified lines
69017048 case INTEL_OUTPUT_ANALOG:
69027049 has_vga = true;
69037050 break;
7051+ default:
7052+ break;
69047053 }
69057054 }
69067055
@@ -6929,11 +7078,16 @@ static int ironlake_get_refclk(struct drm_crtc *crtc) · 22 unmodified lines
69297078 int num_connectors = 0;
69307079 bool is_lvds = false;
69317080
6932− for_each_encoder_on_crtc(dev, crtc, encoder) {
7081+ for_each_intel_encoder(dev, encoder) {
7082+ if (encoder->new_crtc != to_intel_crtc(crtc))
7083+ continue;
7084+
69337085 switch (encoder->type) {
69347086 case INTEL_OUTPUT_LVDS:
69357087 is_lvds = true;
69367088 break;
7089+ default:
7090+ break;
69377091 }
69387092 num_connectors++;
69397093 }
@@ -7118,7 +7272,7 @@ static bool ironlake_compute_clocks(struct drm_crtc *crtc, · 178 unmodified lines
71187272 const intel_limit_t *limit;
71197273 bool ret, is_lvds = false;
71207274
7121− is_lvds = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_LVDS);
7275+ is_lvds = intel_pipe_will_have_type(intel_crtc, INTEL_OUTPUT_LVDS);
71227276
71237277 refclk = ironlake_get_refclk(crtc);
71247278
@@ -7129,7 +7283,7 @@ static bool ironlake_compute_clocks(struct drm_crtc *crtc, · 4 unmodified lines
71297283 */
71307284 limit = intel_limit(intel_crtc, refclk);
71317285 ret = dev_priv->display.find_dpll(limit, intel_crtc,
7132− intel_crtc->config.port_clock,
7286+ intel_crtc->new_config->port_clock,
71337287 refclk, NULL, clock);
71347288 if (!ret)
71357289 return false;
@@ -7179,7 +7333,10 @@ static uint32_t ironlake_compute_dpll(struct intel_crtc *intel_crtc, · 43 unmodified lines
71797333 int factor, num_connectors = 0;
71807334 bool is_lvds = false, is_sdvo = false;
71817335
7182− for_each_encoder_on_crtc(dev, crtc, intel_encoder) {
7336+ for_each_intel_encoder(dev, intel_encoder) {
7337+ if (intel_encoder->new_crtc != to_intel_crtc(crtc))
7338+ continue;
7339+
71837340 switch (intel_encoder->type) {
71847341 case INTEL_OUTPUT_LVDS:
71857342 is_lvds = true;
@@ -7188,6 +7345,8 @@ static uint32_t ironlake_compute_dpll(struct intel_crtc *intel_crtc, · 2 unmodified lines
71887345 case INTEL_OUTPUT_HDMI:
71897346 is_sdvo = true;
71907347 break;
7348+ default:
7349+ break;
71917350 }
71927351
71937352 num_connectors++;
@@ -7200,10 +7359,10 @@ static uint32_t ironlake_compute_dpll(struct intel_crtc *intel_crtc, · 6 unmodified lines
72007359 dev_priv->vbt.lvds_ssc_freq == 100000) ||
72017360 (HAS_PCH_IBX(dev) && intel_is_dual_link_lvds(dev)))
72027361 factor = 25;
7203− } else if (intel_crtc->config.sdvo_tv_clock)
7362+ } else if (intel_crtc->new_config->sdvo_tv_clock)
72047363 factor = 20;
72057364
7206− if (ironlake_needs_fb_cb_tune(&intel_crtc->config.dpll, factor))
7365+ if (ironlake_needs_fb_cb_tune(&intel_crtc->new_config->dpll, factor))
72077366 *fp |= FP_CB_TUNE;
72087367
72097368 if (fp2 && (reduced_clock->m < factor * reduced_clock->n))
@@ -7216,20 +7375,20 @@ static uint32_t ironlake_compute_dpll(struct intel_crtc *intel_crtc, · 6 unmodified lines
72167375 else
72177376 dpll |= DPLLB_MODE_DAC_SERIAL;
72187377
7219− dpll |= (intel_crtc->config.pixel_multiplier - 1)
7378+ dpll |= (intel_crtc->new_config->pixel_multiplier - 1)
72207379 << PLL_REF_SDVO_HDMI_MULTIPLIER_SHIFT;
72217380
72227381 if (is_sdvo)
72237382 dpll |= DPLL_SDVO_HIGH_SPEED;
7224− if (intel_crtc->config.has_dp_encoder)
7383+ if (intel_crtc->new_config->has_dp_encoder)
72257384 dpll |= DPLL_SDVO_HIGH_SPEED;
72267385
72277386 /* compute bitmask from p1 value */
7228− dpll |= (1 << (intel_crtc->config.dpll.p1 - 1)) << DPLL_FPA01_P1_POST_DIV_SHIFT;
7387+ dpll |= (1 << (intel_crtc->new_config->dpll.p1 - 1)) << DPLL_FPA01_P1_POST_DIV_SHIFT;
72297388 /* also FPA1 */
7230− dpll |= (1 << (intel_crtc->config.dpll.p1 - 1)) << DPLL_FPA1_P1_POST_DIV_SHIFT;
7389+ dpll |= (1 << (intel_crtc->new_config->dpll.p1 - 1)) << DPLL_FPA1_P1_POST_DIV_SHIFT;
72317390
7232− switch (intel_crtc->config.dpll.p2) {
7391+ switch (intel_crtc->new_config->dpll.p2) {
72337392 case 5:
72347393 dpll |= DPLL_DAC_SERIAL_P2_CLOCK_DIV_5;
72357394 break;
@@ -7252,9 +7411,7 @@ static uint32_t ironlake_compute_dpll(struct intel_crtc *intel_crtc, · 16 unmodified lines
72527411 return dpll | DPLL_VCO_ENABLE;
72537412 }
72547413
7255−static int ironlake_crtc_mode_set(struct intel_crtc *crtc,
7256− int x, int y,
7257− struct drm_framebuffer *fb)
7414+static int ironlake_crtc_compute_clock(struct intel_crtc *crtc)
72587415 {
72597416 struct drm_device *dev = crtc->base.dev;
72607417 intel_clock_t clock, reduced_clock;
@@ -7270,22 +7427,22 @@ static int ironlake_crtc_mode_set(struct intel_crtc *crtc, · 9 unmodified lines
72707427
72717428 ok = ironlake_compute_clocks(&crtc->base, &clock,
72727429 &has_reduced_clock, &reduced_clock);
7273− if (!ok && !crtc->config.clock_set) {
7430+ if (!ok && !crtc->new_config->clock_set) {
72747431 DRM_ERROR("Couldn't find PLL settings for mode!\n");
72757432 return -EINVAL;
72767433 }
72777434 /* Compat-code for transition, will disappear. */
7278− if (!crtc->config.clock_set) {
7279− crtc->config.dpll.n = clock.n;
7280− crtc->config.dpll.m1 = clock.m1;
7281− crtc->config.dpll.m2 = clock.m2;
7282− crtc->config.dpll.p1 = clock.p1;
7283− crtc->config.dpll.p2 = clock.p2;
7435+ if (!crtc->new_config->clock_set) {
7436+ crtc->new_config->dpll.n = clock.n;
7437+ crtc->new_config->dpll.m1 = clock.m1;
7438+ crtc->new_config->dpll.m2 = clock.m2;
7439+ crtc->new_config->dpll.p1 = clock.p1;
7440+ crtc->new_config->dpll.p2 = clock.p2;
72847441 }
72857442
72867443 /* CPU eDP is the only output that doesn't need a PCH PLL of its own. */
7287− if (crtc->config.has_pch_encoder) {
7288− fp = i9xx_dpll_compute_fp(&crtc->config.dpll);
7444+ if (crtc->new_config->has_pch_encoder) {
7445+ fp = i9xx_dpll_compute_fp(&crtc->new_config->dpll);
72897446 if (has_reduced_clock)
72907447 fp2 = i9xx_dpll_compute_fp(&reduced_clock);
72917448
@@ -7293,12 +7450,12 @@ static int ironlake_crtc_mode_set(struct intel_crtc *crtc, · 1 unmodified line
72937450 &fp, &reduced_clock,
72947451 has_reduced_clock ? &fp2 : NULL);
72957452
7296− crtc->config.dpll_hw_state.dpll = dpll;
7297− crtc->config.dpll_hw_state.fp0 = fp;
7453+ crtc->new_config->dpll_hw_state.dpll = dpll;
7454+ crtc->new_config->dpll_hw_state.fp0 = fp;
72987455 if (has_reduced_clock)
7299− crtc->config.dpll_hw_state.fp1 = fp2;
7456+ crtc->new_config->dpll_hw_state.fp1 = fp2;
73007457 else
7301− crtc->config.dpll_hw_state.fp1 = fp;
7458+ crtc->new_config->dpll_hw_state.fp1 = fp;
73027459
73037460 pll = intel_get_shared_dpll(crtc);
73047461 if (pll == NULL) {
@@ -7306,8 +7463,7 @@ static int ironlake_crtc_mode_set(struct intel_crtc *crtc, · 1 unmodified line
73067463 pipe_name(crtc->pipe));
73077464 return -EINVAL;
73087465 }
7309− } else
7310− intel_put_shared_dpll(crtc);
7466+ }
73117467
73127468 if (is_lvds && has_reduced_clock && i915.powersave)
73137469 crtc->lowfreq_avail = true;
@@ -7796,19 +7952,7 @@ void hsw_disable_pc8(struct drm_i915_private *dev_priv) · 482 unmodified lines
77967952 intel_prepare_ddi(dev);
77977953 }
77987954
7799−static void snb_modeset_global_resources(struct drm_device *dev)
7800−{
7801− modeset_update_crtc_power_domains(dev);
7802−}
7803−
7804−static void haswell_modeset_global_resources(struct drm_device *dev)
7805−{
7806− modeset_update_crtc_power_domains(dev);
7807−}
7808−
7809−static int haswell_crtc_mode_set(struct intel_crtc *crtc,
7810− int x, int y,
7811− struct drm_framebuffer *fb)
7955+static int haswell_crtc_compute_clock(struct intel_crtc *crtc)
78127956 {
78137957 if (!intel_ddi_pll_select(crtc))
78147958 return -EINVAL;
@@ -7940,316 +8084,6 @@ static bool haswell_get_pipe_config(struct intel_crtc *crtc, · 125 unmodified lines
79408084 return true;
79418085 }
79428086
7943−static struct {
7944− int clock;
7945− u32 config;
7946−} hdmi_audio_clock[] = {
7947− { DIV_ROUND_UP(25200 * 1000, 1001), AUD_CONFIG_PIXEL_CLOCK_HDMI_25175 },
7948− { 25200, AUD_CONFIG_PIXEL_CLOCK_HDMI_25200 }, /* default per bspec */
7949− { 27000, AUD_CONFIG_PIXEL_CLOCK_HDMI_27000 },
7950− { 27000 * 1001 / 1000, AUD_CONFIG_PIXEL_CLOCK_HDMI_27027 },
7951− { 54000, AUD_CONFIG_PIXEL_CLOCK_HDMI_54000 },
7952− { 54000 * 1001 / 1000, AUD_CONFIG_PIXEL_CLOCK_HDMI_54054 },
7953− { DIV_ROUND_UP(74250 * 1000, 1001), AUD_CONFIG_PIXEL_CLOCK_HDMI_74176 },
7954− { 74250, AUD_CONFIG_PIXEL_CLOCK_HDMI_74250 },
7955− { DIV_ROUND_UP(148500 * 1000, 1001), AUD_CONFIG_PIXEL_CLOCK_HDMI_148352 },
7956− { 148500, AUD_CONFIG_PIXEL_CLOCK_HDMI_148500 },
7957−};
7958−
7959−/* get AUD_CONFIG_PIXEL_CLOCK_HDMI_* value for mode */
7960−static u32 audio_config_hdmi_pixel_clock(struct drm_display_mode *mode)
7961−{
7962− int i;
7963−
7964− for (i = 0; i < ARRAY_SIZE(hdmi_audio_clock); i++) {
7965− if (mode->clock == hdmi_audio_clock[i].clock)
7966− break;
7967− }
7968−
7969− if (i == ARRAY_SIZE(hdmi_audio_clock)) {
7970− DRM_DEBUG_KMS("HDMI audio pixel clock setting for %d not found, falling back to defaults\n", mode->clock);
7971− i = 1;
7972− }
7973−
7974− DRM_DEBUG_KMS("Configuring HDMI audio for pixel clock %d (0x%08x)\n",
7975− hdmi_audio_clock[i].clock,
7976− hdmi_audio_clock[i].config);
7977−
7978− return hdmi_audio_clock[i].config;
7979−}
7980−
7981−static bool intel_eld_uptodate(struct drm_connector *connector,
7982− int reg_eldv, uint32_t bits_eldv,
7983− int reg_elda, uint32_t bits_elda,
7984− int reg_edid)
7985−{
7986− struct drm_i915_private *dev_priv = connector->dev->dev_private;
7987− uint8_t *eld = connector->eld;
7988− uint32_t i;
7989−
7990− i = I915_READ(reg_eldv);
7991− i &= bits_eldv;
7992−
7993− if (!eld[0])
7994− return !i;
7995−
7996− if (!i)
7997− return false;
7998−
7999− i = I915_READ(reg_elda);
8000− i &= ~bits_elda;
8001− I915_WRITE(reg_elda, i);
8002−
8003− for (i = 0; i < eld[2]; i++)
8004− if (I915_READ(reg_edid) != *((uint32_t *)eld + i))
8005− return false;
8006−
8007− return true;
8008−}
8009−
8010−static void g4x_write_eld(struct drm_connector *connector,
8011− struct drm_crtc *crtc,
8012− struct drm_display_mode *mode)
8013−{
8014− struct drm_i915_private *dev_priv = connector->dev->dev_private;
8015− uint8_t *eld = connector->eld;
8016− uint32_t eldv;
8017− uint32_t len;
8018− uint32_t i;
8019−
8020− i = I915_READ(G4X_AUD_VID_DID);
8021−
8022− if (i == INTEL_AUDIO_DEVBLC || i == INTEL_AUDIO_DEVCL)
8023− eldv = G4X_ELDV_DEVCL_DEVBLC;
8024− else
8025− eldv = G4X_ELDV_DEVCTG;
8026−
8027− if (intel_eld_uptodate(connector,
8028− G4X_AUD_CNTL_ST, eldv,
8029− G4X_AUD_CNTL_ST, G4X_ELD_ADDR,
8030− G4X_HDMIW_HDMIEDID))
8031− return;
8032−
8033− i = I915_READ(G4X_AUD_CNTL_ST);
8034− i &= ~(eldv | G4X_ELD_ADDR);
8035− len = (i >> 9) & 0x1f; /* ELD buffer size */
8036− I915_WRITE(G4X_AUD_CNTL_ST, i);
8037−
8038− if (!eld[0])
8039− return;
8040−
8041− len = min_t(uint8_t, eld[2], len);
8042− DRM_DEBUG_DRIVER("ELD size %d\n", len);
8043− for (i = 0; i < len; i++)
8044− I915_WRITE(G4X_HDMIW_HDMIEDID, *((uint32_t *)eld + i));
8045−
8046− i = I915_READ(G4X_AUD_CNTL_ST);
8047− i |= eldv;
8048− I915_WRITE(G4X_AUD_CNTL_ST, i);
8049−}
8050−
8051−static void haswell_write_eld(struct drm_connector *connector,
8052− struct drm_crtc *crtc,
8053− struct drm_display_mode *mode)
8054−{
8055− struct drm_i915_private *dev_priv = connector->dev->dev_private;
8056− struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
8057− uint8_t *eld = connector->eld;
8058− uint32_t eldv;
8059− uint32_t i;
8060− int len;
8061− int pipe = to_intel_crtc(crtc)->pipe;
8062− int tmp;
8063−
8064− int hdmiw_hdmiedid = HSW_AUD_EDID_DATA(pipe);
8065− int aud_cntl_st = HSW_AUD_DIP_ELD_CTRL(pipe);
8066− int aud_config = HSW_AUD_CFG(pipe);
8067− int aud_cntrl_st2 = HSW_AUD_PIN_ELD_CP_VLD;
8068−
8069− /* Audio output enable */
8070− DRM_DEBUG_DRIVER("HDMI audio: enable codec\n");
8071− tmp = I915_READ(aud_cntrl_st2);
8072− tmp |= (AUDIO_OUTPUT_ENABLE_A << (pipe * 4));
8073− I915_WRITE(aud_cntrl_st2, tmp);
8074− POSTING_READ(aud_cntrl_st2);
8075−
8076− assert_pipe_disabled(dev_priv, to_intel_crtc(crtc)->pipe);
8077−
8078− /* Set ELD valid state */
8079− tmp = I915_READ(aud_cntrl_st2);
8080− DRM_DEBUG_DRIVER("HDMI audio: pin eld vld status=0x%08x\n", tmp);
8081− tmp |= (AUDIO_ELD_VALID_A << (pipe * 4));
8082− I915_WRITE(aud_cntrl_st2, tmp);
8083− tmp = I915_READ(aud_cntrl_st2);
8084− DRM_DEBUG_DRIVER("HDMI audio: eld vld status=0x%08x\n", tmp);
8085−
8086− /* Enable HDMI mode */
8087− tmp = I915_READ(aud_config);
8088− DRM_DEBUG_DRIVER("HDMI audio: audio conf: 0x%08x\n", tmp);
8089− /* clear N_programing_enable and N_value_index */
8090− tmp &= ~(AUD_CONFIG_N_VALUE_INDEX | AUD_CONFIG_N_PROG_ENABLE);
8091− I915_WRITE(aud_config, tmp);
8092−
8093− DRM_DEBUG_DRIVER("ELD on pipe %c\n", pipe_name(pipe));
8094−
8095− eldv = AUDIO_ELD_VALID_A << (pipe * 4);
8096−
8097− if (intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DISPLAYPORT)) {
8098− DRM_DEBUG_DRIVER("ELD: DisplayPort detected\n");
8099− eld[5] |= (1 << 2); /* Conn_Type, 0x1 = DisplayPort */
8100− I915_WRITE(aud_config, AUD_CONFIG_N_VALUE_INDEX); /* 0x1 = DP */
8101− } else {
8102− I915_WRITE(aud_config, audio_config_hdmi_pixel_clock(mode));
8103− }
8104−
8105− if (intel_eld_uptodate(connector,
8106− aud_cntrl_st2, eldv,
8107− aud_cntl_st, IBX_ELD_ADDRESS,
8108− hdmiw_hdmiedid))
8109− return;
8110−
8111− i = I915_READ(aud_cntrl_st2);
8112− i &= ~eldv;
8113− I915_WRITE(aud_cntrl_st2, i);
8114−
8115− if (!eld[0])
8116− return;
8117−
8118− i = I915_READ(aud_cntl_st);
8119− i &= ~IBX_ELD_ADDRESS;
8120− I915_WRITE(aud_cntl_st, i);
8121− i = (i >> 29) & DIP_PORT_SEL_MASK; /* DIP_Port_Select, 0x1 = PortB */
8122− DRM_DEBUG_DRIVER("port num:%d\n", i);
8123−
8124− len = min_t(uint8_t, eld[2], 21); /* 84 bytes of hw ELD buffer */
8125− DRM_DEBUG_DRIVER("ELD size %d\n", len);
8126− for (i = 0; i < len; i++)
8127− I915_WRITE(hdmiw_hdmiedid, *((uint32_t *)eld + i));
8128−
8129− i = I915_READ(aud_cntrl_st2);
8130− i |= eldv;
8131− I915_WRITE(aud_cntrl_st2, i);
8132−
8133−}
8134−
8135−static void ironlake_write_eld(struct drm_connector *connector,
8136− struct drm_crtc *crtc,
8137− struct drm_display_mode *mode)
8138−{
8139− struct drm_i915_private *dev_priv = connector->dev->dev_private;
8140− struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
8141− uint8_t *eld = connector->eld;
8142− uint32_t eldv;
8143− uint32_t i;
8144− int len;
8145− int hdmiw_hdmiedid;
8146− int aud_config;
8147− int aud_cntl_st;
8148− int aud_cntrl_st2;
8149− int pipe = to_intel_crtc(crtc)->pipe;
8150−
8151− if (HAS_PCH_IBX(connector->dev)) {
8152− hdmiw_hdmiedid = IBX_HDMIW_HDMIEDID(pipe);
8153− aud_config = IBX_AUD_CFG(pipe);
8154− aud_cntl_st = IBX_AUD_CNTL_ST(pipe);
8155− aud_cntrl_st2 = IBX_AUD_CNTL_ST2;
8156− } else if (IS_VALLEYVIEW(connector->dev)) {
8157− hdmiw_hdmiedid = VLV_HDMIW_HDMIEDID(pipe);
8158− aud_config = VLV_AUD_CFG(pipe);
8159− aud_cntl_st = VLV_AUD_CNTL_ST(pipe);
8160− aud_cntrl_st2 = VLV_AUD_CNTL_ST2;
8161− } else {
8162− hdmiw_hdmiedid = CPT_HDMIW_HDMIEDID(pipe);
8163− aud_config = CPT_AUD_CFG(pipe);
8164− aud_cntl_st = CPT_AUD_CNTL_ST(pipe);
8165− aud_cntrl_st2 = CPT_AUD_CNTRL_ST2;
8166− }
8167−
8168− DRM_DEBUG_DRIVER("ELD on pipe %c\n", pipe_name(pipe));
8169−
8170− if (IS_VALLEYVIEW(connector->dev)) {
8171− struct intel_encoder *intel_encoder;
8172− struct intel_digital_port *intel_dig_port;
8173−
8174− intel_encoder = intel_attached_encoder(connector);
8175− intel_dig_port = enc_to_dig_port(&intel_encoder->base);
8176− i = intel_dig_port->port;
8177− } else {
8178− i = I915_READ(aud_cntl_st);
8179− i = (i >> 29) & DIP_PORT_SEL_MASK;
8180− /* DIP_Port_Select, 0x1 = PortB */
8181− }
8182−
8183− if (!i) {
8184− DRM_DEBUG_DRIVER("Audio directed to unknown port\n");
8185− /* operate blindly on all ports */
8186− eldv = IBX_ELD_VALIDB;
8187− eldv |= IBX_ELD_VALIDB << 4;
8188− eldv |= IBX_ELD_VALIDB << 8;
8189− } else {
8190− DRM_DEBUG_DRIVER("ELD on port %c\n", port_name(i));
8191− eldv = IBX_ELD_VALIDB << ((i - 1) * 4);
8192− }
8193−
8194− if (intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DISPLAYPORT)) {
8195− DRM_DEBUG_DRIVER("ELD: DisplayPort detected\n");
8196− eld[5] |= (1 << 2); /* Conn_Type, 0x1 = DisplayPort */
8197− I915_WRITE(aud_config, AUD_CONFIG_N_VALUE_INDEX); /* 0x1 = DP */
8198− } else {
8199− I915_WRITE(aud_config, audio_config_hdmi_pixel_clock(mode));
8200− }
8201−
8202− if (intel_eld_uptodate(connector,
8203− aud_cntrl_st2, eldv,
8204− aud_cntl_st, IBX_ELD_ADDRESS,
8205− hdmiw_hdmiedid))
8206− return;
8207−
8208− i = I915_READ(aud_cntrl_st2);
8209− i &= ~eldv;
8210− I915_WRITE(aud_cntrl_st2, i);
8211−
8212− if (!eld[0])
8213− return;
8214−
8215− i = I915_READ(aud_cntl_st);
8216− i &= ~IBX_ELD_ADDRESS;
8217− I915_WRITE(aud_cntl_st, i);
8218−
8219− len = min_t(uint8_t, eld[2], 21); /* 84 bytes of hw ELD buffer */
8220− DRM_DEBUG_DRIVER("ELD size %d\n", len);
8221− for (i = 0; i < len; i++)
8222− I915_WRITE(hdmiw_hdmiedid, *((uint32_t *)eld + i));
8223−
8224− i = I915_READ(aud_cntrl_st2);
8225− i |= eldv;
8226− I915_WRITE(aud_cntrl_st2, i);
8227−}
8228−
8229−void intel_write_eld(struct drm_encoder *encoder,
8230− struct drm_display_mode *mode)
8231−{
8232− struct drm_crtc *crtc = encoder->crtc;
8233− struct drm_connector *connector;
8234− struct drm_device *dev = encoder->dev;
8235− struct drm_i915_private *dev_priv = dev->dev_private;
8236−
8237− connector = drm_select_eld(encoder, mode);
8238− if (!connector)
8239− return;
8240−
8241− DRM_DEBUG_DRIVER("ELD on [CONNECTOR:%d:%s], [ENCODER:%d:%s]\n",
8242− connector->base.id,
8243− connector->name,
8244− connector->encoder->base.id,
8245− connector->encoder->name);
8246−
8247− connector->eld[6] = drm_av_sync_delay(connector, mode) / 2;
8248−
8249− if (dev_priv->display.write_eld)
8250− dev_priv->display.write_eld(connector, crtc, mode);
8251−}
8252−
82538087 static void i845_update_cursor(struct drm_crtc *crtc, u32 base)
82548088 {
82558089 struct drm_device *dev = crtc->dev;
@@ -8544,9 +8378,9 @@ static int intel_crtc_cursor_set_obj(struct drm_crtc *crtc, · 288 unmodified lines
85448378 if (old_width != width)
85458379 intel_update_watermarks(crtc);
85468380 intel_crtc_update_cursor(crtc, intel_crtc->cursor_bo != NULL);
8547− }
85488381
8549− intel_frontbuffer_flip(dev, INTEL_FRONTBUFFER_CURSOR(pipe));
8382+ intel_frontbuffer_flip(dev, INTEL_FRONTBUFFER_CURSOR(pipe));
8383+ }
85508384
85518385 return 0;
85528386 fail_unpin:
@@ -9565,80 +9399,49 @@ static void intel_do_mmio_flip(struct intel_crtc *intel_crtc) · 1012 unmodified lines
95659399 struct intel_framebuffer *intel_fb =
95669400 to_intel_framebuffer(intel_crtc->base.primary->fb);
95679401 struct drm_i915_gem_object *obj = intel_fb->obj;
9402+ bool atomic_update;
9403+ u32 start_vbl_count;
95689404 u32 dspcntr;
95699405 u32 reg;
95709406
95719407 intel_mark_page_flip_active(intel_crtc);
95729408
9409+ atomic_update = intel_pipe_update_start(intel_crtc, &start_vbl_count);
9410+
95739411 reg = DSPCNTR(intel_crtc->plane);
95749412 dspcntr = I915_READ(reg);
95759413
9576− if (INTEL_INFO(dev)->gen >= 4) {
9577− if (obj->tiling_mode != I915_TILING_NONE)
9578− dspcntr |= DISPPLANE_TILED;
9579− else
9580− dspcntr &= ~DISPPLANE_TILED;
9581− }
9414+ if (obj->tiling_mode != I915_TILING_NONE)
9415+ dspcntr |= DISPPLANE_TILED;
9416+ else
9417+ dspcntr &= ~DISPPLANE_TILED;
9418+
95829419 I915_WRITE(reg, dspcntr);
95839420
95849421 I915_WRITE(DSPSURF(intel_crtc->plane),
95859422 intel_crtc->unpin_work->gtt_offset);
95869423 POSTING_READ(DSPSURF(intel_crtc->plane));
9587−}
9588−
9589−static int intel_postpone_flip(struct drm_i915_gem_object *obj)
9590−{
9591− struct intel_engine_cs *ring;
9592− int ret;
9593−
9594− lockdep_assert_held(&obj->base.dev->struct_mutex);
9595−
9596− if (!obj->last_write_seqno)
9597− return 0;
9598−
9599− ring = obj->ring;
96009424
9601− if (i915_seqno_passed(ring->get_seqno(ring, true),
9602− obj->last_write_seqno))
9603− return 0;
9604−
9605− ret = i915_gem_check_olr(ring, obj->last_write_seqno);
9606− if (ret)
9607− return ret;
9608−
9609− if (WARN_ON(!ring->irq_get(ring)))
9610− return 0;
9611−
9612− return 1;
9425+ if (atomic_update)
9426+ intel_pipe_update_end(intel_crtc, start_vbl_count);
96139427 }
96149428
9615−void intel_notify_mmio_flip(struct intel_engine_cs *ring)
9429+static void intel_mmio_flip_work_func(struct work_struct *work)
96169430 {
9617− struct drm_i915_private *dev_priv = to_i915(ring->dev);
9618− struct intel_crtc *intel_crtc;
9619− unsigned long irq_flags;
9620− u32 seqno;
9621−
9622− seqno = ring->get_seqno(ring, false);
9623−
9624− spin_lock_irqsave(&dev_priv->mmio_flip_lock, irq_flags);
9625− for_each_intel_crtc(ring->dev, intel_crtc) {
9626− struct intel_mmio_flip *mmio_flip;
9431+ struct intel_crtc *intel_crtc =
9432+ container_of(work, struct intel_crtc, mmio_flip.work);
9433+ struct intel_engine_cs *ring;
9434+ uint32_t seqno;
96279435
9628− mmio_flip = &intel_crtc->mmio_flip;
9629− if (mmio_flip->seqno == 0)
9630− continue;
9436+ seqno = intel_crtc->mmio_flip.seqno;
9437+ ring = intel_crtc->mmio_flip.ring;
96319438
9632− if (ring->id != mmio_flip->ring_id)
9633− continue;
9439+ if (seqno)
9440+ WARN_ON(__i915_wait_seqno(ring, seqno,
9441+ intel_crtc->reset_counter,
9442+ false, NULL, NULL) != 0);
96349443
9635− if (i915_seqno_passed(seqno, mmio_flip->seqno)) {
9636− intel_do_mmio_flip(intel_crtc);
9637− mmio_flip->seqno = 0;
9638− ring->irq_put(ring);
9639− }
9640− }
9641− spin_unlock_irqrestore(&dev_priv->mmio_flip_lock, irq_flags);
9444+ intel_do_mmio_flip(intel_crtc);
96429445 }
96439446
96449447 static int intel_queue_mmio_flip(struct drm_device *dev,
@@ -9648,31 +9451,13 @@ static int intel_queue_mmio_flip(struct drm_device *dev, · 3 unmodified lines
96489451 struct intel_engine_cs *ring,
96499452 uint32_t flags)
96509453 {
9651− struct drm_i915_private *dev_priv = dev->dev_private;
96529454 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
9653− int ret;
9654−
9655− if (WARN_ON(intel_crtc->mmio_flip.seqno))
9656− return -EBUSY;
9657−
9658− ret = intel_postpone_flip(obj);
9659− if (ret < 0)
9660− return ret;
9661− if (ret == 0) {
9662− intel_do_mmio_flip(intel_crtc);
9663− return 0;
9664− }
96659455
9666− spin_lock_irq(&dev_priv->mmio_flip_lock);
96679456 intel_crtc->mmio_flip.seqno = obj->last_write_seqno;
9668− intel_crtc->mmio_flip.ring_id = obj->ring->id;
9669− spin_unlock_irq(&dev_priv->mmio_flip_lock);
9457+ intel_crtc->mmio_flip.ring = obj->ring;
9458+
9459+ schedule_work(&intel_crtc->mmio_flip.work);
96709460
9671− /*
9672− * Double check to catch cases where irq fired before
9673− * mmio flip data was ready
9674− */
9675− intel_notify_mmio_flip(obj->ring);
96769461 return 0;
96779462 }
96789463
@@ -9855,7 +9640,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc, · 176 unmodified lines
98559640 ring = &dev_priv->ring[RCS];
98569641 }
98579642
9858− ret = intel_pin_and_fence_fb_obj(dev, obj, ring);
9643+ ret = intel_pin_and_fence_fb_obj(crtc->primary, fb, ring);
98599644 if (ret)
98609645 goto cleanup_pending;
98619646
@@ -10397,10 +10182,13 @@ static bool intel_crtc_in_use(struct drm_crtc *crtc) · 535 unmodified lines
1039710182 static void
1039810183 intel_modeset_update_state(struct drm_device *dev, unsigned prepare_pipes)
1039910184 {
10185+ struct drm_i915_private *dev_priv = dev->dev_private;
1040010186 struct intel_encoder *intel_encoder;
1040110187 struct intel_crtc *intel_crtc;
1040210188 struct drm_connector *connector;
1040310189
10190+ intel_shared_dpll_commit(dev_priv);
10191+
1040410192 for_each_intel_encoder(dev, intel_encoder) {
1040510193 if (!intel_encoder->base.crtc)
1040610194 continue;
@@ -10653,6 +10441,56 @@ intel_pipe_config_compare(struct drm_device *dev, · 246 unmodified lines
1065310441 return true;
1065410442 }
1065510443
10444+static void check_wm_state(struct drm_device *dev)
10445+{
10446+ struct drm_i915_private *dev_priv = dev->dev_private;
10447+ struct skl_ddb_allocation hw_ddb, *sw_ddb;
10448+ struct intel_crtc *intel_crtc;
10449+ int plane;
10450+
10451+ if (INTEL_INFO(dev)->gen < 9)
10452+ return;
10453+
10454+ skl_ddb_get_hw_state(dev_priv, &hw_ddb);
10455+ sw_ddb = &dev_priv->wm.skl_hw.ddb;
10456+
10457+ for_each_intel_crtc(dev, intel_crtc) {
10458+ struct skl_ddb_entry *hw_entry, *sw_entry;
10459+ const enum pipe pipe = intel_crtc->pipe;
10460+
10461+ if (!intel_crtc->active)
10462+ continue;
10463+
10464+ /* planes */
10465+ for_each_plane(pipe, plane) {
10466+ hw_entry = &hw_ddb.plane[pipe][plane];
10467+ sw_entry = &sw_ddb->plane[pipe][plane];
10468+
10469+ if (skl_ddb_entry_equal(hw_entry, sw_entry))
10470+ continue;
10471+
10472+ DRM_ERROR("mismatch in DDB state pipe %c plane %d "
10473+ "(expected (%u,%u), found (%u,%u))\n",
10474+ pipe_name(pipe), plane + 1,
10475+ sw_entry->start, sw_entry->end,
10476+ hw_entry->start, hw_entry->end);
10477+ }
10478+
10479+ /* cursor */
10480+ hw_entry = &hw_ddb.cursor[pipe];
10481+ sw_entry = &sw_ddb->cursor[pipe];
10482+
10483+ if (skl_ddb_entry_equal(hw_entry, sw_entry))
10484+ continue;
10485+
10486+ DRM_ERROR("mismatch in DDB state pipe %c cursor "
10487+ "(expected (%u,%u), found (%u,%u))\n",
10488+ pipe_name(pipe),
10489+ sw_entry->start, sw_entry->end,
10490+ hw_entry->start, hw_entry->end);
10491+ }
10492+}
10493+
1065610494 static void
1065710495 check_connector_state(struct drm_device *dev)
1065810496 {
@@ -10819,9 +10657,9 @@ check_shared_dpll_state(struct drm_device *dev) · 160 unmodified lines
1081910657
1082010658 active = pll->get_hw_state(dev_priv, pll, &dpll_hw_state);
1082110659
10822− WARN(pll->active > pll->refcount,
10660+ WARN(pll->active > hweight32(pll->config.crtc_mask),
1082310661 "more active pll users than references: %i vs %i\n",
10824− pll->active, pll->refcount);
10662+ pll->active, hweight32(pll->config.crtc_mask));
1082510663 WARN(pll->active && !pll->on,
1082610664 "pll in active use but not on in sw tracking\n");
1082710665 WARN(pll->on && !pll->active,
@@ -10839,11 +10677,11 @@ check_shared_dpll_state(struct drm_device *dev) · 11 unmodified lines
1083910677 WARN(pll->active != active_crtcs,
1084010678 "pll active crtcs mismatch (expected %i, found %i)\n",
1084110679 pll->active, active_crtcs);
10842− WARN(pll->refcount != enabled_crtcs,
10680+ WARN(hweight32(pll->config.crtc_mask) != enabled_crtcs,
1084310681 "pll enabled crtcs mismatch (expected %i, found %i)\n",
10844− pll->refcount, enabled_crtcs);
10682+ hweight32(pll->config.crtc_mask), enabled_crtcs);
1084510683
10846− WARN(pll->on && memcmp(&pll->hw_state, &dpll_hw_state,
10684+ WARN(pll->on && memcmp(&pll->config.hw_state, &dpll_hw_state,
1084710685 sizeof(dpll_hw_state)),
1084810686 "pll hw state mismatch\n");
1084910687 }
@@ -10852,6 +10690,7 @@ check_shared_dpll_state(struct drm_device *dev) · 2 unmodified lines
1085210690 void
1085310691 intel_modeset_check_state(struct drm_device *dev)
1085410692 {
10693+ check_wm_state(dev);
1085510694 check_connector_state(dev);
1085610695 check_encoder_state(dev);
1085710696 check_crtc_state(dev);
@@ -10961,6 +10800,22 @@ static int __intel_set_mode(struct drm_crtc *crtc, · 103 unmodified lines
1096110800 prepare_pipes &= ~disable_pipes;
1096210801 }
1096310802
10803+ if (dev_priv->display.crtc_compute_clock) {
10804+ unsigned clear_pipes = modeset_pipes | disable_pipes;
10805+
10806+ ret = intel_shared_dpll_start_config(dev_priv, clear_pipes);
10807+ if (ret)
10808+ goto done;
10809+
10810+ for_each_intel_crtc_masked(dev, modeset_pipes, intel_crtc) {
10811+ ret = dev_priv->display.crtc_compute_clock(intel_crtc);
10812+ if (ret) {
10813+ intel_shared_dpll_abort_config(dev_priv);
10814+ goto done;
10815+ }
10816+ }
10817+ }
10818+
1096410819 for_each_intel_crtc_masked(dev, disable_pipes, intel_crtc)
1096510820 intel_crtc_disable(&intel_crtc->base);
1096610821
@@ -10992,8 +10847,7 @@ static int __intel_set_mode(struct drm_crtc *crtc, · 25 unmodified lines
1099210847 * update the the output configuration. */
1099310848 intel_modeset_update_state(dev, prepare_pipes);
1099410849
10995− if (dev_priv->display.modeset_global_resources)
10996− dev_priv->display.modeset_global_resources(dev);
10850+ modeset_update_crtc_power_domains(dev);
1099710851
1099810852 /* Set up the DPLL and any encoders state that needs to adjust or depend
1099910853 * on the DPLL.
@@ -11004,9 +10858,7 @@ static int __intel_set_mode(struct drm_crtc *crtc, · 4 unmodified lines
1100410858 struct drm_i915_gem_object *obj = intel_fb_obj(fb);
1100510859
1100610860 mutex_lock(&dev->struct_mutex);
11007− ret = intel_pin_and_fence_fb_obj(dev,
11008− obj,
11009− NULL);
10861+ ret = intel_pin_and_fence_fb_obj(crtc->primary, fb, NULL);
1101010862 if (ret != 0) {
1101110863 DRM_ERROR("pin & fence failed\n");
1101210864 mutex_unlock(&dev->struct_mutex);
@@ -11021,10 +10873,6 @@ static int __intel_set_mode(struct drm_crtc *crtc, · 8 unmodified lines
1102110873 crtc->primary->fb = fb;
1102210874 crtc->x = x;
1102310875 crtc->y = y;
11024−
11025− ret = dev_priv->display.crtc_mode_set(intel_crtc, x, y, fb);
11026− if (ret)
11027− goto done;
1102810876 }
1102910877
1103010878 /* Now enable the clocks, plane, pipe, and connectors that we set up. */
@@ -11518,8 +11366,8 @@ static bool ibx_pch_dpll_get_hw_state(struct drm_i915_private *dev_priv, · 487 unmodified lines
1151811366 static void ibx_pch_dpll_mode_set(struct drm_i915_private *dev_priv,
1151911367 struct intel_shared_dpll *pll)
1152011368 {
11521− I915_WRITE(PCH_FP0(pll->id), pll->hw_state.fp0);
11522− I915_WRITE(PCH_FP1(pll->id), pll->hw_state.fp1);
11369+ I915_WRITE(PCH_FP0(pll->id), pll->config.hw_state.fp0);
11370+ I915_WRITE(PCH_FP1(pll->id), pll->config.hw_state.fp1);
1152311371 }
1152411372
1152511373 static void ibx_pch_dpll_enable(struct drm_i915_private *dev_priv,
@@ -11528,7 +11376,7 @@ static void ibx_pch_dpll_enable(struct drm_i915_private *dev_priv, · 2 unmodified lines
1152811376 /* PCH refclock must be enabled first */
1152911377 ibx_assert_pch_refclk_enabled(dev_priv);
1153011378
11531− I915_WRITE(PCH_DPLL(pll->id), pll->hw_state.dpll);
11379+ I915_WRITE(PCH_DPLL(pll->id), pll->config.hw_state.dpll);
1153211380
1153311381 /* Wait for the clocks to stabilize. */
1153411382 POSTING_READ(PCH_DPLL(pll->id));
@@ -11539,7 +11387,7 @@ static void ibx_pch_dpll_enable(struct drm_i915_private *dev_priv, · 4 unmodified lines
1153911387 *
1154011388 * So write it again.
1154111389 */
11542− I915_WRITE(PCH_DPLL(pll->id), pll->hw_state.dpll);
11390+ I915_WRITE(PCH_DPLL(pll->id), pll->config.hw_state.dpll);
1154311391 POSTING_READ(PCH_DPLL(pll->id));
1154411392 udelay(200);
1154511393 }
@@ -11646,40 +11494,25 @@ intel_check_primary_plane(struct drm_plane *plane, · 100 unmodified lines
1164611494 struct drm_rect *dest = &state->dst;
1164711495 struct drm_rect *src = &state->src;
1164811496 const struct drm_rect *clip = &state->clip;
11649− int ret;
11650−
11651− ret = drm_plane_helper_check_update(plane, crtc, fb,
11652− src, dest, clip,
11653− DRM_PLANE_HELPER_NO_SCALING,
11654− DRM_PLANE_HELPER_NO_SCALING,
11655− false, true, &state->visible);
11656− if (ret)
11657− return ret;
11658−
11659− /* no fb bound */
11660− if (state->visible && !fb) {
11661− DRM_ERROR("No FB bound\n");
11662− return -EINVAL;
11663− }
1166411497
11665− return 0;
11498+ return drm_plane_helper_check_update(plane, crtc, fb,
11499+ src, dest, clip,
11500+ DRM_PLANE_HELPER_NO_SCALING,
11501+ DRM_PLANE_HELPER_NO_SCALING,
11502+ false, true, &state->visible);
1166611503 }
1166711504
1166811505 static int
11669−intel_commit_primary_plane(struct drm_plane *plane,
11670− struct intel_plane_state *state)
11506+intel_prepare_primary_plane(struct drm_plane *plane,
11507+ struct intel_plane_state *state)
1167111508 {
1167211509 struct drm_crtc *crtc = state->crtc;
1167311510 struct drm_framebuffer *fb = state->fb;
1167411511 struct drm_device *dev = crtc->dev;
11675− struct drm_i915_private *dev_priv = dev->dev_private;
1167611512 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
1167711513 enum pipe pipe = intel_crtc->pipe;
11678− struct drm_framebuffer *old_fb = plane->fb;
1167911514 struct drm_i915_gem_object *obj = intel_fb_obj(fb);
1168011515 struct drm_i915_gem_object *old_obj = intel_fb_obj(plane->fb);
11681− struct intel_plane *intel_plane = to_intel_plane(plane);
11682− struct drm_rect *src = &state->src;
1168311516 int ret;
1168411517
1168511518 intel_crtc_wait_for_pending_flips(crtc);
@@ -11689,9 +11522,9 @@ intel_commit_primary_plane(struct drm_plane *plane, · 3 unmodified lines
1168911522 return -EBUSY;
1169011523 }
1169111524
11692− if (plane->fb != fb) {
11525+ if (old_obj != obj) {
1169311526 mutex_lock(&dev->struct_mutex);
11694− ret = intel_pin_and_fence_fb_obj(dev, obj, NULL);
11527+ ret = intel_pin_and_fence_fb_obj(plane, fb, NULL);
1169511528 if (ret == 0)
1169611529 i915_gem_track_fb(old_obj, obj,
1169711530 INTEL_FRONTBUFFER_PRIMARY(pipe));
@@ -11702,6 +11535,25 @@ intel_commit_primary_plane(struct drm_plane *plane, · 4 unmodified lines
1170211535 }
1170311536 }
1170411537
11538+ return 0;
11539+}
11540+
11541+static void
11542+intel_commit_primary_plane(struct drm_plane *plane,
11543+ struct intel_plane_state *state)
11544+{
11545+ struct drm_crtc *crtc = state->crtc;
11546+ struct drm_framebuffer *fb = state->fb;
11547+ struct drm_device *dev = crtc->dev;
11548+ struct drm_i915_private *dev_priv = dev->dev_private;
11549+ struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
11550+ enum pipe pipe = intel_crtc->pipe;
11551+ struct drm_framebuffer *old_fb = plane->fb;
11552+ struct drm_i915_gem_object *obj = intel_fb_obj(fb);
11553+ struct drm_i915_gem_object *old_obj = intel_fb_obj(plane->fb);
11554+ struct intel_plane *intel_plane = to_intel_plane(plane);
11555+ struct drm_rect *src = &state->src;
11556+
1170511557 crtc->primary->fb = fb;
1170611558 crtc->x = src->x1;
1170711559 crtc->y = src->y1;
@@ -11778,8 +11630,6 @@ intel_commit_primary_plane(struct drm_plane *plane, · 70 unmodified lines
1177811630 intel_unpin_fb_obj(old_obj);
1177911631 mutex_unlock(&dev->struct_mutex);
1178011632 }
11781−
11782− return 0;
1178311633 }
1178411634
1178511635 static int
@@ -11820,6 +11670,10 @@ intel_primary_plane_setplane(struct drm_plane *plane, struct drm_crtc *crtc, · 34 unmodified lines
1182011670 if (ret)
1182111671 return ret;
1182211672
11673+ ret = intel_prepare_primary_plane(plane, &state);
11674+ if (ret)
11675+ return ret;
11676+
1182311677 intel_commit_primary_plane(plane, &state);
1182411678
1182511679 return 0;
@@ -11961,12 +11815,24 @@ intel_commit_cursor_plane(struct drm_plane *plane, · 135 unmodified lines
1196111815 struct drm_crtc *crtc = state->crtc;
1196211816 struct drm_framebuffer *fb = state->fb;
1196311817 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
11818+ struct intel_plane *intel_plane = to_intel_plane(plane);
1196411819 struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb);
1196511820 struct drm_i915_gem_object *obj = intel_fb->obj;
1196611821 int crtc_w, crtc_h;
1196711822
1196811823 crtc->cursor_x = state->orig_dst.x1;
1196911824 crtc->cursor_y = state->orig_dst.y1;
11825+
11826+ intel_plane->crtc_x = state->orig_dst.x1;
11827+ intel_plane->crtc_y = state->orig_dst.y1;
11828+ intel_plane->crtc_w = drm_rect_width(&state->orig_dst);
11829+ intel_plane->crtc_h = drm_rect_height(&state->orig_dst);
11830+ intel_plane->src_x = state->orig_src.x1;
11831+ intel_plane->src_y = state->orig_src.y1;
11832+ intel_plane->src_w = drm_rect_width(&state->orig_src);
11833+ intel_plane->src_h = drm_rect_height(&state->orig_src);
11834+ intel_plane->obj = obj;
11835+
1197011836 if (fb != crtc->cursor->fb) {
1197111837 crtc_w = drm_rect_width(&state->orig_dst);
1197211838 crtc_h = drm_rect_height(&state->orig_dst);
@@ -12117,6 +11983,8 @@ static void intel_crtc_init(struct drm_device *dev, int pipe) · 144 unmodified lines
1211711983 dev_priv->plane_to_crtc_mapping[intel_crtc->plane] = &intel_crtc->base;
1211811984 dev_priv->pipe_to_crtc_mapping[intel_crtc->pipe] = &intel_crtc->base;
1211911985
11986+ INIT_WORK(&intel_crtc->mmio_flip.work, intel_mmio_flip_work_func);
11987+
1212011988 drm_crtc_helper_add(&intel_crtc->base, &intel_helper_funcs);
1212111989
1212211990 WARN_ON(drm_crtc_index(&intel_crtc->base) != intel_crtc->pipe);
@@ -12576,7 +12444,8 @@ static void intel_init_display(struct drm_device *dev) · 453 unmodified lines
1257612444 if (HAS_DDI(dev)) {
1257712445 dev_priv->display.get_pipe_config = haswell_get_pipe_config;
1257812446 dev_priv->display.get_plane_config = ironlake_get_plane_config;
12579− dev_priv->display.crtc_mode_set = haswell_crtc_mode_set;
12447+ dev_priv->display.crtc_compute_clock =
12448+ haswell_crtc_compute_clock;
1258012449 dev_priv->display.crtc_enable = haswell_crtc_enable;
1258112450 dev_priv->display.crtc_disable = haswell_crtc_disable;
1258212451 dev_priv->display.off = ironlake_crtc_off;
@@ -12589,7 +12458,8 @@ static void intel_init_display(struct drm_device *dev) · 6 unmodified lines
1258912458 } else if (HAS_PCH_SPLIT(dev)) {
1259012459 dev_priv->display.get_pipe_config = ironlake_get_pipe_config;
1259112460 dev_priv->display.get_plane_config = ironlake_get_plane_config;
12592− dev_priv->display.crtc_mode_set = ironlake_crtc_mode_set;
12461+ dev_priv->display.crtc_compute_clock =
12462+ ironlake_crtc_compute_clock;
1259312463 dev_priv->display.crtc_enable = ironlake_crtc_enable;
1259412464 dev_priv->display.crtc_disable = ironlake_crtc_disable;
1259512465 dev_priv->display.off = ironlake_crtc_off;
@@ -12598,7 +12468,7 @@ static void intel_init_display(struct drm_device *dev) · 2 unmodified lines
1259812468 } else if (IS_VALLEYVIEW(dev)) {
1259912469 dev_priv->display.get_pipe_config = i9xx_get_pipe_config;
1260012470 dev_priv->display.get_plane_config = i9xx_get_plane_config;
12601− dev_priv->display.crtc_mode_set = i9xx_crtc_mode_set;
12471+ dev_priv->display.crtc_compute_clock = i9xx_crtc_compute_clock;
1260212472 dev_priv->display.crtc_enable = valleyview_crtc_enable;
1260312473 dev_priv->display.crtc_disable = i9xx_crtc_disable;
1260412474 dev_priv->display.off = i9xx_crtc_off;
@@ -12607,7 +12477,7 @@ static void intel_init_display(struct drm_device *dev) · 2 unmodified lines
1260712477 } else {
1260812478 dev_priv->display.get_pipe_config = i9xx_get_pipe_config;
1260912479 dev_priv->display.get_plane_config = i9xx_get_plane_config;
12610− dev_priv->display.crtc_mode_set = i9xx_crtc_mode_set;
12480+ dev_priv->display.crtc_compute_clock = i9xx_crtc_compute_clock;
1261112481 dev_priv->display.crtc_enable = i9xx_crtc_enable;
1261212482 dev_priv->display.crtc_disable = i9xx_crtc_disable;
1261312483 dev_priv->display.off = i9xx_crtc_off;
@@ -12644,35 +12514,20 @@ static void intel_init_display(struct drm_device *dev) · 30 unmodified lines
1264412514 dev_priv->display.get_display_clock_speed =
1264512515 i830_get_display_clock_speed;
1264612516
12647− if (IS_G4X(dev)) {
12648− dev_priv->display.write_eld = g4x_write_eld;
12649− } else if (IS_GEN5(dev)) {
12517+ if (IS_GEN5(dev)) {
1265012518 dev_priv->display.fdi_link_train = ironlake_fdi_link_train;
12651− dev_priv->display.write_eld = ironlake_write_eld;
1265212519 } else if (IS_GEN6(dev)) {
1265312520 dev_priv->display.fdi_link_train = gen6_fdi_link_train;
12654− dev_priv->display.write_eld = ironlake_write_eld;
12655− dev_priv->display.modeset_global_resources =
12656− snb_modeset_global_resources;
1265712521 } else if (IS_IVYBRIDGE(dev)) {
1265812522 /* FIXME: detect B0+ stepping and use auto training */
1265912523 dev_priv->display.fdi_link_train = ivb_manual_fdi_link_train;
12660− dev_priv->display.write_eld = ironlake_write_eld;
1266112524 dev_priv->display.modeset_global_resources =
1266212525 ivb_modeset_global_resources;
1266312526 } else if (IS_HASWELL(dev) || IS_BROADWELL(dev)) {
1266412527 dev_priv->display.fdi_link_train = hsw_fdi_link_train;
12665− dev_priv->display.write_eld = haswell_write_eld;
12666− dev_priv->display.modeset_global_resources =
12667− haswell_modeset_global_resources;
1266812528 } else if (IS_VALLEYVIEW(dev)) {
1266912529 dev_priv->display.modeset_global_resources =
1267012530 valleyview_modeset_global_resources;
12671− dev_priv->display.write_eld = ironlake_write_eld;
12672− } else if (INTEL_INFO(dev)->gen >= 9) {
12673− dev_priv->display.write_eld = haswell_write_eld;
12674− dev_priv->display.modeset_global_resources =
12675− haswell_modeset_global_resources;
1267612531 }
1267712532
1267812533 /* Default just returns -ENODEV to indicate unsupported */
@@ -12928,6 +12783,7 @@ void intel_modeset_init(struct drm_device *dev) · 249 unmodified lines
1292812783 return;
1292912784
1293012785 intel_init_display(dev);
12786+ intel_init_audio(dev);
1293112787
1293212788 if (IS_GEN2(dev)) {
1293312789 dev->mode_config.max_width = 2048;
@@ -13282,18 +13138,21 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev) · 348 unmodified lines
1328213138 for (i = 0; i < dev_priv->num_shared_dpll; i++) {
1328313139 struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i];
1328413140
13285− pll->on = pll->get_hw_state(dev_priv, pll, &pll->hw_state);
13141+ pll->on = pll->get_hw_state(dev_priv, pll,
13142+ &pll->config.hw_state);
1328613143 pll->active = 0;
13144+ pll->config.crtc_mask = 0;
1328713145 for_each_intel_crtc(dev, crtc) {
13288− if (crtc->active && intel_crtc_to_shared_dpll(crtc) == pll)
13146+ if (crtc->active && intel_crtc_to_shared_dpll(crtc) == pll) {
1328913147 pll->active++;
13148+ pll->config.crtc_mask |= 1 << crtc->pipe;
13149+ }
1329013150 }
13291− pll->refcount = pll->active;
1329213151
13293− DRM_DEBUG_KMS("%s hw state readout: refcount %i, on %i\n",
13294− pll->name, pll->refcount, pll->on);
13152+ DRM_DEBUG_KMS("%s hw state readout: crtc_mask 0x%08x, on %i\n",
13153+ pll->name, pll->config.crtc_mask, pll->on);
1329513154
13296− if (pll->refcount)
13155+ if (pll->config.crtc_mask)
1329713156 intel_display_power_get(dev_priv, POWER_DOMAIN_PLLS);
1329813157 }
1329913158
@@ -13383,7 +13242,9 @@ void intel_modeset_setup_hw_state(struct drm_device *dev, · 83 unmodified lines
1338313242 pll->on = false;
1338413243 }
1338513244
13386− if (HAS_PCH_SPLIT(dev))
13245+ if (IS_GEN9(dev))
13246+ skl_wm_get_hw_state(dev);
13247+ else if (HAS_PCH_SPLIT(dev))
1338713248 ilk_wm_get_hw_state(dev);
1338813249
1338913250 if (force_restore) {
@@ -13431,7 +13292,9 @@ void intel_modeset_gem_init(struct drm_device *dev) · 41 unmodified lines
1343113292 if (obj == NULL)
1343213293 continue;
1343313294
13434− if (intel_pin_and_fence_fb_obj(dev, obj, NULL)) {
13295+ if (intel_pin_and_fence_fb_obj(c->primary,
13296+ c->primary->fb,
13297+ NULL)) {
1343513298 DRM_ERROR("failed to pin boot fb on pipe %d\n",
1343613299 to_intel_crtc(c)->pipe);
1343713300 drm_framebuffer_unreference(c->primary->fb);
drivers/gpu/drm/i915/intel_dp.c+283−146
@@ -113,6 +113,9 @@ static struct intel_dp *intel_attached_dp(struct drm_connector *connector) · 112 unmodified lines
113113 static void intel_dp_link_down(struct intel_dp *intel_dp);
114114 static bool edp_panel_vdd_on(struct intel_dp *intel_dp);
115115 static void edp_panel_vdd_off(struct intel_dp *intel_dp, bool sync);
116+static void vlv_init_panel_power_sequencer(struct intel_dp *intel_dp);
117+static void vlv_steal_power_sequencer(struct drm_device *dev,
118+ enum pipe pipe);
116119
117120 int
118121 intel_dp_max_link_bw(struct intel_dp *intel_dp)
@@ -283,12 +286,10 @@ intel_hrawclk(struct drm_device *dev) · 164 unmodified lines
283286
284287 static void
285288 intel_dp_init_panel_power_sequencer(struct drm_device *dev,
286− struct intel_dp *intel_dp,
287− struct edp_power_seq *out);
289+ struct intel_dp *intel_dp);
288290 static void
289291 intel_dp_init_panel_power_sequencer_registers(struct drm_device *dev,
290− struct intel_dp *intel_dp,
291− struct edp_power_seq *out);
292+ struct intel_dp *intel_dp);
292293
293294 static void pps_lock(struct intel_dp *intel_dp)
294295 {
@@ -322,6 +323,66 @@ static void pps_unlock(struct intel_dp *intel_dp) · 27 unmodified lines
322323 intel_display_power_put(dev_priv, power_domain);
323324 }
324325
326+static void
327+vlv_power_sequencer_kick(struct intel_dp *intel_dp)
328+{
329+ struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
330+ struct drm_device *dev = intel_dig_port->base.base.dev;
331+ struct drm_i915_private *dev_priv = dev->dev_private;
332+ enum pipe pipe = intel_dp->pps_pipe;
333+ bool pll_enabled;
334+ uint32_t DP;
335+
336+ if (WARN(I915_READ(intel_dp->output_reg) & DP_PORT_EN,
337+ "skipping pipe %c power seqeuncer kick due to port %c being active\n",
338+ pipe_name(pipe), port_name(intel_dig_port->port)))
339+ return;
340+
341+ DRM_DEBUG_KMS("kicking pipe %c power sequencer for port %c\n",
342+ pipe_name(pipe), port_name(intel_dig_port->port));
343+
344+ /* Preserve the BIOS-computed detected bit. This is
345+ * supposed to be read-only.
346+ */
347+ DP = I915_READ(intel_dp->output_reg) & DP_DETECTED;
348+ DP |= DP_VOLTAGE_0_4 | DP_PRE_EMPHASIS_0;
349+ DP |= DP_PORT_WIDTH(1);
350+ DP |= DP_LINK_TRAIN_PAT_1;
351+
352+ if (IS_CHERRYVIEW(dev))
353+ DP |= DP_PIPE_SELECT_CHV(pipe);
354+ else if (pipe == PIPE_B)
355+ DP |= DP_PIPEB_SELECT;
356+
357+ pll_enabled = I915_READ(DPLL(pipe)) & DPLL_VCO_ENABLE;
358+
359+ /*
360+ * The DPLL for the pipe must be enabled for this to work.
361+ * So enable temporarily it if it's not already enabled.
362+ */
363+ if (!pll_enabled)
364+ vlv_force_pll_on(dev, pipe, IS_CHERRYVIEW(dev) ?
365+ &chv_dpll[0].dpll : &vlv_dpll[0].dpll);
366+
367+ /*
368+ * Similar magic as in intel_dp_enable_port().
369+ * We _must_ do this port enable + disable trick
370+ * to make this power seqeuencer lock onto the port.
371+ * Otherwise even VDD force bit won't work.
372+ */
373+ I915_WRITE(intel_dp->output_reg, DP);
374+ POSTING_READ(intel_dp->output_reg);
375+
376+ I915_WRITE(intel_dp->output_reg, DP | DP_PORT_EN);
377+ POSTING_READ(intel_dp->output_reg);
378+
379+ I915_WRITE(intel_dp->output_reg, DP & ~DP_PORT_EN);
380+ POSTING_READ(intel_dp->output_reg);
381+
382+ if (!pll_enabled)
383+ vlv_force_pll_off(dev, pipe);
384+}
385+
325386 static enum pipe
326387 vlv_power_sequencer_pipe(struct intel_dp *intel_dp)
327388 {
@@ -330,10 +391,13 @@ vlv_power_sequencer_pipe(struct intel_dp *intel_dp) · 2 unmodified lines
330391 struct drm_i915_private *dev_priv = dev->dev_private;
331392 struct intel_encoder *encoder;
332393 unsigned int pipes = (1 << PIPE_A) | (1 << PIPE_B);
333− struct edp_power_seq power_seq;
394+ enum pipe pipe;
334395
335396 lockdep_assert_held(&dev_priv->pps_mutex);
336397
398+ /* We should never land here with regular DP ports */
399+ WARN_ON(!is_edp(intel_dp));
400+
337401 if (intel_dp->pps_pipe != INVALID_PIPE)
338402 return intel_dp->pps_pipe;
339403
@@ -359,18 +423,26 @@ vlv_power_sequencer_pipe(struct intel_dp *intel_dp) · 19 unmodified lines
359423 * are two power sequencers and up to two eDP ports.
360424 */
361425 if (WARN_ON(pipes == 0))
362− return PIPE_A;
426+ pipe = PIPE_A;
427+ else
428+ pipe = ffs(pipes) - 1;
363429
364− intel_dp->pps_pipe = ffs(pipes) - 1;
430+ vlv_steal_power_sequencer(dev, pipe);
431+ intel_dp->pps_pipe = pipe;
365432
366433 DRM_DEBUG_KMS("picked pipe %c power sequencer for port %c\n",
367434 pipe_name(intel_dp->pps_pipe),
368435 port_name(intel_dig_port->port));
369436
370437 /* init power sequencer on this pipe and port */
371− intel_dp_init_panel_power_sequencer(dev, intel_dp, &power_seq);
372− intel_dp_init_panel_power_sequencer_registers(dev, intel_dp,
373− &power_seq);
438+ intel_dp_init_panel_power_sequencer(dev, intel_dp);
439+ intel_dp_init_panel_power_sequencer_registers(dev, intel_dp);
440+
441+ /*
442+ * Even vdd force doesn't work until we've made
443+ * the power sequencer lock in on the port.
444+ */
445+ vlv_power_sequencer_kick(intel_dp);
374446
375447 return intel_dp->pps_pipe;
376448 }
@@ -425,7 +497,6 @@ vlv_initial_power_sequencer_setup(struct intel_dp *intel_dp) · 48 unmodified lines
425497 struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
426498 struct drm_device *dev = intel_dig_port->base.base.dev;
427499 struct drm_i915_private *dev_priv = dev->dev_private;
428− struct edp_power_seq power_seq;
429500 enum port port = intel_dig_port->port;
430501
431502 lockdep_assert_held(&dev_priv->pps_mutex);
@@ -453,9 +524,8 @@ vlv_initial_power_sequencer_setup(struct intel_dp *intel_dp) · 21 unmodified lines
453524 DRM_DEBUG_KMS("initial power sequencer for port %c: pipe %c\n",
454525 port_name(port), pipe_name(intel_dp->pps_pipe));
455526
456− intel_dp_init_panel_power_sequencer(dev, intel_dp, &power_seq);
457− intel_dp_init_panel_power_sequencer_registers(dev, intel_dp,
458− &power_seq);
527+ intel_dp_init_panel_power_sequencer(dev, intel_dp);
528+ intel_dp_init_panel_power_sequencer_registers(dev, intel_dp);
459529 }
460530
461531 void vlv_power_sequencer_reset(struct drm_i915_private *dev_priv)
@@ -550,6 +620,10 @@ static bool edp_have_panel_power(struct intel_dp *intel_dp) · 88 unmodified lines
550620
551621 lockdep_assert_held(&dev_priv->pps_mutex);
552622
623+ if (IS_VALLEYVIEW(dev) &&
624+ intel_dp->pps_pipe == INVALID_PIPE)
625+ return false;
626+
553627 return (I915_READ(_pp_stat_reg(intel_dp)) & PP_ON) != 0;
554628 }
555629
@@ -560,6 +634,10 @@ static bool edp_have_panel_vdd(struct intel_dp *intel_dp) · 4 unmodified lines
560634
561635 lockdep_assert_held(&dev_priv->pps_mutex);
562636
637+ if (IS_VALLEYVIEW(dev) &&
638+ intel_dp->pps_pipe == INVALID_PIPE)
639+ return false;
640+
563641 return I915_READ(_pp_ctrl_reg(intel_dp)) & EDP_FORCE_VDD;
564642 }
565643
@@ -1246,12 +1324,8 @@ static void intel_dp_prepare(struct intel_encoder *encoder) · 680 unmodified lines
12461324 intel_dp->DP |= DP_VOLTAGE_0_4 | DP_PRE_EMPHASIS_0;
12471325 intel_dp->DP |= DP_PORT_WIDTH(intel_dp->lane_count);
12481326
1249− if (crtc->config.has_audio) {
1250− DRM_DEBUG_DRIVER("Enabling DP audio on pipe %c\n",
1251− pipe_name(crtc->pipe));
1327+ if (crtc->config.has_audio)
12521328 intel_dp->DP |= DP_AUDIO_OUTPUT_ENABLE;
1253− intel_write_eld(&encoder->base, adjusted_mode);
1254− }
12551329
12561330 /* Split out the IBX/CPU vs CPT settings */
12571331
@@ -1409,7 +1483,8 @@ static bool edp_panel_vdd_on(struct intel_dp *intel_dp) · 151 unmodified lines
14091483 power_domain = intel_display_port_power_domain(intel_encoder);
14101484 intel_display_power_get(dev_priv, power_domain);
14111485
1412− DRM_DEBUG_KMS("Turning eDP VDD on\n");
1486+ DRM_DEBUG_KMS("Turning eDP port %c VDD on\n",
1487+ port_name(intel_dig_port->port));
14131488
14141489 if (!edp_have_panel_power(intel_dp))
14151490 wait_panel_power_cycle(intel_dp);
@@ -1428,7 +1503,8 @@ static bool edp_panel_vdd_on(struct intel_dp *intel_dp) · 12 unmodified lines
14281503 * If the panel wasn't on, delay before accessing aux channel
14291504 */
14301505 if (!edp_have_panel_power(intel_dp)) {
1431− DRM_DEBUG_KMS("eDP was not running\n");
1506+ DRM_DEBUG_KMS("eDP port %c panel power wasn't enabled\n",
1507+ port_name(intel_dig_port->port));
14321508 msleep(intel_dp->panel_power_up_delay);
14331509 }
14341510
@@ -1453,7 +1529,8 @@ void intel_edp_panel_vdd_on(struct intel_dp *intel_dp) · 18 unmodified lines
14531529 vdd = edp_panel_vdd_on(intel_dp);
14541530 pps_unlock(intel_dp);
14551531
1456− WARN(!vdd, "eDP VDD already requested on\n");
1532+ WARN(!vdd, "eDP port %c VDD already requested on\n",
1533+ port_name(dp_to_dig_port(intel_dp)->port));
14571534 }
14581535
14591536 static void edp_panel_vdd_off_sync(struct intel_dp *intel_dp)
@@ -1474,7 +1551,8 @@ static void edp_panel_vdd_off_sync(struct intel_dp *intel_dp) · 14 unmodified lines
14741551 if (!edp_have_panel_vdd(intel_dp))
14751552 return;
14761553
1477− DRM_DEBUG_KMS("Turning eDP VDD off\n");
1554+ DRM_DEBUG_KMS("Turning eDP port %c VDD off\n",
1555+ port_name(intel_dig_port->port));
14781556
14791557 pp = ironlake_get_pp_control(intel_dp);
14801558 pp &= ~EDP_FORCE_VDD;
@@ -1535,7 +1613,8 @@ static void edp_panel_vdd_off(struct intel_dp *intel_dp, bool sync) · 54 unmodified lines
15351613 if (!is_edp(intel_dp))
15361614 return;
15371615
1538− WARN(!intel_dp->want_panel_vdd, "eDP VDD not forced on");
1616+ WARN(!intel_dp->want_panel_vdd, "eDP port %c VDD not forced on",
1617+ port_name(dp_to_dig_port(intel_dp)->port));
15391618
15401619 intel_dp->want_panel_vdd = false;
15411620
@@ -1545,40 +1624,25 @@ static void edp_panel_vdd_off(struct intel_dp *intel_dp, bool sync) · 3 unmodified lines
15451624 edp_panel_vdd_schedule_off(intel_dp);
15461625 }
15471626
1548−/*
1549− * Must be paired with intel_edp_panel_vdd_on().
1550− * Nested calls to these functions are not allowed since
1551− * we drop the lock. Caller must use some higher level
1552− * locking to prevent nested calls from other threads.
1553− */
1554−static void intel_edp_panel_vdd_off(struct intel_dp *intel_dp, bool sync)
1555−{
1556− if (!is_edp(intel_dp))
1557− return;
1558−
1559− pps_lock(intel_dp);
1560− edp_panel_vdd_off(intel_dp, sync);
1561− pps_unlock(intel_dp);
1562−}
1563−
1564−void intel_edp_panel_on(struct intel_dp *intel_dp)
1627+static void edp_panel_on(struct intel_dp *intel_dp)
15651628 {
15661629 struct drm_device *dev = intel_dp_to_dev(intel_dp);
15671630 struct drm_i915_private *dev_priv = dev->dev_private;
15681631 u32 pp;
15691632 u32 pp_ctrl_reg;
15701633
1634+ lockdep_assert_held(&dev_priv->pps_mutex);
1635+
15711636 if (!is_edp(intel_dp))
15721637 return;
15731638
1574− DRM_DEBUG_KMS("Turn eDP power on\n");
1575−
1576− pps_lock(intel_dp);
1639+ DRM_DEBUG_KMS("Turn eDP port %c panel power on\n",
1640+ port_name(dp_to_dig_port(intel_dp)->port));
15771641
1578− if (edp_have_panel_power(intel_dp)) {
1579− DRM_DEBUG_KMS("eDP power already on\n");
1580− goto out;
1581− }
1642+ if (WARN(edp_have_panel_power(intel_dp),
1643+ "eDP port %c panel power already on\n",
1644+ port_name(dp_to_dig_port(intel_dp)->port)))
1645+ return;
15821646
15831647 wait_panel_power_cycle(intel_dp);
15841648
@@ -1606,12 +1670,20 @@ void intel_edp_panel_on(struct intel_dp *intel_dp) · 21 unmodified lines
16061670 I915_WRITE(pp_ctrl_reg, pp);
16071671 POSTING_READ(pp_ctrl_reg);
16081672 }
1673+}
16091674
1610− out:
1675+void intel_edp_panel_on(struct intel_dp *intel_dp)
1676+{
1677+ if (!is_edp(intel_dp))
1678+ return;
1679+
1680+ pps_lock(intel_dp);
1681+ edp_panel_on(intel_dp);
16111682 pps_unlock(intel_dp);
16121683 }
16131684
1614−void intel_edp_panel_off(struct intel_dp *intel_dp)
1685+
1686+static void edp_panel_off(struct intel_dp *intel_dp)
16151687 {
16161688 struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
16171689 struct intel_encoder *intel_encoder = &intel_dig_port->base;
@@ -1621,14 +1693,16 @@ void intel_edp_panel_off(struct intel_dp *intel_dp) · 3 unmodified lines
16211693 u32 pp;
16221694 u32 pp_ctrl_reg;
16231695
1696+ lockdep_assert_held(&dev_priv->pps_mutex);
1697+
16241698 if (!is_edp(intel_dp))
16251699 return;
16261700
1627− DRM_DEBUG_KMS("Turn eDP power off\n");
1701+ DRM_DEBUG_KMS("Turn eDP port %c panel power off\n",
1702+ port_name(dp_to_dig_port(intel_dp)->port));
16281703
1629− pps_lock(intel_dp);
1630−
1631− WARN(!intel_dp->want_panel_vdd, "Need VDD to turn off panel\n");
1704+ WARN(!intel_dp->want_panel_vdd, "Need eDP port %c VDD to turn off panel\n",
1705+ port_name(dp_to_dig_port(intel_dp)->port));
16321706
16331707 pp = ironlake_get_pp_control(intel_dp);
16341708 /* We need to switch off panel power _and_ force vdd, for otherwise some
@@ -1649,7 +1723,15 @@ void intel_edp_panel_off(struct intel_dp *intel_dp) · 14 unmodified lines
16491723 /* We got a reference when we enabled the VDD. */
16501724 power_domain = intel_display_port_power_domain(intel_encoder);
16511725 intel_display_power_put(dev_priv, power_domain);
1726+}
1727+
1728+void intel_edp_panel_off(struct intel_dp *intel_dp)
1729+{
1730+ if (!is_edp(intel_dp))
1731+ return;
16521732
1733+ pps_lock(intel_dp);
1734+ edp_panel_off(intel_dp);
16531735 pps_unlock(intel_dp);
16541736 }
16551737
@@ -2368,6 +2450,10 @@ static void intel_disable_dp(struct intel_encoder *encoder) · 712 unmodified lines
23682450 {
23692451 struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base);
23702452 struct drm_device *dev = encoder->base.dev;
2453+ struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc);
2454+
2455+ if (crtc->config.has_audio)
2456+ intel_audio_codec_disable(encoder);
23712457
23722458 /* Make sure the panel is off before trying to change the mode. But also
23732459 * ensure that we have vdd while we switch off the panel. */
@@ -2522,14 +2608,23 @@ static void intel_dp_enable_port(struct intel_dp *intel_dp) · 148 unmodified lines
25222608 struct drm_device *dev = intel_dp_to_dev(intel_dp);
25232609 struct drm_i915_private *dev_priv = dev->dev_private;
25242610
2525− intel_dp->DP |= DP_PORT_EN;
2526−
25272611 /* enable with pattern 1 (as per spec) */
25282612 _intel_dp_set_link_train(intel_dp, &intel_dp->DP,
25292613 DP_TRAINING_PATTERN_1);
25302614
25312615 I915_WRITE(intel_dp->output_reg, intel_dp->DP);
25322616 POSTING_READ(intel_dp->output_reg);
2617+
2618+ /*
2619+ * Magic for VLV/CHV. We _must_ first set up the register
2620+ * without actually enabling the port, and then do another
2621+ * write to enable the port. Otherwise link training will
2622+ * fail when the power sequencer is freshly used for this port.
2623+ */
2624+ intel_dp->DP |= DP_PORT_EN;
2625+
2626+ I915_WRITE(intel_dp->output_reg, intel_dp->DP);
2627+ POSTING_READ(intel_dp->output_reg);
25332628 }
25342629
25352630 static void intel_enable_dp(struct intel_encoder *encoder)
@@ -2537,19 +2632,38 @@ static void intel_enable_dp(struct intel_encoder *encoder) · 1 unmodified line
25372632 struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base);
25382633 struct drm_device *dev = encoder->base.dev;
25392634 struct drm_i915_private *dev_priv = dev->dev_private;
2635+ struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc);
25402636 uint32_t dp_reg = I915_READ(intel_dp->output_reg);
25412637
25422638 if (WARN_ON(dp_reg & DP_PORT_EN))
25432639 return;
25442640
2641+ pps_lock(intel_dp);
2642+
2643+ if (IS_VALLEYVIEW(dev))
2644+ vlv_init_panel_power_sequencer(intel_dp);
2645+
25452646 intel_dp_enable_port(intel_dp);
2546− intel_edp_panel_vdd_on(intel_dp);
2547− intel_edp_panel_on(intel_dp);
2548− intel_edp_panel_vdd_off(intel_dp, true);
2647+
2648+ edp_panel_vdd_on(intel_dp);
2649+ edp_panel_on(intel_dp);
2650+ edp_panel_vdd_off(intel_dp, true);
2651+
2652+ pps_unlock(intel_dp);
2653+
2654+ if (IS_VALLEYVIEW(dev))
2655+ vlv_wait_port_ready(dev_priv, dp_to_dig_port(intel_dp));
2656+
25492657 intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
25502658 intel_dp_start_link_train(intel_dp);
25512659 intel_dp_complete_link_train(intel_dp);
25522660 intel_dp_stop_link_train(intel_dp);
2661+
2662+ if (crtc->config.has_audio) {
2663+ DRM_DEBUG_DRIVER("Enabling DP audio on pipe %c\n",
2664+ pipe_name(crtc->pipe));
2665+ intel_audio_codec_enable(encoder);
2666+ }
25532667 }
25542668
25552669 static void g4x_enable_dp(struct intel_encoder *encoder)
@@ -2581,6 +2695,32 @@ static void g4x_pre_enable_dp(struct intel_encoder *encoder) · 25 unmodified lines
25812695 }
25822696 }
25832697
2698+static void vlv_detach_power_sequencer(struct intel_dp *intel_dp)
2699+{
2700+ struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
2701+ struct drm_i915_private *dev_priv = intel_dig_port->base.base.dev->dev_private;
2702+ enum pipe pipe = intel_dp->pps_pipe;
2703+ int pp_on_reg = VLV_PIPE_PP_ON_DELAYS(pipe);
2704+
2705+ edp_panel_vdd_off_sync(intel_dp);
2706+
2707+ /*
2708+ * VLV seems to get confused when multiple power seqeuencers
2709+ * have the same port selected (even if only one has power/vdd
2710+ * enabled). The failure manifests as vlv_wait_port_ready() failing
2711+ * CHV on the other hand doesn't seem to mind having the same port
2712+ * selected in multiple power seqeuencers, but let's clear the
2713+ * port select always when logically disconnecting a power sequencer
2714+ * from a port.
2715+ */
2716+ DRM_DEBUG_KMS("detaching pipe %c power sequencer from port %c\n",
2717+ pipe_name(pipe), port_name(intel_dig_port->port));
2718+ I915_WRITE(pp_on_reg, 0);
2719+ POSTING_READ(pp_on_reg);
2720+
2721+ intel_dp->pps_pipe = INVALID_PIPE;
2722+}
2723+
25842724 static void vlv_steal_power_sequencer(struct drm_device *dev,
25852725 enum pipe pipe)
25862726 {
@@ -2589,6 +2729,9 @@ static void vlv_steal_power_sequencer(struct drm_device *dev, · 2 unmodified lines
25892729
25902730 lockdep_assert_held(&dev_priv->pps_mutex);
25912731
2732+ if (WARN_ON(pipe != PIPE_A && pipe != PIPE_B))
2733+ return;
2734+
25922735 list_for_each_entry(encoder, &dev->mode_config.encoder_list,
25932736 base.head) {
25942737 struct intel_dp *intel_dp;
@@ -2606,10 +2749,12 @@ static void vlv_steal_power_sequencer(struct drm_device *dev, · 11 unmodified lines
26062749 DRM_DEBUG_KMS("stealing pipe %c power sequencer from port %c\n",
26072750 pipe_name(pipe), port_name(port));
26082751
2609− /* make sure vdd is off before we steal it */
2610− edp_panel_vdd_off_sync(intel_dp);
2752+ WARN(encoder->connectors_active,
2753+ "stealing pipe %c power sequencer from active eDP port %c\n",
2754+ pipe_name(pipe), port_name(port));
26112755
2612− intel_dp->pps_pipe = INVALID_PIPE;
2756+ /* make sure vdd is off before we steal it */
2757+ vlv_detach_power_sequencer(intel_dp);
26132758 }
26142759 }
26152760
@@ -2620,10 +2765,12 @@ static void vlv_init_panel_power_sequencer(struct intel_dp *intel_dp) · 4 unmodified lines
26202765 struct drm_device *dev = encoder->base.dev;
26212766 struct drm_i915_private *dev_priv = dev->dev_private;
26222767 struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc);
2623− struct edp_power_seq power_seq;
26242768
26252769 lockdep_assert_held(&dev_priv->pps_mutex);
26262770
2771+ if (!is_edp(intel_dp))
2772+ return;
2773+
26272774 if (intel_dp->pps_pipe == crtc->pipe)
26282775 return;
26292776
@@ -2633,7 +2780,7 @@ static void vlv_init_panel_power_sequencer(struct intel_dp *intel_dp) · 3 unmodified lines
26332780 * we still have control of it.
26342781 */
26352782 if (intel_dp->pps_pipe != INVALID_PIPE)
2636− edp_panel_vdd_off_sync(intel_dp);
2783+ vlv_detach_power_sequencer(intel_dp);
26372784
26382785 /*
26392786 * We may be stealing the power
@@ -2648,9 +2795,8 @@ static void vlv_init_panel_power_sequencer(struct intel_dp *intel_dp) · 8 unmodified lines
26482795 pipe_name(intel_dp->pps_pipe), port_name(intel_dig_port->port));
26492796
26502797 /* init power sequencer on this pipe and port */
2651− intel_dp_init_panel_power_sequencer(dev, intel_dp, &power_seq);
2652− intel_dp_init_panel_power_sequencer_registers(dev, intel_dp,
2653− &power_seq);
2798+ intel_dp_init_panel_power_sequencer(dev, intel_dp);
2799+ intel_dp_init_panel_power_sequencer_registers(dev, intel_dp);
26542800 }
26552801
26562802 static void vlv_pre_enable_dp(struct intel_encoder *encoder)
@@ -2679,15 +2825,7 @@ static void vlv_pre_enable_dp(struct intel_encoder *encoder) · 22 unmodified lines
26792825
26802826 mutex_unlock(&dev_priv->dpio_lock);
26812827
2682− if (is_edp(intel_dp)) {
2683− pps_lock(intel_dp);
2684− vlv_init_panel_power_sequencer(intel_dp);
2685− pps_unlock(intel_dp);
2686− }
2687−
26882828 intel_enable_dp(encoder);
2689−
2690− vlv_wait_port_ready(dev_priv, dport);
26912829 }
26922830
26932831 static void vlv_dp_pre_pll_enable(struct intel_encoder *encoder)
@@ -2779,15 +2917,7 @@ static void chv_pre_enable_dp(struct intel_encoder *encoder) · 85 unmodified lines
27792917
27802918 mutex_unlock(&dev_priv->dpio_lock);
27812919
2782− if (is_edp(intel_dp)) {
2783− pps_lock(intel_dp);
2784− vlv_init_panel_power_sequencer(intel_dp);
2785− pps_unlock(intel_dp);
2786− }
2787−
27882920 intel_enable_dp(encoder);
2789−
2790− vlv_wait_port_ready(dev_priv, dport);
27912921 }
27922922
27932923 static void chv_dp_pre_pll_enable(struct intel_encoder *encoder)
@@ -3696,7 +3826,6 @@ intel_dp_complete_link_train(struct intel_dp *intel_dp) · 902 unmodified lines
36963826
36973827 /* Try 5 times, then try clock recovery if that fails */
36983828 if (tries > 5) {
3699− intel_dp_link_down(intel_dp);
37003829 intel_dp_start_link_train(intel_dp);
37013830 intel_dp_set_link_train(intel_dp, &DP,
37023831 training_pattern |
@@ -3854,8 +3983,6 @@ intel_dp_probe_oui(struct intel_dp *intel_dp) · 151 unmodified lines
38543983 if (!(intel_dp->dpcd[DP_DOWN_STREAM_PORT_COUNT] & DP_OUI_SUPPORT))
38553984 return;
38563985
3857− intel_edp_panel_vdd_on(intel_dp);
3858−
38593986 if (intel_dp_dpcd_read_wake(&intel_dp->aux, DP_SINK_OUI, buf, 3) == 3)
38603987 DRM_DEBUG_KMS("Sink OUI: %02hx%02hx%02hx\n",
38613988 buf[0], buf[1], buf[2]);
@@ -3863,8 +3990,6 @@ intel_dp_probe_oui(struct intel_dp *intel_dp) · 1 unmodified line
38633990 if (intel_dp_dpcd_read_wake(&intel_dp->aux, DP_BRANCH_OUI, buf, 3) == 3)
38643991 DRM_DEBUG_KMS("Branch OUI: %02hx%02hx%02hx\n",
38653992 buf[0], buf[1], buf[2]);
3866−
3867− intel_edp_panel_vdd_off(intel_dp, false);
38683993 }
38693994
38703995 static bool
@@ -3878,7 +4003,6 @@ intel_dp_probe_mst(struct intel_dp *intel_dp) · 7 unmodified lines
38784003 if (intel_dp->dpcd[DP_DPCD_REV] < 0x12)
38794004 return false;
38804005
3881− intel_edp_panel_vdd_on(intel_dp);
38824006 if (intel_dp_dpcd_read_wake(&intel_dp->aux, DP_MSTM_CAP, buf, 1)) {
38834007 if (buf[0] & DP_MST_CAP) {
38844008 DRM_DEBUG_KMS("Sink is MST capable\n");
@@ -3888,7 +4012,6 @@ intel_dp_probe_mst(struct intel_dp *intel_dp) · 3 unmodified lines
38884012 intel_dp->is_mst = false;
38894013 }
38904014 }
3891− intel_edp_panel_vdd_off(intel_dp, false);
38924015
38934016 drm_dp_mst_topology_mgr_set_mst(&intel_dp->mst_mgr, intel_dp->is_mst);
38944017 return intel_dp->is_mst;
@@ -4568,9 +4691,52 @@ static void intel_dp_encoder_suspend(struct intel_encoder *intel_encoder) · 673 unmodified lines
45684691 pps_unlock(intel_dp);
45694692 }
45704693
4694+static void intel_edp_panel_vdd_sanitize(struct intel_dp *intel_dp)
4695+{
4696+ struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
4697+ struct drm_device *dev = intel_dig_port->base.base.dev;
4698+ struct drm_i915_private *dev_priv = dev->dev_private;
4699+ enum intel_display_power_domain power_domain;
4700+
4701+ lockdep_assert_held(&dev_priv->pps_mutex);
4702+
4703+ if (!edp_have_panel_vdd(intel_dp))
4704+ return;
4705+
4706+ /*
4707+ * The VDD bit needs a power domain reference, so if the bit is
4708+ * already enabled when we boot or resume, grab this reference and
4709+ * schedule a vdd off, so we don't hold on to the reference
4710+ * indefinitely.
4711+ */
4712+ DRM_DEBUG_KMS("VDD left on by BIOS, adjusting state tracking\n");
4713+ power_domain = intel_display_port_power_domain(&intel_dig_port->base);
4714+ intel_display_power_get(dev_priv, power_domain);
4715+
4716+ edp_panel_vdd_schedule_off(intel_dp);
4717+}
4718+
45714719 static void intel_dp_encoder_reset(struct drm_encoder *encoder)
45724720 {
4573− intel_edp_panel_vdd_sanitize(to_intel_encoder(encoder));
4721+ struct intel_dp *intel_dp;
4722+
4723+ if (to_intel_encoder(encoder)->type != INTEL_OUTPUT_EDP)
4724+ return;
4725+
4726+ intel_dp = enc_to_intel_dp(encoder);
4727+
4728+ pps_lock(intel_dp);
4729+
4730+ /*
4731+ * Read out the current power sequencer assignment,
4732+ * in case the BIOS did something with it.
4733+ */
4734+ if (IS_VALLEYVIEW(encoder->dev))
4735+ vlv_initial_power_sequencer_setup(intel_dp);
4736+
4737+ intel_edp_panel_vdd_sanitize(intel_dp);
4738+
4739+ pps_unlock(intel_dp);
45744740 }
45754741
45764742 static const struct drm_connector_funcs intel_dp_connector_funcs = {
@@ -4757,16 +4923,20 @@ static void intel_dp_init_panel_power_timestamps(struct intel_dp *intel_dp) · 180 unmodified lines
47574923
47584924 static void
47594925 intel_dp_init_panel_power_sequencer(struct drm_device *dev,
4760− struct intel_dp *intel_dp,
4761− struct edp_power_seq *out)
4926+ struct intel_dp *intel_dp)
47624927 {
47634928 struct drm_i915_private *dev_priv = dev->dev_private;
4764− struct edp_power_seq cur, vbt, spec, final;
4929+ struct edp_power_seq cur, vbt, spec,
4930+ *final = &intel_dp->pps_delays;
47654931 u32 pp_on, pp_off, pp_div, pp;
47664932 int pp_ctrl_reg, pp_on_reg, pp_off_reg, pp_div_reg;
47674933
47684934 lockdep_assert_held(&dev_priv->pps_mutex);
47694935
4936+ /* already initialized? */
4937+ if (final->t11_t12 != 0)
4938+ return;
4939+
47704940 if (HAS_PCH_SPLIT(dev)) {
47714941 pp_ctrl_reg = PCH_PP_CONTROL;
47724942 pp_on_reg = PCH_PP_ON_DELAYS;
@@ -4828,7 +4998,7 @@ intel_dp_init_panel_power_sequencer(struct drm_device *dev, · 55 unmodified lines
48284998
48294999 /* Use the max of the register settings and vbt. If both are
48305000 * unset, fall back to the spec limits. */
4831−#define assign_final(field) final.field = (max(cur.field, vbt.field) == 0 ? \
5001+#define assign_final(field) final->field = (max(cur.field, vbt.field) == 0 ? \
48325002 spec.field : \
48335003 max(cur.field, vbt.field))
48345004 assign_final(t1_t3);
@@ -4838,7 +5008,7 @@ intel_dp_init_panel_power_sequencer(struct drm_device *dev, · 3 unmodified lines
48385008 assign_final(t11_t12);
48395009 #undef assign_final
48405010
4841−#define get_delay(field) (DIV_ROUND_UP(final.field, 10))
5011+#define get_delay(field) (DIV_ROUND_UP(final->field, 10))
48425012 intel_dp->panel_power_up_delay = get_delay(t1_t3);
48435013 intel_dp->backlight_on_delay = get_delay(t8);
48445014 intel_dp->backlight_off_delay = get_delay(t9);
@@ -4852,21 +5022,18 @@ intel_dp_init_panel_power_sequencer(struct drm_device *dev, · 7 unmodified lines
48525022
48535023 DRM_DEBUG_KMS("backlight on delay %d, off delay %d\n",
48545024 intel_dp->backlight_on_delay, intel_dp->backlight_off_delay);
4855−
4856− if (out)
4857− *out = final;
48585025 }
48595026
48605027 static void
48615028 intel_dp_init_panel_power_sequencer_registers(struct drm_device *dev,
4862− struct intel_dp *intel_dp,
4863− struct edp_power_seq *seq)
5029+ struct intel_dp *intel_dp)
48645030 {
48655031 struct drm_i915_private *dev_priv = dev->dev_private;
48665032 u32 pp_on, pp_off, pp_div, port_sel = 0;
48675033 int div = HAS_PCH_SPLIT(dev) ? intel_pch_rawclk(dev) : intel_hrawclk(dev);
48685034 int pp_on_reg, pp_off_reg, pp_div_reg;
48695035 enum port port = dp_to_dig_port(intel_dp)->port;
5036+ const struct edp_power_seq *seq = &intel_dp->pps_delays;
48705037
48715038 lockdep_assert_held(&dev_priv->pps_mutex);
48725039
@@ -5052,40 +5219,8 @@ intel_dp_drrs_init(struct intel_digital_port *intel_dig_port, · 179 unmodified lines
50525219 return downclock_mode;
50535220 }
50545221
5055−void intel_edp_panel_vdd_sanitize(struct intel_encoder *intel_encoder)
5056−{
5057− struct drm_device *dev = intel_encoder->base.dev;
5058− struct drm_i915_private *dev_priv = dev->dev_private;
5059− struct intel_dp *intel_dp;
5060− enum intel_display_power_domain power_domain;
5061−
5062− if (intel_encoder->type != INTEL_OUTPUT_EDP)
5063− return;
5064−
5065− intel_dp = enc_to_intel_dp(&intel_encoder->base);
5066−
5067− pps_lock(intel_dp);
5068−
5069− if (!edp_have_panel_vdd(intel_dp))
5070− goto out;
5071− /*
5072− * The VDD bit needs a power domain reference, so if the bit is
5073− * already enabled when we boot or resume, grab this reference and
5074− * schedule a vdd off, so we don't hold on to the reference
5075− * indefinitely.
5076− */
5077− DRM_DEBUG_KMS("VDD left on by BIOS, adjusting state tracking\n");
5078− power_domain = intel_display_port_power_domain(intel_encoder);
5079− intel_display_power_get(dev_priv, power_domain);
5080−
5081− edp_panel_vdd_schedule_off(intel_dp);
5082− out:
5083− pps_unlock(intel_dp);
5084−}
5085−
50865222 static bool intel_edp_init_connector(struct intel_dp *intel_dp,
5087− struct intel_connector *intel_connector,
5088− struct edp_power_seq *power_seq)
5223+ struct intel_connector *intel_connector)
50895224 {
50905225 struct drm_connector *connector = &intel_connector->base;
50915226 struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
@@ -5103,12 +5238,12 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp, · 11 unmodified lines
51035238 if (!is_edp(intel_dp))
51045239 return true;
51055240
5106− intel_edp_panel_vdd_sanitize(intel_encoder);
5241+ pps_lock(intel_dp);
5242+ intel_edp_panel_vdd_sanitize(intel_dp);
5243+ pps_unlock(intel_dp);
51075244
51085245 /* Cache DPCD and EDID for edp. */
5109− intel_edp_panel_vdd_on(intel_dp);
51105246 has_dpcd = intel_dp_get_dpcd(intel_dp);
5111− intel_edp_panel_vdd_off(intel_dp, false);
51125247
51135248 if (has_dpcd) {
51145249 if (intel_dp->dpcd[DP_DPCD_REV] >= 0x11)
@@ -5123,7 +5258,7 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp, · 8 unmodified lines
51235258
51245259 /* We now know it's not a ghost, init power sequence regs. */
51255260 pps_lock(intel_dp);
5126− intel_dp_init_panel_power_sequencer_registers(dev, intel_dp, power_seq);
5261+ intel_dp_init_panel_power_sequencer_registers(dev, intel_dp);
51275262 pps_unlock(intel_dp);
51285263
51295264 mutex_lock(&dev->mode_config.mutex);
@@ -5184,7 +5319,6 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port, · 54 unmodified lines
51845319 struct drm_device *dev = intel_encoder->base.dev;
51855320 struct drm_i915_private *dev_priv = dev->dev_private;
51865321 enum port port = intel_dig_port->port;
5187− struct edp_power_seq power_seq = { 0 };
51885322 int type;
51895323
51905324 intel_dp->pps_pipe = INVALID_PIPE;
@@ -5223,6 +5357,11 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port, · 32 unmodified lines
52235357 if (type == DRM_MODE_CONNECTOR_eDP)
52245358 intel_encoder->type = INTEL_OUTPUT_EDP;
52255359
5360+ /* eDP only on port B and/or C on vlv/chv */
5361+ if (WARN_ON(IS_VALLEYVIEW(dev) && is_edp(intel_dp) &&
5362+ port != PORT_B && port != PORT_C))
5363+ return false;
5364+
52265365 DRM_DEBUG_KMS("Adding %s connector on port %c\n",
52275366 type == DRM_MODE_CONNECTOR_eDP ? "eDP" : "DP",
52285367 port_name(port));
@@ -5265,13 +5404,11 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port, · 36 unmodified lines
52655404
52665405 if (is_edp(intel_dp)) {
52675406 pps_lock(intel_dp);
5268− if (IS_VALLEYVIEW(dev)) {
5407+ intel_dp_init_panel_power_timestamps(intel_dp);
5408+ if (IS_VALLEYVIEW(dev))
52695409 vlv_initial_power_sequencer_setup(intel_dp);
5270− } else {
5271− intel_dp_init_panel_power_timestamps(intel_dp);
5272− intel_dp_init_panel_power_sequencer(dev, intel_dp,
5273− &power_seq);
5274− }
5410+ else
5411+ intel_dp_init_panel_power_sequencer(dev, intel_dp);
52755412 pps_unlock(intel_dp);
52765413 }
52775414
@@ -5285,7 +5422,7 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port, · 7 unmodified lines
52855422 }
52865423 }
52875424
5288− if (!intel_edp_init_connector(intel_dp, intel_connector, &power_seq)) {
5425+ if (!intel_edp_init_connector(intel_dp, intel_connector)) {
52895426 drm_dp_aux_unregister(&intel_dp->aux);
52905427 if (is_edp(intel_dp)) {
52915428 cancel_delayed_work_sync(&intel_dp->panel_vdd_work);
drivers/gpu/drm/i915/intel_drv.h+44−21
@@ -94,18 +94,20 @@ · 93 unmodified lines
9494
9595 /* these are outputs from the chip - integrated only
9696 external chips are via DVO or SDVO output */
97−#define INTEL_OUTPUT_UNUSED 0
98−#define INTEL_OUTPUT_ANALOG 1
99−#define INTEL_OUTPUT_DVO 2
100−#define INTEL_OUTPUT_SDVO 3
101−#define INTEL_OUTPUT_LVDS 4
102−#define INTEL_OUTPUT_TVOUT 5
103−#define INTEL_OUTPUT_HDMI 6
104−#define INTEL_OUTPUT_DISPLAYPORT 7
105−#define INTEL_OUTPUT_EDP 8
106−#define INTEL_OUTPUT_DSI 9
107−#define INTEL_OUTPUT_UNKNOWN 10
108−#define INTEL_OUTPUT_DP_MST 11
97+enum intel_output_type {
98+ INTEL_OUTPUT_UNUSED = 0,
99+ INTEL_OUTPUT_ANALOG = 1,
100+ INTEL_OUTPUT_DVO = 2,
101+ INTEL_OUTPUT_SDVO = 3,
102+ INTEL_OUTPUT_LVDS = 4,
103+ INTEL_OUTPUT_TVOUT = 5,
104+ INTEL_OUTPUT_HDMI = 6,
105+ INTEL_OUTPUT_DISPLAYPORT = 7,
106+ INTEL_OUTPUT_EDP = 8,
107+ INTEL_OUTPUT_DSI = 9,
108+ INTEL_OUTPUT_UNKNOWN = 10,
109+ INTEL_OUTPUT_DP_MST = 11,
110+};
109111
110112 #define INTEL_DVO_CHIP_NONE 0
111113 #define INTEL_DVO_CHIP_LVDS 1
@@ -136,7 +138,7 @@ struct intel_encoder { · 24 unmodified lines
136138 */
137139 struct intel_crtc *new_crtc;
138140
139− int type;
141+ enum intel_output_type type;
140142 unsigned int cloneable;
141143 bool connectors_active;
142144 void (*hot_plug)(struct intel_encoder *);
@@ -399,7 +401,14 @@ struct intel_pipe_wm { · 256 unmodified lines
399401
400402 struct intel_mmio_flip {
401403 u32 seqno;
402− u32 ring_id;
404+ struct intel_engine_cs *ring;
405+ struct work_struct work;
406+};
407+
408+struct skl_pipe_wm {
409+ struct skl_wm_level wm[8];
410+ struct skl_wm_level trans_wm;
411+ uint32_t linetime;
403412 };
404413
405414 struct intel_crtc {
@@ -449,6 +458,8 @@ struct intel_crtc { · 43 unmodified lines
449458 struct {
450459 /* watermarks currently being used */
451460 struct intel_pipe_wm active;
461+ /* SKL wm values currently in use */
462+ struct skl_pipe_wm skl_active;
452463 } wm;
453464
454465 int scanline_offset;
@@ -590,6 +601,7 @@ struct intel_dp { · 135 unmodified lines
590601 * this port. Only relevant on VLV/CHV.
591602 */
592603 enum pipe pps_pipe;
604+ struct edp_power_seq pps_delays;
593605
594606 bool use_tps3;
595607 bool can_mst; /* this port supports mst */
@@ -848,6 +860,11 @@ void intel_frontbuffer_flip(struct drm_device *dev, · 252 unmodified lines
848860 void intel_fb_obj_flush(struct drm_i915_gem_object *obj, bool retire);
849861
850862
863+/* intel_audio.c */
864+void intel_init_audio(struct drm_device *dev);
865+void intel_audio_codec_enable(struct intel_encoder *encoder);
866+void intel_audio_codec_disable(struct intel_encoder *encoder);
867+
851868 /* intel_display.c */
852869 const char *intel_output_name(int output);
853870 bool intel_has_pending_fb_unpin(struct drm_device *dev);
@@ -873,6 +890,7 @@ int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data, · 19 unmodified lines
873890 struct drm_file *file_priv);
874891 enum transcoder intel_pipe_to_cpu_transcoder(struct drm_i915_private *dev_priv,
875892 enum pipe pipe);
893+bool intel_pipe_has_type(struct intel_crtc *crtc, enum intel_output_type type);
876894 static inline void
877895 intel_wait_for_vblank(struct drm_device *dev, int pipe)
878896 {
@@ -887,8 +905,8 @@ bool intel_get_load_detect_pipe(struct drm_connector *connector, · 8 unmodified lines
887905 struct drm_modeset_acquire_ctx *ctx);
888906 void intel_release_load_detect_pipe(struct drm_connector *connector,
889907 struct intel_load_detect_pipe *old);
890−int intel_pin_and_fence_fb_obj(struct drm_device *dev,
891− struct drm_i915_gem_object *obj,
908+int intel_pin_and_fence_fb_obj(struct drm_plane *plane,
909+ struct drm_framebuffer *fb,
892910 struct intel_engine_cs *pipelined);
893911 void intel_unpin_fb_obj(struct drm_i915_gem_object *obj);
894912 struct drm_framebuffer *
@@ -910,6 +928,10 @@ void assert_shared_dpll(struct drm_i915_private *dev_priv, · 15 unmodified lines
910928 struct intel_shared_dpll *intel_get_shared_dpll(struct intel_crtc *crtc);
911929 void intel_put_shared_dpll(struct intel_crtc *crtc);
912930
931+void vlv_force_pll_on(struct drm_device *dev, enum pipe pipe,
932+ const struct dpll *dpll);
933+void vlv_force_pll_off(struct drm_device *dev, enum pipe pipe);
934+
913935 /* modesetting asserts */
914936 void assert_panel_unlocked(struct drm_i915_private *dev_priv,
915937 enum pipe pipe);
@@ -924,8 +946,6 @@ void assert_fdi_rx_pll(struct drm_i915_private *dev_priv, · 8 unmodified lines
924946 void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe, bool state);
925947 #define assert_pipe_enabled(d, p) assert_pipe(d, p, true)
926948 #define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
927−void intel_write_eld(struct drm_encoder *encoder,
928− struct drm_display_mode *mode);
929949 unsigned long intel_gen4_compute_page_offset(int *x, int *y,
930950 unsigned int tiling_mode,
931951 unsigned int bpp,
@@ -970,7 +990,6 @@ bool intel_dp_hpd_pulse(struct intel_digital_port *intel_dig_port, · 38 unmodified lines
970990 void intel_edp_backlight_on(struct intel_dp *intel_dp);
971991 void intel_edp_backlight_off(struct intel_dp *intel_dp);
972992 void intel_edp_panel_vdd_on(struct intel_dp *intel_dp);
973−void intel_edp_panel_vdd_sanitize(struct intel_encoder *intel_encoder);
974993 void intel_edp_panel_on(struct intel_dp *intel_dp);
975994 void intel_edp_panel_off(struct intel_dp *intel_dp);
976995 void intel_edp_psr_enable(struct intel_dp *intel_dp);
@@ -982,7 +1001,6 @@ void intel_edp_psr_flush(struct drm_device *dev, · 5 unmodified lines
9821001 unsigned frontbuffer_bits);
9831002 void intel_edp_psr_init(struct drm_device *dev);
9841003
985−int intel_dp_handle_hpd_irq(struct intel_digital_port *digport, bool long_hpd);
9861004 void intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connector);
9871005 void intel_dp_mst_suspend(struct drm_device *dev);
9881006 void intel_dp_mst_resume(struct drm_device *dev);
@@ -1139,6 +1157,9 @@ void gen6_update_ring_freq(struct drm_device *dev); · 150 unmodified lines
11391157 void gen6_rps_idle(struct drm_i915_private *dev_priv);
11401158 void gen6_rps_boost(struct drm_i915_private *dev_priv);
11411159 void ilk_wm_get_hw_state(struct drm_device *dev);
1160+void skl_wm_get_hw_state(struct drm_device *dev);
1161+void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
1162+ struct skl_ddb_allocation *ddb /* out */);
11421163
11431164
11441165 /* intel_sdvo.c */
@@ -1158,7 +1179,9 @@ int intel_sprite_set_colorkey(struct drm_device *dev, void *data, · 13 unmodified lines
11581179 struct drm_file *file_priv);
11591180 int intel_sprite_get_colorkey(struct drm_device *dev, void *data,
11601181 struct drm_file *file_priv);
1161−
1182+bool intel_pipe_update_start(struct intel_crtc *crtc,
1183+ uint32_t *start_vbl_count);
1184+void intel_pipe_update_end(struct intel_crtc *crtc, u32 start_vbl_count);
11621185
11631186 /* intel_tv.c */
11641187 void intel_tv_init(struct drm_device *dev);
drivers/gpu/drm/i915/intel_fbdev.c+10−10
@@ -119,25 +119,25 @@ static int intelfb_alloc(struct drm_fb_helper *helper, · 118 unmodified lines
119119 goto out;
120120 }
121121
122− /* Flush everything out, we'll be doing GTT only from now on */
123− ret = intel_pin_and_fence_fb_obj(dev, obj, NULL);
124− if (ret) {
125− DRM_ERROR("failed to pin obj: %d\n", ret);
126− goto out_unref;
127− }
128−
129122 fb = __intel_framebuffer_create(dev, &mode_cmd, obj);
130123 if (IS_ERR(fb)) {
131124 ret = PTR_ERR(fb);
132− goto out_unpin;
125+ goto out_unref;
126+ }
127+
128+ /* Flush everything out, we'll be doing GTT only from now on */
129+ ret = intel_pin_and_fence_fb_obj(NULL, fb, NULL);
130+ if (ret) {
131+ DRM_ERROR("failed to pin obj: %d\n", ret);
132+ goto out_fb;
133133 }
134134
135135 ifbdev->fb = to_intel_framebuffer(fb);
136136
137137 return 0;
138138
139−out_unpin:
140− i915_gem_object_ggtt_unpin(obj);
139+out_fb:
140+ drm_framebuffer_remove(fb);
141141 out_unref:
142142 drm_gem_object_unreference(&obj->base);
143143 out:
drivers/gpu/drm/i915/intel_hdmi.c+11−8
@@ -661,14 +661,6 @@ static void intel_hdmi_prepare(struct intel_encoder *encoder) · 660 unmodified lines
661661 if (crtc->config.has_hdmi_sink)
662662 hdmi_val |= HDMI_MODE_SELECT_HDMI;
663663
664− if (crtc->config.has_audio) {
665− WARN_ON(!crtc->config.has_hdmi_sink);
666− DRM_DEBUG_DRIVER("Enabling HDMI audio on pipe %c\n",
667− pipe_name(crtc->pipe));
668− hdmi_val |= SDVO_AUDIO_ENABLE;
669− intel_write_eld(&encoder->base, adjusted_mode);
670− }
671−
672664 if (HAS_PCH_CPT(dev))
673665 hdmi_val |= SDVO_PIPE_SEL_CPT(crtc->pipe);
674666 else if (IS_CHERRYVIEW(dev))
@@ -791,6 +783,13 @@ static void intel_enable_hdmi(struct intel_encoder *encoder) · 116 unmodified lines
791783 I915_WRITE(intel_hdmi->hdmi_reg, temp);
792784 POSTING_READ(intel_hdmi->hdmi_reg);
793785 }
786+
787+ if (intel_crtc->config.has_audio) {
788+ WARN_ON(!intel_crtc->config.has_hdmi_sink);
789+ DRM_DEBUG_DRIVER("Enabling HDMI audio on pipe %c\n",
790+ pipe_name(intel_crtc->pipe));
791+ intel_audio_codec_enable(encoder);
792+ }
794793 }
795794
796795 static void vlv_enable_hdmi(struct intel_encoder *encoder)
@@ -802,9 +801,13 @@ static void intel_disable_hdmi(struct intel_encoder *encoder) · 5 unmodified lines
802801 struct drm_device *dev = encoder->base.dev;
803802 struct drm_i915_private *dev_priv = dev->dev_private;
804803 struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base);
804+ struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc);
805805 u32 temp;
806806 u32 enable_bits = SDVO_ENABLE | SDVO_AUDIO_ENABLE;
807807
808+ if (crtc->config.has_audio)
809+ intel_audio_codec_disable(encoder);
810+
808811 temp = I915_READ(intel_hdmi->hdmi_reg);
809812
810813 /* HW workaround for IBX, we need to move the port to transcoder A
drivers/gpu/drm/i915/intel_lrc.c+35−17
@@ -356,9 +356,9 @@ static int execlists_ctx_write_tail(struct drm_i915_gem_object *ctx_obj, u32 tai · 355 unmodified lines
356356 return 0;
357357 }
358358
359−static int execlists_submit_context(struct intel_engine_cs *ring,
360− struct intel_context *to0, u32 tail0,
361− struct intel_context *to1, u32 tail1)
359+static void execlists_submit_contexts(struct intel_engine_cs *ring,
360+ struct intel_context *to0, u32 tail0,
361+ struct intel_context *to1, u32 tail1)
362362 {
363363 struct drm_i915_gem_object *ctx_obj0;
364364 struct drm_i915_gem_object *ctx_obj1 = NULL;
@@ -378,8 +378,6 @@ static int execlists_submit_context(struct intel_engine_cs *ring, · 13 unmodified lines
378378 }
379379
380380 execlists_elsp_write(ring, ctx_obj0, ctx_obj1);
381−
382− return 0;
383381 }
384382
385383 static void execlists_context_unqueue(struct intel_engine_cs *ring)
@@ -413,9 +411,9 @@ static void execlists_context_unqueue(struct intel_engine_cs *ring) · 27 unmodified lines
413411
414412 WARN_ON(req1 && req1->elsp_submitted);
415413
416− WARN_ON(execlists_submit_context(ring, req0->ctx, req0->tail,
417− req1 ? req1->ctx : NULL,
418− req1 ? req1->tail : 0));
414+ execlists_submit_contexts(ring, req0->ctx, req0->tail,
415+ req1 ? req1->ctx : NULL,
416+ req1 ? req1->tail : 0);
419417
420418 req0->elsp_submitted++;
421419 if (req1)
@@ -1214,11 +1212,13 @@ static int gen8_emit_request(struct intel_ringbuffer *ringbuf) · 792 unmodified lines
12141212 */
12151213 void intel_logical_ring_cleanup(struct intel_engine_cs *ring)
12161214 {
1217− struct drm_i915_private *dev_priv = ring->dev->dev_private;
1215+ struct drm_i915_private *dev_priv;
12181216
12191217 if (!intel_ring_initialized(ring))
12201218 return;
12211219
1220+ dev_priv = ring->dev->dev_private;
1221+
12221222 intel_logical_ring_stop(ring);
12231223 WARN_ON((I915_READ_MODE(ring) & MODE_IDLE) == 0);
12241224 ring->preallocated_lazy_request = NULL;
@@ -1649,6 +1649,27 @@ static uint32_t get_lr_context_size(struct intel_engine_cs *ring) · 424 unmodified lines
16491649 return ret;
16501650 }
16511651
1652+static int lrc_setup_hardware_status_page(struct intel_engine_cs *ring,
1653+ struct drm_i915_gem_object *default_ctx_obj)
1654+{
1655+ struct drm_i915_private *dev_priv = ring->dev->dev_private;
1656+
1657+ /* The status page is offset 0 from the default context object
1658+ * in LRC mode. */
1659+ ring->status_page.gfx_addr = i915_gem_obj_ggtt_offset(default_ctx_obj);
1660+ ring->status_page.page_addr =
1661+ kmap(sg_page(default_ctx_obj->pages->sgl));
1662+ if (ring->status_page.page_addr == NULL)
1663+ return -ENOMEM;
1664+ ring->status_page.obj = default_ctx_obj;
1665+
1666+ I915_WRITE(RING_HWS_PGA(ring->mmio_base),
1667+ (u32)ring->status_page.gfx_addr);
1668+ POSTING_READ(RING_HWS_PGA(ring->mmio_base));
1669+
1670+ return 0;
1671+}
1672+
16521673 /**
16531674 * intel_lr_context_deferred_create() - create the LRC specific bits of a context
16541675 * @ctx: LR context to create.
@@ -1734,14 +1755,11 @@ int intel_lr_context_deferred_create(struct intel_context *ctx, · 79 unmodified lines
17341755 ctx->engine[ring->id].state = ctx_obj;
17351756
17361757 if (ctx == ring->default_context) {
1737− /* The status page is offset 0 from the default context object
1738− * in LRC mode. */
1739− ring->status_page.gfx_addr = i915_gem_obj_ggtt_offset(ctx_obj);
1740− ring->status_page.page_addr =
1741− kmap(sg_page(ctx_obj->pages->sgl));
1742− if (ring->status_page.page_addr == NULL)
1743− return -ENOMEM;
1744− ring->status_page.obj = ctx_obj;
1758+ ret = lrc_setup_hardware_status_page(ring, ctx_obj);
1759+ if (ret) {
1760+ DRM_ERROR("Failed to setup hardware status page\n");
1761+ goto error;
1762+ }
17451763 }
17461764
17471765 if (ring->id == RCS && !ctx->rcs_initialized) {
drivers/gpu/drm/i915/intel_pm.c+1027−7
@@ -1960,6 +1960,14 @@ static uint32_t ilk_wm_fbc(uint32_t pri_val, uint32_t horiz_pixels, · 1959 unmodified lines
19601960 return DIV_ROUND_UP(pri_val * 64, horiz_pixels * bytes_per_pixel) + 2;
19611961 }
19621962
1963+struct skl_pipe_wm_parameters {
1964+ bool active;
1965+ uint32_t pipe_htotal;
1966+ uint32_t pixel_rate; /* in KHz */
1967+ struct intel_plane_wm_parameters plane[I915_MAX_PLANES];
1968+ struct intel_plane_wm_parameters cursor;
1969+};
1970+
19631971 struct ilk_pipe_wm_parameters {
19641972 bool active;
19651973 uint32_t pipe_htotal;
@@ -2271,11 +2279,82 @@ hsw_compute_linetime_wm(struct drm_device *dev, struct drm_crtc *crtc) · 305 unmodified lines
22712279 PIPE_WM_LINETIME_TIME(linetime);
22722280 }
22732281
2274−static void intel_read_wm_latency(struct drm_device *dev, uint16_t wm[5])
2282+static void intel_read_wm_latency(struct drm_device *dev, uint16_t wm[8])
22752283 {
22762284 struct drm_i915_private *dev_priv = dev->dev_private;
22772285
2278− if (IS_HASWELL(dev) || IS_BROADWELL(dev)) {
2286+ if (IS_GEN9(dev)) {
2287+ uint32_t val;
2288+ int ret, i;
2289+ int level, max_level = ilk_wm_max_level(dev);
2290+
2291+ /* read the first set of memory latencies[0:3] */
2292+ val = 0; /* data0 to be programmed to 0 for first set */
2293+ mutex_lock(&dev_priv->rps.hw_lock);
2294+ ret = sandybridge_pcode_read(dev_priv,
2295+ GEN9_PCODE_READ_MEM_LATENCY,
2296+ &val);
2297+ mutex_unlock(&dev_priv->rps.hw_lock);
2298+
2299+ if (ret) {
2300+ DRM_ERROR("SKL Mailbox read error = %d\n", ret);
2301+ return;
2302+ }
2303+
2304+ wm[0] = val & GEN9_MEM_LATENCY_LEVEL_MASK;
2305+ wm[1] = (val >> GEN9_MEM_LATENCY_LEVEL_1_5_SHIFT) &
2306+ GEN9_MEM_LATENCY_LEVEL_MASK;
2307+ wm[2] = (val >> GEN9_MEM_LATENCY_LEVEL_2_6_SHIFT) &
2308+ GEN9_MEM_LATENCY_LEVEL_MASK;
2309+ wm[3] = (val >> GEN9_MEM_LATENCY_LEVEL_3_7_SHIFT) &
2310+ GEN9_MEM_LATENCY_LEVEL_MASK;
2311+
2312+ /* read the second set of memory latencies[4:7] */
2313+ val = 1; /* data0 to be programmed to 1 for second set */
2314+ mutex_lock(&dev_priv->rps.hw_lock);
2315+ ret = sandybridge_pcode_read(dev_priv,
2316+ GEN9_PCODE_READ_MEM_LATENCY,
2317+ &val);
2318+ mutex_unlock(&dev_priv->rps.hw_lock);
2319+ if (ret) {
2320+ DRM_ERROR("SKL Mailbox read error = %d\n", ret);
2321+ return;
2322+ }
2323+
2324+ wm[4] = val & GEN9_MEM_LATENCY_LEVEL_MASK;
2325+ wm[5] = (val >> GEN9_MEM_LATENCY_LEVEL_1_5_SHIFT) &
2326+ GEN9_MEM_LATENCY_LEVEL_MASK;
2327+ wm[6] = (val >> GEN9_MEM_LATENCY_LEVEL_2_6_SHIFT) &
2328+ GEN9_MEM_LATENCY_LEVEL_MASK;
2329+ wm[7] = (val >> GEN9_MEM_LATENCY_LEVEL_3_7_SHIFT) &
2330+ GEN9_MEM_LATENCY_LEVEL_MASK;
2331+
2332+ /*
2333+ * punit doesn't take into account the read latency so we need
2334+ * to add 2us to the various latency levels we retrieve from
2335+ * the punit.
2336+ * - W0 is a bit special in that it's the only level that
2337+ * can't be disabled if we want to have display working, so
2338+ * we always add 2us there.
2339+ * - For levels >=1, punit returns 0us latency when they are
2340+ * disabled, so we respect that and don't add 2us then
2341+ *
2342+ * Additionally, if a level n (n > 1) has a 0us latency, all
2343+ * levels m (m >= n) need to be disabled. We make sure to
2344+ * sanitize the values out of the punit to satisfy this
2345+ * requirement.
2346+ */
2347+ wm[0] += 2;
2348+ for (level = 1; level <= max_level; level++)
2349+ if (wm[level] != 0)
2350+ wm[level] += 2;
2351+ else {
2352+ for (i = level + 1; i <= max_level; i++)
2353+ wm[i] = 0;
2354+
2355+ break;
2356+ }
2357+ } else if (IS_HASWELL(dev) || IS_BROADWELL(dev)) {
22792358 uint64_t sskpd = I915_READ64(MCH_SSKPD);
22802359
22812360 wm[0] = (sskpd >> 56) & 0xFF;
@@ -2323,7 +2402,9 @@ static void intel_fixup_cur_wm_latency(struct drm_device *dev, uint16_t wm[5]) · 41 unmodified lines
23232402 int ilk_wm_max_level(const struct drm_device *dev)
23242403 {
23252404 /* how many WM levels are we expecting */
2326− if (IS_HASWELL(dev) || IS_BROADWELL(dev))
2405+ if (IS_GEN9(dev))
2406+ return 7;
2407+ else if (IS_HASWELL(dev) || IS_BROADWELL(dev))
23272408 return 4;
23282409 else if (INTEL_INFO(dev)->gen >= 6)
23292410 return 3;
@@ -2333,7 +2414,7 @@ int ilk_wm_max_level(const struct drm_device *dev) · 3 unmodified lines
23332414
23342415 static void intel_print_wm_latency(struct drm_device *dev,
23352416 const char *name,
2336− const uint16_t wm[5])
2417+ const uint16_t wm[8])
23372418 {
23382419 int level, max_level = ilk_wm_max_level(dev);
23392420
@@ -2346,8 +2427,13 @@ static void intel_print_wm_latency(struct drm_device *dev, · 6 unmodified lines
23462427 continue;
23472428 }
23482429
2349− /* WM1+ latency values in 0.5us units */
2350− if (level > 0)
2430+ /*
2431+ * - latencies are in us on gen9.
2432+ * - before then, WM1+ latency values are in 0.5us units
2433+ */
2434+ if (IS_GEN9(dev))
2435+ latency *= 10;
2436+ else if (level > 0)
23512437 latency *= 5;
23522438
23532439 DRM_DEBUG_KMS("%s WM%d latency %u (%u.%u usec)\n",
@@ -2415,6 +2501,14 @@ static void ilk_setup_wm_latency(struct drm_device *dev) · 61 unmodified lines
24152501 snb_wm_latency_quirk(dev);
24162502 }
24172503
2504+static void skl_setup_wm_latency(struct drm_device *dev)
2505+{
2506+ struct drm_i915_private *dev_priv = dev->dev_private;
2507+
2508+ intel_read_wm_latency(dev, dev_priv->wm.skl_latency);
2509+ intel_print_wm_latency(dev, "Gen9 Plane", dev_priv->wm.skl_latency);
2510+}
2511+
24182512 static void ilk_compute_wm_parameters(struct drm_crtc *crtc,
24192513 struct ilk_pipe_wm_parameters *p)
24202514 {
@@ -2905,6 +2999,769 @@ static bool ilk_disable_lp_wm(struct drm_device *dev) · 484 unmodified lines
29052999 return _ilk_disable_lp_wm(dev_priv, WM_DIRTY_LP_ALL);
29063000 }
29073001
3002+/*
3003+ * On gen9, we need to allocate Display Data Buffer (DDB) portions to the
3004+ * different active planes.
3005+ */
3006+
3007+#define SKL_DDB_SIZE 896 /* in blocks */
3008+
3009+static void
3010+skl_ddb_get_pipe_allocation_limits(struct drm_device *dev,
3011+ struct drm_crtc *for_crtc,
3012+ const struct intel_wm_config *config,
3013+ const struct skl_pipe_wm_parameters *params,
3014+ struct skl_ddb_entry *alloc /* out */)
3015+{
3016+ struct drm_crtc *crtc;
3017+ unsigned int pipe_size, ddb_size;
3018+ int nth_active_pipe;
3019+
3020+ if (!params->active) {
3021+ alloc->start = 0;
3022+ alloc->end = 0;
3023+ return;
3024+ }
3025+
3026+ ddb_size = SKL_DDB_SIZE;
3027+
3028+ ddb_size -= 4; /* 4 blocks for bypass path allocation */
3029+
3030+ nth_active_pipe = 0;
3031+ for_each_crtc(dev, crtc) {
3032+ if (!intel_crtc_active(crtc))
3033+ continue;
3034+
3035+ if (crtc == for_crtc)
3036+ break;
3037+
3038+ nth_active_pipe++;
3039+ }
3040+
3041+ pipe_size = ddb_size / config->num_pipes_active;
3042+ alloc->start = nth_active_pipe * ddb_size / config->num_pipes_active;
3043+ alloc->end = alloc->start + pipe_size;
3044+}
3045+
3046+static unsigned int skl_cursor_allocation(const struct intel_wm_config *config)
3047+{
3048+ if (config->num_pipes_active == 1)
3049+ return 32;
3050+
3051+ return 8;
3052+}
3053+
3054+static void skl_ddb_entry_init_from_hw(struct skl_ddb_entry *entry, u32 reg)
3055+{
3056+ entry->start = reg & 0x3ff;
3057+ entry->end = (reg >> 16) & 0x3ff;
3058+ if (entry->end)
3059+ entry->end += 1;
3060+}
3061+
3062+void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
3063+ struct skl_ddb_allocation *ddb /* out */)
3064+{
3065+ struct drm_device *dev = dev_priv->dev;
3066+ enum pipe pipe;
3067+ int plane;
3068+ u32 val;
3069+
3070+ for_each_pipe(dev_priv, pipe) {
3071+ for_each_plane(pipe, plane) {
3072+ val = I915_READ(PLANE_BUF_CFG(pipe, plane));
3073+ skl_ddb_entry_init_from_hw(&ddb->plane[pipe][plane],
3074+ val);
3075+ }
3076+
3077+ val = I915_READ(CUR_BUF_CFG(pipe));
3078+ skl_ddb_entry_init_from_hw(&ddb->cursor[pipe], val);
3079+ }
3080+}
3081+
3082+static unsigned int
3083+skl_plane_relative_data_rate(const struct intel_plane_wm_parameters *p)
3084+{
3085+ return p->horiz_pixels * p->vert_pixels * p->bytes_per_pixel;
3086+}
3087+
3088+/*
3089+ * We don't overflow 32 bits. Worst case is 3 planes enabled, each fetching
3090+ * a 8192x4096@32bpp framebuffer:
3091+ * 3 * 4096 * 8192 * 4 < 2^32
3092+ */
3093+static unsigned int
3094+skl_get_total_relative_data_rate(struct intel_crtc *intel_crtc,
3095+ const struct skl_pipe_wm_parameters *params)
3096+{
3097+ unsigned int total_data_rate = 0;
3098+ int plane;
3099+
3100+ for (plane = 0; plane < intel_num_planes(intel_crtc); plane++) {
3101+ const struct intel_plane_wm_parameters *p;
3102+
3103+ p = &params->plane[plane];
3104+ if (!p->enabled)
3105+ continue;
3106+
3107+ total_data_rate += skl_plane_relative_data_rate(p);
3108+ }
3109+
3110+ return total_data_rate;
3111+}
3112+
3113+static void
3114+skl_allocate_pipe_ddb(struct drm_crtc *crtc,
3115+ const struct intel_wm_config *config,
3116+ const struct skl_pipe_wm_parameters *params,
3117+ struct skl_ddb_allocation *ddb /* out */)
3118+{
3119+ struct drm_device *dev = crtc->dev;
3120+ struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
3121+ enum pipe pipe = intel_crtc->pipe;
3122+ struct skl_ddb_entry *alloc = &ddb->pipe[pipe];
3123+ uint16_t alloc_size, start, cursor_blocks;
3124+ unsigned int total_data_rate;
3125+ int plane;
3126+
3127+ skl_ddb_get_pipe_allocation_limits(dev, crtc, config, params, alloc);
3128+ alloc_size = skl_ddb_entry_size(alloc);
3129+ if (alloc_size == 0) {
3130+ memset(ddb->plane[pipe], 0, sizeof(ddb->plane[pipe]));
3131+ memset(&ddb->cursor[pipe], 0, sizeof(ddb->cursor[pipe]));
3132+ return;
3133+ }
3134+
3135+ cursor_blocks = skl_cursor_allocation(config);
3136+ ddb->cursor[pipe].start = alloc->end - cursor_blocks;
3137+ ddb->cursor[pipe].end = alloc->end;
3138+
3139+ alloc_size -= cursor_blocks;
3140+ alloc->end -= cursor_blocks;
3141+
3142+ /*
3143+ * Each active plane get a portion of the remaining space, in
3144+ * proportion to the amount of data they need to fetch from memory.
3145+ *
3146+ * FIXME: we may not allocate every single block here.
3147+ */
3148+ total_data_rate = skl_get_total_relative_data_rate(intel_crtc, params);
3149+
3150+ start = alloc->start;
3151+ for (plane = 0; plane < intel_num_planes(intel_crtc); plane++) {
3152+ const struct intel_plane_wm_parameters *p;
3153+ unsigned int data_rate;
3154+ uint16_t plane_blocks;
3155+
3156+ p = &params->plane[plane];
3157+ if (!p->enabled)
3158+ continue;
3159+
3160+ data_rate = skl_plane_relative_data_rate(p);
3161+
3162+ /*
3163+ * promote the expression to 64 bits to avoid overflowing, the
3164+ * result is < available as data_rate / total_data_rate < 1
3165+ */
3166+ plane_blocks = div_u64((uint64_t)alloc_size * data_rate,
3167+ total_data_rate);
3168+
3169+ ddb->plane[pipe][plane].start = start;
3170+ ddb->plane[pipe][plane].end = start + plane_blocks;
3171+
3172+ start += plane_blocks;
3173+ }
3174+
3175+}
3176+
3177+static uint32_t skl_pipe_pixel_rate(const struct intel_crtc_config *config)
3178+{
3179+ /* TODO: Take into account the scalers once we support them */
3180+ return config->adjusted_mode.crtc_clock;
3181+}
3182+
3183+/*
3184+ * The max latency should be 257 (max the punit can code is 255 and we add 2us
3185+ * for the read latency) and bytes_per_pixel should always be <= 8, so that
3186+ * should allow pixel_rate up to ~2 GHz which seems sufficient since max
3187+ * 2xcdclk is 1350 MHz and the pixel rate should never exceed that.
3188+*/
3189+static uint32_t skl_wm_method1(uint32_t pixel_rate, uint8_t bytes_per_pixel,
3190+ uint32_t latency)
3191+{
3192+ uint32_t wm_intermediate_val, ret;
3193+
3194+ if (latency == 0)
3195+ return UINT_MAX;
3196+
3197+ wm_intermediate_val = latency * pixel_rate * bytes_per_pixel;
3198+ ret = DIV_ROUND_UP(wm_intermediate_val, 1000);
3199+
3200+ return ret;
3201+}
3202+
3203+static uint32_t skl_wm_method2(uint32_t pixel_rate, uint32_t pipe_htotal,
3204+ uint32_t horiz_pixels, uint8_t bytes_per_pixel,
3205+ uint32_t latency)
3206+{
3207+ uint32_t ret, plane_bytes_per_line, wm_intermediate_val;
3208+
3209+ if (latency == 0)
3210+ return UINT_MAX;
3211+
3212+ plane_bytes_per_line = horiz_pixels * bytes_per_pixel;
3213+ wm_intermediate_val = latency * pixel_rate;
3214+ ret = DIV_ROUND_UP(wm_intermediate_val, pipe_htotal * 1000) *
3215+ plane_bytes_per_line;
3216+
3217+ return ret;
3218+}
3219+
3220+static bool skl_ddb_allocation_changed(const struct skl_ddb_allocation *new_ddb,
3221+ const struct intel_crtc *intel_crtc)
3222+{
3223+ struct drm_device *dev = intel_crtc->base.dev;
3224+ struct drm_i915_private *dev_priv = dev->dev_private;
3225+ const struct skl_ddb_allocation *cur_ddb = &dev_priv->wm.skl_hw.ddb;
3226+ enum pipe pipe = intel_crtc->pipe;
3227+
3228+ if (memcmp(new_ddb->plane[pipe], cur_ddb->plane[pipe],
3229+ sizeof(new_ddb->plane[pipe])))
3230+ return true;
3231+
3232+ if (memcmp(&new_ddb->cursor[pipe], &cur_ddb->cursor[pipe],
3233+ sizeof(new_ddb->cursor[pipe])))
3234+ return true;
3235+
3236+ return false;
3237+}
3238+
3239+static void skl_compute_wm_global_parameters(struct drm_device *dev,
3240+ struct intel_wm_config *config)
3241+{
3242+ struct drm_crtc *crtc;
3243+ struct drm_plane *plane;
3244+
3245+ list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
3246+ config->num_pipes_active += intel_crtc_active(crtc);
3247+
3248+ /* FIXME: I don't think we need those two global parameters on SKL */
3249+ list_for_each_entry(plane, &dev->mode_config.plane_list, head) {
3250+ struct intel_plane *intel_plane = to_intel_plane(plane);
3251+
3252+ config->sprites_enabled |= intel_plane->wm.enabled;
3253+ config->sprites_scaled |= intel_plane->wm.scaled;
3254+ }
3255+}
3256+
3257+static void skl_compute_wm_pipe_parameters(struct drm_crtc *crtc,
3258+ struct skl_pipe_wm_parameters *p)
3259+{
3260+ struct drm_device *dev = crtc->dev;
3261+ struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
3262+ enum pipe pipe = intel_crtc->pipe;
3263+ struct drm_plane *plane;
3264+ int i = 1; /* Index for sprite planes start */
3265+
3266+ p->active = intel_crtc_active(crtc);
3267+ if (p->active) {
3268+ p->pipe_htotal = intel_crtc->config.adjusted_mode.crtc_htotal;
3269+ p->pixel_rate = skl_pipe_pixel_rate(&intel_crtc->config);
3270+
3271+ /*
3272+ * For now, assume primary and cursor planes are always enabled.
3273+ */
3274+ p->plane[0].enabled = true;
3275+ p->plane[0].bytes_per_pixel =
3276+ crtc->primary->fb->bits_per_pixel / 8;
3277+ p->plane[0].horiz_pixels = intel_crtc->config.pipe_src_w;
3278+ p->plane[0].vert_pixels = intel_crtc->config.pipe_src_h;
3279+
3280+ p->cursor.enabled = true;
3281+ p->cursor.bytes_per_pixel = 4;
3282+ p->cursor.horiz_pixels = intel_crtc->cursor_width ?
3283+ intel_crtc->cursor_width : 64;
3284+ }
3285+
3286+ list_for_each_entry(plane, &dev->mode_config.plane_list, head) {
3287+ struct intel_plane *intel_plane = to_intel_plane(plane);
3288+
3289+ if (intel_plane->pipe == pipe)
3290+ p->plane[i++] = intel_plane->wm;
3291+ }
3292+}
3293+
3294+static bool skl_compute_plane_wm(struct skl_pipe_wm_parameters *p,
3295+ struct intel_plane_wm_parameters *p_params,
3296+ uint16_t ddb_allocation,
3297+ uint32_t mem_value,
3298+ uint16_t *out_blocks, /* out */
3299+ uint8_t *out_lines /* out */)
3300+{
3301+ uint32_t method1, method2, plane_bytes_per_line, res_blocks, res_lines;
3302+ uint32_t result_bytes;
3303+
3304+ if (mem_value == 0 || !p->active || !p_params->enabled)
3305+ return false;
3306+
3307+ method1 = skl_wm_method1(p->pixel_rate,
3308+ p_params->bytes_per_pixel,
3309+ mem_value);
3310+ method2 = skl_wm_method2(p->pixel_rate,
3311+ p->pipe_htotal,
3312+ p_params->horiz_pixels,
3313+ p_params->bytes_per_pixel,
3314+ mem_value);
3315+
3316+ plane_bytes_per_line = p_params->horiz_pixels *
3317+ p_params->bytes_per_pixel;
3318+
3319+ /* For now xtile and linear */
3320+ if (((ddb_allocation * 512) / plane_bytes_per_line) >= 1)
3321+ result_bytes = min(method1, method2);
3322+ else
3323+ result_bytes = method1;
3324+
3325+ res_blocks = DIV_ROUND_UP(result_bytes, 512) + 1;
3326+ res_lines = DIV_ROUND_UP(result_bytes, plane_bytes_per_line);
3327+
3328+ if (res_blocks > ddb_allocation || res_lines > 31)
3329+ return false;
3330+
3331+ *out_blocks = res_blocks;
3332+ *out_lines = res_lines;
3333+
3334+ return true;
3335+}
3336+
3337+static void skl_compute_wm_level(const struct drm_i915_private *dev_priv,
3338+ struct skl_ddb_allocation *ddb,
3339+ struct skl_pipe_wm_parameters *p,
3340+ enum pipe pipe,
3341+ int level,
3342+ int num_planes,
3343+ struct skl_wm_level *result)
3344+{
3345+ uint16_t latency = dev_priv->wm.skl_latency[level];
3346+ uint16_t ddb_blocks;
3347+ int i;
3348+
3349+ for (i = 0; i < num_planes; i++) {
3350+ ddb_blocks = skl_ddb_entry_size(&ddb->plane[pipe][i]);
3351+
3352+ result->plane_en[i] = skl_compute_plane_wm(p, &p->plane[i],
3353+ ddb_blocks,
3354+ latency,
3355+ &result->plane_res_b[i],
3356+ &result->plane_res_l[i]);
3357+ }
3358+
3359+ ddb_blocks = skl_ddb_entry_size(&ddb->cursor[pipe]);
3360+ result->cursor_en = skl_compute_plane_wm(p, &p->cursor, ddb_blocks,
3361+ latency, &result->cursor_res_b,
3362+ &result->cursor_res_l);
3363+}
3364+
3365+static uint32_t
3366+skl_compute_linetime_wm(struct drm_crtc *crtc, struct skl_pipe_wm_parameters *p)
3367+{
3368+ if (!intel_crtc_active(crtc))
3369+ return 0;
3370+
3371+ return DIV_ROUND_UP(8 * p->pipe_htotal * 1000, p->pixel_rate);
3372+
3373+}
3374+
3375+static void skl_compute_transition_wm(struct drm_crtc *crtc,
3376+ struct skl_pipe_wm_parameters *params,
3377+ struct skl_wm_level *trans_wm /* out */)
3378+{
3379+ struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
3380+ int i;
3381+
3382+ if (!params->active)
3383+ return;
3384+
3385+ /* Until we know more, just disable transition WMs */
3386+ for (i = 0; i < intel_num_planes(intel_crtc); i++)
3387+ trans_wm->plane_en[i] = false;
3388+ trans_wm->cursor_en = false;
3389+}
3390+
3391+static void skl_compute_pipe_wm(struct drm_crtc *crtc,
3392+ struct skl_ddb_allocation *ddb,
3393+ struct skl_pipe_wm_parameters *params,
3394+ struct skl_pipe_wm *pipe_wm)
3395+{
3396+ struct drm_device *dev = crtc->dev;
3397+ const struct drm_i915_private *dev_priv = dev->dev_private;
3398+ struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
3399+ int level, max_level = ilk_wm_max_level(dev);
3400+
3401+ for (level = 0; level <= max_level; level++) {
3402+ skl_compute_wm_level(dev_priv, ddb, params, intel_crtc->pipe,
3403+ level, intel_num_planes(intel_crtc),
3404+ &pipe_wm->wm[level]);
3405+ }
3406+ pipe_wm->linetime = skl_compute_linetime_wm(crtc, params);
3407+
3408+ skl_compute_transition_wm(crtc, params, &pipe_wm->trans_wm);
3409+}
3410+
3411+static void skl_compute_wm_results(struct drm_device *dev,
3412+ struct skl_pipe_wm_parameters *p,
3413+ struct skl_pipe_wm *p_wm,
3414+ struct skl_wm_values *r,
3415+ struct intel_crtc *intel_crtc)
3416+{
3417+ int level, max_level = ilk_wm_max_level(dev);
3418+ enum pipe pipe = intel_crtc->pipe;
3419+ uint32_t temp;
3420+ int i;
3421+
3422+ for (level = 0; level <= max_level; level++) {
3423+ for (i = 0; i < intel_num_planes(intel_crtc); i++) {
3424+ temp = 0;
3425+
3426+ temp |= p_wm->wm[level].plane_res_l[i] <<
3427+ PLANE_WM_LINES_SHIFT;
3428+ temp |= p_wm->wm[level].plane_res_b[i];
3429+ if (p_wm->wm[level].plane_en[i])
3430+ temp |= PLANE_WM_EN;
3431+
3432+ r->plane[pipe][i][level] = temp;
3433+ }
3434+
3435+ temp = 0;
3436+
3437+ temp |= p_wm->wm[level].cursor_res_l << PLANE_WM_LINES_SHIFT;
3438+ temp |= p_wm->wm[level].cursor_res_b;
3439+
3440+ if (p_wm->wm[level].cursor_en)
3441+ temp |= PLANE_WM_EN;
3442+
3443+ r->cursor[pipe][level] = temp;
3444+
3445+ }
3446+
3447+ /* transition WMs */
3448+ for (i = 0; i < intel_num_planes(intel_crtc); i++) {
3449+ temp = 0;
3450+ temp |= p_wm->trans_wm.plane_res_l[i] << PLANE_WM_LINES_SHIFT;
3451+ temp |= p_wm->trans_wm.plane_res_b[i];
3452+ if (p_wm->trans_wm.plane_en[i])
3453+ temp |= PLANE_WM_EN;
3454+
3455+ r->plane_trans[pipe][i] = temp;
3456+ }
3457+
3458+ temp = 0;
3459+ temp |= p_wm->trans_wm.cursor_res_l << PLANE_WM_LINES_SHIFT;
3460+ temp |= p_wm->trans_wm.cursor_res_b;
3461+ if (p_wm->trans_wm.cursor_en)
3462+ temp |= PLANE_WM_EN;
3463+
3464+ r->cursor_trans[pipe] = temp;
3465+
3466+ r->wm_linetime[pipe] = p_wm->linetime;
3467+}
3468+
3469+static void skl_ddb_entry_write(struct drm_i915_private *dev_priv, uint32_t reg,
3470+ const struct skl_ddb_entry *entry)
3471+{
3472+ if (entry->end)
3473+ I915_WRITE(reg, (entry->end - 1) << 16 | entry->start);
3474+ else
3475+ I915_WRITE(reg, 0);
3476+}
3477+
3478+static void skl_write_wm_values(struct drm_i915_private *dev_priv,
3479+ const struct skl_wm_values *new)
3480+{
3481+ struct drm_device *dev = dev_priv->dev;
3482+ struct intel_crtc *crtc;
3483+
3484+ list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) {
3485+ int i, level, max_level = ilk_wm_max_level(dev);
3486+ enum pipe pipe = crtc->pipe;
3487+
3488+ if (!new->dirty[pipe])
3489+ continue;
3490+
3491+ I915_WRITE(PIPE_WM_LINETIME(pipe), new->wm_linetime[pipe]);
3492+
3493+ for (level = 0; level <= max_level; level++) {
3494+ for (i = 0; i < intel_num_planes(crtc); i++)
3495+ I915_WRITE(PLANE_WM(pipe, i, level),
3496+ new->plane[pipe][i][level]);
3497+ I915_WRITE(CUR_WM(pipe, level),
3498+ new->cursor[pipe][level]);
3499+ }
3500+ for (i = 0; i < intel_num_planes(crtc); i++)
3501+ I915_WRITE(PLANE_WM_TRANS(pipe, i),
3502+ new->plane_trans[pipe][i]);
3503+ I915_WRITE(CUR_WM_TRANS(pipe), new->cursor_trans[pipe]);
3504+
3505+ for (i = 0; i < intel_num_planes(crtc); i++)
3506+ skl_ddb_entry_write(dev_priv,
3507+ PLANE_BUF_CFG(pipe, i),
3508+ &new->ddb.plane[pipe][i]);
3509+
3510+ skl_ddb_entry_write(dev_priv, CUR_BUF_CFG(pipe),
3511+ &new->ddb.cursor[pipe]);
3512+ }
3513+}
3514+
3515+/*
3516+ * When setting up a new DDB allocation arrangement, we need to correctly
3517+ * sequence the times at which the new allocations for the pipes are taken into
3518+ * account or we'll have pipes fetching from space previously allocated to
3519+ * another pipe.
3520+ *
3521+ * Roughly the sequence looks like:
3522+ * 1. re-allocate the pipe(s) with the allocation being reduced and not
3523+ * overlapping with a previous light-up pipe (another way to put it is:
3524+ * pipes with their new allocation strickly included into their old ones).
3525+ * 2. re-allocate the other pipes that get their allocation reduced
3526+ * 3. allocate the pipes having their allocation increased
3527+ *
3528+ * Steps 1. and 2. are here to take care of the following case:
3529+ * - Initially DDB looks like this:
3530+ * | B | C |
3531+ * - enable pipe A.
3532+ * - pipe B has a reduced DDB allocation that overlaps with the old pipe C
3533+ * allocation
3534+ * | A | B | C |
3535+ *
3536+ * We need to sequence the re-allocation: C, B, A (and not B, C, A).
3537+ */
3538+
3539+static void
3540+skl_wm_flush_pipe(struct drm_i915_private *dev_priv, enum pipe pipe, int pass)
3541+{
3542+ struct drm_device *dev = dev_priv->dev;
3543+ int plane;
3544+
3545+ DRM_DEBUG_KMS("flush pipe %c (pass %d)\n", pipe_name(pipe), pass);
3546+
3547+ for_each_plane(pipe, plane) {
3548+ I915_WRITE(PLANE_SURF(pipe, plane),
3549+ I915_READ(PLANE_SURF(pipe, plane)));
3550+ }
3551+ I915_WRITE(CURBASE(pipe), I915_READ(CURBASE(pipe)));
3552+}
3553+
3554+static bool
3555+skl_ddb_allocation_included(const struct skl_ddb_allocation *old,
3556+ const struct skl_ddb_allocation *new,
3557+ enum pipe pipe)
3558+{
3559+ uint16_t old_size, new_size;
3560+
3561+ old_size = skl_ddb_entry_size(&old->pipe[pipe]);
3562+ new_size = skl_ddb_entry_size(&new->pipe[pipe]);
3563+
3564+ return old_size != new_size &&
3565+ new->pipe[pipe].start >= old->pipe[pipe].start &&
3566+ new->pipe[pipe].end <= old->pipe[pipe].end;
3567+}
3568+
3569+static void skl_flush_wm_values(struct drm_i915_private *dev_priv,
3570+ struct skl_wm_values *new_values)
3571+{
3572+ struct drm_device *dev = dev_priv->dev;
3573+ struct skl_ddb_allocation *cur_ddb, *new_ddb;
3574+ bool reallocated[I915_MAX_PIPES] = {false, false, false};
3575+ struct intel_crtc *crtc;
3576+ enum pipe pipe;
3577+
3578+ new_ddb = &new_values->ddb;
3579+ cur_ddb = &dev_priv->wm.skl_hw.ddb;
3580+
3581+ /*
3582+ * First pass: flush the pipes with the new allocation contained into
3583+ * the old space.
3584+ *
3585+ * We'll wait for the vblank on those pipes to ensure we can safely
3586+ * re-allocate the freed space without this pipe fetching from it.
3587+ */
3588+ for_each_intel_crtc(dev, crtc) {
3589+ if (!crtc->active)
3590+ continue;
3591+
3592+ pipe = crtc->pipe;
3593+
3594+ if (!skl_ddb_allocation_included(cur_ddb, new_ddb, pipe))
3595+ continue;
3596+
3597+ skl_wm_flush_pipe(dev_priv, pipe, 1);
3598+ intel_wait_for_vblank(dev, pipe);
3599+
3600+ reallocated[pipe] = true;
3601+ }
3602+
3603+
3604+ /*
3605+ * Second pass: flush the pipes that are having their allocation
3606+ * reduced, but overlapping with a previous allocation.
3607+ *
3608+ * Here as well we need to wait for the vblank to make sure the freed
3609+ * space is not used anymore.
3610+ */
3611+ for_each_intel_crtc(dev, crtc) {
3612+ if (!crtc->active)
3613+ continue;
3614+
3615+ pipe = crtc->pipe;
3616+
3617+ if (reallocated[pipe])
3618+ continue;
3619+
3620+ if (skl_ddb_entry_size(&new_ddb->pipe[pipe]) <
3621+ skl_ddb_entry_size(&cur_ddb->pipe[pipe])) {
3622+ skl_wm_flush_pipe(dev_priv, pipe, 2);
3623+ intel_wait_for_vblank(dev, pipe);
3624+ }
3625+
3626+ reallocated[pipe] = true;
3627+ }
3628+
3629+ /*
3630+ * Third pass: flush the pipes that got more space allocated.
3631+ *
3632+ * We don't need to actively wait for the update here, next vblank
3633+ * will just get more DDB space with the correct WM values.
3634+ */
3635+ for_each_intel_crtc(dev, crtc) {
3636+ if (!crtc->active)
3637+ continue;
3638+
3639+ pipe = crtc->pipe;
3640+
3641+ /*
3642+ * At this point, only the pipes more space than before are
3643+ * left to re-allocate.
3644+ */
3645+ if (reallocated[pipe])
3646+ continue;
3647+
3648+ skl_wm_flush_pipe(dev_priv, pipe, 3);
3649+ }
3650+}
3651+
3652+static bool skl_update_pipe_wm(struct drm_crtc *crtc,
3653+ struct skl_pipe_wm_parameters *params,
3654+ struct intel_wm_config *config,
3655+ struct skl_ddb_allocation *ddb, /* out */
3656+ struct skl_pipe_wm *pipe_wm /* out */)
3657+{
3658+ struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
3659+
3660+ skl_compute_wm_pipe_parameters(crtc, params);
3661+ skl_allocate_pipe_ddb(crtc, config, params, ddb);
3662+ skl_compute_pipe_wm(crtc, ddb, params, pipe_wm);
3663+
3664+ if (!memcmp(&intel_crtc->wm.skl_active, pipe_wm, sizeof(*pipe_wm)))
3665+ return false;
3666+
3667+ intel_crtc->wm.skl_active = *pipe_wm;
3668+ return true;
3669+}
3670+
3671+static void skl_update_other_pipe_wm(struct drm_device *dev,
3672+ struct drm_crtc *crtc,
3673+ struct intel_wm_config *config,
3674+ struct skl_wm_values *r)
3675+{
3676+ struct intel_crtc *intel_crtc;
3677+ struct intel_crtc *this_crtc = to_intel_crtc(crtc);
3678+
3679+ /*
3680+ * If the WM update hasn't changed the allocation for this_crtc (the
3681+ * crtc we are currently computing the new WM values for), other
3682+ * enabled crtcs will keep the same allocation and we don't need to
3683+ * recompute anything for them.
3684+ */
3685+ if (!skl_ddb_allocation_changed(&r->ddb, this_crtc))
3686+ return;
3687+
3688+ /*
3689+ * Otherwise, because of this_crtc being freshly enabled/disabled, the
3690+ * other active pipes need new DDB allocation and WM values.
3691+ */
3692+ list_for_each_entry(intel_crtc, &dev->mode_config.crtc_list,
3693+ base.head) {
3694+ struct skl_pipe_wm_parameters params = {};
3695+ struct skl_pipe_wm pipe_wm = {};
3696+ bool wm_changed;
3697+
3698+ if (this_crtc->pipe == intel_crtc->pipe)
3699+ continue;
3700+
3701+ if (!intel_crtc->active)
3702+ continue;
3703+
3704+ wm_changed = skl_update_pipe_wm(&intel_crtc->base,
3705+ &params, config,
3706+ &r->ddb, &pipe_wm);
3707+
3708+ /*
3709+ * If we end up re-computing the other pipe WM values, it's
3710+ * because it was really needed, so we expect the WM values to
3711+ * be different.
3712+ */
3713+ WARN_ON(!wm_changed);
3714+
3715+ skl_compute_wm_results(dev, &params, &pipe_wm, r, intel_crtc);
3716+ r->dirty[intel_crtc->pipe] = true;
3717+ }
3718+}
3719+
3720+static void skl_update_wm(struct drm_crtc *crtc)
3721+{
3722+ struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
3723+ struct drm_device *dev = crtc->dev;
3724+ struct drm_i915_private *dev_priv = dev->dev_private;
3725+ struct skl_pipe_wm_parameters params = {};
3726+ struct skl_wm_values *results = &dev_priv->wm.skl_results;
3727+ struct skl_pipe_wm pipe_wm = {};
3728+ struct intel_wm_config config = {};
3729+
3730+ memset(results, 0, sizeof(*results));
3731+
3732+ skl_compute_wm_global_parameters(dev, &config);
3733+
3734+ if (!skl_update_pipe_wm(crtc, &params, &config,
3735+ &results->ddb, &pipe_wm))
3736+ return;
3737+
3738+ skl_compute_wm_results(dev, &params, &pipe_wm, results, intel_crtc);
3739+ results->dirty[intel_crtc->pipe] = true;
3740+
3741+ skl_update_other_pipe_wm(dev, crtc, &config, results);
3742+ skl_write_wm_values(dev_priv, results);
3743+ skl_flush_wm_values(dev_priv, results);
3744+
3745+ /* store the new configuration */
3746+ dev_priv->wm.skl_hw = *results;
3747+}
3748+
3749+static void
3750+skl_update_sprite_wm(struct drm_plane *plane, struct drm_crtc *crtc,
3751+ uint32_t sprite_width, uint32_t sprite_height,
3752+ int pixel_size, bool enabled, bool scaled)
3753+{
3754+ struct intel_plane *intel_plane = to_intel_plane(plane);
3755+
3756+ intel_plane->wm.enabled = enabled;
3757+ intel_plane->wm.scaled = scaled;
3758+ intel_plane->wm.horiz_pixels = sprite_width;
3759+ intel_plane->wm.vert_pixels = sprite_height;
3760+ intel_plane->wm.bytes_per_pixel = pixel_size;
3761+
3762+ skl_update_wm(crtc);
3763+}
3764+
29083765 static void ilk_update_wm(struct drm_crtc *crtc)
29093766 {
29103767 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
@@ -2979,6 +3836,113 @@ ilk_update_sprite_wm(struct drm_plane *plane, · 68 unmodified lines
29793836 ilk_update_wm(crtc);
29803837 }
29813838
3839+static void skl_pipe_wm_active_state(uint32_t val,
3840+ struct skl_pipe_wm *active,
3841+ bool is_transwm,
3842+ bool is_cursor,
3843+ int i,
3844+ int level)
3845+{
3846+ bool is_enabled = (val & PLANE_WM_EN) != 0;
3847+
3848+ if (!is_transwm) {
3849+ if (!is_cursor) {
3850+ active->wm[level].plane_en[i] = is_enabled;
3851+ active->wm[level].plane_res_b[i] =
3852+ val & PLANE_WM_BLOCKS_MASK;
3853+ active->wm[level].plane_res_l[i] =
3854+ (val >> PLANE_WM_LINES_SHIFT) &
3855+ PLANE_WM_LINES_MASK;
3856+ } else {
3857+ active->wm[level].cursor_en = is_enabled;
3858+ active->wm[level].cursor_res_b =
3859+ val & PLANE_WM_BLOCKS_MASK;
3860+ active->wm[level].cursor_res_l =
3861+ (val >> PLANE_WM_LINES_SHIFT) &
3862+ PLANE_WM_LINES_MASK;
3863+ }
3864+ } else {
3865+ if (!is_cursor) {
3866+ active->trans_wm.plane_en[i] = is_enabled;
3867+ active->trans_wm.plane_res_b[i] =
3868+ val & PLANE_WM_BLOCKS_MASK;
3869+ active->trans_wm.plane_res_l[i] =
3870+ (val >> PLANE_WM_LINES_SHIFT) &
3871+ PLANE_WM_LINES_MASK;
3872+ } else {
3873+ active->trans_wm.cursor_en = is_enabled;
3874+ active->trans_wm.cursor_res_b =
3875+ val & PLANE_WM_BLOCKS_MASK;
3876+ active->trans_wm.cursor_res_l =
3877+ (val >> PLANE_WM_LINES_SHIFT) &
3878+ PLANE_WM_LINES_MASK;
3879+ }
3880+ }
3881+}
3882+
3883+static void skl_pipe_wm_get_hw_state(struct drm_crtc *crtc)
3884+{
3885+ struct drm_device *dev = crtc->dev;
3886+ struct drm_i915_private *dev_priv = dev->dev_private;
3887+ struct skl_wm_values *hw = &dev_priv->wm.skl_hw;
3888+ struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
3889+ struct skl_pipe_wm *active = &intel_crtc->wm.skl_active;
3890+ enum pipe pipe = intel_crtc->pipe;
3891+ int level, i, max_level;
3892+ uint32_t temp;
3893+
3894+ max_level = ilk_wm_max_level(dev);
3895+
3896+ hw->wm_linetime[pipe] = I915_READ(PIPE_WM_LINETIME(pipe));
3897+
3898+ for (level = 0; level <= max_level; level++) {
3899+ for (i = 0; i < intel_num_planes(intel_crtc); i++)
3900+ hw->plane[pipe][i][level] =
3901+ I915_READ(PLANE_WM(pipe, i, level));
3902+ hw->cursor[pipe][level] = I915_READ(CUR_WM(pipe, level));
3903+ }
3904+
3905+ for (i = 0; i < intel_num_planes(intel_crtc); i++)
3906+ hw->plane_trans[pipe][i] = I915_READ(PLANE_WM_TRANS(pipe, i));
3907+ hw->cursor_trans[pipe] = I915_READ(CUR_WM_TRANS(pipe));
3908+
3909+ if (!intel_crtc_active(crtc))
3910+ return;
3911+
3912+ hw->dirty[pipe] = true;
3913+
3914+ active->linetime = hw->wm_linetime[pipe];
3915+
3916+ for (level = 0; level <= max_level; level++) {
3917+ for (i = 0; i < intel_num_planes(intel_crtc); i++) {
3918+ temp = hw->plane[pipe][i][level];
3919+ skl_pipe_wm_active_state(temp, active, false,
3920+ false, i, level);
3921+ }
3922+ temp = hw->cursor[pipe][level];
3923+ skl_pipe_wm_active_state(temp, active, false, true, i, level);
3924+ }
3925+
3926+ for (i = 0; i < intel_num_planes(intel_crtc); i++) {
3927+ temp = hw->plane_trans[pipe][i];
3928+ skl_pipe_wm_active_state(temp, active, true, false, i, 0);
3929+ }
3930+
3931+ temp = hw->cursor_trans[pipe];
3932+ skl_pipe_wm_active_state(temp, active, true, true, i, 0);
3933+}
3934+
3935+void skl_wm_get_hw_state(struct drm_device *dev)
3936+{
3937+ struct drm_i915_private *dev_priv = dev->dev_private;
3938+ struct skl_ddb_allocation *ddb = &dev_priv->wm.skl_hw.ddb;
3939+ struct drm_crtc *crtc;
3940+
3941+ skl_ddb_get_hw_state(dev_priv, ddb);
3942+ list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
3943+ skl_pipe_wm_get_hw_state(crtc);
3944+}
3945+
29823946 static void ilk_pipe_wm_get_hw_state(struct drm_crtc *crtc)
29833947 {
29843948 struct drm_device *dev = crtc->dev;
@@ -3575,6 +4539,13 @@ static void gen8_disable_rps_interrupts(struct drm_device *dev) · 590 unmodified lines
35754539 I915_WRITE(GEN8_GT_IIR(2), dev_priv->pm_rps_events);
35764540 }
35774541
4542+static void gen9_disable_rps(struct drm_device *dev)
4543+{
4544+ struct drm_i915_private *dev_priv = dev->dev_private;
4545+
4546+ I915_WRITE(GEN6_RC_CONTROL, 0);
4547+}
4548+
35784549 static void gen6_disable_rps_interrupts(struct drm_device *dev)
35794550 {
35804551 struct drm_i915_private *dev_priv = dev->dev_private;
@@ -3735,6 +4706,45 @@ static void parse_rp_state_cap(struct drm_i915_private *dev_priv, u32 rp_state_c · 154 unmodified lines
37354706 dev_priv->rps.min_freq_softlimit = dev_priv->rps.min_freq;
37364707 }
37374708
4709+static void gen9_enable_rps(struct drm_device *dev)
4710+{
4711+ struct drm_i915_private *dev_priv = dev->dev_private;
4712+ struct intel_engine_cs *ring;
4713+ uint32_t rc6_mask = 0;
4714+ int unused;
4715+
4716+ /* 1a: Software RC state - RC0 */
4717+ I915_WRITE(GEN6_RC_STATE, 0);
4718+
4719+ /* 1b: Get forcewake during program sequence. Although the driver
4720+ * hasn't enabled a state yet where we need forcewake, BIOS may have.*/
4721+ gen6_gt_force_wake_get(dev_priv, FORCEWAKE_ALL);
4722+
4723+ /* 2a: Disable RC states. */
4724+ I915_WRITE(GEN6_RC_CONTROL, 0);
4725+
4726+ /* 2b: Program RC6 thresholds.*/
4727+ I915_WRITE(GEN6_RC6_WAKE_RATE_LIMIT, 54 << 16);
4728+ I915_WRITE(GEN6_RC_EVALUATION_INTERVAL, 125000); /* 12500 * 1280ns */
4729+ I915_WRITE(GEN6_RC_IDLE_HYSTERSIS, 25); /* 25 * 1280ns */
4730+ for_each_ring(ring, dev_priv, unused)
4731+ I915_WRITE(RING_MAX_IDLE(ring->mmio_base), 10);
4732+ I915_WRITE(GEN6_RC_SLEEP, 0);
4733+ I915_WRITE(GEN6_RC6_THRESHOLD, 37500); /* 37.5/125ms per EI */
4734+
4735+ /* 3a: Enable RC6 */
4736+ if (intel_enable_rc6(dev) & INTEL_RC6_ENABLE)
4737+ rc6_mask = GEN6_RC_CTL_RC6_ENABLE;
4738+ DRM_INFO("RC6 %s\n", (rc6_mask & GEN6_RC_CTL_RC6_ENABLE) ?
4739+ "on" : "off");
4740+ I915_WRITE(GEN6_RC_CONTROL, GEN6_RC_CTL_HW_ENABLE |
4741+ GEN6_RC_CTL_EI_MODE(1) |
4742+ rc6_mask);
4743+
4744+ gen6_gt_force_wake_put(dev_priv, FORCEWAKE_ALL);
4745+
4746+}
4747+
37384748 static void gen8_enable_rps(struct drm_device *dev)
37394749 {
37404750 struct drm_i915_private *dev_priv = dev->dev_private;
@@ -5269,7 +6279,9 @@ void intel_disable_gt_powersave(struct drm_device *dev) · 1528 unmodified lines
52696279 intel_suspend_gt_powersave(dev);
52706280
52716281 mutex_lock(&dev_priv->rps.hw_lock);
5272− if (IS_CHERRYVIEW(dev))
6282+ if (INTEL_INFO(dev)->gen >= 9)
6283+ gen9_disable_rps(dev);
6284+ else if (IS_CHERRYVIEW(dev))
52736285 cherryview_disable_rps(dev);
52746286 else if (IS_VALLEYVIEW(dev))
52756287 valleyview_disable_rps(dev);
@@ -5293,6 +6305,8 @@ static void intel_gen6_powersave_work(struct work_struct *work) · 17 unmodified lines
52936305 cherryview_enable_rps(dev);
52946306 } else if (IS_VALLEYVIEW(dev)) {
52956307 valleyview_enable_rps(dev);
6308+ } else if (INTEL_INFO(dev)->gen >= 9) {
6309+ gen9_enable_rps(dev);
52966310 } else if (IS_BROADWELL(dev)) {
52976311 gen8_enable_rps(dev);
52986312 __gen6_update_ring_freq(dev);
@@ -6127,7 +7141,11 @@ void intel_init_pm(struct drm_device *dev) · 828 unmodified lines
61277141
61287142 /* For FIFO watermark updates */
61297143 if (IS_GEN9(dev)) {
7144+ skl_setup_wm_latency(dev);
7145+
61307146 dev_priv->display.init_clock_gating = gen9_init_clock_gating;
7147+ dev_priv->display.update_wm = skl_update_wm;
7148+ dev_priv->display.update_sprite_wm = skl_update_sprite_wm;
61317149 } else if (HAS_PCH_SPLIT(dev)) {
61327150 ilk_setup_wm_latency(dev);
61337151
@@ -6219,6 +7237,8 @@ int sandybridge_pcode_read(struct drm_i915_private *dev_priv, u8 mbox, u32 *val) · 85 unmodified lines
62197237 }
62207238
62217239 I915_WRITE(GEN6_PCODE_DATA, *val);
7240+ if (INTEL_INFO(dev_priv)->gen >= 9)
7241+ I915_WRITE(GEN9_PCODE_DATA1, 0);
62227242 I915_WRITE(GEN6_PCODE_MAILBOX, GEN6_PCODE_READY | mbox);
62237243
62247244 if (wait_for((I915_READ(GEN6_PCODE_MAILBOX) & GEN6_PCODE_READY) == 0,
drivers/gpu/drm/i915/intel_renderstate.h+1−0
@@ -29,6 +29,7 @@ · 28 unmodified lines
2929 extern const struct intel_renderstate_rodata gen6_null_state;
3030 extern const struct intel_renderstate_rodata gen7_null_state;
3131 extern const struct intel_renderstate_rodata gen8_null_state;
32+extern const struct intel_renderstate_rodata gen9_null_state;
3233
3334 #define RO_RENDERSTATE(_g) \
3435 const struct intel_renderstate_rodata gen ## _g ## _null_state = { \
drivers/gpu/drm/i915/intel_renderstate_gen8.c+640−162
@@ -1,70 +1,575 @@
11 #include "intel_renderstate.h"
22
33 static const u32 gen8_null_state_relocs[] = {
4− 0x00000048,
5− 0x00000050,
6− 0x00000060,
7− 0x000003ec,
4+ 0x00000798,
5+ 0x000007a4,
6+ 0x000007ac,
7+ 0x000007bc,
88 -1,
99 };
1010
1111 static const u32 gen8_null_state_batch[] = {
12+ 0x7a000004,
13+ 0x01000000,
14+ 0x00000000,
15+ 0x00000000,
16+ 0x00000000,
17+ 0x00000000,
1218 0x69040000,
13− 0x61020001,
19+ 0x78140000,
20+ 0x04000000,
21+ 0x7820000a,
22+ 0x00000000,
23+ 0x00000000,
24+ 0x80000000,
25+ 0x00000000,
26+ 0x00000000,
27+ 0x00000000,
28+ 0x00000000,
29+ 0x00000000,
30+ 0x00000000,
31+ 0x00000000,
32+ 0x00000000,
33+ 0x78130002,
34+ 0x00000000,
35+ 0x00000000,
36+ 0x02001808,
37+ 0x781f0002,
38+ 0x00000000,
39+ 0x00000000,
40+ 0x00000000,
41+ 0x78510009,
42+ 0x00000000,
43+ 0x00000000,
44+ 0x00000000,
45+ 0x00000000,
46+ 0x00000000,
47+ 0x00000000,
48+ 0x00000000,
49+ 0x00000000,
50+ 0x00000000,
51+ 0x00000000,
52+ 0x78100007,
53+ 0x00000000,
54+ 0x00000000,
55+ 0x00010000,
56+ 0x00000000,
57+ 0x00000000,
58+ 0x00000000,
59+ 0x00000000,
60+ 0x00000000,
61+ 0x781b0007,
62+ 0x00000000,
63+ 0x00000000,
64+ 0x00000000,
65+ 0x00000000,
66+ 0x00000000,
67+ 0x00000000,
68+ 0x00000800,
69+ 0x00000000,
70+ 0x78110008,
71+ 0x00000000,
72+ 0x00000000,
73+ 0x00000000,
74+ 0x00000000,
75+ 0x00000000,
76+ 0x00000000,
77+ 0x00000000,
78+ 0x00000000,
79+ 0x00000000,
80+ 0x781e0003,
81+ 0x00000000,
82+ 0x00000000,
83+ 0x00000000,
84+ 0x00000000,
85+ 0x781d0007,
86+ 0x00000000,
87+ 0x00000000,
88+ 0x00000000,
89+ 0x00000000,
90+ 0x00000000,
91+ 0x00000000,
92+ 0x00000000,
93+ 0x00000000,
94+ 0x78120002,
95+ 0x00000000,
96+ 0x00000000,
97+ 0x00000000,
98+ 0x78500003,
99+ 0x00000000,
100+ 0x00000000,
101+ 0x00000000,
102+ 0x00000000,
103+ 0x781c0002,
104+ 0x00000000,
105+ 0x00000000,
106+ 0x00000000,
107+ 0x780c0000,
108+ 0x00000000,
109+ 0x78520003,
110+ 0x00000000,
111+ 0x00000000,
112+ 0x00000000,
113+ 0x00000000,
114+ 0x78300000,
115+ 0x08010040,
116+ 0x78310000,
117+ 0x1e000000,
118+ 0x78320000,
119+ 0x1e000000,
120+ 0x78330000,
121+ 0x1e000000,
122+ 0x79190002,
123+ 0x00000000,
124+ 0x00000000,
125+ 0x00000000,
126+ 0x791a0002,
127+ 0x00000000,
128+ 0x00000000,
129+ 0x00000000,
130+ 0x791b0002,
131+ 0x00000000,
132+ 0x00000000,
133+ 0x00000000,
134+ 0x79120000,
135+ 0x00000000,
136+ 0x79130000,
137+ 0x00000000,
138+ 0x79140000,
139+ 0x00000000,
140+ 0x79150000,
141+ 0x00000000,
142+ 0x79160000,
143+ 0x00000000,
144+ 0x78150009,
145+ 0x00000000,
146+ 0x00000000,
147+ 0x00000000,
148+ 0x00000000,
149+ 0x00000000,
150+ 0x00000000,
151+ 0x00000000,
152+ 0x00000000,
153+ 0x00000000,
154+ 0x00000000,
155+ 0x78190009,
156+ 0x00000000,
157+ 0x00000000,
158+ 0x00000000,
159+ 0x00000000,
160+ 0x00000000,
161+ 0x00000000,
162+ 0x00000000,
163+ 0x00000000,
164+ 0x00000000,
165+ 0x00000000,
166+ 0x781a0009,
167+ 0x00000000,
168+ 0x00000000,
169+ 0x00000000,
170+ 0x00000000,
171+ 0x00000000,
172+ 0x00000000,
173+ 0x00000000,
174+ 0x00000000,
175+ 0x00000000,
176+ 0x00000000,
177+ 0x78160009,
178+ 0x00000000,
179+ 0x00000000,
180+ 0x00000000,
181+ 0x00000000,
182+ 0x00000000,
183+ 0x00000000,
184+ 0x00000000,
185+ 0x00000000,
186+ 0x00000000,
187+ 0x00000000,
188+ 0x78170009,
189+ 0x00000000,
190+ 0x00000000,
191+ 0x00000000,
192+ 0x00000000,
193+ 0x00000000,
194+ 0x00000000,
195+ 0x00000000,
196+ 0x00000000,
197+ 0x00000000,
198+ 0x00000000,
199+ 0x78490001,
200+ 0x00000000,
201+ 0x00000000,
202+ 0x784a0000,
203+ 0x00000000,
204+ 0x784b0000,
205+ 0x00000004,
206+ 0x79170101,
207+ 0x00000000,
208+ 0x00000080,
209+ 0x00000000,
210+ 0x00000000,
211+ 0x00000000,
212+ 0x00000000,
213+ 0x00000000,
214+ 0x00000000,
215+ 0x00000000,
216+ 0x00000000,
217+ 0x00000000,
218+ 0x00000000,
219+ 0x00000000,
220+ 0x00000000,
221+ 0x00000000,
222+ 0x00000000,
223+ 0x00000000,
224+ 0x00000000,
225+ 0x00000000,
226+ 0x00000000,
227+ 0x00000000,
228+ 0x00000000,
229+ 0x00000000,
230+ 0x00000000,
231+ 0x00000000,
232+ 0x00000000,
233+ 0x00000000,
234+ 0x00000000,
235+ 0x00000000,
236+ 0x00000000,
237+ 0x00000000,
238+ 0x00000000,
239+ 0x00000000,
240+ 0x00000000,
241+ 0x00000000,
242+ 0x00000000,
243+ 0x00000000,
244+ 0x00000000,
245+ 0x00000000,
246+ 0x00000000,
247+ 0x00000000,
248+ 0x00000000,
249+ 0x00000000,
250+ 0x00000000,
251+ 0x00000000,
252+ 0x00000000,
253+ 0x00000000,
254+ 0x00000000,
255+ 0x00000000,
256+ 0x00000000,
257+ 0x00000000,
258+ 0x00000000,
259+ 0x00000000,
260+ 0x00000000,
261+ 0x00000000,
262+ 0x00000000,
263+ 0x00000000,
264+ 0x00000000,
265+ 0x00000000,
266+ 0x00000000,
267+ 0x00000000,
268+ 0x00000000,
269+ 0x00000000,
270+ 0x00000000,
271+ 0x00000000,
272+ 0x00000000,
273+ 0x00000000,
274+ 0x00000000,
275+ 0x00000000,
276+ 0x00000000,
277+ 0x00000000,
278+ 0x00000000,
279+ 0x00000000,
280+ 0x00000000,
281+ 0x00000000,
282+ 0x00000000,
283+ 0x00000000,
284+ 0x00000000,
285+ 0x00000000,
286+ 0x00000000,
287+ 0x00000000,
288+ 0x00000000,
289+ 0x00000000,
290+ 0x00000000,
291+ 0x00000000,
292+ 0x00000000,
293+ 0x00000000,
294+ 0x00000000,
295+ 0x00000000,
296+ 0x00000000,
297+ 0x00000000,
298+ 0x00000000,
299+ 0x00000000,
300+ 0x00000000,
301+ 0x00000000,
302+ 0x00000000,
303+ 0x00000000,
304+ 0x00000000,
305+ 0x00000000,
306+ 0x00000000,
307+ 0x00000000,
308+ 0x00000000,
309+ 0x00000000,
310+ 0x00000000,
311+ 0x00000000,
312+ 0x00000000,
313+ 0x00000000,
314+ 0x00000000,
315+ 0x00000000,
316+ 0x00000000,
317+ 0x00000000,
318+ 0x00000000,
319+ 0x00000000,
320+ 0x00000000,
321+ 0x00000000,
322+ 0x00000000,
323+ 0x00000000,
324+ 0x00000000,
325+ 0x00000000,
326+ 0x00000000,
327+ 0x00000000,
328+ 0x00000000,
329+ 0x00000000,
330+ 0x00000000,
331+ 0x00000000,
332+ 0x00000000,
333+ 0x00000000,
334+ 0x00000000,
335+ 0x00000000,
336+ 0x00000000,
337+ 0x00000000,
338+ 0x00000000,
339+ 0x00000000,
340+ 0x00000000,
341+ 0x00000000,
342+ 0x00000000,
343+ 0x00000000,
344+ 0x00000000,
345+ 0x00000000,
346+ 0x00000000,
347+ 0x00000000,
348+ 0x00000000,
349+ 0x00000000,
350+ 0x00000000,
351+ 0x00000000,
352+ 0x00000000,
353+ 0x00000000,
354+ 0x00000000,
355+ 0x00000000,
356+ 0x00000000,
357+ 0x00000000,
358+ 0x00000000,
359+ 0x00000000,
360+ 0x00000000,
361+ 0x00000000,
362+ 0x00000000,
363+ 0x00000000,
364+ 0x00000000,
365+ 0x00000000,
366+ 0x00000000,
367+ 0x00000000,
368+ 0x00000000,
369+ 0x00000000,
370+ 0x00000000,
371+ 0x00000000,
372+ 0x00000000,
373+ 0x00000000,
374+ 0x00000000,
375+ 0x00000000,
376+ 0x00000000,
377+ 0x00000000,
378+ 0x00000000,
379+ 0x00000000,
380+ 0x00000000,
381+ 0x00000000,
382+ 0x00000000,
383+ 0x00000000,
384+ 0x00000000,
385+ 0x00000000,
386+ 0x00000000,
387+ 0x00000000,
388+ 0x00000000,
389+ 0x00000000,
390+ 0x00000000,
391+ 0x00000000,
392+ 0x00000000,
393+ 0x00000000,
394+ 0x00000000,
395+ 0x00000000,
396+ 0x00000000,
14397 0x00000000,
15398 0x00000000,
16− 0x79120000,
17399 0x00000000,
18− 0x79130000,
19400 0x00000000,
20− 0x79140000,
21401 0x00000000,
22− 0x79150000,
23402 0x00000000,
24− 0x79160000,
25403 0x00000000,
26− 0x6101000e,
27− 0x00000001,
28404 0x00000000,
29− 0x00000001,
405+ 0x00000000,
406+ 0x00000000,
407+ 0x00000000,
408+ 0x00000000,
409+ 0x00000000,
410+ 0x00000000,
411+ 0x00000000,
412+ 0x00000000,
413+ 0x00000000,
414+ 0x00000000,
415+ 0x00000000,
416+ 0x00000000,
417+ 0x00000000,
418+ 0x00000000,
419+ 0x00000000,
420+ 0x00000000,
421+ 0x00000000,
422+ 0x00000000,
423+ 0x00000000,
424+ 0x00000000,
425+ 0x00000000,
426+ 0x00000000,
427+ 0x00000000,
428+ 0x00000000,
429+ 0x00000000,
430+ 0x00000000,
431+ 0x00000000,
432+ 0x00000000,
433+ 0x00000000,
434+ 0x00000000,
435+ 0x00000000,
436+ 0x00000000,
437+ 0x00000000,
438+ 0x00000000,
439+ 0x00000000,
440+ 0x00000000,
441+ 0x00000000,
442+ 0x00000000,
443+ 0x00000000,
444+ 0x00000000,
445+ 0x00000000,
446+ 0x00000000,
447+ 0x00000000,
448+ 0x00000000,
449+ 0x00000000,
450+ 0x00000000,
451+ 0x00000000,
452+ 0x00000000,
453+ 0x00000000,
454+ 0x00000000,
455+ 0x00000000,
456+ 0x00000000,
457+ 0x00000000,
458+ 0x00000000,
459+ 0x00000000,
460+ 0x00000000,
461+ 0x00000000,
462+ 0x00000000,
463+ 0x00000000,
464+ 0x00000000,
465+ 0x79180006,
466+ 0x00000000,
467+ 0x00000000,
468+ 0x00000000,
469+ 0x00000000,
470+ 0x00000000,
471+ 0x00000000,
472+ 0x00000000,
473+ 0x79180006,
474+ 0x20000000,
475+ 0x00000000,
476+ 0x00000000,
477+ 0x00000000,
478+ 0x00000000,
479+ 0x00000000,
480+ 0x00000000,
481+ 0x79180006,
482+ 0x40000000,
483+ 0x00000000,
484+ 0x00000000,
485+ 0x00000000,
486+ 0x00000000,
487+ 0x00000000,
488+ 0x00000000,
489+ 0x79180006,
490+ 0x60000000,
491+ 0x00000000,
492+ 0x00000000,
493+ 0x00000000,
494+ 0x00000000,
495+ 0x00000000,
496+ 0x00000000,
497+ 0x6101000e,
30498 0x00000001, /* reloc */
31499 0x00000000,
500+ 0x00000000,
32501 0x00000001, /* reloc */
33502 0x00000000,
503+ 0x00000001, /* reloc */
34504 0x00000000,
505+ 0x00000001,
35506 0x00000000,
36507 0x00000001, /* reloc */
37508 0x00000000,
38− 0xfffff001,
39509 0x00001001,
40− 0xfffff001,
41510 0x00001001,
42− 0x78230000,
43− 0x000006e0,
44− 0x78210000,
45− 0x00000700,
46− 0x78300000,
47− 0x08010040,
48− 0x78330000,
49− 0x08000000,
50− 0x78310000,
51− 0x08000000,
52− 0x78320000,
53− 0x08000000,
54− 0x78240000,
55− 0x00000641,
56− 0x780e0000,
57− 0x00000601,
511+ 0x00000001,
512+ 0x00001001,
513+ 0x61020001,
514+ 0x00000000,
515+ 0x00000000,
516+ 0x79000002,
517+ 0x00000000,
518+ 0x00000000,
519+ 0x00000000,
520+ 0x78050006,
521+ 0x00000000,
522+ 0x00000000,
523+ 0x00000000,
524+ 0x00000000,
525+ 0x00000000,
526+ 0x00000000,
527+ 0x00000000,
528+ 0x79040002,
529+ 0x00000000,
530+ 0x00000000,
531+ 0x00000000,
532+ 0x79040002,
533+ 0x40000000,
534+ 0x00000000,
535+ 0x00000000,
536+ 0x79040002,
537+ 0x80000000,
538+ 0x00000000,
539+ 0x00000000,
540+ 0x79040002,
541+ 0xc0000000,
542+ 0x00000000,
543+ 0x00000000,
544+ 0x79080001,
545+ 0x00000000,
546+ 0x00000000,
547+ 0x790a0001,
548+ 0x00000000,
549+ 0x00000000,
550+ 0x78060003,
551+ 0x00000000,
552+ 0x00000000,
553+ 0x00000000,
554+ 0x00000000,
555+ 0x78070003,
556+ 0x00000000,
557+ 0x00000000,
558+ 0x00000000,
559+ 0x00000000,
560+ 0x78040001,
561+ 0x00000000,
562+ 0x00000000,
563+ 0x79110000,
564+ 0x00000000,
58565 0x780d0000,
59566 0x00000000,
60− 0x78180000,
61− 0x00000001,
62− 0x78520003,
567+ 0x79060000,
63568 0x00000000,
569+ 0x7907001f,
64570 0x00000000,
65571 0x00000000,
66572 0x00000000,
67− 0x78190009,
68573 0x00000000,
69574 0x00000000,
70575 0x00000000,
@@ -75,7 +580,6 @@ static const u32 gen8_null_state_batch[] = { · 4 unmodified lines
75580 0x00000000,
76581 0x00000000,
77582 0x00000000,
78− 0x781b0007,
79583 0x00000000,
80584 0x00000000,
81585 0x00000000,
@@ -84,26 +588,22 @@ static const u32 gen8_null_state_batch[] = { · 2 unmodified lines
84588 0x00000000,
85589 0x00000000,
86590 0x00000000,
87− 0x78270000,
88591 0x00000000,
89− 0x782c0000,
90592 0x00000000,
91− 0x781c0002,
92593 0x00000000,
93594 0x00000000,
94595 0x00000000,
95− 0x78160009,
96596 0x00000000,
97597 0x00000000,
98598 0x00000000,
99599 0x00000000,
100600 0x00000000,
101601 0x00000000,
602+ 0x7902000f,
102603 0x00000000,
103604 0x00000000,
104605 0x00000000,
105606 0x00000000,
106− 0x78110008,
107607 0x00000000,
108608 0x00000000,
109609 0x00000000,
@@ -113,12 +613,10 @@ static const u32 gen8_null_state_batch[] = { · 3 unmodified lines
113613 0x00000000,
114614 0x00000000,
115615 0x00000000,
116− 0x78290000,
117616 0x00000000,
118− 0x782e0000,
119617 0x00000000,
120− 0x781a0009,
121618 0x00000000,
619+ 0x790c000f,
122620 0x00000000,
123621 0x00000000,
124622 0x00000000,
@@ -128,7 +626,6 @@ static const u32 gen8_null_state_batch[] = { · 3 unmodified lines
128626 0x00000000,
129627 0x00000000,
130628 0x00000000,
131− 0x781d0007,
132629 0x00000000,
133630 0x00000000,
134631 0x00000000,
@@ -136,153 +633,153 @@ static const u32 gen8_null_state_batch[] = { · 1 unmodified line
136633 0x00000000,
137634 0x00000000,
138635 0x00000000,
636+ 0x780a0003,
139637 0x00000000,
140− 0x78280000,
141638 0x00000000,
142− 0x782d0000,
143639 0x00000000,
144− 0x78260000,
145640 0x00000000,
146− 0x782b0000,
641+ 0x78080083,
642+ 0x00004000,
147643 0x00000000,
148− 0x78150009,
149644 0x00000000,
150645 0x00000000,
646+ 0x04004000,
151647 0x00000000,
152648 0x00000000,
153649 0x00000000,
650+ 0x08004000,
154651 0x00000000,
155652 0x00000000,
156653 0x00000000,
654+ 0x0c004000,
157655 0x00000000,
158656 0x00000000,
159− 0x78100007,
160657 0x00000000,
658+ 0x10004000,
161659 0x00000000,
162660 0x00000000,
163661 0x00000000,
662+ 0x14004000,
164663 0x00000000,
165664 0x00000000,
166665 0x00000000,
666+ 0x18004000,
167667 0x00000000,
168− 0x781e0003,
169668 0x00000000,
170669 0x00000000,
670+ 0x1c004000,
171671 0x00000000,
172672 0x00000000,
173− 0x78120002,
174673 0x00000000,
674+ 0x20004000,
175675 0x00000000,
176676 0x00000000,
177− 0x781f0002,
178− 0x30400820,
179677 0x00000000,
678+ 0x24004000,
180679 0x00000000,
181− 0x78510009,
182680 0x00000000,
183681 0x00000000,
682+ 0x28004000,
184683 0x00000000,
185684 0x00000000,
186685 0x00000000,
686+ 0x2c004000,
187687 0x00000000,
188688 0x00000000,
189689 0x00000000,
690+ 0x30004000,
190691 0x00000000,
191692 0x00000000,
192− 0x78500003,
193− 0x00210000,
194693 0x00000000,
694+ 0x34004000,
195695 0x00000000,
196696 0x00000000,
197− 0x78130002,
198697 0x00000000,
698+ 0x38004000,
199699 0x00000000,
200700 0x00000000,
201− 0x782a0000,
202− 0x00000480,
203− 0x782f0000,
204− 0x00000540,
205− 0x78140000,
206− 0x00000800,
207− 0x78170009,
208701 0x00000000,
702+ 0x3c004000,
209703 0x00000000,
210704 0x00000000,
211705 0x00000000,
706+ 0x40004000,
212707 0x00000000,
213708 0x00000000,
214709 0x00000000,
710+ 0x44004000,
215711 0x00000000,
216712 0x00000000,
217713 0x00000000,
218− 0x7820000a,
219− 0x00000580,
714+ 0x48004000,
220715 0x00000000,
221− 0x08080000,
222716 0x00000000,
223717 0x00000000,
224− 0x1f000002,
225− 0x00060000,
718+ 0x4c004000,
226719 0x00000000,
227720 0x00000000,
228721 0x00000000,
722+ 0x50004000,
229723 0x00000000,
230− 0x784d0000,
231− 0x40000000,
232− 0x784f0000,
233− 0x80000100,
234− 0x780f0000,
235− 0x00000740,
236− 0x78050006,
237724 0x00000000,
238725 0x00000000,
726+ 0x54004000,
239727 0x00000000,
240728 0x00000000,
241729 0x00000000,
730+ 0x58004000,
242731 0x00000000,
243732 0x00000000,
244− 0x78070003,
245733 0x00000000,
734+ 0x5c004000,
246735 0x00000000,
247736 0x00000000,
248737 0x00000000,
249− 0x78060003,
738+ 0x60004000,
250739 0x00000000,
251740 0x00000000,
252741 0x00000000,
742+ 0x64004000,
253743 0x00000000,
254− 0x78040001,
255744 0x00000000,
256− 0x00000001,
257− 0x79000002,
258− 0xffffffff,
745+ 0x00000000,
746+ 0x68004000,
747+ 0x00000000,
748+ 0x00000000,
749+ 0x00000000,
750+ 0x6c004000,
751+ 0x00000000,
752+ 0x00000000,
753+ 0x00000000,
754+ 0x70004000,
755+ 0x00000000,
756+ 0x00000000,
757+ 0x00000000,
758+ 0x74004000,
759+ 0x00000000,
760+ 0x00000000,
761+ 0x00000000,
762+ 0x78004000,
763+ 0x00000000,
259764 0x00000000,
260765 0x00000000,
261− 0x78080003,
262− 0x00006000,
263− 0x000005e0, /* reloc */
766+ 0x7c004000,
264767 0x00000000,
265768 0x00000000,
266− 0x78090005,
769+ 0x00000000,
770+ 0x80004000,
771+ 0x00000000,
772+ 0x00000000,
773+ 0x00000000,
774+ 0x78090043,
267775 0x02000000,
268776 0x22220000,
269− 0x02f60000,
270− 0x11230000,
271− 0x02850004,
272− 0x11230000,
273− 0x784b0000,
274− 0x0000000f,
275− 0x78490001,
276777 0x00000000,
277778 0x00000000,
278− 0x7b000005,
279779 0x00000000,
280− 0x00000003,
281780 0x00000000,
282− 0x00000001,
283781 0x00000000,
284782 0x00000000,
285− 0x05000000, /* cmds end */
286783 0x00000000,
287784 0x00000000,
288785 0x00000000,
@@ -297,8 +794,6 @@ static const u32 gen8_null_state_batch[] = { · 8 unmodified lines
297794 0x00000000,
298795 0x00000000,
299796 0x00000000,
300− 0x000004c0, /* state start */
301− 0x00000500,
302797 0x00000000,
303798 0x00000000,
304799 0x00000000,
@@ -345,46 +840,65 @@ static const u32 gen8_null_state_batch[] = { · 40 unmodified lines
345840 0x00000000,
346841 0x00000000,
347842 0x00000000,
843+ 0x680b0001,
844+ 0x78260000,
845+ 0x00000000,
846+ 0x78270000,
847+ 0x00000000,
848+ 0x78280000,
849+ 0x00000000,
850+ 0x78290000,
851+ 0x00000000,
852+ 0x782a0000,
853+ 0x00000000,
854+ 0x780e0000,
855+ 0x00000dc1,
856+ 0x78240000,
857+ 0x00000e01,
858+ 0x784f0000,
859+ 0x80000100,
860+ 0x784d0000,
861+ 0x40000000,
862+ 0x782b0000,
863+ 0x00000000,
864+ 0x782c0000,
865+ 0x00000000,
866+ 0x782d0000,
867+ 0x00000000,
868+ 0x782e0000,
869+ 0x00000000,
870+ 0x782f0000,
871+ 0x00000000,
872+ 0x780f0000,
348873 0x00000000,
874+ 0x78230000,
875+ 0x00000e60,
876+ 0x78210000,
877+ 0x00000e80,
878+ 0x7b000005,
879+ 0x00000004,
880+ 0x00000001,
349881 0x00000000,
882+ 0x00000001,
350883 0x00000000,
351− 0x00000092,
352884 0x00000000,
885+ 0x05000000, /* cmds end */
353886 0x00000000,
354887 0x00000000,
355888 0x00000000,
356889 0x00000000,
357890 0x00000000,
358891 0x00000000,
892+ 0x00000000, /* state start */
359893 0x00000000,
894+ 0x3f800000,
895+ 0x3f800000,
896+ 0x3f800000,
897+ 0x3f800000,
360898 0x00000000,
361899 0x00000000,
362900 0x00000000,
363901 0x00000000,
364− 0x0060005a,
365− 0x21403ae8,
366− 0x3a0000c0,
367− 0x008d0040,
368− 0x0060005a,
369− 0x21603ae8,
370− 0x3a0000c0,
371− 0x008d0080,
372− 0x0060005a,
373− 0x21803ae8,
374− 0x3a0000d0,
375− 0x008d0040,
376− 0x0060005a,
377− 0x21a03ae8,
378− 0x3a0000d0,
379− 0x008d0080,
380− 0x02800031,
381− 0x2e0022e8,
382− 0x0e000140,
383− 0x08840001,
384− 0x05800031,
385− 0x200022e0,
386− 0x0e000e00,
387− 0x90031000,
388902 0x00000000,
389903 0x00000000,
390904 0x00000000,
@@ -410,38 +924,6 @@ static const u32 gen8_null_state_batch[] = { · 19 unmodified lines
410924 0x00000000,
411925 0x00000000,
412926 0x00000000,
413− 0x06200000,
414− 0x00000002,
415− 0x06200000,
416− 0x00000002,
417− 0x06200000,
418− 0x00000002,
419− 0x06200000,
420− 0x00000002,
421− 0x06200000,
422− 0x00000002,
423− 0x06200000,
424− 0x00000002,
425− 0x06200000,
426− 0x00000002,
427− 0x06200000,
428− 0x00000002,
429− 0x06200000,
430− 0x00000002,
431− 0x06200000,
432− 0x00000002,
433− 0x06200000,
434− 0x00000002,
435− 0x06200000,
436− 0x00000002,
437− 0x06200000,
438− 0x00000002,
439− 0x06200000,
440− 0x00000002,
441− 0x06200000,
442− 0x00000002,
443− 0x06200000,
444− 0x00000002,
445927 0x00000000,
446928 0x00000000,
447929 0x00000000,
@@ -449,8 +931,6 @@ static const u32 gen8_null_state_batch[] = { · 1 unmodified line
449931 0x00000000,
450932 0x00000000,
451933 0x00000000,
452− 0xf99a130c,
453− 0x799a130c,
454934 0x00000000,
455935 0x00000000,
456936 0x00000000,
@@ -466,9 +946,7 @@ static const u32 gen8_null_state_batch[] = { · 9 unmodified lines
466946 0x00000000,
467947 0x00000000,
468948 0x00000000,
469− 0x3f800000,
470949 0x00000000,
471− 0x3f800000,
472950 0x00000000,
473951 0x00000000,
474952 0x00000000,
drivers/gpu/drm/i915/intel_renderstate_gen9.c+974−0
@@ -0,0 +1,974 @@
1+#include "intel_renderstate.h"
2+
3+static const u32 gen9_null_state_relocs[] = {
4+ 0x000007a8,
5+ 0x000007b4,
6+ 0x000007bc,
7+ 0x000007cc,
8+ -1,
9+};
10+
11+static const u32 gen9_null_state_batch[] = {
12+ 0x7a000004,
13+ 0x01000000,
14+ 0x00000000,
15+ 0x00000000,
16+ 0x00000000,
17+ 0x00000000,
18+ 0x69040300,
19+ 0x78140000,
20+ 0x04000000,
21+ 0x7820000a,
22+ 0x00000000,
23+ 0x00000000,
24+ 0x80000000,
25+ 0x00000000,
26+ 0x00000000,
27+ 0x00000000,
28+ 0x00000000,
29+ 0x00000000,
30+ 0x00000000,
31+ 0x00000000,
32+ 0x00000000,
33+ 0x78130002,
34+ 0x00000000,
35+ 0x00000000,
36+ 0x02001808,
37+ 0x781f0004,
38+ 0x00000000,
39+ 0x00000000,
40+ 0x00000000,
41+ 0x00000000,
42+ 0x00000000,
43+ 0x78510009,
44+ 0x00000000,
45+ 0x00000000,
46+ 0x00000000,
47+ 0x00000000,
48+ 0x00000000,
49+ 0x00000000,
50+ 0x00000000,
51+ 0x00000000,
52+ 0x00000000,
53+ 0x00000000,
54+ 0x78100007,
55+ 0x00000000,
56+ 0x00000000,
57+ 0x00010000,
58+ 0x00000000,
59+ 0x00000000,
60+ 0x00000000,
61+ 0x00000000,
62+ 0x00000000,
63+ 0x781b0007,
64+ 0x00000000,
65+ 0x00000000,
66+ 0x00000000,
67+ 0x00000000,
68+ 0x00000000,
69+ 0x00000000,
70+ 0x00000800,
71+ 0x00000000,
72+ 0x78110008,
73+ 0x00000000,
74+ 0x00000000,
75+ 0x00000000,
76+ 0x00000000,
77+ 0x00000000,
78+ 0x00000000,
79+ 0x00000000,
80+ 0x00000000,
81+ 0x00000000,
82+ 0x781e0003,
83+ 0x00000000,
84+ 0x00000000,
85+ 0x00000000,
86+ 0x00000000,
87+ 0x781d0009,
88+ 0x00000000,
89+ 0x00000000,
90+ 0x00000000,
91+ 0x00000000,
92+ 0x00000000,
93+ 0x00000000,
94+ 0x00000000,
95+ 0x00000000,
96+ 0x00000000,
97+ 0x00000000,
98+ 0x78120002,
99+ 0x00000000,
100+ 0x00000000,
101+ 0x00000000,
102+ 0x78500003,
103+ 0x00000000,
104+ 0x00000000,
105+ 0x00000000,
106+ 0x00000000,
107+ 0x781c0002,
108+ 0x00000000,
109+ 0x00000000,
110+ 0x00000000,
111+ 0x780c0000,
112+ 0x00000000,
113+ 0x78520003,
114+ 0x00000000,
115+ 0x00000000,
116+ 0x00000000,
117+ 0x00000000,
118+ 0x78300000,
119+ 0x08010040,
120+ 0x78310000,
121+ 0x1e000000,
122+ 0x78320000,
123+ 0x1e000000,
124+ 0x78330000,
125+ 0x1e000000,
126+ 0x79190002,
127+ 0x00000000,
128+ 0x00000000,
129+ 0x00000000,
130+ 0x791a0002,
131+ 0x00000000,
132+ 0x00000000,
133+ 0x00000000,
134+ 0x791b0002,
135+ 0x00000000,
136+ 0x00000000,
137+ 0x00000000,
138+ 0x79120000,
139+ 0x00000000,
140+ 0x79130000,
141+ 0x00000000,
142+ 0x79140000,
143+ 0x00000000,
144+ 0x79150000,
145+ 0x00000000,
146+ 0x79160000,
147+ 0x00000000,
148+ 0x78150009,
149+ 0x00000000,
150+ 0x00000000,
151+ 0x00000000,
152+ 0x00000000,
153+ 0x00000000,
154+ 0x00000000,
155+ 0x00000000,
156+ 0x00000000,
157+ 0x00000000,
158+ 0x00000000,
159+ 0x78190009,
160+ 0x00000000,
161+ 0x00000000,
162+ 0x00000000,
163+ 0x00000000,
164+ 0x00000000,
165+ 0x00000000,
166+ 0x00000000,
167+ 0x00000000,
168+ 0x00000000,
169+ 0x00000000,
170+ 0x781a0009,
171+ 0x00000000,
172+ 0x00000000,
173+ 0x00000000,
174+ 0x00000000,
175+ 0x00000000,
176+ 0x00000000,
177+ 0x00000000,
178+ 0x00000000,
179+ 0x00000000,
180+ 0x00000000,
181+ 0x78160009,
182+ 0x00000000,
183+ 0x00000000,
184+ 0x00000000,
185+ 0x00000000,
186+ 0x00000000,
187+ 0x00000000,
188+ 0x00000000,
189+ 0x00000000,
190+ 0x00000000,
191+ 0x00000000,
192+ 0x78170009,
193+ 0x00000000,
194+ 0x00000000,
195+ 0x00000000,
196+ 0x00000000,
197+ 0x00000000,
198+ 0x00000000,
199+ 0x00000000,
200+ 0x00000000,
201+ 0x00000000,
202+ 0x00000000,
203+ 0x78490001,
204+ 0x00000000,
205+ 0x00000000,
206+ 0x784a0000,
207+ 0x00000000,
208+ 0x784b0000,
209+ 0x00000004,
210+ 0x79170101,
211+ 0x00000000,
212+ 0x00000080,
213+ 0x00000000,
214+ 0x00000000,
215+ 0x00000000,
216+ 0x00000000,
217+ 0x00000000,
218+ 0x00000000,
219+ 0x00000000,
220+ 0x00000000,
221+ 0x00000000,
222+ 0x00000000,
223+ 0x00000000,
224+ 0x00000000,
225+ 0x00000000,
226+ 0x00000000,
227+ 0x00000000,
228+ 0x00000000,
229+ 0x00000000,
230+ 0x00000000,
231+ 0x00000000,
232+ 0x00000000,
233+ 0x00000000,
234+ 0x00000000,
235+ 0x00000000,
236+ 0x00000000,
237+ 0x00000000,
238+ 0x00000000,
239+ 0x00000000,
240+ 0x00000000,
241+ 0x00000000,
242+ 0x00000000,
243+ 0x00000000,
244+ 0x00000000,
245+ 0x00000000,
246+ 0x00000000,
247+ 0x00000000,
248+ 0x00000000,
249+ 0x00000000,
250+ 0x00000000,
251+ 0x00000000,
252+ 0x00000000,
253+ 0x00000000,
254+ 0x00000000,
255+ 0x00000000,
256+ 0x00000000,
257+ 0x00000000,
258+ 0x00000000,
259+ 0x00000000,
260+ 0x00000000,
261+ 0x00000000,
262+ 0x00000000,
263+ 0x00000000,
264+ 0x00000000,
265+ 0x00000000,
266+ 0x00000000,
267+ 0x00000000,
268+ 0x00000000,
269+ 0x00000000,
270+ 0x00000000,
271+ 0x00000000,
272+ 0x00000000,
273+ 0x00000000,
274+ 0x00000000,
275+ 0x00000000,
276+ 0x00000000,
277+ 0x00000000,
278+ 0x00000000,
279+ 0x00000000,
280+ 0x00000000,
281+ 0x00000000,
282+ 0x00000000,
283+ 0x00000000,
284+ 0x00000000,
285+ 0x00000000,
286+ 0x00000000,
287+ 0x00000000,
288+ 0x00000000,
289+ 0x00000000,
290+ 0x00000000,
291+ 0x00000000,
292+ 0x00000000,
293+ 0x00000000,
294+ 0x00000000,
295+ 0x00000000,
296+ 0x00000000,
297+ 0x00000000,
298+ 0x00000000,
299+ 0x00000000,
300+ 0x00000000,
301+ 0x00000000,
302+ 0x00000000,
303+ 0x00000000,
304+ 0x00000000,
305+ 0x00000000,
306+ 0x00000000,
307+ 0x00000000,
308+ 0x00000000,
309+ 0x00000000,
310+ 0x00000000,
311+ 0x00000000,
312+ 0x00000000,
313+ 0x00000000,
314+ 0x00000000,
315+ 0x00000000,
316+ 0x00000000,
317+ 0x00000000,
318+ 0x00000000,
319+ 0x00000000,
320+ 0x00000000,
321+ 0x00000000,
322+ 0x00000000,
323+ 0x00000000,
324+ 0x00000000,
325+ 0x00000000,
326+ 0x00000000,
327+ 0x00000000,
328+ 0x00000000,
329+ 0x00000000,
330+ 0x00000000,
331+ 0x00000000,
332+ 0x00000000,
333+ 0x00000000,
334+ 0x00000000,
335+ 0x00000000,
336+ 0x00000000,
337+ 0x00000000,
338+ 0x00000000,
339+ 0x00000000,
340+ 0x00000000,
341+ 0x00000000,
342+ 0x00000000,
343+ 0x00000000,
344+ 0x00000000,
345+ 0x00000000,
346+ 0x00000000,
347+ 0x00000000,
348+ 0x00000000,
349+ 0x00000000,
350+ 0x00000000,
351+ 0x00000000,
352+ 0x00000000,
353+ 0x00000000,
354+ 0x00000000,
355+ 0x00000000,
356+ 0x00000000,
357+ 0x00000000,
358+ 0x00000000,
359+ 0x00000000,
360+ 0x00000000,
361+ 0x00000000,
362+ 0x00000000,
363+ 0x00000000,
364+ 0x00000000,
365+ 0x00000000,
366+ 0x00000000,
367+ 0x00000000,
368+ 0x00000000,
369+ 0x00000000,
370+ 0x00000000,
371+ 0x00000000,
372+ 0x00000000,
373+ 0x00000000,
374+ 0x00000000,
375+ 0x00000000,
376+ 0x00000000,
377+ 0x00000000,
378+ 0x00000000,
379+ 0x00000000,
380+ 0x00000000,
381+ 0x00000000,
382+ 0x00000000,
383+ 0x00000000,
384+ 0x00000000,
385+ 0x00000000,
386+ 0x00000000,
387+ 0x00000000,
388+ 0x00000000,
389+ 0x00000000,
390+ 0x00000000,
391+ 0x00000000,
392+ 0x00000000,
393+ 0x00000000,
394+ 0x00000000,
395+ 0x00000000,
396+ 0x00000000,
397+ 0x00000000,
398+ 0x00000000,
399+ 0x00000000,
400+ 0x00000000,
401+ 0x00000000,
402+ 0x00000000,
403+ 0x00000000,
404+ 0x00000000,
405+ 0x00000000,
406+ 0x00000000,
407+ 0x00000000,
408+ 0x00000000,
409+ 0x00000000,
410+ 0x00000000,
411+ 0x00000000,
412+ 0x00000000,
413+ 0x00000000,
414+ 0x00000000,
415+ 0x00000000,
416+ 0x00000000,
417+ 0x00000000,
418+ 0x00000000,
419+ 0x00000000,
420+ 0x00000000,
421+ 0x00000000,
422+ 0x00000000,
423+ 0x00000000,
424+ 0x00000000,
425+ 0x00000000,
426+ 0x00000000,
427+ 0x00000000,
428+ 0x00000000,
429+ 0x00000000,
430+ 0x00000000,
431+ 0x00000000,
432+ 0x00000000,
433+ 0x00000000,
434+ 0x00000000,
435+ 0x00000000,
436+ 0x00000000,
437+ 0x00000000,
438+ 0x00000000,
439+ 0x00000000,
440+ 0x00000000,
441+ 0x00000000,
442+ 0x00000000,
443+ 0x00000000,
444+ 0x00000000,
445+ 0x00000000,
446+ 0x00000000,
447+ 0x00000000,
448+ 0x00000000,
449+ 0x00000000,
450+ 0x00000000,
451+ 0x00000000,
452+ 0x00000000,
453+ 0x00000000,
454+ 0x00000000,
455+ 0x00000000,
456+ 0x00000000,
457+ 0x00000000,
458+ 0x00000000,
459+ 0x00000000,
460+ 0x00000000,
461+ 0x00000000,
462+ 0x00000000,
463+ 0x00000000,
464+ 0x00000000,
465+ 0x00000000,
466+ 0x00000000,
467+ 0x00000000,
468+ 0x00000000,
469+ 0x79180006,
470+ 0x00000000,
471+ 0x00000000,
472+ 0x00000000,
473+ 0x00000000,
474+ 0x00000000,
475+ 0x00000000,
476+ 0x00000000,
477+ 0x79180006,
478+ 0x20000000,
479+ 0x00000000,
480+ 0x00000000,
481+ 0x00000000,
482+ 0x00000000,
483+ 0x00000000,
484+ 0x00000000,
485+ 0x79180006,
486+ 0x40000000,
487+ 0x00000000,
488+ 0x00000000,
489+ 0x00000000,
490+ 0x00000000,
491+ 0x00000000,
492+ 0x00000000,
493+ 0x79180006,
494+ 0x60000000,
495+ 0x00000000,
496+ 0x00000000,
497+ 0x00000000,
498+ 0x00000000,
499+ 0x00000000,
500+ 0x00000000,
501+ 0x61010011,
502+ 0x00000001, /* reloc */
503+ 0x00000000,
504+ 0x00000000,
505+ 0x00000001, /* reloc */
506+ 0x00000000,
507+ 0x00000001, /* reloc */
508+ 0x00000000,
509+ 0x00000001,
510+ 0x00000000,
511+ 0x00000001, /* reloc */
512+ 0x00000000,
513+ 0x00001001,
514+ 0x00001001,
515+ 0x00000001,
516+ 0x00001001,
517+ 0x00000000,
518+ 0x00000000,
519+ 0x00000000,
520+ 0x61020001,
521+ 0x00000000,
522+ 0x00000000,
523+ 0x79000002,
524+ 0x00000000,
525+ 0x00000000,
526+ 0x00000000,
527+ 0x78050006,
528+ 0x00000000,
529+ 0x00000000,
530+ 0x00000000,
531+ 0x00000000,
532+ 0x00000000,
533+ 0x00000000,
534+ 0x00000000,
535+ 0x79040002,
536+ 0x00000000,
537+ 0x00000000,
538+ 0x00000000,
539+ 0x79040002,
540+ 0x40000000,
541+ 0x00000000,
542+ 0x00000000,
543+ 0x79040002,
544+ 0x80000000,
545+ 0x00000000,
546+ 0x00000000,
547+ 0x79040002,
548+ 0xc0000000,
549+ 0x00000000,
550+ 0x00000000,
551+ 0x79080001,
552+ 0x00000000,
553+ 0x00000000,
554+ 0x790a0001,
555+ 0x00000000,
556+ 0x00000000,
557+ 0x78060003,
558+ 0x00000000,
559+ 0x00000000,
560+ 0x00000000,
561+ 0x00000000,
562+ 0x78070003,
563+ 0x00000000,
564+ 0x00000000,
565+ 0x00000000,
566+ 0x00000000,
567+ 0x78040001,
568+ 0x00000000,
569+ 0x00000000,
570+ 0x79110000,
571+ 0x00000000,
572+ 0x780d0000,
573+ 0x00000000,
574+ 0x79060000,
575+ 0x00000000,
576+ 0x7907001f,
577+ 0x00000000,
578+ 0x00000000,
579+ 0x00000000,
580+ 0x00000000,
581+ 0x00000000,
582+ 0x00000000,
583+ 0x00000000,
584+ 0x00000000,
585+ 0x00000000,
586+ 0x00000000,
587+ 0x00000000,
588+ 0x00000000,
589+ 0x00000000,
590+ 0x00000000,
591+ 0x00000000,
592+ 0x00000000,
593+ 0x00000000,
594+ 0x00000000,
595+ 0x00000000,
596+ 0x00000000,
597+ 0x00000000,
598+ 0x00000000,
599+ 0x00000000,
600+ 0x00000000,
601+ 0x00000000,
602+ 0x00000000,
603+ 0x00000000,
604+ 0x00000000,
605+ 0x00000000,
606+ 0x00000000,
607+ 0x00000000,
608+ 0x00000000,
609+ 0x7902000f,
610+ 0x00000000,
611+ 0x00000000,
612+ 0x00000000,
613+ 0x00000000,
614+ 0x00000000,
615+ 0x00000000,
616+ 0x00000000,
617+ 0x00000000,
618+ 0x00000000,
619+ 0x00000000,
620+ 0x00000000,
621+ 0x00000000,
622+ 0x00000000,
623+ 0x00000000,
624+ 0x00000000,
625+ 0x00000000,
626+ 0x790c000f,
627+ 0x00000000,
628+ 0x00000000,
629+ 0x00000000,
630+ 0x00000000,
631+ 0x00000000,
632+ 0x00000000,
633+ 0x00000000,
634+ 0x00000000,
635+ 0x00000000,
636+ 0x00000000,
637+ 0x00000000,
638+ 0x00000000,
639+ 0x00000000,
640+ 0x00000000,
641+ 0x00000000,
642+ 0x00000000,
643+ 0x780a0003,
644+ 0x00000000,
645+ 0x00000000,
646+ 0x00000000,
647+ 0x00000000,
648+ 0x78080083,
649+ 0x00004000,
650+ 0x00000000,
651+ 0x00000000,
652+ 0x00000000,
653+ 0x04004000,
654+ 0x00000000,
655+ 0x00000000,
656+ 0x00000000,
657+ 0x08004000,
658+ 0x00000000,
659+ 0x00000000,
660+ 0x00000000,
661+ 0x0c004000,
662+ 0x00000000,
663+ 0x00000000,
664+ 0x00000000,
665+ 0x10004000,
666+ 0x00000000,
667+ 0x00000000,
668+ 0x00000000,
669+ 0x14004000,
670+ 0x00000000,
671+ 0x00000000,
672+ 0x00000000,
673+ 0x18004000,
674+ 0x00000000,
675+ 0x00000000,
676+ 0x00000000,
677+ 0x1c004000,
678+ 0x00000000,
679+ 0x00000000,
680+ 0x00000000,
681+ 0x20004000,
682+ 0x00000000,
683+ 0x00000000,
684+ 0x00000000,
685+ 0x24004000,
686+ 0x00000000,
687+ 0x00000000,
688+ 0x00000000,
689+ 0x28004000,
690+ 0x00000000,
691+ 0x00000000,
692+ 0x00000000,
693+ 0x2c004000,
694+ 0x00000000,
695+ 0x00000000,
696+ 0x00000000,
697+ 0x30004000,
698+ 0x00000000,
699+ 0x00000000,
700+ 0x00000000,
701+ 0x34004000,
702+ 0x00000000,
703+ 0x00000000,
704+ 0x00000000,
705+ 0x38004000,
706+ 0x00000000,
707+ 0x00000000,
708+ 0x00000000,
709+ 0x3c004000,
710+ 0x00000000,
711+ 0x00000000,
712+ 0x00000000,
713+ 0x40004000,
714+ 0x00000000,
715+ 0x00000000,
716+ 0x00000000,
717+ 0x44004000,
718+ 0x00000000,
719+ 0x00000000,
720+ 0x00000000,
721+ 0x48004000,
722+ 0x00000000,
723+ 0x00000000,
724+ 0x00000000,
725+ 0x4c004000,
726+ 0x00000000,
727+ 0x00000000,
728+ 0x00000000,
729+ 0x50004000,
730+ 0x00000000,
731+ 0x00000000,
732+ 0x00000000,
733+ 0x54004000,
734+ 0x00000000,
735+ 0x00000000,
736+ 0x00000000,
737+ 0x58004000,
738+ 0x00000000,
739+ 0x00000000,
740+ 0x00000000,
741+ 0x5c004000,
742+ 0x00000000,
743+ 0x00000000,
744+ 0x00000000,
745+ 0x60004000,
746+ 0x00000000,
747+ 0x00000000,
748+ 0x00000000,
749+ 0x64004000,
750+ 0x00000000,
751+ 0x00000000,
752+ 0x00000000,
753+ 0x68004000,
754+ 0x00000000,
755+ 0x00000000,
756+ 0x00000000,
757+ 0x6c004000,
758+ 0x00000000,
759+ 0x00000000,
760+ 0x00000000,
761+ 0x70004000,
762+ 0x00000000,
763+ 0x00000000,
764+ 0x00000000,
765+ 0x74004000,
766+ 0x00000000,
767+ 0x00000000,
768+ 0x00000000,
769+ 0x78004000,
770+ 0x00000000,
771+ 0x00000000,
772+ 0x00000000,
773+ 0x7c004000,
774+ 0x00000000,
775+ 0x00000000,
776+ 0x00000000,
777+ 0x80004000,
778+ 0x00000000,
779+ 0x00000000,
780+ 0x00000000,
781+ 0x78090043,
782+ 0x02000000,
783+ 0x22220000,
784+ 0x00000000,
785+ 0x00000000,
786+ 0x00000000,
787+ 0x00000000,
788+ 0x00000000,
789+ 0x00000000,
790+ 0x00000000,
791+ 0x00000000,
792+ 0x00000000,
793+ 0x00000000,
794+ 0x00000000,
795+ 0x00000000,
796+ 0x00000000,
797+ 0x00000000,
798+ 0x00000000,
799+ 0x00000000,
800+ 0x00000000,
801+ 0x00000000,
802+ 0x00000000,
803+ 0x00000000,
804+ 0x00000000,
805+ 0x00000000,
806+ 0x00000000,
807+ 0x00000000,
808+ 0x00000000,
809+ 0x00000000,
810+ 0x00000000,
811+ 0x00000000,
812+ 0x00000000,
813+ 0x00000000,
814+ 0x00000000,
815+ 0x00000000,
816+ 0x00000000,
817+ 0x00000000,
818+ 0x00000000,
819+ 0x00000000,
820+ 0x00000000,
821+ 0x00000000,
822+ 0x00000000,
823+ 0x00000000,
824+ 0x00000000,
825+ 0x00000000,
826+ 0x00000000,
827+ 0x00000000,
828+ 0x00000000,
829+ 0x00000000,
830+ 0x00000000,
831+ 0x00000000,
832+ 0x00000000,
833+ 0x00000000,
834+ 0x00000000,
835+ 0x00000000,
836+ 0x00000000,
837+ 0x00000000,
838+ 0x00000000,
839+ 0x00000000,
840+ 0x00000000,
841+ 0x00000000,
842+ 0x00000000,
843+ 0x00000000,
844+ 0x00000000,
845+ 0x00000000,
846+ 0x00000000,
847+ 0x00000000,
848+ 0x00000000,
849+ 0x00000000,
850+ 0x78550003,
851+ 0x00000000,
852+ 0x00000000,
853+ 0x00000000,
854+ 0x00000000,
855+ 0x680b0001,
856+ 0x780e0000,
857+ 0x00000e01,
858+ 0x78240000,
859+ 0x00000e41,
860+ 0x784f0000,
861+ 0x80000100,
862+ 0x784d0000,
863+ 0x40000000,
864+ 0x782b0000,
865+ 0x00000000,
866+ 0x782c0000,
867+ 0x00000000,
868+ 0x782d0000,
869+ 0x00000000,
870+ 0x782e0000,
871+ 0x00000000,
872+ 0x782f0000,
873+ 0x00000000,
874+ 0x780f0000,
875+ 0x00000000,
876+ 0x78230000,
877+ 0x00000ea0,
878+ 0x78210000,
879+ 0x00000ec0,
880+ 0x78260000,
881+ 0x00000000,
882+ 0x78270000,
883+ 0x00000000,
884+ 0x78280000,
885+ 0x00000000,
886+ 0x78290000,
887+ 0x00000000,
888+ 0x782a0000,
889+ 0x00000000,
890+ 0x7b000005,
891+ 0x00000004,
892+ 0x00000001,
893+ 0x00000000,
894+ 0x00000001,
895+ 0x00000000,
896+ 0x00000000,
897+ 0x05000000, /* cmds end */
898+ 0x00000000,
899+ 0x00000000,
900+ 0x00000000,
901+ 0x00000000,
902+ 0x00000000,
903+ 0x00000000,
904+ 0x00000000,
905+ 0x00000000,
906+ 0x00000000,
907+ 0x00000000,
908+ 0x00000000, /* state start */
909+ 0x00000000,
910+ 0x3f800000,
911+ 0x3f800000,
912+ 0x3f800000,
913+ 0x3f800000,
914+ 0x00000000,
915+ 0x00000000,
916+ 0x00000000,
917+ 0x00000000,
918+ 0x00000000,
919+ 0x00000000,
920+ 0x00000000,
921+ 0x00000000,
922+ 0x00000000,
923+ 0x00000000,
924+ 0x00000000,
925+ 0x00000000,
926+ 0x00000000,
927+ 0x00000000,
928+ 0x00000000,
929+ 0x00000000,
930+ 0x00000000,
931+ 0x00000000,
932+ 0x00000000,
933+ 0x00000000,
934+ 0x00000000,
935+ 0x00000000,
936+ 0x00000000,
937+ 0x00000000,
938+ 0x00000000,
939+ 0x00000000,
940+ 0x00000000,
941+ 0x00000000,
942+ 0x00000000,
943+ 0x00000000,
944+ 0x00000000,
945+ 0x00000000,
946+ 0x00000000,
947+ 0x00000000,
948+ 0x00000000,
949+ 0x00000000,
950+ 0x00000000,
951+ 0x00000000,
952+ 0x00000000,
953+ 0x00000000,
954+ 0x00000000,
955+ 0x00000000,
956+ 0x00000000,
957+ 0x00000000,
958+ 0x00000000,
959+ 0x00000000,
960+ 0x00000000,
961+ 0x00000000,
962+ 0x00000000,
963+ 0x00000000,
964+ 0x00000000,
965+ 0x00000000,
966+ 0x00000000,
967+ 0x00000000,
968+ 0x00000000,
969+ 0x00000000,
970+ 0x00000000,
971+ 0x00000000, /* state end */
972+};
973+
974+RO_RENDERSTATE(9);
drivers/gpu/drm/i915/intel_ringbuffer.c+5−2
@@ -1845,12 +1845,15 @@ error: · 1844 unmodified lines
18451845
18461846 void intel_cleanup_ring_buffer(struct intel_engine_cs *ring)
18471847 {
1848− struct drm_i915_private *dev_priv = to_i915(ring->dev);
1849− struct intel_ringbuffer *ringbuf = ring->buffer;
1848+ struct drm_i915_private *dev_priv;
1849+ struct intel_ringbuffer *ringbuf;
18501850
18511851 if (!intel_ring_initialized(ring))
18521852 return;
18531853
1854+ dev_priv = to_i915(ring->dev);
1855+ ringbuf = ring->buffer;
1856+
18541857 intel_stop_ring_buffer(ring);
18551858 WARN_ON(!IS_GEN2(ring->dev) && (I915_READ_MODE(ring) & MODE_IDLE) == 0);
18561859
drivers/gpu/drm/i915/intel_runtime_pm.c+14−6
@@ -587,6 +587,9 @@ static void chv_pipe_power_well_disable(struct drm_i915_private *dev_priv, · 586 unmodified lines
587587 power_well->data != PIPE_C);
588588
589589 chv_set_pipe_power_well(dev_priv, power_well, false);
590+
591+ if (power_well->data == PIPE_A)
592+ vlv_power_sequencer_reset(dev_priv);
590593 }
591594
592595 static void check_power_well_state(struct drm_i915_private *dev_priv,
@@ -938,12 +941,20 @@ static struct i915_power_well chv_power_wells[] = { · 345 unmodified lines
938941 .data = PUNIT_POWER_WELL_DISP2D,
939942 .ops = &vlv_display_power_well_ops,
940943 },
944+#endif
941945 {
942946 .name = "pipe-a",
943− .domains = CHV_PIPE_A_POWER_DOMAINS,
947+ /*
948+ * FIXME: pipe A power well seems to be the new disp2d well.
949+ * At least all registers seem to be housed there. Figure
950+ * out if this a a temporary situation in pre-production
951+ * hardware or a permanent state of affairs.
952+ */
953+ .domains = CHV_PIPE_A_POWER_DOMAINS | VLV_DISPLAY_POWER_DOMAINS,
944954 .data = PIPE_A,
945955 .ops = &chv_pipe_power_well_ops,
946956 },
957+#if 0
947958 {
948959 .name = "pipe-b",
949960 .domains = CHV_PIPE_B_POWER_DOMAINS,
@@ -1137,12 +1148,9 @@ static void vlv_cmnlane_wa(struct drm_i915_private *dev_priv) · 187 unmodified lines
11371148 struct i915_power_well *disp2d =
11381149 lookup_power_well(dev_priv, PUNIT_POWER_WELL_DISP2D);
11391150
1140− /* nothing to do if common lane is already off */
1141− if (!cmn->ops->is_enabled(dev_priv, cmn))
1142− return;
1143−
11441151 /* If the display might be already active skip this */
1145− if (disp2d->ops->is_enabled(dev_priv, disp2d) &&
1152+ if (cmn->ops->is_enabled(dev_priv, cmn) &&
1153+ disp2d->ops->is_enabled(dev_priv, disp2d) &&
11461154 I915_READ(DPIO_CTL) & DPIO_CMNRST)
11471155 return;
11481156
drivers/gpu/drm/i915/intel_sprite.c+126−44
@@ -37,6 +37,20 @@ · 36 unmodified lines
3737 #include <drm/i915_drm.h>
3838 #include "i915_drv.h"
3939
40+static bool
41+format_is_yuv(uint32_t format)
42+{
43+ switch (format) {
44+ case DRM_FORMAT_YUYV:
45+ case DRM_FORMAT_UYVY:
46+ case DRM_FORMAT_VYUY:
47+ case DRM_FORMAT_YVYU:
48+ return true;
49+ default:
50+ return false;
51+ }
52+}
53+
4054 static int usecs_to_scanlines(const struct drm_display_mode *mode, int usecs)
4155 {
4256 /* paranoia */
@@ -46,7 +60,23 @@ static int usecs_to_scanlines(const struct drm_display_mode *mode, int usecs) · 3 unmodified lines
4660 return DIV_ROUND_UP(usecs * mode->crtc_clock, 1000 * mode->crtc_htotal);
4761 }
4862
49−static bool intel_pipe_update_start(struct intel_crtc *crtc, uint32_t *start_vbl_count)
63+/**
64+ * intel_pipe_update_start() - start update of a set of display registers
65+ * @crtc: the crtc of which the registers are going to be updated
66+ * @start_vbl_count: vblank counter return pointer used for error checking
67+ *
68+ * Mark the start of an update to pipe registers that should be updated
69+ * atomically regarding vblank. If the next vblank will happens within
70+ * the next 100 us, this function waits until the vblank passes.
71+ *
72+ * After a successful call to this function, interrupts will be disabled
73+ * until a subsequent call to intel_pipe_update_end(). That is done to
74+ * avoid random delays. The value written to @start_vbl_count should be
75+ * supplied to intel_pipe_update_end() for error checking.
76+ *
77+ * Return: true if the call was successful
78+ */
79+bool intel_pipe_update_start(struct intel_crtc *crtc, uint32_t *start_vbl_count)
5080 {
5181 struct drm_device *dev = crtc->base.dev;
5282 const struct drm_display_mode *mode = &crtc->config.adjusted_mode;
@@ -56,8 +86,6 @@ static bool intel_pipe_update_start(struct intel_crtc *crtc, uint32_t *start_vbl · 3 unmodified lines
5686 wait_queue_head_t *wq = drm_crtc_vblank_waitqueue(&crtc->base);
5787 DEFINE_WAIT(wait);
5888
59− WARN_ON(!drm_modeset_is_locked(&crtc->base.mutex));
60−
6189 vblank_start = mode->crtc_vblank_start;
6290 if (mode->flags & DRM_MODE_FLAG_INTERLACE)
6391 vblank_start = DIV_ROUND_UP(vblank_start, 2);
@@ -112,7 +140,16 @@ static bool intel_pipe_update_start(struct intel_crtc *crtc, uint32_t *start_vbl · 48 unmodified lines
112140 return true;
113141 }
114142
115−static void intel_pipe_update_end(struct intel_crtc *crtc, u32 start_vbl_count)
143+/**
144+ * intel_pipe_update_end() - end update of a set of display registers
145+ * @crtc: the crtc of which the registers were updated
146+ * @start_vbl_count: start vblank counter (used for error checking)
147+ *
148+ * Mark the end of an update started with intel_pipe_update_start(). This
149+ * re-enables interrupts and verifies the update was actually completed
150+ * before a vblank using the value of @start_vbl_count.
151+ */
152+void intel_pipe_update_end(struct intel_crtc *crtc, u32 start_vbl_count)
116153 {
117154 struct drm_device *dev = crtc->base.dev;
118155 enum pipe pipe = crtc->pipe;
@@ -319,6 +356,45 @@ skl_get_colorkey(struct drm_plane *drm_plane, · 200 unmodified lines
319356 }
320357 }
321358
359+static void
360+chv_update_csc(struct intel_plane *intel_plane, uint32_t format)
361+{
362+ struct drm_i915_private *dev_priv = intel_plane->base.dev->dev_private;
363+ int plane = intel_plane->plane;
364+
365+ /* Seems RGB data bypasses the CSC always */
366+ if (!format_is_yuv(format))
367+ return;
368+
369+ /*
370+ * BT.601 limited range YCbCr -> full range RGB
371+ *
372+ * |r| | 6537 4769 0| |cr |
373+ * |g| = |-3330 4769 -1605| x |y-64|
374+ * |b| | 0 4769 8263| |cb |
375+ *
376+ * Cb and Cr apparently come in as signed already, so no
377+ * need for any offset. For Y we need to remove the offset.
378+ */
379+ I915_WRITE(SPCSCYGOFF(plane), SPCSC_OOFF(0) | SPCSC_IOFF(-64));
380+ I915_WRITE(SPCSCCBOFF(plane), SPCSC_OOFF(0) | SPCSC_IOFF(0));
381+ I915_WRITE(SPCSCCROFF(plane), SPCSC_OOFF(0) | SPCSC_IOFF(0));
382+
383+ I915_WRITE(SPCSCC01(plane), SPCSC_C1(4769) | SPCSC_C0(6537));
384+ I915_WRITE(SPCSCC23(plane), SPCSC_C1(-3330) | SPCSC_C0(0));
385+ I915_WRITE(SPCSCC45(plane), SPCSC_C1(-1605) | SPCSC_C0(4769));
386+ I915_WRITE(SPCSCC67(plane), SPCSC_C1(4769) | SPCSC_C0(0));
387+ I915_WRITE(SPCSCC8(plane), SPCSC_C0(8263));
388+
389+ I915_WRITE(SPCSCYGICLAMP(plane), SPCSC_IMAX(940) | SPCSC_IMIN(64));
390+ I915_WRITE(SPCSCCBICLAMP(plane), SPCSC_IMAX(448) | SPCSC_IMIN(-448));
391+ I915_WRITE(SPCSCCRICLAMP(plane), SPCSC_IMAX(448) | SPCSC_IMIN(-448));
392+
393+ I915_WRITE(SPCSCYGOCLAMP(plane), SPCSC_OMAX(1023) | SPCSC_OMIN(0));
394+ I915_WRITE(SPCSCCBOCLAMP(plane), SPCSC_OMAX(1023) | SPCSC_OMIN(0));
395+ I915_WRITE(SPCSCCROCLAMP(plane), SPCSC_OMAX(1023) | SPCSC_OMIN(0));
396+}
397+
322398 static void
323399 vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
324400 struct drm_framebuffer *fb,
@@ -430,6 +506,9 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc, · 105 unmodified lines
430506
431507 intel_update_primary_plane(intel_crtc);
432508
509+ if (IS_CHERRYVIEW(dev) && pipe == PIPE_B)
510+ chv_update_csc(intel_plane, fb->pixel_format);
511+
433512 I915_WRITE(SPSTRIDE(pipe, plane), fb->pitches[0]);
434513 I915_WRITE(SPPOS(pipe, plane), (crtc_y << 16) | crtc_x);
435514
@@ -438,6 +517,8 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc, · 2 unmodified lines
438517 else
439518 I915_WRITE(SPLINOFF(pipe, plane), linear_offset);
440519
520+ I915_WRITE(SPCONSTALPHA(pipe, plane), 0);
521+
441522 I915_WRITE(SPSIZE(pipe, plane), (crtc_h << 16) | crtc_w);
442523 I915_WRITE(SPCNTR(pipe, plane), sprctl);
443524 I915_WRITE(SPSURF(pipe, plane), i915_gem_obj_ggtt_offset(obj) +
@@ -1002,20 +1083,6 @@ ilk_get_colorkey(struct drm_plane *plane, struct drm_intel_sprite_colorkey *key) · 558 unmodified lines
10021083 key->flags = I915_SET_COLORKEY_NONE;
10031084 }
10041085
1005−static bool
1006−format_is_yuv(uint32_t format)
1007−{
1008− switch (format) {
1009− case DRM_FORMAT_YUYV:
1010− case DRM_FORMAT_UYVY:
1011− case DRM_FORMAT_VYUY:
1012− case DRM_FORMAT_YVYU:
1013− return true;
1014− default:
1015− return false;
1016− }
1017−}
1018−
10191086 static bool colorkey_enabled(struct intel_plane *intel_plane)
10201087 {
10211088 struct drm_intel_sprite_colorkey key;
@@ -1032,8 +1099,7 @@ intel_check_sprite_plane(struct drm_plane *plane, · 10 unmodified lines
10321099 struct intel_crtc *intel_crtc = to_intel_crtc(state->crtc);
10331100 struct intel_plane *intel_plane = to_intel_plane(plane);
10341101 struct drm_framebuffer *fb = state->fb;
1035− struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb);
1036− struct drm_i915_gem_object *obj = intel_fb->obj;
1102+ struct drm_i915_gem_object *obj = intel_fb_obj(fb);
10371103 int crtc_x, crtc_y;
10381104 unsigned int crtc_w, crtc_h;
10391105 uint32_t src_x, src_y, src_w, src_h;
@@ -1192,34 +1258,18 @@ intel_check_sprite_plane(struct drm_plane *plane, · 152 unmodified lines
11921258 }
11931259
11941260 static int
1195−intel_commit_sprite_plane(struct drm_plane *plane,
1196− struct intel_plane_state *state)
1261+intel_prepare_sprite_plane(struct drm_plane *plane,
1262+ struct intel_plane_state *state)
11971263 {
11981264 struct drm_device *dev = plane->dev;
11991265 struct drm_crtc *crtc = state->crtc;
12001266 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
1201− struct intel_plane *intel_plane = to_intel_plane(plane);
12021267 enum pipe pipe = intel_crtc->pipe;
12031268 struct drm_framebuffer *fb = state->fb;
1204− struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb);
1205− struct drm_i915_gem_object *obj = intel_fb->obj;
1206− struct drm_i915_gem_object *old_obj = intel_plane->obj;
1207− int crtc_x, crtc_y;
1208− unsigned int crtc_w, crtc_h;
1209− uint32_t src_x, src_y, src_w, src_h;
1210− struct drm_rect *dst = &state->dst;
1211− const struct drm_rect *clip = &state->clip;
1212− bool primary_enabled;
1269+ struct drm_i915_gem_object *obj = intel_fb_obj(fb);
1270+ struct drm_i915_gem_object *old_obj = intel_fb_obj(plane->fb);
12131271 int ret;
12141272
1215− /*
1216− * If the sprite is completely covering the primary plane,
1217− * we can disable the primary and save power.
1218− */
1219− primary_enabled = !drm_rect_equals(dst, clip) || colorkey_enabled(intel_plane);
1220− WARN_ON(!primary_enabled && !state->visible && intel_crtc->active);
1221−
1222−
12231273 if (old_obj != obj) {
12241274 mutex_lock(&dev->struct_mutex);
12251275
@@ -1229,7 +1279,7 @@ intel_commit_sprite_plane(struct drm_plane *plane, · 3 unmodified lines
12291279 * the sprite planes only require 128KiB alignment and 32 PTE
12301280 * padding.
12311281 */
1232− ret = intel_pin_and_fence_fb_obj(dev, obj, NULL);
1282+ ret = intel_pin_and_fence_fb_obj(plane, fb, NULL);
12331283 if (ret == 0)
12341284 i915_gem_track_fb(old_obj, obj,
12351285 INTEL_FRONTBUFFER_SPRITE(pipe));
@@ -1238,6 +1288,35 @@ intel_commit_sprite_plane(struct drm_plane *plane, · 2 unmodified lines
12381288 return ret;
12391289 }
12401290
1291+ return 0;
1292+}
1293+
1294+static void
1295+intel_commit_sprite_plane(struct drm_plane *plane,
1296+ struct intel_plane_state *state)
1297+{
1298+ struct drm_device *dev = plane->dev;
1299+ struct drm_crtc *crtc = state->crtc;
1300+ struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
1301+ struct intel_plane *intel_plane = to_intel_plane(plane);
1302+ enum pipe pipe = intel_crtc->pipe;
1303+ struct drm_framebuffer *fb = state->fb;
1304+ struct drm_i915_gem_object *obj = intel_fb_obj(fb);
1305+ struct drm_i915_gem_object *old_obj = intel_fb_obj(plane->fb);
1306+ int crtc_x, crtc_y;
1307+ unsigned int crtc_w, crtc_h;
1308+ uint32_t src_x, src_y, src_w, src_h;
1309+ struct drm_rect *dst = &state->dst;
1310+ const struct drm_rect *clip = &state->clip;
1311+ bool primary_enabled;
1312+
1313+ /*
1314+ * If the sprite is completely covering the primary plane,
1315+ * we can disable the primary and save power.
1316+ */
1317+ primary_enabled = !drm_rect_equals(dst, clip) || colorkey_enabled(intel_plane);
1318+ WARN_ON(!primary_enabled && !state->visible && intel_crtc->active);
1319+
12411320 intel_plane->crtc_x = state->orig_dst.x1;
12421321 intel_plane->crtc_y = state->orig_dst.y1;
12431322 intel_plane->crtc_w = drm_rect_width(&state->orig_dst);
@@ -1298,8 +1377,6 @@ intel_commit_sprite_plane(struct drm_plane *plane, · 54 unmodified lines
12981377 intel_unpin_fb_obj(old_obj);
12991378 mutex_unlock(&dev->struct_mutex);
13001379 }
1301−
1302− return 0;
13031380 }
13041381
13051382 static int
@@ -1339,7 +1416,12 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, · 33 unmodified lines
13391416 if (ret)
13401417 return ret;
13411418
1342− return intel_commit_sprite_plane(plane, &state);
1419+ ret = intel_prepare_sprite_plane(plane, &state);
1420+ if (ret)
1421+ return ret;
1422+
1423+ intel_commit_sprite_plane(plane, &state);
1424+ return 0;
13431425 }
13441426
13451427 static int
drivers/gpu/drm/i915/intel_uncore.c+184−8
@@ -194,15 +194,13 @@ static void vlv_force_wake_reset(struct drm_i915_private *dev_priv) · 193 unmodified lines
194194 static void __vlv_force_wake_get(struct drm_i915_private *dev_priv,
195195 int fw_engine)
196196 {
197− /*
198− * WaRsDontPollForAckOnClearingFWBits:vlv
199− * Hardware clears ack bits lazily (only when all ack
200− * bits become 0) so don't poll for individiual ack
201− * bits to be clear here like on other platforms.
202− */
203−
204197 /* Check for Render Engine */
205198 if (FORCEWAKE_RENDER & fw_engine) {
199+ if (wait_for_atomic((__raw_i915_read32(dev_priv,
200+ FORCEWAKE_ACK_VLV) &
201+ FORCEWAKE_KERNEL) == 0,
202+ FORCEWAKE_ACK_TIMEOUT_MS))
203+ DRM_ERROR("Timed out: Render forcewake old ack to clear.\n");
206204
207205 __raw_i915_write32(dev_priv, FORCEWAKE_VLV,
208206 _MASKED_BIT_ENABLE(FORCEWAKE_KERNEL));
@@ -216,6 +214,11 @@ static void __vlv_force_wake_get(struct drm_i915_private *dev_priv, · 7 unmodified lines
216214
217215 /* Check for Media Engine */
218216 if (FORCEWAKE_MEDIA & fw_engine) {
217+ if (wait_for_atomic((__raw_i915_read32(dev_priv,
218+ FORCEWAKE_ACK_MEDIA_VLV) &
219+ FORCEWAKE_KERNEL) == 0,
220+ FORCEWAKE_ACK_TIMEOUT_MS))
221+ DRM_ERROR("Timed out: Media forcewake old ack to clear.\n");
219222
220223 __raw_i915_write32(dev_priv, FORCEWAKE_MEDIA_VLV,
221224 _MASKED_BIT_ENABLE(FORCEWAKE_KERNEL));
@@ -296,6 +299,154 @@ static void vlv_force_wake_put(struct drm_i915_private *dev_priv, int fw_engine) · 74 unmodified lines
296299 spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags);
297300 }
298301
302+static void __gen9_gt_force_wake_mt_reset(struct drm_i915_private *dev_priv)
303+{
304+ __raw_i915_write32(dev_priv, FORCEWAKE_RENDER_GEN9,
305+ _MASKED_BIT_DISABLE(0xffff));
306+
307+ __raw_i915_write32(dev_priv, FORCEWAKE_MEDIA_GEN9,
308+ _MASKED_BIT_DISABLE(0xffff));
309+
310+ __raw_i915_write32(dev_priv, FORCEWAKE_BLITTER_GEN9,
311+ _MASKED_BIT_DISABLE(0xffff));
312+}
313+
314+static void
315+__gen9_force_wake_get(struct drm_i915_private *dev_priv, int fw_engine)
316+{
317+ /* Check for Render Engine */
318+ if (FORCEWAKE_RENDER & fw_engine) {
319+ if (wait_for_atomic((__raw_i915_read32(dev_priv,
320+ FORCEWAKE_ACK_RENDER_GEN9) &
321+ FORCEWAKE_KERNEL) == 0,
322+ FORCEWAKE_ACK_TIMEOUT_MS))
323+ DRM_ERROR("Timed out: Render forcewake old ack to clear.\n");
324+
325+ __raw_i915_write32(dev_priv, FORCEWAKE_RENDER_GEN9,
326+ _MASKED_BIT_ENABLE(FORCEWAKE_KERNEL));
327+
328+ if (wait_for_atomic((__raw_i915_read32(dev_priv,
329+ FORCEWAKE_ACK_RENDER_GEN9) &
330+ FORCEWAKE_KERNEL),
331+ FORCEWAKE_ACK_TIMEOUT_MS))
332+ DRM_ERROR("Timed out: waiting for Render to ack.\n");
333+ }
334+
335+ /* Check for Media Engine */
336+ if (FORCEWAKE_MEDIA & fw_engine) {
337+ if (wait_for_atomic((__raw_i915_read32(dev_priv,
338+ FORCEWAKE_ACK_MEDIA_GEN9) &
339+ FORCEWAKE_KERNEL) == 0,
340+ FORCEWAKE_ACK_TIMEOUT_MS))
341+ DRM_ERROR("Timed out: Media forcewake old ack to clear.\n");
342+
343+ __raw_i915_write32(dev_priv, FORCEWAKE_MEDIA_GEN9,
344+ _MASKED_BIT_ENABLE(FORCEWAKE_KERNEL));
345+
346+ if (wait_for_atomic((__raw_i915_read32(dev_priv,
347+ FORCEWAKE_ACK_MEDIA_GEN9) &
348+ FORCEWAKE_KERNEL),
349+ FORCEWAKE_ACK_TIMEOUT_MS))
350+ DRM_ERROR("Timed out: waiting for Media to ack.\n");
351+ }
352+
353+ /* Check for Blitter Engine */
354+ if (FORCEWAKE_BLITTER & fw_engine) {
355+ if (wait_for_atomic((__raw_i915_read32(dev_priv,
356+ FORCEWAKE_ACK_BLITTER_GEN9) &
357+ FORCEWAKE_KERNEL) == 0,
358+ FORCEWAKE_ACK_TIMEOUT_MS))
359+ DRM_ERROR("Timed out: Blitter forcewake old ack to clear.\n");
360+
361+ __raw_i915_write32(dev_priv, FORCEWAKE_BLITTER_GEN9,
362+ _MASKED_BIT_ENABLE(FORCEWAKE_KERNEL));
363+
364+ if (wait_for_atomic((__raw_i915_read32(dev_priv,
365+ FORCEWAKE_ACK_BLITTER_GEN9) &
366+ FORCEWAKE_KERNEL),
367+ FORCEWAKE_ACK_TIMEOUT_MS))
368+ DRM_ERROR("Timed out: waiting for Blitter to ack.\n");
369+ }
370+}
371+
372+static void
373+__gen9_force_wake_put(struct drm_i915_private *dev_priv, int fw_engine)
374+{
375+ /* Check for Render Engine */
376+ if (FORCEWAKE_RENDER & fw_engine)
377+ __raw_i915_write32(dev_priv, FORCEWAKE_RENDER_GEN9,
378+ _MASKED_BIT_DISABLE(FORCEWAKE_KERNEL));
379+
380+ /* Check for Media Engine */
381+ if (FORCEWAKE_MEDIA & fw_engine)
382+ __raw_i915_write32(dev_priv, FORCEWAKE_MEDIA_GEN9,
383+ _MASKED_BIT_DISABLE(FORCEWAKE_KERNEL));
384+
385+ /* Check for Blitter Engine */
386+ if (FORCEWAKE_BLITTER & fw_engine)
387+ __raw_i915_write32(dev_priv, FORCEWAKE_BLITTER_GEN9,
388+ _MASKED_BIT_DISABLE(FORCEWAKE_KERNEL));
389+}
390+
391+static void
392+gen9_force_wake_get(struct drm_i915_private *dev_priv, int fw_engine)
393+{
394+ unsigned long irqflags;
395+
396+ spin_lock_irqsave(&dev_priv->uncore.lock, irqflags);
397+
398+ if (FORCEWAKE_RENDER & fw_engine) {
399+ if (dev_priv->uncore.fw_rendercount++ == 0)
400+ dev_priv->uncore.funcs.force_wake_get(dev_priv,
401+ FORCEWAKE_RENDER);
402+ }
403+
404+ if (FORCEWAKE_MEDIA & fw_engine) {
405+ if (dev_priv->uncore.fw_mediacount++ == 0)
406+ dev_priv->uncore.funcs.force_wake_get(dev_priv,
407+ FORCEWAKE_MEDIA);
408+ }
409+
410+ if (FORCEWAKE_BLITTER & fw_engine) {
411+ if (dev_priv->uncore.fw_blittercount++ == 0)
412+ dev_priv->uncore.funcs.force_wake_get(dev_priv,
413+ FORCEWAKE_BLITTER);
414+ }
415+
416+ spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags);
417+}
418+
419+static void
420+gen9_force_wake_put(struct drm_i915_private *dev_priv, int fw_engine)
421+{
422+ unsigned long irqflags;
423+
424+ spin_lock_irqsave(&dev_priv->uncore.lock, irqflags);
425+
426+ if (FORCEWAKE_RENDER & fw_engine) {
427+ WARN_ON(dev_priv->uncore.fw_rendercount == 0);
428+ if (--dev_priv->uncore.fw_rendercount == 0)
429+ dev_priv->uncore.funcs.force_wake_put(dev_priv,
430+ FORCEWAKE_RENDER);
431+ }
432+
433+ if (FORCEWAKE_MEDIA & fw_engine) {
434+ WARN_ON(dev_priv->uncore.fw_mediacount == 0);
435+ if (--dev_priv->uncore.fw_mediacount == 0)
436+ dev_priv->uncore.funcs.force_wake_put(dev_priv,
437+ FORCEWAKE_MEDIA);
438+ }
439+
440+ if (FORCEWAKE_BLITTER & fw_engine) {
441+ WARN_ON(dev_priv->uncore.fw_blittercount == 0);
442+ if (--dev_priv->uncore.fw_blittercount == 0)
443+ dev_priv->uncore.funcs.force_wake_put(dev_priv,
444+ FORCEWAKE_BLITTER);
445+ }
446+
447+ spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags);
448+}
449+
299450 static void gen6_force_wake_timer(unsigned long arg)
300451 {
301452 struct drm_i915_private *dev_priv = (void *)arg;
@@ -334,6 +485,9 @@ void intel_uncore_forcewake_reset(struct drm_device *dev, bool restore) · 32 unmodified lines
334485 if (IS_IVYBRIDGE(dev) || IS_HASWELL(dev) || IS_BROADWELL(dev))
335486 __gen7_gt_force_wake_mt_reset(dev_priv);
336487
488+ if (IS_GEN9(dev))
489+ __gen9_gt_force_wake_mt_reset(dev_priv);
490+
337491 if (restore) { /* If reset with a user forcewake, try to restore */
338492 unsigned fw = 0;
339493
@@ -343,6 +497,15 @@ void intel_uncore_forcewake_reset(struct drm_device *dev, bool restore) · 3 unmodified lines
343497
344498 if (dev_priv->uncore.fw_mediacount)
345499 fw |= FORCEWAKE_MEDIA;
500+ } else if (IS_GEN9(dev)) {
501+ if (dev_priv->uncore.fw_rendercount)
502+ fw |= FORCEWAKE_RENDER;
503+
504+ if (dev_priv->uncore.fw_mediacount)
505+ fw |= FORCEWAKE_MEDIA;
506+
507+ if (dev_priv->uncore.fw_blittercount)
508+ fw |= FORCEWAKE_BLITTER;
346509 } else {
347510 if (dev_priv->uncore.forcewake_count)
348511 fw = FORCEWAKE_ALL;
@@ -414,6 +577,10 @@ void gen6_gt_force_wake_get(struct drm_i915_private *dev_priv, int fw_engine) · 65 unmodified lines
414577
415578 intel_runtime_pm_get(dev_priv);
416579
580+ /* Redirect to Gen9 specific routine */
581+ if (IS_GEN9(dev_priv->dev))
582+ return gen9_force_wake_get(dev_priv, fw_engine);
583+
417584 /* Redirect to VLV specific routine */
418585 if (IS_VALLEYVIEW(dev_priv->dev))
419586 return vlv_force_wake_get(dev_priv, fw_engine);
@@ -435,6 +602,12 @@ void gen6_gt_force_wake_put(struct drm_i915_private *dev_priv, int fw_engine) · 15 unmodified lines
435602 if (!dev_priv->uncore.funcs.force_wake_put)
436603 return;
437604
605+ /* Redirect to Gen9 specific routine */
606+ if (IS_GEN9(dev_priv->dev)) {
607+ gen9_force_wake_put(dev_priv, fw_engine);
608+ goto out;
609+ }
610+
438611 /* Redirect to VLV specific routine */
439612 if (IS_VALLEYVIEW(dev_priv->dev)) {
440613 vlv_force_wake_put(dev_priv, fw_engine);
@@ -855,7 +1028,10 @@ void intel_uncore_init(struct drm_device *dev) · 414 unmodified lines
8551028
8561029 __intel_uncore_early_sanitize(dev, false);
8571030
858− if (IS_VALLEYVIEW(dev)) {
1031+ if (IS_GEN9(dev)) {
1032+ dev_priv->uncore.funcs.force_wake_get = __gen9_force_wake_get;
1033+ dev_priv->uncore.funcs.force_wake_put = __gen9_force_wake_put;
1034+ } else if (IS_VALLEYVIEW(dev)) {
8591035 dev_priv->uncore.funcs.force_wake_get = __vlv_force_wake_get;
8601036 dev_priv->uncore.funcs.force_wake_put = __vlv_force_wake_put;
8611037 } else if (IS_HASWELL(dev) || IS_BROADWELL(dev)) {
include/uapi/drm/i915_drm.h+6−0
@@ -876,6 +876,12 @@ struct drm_i915_gem_get_tiling { · 875 unmodified lines
876876 * mmap mapping.
877877 */
878878 __u32 swizzle_mode;
879+
880+ /**
881+ * Returned address bit 6 swizzling required for CPU access through
882+ * mmap mapping whilst bound.
883+ */
884+ __u32 phys_swizzle_mode;
879885 };
880886
881887 struct drm_i915_gem_get_aperture {

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