Skip to content

hisi: ungate the GK7206 sensor clock before probing, as on EV300 - #288

Merged
dimerr merged 1 commit into
masterfrom
gk7206-sensor-clock
Nov 18, 2026
Merged

dimerr merged 1 commit into
masterfrom
gk7206-sensor-clock

Conversation

@dimerr

@dimerr dimerr commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

On a GK7206V11A with an SC465SL, ipctool printed no sensors: section. The sensor clock (CRG 0x120100F0) is gated until a streamer starts, and without it the sensor does not answer on I2C (i2cdetect: nothing at 0x30). hisi_ensure_sensor_enabled() had no GK7206 arm.

GK7206 keeps sensor 0's clock enable / reset in bits 0 / 1 of CRG 0xF0, where the EV300 has them (the vendor SDK's sys_hal_set_sensor_cken / sys_hal_sensor_reset set bit 8n / 8n+1 there for sensor n). This reuses sensor_crg_enable/sensor_crg_restore and the EV300 constants.

Tested on the camera with the register at 0 beforehand:

sensors:
- vendor: SmartSens
  model: SC465SL
  control:
    bus: 0
    type: i2c
    addr: 0x60

hal_hisi_test passes. (The longse.c link error in a full build is on master too.)

ipctool reported no sensor on a GK7206V11A with an SC465SL: its clock is
gated until a streamer starts, and the sensor does not answer on I2C
without it (i2cdetect: nothing at 0x30). hisi_ensure_sensor_enabled() had
no GK7206 arm.

The GK7206 keeps sensor 0's clock enable and reset where the EV300 does,
bits 0 and 1 of CRG 0xF0 (0x120100F0); the SDK's sys_hal_set_sensor_cken
and sys_hal_sensor_reset write bit 8n and 8n+1 there for sensor n. Same
helper and entitlement rules as V4.

On the camera, register 0 before: sensors: SmartSens SC465SL, bus 0,
addr 0x60.

Co-authored-by: OpenIPC AI team <ai@openipc.org>
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Ungate the GK7206 sensor clock before probing

🐞 Bug fix 🕐 10-20 Minutes

Grey Divider

AI Description

• Enable the GK7206 sensor clock before probing so gated sensors can answer on I2C.
• Reuse the EV300 register masks and clock-restoration safeguards during cleanup.
Merge Risk 🟡 Medium

Blast radius 🟢 Low 💥 1 capability

  • 1 affected end-to-end capability after fault-specific containment; implementation boundaries do not widen its functional scope.
  • The changed CRG operation is consumed by the GK7206 sensor-probing lifecycle and directly controls whether the sensor can answer I2C and remain available to the camera pipeline.
  • These are producer, probe, and consumer stages of one bounded GK7206 camera integration rather than independent technical capabilities; no separate unrelated functional scope was reached by the changed lines.
Sources

src/hal/hisi/hal_hisi.c[643-647]

#ifdef IPCHW_HISI_GOKE7206
    case GOKE_7206:
        gk7206_ensure_sensor_restored();
        break;
#endif

src/hal/hisi/hal_hisi.c[546-553]

static void gk7206_ensure_sensor_enabled() {
    sensor_crg_enable(&gk7206_crg, EV300_PERI_CRG60_ADDR,
        EV300_PERI_CRG60_SENSOR0_CKEN, EV300_PERI_CRG60_SENSOR0_SRST);
}

static void gk7206_ensure_sensor_restored() {
    sensor_crg_restore(&gk7206_crg, EV300_PERI_CRG60_ADDR);
}

src/hal/hisi/hal_hisi.c[621-625]

#ifdef IPCHW_HISI_GOKE7206
    case GOKE_7206:
        gk7206_ensure_sensor_enabled();
        break;
