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/bridge: Fix refcount shown via debugfs for encoder_bridges_show() Date: Fri, 13 Mar 2026 14:28:01 +1000 Message-ID: In-Reply-To: <20260312-drm-misc-next-2026-03-05-fix-encoder-bridges-refcount-v1-1-b9ba3d844732@nxp.com> References: <20260312-drm-misc-next-2026-03-05-fix-encoder-bridges-refcount-v1-1-b9ba3d844732@nxp.com> <20260312-drm-misc-next-2026-03-05-fix-encoder-bridges-refcount-v1-1-b9ba3d844732@nxp.com> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Patch Review **Correctness: The fix is correct.** The `drm_for_each_bridge_in_chain_scop= ed()` macro (defined at `include/drm/drm_bridge.h:1490`) calls `drm_bridge_= chain_get_first_bridge()` and `drm_bridge_get_next_bridge_and_put()`, holdi= ng an extra reference on the current bridge during each iteration. This inf= lates the `kref_read()` value by 1 in the debugfs output. **Style nit =E2=80=94 prefer `refcount - 1` over `--refcount`:** ```c drm_printf(p, "\trefcount: %u%s\n", scoped ? --refcount : refcount, lingering ? " [lingering]" : ""); ``` Using pre-decrement (`--refcount`) on a local variable is unnecessarily sid= e-effectful. Since `refcount` is never used again, it works, but `refcount = - 1` would be clearer and more idiomatic for a display-only adjustment. **Over-engineering concern:** The patch adds 20+ lines (a `__` prefixed inn= er function, two wrappers, and a new `bool scoped` parameter) to fix a one-= line display issue. A simpler approach would avoid the extra abstraction en= tirely. For example, `encoder_bridges_show()` could just call the existing = function and the refcount adjustment could be handled more locally, or the = original function could simply take the offset as a parameter: ```c static void drm_bridge_debugfs_show_bridge(struct drm_printer *p, struct drm_bridge *bridge, unsigned int idx, bool lingering, unsigned int refcount_adj) { unsigned int refcount =3D kref_read(&bridge->refcount) - refcount_adj; ... ``` This avoids needing both a `__` function and two thin wrappers, and it's mo= re transparent about what's happening (subtracting an adjustment rather tha= n a boolean that means "subtract 1"). Alternatively, the simplest possible fix would be to just adjust the refcou= nt inline in `encoder_bridges_show()` without changing the helper at all = =E2=80=94 though that would mean duplicating the format string. **Conceptual question:** Debugfs is a debugging interface. Arguably, showin= g the *actual* refcount (including the iterator's reference) is the most tr= uthful thing to do, and the "expected" value of 3 is a convention, not a co= ntract. A comment in the output or in the code explaining the +1 from the s= coped iterator might be more appropriate than silently adjusting the value.= That said, consistency between `allbridges_show` and `encoder_bridges_show= ` for the same bridge is a reasonable goal, so the fix is defensible. **Summary:** The fix is correct and addresses a real inconsistency. Recomme= nd simplifying the implementation (drop the double-wrapper pattern, use `re= fcount - 1` instead of `--refcount`) before merging. --- Generated by Claude Code Patch Reviewer