imx477: a failed chip-ID read in probe leaves runtime PM disabled for every later probe
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- Ein halber Tag
- Anfängerfreundlichkeit
- 68/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- c, linux, raspberry-pi
- Bereich
- embedded-iot, operating-systems
Rechercherichtung
Start with drivers/media/i2c/imx477.c, focusing on imx477_probe() and the error_power_off label, then compare the ordering with the imx219 driver. The failure is caused by calling runtime PM teardown before pm_runtime_enable() has run, so separate the PM teardown path from the pre-PM power-off path. Validate that failed chip-ID probes no longer increase power.disable_depth; the patch should also be compiled and tested against the affected Raspberry Pi kernel branches.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Describe the bug
imx477_probe() powers the sensor on and reads the chip ID before it enables runtime PM. When that read fails, it jumps to error_power_off, which calls pm_runtime_disable() and pm_runtime_put_noidle() although pm_runtime_enable() has not run yet:
ret = imx477_identify_module(imx477, imx477->compatible_data->chip_id);
if (ret)
goto error_power_off; /* runtime PM not enabled yet */
...
pm_runtime_set_active(dev);
pm_runtime_get_noresume(dev);
pm_runtime_enable(dev);
...
error_power_off:
pm_runtime_disable(&client->dev); /* disable_depth 1 -> 2 */
pm_runtime_put_noidle(&client->dev);
imx477_power_off(&client->dev);
A new device starts with power.disable_depth == 1. The unbalanced pm_runtime_disable() raises it to 2, and the driver core's cleanup after a failed probe (device_unbind_cleanup() -> pm_runtime_reinit()) does not reset it. When the same device is probed again and the chip answers, the single pm_runtime_enable() only brings the depth back to 1, so runtime PM stays disabled for as long as the device exists.
The second probe succeeds and the sensor registers, but it can never stream: imx477_set_stream() calls pm_runtime_resume_and_get(), and rpm_resume() returns -EACCES for a disabled device whose last_status is not RPM_ACTIVE. power/runtime_status reads unsupported. Each further failed probe adds one more to the depth. Only a reboot (or anything else that creates the I2C device anew) recovers.
The kernel does not probe the device again by itself after this failure (the path returns the I2C error, not -EPROBE_DEFER), so the effect shows only when something probes the same device again without a reboot: a module reload (modprobe -r imx477; modprobe imx477), or a write to the driver's bind file or to /sys/bus/i2c/drivers_probe. Our case is the last one: we probe a camera sensor again from user space when its first probe after power-on fails on I2C, which we see on some CM4 units with an IMX462 (imx290 driver, Error writing reg 0x3000: -5). The imx290 driver recovers on the second probe, because its failing paths before pm_runtime_enable() return directly. imx477 would not.
Steps to reproduce the behaviour
Found by reading the source; not reproduced on hardware, because it needs a chip-ID read that fails once and then succeeds on the same device:
- Boot with
dtoverlay=imx477and a sensor that does not answer its first chip-ID read (the driver logsfailed to read chip id 477, with error -5). - Once the sensor answers, probe it again:
echo 10-001a > /sys/bus/i2c/drivers_probe(use the device's own bus and address). - The driver binds;
cat /sys/bus/i2c/devices/10-001a/power/runtime_statusprintsunsupported; starting a stream fails with-EACCES.
Device (s)
Raspberry Pi CM4 (any board with an IMX477 is affected by the code path)
System
Read from rpi-6.18.y, drivers/media/i2c/imx477.c (imx477_probe, the goto error_power_off after imx477_identify_module()). rpi-6.12.y has the same code at the same lines, and rpi-6.6.y has the same order of calls.
Logs
No response
Additional context
Proposed fix
Give the runtime PM teardown its own label, so the paths that fail before pm_runtime_enable() only power the sensor off. imx219 in the same tree already orders its error path this way.
--- a/drivers/media/i2c/imx477.c
+++ b/drivers/media/i2c/imx477.c
@@ -2197,7 +2197,7 @@ static int imx477_probe(struct i2c_client *client)
/* This needs the pm runtime to be registered. */
ret = imx477_init_controls(imx477);
if (ret)
- goto error_power_off;
+ goto error_pm;
/* Initialize subdev */
imx477->sd.internal_ops = &imx477_internal_ops;
@@ -2232,9 +2232,11 @@ error_media_entity:
error_handler_free:
imx477_free_controls(imx477);
-error_power_off:
+error_pm:
pm_runtime_disable(&client->dev);
pm_runtime_put_noidle(&client->dev);
+
+error_power_off:
imx477_power_off(&client->dev);
return ret;
The patch is built against rpi-6.18.y and is not compiled or tested.
- Vorherrschende Sprache
- C
- Sterne
- 13.4k
- Forks
- 5.5k
- Ø Merge
- 1 T. 8 Std.
- Gemergte PRs (30 T.)
- 37
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus raspberrypi/linux
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
raspberrypi/linux#7822 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
raspberrypi/linux#7415 · 2 Kommentare · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
rp1-cfe doesn't forward V4L2_EVENT_SOURCE_CHANGE event from csi-2 sensor driver to userspace appOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
raspberrypi/linux#7399 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 82/100
raspberrypi/linux#7357 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
raspberrypi/linux#7054 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in raspberrypi/linux
Ähnliche Issues
-
CF_CFDP_S_SendFileData computes the file checksum from the SB buffer after CFE_SB_TransmitBufferOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
-
needs triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
389ds/389-ds-base#8251 ·
Maintainer antworten meist innerhalb von 1 Tag
-
ColumnDecimal::Append(Int128) stores a value outside the Decimal(P, S) range with no error: cut to 32/64 bits, or with too many digitsEvtl. vergeben @RUSHIT305 hat das heute übernommen. Offenbug data-types
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
ClickHouse/clickhouse-cpp#645 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
ROCm/hrx-system#3628 ·
Maintainer antworten meist innerhalb von 1 Tag