]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
Merge airlied/drm-next into drm-misc-next
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 21 Nov 2017 10:33:10 +0000 (11:33 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 21 Nov 2017 13:17:56 +0000 (14:17 +0100)
Bake in the conflict between the drm_print.h extraction and the
addition of DRM_DEBUG_LEASES since we lost it a few too many times.

Also fix a new use of drm_plane_helper_check_state in msm to follow
Ville's conversion in

commit a01cb8ba3f6282934cff65e89ab36b18b14cbe27
Author: Ville Syrjälä <ville.syrjala@linux.intel.com>
Date:   Wed Nov 1 22:16:19 2017 +0200

    drm: Move drm_plane_helper_check_state() into drm_atomic_helper.c

Acked-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
28 files changed:
1  2 
MAINTAINERS
drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
drivers/gpu/drm/drm_atomic.c
drivers/gpu/drm/drm_atomic_helper.c
drivers/gpu/drm/drm_drv.c
drivers/gpu/drm/drm_framebuffer.c
drivers/gpu/drm/drm_internal.h
drivers/gpu/drm/drm_syncobj.c
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_dp.c
drivers/gpu/drm/i915/intel_modes.c
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
drivers/gpu/drm/nouveau/nv50_display.c
drivers/gpu/drm/qxl/qxl_ttm.c
drivers/gpu/drm/radeon/radeon_connectors.c
drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
drivers/gpu/drm/tegra/dc.c
drivers/gpu/drm/tegra/output.c
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
include/drm/drm_connector.h
include/drm/drm_dp_helper.h
include/drm/drm_drv.h
include/drm/drm_encoder.h
include/drm/drm_framebuffer.h
include/drm/drm_mode_config.h
include/drm/drm_plane.h
include/drm/drm_print.h
include/drm/drm_syncobj.h

diff --combined MAINTAINERS
index 0d77f22fd38b89bfb57fe6ee8dc9220f127669a0,6e1f94b4ed26352b14b0a561b13424d92755336a..d4b63c7ffb0e06c76b58d5c41bc275a5ad7d96fc
@@@ -759,8 -759,6 +759,6 @@@ F: drivers/gpu/drm/amd/amdkfd
  F:    drivers/gpu/drm/amd/include/cik_structs.h
  F:    drivers/gpu/drm/amd/include/kgd_kfd_interface.h
  F:    drivers/gpu/drm/amd/include/vi_structs.h
- F:    drivers/gpu/drm/radeon/radeon_kfd.c
- F:    drivers/gpu/drm/radeon/radeon_kfd.h
  F:    include/uapi/linux/kfd_ioctl.h
  
  AMD SEATTLE DEVICE TREE SUPPORT
@@@ -4498,7 -4496,6 +4496,7 @@@ F:      include/linux/vga
  DRM DRIVERS AND MISC GPU PATCHES
  M:    Daniel Vetter <daniel.vetter@intel.com>
  M:    Jani Nikula <jani.nikula@linux.intel.com>
 +M:    Gustavo Padovan <gustavo@padovan.org>
  M:    Sean Paul <seanpaul@chromium.org>
  W:    https://01.org/linuxgraphics/gfx-docs/maintainer-tools/drm-misc.html
  S:    Maintained
@@@ -5266,7 -5263,8 +5264,8 @@@ S:      Maintaine
  F:    drivers/iommu/exynos-iommu.c
  
  EZchip NPS platform support
- M:    Noam Camus <noamc@ezchip.com>
+ M:    Elad Kanfi <eladkan@mellanox.com>
+ M:    Vineet Gupta <vgupta@synopsys.com>
  S:    Supported
  F:    arch/arc/plat-eznps
  F:    arch/arc/boot/dts/eznps.dts
@@@ -5352,9 -5350,7 +5351,7 @@@ M:      "J. Bruce Fields" <bfields@fieldses.
  L:    linux-fsdevel@vger.kernel.org
  S:    Maintained
  F:    include/linux/fcntl.h
- F:    include/linux/fs.h
  F:    include/uapi/linux/fcntl.h
- F:    include/uapi/linux/fs.h
  F:    fs/fcntl.c
  F:    fs/locks.c
  
@@@ -5363,6 -5359,8 +5360,8 @@@ M:      Alexander Viro <viro@zeniv.linux.org
  L:    linux-fsdevel@vger.kernel.org
  S:    Maintained
  F:    fs/*
+ F:    include/linux/fs.h
+ F:    include/uapi/linux/fs.h
  
  FINTEK F75375S HARDWARE MONITOR AND FAN CONTROLLER DRIVER
  M:    Riku Voipio <riku.voipio@iki.fi>
@@@ -6746,7 -6744,7 +6745,7 @@@ F:      Documentation/devicetree/bindings/au
  F:    drivers/auxdisplay/img-ascii-lcd.c
  
  IMGTEC IR DECODER DRIVER
- M:    James Hogan <james.hogan@imgtec.com>
+ M:    James Hogan <jhogan@kernel.org>
  S:    Maintained
  F:    drivers/media/rc/img-ir/
  
@@@ -7570,7 -7568,7 +7569,7 @@@ F:      arch/arm64/include/asm/kvm
  F:    arch/arm64/kvm/
  
  KERNEL VIRTUAL MACHINE FOR MIPS (KVM/mips)
- M:    James Hogan <james.hogan@imgtec.com>
+ M:    James Hogan <jhogan@kernel.org>
  L:    linux-mips@linux-mips.org
  S:    Supported
  F:    arch/mips/include/uapi/asm/kvm*
@@@ -7578,7 -7576,7 +7577,7 @@@ F:      arch/mips/include/asm/kvm
  F:    arch/mips/kvm/
  
  KERNEL VIRTUAL MACHINE FOR POWERPC (KVM/powerpc)
- M:    Alexander Graf <agraf@suse.com>
+ M:    Paul Mackerras <paulus@ozlabs.org>
  L:    kvm-ppc@vger.kernel.org
  W:    http://www.linux-kvm.org/
  T:    git git://github.com/agraf/linux-2.6.git
@@@ -8272,6 -8270,12 +8271,12 @@@ L:    libertas-dev@lists.infradead.or
  S:    Orphan
  F:    drivers/net/wireless/marvell/libertas/
  
+ MARVELL MACCHIATOBIN SUPPORT
+ M:    Russell King <rmk@armlinux.org.uk>
+ L:    linux-arm-kernel@lists.infradead.org
+ S:    Maintained
+ F:    arch/arm64/boot/dts/marvell/armada-8040-mcbin.dts
  MARVELL MV643XX ETHERNET DRIVER
  M:    Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
  L:    netdev@vger.kernel.org
@@@ -8893,7 -8897,7 +8898,7 @@@ F:      Documentation/devicetree/bindings/me
  T:    git git://linuxtv.org/media_tree.git
  
  METAG ARCHITECTURE
- M:    James Hogan <james.hogan@imgtec.com>
+ M:    James Hogan <jhogan@kernel.org>
  L:    linux-metag@vger.kernel.org
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/jhogan/metag.git
  S:    Odd Fixes
@@@ -9214,7 -9218,6 +9219,6 @@@ F:      include/linux/isicom.
  MUSB MULTIPOINT HIGH SPEED DUAL-ROLE CONTROLLER
  M:    Bin Liu <b-liu@ti.com>
  L:    linux-usb@vger.kernel.org
- T:    git git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git
  S:    Maintained
  F:    drivers/usb/musb/
  
@@@ -9362,7 -9365,7 +9366,7 @@@ NETWORK BLOCK DEVICE (NBD
  M:    Josef Bacik <jbacik@fb.com>
  S:    Maintained
  L:    linux-block@vger.kernel.org
- L:    nbd-general@lists.sourceforge.net
+ L:    nbd@other.debian.org
  F:    Documentation/blockdev/nbd.txt
  F:    drivers/block/nbd.c
  F:    include/uapi/linux/nbd.h
@@@ -10181,7 -10184,6 +10185,6 @@@ F:   Documentation/parport*.tx
  
  PARAVIRT_OPS INTERFACE
  M:    Juergen Gross <jgross@suse.com>
- M:    Chris Wright <chrisw@sous-sol.org>
  M:    Alok Kataria <akataria@vmware.com>
  M:    Rusty Russell <rusty@rustcorp.com.au>
  L:    virtualization@lists.linux-foundation.org
@@@ -10561,6 -10563,8 +10564,8 @@@ M:   Peter Zijlstra <peterz@infradead.org
  M:    Ingo Molnar <mingo@redhat.com>
  M:    Arnaldo Carvalho de Melo <acme@kernel.org>
  R:    Alexander Shishkin <alexander.shishkin@linux.intel.com>
+ R:    Jiri Olsa <jolsa@redhat.com>
+ R:    Namhyung Kim <namhyung@kernel.org>
  L:    linux-kernel@vger.kernel.org
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git perf/core
  S:    Supported
@@@ -12939,9 -12943,9 +12944,9 @@@ F:   drivers/mmc/host/dw_mmc
  SYNOPSYS HSDK RESET CONTROLLER DRIVER
  M:    Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
  S:    Supported
- F:    drivers/reset/reset-hsdk-v1.c
- F:    include/dt-bindings/reset/snps,hsdk-v1-reset.h
- F:    Documentation/devicetree/bindings/reset/snps,hsdk-v1-reset.txt
+ F:    drivers/reset/reset-hsdk.c
+ F:    include/dt-bindings/reset/snps,hsdk-reset.h
+ F:    Documentation/devicetree/bindings/reset/snps,hsdk-reset.txt
  
  SYSTEM CONFIGURATION (SYSCON)
  M:    Lee Jones <lee.jones@linaro.org>
index 126be9e0f05f8e4fbb73aa4733503fc45355ffec,df9cbc78e1689eebef8c0c15358fb8b94d79a7e2..8ca3783f2debefbc32f1ad3d6bc475cfbc16b986
@@@ -231,7 -231,7 +231,7 @@@ amdgpu_connector_update_scratch_regs(st
                if (connector->encoder_ids[i] == 0)
                        break;
  
-               encoder = drm_encoder_find(connector->dev,
+               encoder = drm_encoder_find(connector->dev, NULL,
                                        connector->encoder_ids[i]);
                if (!encoder)
                        continue;
@@@ -256,7 -256,7 +256,7 @@@ amdgpu_connector_find_encoder(struct dr
        for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
                if (connector->encoder_ids[i] == 0)
                        break;
-               encoder = drm_encoder_find(connector->dev,
+               encoder = drm_encoder_find(connector->dev, NULL,
                                        connector->encoder_ids[i]);
                if (!encoder)
                        continue;
@@@ -358,6 -358,7 +358,6 @@@ static int amdgpu_connector_ddc_get_mod
        if (amdgpu_connector->edid) {
                drm_mode_connector_update_edid_property(connector, amdgpu_connector->edid);
                ret = drm_add_edid_modes(connector, amdgpu_connector->edid);
 -              drm_edid_to_eld(connector, amdgpu_connector->edid);
                return ret;
        }
        drm_mode_connector_update_edid_property(connector, NULL);
@@@ -371,7 -372,7 +371,7 @@@ amdgpu_connector_best_single_encoder(st
  
        /* pick the encoder ids */
        if (enc_id)
-               return drm_encoder_find(connector->dev, enc_id);
+               return drm_encoder_find(connector->dev, NULL, enc_id);
        return NULL;
  }
  
