Repository navigation
libipchw: ask one sensor connector at a time (ipchw_sensor_ports, ipchw_sensor_probe) - #297
Merged
Merged
Conversation
…hw_sensor_probe) A Hi3519DV500 board has four sensor connectors, and the sensors on them come and go with their ribbon cables. detect_sensors() lists them all for the report, but a library consumer had only getsensorshort(): the first sensor anywhere, found by a sweep that names the sensor on SENSOR1 as SENSOR0's when SENSOR0 is empty. majestic needs to know which connector each sensor is on to pick its MIPI receiver, VI device and clock. - ipchw_sensor_ports(): how many connectors the HAL knows the wiring of (hal_sensor_buses; 4 on DV500, 0 everywhere else). - ipchw_sensor_probe(port, &out): that connector's bus only -- no SPI, no fallback sweep -- under the identity lock, with the adapter number put back. It fills the bus, the model as getsensorshort() spells it, and the part that shares its ID registers (os08a10 / os08a20), so a consumer can look for a profile under either name. sensor_id_shared_with() moves out of the report-only block so the library can use it. sensors_test drives the probe on a mock two-connector board with the sensor on the second one: connector 0 answers nothing and opens only bus 4, connector 1 answers os08a10 / os08a20, and out-of-range ports are refused. Making the probe use the sweep fails it.
PR Summary by QodoAdd connector-specific sensor probing to libipchw
AI Description
Merge Risk
|
Code Review by Qodo
1.
|
…nder the lock Review fixes (Qodo on #297): - A connector whose bus does not open reached hal_cleanup() without an arm before it. That spends a restore somebody else is owed: the HiSilicon HAL's setup ungates the sensor clock too, so a probe of a missing adapter could gate a clock it never touched. The cleanup now runs only after the probe's own arm_sensor_clock(). The adapter number and the console are still put back on every path. - ipchw_sensor_probe() counted the connectors -- which runs getchipname(), the HAL's unlocked first-use setup -- and read the bus table before taking the identity lock. Two first calls could race through that setup. The count, the bus choice and the probe now all run under the lock, through sensor_ports_locked(). ipchw_sensor_ports() takes the lock as well. sensors_test gains a third connector whose adapter does not open. Probing it answers 0 with the bus filled in and no cleanup. A probe that armed is undone. Putting the unconditional cleanup back fails the test.
Member
Author
|
Both Qodo findings are fixed in e59d458:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A Hi3519DV500 board has four sensor connectors, and the sensors on them are detachable.
detect_sensors()(#294) lists every sensor for the report. A library consumer, though, has onlygetsensorshort(): the first sensor anywhere, found by a sweep. That sweep names the sensor on SENSOR1 as SENSOR0's when SENSOR0 is empty. majestic needs to know which connector each sensor is on, to pick its MIPI receiver port, VI device and clock.Changes
include/ipchw.hadds two calls:ipchw_sensor_ports()returns how many connectors the HAL knows the wiring of (hal_sensor_buses). That is 4 on DV500 and 0 everywhere else.ipchw_sensor_probe(port, &out)probes that connector's bus only: no SPI and no fallback sweep.getsensorshort()and restores the process-global adapter number afterwards.getsensorshort()spells it;os08a10/os08a20), so a consumer can look for a profile under either name.sensor_id_shared_with()moves out of the report-only block so the library can use it.Tests
sensors_testgains a case that drives the probe on a mock two-connector board with the sensor on the second connector:os08a10/os08a20;If the probe is made to use the sweep (
probe_sensor()), the case fails with 7 failures. All 17 test binaries from the PR build check pass (Release build).On hardware
Tested on a Hi3519DV500 DMEBPRO kit with OS04A10 on SENSOR0 and OS08A20 on SENSOR1, through majestic built against this branch:
SENSOR0: os04a10 on I2C4,SENSOR1: os08a10 (or os08a20) on I2C5.SENSOR0: no sensor answers on I2C4, and SENSOR1 is still found.