--- /dev/null
+From 0d8957c8a90bbb5d34fab9a304459448a5131e06 Mon Sep 17 00:00:00 2001
+From: Daniel Vetter <daniel.vetter@ffwll.ch>
+Date: Tue, 7 Aug 2012 09:54:14 +0200
+Subject: drm/i915: correctly order the ring init sequence
+
+From: Daniel Vetter <daniel.vetter@ffwll.ch>
+
+commit 0d8957c8a90bbb5d34fab9a304459448a5131e06 upstream.
+
+We may only start to set up the new register values after having
+confirmed that the ring is truely off. Otherwise the hw might lose the
+newly written register values. This is caught later on in the init
+sequence, when we check whether the register writes have stuck.
+
+Reviewed-by: Jani Nikula <jani.nikula@intel.com>
+Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=50522
+Tested-by: Yang Guang <guang.a.yang@intel.com>
+Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/gpu/drm/i915/intel_ringbuffer.c | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
++++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
+@@ -258,8 +258,6 @@ static int init_ring_common(struct intel
+ I915_WRITE_HEAD(ring, 0);
+ ring->write_tail(ring, 0);
+
+- /* Initialize the ring. */
+- I915_WRITE_START(ring, obj->gtt_offset);
+ head = I915_READ_HEAD(ring) & HEAD_ADDR;
+
+ /* G45 ring initialization fails to reset head to zero */
+@@ -285,6 +283,11 @@ static int init_ring_common(struct intel
+ }
+ }
+
++ /* Initialize the ring. This must happen _after_ we've cleared the ring
++ * registers with the above sequence (the readback of the HEAD registers
++ * also enforces ordering), otherwise the hw might lose the new ring
++ * register values. */
++ I915_WRITE_START(ring, obj->gtt_offset);
+ I915_WRITE_CTL(ring,
+ ((ring->size - PAGE_SIZE) & RING_NR_PAGES)
+ | RING_VALID);
--- /dev/null
+From 4344b813f105a19f793f1fd93ad775b784648b95 Mon Sep 17 00:00:00 2001
+From: Daniel Vetter <daniel.vetter@ffwll.ch>
+Date: Fri, 10 Aug 2012 11:10:20 +0200
+Subject: drm/i915: ignore eDP bpc settings from vbt
+
+From: Daniel Vetter <daniel.vetter@ffwll.ch>
+
+commit 4344b813f105a19f793f1fd93ad775b784648b95 upstream.
+
+This has originally been introduced to not oversubscribe the dp links
+in
+
+commit 885a5fb5b120a5c7e0b3baad7b0feb5a89f76c18
+Author: Zhenyu Wang <zhenyuw@linux.intel.com>
+Date: Tue Jan 12 05:38:31 2010 +0800
+
+ drm/i915: fix pixel color depth setting on eDP
+
+Since then we've fixed up the dp link bandwidth calculation code and
+should now automatically fall back to 6bpc dithering. So this is
+unnecessary.
+
+Furthermore it seems to break the new MacbookPro with retina display,
+hence let's just rip this out.
+
+Reported-by: Benoit Gschwind <gschwind@gnu-log.net>
+Cc: Benoit Gschwind <gschwind@gnu-log.net>
+Cc: Francois Rigaut <frigaut@gmail.com>
+Tested-by: Benoit Gschwind <gschwind@gnu-log.net>
+Tested-by: Bernhard Froemel <froemel at vmars tuwien.ac.at>
+Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+--
+
+Testing feedback highgly welcome, and thanks for Benoit for finding
+out that the bpc computations are busted.
+-Daniel
+
+---
+ drivers/gpu/drm/i915/intel_display.c | 11 -----------
+ 1 file changed, 11 deletions(-)
+
+--- a/drivers/gpu/drm/i915/intel_display.c
++++ b/drivers/gpu/drm/i915/intel_display.c
+@@ -4982,17 +4982,6 @@ static bool intel_choose_pipe_bpp_dither
+ continue;
+ }
+
+- if (intel_encoder->type == INTEL_OUTPUT_EDP) {
+- /* Use VBT settings if we have an eDP panel */
+- unsigned int edp_bpc = dev_priv->edp.bpp / 3;
+-
+- if (edp_bpc < display_bpc) {
+- DRM_DEBUG_KMS("clamping display bpc (was %d) to eDP (%d)\n", display_bpc, edp_bpc);
+- display_bpc = edp_bpc;
+- }
+- continue;
+- }
+-
+ /* Not one of the known troublemakers, check the EDID */
+ list_for_each_entry(connector, &dev->mode_config.connector_list,
+ head) {
--- /dev/null
+From 35a38556d900b9cb5dfa2529c93944b847f8a8a4 Mon Sep 17 00:00:00 2001
+From: Daniel Vetter <daniel.vetter@ffwll.ch>
+Date: Sun, 12 Aug 2012 22:17:14 +0200
+Subject: drm/i915: reorder edp disabling to fix ivb MacBook Air
+
+From: Daniel Vetter <daniel.vetter@ffwll.ch>
+
+commit 35a38556d900b9cb5dfa2529c93944b847f8a8a4 upstream.
+
+eDP is tons of fun. It turns out that at least the new MacBook Air 5,1
+model absolutely doesn't like the new force vdd dance we've introduced
+in
+
+commit 6cb49835da0426f69a2931bc2a0a8156344b0e41
+Author: Daniel Vetter <daniel.vetter@ffwll.ch>
+Date: Sun May 20 17:14:50 2012 +0200
+
+ drm/i915: enable vdd when switching off the eDP panel
+
+But that patch also tried to fix some neat edp sequence issue with the
+force_vdd timings. Closer inspection reveals that we've raised
+force_vdd only to do the aux channel communication dp_sink_dpms. If we
+move the edp_panel_off below that, we don't need any force_vdd for the
+disable sequence, which makes the Air happy.
+
+Unfortunately the reporter of the original bug that the above commit
+fixed is travelling, so we can't test whether this regresses things.
+But my theory is that since we don't check for any power-off ->
+force_vdd-on delays in edp_panel_vdd_on, this was the actual
+root-cause of this failure. With that force_vdd dance completely
+eliminated, I'm hopeful the original bug stays fixed, too.
+
+For reference the old bug, which hopefully doesn't get broken by this:
+
+https://bugzilla.kernel.org/show_bug.cgi?id=43163
+
+In any case, regression fixers win over plain bugfixes, so this needs
+to go in asap.
+
+v2: The crucial pieces seems to be to clear the force_vdd flag
+uncoditionally, too, in edp_panel_off. Looks like this is left behind
+by the firmware somehow.
+
+v3: The Apple firmware seems to switch off the panel on it's own, hence
+we still need to keep force_vdd on, but properly clear it when switching
+the panel off.
+
+Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=45671
+Tested-by: Roberto Romer <sildurin@gmail.com>
+Tested-by: Daniel Wagner <wagi@monom.org>
+Tested-by: Keith Packard <keithp@keithp.com>
+Cc: Keith Packard <keithp@keithp.com>
+Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/gpu/drm/i915/intel_dp.c | 14 +++++++-------
+ 1 file changed, 7 insertions(+), 7 deletions(-)
+
+--- a/drivers/gpu/drm/i915/intel_dp.c
++++ b/drivers/gpu/drm/i915/intel_dp.c
+@@ -1156,10 +1156,14 @@ static void ironlake_edp_panel_off(struc
+ WARN(!intel_dp->want_panel_vdd, "Need VDD to turn off panel\n");
+
+ pp = ironlake_get_pp_control(dev_priv);
+- pp &= ~(POWER_TARGET_ON | PANEL_POWER_RESET | EDP_BLC_ENABLE);
++ /* We need to switch off panel power _and_ force vdd, for otherwise some
++ * panels get very unhappy and cease to work. */
++ pp &= ~(POWER_TARGET_ON | EDP_FORCE_VDD | PANEL_POWER_RESET | EDP_BLC_ENABLE);
+ I915_WRITE(PCH_PP_CONTROL, pp);
+ POSTING_READ(PCH_PP_CONTROL);
+
++ intel_dp->want_panel_vdd = false;
++
+ ironlake_wait_panel_off(intel_dp);
+ }
+
+@@ -1269,11 +1273,9 @@ static void intel_dp_prepare(struct drm_
+ * ensure that we have vdd while we switch off the panel. */
+ ironlake_edp_panel_vdd_on(intel_dp);
+ ironlake_edp_backlight_off(intel_dp);
+- ironlake_edp_panel_off(intel_dp);
+-
+ intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
++ ironlake_edp_panel_off(intel_dp);
+ intel_dp_link_down(intel_dp);
+- ironlake_edp_panel_vdd_off(intel_dp, false);
+ }
+
+ static void intel_dp_commit(struct drm_encoder *encoder)
+@@ -1308,11 +1310,9 @@ intel_dp_dpms(struct drm_encoder *encode
+ /* Switching the panel off requires vdd. */
+ ironlake_edp_panel_vdd_on(intel_dp);
+ ironlake_edp_backlight_off(intel_dp);
+- ironlake_edp_panel_off(intel_dp);
+-
+ intel_dp_sink_dpms(intel_dp, mode);
++ ironlake_edp_panel_off(intel_dp);
+ intel_dp_link_down(intel_dp);
+- ironlake_edp_panel_vdd_off(intel_dp, false);
+
+ if (is_cpu_edp(intel_dp))
+ ironlake_edp_pll_off(encoder);
--- /dev/null
+From 6c0ae2ab85fc4a95cae82047a7db1f688a7737ab Mon Sep 17 00:00:00 2001
+From: Alex Deucher <alexander.deucher@amd.com>
+Date: Thu, 26 Jul 2012 13:38:52 -0400
+Subject: drm/radeon: properly handle crtc powergating
+
+From: Alex Deucher <alexander.deucher@amd.com>
+
+commit 6c0ae2ab85fc4a95cae82047a7db1f688a7737ab upstream.
+
+Need to make sure the crtc is gated on before modesetting.
+Explicitly gate the crtc on in prepare() and set a flag
+so that the dpms functions don't gate it off during
+mode set.
+
+Noticed by sylware on IRC.
+
+Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/gpu/drm/radeon/atombios_crtc.c | 14 ++++++++++++--
+ drivers/gpu/drm/radeon/radeon_legacy_crtc.c | 4 ++++
+ drivers/gpu/drm/radeon/radeon_mode.h | 1 +
+ 3 files changed, 17 insertions(+), 2 deletions(-)
+
+--- a/drivers/gpu/drm/radeon/atombios_crtc.c
++++ b/drivers/gpu/drm/radeon/atombios_crtc.c
+@@ -259,7 +259,7 @@ void atombios_crtc_dpms(struct drm_crtc
+ /* adjust pm to dpms changes BEFORE enabling crtcs */
+ radeon_pm_compute_clocks(rdev);
+ /* disable crtc pair power gating before programming */
+- if (ASIC_IS_DCE6(rdev))
++ if (ASIC_IS_DCE6(rdev) && !radeon_crtc->in_mode_set)
+ atombios_powergate_crtc(crtc, ATOM_DISABLE);
+ atombios_enable_crtc(crtc, ATOM_ENABLE);
+ if (ASIC_IS_DCE3(rdev) && !ASIC_IS_DCE6(rdev))
+@@ -279,7 +279,7 @@ void atombios_crtc_dpms(struct drm_crtc
+ atombios_enable_crtc(crtc, ATOM_DISABLE);
+ radeon_crtc->enabled = false;
+ /* power gating is per-pair */
+- if (ASIC_IS_DCE6(rdev)) {
++ if (ASIC_IS_DCE6(rdev) && !radeon_crtc->in_mode_set) {
+ struct drm_crtc *other_crtc;
+ struct radeon_crtc *other_radeon_crtc;
+ list_for_each_entry(other_crtc, &rdev->ddev->mode_config.crtc_list, head) {
+@@ -1634,18 +1634,28 @@ static bool atombios_crtc_mode_fixup(str
+ static void atombios_crtc_prepare(struct drm_crtc *crtc)
+ {
+ struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
++ struct drm_device *dev = crtc->dev;
++ struct radeon_device *rdev = dev->dev_private;
+
++ radeon_crtc->in_mode_set = true;
+ /* pick pll */
+ radeon_crtc->pll_id = radeon_atom_pick_pll(crtc);
+
++ /* disable crtc pair power gating before programming */
++ if (ASIC_IS_DCE6(rdev))
++ atombios_powergate_crtc(crtc, ATOM_DISABLE);
++
+ atombios_lock_crtc(crtc, ATOM_ENABLE);
+ atombios_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
+ }
+
+ static void atombios_crtc_commit(struct drm_crtc *crtc)
+ {
++ struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
++
+ atombios_crtc_dpms(crtc, DRM_MODE_DPMS_ON);
+ atombios_lock_crtc(crtc, ATOM_DISABLE);
++ radeon_crtc->in_mode_set = false;
+ }
+
+ static void atombios_crtc_disable(struct drm_crtc *crtc)
+--- a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
++++ b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
+@@ -1025,9 +1025,11 @@ static int radeon_crtc_mode_set(struct d
+
+ static void radeon_crtc_prepare(struct drm_crtc *crtc)
+ {
++ struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
+ struct drm_device *dev = crtc->dev;
+ struct drm_crtc *crtci;
+
++ radeon_crtc->in_mode_set = true;
+ /*
+ * The hardware wedges sometimes if you reconfigure one CRTC
+ * whilst another is running (see fdo bug #24611).
+@@ -1038,6 +1040,7 @@ static void radeon_crtc_prepare(struct d
+
+ static void radeon_crtc_commit(struct drm_crtc *crtc)
+ {
++ struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
+ struct drm_device *dev = crtc->dev;
+ struct drm_crtc *crtci;
+
+@@ -1048,6 +1051,7 @@ static void radeon_crtc_commit(struct dr
+ if (crtci->enabled)
+ radeon_crtc_dpms(crtci, DRM_MODE_DPMS_ON);
+ }
++ radeon_crtc->in_mode_set = false;
+ }
+
+ static const struct drm_crtc_helper_funcs legacy_helper_funcs = {
+--- a/drivers/gpu/drm/radeon/radeon_mode.h
++++ b/drivers/gpu/drm/radeon/radeon_mode.h
+@@ -266,6 +266,7 @@ struct radeon_crtc {
+ u16 lut_r[256], lut_g[256], lut_b[256];
+ bool enabled;
+ bool can_tile;
++ bool in_mode_set;
+ uint32_t crtc_offset;
+ struct drm_gem_object *cursor_bo;
+ uint64_t cursor_addr;
xen-mark-local-pages-as-foreign-in-the-m2p_override.patch
drm-i915-prefer-wide-slow-to-fast-narrow-in-dp-configs.patch
drm-nvd0-disp-mask-off-high-16-bit-of-negative-cursor-x-coordinate.patch
+drm-i915-correctly-order-the-ring-init-sequence.patch
+drm-i915-ignore-edp-bpc-settings-from-vbt.patch
+drm-i915-reorder-edp-disabling-to-fix-ivb-macbook-air.patch
+drm-radeon-properly-handle-crtc-powergating.patch