ARM Sunxi Platform Development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Paul Kocialkowski" <paulk@sys-base.io>
Cc: linux-sunxi@lists.linux.dev
Subject: Re: [PATCH 05/16] media: v4l2-common: Fix NV15_4L4 format info block height
Date: Mon, 18 May 2026 11:14:23 +0000	[thread overview]
Message-ID: <20260518111423.DED13C2BCB7@smtp.kernel.org> (raw)
In-Reply-To: <20260518102451.417971-6-paulk@sys-base.io>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Other tiled formats (MT2110T, MT2110R, NV12MT, NV12MT_16X16) incorrectly take subsampling into account in their block_w and block_h definitions, causing chroma plane under-allocation.
- [High] Formats with bpp_div > 1 (e.g., NV15, NV20, Bayer 10P) lack block_w definitions, causing integer truncation in stride calculations.
--

(Note: The format of this report is altered due to recitation restrictions.
The original patch code is not quoted inline; instead, a free-form summary
of the findings is provided.)

Commit: 04995fa68d4b9c2dd80539724de182a617de7bac
Author: Paul Kocialkowski <paulk@sys-base.io>
Subject: media: v4l2-common: Fix NV15_4L4 format info block height

This commit corrects the NV15_4L4 format info by specifying it as a 4x4
format and ensuring the block size does not take subsampling into account
for luma and chroma.

You noted in the commit message that block size should not take subsampling
into account. Does this mean other tiled formats like MT2110T, MT2110R,
NV12MT, and NV12MT_16X16 are currently incorrect?

Looking at their definitions in v4l2_format_info(), they seem to divide
their chroma block dimensions by the subsampling factor. For instance,
MT2110T defines block_w as { 16, 8, 0, 0 } and block_h as { 32, 16, 0, 0 }.

Because v4l2_format_plane_stride() and v4l2_format_plane_height() apply
these alignments to the luma width and height before dividing by hdiv and
vdiv, an unaligned dimension like width 8 and height 16 would correctly
align the luma plane to 16x32. However, for the chroma plane, it would
align the luma dimensions to 8x16 before dividing by the subsampling
factors.

Could this result in the chroma plane being allocated only half of a
macroblock's required dimensions, leading to out-of-bounds memory writes
when the hardware writes full tiles?

Related to the macroblock sizing logic, do formats with bpp_div greater
than 1 need explicit block_w definitions to prevent integer truncation
during stride calculations?

Linear packed formats like NV15, NV20, SBGGR10P, and the RAW_CRU variants
pack multiple pixels into a fractional number of bytes. For example, NV15
has a bpp_div of 4. Because they currently lack a block_w definition, they
default to an alignment of 1.

If an unaligned width is passed to v4l2_format_plane_stride(), the formula
(aligned_width / hdiv) * bpp / bpp_div truncates. Using NV15 with a width
of 2 calculates a stride of (2 * 5) / 4 = 2 bytes. However, two 10-bit
pixels require 20 bits (2.5 bytes), so the stride rounds down.

Could this allocate less memory per line than the requested pixels require,
potentially causing buffer overflows since hardware typically writes in
multiples of bpp_div blocks?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260518102451.417971-1-paulk@sys-base.io?part=5

  reply	other threads:[~2026-05-18 11:14 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-18 10:24 [PATCH 00/16] media: sun6i-csi/isp MC-centric support and cleanups Paul Kocialkowski
2026-05-18 10:24 ` [PATCH 01/16] media: sun6i-csi: bridge: Use V4L2 subdev active state Paul Kocialkowski
2026-05-18 11:15   ` sashiko-bot
2026-05-18 10:24 ` [PATCH 02/16] media: sun6i-csi: capture: Implement vidioc_enum_framesizes Paul Kocialkowski
2026-05-18 10:24 ` [PATCH 03/16] media: sun6i-mipi-csi2: Use V4L2 subdev active state Paul Kocialkowski
2026-05-18 10:24 ` [PATCH 04/16] media: sun8i-a83t-mipi-csi2: " Paul Kocialkowski
2026-05-18 14:09   ` Paul Kocialkowski
2026-05-18 10:24 ` [PATCH 05/16] media: v4l2-common: Fix NV15_4L4 format info block height Paul Kocialkowski
2026-05-18 11:14   ` sashiko-bot [this message]
2026-05-19 15:16   ` Nicolas Dufresne
2026-05-19 20:33     ` Paul Kocialkowski
2026-05-18 10:24 ` [PATCH 06/16] media: v4l2-common: Add missing tiled format info block sizes Paul Kocialkowski
2026-05-19 15:18   ` Nicolas Dufresne
2026-05-19 20:37     ` Paul Kocialkowski
2026-05-18 10:24 ` [PATCH 07/16] media: v4l2-common: Add NV12_16L16 pixel format to v4l2 format info Paul Kocialkowski
2026-05-19 15:22   ` Nicolas Dufresne
2026-05-18 10:24 ` [PATCH 08/16] media: v4l2-common: Add NV12_32L32 " Paul Kocialkowski
2026-05-19 15:23   ` Nicolas Dufresne
2026-05-18 10:24 ` [PATCH 09/16] media: sun6i-csi: Split format validation to a dedicated helper Paul Kocialkowski
2026-05-18 10:24 ` [PATCH 10/16] media: sun6i-csi: Add support for MC-centric format enumeration Paul Kocialkowski
2026-05-27  5:50   ` arash golgol
2026-05-27  7:59     ` Paul Kocialkowski
2026-05-27 11:53       ` arash golgol
2026-05-18 10:24 ` [PATCH 11/16] media: sun6i-csi: Tidy up and unify coding style Paul Kocialkowski
2026-05-18 10:24 ` [PATCH 12/16] media: sun6i-mipi-csi2: Fix parenthesis alignment Paul Kocialkowski
2026-05-18 10:24 ` [PATCH 13/16] media: sun6i-isp: Add dummy params link_validate implementation Paul Kocialkowski
2026-05-25  3:25   ` arash golgol
2026-05-18 10:24 ` [PATCH 14/16] media: sun6i-isp: Use V4L2 subdev active state Paul Kocialkowski
2026-05-18 11:44   ` sashiko-bot
2026-05-18 11:57     ` Paul Kocialkowski
2026-05-21  9:23   ` arash golgol
2026-05-22 11:15     ` Paul Kocialkowski
2026-05-23  3:15       ` arash golgol
2026-05-18 10:24 ` [PATCH 15/16] media: sun6i-isp: Add support for MC-centric format enumeration Paul Kocialkowski
2026-05-18 11:02   ` sashiko-bot
2026-05-28  7:35   ` arash golgol
2026-05-18 10:24 ` [PATCH 16/16] media: sun6i-isp: Add support for frame size enumeration Paul Kocialkowski
2026-05-23  4:34   ` arash golgol
2026-05-18 12:15 ` [PATCH 00/16] media: sun6i-csi/isp MC-centric support and cleanups Laurent Pinchart
2026-05-18 14:08   ` Paul Kocialkowski

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=20260518111423.DED13C2BCB7@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=paulk@sys-base.io \
    --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