From: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
To: sashiko-reviews@lists.linux.dev
Cc: linux-clk@vger.kernel.org, imx@lists.linux.dev,
devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org,
robh@kernel.org, conor+dt@kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH v12 2/5] drm/imx: Add support for i.MX94 DCIF
Date: Fri, 20 Nov 2026 12:48:30 +0200 [thread overview]
Message-ID: <awAgaVs4LLwqVA57@vm> (raw)
In-Reply-To: <sashiko-outbox-221406@kernel.org>
On Wed, Nov 18, 2026 at 04:02:40PM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 3 potential
> issues to consider:
> - [Medium] drm/imx/dcif: unclocked MMIO access when runtime PM resume
> fails
> - [Medium] drm/imx: dcif: unbalanced clock disable if
> dcif_runtime_resume() fails
> - [Low] drm/imx/dcif: missing shadow load and trigger clear in
> dcif_crc_source_disable()
> --
>
> commit 373caa0eccbfd7fa4334093ea8869b540640e7ab
> Author: Sandor Yu <sandor.yu@nxp.com>
>
> drm/imx: Add support for i.MX94 DCIF
>
> This commit adds a DRM/KMS driver for the NXP i.MX94 Display Control
> Interface (DCIF), supporting primary and overlay planes, YCbCr-to-RGB CSC
> on layer 0, and frame/ROI CRC generation.
>
> > diff --git a/drivers/gpu/drm/imx/dcif/dcif-crc.c b/drivers/gpu/drm/imx/dcif/dcif-crc.c
> > new file mode 100644
> > index 0000000000000..ad94b458a6c59
> > --- /dev/null
> > +++ b/drivers/gpu/drm/imx/dcif/dcif-crc.c
> [ ... ]
> > +void dcif_crc_source_enable(struct dcif_dev *dcif, enum dcif_crc_source source,
> > + struct drm_rect *roi, int ncrc)
> > +{
> > + int ret;
> > +
> > + if (ncrc >= MAX_DCIF_CRC_NUM)
> > + return;
> > +
> > + if (source == DCIF_CRC_SRC_NONE)
> > + return;
> > +
> > + if (dcif->crc_is_enabled)
> > + return;
> > +
> > + ret = drm_crtc_vblank_get(&dcif->crtc);
> > + if (ret) {
> > + drm_err(&dcif->drm, "Could not get vblank reference: %d\n", ret);
> > + return;
> > + }
> > +
> > + dcif_crc_config(dcif, roi, ncrc);
> > +
> > + regmap_set_bits(dcif->regmap, DCIF_CRC_CTRL,
> > + DCIF_CRC_CTRL_CRC_MODE | DCIF_CRC_CTRL_CRC_SHADOW_LOAD_EN |
> > + DCIF_CRC_CTRL_CRC_TRIG);
> > +
> > + scoped_guard(spinlock_irqsave, &dcif->drm.event_lock)
> > + dcif->crc_is_enabled = true;
> > +}
> > +
> > +void dcif_crc_source_disable(struct dcif_dev *dcif, int ncrc)
> > +{
> > + if (!dcif->crc_is_enabled)
> > + return;
> > +
> > + if (ncrc >= MAX_DCIF_CRC_NUM)
> > + return;
> > +
> > + regmap_clear_bits(dcif->regmap, DCIF_CRC_CTRL, DCIF_CRC_CTRL_CRC_EN(ncrc));
>
> [Severity: Low]
> Should dcif_crc_source_disable() also clear DCIF_CRC_CTRL_CRC_TRIG and set
> DCIF_CRC_CTRL_CRC_SHADOW_LOAD_EN when disabling CRC on an active CRTC?
>
> Clearing only DCIF_CRC_CTRL_CRC_EN(ncrc) leaves the disabled state
> unlatched, and if DCIF_CRC_CTRL_CRC_MODE, DCIF_CRC_CTRL_CRC_SHADOW_LOAD_EN
> and DCIF_CRC_CTRL_CRC_TRIG stay set in DCIF_CRC_CTRL, a later
> dcif_crc_source_enable() call via regmap_set_bits() will see no bit changes
> and skip writing the register.
It appears this one is correct. The CRC_EN(n) is shadowed and CRC_TRIG
is not self-clearing in continuous mode. Will fix in v13.
>
> [ ... ]
>
> > diff --git a/drivers/gpu/drm/imx/dcif/dcif-crtc.c b/drivers/gpu/drm/imx/dcif/dcif-crtc.c
> > new file mode 100644
> > index 0000000000000..233e149929964
> > --- /dev/null
> > +++ b/drivers/gpu/drm/imx/dcif/dcif-crtc.c
> [ ... ]
> > +static void dcif_crtc_atomic_enable(struct drm_crtc *crtc,
> > + struct drm_atomic_commit *state)
> > +{
> > + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
> > + struct dcif_crtc_state *dcif_crtc_state = to_dcif_crtc_state(crtc_state);
> > + struct drm_display_mode *adj = &crtc_state->adjusted_mode;
> > + struct dcif_dev *dcif = crtc_to_dcif_dev(crtc);
> > + struct drm_device *drm = crtc->dev;
> > + int ret;
> > +
> > + dev_dbg(drm->dev, "mode " DRM_MODE_FMT "\n", DRM_MODE_ARG(adj));
> > +
> > + /* enable power when we start to set mode for CRTC */
> > + ret = pm_runtime_resume_and_get(drm->dev);
> > + if (ret < 0) {
> > + drm_err(drm, "failed to resume DCIF, ret = %d\n", ret);
> > + return;
> > + }
> > + dcif->crtc_pm_enabled = true;
> [ ... ]
> > +static void dcif_crtc_atomic_disable(struct drm_crtc *crtc,
> > + struct drm_atomic_commit *state)
> > +{
> > + struct dcif_dev *dcif = crtc_to_dcif_dev(crtc);
> > + struct drm_device *drm = crtc->dev;
> > +
> > + if (dcif->has_crc)
> > + dcif_crc_source_disable(dcif, 0);
> > +
> > + dcif_disable_controller(dcif);
> > + dcif_disable_plane_panic(dcif);
> > +
> > + drm_crtc_vblank_off(crtc);
> > +
> > + if (dcif->crtc_pm_enabled) {
> > + dcif->crtc_pm_enabled = false;
> > + pm_runtime_put_sync(drm->dev);
> > + }
>
> [Severity: Medium]
> Can a failure in pm_runtime_resume_and_get() lead to MMIO register accesses
> while the DCIF clocks are disabled?
>
> If pm_runtime_resume_and_get() fails in dcif_crtc_atomic_enable(),
> dcif->crtc_pm_enabled remains false, but crtc_state->active is still true.
> In the same commit tail, drm_atomic_helper_commit_planes() still calls
> dcif_plane_atomic_update() and dcif_crtc_atomic_flush(), and a later
> dcif_crtc_atomic_disable() calls dcif_crc_source_disable(),
> dcif_disable_controller(), and dcif_disable_plane_panic() before checking
> dcif->crtc_pm_enabled. Accessing DCIF registers while the block is
> unclocked can cause an external abort or bus hang on i.MX94.
This one is not worth fixing. First, the only thing that can fail in the
runtime resume is clk_bulk_prepare_enable(). If that fails, the platform
is already broken since the clocks are managed by the SCMI firmware. Second,
adding checks dor crtc_pm_enabled in every commit path (flush, plane
update, etc) would add a lot of unnecessary noise for something that
will probably never happen in practice.
>
> [ ... ]
>
> > diff --git a/drivers/gpu/drm/imx/dcif/dcif-drv.c b/drivers/gpu/drm/imx/dcif/dcif-drv.c
> > new file mode 100644
> > index 0000000000000..80b554f1b6843
> > --- /dev/null
> > +++ b/drivers/gpu/drm/imx/dcif/dcif-drv.c
> [ ... ]
> > +static int dcif_suspend(struct device *dev)
> > +{
> > + struct dcif_dev *dcif = dev_get_drvdata(dev);
> > + int ret;
> > +
> > + ret = drm_mode_config_helper_suspend(&dcif->drm);
> > + if (ret < 0)
> > + return ret;
> > +
> > + if (pm_runtime_suspended(dev))
> > + return 0;
> > +
> > + return dcif_runtime_suspend(dev);
> > +}
> > +
> > +static int dcif_resume(struct device *dev)
> > +{
> > + struct dcif_dev *dcif = dev_get_drvdata(dev);
> > + int ret;
> > +
> > + if (!pm_runtime_suspended(dev)) {
> > + ret = dcif_runtime_resume(dev);
> > + if (ret < 0)
> > + return ret;
> > + }
> > +
> > + return drm_mode_config_helper_resume(&dcif->drm);
> > +}
>
> [Severity: Medium]
> Can a failure in dcif_runtime_resume() during system resume cause an
> unbalanced clk_bulk_disable_unprepare()?
>
> When the CRTC is active entering system suspend, the PM core's
> device_prepare() holds a runtime PM reference, so the pm_runtime_put_sync()
> in dcif_crtc_atomic_disable() leaves the device's runtime PM status as
> RPM_ACTIVE. dcif_suspend() then calls dcif_runtime_suspend() directly,
> disabling clocks without updating runtime_status. If dcif_runtime_resume()
> fails in dcif_resume(), clocks remain disabled while runtime_status is
> still RPM_ACTIVE, and device_complete() -> pm_runtime_put() will invoke
> dcif_runtime_suspend() a second time. Using pm_runtime_force_suspend() and
> pm_runtime_force_resume() would keep runtime_status aligned with the clock
> state.
This is related to the previous issue and also not worth fixing since
the resume is unlikely to fail, as I explained above.
--
Thanks,
Laurentiu
next prev parent reply other threads:[~2026-11-20 10:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 15:21 [PATCH v12 0/5] Add support for i.MX94 DCIF Laurentiu Palcu
2026-11-18 15:21 ` [PATCH v12 1/5] dt-bindings: display: imx: Add " Laurentiu Palcu
2026-11-18 15:21 ` [PATCH v12 2/5] drm/imx: Add support for " Laurentiu Palcu
2026-11-18 16:02 ` sashiko-bot
2026-11-20 10:48 ` Laurentiu Palcu [this message]
2026-11-19 8:32 ` Luca Ceresoli
2026-11-18 15:21 ` [PATCH v12 3/5] dt-bindings: clock: nxp, imx95-blk-ctl: Add LDB bridge child node Laurentiu Palcu
2026-11-18 15:21 ` [PATCH v12 4/5] arm64: dts: imx94: Add display pipeline nodes Laurentiu Palcu
2026-11-18 15:21 ` [PATCH v12 5/5] arm64: dts: imx943-evk: Add display support using IT6263 Laurentiu Palcu
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=awAgaVs4LLwqVA57@vm \
--to=laurentiu.palcu@oss.nxp.com \
--cc=Frank.Li@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=imx@lists.linux.dev \
--cc=linux-clk@vger.kernel.org \
--cc=robh@kernel.org \
--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