DC: Reject too high pixel clocks on DCE6-10
Subsystems (3)
cover DC: Reject too high pixel clocks on DCE6-10
Reject modes with a pixel clock higher than the maximum display clock. These were never supported, but we haven't noticed the issue until the YCbCr 422 fallback was recently added.
For example, the DP 1.2 standard technically supports 4K 120Hz YCbCr 422 6 bpc, but in practice the pixel clock is too high on these old GPUs.
Additionally, there are two small code cleanup patches to avoid excessive code duplication.
Timur Kristóf (3):
drm/amd/display: Reject modes with too high pixel clock on DCE6-10 drm/amd/display: Share dce100_validate_bandwidth with DCE6-8 drm/amd/display: Share dce100_validate_global with DCE6-8
.../display/dc/clk_mgr/dce100/dce_clk_mgr.c | 3 + .../display/dc/clk_mgr/dce60/dce60_clk_mgr.c | 5 ++ .../dc/resource/dce100/dce100_resource.c | 25 +++++-- .../dc/resource/dce100/dce100_resource.h | 9 +++ .../dc/resource/dce60/dce60_resource.c | 69 +------------------ .../dc/resource/dce80/dce80_resource.c | 60 +--------------- 6 files changed, 44 insertions(+), 127 deletions(-)
Signature · 1 line
2.51.0
PATCH 1/3 drm/amd/display: Reject modes with too high pixel clock on DCE6-10
Reject modes with a pixel clock higher than the maximum display clock. Use 400 MHz as a fallback value when the maximum display clock is not known. Pixel clocks that are higher than the display clock just won't work and are not supported.
With the addition of the YUV422 fallback, DC can now accidentally
select a mode requiring higher pixel clock than actually supported when the DP version supports the required bandwidth but the clock is otherwise too high for the display engine. DCE 6-10 don't support these modes but they don't have a bandwidth calculation to reject them properly.
--- .../drm/amd/display/dc/clk_mgr/dce100/dce_clk_mgr.c | 3 +++ .../drm/amd/display/dc/clk_mgr/dce60/dce60_clk_mgr.c | 5 +++++ .../amd/display/dc/resource/dce100/dce100_resource.c | 10 +++++++++- .../drm/amd/display/dc/resource/dce60/dce60_resource.c | 10 +++++++++- .../drm/amd/display/dc/resource/dce80/dce80_resource.c | 10 +++++++++- 5 files changed, 35 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dc/clk_mgr/dce100/dce_clk_mgr.c +3 -0
@@ -463,6 +463,9 @@ void dce_clk_mgr_construct( clk_mgr->max_clks_state =DM_PP_CLOCKS_STATE_NOMINAL ; clk_mgr->cur_min_clks_state =DM_PP_CLOCKS_STATE_INVALID ; + base->clks.max_supported_dispclk_khz = + clk_mgr->max_clks_by_state[DM_PP_CLOCKS_STATE_PERFORMANCE ].display_clk_khz; +dce_clock_read_integrated_info (clk_mgr);dce_clock_read_ss_info (clk_mgr); }
drivers/gpu/drm/amd/display/dc/clk_mgr/dce60/dce60_clk_mgr.c +5 -0
@@ -147,6 +147,8 @@ void dce60_clk_mgr_construct(struct dc_context *ctx, struct clk_mgr_internal *clk_mgr) { + struct clk_mgr *base = &clk_mgr->base; +dce_clk_mgr_construct (ctx, clk_mgr); memcpy(clk_mgr->max_clks_by_state,
@@ -157,5 +159,8 @@ void dce60_clk_mgr_construct( clk_mgr->clk_mgr_shift = &disp_clk_shift; clk_mgr->clk_mgr_mask = &disp_clk_mask; clk_mgr->base.funcs = &dce60_funcs; + + base->clks.max_supported_dispclk_khz = + clk_mgr->max_clks_by_state[DM_PP_CLOCKS_STATE_PERFORMANCE ].display_clk_khz; }
drivers/gpu/drm/amd/display/dc/resource/dce100/dce100_resource.c +9 -1
@@ -29,6 +29,7 @@#include "stream_encoder.h" #include "resource.h" +#include "clk_mgr.h" #include "include/irq_service_interface.h" #include "virtual/virtual_stream_encoder.h" #include "dce110/dce110_resource.h"
@@ -843,10 +844,17 @@ static enum dc_status dce100_validate_bandwidth( {int i;bool at_least_one_pipe = false; +struct dc_stream_state *stream =NULL ; +const uint32_t max_pix_clk_khz =max (dc->clk_mgr->clks.max_supported_dispclk_khz,400000 );for (i =0 ; i < dc->res_pool->pipe_count; i++) { -if (context->res_ctx.pipe_ctx[i].stream) + stream = context->res_ctx.pipe_ctx[i].stream; +if (stream) { at_least_one_pipe = true; + +if (stream->timing.pix_clk_100hz >= max_pix_clk_khz *10 ) +return DC_FAIL_BANDWIDTH_VALIDATE ; + } }if (at_least_one_pipe) {
drivers/gpu/drm/amd/display/dc/resource/dce60/dce60_resource.c +9 -1
@@ -34,6 +34,7 @@#include "stream_encoder.h" #include "resource.h" +#include "clk_mgr.h" #include "include/irq_service_interface.h" #include "irq/dce60/irq_service_dce60.h" #include "dce110/dce110_timing_generator.h"
@@ -870,10 +871,17 @@ static enum dc_status dce60_validate_bandwidth( {int i;bool at_least_one_pipe = false; +struct dc_stream_state *stream =NULL ; +const uint32_t max_pix_clk_khz =max (dc->clk_mgr->clks.max_supported_dispclk_khz,400000 );for (i =0 ; i < dc->res_pool->pipe_count; i++) { -if (context->res_ctx.pipe_ctx[i].stream) + stream = context->res_ctx.pipe_ctx[i].stream; +if (stream) { at_least_one_pipe = true; + +if (stream->timing.pix_clk_100hz >= max_pix_clk_khz *10 ) +return DC_FAIL_BANDWIDTH_VALIDATE ; + } }if (at_least_one_pipe) {
drivers/gpu/drm/amd/display/dc/resource/dce80/dce80_resource.c +9 -1
@@ -32,6 +32,7 @@#include "stream_encoder.h" #include "resource.h" +#include "clk_mgr.h" #include "include/irq_service_interface.h" #include "irq/dce80/irq_service_dce80.h" #include "dce110/dce110_timing_generator.h"
@@ -876,10 +877,17 @@ static enum dc_status dce80_validate_bandwidth( {int i;bool at_least_one_pipe = false; +struct dc_stream_state *stream =NULL ; +const uint32_t max_pix_clk_khz =max (dc->clk_mgr->clks.max_supported_dispclk_khz,400000 );for (i =0 ; i < dc->res_pool->pipe_count; i++) { -if (context->res_ctx.pipe_ctx[i].stream) + stream = context->res_ctx.pipe_ctx[i].stream; +if (stream) { at_least_one_pipe = true; + +if (stream->timing.pix_clk_100hz >= max_pix_clk_khz *10 ) +return DC_FAIL_BANDWIDTH_VALIDATE ; + } }if (at_least_one_pipe) {
Signature · 1 line
2.51.0
PATCH 2/3 drm/amd/display: Share dce100_validate_bandwidth with DCE6-8
In reply to Timur KristófDCE6-8 have very similar capabilities to DCE10, they support the same DP and HDMI versions and work similarly.
Share dce100_validate_bandwidth between DCE6-10 to reduce code duplication in the DC driver.
--- .../dc/resource/dce100/dce100_resource.c | 13 +++++- .../dc/resource/dce100/dce100_resource.h | 5 +++ .../dc/resource/dce60/dce60_resource.c | 43 +------------------ .../dc/resource/dce80/dce80_resource.c | 34 +-------------- 4 files changed, 18 insertions(+), 77 deletions(-)
drivers/gpu/drm/amd/display/dc/resource/dce100/dce100_resource.c +11 -2
@@ -837,7 +837,7 @@ static enum dc_status build_mapped_resource(return DC_OK ; } -static enum dc_status dce100_validate_bandwidth ( +enum dc_status dce100_validate_bandwidth (struct dc *dc,struct dc_state *context,enum dc_validate_mode validate_mode)
@@ -862,7 +862,16 @@ static enum dc_status dce100_validate_bandwidth( context->bw_ctx.bw.dce.dispclk_khz =681000 ; context->bw_ctx.bw.dce.yclk_khz =250000 *MEMORY_TYPE_MULTIPLIER_CZ ; }else { - context->bw_ctx.bw.dce.dispclk_khz =0 ; +/* On DCE 6.0 and 6.4 the PLL0 is both the display engine clock and +* the DP clock, and shouldn't be turned off. Just select the display +* clock value from its low power mode. +*/ +if (dc->ctx->dce_version ==DCE_VERSION_6_0 || + dc->ctx->dce_version ==DCE_VERSION_6_4 ) + context->bw_ctx.bw.dce.dispclk_khz =352000 ; +else + context->bw_ctx.bw.dce.dispclk_khz =0 ; + context->bw_ctx.bw.dce.yclk_khz =0 ; }
drivers/gpu/drm/amd/display/dc/resource/dce100/dce100_resource.h +5 -0
@@ -41,6 +41,11 @@ struct resource_pool *dce100_create_resource_pool(enum dc_status dce100_validate_plane (const struct dc_plane_state *plane_state,struct dc_caps *caps); +enum dc_status dce100_validate_bandwidth ( +struct dc *dc, +struct dc_state *context, +enum dc_validate_mode validate_mode); + enum dc_status dce100_add_stream_to_ctx( struct dc *dc, struct dc_state *new_ctx,
drivers/gpu/drm/amd/display/dc/resource/dce60/dce60_resource.c +1 -42
55 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/resource/dce80/dce80_resource.c +1 -33
@@ -870,38 +870,6 @@ static void dce80_resource_destruct(struct dce110_resource_pool *pool) } } -static enum dc_status dce80_validate_bandwidth ( -struct dc *dc, -struct dc_state *context, -enum dc_validate_mode validate_mode) -{ -int i; -bool at_least_one_pipe = false; -struct dc_stream_state *stream =NULL ; -const uint32_t max_pix_clk_khz =max (dc->clk_mgr->clks.max_supported_dispclk_khz,400000 ); - -for (i =0 ; i < dc->res_pool->pipe_count; i++) { - stream = context->res_ctx.pipe_ctx[i].stream; -if (stream) { - at_least_one_pipe = true; - -if (stream->timing.pix_clk_100hz >= max_pix_clk_khz *10 ) -return DC_FAIL_BANDWIDTH_VALIDATE ; - } - } - -if (at_least_one_pipe) { -/* TODO implement when needed but for now hardcode max value*/ - context->bw_ctx.bw.dce.dispclk_khz =681000 ; - context->bw_ctx.bw.dce.yclk_khz =250000 *MEMORY_TYPE_MULTIPLIER_CZ ; - }else { - context->bw_ctx.bw.dce.dispclk_khz =0 ; - context->bw_ctx.bw.dce.yclk_khz =0 ; - } - -return DC_OK ; -} -static bool dce80_validate_surface_sets (struct dc_state *context) {
@@ -945,7 +913,7 @@ static const struct resource_funcs dce80_res_pool_funcs = { .destroy = dce80_destroy_resource_pool, .link_enc_create = dce80_link_encoder_create, .panel_cntl_create = dce80_panel_cntl_create, - .validate_bandwidth = dce80_validate_bandwidth, + .validate_bandwidth = dce100_validate_bandwidth, .validate_plane = dce100_validate_plane, .add_stream_to_ctx = dce100_add_stream_to_ctx, .validate_global = dce80_validate_global,
Signature · 1 line
2.51.0
PATCH 3/3 drm/amd/display: Share dce100_validate_global with DCE6-8
In reply to Timur KristófThe dce100_validate_global function was verbatim exactly the same as dce60_validate_global and dce80_validate_global.
Share dce100_validate_global between DCE6-10 to save code size.
--- .../dc/resource/dce100/dce100_resource.c | 2 +- .../dc/resource/dce100/dce100_resource.h | 4 +++ .../dc/resource/dce60/dce60_resource.c | 32 +------------------ .../dc/resource/dce80/dce80_resource.c | 32 +------------------ 4 files changed, 7 insertions(+), 63 deletions(-)
drivers/gpu/drm/amd/display/dc/resource/dce100/dce100_resource.c +1 -1
@@ -898,7 +898,7 @@ static bool dce100_validate_surface_sets(return true; } -static enum dc_status dce100_validate_global ( +enum dc_status dce100_validate_global (struct dc *dc,struct dc_state *context) {
drivers/gpu/drm/amd/display/dc/resource/dce100/dce100_resource.h +4 -0
@@ -41,6 +41,10 @@ struct resource_pool *dce100_create_resource_pool(enum dc_status dce100_validate_plane (const struct dc_plane_state *plane_state,struct dc_caps *caps); +enum dc_status dce100_validate_global ( +struct dc *dc, +struct dc_state *context); + enum dc_status dce100_validate_bandwidth( struct dc *dc, struct dc_state *context,
drivers/gpu/drm/amd/display/dc/resource/dce60/dce60_resource.c +1 -31
@@ -864,36 +864,6 @@ static void dce60_resource_destruct(struct dce110_resource_pool *pool) } } -static bool dce60_validate_surface_sets ( -struct dc_state *context) -{ -int i; - -for (i =0 ; i < context->stream_count; i++) { -if (context->stream_status[i].plane_count ==0 ) -continue ; - -if (context->stream_status[i].plane_count >1 ) -return false; - -if (context->stream_status[i].plane_states[0 ]->format - >=SURFACE_PIXEL_FORMAT_VIDEO_BEGIN ) -return false; - } - -return true; -} - -static enum dc_status dce60_validate_global ( -struct dc *dc, -struct dc_state *context) -{ -if (!dce60_validate_surface_sets (context)) -return DC_FAIL_SURFACE_VALIDATE ; - -return DC_OK ; -} -static void dce60_destroy_resource_pool (struct resource_pool **pool) {struct dce110_resource_pool *dce110_pool =TO_DCE110_RES_POOL (*pool);
@@ -910,7 +880,7 @@ static const struct resource_funcs dce60_res_pool_funcs = { .validate_bandwidth = dce100_validate_bandwidth, .validate_plane = dce100_validate_plane, .add_stream_to_ctx = dce100_add_stream_to_ctx, - .validate_global = dce60_validate_global, + .validate_global = dce100_validate_global, .find_first_free_match_stream_enc_for_link = dce100_find_first_free_match_stream_enc_for_link };
drivers/gpu/drm/amd/display/dc/resource/dce80/dce80_resource.c +1 -31
@@ -870,36 +870,6 @@ static void dce80_resource_destruct(struct dce110_resource_pool *pool) } } -static bool dce80_validate_surface_sets ( -struct dc_state *context) -{ -int i; - -for (i =0 ; i < context->stream_count; i++) { -if (context->stream_status[i].plane_count ==0 ) -continue ; - -if (context->stream_status[i].plane_count >1 ) -return false; - -if (context->stream_status[i].plane_states[0 ]->format - >=SURFACE_PIXEL_FORMAT_VIDEO_BEGIN ) -return false; - } - -return true; -} - -static enum dc_status dce80_validate_global ( -struct dc *dc, -struct dc_state *context) -{ -if (!dce80_validate_surface_sets (context)) -return DC_FAIL_SURFACE_VALIDATE ; - -return DC_OK ; -} -static void dce80_destroy_resource_pool (struct resource_pool **pool) {struct dce110_resource_pool *dce110_pool =TO_DCE110_RES_POOL (*pool);
@@ -916,7 +886,7 @@ static const struct resource_funcs dce80_res_pool_funcs = { .validate_bandwidth = dce100_validate_bandwidth, .validate_plane = dce100_validate_plane, .add_stream_to_ctx = dce100_add_stream_to_ctx, - .validate_global = dce80_validate_global, + .validate_global = dce100_validate_global, .find_first_free_match_stream_enc_for_link = dce100_find_first_free_match_stream_enc_for_link };
Signature · 1 line
2.51.0
Re: [PATCH 3/3] drm/amd/display: Share dce100_validate_global with DCE6-8
Quoted 7 lines · Timur Kristóf
The
dce100_validate_globalfunction was verbatim exactly the same asdce60_validate_globalanddce80_validate_global.Share
dce100_validate_globalbetween DCE6-10 to save code size.Signed-off-by Timur Kristóf <[email protected]>
Series is:
Quoted 138 lines
--- .../dc/resource/dce100/dce100_resource.c | 2 +- .../dc/resource/dce100/dce100_resource.h | 4 +++ .../dc/resource/dce60/dce60_resource.c | 32 +------------------ .../dc/resource/dce80/dce80_resource.c | 32 +------------------ 4 files changed, 7 insertions(+), 63 deletions(-)drivers/gpu/drm/amd/display/dc/resource/dce100/dce100_resource.c +1
-1@@ -898,7 +898,7 @@ static bool dce100_validate_surface_sets(return true; } -static enum dc_status dce100_validate_global ( +enum dc_status dce100_validate_global (struct dc *dc,struct dc_state *context) {drivers/gpu/drm/amd/display/dc/resource/dce100/dce100_resource.h +4
-0@@ -41,6 +41,10 @@ struct resource_pool *dce100_create_resource_pool(enum dc_status dce100_validate_plane (const struct dc_plane_state *plane_state,struct dc_caps *caps); +enum dc_status dce100_validate_global ( +struct dc *dc, +struct dc_state *context); + enum dc_status dce100_validate_bandwidth( struct dc *dc, struct dc_state *context,drivers/gpu/drm/amd/display/dc/resource/dce60/dce60_resource.c +1
-31@@ -864,36 +864,6 @@ static void dce60_resource_destruct(struct dce110_resource_pool *pool) } } -static bool dce60_validate_surface_sets ( -struct dc_state *context) -{ -int i; - -for (i =0 ; i < context->stream_count; i++) { -if (context->stream_status[i].plane_count ==0 ) -continue ; - -if (context->stream_status[i].plane_count >1 ) -return false; - -if (context->stream_status[i].plane_states[0 ]->format - >=SURFACE_PIXEL_FORMAT_VIDEO_BEGIN ) -return false; - } - -return true; -} - -static enum dc_status dce60_validate_global ( -struct dc *dc, -struct dc_state *context) -{ -if (!dce60_validate_surface_sets (context)) -return DC_FAIL_SURFACE_VALIDATE ; - -return DC_OK ; -} -static void dce60_destroy_resource_pool (struct resource_pool **pool) {struct dce110_resource_pool *dce110_pool =TO_DCE110_RES_POOL (*pool);@@ -910,7 +880,7 @@ static const struct resource_funcs dce60_res_pool_funcs = { .validate_bandwidth = dce100_validate_bandwidth, .validate_plane = dce100_validate_plane, .add_stream_to_ctx = dce100_add_stream_to_ctx, - .validate_global = dce60_validate_global, + .validate_global = dce100_validate_global, .find_first_free_match_stream_enc_for_link = dce100_find_first_free_match_stream_enc_for_link };drivers/gpu/drm/amd/display/dc/resource/dce80/dce80_resource.c +1
-32@@ -870,36 +870,6 @@ static void dce80_resource_destruct(struct dce110_resource_pool *pool) } } -static bool dce80_validate_surface_sets ( -struct dc_state *context) -{ -int i; - -for (i =0 ; i < context->stream_count; i++) { -if (context->stream_status[i].plane_count ==0 ) -continue ; - -if (context->stream_status[i].plane_count >1 ) -return false; - -if (context->stream_status[i].plane_states[0 ]->format - >=SURFACE_PIXEL_FORMAT_VIDEO_BEGIN ) -return false; - } - -return true; -} - -static enum dc_status dce80_validate_global ( -struct dc *dc, -struct dc_state *context) -{ -if (!dce80_validate_surface_sets (context)) -return DC_FAIL_SURFACE_VALIDATE ; - -return DC_OK ; -} -static void dce80_destroy_resource_pool (struct resource_pool **pool) {struct dce110_resource_pool *dce110_pool =TO_DCE110_RES_POOL (*pool);@@ -916,7 +886,7 @@ static const struct resource_funcs dce80_res_pool_funcs = { .validate_bandwidth = dce100_validate_bandwidth, .validate_plane = dce100_validate_plane, .add_stream_to_ctx = dce100_add_stream_to_ctx, - .validate_global = dce80_validate_global, + .validate_global = dce100_validate_global, .find_first_free_match_stream_enc_for_link = dce100_find_first_free_match_stream_enc_for_link }; --2.51.0
Quoted 16 lines · Timur Kristóf
Reject modes with a pixel clock higher than the maximum display clock. These were never supported, but we haven't noticed the issue until the YCbCr 422 fallback was recently added.
For example, the DP 1.2 standard technically supports 4K 120Hz YCbCr 422 6 bpc, but in practice the pixel clock is too high on these old GPUs.
Additionally, there are two small code cleanup patches to avoid excessive code duplication.
Timur Kristóf (3):
drm/amd/display: Reject modes with too high pixel clock on DCE6-10 drm/amd/display: Sharedce100_validate_bandwidthwith DCE6-8 drm/amd/display: Sharedce100_validate_globalwith DCE6-8
Quoted 8 lines
.../display/dc/clk_mgr/dce100/dce_clk_mgr.c | 3 + .../display/dc/clk_mgr/dce60/dce60_clk_mgr.c | 5 ++ .../dc/resource/dce100/dce100_resource.c | 25 +++++-- .../dc/resource/dce100/dce100_resource.h | 9 +++ .../dc/resource/dce60/dce60_resource.c | 69 +------------------ .../dc/resource/dce80/dce80_resource.c | 60 +--------------- 6 files changed, 44 insertions(+), 127 deletions(-)
I've applied this internally and it will run through CI and come to amd-staging-drm-next soon, thanks!