Commit 697f1ad
authored
hal: re-enable the sensor clock before every probe, not once per process (#184)
getsensorid() reads the sensor over i2c, so the sensor has to be clocked to
answer. On Ingenic that clock is turned on by setup_hal_ingenic(), which runs
from hw_detect_system() inside getchipname() -- and getchipname() caches:
if (*sysid) return sysid;
so the HAL setup happens exactly once per process. That is fine while nothing
takes the clock away again. Something does: a vendor SDK gates it off when it
tears its pipeline down, leaving /proc/jz/clock/cgu_cim/enable reading
"disabled". Every probe after that reads an unclocked sensor and reports that
the board has none.
The symptom is confusing in a specific way. A fresh process always gets the
right answer, because it runs the HAL setup again on its first getchipname() --
so `ipcinfo -l` from a shell answers correctly at the very moment a long-lived
caller is being told there is no sensor. That reads as a caller bug, or as
flaky hardware, rather than as this.
So make it a HAL hook and call it before each probe. NULL for every SoC that
needs nothing done, which is all of them bar Ingenic today, and cleared in
setup_hal_fallback() so detection cannot inherit a previous target's.
Measured on a t31 (sc2332) with a caller that probes once per pipeline reload:
before first probe finds sc2332_i2c, every later one finds nothing
after sc2332_i2c on all of them, across repeated SDK teardowns
Found from majestic, where it surfaced as "sensor autodetection failed" and
then "Cannot start SDK" on every SIGHUP reload.1 parent bd9997b commit 697f1ad
4 files changed
Lines changed: 27 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
223 | 224 | | |
224 | 225 | | |
225 | 226 | | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
226 | 230 | | |
227 | 231 | | |
228 | 232 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
94 | 100 | | |
95 | 101 | | |
96 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
368 | 368 | | |
369 | 369 | | |
370 | 370 | | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
371 | 377 | | |
372 | 378 | | |
373 | 379 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1194 | 1194 | | |
1195 | 1195 | | |
1196 | 1196 | | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
1197 | 1208 | | |
1198 | 1209 | | |
1199 | 1210 | | |
| |||
0 commit comments