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 E323B606A33E for ; Tue, 1 Dec 2026 09:54:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mGxAswca Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5424E10E434; Tue, 1 Dec 2026 09:54:39 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id D336E10E434 for ; Tue, 1 Dec 2026 09:54:32 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id E872661172; Tue, 1 Dec 2026 09:54:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A4521F000C1; Tue, 1 Dec 2026 09:54:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796118871; bh=9dSVH44V9CrqbKNA2Bn7G+mqdo5gbbnyg/blXOfCaxk=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=mGxAswcaDfwE3UfVx61ZmanBb+kdQCzC9/T63jShJqKTd7We+45NDUJg5ehqU984C jaCUouw2hM1ZDTwRnu2KMPl/TBTLAbgQOWs2FVmhvaIxHkqrI6X5Zn9KnH/LacIXCo ka9pnfuzpXTZB1Ab6V3GfY8okpGnl+alIqrFchHO6rnE4HkkXbtkilyfc8qM1MKUYV 0OeLBZzh4er4VMLYwG5r6PZfUjBcekBmzlrJzX1ACUJwU+Fxc0JR5ITy1VEswdVqTK 4lKUJ/lsvZekWPD7gPG7n5oDjJQF2rqtFqbk4FO20bKEaUfX9wRqvVVOx0wcrVQfqn tCcbthlYGL7gQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RFC PATCH v3 1/2] drm/tilcdc: Implement state readout support To: =?utf-8?b?TcOgeGltIFBlZHJhemEgUGFkaWxsYQ==?= Cc: dri-devel@lists.freedesktop.org In-Reply-To: <20261201092651.240295-2-maximpedraza@gmail.com> References: <20261201092651.240295-1-maximpedraza@gmail.com> <20261201092651.240295-2-maximpedraza@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 09:54:31 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "dri-devel" 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=unavailable 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 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=C3=A0xim Pedraza Padilla 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 w= hen the bootloader leaves the display controller running. > diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcd= c/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 =3D true; > + tilcdc_crtc->hvtotal_us =3D tilcdc_mode_hvtotal(&crtc->hwmode); > + tilcdc_crtc->lcd_fck_rate =3D clk_get_rate(priv->clk); > + tilcdc_crtc->last_vblank =3D ktime_get(); > + > + tilcdc_crtc_enable_irqs(dev); > + > + drm_calc_timestamping_constants(crtc, &crtc->hwmode); > + drm_crtc_vblank_on(crtc); > + > + tilcdc_crtc->enabled =3D 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 a= nd the hardware raster is already running, enabling LCDC interrupts before drm_calc_timestamping_constants(), drm_crtc_vblank_on(), and tilcdc_crtc->enabled =3D 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 interru= pt 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 @@ > =20 > #include > #include > +#include > +#include > #include > #include > #include > @@ -75,6 +77,13 @@ static const struct drm_mode_config_funcs mode_config_= funcs =3D { > .fb_create =3D drm_gem_fb_create, > .atomic_check =3D tilcdc_atomic_check, > .atomic_commit =3D drm_atomic_helper_commit, > + .atomic_sro_readout_state =3D drm_atomic_helper_sro_readout_state, > + .hw_reset =3D drm_mode_config_helper_hw_reset, > +}; > + > +static const struct drm_mode_config_helper_funcs mode_config_helper_func= s =3D { > + .atomic_sro_build_state =3D drm_atomic_helper_sro_build_state, > + .atomic_sro_install_state =3D drm_atomic_helper_sro_install_state, > }; [Severity: High] Are the prerequisite DRM atomic state readout patches missing from this tre= e? 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 field= s, struct drm_atomic_sro_state, and drm_atomic_helper_sro_*() helpers referenc= ed 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 inste= ad of performing state readout. [ ... ] > @@ -436,6 +446,8 @@ static int tilcdc_pdev_probe(struct platform_device *= pdev) > =20 > 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 uninstalli= ng 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 o= nly 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 fo= r a frame-done IRQ that was already uninstalled, call pm_runtime_put_sync() aft= er 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/ti= lcdc/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 =3D=3D 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 t= he 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 =3D=3D 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_mo= de if CRTC readout left the CRTC inactive. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201092651.2402= 95-1-maximpedraza@gmail.com?part=3D1