Skip to content

Commit 18f0817

Browse files
Aurabindo Pillaialexdeucher
authored andcommitted
drm/amd/display: Initial support for SmartMux
SmartMux is a mechanism to switch the GPU being used for scanout in a hybrid configuration. This is used for devices with an eDP and two GPUs. This is only valid when the system has a physical switch (Multiplexer) in the board to switch between the two GPUs. When a graphically intensive workload like a game is being run, the system can be switch the active display to the dGPU, so that we can avoid copying the buffer from dGPU to APU for scanout. This helps with latency and FPS. When power consumption is preferred, the system can be switched to the APU. Reviewed-by: Alvin Lee <alvin.lee2@amd.com> Signed-off-by: Aurabindo Pillai <aurabindo.pillai@amd.com> Signed-off-by: Ivan Lipski <ivan.lipski@amd.com> Tested-by: Daniel Wheeler <daniel.wheeler@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent fa699ac commit 18f0817

File tree

20 files changed

+366
-6
lines changed

20 files changed

+366
-6
lines changed

drivers/gpu/drm/amd/display/dc/clk_mgr/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ AMD_DISPLAY_FILES += $(AMD_DAL_CLK_MGR_DCN21)
112112
###############################################################################
113113
# DCN30
114114
###############################################################################
115-
CLK_MGR_DCN30 = dcn30_clk_mgr.o dcn30_clk_mgr_smu_msg.o
115+
CLK_MGR_DCN30 = dcn30_clk_mgr.o dcn30_clk_mgr_smu_msg.o dcn30m_clk_mgr.o dcn30m_clk_mgr_smu_msg.o
116116

117117
AMD_DAL_CLK_MGR_DCN30 = $(addprefix $(AMDDALPATH)/dc/clk_mgr/dcn30/,$(CLK_MGR_DCN30))
118118

drivers/gpu/drm/amd/display/dc/clk_mgr/clk_mgr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ int clk_mgr_helper_get_active_display_cnt(
6767
if (dc_state_get_stream_subvp_type(context, stream) == SUBVP_PHANTOM)
6868
continue;
6969

70-
if (!stream->dpms_off || (stream_status && stream_status->plane_count))
70+
if (!stream->dpms_off || dc->is_switch_in_progress_dest || (stream_status && stream_status->plane_count))
7171
display_count++;
7272
}
7373

drivers/gpu/drm/amd/display/dc/clk_mgr/dcn30/dalsmc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
#define DALSMC_MSG_SetDisplayRefreshFromMall 0xF
5757
#define DALSMC_MSG_SetExternalClientDfCstateAllow 0x10
5858
#define DALSMC_MSG_BacoAudioD3PME 0x11
59-
#define DALSMC_Message_Count 0x12
59+
#define DALSMC_MSG_SmartAccess 0x12
60+
#define DALSMC_Message_Count 0x13
6061

6162
#endif

drivers/gpu/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "dce100/dce_clk_mgr.h"
3131
#include "dcn30/dcn30_clk_mgr.h"
3232
#include "dml/dcn30/dcn30_fpu.h"
33+
#include "dcn30/dcn30m_clk_mgr.h"
3334
#include "reg_helper.h"
3435
#include "core_types.h"
3536
#include "dm_helpers.h"
@@ -498,7 +499,8 @@ static struct clk_mgr_funcs dcn3_funcs = {
498499
.are_clock_states_equal = dcn3_are_clock_states_equal,
499500
.enable_pme_wa = dcn3_enable_pme_wa,
500501
.notify_link_rate_change = dcn30_notify_link_rate_change,
501-
.is_smu_present = dcn3_is_smu_present
502+
.is_smu_present = dcn3_is_smu_present,
503+
.set_smartmux_switch = dcn30m_set_smartmux_switch
502504
};
503505

