int i;
        struct dc_stream_state *del_streams[MAX_PIPES];
        int del_streams_count = 0;
+       struct dc_commit_streams_params params = {};
 
        memset(del_streams, 0, sizeof(del_streams));
 
                        goto fail;
        }
 
-       res = dc_commit_streams(dc, context->streams, context->stream_count);
+       params.streams = context->streams;
+       params.stream_count = context->stream_count;
+       res = dc_commit_streams(dc, ¶ms);
 
 fail:
        dc_state_release(context);
        struct dc_state *dc_state;
        int i, r, j, ret;
        bool need_hotplug = false;
+       struct dc_commit_streams_params commit_params = {};
 
        if (dm->dc->caps.ips_support) {
                dc_dmub_srv_apply_idle_power_optimizations(dm->dc, false);
                        dc_enable_dmub_outbox(adev->dm.dc);
                }
 
-               WARN_ON(!dc_commit_streams(dm->dc, dc_state->streams, dc_state->stream_count));
+               commit_params.streams = dc_state->streams;
+               commit_params.stream_count = dc_state->stream_count;
+               WARN_ON(!dc_commit_streams(dm->dc, &commit_params));
 
                dm_gpureset_commit_state(dm->cached_dc_state, dm);
 
        }
        /* Recreate dc_state - DC invalidates it when setting power state to S3. */
        dc_state_release(dm_state->context);
-       dm_state->context = dc_state_create(dm->dc);
+       dm_state->context = dc_state_create(dm->dc, NULL);
        /* TODO: Remove dc_state->dccg, use dc->dccg directly. */
 
        /* Before powering on DC we need to re-initialize DMUB. */
        if (!dc_plane_state)
                goto cleanup;
 
-       dc_state = dc_state_create(dc);
+       dc_state = dc_state_create(dc, NULL);
        if (!dc_state)
                goto cleanup;
 
        struct drm_connector *connector;
        bool mode_set_reset_required = false;
        u32 i;