#endif
Behavioral complexity 🟡 Medium 🧩 Interacting branches

  • Before: GOKE_7206 fell through the generic HiSilicon sensor-clock switch and had no GK7206-specific CRG entitlement during probing.
  • After: the new compile-time branch arms sensor 0, records ownership through the shared sensor_crg_t state, and conditionally restores it during cleanup.
  • New correctness condition: the arm/cleanup lifecycle must preserve a clock enabled by another consumer, including the case where that consumer writes the same register word between the probe arm and cleanup.
  • The existing helper supplies the ownership and exact-word branches; the materially affected condition is applying that state protocol to a new GK7206 producer/consumer interleaving, not the mere reuse of the helper.
Sources

src/hal/hisi/hal_hisi.c[546-553]

static void gk7206_ensure_sensor_enabled() {
    sensor_crg_enable(&gk7206_crg, EV300_PERI_CRG60_ADDR,
        EV300_PERI_CRG60_SENSOR0_CKEN, EV300_PERI_CRG60_SENSOR0_SRST);
}

static void gk7206_ensure_sensor_restored() {
    sensor_crg_restore(&gk7206_crg, EV300_PERI_CRG60_ADDR);
}

src/hal/hisi/hal_hisi.c[621-625]

#ifdef IPCHW_HISI_GOKE7206
    case GOKE_7206:
        gk7206_ensure_sensor_enabled();
        break;
#endif

src/hal/hisi/hal_hisi.c[643-647]

#ifdef IPCHW_HISI_GOKE7206
    case GOKE_7206:
        gk7206_ensure_sensor_restored();
        break;
#endif
Potential damage 🟡 Medium 🩹 Temporary loss

  • If the race occurs while streaming, the sensor clock can be gated and I2C access or the camera stream can stop.
  • Reverting the code prevents future occurrences but does not necessarily repair a clock already gated by a running process.
  • Recovery is expected through a supported pipeline restart/rebuild or equivalent consumer re-enable; the source does not establish automatic repair or compensation for an already interrupted stream.
  • No persistent sensor data corruption or external financial/confidentiality effect is evidenced.
  • Recoverable operational outage.
  • A pipeline restart or supported consumer reinitialization should re-enable the clock, but the source does not show an automatic worker, retry, or state-repair path.
  • The failure is temporary capability loss rather than irreversible data loss.
Sources

src/hal/hisi/hal_hisi.c[546-553]

static void gk7206_ensure_sensor_enabled() {
    sensor_crg_enable(&gk7206_crg, EV300_PERI_CRG60_ADDR,
        EV300_PERI_CRG60_SENSOR0_CKEN, EV300_PERI_CRG60_SENSOR0_SRST);
}

static void gk7206_ensure_sensor_restored() {
    sensor_crg_restore(&gk7206_crg, EV300_PERI_CRG60_ADDR);
}

src/hal/hisi/hal_hisi.c[643-647]

#ifdef IPCHW_HISI_GOKE7206
    case GOKE_7206:
        gk7206_ensure_sensor_restored();
        break;
#endif
Assessed commit e16d048 > Snapshot assessment: the current PR revision could not be verified.
Diagram

graph TD
  A["HAL setup"] --> B["GK7206 dispatch"] --> C["Clock entitlement"] --> D[("Sensor CRG")] --> E["I2C probe"] --> F["HAL cleanup"]
  F -->|"Conditional restore"| D
Loading
High-Level Assessment

Reusing the EV300 masks and existing entitlement-based restore logic is appropriate because GK7206 uses the same sensor clock and reset bits. Direct register writes would bypass safeguards against gating a clock used by a running pipeline.

Files changed (1) +31 / -2

Bug fix (1) +31 / -2
hal_hisi.cAdd GK7206 sensor-clock enable and restore paths +31/-2

Add GK7206 sensor-clock enable and restore paths

• Compiles the shared CRG helper for GK7206 and uses the EV300 sensor-0 register masks to enable its clock before probing. Adds GK7206 cases to the enable and cleanup dispatchers so restoration follows the existing entitlement rules.

src/hal/hisi/hal_hisi.c

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can type 'qodo, fix this' on a finding and the fix lands right on your PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@dimerr
dimerr merged commit 4679688 into master Nov 18, 2026
5 checks passed
@dimerr
dimerr deleted the gk7206-sensor-clock branch November 18, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant