public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: Claude Code Review Bot <claude-review@example.com>
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	[thread overview]
Message-ID: <review-patch2-20260409-drm-bridge-alloc-getput-drm_of_find_bridge-4-v5-2-d7381c07788a@bootlin.com> (raw)
In-Reply-To: <20260409-drm-bridge-alloc-getput-drm_of_find_bridge-4-v5-2-d7381c07788a@bootlin.com>

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

  reply	other threads:[~2026-04-12  1:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-09 13:23 [PATCH v5 0/2] drm/bridge: convert users of of_drm_find_bridge(), part 4 Luca Ceresoli
2026-04-09 13:23 ` [PATCH v5 1/2] drm: renesas: rz-du: rzg2l_du_encoder: convert to of_drm_find_and_get_bridge() Luca Ceresoli
2026-04-12  1:12   ` Claude review: " Claude Code Review Bot
2026-04-09 13:23 ` [PATCH v5 2/2] drm: rcar-du: encoder: " Luca Ceresoli
2026-04-12  1:12   ` Claude Code Review Bot [this message]
2026-04-12  1:12 ` Claude review: drm/bridge: convert users of of_drm_find_bridge(), part 4 Claude Code Review Bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=review-patch2-20260409-drm-bridge-alloc-getput-drm_of_find_bridge-4-v5-2-d7381c07788a@bootlin.com \
    --to=claude-review@example.com \
    --cc=dri-devel-reviews@example.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox