All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "AngeloGioacchino Del Regno" <angelogioacchino.delregno@collabora.com>
Cc: dri-devel@lists.freedesktop.org, robh@kernel.org,
	devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v3 07/10] drm/mediatek: mtk_dsi: Add support for MT8196
Date: Mon, 13 Jul 2026 13:11:02 +0000	[thread overview]
Message-ID: <20260713131102.A11C21F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260713130103.34654-8-angelogioacchino.delregno@collabora.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Unit mismatch between DSI data rate (Hz) and pixel clock rate (MHz) leads to integer underflow and incorrect QoS hardware buffer configuration.
- [High] 64-bit division by a non-constant variable causes a build error on 32-bit platforms.
--

--- Patch [7]: [PATCH v3 07/10] drm/mediatek: mtk_dsi: Add support for MT8196 ---
commit 92e543d518b805c7b9129880068f5a6955059779
Author: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Subject: drm/mediatek: mtk_dsi: Add support for MT8196

This commit adds support for the new DSI IP in the MT8196 SoC. It
implements hardware buffer configuration and initializes QoS parameters
required by this newer hardware.

> diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c
> index dffb6befc749e..573299f0e63b6 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dsi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
[ ... ]
> @@ -776,6 +872,91 @@ static int mtk_dsi_set_dsc_params(struct mtk_dsi *dsi)
>  	return drm_dsc_compute_rc_parameters(dsc);
>  }
>  
> +static void mtk_dsi_config_hw_buffers(struct mtk_dsi *dsi)
> +{
[ ... ]
> +	tmp = (u64)dsi->data_rate * dsi->lanes;
> +	data_rate_per_buf = tmp / 8 / buffer_unit;

[Severity: High]
Does this 64-bit division break builds on 32-bit platforms?

Since tmp is a u64 and buffer_unit is a non-constant u32, this will likely
cause an undefined reference to __udivdi3 or __aeabi_uldivmod when compiling
for 32-bit architectures. Should this use div_u64() instead?

> +
> +	/* Calculate valid threshold and avoid exceeding FIFO size */
> +	out_valid_thresh = MTK_DSI_DEFAULT_QOS_VALID_FIFO_US * data_rate_per_buf;

[Severity: High]
Are there unit mismatches in these rate calculations?

Since dsi->data_rate is in Hz, data_rate_per_buf is calculated
as buffers per second (e.g., ~15,000,000). Multiplying it by
MTK_DSI_DEFAULT_QOS_VALID_FIFO_US (25) will result in a huge value
that will always over-saturate the FIFO limit.

> +	out_valid_thresh = min(out_valid_thresh, MTK_DSI_MAX_FIFO_BYTES - 1);
> +	mtk_dsi_mask(dsi, reg_qos[DSI_QOS_BUF_CON1], BUF_OUT_VALID_THRESH, out_valid_thresh);
> +
> +	/* Enable ULTRA signal trigger between SOF and VACT */
> +	mtk_dsi_mask(dsi, data->reg_adv[DSI_VDE], VDE_BLOCK_ULTRA, 0);
> +
> +	/* Calculate fill rate with line counter mode for DSI Video Mode */
> +	if (dsi->format == MIPI_DSI_FMT_RGB565)
> +		dsi_buf_bpp = 2;
> +	else
> +		dsi_buf_bpp = 3;
> +
> +	pclk_mhz = dsi->vm.pixelclock / HZ_PER_MHZ;
> +	fill_rate = pclk_mhz * data->pixels_per_iter * dsi_buf_bpp / buffer_unit;
> +
> +	/* Calculate QoS Anti-Latency parameters */
> +	sodi_hi = MTK_DSI_MAX_FIFO_BYTES * num_hw_buffers;
> +	sodi_hi -= (fill_rate - data_rate_per_buf) * 12 / 10;

Similarly, here fill_rate is computed using pclk_mhz and results in
buffers per microsecond (e.g., ~40). Subtracting the much larger
buffers-per-second value of data_rate_per_buf will cause an integer
underflow, resulting in incorrect hardware buffer configurations.

Could data_rate_per_buf be converted to a per-microsecond rate to align
with fill_rate and the microseconds constant?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260713130103.34654-1-angelogioacchino.delregno@collabora.com?part=7

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

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-13 13:00 [PATCH v3 00/10] drm/mediatek: Add DSC, WDMA, MT8189/96 DSI support AngeloGioacchino Del Regno
2026-07-13 13:00 ` [PATCH v3 01/10] dt-bindings: display: mediatek: dsc: Add MT8196 compatible AngeloGioacchino Del Regno
2026-07-13 13:00 ` [PATCH v3 02/10] drm/mediatek: Implement Display Stream Compression support AngeloGioacchino Del Regno
2026-07-13 13:16   ` sashiko-bot
2026-07-13 13:00 ` [PATCH v3 03/10] dt-bindings: display: mediatek: dsi: Document MT8189 and MT8196 AngeloGioacchino Del Regno
2026-07-13 13:00 ` [PATCH v3 04/10] drm/mediatek: mtk_dsi: Enable interrupt at component bind time AngeloGioacchino Del Regno
2026-07-13 13:13   ` sashiko-bot
2026-07-13 13:00 ` [PATCH v3 05/10] drm/mediatek: mtk_dsi: Transfer register offsets to per-SoC const AngeloGioacchino Del Regno
2026-07-13 13:07   ` sashiko-bot
2026-07-13 13:00 ` [PATCH v3 06/10] drm/mediatek: mtk_dsi: Add support for MT8189 AngeloGioacchino Del Regno
2026-07-13 13:13   ` sashiko-bot
2026-07-13 13:01 ` [PATCH v3 07/10] drm/mediatek: mtk_dsi: Add support for MT8196 AngeloGioacchino Del Regno
2026-07-13 13:11   ` sashiko-bot [this message]
2026-07-13 13:01 ` [PATCH v3 08/10] drm/mediatek: mtk_dsi: Enable PM Runtime on probe AngeloGioacchino Del Regno
2026-07-13 13:15   ` sashiko-bot
2026-07-13 13:01 ` [PATCH v3 09/10] dt-bindings: display: mediatek: wdma: Add compatibles for more SoCs AngeloGioacchino Del Regno
2026-07-13 13:14   ` sashiko-bot
2026-07-13 13:01 ` [PATCH v3 10/10] drm/mediatek: Add Write DMA (WDMA) Engine for Writeback support AngeloGioacchino Del Regno
2026-07-13 13:18   ` sashiko-bot

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=20260713131102.A11C21F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=angelogioacchino.delregno@collabora.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 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.