public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: optimize psp_copy_fw()
@ 2026-05-25  8:31 Christophe JAILLET
  2026-05-25 21:30 ` Claude review: " Claude Code Review Bot
  2026-05-25 21:30 ` Claude Code Review Bot
  0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2026-05-25  8:31 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David Airlie, Simona Vetter
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, amd-gfx,
	dri-devel

In psp_copy_fw(), 1 Mo of memory is zeroed, the partially re-written.
Save a few cycles and use memcpy_and_pad() which avoids writing twice
some of the memory.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile-tested only.
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 665a2632379d..9525a6bab33b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -4586,8 +4586,7 @@ int psp_copy_fw(struct psp_context *psp, uint8_t *start_addr, uint32_t bin_size)
 		return -EINVAL;
 	}
 
-	memset(psp->fw_pri_buf, 0, PSP_1_MEG);
-	memcpy(psp->fw_pri_buf, start_addr, bin_size);
+	memcpy_and_pad(psp->fw_pri_buf, PSP_1_MEG, start_addr, bin_size, 0);
 
 	drm_dev_exit(idx);
 	return 0;
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Claude review: drm/amdgpu: optimize psp_copy_fw()
  2026-05-25  8:31 [PATCH] drm/amdgpu: optimize psp_copy_fw() Christophe JAILLET
@ 2026-05-25 21:30 ` Claude Code Review Bot
  2026-05-25 21:30 ` Claude Code Review Bot
  1 sibling, 0 replies; 3+ messages in thread
From: Claude Code Review Bot @ 2026-05-25 21:30 UTC (permalink / raw)
  To: dri-devel-reviews

Overall Series Review

Subject: drm/amdgpu: optimize psp_copy_fw()
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Patches: 1
Reviewed: 2026-05-26T07:30:33.539468

---

This is a single-patch series that replaces a `memset` + `memcpy` pair with `memcpy_and_pad()` in `psp_copy_fw()`. The transformation is correct and uses an existing kernel helper designed for exactly this pattern. The optimization avoids writing the first `bin_size` bytes of the buffer twice (once by the `memset`, then again by the `memcpy`).

**Verdict: Patch looks good.**

---
Generated by Claude Code Patch Reviewer

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Claude review: drm/amdgpu: optimize psp_copy_fw()
  2026-05-25  8:31 [PATCH] drm/amdgpu: optimize psp_copy_fw() Christophe JAILLET
  2026-05-25 21:30 ` Claude review: " Claude Code Review Bot
@ 2026-05-25 21:30 ` Claude Code Review Bot
  1 sibling, 0 replies; 3+ messages in thread
From: Claude Code Review Bot @ 2026-05-25 21:30 UTC (permalink / raw)
  To: dri-devel-reviews

Patch Review

**Correctness: OK**

The original code:
```c
memset(psp->fw_pri_buf, 0, PSP_1_MEG);
memcpy(psp->fw_pri_buf, start_addr, bin_size);
```

is replaced with:
```c
memcpy_and_pad(psp->fw_pri_buf, PSP_1_MEG, start_addr, bin_size, 0);
```

The `memcpy_and_pad` implementation (`lib/string_helpers.c:1004`) does:
```c
if (dest_len > count) {
    memcpy(dest, src, count);
    memset(dest + count, pad, dest_len - count);
} else {
    memcpy(dest, src, dest_len);
}
```

The guard at line 4583 ensures `bin_size <= PSP_1_MEG`, so `memcpy_and_pad` will either copy `bin_size` bytes then zero-pad the remainder (when `bin_size < PSP_1_MEG`), or copy exactly `PSP_1_MEG` bytes (when equal). Both cases are semantically identical to the original. The arguments are mapped correctly: `dest=fw_pri_buf`, `dest_len=PSP_1_MEG`, `src=start_addr`, `count=bin_size`, `pad=0`.

**Nits (commit message only):**

- "1 Mo" should be "1 MB" (Mo is the French abbreviation for megaoctet).
- "the partially re-written" should be "then partially re-written".

These are cosmetic commit message issues; the code change itself is clean and correct.

---
Generated by Claude Code Patch Reviewer

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-25 21:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-25  8:31 [PATCH] drm/amdgpu: optimize psp_copy_fw() Christophe JAILLET
2026-05-25 21:30 ` Claude review: " Claude Code Review Bot
2026-05-25 21:30 ` Claude Code Review Bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox