[PATCH] drm/amd/display: Don't call dm_log_to_buffer directly in dc_conn_log

Harry Wentland harry.wentland at amd.com
Thu Nov 23 15:30:16 UTC 2017


On 2017-11-23 06:51 AM, Michel Dänzer wrote:
> From: Michel Dänzer <michel.daenzer at amd.com>
> 
> dm_log_to_buffer logs unconditionally, so calling it directly resulted
> in the main message being logged even when the event type isn't enabled
> in the event mask.
> 
> To fix this, remove the trailing newline from the format string and call
> dm_logger_append instead.
> 
> Fixes spurious messages like
> 
>  [drm] {1920x1200, 2080x1235 at 154000Khz}
> 
> in dmesg when a mode is set.
> 
> Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>

Thanks for catching and fixing this. I missed this when eye-balling the code yesterday.

Reviewed-by: Harry Wentland <harry.wentland at amd.com>

Harry

> ---
>  drivers/gpu/drm/amd/display/dc/basics/log_helpers.c | 20 +++++++++-----------
>  1 file changed, 9 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/dc/basics/log_helpers.c b/drivers/gpu/drm/amd/display/dc/basics/log_helpers.c
> index 785b943b60ed..02d43e29ded5 100644
> --- a/drivers/gpu/drm/amd/display/dc/basics/log_helpers.c
> +++ b/drivers/gpu/drm/amd/display/dc/basics/log_helpers.c
> @@ -60,6 +60,8 @@ void dc_conn_log(struct dc_context *ctx,
>  	va_list args;
>  	struct log_entry entry = { 0 };
>  	enum signal_type signal;
> +	char *msg_no_newline = (char*)msg;
> +	size_t msg_len = strlen(msg) - 1;
>  
>  	if (link->local_sink)
>  		signal = link->local_sink->sink_signal;
> @@ -79,17 +81,15 @@ void dc_conn_log(struct dc_context *ctx,
>  			signal_type_info_tbl[i].name,
>  			link->link_index);
>  
> -	va_start(args, msg);
> -	entry.buf_offset += dm_log_to_buffer(
> -		&entry.buf[entry.buf_offset],
> -		LOG_MAX_LINE_SIZE - entry.buf_offset,
> -		msg, args);
> -
> -	if (entry.buf[strlen(entry.buf) - 1] == '\n') {
> -		entry.buf[strlen(entry.buf) - 1] = '\0';
> -		entry.buf_offset--;
> +	if (msg[msg_len] == '\n') {
> +		msg_no_newline = kstrdup(msg, GFP_KERNEL);
> +		msg_no_newline[msg_len] = '\0';
>  	}
>  
> +	dm_logger_append(&entry, msg_no_newline, args);
> +	if (msg_no_newline != msg)
> +		kfree(msg_no_newline);
> +
>  	if (hex_data)
>  		for (i = 0; i < hex_data_count; i++)
>  			dm_logger_append(&entry, "%2.2X ", hex_data[i]);
> @@ -97,6 +97,4 @@ void dc_conn_log(struct dc_context *ctx,
>  	dm_logger_append(&entry, "^\n");
>  	dm_helpers_dc_conn_log(ctx, &entry, event);
>  	dm_logger_close(&entry);
> -
> -	va_end(args);
>  }
> 


More information about the amd-gfx mailing list