Merge drm/drm-next into drm-misc-next
authorSean Paul <seanpaul@chromium.org>
Mon, 27 Aug 2018 14:00:03 +0000 (10:00 -0400)
committerSean Paul <seanpaul@chromium.org>
Mon, 27 Aug 2018 14:00:03 +0000 (10:00 -0400)
Now that 4.19-rc1 is cut, backmerge it into -misc-next.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
12 files changed:
1  2 
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c
drivers/gpu/drm/drm_atomic_helper.c
drivers/gpu/drm/gma500/psb_drv.h
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_drv.h
drivers/gpu/drm/i915/intel_pipe_crc.c
drivers/gpu/drm/vc4/vc4_plane.c
drivers/gpu/drm/vkms/vkms_drv.c
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
include/drm/drm_print.h
include/uapi/drm/drm_fourcc.h

index a5c1617e55c528e923eed2454cc632e1dc2b7982,800f481a6995fce0129bb316e078d2dcd8ab9eeb..11d6dd23eeb874d7dcaf633139192b77db9aa36c
@@@ -39,6 -39,9 +39,9 @@@
  #include "dm_helpers.h"
  #include "dm_services_types.h"
  #include "amdgpu_dm_mst_types.h"
+ #if defined(CONFIG_DEBUG_FS)
+ #include "amdgpu_dm_debugfs.h"
+ #endif
  
  #include "ivsrcid/ivsrcid_vislands30.h"
  
@@@ -55,8 -58,6 +58,6 @@@
  #include <drm/drm_fb_helper.h>
  #include <drm/drm_edid.h>
  
- #include "modules/inc/mod_freesync.h"
  #if defined(CONFIG_DRM_AMD_DC_DCN1_0)
  #include "ivsrcid/irqsrcs_dcn_1_0.h"
  
