Linux Media Controller development
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>,
	Hans Verkuil <hverkuil+cisco@kernel.org>,
	Sasha Levin <sashal@kernel.org>,
	bingbu.cao@intel.com, linux-media@vger.kernel.org
Subject: [PATCH AUTOSEL 6.17-6.12] media: ipu6: isys: Set embedded data type correctly for metadata formats
Date: Sat, 25 Oct 2025 11:59:54 -0400	[thread overview]
Message-ID: <20251025160905.3857885-363-sashal@kernel.org> (raw)
In-Reply-To: <20251025160905.3857885-1-sashal@kernel.org>

From: Sakari Ailus <sakari.ailus@linux.intel.com>

[ Upstream commit f5a2826cd50c6fd1af803812d1d910a64ae8e0a1 ]

The IPU6 ISYS driver supported metadata formats but was missing correct
embedded data type in the receiver configuration. Add it now.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---

LLM Generated explanations, may be completely bogus:

## **BACKPORT RECOMMENDATION: YES**

After conducting an exhaustive analysis of this commit, I strongly
recommend backporting it to stable kernel trees (v6.10+).

---

## **DETAILED ANALYSIS**

### **The Bug Identified**

This commit fixes a **genuine implementation bug** in the IPU6 ISYS
driver's metadata format support:

1. **Incomplete Feature Implementation**: Commit `d3bd039cd2a00`
   (January 31, 2024) added "line-based metadata capture support" to the
   IPU6 driver in v6.10. However, the implementation was incomplete:
   - The function `ipu6_isys_mbus_code_to_bpp()` at lines 19-52
     correctly handles metadata formats (META_8, META_10, META_12,
     META_16, META_24)
   - The function `ipu6_isys_mbus_code_to_mipi()` at lines 54-89 **does
     not** handle metadata formats

2. **Consequences of the Bug**:
   - When metadata formats are used, `ipu6_isys_mbus_code_to_mipi()`
     falls through to the default case (line 84-87)
   - This triggers `WARN_ON(1)` causing kernel warning messages in dmesg
   - Returns 0x3f (an invalid MIPI data type) instead of the correct
     `MIPI_CSI2_DT_EMBEDDED_8B` (0x12)
   - The invalid data type gets propagated to firmware at
     `drivers/media/pci/intel/ipu6/ipu6-isys-video.c:477` where
     `input_pin->dt = av->dt`
   - Result: **Metadata capture doesn't work correctly** and hardware is
     misconfigured

3. **Evidence of the Bug**:
   - The driver advertises support for metadata formats in CSI2 receiver
     (`ipu6-isys-csi2.c:45-49`)
   - Maps metadata formats to V4L2 pixel formats (`ipu6-isys-
     video.c:88-95`)
   - But fails to provide correct MIPI data type conversion for these
     formats

### **The Fix Evaluation**

**Technical Correctness:**
- Adds 6 case statements for `MEDIA_BUS_FMT_META_*` formats
- Returns `MIPI_CSI2_DT_EMBEDDED_8B` (0x12), which is the **correct MIPI
  CSI-2 data type** per the MIPI CSI-2 specification
  (`include/media/mipi-csi2.h:21`)
- Aligns with standard V4L2/media subsystem conventions for embedded
  data

**Code Changes Analysis:**
```c
// Added lines 85-90:
case MEDIA_BUS_FMT_META_8:
case MEDIA_BUS_FMT_META_10:
case MEDIA_BUS_FMT_META_12:
case MEDIA_BUS_FMT_META_16:
case MEDIA_BUS_FMT_META_24:
    return MIPI_CSI2_DT_EMBEDDED_8B;
```

**Risk Assessment: VERY LOW**
1. **Minimal Scope**: Only 6 lines added to a switch statement
2. **No Regression Risk**: Only affects formats that were **completely
   broken** before (triggering WARN_ON and returning invalid data type)
3. **Self-Contained**: No dependencies, no side effects on existing
   working formats (RGB, YUV, Bayer patterns)
4. **Trivial to Verify**: Basic functional testing would immediately
   confirm correctness

### **Stable Tree Rules Compliance**

Evaluating against Documentation/process/stable-kernel-rules.rst:

✅ **Fixes an important bug**: Metadata capture is advertised but doesn't
work
✅ **Small and obviously correct**: 6 lines, trivial logic
✅ **No complex dependencies**: Self-contained change
✅ **Not theoretical**: Real bug with observable symptoms (WARN_ON,
hardware misconfiguration)
✅ **Affects stable kernels**: Bug present since v6.10

### **Impact Assessment**

**Who is Affected:**
- Users of Intel IPU6 hardware (Tiger Lake, Alder Lake, and newer
  platforms)
- Applications requiring metadata capture (e.g., camera statistics,
  embedded data from sensors)
- Professional camera software and development tools

**Why Low User Reports:**
- **Specialized Feature**: Metadata capture is a niche feature used
  mainly by professional camera applications
- **Recent Addition**: Feature added in v6.10 (2024), relatively new
- **Hardware Availability**: IPU6 hardware is in newer Intel platforms
- **Professional Users**: May have workarounds or simply disabled
  metadata capture