@@@ -1076,7 -1077,7 +1076,7 @@@ amdgpu_connector_dvi_detect(struct drm_
                        if (connector->encoder_ids[i] == 0)
                                break;
  
-                       encoder = drm_encoder_find(connector->dev, connector->encoder_ids[i]);
+                       encoder = drm_encoder_find(connector->dev, NULL, connector->encoder_ids[i]);
                        if (!encoder)
                                continue;
  
@@@ -1133,7 -1134,7 +1133,7 @@@ amdgpu_connector_dvi_encoder(struct drm
                if (connector->encoder_ids[i] == 0)
                        break;
  
-               encoder = drm_encoder_find(connector->dev, connector->encoder_ids[i]);
+               encoder = drm_encoder_find(connector->dev, NULL, connector->encoder_ids[i]);
                if (!encoder)
                        continue;
  
        /* then check use digitial */
        /* pick the first one */
        if (enc_id)
-               return drm_encoder_find(connector->dev, enc_id);
+               return drm_encoder_find(connector->dev, NULL, enc_id);
        return NULL;
  }
  
@@@ -1293,7 -1294,7 +1293,7 @@@ u16 amdgpu_connector_encoder_get_dp_bri
                if (connector->encoder_ids[i] == 0)
                        break;
  
-               encoder = drm_encoder_find(connector->dev,
+               encoder = drm_encoder_find(connector->dev, NULL,
                                        connector->encoder_ids[i]);
                if (!encoder)
                        continue;
@@@ -1322,7 -1323,7 +1322,7 @@@ static bool amdgpu_connector_encoder_is
        for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
                if (connector->encoder_ids[i] == 0)
                        break;
-               encoder = drm_encoder_find(connector->dev,
+               encoder = drm_encoder_find(connector->dev, NULL,
                                        connector->encoder_ids[i]);
                if (!encoder)
                        continue;
index bf8ca515c958805229aca848978c0dbc016b3cae,c2da5585e2012ae93092f964f25bfefaa4c621da..37445d50816a5c2654b5b145c3c397044a429db1
@@@ -33,7 -33,6 +33,7 @@@
  #include <linux/sync_file.h>
  
  #include "drm_crtc_internal.h"
 +#include "drm_internal.h"
  
  void __drm_crtc_commit_free(struct kref *kref)
  {
@@@ -716,7 -715,7 +716,7 @@@ static int drm_atomic_plane_set_propert
        struct drm_mode_config *config = &dev->mode_config;
  
        if (property == config->prop_fb_id) {
-               struct drm_framebuffer *fb = drm_framebuffer_lookup(dev, val);
+               struct drm_framebuffer *fb = drm_framebuffer_lookup(dev, NULL, val);
                drm_atomic_set_fb_for_plane(state, fb);
                if (fb)
                        drm_framebuffer_put(fb);
                        return -EINVAL;
  
        } else if (property == config->prop_crtc_id) {
-               struct drm_crtc *crtc = drm_crtc_find(dev, val);
+               struct drm_crtc *crtc = drm_crtc_find(dev, NULL, val);
                return drm_atomic_set_crtc_for_plane(state, crtc);
        } else if (property == config->prop_crtc_x) {
                state->crtc_x = U642I64(val);
@@@ -908,12 -907,11 +908,12 @@@ static int drm_atomic_plane_check(struc
            state->src_h > fb_height ||
            state->src_y > fb_height - state->src_h) {
                DRM_DEBUG_ATOMIC("Invalid source coordinates "
 -                               "%u.%06ux%u.%06u+%u.%06u+%u.%06u\n",
 +                               "%u.%06ux%u.%06u+%u.%06u+%u.%06u (fb %ux%u)\n",
                                 state->src_w >> 16, ((state->src_w & 0xffff) * 15625) >> 10,
                                 state->src_h >> 16, ((state->src_h & 0xffff) * 15625) >> 10,
                                 state->src_x >> 16, ((state->src_x & 0xffff) * 15625) >> 10,
 -                               state->src_y >> 16, ((state->src_y & 0xffff) * 15625) >> 10);
 +                               state->src_y >> 16, ((state->src_y & 0xffff) * 15625) >> 10,
 +                               state->fb->width, state->fb->height);
                return -ENOSPC;
        }
  
@@@ -936,8 -934,21 +936,8 @@@ static void drm_atomic_plane_print_stat
        drm_printf(p, "plane[%u]: %s\n", plane->base.id, plane->name);
        drm_printf(p, "\tcrtc=%s\n", state->crtc ? state->crtc->name : "(null)");
        drm_printf(p, "\tfb=%u\n", state->fb ? state->fb->base.id : 0);
 -      if (state->fb) {
 -              struct drm_framebuffer *fb = state->fb;
 -              int i, n = fb->format->num_planes;
 -              struct drm_format_name_buf format_name;
 -
 -              drm_printf(p, "\t\tformat=%s\n",
 -                            drm_get_format_name(fb->format->format, &format_name));
 -              drm_printf(p, "\t\t\tmodifier=0x%llx\n", fb->modifier);
 -              drm_printf(p, "\t\tsize=%dx%d\n", fb->width, fb->height);
 -              drm_printf(p, "\t\tlayers:\n");
 -              for (i = 0; i < n; i++) {
 -                      drm_printf(p, "\t\t\tpitch[%d]=%u\n", i, fb->pitches[i]);
 -                      drm_printf(p, "\t\t\toffset[%d]=%u\n", i, fb->offsets[i]);
 -              }
 -      }
 +      if (state->fb)
 +              drm_framebuffer_print_info(p, 2, state->fb);
        drm_printf(p, "\tcrtc-pos=" DRM_RECT_FMT "\n", DRM_RECT_ARG(&dest));
        drm_printf(p, "\tsrc-pos=" DRM_RECT_FP_FMT "\n", DRM_RECT_FP_ARG(&src));
        drm_printf(p, "\trotation=%x\n", state->rotation);
@@@ -1135,7 -1146,7 +1135,7 @@@ static int drm_atomic_connector_set_pro
        struct drm_mode_config *config = &dev->mode_config;
  
        if (property == config->prop_crtc_id) {
-               struct drm_crtc *crtc = drm_crtc_find(dev, val);
+               struct drm_crtc *crtc = drm_crtc_find(dev, NULL, val);
                return drm_atomic_set_crtc_for_connector(state, crtc);
        } else if (property == config->dpms_property) {
                /* setting DPMS property requires special handling, which
@@@ -1797,11 -1808,11 +1797,11 @@@ int drm_atomic_debugfs_init(struct drm_
  #endif
  
  /*
 - * The big monstor ioctl
 + * The big monster ioctl
   */
  
  static struct drm_pending_vblank_event *create_vblank_event(
-               struct drm_device *dev, uint64_t user_data)
+               struct drm_crtc *crtc, uint64_t user_data)
  {
        struct drm_pending_vblank_event *e = NULL;
  
  
        e->event.base.type = DRM_EVENT_FLIP_COMPLETE;
        e->event.base.length = sizeof(e->event);
-       e->event.user_data = user_data;
+       e->event.vbl.crtc_id = crtc->base.id;
+       e->event.vbl.user_data = user_data;
  
        return e;
  }
@@@ -2065,7 -2077,7 +2066,7 @@@ static int prepare_crtc_signaling(struc
                if (arg->flags & DRM_MODE_PAGE_FLIP_EVENT || fence_ptr) {
                        struct drm_pending_vblank_event *e;
  
-                       e = create_vblank_event(dev, arg->user_data);
+                       e = create_vblank_event(crtc, arg->user_data);
                        if (!e)
                                return -ENOMEM;
  
@@@ -2245,7 -2257,7 +2246,7 @@@ retry
                        goto out;
                }
  
-               obj = drm_mode_object_find(dev, obj_id, DRM_MODE_OBJECT_ANY);
+               obj = drm_mode_object_find(dev, file_priv, obj_id, DRM_MODE_OBJECT_ANY);
                if (!obj) {
                        ret = -ENOENT;
                        goto out;
index ce6d11ae9e265b2f6f5313a27a68da75bbc7b043,71d712f1b56a285bac904b0d1e74a7363d766af3..2f80377101a19b9fb9007f4309fffc759262fda0
@@@ -695,100 -695,6 +695,100 @@@ drm_atomic_helper_check_modeset(struct 
  }
  EXPORT_SYMBOL(drm_atomic_helper_check_modeset);
  
 +/**
 + * drm_atomic_helper_check_plane_state() - Check plane state for validity
 + * @plane_state: plane state to check
 + * @crtc_state: crtc state to check
 + * @clip: integer clipping coordinates
 + * @min_scale: minimum @src:@dest scaling factor in 16.16 fixed point
 + * @max_scale: maximum @src:@dest scaling factor in 16.16 fixed point
 + * @can_position: is it legal to position the plane such that it
 + *                doesn't cover the entire crtc?  This will generally
 + *                only be false for primary planes.
 + * @can_update_disabled: can the plane be updated while the crtc
 + *                       is disabled?
 + *
 + * Checks that a desired plane update is valid, and updates various
 + * bits of derived state (clipped coordinates etc.). Drivers that provide
 + * their own plane handling rather than helper-provided implementations may
 + * still wish to call this function to avoid duplication of error checking
 + * code.
 + *
 + * RETURNS:
 + * Zero if update appears valid, error code on failure
 + */
 +int drm_atomic_helper_check_plane_state(struct drm_plane_state *plane_state,
 +                                      const struct drm_crtc_state *crtc_state,
 +                                      const struct drm_rect *clip,
 +                                      int min_scale,
 +                                      int max_scale,
 +                                      bool can_position,
 +                                      bool can_update_disabled)
 +{
 +      struct drm_framebuffer *fb = plane_state->fb;
 +      struct drm_rect *src = &plane_state->src;
 +      struct drm_rect *dst = &plane_state->dst;
 +      unsigned int rotation = plane_state->rotation;
 +      int hscale, vscale;
 +
 +      WARN_ON(plane_state->crtc && plane_state->crtc != crtc_state->crtc);
 +
 +      *src = drm_plane_state_src(plane_state);
 +      *dst = drm_plane_state_dest(plane_state);
 +
 +      if (!fb) {
 +              plane_state->visible = false;
 +              return 0;
 +      }
 +
 +      /* crtc should only be NULL when disabling (i.e., !fb) */
 +      if (WARN_ON(!plane_state->crtc)) {
 +              plane_state->visible = false;
 +              return 0;
 +      }
 +
 +      if (!crtc_state->enable && !can_update_disabled) {
 +              DRM_DEBUG_KMS("Cannot update plane of a disabled CRTC.\n");
 +              return -EINVAL;
 +      }
 +
 +      drm_rect_rotate(src, fb->width << 16, fb->height << 16, rotation);
 +
 +      /* Check scaling */
 +      hscale = drm_rect_calc_hscale(src, dst, min_scale, max_scale);
 +      vscale = drm_rect_calc_vscale(src, dst, min_scale, max_scale);
 +      if (hscale < 0 || vscale < 0) {
 +              DRM_DEBUG_KMS("Invalid scaling of plane\n");
 +              drm_rect_debug_print("src: ", &plane_state->src, true);
 +              drm_rect_debug_print("dst: ", &plane_state->dst, false);
 +              return -ERANGE;
 +      }
 +
 +      plane_state->visible = drm_rect_clip_scaled(src, dst, clip, hscale, vscale);
 +
 +      drm_rect_rotate_inv(src, fb->width << 16, fb->height << 16, rotation);
 +
 +      if (!plane_state->visible)
 +              /*
 +               * Plane isn't visible; some drivers can handle this
 +               * so we just return success here.  Drivers that can't
 +               * (including those that use the primary plane helper's
 +               * update function) will return an error from their
 +               * update_plane handler.
 +               */
 +              return 0;
 +
 +      if (!can_position && !drm_rect_equals(dst, clip)) {
 +              DRM_DEBUG_KMS("Plane must cover entire CRTC\n");
 +              drm_rect_debug_print("dst: ", dst, false);
 +              drm_rect_debug_print("clip: ", clip, false);
 +              return -EINVAL;
 +      }
 +
 +      return 0;
 +}
 +EXPORT_SYMBOL(drm_atomic_helper_check_plane_state);
 +
  /**
   * drm_atomic_helper_check_planes - validate state object for planes changes
   * @dev: DRM device
@@@ -1001,12 -907,6 +1001,12 @@@ disable_outputs(struct drm_device *dev
   *
   * Drivers can use this for building their own atomic commit if they don't have
   * a pure helper-based modeset implementation.
 + *
 + * Since these updates are not synchronized with lockings, only code paths
 + * called from &drm_mode_config_helper_funcs.atomic_commit_tail can look at the
 + * legacy state filled out by this helper. Defacto this means this helper and
 + * the legacy state pointers are only really useful for transitioning an
 + * existing driver to the atomic world.
   */
  void
  drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev,
@@@ -1887,8 -1787,11 +1887,8 @@@ int drm_atomic_helper_setup_commit(stru
                    !try_wait_for_completion(&old_conn_state->commit->flip_done))
                        return -EBUSY;
  
 -              /* commit tracked through new_crtc_state->commit, no need to do it explicitly */
 -              if (new_conn_state->crtc)
 -                      continue;
 -
 -              commit = crtc_or_fake_commit(state, old_conn_state->crtc);
 +              /* Always track connectors explicitly for e.g. link retraining. */
 +              commit = crtc_or_fake_commit(state, new_conn_state->crtc ?: old_conn_state->crtc);
                if (!commit)
                        return -ENOMEM;
  
                    !try_wait_for_completion(&old_plane_state->commit->flip_done))
                        return -EBUSY;
  
 -              /*
 -               * Unlike connectors, always track planes explicitly for
 -               * async pageflip support.
 -               */
 +              /* Always track planes explicitly for async pageflip support. */
                commit = crtc_or_fake_commit(state, new_plane_state->crtc ?: old_plane_state->crtc);
                if (!commit)
                        return -ENOMEM;
@@@ -3309,7 -3215,7 +3309,7 @@@ struct drm_encoder 
  drm_atomic_helper_best_encoder(struct drm_connector *connector)
  {
        WARN_ON(connector->encoder_ids[1]);
-       return drm_encoder_find(connector->dev, connector->encoder_ids[0]);
+       return drm_encoder_find(connector->dev, NULL, connector->encoder_ids[0]);
  }
  EXPORT_SYMBOL(drm_atomic_helper_best_encoder);
  
index bc2f10adc5901a847aae66ed3a8ba0119b00b2bf,a934fd5e7e5590bb187ef79f5fa4c5828a4a57c8..9acc1e15781381ad5979dd1efa57cdd764822a78
@@@ -57,7 -57,8 +57,8 @@@ MODULE_PARM_DESC(debug, "Enable debug o
  "\t\tBit 2 (0x04) will enable KMS messages (modesetting code)\n"
  "\t\tBit 3 (0x08) will enable PRIME messages (prime code)\n"
  "\t\tBit 4 (0x10) will enable ATOMIC messages (atomic code)\n"
- "\t\tBit 5 (0x20) will enable VBL messages (vblank code)");
+ "\t\tBit 5 (0x20) will enable VBL messages (vblank code)\n"
+ "\t\tBit 7 (0x80) will enable LEASE messages (leasing code)");
  module_param_named(debug, drm_debug, int, 0600);
  
  static DEFINE_SPINLOCK(drm_minor_lock);
@@@ -74,6 -75,53 +75,6 @@@ static bool drm_core_init_complete = fa
  
  static struct dentry *drm_debugfs_root;
  
 -#define DRM_PRINTK_FMT "[" DRM_NAME ":%s]%s %pV"
 -
 -void drm_dev_printk(const struct device *dev, const char *level,
 -                  unsigned int category, const char *function_name,
 -                  const char *prefix, const char *format, ...)
 -{
 -      struct va_format vaf;
 -      va_list args;
 -
 -      if (category != DRM_UT_NONE && !(drm_debug & category))
 -              return;
 -
 -      va_start(args, format);
 -      vaf.fmt = format;
 -      vaf.va = &args;
 -
 -      if (dev)
 -              dev_printk(level, dev, DRM_PRINTK_FMT, function_name, prefix,
 -                         &vaf);
 -      else
 -              printk("%s" DRM_PRINTK_FMT, level, function_name, prefix, &vaf);
 -
 -      va_end(args);
 -}
 -EXPORT_SYMBOL(drm_dev_printk);
 -
 -void drm_printk(const char *level, unsigned int category,
 -              const char *format, ...)
 -{
 -      struct va_format vaf;
 -      va_list args;
 -
 -      if (category != DRM_UT_NONE && !(drm_debug & category))
 -              return;
 -
 -      va_start(args, format);
 -      vaf.fmt = format;
 -      vaf.va = &args;
 -
 -      printk("%s" "[" DRM_NAME ":%ps]%s %pV",
 -             level, __builtin_return_address(0),
 -             strcmp(level, KERN_ERR) == 0 ? " *ERROR*" : "", &vaf);
 -
 -      va_end(args);
 -}
 -EXPORT_SYMBOL(drm_printk);
 -
  /*
   * DRM Minors
   * A DRM device can provide several char-dev interfaces on the DRM-Major. Each
index 0153000373ae8df27d91ded86d6124d1d5058d17,279c1035c12dadf30794a89209084e8617058dec..d63d4c2ac4c8126e8d38cdcc32638893cb1fcfb2
@@@ -25,9 -25,7 +25,9 @@@
  #include <drm/drm_auth.h>
  #include <drm/drm_framebuffer.h>
  #include <drm/drm_atomic.h>
 +#include <drm/drm_print.h>
  
 +#include "drm_internal.h"
  #include "drm_crtc_internal.h"
  
  /**
@@@ -80,12 -78,11 +80,12 @@@ int drm_framebuffer_check_src_coords(ui
            src_h > fb_height ||
            src_y > fb_height - src_h) {
                DRM_DEBUG_KMS("Invalid source coordinates "
 -                            "%u.%06ux%u.%06u+%u.%06u+%u.%06u\n",
 +                            "%u.%06ux%u.%06u+%u.%06u+%u.%06u (fb %ux%u)\n",
                              src_w >> 16, ((src_w & 0xffff) * 15625) >> 10,
                              src_h >> 16, ((src_h & 0xffff) * 15625) >> 10,
                              src_x >> 16, ((src_x & 0xffff) * 15625) >> 10,
 -                            src_y >> 16, ((src_y & 0xffff) * 15625) >> 10);
 +                            src_y >> 16, ((src_y & 0xffff) * 15625) >> 10,
 +                            fb->width, fb->height);
                return -ENOSPC;
        }
  
@@@ -384,7 -381,7 +384,7 @@@ int drm_mode_rmfb(struct drm_device *de
        if (!drm_core_check_feature(dev, DRIVER_MODESET))
                return -EINVAL;
  
-       fb = drm_framebuffer_lookup(dev, *id);
+       fb = drm_framebuffer_lookup(dev, file_priv, *id);
        if (!fb)
                return -ENOENT;
  
@@@ -453,7 -450,7 +453,7 @@@ int drm_mode_getfb(struct drm_device *d
        if (!drm_core_check_feature(dev, DRIVER_MODESET))
                return -EINVAL;
  
-       fb = drm_framebuffer_lookup(dev, r->fb_id);
+       fb = drm_framebuffer_lookup(dev, file_priv, r->fb_id);
        if (!fb)
                return -ENOENT;
  
@@@ -518,7 -515,7 +518,7 @@@ int drm_mode_dirtyfb_ioctl(struct drm_d
        if (!drm_core_check_feature(dev, DRIVER_MODESET))
                return -EINVAL;
  
-       fb = drm_framebuffer_lookup(dev, r->fb_id);
+       fb = drm_framebuffer_lookup(dev, file_priv, r->fb_id);
        if (!fb)
                return -ENOENT;
  
@@@ -684,6 -681,7 +684,7 @@@ EXPORT_SYMBOL(drm_framebuffer_init)
  /**
   * drm_framebuffer_lookup - look up a drm framebuffer and grab a reference
   * @dev: drm device
+  * @file_priv: drm file to check for lease against.
   * @id: id of the fb object
   *
   * If successful, this grabs an additional reference to the framebuffer -
   * again, using drm_framebuffer_put().
   */
  struct drm_framebuffer *drm_framebuffer_lookup(struct drm_device *dev,
+                                              struct drm_file *file_priv,
                                               uint32_t id)
  {
        struct drm_mode_object *obj;
        struct drm_framebuffer *fb = NULL;
  
-       obj = __drm_mode_object_find(dev, id, DRM_MODE_OBJECT_FB);
+       obj = __drm_mode_object_find(dev, file_priv, id, DRM_MODE_OBJECT_FB);
        if (obj)
                fb = obj_to_fb(obj);
        return fb;
@@@ -767,18 -766,14 +769,18 @@@ static int atomic_remove_fb(struct drm_
        struct drm_plane *plane;
        struct drm_connector *conn;
        struct drm_connector_state *conn_state;
 -      int i, ret = 0;
 +      int i, ret;
        unsigned plane_mask;
 +      bool disable_crtcs = false;
  
 -      state = drm_atomic_state_alloc(dev);
 -      if (!state)
 -              return -ENOMEM;
 -
 +retry_disable:
        drm_modeset_acquire_init(&ctx, 0);
 +
 +      state = drm_atomic_state_alloc(dev);
 +      if (!state) {
 +              ret = -ENOMEM;
 +              goto out;
 +      }
        state->acquire_ctx = &ctx;
  
  retry:
                        goto unlock;
                }
  
 -              if (plane_state->crtc->primary == plane) {
 +              if (disable_crtcs && plane_state->crtc->primary == plane) {
                        struct drm_crtc_state *crtc_state;
  
                        crtc_state = drm_atomic_get_existing_crtc_state(state, plane_state->crtc);
                plane->old_fb = plane->fb;
        }
  
 +      /* This list is only filled when disable_crtcs is set. */
        for_each_new_connector_in_state(state, conn, conn_state, i) {
                ret = drm_atomic_set_crtc_for_connector(conn_state, NULL);
  
@@@ -847,15 -841,9 +849,15 @@@ unlock
  
        drm_atomic_state_put(state);
  
 +out:
        drm_modeset_drop_locks(&ctx);
        drm_modeset_acquire_fini(&ctx);
  
 +      if (ret == -EINVAL && !disable_crtcs) {
 +              disable_crtcs = true;
 +              goto retry_disable;
 +      }
 +
        return ret;
  }
  
@@@ -969,60 -957,3 +971,60 @@@ int drm_framebuffer_plane_height(int he
        return fb_plane_height(height, fb->format, plane);
  }
  EXPORT_SYMBOL(drm_framebuffer_plane_height);
 +
 +void drm_framebuffer_print_info(struct drm_printer *p, unsigned int indent,
 +                              const struct drm_framebuffer *fb)
 +{
 +      struct drm_format_name_buf format_name;
 +      unsigned int i;
 +
 +      drm_printf_indent(p, indent, "refcount=%u\n",
 +                        drm_framebuffer_read_refcount(fb));
 +      drm_printf_indent(p, indent, "format=%s\n",
 +                        drm_get_format_name(fb->format->format, &format_name));
 +      drm_printf_indent(p, indent, "modifier=0x%llx\n", fb->modifier);
 +      drm_printf_indent(p, indent, "size=%ux%u\n", fb->width, fb->height);
 +      drm_printf_indent(p, indent, "layers:\n");
 +
 +      for (i = 0; i < fb->format->num_planes; i++) {
 +              drm_printf_indent(p, indent + 1, "size[%u]=%dx%d\n", i,
 +                                drm_framebuffer_plane_width(fb->width, fb, i),
 +                                drm_framebuffer_plane_height(fb->height, fb, i));
 +              drm_printf_indent(p, indent + 1, "pitch[%u]=%u\n", i, fb->pitches[i]);
 +              drm_printf_indent(p, indent + 1, "offset[%u]=%u\n", i, fb->offsets[i]);
 +              drm_printf_indent(p, indent + 1, "obj[%u]:%s\n", i,
 +                                fb->obj[i] ? "" : "(null)");
 +              if (fb->obj[i])
 +                      drm_gem_print_info(p, indent + 2, fb->obj[i]);
 +      }
 +}
 +
 +#ifdef CONFIG_DEBUG_FS
 +static int drm_framebuffer_info(struct seq_file *m, void *data)
 +{
 +      struct drm_info_node *node = m->private;
 +      struct drm_device *dev = node->minor->dev;
 +      struct drm_printer p = drm_seq_file_printer(m);
 +      struct drm_framebuffer *fb;
 +
 +      mutex_lock(&dev->mode_config.fb_lock);
 +      drm_for_each_fb(fb, dev) {
 +              drm_printf(&p, "framebuffer[%u]:\n", fb->base.id);
 +              drm_framebuffer_print_info(&p, 1, fb);
 +      }
 +      mutex_unlock(&dev->mode_config.fb_lock);
 +
 +      return 0;
 +}
 +
 +static const struct drm_info_list drm_framebuffer_debugfs_list[] = {
 +      { "framebuffer", drm_framebuffer_info, 0 },
 +};
 +
 +int drm_framebuffer_debugfs_init(struct drm_minor *minor)
 +{
 +      return drm_debugfs_create_files(drm_framebuffer_debugfs_list,
 +                              ARRAY_SIZE(drm_framebuffer_debugfs_list),
 +                              minor->debugfs_root, minor);
 +}
 +#endif
index 430ce3fe4f3b1887a623ddf42e5a73892e06e293,c9d5a6cd4d419deb7ee5966f06b6e25523de6d9c..b72242e93ea471114ec738609e70321cbb5233c9
@@@ -55,7 -55,6 +55,6 @@@ int drm_clients_info(struct seq_file *m
  int drm_gem_name_info(struct seq_file *m, void *data);
  
  /* drm_vblank.c */
- extern unsigned int drm_timestamp_monotonic;
  void drm_vblank_disable_and_save(struct drm_device *dev, unsigned int pipe);
  void drm_vblank_cleanup(struct drm_device *dev);
  
@@@ -71,6 -70,12 +70,12 @@@ int drm_legacy_modeset_ctl_ioctl(struc
  int drm_legacy_irq_control(struct drm_device *dev, void *data,
                           struct drm_file *file_priv);
  
+ int drm_crtc_get_sequence_ioctl(struct drm_device *dev, void *data,
+                               struct drm_file *filp);
+ int drm_crtc_queue_sequence_ioctl(struct drm_device *dev, void *data,
+                                 struct drm_file *filp);
  /* drm_auth.c */
  int drm_getmagic(struct drm_device *dev, void *data,
                 struct drm_file *file_priv);
@@@ -106,8 -111,6 +111,8 @@@ int drm_gem_open_ioctl(struct drm_devic
                       struct drm_file *file_priv);
  void drm_gem_open(struct drm_device *dev, struct drm_file *file_private);
  void drm_gem_release(struct drm_device *dev, struct drm_file *file_private);
 +void drm_gem_print_info(struct drm_printer *p, unsigned int indent,
 +                      const struct drm_gem_object *obj);
  
  /* drm_debugfs.c drm_debugfs_crc.c */
  #if defined(CONFIG_DEBUG_FS)
@@@ -175,8 -178,3 +180,8 @@@ int drm_syncobj_reset_ioctl(struct drm_
                            struct drm_file *file_private);
  int drm_syncobj_signal_ioctl(struct drm_device *dev, void *data,
                             struct drm_file *file_private);
 +
 +/* drm_framebuffer.c */
 +void drm_framebuffer_print_info(struct drm_printer *p, unsigned int indent,
 +                              const struct drm_framebuffer *fb);
 +int drm_framebuffer_debugfs_init(struct drm_minor *minor);
index 7943c215a03ce57f06bbd14d612356b42cc351fa,f776fc1cc543abf8e752a5133aaf1ca63fb2d8ff..9b733c510cbfc3030600ff33de96ee54b965b6e3
@@@ -106,8 -106,7 +106,8 @@@ static int drm_syncobj_fence_get_or_add
         * callback when a fence has already been set.
         */
        if (syncobj->fence) {
 -              *fence = dma_fence_get(syncobj->fence);
 +              *fence = dma_fence_get(rcu_dereference_protected(syncobj->fence,
 +                                                               lockdep_is_held(&syncobj->lock)));
                ret = 1;
        } else {
                *fence = NULL;
@@@ -169,9 -168,8 +169,9 @@@ void drm_syncobj_replace_fence(struct d
  
        spin_lock(&syncobj->lock);
  
 -      old_fence = syncobj->fence;
 -      syncobj->fence = fence;
 +      old_fence = rcu_dereference_protected(syncobj->fence,
 +                                            lockdep_is_held(&syncobj->lock));
 +      rcu_assign_pointer(syncobj->fence, fence);
  
        if (fence != old_fence) {
                list_for_each_entry_safe(cur, tmp, &syncobj->cb_list, node) {
@@@ -264,8 -262,14 +264,14 @@@ void drm_syncobj_free(struct kref *kref
  }
  EXPORT_SYMBOL(drm_syncobj_free);
  
- static int drm_syncobj_create(struct drm_file *file_private,
-                             u32 *handle, uint32_t flags)
+ /**
+  * drm_syncobj_create - create a new syncobj
+  * @out_syncobj: returned syncobj
+  * @flags: DRM_SYNCOBJ_* flags
+  * @fence: if non-NULL, the syncobj will represent this fence
+  */
+ int drm_syncobj_create(struct drm_syncobj **out_syncobj, uint32_t flags,
+                      struct dma_fence *fence)
  {
        int ret;
        struct drm_syncobj *syncobj;
                }
        }
  
+       if (fence)
+               drm_syncobj_replace_fence(syncobj, fence);
+       *out_syncobj = syncobj;
+       return 0;
+ }
+ EXPORT_SYMBOL(drm_syncobj_create);
+ /**
+  * drm_syncobj_get_handle - get a handle from a syncobj
+  */
+ int drm_syncobj_get_handle(struct drm_file *file_private,
+                          struct drm_syncobj *syncobj, u32 *handle)
+ {
+       int ret;
+       /* take a reference to put in the idr */
+       drm_syncobj_get(syncobj);
        idr_preload(GFP_KERNEL);
        spin_lock(&file_private->syncobj_table_lock);
        ret = idr_alloc(&file_private->syncobj_idr, syncobj, 1, 0, GFP_NOWAIT);
        *handle = ret;
        return 0;
  }
+ EXPORT_SYMBOL(drm_syncobj_get_handle);
+ static int drm_syncobj_create_as_handle(struct drm_file *file_private,
+                                       u32 *handle, uint32_t flags)
+ {
+       int ret;
+       struct drm_syncobj *syncobj;
+       ret = drm_syncobj_create(&syncobj, flags, NULL);
+       if (ret)
+               return ret;
+       ret = drm_syncobj_get_handle(file_private, syncobj, handle);
+       drm_syncobj_put(syncobj);
+       return ret;
+ }
  
  static int drm_syncobj_destroy(struct drm_file *file_private,
                               u32 handle)
@@@ -347,33 -386,38 +388,38 @@@ static int drm_syncobj_alloc_file(struc
        return 0;
  }
  
- static int drm_syncobj_handle_to_fd(struct drm_file *file_private,
-                                   u32 handle, int *p_fd)
+ int drm_syncobj_get_fd(struct drm_syncobj *syncobj, int *p_fd)
  {
-       struct drm_syncobj *syncobj = drm_syncobj_find(file_private, handle);
        int ret;
        int fd;
  
-       if (!syncobj)
-               return -EINVAL;
        fd = get_unused_fd_flags(O_CLOEXEC);
-       if (fd < 0) {
-               drm_syncobj_put(syncobj);
+       if (fd < 0)
                return fd;
-       }
  
        if (!syncobj->file) {
                ret = drm_syncobj_alloc_file(syncobj);
-               if (ret)
-                       goto out_put_fd;
+               if (ret) {
+                       put_unused_fd(fd);
+                       return ret;
+               }
        }
        fd_install(fd, syncobj->file);
-       drm_syncobj_put(syncobj);
        *p_fd = fd;
        return 0;
- out_put_fd:
-       put_unused_fd(fd);
+ }
+ EXPORT_SYMBOL(drm_syncobj_get_fd);
+ static int drm_syncobj_handle_to_fd(struct drm_file *file_private,
+                                   u32 handle, int *p_fd)
+ {
+       struct drm_syncobj *syncobj = drm_syncobj_find(file_private, handle);
+       int ret;
+       if (!syncobj)
+               return -EINVAL;
+       ret = drm_syncobj_get_fd(syncobj, p_fd);
        drm_syncobj_put(syncobj);
        return ret;
  }
@@@ -524,8 -568,8 +570,8 @@@ drm_syncobj_create_ioctl(struct drm_dev
        if (args->flags & ~DRM_SYNCOBJ_CREATE_SIGNALED)
                return -EINVAL;
  
-       return drm_syncobj_create(file_private,
-                                 &args->handle, args->flags);
+       return drm_syncobj_create_as_handle(file_private,
+                                           &args->handle, args->flags);
  }
  
  int
@@@ -615,8 -659,7 +661,8 @@@ static void syncobj_wait_syncobj_func(s
                container_of(cb, struct syncobj_wait_entry, syncobj_cb);
  
        /* This happens inside the syncobj lock */
 -      wait->fence = dma_fence_get(syncobj->fence);
 +      wait->fence = dma_fence_get(rcu_dereference_protected(syncobj->fence,
 +                                                            lockdep_is_held(&syncobj->lock)));
        wake_up_process(wait->task);
  }
  
index 97406166417dc63b5bdd3e207263f218e875738a,f4a9a182868f50dc0cd3f04c69de73909e94216a..053ae6d3d3395697836c7fbd602ee1edc94343b2
@@@ -1539,7 -1539,7 +1539,7 @@@ static void chv_enable_pll(struct intel
                 * DPLLCMD is AWOL. Use chicken bits to propagate
                 * the value from DPLLBMD to either pipe B or C.
                 */
-               I915_WRITE(CBR4_VLV, pipe == PIPE_B ? CBR_DPLLBMD_PIPE_B : CBR_DPLLBMD_PIPE_C);
+               I915_WRITE(CBR4_VLV, CBR_DPLLBMD_PIPE(pipe));
                I915_WRITE(DPLL_MD(PIPE_B), pipe_config->dpll_hw_state.dpll_md);
                I915_WRITE(CBR4_VLV, 0);
                dev_priv->chv_dpll_md[pipe] = pipe_config->dpll_hw_state.dpll_md;
@@@ -1568,11 -1568,12 +1568,12 @@@ static int intel_num_dvo_pipes(struct d
        return count;
  }
  
- static void i9xx_enable_pll(struct intel_crtc *crtc)
+ static void i9xx_enable_pll(struct intel_crtc *crtc,
+                           const struct intel_crtc_state *crtc_state)
  {
        struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
        i915_reg_t reg = DPLL(crtc->pipe);
-       u32 dpll = crtc->config->dpll_hw_state.dpll;
+       u32 dpll = crtc_state->dpll_hw_state.dpll;
        int i;
  
        assert_pipe_disabled(dev_priv, crtc->pipe);
  
        if (INTEL_GEN(dev_priv) >= 4) {
                I915_WRITE(DPLL_MD(crtc->pipe),
-                          crtc->config->dpll_hw_state.dpll_md);
+                          crtc_state->dpll_hw_state.dpll_md);
        } else {
                /* The pixel multiplier can only be updated once the
                 * DPLL is enabled and the clocks are stable.
        }
  }
  
- /**
-  * i9xx_disable_pll - disable a PLL
-  * @dev_priv: i915 private structure
-  * @pipe: pipe PLL to disable
-  *
-  * Disable the PLL for @pipe, making sure the pipe is off first.
-  *
-  * Note!  This is for pre-ILK only.
-  */
  static void i9xx_disable_pll(struct intel_crtc *crtc)
  {
        struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
@@@ -2219,8 -2211,7 +2211,7 @@@ intel_pin_and_fence_fb_obj(struct drm_f
                 * something and try to run the system in a "less than optimal"
                 * mode that matches the user configuration.
                 */
-               if (i915_vma_get_fence(vma) == 0)
-                       i915_vma_pin_fence(vma);
+               i915_vma_pin_fence(vma);
        }
  
        i915_vma_get(vma);
@@@ -2856,7 -2847,7 +2847,7 @@@ intel_find_initial_plane_obj(struct int
  
                if (intel_plane_ggtt_offset(state) == plane_config->base) {
                        fb = c->primary->fb;
-                       drm_framebuffer_reference(fb);
+                       drm_framebuffer_get(fb);
                        goto valid_fb;
                }
        }
@@@ -2887,7 -2878,7 +2878,7 @@@ valid_fb
                          intel_crtc->pipe, PTR_ERR(intel_state->vma));
  
                intel_state->vma = NULL;
-               drm_framebuffer_unreference(fb);
+               drm_framebuffer_put(fb);
                return;
        }
  
        if (i915_gem_object_is_tiled(obj))
                dev_priv->preserve_bios_swizzle = true;
  
-       drm_framebuffer_reference(fb);
+       drm_framebuffer_get(fb);
        primary->fb = primary->state->fb = fb;
        primary->crtc = primary->state->crtc = &intel_crtc->base;
  
@@@ -3298,7 -3289,6 +3289,6 @@@ static void i9xx_update_primary_plane(s
                                      const struct intel_plane_state *plane_state)
  {
        struct drm_i915_private *dev_priv = to_i915(primary->base.dev);
-       struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
        const struct drm_framebuffer *fb = plane_state->base.fb;
        enum plane plane = primary->plane;
        u32 linear_offset;
        int x = plane_state->main.x;
        int y = plane_state->main.y;
        unsigned long irqflags;
+       u32 dspaddr_offset;
  
        linear_offset = intel_fb_xy_to_linear(x, y, plane_state, 0);
  
        if (INTEL_GEN(dev_priv) >= 4)
-               crtc->dspaddr_offset = plane_state->main.offset;
+               dspaddr_offset = plane_state->main.offset;
        else
-               crtc->dspaddr_offset = linear_offset;
-       crtc->adjusted_x = x;
-       crtc->adjusted_y = y;
+               dspaddr_offset = linear_offset;
  
        spin_lock_irqsave(&dev_priv->uncore.lock, irqflags);
  
        if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) {
                I915_WRITE_FW(DSPSURF(plane),
                              intel_plane_ggtt_offset(plane_state) +
-                             crtc->dspaddr_offset);
+                             dspaddr_offset);
                I915_WRITE_FW(DSPOFFSET(plane), (y << 16) | x);
        } else if (INTEL_GEN(dev_priv) >= 4) {
                I915_WRITE_FW(DSPSURF(plane),
                              intel_plane_ggtt_offset(plane_state) +
-                             crtc->dspaddr_offset);
+                             dspaddr_offset);
                I915_WRITE_FW(DSPTILEOFF(plane), (y << 16) | x);
                I915_WRITE_FW(DSPLINOFF(plane), linear_offset);
        } else {
                I915_WRITE_FW(DSPADDR(plane),
                              intel_plane_ggtt_offset(plane_state) +
-                             crtc->dspaddr_offset);
+                             dspaddr_offset);
        }
        POSTING_READ_FW(reg);
  
@@@ -3553,100 -3541,6 +3541,6 @@@ u32 skl_plane_ctl(const struct intel_cr
        return plane_ctl;
  }
  
- static void skylake_update_primary_plane(struct intel_plane *plane,
-                                        const struct intel_crtc_state *crtc_state,
-                                        const struct intel_plane_state *plane_state)
- {
-       struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
-       struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
-       const struct drm_framebuffer *fb = plane_state->base.fb;
-       enum plane_id plane_id = plane->id;
-       enum pipe pipe = plane->pipe;
-       u32 plane_ctl = plane_state->ctl;
-       unsigned int rotation = plane_state->base.rotation;
-       u32 stride = skl_plane_stride(fb, 0, rotation);
-       u32 aux_stride = skl_plane_stride(fb, 1, rotation);
-       u32 surf_addr = plane_state->main.offset;
-       int scaler_id = plane_state->scaler_id;
-       int src_x = plane_state->main.x;
-       int src_y = plane_state->main.y;
-       int src_w = drm_rect_width(&plane_state->base.src) >> 16;
-       int src_h = drm_rect_height(&plane_state->base.src) >> 16;
-       int dst_x = plane_state->base.dst.x1;
-       int dst_y = plane_state->base.dst.y1;
-       int dst_w = drm_rect_width(&plane_state->base.dst);
-       int dst_h = drm_rect_height(&plane_state->base.dst);
-       unsigned long irqflags;
-       /* Sizes are 0 based */
-       src_w--;
-       src_h--;
-       dst_w--;
-       dst_h--;
-       crtc->dspaddr_offset = surf_addr;
-       crtc->adjusted_x = src_x;
-       crtc->adjusted_y = src_y;
-       spin_lock_irqsave(&dev_priv->uncore.lock, irqflags);
-       if (IS_GEMINILAKE(dev_priv) || IS_CANNONLAKE(dev_priv)) {
-               I915_WRITE_FW(PLANE_COLOR_CTL(pipe, plane_id),
-                             PLANE_COLOR_PIPE_GAMMA_ENABLE |
-                             PLANE_COLOR_PIPE_CSC_ENABLE |
-                             PLANE_COLOR_PLANE_GAMMA_DISABLE);
-       }
-       I915_WRITE_FW(PLANE_CTL(pipe, plane_id), plane_ctl);
-       I915_WRITE_FW(PLANE_OFFSET(pipe, plane_id), (src_y << 16) | src_x);
-       I915_WRITE_FW(PLANE_STRIDE(pipe, plane_id), stride);
-       I915_WRITE_FW(PLANE_SIZE(pipe, plane_id), (src_h << 16) | src_w);
-       I915_WRITE_FW(PLANE_AUX_DIST(pipe, plane_id),
-                     (plane_state->aux.offset - surf_addr) | aux_stride);
-       I915_WRITE_FW(PLANE_AUX_OFFSET(pipe, plane_id),
-                     (plane_state->aux.y << 16) | plane_state->aux.x);
-       if (scaler_id >= 0) {
-               uint32_t ps_ctrl = 0;
-               WARN_ON(!dst_w || !dst_h);
-               ps_ctrl = PS_SCALER_EN | PS_PLANE_SEL(plane_id) |
-                       crtc_state->scaler_state.scalers[scaler_id].mode;
-               I915_WRITE_FW(SKL_PS_CTRL(pipe, scaler_id), ps_ctrl);
-               I915_WRITE_FW(SKL_PS_PWR_GATE(pipe, scaler_id), 0);
-               I915_WRITE_FW(SKL_PS_WIN_POS(pipe, scaler_id), (dst_x << 16) | dst_y);
-               I915_WRITE_FW(SKL_PS_WIN_SZ(pipe, scaler_id), (dst_w << 16) | dst_h);
-               I915_WRITE_FW(PLANE_POS(pipe, plane_id), 0);
-       } else {
-               I915_WRITE_FW(PLANE_POS(pipe, plane_id), (dst_y << 16) | dst_x);
-       }
-       I915_WRITE_FW(PLANE_SURF(pipe, plane_id),
-                     intel_plane_ggtt_offset(plane_state) + surf_addr);
-       POSTING_READ_FW(PLANE_SURF(pipe, plane_id));
-       spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags);
- }
- static void skylake_disable_primary_plane(struct intel_plane *primary,
-                                         struct intel_crtc *crtc)
- {
-       struct drm_i915_private *dev_priv = to_i915(primary->base.dev);
-       enum plane_id plane_id = primary->id;
-       enum pipe pipe = primary->pipe;
-       unsigned long irqflags;
-       spin_lock_irqsave(&dev_priv->uncore.lock, irqflags);
-       I915_WRITE_FW(PLANE_CTL(pipe, plane_id), 0);
-       I915_WRITE_FW(PLANE_SURF(pipe, plane_id), 0);
-       POSTING_READ_FW(PLANE_SURF(pipe, plane_id));
-       spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags);
- }
  static int
  __intel_display_resume(struct drm_device *dev,
                       struct drm_atomic_state *state,
@@@ -3701,7 -3595,7 +3595,7 @@@ void intel_prepare_reset(struct drm_i91
  
  
        /* reset doesn't touch the display */
-       if (!i915.force_reset_modeset_test &&
+       if (!i915_modparams.force_reset_modeset_test &&
            !gpu_reset_clobbers_display(dev_priv))
                return;
  
@@@ -3757,7 -3651,7 +3651,7 @@@ void intel_finish_reset(struct drm_i915
        int ret;
  
        /* reset doesn't touch the display */
-       if (!i915.force_reset_modeset_test &&
+       if (!i915_modparams.force_reset_modeset_test &&
            !gpu_reset_clobbers_display(dev_priv))
                return;
  
  
                intel_pps_unlock_regs_wa(dev_priv);
                intel_modeset_init_hw(dev);
+               intel_init_clock_gating(dev_priv);
  
                spin_lock_irq(&dev_priv->irq_lock);
                if (dev_priv->display.hpd_irq_setup)
@@@ -4955,9 -4850,10 +4850,10 @@@ void hsw_enable_ips(struct intel_crtc *
  
        assert_plane_enabled(dev_priv, crtc->plane);
        if (IS_BROADWELL(dev_priv)) {
-               mutex_lock(&dev_priv->rps.hw_lock);
-               WARN_ON(sandybridge_pcode_write(dev_priv, DISPLAY_IPS_CONTROL, 0xc0000000));
-               mutex_unlock(&dev_priv->rps.hw_lock);
+               mutex_lock(&dev_priv->pcu_lock);
+               WARN_ON(sandybridge_pcode_write(dev_priv, DISPLAY_IPS_CONTROL,
+                                               IPS_ENABLE | IPS_PCODE_CONTROL));
+               mutex_unlock(&dev_priv->pcu_lock);
                /* Quoting Art Runyan: "its not safe to expect any particular
                 * value in IPS_CTL bit 31 after enabling IPS through the
                 * mailbox." Moreover, the mailbox may return a bogus state,
@@@ -4987,9 -4883,9 +4883,9 @@@ void hsw_disable_ips(struct intel_crtc 
  
        assert_plane_enabled(dev_priv, crtc->plane);
        if (IS_BROADWELL(dev_priv)) {
-               mutex_lock(&dev_priv->rps.hw_lock);
+               mutex_lock(&dev_priv->pcu_lock);
                WARN_ON(sandybridge_pcode_write(dev_priv, DISPLAY_IPS_CONTROL, 0));
-               mutex_unlock(&dev_priv->rps.hw_lock);
+               mutex_unlock(&dev_priv->pcu_lock);
                /* wait for pcode to finish disabling IPS, which may take up to 42ms */
                if (intel_wait_for_register(dev_priv,
                                            IPS_CTL, IPS_ENABLE, 0,
@@@ -5458,6 -5354,20 +5354,20 @@@ static bool hsw_crtc_supports_ips(struc
        return HAS_IPS(to_i915(crtc->base.dev)) && crtc->pipe == PIPE_A;
  }
  
+ static void glk_pipe_scaler_clock_gating_wa(struct drm_i915_private *dev_priv,
+                                           enum pipe pipe, bool apply)
+ {
+       u32 val = I915_READ(CLKGATE_DIS_PSL(pipe));
+       u32 mask = DPF_GATING_DIS | DPF_RAM_GATING_DIS | DPFR_GATING_DIS;
+       if (apply)
+               val |= mask;
+       else
+               val &= ~mask;
+       I915_WRITE(CLKGATE_DIS_PSL(pipe), val);
+ }
  static void haswell_crtc_enable(struct intel_crtc_state *pipe_config,
                                struct drm_atomic_state *old_state)
  {
        enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
        struct intel_atomic_state *old_intel_state =
                to_intel_atomic_state(old_state);
+       bool psl_clkgate_wa;
  
        if (WARN_ON(intel_crtc->active))
                return;
  
-       if (intel_crtc->config->has_pch_encoder)
-               intel_set_pch_fifo_underrun_reporting(dev_priv, PIPE_A, false);
        intel_encoders_pre_pll_enable(crtc, pipe_config, old_state);
  
        if (intel_crtc->config->shared_dpll)
  
        intel_crtc->active = true;
  
-       if (intel_crtc->config->has_pch_encoder)
-               intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, false);
-       else
-               intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, true);
        intel_encoders_pre_enable(crtc, pipe_config, old_state);
  
-       if (intel_crtc->config->has_pch_encoder)
-               dev_priv->display.fdi_link_train(intel_crtc, pipe_config);
        if (!transcoder_is_dsi(cpu_transcoder))
                intel_ddi_enable_pipe_clock(pipe_config);
  
+       /* Display WA #1180: WaDisableScalarClockGating: glk, cnl */
+       psl_clkgate_wa = (IS_GEMINILAKE(dev_priv) || IS_CANNONLAKE(dev_priv)) &&
+                        intel_crtc->config->pch_pfit.enabled;
+       if (psl_clkgate_wa)
+               glk_pipe_scaler_clock_gating_wa(dev_priv, pipe, true);
        if (INTEL_GEN(dev_priv) >= 9)
                skylake_pfit_enable(intel_crtc);
        else
  
        intel_encoders_enable(crtc, pipe_config, old_state);
  
-       if (intel_crtc->config->has_pch_encoder) {
+       if (psl_clkgate_wa) {
                intel_wait_for_vblank(dev_priv, pipe);
-               intel_wait_for_vblank(dev_priv, pipe);
-               intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, true);
-               intel_set_pch_fifo_underrun_reporting(dev_priv, PIPE_A, true);
+               glk_pipe_scaler_clock_gating_wa(dev_priv, pipe, false);
        }
  
        /* If we change the relative order between pipe/planes enabling, we need
@@@ -5654,9 -5558,6 +5558,6 @@@ static void haswell_crtc_disable(struc
        struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
        enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
  
-       if (intel_crtc->config->has_pch_encoder)
-               intel_set_pch_fifo_underrun_reporting(dev_priv, PIPE_A, false);
        intel_encoders_disable(crtc, old_crtc_state, old_state);
  
        drm_crtc_vblank_off(crtc);
                intel_ddi_disable_pipe_clock(intel_crtc->config);
  
        intel_encoders_post_disable(crtc, old_crtc_state, old_state);
-       if (old_crtc_state->has_pch_encoder)
-               intel_set_pch_fifo_underrun_reporting(dev_priv, PIPE_A, true);
  }
  
  static void i9xx_pfit_enable(struct intel_crtc *crtc)
@@@ -5893,7 -5791,7 +5791,7 @@@ static void i9xx_crtc_enable(struct int
  
        intel_encoders_pre_enable(crtc, pipe_config, old_state);
  
-       i9xx_enable_pll(intel_crtc);
+       i9xx_enable_pll(intel_crtc, pipe_config);
  
        i9xx_pfit_enable(intel_crtc);
  
@@@ -6145,6 -6043,19 +6043,19 @@@ struct intel_connector *intel_connector
        return connector;
  }
  
+ /*
+  * Free the bits allocated by intel_connector_alloc.
+  * This should only be used after intel_connector_alloc has returned
+  * successfully, and before drm_connector_init returns successfully.
+  * Otherwise the destroy callbacks for the connector and the state should
+  * take care of proper cleanup/free
+  */
+ void intel_connector_free(struct intel_connector *connector)
+ {
+       kfree(to_intel_digital_connector_state(connector->base.state));
+       kfree(connector);
+ }
  /* Simple connector->get_hw_state implementation for encoders that support only
   * one connector and no cloning and hence the encoder state determines the state
   * of the connector. */
@@@ -6312,7 -6223,7 +6223,7 @@@ static void hsw_compute_ips_config(stru
        struct drm_device *dev = crtc->base.dev;
        struct drm_i915_private *dev_priv = to_i915(dev);
  
-       pipe_config->ips_enabled = i915.enable_ips &&
+       pipe_config->ips_enabled = i915_modparams.enable_ips &&
                hsw_crtc_supports_ips(crtc) &&
                pipe_config_supports_ips(dev_priv, pipe_config);
  }
@@@ -6493,8 -6404,8 +6404,8 @@@ intel_link_compute_m_n(int bits_per_pix
  
  static inline bool intel_panel_use_ssc(struct drm_i915_private *dev_priv)
  {
-       if (i915.panel_use_ssc >= 0)
-               return i915.panel_use_ssc != 0;
+       if (i915_modparams.panel_use_ssc >= 0)
+               return i915_modparams.panel_use_ssc != 0;
        return dev_priv->vbt.lvds_use_ssc
                && !(dev_priv->quirks & QUIRK_LVDS_SSC_DISABLE);
  }
@@@ -6528,11 -6439,9 +6439,9 @@@ static void i9xx_update_pll_dividers(st
  
        crtc_state->dpll_hw_state.fp0 = fp;
  
-       crtc->lowfreq_avail = false;
        if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_LVDS) &&
            reduced_clock) {
                crtc_state->dpll_hw_state.fp1 = fp2;
-               crtc->lowfreq_avail = true;
        } else {
                crtc_state->dpll_hw_state.fp1 = fp;
        }
@@@ -7227,15 -7136,6 +7136,6 @@@ static void i9xx_set_pipeconf(struct in
                }
        }
  
-       if (HAS_PIPE_CXSR(dev_priv)) {
-               if (intel_crtc->lowfreq_avail) {
-                       DRM_DEBUG_KMS("enabling CxSR downclocking\n");
-                       pipeconf |= PIPECONF_CXSR_DOWNCLOCK;
-               } else {
-                       DRM_DEBUG_KMS("disabling CxSR downclocking\n");
-               }
-       }
        if (intel_crtc->config->base.adjusted_mode.flags & DRM_MODE_FLAG_INTERLACE) {
                if (INTEL_GEN(dev_priv) < 4 ||
                    intel_crtc_has_type(intel_crtc->config, INTEL_OUTPUT_SDVO))
@@@ -8371,8 -8271,6 +8271,6 @@@ static int ironlake_crtc_compute_clock(
        memset(&crtc_state->dpll_hw_state, 0,
               sizeof(crtc_state->dpll_hw_state));
  
-       crtc->lowfreq_avail = false;
        /* CPU eDP is the only output that doesn't need a PCH PLL of its own. */
        if (!crtc_state->has_pch_encoder)
                return 0;
@@@ -8845,11 -8743,11 +8743,11 @@@ static uint32_t hsw_read_dcomp(struct d
  static void hsw_write_dcomp(struct drm_i915_private *dev_priv, uint32_t val)
  {
        if (IS_HASWELL(dev_priv)) {
-               mutex_lock(&dev_priv->rps.hw_lock);
+               mutex_lock(&dev_priv->pcu_lock);
                if (sandybridge_pcode_write(dev_priv, GEN6_PCODE_WRITE_D_COMP,
                                            val))
                        DRM_DEBUG_KMS("Failed to write to D_COMP\n");
-               mutex_unlock(&dev_priv->rps.hw_lock);
+               mutex_unlock(&dev_priv->pcu_lock);
        } else {
                I915_WRITE(D_COMP_BDW, val);
                POSTING_READ(D_COMP_BDW);
@@@ -9031,8 -8929,6 +8929,6 @@@ static int haswell_crtc_compute_clock(s
                }
        }
  
-       crtc->lowfreq_avail = false;
        return 0;
  }
  
@@@ -9309,11 -9205,11 +9205,11 @@@ static bool haswell_get_pipe_config(str
        pipe_config->gamma_mode =
                I915_READ(GAMMA_MODE(crtc->pipe)) & GAMMA_MODE_MODE_MASK;
  
-       if (IS_BROADWELL(dev_priv) || dev_priv->info.gen >= 9) {
+       if (IS_BROADWELL(dev_priv) || INTEL_GEN(dev_priv) >= 9) {
                u32 tmp = I915_READ(PIPEMISC(crtc->pipe));
                bool clrspace_yuv = tmp & PIPEMISC_OUTPUT_COLORSPACE_YUV;
  
-               if (IS_GEMINILAKE(dev_priv) || dev_priv->info.gen >= 10) {
+               if (IS_GEMINILAKE(dev_priv) || INTEL_GEN(dev_priv) >= 10) {
                        bool blend_mode_420 = tmp &
                                              PIPEMISC_YUV420_MODE_FULL_BLEND;
  
@@@ -9418,12 -9314,11 +9314,12 @@@ static int intel_check_cursor(struct in
        u32 offset;
        int ret;
  
 -      ret = drm_plane_helper_check_state(&plane_state->base,
 -                                         &plane_state->clip,
 -                                         DRM_PLANE_HELPER_NO_SCALING,
 -                                         DRM_PLANE_HELPER_NO_SCALING,
 -                                         true, true);
 +      ret = drm_atomic_helper_check_plane_state(&plane_state->base,
 +                                                &crtc_state->base,
 +                                                &plane_state->clip,
 +                                                DRM_PLANE_HELPER_NO_SCALING,
 +                                                DRM_PLANE_HELPER_NO_SCALING,
 +                                                true, true);
        if (ret)
                return ret;
  
@@@ -9853,7 -9748,7 +9749,7 @@@ mode_fits_in_fbdev(struct drm_device *d
        if (obj->base.size < mode->vdisplay * fb->pitches[0])
                return NULL;
  
-       drm_framebuffer_reference(fb);
+       drm_framebuffer_get(fb);
        return fb;
  #else
        return NULL;
@@@ -10034,7 -9929,7 +9930,7 @@@ found
        if (ret)
                goto fail;
  
-       drm_framebuffer_unreference(fb);
+       drm_framebuffer_put(fb);
  
        ret = drm_atomic_set_mode_for_crtc(&crtc_state->base, mode);
        if (ret)
@@@ -10224,7 -10119,7 +10120,7 @@@ int intel_dotclock_calculate(int link_f
        if (!m_n->link_n)
                return 0;
  
-       return div_u64((u64)m_n->link_m * link_freq, m_n->link_n);
+       return div_u64(mul_u32_u32(m_n->link_m, link_freq), m_n->link_n);
  }
  
  static void ironlake_pch_clock_get(struct intel_crtc *crtc,
                                         &pipe_config->fdi_m_n);
  }
  
- /** Returns the currently programmed mode of the given pipe. */
- struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
                                           struct drm_crtc *crtc)
+ /* Returns the currently programmed mode of the given encoder. */
+ struct drm_display_mode *
intel_encoder_current_mode(struct intel_encoder *encoder)
  {
-       struct drm_i915_private *dev_priv = to_i915(dev);
-       struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-       enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
+       struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
+       struct intel_crtc_state *crtc_state;
        struct drm_display_mode *mode;
-       struct intel_crtc_state *pipe_config;
-       int htot = I915_READ(HTOTAL(cpu_transcoder));
-       int hsync = I915_READ(HSYNC(cpu_transcoder));
-       int vtot = I915_READ(VTOTAL(cpu_transcoder));
-       int vsync = I915_READ(VSYNC(cpu_transcoder));
-       enum pipe pipe = intel_crtc->pipe;
+       struct intel_crtc *crtc;
+       enum pipe pipe;
+       if (!encoder->get_hw_state(encoder, &pipe))
+               return NULL;
+       crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
  
        mode = kzalloc(sizeof(*mode), GFP_KERNEL);
        if (!mode)
                return NULL;
  
-       pipe_config = kzalloc(sizeof(*pipe_config), GFP_KERNEL);
-       if (!pipe_config) {
+       crtc_state = kzalloc(sizeof(*crtc_state), GFP_KERNEL);
+       if (!crtc_state) {
                kfree(mode);
                return NULL;
        }
  
-       /*
-        * Construct a pipe_config sufficient for getting the clock info
-        * back out of crtc_clock_get.
-        *
-        * Note, if LVDS ever uses a non-1 pixel multiplier, we'll need
-        * to use a real value here instead.
-        */
-       pipe_config->cpu_transcoder = (enum transcoder) pipe;
-       pipe_config->pixel_multiplier = 1;
-       pipe_config->dpll_hw_state.dpll = I915_READ(DPLL(pipe));
-       pipe_config->dpll_hw_state.fp0 = I915_READ(FP0(pipe));
-       pipe_config->dpll_hw_state.fp1 = I915_READ(FP1(pipe));
-       i9xx_crtc_clock_get(intel_crtc, pipe_config);
-       mode->clock = pipe_config->port_clock / pipe_config->pixel_multiplier;
-       mode->hdisplay = (htot & 0xffff) + 1;
-       mode->htotal = ((htot & 0xffff0000) >> 16) + 1;
-       mode->hsync_start = (hsync & 0xffff) + 1;
-       mode->hsync_end = ((hsync & 0xffff0000) >> 16) + 1;
-       mode->vdisplay = (vtot & 0xffff) + 1;
-       mode->vtotal = ((vtot & 0xffff0000) >> 16) + 1;
-       mode->vsync_start = (vsync & 0xffff) + 1;
-       mode->vsync_end = ((vsync & 0xffff0000) >> 16) + 1;
+       crtc_state->base.crtc = &crtc->base;
  
-       drm_mode_set_name(mode);
+       if (!dev_priv->display.get_pipe_config(crtc, crtc_state)) {
+               kfree(crtc_state);
+               kfree(mode);
+               return NULL;
+       }
  
-       kfree(pipe_config);
+       encoder->get_config(encoder, crtc_state);
+       intel_mode_from_pipe_config(mode, crtc_state);
+       kfree(crtc_state);
  
        return mode;
  }
@@@ -10683,6 -10564,52 +10565,52 @@@ intel_dump_m_n_config(struct intel_crtc
                      m_n->link_m, m_n->link_n, m_n->tu);
  }
  
+ #define OUTPUT_TYPE(x) [INTEL_OUTPUT_ ## x] = #x
+ static const char * const output_type_str[] = {
+       OUTPUT_TYPE(UNUSED),
+       OUTPUT_TYPE(ANALOG),
+       OUTPUT_TYPE(DVO),
+       OUTPUT_TYPE(SDVO),
+       OUTPUT_TYPE(LVDS),
+       OUTPUT_TYPE(TVOUT),
+       OUTPUT_TYPE(HDMI),
+       OUTPUT_TYPE(DP),
+       OUTPUT_TYPE(EDP),
+       OUTPUT_TYPE(DSI),
+       OUTPUT_TYPE(UNKNOWN),
+       OUTPUT_TYPE(DP_MST),
+ };
+ #undef OUTPUT_TYPE
+ static void snprintf_output_types(char *buf, size_t len,
+                                 unsigned int output_types)
+ {
+       char *str = buf;
+       int i;
+       str[0] = '\0';
+       for (i = 0; i < ARRAY_SIZE(output_type_str); i++) {
+               int r;
+               if ((output_types & BIT(i)) == 0)
+                       continue;
+               r = snprintf(str, len, "%s%s",
+                            str != buf ? "," : "", output_type_str[i]);
+               if (r >= len)
+                       break;
+               str += r;
+               len -= r;
+               output_types &= ~BIT(i);
+       }
+       WARN_ON_ONCE(output_types != 0);
+ }
  static void intel_dump_pipe_config(struct intel_crtc *crtc,
                                   struct intel_crtc_state *pipe_config,
                                   const char *context)
        struct intel_plane *intel_plane;
        struct intel_plane_state *state;
        struct drm_framebuffer *fb;
+       char buf[64];
  
        DRM_DEBUG_KMS("[CRTC:%d:%s]%s\n",
                      crtc->base.base.id, crtc->base.name, context);
  
+       snprintf_output_types(buf, sizeof(buf), pipe_config->output_types);
+       DRM_DEBUG_KMS("output_types: %s (0x%x)\n",
+                     buf, pipe_config->output_types);
        DRM_DEBUG_KMS("cpu_transcoder: %s, pipe bpp: %i, dithering: %i\n",
                      transcoder_name(pipe_config->cpu_transcoder),
                      pipe_config->pipe_bpp, pipe_config->dither);
@@@ -11336,6 -11268,18 +11269,18 @@@ intel_pipe_config_compare(struct drm_i9
        PIPE_CONF_CHECK_X(dpll_hw_state.ctrl1);
        PIPE_CONF_CHECK_X(dpll_hw_state.cfgcr1);
        PIPE_CONF_CHECK_X(dpll_hw_state.cfgcr2);
+       PIPE_CONF_CHECK_X(dpll_hw_state.cfgcr0);
+       PIPE_CONF_CHECK_X(dpll_hw_state.ebb0);
+       PIPE_CONF_CHECK_X(dpll_hw_state.ebb4);
+       PIPE_CONF_CHECK_X(dpll_hw_state.pll0);
+       PIPE_CONF_CHECK_X(dpll_hw_state.pll1);
+       PIPE_CONF_CHECK_X(dpll_hw_state.pll2);
+       PIPE_CONF_CHECK_X(dpll_hw_state.pll3);
+       PIPE_CONF_CHECK_X(dpll_hw_state.pll6);
+       PIPE_CONF_CHECK_X(dpll_hw_state.pll8);
+       PIPE_CONF_CHECK_X(dpll_hw_state.pll9);
+       PIPE_CONF_CHECK_X(dpll_hw_state.pll10);
+       PIPE_CONF_CHECK_X(dpll_hw_state.pcsdw12);
  
        PIPE_CONF_CHECK_X(dsi_pll.ctrl);
        PIPE_CONF_CHECK_X(dsi_pll.div);
@@@ -12084,7 -12028,7 +12029,7 @@@ static int intel_atomic_check(struct dr
                        return ret;
                }
  
-               if (i915.fastboot &&
+               if (i915_modparams.fastboot &&
                    intel_pipe_config_compare(dev_priv,
                                        to_intel_crtc_state(old_crtc_state),
                                        pipe_config, true)) {
@@@ -12220,7 -12164,10 +12165,10 @@@ static void skl_update_crtcs(struct drm
                        if (updated & cmask || !cstate->base.active)
                                continue;
  
-                       if (skl_ddb_allocation_overlaps(entries, &cstate->wm.skl.ddb, i))
+                       if (skl_ddb_allocation_overlaps(dev_priv,
+                                                       entries,
+                                                       &cstate->wm.skl.ddb,
+                                                       i))
                                continue;
  
                        updated |= cmask;
@@@ -12299,7 -12246,6 +12247,6 @@@ static void intel_atomic_commit_tail(st
        struct drm_crtc_state *old_crtc_state, *new_crtc_state;
        struct drm_crtc *crtc;
        struct intel_crtc_state *intel_cstate;
-       bool hw_check = intel_state->modeset;
        u64 put_domains[I915_MAX_PIPES] = {};
        int i;
  
  
                if (needs_modeset(new_crtc_state) ||
                    to_intel_crtc_state(new_crtc_state)->update_pipe) {
-                       hw_check = true;
  
                        put_domains[to_intel_crtc(crtc)->pipe] =
                                modeset_get_crtc_power_domains(crtc,
@@@ -12517,21 -12462,10 +12463,10 @@@ static int intel_atomic_commit(struct d
        struct drm_i915_private *dev_priv = to_i915(dev);
        int ret = 0;
  
-       ret = drm_atomic_helper_setup_commit(state, nonblock);
-       if (ret)
-               return ret;
        drm_atomic_state_get(state);
        i915_sw_fence_init(&intel_state->commit_ready,
                           intel_atomic_commit_ready);
  
-       ret = intel_atomic_prepare_commit(dev, state);
-       if (ret) {
-               DRM_DEBUG_ATOMIC("Preparing state failed with %i\n", ret);
-               i915_sw_fence_commit(&intel_state->commit_ready);
-               return ret;
-       }
        /*
         * The intel_legacy_cursor_update() fast path takes care
         * of avoiding the vblank waits for simple cursor
         * updates happen during the correct frames. Gen9+ have
         * double buffered watermarks and so shouldn't need this.
         *
-        * Do this after drm_atomic_helper_setup_commit() and
-        * intel_atomic_prepare_commit() because we still want
-        * to skip the flip and fb cleanup waits. Although that
-        * does risk yanking the mapping from under the display
-        * engine.
+        * Unset state->legacy_cursor_update before the call to
+        * drm_atomic_helper_setup_commit() because otherwise
+        * drm_atomic_helper_wait_for_flip_done() is a noop and
+        * we get FIFO underruns because we didn't wait
+        * for vblank.
         *
         * FIXME doing watermarks and fb cleanup from a vblank worker
         * (assuming we had any) would solve these problems.
         */
-       if (INTEL_GEN(dev_priv) < 9)
-               state->legacy_cursor_update = false;
+       if (INTEL_GEN(dev_priv) < 9 && state->legacy_cursor_update) {
+               struct intel_crtc_state *new_crtc_state;
+               struct intel_crtc *crtc;
+               int i;
+               for_each_new_intel_crtc_in_state(intel_state, crtc, new_crtc_state, i)
+                       if (new_crtc_state->wm.need_postvbl_update ||
+                           new_crtc_state->update_wm_post)
+                               state->legacy_cursor_update = false;
+       }
+       ret = intel_atomic_prepare_commit(dev, state);
+       if (ret) {
+               DRM_DEBUG_ATOMIC("Preparing state failed with %i\n", ret);
+               i915_sw_fence_commit(&intel_state->commit_ready);
+               return ret;
+       }
+       ret = drm_atomic_helper_setup_commit(state, nonblock);
+       if (!ret)
+               ret = drm_atomic_helper_swap_state(state, true);
  
-       ret = drm_atomic_helper_swap_state(state, true);
        if (ret) {
                i915_sw_fence_commit(&intel_state->commit_ready);
  
@@@ -12842,11 -12794,10 +12795,11 @@@ intel_check_primary_plane(struct intel_
                can_position = true;
        }
  
 -      ret = drm_plane_helper_check_state(&state->base,
 -                                         &state->clip,
 -                                         min_scale, max_scale,
 -                                         can_position, true);
 +      ret = drm_atomic_helper_check_plane_state(&state->base,
 +                                                &crtc_state->base,
 +                                                &state->clip,
 +                                                min_scale, max_scale,
 +                                                can_position, true);
        if (ret)
                return ret;
  
@@@ -13231,8 -13182,8 +13184,8 @@@ intel_primary_plane_create(struct drm_i
                num_formats = ARRAY_SIZE(skl_primary_formats);
                modifiers = skl_format_modifiers_ccs;
  
-               primary->update_plane = skylake_update_primary_plane;
-               primary->disable_plane = skylake_disable_primary_plane;
+               primary->update_plane = skl_update_plane;
+               primary->disable_plane = skl_disable_plane;
        } else if (INTEL_GEN(dev_priv) >= 9) {
                intel_primary_formats = skl_primary_formats;
                num_formats = ARRAY_SIZE(skl_primary_formats);
                else
                        modifiers = skl_format_modifiers_noccs;
  
-               primary->update_plane = skylake_update_primary_plane;
-               primary->disable_plane = skylake_disable_primary_plane;
+               primary->update_plane = skl_update_plane;
+               primary->disable_plane = skl_disable_plane;
        } else if (INTEL_GEN(dev_priv) >= 4) {
                intel_primary_formats = i965_primary_formats;
                num_formats = ARRAY_SIZE(i965_primary_formats);
@@@ -13513,7 -13464,7 +13466,7 @@@ int intel_get_pipe_from_crtc_id(struct 
        struct drm_crtc *drmmode_crtc;
        struct intel_crtc *crtc;
  
-       drmmode_crtc = drm_crtc_find(dev, pipe_from_crtc_id->crtc_id);
+       drmmode_crtc = drm_crtc_find(dev, file, pipe_from_crtc_id->crtc_id);
        if (!drmmode_crtc)
                return -ENOENT;
  
@@@ -14220,7 -14171,7 +14173,7 @@@ void intel_init_display_hooks(struct dr
                dev_priv->display.fdi_link_train = hsw_fdi_link_train;
        }
  
-       if (dev_priv->info.gen >= 9)
+       if (INTEL_GEN(dev_priv) >= 9)
                dev_priv->display.update_crtcs = skl_update_crtcs;
        else
                dev_priv->display.update_crtcs = intel_update_crtcs;
@@@ -14400,8 -14351,6 +14353,6 @@@ void intel_modeset_init_hw(struct drm_d
  
        intel_update_cdclk(dev_priv);
        dev_priv->cdclk.logical = dev_priv->cdclk.actual = dev_priv->cdclk.hw;
-       intel_init_clock_gating(dev_priv);
  }
  
  /*
@@@ -14751,10 -14700,10 +14702,10 @@@ static struct intel_connector *intel_en
  }
  
  static bool has_pch_trancoder(struct drm_i915_private *dev_priv,
-                             enum transcoder pch_transcoder)
+                             enum pipe pch_transcoder)
  {
        return HAS_PCH_IBX(dev_priv) || HAS_PCH_CPT(dev_priv) ||
-               (HAS_PCH_LPT_H(dev_priv) && pch_transcoder == TRANSCODER_A);
+               (HAS_PCH_LPT_H(dev_priv) && pch_transcoder == PIPE_A);
  }
  
  static void intel_sanitize_crtc(struct intel_crtc *crtc,
                 * PCH transcoders B and C would prevent enabling the south
                 * error interrupt (see cpt_can_enable_serr_int()).
                 */
-               if (has_pch_trancoder(dev_priv, (enum transcoder)crtc->pipe))
+               if (has_pch_trancoder(dev_priv, crtc->pipe))
                        crtc->pch_fifo_underrun_disabled = true;
        }
  }
@@@ -15113,6 -15062,15 +15064,15 @@@ intel_modeset_setup_hw_state(struct drm
        struct intel_encoder *encoder;
        int i;
  
+       if (IS_HASWELL(dev_priv)) {
+               /*
+                * WaRsPkgCStateDisplayPMReq:hsw
+                * System hang if this isn't done before disabling all planes!
+                */
+               I915_WRITE(CHICKEN_PAR1_1,
+                          I915_READ(CHICKEN_PAR1_1) | FORCE_ARB_IDLE_PLANES);
+       }
        intel_modeset_readout_hw_state(dev);
  
        /* HW state is read out, now we need to sanitize this mess. */
@@@ -15194,6 -15152,7 +15154,7 @@@ void intel_display_resume(struct drm_de
        if (!ret)
                ret = __intel_display_resume(dev, state, &ctx);
  
+       intel_enable_ipc(dev_priv);
        drm_modeset_drop_locks(&ctx);
        drm_modeset_acquire_fini(&ctx);
  
@@@ -15209,6 -15168,8 +15170,8 @@@ void intel_modeset_gem_init(struct drm_
  
        intel_init_gt_powersave(dev_priv);
  
+       intel_init_clock_gating(dev_priv);
        intel_setup_overlay(dev_priv);
  }
  
index 6fce08209b4f63a8fdf6384a9b27ad9464c921f2,aa75f55eeb61b16c282bde6a47aeb68ddc7b898e..d112810041098171398dc81f016b3fdd20f2707f
@@@ -42,6 -42,7 +42,7 @@@
  #include "i915_drv.h"
  
  #define DP_LINK_CHECK_TIMEOUT (10 * 1000)
+ #define DP_DPRX_ESI_LEN 14
  
  /* Compliance test status bits  */
  #define INTEL_DP_RESOLUTION_SHIFT_MASK        0
@@@ -136,32 -137,20 +137,20 @@@ static void vlv_steal_power_sequencer(s
                                      enum pipe pipe);
  static void intel_dp_unset_edid(struct intel_dp *intel_dp);
  
- static int intel_dp_num_rates(u8 link_bw_code)
- {
-       switch (link_bw_code) {
-       default:
-               WARN(1, "invalid max DP link bw val %x, using 1.62Gbps\n",
-                    link_bw_code);
-       case DP_LINK_BW_1_62:
-               return 1;
-       case DP_LINK_BW_2_7:
-               return 2;
-       case DP_LINK_BW_5_4:
-               return 3;
-       }
- }
  /* update sink rates from dpcd */
  static void intel_dp_set_sink_rates(struct intel_dp *intel_dp)
  {
-       int i, num_rates;
+       int i, max_rate;
  
-       num_rates = intel_dp_num_rates(intel_dp->dpcd[DP_MAX_LINK_RATE]);
+       max_rate = drm_dp_bw_code_to_link_rate(intel_dp->dpcd[DP_MAX_LINK_RATE]);
  
-       for (i = 0; i < num_rates; i++)
+       for (i = 0; i < ARRAY_SIZE(default_rates); i++) {
+               if (default_rates[i] > max_rate)
+                       break;
                intel_dp->sink_rates[i] = default_rates[i];
+       }
  
-       intel_dp->num_sink_rates = num_rates;
+       intel_dp->num_sink_rates = i;
  }
  
  /* Theoretical max between source and sink */
@@@ -253,15 -242,15 +242,15 @@@ intel_dp_set_source_rates(struct intel_
        } else if (IS_GEN9_BC(dev_priv)) {
                source_rates = skl_rates;
                size = ARRAY_SIZE(skl_rates);
-       } else {
+       } else if ((IS_HASWELL(dev_priv) && !IS_HSW_ULX(dev_priv)) ||
+                  IS_BROADWELL(dev_priv)) {
                source_rates = default_rates;
                size = ARRAY_SIZE(default_rates);
+       } else {
+               source_rates = default_rates;
+               size = ARRAY_SIZE(default_rates) - 1;
        }
  
-       /* This depends on the fact that 5.4 is last value in the array */
-       if (!intel_dp_source_supports_hbr2(intel_dp))
-               size--;
        intel_dp->source_rates = source_rates;
        intel_dp->num_source_rates = size;
  }
@@@ -1018,7 -1007,7 +1007,7 @@@ static uint32_t g4x_get_aux_send_ctl(st
        else
                precharge = 5;
  
-       if (IS_BROADWELL(dev_priv) && intel_dig_port->port == PORT_A)
+       if (IS_BROADWELL(dev_priv))
                timeout = DP_AUX_CH_CTL_TIME_OUT_600us;
        else
                timeout = DP_AUX_CH_CTL_TIME_OUT_400us;
@@@ -1043,7 -1032,7 +1032,7 @@@ static uint32_t skl_get_aux_send_ctl(st
               DP_AUX_CH_CTL_DONE |
               (has_aux_irq ? DP_AUX_CH_CTL_INTERRUPT : 0) |
               DP_AUX_CH_CTL_TIME_OUT_ERROR |
-              DP_AUX_CH_CTL_TIME_OUT_1600us |
+              DP_AUX_CH_CTL_TIME_OUT_MAX |
               DP_AUX_CH_CTL_RECEIVE_ERROR |
               (send_bytes << DP_AUX_CH_CTL_MESSAGE_SIZE_SHIFT) |
               DP_AUX_CH_CTL_FW_SYNC_PULSE_SKL(32) |
@@@ -1481,14 -1470,9 +1470,9 @@@ intel_dp_aux_init(struct intel_dp *inte
  
  bool intel_dp_source_supports_hbr2(struct intel_dp *intel_dp)
  {
-       struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
-       struct drm_i915_private *dev_priv = to_i915(dig_port->base.base.dev);
+       int max_rate = intel_dp->source_rates[intel_dp->num_source_rates - 1];
  
-       if ((IS_HASWELL(dev_priv) && !IS_HSW_ULX(dev_priv)) ||
-           IS_BROADWELL(dev_priv) || (INTEL_GEN(dev_priv) >= 9))
-               return true;
-       else
-               return false;
+       return max_rate >= 540000;
  }
  
  static void
@@@ -1848,6 -1832,8 +1832,8 @@@ found
        if (!HAS_DDI(dev_priv))
                intel_dp_set_clock(encoder, pipe_config);
  
+       intel_psr_compute_config(intel_dp, pipe_config);
        return true;
  }
  
@@@ -2307,8 -2293,8 +2293,8 @@@ static void edp_panel_off(struct intel_
        I915_WRITE(pp_ctrl_reg, pp);
        POSTING_READ(pp_ctrl_reg);
  
-       intel_dp->panel_power_off_time = ktime_get_boottime();
        wait_panel_off(intel_dp);
+       intel_dp->panel_power_off_time = ktime_get_boottime();
  
        /* We got a reference when we enabled the VDD. */
        intel_display_power_put(dev_priv, intel_dp->aux_power_domain);
@@@ -2692,24 -2678,46 +2678,46 @@@ static void intel_disable_dp(struct int
                             const struct drm_connector_state *old_conn_state)
  {
        struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base);
-       struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
  
        if (old_crtc_state->has_audio)
                intel_audio_codec_disable(encoder);
  
-       if (HAS_PSR(dev_priv) && !HAS_DDI(dev_priv))
-               intel_psr_disable(intel_dp, old_crtc_state);
        /* Make sure the panel is off before trying to change the mode. But also
         * ensure that we have vdd while we switch off the panel. */
        intel_edp_panel_vdd_on(intel_dp);
        intel_edp_backlight_off(old_conn_state);
        intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
        intel_edp_panel_off(intel_dp);
+ }
+ static void g4x_disable_dp(struct intel_encoder *encoder,
+                          const struct intel_crtc_state *old_crtc_state,
+                          const struct drm_connector_state *old_conn_state)
+ {
+       struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base);
+       intel_disable_dp(encoder, old_crtc_state, old_conn_state);
  
        /* disable the port before the pipe on g4x */
-       if (INTEL_GEN(dev_priv) < 5)
-               intel_dp_link_down(intel_dp);
+       intel_dp_link_down(intel_dp);
+ }
+ static void ilk_disable_dp(struct intel_encoder *encoder,
+                          const struct intel_crtc_state *old_crtc_state,
+                          const struct drm_connector_state *old_conn_state)
+ {
+       intel_disable_dp(encoder, old_crtc_state, old_conn_state);
+ }
+ static void vlv_disable_dp(struct intel_encoder *encoder,
+                          const struct intel_crtc_state *old_crtc_state,
+                          const struct drm_connector_state *old_conn_state)
+ {
+       struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base);
+       intel_psr_disable(intel_dp, old_crtc_state);
+       intel_disable_dp(encoder, old_crtc_state, old_conn_state);
  }
  
  static void ilk_post_disable_dp(struct intel_encoder *encoder,
@@@ -3147,9 -3155,7 +3155,7 @@@ intel_dp_voltage_max(struct intel_dp *i
        struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp));
        enum port port = dp_to_dig_port(intel_dp)->port;
  
-       if (IS_GEN9_LP(dev_priv))
-               return DP_TRAIN_VOLTAGE_SWING_LEVEL_3;
-       else if (INTEL_GEN(dev_priv) >= 9) {
+       if (INTEL_GEN(dev_priv) >= 9) {
                struct intel_encoder *encoder = &dp_to_dig_port(intel_dp)->base;
                return intel_ddi_dp_voltage_max(encoder);
        } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
@@@ -3826,7 -3832,7 +3832,7 @@@ intel_dp_can_mst(struct intel_dp *intel
  {
        u8 mstm_cap;
  
-       if (!i915.enable_dp_mst)
+       if (!i915_modparams.enable_dp_mst)
                return false;
  
        if (!intel_dp->can_mst)
  static void
  intel_dp_configure_mst(struct intel_dp *intel_dp)
  {
-       if (!i915.enable_dp_mst)
+       if (!i915_modparams.enable_dp_mst)
                return;
  
        if (!intel_dp->can_mst)
@@@ -3991,15 -3997,9 +3997,9 @@@ intel_dp_get_sink_irq(struct intel_dp *
  static bool
  intel_dp_get_sink_irq_esi(struct intel_dp *intel_dp, u8 *sink_irq_vector)
  {
-       int ret;
-       ret = drm_dp_dpcd_read(&intel_dp->aux,
-                                            DP_SINK_COUNT_ESI,
-                                            sink_irq_vector, 14);
-       if (ret != 14)
-               return false;
-       return true;
+       return drm_dp_dpcd_read(&intel_dp->aux, DP_SINK_COUNT_ESI,
+                               sink_irq_vector, DP_DPRX_ESI_LEN) ==
+               DP_DPRX_ESI_LEN;
  }
  
  static uint8_t intel_dp_autotest_link_training(struct intel_dp *intel_dp)
@@@ -4199,7 -4199,7 +4199,7 @@@ intel_dp_check_mst_status(struct intel_
        bool bret;
  
        if (intel_dp->is_mst) {
-               u8 esi[16] = { 0 };
+               u8 esi[DP_DPRX_ESI_LEN] = { 0 };
                int ret = 0;
                int retry;
                bool handled;
@@@ -4736,10 -4736,6 +4736,6 @@@ intel_dp_long_pulse(struct intel_connec
        if (intel_encoder->type != INTEL_OUTPUT_EDP)
                intel_encoder->type = INTEL_OUTPUT_DP;
  
-       DRM_DEBUG_KMS("Display Port TPS3 support: source %s, sink %s\n",
-                     yesno(intel_dp_source_supports_hbr2(intel_dp)),
-                     yesno(drm_dp_tps3_supported(intel_dp->dpcd)));
        if (intel_dp->reset_link_params) {
                /* Initial max link lane count */
                intel_dp->max_link_lane_count = intel_dp_max_common_lane_count(intel_dp);
@@@ -5273,7 -5269,7 +5269,7 @@@ intel_dp_init_panel_power_sequencer(str
         * seems sufficient to avoid this problem.
         */
        if (dev_priv->quirks & QUIRK_INCREASE_T12_DELAY) {
-               vbt.t11_t12 = max_t(u16, vbt.t11_t12, 900 * 10);
+               vbt.t11_t12 = max_t(u16, vbt.t11_t12, 1300 * 10);
                DRM_DEBUG_KMS("Increasing T12 panel delay as per the quirk to %d\n",
                              vbt.t11_t12);
        }
@@@ -5467,11 -5463,6 +5463,6 @@@ static void intel_dp_set_drrs_state(str
                return;
        }
  
-       /*
-        * FIXME: This needs proper synchronization with psr state for some
-        * platforms that cannot have PSR and DRRS enabled at the same time.
-        */
        dig_port = dp_to_dig_port(intel_dp);
        encoder = &dig_port->base;
        intel_crtc = to_intel_crtc(encoder->base.crtc);
@@@ -5555,6 -5546,11 +5546,11 @@@ void intel_edp_drrs_enable(struct intel
                return;
        }
  
+       if (dev_priv->psr.enabled) {
+               DRM_DEBUG_KMS("PSR enabled. Not enabling DRRS.\n");
+               return;
+       }
        mutex_lock(&dev_priv->drrs.mutex);
        if (WARN_ON(dev_priv->drrs.dp)) {
                DRM_ERROR("DRRS already enabled\n");
@@@ -5865,6 -5861,7 +5861,6 @@@ static bool intel_edp_init_connector(st
                if (drm_add_edid_modes(connector, edid)) {
                        drm_mode_connector_update_edid_property(connector,
                                                                edid);
 -                      drm_edid_to_eld(connector, edid);
                } else {
                        kfree(edid);
                        edid = ERR_PTR(-EINVAL);
@@@ -6144,7 -6141,6 +6140,6 @@@ bool intel_dp_init(struct drm_i915_priv
                goto err_encoder_init;
  
        intel_encoder->compute_config = intel_dp_compute_config;
-       intel_encoder->disable = intel_disable_dp;
        intel_encoder->get_hw_state = intel_dp_get_hw_state;
        intel_encoder->get_config = intel_dp_get_config;
        intel_encoder->suspend = intel_dp_encoder_suspend;
                intel_encoder->pre_pll_enable = chv_dp_pre_pll_enable;
                intel_encoder->pre_enable = chv_pre_enable_dp;
                intel_encoder->enable = vlv_enable_dp;
+               intel_encoder->disable = vlv_disable_dp;
                intel_encoder->post_disable = chv_post_disable_dp;
                intel_encoder->post_pll_disable = chv_dp_post_pll_disable;
        } else if (IS_VALLEYVIEW(dev_priv)) {
                intel_encoder->pre_pll_enable = vlv_dp_pre_pll_enable;
                intel_encoder->pre_enable = vlv_pre_enable_dp;
                intel_encoder->enable = vlv_enable_dp;
+               intel_encoder->disable = vlv_disable_dp;
                intel_encoder->post_disable = vlv_post_disable_dp;
+       } else if (INTEL_GEN(dev_priv) >= 5) {
+               intel_encoder->pre_enable = g4x_pre_enable_dp;
+               intel_encoder->enable = g4x_enable_dp;
+               intel_encoder->disable = ilk_disable_dp;
+               intel_encoder->post_disable = ilk_post_disable_dp;
        } else {
                intel_encoder->pre_enable = g4x_pre_enable_dp;
                intel_encoder->enable = g4x_enable_dp;
-               if (INTEL_GEN(dev_priv) >= 5)
-                       intel_encoder->post_disable = ilk_post_disable_dp;
+               intel_encoder->disable = g4x_disable_dp;
        }
  
        intel_dig_port->port = port;
index b39846613e3c78f558ffc3c65233a1bad2e4dd7e,28a778b785ac9e02ea7de55878e5fec98f019b98..4e43f873c8891a3c5e64d78af644f38e87610776
  #include "intel_drv.h"
  #include "i915_drv.h"
  
+ static void intel_connector_update_eld_conn_type(struct drm_connector *connector)
+ {
+       u8 conn_type;
+       if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
+           connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
+               conn_type = DRM_ELD_CONN_TYPE_DP;
+       } else {
+               conn_type = DRM_ELD_CONN_TYPE_HDMI;
+       }
+       connector->eld[DRM_ELD_SAD_COUNT_CONN_TYPE] &= ~DRM_ELD_CONN_TYPE_MASK;
+       connector->eld[DRM_ELD_SAD_COUNT_CONN_TYPE] |= conn_type;
+ }
  /**
   * intel_connector_update_modes - update connector from edid
   * @connector: DRM connector device to use
@@@ -42,7 -57,10 +57,9 @@@ int intel_connector_update_modes(struc
  
        drm_mode_connector_update_edid_property(connector, edid);
        ret = drm_add_edid_modes(connector, edid);
 -      drm_edid_to_eld(connector, edid);
  
+       intel_connector_update_eld_conn_type(connector);
        return ret;
  }
  
index df3360acaccac371eb8e47da2bb7f57791750f51,be50445f9901a2463425fe9d803f4f2f74a9d726..ee41423baeb7c9db07cb5152e655fc6060d4826c
@@@ -31,15 -31,6 +31,6 @@@ static int mdp5_plane_mode_set(struct d
                struct drm_crtc *crtc, struct drm_framebuffer *fb,
                struct drm_rect *src, struct drm_rect *dest);
  
- static int mdp5_update_cursor_plane_legacy(struct drm_plane *plane,
-               struct drm_crtc *crtc,
-               struct drm_framebuffer *fb,
-               int crtc_x, int crtc_y,
-               unsigned int crtc_w, unsigned int crtc_h,
-               uint32_t src_x, uint32_t src_y,
-               uint32_t src_w, uint32_t src_h,
-               struct drm_modeset_acquire_ctx *ctx);
  static struct mdp5_kms *get_kms(struct drm_plane *plane)
  {
        struct msm_drm_private *priv = plane->dev->dev_private;
@@@ -254,18 -245,6 +245,6 @@@ static const struct drm_plane_funcs mdp
                .atomic_print_state = mdp5_plane_atomic_print_state,
  };
  
- static const struct drm_plane_funcs mdp5_cursor_plane_funcs = {
-               .update_plane = mdp5_update_cursor_plane_legacy,
-               .disable_plane = drm_atomic_helper_disable_plane,
-               .destroy = mdp5_plane_destroy,
-               .atomic_set_property = mdp5_plane_atomic_set_property,
-               .atomic_get_property = mdp5_plane_atomic_get_property,
-               .reset = mdp5_plane_reset,
-               .atomic_duplicate_state = mdp5_plane_duplicate_state,
-               .atomic_destroy_state = mdp5_plane_destroy_state,
-               .atomic_print_state = mdp5_plane_atomic_print_state,
- };
  static int mdp5_plane_prepare_fb(struct drm_plane *plane,
                                 struct drm_plane_state *new_state)
  {
@@@ -348,9 -327,8 +327,9 @@@ static int mdp5_plane_atomic_check_with
        min_scale = FRAC_16_16(1, 8);
        max_scale = FRAC_16_16(8, 1);
  
 -      ret = drm_plane_helper_check_state(state, &clip, min_scale,
 -                                         max_scale, true, true);
 +      ret = drm_atomic_helper_check_plane_state(state, crtc_state, &clip,
 +                                                min_scale, max_scale,
 +                                                true, true);
        if (ret)
                return ret;
  
                        struct mdp5_hw_pipe *old_hwpipe = mdp5_state->hwpipe;
                        struct mdp5_hw_pipe *old_right_hwpipe =
                                                          mdp5_state->r_hwpipe;
-                       mdp5_state->hwpipe = mdp5_pipe_assign(state->state,
-                                       plane, caps, blkcfg);
-                       if (IS_ERR(mdp5_state->hwpipe)) {
-                               DBG("%s: failed to assign hwpipe!", plane->name);
-                               return PTR_ERR(mdp5_state->hwpipe);
+                       struct mdp5_hw_pipe *new_hwpipe = NULL;
+                       struct mdp5_hw_pipe *new_right_hwpipe = NULL;
+                       ret = mdp5_pipe_assign(state->state, plane, caps,
+                                              blkcfg, &new_hwpipe,
+                                              need_right_hwpipe ?
+                                              &new_right_hwpipe : NULL);
+                       if (ret) {
+                               DBG("%s: failed to assign hwpipe(s)!",
+                                   plane->name);
+                               return ret;
                        }
  
-                       if (need_right_hwpipe) {
-                               mdp5_state->r_hwpipe =
-                                       mdp5_pipe_assign(state->state, plane,
-                                                        caps, blkcfg);
-                               if (IS_ERR(mdp5_state->r_hwpipe)) {
-                                       DBG("%s: failed to assign right hwpipe",
-                                           plane->name);
-                                       return PTR_ERR(mdp5_state->r_hwpipe);
-                               }
-                       } else {
+                       mdp5_state->hwpipe = new_hwpipe;
+                       if (need_right_hwpipe)
+                               mdp5_state->r_hwpipe = new_right_hwpipe;
+                       else
                                /*
                                 * set it to NULL so that the driver knows we
                                 * don't have a right hwpipe when committing a
                                 * new state
                                 */
                                mdp5_state->r_hwpipe = NULL;
-                       }
  
                        mdp5_pipe_release(state->state, old_hwpipe);
                        mdp5_pipe_release(state->state, old_right_hwpipe);
@@@ -488,11 -465,98 +466,99 @@@ static void mdp5_plane_atomic_update(st
        }
  }
  
 -      ret = drm_plane_helper_check_state(state, &clip, min_scale,
 -                                         max_scale, true, true);
+ static int mdp5_plane_atomic_async_check(struct drm_plane *plane,
+                                        struct drm_plane_state *state)
+ {
+       struct mdp5_plane_state *mdp5_state = to_mdp5_plane_state(state);
+       struct drm_crtc_state *crtc_state;
+       struct drm_rect clip;
+       int min_scale, max_scale;
+       int ret;
+       crtc_state = drm_atomic_get_existing_crtc_state(state->state,
+                                                       state->crtc);
+       if (WARN_ON(!crtc_state))
+               return -EINVAL;
+       if (!crtc_state->active)
+               return -EINVAL;
+       mdp5_state = to_mdp5_plane_state(state);
+       /* don't use fast path if we don't have a hwpipe allocated yet */
+       if (!mdp5_state->hwpipe)
+               return -EINVAL;
+       /* only allow changing of position(crtc x/y or src x/y) in fast path */
+       if (plane->state->crtc != state->crtc ||
+           plane->state->src_w != state->src_w ||
+           plane->state->src_h != state->src_h ||
+           plane->state->crtc_w != state->crtc_w ||
+           plane->state->crtc_h != state->crtc_h ||
+           !plane->state->fb ||
+           plane->state->fb != state->fb)
+               return -EINVAL;
+       clip.x1 = 0;
+       clip.y1 = 0;
+       clip.x2 = crtc_state->adjusted_mode.hdisplay;
+       clip.y2 = crtc_state->adjusted_mode.vdisplay;
+       min_scale = FRAC_16_16(1, 8);
+       max_scale = FRAC_16_16(8, 1);
++      ret = drm_atomic_helper_check_plane_state(state, crtc_state, &clip,
++                                                min_scale, max_scale,
++                                                true, true);
+       if (ret)
+               return ret;
+       /*
+        * if the visibility of the plane changes (i.e, if the cursor is
+        * clipped out completely, we can't take the async path because
+        * we need to stage/unstage the plane from the Layer Mixer(s). We
+        * also assign/unassign the hwpipe(s) tied to the plane. We avoid
+        * taking the fast path for both these reasons.
+        */
+       if (state->visible != plane->state->visible)
+               return -EINVAL;
+       return 0;
+ }
+ static void mdp5_plane_atomic_async_update(struct drm_plane *plane,
+                                          struct drm_plane_state *new_state)
+ {
+       plane->state->src_x = new_state->src_x;
+       plane->state->src_y = new_state->src_y;
+       plane->state->crtc_x = new_state->crtc_x;
+       plane->state->crtc_y = new_state->crtc_y;
+       if (plane_enabled(new_state)) {
+               struct mdp5_ctl *ctl;
+               struct mdp5_pipeline *pipeline =
+                                       mdp5_crtc_get_pipeline(plane->crtc);
+               int ret;
+               ret = mdp5_plane_mode_set(plane, new_state->crtc, new_state->fb,
+                               &new_state->src, &new_state->dst);
+               WARN_ON(ret < 0);
+               ctl = mdp5_crtc_get_ctl(new_state->crtc);
+               mdp5_ctl_commit(ctl, pipeline, mdp5_plane_get_flush(plane));
+       }
+       *to_mdp5_plane_state(plane->state) =
+               *to_mdp5_plane_state(new_state);
+ }
  static const struct drm_plane_helper_funcs mdp5_plane_helper_funcs = {
                .prepare_fb = mdp5_plane_prepare_fb,
                .cleanup_fb = mdp5_plane_cleanup_fb,
                .atomic_check = mdp5_plane_atomic_check,
                .atomic_update = mdp5_plane_atomic_update,
+               .atomic_async_check = mdp5_plane_atomic_async_check,
+               .atomic_async_update = mdp5_plane_atomic_async_update,
  };
  
  static void set_scanout_locked(struct mdp5_kms *mdp5_kms,
@@@ -997,84 -1061,6 +1063,6 @@@ static int mdp5_plane_mode_set(struct d
        return ret;
  }
  
- static int mdp5_update_cursor_plane_legacy(struct drm_plane *plane,
-                       struct drm_crtc *crtc, struct drm_framebuffer *fb,
-                       int crtc_x, int crtc_y,
-                       unsigned int crtc_w, unsigned int crtc_h,
-                       uint32_t src_x, uint32_t src_y,
-                       uint32_t src_w, uint32_t src_h,
-                       struct drm_modeset_acquire_ctx *ctx)
- {
-       struct drm_plane_state *plane_state, *new_plane_state;
-       struct mdp5_plane_state *mdp5_pstate;
-       struct drm_crtc_state *crtc_state = crtc->state;
-       int ret;
-       if (!crtc_state->active || drm_atomic_crtc_needs_modeset(crtc_state))
-               goto slow;
-       plane_state = plane->state;
-       mdp5_pstate = to_mdp5_plane_state(plane_state);
-       /* don't use fast path if we don't have a hwpipe allocated yet */
-       if (!mdp5_pstate->hwpipe)
-               goto slow;
-       /* only allow changing of position(crtc x/y or src x/y) in fast path */
-       if (plane_state->crtc != crtc ||
-           plane_state->src_w != src_w ||
-           plane_state->src_h != src_h ||
-           plane_state->crtc_w != crtc_w ||
-           plane_state->crtc_h != crtc_h ||
-           !plane_state->fb ||
-           plane_state->fb != fb)
-               goto slow;
-       new_plane_state = mdp5_plane_duplicate_state(plane);
-       if (!new_plane_state)
-               return -ENOMEM;
-       new_plane_state->src_x = src_x;
-       new_plane_state->src_y = src_y;
-       new_plane_state->src_w = src_w;
-       new_plane_state->src_h = src_h;
-       new_plane_state->crtc_x = crtc_x;
-       new_plane_state->crtc_y = crtc_y;
-       new_plane_state->crtc_w = crtc_w;
-       new_plane_state->crtc_h = crtc_h;
-       ret = mdp5_plane_atomic_check_with_state(crtc_state, new_plane_state);
-       if (ret)
-               goto slow_free;
-       if (new_plane_state->visible) {
-               struct mdp5_ctl *ctl;
-               struct mdp5_pipeline *pipeline = mdp5_crtc_get_pipeline(crtc);
-               ret = mdp5_plane_mode_set(plane, crtc, fb,
-                                         &new_plane_state->src,
-                                         &new_plane_state->dst);
-               WARN_ON(ret < 0);
-               ctl = mdp5_crtc_get_ctl(crtc);
-               mdp5_ctl_commit(ctl, pipeline, mdp5_plane_get_flush(plane));
-       }
-       *to_mdp5_plane_state(plane_state) =
-               *to_mdp5_plane_state(new_plane_state);
-       mdp5_plane_destroy_state(plane, new_plane_state);
-       return 0;
- slow_free:
-       mdp5_plane_destroy_state(plane, new_plane_state);
- slow:
-       return drm_atomic_helper_update_plane(plane, crtc, fb,
-                                             crtc_x, crtc_y, crtc_w, crtc_h,
-                                             src_x, src_y, src_w, src_h, ctx);
- }
  /*
   * Use this func and the one below only after the atomic state has been
   * successfully swapped
@@@ -1134,16 -1120,9 +1122,9 @@@ struct drm_plane *mdp5_plane_init(struc
        mdp5_plane->nformats = mdp_get_formats(mdp5_plane->formats,
                ARRAY_SIZE(mdp5_plane->formats), false);
  
-       if (type == DRM_PLANE_TYPE_CURSOR)
-               ret = drm_universal_plane_init(dev, plane, 0xff,
-                               &mdp5_cursor_plane_funcs,
-                               mdp5_plane->formats, mdp5_plane->nformats,
-                               NULL, type, NULL);
-       else
-               ret = drm_universal_plane_init(dev, plane, 0xff,
-                               &mdp5_plane_funcs,
-                               mdp5_plane->formats, mdp5_plane->nformats,
-                               NULL, type, NULL);
+       ret = drm_universal_plane_init(dev, plane, 0xff, &mdp5_plane_funcs,
+                       mdp5_plane->formats, mdp5_plane->nformats,
+                       NULL, type, NULL);
        if (ret)
                goto fail;
  
index 9fc8fe0171184015da12856082035a020b6e644d,92d46222c79dfa51bdb58413d788821322f3c26f..9c61e767950d6f903d63485d6cd0cd7dd2ff935e
@@@ -318,7 -318,7 +318,7 @@@ nv50_chan_create(struct nvif_device *de
                                ret = nvif_object_init(disp, 0, oclass[0],
                                                       data, size, &chan->user);
                                if (ret == 0)
-                                       nvif_object_map(&chan->user);
+                                       nvif_object_map(&chan->user, NULL, 0);
                                nvif_object_sclass_put(&sclass);
                                return ret;
                        }
@@@ -424,7 -424,7 +424,7 @@@ nv50_dmac_ctxdma_new(struct nv50_dmac *
  {
        struct nouveau_drm *drm = nouveau_drm(fb->base.dev);
        struct nv50_dmac_ctxdma *ctxdma;
-       const u8    kind = (fb->nvbo->tile_flags & 0x0000ff00) >> 8;
+       const u8    kind = fb->nvbo->kind;
        const u32 handle = 0xfb000000 | kind;
        struct {
                struct nv_dma_v0 base;
@@@ -510,6 -510,7 +510,7 @@@ nv50_dmac_create(struct nvif_device *de
        int ret;
  
        mutex_init(&dmac->lock);
+       INIT_LIST_HEAD(&dmac->ctxdma);
  
        dmac->ptr = dma_alloc_coherent(nvxx_device(device)->dev, PAGE_SIZE,
                                       &dmac->handle, GFP_KERNEL);
        if (ret)
                return ret;
  
-       INIT_LIST_HEAD(&dmac->ctxdma);
        return ret;
  }
  
@@@ -847,7 -847,7 +847,7 @@@ nv50_wndw_atomic_check_acquire(struct n
  
        asyw->image.w = fb->base.width;
        asyw->image.h = fb->base.height;
-       asyw->image.kind = (fb->nvbo->tile_flags & 0x0000ff00) >> 8;
+       asyw->image.kind = fb->nvbo->kind;
  
        if (asyh->state.pageflip_flags & DRM_MODE_PAGE_FLIP_ASYNC)
                asyw->interval = 0;
        if (asyw->image.kind) {
                asyw->image.layout = 0;
                if (drm->client.device.info.chipset >= 0xc0)
-                       asyw->image.block = fb->nvbo->tile_mode >> 4;
+                       asyw->image.block = fb->nvbo->mode >> 4;
                else
-                       asyw->image.block = fb->nvbo->tile_mode;
+                       asyw->image.block = fb->nvbo->mode;
                asyw->image.pitch = (fb->base.pitches[0] / 4) << 4;
        } else {
                asyw->image.layout = 1;
@@@ -1143,11 -1143,10 +1143,11 @@@ nv50_curs_acquire(struct nv50_wndw *wnd
  {
        int ret;
  
 -      ret = drm_plane_helper_check_state(&asyw->state, &asyw->clip,
 -                                         DRM_PLANE_HELPER_NO_SCALING,
 -                                         DRM_PLANE_HELPER_NO_SCALING,
 -                                         true, true);
 +      ret = drm_atomic_helper_check_plane_state(&asyw->state, &asyh->state,
 +                                                &asyw->clip,
 +                                                DRM_PLANE_HELPER_NO_SCALING,
 +                                                DRM_PLANE_HELPER_NO_SCALING,
 +                                                true, true);
        asyh->curs.visible = asyw->state.visible;
        if (ret || !asyh->curs.visible)
                return ret;
@@@ -1433,11 -1432,10 +1433,11 @@@ nv50_base_acquire(struct nv50_wndw *wnd
        if (!fb->format->depth)
                return -EINVAL;
  
 -      ret = drm_plane_helper_check_state(&asyw->state, &asyw->clip,
 -                                         DRM_PLANE_HELPER_NO_SCALING,
 -                                         DRM_PLANE_HELPER_NO_SCALING,
 -                                         false, true);
 +      ret = drm_atomic_helper_check_plane_state(&asyw->state, &asyh->state,
 +                                                &asyw->clip,
 +                                                DRM_PLANE_HELPER_NO_SCALING,
 +                                                DRM_PLANE_HELPER_NO_SCALING,
 +                                                false, true);
        if (ret)
                return ret;
  
@@@ -2690,6 -2688,7 +2690,6 @@@ nv50_audio_enable(struct drm_encoder *e
        if (!drm_detect_monitor_audio(nv_connector->edid))
                return;
  
 -      drm_edid_to_eld(&nv_connector->base, nv_connector->edid);
        memcpy(args.data, nv_connector->base.eld, sizeof(args.data));
  
        nvif_mthd(disp->disp, 0, &args,
@@@ -3065,8 -3064,10 +3065,8 @@@ nv50_mstc_get_modes(struct drm_connecto
  
        mstc->edid = drm_dp_mst_get_edid(&mstc->connector, mstc->port->mgr, mstc->port);
        drm_mode_connector_update_edid_property(&mstc->connector, mstc->edid);
 -      if (mstc->edid) {
 +      if (mstc->edid)
                ret = drm_add_edid_modes(&mstc->connector, mstc->edid);
 -              drm_edid_to_eld(&mstc->connector, mstc->edid);
 -      }
  
        if (!mstc->connector.display_info.bpc)
                mstc->connector.display_info.bpc = 8;
@@@ -3264,11 -3265,14 +3264,14 @@@ nv50_mstm = 
  void
  nv50_mstm_service(struct nv50_mstm *mstm)
  {
-       struct drm_dp_aux *aux = mstm->mgr.aux;
+       struct drm_dp_aux *aux = mstm ? mstm->mgr.aux : NULL;
        bool handled = true;
        int ret;
        u8 esi[8] = {};
  
+       if (!aux)
+               return;
        while (handled) {
                ret = drm_dp_dpcd_read(aux, DP_SINK_COUNT_ESI, esi, 8);
                if (ret != 8) {
index 0f50c0b25a585fbb3f946fb17e3430eacabd2375,ab48238753118862e4d54d559404f93dc91c9eb1..586ecd6e0e457ec020116c87d065abfc1e5e63a2
@@@ -123,8 -123,11 +123,8 @@@ int qxl_mmap(struct file *filp, struct 
        struct qxl_device *qdev;
        int r;
  
 -      if (unlikely(vma->vm_pgoff < DRM_FILE_PAGE_OFFSET)) {
 -              pr_info("%s: vma->vm_pgoff (%ld) < DRM_FILE_PAGE_OFFSET\n",
 -                      __func__, vma->vm_pgoff);
 +      if (unlikely(vma->vm_pgoff < DRM_FILE_PAGE_OFFSET))
                return -EINVAL;
 -      }
  
        file_priv = filp->private_data;
        qdev = file_priv->minor->dev->dev_private;
                 "filp->private_data->minor->dev->dev_private == NULL\n");
                return -EINVAL;
        }
-       QXL_INFO(qdev, "%s: filp->private_data = 0x%p, vma->vm_pgoff = %lx\n",
-                __func__, filp->private_data, vma->vm_pgoff);
+       DRM_DEBUG_DRIVER("filp->private_data = 0x%p, vma->vm_pgoff = %lx\n",
+                 filp->private_data, vma->vm_pgoff);
  
        r = ttm_bo_mmap(filp, vma, &qdev->mman.bdev);
        if (unlikely(r != 0))
index 9e45127329d76268287f7640d25c10f563345abb,59dcefb2df3bce8b6b914fce5d40d8b064c218e7..5012f5e47a1e599d1758b91957d79925487de260
@@@ -263,7 -263,7 +263,7 @@@ radeon_connector_update_scratch_regs(st
                if (connector->encoder_ids[i] == 0)
                        break;
  
-               encoder = drm_encoder_find(connector->dev,
+               encoder = drm_encoder_find(connector->dev, NULL,
                                           connector->encoder_ids[i]);
                if (!encoder)
                        continue;
@@@ -290,7 -290,7 +290,7 @@@ static struct drm_encoder *radeon_find_
                if (connector->encoder_ids[i] == 0)
                        break;
  
-               encoder = drm_encoder_find(connector->dev, connector->encoder_ids[i]);
+               encoder = drm_encoder_find(connector->dev, NULL, connector->encoder_ids[i]);
                if (!encoder)
                        continue;
  
@@@ -392,6 -392,7 +392,6 @@@ static int radeon_ddc_get_modes(struct 
        if (radeon_connector->edid) {
                drm_mode_connector_update_edid_property(connector, radeon_connector->edid);
                ret = drm_add_edid_modes(connector, radeon_connector->edid);
 -              drm_edid_to_eld(connector, radeon_connector->edid);
                return ret;
        }
        drm_mode_connector_update_edid_property(connector, NULL);
@@@ -403,7 -404,7 +403,7 @@@ static struct drm_encoder *radeon_best_
        int enc_id = connector->encoder_ids[0];
        /* pick the encoder ids */
        if (enc_id)
-               return drm_encoder_find(connector->dev, enc_id);
+               return drm_encoder_find(connector->dev, NULL, enc_id);
        return NULL;
  }
  
@@@ -1367,7 -1368,7 +1367,7 @@@ radeon_dvi_detect(struct drm_connector 
                        if (connector->encoder_ids[i] == 0)
                                break;
  
-                       encoder = drm_encoder_find(connector->dev,
+                       encoder = drm_encoder_find(connector->dev, NULL,
                                                   connector->encoder_ids[i]);
                        if (!encoder)
                                continue;
@@@ -1453,7 -1454,7 +1453,7 @@@ static struct drm_encoder *radeon_dvi_e
                if (connector->encoder_ids[i] == 0)
                        break;
  
-               encoder = drm_encoder_find(connector->dev, connector->encoder_ids[i]);
+               encoder = drm_encoder_find(connector->dev, NULL, connector->encoder_ids[i]);
                if (!encoder)
                        continue;
  
        /* then check use digitial */
        /* pick the first one */
        if (enc_id)
-               return drm_encoder_find(connector->dev, enc_id);
+               return drm_encoder_find(connector->dev, NULL, enc_id);
        return NULL;
  }
  
@@@ -1619,7 -1620,7 +1619,7 @@@ u16 radeon_connector_encoder_get_dp_bri
                if (connector->encoder_ids[i] == 0)
                        break;
  
-               encoder = drm_encoder_find(connector->dev, connector->encoder_ids[i]);
+               encoder = drm_encoder_find(connector->dev, NULL, connector->encoder_ids[i]);
                if (!encoder)
                        continue;
  
@@@ -1648,7 -1649,7 +1648,7 @@@ static bool radeon_connector_encoder_is
                if (connector->encoder_ids[i] == 0)
                        break;
  
-               encoder = drm_encoder_find(connector->dev, connector->encoder_ids[i]);
+               encoder = drm_encoder_find(connector->dev, NULL, connector->encoder_ids[i]);
                if (!encoder)
                        continue;
  
index 39944c0f1c0bec304e0a6aa9bd26033e2244d2ea,93b7102dd008931ee0fbceb1f59e7f60fc292923..1262120a3834114efee27e3b31d26fb8d08346b1
@@@ -72,7 -72,7 +72,7 @@@ struct rockchip_dp_device 
        struct reset_control     *rst;
  
        struct work_struct       psr_work;
-       spinlock_t               psr_lock;
+       struct mutex             psr_lock;
        unsigned int             psr_state;
  
        const struct rockchip_dp_chip_data *data;
  static void analogix_dp_psr_set(struct drm_encoder *encoder, bool enabled)
  {
        struct rockchip_dp_device *dp = to_dp(encoder);
-       unsigned long flags;
  
        if (!analogix_dp_psr_supported(dp->dev))
                return;
  
        DRM_DEV_DEBUG(dp->dev, "%s PSR...\n", enabled ? "Entry" : "Exit");
  
-       spin_lock_irqsave(&dp->psr_lock, flags);
+       mutex_lock(&dp->psr_lock);
        if (enabled)
                dp->psr_state = EDP_VSC_PSR_STATE_ACTIVE;
        else
                dp->psr_state = ~EDP_VSC_PSR_STATE_ACTIVE;
  
        schedule_work(&dp->psr_work);
-       spin_unlock_irqrestore(&dp->psr_lock, flags);
+       mutex_unlock(&dp->psr_lock);
  }
  
  static void analogix_dp_psr_work(struct work_struct *work)
        struct rockchip_dp_device *dp =
                                container_of(work, typeof(*dp), psr_work);
        int ret;
-       unsigned long flags;
  
        ret = rockchip_drm_wait_vact_end(dp->encoder.crtc,
                                         PSR_WAIT_LINE_FLAG_TIMEOUT_MS);
                return;
        }
  
-       spin_lock_irqsave(&dp->psr_lock, flags);
+       mutex_lock(&dp->psr_lock);
        if (dp->psr_state == EDP_VSC_PSR_STATE_ACTIVE)
                analogix_dp_enable_psr(dp->dev);
        else
                analogix_dp_disable_psr(dp->dev);
-       spin_unlock_irqrestore(&dp->psr_lock, flags);
+       mutex_unlock(&dp->psr_lock);
  }
  
  static int rockchip_dp_pre_init(struct rockchip_dp_device *dp)
@@@ -269,10 -267,11 +267,10 @@@ static struct drm_encoder_funcs rockchi
        .destroy = rockchip_dp_drm_encoder_destroy,
  };
  
 -static int rockchip_dp_init(struct rockchip_dp_device *dp)
 +static int rockchip_dp_of_probe(struct rockchip_dp_device *dp)
  {
        struct device *dev = dp->dev;
        struct device_node *np = dev->of_node;
 -      int ret;
  
        dp->grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf");
        if (IS_ERR(dp->grf)) {
                return PTR_ERR(dp->rst);
        }
  
 -      ret = clk_prepare_enable(dp->pclk);
 -      if (ret < 0) {
 -              DRM_DEV_ERROR(dp->dev, "failed to enable pclk %d\n", ret);
 -              return ret;
 -      }
 -
 -      ret = rockchip_dp_pre_init(dp);
 -      if (ret < 0) {
 -              DRM_DEV_ERROR(dp->dev, "failed to pre init %d\n", ret);
 -              clk_disable_unprepare(dp->pclk);
 -              return ret;
 -      }
 -
        return 0;
  }
  
@@@ -347,6 -359,10 +345,6 @@@ static int rockchip_dp_bind(struct devi
        if (!dp_data)
                return -ENODEV;
  
 -      ret = rockchip_dp_init(dp);
 -      if (ret < 0)
 -              return ret;
 -
        dp->data = dp_data;
        dp->drm_dev = drm_dev;
  
        dp->plat_data.power_off = rockchip_dp_powerdown;
        dp->plat_data.get_modes = rockchip_dp_get_modes;
  
-       spin_lock_init(&dp->psr_lock);
+       mutex_init(&dp->psr_lock);
        dp->psr_state = ~EDP_VSC_PSR_STATE_ACTIVE;
        INIT_WORK(&dp->psr_work, analogix_dp_psr_work);
  
@@@ -380,6 -396,7 +378,6 @@@ static void rockchip_dp_unbind(struct d
        rockchip_drm_psr_unregister(&dp->encoder);
  
        analogix_dp_unbind(dev, master, data);
 -      clk_disable_unprepare(dp->pclk);
  }
  
  static const struct component_ops rockchip_dp_component_ops = {
@@@ -395,7 -412,7 +393,7 @@@ static int rockchip_dp_probe(struct pla
        int ret;
  
        ret = drm_of_find_panel_or_bridge(dev->of_node, 1, 0, &panel, NULL);
 -      if (ret)
 +      if (ret < 0)
                return ret;
  
        dp = devm_kzalloc(dev, sizeof(*dp), GFP_KERNEL);
                return -ENOMEM;
  
        dp->dev = dev;
 -
        dp->plat_data.panel = panel;
  
 +      ret = rockchip_dp_of_probe(dp);
 +      if (ret < 0)
 +              return ret;
 +
        /*
         * We just use the drvdata until driver run into component
         * add function, and then we would set drvdata to null, so
index 91919d52b2075e91e91f2acfbcb2276cfec8f8e6,24a5ef4f5bb81e9bffccaf8a968147717c992a88..fc70351b9017a0a916aadb013fb58bd3a490e245
@@@ -10,6 -10,7 +10,7 @@@
  #include <linux/clk.h>
  #include <linux/debugfs.h>
  #include <linux/iommu.h>
+ #include <linux/of_device.h>
  #include <linux/pm_runtime.h>
  #include <linux/reset.h>
  
  #include <drm/drm_atomic_helper.h>
  #include <drm/drm_plane_helper.h>
  
- struct tegra_dc_soc_info {
-       bool supports_border_color;
-       bool supports_interlacing;
-       bool supports_cursor;
-       bool supports_block_linear;
-       unsigned int pitch_align;
-       bool has_powergate;
-       bool broken_reset;
- };
  struct tegra_plane {
        struct drm_plane base;
        unsigned int index;
@@@ -500,8 -491,8 +491,8 @@@ static int tegra_plane_state_add(struc
        clip.y2 = crtc_state->mode.vdisplay;
  
        /* Check plane state for visibility and calculate clipping bounds */
 -      err = drm_plane_helper_check_state(state, &clip, 0, INT_MAX,
 -                                         true, true);
 +      err = drm_atomic_helper_check_plane_state(state, crtc_state, &clip,
 +                                                0, INT_MAX, true, true);
        if (err < 0)
                return err;
  
@@@ -559,14 -550,21 +550,21 @@@ static int tegra_plane_atomic_check(str
        return 0;
  }
  
- static void tegra_dc_disable_window(struct tegra_dc *dc, int index)
+ static void tegra_plane_atomic_disable(struct drm_plane *plane,
+                                      struct drm_plane_state *old_state)
  {
+       struct tegra_dc *dc = to_tegra_dc(old_state->crtc);
+       struct tegra_plane *p = to_tegra_plane(plane);
        unsigned long flags;
        u32 value;
  
+       /* rien ne va plus */
+       if (!old_state || !old_state->crtc)
+               return;
        spin_lock_irqsave(&dc->lock, flags);
  
-       value = WINDOW_A_SELECT << index;
+       value = WINDOW_A_SELECT << p->index;
        tegra_dc_writel(dc, value, DC_CMD_DISPLAY_WINDOW_HEADER);
  
        value = tegra_dc_readl(dc, DC_WIN_WIN_OPTIONS);
@@@ -591,7 -589,7 +589,7 @@@ static void tegra_plane_atomic_update(s
                return;
  
        if (!plane->state->visible)
-               return tegra_dc_disable_window(dc, p->index);
+               return tegra_plane_atomic_disable(plane, old_state);
  
        memset(&window, 0, sizeof(window));
        window.src.x = plane->state->src.x1 >> 16;
        tegra_dc_setup_window(dc, p->index, &window);
  }
  
- static void tegra_plane_atomic_disable(struct drm_plane *plane,
-                                      struct drm_plane_state *old_state)
- {
-       struct tegra_plane *p = to_tegra_plane(plane);
-       struct tegra_dc *dc;
-       /* rien ne va plus */
-       if (!old_state || !old_state->crtc)
-               return;
-       dc = to_tegra_dc(old_state->crtc);
-       tegra_dc_disable_window(dc, p->index);
- }
- static const struct drm_plane_helper_funcs tegra_primary_plane_helper_funcs = {
+ static const struct drm_plane_helper_funcs tegra_plane_helper_funcs = {
        .atomic_check = tegra_plane_atomic_check,
-       .atomic_update = tegra_plane_atomic_update,
        .atomic_disable = tegra_plane_atomic_disable,
+       .atomic_update = tegra_plane_atomic_update,
  };
  
  static struct drm_plane *tegra_dc_primary_plane_create(struct drm_device *drm,
                return ERR_PTR(err);
        }
  
-       drm_plane_helper_add(&plane->base, &tegra_primary_plane_helper_funcs);
+       drm_plane_helper_add(&plane->base, &tegra_plane_helper_funcs);
  
        return &plane->base;
  }
@@@ -880,12 -863,6 +863,6 @@@ static const uint32_t tegra_overlay_pla
        DRM_FORMAT_YUV422,
  };
  
- static const struct drm_plane_helper_funcs tegra_overlay_plane_helper_funcs = {
-       .atomic_check = tegra_plane_atomic_check,
-       .atomic_update = tegra_plane_atomic_update,
-       .atomic_disable = tegra_plane_atomic_disable,
- };
  static struct drm_plane *tegra_dc_overlay_plane_create(struct drm_device *drm,
                                                       struct tegra_dc *dc,
                                                       unsigned int index)
                return ERR_PTR(err);
        }
  
-       drm_plane_helper_add(&plane->base, &tegra_overlay_plane_helper_funcs);
+       drm_plane_helper_add(&plane->base, &tegra_plane_helper_funcs);
  
        return &plane->base;
  }
@@@ -1161,6 -1138,11 +1138,11 @@@ static void tegra_dc_commit_state(struc
  
        value = SHIFT_CLK_DIVIDER(state->div) | PIXEL_CLK_DIVIDER_PCD1;
        tegra_dc_writel(dc, value, DC_DISP_DISP_CLOCK_CONTROL);
+       err = clk_set_rate(dc->clk, state->pclk);
+       if (err < 0)
+               dev_err(dc->dev, "failed to set clock %pC to %lu Hz: %d\n",
+                       dc->clk, state->pclk, err);
  }
  
  static void tegra_dc_stop(struct tegra_dc *dc)
@@@ -1756,7 -1738,7 +1738,7 @@@ static int tegra_dc_init(struct host1x_
        struct drm_plane *cursor = NULL;
        int err;
  
-       dc->syncpt = host1x_syncpt_request(dc->dev, flags);
+       dc->syncpt = host1x_syncpt_request(client, flags);
        if (!dc->syncpt)
                dev_warn(dc->dev, "failed to allocate syncpoint\n");
  
@@@ -1985,7 -1967,6 +1967,6 @@@ static int tegra_dc_parse_dt(struct teg
  
  static int tegra_dc_probe(struct platform_device *pdev)
  {
-       const struct of_device_id *id;
        struct resource *regs;
        struct tegra_dc *dc;
        int err;
        if (!dc)
                return -ENOMEM;
  
-       id = of_match_node(tegra_dc_of_match, pdev->dev.of_node);
-       if (!id)
-               return -ENODEV;
+       dc->soc = of_device_get_match_data(&pdev->dev);
  
        spin_lock_init(&dc->lock);
        INIT_LIST_HEAD(&dc->list);
        dc->dev = &pdev->dev;
-       dc->soc = id->data;
  
        err = tegra_dc_parse_dt(dc);
        if (err < 0)
                return PTR_ERR(dc->rst);
        }
  
-       if (!dc->soc->broken_reset)
-               reset_control_assert(dc->rst);
+       /* assert reset and disable clock */
+       if (!dc->soc->broken_reset) {
+               err = clk_prepare_enable(dc->clk);
+               if (err < 0)
+                       return err;
+               usleep_range(2000, 4000);
+               err = reset_control_assert(dc->rst);
+               if (err < 0)
+                       return err;
+               usleep_range(2000, 4000);
+               clk_disable_unprepare(dc->clk);
+       }
  
        if (dc->soc->has_powergate) {
                if (dc->pipe == 0)
index 1480f6aaffe492f7d33fb8186f9e0e4039e6d3b4,1cfbacea811396c9db03927561e619d43da72b72..24f8a3b712b4afb0fd6ac98afdf285b17c176e40
@@@ -11,6 -11,8 +11,8 @@@
  #include <drm/drm_panel.h>
  #include "drm.h"
  
+ #include <media/cec-notifier.h>
  int tegra_output_connector_get_modes(struct drm_connector *connector)
  {
        struct tegra_output *output = connector_to_output(connector);
        else if (output->ddc)
                edid = drm_get_edid(connector, output->ddc);
  
+       cec_notifier_set_phys_addr_from_edid(output->notifier, edid);
        drm_mode_connector_update_edid_property(connector, edid);
  
        if (edid) {
                err = drm_add_edid_modes(connector, edid);
 -              drm_edid_to_eld(connector, edid);
                kfree(edid);
        }
  
@@@ -67,6 -71,9 +70,9 @@@ tegra_output_connector_detect(struct dr
                        status = connector_status_connected;
        }
  
+       if (status != connector_status_connected)
+               cec_notifier_phys_addr_invalidate(output->notifier);
        return status;
  }
  
index 13ac2c5a04ee112bb097814a621a80fa0f4bde35,0545740b3724f1d6c28b9e1dd169351fdd723949..a2a93d7e2a0420612eadc9070cc3b9ffb61986e0
@@@ -441,23 -441,31 +441,23 @@@ vmw_du_cursor_plane_atomic_update(struc
  int vmw_du_primary_plane_atomic_check(struct drm_plane *plane,
                                      struct drm_plane_state *state)
  {
 +      struct drm_crtc_state *crtc_state = NULL;
        struct drm_framebuffer *new_fb = state->fb;
 -      bool visible;
 -
 -      struct drm_rect src = {
 -              .x1 = state->src_x,
 -              .y1 = state->src_y,
 -              .x2 = state->src_x + state->src_w,
 -              .y2 = state->src_y + state->src_h,
 -      };
 -      struct drm_rect dest = {
 -              .x1 = state->crtc_x,
 -              .y1 = state->crtc_y,
 -              .x2 = state->crtc_x + state->crtc_w,
 -              .y2 = state->crtc_y + state->crtc_h,
 -      };
 -      struct drm_rect clip = dest;
 +      struct drm_rect clip = {};
        int ret;
  
 -      ret = drm_plane_helper_check_update(plane, state->crtc, new_fb,
 -                                          &src, &dest, &clip,
 -                                          DRM_MODE_ROTATE_0,
 -                                          DRM_PLANE_HELPER_NO_SCALING,
 -                                          DRM_PLANE_HELPER_NO_SCALING,
 -                                          false, true, &visible);
 +      if (state->crtc)
 +              crtc_state = drm_atomic_get_new_crtc_state(state->state, state->crtc);
  
 +      if (crtc_state && crtc_state->enable) {
 +              clip.x2 = crtc_state->adjusted_mode.hdisplay;
 +              clip.y2 = crtc_state->adjusted_mode.vdisplay;
 +      }
 +
 +      ret = drm_atomic_helper_check_plane_state(state, crtc_state, &clip,
 +                                                DRM_PLANE_HELPER_NO_SCALING,
 +                                                DRM_PLANE_HELPER_NO_SCALING,
 +                                                false, true);
  
        if (!ret && new_fb) {
                struct drm_crtc *crtc = state->crtc;
  
                vcs = vmw_connector_state_to_vcs(du->connector.state);
  
 -              if ((dest.x2 > new_fb->width ||
 -                   dest.y2 > new_fb->height)) {
 -                      DRM_ERROR("CRTC area outside of framebuffer\n");
 -                      return -EINVAL;
 -              }
 -
                /* Only one active implicit framebuffer at a time. */
                mutex_lock(&dev_priv->global_kms_state_mutex);
                if (vcs->is_implicit && dev_priv->implicit_fb &&
@@@ -1712,7 -1726,7 +1712,7 @@@ int vmw_kms_cursor_bypass_ioctl(struct 
                return 0;
        }
  
-       crtc = drm_crtc_find(dev, arg->crtc_id);
+       crtc = drm_crtc_find(dev, file_priv, arg->crtc_id);
        if (!crtc) {
                ret = -ENOENT;
                goto out;
index b81b7fb846f9bfca0fc95aec44ed509c328187a0,7a714054301226ffe34de6e22b43e38bd1979ea1..2b97d1e28f6029e69e08bb854ce40859d7b76b01
@@@ -699,6 -699,7 +699,6 @@@ struct drm_cmdline_mode 
   * @force: a DRM_FORCE_<foo> state for forced mode sets
   * @override_edid: has the EDID been overwritten through debugfs for testing?
   * @encoder_ids: valid encoders for this connector
 - * @encoder: encoder driving this connector, if any
   * @eld: EDID-like data, if present
   * @latency_present: AV delay info from ELD, if found
   * @video_latency: video latency info from ELD, if found
@@@ -868,13 -869,7 +868,13 @@@ struct drm_connector 
  
  #define DRM_CONNECTOR_MAX_ENCODER 3
        uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER];
 -      struct drm_encoder *encoder; /* currently active encoder */
 +      /**
 +       * @encoder: Currently bound encoder driving this connector, if any.
 +       * Only really meaningful for non-atomic drivers. Atomic drivers should
 +       * instead look at &drm_connector_state.best_encoder, and in case they
 +       * need the CRTC driving this output, &drm_connector_state.crtc.
 +       */
 +      struct drm_encoder *encoder;
  
  #define MAX_ELD_BYTES 128
        /* EDID bits */
@@@ -938,16 -933,18 +938,18 @@@ static inline unsigned drm_connector_in
  /**
   * drm_connector_lookup - lookup connector object
   * @dev: DRM device
+  * @file_priv: drm file to check for lease against.
   * @id: connector object id
   *
   * This function looks up the connector object specified by id
   * add takes a reference to it.
   */
  static inline struct drm_connector *drm_connector_lookup(struct drm_device *dev,
+               struct drm_file *file_priv,
                uint32_t id)
  {
        struct drm_mode_object *mo;
-       mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_CONNECTOR);
+       mo = drm_mode_object_find(dev, file_priv, id, DRM_MODE_OBJECT_CONNECTOR);
        return mo ? obj_to_connector(mo) : NULL;
  }
  
index d9bcc0861fba83fc809266c1655704a6e88cfcff,8b9ac321c3bdb059954a30cd49a7d383a54293ee..9049ef133d692536c175a11fb56e3f3ef7585260
  # define DP_SET_POWER_D0                    0x1
  # define DP_SET_POWER_D3                    0x2
  # define DP_SET_POWER_MASK                  0x3
 +# define DP_SET_POWER_D3_AUX_ON             0x5
  
  #define DP_EDP_DPCD_REV                           0x700    /* eDP 1.2 */
  # define DP_EDP_11                        0x00
  # define DP_PSR_SINK_INTERNAL_ERROR         7
  # define DP_PSR_SINK_STATE_MASK             0x07
  
+ #define DP_SYNCHRONIZATION_LATENCY_IN_SINK            0x2009 /* edp 1.4 */
+ # define DP_MAX_RESYNC_FRAME_COUNT_MASK                       (0xf << 0)
+ # define DP_MAX_RESYNC_FRAME_COUNT_SHIFT              0
+ # define DP_LAST_ACTUAL_SYNCHRONIZATION_LATENCY_MASK  (0xf << 4)
+ # define DP_LAST_ACTUAL_SYNCHRONIZATION_LATENCY_SHIFT 4
  #define DP_RECEIVER_ALPM_STATUS                   0x200b  /* eDP 1.4 */
  # define DP_ALPM_LOCK_TIMEOUT_ERROR       (1 << 0)
  
diff --combined include/drm/drm_drv.h
index 1536e5bddeaf037def4526deae228c88a41323cb,412e83a4d3dba895355b6813f0e9410a7eeecef4..d32b688eb346c9252eb66d73be49fdd477e290de
@@@ -39,7 -39,6 +39,7 @@@ struct drm_minor
  struct dma_buf_attachment;
  struct drm_display_mode;
  struct drm_mode_create_dumb;
 +struct drm_printer;
  
  /* driver capabilities and requirements mask */
  #define DRIVER_USE_AGP                        0x1
@@@ -325,7 -324,7 +325,7 @@@ struct drm_driver 
         */
        bool (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
                                     int *max_error,
-                                    struct timeval *vblank_time,
+                                    ktime_t *vblank_time,
                                     bool in_vblank_irq);
  
        /**
         */
        void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
  
 +      /**
 +       * @gem_print_info:
 +       *
 +       * If driver subclasses struct &drm_gem_object, it can implement this
 +       * optional hook for printing additional driver specific info.
 +       *
 +       * drm_printf_indent() should be used in the callback passing it the
 +       * indent argument.
 +       *
 +       * This callback is called from drm_gem_print_info().
 +       */
 +      void (*gem_print_info)(struct drm_printer *p, unsigned int indent,
 +                             const struct drm_gem_object *obj);
 +
        /**
         * @gem_create_object: constructor for gem objects
         *
        int dev_priv_size;
  };
  
 -__printf(6, 7)
 -void drm_dev_printk(const struct device *dev, const char *level,
 -                  unsigned int category, const char *function_name,
 -                  const char *prefix, const char *format, ...);
 -__printf(3, 4)
 -void drm_printk(const char *level, unsigned int category,
 -              const char *format, ...);
  extern unsigned int drm_debug;
  
  int drm_dev_init(struct drm_device *dev,
index c3ca2278ea6e35e109e73e032a290541d4f335a3,ee4cfbe63c5207bced753654687b50dd5e208651..fb299696c7c417a24f953faaeb6cfd55b57833ed
@@@ -88,6 -88,7 +88,6 @@@ struct drm_encoder_funcs 
   * @head: list management
   * @base: base KMS object
   * @name: human readable name, can be overwritten by the driver
 - * @crtc: currently bound CRTC
   * @bridge: bridge associated to the encoder
   * @funcs: control functions
   * @helper_private: mid-layer private data
@@@ -165,11 -166,6 +165,11 @@@ struct drm_encoder 
         */
        uint32_t possible_clones;
  
 +      /**
 +       * @crtc: Currently bound CRTC, only really meaningful for non-atomic
 +       * drivers.  Atomic drivers should instead check
 +       * &drm_connector_state.crtc.
 +       */
        struct drm_crtc *crtc;
        struct drm_bridge *bridge;
        const struct drm_encoder_funcs *funcs;
@@@ -212,17 -208,19 +212,19 @@@ static inline bool drm_encoder_crtc_ok(
  /**
   * drm_encoder_find - find a &drm_encoder
   * @dev: DRM device
+  * @file_priv: drm file to check for lease against.
   * @id: encoder id
   *
   * Returns the encoder with @id, NULL if it doesn't exist. Simple wrapper around
   * drm_mode_object_find().
   */
  static inline struct drm_encoder *drm_encoder_find(struct drm_device *dev,
+                                                  struct drm_file *file_priv,
                                                   uint32_t id)
  {
        struct drm_mode_object *mo;
  
-       mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_ENCODER);
+       mo = drm_mode_object_find(dev, file_priv, id, DRM_MODE_OBJECT_ENCODER);
  
        return mo ? obj_to_encoder(mo) : NULL;
  }
index 6cce22e1a0f2718eb822fb114f6bcb9b74111a18,4c5ee4ae54dfa73dc4ae47d65a4913254c892d73..dccb897951bada497603e41f6bb21ec02687a72e
@@@ -205,6 -205,7 +205,7 @@@ int drm_framebuffer_init(struct drm_dev
                         struct drm_framebuffer *fb,
                         const struct drm_framebuffer_funcs *funcs);
  struct drm_framebuffer *drm_framebuffer_lookup(struct drm_device *dev,
+                                              struct drm_file *file_priv,
                                               uint32_t id);
  void drm_framebuffer_remove(struct drm_framebuffer *fb);
  void drm_framebuffer_cleanup(struct drm_framebuffer *fb);
@@@ -263,7 -264,7 +264,7 @@@ static inline void drm_framebuffer_unre
   *
   * This functions returns the framebuffer's reference count.
   */
 -static inline uint32_t drm_framebuffer_read_refcount(struct drm_framebuffer *fb)
 +static inline uint32_t drm_framebuffer_read_refcount(const struct drm_framebuffer *fb)
  {
        return kref_read(&fb->base.refcount);
  }
index 6040c4b73e6d51589da43b96aa8ba7ad6b6a2624,0b4ac2ebc6105a0f3d9f364c7bf83eeee2928ad4..cf73c5eaab9808790b9bf432b5c762579a99d46e
@@@ -429,19 -429,6 +429,6 @@@ struct drm_mode_config 
         */
        struct list_head encoder_list;
  
-       /**
-        * @num_overlay_plane:
-        *
-        * Number of overlay planes on this device, excluding primary and cursor
-        * planes.
-        *
-        * Track number of overlay planes separately from number of total
-        * planes.  By default we only advertise overlay planes to userspace; if
-        * userspace sets the "universal plane" capability bit, we'll go ahead
-        * and expose all planes. This is invariant over the lifetime of a
-        * device and hence doesn't need any locks.
-        */
-       int num_overlay_plane;
        /**
         * @num_total_plane:
         *
        bool allow_fb_modifiers;
  
        /**
 -       * @modifiers: Plane property to list support modifier/format
 +       * @modifiers_property: Plane property to list support modifier/format
         * combination.
         */
        struct drm_property *modifiers_property;
diff --combined include/drm/drm_plane.h
index c062d797b9f99b9bb6ba7974553294b1f56c66d3,5716150792307d18f8cf276ae6ce09eacb0d6956..8185e3468a23167cb2fd4a506214b635ecec53da
@@@ -474,8 -474,8 +474,8 @@@ enum drm_plane_type 
   * @format_types: array of formats supported by this plane
   * @format_count: number of formats supported
   * @format_default: driver hasn't supplied supported formats for the plane
 - * @crtc: currently bound CRTC
 - * @fb: currently bound fb
 + * @modifiers: array of modifiers supported by this plane
 + * @modifier_count: number of modifiers supported
   * @old_fb: Temporary tracking of the old fb while a modeset is ongoing. Used by
   *    drm_mode_set_config_internal() to implement correct refcounting.
   * @funcs: helper functions
@@@ -512,17 -512,7 +512,17 @@@ struct drm_plane 
        uint64_t *modifiers;
        unsigned int modifier_count;
  
 +      /**
 +       * @crtc: Currently bound CRTC, only really meaningful for non-atomic
 +       * drivers.  Atomic drivers should instead check &drm_plane_state.crtc.
 +       */
        struct drm_crtc *crtc;
 +
 +      /**
 +       * @fb: Currently bound framebuffer, only really meaningful for
 +       * non-atomic drivers.  Atomic drivers should instead check
 +       * &drm_plane_state.fb.
 +       */
        struct drm_framebuffer *fb;
  
        struct drm_framebuffer *old_fb;
@@@ -601,16 -591,18 +601,18 @@@ int drm_mode_plane_set_obj_prop(struct 
  /**
   * drm_plane_find - find a &drm_plane
   * @dev: DRM device
+  * @file_priv: drm file to check for lease against.
   * @id: plane id
   *
   * Returns the plane with @id, NULL if it doesn't exist. Simple wrapper around
   * drm_mode_object_find().
   */
  static inline struct drm_plane *drm_plane_find(struct drm_device *dev,
+               struct drm_file *file_priv,
                uint32_t id)
  {
        struct drm_mode_object *mo;
-       mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_PLANE);
+       mo = drm_mode_object_find(dev, file_priv, id, DRM_MODE_OBJECT_PLANE);
        return mo ? obj_to_plane(mo) : NULL;
  }
  
diff --combined include/drm/drm_print.h
index 7dbfdebec973e09cb0ac1448ab3ddf6e248d5452,ca4d7c6321f28fcea1286720f2da65a2db0395cf..0968e411f56274f8e4c1be7ae8ab39458da17266
@@@ -80,14 -80,6 +80,14 @@@ void __drm_printfn_debug(struct drm_pri
  __printf(2, 3)
  void drm_printf(struct drm_printer *p, const char *f, ...);
  
 +/**
 + * drm_printf_indent - Print to a &drm_printer stream with indentation
 + * @printer: DRM printer
 + * @indent: Tab indentation level (max 5)
 + * @fmt: Format string
 + */
 +#define drm_printf_indent(printer, indent, fmt, ...) \
 +      drm_printf((printer), "%.*s" fmt, (indent), "\t\t\t\t\tX", ##__VA_ARGS__)
  
  /**
   * drm_seq_file_printer - construct a &drm_printer that outputs to &seq_file
@@@ -136,196 -128,4 +136,200 @@@ static inline struct drm_printer drm_de
        };
        return p;
  }
 +
 +/*
 + * The following categories are defined:
 + *
 + * CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, drm_memory.c, ...
 + *     This is the category used by the DRM_DEBUG() macro.
 + *
 + * DRIVER: Used in the vendor specific part of the driver: i915, radeon, ...
 + *       This is the category used by the DRM_DEBUG_DRIVER() macro.
 + *
 + * KMS: used in the modesetting code.
 + *    This is the category used by the DRM_DEBUG_KMS() macro.
 + *
 + * PRIME: used in the prime code.
 + *      This is the category used by the DRM_DEBUG_PRIME() macro.
 + *
 + * ATOMIC: used in the atomic code.
 + *      This is the category used by the DRM_DEBUG_ATOMIC() macro.
 + *
 + * VBL: used for verbose debug message in the vblank code
 + *      This is the category used by the DRM_DEBUG_VBL() macro.
 + *
 + * Enabling verbose debug messages is done through the drm.debug parameter,
 + * each category being enabled by a bit.
 + *
 + * drm.debug=0x1 will enable CORE messages
 + * drm.debug=0x2 will enable DRIVER messages
 + * drm.debug=0x3 will enable CORE and DRIVER messages
 + * ...
 + * drm.debug=0x3f will enable all messages
 + *
 + * An interesting feature is that it's possible to enable verbose logging at
 + * run-time by echoing the debug value in its sysfs node:
 + *   # echo 0xf > /sys/module/drm/parameters/debug
 + */
 +#define DRM_UT_NONE           0x00
 +#define DRM_UT_CORE           0x01
 +#define DRM_UT_DRIVER         0x02
 +#define DRM_UT_KMS            0x04
 +#define DRM_UT_PRIME          0x08
 +#define DRM_UT_ATOMIC         0x10
 +#define DRM_UT_VBL            0x20
 +#define DRM_UT_STATE          0x40
++#define DRM_UT_LEASE          0x80
 +
 +__printf(6, 7)
 +void drm_dev_printk(const struct device *dev, const char *level,
 +                  unsigned int category, const char *function_name,
 +                  const char *prefix, const char *format, ...);
 +__printf(3, 4)
 +void drm_printk(const char *level, unsigned int category,
 +              const char *format, ...);
 +
 +/* Macros to make printk easier */
 +
 +#define _DRM_PRINTK(once, level, fmt, ...)                            \
 +      do {                                                            \
 +              printk##once(KERN_##level "[" DRM_NAME "] " fmt,        \
 +                           ##__VA_ARGS__);                            \
 +      } while (0)
 +
 +#define DRM_INFO(fmt, ...)                                            \
 +      _DRM_PRINTK(, INFO, fmt, ##__VA_ARGS__)
 +#define DRM_NOTE(fmt, ...)                                            \
 +      _DRM_PRINTK(, NOTICE, fmt, ##__VA_ARGS__)
 +#define DRM_WARN(fmt, ...)                                            \
 +      _DRM_PRINTK(, WARNING, fmt, ##__VA_ARGS__)
 +
 +#define DRM_INFO_ONCE(fmt, ...)                                               \
 +      _DRM_PRINTK(_once, INFO, fmt, ##__VA_ARGS__)
 +#define DRM_NOTE_ONCE(fmt, ...)                                               \
 +      _DRM_PRINTK(_once, NOTICE, fmt, ##__VA_ARGS__)
 +#define DRM_WARN_ONCE(fmt, ...)                                               \
 +      _DRM_PRINTK(_once, WARNING, fmt, ##__VA_ARGS__)
 +
 +/**
 + * Error output.
 + *
 + * @dev: device pointer
 + * @fmt: printf() like format string.
 + */
 +#define DRM_DEV_ERROR(dev, fmt, ...)                                  \
 +      drm_dev_printk(dev, KERN_ERR, DRM_UT_NONE, __func__, " *ERROR*",\
 +                     fmt, ##__VA_ARGS__)
 +#define DRM_ERROR(fmt, ...)                                           \
 +      drm_printk(KERN_ERR, DRM_UT_NONE, fmt,  ##__VA_ARGS__)
 +
 +/**
 + * Rate limited error output.  Like DRM_ERROR() but won't flood the log.
 + *
 + * @dev: device pointer
 + * @fmt: printf() like format string.
 + */
 +#define DRM_DEV_ERROR_RATELIMITED(dev, fmt, ...)                      \
 +({                                                                    \
 +      static DEFINE_RATELIMIT_STATE(_rs,                              \
 +                                    DEFAULT_RATELIMIT_INTERVAL,       \
 +                                    DEFAULT_RATELIMIT_BURST);         \
 +                                                                      \
 +      if (__ratelimit(&_rs))                                          \
 +              DRM_DEV_ERROR(dev, fmt, ##__VA_ARGS__);                 \
 +})
 +#define DRM_ERROR_RATELIMITED(fmt, ...)                                       \
 +      DRM_DEV_ERROR_RATELIMITED(NULL, fmt, ##__VA_ARGS__)
 +
 +#define DRM_DEV_INFO(dev, fmt, ...)                                   \
 +      drm_dev_printk(dev, KERN_INFO, DRM_UT_NONE, __func__, "", fmt,  \
 +                     ##__VA_ARGS__)
 +
 +#define DRM_DEV_INFO_ONCE(dev, fmt, ...)                              \
 +({                                                                    \
 +      static bool __print_once __read_mostly;                         \
 +      if (!__print_once) {                                            \
 +              __print_once = true;                                    \
 +              DRM_DEV_INFO(dev, fmt, ##__VA_ARGS__);                  \
 +      }                                                               \
 +})
 +
 +/**
 + * Debug output.
 + *
 + * @dev: device pointer
 + * @fmt: printf() like format string.
 + */
 +#define DRM_DEV_DEBUG(dev, fmt, args...)                              \
 +      drm_dev_printk(dev, KERN_DEBUG, DRM_UT_CORE, __func__, "", fmt, \
 +                     ##args)
 +#define DRM_DEBUG(fmt, ...)                                           \
 +      drm_printk(KERN_DEBUG, DRM_UT_CORE, fmt, ##__VA_ARGS__)
 +
 +#define DRM_DEV_DEBUG_DRIVER(dev, fmt, args...)                               \
 +      drm_dev_printk(dev, KERN_DEBUG, DRM_UT_DRIVER, __func__, "",    \
 +                     fmt, ##args)
 +#define DRM_DEBUG_DRIVER(fmt, ...)                                    \
 +      drm_printk(KERN_DEBUG, DRM_UT_DRIVER, fmt, ##__VA_ARGS__)
 +
 +#define DRM_DEV_DEBUG_KMS(dev, fmt, args...)                          \
 +      drm_dev_printk(dev, KERN_DEBUG, DRM_UT_KMS, __func__, "", fmt,  \
 +                     ##args)
 +#define DRM_DEBUG_KMS(fmt, ...)                                       \
 +      drm_printk(KERN_DEBUG, DRM_UT_KMS, fmt, ##__VA_ARGS__)
 +
 +#define DRM_DEV_DEBUG_PRIME(dev, fmt, args...)                                \
 +      drm_dev_printk(dev, KERN_DEBUG, DRM_UT_PRIME, __func__, "",     \
 +                     fmt, ##args)
 +#define DRM_DEBUG_PRIME(fmt, ...)                                     \
 +      drm_printk(KERN_DEBUG, DRM_UT_PRIME, fmt, ##__VA_ARGS__)
 +
 +#define DRM_DEV_DEBUG_ATOMIC(dev, fmt, args...)                               \
 +      drm_dev_printk(dev, KERN_DEBUG, DRM_UT_ATOMIC, __func__, "",    \
 +                     fmt, ##args)
 +#define DRM_DEBUG_ATOMIC(fmt, ...)                                    \
 +      drm_printk(KERN_DEBUG, DRM_UT_ATOMIC, fmt, ##__VA_ARGS__)
 +
 +#define DRM_DEV_DEBUG_VBL(dev, fmt, args...)                          \
 +      drm_dev_printk(dev, KERN_DEBUG, DRM_UT_VBL, __func__, "", fmt,  \
 +                     ##args)
 +#define DRM_DEBUG_VBL(fmt, ...)                                       \
 +      drm_printk(KERN_DEBUG, DRM_UT_VBL, fmt, ##__VA_ARGS__)
 +
++#define DRM_DEBUG_LEASE(fmt, ...)                                     \
++      drm_printk(KERN_DEBUG, DRM_UT_LEASE, fmt, ##__VA_ARGS__)
++
 +#define _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, level, fmt, args...)   \
 +({                                                                    \
 +      static DEFINE_RATELIMIT_STATE(_rs,                              \
 +                                    DEFAULT_RATELIMIT_INTERVAL,       \
 +                                    DEFAULT_RATELIMIT_BURST);         \
 +      if (__ratelimit(&_rs))                                          \
 +              drm_dev_printk(dev, KERN_DEBUG, DRM_UT_ ## level,       \
 +                             __func__, "", fmt, ##args);              \
 +})
 +
 +/**
 + * Rate limited debug output. Like DRM_DEBUG() but won't flood the log.
 + *
 + * @dev: device pointer
 + * @fmt: printf() like format string.
 + */
 +#define DRM_DEV_DEBUG_RATELIMITED(dev, fmt, args...)                  \
 +      DEV__DRM_DEFINE_DEBUG_RATELIMITED(dev, CORE, fmt, ##args)
 +#define DRM_DEBUG_RATELIMITED(fmt, args...)                           \
 +      DRM_DEV_DEBUG_RATELIMITED(NULL, fmt, ##args)
 +#define DRM_DEV_DEBUG_DRIVER_RATELIMITED(dev, fmt, args...)           \
 +      _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, DRIVER, fmt, ##args)
 +#define DRM_DEBUG_DRIVER_RATELIMITED(fmt, args...)                    \
 +      DRM_DEV_DEBUG_DRIVER_RATELIMITED(NULL, fmt, ##args)
 +#define DRM_DEV_DEBUG_KMS_RATELIMITED(dev, fmt, args...)              \
 +      _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, KMS, fmt, ##args)
 +#define DRM_DEBUG_KMS_RATELIMITED(fmt, args...)                               \
 +      DRM_DEV_DEBUG_KMS_RATELIMITED(NULL, fmt, ##args)
 +#define DRM_DEV_DEBUG_PRIME_RATELIMITED(dev, fmt, args...)            \
 +      _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, PRIME, fmt, ##args)
 +#define DRM_DEBUG_PRIME_RATELIMITED(fmt, args...)                     \
 +      DRM_DEV_DEBUG_PRIME_RATELIMITED(NULL, fmt, ##args)
 +
  #endif /* DRM_PRINT_H_ */
index 4556606732599b7034f7085e612fcae24e7df3ac,43e2f382d2f0ab9c7571c385bde82373eb898088..9e8ba90c6784a23a2ac4c52523290b0b289bc82c
@@@ -49,7 -49,7 +49,7 @@@ struct drm_syncobj 
         * This field should not be used directly.  Use drm_syncobj_fence_get
         * and drm_syncobj_replace_fence instead.
         */
 -      struct dma_fence *fence;
 +      struct dma_fence __rcu *fence;
        /**
         * @cb_list:
         * List of callbacks to call when the fence gets replaced
@@@ -136,5 -136,10 +136,10 @@@ int drm_syncobj_find_fence(struct drm_f
                           u32 handle,
                           struct dma_fence **fence);
  void drm_syncobj_free(struct kref *kref);
+ int drm_syncobj_create(struct drm_syncobj **out_syncobj, uint32_t flags,
+                      struct dma_fence *fence);
+ int drm_syncobj_get_handle(struct drm_file *file_private,
+                          struct drm_syncobj *syncobj, u32 *handle);
+ int drm_syncobj_get_fd(struct drm_syncobj *syncobj, int *p_fd);
  
  #endif