dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Svyatoslav Ryhel" <clamor95@gmail.com>
Cc: conor+dt@kernel.org, dri-devel@lists.freedesktop.org,
	devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v1 2/6] drm/tegra: rgb: Parameterize configuration based on bus flags
Date: Wed, 30 Sep 2026 07:38:08 +0000	[thread overview]
Message-ID: <20260930073808.E19041F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260930070535.47130-3-clamor95@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] drm/tegra: rgb: NULL pointer deref in tegra_rgb_encoder_enable()
- [High] drm/tegra: rgb: pixel clock polarity regression for legacy panels
--

commit 54b0f3191ac9412b6aca8d1f4028b3159a42b6a2
Author: Svyatoslav Ryhel <clamor95@gmail.com>

drm/tegra: rgb: Parameterize configuration based on bus flags

This commit parameterizes the RGB display configuration based on bus flags
passed from the bridge or panel. It updates pixel clock polarity, display
enable polarity, and data alignment according to the input bus configuration.

> --- a/drivers/gpu/drm/tegra/rgb.c
> +++ b/drivers/gpu/drm/tegra/rgb.c
> @@ -104,14 +105,19 @@ static void tegra_rgb_encoder_enable(struct drm_encoder *encoder)
>  	struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode;
>  	struct tegra_output *output = encoder_to_output(encoder);
>  	struct tegra_rgb *rgb = to_rgb(output);
> -	u32 value;
> +	struct drm_bridge_state *bridge_state;
> +	u32 bus_flags, value;
>  
> +	/* Get but flags from the bridge state. */
> +	bridge_state = drm_bridge_get_current_state(output->bridge);
> +	bus_flags = bridge_state->input_bus_cfg.flags;

[Severity: High]
Does this introduce a NULL pointer dereference for non-atomic bridges?

Looking at drm_bridge_get_current_state(), it can return NULL if the
attached bridge does not support atomic state:

static inline struct drm_bridge_state *
drm_bridge_get_current_state(struct drm_bridge *bridge)
{
	...
	if (!bridge->base.state)
		return NULL;

	return drm_priv_to_bridge_state(bridge->base.state);
}

Since bridge_state is unconditionally dereferenced to read
input_bus_cfg.flags, will this crash the display pipeline during
tegra_rgb_encoder_enable() for any devices using non-atomic bridges?

[ ... ]
> -	/* configure H- and V-sync signal polarities */
> +	/* configure H- and V-sync and pixel clock signal polarities */
>  	value = tegra_dc_readl(rgb->dc, DC_COM_PIN_OUTPUT_POLARITY(1));
>  
>  	if (mode->flags & DRM_MODE_FLAG_NHSYNC)
> @@ -124,11 +130,31 @@ static void tegra_rgb_encoder_enable(struct drm_encoder *encoder)
>  	else
>  		value &= ~LVS_OUTPUT_POLARITY_LOW;
>  
> +	if (bus_flags & DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE)
> +		value |= LSC0_OUTPUT_POLARITY_LOW;
> +	else
> +		value &= ~LSC0_OUTPUT_POLARITY_LOW;

[Severity: High]
Can this cause a regression for legacy panels by inverting the pixel clock?

The previous code preserved the initial state of the
LSC0_OUTPUT_POLARITY_LOW bit (which is initialized just prior to this block
via tegra_dc_write_regs(..., rgb_enable, ...)).

By forcefully clearing LSC0_OUTPUT_POLARITY_LOW when the
DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE flag is absent, doesn't this break
existing hardware relying on older device trees that do not explicitly
specify this bus flag?

> +
>  	tegra_dc_writel(rgb->dc, value, DC_COM_PIN_OUTPUT_POLARITY(1));

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260930070535.47130-1-clamor95@gmail.com?part=2

  reply	other threads:[~2026-09-30  7:38 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-30  7:05 [PATCH v1 0/6] drm/tegra: Add support for Tegra20/Tegra30 8-bit CPU interface Svyatoslav Ryhel
2026-09-30  7:05 ` [PATCH v1 1/6] drm/tegra: dc: Expand available registers layouts Svyatoslav Ryhel
2026-09-30  7:15   ` sashiko-bot
2026-09-30  8:34   ` Thierry Reding
2026-09-30  8:55     ` Svyatoslav Ryhel
2026-09-30  7:05 ` [PATCH v1 2/6] drm/tegra: rgb: Parameterize configuration based on bus flags Svyatoslav Ryhel
2026-09-30  7:38   ` sashiko-bot [this message]
2026-09-30  7:05 ` [PATCH v1 3/6] dt-bindings: display: tegra: Document 8-bit CPU parallel interface Svyatoslav Ryhel
2026-09-30  7:15   ` sashiko-bot
2026-09-30  8:47   ` Thierry Reding
2026-09-30  9:00     ` Svyatoslav Ryhel
2026-09-30 10:34       ` Thierry Reding
2026-09-30 10:42         ` Svyatoslav Ryhel
2026-09-30 10:54           ` Thierry Reding
2026-09-30 11:10             ` Svyatoslav Ryhel
2026-09-30 11:41               ` Thierry Reding
2026-09-30 11:47                 ` Svyatoslav Ryhel
2026-09-30  9:19   ` Mikko Perttunen
2026-09-30  9:52     ` Svyatoslav Ryhel
2026-09-30 10:50       ` Thierry Reding
2026-09-30 10:56         ` Svyatoslav Ryhel
2026-09-30 11:46           ` Thierry Reding
2026-09-30 11:56             ` Svyatoslav Ryhel
2026-09-30 12:58               ` Thierry Reding
2026-09-30 13:10                 ` Svyatoslav Ryhel
2026-09-30 18:03     ` Svyatoslav Ryhel
2026-10-02  5:58       ` Mikko Perttunen
2026-09-30 11:51   ` Rob Herring (Arm)
2026-09-30  7:05 ` [PATCH v1 4/6] drm/tegra: Add support for 8-bit CPU interface Svyatoslav Ryhel
2026-09-30  7:25   ` sashiko-bot
2026-09-30  8:48   ` Thierry Reding
2026-09-30  9:02     ` Svyatoslav Ryhel
2026-09-30 10:39       ` Thierry Reding
2026-09-30  7:05 ` [PATCH v1 5/6] dt-bindings: display: panel: Document Hitachi TX10D07VM0BAA and LG LH400WV3 panels Svyatoslav Ryhel
2026-09-30  7:17   ` sashiko-bot
2026-09-30  7:05 ` [PATCH v1 6/6] drm/panel: Add Hitachi TX10D07VM0BAA and LG LH400WV3-SD04 MIPI DBI panel driver Svyatoslav Ryhel
2026-09-30  7:15   ` sashiko-bot
2026-09-30  9:02   ` Thierry Reding
2026-09-30  9:08     ` Svyatoslav Ryhel
2026-09-30 10:23       ` Thierry Reding
2026-09-30 10:34         ` Svyatoslav Ryhel
2026-09-30 10:43           ` Thierry Reding
2026-09-30 10:48             ` Svyatoslav Ryhel
2026-09-30 10:58               ` Thierry Reding

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=20260930073808.E19041F000FF@smtp.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