Commit 0ed3bcc4 authored by Nicholas Kazlauskas's avatar Nicholas Kazlauskas Committed by Alex Deucher
Browse files

drm/amd/display: Pass command instead of header into DMUB service



[Why]
We read memory that we shouldn't be touching if the struct isn't
a full union dmub_rb_cmd.

[How]
Fix up all the callers and functions that take in the dmub_cmd_header
to use the dmub_rb_cmd instead.

Signed-off-by: default avatarNicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Reviewed-by: default avatarTony Cheng <Tony.Cheng@amd.com>
Acked-by: default avatarAurabindo Pillai <aurabindo.pillai@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 77ef333e
Loading
Loading
Loading
Loading
+42 −20
Original line number Diff line number Diff line
@@ -113,13 +113,19 @@ static void encoder_control_dmcub(
		struct dc_dmub_srv *dmcub,
		struct dig_encoder_stream_setup_parameters_v1_5 *dig)
{
	struct dmub_rb_cmd_digx_encoder_control encoder_control = { 0 };
	union dmub_rb_cmd cmd;

	encoder_control.header.type = DMUB_CMD__VBIOS;
	encoder_control.header.sub_type = DMUB_CMD__VBIOS_DIGX_ENCODER_CONTROL;
	encoder_control.encoder_control.dig.stream_param = *dig;
	memset(&cmd, 0, sizeof(cmd));

	dc_dmub_srv_cmd_queue(dmcub, &encoder_control.header);
	cmd.digx_encoder_control.header.type = DMUB_CMD__VBIOS;
	cmd.digx_encoder_control.header.sub_type =
		DMUB_CMD__VBIOS_DIGX_ENCODER_CONTROL;
	cmd.digx_encoder_control.header.payload_bytes =
		sizeof(cmd.digx_encoder_control) -
		sizeof(cmd.digx_encoder_control.header);
	cmd.digx_encoder_control.encoder_control.dig.stream_param = *dig;

	dc_dmub_srv_cmd_queue(dmcub, &cmd);
	dc_dmub_srv_cmd_execute(dmcub);
	dc_dmub_srv_wait_idle(dmcub);
}
@@ -238,14 +244,19 @@ static void transmitter_control_dmcub(
		struct dc_dmub_srv *dmcub,
		struct dig_transmitter_control_parameters_v1_6 *dig)
{
	struct dmub_rb_cmd_dig1_transmitter_control transmitter_control;
	union dmub_rb_cmd cmd;

	memset(&cmd, 0, sizeof(cmd));

	transmitter_control.header.type = DMUB_CMD__VBIOS;
	transmitter_control.header.sub_type =
	cmd.dig1_transmitter_control.header.type = DMUB_CMD__VBIOS;
	cmd.dig1_transmitter_control.header.sub_type =
		DMUB_CMD__VBIOS_DIG1_TRANSMITTER_CONTROL;
	transmitter_control.transmitter_control.dig = *dig;
	cmd.dig1_transmitter_control.header.payload_bytes =
		sizeof(cmd.dig1_transmitter_control) -
		sizeof(cmd.dig1_transmitter_control.header);
	cmd.dig1_transmitter_control.transmitter_control.dig = *dig;

	dc_dmub_srv_cmd_queue(dmcub, &transmitter_control.header);
	dc_dmub_srv_cmd_queue(dmcub, &cmd);
	dc_dmub_srv_cmd_execute(dmcub);
	dc_dmub_srv_wait_idle(dmcub);
}
@@ -339,13 +350,18 @@ static void set_pixel_clock_dmcub(
		struct dc_dmub_srv *dmcub,
		struct set_pixel_clock_parameter_v1_7 *clk)
{
	struct dmub_rb_cmd_set_pixel_clock pixel_clock = { 0 };
	union dmub_rb_cmd cmd;

	pixel_clock.header.type = DMUB_CMD__VBIOS;
	pixel_clock.header.sub_type = DMUB_CMD__VBIOS_SET_PIXEL_CLOCK;
	pixel_clock.pixel_clock.clk = *clk;
	memset(&cmd, 0, sizeof(cmd));

