From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/bridge: analogix_dp: Add support for optional data-lanes mapping
Date: Mon, 25 May 2026 20:15:52 +1000 [thread overview]
Message-ID: <review-patch3-20260521114459.1394264-4-damon.ding@rock-chips.com> (raw)
In-Reply-To: <20260521114459.1394264-4-damon.ding@rock-chips.com>
Patch Review
**Status: Needs revision — potential mapping inversion bug and minor issues**
#### 1. Potential lane mapping semantic bug (important)
The `data-lanes` DT standard (from `video-interfaces.yaml`) defines: **position = logical lane index, value = physical lane index**. So `data-lanes = <1 2 3 0>` means logical lane 0 is on physical lane 1, etc.
The register `ANALOGIX_DP_LANE_MAP` maps in the opposite direction: `LANE_N_MAP` specifies which **logical** lane **physical** lane N carries.
The code writes the `data-lanes` array directly into the register:
```c
reg = lane_map[0] << LANE0_MAP_SHIFT;
reg |= lane_map[1] << LANE1_MAP_SHIFT;
reg |= lane_map[2] << LANE2_MAP_SHIFT;
reg |= lane_map[3] << LANE3_MAP_SHIFT;
```
This treats `data-lanes[physical] = logical`, but the standard says `data-lanes[logical] = physical`. These interpretations yield the same result only for self-inverse permutations (involutions) like `<1 0 3 2>` or `<3 2 1 0>`. For a permutation like `<1 2 3 0>`, the mapping would be wrong.
For example, `data-lanes = <1 2 3 0>` means:
- Logical 0 → Physical 1, Logical 1 → Physical 2, Logical 2 → Physical 3, Logical 3 → Physical 0
The correct register values should be the **inverse** permutation:
- Physical 0 carries Logical 3 → LANE0_MAP = 3
- Physical 1 carries Logical 0 → LANE1_MAP = 0
But the code writes LANE0_MAP = 1, LANE1_MAP = 2, which is incorrect.
**Recommendation**: Either compute the inverse permutation when programming the register, or document clearly in the binding that this driver interprets `data-lanes` as physical-to-logical (non-standard). The former is preferred for DT convention compliance.
#### 2. Redundant endpoint lookup
The endpoint node is fetched twice — once inside `drm_of_get_data_lanes_count_ep()` and once explicitly:
```c
num_lanes = drm_of_get_data_lanes_count_ep(dp->dev->of_node, 1, 0, 1,
video_info->max_lane_count);
...
endpoint = of_graph_get_endpoint_by_regs(dp->dev->of_node, 1, -1);
```
Consider using `of_graph_get_endpoint_by_regs()` once, then calling `drm_of_get_data_lanes_count()` (the non-`_ep` variant) on the resulting endpoint node directly, reading the property from the same node.
#### 3. Inconsistent endpoint reg parameter
The first call uses `reg=0`:
```c
drm_of_get_data_lanes_count_ep(dp->dev->of_node, 1, 0, ...)
```
The second uses `reg=-1` (wildcard):
```c
of_graph_get_endpoint_by_regs(dp->dev->of_node, 1, -1)
```
If there were multiple endpoints under port@1, these could find different endpoints. Use the same value in both calls to ensure consistency.
#### 4. Early default initialization is partially redundant
```c
u32 map[LANE_COUNT4] = {0, 1, 2, 3};
...
memcpy(video_info->lane_map, map, sizeof(map));
```
The `memcpy` at line 230 sets the default immediately, which is good for the early-return paths. But the `map` array itself is initialized at declaration with the same values, so this is fine functionally — just slightly redundant since the two copies serve the same purpose.
#### 5. Minor style: unnecessary parentheses on shift defines
```c
#define LANE3_MAP_SHIFT (6)
#define LANE2_MAP_SHIFT (4)
```
Kernel coding style doesn't require parentheses around simple integer constants. Consider `#define LANE3_MAP_SHIFT 6` for consistency with the existing defines in the same file (e.g., `(0x0 << 6)` uses parentheses around expressions, not bare constants).
#### 6. The rename from `analogix_dp_lane_swap` to `analogix_dp_lane_mapping` is clean
The old boolean `enable` parameter is replaced by reading from `dp->video_info.lane_map`, and the single call site in `analogix_dp_reset()` is updated. No external callers exist. This is a clean API evolution.
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-05-25 10:15 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-21 11:44 [PATCH v2 0/3] Add eDP lane mapping support Damon Ding
2026-05-21 11:44 ` [PATCH v2 1/3] dt-bindings: display: bridge: analogix-dp: Add data-lanes support for endpoint Damon Ding
2026-05-21 19:50 ` Conor Dooley
2026-05-22 1:32 ` Damon Ding
2026-05-25 10:15 ` Claude review: " Claude Code Review Bot
2026-05-21 11:44 ` [PATCH v2 2/3] dt-bindings: rockchip: analogix-dp: Add data-lanes example Damon Ding
2026-05-21 19:47 ` Conor Dooley
2026-05-22 1:25 ` Damon Ding
2026-05-25 10:15 ` Claude review: " Claude Code Review Bot
2026-05-21 11:44 ` [PATCH v2 3/3] drm/bridge: analogix_dp: Add support for optional data-lanes mapping Damon Ding
2026-05-25 10:15 ` Claude Code Review Bot [this message]
2026-05-25 10:15 ` Claude review: Add eDP lane mapping support Claude Code Review Bot
-- strict thread matches above, loose matches on Subject: below --
2026-05-25 9:47 [PATCH v3 0/2] " Damon Ding
2026-05-25 9:47 ` [PATCH v3 2/2] drm/bridge: analogix_dp: Add support for optional data-lanes mapping Damon Ding
2026-05-25 21:20 ` Claude review: " Claude Code Review Bot
2026-05-14 7:01 [PATCH v1 0/3] Add eDP lane mapping support Damon Ding
2026-05-14 7:01 ` [PATCH v1 3/3] drm/bridge: analogix_dp: Add support for optional data-lanes mapping Damon Ding
2026-05-16 1:13 ` Claude review: " 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-patch3-20260521114459.1394264-4-damon.ding@rock-chips.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