From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A3087606A320 for ; Tue, 1 Dec 2026 20:57:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KLXgbnwF Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3CE1410FD1C; Tue, 1 Dec 2026 20:57:16 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 030F410FD1C for ; Tue, 1 Dec 2026 20:57:10 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id C9258453FC; Tue, 1 Dec 2026 20:57:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9855F1F00939; Tue, 1 Dec 2026 20:57:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796158629; bh=RaiLd6cXMhDm6eqkKAzX/Kk90RXPK8s2lFhZ8j5Q+5c=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=KLXgbnwFO0iD7NBOSOd3FVKj9RM5BWuAKPawcm0U9wsc6wDKPUu8jlai9+Ob5NtZo ujLnzYm2qMQp7m+wfrX0JM4s6WwXI3rw8sOSMamCUjD5i5QTUuFCHDibnkQsvi1uJq JNhsZAz+AjUa+fawrx+9jgXEIBM+NJT6Nne9cTyuYnc3It/pux7enNHhTbCPmhfDZ5 f2+F0oFiGzX04ozXbRUn7PCAmjL1SZsnFiV1o4tR+V8JfigqHHo+fda9J4Y868kp2D SrJgCST4XtqxxxROPtIKVXlBInRYMSX5251gi2XN4WCwmUmzKUG+JuFfQ4iTrEZp45 QgvWfEvKOA4dg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 27/30] drm/amd/display: Sync OTG timing in the DC2 non-seamless commit To: "George Zhang" , amd-gfx@lists.freedesktop.org In-Reply-To: <20261201202451.463794-29-george.zhang@amd.com> References: <20261201202451.463794-2-george.zhang@amd.com> <20261201202451.463794-29-george.zhang@amd.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 20:57:09 +0000 X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "amd-gfx" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] drm/amd/display: missed OTG sync in dcn401_timing_sync_source() - [Medium] drm/amd/display: data race on static buffers in wa_dpg_height_apply() -- commit 38a0b1198247f1d2010554b1b7b6370ab3f8b13a Author: Tony Cheng drm/amd/display: Sync OTG timing in the DC2 non-seamless commit This commit adds OTG timing synchronization steps to the DCN401 DC2 non-seamless commit builder and registers a workaround to raise the DPG height around the OTG reset trigger steps. > diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_b= uilder.c b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_build= er.c > index 6ee61bea0c0bc..9ad9081b1b9ae 100644 > --- a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c > +++ b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c [ ... ] > @@ -2853,6 +2871,42 @@ static bool dcn401_walks_stream(const struct dcn40= 1_commit_step_args *args, > args->new_state, stream); > } > =20 > +/* > + * The OTG master that pipe resets to, chosen as program_timing_sync doe= s: > + * the first OTG master with the same timing that shows a plane, else the > + * first one. NULL when that is pipe. > + */ > +static const struct pipe_ctx *dcn401_timing_sync_source( > + const struct dcn401_commit_step_args *args, > + const struct pipe_ctx *pipe) > +{ > + const struct dc_state_update_flags *flags =3D args->update_flags; > + const struct pipe_ctx *source =3D NULL; > + const struct pipe_ctx *member; > + unsigned int i; > + > + if (args->dc->debug.disable_timing_sync) > + return NULL; > + for (i =3D 0; i < args->dc->res_pool->pipe_count; i++) { > + member =3D &args->new_state->res_ctx.pipe_ctx[i]; > + if (!member->stream || member->top_pipe || > + member->prev_odm_pipe || > + !resource_are_streams_timing_synchronizable( > + member->stream, pipe->stream)) > + continue; > + if (flags->cur_pipes[i].has_plane && > + flags->new_pipes[i].has_plane) { > + source =3D member; > + break; > + } > + if (!source) > + source =3D member; > + } > + if (!source || source->pipe_idx =3D=3D pipe->pipe_idx) > + return NULL; > + return source; > +} [Severity: Medium] Can dcn401_timing_sync_source() skip OTG timing synchronization when a kept stream had no plane in current_state? Because dcn401_timing_sync_source() only prioritizes an OTG master when both flags->cur_pipes[i].has_plane and flags->new_pipes[i].has_plane are set, it falls back to the lowest matching pipe_idx when a kept stream had no plane in current_state. If a newly enabled stream with the same timing is allocated on a lower pipe_idx (e.g. pipe 0) than the kept stream (e.g. pipe 1), dcn401_timing_sync_source() picks pipe 0 as source and returns NULL for pipe 0 because source->pipe_idx =3D=3D pipe->pipe_idx. Meanwhile, when bls_sync is expanded, dcn401_walks_stream() skips all kept streams (!dcn401_stream_kept()), so neither stream emits TG_ENABLE_RESET_TRIGGER and the two OTGs remain out of phase. In addition, if that kept stream gains a plane during the commit, dcn401_add_stream_update() enables its plane and unblanks its OPP before bls_postamble, yet the second bls_sync pass still checks flags->cur_pipes[i].has_plane && flags->new_pipes[i].has_plane and fails to select the newly unblanked kept stream as the timing sync source. > diff --git a/drivers/gpu/drm/amd/display/dc/workaround_manager/workaround= _manager.c b/drivers/gpu/drm/amd/display/dc/workaround_manager/workaround_m= anager.c > index 067a7069186bb..7e7e29d2530ad 100644 > --- a/drivers/gpu/drm/amd/display/dc/workaround_manager/workaround_manage= r.c > +++ b/drivers/gpu/drm/amd/display/dc/workaround_manager/workaround_manage= r.c > @@ -4,19 +4,129 @@ > */ > =20 > #include "dm_services.h" > +#include "core_types.h" > #include "workaround_manager/workaround_manager.h" > =20 > -static const struct workaround_manager dc2_wam_empty =3D { > - .registry =3D NULL, > - .count =3D 0, > -}; > - > /* BSS, not the stack: 64 block_sequence entries exceed the kernel frame= limit. */ > static struct block_sequence dc2_wam_saved_steps[DC2_BLS_MAX_STEPS]; > +static struct block_sequence dc2_wam_input_steps[DC2_BLS_MAX_STEPS]; [ ... ] > +static enum workaround_manager_result wa_dpg_height_apply( > + struct block_sequence_state *bls, > + const struct workaround_context *ctx) > +{ > + struct block_sequence *in =3D dc2_wam_input_steps; > + unsigned int num =3D *bls->num_steps; > + unsigned int n =3D 0; > + unsigned int i =3D 0; > + unsigned int j =3D 0; > + > + memmove(in, bls->steps, num * sizeof(in[0])); > + for (i =3D 0; i < num; i =3D j) { > + for (j =3D i + 1; j < num && in[j].func =3D=3D in[i].func; j++) > + ; > + if (in[i].func =3D=3D TG_ENABLE_RESET_TRIGGER && > + !wa_dpg_height_add(bls->steps, &n, ctx->target, > + &in[i], j - i, true)) > + return WAM_SIZE_EXCEEDED; > + if (n + j - i > DC2_BLS_MAX_STEPS) > + return WAM_SIZE_EXCEEDED; > + memmove(&bls->steps[n], &in[i], (j - i) * sizeof(in[0])); > + n +=3D j - i; > + if (in[i].func =3D=3D TG_DISABLE_RESET_TRIGGER && > + !wa_dpg_height_add(bls->steps, &n, ctx->target, > + &in[i], j - i, false)) > + return WAM_SIZE_EXCEEDED; > + } > + *bls->num_steps =3D n; > + return WAM_OK; > +} [Severity: Medium] Can concurrent calls to workaround_manager_apply() race on the static dc2_wam_input_steps and dc2_wam_saved_steps arrays? dc2_wam_input_steps and dc2_wam_saved_steps are file-scope static buffers shared across all struct dc instances without a lock. If two threads run core2_run_sequence() concurrently (for example, modesets on two AMD GPUs, each serialized only by its own per-device adev->dm.dc_lock), they will overwrite dc2_wam_input_steps and dc2_wam_saved_steps while rebuilding or restoring bls->steps, corrupting the block_sequence array passed to dc2_bls_execute(). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201202451.4637= 94-2-george.zhang@amd.com?part=3D27