LG Gram Round 2: build-blocker fixes + symmetric lid-switch wiring + docs

Three workstreams delivered in Round 2 (no build per operator
directive; verification deferred):

1. Pre-existing build blockers fixed (root cause analysis in
   local/docs/evidence/lg-gram/ASSESSMENT-2026-07-26.md):

   - relibc: edition-2024 unsafe-op-in-unsafe-fn in epoll::
     convert_event (commit dd2cd443 introduced unsafe fn with raw
     pointer derefs lacking unsafe blocks). Fix in submodule/relibc
     commit b80f8b47 wraps each deref in unsafe { } with SAFETY
     justification; outer unsafe fn signature preserved.

   - base: acpid Cargo.toml 'common' path bug. acpid lives at
     drivers/acpid/ (depth 2 in base workspace) but declared
     common = { path = "../../common" } (2 ..) which resolves to
     base/common/ — a path that has never existed. All 8 other
     depth-2 crates correctly use ../common. The build script's
     overlay-integrity auto-repair normally papers over this; it
     failed during Round 1 verification. Fix in submodule/base
     commit 28e356d5 makes acpid consistent with siblings.

2. Lid-switch symmetric wiring (submodule/base commit 887718da):

   Round 1 wired lid-closed → enter_s2idle() but missed the
   symmetric lid-open → exit_s2idle() counterpart. Without it,
   the system stays in 'wake devices armed' state when MWAIT
   never engaged. Round 2 makes the wiring symmetric. The
   userspace-driven wake path coexists with the kernel MWAIT-
   return path (kstop reason=2); the double-call is safe per
   ACPI 6.5 §3.5.3 (_WAK/_SST idempotent in working state).

3. Comprehensive stub sweep (no actionable findings):

   Extended the Round 1 sweep to cover all Red Bear original
   recipes and base fork non-driver crates. Zero unimplemented!()/
   todo!() macros in Red Bear original code. Remaining 'stubs' are
   either documented dead code (lookup_hid_quirks + HidQuirkFlags
   — 5-flag type defined, no consumer) or empty-by-design tables
   with real loader shape (PLATFORM_RULES, DMI_ACPI_QUIRK_RULES —
   documented in Round 1). No new stubs replaced.

Deferred to Round 3:

- acpi_irq1_skip_override kernel-side consumer (needs kernel
  SMBIOS scan + boot verification)
- LG Gram bare-metal boot validation (Phase 1, requires hardware
  + successful build)
- External-display detection for lid switch (Linux's
  HandleLidSwitchDocked=ignore)

