All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Minseo Park" <hiyoukou@gmail.com>, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 2/4] drm/sti: gdp: set the pixel clock from .atomic_update()
Date: Thu, 26 Nov 2026 08:35:12 +0000	[thread overview]
Message-ID: <sashiko-outbox-235038@kernel.org> (raw)
In-Reply-To: <20261126024710.33401-3-hiyoukou@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] drm/sti: skipped GDP clock update on modeset in
  sti_gdp_atomic_update()
- [Medium] drm/sti: clock enabled before rate setup and leaked in
  sti_gdp_atomic_update()
--

commit d592a33824a375f249463d88ff389958a6b8400e
Author: Minseo Park <hiyoukou@gmail.com>

drm/sti: gdp: set the pixel clock from .atomic_update()

This commit moves the GDP pixel clock reparenting and rate configuration
from sti_gdp_atomic_check() to sti_gdp_atomic_update(), using
clk_round_rate() in sti_gdp_atomic_check() to validate the mode clock
when the parent clock does not change.

> diff --git a/drivers/gpu/drm/sti/sti_gdp.c b/drivers/gpu/drm/sti/sti_gdp.c
> index d0c886029c570..4a01bc64f4ab0 100644
> --- a/drivers/gpu/drm/sti/sti_gdp.c
> +++ b/drivers/gpu/drm/sti/sti_gdp.c
[ ... ]
> @@ -757,6 +760,32 @@ static void sti_gdp_atomic_update(struct drm_plane *drm_plane,
>  	}
>  
>  	mode = &crtc->mode;
> +
> +	/* Set gdp clock */
> +	if (mode->clock && gdp->clk_pix) {
> +		struct sti_mixer *mixer = to_sti_mixer(crtc);
> +		int rate = mode->clock * 1000;
> +		struct clk *clkp;
> +
> +		/*
> +		 * According to the mixer used, the gdp pixel clock
> +		 * should have a different parent clock.
> +		 */
> +		if (mixer->id == STI_MIXER_MAIN)
> +			clkp = gdp->clk_main_parent;
> +		else
> +			clkp = gdp->clk_aux_parent;
> +
> +		if (clkp)
> +			clk_set_parent(gdp->clk_pix, clkp);
> +
> +		if (clk_set_rate(gdp->clk_pix, rate) < 0) {
> +			drm_err_once(drm_plane->dev,
> +				     "Cannot set rate (%dHz) for gdp\n", rate);
> +			return;
> +		}
> +	}

[Severity: High]
Can sti_gdp_atomic_update() skip this clock update when a modeset changes
mode->clock or moves the plane to another CRTC without changing the plane's
framebuffer or coordinates?

Earlier in sti_gdp_atomic_update(), the function returns early if fb and
the crtc_* and src_* coordinates are unchanged:

drivers/gpu/drm/sti/sti_gdp.c:sti_gdp_atomic_update() {
    ...
	if ((oldstate->fb == newstate->fb) &&
	    (oldstate->crtc_x == newstate->crtc_x) &&
	    (oldstate->crtc_y == newstate->crtc_y) &&
	    (oldstate->crtc_w == newstate->crtc_w) &&
	    (oldstate->crtc_h == newstate->crtc_h) &&
	    (oldstate->src_x == newstate->src_x) &&
	    (oldstate->src_y == newstate->src_y) &&
	    (oldstate->src_w == newstate->src_w) &&
	    (oldstate->src_h == newstate->src_h)) {
		/* No change since last update, do not post cmd */
		DRM_DEBUG_DRIVER("No change, not posting cmd\n");
		plane->status = STI_PLANE_UPDATED;
		return;
	}
    ...
}

Previously, sti_gdp_atomic_check() always ran clk_set_parent() and
clk_set_rate() when the CRTC mode or CRTC assignment changed.  With the
clock setup placed after this early return, a refresh-rate change at the
same resolution or a switch between STI_MIXER_MAIN and STI_MIXER_AUX with
the same fb and coordinates returns before updating gdp->clk_pix, leaving
the plane scanning out with the old pixel clock rate or wrong parent clock.

[Severity: Medium]
When a disabled GDP plane is first enabled (!gdp->vtg), does returning on
clk_set_rate() failure leak the VTG client registration and gdp->clk_pix
enable count?

Just above the new clock block, sti_gdp_atomic_update() sets gdp->vtg,
registers gdp->vtg_field_nb, and calls clk_prepare_enable(gdp->clk_pix):

drivers/gpu/drm/sti/sti_gdp.c:sti_gdp_atomic_update() {
    ...
	if (!gdp->vtg) {
		struct sti_compositor *compo = dev_get_drvdata(gdp->dev);
		struct sti_mixer *mixer = to_sti_mixer(crtc);

		/* Register gdp callback */
		gdp->vtg = compo->vtg[mixer->id];
		sti_vtg_register_client(gdp->vtg, &gdp->vtg_field_nb, crtc);
		clk_prepare_enable(gdp->clk_pix);
	}
    ...
}

Besides enabling gdp->clk_pix before its parent and rate are configured,
sti_gdp_atomic_check() skips clk_round_rate() when the parent clock
changes, so clk_set_rate() can fail here.  Returning early leaves
gdp->clk_pix enabled and gdp->vtg_field_nb registered while plane->status
remains STI_PLANE_DISABLED, so disabling the CRTC will not call
sti_gdp_disable() to clean them up.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126024710.33401-1-hiyoukou@gmail.com?part=2

  reply	other threads:[~2026-11-26  8:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  2:47 [PATCH v2 0/4] drm/sti: move commit work out of .atomic_check() Minseo Park
2026-11-26  2:47 ` [PATCH v2 1/4] drm/sti: cursor: do not resize the pixmap from .atomic_check() Minseo Park
2026-11-26  8:32   ` sashiko-bot
2026-11-26  2:47 ` [PATCH v2 2/4] drm/sti: gdp: set the pixel clock from .atomic_update() Minseo Park
2026-11-26  8:35   ` sashiko-bot [this message]
2026-11-26  2:47 ` [PATCH v2 3/4] drm/sti: hqvdp: start the XP70 from device init Minseo Park
2026-11-26  8:34   ` sashiko-bot
2026-11-26  2:47 ` [PATCH v2 4/4] drm/sti: hqvdp: register the VTG client from .atomic_update() Minseo Park

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=sashiko-outbox-235038@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hiyoukou@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.