	dc_dmub_srv_cmd_queue(dmcub, &pixel_clock.header);
	cmd.set_pixel_clock.header.type = DMUB_CMD__VBIOS;
	cmd.set_pixel_clock.header.sub_type = DMUB_CMD__VBIOS_SET_PIXEL_CLOCK;
	cmd.set_pixel_clock.header.payload_bytes =
		sizeof(cmd.set_pixel_clock) -
		sizeof(cmd.set_pixel_clock.header);
	cmd.set_pixel_clock.pixel_clock.clk = *clk;

	dc_dmub_srv_cmd_queue(dmcub, &cmd);
	dc_dmub_srv_cmd_execute(dmcub);
	dc_dmub_srv_wait_idle(dmcub);
}
@@ -705,13 +721,19 @@ static void enable_disp_power_gating_dmcub(
	struct dc_dmub_srv *dmcub,
	struct enable_disp_power_gating_parameters_v2_1 *pwr)
{
	struct dmub_rb_cmd_enable_disp_power_gating power_gating;
	union dmub_rb_cmd cmd;

	memset(&cmd, 0, sizeof(cmd));

	power_gating.header.type = DMUB_CMD__VBIOS;
	power_gating.header.sub_type = DMUB_CMD__VBIOS_ENABLE_DISP_POWER_GATING;
	power_gating.power_gating.pwr = *pwr;
	cmd.enable_disp_power_gating.header.type = DMUB_CMD__VBIOS;
	cmd.enable_disp_power_gating.header.sub_type =
		DMUB_CMD__VBIOS_ENABLE_DISP_POWER_GATING;
	cmd.enable_disp_power_gating.header.payload_bytes =
		sizeof(cmd.enable_disp_power_gating) -
		sizeof(cmd.enable_disp_power_gating.header);
	cmd.enable_disp_power_gating.power_gating.pwr = *pwr;

	dc_dmub_srv_cmd_queue(dmcub, &power_gating.header);
	dc_dmub_srv_cmd_queue(dmcub, &cmd);
	dc_dmub_srv_cmd_execute(dmcub);
	dc_dmub_srv_wait_idle(dmcub);
}
+1 −1
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ void dc_dmub_srv_destroy(struct dc_dmub_srv **dmub_srv)
}

