public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Hans de Goede <johannes.goede@oss.qualcomm.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Hans Verkuil <hverkuil+cisco@kernel.org>,
	Sasha Levin <sashal@kernel.org>,
	linux-media@vger.kernel.org
Subject: [PATCH AUTOSEL 6.19-6.12] media: mt9m114: Return -EPROBE_DEFER if no endpoint is found
Date: Fri, 13 Feb 2026 19:58:52 -0500	[thread overview]
Message-ID: <20260214010245.3671907-52-sashal@kernel.org> (raw)
In-Reply-To: <20260214010245.3671907-1-sashal@kernel.org>

From: Hans de Goede <johannes.goede@oss.qualcomm.com>

[ Upstream commit 437e1f6a960035166495a5117aacbc596115eeb6 ]

With IPU# bridges, endpoints may only be created when the IPU bridge is
initialized. This may happen after the sensor driver's first probe().

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
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:

## Analysis of mt9m114: Return -EPROBE_DEFER if no endpoint is found

### Commit Message Analysis

The commit changes the mt9m114 camera sensor driver to return
`-EPROBE_DEFER` instead of `-EINVAL` when no fwnode graph endpoint is
found during probe. The rationale is that on ACPI systems (specifically
with IPU bridges), the fwnode graph endpoints may not yet exist at the
time the sensor driver first probes — they are created later when the
IPU bridge driver initializes.

### Code Change Analysis

The change is small and focused:

1. **Old behavior**: When `fwnode_graph_get_next_endpoint()` returns
   NULL, the driver logs an error and returns `-EINVAL`, causing
   permanent probe failure.

2. **New behavior**: When no endpoint is found, return `-EPROBE_DEFER`
   (via `dev_err_probe()`), which tells the driver core to retry probing
   later. A comment explains this is needed because on ACPI systems, the
   bridge driver that creates the fwnode graph may not have probed yet.

3. The `dev_err()` is replaced with `dev_err_probe()`, which is the
   standard kernel pattern for deferred probing — it only logs at debug
   level for `-EPROBE_DEFER` (avoiding log spam) and at error level for
   other errors.

### Bug Classification

This fixes a **real probe ordering bug** on ACPI-based systems. Without
this fix, the mt9m114 sensor driver will permanently fail to probe on
systems where the IPU bridge hasn't initialized yet at the time of the
first probe attempt. This is a **race condition** between driver
initialization order — the sensor driver needs endpoints that the bridge
driver creates, but there's no guaranteed ordering.

This is a common pattern in the kernel — many drivers have been updated
to return `-EPROBE_DEFER` for exactly this kind of dependency issue.
It's a well-understood fix.

### Scope and Risk Assessment

- **Lines changed**: ~15 lines (very small)
- **Files affected**: 1 file (`drivers/media/i2c/mt9m114.c`)
- **Risk**: Very low. The change only affects the case where no endpoint
  is found. If an endpoint IS found, behavior is unchanged. The worst
  case is that on systems where no endpoint will ever appear, the driver
  will defer indefinitely rather than failing immediately — but this is
  standard kernel behavior for deferred probing, and the driver core
  handles this gracefully.

### User Impact

Users with mt9m114 camera sensors on ACPI-based systems (e.g., Intel
platforms with IPU bridges) would find the camera doesn't work at all
without this fix. The sensor driver would fail to probe permanently.
This is a real-world issue affecting actual hardware functionality.

### Review and Testing

- **Reviewed-by: Laurent Pinchart** — well-known media subsystem
  maintainer
- **Signed-off-by**: Hans de Goede (Qualcomm/known kernel developer),
  Sakari Ailus (Intel, media maintainer), Hans Verkuil (media subsystem
  maintainer)

The patch has strong review credentials from multiple experienced media
subsystem developers.

### Stable Criteria Check

1. **Obviously correct and tested**: Yes — standard `-EPROBE_DEFER`
   pattern, reviewed by multiple maintainers
2. **Fixes a real bug**: Yes — sensor driver fails to probe on ACPI
   systems with IPU bridges
3. **Important issue**: Moderate — camera hardware doesn't work without
   this fix on affected systems
4. **Small and contained**: Yes — ~15 lines in a single file
5. **No new features**: Correct — this is a bug fix for probe ordering
6. **Applies cleanly**: Should apply cleanly as it's a self-contained
   change

### Dependency Check

Let me verify if the mt9m114 driver exists in older stable trees and if
there are any dependencies.

The `dev_err_probe()` function has been available since kernel 5.10, so
this should be backportable to any stable tree that has the mt9m114
driver. The mt9m114 driver was added relatively recently (v6.x era), so
the backport scope may be limited to recent stable trees, but that
doesn't affect the decision.

