All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Laurentiu Palcu" <laurentiu.palcu@oss.nxp.com>
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 v13 2/5] drm/imx: Add support for i.MX94 DCIF
Date: Fri, 20 Nov 2026 13:16:15 +0000	[thread overview]
Message-ID: <sashiko-outbox-225210@kernel.org> (raw)
In-Reply-To: <20261120-dcif-upstreaming-v13-2-966ac248773f@oss.nxp.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/imx/dcif: unclocked MMIO access after
  pm_runtime_resume_and_get() fails
- [Medium] drm/imx: dcif: unbalanced clock disable if
  dcif_runtime_resume() fails
--

commit aec0e23d14596f3fd993df3e2ad261bfab2bf2dd
Author: Sandor Yu <sandor.yu@nxp.com>

drm/imx: Add support for i.MX94 DCIF

This commit adds a DRM driver for the Display Control Interface (DCIF) on
NXP i.MX94 SoCs, supporting primary and overlay planes, alpha blending,
and display output CRC generation.

> 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
> @@ -0,0 +1,710 @@

[ ... ]

> +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 unclocked MMIO
accesses and a synchronous external abort?

When pm_runtime_resume_and_get() fails in dcif_crtc_atomic_enable(),
dcif->crtc_pm_enabled stays false and the DCIF clocks remain disabled,
while crtc_state->active is still true.  In the same commit tail,
drm_atomic_helper_commit_planes() then runs dcif_plane_atomic_update() and
dcif_crtc_atomic_flush(), writing to plane and shadow-load registers
without checking dcif->crtc_pm_enabled.  Later, dcif_crtc_atomic_disable()
also accesses and polls DCIF registers in dcif_crc_source_disable(),
dcif_disable_controller(), and dcif_disable_plane_panic() before checking
dcif->crtc_pm_enabled.

> 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
> @@ -0,0 +1,250 @@

[ ... ]

> +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 holds an
extra runtime PM reference from device_prepare(), so the
pm_runtime_put_sync() in dcif_crtc_atomic_disable() leaves the device
runtime-active.  dcif_suspend() then calls dcif_runtime_suspend() directly,
disabling dcif->clks while runtime_status remains RPM_ACTIVE.

If dcif_runtime_resume() fails in dcif_resume(), the device stays
RPM_ACTIVE with its clocks already disabled, 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 the
runtime PM state in sync with the clocks.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120-dcif-upstreaming-v13-0-966ac248773f@oss.nxp.com?part=2

  reply	other threads:[~2026-11-20 13:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 12:50 [PATCH v13 0/5] Add support for i.MX94 DCIF Laurentiu Palcu
2026-11-20 12:50 ` [PATCH v13 1/5] dt-bindings: display: imx: Add " Laurentiu Palcu
2026-11-20 12:50 ` [PATCH v13 2/5] drm/imx: Add support for " Laurentiu Palcu
2026-11-20 13:16   ` sashiko-bot [this message]
2026-11-20 13:21     ` Laurentiu Palcu
2026-11-20 12:50 ` [PATCH v13 3/5] dt-bindings: clock: nxp,imx95-blk-ctl: Add LDB bridge child node Laurentiu Palcu
2026-11-20 12:50   ` [PATCH v13 3/5] dt-bindings: clock: nxp, imx95-blk-ctl: " Laurentiu Palcu
2026-11-20 12:50 ` [PATCH v13 4/5] arm64: dts: imx94: Add display pipeline nodes Laurentiu Palcu
2026-11-20 12:50 ` [PATCH v13 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=sashiko-outbox-225210@kernel.org \
    --to=sashiko-bot@kernel.org \
    --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=laurentiu.palcu@oss.nxp.com \
    --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 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.