mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alex Hung <alex.hung@amd.com>
To: Yibiao Li <biaobiao2233@gmail.com>,
	amd-gfx@lists.freedesktop.org,
	Harry Wentland <harry.wentland@amd.com>,
	Leo Li <sunpeng.li@amd.com>
Cc: "Rodrigo Siqueira" <siqueira@igalia.com>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"Christian König" <christian.koenig@amd.com>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	"kernel test robot" <lkp@intel.com>
Subject: Re: [PATCH] drm/amd/display: Use separate iterator for preferred mode lookup
Date: Fri, 16 Oct 2026 09:50:44 -0600	[thread overview]
Message-ID: <f4dcee55-8cc6-4287-a25a-1ace385f092b@amd.com> (raw)
In-Reply-To: <CAG1agfwtnjmb8RVLmZvY9W-zrR1onhK6urJA3Lqai82tAXn2Cg@mail.gmail.com>

Reviewed-by: Alex Hung <alex.hung@amd.com>

On 10/7/26 23:17, Yibiao Li wrote:
> [Some people who received this message don't often get email from biaobiao2233@gmail.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> 
> From: Yibiao Li <biaobiao2233@gmail.com>
> 
> create_stream_for_sink() uses preferred_mode both as the list iterator
> and as the selected mode. This triggers a false positive from
> scripts/coccinelle/iterators/use_after_iter.cocci: native_mode_found
> already ensures that an exhausted iterator is replaced before use.
> 
> Use a separate iterator and assign preferred_mode only when a preferred
> entry is found. This keeps the selected mode separate from the iterator
> state and makes native_mode_found unnecessary. Preserve the fallback to
> the first entry, or NULL when the list is empty.
> 
> No functional change intended.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Link: https://lore.kernel.org/oe-kbuild-all/202609190901.yKTzhsGz-lkp@intel.com/
> Assisted-by: LLM coccinelle
> Signed-off-by: Yibiao Li <biaobiao2233@gmail.com>
> ---
>   .../drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c    | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
> index d386bb1475..ceea8fe481 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
> @@ -1453,12 +1453,12 @@ create_stream_for_sink(struct drm_connector *connector,
>          struct drm_device *dev = connector->dev;
>          struct amdgpu_dm_connector *aconnector = NULL;
>          struct drm_display_mode *preferred_mode = NULL;
> +       struct drm_display_mode *connector_mode;
>          const struct drm_connector_state *con_state = &dm_state->base;
>          struct dc_stream_state *stream = NULL;
>          struct drm_display_mode mode;
>          struct drm_display_mode saved_mode;
>          struct drm_display_mode *freesync_mode = NULL;
> -       bool native_mode_found = false;
>          bool recalculate_timing = false;
>          bool scale = dm_state->scaling != RMX_OFF;
>          int mode_refresh;
> @@ -1509,14 +1509,14 @@ create_stream_for_sink(struct drm_connector *connector,
>          stream->timing.flags.LTE_340MCSC_SCRAMBLE =
>                  connector->display_info.hdmi.scdc.scrambling.low_rates;
> 
> -       list_for_each_entry(preferred_mode, &connector->modes, head) {
> +       list_for_each_entry(connector_mode, &connector->modes, head) {
>                  /* Search for preferred mode */
> -               if (preferred_mode->type & DRM_MODE_TYPE_PREFERRED) {
> -                       native_mode_found = true;
> +               if (connector_mode->type & DRM_MODE_TYPE_PREFERRED) {
> +                       preferred_mode = connector_mode;
>                          break;
>                  }
>          }
> -       if (!native_mode_found)
> +       if (!preferred_mode)
>                  preferred_mode = list_first_entry_or_null(
>                                  &connector->modes,
>                                  struct drm_display_mode,
> --
> 2.43.0


  reply	other threads:[~2026-10-16 15:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-08  5:17 Yibiao Li
2026-10-16 15:50 ` Alex Hung [this message]
2026-10-16 17:37   ` Yibiao Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f4dcee55-8cc6-4287-a25a-1ace385f092b@amd.com \
    --to=alex.hung@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=biaobiao2233@gmail.com \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=harry.wentland@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=siqueira@igalia.com \
    --cc=sunpeng.li@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®