@@@ -1038,7 -1039,7 +1039,7 @@@ static void handle_hpd_rx_irq(void *par
        if (dc_link->type != dc_connection_mst_branch)
                mutex_lock(&aconnector->hpd_lock);
  
-       if (dc_link_handle_hpd_rx_irq(dc_link, NULL) &&
+       if (dc_link_handle_hpd_rx_irq(dc_link, NULL, NULL) &&
                        !is_mst_root_connector) {
                /* Downstream Port status changed. */
                if (dc_link_detect(dc_link, DETECT_REASON_HPDRX)) {
@@@ -1317,7 -1318,12 +1318,12 @@@ static int amdgpu_dm_backlight_update_s
  
  static int amdgpu_dm_backlight_get_brightness(struct backlight_device *bd)
  {
-       return bd->props.brightness;
+       struct amdgpu_display_manager *dm = bl_get_data(bd);
+       int ret = dc_link_get_backlight_level(dm->backlight_link);
+       if (ret == DC_ERROR_UNEXPECTED)
+               return bd->props.brightness;
+       return ret;
  }
  
  static const struct backlight_ops amdgpu_dm_backlight_ops = {
@@@ -1332,6 -1338,7 +1338,7 @@@ amdgpu_dm_register_backlight_device(str
        struct backlight_properties props = { 0 };
  
        props.max_brightness = AMDGPU_MAX_BL_LEVEL;
+       props.brightness = AMDGPU_MAX_BL_LEVEL;
        props.type = BACKLIGHT_RAW;
  
        snprintf(bl_name, sizeof(bl_name), "amdgpu_bl%d",
@@@ -1529,10 -1536,6 +1536,6 @@@ static int amdgpu_dm_initialize_drm_dev
                        DRM_ERROR("DM: Failed to initialize IRQ\n");
                        goto fail;
                }
-               /*
-                * Temporary disable until pplib/smu interaction is implemented
-                */
-               dm->dc->debug.disable_stutter = true;
                break;
  #endif
        default:
                goto fail;
        }
  
+       if (adev->asic_type != CHIP_CARRIZO && adev->asic_type != CHIP_STONEY)
+               dm->dc->debug.disable_stutter = amdgpu_pp_feature_mask & PP_STUTTER_MODE ? false : true;
        return 0;
  fail:
        kfree(aencoder);
@@@ -1571,18 -1577,6 +1577,6 @@@ static void dm_bandwidth_update(struct 
        /* TODO: implement later */
  }
  
- static void dm_set_backlight_level(struct amdgpu_encoder *amdgpu_encoder,
-                                    u8 level)
- {
-       /* TODO: translate amdgpu_encoder to display_index and call DAL */
- }
- static u8 dm_get_backlight_level(struct amdgpu_encoder *amdgpu_encoder)
- {
-       /* TODO: translate amdgpu_encoder to display_index and call DAL */
-       return 0;
- }
  static int amdgpu_notify_freesync(struct drm_device *dev, void *data,
                                struct drm_file *filp)
  {
  static const struct amdgpu_display_funcs dm_display_funcs = {
        .bandwidth_update = dm_bandwidth_update, /* called unconditionally */
        .vblank_get_counter = dm_vblank_get_counter,/* called unconditionally */
-       .backlight_set_level =
-               dm_set_backlight_level,/* called unconditionally */
-       .backlight_get_level =
-               dm_get_backlight_level,/* called unconditionally */
+       .backlight_set_level = NULL, /* never called for DC */
+       .backlight_get_level = NULL, /* never called for DC */
        .hpd_sense = NULL,/* called unconditionally */
        .hpd_set_polarity = NULL, /* called unconditionally */
        .hpd_get_gpio_reg = NULL, /* VBIOS parsing. DAL does it. */
@@@ -2121,13 -2113,8 +2113,8 @@@ convert_color_depth_from_display_info(c
  static enum dc_aspect_ratio
  get_aspect_ratio(const struct drm_display_mode *mode_in)
  {
-       int32_t width = mode_in->crtc_hdisplay * 9;
-       int32_t height = mode_in->crtc_vdisplay * 16;
-       if ((width - height) < 10 && (width - height) > -10)
-               return ASPECT_RATIO_16_9;
-       else
-               return ASPECT_RATIO_4_3;
+       /* 1-1 mapping, since both enums follow the HDMI spec. */
+       return (enum dc_aspect_ratio) mode_in->picture_aspect_ratio;
  }
  
  static enum dc_color_space
@@@ -2173,6 -2160,46 +2160,46 @@@ get_output_color_space(const struct dc_
        return color_space;
  }
  
+ static void reduce_mode_colour_depth(struct dc_crtc_timing *timing_out)
+ {
+       if (timing_out->display_color_depth <= COLOR_DEPTH_888)
+               return;
+       timing_out->display_color_depth--;
+ }
+ static void adjust_colour_depth_from_display_info(struct dc_crtc_timing *timing_out,
+                                               const struct drm_display_info *info)
+ {
+       int normalized_clk;
+       if (timing_out->display_color_depth <= COLOR_DEPTH_888)
+               return;
+       do {
+               normalized_clk = timing_out->pix_clk_khz;
+               /* YCbCr 4:2:0 requires additional adjustment of 1/2 */
+               if (timing_out->pixel_encoding == PIXEL_ENCODING_YCBCR420)
+                       normalized_clk /= 2;
+               /* Adjusting pix clock following on HDMI spec based on colour depth */
+               switch (timing_out->display_color_depth) {
+               case COLOR_DEPTH_101010:
+                       normalized_clk = (normalized_clk * 30) / 24;
+                       break;
+               case COLOR_DEPTH_121212:
+                       normalized_clk = (normalized_clk * 36) / 24;
+                       break;
+               case COLOR_DEPTH_161616:
+                       normalized_clk = (normalized_clk * 48) / 24;
+                       break;
+               default:
+                       return;
+               }
+               if (normalized_clk <= info->max_tmds_clock)
+                       return;
+               reduce_mode_colour_depth(timing_out);
+       } while (timing_out->display_color_depth > COLOR_DEPTH_888);
+ }
  /*****************************************************************************/
  
  static void
@@@ -2181,6 -2208,7 +2208,7 @@@ fill_stream_properties_from_drm_display
                                             const struct drm_connector *connector)
  {
        struct dc_crtc_timing *timing_out = &stream->timing;
+       const struct drm_display_info *info = &connector->display_info;
  
        memset(timing_out, 0, sizeof(struct dc_crtc_timing));
  
        timing_out->v_border_top = 0;
        timing_out->v_border_bottom = 0;
        /* TODO: un-hardcode */
-       if ((connector->display_info.color_formats & DRM_COLOR_FORMAT_YCRCB444)
+       if (drm_mode_is_420_only(info, mode_in)
+                       && stream->sink->sink_signal == SIGNAL_TYPE_HDMI_TYPE_A)
+               timing_out->pixel_encoding = PIXEL_ENCODING_YCBCR420;
+       else if ((connector->display_info.color_formats & DRM_COLOR_FORMAT_YCRCB444)
                        && stream->sink->sink_signal == SIGNAL_TYPE_HDMI_TYPE_A)
                timing_out->pixel_encoding = PIXEL_ENCODING_YCBCR444;
        else
  
        stream->out_transfer_func->type = TF_TYPE_PREDEFINED;
        stream->out_transfer_func->tf = TRANSFER_FUNCTION_SRGB;
+       if (stream->sink->sink_signal == SIGNAL_TYPE_HDMI_TYPE_A)
+               adjust_colour_depth_from_display_info(timing_out, info);
  }
  
  static void fill_audio_info(struct audio_info *audio_info,
@@@ -2563,7 -2595,6 +2595,7 @@@ static const struct drm_crtc_funcs amdg
        .atomic_duplicate_state = dm_crtc_duplicate_state,
        .atomic_destroy_state = dm_crtc_destroy_state,
        .set_crc_source = amdgpu_dm_crtc_set_crc_source,
 +      .verify_crc_source = amdgpu_dm_crtc_verify_crc_source,
        .enable_vblank = dm_enable_vblank,
        .disable_vblank = dm_disable_vblank,
  };
@@@ -3047,14 -3078,24 +3079,24 @@@ static int dm_plane_helper_prepare_fb(s
        else
                domain = AMDGPU_GEM_DOMAIN_VRAM;
  
-       r = amdgpu_bo_pin(rbo, domain, &afb->address);
-       amdgpu_bo_unreserve(rbo);
+       r = amdgpu_bo_pin(rbo, domain);
        if (unlikely(r != 0)) {
                if (r != -ERESTARTSYS)
                        DRM_ERROR("Failed to pin framebuffer with error %d\n", r);
+               amdgpu_bo_unreserve(rbo);
+               return r;
+       }
+       r = amdgpu_ttm_alloc_gart(&rbo->tbo);
+       if (unlikely(r != 0)) {
+               amdgpu_bo_unpin(rbo);
+               amdgpu_bo_unreserve(rbo);
+               DRM_ERROR("%p bind failed\n", rbo);
                return r;
        }
+       amdgpu_bo_unreserve(rbo);
+       afb->address = amdgpu_bo_gpu_offset(rbo);
  
        amdgpu_bo_ref(rbo);
  
@@@ -3452,7 -3493,6 +3494,6 @@@ void amdgpu_dm_connector_init_helper(st
        aconnector->base.stereo_allowed = false;
        aconnector->base.dpms = DRM_MODE_DPMS_OFF;
        aconnector->hpd.hpd = AMDGPU_HPD_NONE; /* not used */
        mutex_init(&aconnector->hpd_lock);
  
        /* configure support HPD hot plug connector_>polled default value is 0
        switch (connector_type) {
        case DRM_MODE_CONNECTOR_HDMIA:
                aconnector->base.polled = DRM_CONNECTOR_POLL_HPD;
+               aconnector->base.ycbcr_420_allowed =
+                       link->link_enc->features.ycbcr420_supported ? true : false;
                break;
        case DRM_MODE_CONNECTOR_DisplayPort:
                aconnector->base.polled = DRM_CONNECTOR_POLL_HPD;
+               aconnector->base.ycbcr_420_allowed =
+                       link->link_enc->features.ycbcr420_supported ? true : false;
                break;
        case DRM_MODE_CONNECTOR_DVID:
                aconnector->base.polled = DRM_CONNECTOR_POLL_HPD;
@@@ -3620,6 -3664,13 +3665,13 @@@ static int amdgpu_dm_connector_init(str
                &aconnector->base, &aencoder->base);
  
        drm_connector_register(&aconnector->base);
+ #if defined(CONFIG_DEBUG_FS)
+       res = connector_debugfs_init(aconnector);
+       if (res) {
+               DRM_ERROR("Failed to create debugfs for connector");
+               goto out_free;
+       }
+ #endif
  
        if (connector_type == DRM_MODE_CONNECTOR_DisplayPort
                || connector_type == DRM_MODE_CONNECTOR_eDP)
index e7ad528f5853bfc410718e804fbfbce4177f0f38,9bfb040352e9875584b4efbb137c84e2fb7a0bf9..01fc5717b657fb73ecb5b5d41ca03d511ba358a3
@@@ -46,23 -46,8 +46,23 @@@ static enum amdgpu_dm_pipe_crc_source d
        return AMDGPU_DM_PIPE_CRC_SOURCE_INVALID;
  }
  
 -int amdgpu_dm_crtc_set_crc_source(struct drm_crtc *crtc, const char *src_name,
 -                         size_t *values_cnt)
 +int
 +amdgpu_dm_crtc_verify_crc_source(struct drm_crtc *crtc, const char *src_name,
 +                               size_t *values_cnt)
 +{
 +      enum amdgpu_dm_pipe_crc_source source = dm_parse_crc_source(src_name);
 +
 +      if (source < 0) {
 +              DRM_DEBUG_DRIVER("Unknown CRC source %s for CRTC%d\n",
 +                               src_name, crtc->index);
 +              return -EINVAL;
 +      }
 +
 +      *values_cnt = 3;
 +      return 0;
 +}
 +
 +int amdgpu_dm_crtc_set_crc_source(struct drm_crtc *crtc, const char *src_name)
  {
        struct dm_crtc_state *crtc_state = to_dm_crtc_state(crtc->state);
        struct dc_stream_state *stream_state = crtc_state->stream;
@@@ -98,6 -83,7 +98,6 @@@
                        return -EINVAL;
        }
  
 -      *values_cnt = 3;
        /* Reset crc_skipped on dm state */
        crtc_state->crc_skip_count = 0;
        return 0;
   */
  void amdgpu_dm_crtc_handle_crc_irq(struct drm_crtc *crtc)
  {
-       struct dm_crtc_state *crtc_state = to_dm_crtc_state(crtc->state);
-       struct dc_stream_state *stream_state = crtc_state->stream;
+       struct dm_crtc_state *crtc_state;
+       struct dc_stream_state *stream_state;
        uint32_t crcs[3];
  
+       if (crtc == NULL)
+               return;
+       crtc_state = to_dm_crtc_state(crtc->state);
+       stream_state = crtc_state->stream;
        /* Early return if CRC capture is not enabled. */
        if (!crtc_state->crc_enabled)
                return;
index 284a5d2bc11d3529c8c5be6eb56bd4c6bc065b7e,80be74df7ba66355163368f9f2b3eaeaf967a0d8..2c23a48482da4445d9ca3e4c280d7b9d853431d2
@@@ -1538,8 -1538,9 +1538,9 @@@ int drm_atomic_helper_async_check(struc
  {
        struct drm_crtc *crtc;
        struct drm_crtc_state *crtc_state;
-       struct drm_plane *plane;
-       struct drm_plane_state *old_plane_state, *new_plane_state;
+       struct drm_plane *plane = NULL;
+       struct drm_plane_state *old_plane_state = NULL;
+       struct drm_plane_state *new_plane_state = NULL;
        const struct drm_plane_helper_funcs *funcs;
        int i, n_planes = 0;
  
        if (n_planes != 1)
                return -EINVAL;
  
-       if (!new_plane_state->crtc)
+       if (!new_plane_state->crtc ||
+           old_plane_state->crtc != new_plane_state->crtc)
                return -EINVAL;
  
        funcs = plane->helper_private;
@@@ -3552,29 -3554,6 +3554,29 @@@ void drm_atomic_helper_crtc_destroy_sta
  }
  EXPORT_SYMBOL(drm_atomic_helper_crtc_destroy_state);
  
 +/**
 + * __drm_atomic_helper_plane_reset - resets planes state to default values
 + * @plane: plane object, must not be NULL
 + * @state: atomic plane state, must not be NULL
 + *
 + * Initializes plane state to default. This is useful for drivers that subclass
 + * the plane state.
 + */
 +void __drm_atomic_helper_plane_reset(struct drm_plane *plane,
 +                                   struct drm_plane_state *state)
 +{
 +      state->plane = plane;
 +      state->rotation = DRM_MODE_ROTATE_0;
 +
 +      /* Reset the alpha value to fully opaque if it matters */
 +      if (plane->alpha_property)
 +              state->alpha = plane->alpha_property->values[1];
 +      state->pixel_blend_mode = DRM_MODE_BLEND_PREMULTI;
 +
 +      plane->state = state;
 +}
 +EXPORT_SYMBOL(__drm_atomic_helper_plane_reset);
 +
  /**
   * drm_atomic_helper_plane_reset - default &drm_plane_funcs.reset hook for planes
   * @plane: drm plane
@@@ -3589,8 -3568,15 +3591,8 @@@ void drm_atomic_helper_plane_reset(stru
  
        kfree(plane->state);
        plane->state = kzalloc(sizeof(*plane->state), GFP_KERNEL);
 -
 -      if (plane->state) {
 -              plane->state->plane = plane;
 -              plane->state->rotation = DRM_MODE_ROTATE_0;
 -
 -              /* Reset the alpha value to fully opaque if it matters */
 -              if (plane->alpha_property)
 -                      plane->state->alpha = plane->alpha_property->values[1];
 -      }
 +      if (plane->state)
 +              __drm_atomic_helper_plane_reset(plane, plane->state);
  }
  EXPORT_SYMBOL(drm_atomic_helper_plane_reset);
  
index d876ed5e92655ceaadf2e5347d80bdc7ea9fab58,93d2f4000d2f90beb943539dd0bdfc0f668c7707..941b238bdcc9642067df5c95273a109bee7df3a8
  #define _PSB_DRV_H_
  
  #include <linux/kref.h>
+ #include <linux/mm_types.h>
  
  #include <drm/drmP.h>
 -#include <drm/drm_global.h>
  #include <drm/gma_drm.h>
  #include "psb_reg.h"
  #include "psb_intel_drv.h"
@@@ -748,7 -750,7 +749,7 @@@ extern int psb_gem_get_aperture(struct 
                        struct drm_file *file);
  extern int psb_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
                        struct drm_mode_create_dumb *args);
- extern int psb_gem_fault(struct vm_fault *vmf);
+ extern vm_fault_t psb_gem_fault(struct vm_fault *vmf);
  
  /* psb_device.c */
  extern const struct psb_ops psb_chip_ops;
index bd8956f2544d637d9a45a5e56d918bcb52d916ba,ed3fa1c8a98342d549ec8bf5b027b3b783affa08..9382375d33b27258786b151a69b9eb1184902453
@@@ -5632,6 -5632,7 +5632,7 @@@ static void haswell_crtc_enable(struct 
        struct intel_atomic_state *old_intel_state =
                to_intel_atomic_state(old_state);
        bool psl_clkgate_wa;
+       u32 pipe_chicken;
  
        if (WARN_ON(intel_crtc->active))
                return;
         */
        intel_color_load_luts(&pipe_config->base);
  
+       /*
+        * Display WA #1153: enable hardware to bypass the alpha math
+        * and rounding for per-pixel values 00 and 0xff
+        */
+       if (INTEL_GEN(dev_priv) >= 11) {
+               pipe_chicken = I915_READ(PIPE_CHICKEN(pipe));
+               if (!(pipe_chicken & PER_PIXEL_ALPHA_BYPASS_EN))
+                       I915_WRITE_FW(PIPE_CHICKEN(pipe),
+                                     pipe_chicken | PER_PIXEL_ALPHA_BYPASS_EN);
+       }
        intel_ddi_set_pipe_settings(pipe_config);
        if (!transcoder_is_dsi(cpu_transcoder))
                intel_ddi_enable_transcoder_func(pipe_config);
@@@ -5825,7 -5837,7 +5837,7 @@@ static void haswell_crtc_disable(struc
                intel_ddi_set_vc_payload_alloc(old_crtc_state, false);
  
        if (!transcoder_is_dsi(cpu_transcoder))
-               intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
+               intel_ddi_disable_transcoder_func(old_crtc_state);
  
        if (INTEL_GEN(dev_priv) >= 9)
                skylake_scaler_disable(intel_crtc);
@@@ -9347,6 -9359,7 +9359,7 @@@ static bool hsw_get_transcoder_state(st
                switch (tmp & TRANS_DDI_EDP_INPUT_MASK) {
                default:
                        WARN(1, "unknown pipe linked to edp transcoder\n");
+                       /* fall through */
                case TRANS_DDI_EDP_INPUT_A_ONOFF:
                case TRANS_DDI_EDP_INPUT_A_ON:
                        trans_edp_pipe = PIPE_A;
@@@ -9402,7 -9415,7 +9415,7 @@@ static bool bxt_get_dsi_transcoder_stat
                 * registers/MIPI[BXT]. We can break out here early, since we
                 * need the same DSI PLL to be enabled for both DSI ports.
                 */
-               if (!intel_dsi_pll_is_enabled(dev_priv))
+               if (!bxt_dsi_pll_is_enabled(dev_priv))
                        break;
  
                /* XXX: this works for video mode only */
@@@ -10724,7 -10737,7 +10737,7 @@@ static void intel_modeset_update_connec
        drm_connector_list_iter_begin(dev, &conn_iter);
        for_each_intel_connector_iter(connector, &conn_iter) {
                if (connector->base.state->crtc)
-                       drm_connector_unreference(&connector->base);
+                       drm_connector_put(&connector->base);
  
                if (connector->base.encoder) {
                        connector->base.state->best_encoder =
                        connector->base.state->crtc =
                                connector->base.encoder->crtc;
  
-                       drm_connector_reference(&connector->base);
+                       drm_connector_get(&connector->base);
                } else {
                        connector->base.state->best_encoder = NULL;
                        connector->base.state->crtc = NULL;
@@@ -11011,6 -11024,7 +11024,7 @@@ static bool check_digital_port_conflict
                case INTEL_OUTPUT_DDI:
                        if (WARN_ON(!HAS_DDI(to_i915(dev))))
                                break;
+                       /* else: fall through */
                case INTEL_OUTPUT_DP:
                case INTEL_OUTPUT_HDMI:
                case INTEL_OUTPUT_EDP:
@@@ -12542,6 -12556,19 +12556,19 @@@ static void intel_atomic_commit_fence_w
        finish_wait(&dev_priv->gpu_error.wait_queue, &wait_reset);
  }
  
+ static void intel_atomic_cleanup_work(struct work_struct *work)
+ {
+       struct drm_atomic_state *state =
+               container_of(work, struct drm_atomic_state, commit_work);
+       struct drm_i915_private *i915 = to_i915(state->dev);
+       drm_atomic_helper_cleanup_planes(&i915->drm, state);
+       drm_atomic_helper_commit_cleanup_done(state);
+       drm_atomic_state_put(state);
+       intel_atomic_helper_free_state(i915);
+ }
  static void intel_atomic_commit_tail(struct drm_atomic_state *state)
  {
        struct drm_device *dev = state->dev;
                intel_display_power_put(dev_priv, POWER_DOMAIN_MODESET);
        }
  
-       drm_atomic_helper_cleanup_planes(dev, state);
-       drm_atomic_helper_commit_cleanup_done(state);
-       drm_atomic_state_put(state);
-       intel_atomic_helper_free_state(dev_priv);
+       /*
+        * Defer the cleanup of the old state to a separate worker to not
+        * impede the current task (userspace for blocking modesets) that
+        * are executed inline. For out-of-line asynchronous modesets/flips,
+        * deferring to a new worker seems overkill, but we would place a
+        * schedule point (cond_resched()) here anyway to keep latencies
+        * down.
+        */
+       INIT_WORK(&state->commit_work, intel_atomic_cleanup_work);
+       schedule_work(&state->commit_work);
  }
  
  static void intel_atomic_commit_work(struct work_struct *work)
@@@ -12865,8 -12895,6 +12895,8 @@@ static const struct drm_crtc_funcs inte
        .atomic_duplicate_state = intel_crtc_duplicate_state,
        .atomic_destroy_state = intel_crtc_destroy_state,
        .set_crc_source = intel_crtc_set_crc_source,
 +      .verify_crc_source = intel_crtc_verify_crc_source,
 +      .get_crc_sources = intel_crtc_get_crc_sources,
  };
  
  struct wait_rps_boost {
@@@ -13076,6 -13104,19 +13106,19 @@@ intel_prepare_plane_fb(struct drm_plan
                add_rps_boost_after_vblank(new_state->crtc, new_state->fence);
        }
  
+       /*
+        * We declare pageflips to be interactive and so merit a small bias
+        * towards upclocking to deliver the frame on time. By only changing
+        * the RPS thresholds to sample more regularly and aim for higher
+        * clocks we can hopefully deliver low power workloads (like kodi)
+        * that are not quite steady state without resorting to forcing
+        * maximum clocks following a vblank miss (see do_rps_boost()).
+        */
+       if (!intel_state->rps_interactive) {
+               intel_rps_mark_interactive(dev_priv, true);
+               intel_state->rps_interactive = true;
+       }
        return 0;
  }
  
  intel_cleanup_plane_fb(struct drm_plane *plane,
                       struct drm_plane_state *old_state)
  {
+       struct intel_atomic_state *intel_state =
+               to_intel_atomic_state(old_state->state);
        struct drm_i915_private *dev_priv = to_i915(plane->dev);
  
+       if (intel_state->rps_interactive) {
+               intel_rps_mark_interactive(dev_priv, false);
+               intel_state->rps_interactive = false;
+       }
        /* Should only be called after a successful intel_prepare_plane_fb()! */
        mutex_lock(&dev_priv->drm.struct_mutex);
        intel_plane_unpin_fb(to_intel_plane_state(old_state));
@@@ -14107,7 -14155,7 +14157,7 @@@ static void intel_setup_outputs(struct 
                intel_ddi_init(dev_priv, PORT_B);
                intel_ddi_init(dev_priv, PORT_C);
  
-               intel_dsi_init(dev_priv);
+               vlv_dsi_init(dev_priv);
        } else if (HAS_DDI(dev_priv)) {
                int found;
  
                                intel_hdmi_init(dev_priv, CHV_HDMID, PORT_D);
                }
  
-               intel_dsi_init(dev_priv);
+               vlv_dsi_init(dev_priv);
        } else if (!IS_GEN2(dev_priv) && !IS_PINEVIEW(dev_priv)) {
                bool found = false;
  
@@@ -14495,11 -14543,6 +14545,6 @@@ static int intel_framebuffer_init(struc
                }
                break;
        case DRM_FORMAT_NV12:
-               if (mode_cmd->modifier[0] == I915_FORMAT_MOD_Y_TILED_CCS ||
-                   mode_cmd->modifier[0] == I915_FORMAT_MOD_Yf_TILED_CCS) {
-                       DRM_DEBUG_KMS("RC not to be enabled with NV12\n");
-                       goto err;
-               }
                if (INTEL_GEN(dev_priv) < 9 || IS_SKYLAKE(dev_priv) ||
                    IS_BROXTON(dev_priv)) {
                        DRM_DEBUG_KMS("unsupported pixel format: %s\n",
@@@ -14826,6 -14869,18 +14871,18 @@@ static void quirk_increase_t12_delay(st
        DRM_INFO("Applying T12 delay quirk\n");
  }
  
+ /*
+  * GeminiLake NUC HDMI outputs require additional off time
+  * this allows the onboard retimer to correctly sync to signal
+  */
+ static void quirk_increase_ddi_disabled_time(struct drm_device *dev)
+ {
+       struct drm_i915_private *dev_priv = to_i915(dev);
+       dev_priv->quirks |= QUIRK_INCREASE_DDI_DISABLED_TIME;
+       DRM_INFO("Applying Increase DDI Disabled quirk\n");
+ }
  struct intel_quirk {
        int device;
        int subsystem_vendor;
@@@ -14912,6 -14967,13 +14969,13 @@@ static struct intel_quirk intel_quirks[
  
        /* Toshiba Satellite P50-C-18C */
        { 0x191B, 0x1179, 0xF840, quirk_increase_t12_delay },
+       /* GeminiLake NUC */
+       { 0x3185, 0x8086, 0x2072, quirk_increase_ddi_disabled_time },
+       { 0x3184, 0x8086, 0x2072, quirk_increase_ddi_disabled_time },
+       /* ASRock ITX*/
+       { 0x3185, 0x1849, 0x2212, quirk_increase_ddi_disabled_time },
+       { 0x3184, 0x1849, 0x2212, quirk_increase_ddi_disabled_time },
  };
  
  static void intel_init_quirks(struct drm_device *dev)
@@@ -15678,11 -15740,20 +15742,20 @@@ get_encoder_power_domains(struct drm_i9
        for_each_intel_encoder(&dev_priv->drm, encoder) {
                u64 get_domains;
                enum intel_display_power_domain domain;
+               struct intel_crtc_state *crtc_state;
  
                if (!encoder->get_power_domains)
                        continue;
  
-               get_domains = encoder->get_power_domains(encoder);
+               /*
+                * MST-primary and inactive encoders don't have a crtc state
+                * and neither of these require any power domain references.
+                */
+               if (!encoder->base.crtc)
+                       continue;
+               crtc_state = to_intel_crtc_state(encoder->base.crtc->state);
+               get_domains = encoder->get_power_domains(encoder, crtc_state);
                for_each_power_domain(domain, get_domains)
                        intel_display_power_get(dev_priv, domain);
        }
@@@ -15858,6 -15929,8 +15931,8 @@@ void intel_modeset_cleanup(struct drm_d
  {
        struct drm_i915_private *dev_priv = to_i915(dev);
  
+       flush_workqueue(dev_priv->modeset_wq);
        flush_work(&dev_priv->atomic_helper.free_work);
        WARN_ON(!llist_empty(&dev_priv->atomic_helper.free_list));
  
index b41515bb9a15157cc6f2e4b8ea2bbe0e3bfb4e83,8fc61e96754ff540626ce6421a275408359be6e4..5f63e1a9c25b9c31331ad87edb3ee5a5466d434f
@@@ -39,6 -39,7 +39,7 @@@
  #include <drm/drm_dp_mst_helper.h>
  #include <drm/drm_rect.h>
  #include <drm/drm_atomic.h>
+ #include <media/cec-notifier.h>
  
  /**
   * __wait_for - magic wait macro
@@@ -254,7 -255,8 +255,8 @@@ struct intel_encoder 
                           struct intel_crtc_state *pipe_config);
        /* Returns a mask of power domains that need to be referenced as part
         * of the hardware state readout code. */
-       u64 (*get_power_domains)(struct intel_encoder *encoder);
+       u64 (*get_power_domains)(struct intel_encoder *encoder,
+                                struct intel_crtc_state *crtc_state);
        /*
         * Called during system suspend after all pending requests for the
         * encoder are flushed (for example for DP AUX transactions) and
@@@ -303,6 -305,8 +305,8 @@@ struct intel_panel 
        } backlight;
  };
  
+ struct intel_digital_port;
  /*
   * This structure serves as a translation layer between the generic HDCP code
   * and the bus-specific code. What that means is that HDCP over HDMI differs
@@@ -481,6 -485,8 +485,8 @@@ struct intel_atomic_state 
         */
        bool skip_intermediate_wm;
  
+       bool rps_interactive;
        /* Gen9+ only */
        struct skl_ddb_values wm_results;
  
@@@ -1011,6 -1017,7 +1017,7 @@@ struct intel_hdmi 
        bool has_audio;
        bool rgb_quant_range_selectable;
        struct intel_connector *attached_connector;
+       struct cec_notifier *cec_notifier;
  };
  
  struct intel_dp_mst_encoder;
@@@ -1133,7 -1140,6 +1140,6 @@@ struct intel_dp 
         * register with to kick off an AUX transaction.
         */
        uint32_t (*get_aux_send_ctl)(struct intel_dp *dp,
-                                    bool has_aux_irq,
                                     int send_bytes,
                                     uint32_t aux_clock_divider);
  
@@@ -1246,22 -1252,29 +1252,29 @@@ intel_attached_encoder(struct drm_conne
        return to_intel_connector(connector)->encoder;
  }
  
- static inline struct intel_digital_port *
- enc_to_dig_port(struct drm_encoder *encoder)
+ static inline bool intel_encoder_is_dig_port(struct intel_encoder *encoder)
  {
-       struct intel_encoder *intel_encoder = to_intel_encoder(encoder);
-       switch (intel_encoder->type) {
+       switch (encoder->type) {
        case INTEL_OUTPUT_DDI:
-               WARN_ON(!HAS_DDI(to_i915(encoder->dev)));
        case INTEL_OUTPUT_DP:
        case INTEL_OUTPUT_EDP:
        case INTEL_OUTPUT_HDMI:
+               return true;
+       default:
+               return false;
+       }
+ }
+ static inline struct intel_digital_port *
+ enc_to_dig_port(struct drm_encoder *encoder)
+ {
+       struct intel_encoder *intel_encoder = to_intel_encoder(encoder);
+       if (intel_encoder_is_dig_port(intel_encoder))
                return container_of(encoder, struct intel_digital_port,
                                    base.base);
-       default:
+       else
                return NULL;
-       }
  }
  
  static inline struct intel_dp_mst_encoder *
@@@ -1275,6 -1288,20 +1288,20 @@@ static inline struct intel_dp *enc_to_i
        return &enc_to_dig_port(encoder)->dp;
  }
  
+ static inline bool intel_encoder_is_dp(struct intel_encoder *encoder)
+ {
+       switch (encoder->type) {
+       case INTEL_OUTPUT_DP:
+       case INTEL_OUTPUT_EDP:
+               return true;
+       case INTEL_OUTPUT_DDI:
+               /* Skip pure HDMI/DVI DDI encoders */
+               return i915_mmio_reg_valid(enc_to_intel_dp(&encoder->base)->output_reg);
+       default:
+               return false;
+       }
+ }
  static inline struct intel_digital_port *
  dp_to_dig_port(struct intel_dp *intel_dp)
  {
@@@ -1331,9 -1358,6 +1358,6 @@@ void intel_check_cpu_fifo_underruns(str
  void intel_check_pch_fifo_underruns(struct drm_i915_private *dev_priv);
  
  /* i915_irq.c */
- bool gen11_reset_one_iir(struct drm_i915_private * const i915,
-                        const unsigned int bank,
-                        const unsigned int bit);
  void gen5_enable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  void gen5_disable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  void gen6_mask_pm_irq(struct drm_i915_private *dev_priv, u32 mask);
@@@ -1384,8 -1408,7 +1408,7 @@@ void hsw_fdi_link_train(struct intel_cr
  void intel_ddi_init(struct drm_i915_private *dev_priv, enum port port);
  bool intel_ddi_get_hw_state(struct intel_encoder *encoder, enum pipe *pipe);
  void intel_ddi_enable_transcoder_func(const struct intel_crtc_state *crtc_state);
- void intel_ddi_disable_transcoder_func(struct drm_i915_private *dev_priv,
-                                      enum transcoder cpu_transcoder);
+ void intel_ddi_disable_transcoder_func(const struct intel_crtc_state *crtc_state);
  void intel_ddi_enable_pipe_clock(const struct intel_crtc_state *crtc_state);
  void intel_ddi_disable_pipe_clock(const  struct intel_crtc_state *crtc_state);
  void intel_ddi_set_pipe_settings(const struct intel_crtc_state *crtc_state);
@@@ -1664,8 -1687,6 +1687,6 @@@ void intel_dp_sink_dpms(struct intel_d
  void intel_dp_encoder_reset(struct drm_encoder *encoder);
  void intel_dp_encoder_suspend(struct intel_encoder *intel_encoder);
  void intel_dp_encoder_destroy(struct drm_encoder *encoder);
- int intel_dp_sink_crc(struct intel_dp *intel_dp,
-                     struct intel_crtc_state *crtc_state, u8 *crc);
  bool intel_dp_compute_config(struct intel_encoder *encoder,
                             struct intel_crtc_state *pipe_config,
                             struct drm_connector_state *conn_state);
@@@ -1679,8 -1700,8 +1700,8 @@@ void intel_edp_backlight_off(const stru
  void intel_edp_panel_vdd_on(struct intel_dp *intel_dp);
  void intel_edp_panel_on(struct intel_dp *intel_dp);
  void intel_edp_panel_off(struct intel_dp *intel_dp);
- void intel_dp_mst_suspend(struct drm_device *dev);
- void intel_dp_mst_resume(struct drm_device *dev);
+ void intel_dp_mst_suspend(struct drm_i915_private *dev_priv);
+ void intel_dp_mst_resume(struct drm_i915_private *dev_priv);
  int intel_dp_max_link_rate(struct intel_dp *intel_dp);
  int intel_dp_max_lane_count(struct intel_dp *intel_dp);
  int intel_dp_rate_select(struct intel_dp *intel_dp, int rate);
@@@ -1730,8 -1751,8 +1751,8 @@@ int intel_dp_aux_init_backlight_funcs(s
  /* intel_dp_mst.c */
  int intel_dp_mst_encoder_init(struct intel_digital_port *intel_dig_port, int conn_id);
  void intel_dp_mst_encoder_cleanup(struct intel_digital_port *intel_dig_port);
- /* intel_dsi.c */
- void intel_dsi_init(struct drm_i915_private *dev_priv);
+ /* vlv_dsi.c */
+ void vlv_dsi_init(struct drm_i915_private *dev_priv);
  
  /* intel_dsi_dcs_backlight.c */
  int intel_dsi_dcs_init_backlight_funcs(struct intel_connector *intel_connector);
@@@ -1873,7 -1894,6 +1894,6 @@@ void intel_panel_enable_backlight(cons
                                  const struct drm_connector_state *conn_state);
  void intel_panel_disable_backlight(const struct drm_connector_state *old_conn_state);
  void intel_panel_destroy_backlight(struct drm_connector *connector);
- enum drm_connector_status intel_panel_detect(struct drm_i915_private *dev_priv);
  extern struct drm_display_mode *intel_find_panel_downclock(
                                struct drm_i915_private *dev_priv,
                                struct drm_display_mode *fixed_mode,
@@@ -1921,6 -1941,8 +1941,8 @@@ void intel_psr_compute_config(struct in
                              struct intel_crtc_state *crtc_state);
  void intel_psr_irq_control(struct drm_i915_private *dev_priv, bool debug);
  void intel_psr_irq_handler(struct drm_i915_private *dev_priv, u32 psr_iir);
+ void intel_psr_short_pulse(struct intel_dp *intel_dp);
+ int intel_psr_wait_for_idle(const struct intel_crtc_state *new_crtc_state);
  
  /* intel_runtime_pm.c */
  int intel_power_domains_init(struct drm_i915_private *);
@@@ -2149,19 -2171,13 +2171,18 @@@ void lspcon_resume(struct intel_lspcon 
  void lspcon_wait_pcon_mode(struct intel_lspcon *lspcon);
  
  /* intel_pipe_crc.c */
- int intel_pipe_crc_create(struct drm_minor *minor);
  #ifdef CONFIG_DEBUG_FS
 -int intel_crtc_set_crc_source(struct drm_crtc *crtc, const char *source_name,
 -                            size_t *values_cnt);
 +int intel_crtc_set_crc_source(struct drm_crtc *crtc, const char *source_name);
 +int intel_crtc_verify_crc_source(struct drm_crtc *crtc,
 +                               const char *source_name, size_t *values_cnt);
 +const char *const *intel_crtc_get_crc_sources(struct drm_crtc *crtc,
 +                                            size_t *count);
  void intel_crtc_disable_pipe_crc(struct intel_crtc *crtc);
  void intel_crtc_enable_pipe_crc(struct intel_crtc *crtc);
  #else
  #define intel_crtc_set_crc_source NULL
 +#define intel_crtc_verify_crc_source NULL
 +#define intel_crtc_get_crc_sources NULL
  static inline void intel_crtc_disable_pipe_crc(struct intel_crtc *crtc)
  {
  }
@@@ -2170,5 -2186,4 +2191,4 @@@ static inline void intel_crtc_enable_pi
  {
  }
  #endif
- extern const struct file_operations i915_display_crc_ctl_fops;
  #endif /* __INTEL_DRV_H__ */
index 27d560f7a817c5e305e95c7dca888469163f0cf6,849e1b69ba739e9fd61407313582cde5461820a9..f3c9010e332a0eab4a7ca440e547307431dc0bb5
  #include <linux/debugfs.h>
  #include "intel_drv.h"
  
- struct pipe_crc_info {
-       const char *name;
-       struct drm_i915_private *dev_priv;
-       enum pipe pipe;
- };
- static int i915_pipe_crc_open(struct inode *inode, struct file *filep)
- {
-       struct pipe_crc_info *info = inode->i_private;
-       struct drm_i915_private *dev_priv = info->dev_priv;
-       struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
-       if (info->pipe >= INTEL_INFO(dev_priv)->num_pipes)
-               return -ENODEV;
-       spin_lock_irq(&pipe_crc->lock);
-       if (pipe_crc->opened) {
-               spin_unlock_irq(&pipe_crc->lock);
-               return -EBUSY; /* already open */
-       }
-       pipe_crc->opened = true;
-       filep->private_data = inode->i_private;
-       spin_unlock_irq(&pipe_crc->lock);
-       return 0;
- }
- static int i915_pipe_crc_release(struct inode *inode, struct file *filep)
- {
-       struct pipe_crc_info *info = inode->i_private;
-       struct drm_i915_private *dev_priv = info->dev_priv;
-       struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
-       spin_lock_irq(&pipe_crc->lock);
-       pipe_crc->opened = false;
-       spin_unlock_irq(&pipe_crc->lock);
-       return 0;
- }
- /* (6 fields, 8 chars each, space separated (5) + '\n') */
- #define PIPE_CRC_LINE_LEN     (6 * 8 + 5 + 1)
- /* account for \'0' */
- #define PIPE_CRC_BUFFER_LEN   (PIPE_CRC_LINE_LEN + 1)
- static int pipe_crc_data_count(struct intel_pipe_crc *pipe_crc)
- {
-       lockdep_assert_held(&pipe_crc->lock);
-       return CIRC_CNT(pipe_crc->head, pipe_crc->tail,
-                       INTEL_PIPE_CRC_ENTRIES_NR);
- }
- static ssize_t
- i915_pipe_crc_read(struct file *filep, char __user *user_buf, size_t count,
-                  loff_t *pos)
- {
-       struct pipe_crc_info *info = filep->private_data;
-       struct drm_i915_private *dev_priv = info->dev_priv;
-       struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
-       char buf[PIPE_CRC_BUFFER_LEN];
-       int n_entries;
-       ssize_t bytes_read;
-       /*
-        * Don't allow user space to provide buffers not big enough to hold
-        * a line of data.
-        */
-       if (count < PIPE_CRC_LINE_LEN)
-               return -EINVAL;
-       if (pipe_crc->source == INTEL_PIPE_CRC_SOURCE_NONE)
-               return 0;
-       /* nothing to read */
-       spin_lock_irq(&pipe_crc->lock);
-       while (pipe_crc_data_count(pipe_crc) == 0) {
-               int ret;
-               if (filep->f_flags & O_NONBLOCK) {
-                       spin_unlock_irq(&pipe_crc->lock);
-                       return -EAGAIN;
-               }
-               ret = wait_event_interruptible_lock_irq(pipe_crc->wq,
-                               pipe_crc_data_count(pipe_crc), pipe_crc->lock);
-               if (ret) {
-                       spin_unlock_irq(&pipe_crc->lock);
-                       return ret;
-               }
-       }
-       /* We now have one or more entries to read */
-       n_entries = count / PIPE_CRC_LINE_LEN;
-       bytes_read = 0;
-       while (n_entries > 0) {
-               struct intel_pipe_crc_entry *entry =
-                       &pipe_crc->entries[pipe_crc->tail];
-               if (CIRC_CNT(pipe_crc->head, pipe_crc->tail,
-                            INTEL_PIPE_CRC_ENTRIES_NR) < 1)
-                       break;
-               BUILD_BUG_ON_NOT_POWER_OF_2(INTEL_PIPE_CRC_ENTRIES_NR);
-               pipe_crc->tail = (pipe_crc->tail + 1) &
-                                (INTEL_PIPE_CRC_ENTRIES_NR - 1);
-               bytes_read += snprintf(buf, PIPE_CRC_BUFFER_LEN,
-                                      "%8u %8x %8x %8x %8x %8x\n",
-                                      entry->frame, entry->crc[0],
-                                      entry->crc[1], entry->crc[2],
-                                      entry->crc[3], entry->crc[4]);
-               spin_unlock_irq(&pipe_crc->lock);
-               if (copy_to_user(user_buf, buf, PIPE_CRC_LINE_LEN))
-                       return -EFAULT;
-               user_buf += PIPE_CRC_LINE_LEN;
-               n_entries--;
-               spin_lock_irq(&pipe_crc->lock);
-       }
-       spin_unlock_irq(&pipe_crc->lock);
-       return bytes_read;
- }
- static const struct file_operations i915_pipe_crc_fops = {
-       .owner = THIS_MODULE,
-       .open = i915_pipe_crc_open,
-       .read = i915_pipe_crc_read,
-       .release = i915_pipe_crc_release,
- };
- static struct pipe_crc_info i915_pipe_crc_data[I915_MAX_PIPES] = {
-       {
-               .name = "i915_pipe_A_crc",
-               .pipe = PIPE_A,
-       },
-       {
-               .name = "i915_pipe_B_crc",
-               .pipe = PIPE_B,
-       },
-       {
-               .name = "i915_pipe_C_crc",
-               .pipe = PIPE_C,
-       },
- };
  static const char * const pipe_crc_sources[] = {
        "none",
        "plane1",
        "auto",
  };
  
- static const char *pipe_crc_source_name(enum intel_pipe_crc_source source)
- {
-       BUILD_BUG_ON(ARRAY_SIZE(pipe_crc_sources) != INTEL_PIPE_CRC_SOURCE_MAX);
-       return pipe_crc_sources[source];
- }
- static int display_crc_ctl_show(struct seq_file *m, void *data)
- {
-       struct drm_i915_private *dev_priv = m->private;
-       enum pipe pipe;
-       for_each_pipe(dev_priv, pipe)
-               seq_printf(m, "%c %s\n", pipe_name(pipe),
-                          pipe_crc_source_name(dev_priv->pipe_crc[pipe].source));
-       return 0;
- }
- static int display_crc_ctl_open(struct inode *inode, struct file *file)
- {
-       return single_open(file, display_crc_ctl_show, inode->i_private);
- }
  static int i8xx_pipe_crc_ctl_reg(enum intel_pipe_crc_source *source,
                                 uint32_t *val)
  {
@@@ -616,177 -439,6 +439,6 @@@ static int get_new_crc_ctl_reg(struct d
                return ivb_pipe_crc_ctl_reg(dev_priv, pipe, source, val, set_wa);
  }
  
- static int pipe_crc_set_source(struct drm_i915_private *dev_priv,
-                              enum pipe pipe,
-                              enum intel_pipe_crc_source source)
- {
-       struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
-       enum intel_display_power_domain power_domain;
-       u32 val = 0; /* shut up gcc */
-       int ret;
-       if (pipe_crc->source == source)
-               return 0;
-       /* forbid changing the source without going back to 'none' */
-       if (pipe_crc->source && source)
-               return -EINVAL;
-       power_domain = POWER_DOMAIN_PIPE(pipe);
-       if (!intel_display_power_get_if_enabled(dev_priv, power_domain)) {
-               DRM_DEBUG_KMS("Trying to capture CRC while pipe is off\n");
-               return -EIO;
-       }
-       ret = get_new_crc_ctl_reg(dev_priv, pipe, &source, &val, true);
-       if (ret != 0)
-               goto out;
-       /* none -> real source transition */
-       if (source) {
-               struct intel_pipe_crc_entry *entries;
-               DRM_DEBUG_DRIVER("collecting CRCs for pipe %c, %s\n",
-                                pipe_name(pipe), pipe_crc_source_name(source));
-               entries = kcalloc(INTEL_PIPE_CRC_ENTRIES_NR,
-                                 sizeof(pipe_crc->entries[0]),
-                                 GFP_KERNEL);
-               if (!entries) {
-                       ret = -ENOMEM;
-                       goto out;
-               }
-               spin_lock_irq(&pipe_crc->lock);
-               kfree(pipe_crc->entries);
-               pipe_crc->entries = entries;
-               pipe_crc->head = 0;
-               pipe_crc->tail = 0;
-               spin_unlock_irq(&pipe_crc->lock);
-       }
-       pipe_crc->source = source;
-       I915_WRITE(PIPE_CRC_CTL(pipe), val);
-       POSTING_READ(PIPE_CRC_CTL(pipe));
-       /* real source -> none transition */
-       if (!source) {
-               struct intel_pipe_crc_entry *entries;
-               struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv,
-                                                                 pipe);
-               DRM_DEBUG_DRIVER("stopping CRCs for pipe %c\n",
-                                pipe_name(pipe));
-               drm_modeset_lock(&crtc->base.mutex, NULL);
-               if (crtc->base.state->active)
-                       intel_wait_for_vblank(dev_priv, pipe);
-               drm_modeset_unlock(&crtc->base.mutex);
-               spin_lock_irq(&pipe_crc->lock);
-               entries = pipe_crc->entries;
-               pipe_crc->entries = NULL;
-               pipe_crc->head = 0;
-               pipe_crc->tail = 0;
-               spin_unlock_irq(&pipe_crc->lock);
-               kfree(entries);
-               if (IS_G4X(dev_priv))
-                       g4x_undo_pipe_scramble_reset(dev_priv, pipe);
-               else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
-                       vlv_undo_pipe_scramble_reset(dev_priv, pipe);
-               else if ((IS_HASWELL(dev_priv) ||
-                         IS_BROADWELL(dev_priv)) && pipe == PIPE_A)
-                       hsw_pipe_A_crc_wa(dev_priv, false);
-       }
-       ret = 0;
- out:
-       intel_display_power_put(dev_priv, power_domain);
-       return ret;
- }
- /*
-  * Parse pipe CRC command strings:
-  *   command: wsp* object wsp+ name wsp+ source wsp*
-  *   object: 'pipe'
-  *   name: (A | B | C)
-  *   source: (none | plane1 | plane2 | pf)
-  *   wsp: (#0x20 | #0x9 | #0xA)+
-  *
-  * eg.:
-  *  "pipe A plane1"  ->  Start CRC computations on plane1 of pipe A
-  *  "pipe A none"    ->  Stop CRC
-  */
- static int display_crc_ctl_tokenize(char *buf, char *words[], int max_words)
- {
-       int n_words = 0;
-       while (*buf) {
-               char *end;
-               /* skip leading white space */
-               buf = skip_spaces(buf);
-               if (!*buf)
-                       break;  /* end of buffer */
-               /* find end of word */
-               for (end = buf; *end && !isspace(*end); end++)
-                       ;
-               if (n_words == max_words) {
-                       DRM_DEBUG_DRIVER("too many words, allowed <= %d\n",
-                                        max_words);
-                       return -EINVAL; /* ran out of words[] before bytes */
-               }
-               if (*end)
-                       *end++ = '\0';
-               words[n_words++] = buf;
-               buf = end;
-       }
-       return n_words;
- }
- enum intel_pipe_crc_object {
-       PIPE_CRC_OBJECT_PIPE,
- };
- static const char * const pipe_crc_objects[] = {
-       "pipe",
- };
- static int
- display_crc_ctl_parse_object(const char *buf, enum intel_pipe_crc_object *o)
- {
-       int i;
-       i = match_string(pipe_crc_objects, ARRAY_SIZE(pipe_crc_objects), buf);
-       if (i < 0)
-               return i;
-       *o = i;
-       return 0;
- }
- static int display_crc_ctl_parse_pipe(struct drm_i915_private *dev_priv,
-                                     const char *buf, enum pipe *pipe)
- {
-       const char name = buf[0];
-       if (name < 'A' || name >= pipe_name(INTEL_INFO(dev_priv)->num_pipes))
-               return -EINVAL;
-       *pipe = name - 'A';
-       return 0;
- }
  static int
  display_crc_ctl_parse_source(const char *buf, enum intel_pipe_crc_source *s)
  {
        return 0;
  }
  
- static int display_crc_ctl_parse(struct drm_i915_private *dev_priv,
-                                char *buf, size_t len)
- {
- #define N_WORDS 3
-       int n_words;
-       char *words[N_WORDS];
-       enum pipe pipe;
-       enum intel_pipe_crc_object object;
-       enum intel_pipe_crc_source source;
-       n_words = display_crc_ctl_tokenize(buf, words, N_WORDS);
-       if (n_words != N_WORDS) {
-               DRM_DEBUG_DRIVER("tokenize failed, a command is %d words\n",
-                                N_WORDS);
-               return -EINVAL;
-       }
-       if (display_crc_ctl_parse_object(words[0], &object) < 0) {
-               DRM_DEBUG_DRIVER("unknown object %s\n", words[0]);
-               return -EINVAL;
-       }
-       if (display_crc_ctl_parse_pipe(dev_priv, words[1], &pipe) < 0) {
-               DRM_DEBUG_DRIVER("unknown pipe %s\n", words[1]);
-               return -EINVAL;
-       }
-       if (display_crc_ctl_parse_source(words[2], &source) < 0) {
-               DRM_DEBUG_DRIVER("unknown source %s\n", words[2]);
-               return -EINVAL;
-       }
-       return pipe_crc_set_source(dev_priv, pipe, source);
- }
- static ssize_t display_crc_ctl_write(struct file *file, const char __user *ubuf,
-                                    size_t len, loff_t *offp)
- {
-       struct seq_file *m = file->private_data;
-       struct drm_i915_private *dev_priv = m->private;
-       char *tmpbuf;
-       int ret;
-       if (len == 0)
-               return 0;
-       if (len > PAGE_SIZE - 1) {
-               DRM_DEBUG_DRIVER("expected <%lu bytes into pipe crc control\n",
-                                PAGE_SIZE);
-               return -E2BIG;
-       }
-       tmpbuf = memdup_user_nul(ubuf, len);
-       if (IS_ERR(tmpbuf))
-               return PTR_ERR(tmpbuf);
-       ret = display_crc_ctl_parse(dev_priv, tmpbuf, len);
-       kfree(tmpbuf);
-       if (ret < 0)
-               return ret;
-       *offp += len;
-       return len;
- }
- const struct file_operations i915_display_crc_ctl_fops = {
-       .owner = THIS_MODULE,
-       .open = display_crc_ctl_open,
-       .read = seq_read,
-       .llseek = seq_lseek,
-       .release = single_release,
-       .write = display_crc_ctl_write
- };
  void intel_display_crc_init(struct drm_i915_private *dev_priv)
  {
        enum pipe pipe;
        for_each_pipe(dev_priv, pipe) {
                struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
  
-               pipe_crc->opened = false;
                spin_lock_init(&pipe_crc->lock);
-               init_waitqueue_head(&pipe_crc->wq);
-       }
- }
- int intel_pipe_crc_create(struct drm_minor *minor)
- {
-       struct drm_i915_private *dev_priv = to_i915(minor->dev);
-       struct dentry *ent;
-       int i;
-       for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) {
-               struct pipe_crc_info *info = &i915_pipe_crc_data[i];
-               info->dev_priv = dev_priv;
-               ent = debugfs_create_file(info->name, S_IRUGO,
-                                         minor->debugfs_root, info,
-                                         &i915_pipe_crc_fops);
-               if (!ent)
-                       return -ENOMEM;
        }
-       return 0;
  }
  
 -int intel_crtc_set_crc_source(struct drm_crtc *crtc, const char *source_name,
 -                            size_t *values_cnt)
 +static int i8xx_crc_source_valid(struct drm_i915_private *dev_priv,
 +                               const enum intel_pipe_crc_source source)
 +{
 +      switch (source) {
 +      case INTEL_PIPE_CRC_SOURCE_PIPE:
 +      case INTEL_PIPE_CRC_SOURCE_NONE:
 +              return 0;
 +      default:
 +              return -EINVAL;
 +      }
 +}
 +
 +static int i9xx_crc_source_valid(struct drm_i915_private *dev_priv,
 +                               const enum intel_pipe_crc_source source)
 +{
 +      switch (source) {
 +      case INTEL_PIPE_CRC_SOURCE_PIPE:
 +      case INTEL_PIPE_CRC_SOURCE_TV:
 +      case INTEL_PIPE_CRC_SOURCE_DP_B:
 +      case INTEL_PIPE_CRC_SOURCE_DP_C:
 +      case INTEL_PIPE_CRC_SOURCE_DP_D:
 +      case INTEL_PIPE_CRC_SOURCE_NONE:
 +              return 0;
 +      default:
 +              return -EINVAL;
 +      }
 +}
 +
 +static int vlv_crc_source_valid(struct drm_i915_private *dev_priv,
 +                              const enum intel_pipe_crc_source source)
 +{
 +      switch (source) {
 +      case INTEL_PIPE_CRC_SOURCE_PIPE:
 +      case INTEL_PIPE_CRC_SOURCE_DP_B:
 +      case INTEL_PIPE_CRC_SOURCE_DP_C:
 +      case INTEL_PIPE_CRC_SOURCE_DP_D:
 +      case INTEL_PIPE_CRC_SOURCE_NONE:
 +              return 0;
 +      default:
 +              return -EINVAL;
 +      }
 +}
 +
 +static int ilk_crc_source_valid(struct drm_i915_private *dev_priv,
 +                              const enum intel_pipe_crc_source source)
 +{
 +      switch (source) {
 +      case INTEL_PIPE_CRC_SOURCE_PIPE:
 +      case INTEL_PIPE_CRC_SOURCE_PLANE1:
 +      case INTEL_PIPE_CRC_SOURCE_PLANE2:
 +      case INTEL_PIPE_CRC_SOURCE_NONE:
 +              return 0;
 +      default:
 +              return -EINVAL;
 +      }
 +}
 +
 +static int ivb_crc_source_valid(struct drm_i915_private *dev_priv,
 +                              const enum intel_pipe_crc_source source)
 +{
 +      switch (source) {
 +      case INTEL_PIPE_CRC_SOURCE_PIPE:
 +      case INTEL_PIPE_CRC_SOURCE_PLANE1:
 +      case INTEL_PIPE_CRC_SOURCE_PLANE2:
 +      case INTEL_PIPE_CRC_SOURCE_PF:
 +      case INTEL_PIPE_CRC_SOURCE_NONE:
 +              return 0;
 +      default:
 +              return -EINVAL;
 +      }
 +}
 +
 +static int
 +intel_is_valid_crc_source(struct drm_i915_private *dev_priv,
 +                        const enum intel_pipe_crc_source source)
 +{
 +      if (IS_GEN2(dev_priv))
 +              return i8xx_crc_source_valid(dev_priv, source);
 +      else if (INTEL_GEN(dev_priv) < 5)
 +              return i9xx_crc_source_valid(dev_priv, source);
 +      else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
 +              return vlv_crc_source_valid(dev_priv, source);
 +      else if (IS_GEN5(dev_priv) || IS_GEN6(dev_priv))
 +              return ilk_crc_source_valid(dev_priv, source);
 +      else
 +              return ivb_crc_source_valid(dev_priv, source);
 +}
 +
 +const char *const *intel_crtc_get_crc_sources(struct drm_crtc *crtc,
 +                                            size_t *count)
 +{
 +      *count = ARRAY_SIZE(pipe_crc_sources);
 +      return pipe_crc_sources;
 +}
 +
 +int intel_crtc_verify_crc_source(struct drm_crtc *crtc, const char *source_name,
 +                               size_t *values_cnt)
 +{
 +      struct drm_i915_private *dev_priv = to_i915(crtc->dev);
 +      enum intel_pipe_crc_source source;
 +
 +      if (display_crc_ctl_parse_source(source_name, &source) < 0) {
 +              DRM_DEBUG_DRIVER("unknown source %s\n", source_name);
 +              return -EINVAL;
 +      }
 +
 +      if (source == INTEL_PIPE_CRC_SOURCE_AUTO ||
 +          intel_is_valid_crc_source(dev_priv, source) == 0) {
 +              *values_cnt = 5;
 +              return 0;
 +      }
 +
 +      return -EINVAL;
 +}
 +
 +int intel_crtc_set_crc_source(struct drm_crtc *crtc, const char *source_name)
  {
        struct drm_i915_private *dev_priv = to_i915(crtc->dev);
        struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[crtc->index];
        }
  
        pipe_crc->skipped = 0;
 -      *values_cnt = 5;
  
  out:
        intel_display_power_put(dev_priv, power_domain);
index 688ad9bb0f086ead01321382a2f3181c0df170b3,cfb50fedfa2b3a49bd37198f093eff841ecd3603..cf78f74bb87f4670efd78be4cf439a0543e59f3c
@@@ -200,7 -200,9 +200,7 @@@ static void vc4_plane_reset(struct drm_
        if (!vc4_state)
                return;
  
 -      plane->state = &vc4_state->base;
 -      plane->state->alpha = DRM_BLEND_ALPHA_OPAQUE;
 -      vc4_state->base.plane = plane;
 +      __drm_atomic_helper_plane_reset(plane, &vc4_state->base);
  }
  
  static void vc4_dlist_write(struct vc4_plane_state *vc4_state, u32 val)
@@@ -318,6 -320,9 +318,9 @@@ static int vc4_plane_setup_clipping_and
                        vc4_state->x_scaling[0] = VC4_SCALING_TPZ;
                if (vc4_state->y_scaling[0] == VC4_SCALING_NONE)
                        vc4_state->y_scaling[0] = VC4_SCALING_TPZ;
+       } else {
+               vc4_state->x_scaling[1] = VC4_SCALING_NONE;
+               vc4_state->y_scaling[1] = VC4_SCALING_NONE;
        }
  
        vc4_state->is_unity = (vc4_state->x_scaling[0] == VC4_SCALING_NONE &&
index 5d78bd97e69c0e6fd2aad98dac4628de8dd2f022,6e728b8252596e02745831eee0a5351f698d8c11..bd9d4b2389bd9ee085b08888dc084aac37867e6e
@@@ -44,9 -44,9 +44,10 @@@ static void vkms_release(struct drm_dev
        struct vkms_device *vkms = container_of(dev, struct vkms_device, drm);
  
        platform_device_unregister(vkms->platform);
+       drm_atomic_helper_shutdown(&vkms->drm);
        drm_mode_config_cleanup(&vkms->drm);
        drm_dev_fini(&vkms->drm);
 +      destroy_workqueue(vkms->output.crc_workq);
  }
  
  static struct drm_driver vkms_driver = {
index 61824e360619c5d13650526d2aedf1dbcbfd5774,23beff5d8e3c37e6904314db295cc9896657a38f..0c25bb8faf80d6ef0527b8f8c60767e4e4cea5b9
@@@ -85,10 -85,10 +85,10 @@@ static int vmw_cursor_update_image(stru
        return 0;
  }
  
- static int vmw_cursor_update_dmabuf(struct vmw_private *dev_priv,
-                                   struct vmw_dma_buffer *dmabuf,
-                                   u32 width, u32 height,
-                                   u32 hotspotX, u32 hotspotY)
+ static int vmw_cursor_update_bo(struct vmw_private *dev_priv,
+                               struct vmw_buffer_object *bo,
+                               u32 width, u32 height,
+                               u32 hotspotX, u32 hotspotY)
  {
        struct ttm_bo_kmap_obj map;
        unsigned long kmap_offset;
        kmap_offset = 0;
        kmap_num = (width*height*4 + PAGE_SIZE - 1) >> PAGE_SHIFT;
  
-       ret = ttm_bo_reserve(&dmabuf->base, true, false, NULL);
+       ret = ttm_bo_reserve(&bo->base, true, false, NULL);
        if (unlikely(ret != 0)) {
                DRM_ERROR("reserve failed\n");
                return -EINVAL;
        }
  
-       ret = ttm_bo_kmap(&dmabuf->base, kmap_offset, kmap_num, &map);
+       ret = ttm_bo_kmap(&bo->base, kmap_offset, kmap_num, &map);
        if (unlikely(ret != 0))
                goto err_unreserve;
  
  
        ttm_bo_kunmap(&map);
  err_unreserve:
-       ttm_bo_unreserve(&dmabuf->base);
+       ttm_bo_unreserve(&bo->base);
  
        return ret;
  }
@@@ -352,13 -352,13 +352,13 @@@ vmw_du_cursor_plane_prepare_fb(struct d
        if (vps->surf)
                vmw_surface_unreference(&vps->surf);
  
-       if (vps->dmabuf)
-               vmw_dmabuf_unreference(&vps->dmabuf);
+       if (vps->bo)
+               vmw_bo_unreference(&vps->bo);
  
        if (fb) {
-               if (vmw_framebuffer_to_vfb(fb)->dmabuf) {
-                       vps->dmabuf = vmw_framebuffer_to_vfbd(fb)->buffer;
-                       vmw_dmabuf_reference(vps->dmabuf);
+               if (vmw_framebuffer_to_vfb(fb)->bo) {
+                       vps->bo = vmw_framebuffer_to_vfbd(fb)->buffer;
+                       vmw_bo_reference(vps->bo);
                } else {
                        vps->surf = vmw_framebuffer_to_vfbs(fb)->surface;
                        vmw_surface_reference(vps->surf);
@@@ -390,7 -390,7 +390,7 @@@ vmw_du_cursor_plane_atomic_update(struc
        }
  
        du->cursor_surface = vps->surf;
-       du->cursor_dmabuf = vps->dmabuf;
+       du->cursor_bo = vps->bo;
  
        if (vps->surf) {
                du->cursor_age = du->cursor_surface->snooper.age;
                                              vps->surf->snooper.image,
                                              64, 64, hotspot_x,
                                              hotspot_y);
-       } else if (vps->dmabuf) {
-               ret = vmw_cursor_update_dmabuf(dev_priv, vps->dmabuf,
-                                              plane->state->crtc_w,
-                                              plane->state->crtc_h,
-                                              hotspot_x, hotspot_y);
+       } else if (vps->bo) {
+               ret = vmw_cursor_update_bo(dev_priv, vps->bo,
+                                          plane->state->crtc_w,
+                                          plane->state->crtc_h,
+                                          hotspot_x, hotspot_y);
        } else {
                vmw_cursor_update_position(dev_priv, false, 0, 0);
                return;
@@@ -519,7 -519,7 +519,7 @@@ int vmw_du_cursor_plane_atomic_check(st
                ret = -EINVAL;
        }
  
-       if (!vmw_framebuffer_to_vfb(fb)->dmabuf)
+       if (!vmw_framebuffer_to_vfb(fb)->bo)
                surface = vmw_framebuffer_to_vfbs(fb)->surface;
  
        if (surface && !surface->snooper.image) {
@@@ -687,8 -687,8 +687,8 @@@ vmw_du_plane_duplicate_state(struct drm
        if (vps->surf)
                (void) vmw_surface_reference(vps->surf);
  
-       if (vps->dmabuf)
-               (void) vmw_dmabuf_reference(vps->dmabuf);
+       if (vps->bo)
+               (void) vmw_bo_reference(vps->bo);
  
        state = &vps->base;
  
@@@ -720,7 -720,9 +720,7 @@@ void vmw_du_plane_reset(struct drm_plan
                return;
        }
  
 -      plane->state = &vps->base;
 -      plane->state->plane = plane;
 -      plane->state->rotation = DRM_MODE_ROTATE_0;
 +      __drm_atomic_helper_plane_reset(plane, &vps->base);
  }
  
  
@@@ -743,8 -745,8 +743,8 @@@ vmw_du_plane_destroy_state(struct drm_p
        if (vps->surf)
                vmw_surface_unreference(&vps->surf);
  
-       if (vps->dmabuf)
-               vmw_dmabuf_unreference(&vps->dmabuf);
+       if (vps->bo)
+               vmw_bo_unreference(&vps->bo);
  
        drm_atomic_helper_plane_destroy_state(plane, state);
  }
@@@ -900,12 -902,12 +900,12 @@@ static int vmw_framebuffer_surface_dirt
  
  /**
   * vmw_kms_readback - Perform a readback from the screen system to
-  * a dma-buffer backed framebuffer.
+  * a buffer-object backed framebuffer.
   *
   * @dev_priv: Pointer to the device private structure.
   * @file_priv: Pointer to a struct drm_file identifying the caller.
   * Must be set to NULL if @user_fence_rep is NULL.
-  * @vfb: Pointer to the dma-buffer backed framebuffer.
+  * @vfb: Pointer to the buffer-object backed framebuffer.
   * @user_fence_rep: User-space provided structure for fence information.
   * Must be set to non-NULL if @file_priv is non-NULL.
   * @vclips: Array of clip rects.
@@@ -949,7 -951,7 +949,7 @@@ static int vmw_kms_new_framebuffer_surf
                                           struct vmw_framebuffer **out,
                                           const struct drm_mode_fb_cmd2
                                           *mode_cmd,
-                                          bool is_dmabuf_proxy)
+                                          bool is_bo_proxy)
  
  {
        struct drm_device *dev = dev_priv->dev;
        drm_helper_mode_fill_fb_struct(dev, &vfbs->base.base, mode_cmd);
        vfbs->surface = vmw_surface_reference(surface);
        vfbs->base.user_handle = mode_cmd->handles[0];
-       vfbs->is_dmabuf_proxy = is_dmabuf_proxy;
+       vfbs->is_bo_proxy = is_bo_proxy;
  
        *out = &vfbs->base;
  
@@@ -1036,30 -1038,30 +1036,30 @@@ out_err1
  }
  
  /*
-  * Dmabuf framebuffer code
+  * Buffer-object framebuffer code
   */
  
- static void vmw_framebuffer_dmabuf_destroy(struct drm_framebuffer *framebuffer)
+ static void vmw_framebuffer_bo_destroy(struct drm_framebuffer *framebuffer)
  {
-       struct vmw_framebuffer_dmabuf *vfbd =
+       struct vmw_framebuffer_bo *vfbd =
                vmw_framebuffer_to_vfbd(framebuffer);
  
        drm_framebuffer_cleanup(framebuffer);
-       vmw_dmabuf_unreference(&vfbd->buffer);
+       vmw_bo_unreference(&vfbd->buffer);
        if (vfbd->base.user_obj)
                ttm_base_object_unref(&vfbd->base.user_obj);
  
        kfree(vfbd);
  }
  
- static int vmw_framebuffer_dmabuf_dirty(struct drm_framebuffer *framebuffer,
-                                struct drm_file *file_priv,
-                                unsigned flags, unsigned color,
-                                struct drm_clip_rect *clips,
-                                unsigned num_clips)
+ static int vmw_framebuffer_bo_dirty(struct drm_framebuffer *framebuffer,
+                                   struct drm_file *file_priv,
+                                   unsigned int flags, unsigned int color,
+                                   struct drm_clip_rect *clips,
+                                   unsigned int num_clips)
  {
        struct vmw_private *dev_priv = vmw_priv(framebuffer->dev);
-       struct vmw_framebuffer_dmabuf *vfbd =
+       struct vmw_framebuffer_bo *vfbd =
                vmw_framebuffer_to_vfbd(framebuffer);
        struct drm_clip_rect norect;
        int ret, increment = 1;
                                       true, true, NULL);
                break;
        case vmw_du_screen_object:
-               ret = vmw_kms_sou_do_dmabuf_dirty(dev_priv, &vfbd->base,
-                                                 clips, NULL, num_clips,
-                                                 increment, true, NULL, NULL);
+               ret = vmw_kms_sou_do_bo_dirty(dev_priv, &vfbd->base,
+                                             clips, NULL, num_clips,
+                                             increment, true, NULL, NULL);
                break;
        case vmw_du_legacy:
-               ret = vmw_kms_ldu_do_dmabuf_dirty(dev_priv, &vfbd->base, 0, 0,
-                                                 clips, num_clips, increment);
+               ret = vmw_kms_ldu_do_bo_dirty(dev_priv, &vfbd->base, 0, 0,
+                                             clips, num_clips, increment);
                break;
        default:
                ret = -EINVAL;
        return ret;
  }
  
- static const struct drm_framebuffer_funcs vmw_framebuffer_dmabuf_funcs = {
-       .destroy = vmw_framebuffer_dmabuf_destroy,
-       .dirty = vmw_framebuffer_dmabuf_dirty,
+ static const struct drm_framebuffer_funcs vmw_framebuffer_bo_funcs = {
+       .destroy = vmw_framebuffer_bo_destroy,
+       .dirty = vmw_framebuffer_bo_dirty,
  };
  
  /**
-  * Pin the dmabuffer in a location suitable for access by the
+  * Pin the bofer in a location suitable for access by the
   * display system.
   */
  static int vmw_framebuffer_pin(struct vmw_framebuffer *vfb)
  {
        struct vmw_private *dev_priv = vmw_priv(vfb->base.dev);
-       struct vmw_dma_buffer *buf;
+       struct vmw_buffer_object *buf;
        struct ttm_placement *placement;
        int ret;
  
-       buf = vfb->dmabuf ?  vmw_framebuffer_to_vfbd(&vfb->base)->buffer :
+       buf = vfb->bo ?  vmw_framebuffer_to_vfbd(&vfb->base)->buffer :
                vmw_framebuffer_to_vfbs(&vfb->base)->surface->res.backup;
  
        if (!buf)
        switch (dev_priv->active_display_unit) {
        case vmw_du_legacy:
                vmw_overlay_pause_all(dev_priv);
-               ret = vmw_dmabuf_pin_in_start_of_vram(dev_priv, buf, false);
+               ret = vmw_bo_pin_in_start_of_vram(dev_priv, buf, false);
                vmw_overlay_resume_all(dev_priv);
                break;
        case vmw_du_screen_object:
        case vmw_du_screen_target:
-               if (vfb->dmabuf) {
+               if (vfb->bo) {
                        if (dev_priv->capabilities & SVGA_CAP_3D) {
                                /*
                                 * Use surface DMA to get content to
                        placement = &vmw_mob_placement;
                }
  
-               return vmw_dmabuf_pin_in_placement(dev_priv, buf, placement,
-                                                  false);
+               return vmw_bo_pin_in_placement(dev_priv, buf, placement, false);
        default:
                return -EINVAL;
        }
  static int vmw_framebuffer_unpin(struct vmw_framebuffer *vfb)
  {
        struct vmw_private *dev_priv = vmw_priv(vfb->base.dev);
-       struct vmw_dma_buffer *buf;
+       struct vmw_buffer_object *buf;
  
-       buf = vfb->dmabuf ?  vmw_framebuffer_to_vfbd(&vfb->base)->buffer :
+       buf = vfb->bo ?  vmw_framebuffer_to_vfbd(&vfb->base)->buffer :
                vmw_framebuffer_to_vfbs(&vfb->base)->surface->res.backup;
  
        if (WARN_ON(!buf))
                return 0;
  
-       return vmw_dmabuf_unpin(dev_priv, buf, false);
+       return vmw_bo_unpin(dev_priv, buf, false);
  }
  
  /**
-  * vmw_create_dmabuf_proxy - create a proxy surface for the DMA buf
+  * vmw_create_bo_proxy - create a proxy surface for the buffer object
   *
   * @dev: DRM device
   * @mode_cmd: parameters for the new surface
-  * @dmabuf_mob: MOB backing the DMA buf
+  * @bo_mob: MOB backing the buffer object
   * @srf_out: newly created surface
   *
-  * When the content FB is a DMA buf, we create a surface as a proxy to the
+  * When the content FB is a buffer object, we create a surface as a proxy to the
   * same buffer.  This way we can do a surface copy rather than a surface DMA.
   * This is a more efficient approach
   *
   * RETURNS:
   * 0 on success, error code otherwise
   */
- static int vmw_create_dmabuf_proxy(struct drm_device *dev,
-                                  const struct drm_mode_fb_cmd2 *mode_cmd,
-                                  struct vmw_dma_buffer *dmabuf_mob,
-                                  struct vmw_surface **srf_out)
+ static int vmw_create_bo_proxy(struct drm_device *dev,
+                              const struct drm_mode_fb_cmd2 *mode_cmd,
+                              struct vmw_buffer_object *bo_mob,
+                              struct vmw_surface **srf_out)
  {
        uint32_t format;
        struct drm_vmw_size content_base_size = {0};
        content_base_size.depth  = 1;
  
        ret = vmw_surface_gb_priv_define(dev,
-                       0, /* kernel visible only */
-                       0, /* flags */
-                       format,
-                       true, /* can be a scanout buffer */
-                       1, /* num of mip levels */
-                       0,
-                       0,
-                       content_base_size,
-                       srf_out);
+                                        0, /* kernel visible only */
+                                        0, /* flags */
+                                        format,
+                                        true, /* can be a scanout buffer */
+                                        1, /* num of mip levels */
+                                        0,
+                                        0,
+                                        content_base_size,
+                                        SVGA3D_MS_PATTERN_NONE,
+                                        SVGA3D_MS_QUALITY_NONE,
+                                        srf_out);
        if (ret) {
                DRM_ERROR("Failed to allocate proxy content buffer\n");
                return ret;
        /* Reserve and switch the backing mob. */
        mutex_lock(&res->dev_priv->cmdbuf_mutex);
        (void) vmw_resource_reserve(res, false, true);
-       vmw_dmabuf_unreference(&res->backup);
-       res->backup = vmw_dmabuf_reference(dmabuf_mob);
+       vmw_bo_unreference(&res->backup);
+       res->backup = vmw_bo_reference(bo_mob);
        res->backup_offset = 0;
        vmw_resource_unreserve(res, false, NULL, 0);
        mutex_unlock(&res->dev_priv->cmdbuf_mutex);
  
  
  
- static int vmw_kms_new_framebuffer_dmabuf(struct vmw_private *dev_priv,
-                                         struct vmw_dma_buffer *dmabuf,
-                                         struct vmw_framebuffer **out,
-                                         const struct drm_mode_fb_cmd2
-                                         *mode_cmd)
+ static int vmw_kms_new_framebuffer_bo(struct vmw_private *dev_priv,
+                                     struct vmw_buffer_object *bo,
+                                     struct vmw_framebuffer **out,
+                                     const struct drm_mode_fb_cmd2
+                                     *mode_cmd)
  
  {
        struct drm_device *dev = dev_priv->dev;
-       struct vmw_framebuffer_dmabuf *vfbd;
+       struct vmw_framebuffer_bo *vfbd;
        unsigned int requested_size;
        struct drm_format_name_buf format_name;
        int ret;
  
        requested_size = mode_cmd->height * mode_cmd->pitches[0];
-       if (unlikely(requested_size > dmabuf->base.num_pages * PAGE_SIZE)) {
+       if (unlikely(requested_size > bo->base.num_pages * PAGE_SIZE)) {
                DRM_ERROR("Screen buffer object size is too small "
                          "for requested mode.\n");
                return -EINVAL;
        }
  
        drm_helper_mode_fill_fb_struct(dev, &vfbd->base.base, mode_cmd);
-       vfbd->base.dmabuf = true;
-       vfbd->buffer = vmw_dmabuf_reference(dmabuf);
+       vfbd->base.bo = true;
+       vfbd->buffer = vmw_bo_reference(bo);
        vfbd->base.user_handle = mode_cmd->handles[0];
        *out = &vfbd->base;
  
        ret = drm_framebuffer_init(dev, &vfbd->base.base,
-                                  &vmw_framebuffer_dmabuf_funcs);
+                                  &vmw_framebuffer_bo_funcs);
        if (ret)
                goto out_err2;
  
        return 0;
  
  out_err2:
-       vmw_dmabuf_unreference(&dmabuf);
+       vmw_bo_unreference(&bo);
        kfree(vfbd);
  out_err1:
        return ret;
@@@ -1352,57 -1355,57 +1353,57 @@@ vmw_kms_srf_ok(struct vmw_private *dev_
   * vmw_kms_new_framebuffer - Create a new framebuffer.
   *
   * @dev_priv: Pointer to device private struct.
-  * @dmabuf: Pointer to dma buffer to wrap the kms framebuffer around.
-  * Either @dmabuf or @surface must be NULL.
+  * @bo: Pointer to buffer object to wrap the kms framebuffer around.
+  * Either @bo or @surface must be NULL.
   * @surface: Pointer to a surface to wrap the kms framebuffer around.
-  * Either @dmabuf or @surface must be NULL.
-  * @only_2d: No presents will occur to this dma buffer based framebuffer. This
-  * Helps the code to do some important optimizations.
+  * Either @bo or @surface must be NULL.
+  * @only_2d: No presents will occur to this buffer object based framebuffer.
+  * This helps the code to do some important optimizations.
   * @mode_cmd: Frame-buffer metadata.
   */
  struct vmw_framebuffer *
  vmw_kms_new_framebuffer(struct vmw_private *dev_priv,
-                       struct vmw_dma_buffer *dmabuf,
+                       struct vmw_buffer_object *bo,
                        struct vmw_surface *surface,
                        bool only_2d,
                        const struct drm_mode_fb_cmd2 *mode_cmd)
  {
        struct vmw_framebuffer *vfb = NULL;
-       bool is_dmabuf_proxy = false;
+       bool is_bo_proxy = false;
        int ret;
  
        /*
         * We cannot use the SurfaceDMA command in an non-accelerated VM,
-        * therefore, wrap the DMA buf in a surface so we can use the
+        * therefore, wrap the buffer object in a surface so we can use the
         * SurfaceCopy command.
         */
        if (vmw_kms_srf_ok(dev_priv, mode_cmd->width, mode_cmd->height)  &&
-           dmabuf && only_2d &&
+           bo && only_2d &&
            mode_cmd->width > 64 &&  /* Don't create a proxy for cursor */
            dev_priv->active_display_unit == vmw_du_screen_target) {
-               ret = vmw_create_dmabuf_proxy(dev_priv->dev, mode_cmd,
-                                             dmabuf, &surface);
+               ret = vmw_create_bo_proxy(dev_priv->dev, mode_cmd,
+                                         bo, &surface);
                if (ret)
                        return ERR_PTR(ret);
  
-               is_dmabuf_proxy = true;
+               is_bo_proxy = true;
        }
  
        /* Create the new framebuffer depending one what we have */
        if (surface) {
                ret = vmw_kms_new_framebuffer_surface(dev_priv, surface, &vfb,
                                                      mode_cmd,
-                                                     is_dmabuf_proxy);
+                                                     is_bo_proxy);
  
                /*
-                * vmw_create_dmabuf_proxy() adds a reference that is no longer
+                * vmw_create_bo_proxy() adds a reference that is no longer
                 * needed
                 */
-               if (is_dmabuf_proxy)
+               if (is_bo_proxy)
                        vmw_surface_unreference(&surface);
-       } else if (dmabuf) {
-               ret = vmw_kms_new_framebuffer_dmabuf(dev_priv, dmabuf, &vfb,
-                                                    mode_cmd);
+       } else if (bo) {
+               ret = vmw_kms_new_framebuffer_bo(dev_priv, bo, &vfb,
+                                                mode_cmd);
        } else {
                BUG();
        }
@@@ -1428,23 -1431,10 +1429,10 @@@ static struct drm_framebuffer *vmw_kms_
        struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
        struct vmw_framebuffer *vfb = NULL;
        struct vmw_surface *surface = NULL;
-       struct vmw_dma_buffer *bo = NULL;
+       struct vmw_buffer_object *bo = NULL;
        struct ttm_base_object *user_obj;
        int ret;
  
-       /**
-        * This code should be conditioned on Screen Objects not being used.
-        * If screen objects are used, we can allocate a GMR to hold the
-        * requested framebuffer.
-        */
-       if (!vmw_kms_validate_mode_vram(dev_priv,
-                                       mode_cmd->pitches[0],
-                                       mode_cmd->height)) {
-               DRM_ERROR("Requested mode exceed bounding box limit.\n");
-               return ERR_PTR(-ENOMEM);
-       }
        /*
         * Take a reference on the user object of the resource
         * backing the kms fb. This ensures that user-space handle
         * End conditioned code.
         */
  
-       /* returns either a dmabuf or surface */
+       /* returns either a bo or surface */
        ret = vmw_user_lookup_handle(dev_priv, tfile,
                                     mode_cmd->handles[0],
                                     &surface, &bo);
  err_out:
        /* vmw_user_lookup_handle takes one ref so does new_fb */
        if (bo)
-               vmw_dmabuf_unreference(&bo);
+               vmw_bo_unreference(&bo);
        if (surface)
                vmw_surface_unreference(&surface);
  
        return &vfb->base;
  }
  
+ /**
+  * vmw_kms_check_display_memory - Validates display memory required for a
+  * topology
+  * @dev: DRM device
+  * @num_rects: number of drm_rect in rects
+  * @rects: array of drm_rect representing the topology to validate indexed by
+  * crtc index.
+  *
+  * Returns:
+  * 0 on success otherwise negative error code
+  */
+ static int vmw_kms_check_display_memory(struct drm_device *dev,
+                                       uint32_t num_rects,
+                                       struct drm_rect *rects)
+ {
+       struct vmw_private *dev_priv = vmw_priv(dev);
+       struct drm_mode_config *mode_config = &dev->mode_config;
+       struct drm_rect bounding_box = {0};
+       u64 total_pixels = 0, pixel_mem, bb_mem;
+       int i;
+       for (i = 0; i < num_rects; i++) {
+               /*
+                * Currently this check is limiting the topology within max
+                * texture/screentarget size. This should change in future when
+                * user-space support multiple fb with topology.
+                */
+               if (rects[i].x1 < 0 ||  rects[i].y1 < 0 ||
+                   rects[i].x2 > mode_config->max_width ||
+                   rects[i].y2 > mode_config->max_height) {
+                       DRM_ERROR("Invalid GUI layout.\n");
+                       return -EINVAL;
+               }
+               /* Bounding box upper left is at (0,0). */
+               if (rects[i].x2 > bounding_box.x2)
+                       bounding_box.x2 = rects[i].x2;
+               if (rects[i].y2 > bounding_box.y2)
+                       bounding_box.y2 = rects[i].y2;
+               total_pixels += (u64) drm_rect_width(&rects[i]) *
+                       (u64) drm_rect_height(&rects[i]);
+       }
+       /* Virtual svga device primary limits are always in 32-bpp. */
+       pixel_mem = total_pixels * 4;
+       /*
+        * For HV10 and below prim_bb_mem is vram size. When
+        * SVGA_REG_MAX_PRIMARY_BOUNDING_BOX_MEM is not present vram size is
+        * limit on primary bounding box
+        */
+       if (pixel_mem > dev_priv->prim_bb_mem) {
+               DRM_ERROR("Combined output size too large.\n");
+               return -EINVAL;
+       }
+       /* SVGA_CAP_NO_BB_RESTRICTION is available for STDU only. */
+       if (dev_priv->active_display_unit != vmw_du_screen_target ||
+           !(dev_priv->capabilities & SVGA_CAP_NO_BB_RESTRICTION)) {
+               bb_mem = (u64) bounding_box.x2 * bounding_box.y2 * 4;
+               if (bb_mem > dev_priv->prim_bb_mem) {
+                       DRM_ERROR("Topology is beyond supported limits.\n");
+                       return -EINVAL;
+               }
+       }
+       return 0;
+ }
+ /**
+  * vmw_kms_check_topology - Validates topology in drm_atomic_state
+  * @dev: DRM device
+  * @state: the driver state object
+  *
+  * Returns:
+  * 0 on success otherwise negative error code
+  */
+ static int vmw_kms_check_topology(struct drm_device *dev,
+                                 struct drm_atomic_state *state)
+ {
+       struct vmw_private *dev_priv = vmw_priv(dev);
+       struct drm_crtc_state *old_crtc_state, *new_crtc_state;
+       struct drm_rect *rects;
+       struct drm_crtc *crtc;
+       uint32_t i;
+       int ret = 0;
+       rects = kcalloc(dev->mode_config.num_crtc, sizeof(struct drm_rect),
+                       GFP_KERNEL);
+       if (!rects)
+               return -ENOMEM;
+       mutex_lock(&dev_priv->requested_layout_mutex);
+       drm_for_each_crtc(crtc, dev) {
+               struct vmw_display_unit *du = vmw_crtc_to_du(crtc);
+               struct drm_crtc_state *crtc_state = crtc->state;
+               i = drm_crtc_index(crtc);
+               if (crtc_state && crtc_state->enable) {
+                       rects[i].x1 = du->gui_x;
+                       rects[i].y1 = du->gui_y;
+                       rects[i].x2 = du->gui_x + crtc_state->mode.hdisplay;
+                       rects[i].y2 = du->gui_y + crtc_state->mode.vdisplay;
+               }
+       }
+       /* Determine change to topology due to new atomic state */
+       for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state,
+                                     new_crtc_state, i) {
+               struct vmw_display_unit *du = vmw_crtc_to_du(crtc);
+               struct drm_connector *connector;
+               struct drm_connector_state *conn_state;
+               struct vmw_connector_state *vmw_conn_state;
+               if (!new_crtc_state->enable && old_crtc_state->enable) {
+                       rects[i].x1 = 0;
+                       rects[i].y1 = 0;
+                       rects[i].x2 = 0;
+                       rects[i].y2 = 0;
+                       continue;
+               }
+               if (!du->pref_active) {
+                       ret = -EINVAL;
+                       goto clean;
+               }
+               /*
+                * For vmwgfx each crtc has only one connector attached and it
+                * is not changed so don't really need to check the
+                * crtc->connector_mask and iterate over it.
+                */
+               connector = &du->connector;
+               conn_state = drm_atomic_get_connector_state(state, connector);
+               if (IS_ERR(conn_state)) {
+                       ret = PTR_ERR(conn_state);
+                       goto clean;
+               }
+               vmw_conn_state = vmw_connector_state_to_vcs(conn_state);
+               vmw_conn_state->gui_x = du->gui_x;
+               vmw_conn_state->gui_y = du->gui_y;
+               rects[i].x1 = du->gui_x;
+               rects[i].y1 = du->gui_y;
+               rects[i].x2 = du->gui_x + new_crtc_state->mode.hdisplay;
+               rects[i].y2 = du->gui_y + new_crtc_state->mode.vdisplay;
+       }
+       ret = vmw_kms_check_display_memory(dev, dev->mode_config.num_crtc,
+                                          rects);
  
+ clean:
+       mutex_unlock(&dev_priv->requested_layout_mutex);
+       kfree(rects);
+       return ret;
+ }
  
  /**
   * vmw_kms_atomic_check_modeset- validate state object for modeset changes
   * us to assign a value to mode->crtc_clock so that
   * drm_calc_timestamping_constants() won't throw an error message
   *
-  * RETURNS
+  * Returns:
   * Zero for success or -errno
   */
  static int
  vmw_kms_atomic_check_modeset(struct drm_device *dev,
                             struct drm_atomic_state *state)
  {
-       struct drm_crtc_state *crtc_state;
        struct drm_crtc *crtc;
-       struct vmw_private *dev_priv = vmw_priv(dev);
-       int i;
-       for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
-               unsigned long requested_bb_mem = 0;
-               if (dev_priv->active_display_unit == vmw_du_screen_target) {
-                       struct drm_plane *plane = crtc->primary;
-                       struct drm_plane_state *plane_state;
-                       plane_state = drm_atomic_get_new_plane_state(state, plane);
+       struct drm_crtc_state *crtc_state;
+       bool need_modeset = false;
+       int i, ret;
  
-                       if (plane_state && plane_state->fb) {
-                               int cpp = plane_state->fb->format->cpp[0];
+       ret = drm_atomic_helper_check(dev, state);
+       if (ret)
+               return ret;
  
-                               requested_bb_mem += crtc->mode.hdisplay * cpp *
-                                                   crtc->mode.vdisplay;
-                       }
+       if (!state->allow_modeset)
+               return ret;
  
-                       if (requested_bb_mem > dev_priv->prim_bb_mem)
-                               return -EINVAL;
-               }
+       /*
+        * Legacy path do not set allow_modeset properly like
+        * @drm_atomic_helper_update_plane, This will result in unnecessary call
+        * to vmw_kms_check_topology. So extra set of check.
+        */
+       for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
+               if (drm_atomic_crtc_needs_modeset(crtc_state))
+                       need_modeset = true;
        }
  
-       return drm_atomic_helper_check(dev, state);
+       if (need_modeset)
+               return vmw_kms_check_topology(dev, state);
+       return ret;
  }
  
  static const struct drm_mode_config_funcs vmw_kms_funcs = {
@@@ -1843,40 -1993,49 +1991,49 @@@ void vmw_disable_vblank(struct drm_devi
  {
  }
  
- /*
-  * Small shared kms functions.
+ /**
+  * vmw_du_update_layout - Update the display unit with topology from resolution
+  * plugin and generate DRM uevent
+  * @dev_priv: device private
+  * @num_rects: number of drm_rect in rects
+  * @rects: toplogy to update
   */
- static int vmw_du_update_layout(struct vmw_private *dev_priv, unsigned num,
-                        struct drm_vmw_rect *rects)
+ static int vmw_du_update_layout(struct vmw_private *dev_priv,
+                               unsigned int num_rects, struct drm_rect *rects)
  {
        struct drm_device *dev = dev_priv->dev;
        struct vmw_display_unit *du;
        struct drm_connector *con;
+       struct drm_connector_list_iter conn_iter;
  
-       mutex_lock(&dev->mode_config.mutex);
- #if 0
-       {
-               unsigned int i;
-               DRM_INFO("%s: new layout ", __func__);
-               for (i = 0; i < num; i++)
-                       DRM_INFO("(%i, %i %ux%u) ", rects[i].x, rects[i].y,
-                                rects[i].w, rects[i].h);
-               DRM_INFO("\n");
+       /*
+        * Currently only gui_x/y is protected with requested_layout_mutex.
+        */
+       mutex_lock(&dev_priv->requested_layout_mutex);
+       drm_connector_list_iter_begin(dev, &conn_iter);
+       drm_for_each_connector_iter(con, &conn_iter) {
+               du = vmw_connector_to_du(con);
+               if (num_rects > du->unit) {
+                       du->pref_width = drm_rect_width(&rects[du->unit]);
+                       du->pref_height = drm_rect_height(&rects[du->unit]);
+                       du->pref_active = true;
+                       du->gui_x = rects[du->unit].x1;
+                       du->gui_y = rects[du->unit].y1;
+               } else {
+                       du->pref_width = 800;
+                       du->pref_height = 600;
+                       du->pref_active = false;
+                       du->gui_x = 0;
+                       du->gui_y = 0;
+               }
        }
- #endif
+       drm_connector_list_iter_end(&conn_iter);
+       mutex_unlock(&dev_priv->requested_layout_mutex);
  
+       mutex_lock(&dev->mode_config.mutex);
        list_for_each_entry(con, &dev->mode_config.connector_list, head) {
                du = vmw_connector_to_du(con);
-               if (num > du->unit) {
-                       du->pref_width = rects[du->unit].w;
-                       du->pref_height = rects[du->unit].h;
-                       du->pref_active = true;
-                       du->gui_x = rects[du->unit].x;
-                       du->gui_y = rects[du->unit].y;
+               if (num_rects > du->unit) {
                        drm_object_property_set_value
                          (&con->base, dev->mode_config.suggested_x_property,
                           du->gui_x);
                          (&con->base, dev->mode_config.suggested_y_property,
                           du->gui_y);
                } else {
-                       du->pref_width = 800;
-                       du->pref_height = 600;
-                       du->pref_active = false;
                        drm_object_property_set_value
                          (&con->base, dev->mode_config.suggested_x_property,
                           0);
                }
                con->status = vmw_du_connector_detect(con, true);
        }
        mutex_unlock(&dev->mode_config.mutex);
        drm_sysfs_hotplug_event(dev);
  
        return 0;
@@@ -2197,7 -2353,25 +2351,25 @@@ vmw_du_connector_atomic_get_property(st
        return 0;
  }
  
+ /**
+  * vmw_kms_update_layout_ioctl - Handler for DRM_VMW_UPDATE_LAYOUT ioctl
+  * @dev: drm device for the ioctl
+  * @data: data pointer for the ioctl
+  * @file_priv: drm file for the ioctl call
+  *
+  * Update preferred topology of display unit as per ioctl request. The topology
+  * is expressed as array of drm_vmw_rect.
+  * e.g.
+  * [0 0 640 480] [640 0 800 600] [0 480 640 480]
+  *
+  * NOTE:
+  * The x and y offset (upper left) in drm_vmw_rect cannot be less than 0. Beside
+  * device limit on topology, x + w and y + h (lower right) cannot be greater
+  * than INT_MAX. So topology beyond these limits will return with error.
+  *
+  * Returns:
+  * Zero on success, negative errno on failure.
+  */
  int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data,
                                struct drm_file *file_priv)
  {
                (struct drm_vmw_update_layout_arg *)data;
        void __user *user_rects;
        struct drm_vmw_rect *rects;
+       struct drm_rect *drm_rects;
        unsigned rects_size;
-       int ret;
-       int i;
-       u64 total_pixels = 0;
-       struct drm_mode_config *mode_config = &dev->mode_config;
-       struct drm_vmw_rect bounding_box = {0};
+       int ret, i;
  
        if (!arg->num_outputs) {
-               struct drm_vmw_rect def_rect = {0, 0, 800, 600};
+               struct drm_rect def_rect = {0, 0, 800, 600};
                vmw_du_update_layout(dev_priv, 1, &def_rect);
                return 0;
        }
                goto out_free;
        }
  
-       for (i = 0; i < arg->num_outputs; ++i) {
-               if (rects[i].x < 0 ||
-                   rects[i].y < 0 ||
-                   rects[i].x + rects[i].w > mode_config->max_width ||
-                   rects[i].y + rects[i].h > mode_config->max_height) {
-                       DRM_ERROR("Invalid GUI layout.\n");
-                       ret = -EINVAL;
-                       goto out_free;
-               }
-               /*
-                * bounding_box.w and bunding_box.h are used as
-                * lower-right coordinates
-                */
-               if (rects[i].x + rects[i].w > bounding_box.w)
-                       bounding_box.w = rects[i].x + rects[i].w;
-               if (rects[i].y + rects[i].h > bounding_box.h)
-                       bounding_box.h = rects[i].y + rects[i].h;
+       drm_rects = (struct drm_rect *)rects;
  
-               total_pixels += (u64) rects[i].w * (u64) rects[i].h;
-       }
+       for (i = 0; i < arg->num_outputs; i++) {
+               struct drm_vmw_rect curr_rect;
  
-       if (dev_priv->active_display_unit == vmw_du_screen_target) {
-               /*
-                * For Screen Targets, the limits for a toplogy are:
-                *      1. Bounding box (assuming 32bpp) must be < prim_bb_mem
-                *      2. Total pixels (assuming 32bpp) must be < prim_bb_mem
-                */
-               u64 bb_mem    = (u64) bounding_box.w * bounding_box.h * 4;
-               u64 pixel_mem = total_pixels * 4;
-               if (bb_mem > dev_priv->prim_bb_mem) {
-                       DRM_ERROR("Topology is beyond supported limits.\n");
-                       ret = -EINVAL;
+               /* Verify user-space for overflow as kernel use drm_rect */
+               if ((rects[i].x + rects[i].w > INT_MAX) ||
+                   (rects[i].y + rects[i].h > INT_MAX)) {
+                       ret = -ERANGE;
                        goto out_free;
                }
  
-               if (pixel_mem > dev_priv->prim_bb_mem) {
-                       DRM_ERROR("Combined output size too large\n");
-                       ret = -EINVAL;
-                       goto out_free;
-               }
+               curr_rect = rects[i];
+               drm_rects[i].x1 = curr_rect.x;
+               drm_rects[i].y1 = curr_rect.y;
+               drm_rects[i].x2 = curr_rect.x + curr_rect.w;
+               drm_rects[i].y2 = curr_rect.y + curr_rect.h;
        }
  
-       vmw_du_update_layout(dev_priv, arg->num_outputs, rects);
+       ret = vmw_kms_check_display_memory(dev, arg->num_outputs, drm_rects);
+       if (ret == 0)
+               vmw_du_update_layout(dev_priv, arg->num_outputs, drm_rects);
  
  out_free:
        kfree(rects);
@@@ -2425,7 -2573,7 +2571,7 @@@ int vmw_kms_helper_dirty(struct vmw_pri
   * interrupted by a signal.
   */
  int vmw_kms_helper_buffer_prepare(struct vmw_private *dev_priv,
-                                 struct vmw_dma_buffer *buf,
+                                 struct vmw_buffer_object *buf,
                                  bool interruptible,
                                  bool validate_as_mob,
                                  bool for_cpu_blit)
   * Helper to be used if an error forces the caller to undo the actions of
   * vmw_kms_helper_buffer_prepare.
   */
- void vmw_kms_helper_buffer_revert(struct vmw_dma_buffer *buf)
+ void vmw_kms_helper_buffer_revert(struct vmw_buffer_object *buf)
  {
        if (buf)
                ttm_bo_unreserve(&buf->base);
   */
  void vmw_kms_helper_buffer_finish(struct vmw_private *dev_priv,
                                  struct drm_file *file_priv,
-                                 struct vmw_dma_buffer *buf,
+                                 struct vmw_buffer_object *buf,
                                  struct vmw_fence_obj **out_fence,
                                  struct drm_vmw_fence_rep __user *
                                  user_fence_rep)
        ret = vmw_execbuf_fence_commands(file_priv, dev_priv, &fence,
                                         file_priv ? &handle : NULL);
        if (buf)
-               vmw_fence_single_bo(&buf->base, fence);
+               vmw_bo_fence_single(&buf->base, fence);
        if (file_priv)
                vmw_execbuf_copy_fence_user(dev_priv, vmw_fpriv(file_priv),
                                            ret, user_fence_rep, fence,
@@@ -2520,7 -2668,7 +2666,7 @@@ void vmw_kms_helper_resource_revert(str
        struct vmw_resource *res = ctx->res;
  
        vmw_kms_helper_buffer_revert(ctx->buf);
-       vmw_dmabuf_unreference(&ctx->buf);
+       vmw_bo_unreference(&ctx->buf);
        vmw_resource_unreserve(res, false, NULL, 0);
        mutex_unlock(&res->dev_priv->cmdbuf_mutex);
  }
@@@ -2565,7 -2713,7 +2711,7 @@@ int vmw_kms_helper_resource_prepare(str
                if (ret)
                        goto out_unreserve;
  
-               ctx->buf = vmw_dmabuf_reference(res->backup);
+               ctx->buf = vmw_bo_reference(res->backup);
        }
        ret = vmw_resource_validate(res);
        if (ret)
@@@ -2598,7 -2746,7 +2744,7 @@@ void vmw_kms_helper_resource_finish(str
                vmw_kms_helper_buffer_finish(res->dev_priv, NULL, ctx->buf,
                                             out_fence, NULL);
  
-       vmw_dmabuf_unreference(&ctx->buf);
+       vmw_bo_unreference(&ctx->buf);
        vmw_resource_unreserve(res, false, NULL, 0);
        mutex_unlock(&res->dev_priv->cmdbuf_mutex);
  }
diff --combined include/drm/drm_print.h
index fc08584a51019c5ef6fcecf50325c9c09508dae1,f3e6eed3e79c640e04ff1c163701a74a13ee9f40..afbc3beef089a38f3ada870c9002c3e730a8f296
  struct drm_printer {
        /* private: */
        void (*printfn)(struct drm_printer *p, struct va_format *vaf);
+       void (*puts)(struct drm_printer *p, const char *str);
        void *arg;
        const char *prefix;
  };
  
+ void __drm_printfn_coredump(struct drm_printer *p, struct va_format *vaf);
+ void __drm_puts_coredump(struct drm_printer *p, const char *str);
  void __drm_printfn_seq_file(struct drm_printer *p, struct va_format *vaf);
+ void __drm_puts_seq_file(struct drm_printer *p, const char *str);
  void __drm_printfn_info(struct drm_printer *p, struct va_format *vaf);
  void __drm_printfn_debug(struct drm_printer *p, struct va_format *vaf);
  
  __printf(2, 3)
  void drm_printf(struct drm_printer *p, const char *f, ...);
+ void drm_puts(struct drm_printer *p, const char *str);
  
  __printf(2, 0)
  /**
@@@ -104,6 -109,71 +109,71 @@@ drm_vprintf(struct drm_printer *p, cons
  #define drm_printf_indent(printer, indent, fmt, ...) \
        drm_printf((printer), "%.*s" fmt, (indent), "\t\t\t\t\tX", ##__VA_ARGS__)
  
+ /**
+  * struct drm_print_iterator - local struct used with drm_printer_coredump
+  * @data: Pointer to the devcoredump output buffer
+  * @start: The offset within the buffer to start writing
+  * @remain: The number of bytes to write for this iteration
+  */
+ struct drm_print_iterator {
+       void *data;
+       ssize_t start;
+       ssize_t remain;
+       /* private: */
+       ssize_t offset;
+ };
+ /**
+  * drm_coredump_printer - construct a &drm_printer that can output to a buffer
+  * from the read function for devcoredump
+  * @iter: A pointer to a struct drm_print_iterator for the read instance
+  *
+  * This wrapper extends drm_printf() to work with a dev_coredumpm() callback
+  * function. The passed in drm_print_iterator struct contains the buffer
+  * pointer, size and offset as passed in from devcoredump.
+  *
+  * For example::
+  *
+  *    void coredump_read(char *buffer, loff_t offset, size_t count,
+  *            void *data, size_t datalen)
+  *    {
+  *            struct drm_print_iterator iter;
+  *            struct drm_printer p;
+  *
+  *            iter.data = buffer;
+  *            iter.start = offset;
+  *            iter.remain = count;
+  *
+  *            p = drm_coredump_printer(&iter);
+  *
+  *            drm_printf(p, "foo=%d\n", foo);
+  *    }
+  *
+  *    void makecoredump(...)
+  *    {
+  *            ...
+  *            dev_coredumpm(dev, THIS_MODULE, data, 0, GFP_KERNEL,
+  *                    coredump_read, ...)
+  *    }
+  *
+  * RETURNS:
+  * The &drm_printer object
+  */
+ static inline struct drm_printer
+ drm_coredump_printer(struct drm_print_iterator *iter)
+ {
+       struct drm_printer p = {
+               .printfn = __drm_printfn_coredump,
+               .puts = __drm_puts_coredump,
+               .arg = iter,
+       };
+       /* Set the internal offset of the iterator to zero */
+       iter->offset = 0;
+       return p;
+ }
  /**
   * drm_seq_file_printer - construct a &drm_printer that outputs to &seq_file
   * @f:  the &struct seq_file to output to
@@@ -115,6 -185,7 +185,7 @@@ static inline struct drm_printer drm_se
  {
        struct drm_printer p = {
                .printfn = __drm_printfn_seq_file,
+               .puts = __drm_puts_seq_file,
                .arg = f,
        };
        return p;
@@@ -310,7 -381,7 +381,7 @@@ void drm_err(const char *format, ...)
  
  #define       DRM_DEV_DEBUG_DP(dev, fmt, ...)                                 \
        drm_dev_dbg(dev, DRM_UT_DP, fmt, ## __VA_ARGS__)
 -#define DRM_DEBUG_DP(dev, fmt, ...)                                   \
 +#define DRM_DEBUG_DP(fmt, ...)                                                \
        drm_dbg(DRM_UT_DP, fmt, ## __VA_ARGS__)
  
  #define _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, category, fmt, ...)    \
index 21c50b39596f8db373c6dd09284ce78a460e0a97,721ab7e54d96d95afbd895b298729c0e1e172580..2ed46e9ae16aef43b8ef21bb129107f8c1eefd87
  extern "C" {
  #endif
  
 +/**
 + * DOC: overview
 + *
 + * In the DRM subsystem, framebuffer pixel formats are described using the
 + * fourcc codes defined in `include/uapi/drm/drm_fourcc.h`. In addition to the
 + * fourcc code, a Format Modifier may optionally be provided, in order to
 + * further describe the buffer's format - for example tiling or compression.
 + *
 + * Format Modifiers
 + * ----------------
 + *
 + * Format modifiers are used in conjunction with a fourcc code, forming a
 + * unique fourcc:modifier pair. This format:modifier pair must fully define the
 + * format and data layout of the buffer, and should be the only way to describe
 + * that particular buffer.
 + *
 + * Having multiple fourcc:modifier pairs which describe the same layout should
 + * be avoided, as such aliases run the risk of different drivers exposing
 + * different names for the same data format, forcing userspace to understand
 + * that they are aliases.
 + *
 + * Format modifiers may change any property of the buffer, including the number
 + * of planes and/or the required allocation size. Format modifiers are
 + * vendor-namespaced, and as such the relationship between a fourcc code and a
 + * modifier is specific to the modifer being used. For example, some modifiers
 + * may preserve meaning - such as number of planes - from the fourcc code,
 + * whereas others may not.
 + *
 + * Vendors should document their modifier usage in as much detail as
 + * possible, to ensure maximum compatibility across devices, drivers and
 + * applications.
 + *
 + * The authoritative list of format modifier codes is found in
 + * `include/uapi/drm/drm_fourcc.h`
 + */
 +
  #define fourcc_code(a, b, c, d) ((__u32)(a) | ((__u32)(b) << 8) | \
                                 ((__u32)(c) << 16) | ((__u32)(d) << 24))
  
   */
  #define DRM_FORMAT_MOD_SAMSUNG_64_32_TILE     fourcc_mod_code(SAMSUNG, 1)
  
+ /*
+  * Qualcomm Compressed Format
+  *
+  * Refers to a compressed variant of the base format that is compressed.
+  * Implementation may be platform and base-format specific.
+  *
+  * Each macrotile consists of m x n (mostly 4 x 4) tiles.
+  * Pixel data pitch/stride is aligned with macrotile width.
+  * Pixel data height is aligned with macrotile height.
+  * Entire pixel data buffer is aligned with 4k(bytes).
+  */
+ #define DRM_FORMAT_MOD_QCOM_COMPRESSED        fourcc_mod_code(QCOM, 1)
  /* Vivante framebuffer modifiers */
  
  /*