aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_display.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2014-07-08 20:38:42 -0400
committerDave Airlie <airlied@redhat.com>2014-07-08 20:38:42 -0400
commitca5a1b9ba0fb5291b555a23b76dbe5f6c30bfd7a (patch)
tree9a012a2a610ad4e9500c8e4f0aa68ecdc23c4dba /drivers/gpu/drm/i915/intel_display.c
parentc7dbc6c9ae5c3baa3be755a228a349374d043b5b (diff)
parent34882298b93e998d5fccde852b860e8fbe6c8f6b (diff)
Merge tag 'drm-intel-next-2014-06-20' of git://anongit.freedesktop.org/drm-intel into drm-next
- Accurate frontbuffer tracking and frontbuffer rendering invalidate, flush and flip events. This is prep work for proper PSR support and should also be useful for DRRS&fbc. - Runtime suspend hardware on system suspend to support the new SOix sleep states, from Jesse. - PSR updates for broadwell (Rodrigo) - Universal plane support for cursors (Matt Roper), including core drm patches. - Prefault gtt mappings (Chris) - baytrail write-enable pte bit support (Akash Goel) - mmio based flips (Sourab Gupta) instead of blitter ring flips - interrupt handling race fixes (Oscar Mateo) And old, not yet merged features from the previous round: - rps/turbo support for chv (Deepak) - some other straggling chv patches (Ville) - proper universal plane conversion for the primary plane (Matt Roper) - ppgtt on vlv from Jesse - pile of cleanups, little fixes for insane corner cases and improved debug support all over * tag 'drm-intel-next-2014-06-20' of git://anongit.freedesktop.org/drm-intel: (99 commits) drm/i915: Update DRIVER_DATE to 20140620 drivers/i915: Fix unnoticed failure of init_ring_common() drm/i915: Track frontbuffer invalidation/flushing drm/i915: Use new frontbuffer bits to increase pll clock drm/i915: don't take runtime PM reference around freeze/thaw drm/i915: use runtime irq suspend/resume in freeze/thaw drm/i915: Properly track domain of the fbcon fb drm/i915: Print obj->frontbuffer_bits in debugfs output drm/i915: Introduce accurate frontbuffer tracking drm/i915: Drop schedule_back from psr_exit drm/i915: Ditch intel_edp_psr_update drm/i915: Drop unecessary complexity from psr_inactivate drm/i915: Remove ctx->last_ring drm/i915/chv: Ack interrupts before handling them (CHV) drm/i915/bdw: Ack interrupts before handling them (GEN8) drm/i915/vlv: Ack interrupts before handling them (VLV) drm/i915: Ack interrupts before handling them (GEN5 - GEN7) drm/i915: Don't BUG_ON in i915_gem_obj_offset drm/i915: Grab dev->struct_mutex in i915_gem_pageflip_info drm/i915: Add some L3 registers to the parser whitelist ... Conflicts: drivers/gpu/drm/i915/i915_drv.c
Diffstat (limited to 'drivers/gpu/drm/i915/intel_display.c')
-rw-r--r--drivers/gpu/drm/i915/intel_display.c903
1 files changed, 808 insertions, 95 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 1112d9ecc226..927d2476f60a 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -39,12 +39,45 @@
39#include "i915_trace.h" 39#include "i915_trace.h"
40#include <drm/drm_dp_helper.h> 40#include <drm/drm_dp_helper.h>
41#include <drm/drm_crtc_helper.h> 41#include <drm/drm_crtc_helper.h>
42#include <drm/drm_plane_helper.h>
43#include <drm/drm_rect.h>
42#include <linux/dma_remapping.h> 44#include <linux/dma_remapping.h>
43 45
46/* Primary plane formats supported by all gen */
47#define COMMON_PRIMARY_FORMATS \
48 DRM_FORMAT_C8, \
49 DRM_FORMAT_RGB565, \
50 DRM_FORMAT_XRGB8888, \
51 DRM_FORMAT_ARGB8888
52
53/* Primary plane formats for gen <= 3 */
54static const uint32_t intel_primary_formats_gen2[] = {
55 COMMON_PRIMARY_FORMATS,
56 DRM_FORMAT_XRGB1555,
57 DRM_FORMAT_ARGB1555,
58};
59
60/* Primary plane formats for gen >= 4 */
61static const uint32_t intel_primary_formats_gen4[] = {
62 COMMON_PRIMARY_FORMATS, \
63 DRM_FORMAT_XBGR8888,
64 DRM_FORMAT_ABGR8888,
65 DRM_FORMAT_XRGB2101010,
66 DRM_FORMAT_ARGB2101010,
67 DRM_FORMAT_XBGR2101010,
68 DRM_FORMAT_ABGR2101010,
69};
70
71/* Cursor formats */
72static const uint32_t intel_cursor_formats[] = {
73 DRM_FORMAT_ARGB8888,
74};
75
44#define DIV_ROUND_CLOSEST_ULL(ll, d) \ 76#define DIV_ROUND_CLOSEST_ULL(ll, d) \
45 ({ unsigned long long _tmp = (ll)+(d)/2; do_div(_tmp, d); _tmp; }) 77({ unsigned long long _tmp = (ll)+(d)/2; do_div(_tmp, d); _tmp; })
46 78
47static void intel_increase_pllclock(struct drm_crtc *crtc); 79static void intel_increase_pllclock(struct drm_device *dev,
80 enum pipe pipe);
48static void intel_crtc_update_cursor(struct drm_crtc *crtc, bool on); 81static void intel_crtc_update_cursor(struct drm_crtc *crtc, bool on);
49 82
50static void i9xx_crtc_clock_get(struct intel_crtc *crtc, 83static void i9xx_crtc_clock_get(struct intel_crtc *crtc,
@@ -1712,6 +1745,17 @@ static void chv_disable_pll(struct drm_i915_private *dev_priv, enum pipe pipe)
1712 val &= ~DPIO_DCLKP_EN; 1745 val &= ~DPIO_DCLKP_EN;
1713 vlv_dpio_write(dev_priv, pipe, CHV_CMN_DW14(port), val); 1746 vlv_dpio_write(dev_priv, pipe, CHV_CMN_DW14(port), val);
1714 1747
1748 /* disable left/right clock distribution */
1749 if (pipe != PIPE_B) {
1750 val = vlv_dpio_read(dev_priv, pipe, _CHV_CMN_DW5_CH0);
1751 val &= ~(CHV_BUFLEFTENA1_MASK | CHV_BUFRIGHTENA1_MASK);
1752 vlv_dpio_write(dev_priv, pipe, _CHV_CMN_DW5_CH0, val);
1753 } else {
1754 val = vlv_dpio_read(dev_priv, pipe, _CHV_CMN_DW1_CH1);
1755 val &= ~(CHV_BUFLEFTENA2_MASK | CHV_BUFRIGHTENA2_MASK);
1756 vlv_dpio_write(dev_priv, pipe, _CHV_CMN_DW1_CH1, val);
1757 }
1758
1715 mutex_unlock(&dev_priv->dpio_lock); 1759 mutex_unlock(&dev_priv->dpio_lock);
1716} 1760}
1717 1761
@@ -1749,6 +1793,9 @@ static void intel_prepare_shared_dpll(struct intel_crtc *crtc)
1749 struct drm_i915_private *dev_priv = dev->dev_private; 1793 struct drm_i915_private *dev_priv = dev->dev_private;
1750 struct intel_shared_dpll *pll = intel_crtc_to_shared_dpll(crtc); 1794 struct intel_shared_dpll *pll = intel_crtc_to_shared_dpll(crtc);
1751 1795
1796 if (WARN_ON(pll == NULL))
1797 return;
1798
1752 WARN_ON(!pll->refcount); 1799 WARN_ON(!pll->refcount);
1753 if (pll->active == 0) { 1800 if (pll->active == 0) {
1754 DRM_DEBUG_DRIVER("setting up %s\n", pll->name); 1801 DRM_DEBUG_DRIVER("setting up %s\n", pll->name);
@@ -2314,6 +2361,7 @@ static bool intel_alloc_plane_obj(struct intel_crtc *crtc,
2314 goto out_unref_obj; 2361 goto out_unref_obj;
2315 } 2362 }
2316 2363
2364 obj->frontbuffer_bits = INTEL_FRONTBUFFER_PRIMARY(crtc->pipe);
2317 mutex_unlock(&dev->struct_mutex); 2365 mutex_unlock(&dev->struct_mutex);
2318 2366
2319 DRM_DEBUG_KMS("plane fb obj %p\n", obj); 2367 DRM_DEBUG_KMS("plane fb obj %p\n", obj);
@@ -2359,6 +2407,7 @@ static void intel_find_plane_obj(struct intel_crtc *intel_crtc,
2359 if (i915_gem_obj_ggtt_offset(fb->obj) == plane_config->base) { 2407 if (i915_gem_obj_ggtt_offset(fb->obj) == plane_config->base) {
2360 drm_framebuffer_reference(c->primary->fb); 2408 drm_framebuffer_reference(c->primary->fb);
2361 intel_crtc->base.primary->fb = c->primary->fb; 2409 intel_crtc->base.primary->fb = c->primary->fb;
2410 fb->obj->frontbuffer_bits |= INTEL_FRONTBUFFER_PRIMARY(intel_crtc->pipe);
2362 break; 2411 break;
2363 } 2412 }
2364 } 2413 }
@@ -2546,7 +2595,7 @@ intel_pipe_set_base_atomic(struct drm_crtc *crtc, struct drm_framebuffer *fb,
2546 2595
2547 if (dev_priv->display.disable_fbc) 2596 if (dev_priv->display.disable_fbc)
2548 dev_priv->display.disable_fbc(dev); 2597 dev_priv->display.disable_fbc(dev);
2549 intel_increase_pllclock(crtc); 2598 intel_increase_pllclock(dev, to_intel_crtc(crtc)->pipe);
2550 2599
2551 dev_priv->display.update_primary_plane(crtc, fb, x, y); 2600 dev_priv->display.update_primary_plane(crtc, fb, x, y);
2552 2601
@@ -2647,7 +2696,9 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
2647 struct drm_device *dev = crtc->dev; 2696 struct drm_device *dev = crtc->dev;
2648 struct drm_i915_private *dev_priv = dev->dev_private; 2697 struct drm_i915_private *dev_priv = dev->dev_private;
2649 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 2698 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
2699 enum pipe pipe = intel_crtc->pipe;
2650 struct drm_framebuffer *old_fb; 2700 struct drm_framebuffer *old_fb;
2701 struct drm_i915_gem_object *obj = to_intel_framebuffer(fb)->obj;
2651 int ret; 2702 int ret;
2652 2703
2653 if (intel_crtc_has_pending_flip(crtc)) { 2704 if (intel_crtc_has_pending_flip(crtc)) {
@@ -2668,10 +2719,13 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
2668 return -EINVAL; 2719 return -EINVAL;
2669 } 2720 }
2670 2721
2722 old_fb = crtc->primary->fb;
2723
2671 mutex_lock(&dev->struct_mutex); 2724 mutex_lock(&dev->struct_mutex);
2672 ret = intel_pin_and_fence_fb_obj(dev, 2725 ret = intel_pin_and_fence_fb_obj(dev, obj, NULL);
2673 to_intel_framebuffer(fb)->obj, 2726 if (ret == 0)
2674 NULL); 2727 i915_gem_track_fb(to_intel_framebuffer(old_fb)->obj, obj,
2728 INTEL_FRONTBUFFER_PRIMARY(pipe));
2675 mutex_unlock(&dev->struct_mutex); 2729 mutex_unlock(&dev->struct_mutex);
2676 if (ret != 0) { 2730 if (ret != 0) {
2677 DRM_ERROR("pin & fence failed\n"); 2731 DRM_ERROR("pin & fence failed\n");
@@ -2711,7 +2765,9 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
2711 2765
2712 dev_priv->display.update_primary_plane(crtc, fb, x, y); 2766 dev_priv->display.update_primary_plane(crtc, fb, x, y);
2713 2767
2714 old_fb = crtc->primary->fb; 2768 if (intel_crtc->active)
2769 intel_frontbuffer_flip(dev, INTEL_FRONTBUFFER_PRIMARY(pipe));
2770
2715 crtc->primary->fb = fb; 2771 crtc->primary->fb = fb;
2716 crtc->x = x; 2772 crtc->x = x;
2717 crtc->y = y; 2773 crtc->y = y;
@@ -2726,7 +2782,6 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
2726 2782
2727 mutex_lock(&dev->struct_mutex); 2783 mutex_lock(&dev->struct_mutex);
2728 intel_update_fbc(dev); 2784 intel_update_fbc(dev);
2729 intel_edp_psr_update(dev);
2730 mutex_unlock(&dev->struct_mutex); 2785 mutex_unlock(&dev->struct_mutex);
2731 2786
2732 return 0; 2787 return 0;
@@ -3892,6 +3947,8 @@ static void intel_crtc_enable_planes(struct drm_crtc *crtc)
3892 int pipe = intel_crtc->pipe; 3947 int pipe = intel_crtc->pipe;
3893 int plane = intel_crtc->plane; 3948 int plane = intel_crtc->plane;
3894 3949
3950 drm_vblank_on(dev, pipe);
3951
3895 intel_enable_primary_hw_plane(dev_priv, plane, pipe); 3952 intel_enable_primary_hw_plane(dev_priv, plane, pipe);
3896 intel_enable_planes(crtc); 3953 intel_enable_planes(crtc);
3897 /* The fixup needs to happen before cursor is enabled */ 3954 /* The fixup needs to happen before cursor is enabled */
@@ -3904,8 +3961,14 @@ static void intel_crtc_enable_planes(struct drm_crtc *crtc)
3904 3961
3905 mutex_lock(&dev->struct_mutex); 3962 mutex_lock(&dev->struct_mutex);
3906 intel_update_fbc(dev); 3963 intel_update_fbc(dev);
3907 intel_edp_psr_update(dev);
3908 mutex_unlock(&dev->struct_mutex); 3964 mutex_unlock(&dev->struct_mutex);
3965
3966 /*
3967 * FIXME: Once we grow proper nuclear flip support out of this we need
3968 * to compute the mask of flip planes precisely. For the time being
3969 * consider this a flip from a NULL plane.
3970 */
3971 intel_frontbuffer_flip(dev, INTEL_FRONTBUFFER_ALL_MASK(pipe));
3909} 3972}
3910 3973
3911static void intel_crtc_disable_planes(struct drm_crtc *crtc) 3974static void intel_crtc_disable_planes(struct drm_crtc *crtc)
@@ -3917,7 +3980,6 @@ static void intel_crtc_disable_planes(struct drm_crtc *crtc)
3917 int plane = intel_crtc->plane; 3980 int plane = intel_crtc->plane;
3918 3981
3919 intel_crtc_wait_for_pending_flips(crtc); 3982 intel_crtc_wait_for_pending_flips(crtc);
3920 drm_crtc_vblank_off(crtc);
3921 3983
3922 if (dev_priv->fbc.plane == plane) 3984 if (dev_priv->fbc.plane == plane)
3923 intel_disable_fbc(dev); 3985 intel_disable_fbc(dev);
@@ -3928,6 +3990,15 @@ static void intel_crtc_disable_planes(struct drm_crtc *crtc)
3928 intel_crtc_update_cursor(crtc, false); 3990 intel_crtc_update_cursor(crtc, false);
3929 intel_disable_planes(crtc); 3991 intel_disable_planes(crtc);
3930 intel_disable_primary_hw_plane(dev_priv, plane, pipe); 3992 intel_disable_primary_hw_plane(dev_priv, plane, pipe);
3993
3994 /*
3995 * FIXME: Once we grow proper nuclear flip support out of this we need
3996 * to compute the mask of flip planes precisely. For the time being
3997 * consider this a flip to a NULL plane.
3998 */
3999 intel_frontbuffer_flip(dev, INTEL_FRONTBUFFER_ALL_MASK(pipe));
4000
4001 drm_vblank_off(dev, pipe);
3931} 4002}
3932 4003
3933static void ironlake_crtc_enable(struct drm_crtc *crtc) 4004static void ironlake_crtc_enable(struct drm_crtc *crtc)
@@ -4006,8 +4077,6 @@ static void ironlake_crtc_enable(struct drm_crtc *crtc)
4006 cpt_verify_modeset(dev, intel_crtc->pipe); 4077 cpt_verify_modeset(dev, intel_crtc->pipe);
4007 4078
4008 intel_crtc_enable_planes(crtc); 4079 intel_crtc_enable_planes(crtc);
4009
4010 drm_crtc_vblank_on(crtc);
4011} 4080}
4012 4081
4013/* IPS only exists on ULT machines and is tied to pipe A. */ 4082/* IPS only exists on ULT machines and is tied to pipe A. */
@@ -4121,8 +4190,6 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
4121 * to change the workaround. */ 4190 * to change the workaround. */
4122 haswell_mode_set_planes_workaround(intel_crtc); 4191 haswell_mode_set_planes_workaround(intel_crtc);
4123 intel_crtc_enable_planes(crtc); 4192 intel_crtc_enable_planes(crtc);
4124
4125 drm_crtc_vblank_on(crtc);
4126} 4193}
4127 4194
4128static void ironlake_pfit_disable(struct intel_crtc *crtc) 4195static void ironlake_pfit_disable(struct intel_crtc *crtc)
@@ -4200,7 +4267,6 @@ static void ironlake_crtc_disable(struct drm_crtc *crtc)
4200 4267
4201 mutex_lock(&dev->struct_mutex); 4268 mutex_lock(&dev->struct_mutex);
4202 intel_update_fbc(dev); 4269 intel_update_fbc(dev);
4203 intel_edp_psr_update(dev);
4204 mutex_unlock(&dev->struct_mutex); 4270 mutex_unlock(&dev->struct_mutex);
4205} 4271}
4206 4272
@@ -4248,7 +4314,6 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
4248 4314
4249 mutex_lock(&dev->struct_mutex); 4315 mutex_lock(&dev->struct_mutex);
4250 intel_update_fbc(dev); 4316 intel_update_fbc(dev);
4251 intel_edp_psr_update(dev);
4252 mutex_unlock(&dev->struct_mutex); 4317 mutex_unlock(&dev->struct_mutex);
4253} 4318}
4254 4319
@@ -4633,8 +4698,6 @@ static void valleyview_crtc_enable(struct drm_crtc *crtc)
4633 4698
4634 intel_crtc_enable_planes(crtc); 4699 intel_crtc_enable_planes(crtc);
4635 4700
4636 drm_crtc_vblank_on(crtc);
4637
4638 /* Underruns don't raise interrupts, so check manually. */ 4701 /* Underruns don't raise interrupts, so check manually. */
4639 i9xx_check_fifo_underruns(dev); 4702 i9xx_check_fifo_underruns(dev);
4640} 4703}
@@ -4727,8 +4790,6 @@ static void i9xx_crtc_enable(struct drm_crtc *crtc)
4727 if (IS_GEN2(dev)) 4790 if (IS_GEN2(dev))
4728 intel_set_cpu_fifo_underrun_reporting(dev, pipe, true); 4791 intel_set_cpu_fifo_underrun_reporting(dev, pipe, true);
4729 4792
4730 drm_crtc_vblank_on(crtc);
4731
4732 /* Underruns don't raise interrupts, so check manually. */ 4793 /* Underruns don't raise interrupts, so check manually. */
4733 i9xx_check_fifo_underruns(dev); 4794 i9xx_check_fifo_underruns(dev);
4734} 4795}
@@ -4805,7 +4866,6 @@ static void i9xx_crtc_disable(struct drm_crtc *crtc)
4805 4866
4806 mutex_lock(&dev->struct_mutex); 4867 mutex_lock(&dev->struct_mutex);
4807 intel_update_fbc(dev); 4868 intel_update_fbc(dev);
4808 intel_edp_psr_update(dev);
4809 mutex_unlock(&dev->struct_mutex); 4869 mutex_unlock(&dev->struct_mutex);
4810} 4870}
4811 4871
@@ -4850,16 +4910,43 @@ void intel_crtc_update_dpms(struct drm_crtc *crtc)
4850{ 4910{
4851 struct drm_device *dev = crtc->dev; 4911 struct drm_device *dev = crtc->dev;
4852 struct drm_i915_private *dev_priv = dev->dev_private; 4912 struct drm_i915_private *dev_priv = dev->dev_private;
4913 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
4853 struct intel_encoder *intel_encoder; 4914 struct intel_encoder *intel_encoder;
4915 enum intel_display_power_domain domain;
4916 unsigned long domains;
4854 bool enable = false; 4917 bool enable = false;
4855 4918
4856 for_each_encoder_on_crtc(dev, crtc, intel_encoder) 4919 for_each_encoder_on_crtc(dev, crtc, intel_encoder)
4857 enable |= intel_encoder->connectors_active; 4920 enable |= intel_encoder->connectors_active;
4858 4921
4859 if (enable) 4922 if (enable) {
4860 dev_priv->display.crtc_enable(crtc); 4923 if (!intel_crtc->active) {
4861 else 4924 /*
4862 dev_priv->display.crtc_disable(crtc); 4925 * FIXME: DDI plls and relevant code isn't converted
4926 * yet, so do runtime PM for DPMS only for all other
4927 * platforms for now.
4928 */
4929 if (!HAS_DDI(dev)) {
4930 domains = get_crtc_power_domains(crtc);
4931 for_each_power_domain(domain, domains)
4932 intel_display_power_get(dev_priv, domain);
4933 intel_crtc->enabled_power_domains = domains;
4934 }
4935
4936 dev_priv->display.crtc_enable(crtc);
4937 }
4938 } else {
4939 if (intel_crtc->active) {
4940 dev_priv->display.crtc_disable(crtc);
4941
4942 if (!HAS_DDI(dev)) {
4943 domains = intel_crtc->enabled_power_domains;
4944 for_each_power_domain(domain, domains)
4945 intel_display_power_put(dev_priv, domain);
4946 intel_crtc->enabled_power_domains = 0;
4947 }
4948 }
4949 }
4863 4950
4864 intel_crtc_update_sarea(crtc, enable); 4951 intel_crtc_update_sarea(crtc, enable);
4865} 4952}
@@ -4869,6 +4956,8 @@ static void intel_crtc_disable(struct drm_crtc *crtc)
4869 struct drm_device *dev = crtc->dev; 4956 struct drm_device *dev = crtc->dev;
4870 struct drm_connector *connector; 4957 struct drm_connector *connector;
4871 struct drm_i915_private *dev_priv = dev->dev_private; 4958 struct drm_i915_private *dev_priv = dev->dev_private;
4959 struct drm_i915_gem_object *old_obj;
4960 enum pipe pipe = to_intel_crtc(crtc)->pipe;
4872 4961
4873 /* crtc should still be enabled when we disable it. */ 4962 /* crtc should still be enabled when we disable it. */
4874 WARN_ON(!crtc->enabled); 4963 WARN_ON(!crtc->enabled);
@@ -4878,12 +4967,15 @@ static void intel_crtc_disable(struct drm_crtc *crtc)
4878 dev_priv->display.off(crtc); 4967 dev_priv->display.off(crtc);
4879 4968
4880 assert_plane_disabled(dev->dev_private, to_intel_crtc(crtc)->plane); 4969 assert_plane_disabled(dev->dev_private, to_intel_crtc(crtc)->plane);
4881 assert_cursor_disabled(dev_priv, to_intel_crtc(crtc)->pipe); 4970 assert_cursor_disabled(dev_priv, pipe);
4882 assert_pipe_disabled(dev->dev_private, to_intel_crtc(crtc)->pipe); 4971 assert_pipe_disabled(dev->dev_private, pipe);
4883 4972
4884 if (crtc->primary->fb) { 4973 if (crtc->primary->fb) {
4974 old_obj = to_intel_framebuffer(crtc->primary->fb)->obj;
4885 mutex_lock(&dev->struct_mutex); 4975 mutex_lock(&dev->struct_mutex);
4886 intel_unpin_fb_obj(to_intel_framebuffer(crtc->primary->fb)->obj); 4976 intel_unpin_fb_obj(old_obj);
4977 i915_gem_track_fb(old_obj, NULL,
4978 INTEL_FRONTBUFFER_PRIMARY(pipe));
4887 mutex_unlock(&dev->struct_mutex); 4979 mutex_unlock(&dev->struct_mutex);
4888 crtc->primary->fb = NULL; 4980 crtc->primary->fb = NULL;
4889 } 4981 }
@@ -7991,8 +8083,8 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,
7991 struct drm_i915_private *dev_priv = dev->dev_private; 8083 struct drm_i915_private *dev_priv = dev->dev_private;
7992 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 8084 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
7993 int pipe = intel_crtc->pipe; 8085 int pipe = intel_crtc->pipe;
7994 int x = intel_crtc->cursor_x; 8086 int x = crtc->cursor_x;
7995 int y = intel_crtc->cursor_y; 8087 int y = crtc->cursor_y;
7996 u32 base = 0, pos = 0; 8088 u32 base = 0, pos = 0;
7997 8089
7998 if (on) 8090 if (on)
@@ -8036,21 +8128,27 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,
8036 intel_crtc->cursor_base = base; 8128 intel_crtc->cursor_base = base;
8037} 8129}
8038 8130
8039static int intel_crtc_cursor_set(struct drm_crtc *crtc, 8131/*
8040 struct drm_file *file, 8132 * intel_crtc_cursor_set_obj - Set cursor to specified GEM object
8041 uint32_t handle, 8133 *
8042 uint32_t width, uint32_t height) 8134 * Note that the object's reference will be consumed if the update fails. If
8135 * the update succeeds, the reference of the old object (if any) will be
8136 * consumed.
8137 */
8138static int intel_crtc_cursor_set_obj(struct drm_crtc *crtc,
8139 struct drm_i915_gem_object *obj,
8140 uint32_t width, uint32_t height)
8043{ 8141{
8044 struct drm_device *dev = crtc->dev; 8142 struct drm_device *dev = crtc->dev;
8045 struct drm_i915_private *dev_priv = dev->dev_private; 8143 struct drm_i915_private *dev_priv = dev->dev_private;
8046 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 8144 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
8047 struct drm_i915_gem_object *obj; 8145 enum pipe pipe = intel_crtc->pipe;
8048 unsigned old_width; 8146 unsigned old_width;
8049 uint32_t addr; 8147 uint32_t addr;
8050 int ret; 8148 int ret;
8051 8149
8052 /* if we want to turn off the cursor ignore width and height */ 8150 /* if we want to turn off the cursor ignore width and height */
8053 if (!handle) { 8151 if (!obj) {
8054 DRM_DEBUG_KMS("cursor off\n"); 8152 DRM_DEBUG_KMS("cursor off\n");
8055 addr = 0; 8153 addr = 0;
8056 obj = NULL; 8154 obj = NULL;
@@ -8066,12 +8164,8 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
8066 return -EINVAL; 8164 return -EINVAL;
8067 } 8165 }
8068 8166
8069 obj = to_intel_bo(drm_gem_object_lookup(dev, file, handle));
8070 if (&obj->base == NULL)
8071 return -ENOENT;
8072
8073 if (obj->base.size < width * height * 4) { 8167 if (obj->base.size < width * height * 4) {
8074 DRM_DEBUG_KMS("buffer is to small\n"); 8168 DRM_DEBUG_KMS("buffer is too small\n");
8075 ret = -ENOMEM; 8169 ret = -ENOMEM;
8076 goto fail; 8170 goto fail;
8077 } 8171 }
@@ -8126,9 +8220,10 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
8126 if (intel_crtc->cursor_bo) { 8220 if (intel_crtc->cursor_bo) {
8127 if (!INTEL_INFO(dev)->cursor_needs_physical) 8221 if (!INTEL_INFO(dev)->cursor_needs_physical)
8128 i915_gem_object_unpin_from_display_plane(intel_crtc->cursor_bo); 8222 i915_gem_object_unpin_from_display_plane(intel_crtc->cursor_bo);
8129 drm_gem_object_unreference(&intel_crtc->cursor_bo->base);
8130 } 8223 }
8131 8224
8225 i915_gem_track_fb(intel_crtc->cursor_bo, obj,
8226 INTEL_FRONTBUFFER_CURSOR(pipe));
8132 mutex_unlock(&dev->struct_mutex); 8227 mutex_unlock(&dev->struct_mutex);
8133 8228
8134 old_width = intel_crtc->cursor_width; 8229 old_width = intel_crtc->cursor_width;
@@ -8144,6 +8239,8 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
8144 intel_crtc_update_cursor(crtc, intel_crtc->cursor_bo != NULL); 8239 intel_crtc_update_cursor(crtc, intel_crtc->cursor_bo != NULL);
8145 } 8240 }
8146 8241
8242 intel_frontbuffer_flip(dev, INTEL_FRONTBUFFER_CURSOR(pipe));
8243
8147 return 0; 8244 return 0;
8148fail_unpin: 8245fail_unpin:
8149 i915_gem_object_unpin_from_display_plane(obj); 8246 i915_gem_object_unpin_from_display_plane(obj);
@@ -8154,19 +8251,6 @@ fail:
8154 return ret; 8251 return ret;
8155} 8252}
8156 8253
8157static int intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
8158{
8159 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
8160
8161 intel_crtc->cursor_x = clamp_t(int, x, SHRT_MIN, SHRT_MAX);
8162 intel_crtc->cursor_y = clamp_t(int, y, SHRT_MIN, SHRT_MAX);
8163
8164 if (intel_crtc->active)
8165 intel_crtc_update_cursor(crtc, intel_crtc->cursor_bo != NULL);
8166
8167 return 0;
8168}
8169
8170static void intel_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, 8254static void intel_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
8171 u16 *blue, uint32_t start, uint32_t size) 8255 u16 *blue, uint32_t start, uint32_t size)
8172{ 8256{
@@ -8667,12 +8751,10 @@ struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
8667 return mode; 8751 return mode;
8668} 8752}
8669 8753
8670static void intel_increase_pllclock(struct drm_crtc *crtc) 8754static void intel_increase_pllclock(struct drm_device *dev,
8755 enum pipe pipe)
8671{ 8756{
8672 struct drm_device *dev = crtc->dev;
8673 struct drm_i915_private *dev_priv = dev->dev_private; 8757 struct drm_i915_private *dev_priv = dev->dev_private;
8674 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
8675 int pipe = intel_crtc->pipe;
8676 int dpll_reg = DPLL(pipe); 8758 int dpll_reg = DPLL(pipe);
8677 int dpll; 8759 int dpll;
8678 8760
@@ -8773,28 +8855,179 @@ out:
8773 intel_runtime_pm_put(dev_priv); 8855 intel_runtime_pm_put(dev_priv);
8774} 8856}
8775 8857
8776void intel_mark_fb_busy(struct drm_i915_gem_object *obj, 8858
8777 struct intel_engine_cs *ring) 8859/**
8860 * intel_mark_fb_busy - mark given planes as busy
8861 * @dev: DRM device
8862 * @frontbuffer_bits: bits for the affected planes
8863 * @ring: optional ring for asynchronous commands
8864 *
8865 * This function gets called every time the screen contents change. It can be
8866 * used to keep e.g. the update rate at the nominal refresh rate with DRRS.
8867 */
8868static void intel_mark_fb_busy(struct drm_device *dev,
8869 unsigned frontbuffer_bits,
8870 struct intel_engine_cs *ring)
8778{ 8871{
8779 struct drm_device *dev = obj->base.dev; 8872 enum pipe pipe;
8780 struct drm_crtc *crtc;
8781 8873
8782 if (!i915.powersave) 8874 if (!i915.powersave)
8783 return; 8875 return;
8784 8876
8785 for_each_crtc(dev, crtc) { 8877 for_each_pipe(pipe) {
8786 if (!crtc->primary->fb) 8878 if (!(frontbuffer_bits & INTEL_FRONTBUFFER_ALL_MASK(pipe)))
8787 continue;
8788
8789 if (to_intel_framebuffer(crtc->primary->fb)->obj != obj)
8790 continue; 8879 continue;
8791 8880
8792 intel_increase_pllclock(crtc); 8881 intel_increase_pllclock(dev, pipe);
8793 if (ring && intel_fbc_enabled(dev)) 8882 if (ring && intel_fbc_enabled(dev))
8794 ring->fbc_dirty = true; 8883 ring->fbc_dirty = true;
8795 } 8884 }
8796} 8885}
8797 8886
8887/**
8888 * intel_fb_obj_invalidate - invalidate frontbuffer object
8889 * @obj: GEM object to invalidate
8890 * @ring: set for asynchronous rendering
8891 *
8892 * This function gets called every time rendering on the given object starts and
8893 * frontbuffer caching (fbc, low refresh rate for DRRS, panel self refresh) must
8894 * be invalidated. If @ring is non-NULL any subsequent invalidation will be delayed
8895 * until the rendering completes or a flip on this frontbuffer plane is
8896 * scheduled.
8897 */
8898void intel_fb_obj_invalidate(struct drm_i915_gem_object *obj,
8899 struct intel_engine_cs *ring)
8900{
8901 struct drm_device *dev = obj->base.dev;
8902 struct drm_i915_private *dev_priv = dev->dev_private;
8903
8904 WARN_ON(!mutex_is_locked(&dev->struct_mutex));
8905
8906 if (!obj->frontbuffer_bits)
8907 return;
8908
8909 if (ring) {
8910 mutex_lock(&dev_priv->fb_tracking.lock);
8911 dev_priv->fb_tracking.busy_bits
8912 |= obj->frontbuffer_bits;
8913 dev_priv->fb_tracking.flip_bits
8914 &= ~obj->frontbuffer_bits;
8915 mutex_unlock(&dev_priv->fb_tracking.lock);
8916 }
8917
8918 intel_mark_fb_busy(dev, obj->frontbuffer_bits, ring);
8919
8920 intel_edp_psr_exit(dev);
8921}
8922
8923/**
8924 * intel_frontbuffer_flush - flush frontbuffer
8925 * @dev: DRM device
8926 * @frontbuffer_bits: frontbuffer plane tracking bits
8927 *
8928 * This function gets called every time rendering on the given planes has
8929 * completed and frontbuffer caching can be started again. Flushes will get
8930 * delayed if they're blocked by some oustanding asynchronous rendering.
8931 *
8932 * Can be called without any locks held.
8933 */
8934void intel_frontbuffer_flush(struct drm_device *dev,
8935 unsigned frontbuffer_bits)
8936{
8937 struct drm_i915_private *dev_priv = dev->dev_private;
8938
8939 /* Delay flushing when rings are still busy.*/
8940 mutex_lock(&dev_priv->fb_tracking.lock);
8941 frontbuffer_bits &= ~dev_priv->fb_tracking.busy_bits;
8942 mutex_unlock(&dev_priv->fb_tracking.lock);
8943
8944 intel_mark_fb_busy(dev, frontbuffer_bits, NULL);
8945
8946 intel_edp_psr_exit(dev);
8947}
8948
8949/**
8950 * intel_fb_obj_flush - flush frontbuffer object
8951 * @obj: GEM object to flush
8952 * @retire: set when retiring asynchronous rendering
8953 *
8954 * This function gets called every time rendering on the given object has
8955 * completed and frontbuffer caching can be started again. If @retire is true
8956 * then any delayed flushes will be unblocked.
8957 */
8958void intel_fb_obj_flush(struct drm_i915_gem_object *obj,
8959 bool retire)
8960{
8961 struct drm_device *dev = obj->base.dev;
8962 struct drm_i915_private *dev_priv = dev->dev_private;
8963 unsigned frontbuffer_bits;
8964
8965 WARN_ON(!mutex_is_locked(&dev->struct_mutex));
8966
8967 if (!obj->frontbuffer_bits)
8968 return;
8969
8970 frontbuffer_bits = obj->frontbuffer_bits;
8971
8972 if (retire) {
8973 mutex_lock(&dev_priv->fb_tracking.lock);
8974 /* Filter out new bits since rendering started. */
8975 frontbuffer_bits &= dev_priv->fb_tracking.busy_bits;
8976
8977 dev_priv->fb_tracking.busy_bits &= ~frontbuffer_bits;
8978 mutex_unlock(&dev_priv->fb_tracking.lock);
8979 }
8980
8981 intel_frontbuffer_flush(dev, frontbuffer_bits);
8982}
8983
8984/**
8985 * intel_frontbuffer_flip_prepare - prepare asnychronous frontbuffer flip
8986 * @dev: DRM device
8987 * @frontbuffer_bits: frontbuffer plane tracking bits
8988 *
8989 * This function gets called after scheduling a flip on @obj. The actual
8990 * frontbuffer flushing will be delayed until completion is signalled with
8991 * intel_frontbuffer_flip_complete. If an invalidate happens in between this
8992 * flush will be cancelled.
8993 *
8994 * Can be called without any locks held.
8995 */
8996void intel_frontbuffer_flip_prepare(struct drm_device *dev,
8997 unsigned frontbuffer_bits)
8998{
8999 struct drm_i915_private *dev_priv = dev->dev_private;
9000
9001 mutex_lock(&dev_priv->fb_tracking.lock);
9002 dev_priv->fb_tracking.flip_bits
9003 |= frontbuffer_bits;
9004 mutex_unlock(&dev_priv->fb_tracking.lock);
9005}
9006
9007/**
9008 * intel_frontbuffer_flip_complete - complete asynchronous frontbuffer flush
9009 * @dev: DRM device
9010 * @frontbuffer_bits: frontbuffer plane tracking bits
9011 *
9012 * This function gets called after the flip has been latched and will complete
9013 * on the next vblank. It will execute the fush if it hasn't been cancalled yet.
9014 *
9015 * Can be called without any locks held.
9016 */
9017void intel_frontbuffer_flip_complete(struct drm_device *dev,
9018 unsigned frontbuffer_bits)
9019{
9020 struct drm_i915_private *dev_priv = dev->dev_private;
9021
9022 mutex_lock(&dev_priv->fb_tracking.lock);
9023 /* Mask any cancelled flips. */
9024 frontbuffer_bits &= dev_priv->fb_tracking.flip_bits;
9025 dev_priv->fb_tracking.flip_bits &= ~frontbuffer_bits;
9026 mutex_unlock(&dev_priv->fb_tracking.lock);
9027
9028 intel_frontbuffer_flush(dev, frontbuffer_bits);
9029}
9030
8798static void intel_crtc_destroy(struct drm_crtc *crtc) 9031static void intel_crtc_destroy(struct drm_crtc *crtc)
8799{ 9032{
8800 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 9033 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
@@ -8812,8 +9045,6 @@ static void intel_crtc_destroy(struct drm_crtc *crtc)
8812 kfree(work); 9045 kfree(work);
8813 } 9046 }
8814 9047
8815 intel_crtc_cursor_set(crtc, NULL, 0, 0, 0);
8816
8817 drm_crtc_cleanup(crtc); 9048 drm_crtc_cleanup(crtc);
8818 9049
8819 kfree(intel_crtc); 9050 kfree(intel_crtc);
@@ -8824,6 +9055,7 @@ static void intel_unpin_work_fn(struct work_struct *__work)
8824 struct intel_unpin_work *work = 9055 struct intel_unpin_work *work =
8825 container_of(__work, struct intel_unpin_work, work); 9056 container_of(__work, struct intel_unpin_work, work);
8826 struct drm_device *dev = work->crtc->dev; 9057 struct drm_device *dev = work->crtc->dev;
9058 enum pipe pipe = to_intel_crtc(work->crtc)->pipe;
8827 9059
8828 mutex_lock(&dev->struct_mutex); 9060 mutex_lock(&dev->struct_mutex);
8829 intel_unpin_fb_obj(work->old_fb_obj); 9061 intel_unpin_fb_obj(work->old_fb_obj);
@@ -8833,6 +9065,8 @@ static void intel_unpin_work_fn(struct work_struct *__work)
8833 intel_update_fbc(dev); 9065 intel_update_fbc(dev);
8834 mutex_unlock(&dev->struct_mutex); 9066 mutex_unlock(&dev->struct_mutex);
8835 9067
9068 intel_frontbuffer_flip_complete(dev, INTEL_FRONTBUFFER_PRIMARY(pipe));
9069
8836 BUG_ON(atomic_read(&to_intel_crtc(work->crtc)->unpin_work_count) == 0); 9070 BUG_ON(atomic_read(&to_intel_crtc(work->crtc)->unpin_work_count) == 0);
8837 atomic_dec(&to_intel_crtc(work->crtc)->unpin_work_count); 9071 atomic_dec(&to_intel_crtc(work->crtc)->unpin_work_count);
8838 9072
@@ -9202,6 +9436,147 @@ static int intel_gen7_queue_flip(struct drm_device *dev,
9202 return 0; 9436 return 0;
9203} 9437}
9204 9438
9439static bool use_mmio_flip(struct intel_engine_cs *ring,
9440 struct drm_i915_gem_object *obj)
9441{
9442 /*
9443 * This is not being used for older platforms, because
9444 * non-availability of flip done interrupt forces us to use
9445 * CS flips. Older platforms derive flip done using some clever
9446 * tricks involving the flip_pending status bits and vblank irqs.
9447 * So using MMIO flips there would disrupt this mechanism.
9448 */
9449
9450 if (INTEL_INFO(ring->dev)->gen < 5)
9451 return false;
9452
9453 if (i915.use_mmio_flip < 0)
9454 return false;
9455 else if (i915.use_mmio_flip > 0)
9456 return true;
9457 else
9458 return ring != obj->ring;
9459}
9460
9461static void intel_do_mmio_flip(struct intel_crtc *intel_crtc)
9462{
9463 struct drm_device *dev = intel_crtc->base.dev;
9464 struct drm_i915_private *dev_priv = dev->dev_private;
9465 struct intel_framebuffer *intel_fb =
9466 to_intel_framebuffer(intel_crtc->base.primary->fb);
9467 struct drm_i915_gem_object *obj = intel_fb->obj;
9468 u32 dspcntr;
9469 u32 reg;
9470
9471 intel_mark_page_flip_active(intel_crtc);
9472
9473 reg = DSPCNTR(intel_crtc->plane);
9474 dspcntr = I915_READ(reg);
9475
9476 if (INTEL_INFO(dev)->gen >= 4) {
9477 if (obj->tiling_mode != I915_TILING_NONE)
9478 dspcntr |= DISPPLANE_TILED;
9479 else
9480 dspcntr &= ~DISPPLANE_TILED;
9481 }
9482 I915_WRITE(reg, dspcntr);
9483
9484 I915_WRITE(DSPSURF(intel_crtc->plane),
9485 intel_crtc->unpin_work->gtt_offset);
9486 POSTING_READ(DSPSURF(intel_crtc->plane));
9487}
9488
9489static int intel_postpone_flip(struct drm_i915_gem_object *obj)
9490{
9491 struct intel_engine_cs *ring;
9492 int ret;
9493
9494 lockdep_assert_held(&obj->base.dev->struct_mutex);
9495
9496 if (!obj->last_write_seqno)
9497 return 0;
9498
9499 ring = obj->ring;
9500
9501 if (i915_seqno_passed(ring->get_seqno(ring, true),
9502 obj->last_write_seqno))
9503 return 0;
9504
9505 ret = i915_gem_check_olr(ring, obj->last_write_seqno);
9506 if (ret)
9507 return ret;
9508
9509 if (WARN_ON(!ring->irq_get(ring)))
9510 return 0;
9511
9512 return 1;
9513}
9514
9515void intel_notify_mmio_flip(struct intel_engine_cs *ring)
9516{
9517 struct drm_i915_private *dev_priv = to_i915(ring->dev);
9518 struct intel_crtc *intel_crtc;
9519 unsigned long irq_flags;
9520 u32 seqno;
9521
9522 seqno = ring->get_seqno(ring, false);
9523
9524 spin_lock_irqsave(&dev_priv->mmio_flip_lock, irq_flags);
9525 for_each_intel_crtc(ring->dev, intel_crtc) {
9526 struct intel_mmio_flip *mmio_flip;
9527
9528 mmio_flip = &intel_crtc->mmio_flip;
9529 if (mmio_flip->seqno == 0)
9530 continue;
9531
9532 if (ring->id != mmio_flip->ring_id)
9533 continue;
9534
9535 if (i915_seqno_passed(seqno, mmio_flip->seqno)) {
9536 intel_do_mmio_flip(intel_crtc);
9537 mmio_flip->seqno = 0;
9538 ring->irq_put(ring);
9539 }
9540 }
9541 spin_unlock_irqrestore(&dev_priv->mmio_flip_lock, irq_flags);
9542}
9543
9544static int intel_queue_mmio_flip(struct drm_device *dev,
9545 struct drm_crtc *crtc,
9546 struct drm_framebuffer *fb,
9547 struct drm_i915_gem_object *obj,
9548 struct intel_engine_cs *ring,
9549 uint32_t flags)
9550{
9551 struct drm_i915_private *dev_priv = dev->dev_private;
9552 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
9553 unsigned long irq_flags;
9554 int ret;
9555
9556 if (WARN_ON(intel_crtc->mmio_flip.seqno))
9557 return -EBUSY;
9558
9559 ret = intel_postpone_flip(obj);
9560 if (ret < 0)
9561 return ret;
9562 if (ret == 0) {
9563 intel_do_mmio_flip(intel_crtc);
9564 return 0;
9565 }
9566
9567 spin_lock_irqsave(&dev_priv->mmio_flip_lock, irq_flags);
9568 intel_crtc->mmio_flip.seqno = obj->last_write_seqno;
9569 intel_crtc->mmio_flip.ring_id = obj->ring->id;
9570 spin_unlock_irqrestore(&dev_priv->mmio_flip_lock, irq_flags);
9571
9572 /*
9573 * Double check to catch cases where irq fired before
9574 * mmio flip data was ready
9575 */
9576 intel_notify_mmio_flip(obj->ring);
9577 return 0;
9578}
9579
9205static int intel_default_queue_flip(struct drm_device *dev, 9580static int intel_default_queue_flip(struct drm_device *dev,
9206 struct drm_crtc *crtc, 9581 struct drm_crtc *crtc,
9207 struct drm_framebuffer *fb, 9582 struct drm_framebuffer *fb,
@@ -9222,6 +9597,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
9222 struct drm_framebuffer *old_fb = crtc->primary->fb; 9597 struct drm_framebuffer *old_fb = crtc->primary->fb;
9223 struct drm_i915_gem_object *obj = to_intel_framebuffer(fb)->obj; 9598 struct drm_i915_gem_object *obj = to_intel_framebuffer(fb)->obj;
9224 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 9599 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
9600 enum pipe pipe = intel_crtc->pipe;
9225 struct intel_unpin_work *work; 9601 struct intel_unpin_work *work;
9226 struct intel_engine_cs *ring; 9602 struct intel_engine_cs *ring;
9227 unsigned long flags; 9603 unsigned long flags;
@@ -9290,7 +9666,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
9290 intel_crtc->reset_counter = atomic_read(&dev_priv->gpu_error.reset_counter); 9666 intel_crtc->reset_counter = atomic_read(&dev_priv->gpu_error.reset_counter);
9291 9667
9292 if (INTEL_INFO(dev)->gen >= 5 || IS_G4X(dev)) 9668 if (INTEL_INFO(dev)->gen >= 5 || IS_G4X(dev))
9293 work->flip_count = I915_READ(PIPE_FLIPCOUNT_GM45(intel_crtc->pipe)) + 1; 9669 work->flip_count = I915_READ(PIPE_FLIPCOUNT_GM45(pipe)) + 1;
9294 9670
9295 if (IS_VALLEYVIEW(dev)) { 9671 if (IS_VALLEYVIEW(dev)) {
9296 ring = &dev_priv->ring[BCS]; 9672 ring = &dev_priv->ring[BCS];
@@ -9309,12 +9685,20 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
9309 work->gtt_offset = 9685 work->gtt_offset =
9310 i915_gem_obj_ggtt_offset(obj) + intel_crtc->dspaddr_offset; 9686 i915_gem_obj_ggtt_offset(obj) + intel_crtc->dspaddr_offset;
9311 9687
9312 ret = dev_priv->display.queue_flip(dev, crtc, fb, obj, ring, page_flip_flags); 9688 if (use_mmio_flip(ring, obj))
9689 ret = intel_queue_mmio_flip(dev, crtc, fb, obj, ring,
9690 page_flip_flags);
9691 else
9692 ret = dev_priv->display.queue_flip(dev, crtc, fb, obj, ring,
9693 page_flip_flags);
9313 if (ret) 9694 if (ret)
9314 goto cleanup_unpin; 9695 goto cleanup_unpin;
9315 9696
9697 i915_gem_track_fb(work->old_fb_obj, obj,
9698 INTEL_FRONTBUFFER_PRIMARY(pipe));
9699
9316 intel_disable_fbc(dev); 9700 intel_disable_fbc(dev);
9317 intel_mark_fb_busy(obj, NULL); 9701 intel_frontbuffer_flip_prepare(dev, INTEL_FRONTBUFFER_PRIMARY(pipe));
9318 mutex_unlock(&dev->struct_mutex); 9702 mutex_unlock(&dev->struct_mutex);
9319 9703
9320 trace_i915_flip_request(intel_crtc->plane, obj); 9704 trace_i915_flip_request(intel_crtc->plane, obj);
@@ -9344,7 +9728,7 @@ out_hang:
9344 intel_crtc_wait_for_pending_flips(crtc); 9728 intel_crtc_wait_for_pending_flips(crtc);
9345 ret = intel_pipe_set_base(crtc, crtc->x, crtc->y, fb); 9729 ret = intel_pipe_set_base(crtc, crtc->x, crtc->y, fb);
9346 if (ret == 0 && event) 9730 if (ret == 0 && event)
9347 drm_send_vblank_event(dev, intel_crtc->pipe, event); 9731 drm_send_vblank_event(dev, pipe, event);
9348 } 9732 }
9349 return ret; 9733 return ret;
9350} 9734}
@@ -10379,10 +10763,13 @@ static int __intel_set_mode(struct drm_crtc *crtc,
10379 */ 10763 */
10380 for_each_intel_crtc_masked(dev, modeset_pipes, intel_crtc) { 10764 for_each_intel_crtc_masked(dev, modeset_pipes, intel_crtc) {
10381 struct drm_framebuffer *old_fb; 10765 struct drm_framebuffer *old_fb;
10766 struct drm_i915_gem_object *old_obj = NULL;
10767 struct drm_i915_gem_object *obj =
10768 to_intel_framebuffer(fb)->obj;
10382 10769
10383 mutex_lock(&dev->struct_mutex); 10770 mutex_lock(&dev->struct_mutex);
10384 ret = intel_pin_and_fence_fb_obj(dev, 10771 ret = intel_pin_and_fence_fb_obj(dev,
10385 to_intel_framebuffer(fb)->obj, 10772 obj,
10386 NULL); 10773 NULL);
10387 if (ret != 0) { 10774 if (ret != 0) {
10388 DRM_ERROR("pin & fence failed\n"); 10775 DRM_ERROR("pin & fence failed\n");
@@ -10390,8 +10777,12 @@ static int __intel_set_mode(struct drm_crtc *crtc,
10390 goto done; 10777 goto done;
10391 } 10778 }
10392 old_fb = crtc->primary->fb; 10779 old_fb = crtc->primary->fb;
10393 if (old_fb) 10780 if (old_fb) {
10394 intel_unpin_fb_obj(to_intel_framebuffer(old_fb)->obj); 10781 old_obj = to_intel_framebuffer(old_fb)->obj;
10782 intel_unpin_fb_obj(old_obj);
10783 }
10784 i915_gem_track_fb(old_obj, obj,
10785 INTEL_FRONTBUFFER_PRIMARY(intel_crtc->pipe));
10395 mutex_unlock(&dev->struct_mutex); 10786 mutex_unlock(&dev->struct_mutex);
10396 10787
10397 crtc->primary->fb = fb; 10788 crtc->primary->fb = fb;
@@ -10563,12 +10954,17 @@ intel_set_config_compute_mode_changes(struct drm_mode_set *set,
10563 if (is_crtc_connector_off(set)) { 10954 if (is_crtc_connector_off(set)) {
10564 config->mode_changed = true; 10955 config->mode_changed = true;
10565 } else if (set->crtc->primary->fb != set->fb) { 10956 } else if (set->crtc->primary->fb != set->fb) {
10566 /* If we have no fb then treat it as a full mode set */ 10957 /*
10958 * If we have no fb, we can only flip as long as the crtc is
10959 * active, otherwise we need a full mode set. The crtc may
10960 * be active if we've only disabled the primary plane, or
10961 * in fastboot situations.
10962 */
10567 if (set->crtc->primary->fb == NULL) { 10963 if (set->crtc->primary->fb == NULL) {
10568 struct intel_crtc *intel_crtc = 10964 struct intel_crtc *intel_crtc =
10569 to_intel_crtc(set->crtc); 10965 to_intel_crtc(set->crtc);
10570 10966
10571 if (intel_crtc->active && i915.fastboot) { 10967 if (intel_crtc->active) {
10572 DRM_DEBUG_KMS("crtc has no fb, will flip\n"); 10968 DRM_DEBUG_KMS("crtc has no fb, will flip\n");
10573 config->fb_changed = true; 10969 config->fb_changed = true;
10574 } else { 10970 } else {
@@ -10806,10 +11202,24 @@ static int intel_crtc_set_config(struct drm_mode_set *set)
10806 ret = intel_set_mode(set->crtc, set->mode, 11202 ret = intel_set_mode(set->crtc, set->mode,
10807 set->x, set->y, set->fb); 11203 set->x, set->y, set->fb);
10808 } else if (config->fb_changed) { 11204 } else if (config->fb_changed) {
11205 struct drm_i915_private *dev_priv = dev->dev_private;
11206 struct intel_crtc *intel_crtc = to_intel_crtc(set->crtc);
11207
10809 intel_crtc_wait_for_pending_flips(set->crtc); 11208 intel_crtc_wait_for_pending_flips(set->crtc);
10810 11209
10811 ret = intel_pipe_set_base(set->crtc, 11210 ret = intel_pipe_set_base(set->crtc,
10812 set->x, set->y, set->fb); 11211 set->x, set->y, set->fb);
11212
11213 /*
11214 * We need to make sure the primary plane is re-enabled if it
11215 * has previously been turned off.
11216 */
11217 if (!intel_crtc->primary_enabled && ret == 0) {
11218 WARN_ON(!intel_crtc->active);
11219 intel_enable_primary_hw_plane(dev_priv, intel_crtc->plane,
11220 intel_crtc->pipe);
11221 }
11222
10813 /* 11223 /*
10814 * In the fastboot case this may be our only check of the 11224 * In the fastboot case this may be our only check of the
10815 * state after boot. It would be better to only do it on 11225 * state after boot. It would be better to only do it on
@@ -10850,8 +11260,6 @@ out_config:
10850} 11260}
10851 11261
10852static const struct drm_crtc_funcs intel_crtc_funcs = { 11262static const struct drm_crtc_funcs intel_crtc_funcs = {
10853 .cursor_set = intel_crtc_cursor_set,
10854 .cursor_move = intel_crtc_cursor_move,
10855 .gamma_set = intel_crtc_gamma_set, 11263 .gamma_set = intel_crtc_gamma_set,
10856 .set_config = intel_crtc_set_config, 11264 .set_config = intel_crtc_set_config,
10857 .destroy = intel_crtc_destroy, 11265 .destroy = intel_crtc_destroy,
@@ -10959,17 +11367,318 @@ static void intel_shared_dpll_init(struct drm_device *dev)
10959 BUG_ON(dev_priv->num_shared_dpll > I915_NUM_PLLS); 11367 BUG_ON(dev_priv->num_shared_dpll > I915_NUM_PLLS);
10960} 11368}
10961 11369
11370static int
11371intel_primary_plane_disable(struct drm_plane *plane)
11372{
11373 struct drm_device *dev = plane->dev;
11374 struct drm_i915_private *dev_priv = dev->dev_private;
11375 struct intel_plane *intel_plane = to_intel_plane(plane);
11376 struct intel_crtc *intel_crtc;
11377
11378 if (!plane->fb)
11379 return 0;
11380
11381 BUG_ON(!plane->crtc);
11382
11383 intel_crtc = to_intel_crtc(plane->crtc);
11384
11385 /*
11386 * Even though we checked plane->fb above, it's still possible that
11387 * the primary plane has been implicitly disabled because the crtc
11388 * coordinates given weren't visible, or because we detected
11389 * that it was 100% covered by a sprite plane. Or, the CRTC may be
11390 * off and we've set a fb, but haven't actually turned on the CRTC yet.
11391 * In either case, we need to unpin the FB and let the fb pointer get
11392 * updated, but otherwise we don't need to touch the hardware.
11393 */
11394 if (!intel_crtc->primary_enabled)
11395 goto disable_unpin;
11396
11397 intel_crtc_wait_for_pending_flips(plane->crtc);
11398 intel_disable_primary_hw_plane(dev_priv, intel_plane->plane,
11399 intel_plane->pipe);
11400disable_unpin:
11401 i915_gem_track_fb(to_intel_framebuffer(plane->fb)->obj, NULL,
11402 INTEL_FRONTBUFFER_PRIMARY(intel_crtc->pipe));
11403 intel_unpin_fb_obj(to_intel_framebuffer(plane->fb)->obj);
11404 plane->fb = NULL;
11405
11406 return 0;
11407}
11408
11409static int
11410intel_primary_plane_setplane(struct drm_plane *plane, struct drm_crtc *crtc,
11411 struct drm_framebuffer *fb, int crtc_x, int crtc_y,
11412 unsigned int crtc_w, unsigned int crtc_h,
11413 uint32_t src_x, uint32_t src_y,
11414 uint32_t src_w, uint32_t src_h)
11415{
11416 struct drm_device *dev = crtc->dev;
11417 struct drm_i915_private *dev_priv = dev->dev_private;
11418 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
11419 struct intel_plane *intel_plane = to_intel_plane(plane);
11420 struct drm_i915_gem_object *obj, *old_obj = NULL;
11421 struct drm_rect dest = {
11422 /* integer pixels */
11423 .x1 = crtc_x,
11424 .y1 = crtc_y,
11425 .x2 = crtc_x + crtc_w,
11426 .y2 = crtc_y + crtc_h,
11427 };
11428 struct drm_rect src = {
11429 /* 16.16 fixed point */
11430 .x1 = src_x,
11431 .y1 = src_y,
11432 .x2 = src_x + src_w,
11433 .y2 = src_y + src_h,
11434 };
11435 const struct drm_rect clip = {
11436 /* integer pixels */
11437 .x2 = intel_crtc->active ? intel_crtc->config.pipe_src_w : 0,
11438 .y2 = intel_crtc->active ? intel_crtc->config.pipe_src_h : 0,
11439 };
11440 bool visible;
11441 int ret;
11442
11443 ret = drm_plane_helper_check_update(plane, crtc, fb,
11444 &src, &dest, &clip,
11445 DRM_PLANE_HELPER_NO_SCALING,
11446 DRM_PLANE_HELPER_NO_SCALING,
11447 false, true, &visible);
11448
11449 if (ret)
11450 return ret;
11451
11452 if (plane->fb)
11453 old_obj = to_intel_framebuffer(plane->fb)->obj;
11454 obj = to_intel_framebuffer(fb)->obj;
11455
11456 /*
11457 * If the CRTC isn't enabled, we're just pinning the framebuffer,
11458 * updating the fb pointer, and returning without touching the
11459 * hardware. This allows us to later do a drmModeSetCrtc with fb=-1 to
11460 * turn on the display with all planes setup as desired.
11461 */
11462 if (!crtc->enabled) {
11463 /*
11464 * If we already called setplane while the crtc was disabled,
11465 * we may have an fb pinned; unpin it.
11466 */
11467 if (plane->fb)
11468 intel_unpin_fb_obj(old_obj);
11469
11470 i915_gem_track_fb(old_obj, obj,
11471 INTEL_FRONTBUFFER_PRIMARY(intel_crtc->pipe));
11472
11473 /* Pin and return without programming hardware */
11474 return intel_pin_and_fence_fb_obj(dev, obj, NULL);
11475 }
11476
11477 intel_crtc_wait_for_pending_flips(crtc);
11478
11479 /*
11480 * If clipping results in a non-visible primary plane, we'll disable
11481 * the primary plane. Note that this is a bit different than what
11482 * happens if userspace explicitly disables the plane by passing fb=0
11483 * because plane->fb still gets set and pinned.
11484 */
11485 if (!visible) {
11486 /*
11487 * Try to pin the new fb first so that we can bail out if we
11488 * fail.
11489 */
11490 if (plane->fb != fb) {
11491 ret = intel_pin_and_fence_fb_obj(dev, obj, NULL);
11492 if (ret)
11493 return ret;
11494 }
11495
11496 i915_gem_track_fb(old_obj, obj,
11497 INTEL_FRONTBUFFER_PRIMARY(intel_crtc->pipe));
11498
11499 if (intel_crtc->primary_enabled)
11500 intel_disable_primary_hw_plane(dev_priv,
11501 intel_plane->plane,
11502 intel_plane->pipe);
11503
11504
11505 if (plane->fb != fb)
11506 if (plane->fb)
11507 intel_unpin_fb_obj(old_obj);
11508
11509 return 0;
11510 }
11511
11512 ret = intel_pipe_set_base(crtc, src.x1, src.y1, fb);
11513 if (ret)
11514 return ret;
11515
11516 if (!intel_crtc->primary_enabled)
11517 intel_enable_primary_hw_plane(dev_priv, intel_crtc->plane,
11518 intel_crtc->pipe);
11519
11520 return 0;
11521}
11522
11523/* Common destruction function for both primary and cursor planes */
11524static void intel_plane_destroy(struct drm_plane *plane)
11525{
11526 struct intel_plane *intel_plane = to_intel_plane(plane);
11527 drm_plane_cleanup(plane);
11528 kfree(intel_plane);
11529}
11530
11531static const struct drm_plane_funcs intel_primary_plane_funcs = {
11532 .update_plane = intel_primary_plane_setplane,
11533 .disable_plane = intel_primary_plane_disable,
11534 .destroy = intel_plane_destroy,
11535};
11536
11537static struct drm_plane *intel_primary_plane_create(struct drm_device *dev,
11538 int pipe)
11539{
11540 struct intel_plane *primary;
11541 const uint32_t *intel_primary_formats;
11542 int num_formats;
11543
11544 primary = kzalloc(sizeof(*primary), GFP_KERNEL);
11545 if (primary == NULL)
11546 return NULL;
11547
11548 primary->can_scale = false;
11549 primary->max_downscale = 1;
11550 primary->pipe = pipe;
11551 primary->plane = pipe;
11552 if (HAS_FBC(dev) && INTEL_INFO(dev)->gen < 4)
11553 primary->plane = !pipe;
11554
11555 if (INTEL_INFO(dev)->gen <= 3) {
11556 intel_primary_formats = intel_primary_formats_gen2;
11557 num_formats = ARRAY_SIZE(intel_primary_formats_gen2);
11558 } else {
11559 intel_primary_formats = intel_primary_formats_gen4;
11560 num_formats = ARRAY_SIZE(intel_primary_formats_gen4);
11561 }
11562
11563 drm_universal_plane_init(dev, &primary->base, 0,
11564 &intel_primary_plane_funcs,
11565 intel_primary_formats, num_formats,
11566 DRM_PLANE_TYPE_PRIMARY);
11567 return &primary->base;
11568}
11569
11570static int
11571intel_cursor_plane_disable(struct drm_plane *plane)
11572{
11573 if (!plane->fb)
11574 return 0;
11575
11576 BUG_ON(!plane->crtc);
11577
11578 return intel_crtc_cursor_set_obj(plane->crtc, NULL, 0, 0);
11579}
11580
11581static int
11582intel_cursor_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
11583 struct drm_framebuffer *fb, int crtc_x, int crtc_y,
11584 unsigned int crtc_w, unsigned int crtc_h,
11585 uint32_t src_x, uint32_t src_y,
11586 uint32_t src_w, uint32_t src_h)
11587{
11588 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
11589 struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb);
11590 struct drm_i915_gem_object *obj = intel_fb->obj;
11591 struct drm_rect dest = {
11592 /* integer pixels */
11593 .x1 = crtc_x,
11594 .y1 = crtc_y,
11595 .x2 = crtc_x + crtc_w,
11596 .y2 = crtc_y + crtc_h,
11597 };
11598 struct drm_rect src = {
11599 /* 16.16 fixed point */
11600 .x1 = src_x,
11601 .y1 = src_y,
11602 .x2 = src_x + src_w,
11603 .y2 = src_y + src_h,
11604 };
11605 const struct drm_rect clip = {
11606 /* integer pixels */
11607 .x2 = intel_crtc->config.pipe_src_w,
11608 .y2 = intel_crtc->config.pipe_src_h,
11609 };
11610 bool visible;
11611 int ret;
11612
11613 ret = drm_plane_helper_check_update(plane, crtc, fb,
11614 &src, &dest, &clip,
11615 DRM_PLANE_HELPER_NO_SCALING,
11616 DRM_PLANE_HELPER_NO_SCALING,
11617 true, true, &visible);
11618 if (ret)
11619 return ret;
11620
11621 crtc->cursor_x = crtc_x;
11622 crtc->cursor_y = crtc_y;
11623 if (fb != crtc->cursor->fb) {
11624 return intel_crtc_cursor_set_obj(crtc, obj, crtc_w, crtc_h);
11625 } else {
11626 intel_crtc_update_cursor(crtc, visible);
11627 return 0;
11628 }
11629}
11630static const struct drm_plane_funcs intel_cursor_plane_funcs = {
11631 .update_plane = intel_cursor_plane_update,
11632 .disable_plane = intel_cursor_plane_disable,
11633 .destroy = intel_plane_destroy,
11634};
11635
11636static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev,
11637 int pipe)
11638{
11639 struct intel_plane *cursor;
11640
11641 cursor = kzalloc(sizeof(*cursor), GFP_KERNEL);
11642 if (cursor == NULL)
11643 return NULL;
11644
11645 cursor->can_scale = false;
11646 cursor->max_downscale = 1;
11647 cursor->pipe = pipe;
11648 cursor->plane = pipe;
11649
11650 drm_universal_plane_init(dev, &cursor->base, 0,
11651 &intel_cursor_plane_funcs,
11652 intel_cursor_formats,
11653 ARRAY_SIZE(intel_cursor_formats),
11654 DRM_PLANE_TYPE_CURSOR);
11655 return &cursor->base;
11656}
11657
10962static void intel_crtc_init(struct drm_device *dev, int pipe) 11658static void intel_crtc_init(struct drm_device *dev, int pipe)
10963{ 11659{
10964 struct drm_i915_private *dev_priv = dev->dev_private; 11660 struct drm_i915_private *dev_priv = dev->dev_private;
10965 struct intel_crtc *intel_crtc; 11661 struct intel_crtc *intel_crtc;
10966 int i; 11662 struct drm_plane *primary = NULL;
11663 struct drm_plane *cursor = NULL;
11664 int i, ret;
10967 11665
10968 intel_crtc = kzalloc(sizeof(*intel_crtc), GFP_KERNEL); 11666 intel_crtc = kzalloc(sizeof(*intel_crtc), GFP_KERNEL);
10969 if (intel_crtc == NULL) 11667 if (intel_crtc == NULL)
10970 return; 11668 return;
10971 11669
10972 drm_crtc_init(dev, &intel_crtc->base, &intel_crtc_funcs); 11670 primary = intel_primary_plane_create(dev, pipe);
11671 if (!primary)
11672 goto fail;
11673
11674 cursor = intel_cursor_plane_create(dev, pipe);
11675 if (!cursor)
11676 goto fail;
11677
11678 ret = drm_crtc_init_with_planes(dev, &intel_crtc->base, primary,
11679 cursor, &intel_crtc_funcs);
11680 if (ret)
11681 goto fail;
10973 11682
10974 drm_mode_crtc_set_gamma_size(&intel_crtc->base, 256); 11683 drm_mode_crtc_set_gamma_size(&intel_crtc->base, 256);
10975 for (i = 0; i < 256; i++) { 11684 for (i = 0; i < 256; i++) {
@@ -10980,7 +11689,7 @@ static void intel_crtc_init(struct drm_device *dev, int pipe)
10980 11689
10981 /* 11690 /*
10982 * On gen2/3 only plane A can do fbc, but the panel fitter and lvds port 11691 * On gen2/3 only plane A can do fbc, but the panel fitter and lvds port
10983 * is hooked to plane B. Hence we want plane A feeding pipe B. 11692 * is hooked to pipe B. Hence we want plane A feeding pipe B.
10984 */ 11693 */
10985 intel_crtc->pipe = pipe; 11694 intel_crtc->pipe = pipe;
10986 intel_crtc->plane = pipe; 11695 intel_crtc->plane = pipe;
@@ -11002,6 +11711,14 @@ static void intel_crtc_init(struct drm_device *dev, int pipe)
11002 drm_crtc_helper_add(&intel_crtc->base, &intel_helper_funcs); 11711 drm_crtc_helper_add(&intel_crtc->base, &intel_helper_funcs);
11003 11712
11004 WARN_ON(drm_crtc_index(&intel_crtc->base) != intel_crtc->pipe); 11713 WARN_ON(drm_crtc_index(&intel_crtc->base) != intel_crtc->pipe);
11714 return;
11715
11716fail:
11717 if (primary)
11718 drm_plane_cleanup(primary);
11719 if (cursor)
11720 drm_plane_cleanup(cursor);
11721 kfree(intel_crtc);
11005} 11722}
11006 11723
11007enum pipe intel_get_pipe_from_connector(struct intel_connector *connector) 11724enum pipe intel_get_pipe_from_connector(struct intel_connector *connector)
@@ -11236,6 +11953,8 @@ static void intel_setup_outputs(struct drm_device *dev)
11236 if (SUPPORTS_TV(dev)) 11953 if (SUPPORTS_TV(dev))
11237 intel_tv_init(dev); 11954 intel_tv_init(dev);
11238 11955
11956 intel_edp_psr_init(dev);
11957
11239 list_for_each_entry(encoder, &dev->mode_config.encoder_list, base.head) { 11958 list_for_each_entry(encoder, &dev->mode_config.encoder_list, base.head) {
11240 encoder->base.possible_crtcs = encoder->crtc_mask; 11959 encoder->base.possible_crtcs = encoder->crtc_mask;
11241 encoder->base.possible_clones = 11960 encoder->base.possible_clones =
@@ -11249,11 +11968,14 @@ static void intel_setup_outputs(struct drm_device *dev)
11249 11968
11250static void intel_user_framebuffer_destroy(struct drm_framebuffer *fb) 11969static void intel_user_framebuffer_destroy(struct drm_framebuffer *fb)
11251{ 11970{
11971 struct drm_device *dev = fb->dev;
11252 struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); 11972 struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb);
11253 11973
11254 drm_framebuffer_cleanup(fb); 11974 drm_framebuffer_cleanup(fb);
11975 mutex_lock(&dev->struct_mutex);
11255 WARN_ON(!intel_fb->obj->framebuffer_references--); 11976 WARN_ON(!intel_fb->obj->framebuffer_references--);
11256 drm_gem_object_unreference_unlocked(&intel_fb->obj->base); 11977 drm_gem_object_unreference(&intel_fb->obj->base);
11978 mutex_unlock(&dev->struct_mutex);
11257 kfree(intel_fb); 11979 kfree(intel_fb);
11258} 11980}
11259 11981
@@ -12266,7 +12988,6 @@ void intel_connector_unregister(struct intel_connector *intel_connector)
12266void intel_modeset_cleanup(struct drm_device *dev) 12988void intel_modeset_cleanup(struct drm_device *dev)
12267{ 12989{
12268 struct drm_i915_private *dev_priv = dev->dev_private; 12990 struct drm_i915_private *dev_priv = dev->dev_private;
12269 struct drm_crtc *crtc;
12270 struct drm_connector *connector; 12991 struct drm_connector *connector;
12271 12992
12272 /* 12993 /*
@@ -12286,14 +13007,6 @@ void intel_modeset_cleanup(struct drm_device *dev)
12286 13007
12287 intel_unregister_dsm_handler(); 13008 intel_unregister_dsm_handler();
12288 13009
12289 for_each_crtc(dev, crtc) {
12290 /* Skip inactive CRTCs */
12291 if (!crtc->primary->fb)
12292 continue;
12293
12294 intel_increase_pllclock(crtc);
12295 }
12296
12297 intel_disable_fbc(dev); 13010 intel_disable_fbc(dev);
12298 13011
12299 intel_disable_gt_powersave(dev); 13012 intel_disable_gt_powersave(dev);