From: sashiko-bot@kernel.org
To: "Cody Kang" <codykang.hk@gmail.com>
Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
linux-phy@lists.infradead.org, linux-clk@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org, vkoul@kernel.org,
neil.armstrong@linaro.org, olteanv@gmail.com
Subject: Re: [PATCH v3 10/17] drm/spacemit: add Saturn DPU KMS pipeline
Date: Sat, 21 Nov 2026 08:06:33 +0000 [thread overview]
Message-ID: <sashiko-outbox-226819@kernel.org> (raw)
In-Reply-To: <20261121-k3-display-v3-10-ec419e8e96b8@gmail.com>
Thank you for your contribution! Sashiko AI review found 6 potential
issues to consider:
- [High] drm/spacemit: premature event send in
spacemit_crtc_atomic_disable()
- [High] drm/spacemit: premature event arming in
spacemit_crtc_atomic_flush() and ISR
- [High] drm/spacemit: stale INT_VSYNC not cleared in
spacemit_crtc_enable_vblank()
- [Medium] drm/spacemit: unbind before poll_fini in
spacemit_drm_master_bind()
- [Medium] drm/spacemit: composer dst_w and dst_h left at 0 when no
plane is visible
- [Medium] drm/spacemit: vblank not reset due to drm_vblank_init()
ordering
--
commit c4c8906d170c5bfb4e5c852ca468ddf4805b4d47
Author: Cody Kang <codykang@vsit.ai>
drm/spacemit: add Saturn DPU KMS pipeline
This commit adds the atomic KMS CRTC and primary plane implementation,
runtime PM hooks, and component master bind/unbind logic for the Saturn
DPU.
> diff --git a/drivers/gpu/drm/spacemit/spacemit_crtc.c b/drivers/gpu/drm/spacemit/spacemit_crtc.c
> new file mode 100644
> index 0000000000000..c1257444dd150
> --- /dev/null
> +++ b/drivers/gpu/drm/spacemit/spacemit_crtc.c
> @@ -0,0 +1,589 @@
[ ... ]
> +static void spacemit_crtc_atomic_disable(struct drm_crtc *crtc,
> + struct drm_atomic_commit *state)
> +{
> + struct drm_crtc_state *crtc_state =
> + drm_atomic_get_new_crtc_state(state, crtc);
> + struct spacemit_crtc *a_crtc = to_spacemit_crtc(crtc);
> + struct drm_device *drm = a_crtc->crtc.dev;
> + struct spacemit_drm_private *priv = drm->dev_private;
> + int idx;
> +
> + if (drm_dev_enter(drm, &idx)) {
> + spacemit_dpu_uninit(a_crtc);
> + drm_dev_exit(idx);
> + }
> +
> + drm_crtc_vblank_off(&a_crtc->crtc);
> +
> + /* A commit may still be waiting for CFG_RDY: stop its watchdog. */
> + timer_delete_sync(&a_crtc->cfg_rdy_timer);
> +
> + pm_runtime_put_sync(priv->dev);
> +
> + /* No further vblank will come; complete the disable event here. */
> + spacemit_dpu_complete_event(a_crtc);
> + spin_lock_irq(&drm->event_lock);
> + if (crtc_state->event) {
> + drm_crtc_send_vblank_event(crtc, crtc_state->event);
> + crtc_state->event = NULL;
> + }
> + spin_unlock_irq(&drm->event_lock);
> +}
[Severity: High]
Does sending crtc_state->event without checking !crtc_state->active
complete the vblank event prematurely during an active-to-active modeset?
When changing modes on an active CRTC, drm_atomic_helper_commit_modeset_disables()
calls spacemit_crtc_atomic_disable() before spacemit_crtc_atomic_enable()
and spacemit_crtc_atomic_flush() run. Consuming crtc_state->event here
delivers the event and signals commit->flip_done before the new mode is
programmed, allowing a subsequent non-blocking commit to overwrite the
2-slot command-list ring before the engine takes the modeset lists.
[ ... ]
> +static void spacemit_crtc_atomic_flush(struct drm_crtc *crtc,
> + struct drm_atomic_commit *state)
> +{
> + struct drm_crtc_state *crtc_state =
> + drm_atomic_get_new_crtc_state(state, crtc);
> + struct spacemit_crtc *a_crtc = to_spacemit_crtc(crtc);
> + struct spacemit_drm_private *priv = crtc->dev->dev_private;
> + int idx;
> +
> + /*
> + * The event releases the next commit, which rewrites the other
> + * command list and points the engine at it. Hold the event until
> + * CFG_RDY says the engine has taken this commit's lists; the
> + * interrupt then arms it for the following vblank.
> + */
> + spin_lock_irq(&crtc->dev->event_lock);
> + if (crtc_state->event) {
> + if (drm_crtc_vblank_get(crtc) == 0)
> + a_crtc->event = crtc_state->event;
> + else
> + drm_crtc_send_vblank_event(crtc, crtc_state->event);
> + crtc_state->event = NULL;
> + }
> + spin_unlock_irq(&crtc->dev->event_lock);
> +
> + /* clocks_on is false here only after a failed power-up. */
> + if (priv->clocks_on && drm_dev_enter(crtc->dev, &idx)) {
> + spacemit_dpu_run(crtc, state);
> + drm_dev_exit(idx);
> + } else {
> + spacemit_dpu_complete_event(a_crtc);
> + }
> +}
[Severity: High]
Can a_crtc->event be armed and delivered before the hardware takes the new
command lists?
spacemit_crtc_atomic_flush()
spin_lock_irq(&crtc->dev->event_lock)
drm_crtc_vblank_get(crtc)
a_crtc->event = crtc_state->event
spin_unlock_irq(&crtc->dev->event_lock)
<hardirq>
spacemit_dpu_online_isr()
if (irq_raw & INT_CFG_RDY)
drm_crtc_arm_vblank_event(..., a_crtc->event) <-- armed early
if (irq_raw & INT_VSYNC)
drm_crtc_handle_vblank(...) <-- sent early
spacemit_dpu_run()
saturn_hee_conf_dpuctrl()
saturn_hee_clr_int_sts(..., INT_CFG_RDY)
saturn_hee_cfg_ready()
spacemit_dpu_online_isr() inspects the unmasked DPU_ONLINE_IRQ_STS
register. If an enabled interrupt (such as INT_VSYNC) fires after
event_lock is dropped and before spacemit_dpu_run() clears a leftover
INT_CFG_RDY status bit and raises both_cfg_rdy, the ISR sees INT_CFG_RDY
and arms a_crtc->event before the CRTC command list is even submitted.
In addition, because spacemit_dpu_online_isr() handles INT_CFG_RDY before
INT_VSYNC and there is no get_vblank_counter hook, when both bits are set
in irq_raw, drm_crtc_arm_vblank_event() arms the event for vblank->count + 1
and the immediately following drm_crtc_handle_vblank() increments
vblank->count and delivers it in the same interrupt instead of at the next
vblank, releasing flip_done while the command list is still in use.
> +
> +static int spacemit_crtc_enable_vblank(struct drm_crtc *crtc)
> +{
> + saturn_hee_enable_irq(to_spacemit_crtc(crtc), INT_VSYNC, true);
> +
> + return 0;
> +}
[Severity: High]
Does unmasking INT_VSYNC without clearing DPU_ONLINE_IRQ_STS first fire a
spurious mid-frame vblank interrupt?
As noted in saturn_hee_irq_enable(), DPU_ONLINE_IRQ_STS latches status
bits while masked and fires as soon as the mask opens, but
saturn_hee_irq_enable() only clears INT_UNDERRUN | INT_CFG_RDY:
drivers/gpu/drm/spacemit/dpu/dpu_saturn_hee.c:saturn_hee_irq_enable() {
mask = saturn_hee_get_irq_bit(INT_UNDERRUN) |
saturn_hee_get_irq_bit(INT_CFG_RDY);
if (enable) {
...
regmap_write(priv->hwdev->regmap,
DPU_INT_BASE_ADDR + DPU_ONLINE_IRQ_STS, mask);
}
}
Whenever vblank has been disabled while the CRTC is running, the next
frame latches INT_VSYNC in DPU_ONLINE_IRQ_STS. Re-enabling vblank then
immediately raises an interrupt mid-frame, incrementing the software
vblank counter with a mid-frame timestamp or completing an event armed by
INT_CFG_RDY in the same ISR call before the actual vblank.
[ ... ]
> + drm_mode_config_reset(drm);
> +
> + ret = drm_vblank_init(drm, drm->mode_config.num_crtc);
> + if (ret) {
> + dev_err_probe(dev, ret, "failed to initialize vblank\n");
> + goto err_unbind_all;
> + }
> +
> + drmm_kms_helper_poll_init(drm);
> + drm_helper_hpd_irq_event(drm);
> +
> + enable_irq(priv->irq_online);
> +
> + ret = drm_dev_register(drm, 0);
> + if (ret < 0)
> + goto err_disable_irq;
> + drm_client_setup(drm, NULL);
> +
> + return 0;
> +
> +err_disable_irq:
> + disable_irq(priv->irq_online);
> +
> +err_unbind_all:
> + component_unbind_all(dev, drm);
> +err_dc:
> + /*
> + * .shutdown tests priv->ddev; never leave it on a half-initialised
> + * device.
> + */
> + priv->ddev = NULL;
> + priv->a_crtc = NULL;
> + drm_dev_put(drm);
> + return ret;
> +}
[Severity: Medium]
Does calling drm_mode_config_reset() before drm_vblank_init() leave
vblank->inmodeset unset while the CRTC is initially disabled?
drm_mode_config_crtc_create_state() only calls drm_crtc_vblank_reset()
when drm_dev_has_vblank() is true, which requires dev->num_crtcs to have
been set by drm_vblank_init(). With the current order, drm_vblank_get()
on the disabled CRTC succeeds instead of returning -EINVAL and enables
vblank while the DPU is powered off. Calling drm_vblank_init() before
drm_mode_config_reset() avoids this.
[Severity: Medium]
If drm_dev_register() fails, does err_disable_irq unbind the components
while output polling is still active?
drmm_kms_helper_poll_init() and drm_helper_hpd_irq_event() start output
polling before drm_dev_register(), but the error path runs
component_unbind_all() before drm_dev_put() invokes the drmm poll release
action, unlike spacemit_drm_master_unbind() which calls
drm_kms_helper_poll_fini() before component_unbind_all().
[ ... ]
> diff --git a/drivers/gpu/drm/spacemit/spacemit_planes.c b/drivers/gpu/drm/spacemit/spacemit_planes.c
> new file mode 100644
> index 0000000000000..c49a2e1572771
> --- /dev/null
> +++ b/drivers/gpu/drm/spacemit/spacemit_planes.c
> @@ -0,0 +1,332 @@
[ ... ]
> +static void spacemit_plane_atomic_update(struct drm_plane *plane,
> + struct drm_atomic_commit *state)
> +{
> + struct drm_plane_state *new_state =
> + drm_atomic_get_new_plane_state(state, plane);
> + struct drm_crtc_state *crtc_state =
> + drm_atomic_get_new_crtc_state(state, new_state->crtc);
> + struct spacemit_drm_private *priv = plane->dev->dev_private;
> + int idx;
> +
> + if (priv->clocks_on && drm_dev_enter(plane->dev, &idx)) {
> + /* A plane moved off the screen has no rectangle to program. */
> + if (new_state->visible)
> + spacemit_plane_program(plane, new_state,
> + &crtc_state->adjusted_mode);
> + else
> + spacemit_plane_off(plane, new_state->crtc);
> + drm_dev_exit(idx);
> + }
> +}
[Severity: Medium]
When a CRTC is enabled with no visible plane (disabled or clipped
off-screen), do the composer output dimensions CMPS_X_REG dst_w and dst_h
remain at 0?
saturn_init_regs() enables CMPS_X_REG (module_enable = 1) and
saturn_hee_conf_dpuctrl() sets POSTPIPE_REG m_inwidth and m_inheight to
mode->hdisplay and mode->vdisplay, but CMPS_X_REG dst_w and dst_h are only
written in saturn_hee_plane_update_hw_channel():
drivers/gpu/drm/spacemit/dpu/dpu_saturn_hee.c:saturn_hee_plane_update_hw_channel() {
...
base = CMP1_BASE_ADDR;
dpu_write(hwdev, CMPS_X_REG, base, dst_w, mode->hdisplay, cl_cmp);
dpu_write(hwdev, CMPS_X_REG, base, dst_h, mode->vdisplay, cl_cmp);
...
}
Skipping spacemit_plane_program() when new_state->visible is false leaves
the composer configured for a 0x0 output feeding a full-mode postpipe and
timing generator, causing a pipeline dimension mismatch and display
underrun.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261121-k3-display-v3-0-ec419e8e96b8@gmail.com?part=10
next prev parent reply other threads:[~2026-11-21 8:06 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-21 7:40 [PATCH v3 00/17] drm/spacemit: add SpacemiT K3 display support Cody Kang via B4 Relay
2026-11-21 7:40 ` [PATCH v3 01/17] dt-bindings: display: spacemit: add K3 Saturn DPU controller Cody Kang via B4 Relay
2026-11-21 7:44 ` sashiko-bot
2026-11-21 7:40 ` [PATCH v3 02/17] dt-bindings: phy: add SpacemiT K3 Innosilicon DP PHY Cody Kang via B4 Relay
2026-11-21 7:40 ` [PATCH v3 03/17] dt-bindings: display: spacemit: add K3 Innosilicon DP/eDP controller Cody Kang via B4 Relay
2026-11-21 7:45 ` sashiko-bot
2026-11-21 7:40 ` [PATCH v3 04/17] dt-bindings: soc: spacemit: allow eDP/DP PHY PLL pixel clocks on K3 APMU Cody Kang via B4 Relay
2026-11-21 7:40 ` [PATCH v3 05/17] phy: spacemit: add Innosilicon DP TX PHY driver Cody Kang via B4 Relay
2026-11-21 7:40 ` [PATCH v3 06/17] clk: spacemit: k3: parent eDP/DP pixel clock to the PHY PLL Cody Kang via B4 Relay
2026-11-21 7:40 ` [PATCH v3 07/17] drm/spacemit: add Saturn DPU register model Cody Kang via B4 Relay
2026-11-21 7:40 ` [PATCH v3 08/17] drm/spacemit: add Saturn DPU core types, cmdlist and display MMU Cody Kang via B4 Relay
2026-11-21 7:40 ` [PATCH v3 09/17] drm/spacemit: add Saturn DPU hardware backend Cody Kang via B4 Relay
2026-11-21 8:01 ` sashiko-bot
2026-11-21 7:40 ` [PATCH v3 10/17] drm/spacemit: add Saturn DPU KMS pipeline Cody Kang via B4 Relay
2026-11-21 8:06 ` sashiko-bot [this message]
2026-11-21 7:40 ` [PATCH v3 11/17] drm/spacemit: add Saturn DPU DRM device driver Cody Kang via B4 Relay
2026-11-21 7:40 ` [PATCH v3 12/17] drm/spacemit: add Innosilicon DP/eDP controller bridge driver Cody Kang via B4 Relay
2026-11-21 8:08 ` sashiko-bot
2026-11-21 7:40 ` [PATCH v3 13/17] MAINTAINERS: add SpacemiT K3 display driver entry Cody Kang via B4 Relay
2026-11-21 7:40 ` [PATCH v3 14/17] riscv: dts: spacemit: k3: add display nodes Cody Kang via B4 Relay
2026-11-21 7:40 ` [PATCH v3 15/17] riscv: dts: spacemit: k3-pico-itx: enable the DisplayPort output Cody Kang via B4 Relay
2026-11-21 7:40 ` [PATCH v3 16/17] riscv: dts: spacemit: k3-com260-ifx: " Cody Kang via B4 Relay
2026-11-21 7:40 ` [PATCH v3 17/17] riscv: defconfig: spacemit: k3: enable display driver Cody Kang via B4 Relay
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-226819@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=codykang.hk@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=neil.armstrong@linaro.org \
--cc=olteanv@gmail.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vkoul@kernel.org \
/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