504506
static void dcn3_init_clocks_fpga(struct clk_mgr *clk_mgr)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2019 Advanced Micro Devices, Inc.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18+
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+
* OTHER DEALINGS IN THE SOFTWARE.
21+
*
22+
* Authors: AMD
23+
*
24+
*/
25+
26+
#include "clk_mgr_internal.h"
27+
#include "dcn30/dcn30m_clk_mgr.h"
28+
#include "dcn30m_clk_mgr_smu_msg.h"
29+
30+
31+
uint32_t dcn30m_set_smartmux_switch(struct clk_mgr *clk_mgr_base, uint32_t pins_to_set)
32+
{
33+
struct clk_mgr_internal *clk_mgr = TO_CLK_MGR_INTERNAL(clk_mgr_base);
34+
35+
return dcn30m_smu_set_smart_mux_switch(clk_mgr, pins_to_set);
36+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2019 Advanced Micro Devices, Inc.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18+
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+
* OTHER DEALINGS IN THE SOFTWARE.
21+
*
22+
* Authors: AMD
23+
*
24+
*/
25+
26+
#ifndef __DCN30M_CLK_MGR_H__
27+
#define __DCN30M_CLK_MGR_H__
28+
29+
uint32_t dcn30m_set_smartmux_switch(struct clk_mgr *clk_mgr_base, uint32_t pins_to_set);
30+
31+
#endif //__DCN30M_CLK_MGR_H__
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*
2+
* Copyright 2020 Advanced Micro Devices, Inc.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18+
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+
* OTHER DEALINGS IN THE SOFTWARE.
21+
*
22+
* Authors: AMD
23+
*
24+
*/
25+
26+
#include "dcn30m_clk_mgr_smu_msg.h"
27+
28+
#include "clk_mgr_internal.h"
29+
#include "reg_helper.h"
30+
#include "dm_helpers.h"
31+
32+
#include "dalsmc.h"
33+
34+
#define mmDAL_MSG_REG 0x1628A
35+
#define mmDAL_ARG_REG 0x16273
36+
#define mmDAL_RESP_REG 0x16274
37+
38+
#define REG(reg_name) \
39+
mm ## reg_name
40+
41+
#include "logger_types.h"
42+
#undef DC_LOGGER
43+
#define DC_LOGGER \
44+
CTX->logger
45+
#define smu_print(str, ...) {DC_LOG_SMU(str, ##__VA_ARGS__); }
46+
47+
48+
/*
49+
* Function to be used instead of REG_WAIT macro because the wait ends when
50+
* the register is NOT EQUAL to zero, and because the translation in msg_if.h
51+
* won't work with REG_WAIT.
52+
*/
53+
static uint32_t dcn30m_smu_wait_for_response(struct clk_mgr_internal *clk_mgr,
54+
unsigned int delay_us, unsigned int max_retries)
55+
{
56+
uint32_t reg = 0;
57+
58+
do {
59+
reg = REG_READ(DAL_RESP_REG);
60+
if (reg)
61+
break;
62+
63+
if (delay_us >= 1000)
64+
msleep(delay_us/1000);
65+
else if (delay_us > 0)
66+
udelay(delay_us);
67+
} while (max_retries--);
68+
69+
/* handle DALSMC_Result_CmdRejectedBusy? */
70+
71+
/* Log? */
72+
73+
return reg;
74+
}
75+
76+
static bool dcn30m_smu_send_msg_with_param(struct clk_mgr_internal *clk_mgr,
77+
uint32_t msg_id, uint32_t param_in, uint32_t *param_out)
78+
{
79+
uint32_t result;
80+
/* Wait for response register to be ready */
81+
dcn30m_smu_wait_for_response(clk_mgr, 10, 200000);
82+
83+
/* Clear response register */
84+
REG_WRITE(DAL_RESP_REG, 0);
85+
86+
/* Set the parameter register for the SMU message */
87+
REG_WRITE(DAL_ARG_REG, param_in);
88+
89+
/* Trigger the message transaction by writing the message ID */
90+
REG_WRITE(DAL_MSG_REG, msg_id);
91+
92+
result = dcn30m_smu_wait_for_response(clk_mgr, 10, 200000);
93+
94+
if (IS_SMU_TIMEOUT(result))
95+
dm_helpers_smu_timeout(CTX, msg_id, param_in, 10 * 200000);
96+
97+
/* Wait for response */
98+
if (result == DALSMC_Result_OK) {
99+
if (param_out)
100+
*param_out = REG_READ(DAL_ARG_REG);
101+
102+
return true;
103+
}
104+
105+
return false;
106+
}
107+
108+
uint32_t dcn30m_smu_set_smart_mux_switch(struct clk_mgr_internal *clk_mgr, uint32_t pins_to_set)
109+
{
110+
uint32_t response = 0;
111+
112+
smu_print("SMU Set SmartMux Switch: switch_dgpu = %d\n", pins_to_set);
113+
114+
dcn30m_smu_send_msg_with_param(clk_mgr,
115+
DALSMC_MSG_SmartAccess, pins_to_set, &response);
116+
117+
return response;
118+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright 2020 Advanced Micro Devices, Inc.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18+
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+
* OTHER DEALINGS IN THE SOFTWARE.
21+
*
22+
* Authors: AMD
23+
*
24+
*/
25+
26+
#ifndef DAL_DC_DCN30M_CLK_MGR_SMU_MSG_H_
27+
#define DAL_DC_DCN30M_CLK_MGR_SMU_MSG_H_
28+
29+
#include "core_types.h"
30+
31+
struct clk_mgr_internal;
32+
33+
uint32_t dcn30m_smu_set_smart_mux_switch(struct clk_mgr_internal *clk_mgr, uint32_t pins_to_set);
34+
#endif /* DAL_DC_DCN30M_CLK_MGR_SMU_MSG_H_ */

drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,32 @@ void get_hdr_visual_confirm_color(
427427
}
428428
}
429429

430+
/* Visual Confirm color definition for Smart Mux */
431+
void get_smartmux_visual_confirm_color(
432+
struct dc *dc,
433+
struct tg_color *color)
434+
{
435+
uint32_t color_value = MAX_TG_COLOR_VALUE;
436+
437+
const struct tg_color sm_ver_colors[5] = {
438+
{0, 0, 0}, /* SMUX_MUXCONTROL_UNSUPPORTED - Black */
439+
{0, MAX_TG_COLOR_VALUE, 0}, /* SMUX_MUXCONTROL_v10 - Green */
440+
{0, MAX_TG_COLOR_VALUE, MAX_TG_COLOR_VALUE}, /* SMUX_MUXCONTROL_v15 - Cyan */
441+
{MAX_TG_COLOR_VALUE, MAX_TG_COLOR_VALUE, 0}, /* SMUX_MUXCONTROL_MDM - Yellow */
442+
{MAX_TG_COLOR_VALUE, 0, MAX_TG_COLOR_VALUE}, /* SMUX_MUXCONTROL_vUNKNOWN - Magenta*/
443+
};
444+
445+
if (dc->caps.is_apu) {
446+
/* APU driving the eDP */
447+
*color = sm_ver_colors[dc->config.smart_mux_version];
448+
} else {
449+
/* dGPU driving the eDP - red */
450+
color->color_r_cr = color_value;
451+
color->color_g_y = 0;
452+
color->color_b_cb = 0;
453+
}
454+
}
455+
430456
/* Visual Confirm color definition for VABC */
431457
void get_vabc_visual_confirm_color(
432458
struct pipe_ctx *pipe_ctx,

drivers/gpu/drm/amd/display/dc/dc.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,7 @@ struct dc_config {
505505
bool use_spl;
506506
bool prefer_easf;
507507
bool use_pipe_ctx_sync_logic;
508+
int smart_mux_version;
508509
bool ignore_dpref_ss;
509510
bool enable_mipi_converter_optimization;
510511
bool use_default_clock_table;
@@ -541,6 +542,7 @@ enum visual_confirm {
541542
VISUAL_CONFIRM_SWAPCHAIN = 6,
542543
VISUAL_CONFIRM_FAMS = 7,
543544
VISUAL_CONFIRM_SWIZZLE = 9,
545+
VISUAL_CONFIRM_SMARTMUX_DGPU = 10,
544546
VISUAL_CONFIRM_REPLAY = 12,
545547
VISUAL_CONFIRM_SUBVP = 14,
546548
VISUAL_CONFIRM_MCLK_SWITCH = 16,
@@ -1639,6 +1641,8 @@ struct dc_scratch_space {
16391641

16401642
struct gpio *hpd_gpio;
16411643
enum dc_link_fec_state fec_state;
1644+
bool is_dds;
1645+
bool is_display_mux_present;
16421646
bool link_powered_externally; // Used to bypass hardware sequencing delays when panel is powered down forcibly
16431647

16441648
struct dc_panel_config panel_config;
@@ -1693,6 +1697,10 @@ struct dc {
16931697

16941698
/* Require to maintain clocks and bandwidth for UEFI enabled HW */
16951699

1700+
/* For eDP to know the switching state of SmartMux */
1701+
bool is_switch_in_progress_orig;
1702+
bool is_switch_in_progress_dest;
1703+
16961704
/* FBC compressor */
16971705
struct compressor *fbc_compressor;
16981706

0 commit comments

Comments
 (0)