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: rcar-du: encoder: convert to of_drm_find_and_get_bridge() Date: Sun, 12 Apr 2026 11:12:50 +1000 Message-ID: In-Reply-To: <20260409-drm-bridge-alloc-getput-drm_of_find_bridge-4-v5-2-d7381c07788a@bootlin.com> References: <20260409-drm-bridge-alloc-getput-drm_of_find_bridge-4-v5-0-d7381c07788a@bootlin.com> <20260409-drm-bridge-alloc-getput-drm_of_find_bridge-4-v5-2-d7381c07788a@bootlin.com> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 Patch Review **Status: Good to merge.** This is the more complex patch because `rcar_du_encoder_init()` stores bridge pointers in long-lived `rcdu->lvds[]` and `rcdu->dsi[]` arrays, requiring explicit cleanup. **Refcounting analysis for stored references:** ```c rcdu->lvds[output - RCAR_DU_OUTPUT_LVDS0] = drm_bridge_get(bridge); ``` This neatly takes a new reference and assigns it in one expression. After function return, `__free` puts the local reference, and `rcdu->lvds[]` retains its own independent reference. Same pattern for `dsi[]`. **Cleanup correctness:** The new `rcar_du_encoder_cleanup()`: ```c for (i = 0; i < ARRAY_SIZE(rcdu->lvds); i++) drm_bridge_put(rcdu->lvds[i]); for (i = 0; i < ARRAY_SIZE(rcdu->dsi); i++) drm_bridge_put(rcdu->dsi[i]); ``` This is safe for NULL entries (the `DEFINE_FREE` pattern at `drm_bridge.h:1297` checks for NULL, and `drm_bridge_put()` itself should handle NULL). It's called from `rcar_du_modeset_cleanup()` which is registered via `drmm_add_action()` early in `rcar_du_modeset_init()` (line 857) -- before `rcar_du_encoders_init()` is called (line 955). This ensures cleanup runs even if encoder init fails partway through. **Early return paths after lvds/dsi storage:** The `-ENOLINK` returns at lines 98 and 103 happen after `rcdu->lvds[]` may have been populated with an extra reference. This is safe because: 1. `__free` puts the local reference 2. The stored reference in `rcdu->lvds[]` will be put by `rcar_du_encoder_cleanup()` via the already-registered `drmm_add_action` 3. The caller (`rcar_du_encoders_init`) handles `-ENOLINK` with `continue`, and other error paths also eventually tear down via drmm **One observation** (not a blocker): `drm_bridge_put()` is called directly rather than going through `if (ptr)` guards in `rcar_du_encoder_cleanup()`. This relies on `drm_bridge_put()` handling NULL gracefully. Checking the `DEFINE_FREE` at `drm_bridge.h:1297` shows it does check `if (_T)`, and looking at standard kernel conventions, `drm_bridge_put(NULL)` should be a no-op. This is fine. No issues. --- Generated by Claude Code Patch Reviewer