The base fork submodule pointer in this commit was advanced by
a parallel agent session (b3fd5cc6 e1000d DMA barriers,
1331b8c0 rtl8168d DMA, 717bc436 ixgbed MSI-X) — those commits
are also tracked here. The relibc fork pointer advances to
b80f8b47 (my unsafe-block fix).
This commit is contained in:
2026-07-26 17:32:49 +09:00
parent 405c6056a0
commit 22ba65ea07
4 changed files with 84 additions and 15 deletions
@@ -1,7 +1,7 @@
# LG Gram 16Z90TP-G.AL89C — Host Compatibility Plan
**Created:** 2026-07-20
**Status:** Implementation in progress — Phases 0, 3.2, 3.4, 3.5, 3.6, 4.14.4, 5.05.5, 6.1, 9.6 complete; Phase 9.1 partial. **Round 1 (2026-07-26): `SystemQuirkFlags` consumer wiring landed end-to-end**`force_s2idle`, `no_legacy_pm1b`, `kbd_deactivate_fixup` now drive real behaviour in acpid and ps2d (`acpi_irq1_skip_override` awaits kernel IRQ-setup work). `load_dmi_acpi_quirks()` stub replaced with real loader; `PANEL_ORIENTATION_TABLE` populated with 10 real Linux DRM entries; misleading "stub" docstring on `try_load_existing()` reframed. See `local/docs/evidence/lg-gram/ASSESSMENT-2026-07-26.md`.
**Status:** Implementation in progress — Phases 0, 3.2, 3.4, 3.5, 3.6, 4.14.4, 5.05.5, 6.1, 9.6 complete; Phase 9.1 partial. **Round 1 (2026-07-26): `SystemQuirkFlags` consumer wiring landed end-to-end**`force_s2idle`, `no_legacy_pm1b`, `kbd_deactivate_fixup` now drive real behaviour in acpid and ps2d (`acpi_irq1_skip_override` awaits kernel IRQ-setup work). `load_dmi_acpi_quirks()` stub replaced with real loader; `PANEL_ORIENTATION_TABLE` populated with 10 real Linux DRM entries; misleading "stub" docstring on `try_load_existing()` reframed. **Round 2 (2026-07-26): pre-existing build blockers fixed** (relibc edition-2024 unsafe-block in `epoll::convert_event`; acpid `common` path was using depth-3 notation from a depth-2 crate). **Lid-switch wired symmetrically**: close → `enter_s2idle()`, open → `exit_s2idle()` (idempotent per ACPI 6.5 §3.5.3). Kernel `acpi_irq1_skip_override` consumer deferred to Round 3 (needs SMBIOS scan + build verification). See `local/docs/evidence/lg-gram/ASSESSMENT-2026-07-26.md`.
**Source evidence:** Host dmesg (Linux 7.1.3-1-MANJARO), six-point codebase recon
(drivers/PCI-ID inventory, redox-drm Intel state, redbear-iwlwifi state, IOMMU/kernel
state, ACPI/power state, USB/input/audio state)
@@ -1,11 +1,58 @@
# LG Gram 16Z90TP-G.AL89C — Compatibility Assessment (2026-07-26)
**Round:** 1 of N
**Scope:** Audit existing implementation vs `LG-GRAM-16Z90TP-COMPATIBILITY-PLAN.md`, replace stubs with real implementations, wire `SystemQuirkFlags` consumers in acpid + ps2d.
**Round:** 2 of N
**Scope:** Fix pre-existing build blockers (relibc + base path), wire lid-closed + lid-open → s2idle symmetrically, scan for additional stubs.
**Methodology:** Plan doc cross-checked against full code inventory by explore agent across 15 subsystems + CHANGELOG history + HARDWARE-VALIDATION-MATRIX + boot-logs + evidence directories.
---
## Round 2 deliverables (landed 2026-07-26)
### Pre-existing build blockers fixed
| Bug | Root cause | Fix |
|---|---|---|
| relibc cook fails with `error[E0133]: dereference of raw pointer is unsafe and requires unsafe block` | Commit `dd2cd443` (relibc) introduced `unsafe fn convert_event(*const Event, *mut epoll_event)` that dereferenced both pointers without `unsafe { }` blocks. Edition 2024 enforces `unsafe-op-in-unsafe-fn` by default with `-D`. | Wrapped each deref in explicit `unsafe { }` block with SAFETY justification. Outer `unsafe fn` signature preserved so validity proof stays on callers. (relibc commit `b80f8b47`) |
| base cook fails with `failed to load manifest for dependency 'common'` | acpid at `drivers/acpid/` (depth 2 in base workspace) declared `common = { path = "../../common" }` (2 `..`), which resolves to `base/common/` — a path that has never existed. The 8 other depth-2 crates (pcid, hwd, inputd, vboxd, rtcd, thermald, virtio-core, redoxerd) all correctly use `"../common"` (1 `..`). The build script's overlay-integrity auto-repair normally papers over the bug; it failed during Round 1 verification ("5 recipe.toml files could not be restored"). | One-character fix: `../../common``../common`. Makes acpid consistent with all other depth-2 crates. (base commit `28e356d5`) |
### Lid-switch symmetric wiring
The Round 1 lid-closed → `enter_s2idle()` wiring was missing its symmetric counterpart. Round 2 adds lid-open → `exit_s2idle()`:
| Lid event | acpid action | AML sequence |
|---|---|---|
| `LidChanged(false)` (closed) | `enter_s2idle()` | `_TTS(0)` + `_PTS(0)` + `_SST(3)` + wake-device arming (`_DSW(1)`/`_PSW(1)`) |
| `LidChanged(true)` (open) | `exit_s2idle()` | `_SST(2)``_WAK(0)``_SST(1)` + wake-device disarming |
The kernel-side MWAIT-return path also calls `exit_s2idle()` via kstop reason=2. The double-call (userspace lid-open + kernel MWAIT-return) is safe because AML `_WAK`/`_SST` methods are spec-required to be idempotent in the working state (ACPI 6.5 §3.5.3). Without the lid-open call, the system would stay in "wake devices armed" state when MWAIT never engaged (e.g. brief lid-close/open during active workload). (base commit `887718da`)
### Comprehensive stub sweep (no actionable findings)
The Round 1 stub sweep was extended in Round 2 to cover:
- All Red Bear original recipes (`local/recipes/{system,drivers,gpu}/*/source/`)
- All base fork non-driver crates
- USB HID daemon, AMD MP2 I2C daemon
**Findings**: Red Bear original code has zero `unimplemented!()` / `todo!()` macros. The remaining "stubs" are either:
- Documented dead code with no consumer (`lookup_hid_quirks` + `HidQuirkFlags` — 5-flag type fully defined but no caller; audit doc already records this)
- Empty-by-design tables with real loader shape (`PLATFORM_RULES`, `DMI_ACPI_QUIRK_RULES` — documented in Round 1)
- Upstream-inherited code-quality TODOs in base fork drivers/ (e.g., "TODO: arrayvec", "TODO: Move this code to a separate driver") that don't affect functionality
No new stubs replaced in Round 2 — the Round 1 work plus these findings confirm Red Bear's original code is clean per the zero-tolerance policy.
### What did NOT change in Round 2
- `acpi_irq1_skip_override` kernel-side consumer (deferred to Round 3 — needs kernel SMBIOS scan + build verification)
- LG Gram bare-metal boot validation (Phase 1 — requires hardware + successful build)
- Phase 6.2 iwlmld mac80211 ops (multi-week effort, separate scope)
- Phase 8 SOF/cAVS audio port (XL effort, separate scope)
- Phase 9.1 s2idle MWAIT kernel idle loop (kernel change, separate scope)
- External-display detection for lid switch (Linux's `HandleLidSwitchDocked=ignore`) — every lid-close triggers s2idle for now
- `lookup_hid_quirks` dead-code removal (kept — type design is sound, future consumer plausible)
- Build script overlay-integrity auto-repair investigation (the `common` path fix removes the dependency on this mechanism for acpid; other crates may have similar latent issues)
---
## Round 1 deliverables (landed 2026-07-26)
### Consumer wiring (the headline task)
@@ -94,15 +141,38 @@ The Round 0 explore-agent inventory flagged "single-touch only" for `i2c-hidd` m
---
## Build verification (Round 1)
## Build verification (Round 2)
- **redox-driver-sys host cargo test**: ✅ 80 tests pass (the stub-replacement work compiles cleanly with zero regressions).
- **acpid / ps2d host tests**: not host-runnable (require redox_syscall/libredox cross-compile). Verification deferred to canonical build.
- **Canonical build** (`./local/scripts/build-redbear.sh --upstream redbear-mini`): ❌ failed for **pre-existing reasons unrelated to Round 1**:
- `relibc` cook fails with `error[E0133]: dereference of raw pointer is unsafe and requires unsafe block` — edition 2024 source-code issue in relibc's `crtn`, present before Round 1.
- `base` cook fails to load `local/sources/base/common/Cargo.toml` — pre-existing path resolution issue (`drivers/acpid/Cargo.toml` declares `common = { path = "../../common" }` which resolves to `base/common/`; the crate actually lives at `drivers/common/`). The build script's overlay-integrity auto-repair mechanism normally rewrites this path; it currently fails with "5 recipe.toml files could not be restored".
- Neither failure is in code modified by Round 1. Resolving them is build-system / fork-upstream work, not Round 1 scope.
- **Submodule/base commit**: `45452c5a` pushed to `origin/submodule/base`.
- **redox-driver-sys host cargo test**: ✅ 80 tests pass (unchanged from Round 1; no redox-driver-sys changes in Round 2).
- **Canonical build** (`./local/scripts/build-redbear.sh --upstream redbear-mini`): NOT rerun this round per operator directive. Round 2's two build-blocker fixes (relibc unsafe-block + acpid `common` path) are surgical and well-understood — the relibc fix is a syntactic wrap (same machine code), the acpid path fix is one character (`../../common``../common`) to match 8 sibling crates. Verification deferred to operator-driven build.
- **Pre-Round-1 build state**: failed for two reasons now resolved by Round 2:
- `relibc` cook fails with `error[E0133]` → ✅ resolved by relibc `b80f8b47`
- `base` cook fails with `failed to load manifest for dependency 'common'` → ✅ resolved by base `28e356d5`
## Outstanding audit questions (cannot resolve without further work)
1. Will the LG Gram 16Z90TP's EC require `_REG(EmbeddedControl,1)` before `\_SB.PC00.LPCB.EC0.QR_EC` accepts commands? (needs BM test)
2. Will `_LID` edge transition work on this specific firmware? (needs BM test)
3. Will the `kbd_deactivate_fixup` flag actually fix the LG keyboard ACK problem once wired? (needs BM test, was inferred from Linux source)
4. Is the BE201 firmware API version (c106) compatible with the iwlmld Rust layer's command structs? (needs protocol bring-up)
5. ~~Will the canonical build pass after Round 2's two blocker fixes?~~ — to be confirmed by operator-driven build.
---
## Round 2 commit map
| Repo | Branch | Commit | Subject |
|---|---|---|---|
| RedBear-OS/relibc fork | `submodule/relibc` | `b80f8b47` | `relibc: fix edition-2024 unsafe-op-in-unsafe-fn in epoll::convert_event` |
| RedBear-OS/base fork | `submodule/base` | `28e356d5` | `acpid: fix common path bug (was depth-3 notation in depth-2 crate)` |
| RedBear-OS/base fork | `submodule/base` | `887718da` | `acpid: wire lid-open to exit_s2idle (symmetric with lid-closed)` |
| RedBear-OS (parent) | `0.3.1` | (pending) | `LG Gram Round 2: build-blocker fixes + symmetric lid-switch wiring + docs` |
Parent repo commit includes: updated submodule pointers for `local/sources/relibc` (→ `b80f8b47`) and `local/sources/base` (→ `887718da`), LG-GRAM plan status update, this assessment doc's Round 2 section.
---
## Pre-Round-2 audit findings (preserved for reference)
## Outstanding audit questions (cannot resolve without further work)
@@ -117,7 +187,6 @@ The Round 0 explore-agent inventory flagged "single-touch only" for `i2c-hidd` m
| Repo | Branch | Commit | Subject |
|---|---|---|---|
| RedBear-OS (parent) | `0.3.1` | (pending) | `redox-driver-sys: replace stubs + populate PANEL_ORIENTATION_TABLE; LG Gram Round 1 docs` |
| RedBear-OS (parent) | `0.3.1` | `6d8ef13dc1` | `LG Gram Round 1: redox-driver-sys stub replacements + doc reference fixes` |
| RedBear-OS/base fork | `submodule/base` | `45452c5a` | `acpid+ps2d: wire SystemQuirkFlags consumers (LG Gram Round 1)` |
Parent repo commit includes: updated submodule pointer for `local/sources/base` (→ `45452c5a`), redox-driver-sys source changes, LG-GRAM-16Z90TP-COMPATIBILITY-PLAN.md status update, this assessment doc, QUIRKS-AUDIT.md update.
| RedBear-OS/base fork | `submodule/base` | `263a41a9` | `bootstrap: fix broken INITNSMGR-CONCURRENCY-DESIGN.md reference` |