From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/virtio: Add PM notifier to restore objects after hibernation
Date: Wed, 27 May 2026 14:17:08 +1000 [thread overview]
Message-ID: <review-patch3-20260526192814.179673-4-dongwon.kim@intel.com> (raw)
In-Reply-To: <20260526192814.179673-4-dongwon.kim@intel.com>
Patch Review
**Overall:** The notifier approach correctly gates the restore logic behind PM_HIBERNATION_PREPARE. The VIRGL 3D check is a reasonable guard since virgl resources can't be restored.
**Issue 1 — `no_cb` parameter should be `bool`, not `int`:**
```c
void virtio_gpu_cmd_unref_resource(struct virtio_gpu_device *vgdev,
struct virtio_gpu_object *bo,
int no_cb)
```
All callers pass `true` or `false`. Using `bool` would be more idiomatic and self-documenting.
**Issue 2 — Unnecessary `#include <linux/pm_runtime.h>`:**
```c
#include <linux/suspend.h>
#include <linux/pm_runtime.h>
```
Nothing from `pm_runtime.h` is used. Only `<linux/suspend.h>` is needed for `register_pm_notifier()` and `PM_HIBERNATION_PREPARE`.
**Issue 3 — `virtio_gpu_notify` called per-object inside the loop:**
In `virtio_gpu_object_unref_all()`:
```c
list_for_each_entry_safe(bo, tmp, &vgdev->obj_restore_list,
restore_node)
if (bo->created) {
virtio_gpu_cmd_unref_resource(vgdev, bo, true);
virtio_gpu_notify(vgdev);
}
```
The `virtio_gpu_notify` kicks the virtqueue. It could be called once after the loop instead of per-object. Not a correctness issue since this is the hibernation path, but it's cleaner.
**Issue 4 — Missing braces around multi-statement loop body:**
```c
list_for_each_entry_safe(bo, tmp, &vgdev->obj_restore_list,
restore_node)
if (bo->created) {
virtio_gpu_cmd_unref_resource(vgdev, bo, true);
virtio_gpu_notify(vgdev);
}
```
Kernel coding style requires braces when the loop body is more than a simple statement. The `if` block should be wrapped:
```c
list_for_each_entry_safe(bo, tmp, &vgdev->obj_restore_list,
restore_node) {
if (bo->created) {
virtio_gpu_cmd_unref_resource(vgdev, bo, true);
virtio_gpu_notify(vgdev);
}
}
```
**Issue 5 — `hibernation` flag not cleared on cancelled hibernation:**
If PM_HIBERNATION_PREPARE fires but hibernation is aborted before freeze is called, the `hibernation` flag remains `true` indefinitely. It's only cleared in `virtgpu_restore()`. While this is practically harmless (since `.freeze`/`.restore` are only called during S4 and the next S4 attempt would set the flag again anyway), handling `PM_POST_HIBERNATION` to clear the flag would be cleaner:
```c
if (mode == PM_POST_HIBERNATION)
vgdev->hibernation = false;
```
**Issue 6 — Error recovery in freeze with hibernation (same as patch 1):**
Patch 3 adds `virtio_gpu_object_unref_all()` before flush_work:
```c
if (vgdev->hibernation)
virtio_gpu_object_unref_all(vgdev);
flush_work(&vgdev->obj_free_work);
```
If the subsequent `wait_queue` calls fail, the objects have already been unreffed on the host side but the error path doesn't attempt to re-create them. This could leave the driver in an inconsistent state where guest objects exist but host resources have been destroyed. Combined with the missing `drm_mode_config_helper_resume` from patch 1, a timeout during hibernation freeze would leave the driver in a broken state.
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-05-27 4:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-26 19:28 [PATCH v9 0/3] Virtio-GPU S4 support dongwon.kim
2026-05-26 19:28 ` [PATCH v9 1/3] drm/virtio: Freeze and restore hooks to support suspend and resume dongwon.kim
2026-05-27 4:17 ` Claude review: " Claude Code Review Bot
2026-05-26 19:28 ` [PATCH v9 2/3] drm/virtio: Add support for saving and restoring virtio_gpu_objects dongwon.kim
2026-05-27 4:17 ` Claude review: " Claude Code Review Bot
2026-05-26 19:28 ` [PATCH v9 3/3] drm/virtio: Add PM notifier to restore objects after hibernation dongwon.kim
2026-05-27 4:17 ` Claude Code Review Bot [this message]
2026-05-27 4:17 ` Claude review: Virtio-GPU S4 support Claude Code Review Bot
-- strict thread matches above, loose matches on Subject: below --
2026-04-29 20:47 [PATCH v8 0/3] Virtio-GPU S4 (hibernation) support dongwon.kim
2026-04-29 20:47 ` [PATCH v8 3/3] drm/virtio: Add PM notifier to restore objects after hibernation dongwon.kim
2026-05-05 1:00 ` 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-20260526192814.179673-4-dongwon.kim@intel.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