### Conclusion

This is a straightforward probe-deferral fix for a real hardware
functionality issue. It uses a well-established kernel pattern
(`-EPROBE_DEFER`), is small and surgical, has been reviewed by multiple
media subsystem maintainers, and carries very low regression risk. It
fixes a real problem where the mt9m114 camera sensor fails to work on
ACPI-based systems with IPU bridges.

**YES**

 drivers/media/i2c/mt9m114.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/mt9m114.c b/drivers/media/i2c/mt9m114.c
index 554f25071cca6..b1325e2cd1321 100644
--- a/drivers/media/i2c/mt9m114.c
+++ b/drivers/media/i2c/mt9m114.c
@@ -2360,11 +2360,17 @@ static int mt9m114_parse_dt(struct mt9m114 *sensor)
 	struct fwnode_handle *ep;
 	int ret;
 
+	/*
+	 * On ACPI systems the fwnode graph can be initialized by a bridge
+	 * driver, which may not have probed yet. Wait for this.
+	 *
+	 * TODO: Return an error once bridge driver code will have moved
+	 * to the ACPI core.
+	 */
 	ep = fwnode_graph_get_next_endpoint(fwnode, NULL);
-	if (!ep) {
-		dev_err(&sensor->client->dev, "No endpoint found\n");
-		return -EINVAL;
-	}
+	if (!ep)
+		return dev_err_probe(&sensor->client->dev, -EPROBE_DEFER,
+				     "waiting for fwnode graph endpoint\n");
 
 	sensor->bus_cfg.bus_type = V4L2_MBUS_UNKNOWN;
 	ret = v4l2_fwnode_endpoint_alloc_parse(ep, &sensor->bus_cfg);
-- 
2.51.0


  parent reply	other threads:[~2026-02-14  1:04 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-14  0:58 [PATCH AUTOSEL 6.19-6.12] media: ipu6: Close firmware streams on streaming enable failure Sasha Levin
2026-02-14  0:58 ` [PATCH AUTOSEL 6.19-6.12] media: chips-media: wave5: Fix conditional in start_streaming Sasha Levin
2026-02-14  0:58 ` [PATCH AUTOSEL 6.19-6.12] media: mt9m114: Avoid a reset low spike during probe() Sasha Levin
2026-02-14  0:58 ` [PATCH AUTOSEL 6.19-6.1] media: amphion: Clear last_buffer_dequeued flag for DEC_CMD_START Sasha Levin
2026-02-14  0:58 ` [PATCH AUTOSEL 6.19-5.10] media: adv7180: fix frame interval in progressive mode Sasha Levin
2026-02-14  0:58 ` [PATCH AUTOSEL 6.19-6.6] media: v4l2-async: Fix error handling on steps after finding a match Sasha Levin
2026-02-14  0:58 ` [PATCH AUTOSEL 6.19-6.1] media: rkisp1: Fix filter mode register configuration Sasha Levin
2026-02-14  0:58 ` [PATCH AUTOSEL 6.19-6.12] media: ipu6: Ensure stream_mutex is acquired when dealing with node list Sasha Levin
2026-02-14  0:58 ` Sasha Levin [this message]
2026-02-14  0:59 ` [PATCH AUTOSEL 6.19-6.18] media: uvcvideo: Create an ID namespace for streaming output terminals Sasha Levin
2026-02-14  0:59 ` [PATCH AUTOSEL 6.19-6.12] media: ipu6: Always close firmware stream Sasha Levin
2026-02-14  0:59 ` [PATCH AUTOSEL 6.19-6.18] media: qcom: camss: Do not enable cpas fast ahb clock for SM8550 VFE lite Sasha Levin
2026-02-14  0:59 ` [PATCH AUTOSEL 6.19-5.10] media: solo6x10: Check for out of bounds chip_id Sasha Levin
2026-02-14  0:59 ` [PATCH AUTOSEL 6.19-6.18] drm/amdgpu: Refactor amdgpu_gem_va_ioctl for Handling Last Fence Update and Timeline Management v4 Sasha Levin
2026-02-14  0:59 ` [PATCH AUTOSEL 6.19-6.12] media: chips-media: wave5: Process ready frames when CMD_STOP sent to Encoder Sasha Levin
2026-02-14  0:59 ` [PATCH AUTOSEL 6.19-5.10] media: pvrusb2: fix URB leak in pvr2_send_request_ex Sasha Levin
2026-02-14  0:59 ` [PATCH AUTOSEL 6.19-5.10] media: dvb-core: dmxdevfilter must always flush bufs 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=20260214010245.3671907-52-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=hverkuil+cisco@kernel.org \
    --cc=johannes.goede@oss.qualcomm.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --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