Merge tag 'amd-drm-next-5.8-2020-05-12' of git://people.freedesktop.org/~agd5f/linux...
[linux-block.git] / drivers / gpu / drm / amd / display / amdgpu_dm / amdgpu_dm.c
index f7c5cdc10a705b1b78cfb074596649f55d831639..48f2b3710e7ce88b7a36a2e3dbf759af0451085c 100644 (file)
@@ -30,7 +30,7 @@
 #include "dc.h"
 #include "dc/inc/core_types.h"
 #include "dal_asic_id.h"
-#include "dmub/inc/dmub_srv.h"
+#include "dmub/dmub_srv.h"
 #include "dc/inc/hw/dmcu.h"
 #include "dc/inc/hw/abm.h"
 #include "dc/dc_dmub_srv.h"
@@ -441,7 +441,7 @@ static void dm_vupdate_high_irq(void *interrupt_params)
 
 /**
  * dm_crtc_high_irq() - Handles CRTC interrupt
- * @interrupt_params: ignored
+ * @interrupt_params: used for determining the CRTC instance
  *
  * Handles the CRTC/VSYNC interrupt by notfying DRM's VBLANK
  * event handler.
@@ -455,70 +455,6 @@ static void dm_crtc_high_irq(void *interrupt_params)
        unsigned long flags;
 
        acrtc = get_crtc_by_otg_inst(adev, irq_params->irq_src - IRQ_TYPE_VBLANK);
-
-       if (acrtc) {
-               acrtc_state = to_dm_crtc_state(acrtc->base.state);
-
-               DRM_DEBUG_VBL("crtc:%d, vupdate-vrr:%d\n",
-                             acrtc->crtc_id,
-                             amdgpu_dm_vrr_active(acrtc_state));
-
-               /* Core vblank handling at start of front-porch is only possible
-                * in non-vrr mode, as only there vblank timestamping will give
-                * valid results while done in front-porch. Otherwise defer it
-                * to dm_vupdate_high_irq after end of front-porch.
-                */
-               if (!amdgpu_dm_vrr_active(acrtc_state))
-                       drm_crtc_handle_vblank(&acrtc->base);
-
-               /* Following stuff must happen at start of vblank, for crc
-                * computation and below-the-range btr support in vrr mode.
-                */
-               amdgpu_dm_crtc_handle_crc_irq(&acrtc->base);
-
-               if (acrtc_state->stream && adev->family >= AMDGPU_FAMILY_AI &&
-                   acrtc_state->vrr_params.supported &&
-                   acrtc_state->freesync_config.state == VRR_STATE_ACTIVE_VARIABLE) {
-                       spin_lock_irqsave(&adev->ddev->event_lock, flags);
-                       mod_freesync_handle_v_update(
-                               adev->dm.freesync_module,
-                               acrtc_state->stream,
-                               &acrtc_state->vrr_params);
-
-                       dc_stream_adjust_vmin_vmax(
-                               adev->dm.dc,
-                               acrtc_state->stream,
-                               &acrtc_state->vrr_params.adjust);
-                       spin_unlock_irqrestore(&adev->ddev->event_lock, flags);
-               }
-       }
-}
-
-#if defined(CONFIG_DRM_AMD_DC_DCN)
-/**
- * dm_dcn_crtc_high_irq() - Handles VStartup interrupt for DCN generation ASICs
- * @interrupt params - interrupt parameters
- *
- * Notify DRM's vblank event handler at VSTARTUP
- *
- * Unlike DCE hardware, we trigger the handler at VSTARTUP. at which:
- * * We are close enough to VUPDATE - the point of no return for hw
- * * We are in the fixed portion of variable front porch when vrr is enabled
- * * We are before VUPDATE, where double-buffered vrr registers are swapped
- *
- * It is therefore the correct place to signal vblank, send user flip events,
- * and update VRR.
- */
-static void dm_dcn_crtc_high_irq(void *interrupt_params)
-{
-       struct common_irq_params *irq_params = interrupt_params;
-       struct amdgpu_device *adev = irq_params->adev;
-       struct amdgpu_crtc *acrtc;
-       struct dm_crtc_state *acrtc_state;
-       unsigned long flags;
-
-       acrtc = get_crtc_by_otg_inst(adev, irq_params->irq_src - IRQ_TYPE_VBLANK);
-
        if (!acrtc)
                return;
 
@@ -528,22 +464,35 @@ static void dm_dcn_crtc_high_irq(void *interrupt_params)
                         amdgpu_dm_vrr_active(acrtc_state),
                         acrtc_state->active_planes);
 
+       /**
+        * Core vblank handling at start of front-porch is only possible
+        * in non-vrr mode, as only there vblank timestamping will give
+        * valid results while done in front-porch. Otherwise defer it
+        * to dm_vupdate_high_irq after end of front-porch.
+        */
+       if (!amdgpu_dm_vrr_active(acrtc_state))
+               drm_crtc_handle_vblank(&acrtc->base);
+
+       /**
+        * Following stuff must happen at start of vblank, for crc
+        * computation and below-the-range btr support in vrr mode.
+        */
        amdgpu_dm_crtc_handle_crc_irq(&acrtc->base);
-       drm_crtc_handle_vblank(&acrtc->base);
+
+       /* BTR updates need to happen before VUPDATE on Vega and above. */
+       if (adev->family < AMDGPU_FAMILY_AI)
+               return;
 
        spin_lock_irqsave(&adev->ddev->event_lock, flags);
 
-       if (acrtc_state->vrr_params.supported &&
+       if (acrtc_state->stream && acrtc_state->vrr_params.supported &&
            acrtc_state->freesync_config.state == VRR_STATE_ACTIVE_VARIABLE) {
-               mod_freesync_handle_v_update(
-               adev->dm.freesync_module,
-               acrtc_state->stream,
-               &acrtc_state->vrr_params);
+               mod_freesync_handle_v_update(adev->dm.freesync_module,
+                                            acrtc_state->stream,
+                                            &acrtc_state->vrr_params);
 
-               dc_stream_adjust_vmin_vmax(
-                       adev->dm.dc,
-                       acrtc_state->stream,
-                       &acrtc_state->vrr_params.adjust);
+               dc_stream_adjust_vmin_vmax(adev->dm.dc, acrtc_state->stream,
+                                          &acrtc_state->vrr_params.adjust);
        }
 
        /*
@@ -556,7 +505,8 @@ static void dm_dcn_crtc_high_irq(void *interrupt_params)
         * avoid race conditions between flip programming and completion,
         * which could cause too early flip completion events.
         */
-       if (acrtc->pflip_status == AMDGPU_FLIP_SUBMITTED &&
+       if (adev->family >= AMDGPU_FAMILY_RV &&
+           acrtc->pflip_status == AMDGPU_FLIP_SUBMITTED &&
            acrtc_state->active_planes == 0) {
                if (acrtc->event) {
                        drm_crtc_send_vblank_event(&acrtc->base, acrtc->event);
@@ -568,7 +518,6 @@ static void dm_dcn_crtc_high_irq(void *interrupt_params)
 
        spin_unlock_irqrestore(&adev->ddev->event_lock, flags);
 }
-#endif
 
 static int dm_set_clockgating_state(void *handle,
                  enum amd_clockgating_state state)
@@ -825,8 +774,9 @@ static int dm_dmub_hw_init(struct amdgpu_device *adev)
                                fw_inst_const_size);
        }
 
-       memcpy(fb_info->fb[DMUB_WINDOW_2_BSS_DATA].cpu_addr, fw_bss_data,
-              fw_bss_data_size);
+       if (fw_bss_data_size)
+               memcpy(fb_info->fb[DMUB_WINDOW_2_BSS_DATA].cpu_addr,
+                      fw_bss_data, fw_bss_data_size);
 
        /* Copy firmware bios info into FB memory. */
        memcpy(fb_info->fb[DMUB_WINDOW_3_VBIOS].cpu_addr, adev->bios,
@@ -1265,6 +1215,10 @@ static int dm_dmub_sw_init(struct amdgpu_device *adev)
                adev->dm.dmub_fw->data +
                le32_to_cpu(hdr->header.ucode_array_offset_bytes) +
                le32_to_cpu(hdr->inst_const_bytes);
+       region_params.fw_inst_const =
+               adev->dm.dmub_fw->data +
+               le32_to_cpu(hdr->header.ucode_array_offset_bytes) +
+               PSP_HEADER_BYTES;
 
        status = dmub_srv_calc_region_info(dmub_srv, &region_params,
                                           &region_info);
@@ -1384,9 +1338,14 @@ static int dm_late_init(void *handle)
        struct dmcu_iram_parameters params;
        unsigned int linear_lut[16];
        int i;
-       struct dmcu *dmcu = adev->dm.dc->res_pool->dmcu;
+       struct dmcu *dmcu = NULL;
        bool ret = false;
 
+       if (!adev->dm.fw_dmcu)
+               return detect_mst_link_for_all_connectors(adev->ddev);
+
+       dmcu = adev->dm.dc->res_pool->dmcu;
+
        for (i = 0; i < 16; i++)
                linear_lut[i] = 0xFFFF * i / 15;
 
@@ -1566,7 +1525,6 @@ static int dm_suspend(void *handle)
 {
        struct amdgpu_device *adev = handle;
        struct amdgpu_display_manager *dm = &adev->dm;
-       int ret = 0;
 
        WARN_ON(adev->dm.cached_state);
        adev->dm.cached_state = drm_atomic_helper_suspend(adev->ddev);
@@ -1578,7 +1536,7 @@ static int dm_suspend(void *handle)
 
        dc_set_power_state(dm->dc, DC_ACPI_CM_POWER_STATE_D3);
 
-       return ret;
+       return 0;
 }
 
 static struct amdgpu_dm_connector *
@@ -2008,17 +1966,22 @@ void amdgpu_dm_update_connector_after_detect(
                dc_sink_retain(aconnector->dc_sink);
                if (sink->dc_edid.length == 0) {
                        aconnector->edid = NULL;
-                       drm_dp_cec_unset_edid(&aconnector->dm_dp_aux.aux);
+                       if (aconnector->dc_link->aux_mode) {
+                               drm_dp_cec_unset_edid(
+                                       &aconnector->dm_dp_aux.aux);
+                       }
                } else {
                        aconnector->edid =
-                               (struct edid *) sink->dc_edid.raw_edid;
-
+                               (struct edid *)sink->dc_edid.raw_edid;
 
                        drm_connector_update_edid_property(connector,
-                                       aconnector->edid);
-                       drm_dp_cec_set_edid(&aconnector->dm_dp_aux.aux,
-                                           aconnector->edid);
+                                                          aconnector->edid);
+
+                       if (aconnector->dc_link->aux_mode)
+                               drm_dp_cec_set_edid(&aconnector->dm_dp_aux.aux,
+                                                   aconnector->edid);
                }
+
                amdgpu_dm_update_freesync_caps(connector, aconnector->edid);
                update_connector_ext_caps(aconnector);
        } else {
@@ -2440,8 +2403,36 @@ static int dcn10_register_irq_handlers(struct amdgpu_device *adev)
                c_irq_params->adev = adev;
                c_irq_params->irq_src = int_params.irq_source;
 
+               amdgpu_dm_irq_register_interrupt(
+                       adev, &int_params, dm_crtc_high_irq, c_irq_params);
+       }
+
+       /* Use VUPDATE_NO_LOCK interrupt on DCN, which seems to correspond to
+        * the regular VUPDATE interrupt on DCE. We want DC_IRQ_SOURCE_VUPDATEx
+        * to trigger at end of each vblank, regardless of state of the lock,
+        * matching DCE behaviour.
+        */
+       for (i = DCN_1_0__SRCID__OTG0_IHC_V_UPDATE_NO_LOCK_INTERRUPT;
+            i <= DCN_1_0__SRCID__OTG0_IHC_V_UPDATE_NO_LOCK_INTERRUPT + adev->mode_info.num_crtc - 1;
+            i++) {
+               r = amdgpu_irq_add_id(adev, SOC15_IH_CLIENTID_DCE, i, &adev->vupdate_irq);
+
+               if (r) {
+                       DRM_ERROR("Failed to add vupdate irq id!\n");
+                       return r;
+               }
+
+               int_params.int_context = INTERRUPT_HIGH_IRQ_CONTEXT;
+               int_params.irq_source =
+                       dc_interrupt_to_irq_source(dc, i, 0);
+
+               c_irq_params = &adev->dm.vupdate_params[int_params.irq_source - DC_IRQ_SOURCE_VUPDATE1];
+
+               c_irq_params->adev = adev;
+               c_irq_params->irq_src = int_params.irq_source;
+
                amdgpu_dm_irq_register_interrupt(adev, &int_params,
-                               dm_dcn_crtc_high_irq, c_irq_params);
+                               dm_vupdate_high_irq, c_irq_params);
        }
 
        /* Use GRPH_PFLIP interrupt */
@@ -3304,7 +3295,7 @@ static int fill_dc_scaling_info(const struct drm_plane_state *state,
 }
 
 static int get_fb_info(const struct amdgpu_framebuffer *amdgpu_fb,
-                      uint64_t *tiling_flags)
+                      uint64_t *tiling_flags, bool *tmz_surface)
 {
        struct amdgpu_bo *rbo = gem_to_amdgpu_bo(amdgpu_fb->base.obj[0]);
        int r = amdgpu_bo_reserve(rbo, false);
@@ -3319,6 +3310,9 @@ static int get_fb_info(const struct amdgpu_framebuffer *amdgpu_fb,
        if (tiling_flags)
                amdgpu_bo_get_tiling_flags(rbo, tiling_flags);
 
+       if (tmz_surface)
+               *tmz_surface = amdgpu_bo_encrypted(rbo);
+
        amdgpu_bo_unreserve(rbo);
 
        return r;
@@ -3340,7 +3334,8 @@ fill_plane_dcc_attributes(struct amdgpu_device *adev,
                          const union dc_tiling_info *tiling_info,
                          const uint64_t info,
                          struct dc_plane_dcc_param *dcc,
-                         struct dc_plane_address *address)
+                         struct dc_plane_address *address,
+                         bool force_disable_dcc)
 {
        struct dc *dc = adev->dm.dc;
        struct dc_dcc_surface_param input;
@@ -3352,6 +3347,9 @@ fill_plane_dcc_attributes(struct amdgpu_device *adev,
        memset(&input, 0, sizeof(input));
        memset(&output, 0, sizeof(output));
 
+       if (force_disable_dcc)
+               return 0;
+
        if (!offset)
                return 0;
 
@@ -3401,7 +3399,9 @@ fill_plane_buffer_attributes(struct amdgpu_device *adev,
                             union dc_tiling_info *tiling_info,
                             struct plane_size *plane_size,
                             struct dc_plane_dcc_param *dcc,
-                            struct dc_plane_address *address)
+                            struct dc_plane_address *address,
+                            bool tmz_surface,
+                            bool force_disable_dcc)
 {
        const struct drm_framebuffer *fb = &afb->base;
        int ret;
@@ -3411,6 +3411,8 @@ fill_plane_buffer_attributes(struct amdgpu_device *adev,
        memset(dcc, 0, sizeof(*dcc));
        memset(address, 0, sizeof(*address));
 
+       address->tmz_surface = tmz_surface;
+
        if (format < SURFACE_PIXEL_FORMAT_VIDEO_BEGIN) {
                plane_size->surface_size.x = 0;
                plane_size->surface_size.y = 0;
@@ -3507,7 +3509,8 @@ fill_plane_buffer_attributes(struct amdgpu_device *adev,
 
                ret = fill_plane_dcc_attributes(adev, afb, format, rotation,
                                                plane_size, tiling_info,
-                                               tiling_flags, dcc, address);
+                                               tiling_flags, dcc, address,
+                                               force_disable_dcc);
                if (ret)
                        return ret;
        }
@@ -3599,7 +3602,9 @@ fill_dc_plane_info_and_addr(struct amdgpu_device *adev,
                            const struct drm_plane_state *plane_state,
                            const uint64_t tiling_flags,
                            struct dc_plane_info *plane_info,
-                           struct dc_plane_address *address)
+                           struct dc_plane_address *address,
+                           bool tmz_surface,
+                           bool force_disable_dcc)
 {
        const struct drm_framebuffer *fb = plane_state->fb;
        const struct amdgpu_framebuffer *afb =
@@ -3642,6 +3647,10 @@ fill_dc_plane_info_and_addr(struct amdgpu_device *adev,
        case DRM_FORMAT_P010:
                plane_info->format = SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCrCb;
                break;
+       case DRM_FORMAT_XRGB16161616F:
+       case DRM_FORMAT_ARGB16161616F:
+               plane_info->format = SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616F;
+               break;
        default:
                DRM_ERROR(
                        "Unsupported screen format %s\n",
@@ -3681,7 +3690,8 @@ fill_dc_plane_info_and_addr(struct amdgpu_device *adev,
                                           plane_info->rotation, tiling_flags,
                                           &plane_info->tiling_info,
                                           &plane_info->plane_size,
-                                          &plane_info->dcc, address);
+                                          &plane_info->dcc, address, tmz_surface,
+                                          force_disable_dcc);
        if (ret)
                return ret;
 
@@ -3704,6 +3714,8 @@ static int fill_dc_plane_attributes(struct amdgpu_device *adev,
        struct dc_plane_info plane_info;
        uint64_t tiling_flags;
        int ret;
+       bool tmz_surface = false;
+       bool force_disable_dcc = false;
 
        ret = fill_dc_scaling_info(plane_state, &scaling_info);
        if (ret)
@@ -3714,13 +3726,16 @@ static int fill_dc_plane_attributes(struct amdgpu_device *adev,
        dc_plane_state->clip_rect = scaling_info.clip_rect;
        dc_plane_state->scaling_quality = scaling_info.scaling_quality;
 
-       ret = get_fb_info(amdgpu_fb, &tiling_flags);
+       ret = get_fb_info(amdgpu_fb, &tiling_flags, &tmz_surface);
        if (ret)
                return ret;
 
+       force_disable_dcc = adev->asic_type == CHIP_RAVEN && adev->in_suspend;
        ret = fill_dc_plane_info_and_addr(adev, plane_state, tiling_flags,
                                          &plane_info,
-                                         &dc_plane_state->address);
+                                         &dc_plane_state->address,
+                                         tmz_surface,
+                                         force_disable_dcc);
        if (ret)
                return ret;
 
@@ -4324,14 +4339,10 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
 
        if (stream->signal == SIGNAL_TYPE_HDMI_TYPE_A)
                mod_build_hf_vsif_infopacket(stream, &stream->vsp_infopacket, false, false);
-       if (stream->link->psr_feature_enabled)  {
+       if (stream->link->psr_settings.psr_feature_enabled)     {
                struct dc  *core_dc = stream->link->ctx->dc;
 
                if (dc_is_dmcu_initialized(core_dc)) {
-                       struct dmcu *dmcu = core_dc->res_pool->dmcu;
-
-                       stream->psr_version = dmcu->dmcu_version.psr_version;
-
                        //
                        // should decide stream support vsc sdp colorimetry capability
                        // before building vsc info packet
@@ -4437,10 +4448,6 @@ static inline int dm_set_vupdate_irq(struct drm_crtc *crtc, bool enable)
        struct amdgpu_device *adev = crtc->dev->dev_private;
        int rc;
 
-       /* Do not set vupdate for DCN hardware */
-       if (adev->family > AMDGPU_FAMILY_AI)
-               return 0;
-
        irq_source = IRQ_TYPE_VUPDATE + acrtc->otg_inst;
 
        rc = dc_interrupt_set(adev->dm.dc, irq_source, enable) ? 0 : -EBUSY;
@@ -4664,6 +4671,7 @@ static void amdgpu_dm_connector_destroy(struct drm_connector *connector)
                i2c_del_adapter(&aconnector->i2c->base);
                kfree(aconnector->i2c);
        }
+       kfree(aconnector->dm_dp_aux.aux.name);
 
        kfree(connector);
 }
@@ -4726,6 +4734,15 @@ amdgpu_dm_connector_late_register(struct drm_connector *connector)
 #if defined(CONFIG_DEBUG_FS)
        struct amdgpu_dm_connector *amdgpu_dm_connector =
                to_amdgpu_dm_connector(connector);
+       int r;
+
+       if ((connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) ||
+           (connector->connector_type == DRM_MODE_CONNECTOR_eDP)) {
+               amdgpu_dm_connector->dm_dp_aux.aux.dev = connector->kdev;
+               r = drm_dp_aux_register(&amdgpu_dm_connector->dm_dp_aux.aux);
+               if (r)
+                       return r;
+       }
 
        connector_debugfs_init(amdgpu_dm_connector);
 #endif
@@ -5332,6 +5349,8 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,
        uint64_t tiling_flags;
        uint32_t domain;
        int r;
+       bool tmz_surface = false;
+       bool force_disable_dcc = false;
 
        dm_plane_state_old = to_dm_plane_state(plane->state);
        dm_plane_state_new = to_dm_plane_state(new_state);
@@ -5380,6 +5399,8 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,
 
        amdgpu_bo_get_tiling_flags(rbo, &tiling_flags);
 
+       tmz_surface = amdgpu_bo_encrypted(rbo);
+
        ttm_eu_backoff_reservation(&ticket, &list);
 
        afb->address = amdgpu_bo_gpu_offset(rbo);
@@ -5390,11 +5411,13 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,
                        dm_plane_state_old->dc_state != dm_plane_state_new->dc_state) {
                struct dc_plane_state *plane_state = dm_plane_state_new->dc_state;
 
+               force_disable_dcc = adev->asic_type == CHIP_RAVEN && adev->in_suspend;
                fill_plane_buffer_attributes(
                        adev, afb, plane_state->format, plane_state->rotation,
                        tiling_flags, &plane_state->tiling_info,
                        &plane_state->plane_size, &plane_state->dcc,
-                       &plane_state->address);
+                       &plane_state->address, tmz_surface,
+                       force_disable_dcc);
        }
 
        return 0;
@@ -5540,6 +5563,10 @@ static int get_plane_formats(const struct drm_plane *plane,
                        formats[num_formats++] = DRM_FORMAT_NV12;
                if (plane_cap && plane_cap->pixel_format_support.p010)
                        formats[num_formats++] = DRM_FORMAT_P010;
+               if (plane_cap && plane_cap->pixel_format_support.fp16) {
+                       formats[num_formats++] = DRM_FORMAT_XRGB16161616F;
+                       formats[num_formats++] = DRM_FORMAT_ARGB16161616F;
+               }
                break;
 
        case DRM_PLANE_TYPE_OVERLAY:
@@ -6092,7 +6119,7 @@ static int amdgpu_dm_connector_init(struct amdgpu_display_manager *dm,
 
        if (connector_type == DRM_MODE_CONNECTOR_DisplayPort
                || connector_type == DRM_MODE_CONNECTOR_eDP)
-               amdgpu_dm_initialize_dp_connector(dm, aconnector);
+               amdgpu_dm_initialize_dp_connector(dm, aconnector, link->link_index);
 
 out_free:
        if (res) {
@@ -6567,6 +6594,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
        unsigned long flags;
        struct amdgpu_bo *abo;
        uint64_t tiling_flags;
+       bool tmz_surface = false;
        uint32_t target_vblank, last_flip_vblank;
        bool vrr_active = amdgpu_dm_vrr_active(acrtc_state);
        bool pflip_present = false;
@@ -6619,6 +6647,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
                if (new_pcrtc_state->color_mgmt_changed) {
                        bundle->surface_updates[planes_count].gamma = dc_plane->gamma_correction;
                        bundle->surface_updates[planes_count].in_transfer_func = dc_plane->in_transfer_func;
+                       bundle->surface_updates[planes_count].gamut_remap_matrix = &dc_plane->gamut_remap_matrix;
                }
 
                fill_dc_scaling_info(new_plane_state,
@@ -6661,12 +6690,20 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
 
                amdgpu_bo_get_tiling_flags(abo, &tiling_flags);
 
+               tmz_surface = amdgpu_bo_encrypted(abo);
+
                amdgpu_bo_unreserve(abo);
 
                fill_dc_plane_info_and_addr(
                        dm->adev, new_plane_state, tiling_flags,
                        &bundle->plane_infos[planes_count],
-                       &bundle->flip_addrs[planes_count].address);
+                       &bundle->flip_addrs[planes_count].address,
+                       tmz_surface,
+                       false);
+
+               DRM_DEBUG_DRIVER("plane: id=%d dcc_en=%d\n",
+                                new_plane_state->plane->index,
+                                bundle->plane_infos[planes_count].dcc.enable);
 
                bundle->surface_updates[planes_count].plane_info =
                        &bundle->plane_infos[planes_count];
@@ -6807,7 +6844,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
                }
                mutex_lock(&dm->dc_lock);
                if ((acrtc_state->update_type > UPDATE_TYPE_FAST) &&
-                               acrtc_state->stream->link->psr_allow_active)
+                               acrtc_state->stream->link->psr_settings.psr_allow_active)
                        amdgpu_dm_psr_disable(acrtc_state->stream);
 
                dc_commit_updates_for_stream(dm->dc,
@@ -6818,12 +6855,12 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
                                                     dc_state);
 
                if ((acrtc_state->update_type > UPDATE_TYPE_FAST) &&
-                                               acrtc_state->stream->psr_version &&
-                                               !acrtc_state->stream->link->psr_feature_enabled)
+                               acrtc_state->stream->link->psr_settings.psr_version != DC_PSR_VERSION_UNSUPPORTED &&
+                               !acrtc_state->stream->link->psr_settings.psr_feature_enabled)
                        amdgpu_dm_link_setup_psr(acrtc_state->stream);
                else if ((acrtc_state->update_type == UPDATE_TYPE_FAST) &&
-                                               acrtc_state->stream->link->psr_feature_enabled &&
-                                               !acrtc_state->stream->link->psr_allow_active) {
+                               acrtc_state->stream->link->psr_settings.psr_feature_enabled &&
+                               !acrtc_state->stream->link->psr_settings.psr_allow_active) {
                        amdgpu_dm_psr_enable(acrtc_state->stream);
                }
 
@@ -7137,7 +7174,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
                        DRM_DEBUG_DRIVER("Atomic commit: RESET. crtc id %d:[%p]\n", acrtc->crtc_id, acrtc);
                        /* i.e. reset mode */
                        if (dm_old_crtc_state->stream) {
-                               if (dm_old_crtc_state->stream->link->psr_allow_active)
+                               if (dm_old_crtc_state->stream->link->psr_settings.psr_allow_active)
                                        amdgpu_dm_psr_disable(dm_old_crtc_state->stream);
 
                                remove_stream(adev, acrtc, dm_old_crtc_state->stream);
@@ -7848,6 +7885,7 @@ static int dm_update_plane_state(struct dc *dc,
        struct drm_crtc_state *old_crtc_state, *new_crtc_state;
        struct dm_crtc_state *dm_new_crtc_state, *dm_old_crtc_state;
        struct dm_plane_state *dm_new_plane_state, *dm_old_plane_state;
+       struct amdgpu_crtc *new_acrtc;
        bool needs_reset;
        int ret = 0;
 
@@ -7857,9 +7895,30 @@ static int dm_update_plane_state(struct dc *dc,
        dm_new_plane_state = to_dm_plane_state(new_plane_state);
        dm_old_plane_state = to_dm_plane_state(old_plane_state);
 
-       /*TODO Implement atomic check for cursor plane */
-       if (plane->type == DRM_PLANE_TYPE_CURSOR)
+       /*TODO Implement better atomic check for cursor plane */
+       if (plane->type == DRM_PLANE_TYPE_CURSOR) {
+               if (!enable || !new_plane_crtc ||
+                       drm_atomic_plane_disabling(plane->state, new_plane_state))
+                       return 0;
+
+               new_acrtc = to_amdgpu_crtc(new_plane_crtc);
+
+               if ((new_plane_state->crtc_w > new_acrtc->max_cursor_width) ||
+                       (new_plane_state->crtc_h > new_acrtc->max_cursor_height)) {
+                       DRM_DEBUG_ATOMIC("Bad cursor size %d x %d\n",
+                                                        new_plane_state->crtc_w, new_plane_state->crtc_h);
+                       return -EINVAL;
+               }
+
+               if (new_plane_state->crtc_x <= -new_acrtc->max_cursor_width ||
+                       new_plane_state->crtc_y <= -new_acrtc->max_cursor_height) {
+                       DRM_DEBUG_ATOMIC("Bad cursor position %d, %d\n",
+                                                        new_plane_state->crtc_x, new_plane_state->crtc_y);
+                       return -EINVAL;
+               }
+
                return 0;
+       }
 
        needs_reset = should_reset_plane(state, plane, old_plane_state,
                                         new_plane_state);
@@ -8034,6 +8093,7 @@ dm_determine_update_type_for_commit(struct amdgpu_display_manager *dm,
                        struct dc_flip_addrs *flip_addr = &bundle->flip_addrs[num_plane];
                        struct dc_scaling_info *scaling_info = &bundle->scaling_infos[num_plane];
                        uint64_t tiling_flags;
+                       bool tmz_surface = false;
 
                        new_plane_crtc = new_plane_state->crtc;
                        new_dm_plane_state = to_dm_plane_state(new_plane_state);
@@ -8063,6 +8123,8 @@ dm_determine_update_type_for_commit(struct amdgpu_display_manager *dm,
                                                new_dm_plane_state->dc_state->gamma_correction;
                                bundle->surface_updates[num_plane].in_transfer_func =
                                                new_dm_plane_state->dc_state->in_transfer_func;
+                               bundle->surface_updates[num_plane].gamut_remap_matrix =
+                                               &new_dm_plane_state->dc_state->gamut_remap_matrix;
                                bundle->stream_update.gamut_remap =
                                                &new_dm_crtc_state->stream->gamut_remap_matrix;
                                bundle->stream_update.output_csc_transform =
@@ -8079,14 +8141,15 @@ dm_determine_update_type_for_commit(struct amdgpu_display_manager *dm,
                        bundle->surface_updates[num_plane].scaling_info = scaling_info;
 
                        if (amdgpu_fb) {
-                               ret = get_fb_info(amdgpu_fb, &tiling_flags);
+                               ret = get_fb_info(amdgpu_fb, &tiling_flags, &tmz_surface);
                                if (ret)
                                        goto cleanup;
 
                                ret = fill_dc_plane_info_and_addr(
                                        dm->adev, new_plane_state, tiling_flags,
                                        plane_info,
-                                       &flip_addr->address);
+                                       &flip_addr->address, tmz_surface,
+                                       false);
                                if (ret)
                                        goto cleanup;
 
@@ -8586,8 +8649,17 @@ static void amdgpu_dm_set_psr_caps(struct dc_link *link)
                return;
        if (dm_helpers_dp_read_dpcd(NULL, link, DP_PSR_SUPPORT,
                                        dpcd_data, sizeof(dpcd_data))) {
-               link->psr_feature_enabled = dpcd_data[0] ? true:false;
-               DRM_INFO("PSR support:%d\n", link->psr_feature_enabled);
+               link->dpcd_caps.psr_caps.psr_version = dpcd_data[0];
+
+               if (dpcd_data[0] == 0) {
+                       link->psr_settings.psr_version = DC_PSR_VERSION_UNSUPPORTED;
+                       link->psr_settings.psr_feature_enabled = false;
+               } else {
+                       link->psr_settings.psr_version = DC_PSR_VERSION_1;
+                       link->psr_settings.psr_feature_enabled = true;
+               }
+
+               DRM_INFO("PSR support:%d\n", link->psr_settings.psr_feature_enabled);
        }
 }
 
@@ -8602,16 +8674,14 @@ static bool amdgpu_dm_link_setup_psr(struct dc_stream_state *stream)
        struct dc_link *link = NULL;
        struct psr_config psr_config = {0};
        struct psr_context psr_context = {0};
-       struct dc *dc = NULL;
        bool ret = false;
 
        if (stream == NULL)
                return false;
 
        link = stream->link;
-       dc = link->ctx->dc;
 
-       psr_config.psr_version = dc->res_pool->dmcu->dmcu_version.psr_version;
+       psr_config.psr_version = link->dpcd_caps.psr_caps.psr_version;
 
        if (psr_config.psr_version > 0) {
                psr_config.psr_exit_link_training_required = 0x1;
@@ -8623,7 +8693,7 @@ static bool amdgpu_dm_link_setup_psr(struct dc_stream_state *stream)
                ret = dc_link_setup_psr(link, stream, &psr_config, &psr_context);
 
        }
-       DRM_DEBUG_DRIVER("PSR link: %d\n",      link->psr_feature_enabled);
+       DRM_DEBUG_DRIVER("PSR link: %d\n",      link->psr_settings.psr_feature_enabled);
 
        return ret;
 }