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/amdgpu: add VRAM migration infrastructure for drm_pagemap Date: Tue, 28 Apr 2026 14:43:03 +1000 Message-ID: In-Reply-To: <20260427100522.7014-2-Junhua.Shen@amd.com> References: <20260427100522.7014-1-Junhua.Shen@amd.com> <20260427100522.7014-2-Junhua.Shen@amd.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 **Overall:** Good foundational patch. Sets up ZONE_DEVICE registration and = drm_pagemap initialization. **Issue: SPDX vs. license boilerplate mismatch.** The file uses `/* SPDX-Li= cense-Identifier: GPL-2.0 OR MIT */` but then includes the full MIT permiss= ive license text in the header block. The SPDX tag should be sufficient; th= e verbose boilerplate is unnecessary and adds noise. This applies to all ne= w files in this series. **Issue: `pgmap->flags =3D 0` is redundant** after `devm_kzalloc`: ```c + pgmap->nr_range =3D 1; + pgmap->flags =3D 0; ``` The struct was zero-initialized already. **Issue: Error path leak in `drm_pagemap_init` failure.** If `drm_pagemap_i= nit()` fails, the `devm_memremap_pages()` region is not cleaned up: ```c + if (drm_pagemap_init(&svm_dm->dpagemap, pgmap, adev_to_drm(adev), + &amdgpu_svm_drm_pagemap_ops)) { + dev_err(adev->dev, "SVM: failed to init drm_pagemap\n"); + return -EINVAL; + } ``` After a successful `devm_memremap_pages()`, failing to init the pagemap sho= uld unwind the memremap. Although devres will eventually clean up, returnin= g `-EINVAL` here leaves `adev->apagemap` as NULL with a phantom ZONE_DEVICE= region registered. **Issue: Alignment of `drm_pagemap_init` arguments:** ```c + if (drm_pagemap_init(&svm_dm->dpagemap, pgmap, adev_to_drm(adev), + &amdgpu_svm_drm_pagemap_ops)) { ``` The continuation is over-indented =E2=80=94 should align after the opening = paren per kernel style. **Nit: `struct dev_pagemap` flex-array comment.** The comment says `pgmap` = "must be last =E2=80=94 flex-array" but `struct dev_pagemap` in current ker= nels uses `struct range ranges[]` which is indeed a flex-array. This constr= aint should be documented in the `amdgpu_pagemap` definition with `static_a= ssert` or a build-time check, not just a comment. **Question: `AMDGPU_SVM_PGMAP_OWNER` and `adev->hive`.** The macro: ```c +#define AMDGPU_SVM_PGMAP_OWNER(adev) \ + ((adev)->hive ? (void *)(adev)->hive : (void *)(adev)) ``` The `hive` field on `struct amdgpu_device` is `struct amdgpu_hive_info *hiv= e`. This is valid, but note that `hive` can be set/cleared during runtime (= XGMI topology changes). If the owner changes between registration and migra= tion, `migrate_vma_setup()` will misidentify pages. Is this a concern for h= ot-plug scenarios? **Nit:** `dpagemap_to_adev()` and `amdgpu_svm_page_to_apagemap()` are defin= ed here but not used until patch 2. Unused code in patch 1 could trigger co= mpiler warnings depending on config. --- Generated by Claude Code Patch Reviewer