**Note**: Absence of user bug reports does **NOT** mean the bug should
be ignored. The driver claims to support a feature that is fundamentally
broken.

### **Research Findings**

Using the search-specialist agent, I found:
- **No specific user bug reports** for this WARN_ON issue
- **No CVE or security implications**
- **No related fixes or reverts** in the codebase
- The code clearly shows the bug exists and the fix is correct

### **Comparison with Similar Commits**

This commit is similar to other stable-worthy commits that:
- Fix incomplete driver implementations
- Have minimal code changes
- Fix bugs in specialized features
- Prevent kernel warnings (WARN_ON)
- Correct hardware configuration issues

---

## **FINAL RECOMMENDATION**

**YES - This commit SHOULD be backported to stable kernel trees
(v6.10+)**

**Justification:**
1. Fixes a **real, verifiable bug** with observable symptoms
2. Extremely **low risk** - only affects broken functionality
3. **Simple and contained** - 6 lines in a switch statement
4. Provides **correct hardware configuration** per MIPI CSI-2
   specification
5. Eliminates **kernel warnings** (WARN_ON)
6. Completes the metadata format support that was partially implemented
7. No known side effects or regression risks

The fix is so simple, correct, and low-risk that there is no compelling
reason NOT to backport it. Even if metadata capture is a specialized
feature with few current users, having broken functionality in the
kernel is unacceptable when the fix is this straightforward.

 drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c b/drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c
index 0a06de5c739c7..463a0adf9e131 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c
+++ b/drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c
@@ -81,6 +81,12 @@ unsigned int ipu6_isys_mbus_code_to_mipi(u32 code)
 	case MEDIA_BUS_FMT_SGRBG8_1X8:
 	case MEDIA_BUS_FMT_SRGGB8_1X8:
 		return MIPI_CSI2_DT_RAW8;
+	case MEDIA_BUS_FMT_META_8:
+	case MEDIA_BUS_FMT_META_10:
+	case MEDIA_BUS_FMT_META_12:
+	case MEDIA_BUS_FMT_META_16:
+	case MEDIA_BUS_FMT_META_24:
+		return MIPI_CSI2_DT_EMBEDDED_8B;
 	default:
 		/* return unavailable MIPI data type - 0x3f */
 		WARN_ON(1);
-- 
2.51.0


  parent reply	other threads:[~2025-10-25 16:25 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20251025160905.3857885-1-sashal@kernel.org>
2025-10-25 15:53 ` [PATCH AUTOSEL 6.17] media: nxp: imx8-isi: Fix streaming cleanup on release Sasha Levin
2025-10-25 15:54 ` [PATCH AUTOSEL 6.17] drm/xe: improve dma-resv handling for backup object Sasha Levin
2025-10-25 15:54 ` [PATCH AUTOSEL 6.17-5.15] media: adv7180: Only validate format in querystd Sasha Levin
2025-10-25 15:54 ` [PATCH AUTOSEL 6.17-6.6] media: ov08x40: Fix the horizontal flip control Sasha Levin
2025-10-25 15:55 ` [PATCH AUTOSEL 6.17-5.15] media: em28xx: add special case for legacy gpiolib interface Sasha Levin
2025-10-27  9:24   ` Arnd Bergmann
2025-11-04 13:55     ` Sasha Levin
2025-10-25 15:56 ` [PATCH AUTOSEL 6.17-5.15] media: adv7180: Do not write format to device in set_fmt Sasha Levin
2025-10-25 15:56 ` [PATCH AUTOSEL 6.17] media: imx-mipi-csis: Only set clock rate when specified in DT Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17] media: qcom: camss: csiphy-3ph: Add CSIPHY 2ph DPHY v2.0.1 init sequence Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17-5.4] media: redrat3: use int type to store negative error codes Sasha Levin
2025-10-25 15:58 ` [PATCH AUTOSEL 6.17-5.4] media: pci: ivtv: Don't create fake v4l2_fh Sasha Levin
2025-10-25 15:58 ` [PATCH AUTOSEL 6.17-5.4] media: imon: make send_packet() more robust Sasha Levin
2025-10-25 15:58 ` [PATCH AUTOSEL 6.17-5.15] media: adv7180: Add missing lock in suspend callback Sasha Levin
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17-6.1] media: verisilicon: Explicitly disable selection api ioctls for decoders Sasha Levin
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17-6.12] media: pci: mgb4: Fix timings comparison in VIDIOC_S_DV_TIMINGS Sasha Levin
2025-10-25 15:59 ` Sasha Levin [this message]
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17-6.1] media: i2c: og01a1b: Specify monochrome media bus format instead of Bayer Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17-6.1] media: amphion: Delete v4l2_fh synchronously in .release() Sasha Levin

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=20251025160905.3857885-363-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=bingbu.cao@intel.com \
    --cc=hverkuil+cisco@kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=patches@lists.linux.dev \
    --cc=sakari.ailus@linux.intel.com \
    --cc=stable@vger.kernel.org \
    /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