From: sashiko-bot@kernel.org
To: "Svyatoslav Ryhel" <clamor95@gmail.com>
Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v7 12/12] drm/tegra: Add support for 8-bit CPU interface
Date: Mon, 16 Nov 2026 15:49:59 +0000 [thread overview]
Message-ID: <sashiko-outbox-217315@kernel.org> (raw)
In-Reply-To: <20261116151017.274764-13-clamor95@gmail.com>
Thank you for your contribution! Sashiko AI review found 8 potential
issues to consider:
- [High] drm/tegra: broken disable sequence and active state in
tegra_dbi_atomic_disable()
- [High] drm/tegra: premature bridge add and NULL next_bridge in
tegra_dbi_attach()
- [Medium] drm/tegra: duplicate next_bridge enable call in
tegra_dbi_atomic_enable()
- [Medium] drm/tegra: dangling priv->next_bridge pointer in
tegra_dbi_host_detach()
- [Medium] drm/tegra: device_node refcount leak on dbi_np in
tegra_dc_dbi_probe()
- [Medium] drm/tegra: unbalanced of_node_put() on remote panel node in
tegra_dc_dbi_probe()
- [Medium] drm/tegra: dbi: missing idle wait after stopping DC in
tegra_dbi_atomic_enable()
- [Medium] drm/tegra: unconditional PIN_LDC muxing in
tegra_dbi_atomic_enable()
--
commit c9bf1d91683f8b29d2b2a60164a0b606d5716c0d
Author: Svyatoslav Ryhel <clamor95@gmail.com>
drm/tegra: Add support for 8-bit CPU interface
This commit adds a MIPI DBI host and DRM bridge driver for the 8-bit CPU
display controller interface on Tegra20 and Tegra30 SoCs, and hooks its probe
into tegra_dc_probe().
> diff --git a/drivers/gpu/drm/tegra/dbi.c b/drivers/gpu/drm/tegra/dbi.c
> new file mode 100644
> index 0000000000000..290e4c51dd3a7
> --- /dev/null
> +++ b/drivers/gpu/drm/tegra/dbi.c
[ ... ]
> +static void tegra_dbi_host_detach(struct mipi_dbi_host *host, struct mipi_dbi_device *dbidev)
> +{
> + struct tegra_dbi_priv *priv = dbi_host_to_tegra_dbi(host);
> +
> + drm_bridge_put(priv->next_bridge);
> +}
[Severity: Medium]
Does tegra_dbi_host_detach() leave a dangling pointer in priv->next_bridge
after dropping its reference? If the DBI peripheral driver is unbound,
later accesses in tegra_dbi_atomic_enable() or tegra_dbi_attach() will
dereference the freed bridge unless priv->next_bridge is cleared (for
example with drm_bridge_clear_and_put()).
[ ... ]
> +static void tegra_dbi_atomic_enable(struct drm_bridge *bridge,
> + struct drm_atomic_commit *state)
> +{
> + struct tegra_dbi_priv *priv = bridge_to_tegra_dbi(bridge);
> + struct drm_bridge *next_bridge = priv->next_bridge;
> + struct tegra_dc *dc = priv->dc;
> + u32 value;
> +
> + value = tegra_dc_readl(dc, DC_CMD_DISPLAY_COMMAND);
> + value &= ~DISP_CTRL_MODE_MASK;
> + tegra_dc_writel(dc, value, DC_CMD_DISPLAY_COMMAND);
> +
> + /* Disable all options except cursor if enabled */
> + value = tegra_dc_readl(dc, DC_DISP_DISP_WIN_OPTIONS);
> + value &= CURSOR_ENABLE;
> + tegra_dc_writel(dc, value, DC_DISP_DISP_WIN_OPTIONS);
> +
> + tegra_dc_commit(dc);
[Severity: Medium]
Should tegra_dbi_atomic_enable() wait for the display controller to become
idle after committing DISP_CTRL_MODE_STOP?
tegra_crtc_atomic_enable() has already started DISP_CTRL_MODE_C_DISPLAY and
tegra_rgb_encoder_enable() has committed rgb_enable, so GENERAL_ACT_REQ is
deferred until the next frame boundary rather than latching immediately.
Because panel enable callbacks sleep across multiple frames while
bit-banging DCS commands, the pending frame-boundary latch can overwrite
the active DC_COM_PIN_OUTPUT_* GPIO settings with the shadowed video-mode
values mid-transfer.
[ ... ]
> + /* Set LDC pin to V Pulse 1 */
> + value = tegra_dc_readl(dc, DC_COM_PIN_OUTPUT_SELECT(6));
> + value &= ~PIN_OUTPUT_SELECT_MASK(PIN_OUTPUT_SELECT_LDC);
> + value |= PIN_OUTPUT_SELECT_F4(PIN_OUTPUT_SELECT_LDC);
> + tegra_dc_writel(dc, value, DC_COM_PIN_OUTPUT_SELECT(6));
[Severity: Medium]
Does this unconditionally mux V_PULSE1 onto the primary interface D/C pin
(PIN_LDC) even when the secondary 8-bit CPU interface is used?
On the secondary interface (nvidia,interface = 1), the D/C signal is on
PIN_LVP0 in DC_COM_PIN_OUTPUT_SELECT(4), which tegra_rgb_encoder_enable()
leaves set to PIN_OUTPUT_SELECT_OUT (0x00210222). Restoring com_pin_backup
therefore leaves PIN_LVP0 in fixed GPIO output mode during scanout instead
of driving per-frame MIPI_DCS_WRITE_MEMORY_START commands.
[ ... ]
> + /* Unshadow to set up command and data pins */
> + tegra_dc_writel(dc, WRITE_MUX | READ_MUX, DC_CMD_STATE_ACCESS);
> +
> + priv->interface->init(priv);
> +
> + priv->active = true;
> +
> + /*
> + * DBI requires that the next bridge be enabled here in order to
> + * send DCS commands, since the interface pins will subsequently be
> + * reconfigured for video data.
> + *
> + * Using the prepare_prev_first flag in the panel will not work,
> + * because the DBI bridge requires the panel to be enabled beforehand
> + * for proper configuration.
> + */
> + if (next_bridge->funcs && next_bridge->funcs->atomic_enable)
> + next_bridge->funcs->atomic_enable(next_bridge, state);
[Severity: Medium]
As reported by Mikko Perttunen on v5 [1], does calling
next_bridge->funcs->atomic_enable() here cause it to run twice on every
modeset?
Because tegra_dbi_attach() links priv->next_bridge into
encoder->bridge_chain after priv->bridge, drm_atomic_bridge_chain_enable()
immediately advances to priv->next_bridge and calls its atomic_enable
callback a second time while priv->active is false. For panel_bridge, this
triggers the "Skipping enable of already enabled panel" warning in
drm_panel_enable(), and any downstream bridge that sends DBI commands in
the second call fails with -ENODEV.
> +
> + tegra_dbi_pin_set(dc, &priv->interface->cs, 0);
> +
> + priv->active = false;
[ ... ]
> +static void tegra_dbi_atomic_disable(struct drm_bridge *bridge,
> + struct drm_atomic_commit *state)
> +{
> + struct tegra_dbi_priv *priv = bridge_to_tegra_dbi(bridge);
> + struct tegra_dc *dc = priv->dc;
> +
> + tegra_dc_writel(dc, WRITE_MUX | READ_MUX, DC_CMD_STATE_ACCESS);
> +
> + priv->interface->init(priv);
> + priv->active = true;
> +}
[Severity: High]
Does running this setup in atomic_disable prevent panel power-down commands
from working and leave the interface marked active after CRTC disable?
During disable_outputs(), drm_atomic_bridge_chain_disable() walks the chain
in reverse, so next_bridge->funcs->atomic_disable() runs before
tegra_dbi_atomic_disable() while priv->active is still false. Immediately
after tegra_dbi_atomic_disable() configures the DBI pins with WRITE_MUX |
READ_MUX enabled, drm_atomic_helper_commit_encoder_bridge_disable() calls
tegra_rgb_encoder_disable(), which writes rgb_disable directly to the
active DC_COM_PIN_OUTPUT_SELECT and DC_COM_PIN_OUTPUT_ENABLE registers and
tristates the pins before drm_panel_unprepare() runs in post_disable. In
addition, nothing clears priv->active or DC_CMD_STATE_ACCESS afterward, so
tegra_dbi_dbi_command() remains open for MMIO writes after the display
controller is suspended and unclocked.
[ ... ]
> +static int tegra_dbi_attach(struct drm_bridge *bridge,
> + struct drm_encoder *encoder,
> + enum drm_bridge_attach_flags flags)
> +{
> + struct tegra_dbi_priv *priv = bridge_to_tegra_dbi(bridge);
> +
> + return drm_bridge_attach(bridge->encoder, priv->next_bridge, bridge,
> + flags);
> +}
[Severity: High]
What happens if tegra_dbi_attach() runs before the MIPI DBI panel driver
has bound and called tegra_dbi_host_attach()?
tegra_dc_dbi_probe() publishes priv->bridge via devm_drm_bridge_add()
before devm_mipi_dbi_device_register(), and device_add() succeeds even when
the panel driver has not probed yet or deferred probe (for instance,
drivers/gpu/drm/Makefile links tegra/ before panel/). In that case
priv->next_bridge is still NULL when host1x_drm_probe() calls
tegra_dbi_attach(), so drm_bridge_attach() returns -EINVAL instead of
-EPROBE_DEFER and aborts DRM initialization permanently.
[ ... ]
> + priv->bridge.of_node = of_node_get(dbi_np);
> + priv->bridge.timings = &default_tegra_dbi_timings;
> +
> + ret = devm_drm_bridge_add(dev, &priv->bridge);
> + if (ret)
> + return ret;
[Severity: Medium]
Does of_node_get(dbi_np) leak a reference to the dbi device_node?
dbi_np is already managed with __free(device_node), and neither the DRM
bridge core nor a devm action releases the extra reference stored in
priv->bridge.of_node on error, probe deferral, or driver unbind.
> +
> + np = of_graph_get_remote_node(dbi_np, 1, -1);
> + if (!np)
> + return -EINVAL;
> +
> + dbidev = devm_mipi_dbi_device_register(dev, &priv->dbi_host, np);
> + of_node_put(np);
[Severity: Medium]
Does calling of_node_put(np) here cause an of_node refcount underflow when
dbidev is released?
devm_mipi_dbi_device_register() attaches np to dbidev->dev via
device_set_node() without taking its own reference, and
mipi_dbi_device_release() calls of_node_put(dev->of_node) when the device
is freed:
drivers/gpu/drm/drm_mipi_dbi_bus.c:devm_mipi_dbi_device_register() {
...
dbidev->dev.release = mipi_dbi_device_release;
device_set_node(&dbidev->dev, of_fwnode_handle(np));
...
}
Dropping np's only reference right after registration leaves
dbidev->dev.of_node unreferenced and results in a double of_node_put() on
error unwind or device removal.
[1] https://lore.kernel.org/r/weWUeY3nRGCfNVcl2RuY5g@nvidia.com
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261116151017.274764-1-clamor95@gmail.com?part=12
prev parent reply other threads:[~2026-11-16 15:50 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 15:10 [PATCH v7 00/12] drm/tegra: Add support for Tegra20/Tegra30 8-bit CPU interface Svyatoslav Ryhel
2026-11-16 15:10 ` [PATCH v7 01/12] drm: Add MIPI DBI bus support for MIPI DBI Type A and B Svyatoslav Ryhel
2026-11-16 15:28 ` sashiko-bot
2026-11-16 15:10 ` [PATCH v7 02/12] drm/panel: panel-hitachi-tx10d07vm0baa: Convert to use MIPI DBI bus Svyatoslav Ryhel
2026-11-16 15:10 ` [PATCH v7 03/12] drm/panel: panel-hitachi-tx10d07vm0baa: Drop redundant disable() operation Svyatoslav Ryhel
2026-11-16 15:10 ` [PATCH v7 04/12] drm/panel: panel-lg-lh400wv3: Convert to use MIPI DBI bus Svyatoslav Ryhel
2026-11-16 15:10 ` [PATCH v7 05/12] drm/panel: panel-lg-lh400wv3: Drop redundant disable() operation Svyatoslav Ryhel
2026-11-16 15:10 ` [PATCH v7 06/12] drm/tegra: dc: Add elements required by Tegra MIPI DBI Svyatoslav Ryhel
2026-11-16 15:10 ` [PATCH v7 07/12] dt-bindings: display: tegra: Document Tegra20 DSI port Svyatoslav Ryhel
2026-11-16 15:10 ` [PATCH v7 08/12] drm/tegra: output: Make panel parsing configurable Svyatoslav Ryhel
2026-11-16 15:10 ` [PATCH v7 09/12] drm/tegra: Convert to use atomic versions of drm_encoder_helper_funcs Svyatoslav Ryhel
2026-11-16 15:10 ` [PATCH v7 10/12] drm/tegra: rgb: Parameterize configuration based on bus flags Svyatoslav Ryhel
2026-11-16 15:10 ` [PATCH v7 11/12] dt-bindings: display: tegra: Document 8-bit CPU parallel interface Svyatoslav Ryhel
2026-11-16 15:10 ` [PATCH v7 12/12] drm/tegra: Add support for 8-bit CPU interface Svyatoslav Ryhel
2026-11-16 15:49 ` sashiko-bot [this message]
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-217315@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=clamor95@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.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