From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: drm/scdc-helper: Add scdc_status debugfs entry Date: Wed, 27 May 2026 15:01:44 +1000 Message-ID: In-Reply-To: <20260526-scdc-link-health-v3-2-59e4a4aaead1@collabora.com> References: <20260526-scdc-link-health-v3-0-59e4a4aaead1@collabora.com> <20260526-scdc-link-health-v3-2-59e4a4aaead1@collabora.com> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 Patch Review This is the core patch. Several observations: **Bitfield portability (issue):** The `drm_scdc_status_flags` struct uses a union of `bool` bitfields with `u8 data`: ```c union { struct { bool clock_detected : 1; bool ch0_locked : 1; bool ch1_locked : 1; bool ch2_locked : 1; ... } flags __packed; u8 data; } status0; ``` Bitfield ordering within a storage unit is implementation-defined. GCC allocates from LSB on little-endian targets and from MSB on big-endian targets. On a big-endian system, `clock_detected` would map to bit 7, not bit 0 as the SCDC register defines (`SCDC_CLOCK_DETECT` = `(1 << 0)`). The kernel handles this elsewhere (e.g., `struct iphdr`) using `#if defined(__LITTLE_ENDIAN_BITFIELD)` / `#elif defined(__BIG_ENDIAN_BITFIELD)` guards. The DRM subsystem doesn't currently use this pattern (no hits in `include/drm/`), but these bitfields directly overlay a hardware register byte, which is where it matters. Consider using explicit bit masks and shifts instead, or adding endianness guards. **Conditional reads from update flags (design concern):** In `drm_scdc_read_state`, status flags and error counters are only read when the corresponding update flags are set: ```c if (upd_flags[0] & SCDC_STATUS_UPDATE) { ret = drm_scdc_read_status0_flags(connector, &state->stf); ... } if (upd_flags[0] & SCDC_CED_UPDATE) { ret = drm_scdc_read_error_counters(connector, state->error_count); ... } ``` Since the state persists in `scdc_debugfs_priv`, on the first debugfs read (or if no updates have occurred), the status and error fields will be zero. Subsequent reads will show stale data from the last update. For a polling-oriented debugfs interface, always reading status flags (which have no side effects besides clearing the notification bit) would produce more useful output. Error counters have clear-on-read semantics so the conditional approach is more defensible there. **Update flag clearing order:** `drm_scdc_read_status0_flags` clears the `SCDC_STATUS_UPDATE` flag *before* reading the status register. This is fine because status registers always reflect current state (they aren't latched on the update flag), but it differs from the typical spec-described flow of read-then-clear. Not a bug, just worth noting. **Minor: doc typo in `drm_scdc_state`:** ```c /** @scramling_enabled: true if TMDS scrambling is on */ ``` Should be `@scrambling_enabled`. **Connector refcounting:** The `scdc_status_show` function correctly releases the connector ref after `drm_scdc_read_state` and before printing the state (which only accesses the local state copy). This is fine. **Exported symbols:** `drm_scdc_read_status0_flags`, `drm_scdc_read_error_counters`, and `drm_scdc_read_state` are all `EXPORT_SYMBOL`. If these are only used by the debugfs show function, they could remain static to avoid expanding the kernel symbol surface. If they're intended for future driver use, the exports are reasonable. --- Generated by Claude Code Patch Reviewer