Skip to content

sensor/av100: use <linux/ioctl.h> for _IOC_SIZEBITS in hi_spi.h#90

Merged
widgetii merged 1 commit into
mainfrom
fix/av100-hi_spi-musl-_IOC_SIZEBITS-take2
May 7, 2026
Merged

sensor/av100: use <linux/ioctl.h> for _IOC_SIZEBITS in hi_spi.h#90
widgetii merged 1 commit into
mainfrom
fix/av100-hi_spi-musl-_IOC_SIZEBITS-take2

Conversation

@widgetii

@widgetii widgetii commented May 7, 2026

Copy link
Copy Markdown
Member

Summary

Take 2 of the musl fix from #83. The previous attempt added `<sys/ioctl.h>`, which works under glibc (transitively pulls in `<asm-generic/ioctl.h>` with `_IOC_SIZEBITS`) but not under musl on arm — musl's `<sys/ioctl.h>` -> `<bits/ioctl.h>` chain doesn't re-export the kernel UAPI `_IOC_SIZEBITS` macro.

Match the pattern that `hi3516cv200/hi_spi.h` and `hi3516cv300/hi_spi.h` already use:

```diff
-#include <sys/ioctl.h>
+#include <linux/ioctl.h>
```

`<linux/ioctl.h>` is the kernel UAPI header that defines `_IOC_SIZEBITS` directly (both libcs forward to it). No-op under glibc, fixes the musl build of `imx117`, `imx123`, `imx185` — every av100 sensor whose `*_sensor_ctl.c` issues `SPI_IOC_MESSAGE`.

How surfaced

OpenIPC/firmware#2056's CI install step:

```
hi_spi.h:92:60: error: '_IOC_SIZEBITS' undeclared (first use in this function)

/usr/bin/install: cannot stat '.../sony_imx117/libsns_imx117.so': No such file or directory
/usr/bin/install: cannot stat '.../sony_imx123/libsns_imx123.so': No such file or directory
/usr/bin/install: cannot stat '.../sony_imx185/libsns_imx185.so': No such file or directory
```

The previous `<sys/ioctl.h>` change landed CI-green on #83 because the libraries Makefile's `|| true` hides per-sensor build failures — only the firmware-side install foreach surfaces them.

Test plan

  • Build sony_imx117/imx123/imx185 locally with arm-openipc-linux-gnueabi-gcc 13.3.0 (still clean)
  • CI: `Build SDK (hi3516av100, hi3516av100_lite)` job under musl produces all 3 .so files
  • After merge + firmware pin bump: re-run firmware#2056 build-one for hi3516av100_lite, verify install succeeds

🤖 Generated with Claude Code

Take 2 of the musl fix from #83. The previous attempt added
<sys/ioctl.h>, which works under glibc (transitively pulls in
<asm-generic/ioctl.h> with _IOC_SIZEBITS) but not under musl on
arm — musl's <sys/ioctl.h> -> <bits/ioctl.h> chain doesn't
re-export the kernel UAPI _IOC_SIZEBITS macro.

Match the pattern that hi3516cv200/hi_spi.h and hi3516cv300/hi_spi.h
already use:

  #include <linux/ioctl.h>

This is the kernel UAPI header that defines _IOC_SIZEBITS directly
(both libcs forward to it). No-op under glibc, fixes the musl build
of imx117, imx123, imx185 (every av100 sensor whose *_sensor_ctl.c
issues SPI_IOC_MESSAGE).

Surfaced when OpenIPC/firmware#2056 wired the av100 source-built
sensors via HISILICON_OPENSDK_SENSORS_hi3516av100 — the install
foreach failed with "cannot stat libsns_imx117.so" / imx123 / imx185
because the libraries Makefile's "|| true" hid the per-sensor build
failures, so #83 looked green but the install step couldn't find
the missing .so files.
@widgetii widgetii merged commit d3df3bb into main May 7, 2026
24 checks passed
@widgetii widgetii deleted the fix/av100-hi_spi-musl-_IOC_SIZEBITS-take2 branch May 7, 2026 15:07
widgetii added a commit that referenced this pull request May 9, 2026
Both libraries/Makefile and libraries/sensor/hi3516cv500/Makefile
iterated subdirs with `make ... || true`, which silently swallowed
per-sensor compile failures. Three musl-only header bugs surfaced
this way during the per-platform sensor source migration:

  cv300/imx323         missing <linux/ioctl.h> -> _IOC_SIZEBITS  fixed in #84
  av100/imx117          missing -I kernel/pwm/hi3516av100        fixed in #83
  av100/imx123/imx185   av100 hi_spi.h <sys/ioctl.h> vs musl     fixed in #90

In each case the `Build SDK (chiparch)` CI job stayed green because
the libraries Makefile reported success even when individual sensors
didn't link. The breakage was only caught when the firmware-side
INSTALL_TARGET_CMDS step couldn't stat the missing .so. For cv300
that even slipped past CI entirely (the install foreach uses `;`
so its exit code is the LAST install's exit code) — only sysupgrading
a real camera surfaced the missing libsns_imx323.so.

Replace `|| true` with a fail-late accumulator: keep iterating so
all errors surface in one CI run, then exit 1 with a summary list
of failing dirs at the end. Verified locally:

  - all 7 platforms still build clean under arm-openipc-linux-gnueabi-gcc
  - injecting `#error` into one sensor source causes:
      * the surrounding sensors continue to build
      * the loop reports "Build failed for: ./sensor/.../"
      * make exits 1 (CI red)

The libraries/Makefile and libraries/sensor/hi3516cv500/Makefile
are independent invocation paths (the latter is reached when
CHIPARCH=hi3516cv500 since the outer SUBDIRS filter pulls in
./sensor/hi3516cv500/ alongside its subsensors), so both need the
same fix.

Co-authored-by: Vasiliy Yakovlev <vixand@openipc.org>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

2 participants