+       struct dc_commit_streams_params params = {dc_state->streams, dc_state->stream_count};
 
        /* Disable writeback */
        for_each_old_connector_in_state(state, connector, old_con_state, i) {
 
        dm_enable_per_frame_crtc_master_sync(dc_state);
        mutex_lock(&dm->dc_lock);
-       WARN_ON(!dc_commit_streams(dm->dc, dc_state->streams, dc_state->stream_count));
+       WARN_ON(!dc_commit_streams(dm->dc, ¶ms));
 
        /* Allow idle optimization when vblank count is 0 for display off */
        if (dm->active_vblank_irq_count == 0)
 
         * is initialized in dc_create_resource_pool because
         * on creation it copies the contents of dc->dml
         */
-
-       dc->current_state = dc_state_create(dc);
+       dc->current_state = dc_state_create(dc, NULL);
 
        if (!dc->current_state) {
                dm_error("%s: failed to create validate ctx\n", __func__);
  * Return DC_OK if everything work as expected, otherwise, return a dc_status
  * code.
  */
-enum dc_status dc_commit_streams(struct dc *dc,
-                                struct dc_stream_state *streams[],
-                                uint8_t stream_count)
+enum dc_status dc_commit_streams(struct dc *dc, struct dc_commit_streams_params *params)
 {
        int i, j;
        struct dc_state *context;
        struct pipe_ctx *pipe;
        bool handle_exit_odm2to1 = false;
 
+       if (!params)
+               return DC_ERROR_UNEXPECTED;
+
        if (dc->ctx->dce_environment == DCE_ENV_VIRTUAL_HW)
                return res;
 
-       if (!streams_changed(dc, streams, stream_count))
+       if (!streams_changed(dc, params->streams, params->stream_count) &&
+                       dc->current_state->power_source == params->power_source)
                return res;
 
        dc_exit_ips_for_hw_access(dc);
 
-       DC_LOG_DC("%s: %d streams\n", __func__, stream_count);
+       DC_LOG_DC("%s: %d streams\n", __func__, params->stream_count);
 
-       for (i = 0; i < stream_count; i++) {
-               struct dc_stream_state *stream = streams[i];
+       for (i = 0; i < params->stream_count; i++) {
+               struct dc_stream_state *stream = params->streams[i];
                struct dc_stream_status *status = dc_stream_get_status(stream);
 
                dc_stream_log(dc, stream);
         * scenario, it uses extra pipes than needed to reduce power consumption
         * We need to switch off this feature to make room for new streams.
         */
-       if (stream_count > dc->current_state->stream_count &&
+       if (params->stream_count > dc->current_state->stream_count &&
                        dc->current_state->stream_count == 1) {
                for (i = 0; i < dc->res_pool->pipe_count; i++) {
                        pipe = &dc->current_state->res_ctx.pipe_ctx[i];
        if (!context)
                goto context_alloc_fail;
 
-       res = dc_validate_with_context(dc, set, stream_count, context, false);
+       context->power_source = params->power_source;
+
+       res = dc_validate_with_context(dc, set, params->stream_count, context, false);
        if (res != DC_OK) {
                BREAK_TO_DEBUGGER();
                goto fail;
 
        res = dc_commit_state_no_check(dc, context);
 
-       for (i = 0; i < stream_count; i++) {
+       for (i = 0; i < params->stream_count; i++) {
                for (j = 0; j < context->stream_count; j++) {
-                       if (streams[i]->stream_id == context->streams[j]->stream_id)
-                               streams[i]->out.otg_offset = context->stream_status[j].primary_otg_inst;
+                       if (params->streams[i]->stream_id == context->streams[j]->stream_id)
+                               params->streams[i]->out.otg_offset = context->stream_status[j].primary_otg_inst;
 
-                       if (dc_is_embedded_signal(streams[i]->signal)) {
-                               struct dc_stream_status *status = dc_state_get_stream_status(context, streams[i]);
+                       if (dc_is_embedded_signal(params->streams[i]->signal)) {
+                               struct dc_stream_status *status = dc_state_get_stream_status(context, params->streams[i]);
 
                                if (dc->hwss.is_abm_supported)
-                                       status->is_abm_supported = dc->hwss.is_abm_supported(dc, context, streams[i]);
+                                       status->is_abm_supported = dc->hwss.is_abm_supported(dc, context, params->streams[i]);
                                else
                                        status->is_abm_supported = true;
                        }
 
 }
 
 /* Public dc_state functions */
-struct dc_state *dc_state_create(struct dc *dc)
+struct dc_state *dc_state_create(struct dc *dc, struct dc_state_create_params *params)
 {
+#ifdef CONFIG_DRM_AMD_DC_FP
+       struct dml2_configuration_options dml2_opt = dc->dml2_options;
+#endif
        struct dc_state *state = kvzalloc(sizeof(struct dc_state),
                        GFP_KERNEL);
 
 
        init_state(dc, state);
        dc_state_construct(dc, state);
+       state->power_source = params ? params->power_source : DC_POWER_SOURCE_AC;
 
 #ifdef CONFIG_DRM_AMD_DC_FP
-       if (dc->debug.using_dml2)
-               dml2_create(dc, &dc->dml2_options, &state->bw_ctx.dml2);
+       if (dc->debug.using_dml2) {
+               dml2_opt.use_clock_dc_limits = false;
+               dml2_create(dc, &dml2_opt, &state->bw_ctx.dml2);
+
+               dml2_opt.use_clock_dc_limits = true;
+               dml2_create(dc, &dml2_opt, &state->bw_ctx.dml2_dc_power_source);
+       }
 #endif
 
        kref_init(&state->refcount);
        struct kref refcount = dst_state->refcount;
 #ifdef CONFIG_DRM_AMD_DC_FP
        struct dml2_context *dst_dml2 = dst_state->bw_ctx.dml2;
+       struct dml2_context *dst_dml2_dc_power_source = dst_state->bw_ctx.dml2_dc_power_source;
 #endif
 
        dc_state_copy_internal(dst_state, src_state);
        dst_state->bw_ctx.dml2 = dst_dml2;
        if (src_state->bw_ctx.dml2)
                dml2_copy(dst_state->bw_ctx.dml2, src_state->bw_ctx.dml2);
+
+       dst_state->bw_ctx.dml2_dc_power_source = dst_dml2_dc_power_source;
+       if (src_state->bw_ctx.dml2_dc_power_source)
+               dml2_copy(dst_state->bw_ctx.dml2_dc_power_source, src_state->bw_ctx.dml2_dc_power_source);
 #endif
 
        /* context refcount should not be overridden */
                dc_state_release(new_state);
                return NULL;
        }
+
+       if (src_state->bw_ctx.dml2_dc_power_source &&
+                       !dml2_create_copy(&new_state->bw_ctx.dml2_dc_power_source, src_state->bw_ctx.dml2_dc_power_source)) {
+               dc_state_release(new_state);
+               return NULL;
+       }
 #endif
 
        kref_init(&new_state->refcount);
 #ifdef CONFIG_DRM_AMD_DC_FP
        dml2_destroy(state->bw_ctx.dml2);
        state->bw_ctx.dml2 = 0;
+
+       dml2_destroy(state->bw_ctx.dml2_dc_power_source);
+       state->bw_ctx.dml2_dc_power_source = 0;
 #endif
 
        kvfree(state);
 
 bool dc_resource_is_dsc_encoding_supported(const struct dc *dc);
 void get_audio_check(struct audio_info *aud_modes,
        struct audio_check *aud_chk);
-
-enum dc_status dc_commit_streams(struct dc *dc,
-                                struct dc_stream_state *streams[],
-                                uint8_t stream_count);
+/*
+ * Set up streams and links associated to drive sinks
+ * The streams parameter is an absolute set of all active streams.
+ *
+ * After this call:
+ *   Phy, Encoder, Timing Generator are programmed and enabled.
+ *   New streams are enabled with blank stream; no memory read.
+ */
+enum dc_status dc_commit_streams(struct dc *dc, struct dc_commit_streams_params *params);
 
 
 struct dc_plane_state *dc_get_surface_for_mpcc(struct dc *dc,
 
 #include "dc.h"
 #include "inc/core_status.h"
 
-struct dc_state *dc_state_create(struct dc *dc);
+struct dc_state *dc_state_create(struct dc *dc, struct dc_state_create_params *params);
 void dc_state_copy(struct dc_state *dst_state, struct dc_state *src_state);
 struct dc_state *dc_state_create_copy(struct dc_state *src_state);
 void dc_state_copy_current(struct dc *dc, struct dc_state *dst_state);
 
 
 enum dc_status dc_validate_stream(struct dc *dc, struct dc_stream_state *stream);
 
-/*
- * Set up streams and links associated to drive sinks
- * The streams parameter is an absolute set of all active streams.
- *
- * After this call:
- *   Phy, Encoder, Timing Generator are programmed and enabled.
- *   New streams are enabled with blank stream; no memory read.
- */
 /*
  * Enable stereo when commit_streams is not required,
  * for example, frame alternate.
 
        SUBVP_MAIN, // subvp in use, this stream is main stream
        SUBVP_PHANTOM, // subvp in use, this stream is a phantom stream
 };
+
+enum dc_power_source_type {
+       DC_POWER_SOURCE_AC, // wall power
+       DC_POWER_SOURCE_DC, // battery power
+};
+
+struct dc_state_create_params {
+       enum dc_power_source_type power_source;
+};
+
+struct dc_commit_streams_params {
+       struct dc_stream_state **streams;
+       uint8_t stream_count;
+       enum dc_power_source_type power_source;
+};
+
 #endif /* DC_TYPES_H_ */
 
        unsigned int max_segments_per_hubp;
        unsigned int det_segment_size;
        bool map_dc_pipes_with_callbacks;
+
+       bool use_clock_dc_limits;
 };
 
 /*
 
        union bw_output bw;
        struct display_mode_lib dml;
        struct dml2_context *dml2;
+       struct dml2_context *dml2_dc_power_source;
 };
 
 struct dc_dmub_cmd {
        struct {
                unsigned int stutter_period_us;
        } perf_params;
+
+       enum dc_power_source_type power_source;
 };
 
 struct replay_context {
 
        bool out = false;
 
        if (dc->debug.using_dml2)
-               out = dml2_validate(dc, context, context->bw_ctx.dml2, fast_validate);
+               out = dml2_validate(dc, context,
+                               context->power_source == DC_POWER_SOURCE_DC ? context->bw_ctx.dml2_dc_power_source : context->bw_ctx.dml2,
+                               fast_validate);
        else
                out = dml1_validate(dc, context, fast_validate);
        return out;
 
 static void dcn32_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params)
 {
+       struct dml2_configuration_options dml2_opt = dc->dml2_options;
+
        DC_FP_START();
+
        dcn32_update_bw_bounding_box_fpu(dc, bw_params);
+
+       dml2_opt.use_clock_dc_limits = false;
        if (dc->debug.using_dml2 && dc->current_state && dc->current_state->bw_ctx.dml2)
-               dml2_reinit(dc, &dc->dml2_options, &dc->current_state->bw_ctx.dml2);
+               dml2_reinit(dc, &dml2_opt, &dc->current_state->bw_ctx.dml2);
+
+       dml2_opt.use_clock_dc_limits = true;
+       if (dc->debug.using_dml2 && dc->current_state && dc->current_state->bw_ctx.dml2_dc_power_source)
+               dml2_reinit(dc, &dml2_opt, &dc->current_state->bw_ctx.dml2_dc_power_source);
+
        DC_FP_END();
 }
 
 
 
 static void dcn321_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params)
 {
+       struct dml2_configuration_options dml2_opt = dc->dml2_options;
+
        DC_FP_START();
+
        dcn321_update_bw_bounding_box_fpu(dc, bw_params);
+
+       dml2_opt.use_clock_dc_limits = false;
        if (dc->debug.using_dml2 && dc->current_state && dc->current_state->bw_ctx.dml2)
-               dml2_reinit(dc, &dc->dml2_options, &dc->current_state->bw_ctx.dml2);
+               dml2_reinit(dc, &dml2_opt, &dc->current_state->bw_ctx.dml2);
+
+       dml2_opt.use_clock_dc_limits = true;
+       if (dc->debug.using_dml2 && dc->current_state && dc->current_state->bw_ctx.dml2_dc_power_source)
+               dml2_reinit(dc, &dml2_opt, &dc->current_state->bw_ctx.dml2_dc_power_source);
+
        DC_FP_END();
 }
 
 
 {
        bool out = false;
 
-       out = dml2_validate(dc, context, context->bw_ctx.dml2, fast_validate);
+       out = dml2_validate(dc, context,
+                       context->power_source == DC_POWER_SOURCE_DC ? context->bw_ctx.dml2_dc_power_source : context->bw_ctx.dml2,
+                       fast_validate);
 
        if (fast_validate)
                return out;
 
 {
        bool out = false;
 
-       out = dml2_validate(dc, context, context->bw_ctx.dml2, fast_validate);
+       out = dml2_validate(dc, context,
+                       context->power_source == DC_POWER_SOURCE_DC ? context->bw_ctx.dml2_dc_power_source : context->bw_ctx.dml2,
+                       fast_validate);
 
        if (fast_validate)
                return out;