void dc_dmub_srv_cmd_queue(struct dc_dmub_srv *dc_dmub_srv,
			   struct dmub_cmd_header *cmd)
			   union dmub_rb_cmd *cmd)
{
	struct dmub_srv *dmub = dc_dmub_srv->dmub;
	struct dc_context *dc_ctx = dc_dmub_srv->ctx;
+1 −2
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@
#include "dmub/inc/dmub_cmd.h"

struct dmub_srv;
struct dmub_cmd_header;

struct dc_reg_helper_state {
	bool gather_in_progress;
@@ -49,7 +48,7 @@ struct dc_dmub_srv {
};

void dc_dmub_srv_cmd_queue(struct dc_dmub_srv *dc_dmub_srv,
			   struct dmub_cmd_header *cmd);
			   union dmub_rb_cmd *cmd);

void dc_dmub_srv_cmd_execute(struct dc_dmub_srv *dc_dmub_srv);

+3 −3
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ static inline void submit_dmub_read_modify_write(
	gather = ctx->dmub_srv->reg_helper_offload.gather_in_progress;
	ctx->dmub_srv->reg_helper_offload.gather_in_progress = false;

	dc_dmub_srv_cmd_queue(ctx->dmub_srv, &cmd_buf->header);
	dc_dmub_srv_cmd_queue(ctx->dmub_srv, &offload->cmd_data);

	ctx->dmub_srv->reg_helper_offload.gather_in_progress = gather;

@@ -73,7 +73,7 @@ static inline void submit_dmub_burst_write(
	gather = ctx->dmub_srv->reg_helper_offload.gather_in_progress;
	ctx->dmub_srv->reg_helper_offload.gather_in_progress = false;

	dc_dmub_srv_cmd_queue(ctx->dmub_srv, &cmd_buf->header);
	dc_dmub_srv_cmd_queue(ctx->dmub_srv, &offload->cmd_data);

	ctx->dmub_srv->reg_helper_offload.gather_in_progress = gather;

@@ -92,7 +92,7 @@ static inline void submit_dmub_reg_wait(
	gather = ctx->dmub_srv->reg_helper_offload.gather_in_progress;
	ctx->dmub_srv->reg_helper_offload.gather_in_progress = false;

	dc_dmub_srv_cmd_queue(ctx->dmub_srv, &cmd_buf->header);
	dc_dmub_srv_cmd_queue(ctx->dmub_srv, &offload->cmd_data);

	memset(cmd_buf, 0, sizeof(*cmd_buf));
	offload->reg_seq_count = 0;
+5 −5
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ static bool dmub_abm_set_pipe(struct abm *abm, uint32_t otg_inst)
	cmd.abm_set_pipe.abm_set_pipe_data.ramping_boundary = ramping_boundary;
	cmd.abm_set_pipe.header.payload_bytes = sizeof(struct dmub_cmd_abm_set_pipe_data);

	dc_dmub_srv_cmd_queue(dc->dmub_srv, &cmd.abm_set_pipe.header);
	dc_dmub_srv_cmd_queue(dc->dmub_srv, &cmd);
	dc_dmub_srv_cmd_execute(dc->dmub_srv);
	dc_dmub_srv_wait_idle(dc->dmub_srv);

@@ -146,7 +146,7 @@ static void dmcub_set_backlight_level(
	cmd.abm_set_backlight.abm_set_backlight_data.frame_ramp = frame_ramp;
	cmd.abm_set_backlight.header.payload_bytes = sizeof(struct dmub_cmd_abm_set_backlight_data);

	dc_dmub_srv_cmd_queue(dc->dmub_srv, &cmd.abm_set_backlight.header);
	dc_dmub_srv_cmd_queue(dc->dmub_srv, &cmd);
	dc_dmub_srv_cmd_execute(dc->dmub_srv);
	dc_dmub_srv_wait_idle(dc->dmub_srv);

@@ -171,7 +171,7 @@ static void dmub_abm_enable_fractional_pwm(struct dc_context *dc)
	cmd.abm_set_pwm_frac.abm_set_pwm_frac_data.fractional_pwm = fractional_pwm;
	cmd.abm_set_pwm_frac.header.payload_bytes = sizeof(struct dmub_cmd_abm_set_pwm_frac_data);

	dc_dmub_srv_cmd_queue(dc->dmub_srv, &cmd.abm_set_pwm_frac.header);
	dc_dmub_srv_cmd_queue(dc->dmub_srv, &cmd);
	dc_dmub_srv_cmd_execute(dc->dmub_srv);
	dc_dmub_srv_wait_idle(dc->dmub_srv);
}
@@ -250,7 +250,7 @@ static bool dmub_abm_set_level(struct abm *abm, uint32_t level)
	cmd.abm_set_level.abm_set_level_data.level = level;
	cmd.abm_set_level.header.payload_bytes = sizeof(struct dmub_cmd_abm_set_level_data);

	dc_dmub_srv_cmd_queue(dc->dmub_srv, &cmd.abm_set_level.header);
	dc_dmub_srv_cmd_queue(dc->dmub_srv, &cmd);
	dc_dmub_srv_cmd_execute(dc->dmub_srv);
	dc_dmub_srv_wait_idle(dc->dmub_srv);

@@ -370,7 +370,7 @@ static bool dmub_abm_init_config(struct abm *abm,
	cmd.abm_init_config.abm_init_config_data.bytes = bytes;
	cmd.abm_init_config.header.payload_bytes = sizeof(struct dmub_cmd_abm_init_config_data);

	dc_dmub_srv_cmd_queue(dc->dmub_srv, &cmd.abm_init_config.header);
	dc_dmub_srv_cmd_queue(dc->dmub_srv, &cmd);
	dc_dmub_srv_cmd_execute(dc->dmub_srv);
	dc_dmub_srv_wait_idle(dc->dmub_srv);

Loading