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/amd/pm: Use pm_display_cfg in legacy DPM (v2)
Date: Fri, 27 Feb 2026 12:46:57 +1000	[thread overview]
Message-ID: <review-patch2-20260225215013.11224-3-rosenp@gmail.com> (raw)
In-Reply-To: <20260225215013.11224-3-rosenp@gmail.com>

Patch Review

This is the main patch. It adds `amdgpu_dpm_get_display_cfg()` to populate the `pm_display_cfg` struct from legacy (non-DC) display state, and converts all legacy DPM consumers from the old `dpm.new_active_crtcs`/`dpm.new_active_crtc_count` fields to use `pm_display_cfg`.

**Observation (pre-existing upstream bug):** In `amdgpu_dpm_get_display_cfg()`, the `crtc_index` field is not initialized before the iteration loop:
```c
+	if (amdgpu_crtc->crtc_id < cfg->crtc_index) {
+		/* Find first active CRTC and its line time. */
+		cfg->crtc_index = amdgpu_crtc->crtc_id;
+		cfg->line_time_in_us = amdgpu_crtc->line_time;
+	}
```
Since `cfg` is `&adev->pm.pm_display_cfg` (zero-initialized from device struct allocation), `cfg->crtc_index` starts at 0. No `crtc_id` can be less than 0 (uint32_t), so this block will never execute on the first call. As a result, `line_time_in_us` remains 0. Compare with the DC code path in `dce110_clk_mgr.c:130` which correctly initializes `crtc_index` to `num_timing_generator` before the loop to act as a sentinel value. The non-DC path should similarly initialize `cfg->crtc_index` to a large value (e.g. `UINT_MAX`) at the start of the function. The same issue affects `cfg->vrefresh` which is not reset between calls.

However, this matches the upstream code exactly, so it is **not** a valid objection to this stable backport. The consumers in `si_upload_smc_data` guard against `line_time_in_us == 0`:
```c
+		if (cfg->line_time_in_us) {
+			mclk_change_block_cp_min = 200 / cfg->line_time_in_us;
+			mclk_change_block_cp_max = 100 / cfg->line_time_in_us;
```
so it won't cause a division by zero, just suboptimal MCLK switching behavior. Worth fixing upstream separately.

The conversion of `legacy_dpm.c` to conditionally call the new function only for non-DC:
```c
-	amdgpu_dpm_get_active_displays(adev);
+	if (!adev->dc_enabled)
+		amdgpu_dpm_get_display_cfg(adev);
```
is correct — when DC is enabled, DC already populates `pm_display_cfg` through its own path.

The changes in `si_dpm.c` and `kv_dpm.c` are mechanical replacements from old fields to new ones and look correct. The `amd_powerplay.c` change consolidates the previously inline display config population into the shared function, which is also correct.

The `NULL` pointer safety for `amdgpu_crtc->connector` in the new function relies on the `!amdgpu_crtc->enabled` check above, which is the same pattern used by the old code.

Overall: correct stable backport. The crtc_index initialization issue should be raised as a separate upstream fix.

---
Generated by Claude Code Patch Reviewer

  reply	other threads:[~2026-02-27  2:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-25 21:50 [PATCH for 6.12 and 6.6 0/2] amdgpu: fix panic on old GPUs Rosen Penev
2026-02-25 21:50 ` [PATCH 1/2] drm/amd/display: Add pixel_clock to amd_pp_display_configuration Rosen Penev
2026-02-27  2:46   ` Claude review: " Claude Code Review Bot
2026-02-25 21:50 ` [PATCH 2/2] drm/amd/pm: Use pm_display_cfg in legacy DPM (v2) Rosen Penev
2026-02-27  2:46   ` Claude Code Review Bot [this message]
2026-02-27  2:46 ` Claude review: amdgpu: fix panic on old GPUs 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-20260225215013.11224-3-rosenp@gmail.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