Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] drm/tegra: duplicate and out-of-order next_bridge enable/disable calls - [Medium] drm/tegra: unconditional PIN_LDC muxing in tegra_dbi_atomic_enable() --
commit 38f73e44f1c5bf7df4c07a00d683e9382cb4da10 Author: Svyatoslav Ryhel <[email protected]> drm/tegra: Add support for 8-bit CPU interface This commit adds a DRM bridge and MIPI DBI host driver for the Tegra20/30 display controller's 8-bit CPU interface to transfer MIPI DCS commands before switching the pins to RGB scanout. > diff --git a/drivers/gpu/drm/tegra/dbi.c b/drivers/gpu/drm/tegra/dbi.c > new file mode 100644 > index 0000000000000..a33e2c1147122 > --- /dev/null > +++ b/drivers/gpu/drm/tegra/dbi.c [ ... ] > +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, reg_idx; > + int ret; [ ... ] > + /* > + * Set the LDC pin to V Pulse 1. The secondary interface may require > + * LVP0 to be set to function 6 (V Pulse 1), but this is not confirmed. > + * TODO: parameterize this if needed. > + */ > + reg_idx = PIN_SELECT_REGISTER_INDEX(PIN_LDC); > + value = tegra_dc_readl(dc, DC_COM_PIN_OUTPUT_SELECT(reg_idx)); > + value &= ~PIN_OUTPUT_SELECT_MASK(PIN_SELECT_SHIFT(PIN_LDC)); > + value |= PIN_OUTPUT_SELECT_F4(PIN_SELECT_SHIFT(PIN_LDC)); > + tegra_dc_writel(dc, value, DC_COM_PIN_OUTPUT_SELECT(reg_idx)); [Severity: Medium] Does this break per-frame D/C signaling when the secondary interface (nvidia,interface = <1>) is selected? tegra_dc_dbi_probe() accepts both interface 0 (where dc_pin is PIN_LDC) and interface 1 (where dc_pin is PIN_LVP0), but tegra_dbi_atomic_enable() unconditionally muxes V_PULSE1 onto PIN_LDC before saving tegra_dbi_pin_regs[] into com_pin_backup. When interface 1 is used, PIN_LDC is clobbered while PIN_LVP0 in DC_COM_PIN_OUTPUT_SELECT(4) keeps the PIN_OUTPUT_SELECT_OUT setting programmed by tegra_rgb_encoder_enable(), leaving PIN_LVP0 in static GPIO output mode once com_pin_backup is restored for active scanout. [ ... ] > + /* Unshadow to set up command and data pins */ > + tegra_dc_writel(dc, WRITE_MUX | READ_MUX, DC_CMD_STATE_ACCESS); > + > + tegra_dbi_init_interface(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 && next_bridge->funcs && > next_bridge->funcs->atomic_enable) > + next_bridge->funcs->atomic_enable(next_bridge, state); > + > + tegra_dbi_pin_set(dc, priv->interface->cs_pin, 0); > + > + priv->active = false; > + > + tegra_dc_writel(dc, 0, DC_CMD_STATE_ACCESS); > + > + for (int i = 0; i < ARRAY_SIZE(tegra_dbi_pin_regs); i++) > + tegra_dc_writel(dc, priv->com_pin_backup[i], > + tegra_dbi_pin_regs[i]); > + > + tegra_dc_commit(dc); > + > + value = tegra_dc_readl(dc, DC_CMD_DISPLAY_COMMAND); > + value &= ~DISP_CTRL_MODE_MASK; > + value |= DISP_CTRL_MODE_C_DISPLAY; > + tegra_dc_writel(dc, value, DC_CMD_DISPLAY_COMMAND); > +} > + > +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 drm_bridge *next_bridge = priv->next_bridge; > + struct tegra_dc *dc = priv->dc; > + int ret; > + > + for (int i = 0; i < ARRAY_SIZE(tegra_dbi_pin_regs); i++) > + priv->com_pin_backup[i] = tegra_dc_readl(dc, > tegra_dbi_pin_regs[i]); > + > + ret = tegra_dbi_stop_dc(priv); > + if (ret) > + return; > + > + tegra_dc_writel(dc, WRITE_MUX | READ_MUX, DC_CMD_STATE_ACCESS); > + > + tegra_dbi_init_interface(priv); > + priv->active = true; > + > + /* > + * DBI requires that the next bridge be disabled here in order to > + * send DCS commands, since the interface pins will subsequently be > + * reconfigured for video data and tegra_rgb_encoder_disable() will > + * be called before drm_panel_unprepare() runs in post_disable. > + */ > + if (next_bridge && next_bridge->funcs && > next_bridge->funcs->atomic_disable) > + next_bridge->funcs->atomic_disable(next_bridge, state); [Severity: High] As reported by Mikko Perttunen on v5 [1], does manually calling next_bridge->funcs->atomic_enable() and atomic_disable() cause duplicate and out-of-order execution with drm_atomic_bridge_chain_enable() and drm_atomic_bridge_chain_disable()? Because tegra_dbi_attach() attaches priv->next_bridge to encoder->bridge_chain, the DRM bridge helpers already walk both bridges: 1. On enable, drm_atomic_bridge_chain_enable() calls tegra_dbi_atomic_enable() (which manually runs next_bridge->funcs->atomic_enable() while priv->active is true) and then advances to next_bridge and calls its atomic_enable() a second time while priv->active is false, triggering the "Skipping enable of already enabled panel" warning in drm_panel_enable(). 2. On disable, drm_atomic_bridge_chain_disable() walks encoder->bridge_chain in reverse order and calls next_bridge->funcs->atomic_disable() before tegra_dbi_atomic_disable() has stopped the DC, configured the pins for DBI output, or set priv->active = true. During that first call, tegra_dbi_dbi_command() rejects every DCS shutdown command with -ENODEV while the panel driver still runs its msleep() delays; tegra_dbi_atomic_disable() then runs next_bridge->funcs->atomic_disable() a second time. [1] https://lore.kernel.org/r/[email protected] -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=13
