From: sashiko-bot@kernel.org
To: "Màxim Pedraza Padilla" <maximpedraza@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [RFC PATCH v3 1/2] drm/tilcdc: Implement state readout support
Date: Tue, 01 Dec 2026 09:54:31 +0000 [thread overview]
Message-ID: <sashiko-outbox-243005@kernel.org> (raw)
In-Reply-To: <20261201092651.240295-2-maximpedraza@gmail.com>
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] drm/tilcdc: build failure due to missing DRM atomic state
readout infrastructure
- [High] drm/tilcdc: missing tilcdc_crtc_shutdown() before teardown in
tilcdc_pdev_remove()
- [High] drm/tilcdc: tilcdc_encoder_get_current_crtc() returns CRTC when
raster is off
- [Medium] drm/tilcdc: unlocked last_vblank write and early IRQ enable
in install_state()
--
commit 6a2dac26c5f1471aa8cf7784667f51df160cd3ba
Author: Màxim Pedraza Padilla <maximpedraza@gmail.com>
drm/tilcdc: Implement state readout support
This commit adds atomic state readout callbacks to reconstruct the initial
CRTC, encoder, and primary plane KMS state from the LCDC raster registers when
the bootloader leaves the display controller running.
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> index f619b7a6e70d9..1647b8af7dbbb 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
[ ... ]
> +static void tilcdc_crtc_install_state(struct drm_crtc *crtc,
> + struct drm_crtc_state *crtc_state)
> +{
[ ... ]
> + drm_mode_copy(&crtc->mode, &crtc_state->mode);
> + drm_mode_copy(&crtc->hwmode, &crtc_state->adjusted_mode);
> + crtc->enabled = true;
> + tilcdc_crtc->hvtotal_us = tilcdc_mode_hvtotal(&crtc->hwmode);
> + tilcdc_crtc->lcd_fck_rate = clk_get_rate(priv->clk);
> + tilcdc_crtc->last_vblank = ktime_get();
> +
> + tilcdc_crtc_enable_irqs(dev);
> +
> + drm_calc_timestamping_constants(crtc, &crtc->hwmode);
> + drm_crtc_vblank_on(crtc);
> +
> + tilcdc_crtc->enabled = true;
> + mutex_unlock(&tilcdc_crtc->enable_lock);
> +}
[Severity: Medium]
Can tilcdc_crtc_irq() race with tilcdc_crtc_install_state() here?
Because tilcdc_irq_install() has already registered the interrupt handler and
the hardware raster is already running, enabling LCDC interrupts before
drm_calc_timestamping_constants(), drm_crtc_vblank_on(), and
tilcdc_crtc->enabled = true allows an immediate interrupt to run against
partially initialized vblank state. Also, unlike tilcdc_crtc_enable(),
tilcdc_crtc->last_vblank is written without holding tilcdc_crtc->irq_lock
(which can tear the 64-bit ktime_t on 32-bit ARM if an end-of-frame interrupt
was left enabled by the bootloader).
[ ... ]
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> index 1d6c9a423a410..3d8e12878f94d 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> @@ -12,6 +12,8 @@
>
> #include <drm/clients/drm_client_setup.h>
> #include <drm/drm_atomic_helper.h>
> +#include <drm/drm_atomic_state_readout.h>
> +#include <drm/drm_atomic_state_readout_helper.h>
> #include <drm/drm_debugfs.h>
> #include <drm/drm_drv.h>
> #include <drm/drm_fbdev_dma.h>
> @@ -75,6 +77,13 @@ static const struct drm_mode_config_funcs mode_config_funcs = {
> .fb_create = drm_gem_fb_create,
> .atomic_check = tilcdc_atomic_check,
> .atomic_commit = drm_atomic_helper_commit,
> + .atomic_sro_readout_state = drm_atomic_helper_sro_readout_state,
> + .hw_reset = drm_mode_config_helper_hw_reset,
> +};
> +
> +static const struct drm_mode_config_helper_funcs mode_config_helper_funcs = {
> + .atomic_sro_build_state = drm_atomic_helper_sro_build_state,
> + .atomic_sro_install_state = drm_atomic_helper_sro_install_state,
> };
[Severity: High]
Are the prerequisite DRM atomic state readout patches missing from this tree?
drm/drm_atomic_state_readout.h and drm/drm_atomic_state_readout_helper.h do
not exist in include/drm/, and the .atomic_sro_* and .hw_reset vtable fields,
struct drm_atomic_sro_state, and drm_atomic_helper_sro_*() helpers referenced
across tilcdc_drv.c, tilcdc_crtc.c, tilcdc_encoder.c, and tilcdc_plane.c are
undeclared, breaking the build when CONFIG_DRM_TILCDC is enabled. In
addition, tilcdc_pdev_probe() still calls drm_mode_config_reset(ddev), which
unconditionally calls tilcdc_crtc_hw_reset() and turns the raster off instead
of performing state readout.
[ ... ]
> @@ -436,6 +446,8 @@ static int tilcdc_pdev_probe(struct platform_device *pdev)
>
> stop_poll:
> drm_kms_helper_poll_fini(ddev);
> + /* A CRTC adopted from the bootloader holds a runtime PM reference */
> + tilcdc_crtc_shutdown(priv->crtc);
> tilcdc_irq_uninstall(ddev);
> unregister_cpufreq_notif:
> #ifdef CONFIG_CPU_FREQ
[Severity: High]
Does tilcdc_pdev_remove() also need to shut down the CRTC before uninstalling
the IRQ and disabling runtime PM?
drivers/gpu/drm/tilcdc/tilcdc_drv.c:tilcdc_pdev_remove() {
drm_dev_unregister(ddev);
drm_kms_helper_poll_fini(ddev);
tilcdc_irq_uninstall(ddev);
...
pm_runtime_disable(&pdev->dev);
clk_put(priv->clk);
destroy_workqueue(priv->wq);
}
tilcdc_crtc_destroy() is registered via drmm_add_action_or_reset(), so it only
runs when devres releases devm_drm_dev_alloc() after tilcdc_pdev_remove()
returns. When the driver is unbound while an adopted (or active) CRTC is
enabled, tilcdc_crtc_destroy() -> tilcdc_crtc_shutdown() will access LCDC
registers after runtime PM is disabled and priv->clk is put, wait 500 ms for a
frame-done IRQ that was already uninstalled, call pm_runtime_put_sync() after
pm_runtime_disable(), and call flush_workqueue(priv->wq) after
destroy_workqueue(priv->wq).
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_encoder.c b/drivers/gpu/drm/tilcdc/tilcdc_encoder.c
> index ac4b5beb2dd58..b3fe18f69f174 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_encoder.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_encoder.c
[ ... ]
> +static struct drm_crtc *
> +tilcdc_encoder_get_current_crtc(struct drm_encoder *encoder)
> +{
> + struct drm_crtc *crtc;
> +
> + drm_for_each_crtc(crtc, encoder->dev)
> + if (encoder->possible_crtcs == drm_crtc_mask(crtc))
> + return crtc;
> +
> + return NULL;
> +}
[Severity: High]
Does tilcdc_encoder_get_current_crtc() return the CRTC even when the LCDC
raster is disabled?
When LCDC_RASTER_ENABLE is not set in LCDC_RASTER_CTRL_REG,
tilcdc_crtc_readout_state() and tilcdc_plane_atomic_readout_state() leave the
CRTC and primary plane disabled, but tilcdc_encoder_get_current_crtc() still
returns the CRTC, linking the encoder and connector to a disabled CRTC
(crtc_state->enable == false with a non-zero connector_mask). Also, in
tilcdc_plane_atomic_readout_state(), checking !crtc_state->active instead of
re-reading LCDC_RASTER_CTRL_REG would avoid reading crtc_state->adjusted_mode
if CRTC readout left the CRTC inactive.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201092651.240295-1-maximpedraza@gmail.com?part=1
next prev parent reply other threads:[~2026-12-01 9:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 9:26 [RFC PATCH v3 0/2] drm/tilcdc: Implement state readout Màxim Pedraza Padilla
2026-12-01 9:26 ` [RFC PATCH v3 1/2] drm/tilcdc: Implement state readout support Màxim Pedraza Padilla
2026-12-01 9:54 ` sashiko-bot [this message]
2026-12-01 9:26 ` [RFC PATCH v3 2/2] drm/panel: simple: Keep the enable GPIO as left by the bootloader Màxim Pedraza Padilla
2026-12-01 9:40 ` sashiko-bot
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-243005@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=maximpedraza@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox