public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
* Claude review: drm/tegra: gr2d/gr3d: Contain PM in the gr*d_probe/gr*d_remove
  2026-05-03 16:38 ` [PATCH v2 2/2] drm/tegra: gr2d/gr3d: Contain PM in the gr*d_probe/gr*d_remove Svyatoslav Ryhel
@ 2026-05-04 22:41   ` Claude Code Review Bot
  0 siblings, 0 replies; 7+ messages in thread
From: Claude Code Review Bot @ 2026-05-04 22:41 UTC (permalink / raw)
  To: dri-devel-reviews

Patch Review

**Assessment: Good, one typo and one observation.**

This patch does three things in both gr2d.c and gr3d.c:

1. Adds `pm_runtime_enable()`, `pm_runtime_use_autosuspend()`, `pm_runtime_set_autosuspend_delay()` to `gr*d_probe()`.
2. Removes the same three calls from `gr*d_runtime_resume()`.
3. Removes `pm_runtime_dont_use_autosuspend()` and `pm_runtime_force_suspend()` from `gr*d_exit()`.

This is the correct standard pattern. The current code has `pm_runtime_enable()` inside the runtime resume callback, which is architecturally circular — the PM core can only call the runtime resume callback if runtime PM is already enabled. On a second system suspend/resume cycle, `pm_runtime_enable()` gets called again with `disable_depth == 0`, triggering a kernel warning and PM state corruption.

**Typo in commit message:**

> The current power management configuration causes GR2G/GR3D to malfunction after resume.

`GR2G` should be `GR2D`.

**Observation — removal of `pm_runtime_force_suspend()` from `exit()`:**

The patch removes these lines from `gr2d_exit()` / `gr3d_exit()`:
```c
pm_runtime_dont_use_autosuspend(client->dev);
pm_runtime_force_suspend(client->dev);
```

This means during driver teardown, the hardware won't be explicitly suspended by `exit()`. The sequence becomes:
1. `remove()`: `pm_runtime_disable()` — disables PM tracking
2. `remove()`: `host1x_client_unregister()` → triggers `exit()` → frees channels/syncpts/IOMMU
3. devm cleanup releases clocks and resets

Since `pm_runtime_disable()` is called before `exit()`, and `gr*d_runtime_suspend()` won't be invoked (PM is disabled), the channel won't be explicitly stopped via `host1x_channel_stop()` that normally runs in `gr*d_runtime_suspend()`. The clocks and resets are devm-managed so they'll be cleaned up automatically, but skipping `host1x_channel_stop()` during teardown is a behavioral change worth being aware of. In practice this is likely fine since all users have been torn down by this point, but it's worth confirming with the Tegra maintainers.

**Error path:** `pm_runtime_enable()` is placed as the last operation before `return 0` in both probe functions, so there's no failure path that needs a corresponding `pm_runtime_disable()` — this is correct.

---
Generated by Claude Code Patch Reviewer

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

* [PATCH v3 0/2] drm/tegra: gr2d/gr3d: Move pm_runtime_enable to gr*d_probe
@ 2026-05-17  9:14 Svyatoslav Ryhel
  2026-05-17  9:14 ` [PATCH v3 1/2] drm/tegra: gr2d/gr3d: Initialize address register map before HOST1X client is registered Svyatoslav Ryhel
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Svyatoslav Ryhel @ 2026-05-17  9:14 UTC (permalink / raw)
  To: Thierry Reding, Mikko Perttunen, David Airlie, Simona Vetter,
	Jonathan Hunter, Ion Agorria, Svyatoslav Ryhel
  Cc: dri-devel, linux-tegra, linux-kernel

The gr*d_remove() has pm_runtime_disable, this indicates it should be
paired with pm_runtime_enable in the probe instead of being inside
gr*d_runtime_resume().

---
Changes in v3:
- pm_runtime_enable moved before host1x_client_register

Changes in v2:
- remove pm from gr2d_exit along with pm from gr2d_runtime_resume
- move register map initialize before host1x_client_register
---

Ion Agorria (1):
  drm/tegra: gr2d/gr3d: Contain PM in the gr*d_probe/gr*d_remove

Svyatoslav Ryhel (1):
  drm/tegra: gr2d/gr3d: Initialize address register map before HOST1X
    client is registered

 drivers/gpu/drm/tegra/gr2d.c | 19 +++++++++----------
 drivers/gpu/drm/tegra/gr3d.c | 19 +++++++++----------
 2 files changed, 18 insertions(+), 20 deletions(-)

-- 
2.51.0


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

* [PATCH v3 1/2] drm/tegra: gr2d/gr3d: Initialize address register map before HOST1X client is registered
  2026-05-17  9:14 [PATCH v3 0/2] drm/tegra: gr2d/gr3d: Move pm_runtime_enable to gr*d_probe Svyatoslav Ryhel
@ 2026-05-17  9:14 ` Svyatoslav Ryhel
  2026-05-18  6:14   ` Claude review: " Claude Code Review Bot
  2026-05-17  9:14 ` [PATCH v3 2/2] drm/tegra: gr2d/gr3d: Contain PM in the gr*d_probe/gr*d_remove Svyatoslav Ryhel
  2026-05-18  6:14 ` Claude review: drm/tegra: gr2d/gr3d: Move pm_runtime_enable to gr*d_probe Claude Code Review Bot
  2 siblings, 1 reply; 7+ messages in thread
From: Svyatoslav Ryhel @ 2026-05-17  9:14 UTC (permalink / raw)
  To: Thierry Reding, Mikko Perttunen, David Airlie, Simona Vetter,
	Jonathan Hunter, Ion Agorria, Svyatoslav Ryhel
  Cc: dri-devel, linux-tegra, linux-kernel

The host1x_client_register() function is called just prior to register map
initialization loop, making the device available to userspace. This may
result in userspace attempting to submits a job before the register map is
initialized. Address this by moving register initialization before host1x
client registration.

Acked-by: Mikko Perttunen <mperttunen@nvidia.com>
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 drivers/gpu/drm/tegra/gr2d.c | 8 ++++----
 drivers/gpu/drm/tegra/gr3d.c | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/tegra/gr2d.c b/drivers/gpu/drm/tegra/gr2d.c
index 21f4dd0fa6af..e4148b034af7 100644
--- a/drivers/gpu/drm/tegra/gr2d.c
+++ b/drivers/gpu/drm/tegra/gr2d.c
@@ -276,16 +276,16 @@ static int gr2d_probe(struct platform_device *pdev)
 	if (err)
 		return err;
 
+	/* initialize address register map */
+	for (i = 0; i < ARRAY_SIZE(gr2d_addr_regs); i++)
+		set_bit(gr2d_addr_regs[i], gr2d->addr_regs);
+
 	err = host1x_client_register(&gr2d->client.base);
 	if (err < 0) {
 		dev_err(dev, "failed to register host1x client: %d\n", err);
 		return err;
 	}
 
-	/* initialize address register map */
-	for (i = 0; i < ARRAY_SIZE(gr2d_addr_regs); i++)
-		set_bit(gr2d_addr_regs[i], gr2d->addr_regs);
-
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/tegra/gr3d.c b/drivers/gpu/drm/tegra/gr3d.c
index 42e9656ab80c..47b0c6c56bfd 100644
--- a/drivers/gpu/drm/tegra/gr3d.c
+++ b/drivers/gpu/drm/tegra/gr3d.c
@@ -506,6 +506,10 @@ static int gr3d_probe(struct platform_device *pdev)
 	if (err)
 		return err;
 
+	/* initialize address register map */
+	for (i = 0; i < ARRAY_SIZE(gr3d_addr_regs); i++)
+		set_bit(gr3d_addr_regs[i], gr3d->addr_regs);
+
 	err = host1x_client_register(&gr3d->client.base);
 	if (err < 0) {
 		dev_err(&pdev->dev, "failed to register host1x client: %d\n",
@@ -513,10 +517,6 @@ static int gr3d_probe(struct platform_device *pdev)
 		return err;
 	}
 
-	/* initialize address register map */
-	for (i = 0; i < ARRAY_SIZE(gr3d_addr_regs); i++)
-		set_bit(gr3d_addr_regs[i], gr3d->addr_regs);
-
 	return 0;
 }
 
-- 
2.51.0


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

* [PATCH v3 2/2] drm/tegra: gr2d/gr3d: Contain PM in the gr*d_probe/gr*d_remove
  2026-05-17  9:14 [PATCH v3 0/2] drm/tegra: gr2d/gr3d: Move pm_runtime_enable to gr*d_probe Svyatoslav Ryhel
  2026-05-17  9:14 ` [PATCH v3 1/2] drm/tegra: gr2d/gr3d: Initialize address register map before HOST1X client is registered Svyatoslav Ryhel
@ 2026-05-17  9:14 ` Svyatoslav Ryhel
  2026-05-18  6:14   ` Claude review: " Claude Code Review Bot
  2026-05-18  6:14 ` Claude review: drm/tegra: gr2d/gr3d: Move pm_runtime_enable to gr*d_probe Claude Code Review Bot
  2 siblings, 1 reply; 7+ messages in thread
From: Svyatoslav Ryhel @ 2026-05-17  9:14 UTC (permalink / raw)
  To: Thierry Reding, Mikko Perttunen, David Airlie, Simona Vetter,
	Jonathan Hunter, Ion Agorria, Svyatoslav Ryhel
  Cc: dri-devel, linux-tegra, linux-kernel

From: Ion Agorria <ion@agorria.com>

The current power management configuration causes GR2G/GR3D to malfunction
after resume. Reconfigure all PM actions to be handled within the GR*D
probe and remove operations to address this.

Fixes: 62fa0a985e2c ("drm/tegra: Enable runtime PM during probe")
Acked-by: Mikko Perttunen <mperttunen@nvidia.com>
Signed-off-by: Ion Agorria <ion@agorria.com>
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 drivers/gpu/drm/tegra/gr2d.c | 13 ++++++-------
 drivers/gpu/drm/tegra/gr3d.c | 13 ++++++-------
 2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/tegra/gr2d.c b/drivers/gpu/drm/tegra/gr2d.c
index e4148b034af7..892e3450b281 100644
--- a/drivers/gpu/drm/tegra/gr2d.c
+++ b/drivers/gpu/drm/tegra/gr2d.c
@@ -100,9 +100,6 @@ static int gr2d_exit(struct host1x_client *client)
 	if (err < 0)
 		return err;
 
-	pm_runtime_dont_use_autosuspend(client->dev);
-	pm_runtime_force_suspend(client->dev);
-
 	host1x_client_iommu_detach(client);
 	host1x_syncpt_put(client->syncpts[0]);
 	host1x_channel_put(gr2d->channel);
@@ -280,12 +277,18 @@ static int gr2d_probe(struct platform_device *pdev)
 	for (i = 0; i < ARRAY_SIZE(gr2d_addr_regs); i++)
 		set_bit(gr2d_addr_regs[i], gr2d->addr_regs);
 
+	pm_runtime_enable(dev);
+
 	err = host1x_client_register(&gr2d->client.base);
 	if (err < 0) {
+		pm_runtime_disable(dev);
 		dev_err(dev, "failed to register host1x client: %d\n", err);
 		return err;
 	}
 
+	pm_runtime_use_autosuspend(dev);
+	pm_runtime_set_autosuspend_delay(dev, 500);
+
 	return 0;
 }
 
@@ -367,10 +370,6 @@ static int __maybe_unused gr2d_runtime_resume(struct device *dev)
 		goto disable_clk;
 	}
 
-	pm_runtime_enable(dev);
-	pm_runtime_use_autosuspend(dev);
-	pm_runtime_set_autosuspend_delay(dev, 500);
-
 	return 0;
 
 disable_clk:
diff --git a/drivers/gpu/drm/tegra/gr3d.c b/drivers/gpu/drm/tegra/gr3d.c
index 47b0c6c56bfd..388e47943d5e 100644
--- a/drivers/gpu/drm/tegra/gr3d.c
+++ b/drivers/gpu/drm/tegra/gr3d.c
@@ -109,9 +109,6 @@ static int gr3d_exit(struct host1x_client *client)
 	if (err < 0)
 		return err;
 
-	pm_runtime_dont_use_autosuspend(client->dev);
-	pm_runtime_force_suspend(client->dev);
-
 	host1x_client_iommu_detach(client);
 	host1x_syncpt_put(client->syncpts[0]);
 	host1x_channel_put(gr3d->channel);
@@ -510,13 +507,19 @@ static int gr3d_probe(struct platform_device *pdev)
 	for (i = 0; i < ARRAY_SIZE(gr3d_addr_regs); i++)
 		set_bit(gr3d_addr_regs[i], gr3d->addr_regs);
 
+	pm_runtime_enable(&pdev->dev);
+
 	err = host1x_client_register(&gr3d->client.base);
 	if (err < 0) {
+		pm_runtime_disable(&pdev->dev);
 		dev_err(&pdev->dev, "failed to register host1x client: %d\n",
 			err);
 		return err;
 	}
 
+	pm_runtime_use_autosuspend(&pdev->dev);
+	pm_runtime_set_autosuspend_delay(&pdev->dev, 500);
+
 	return 0;
 }
 
@@ -578,10 +581,6 @@ static int __maybe_unused gr3d_runtime_resume(struct device *dev)
 		goto disable_clk;
 	}
 
-	pm_runtime_enable(dev);
-	pm_runtime_use_autosuspend(dev);
-	pm_runtime_set_autosuspend_delay(dev, 500);
-
 	return 0;
 
 disable_clk:
-- 
2.51.0


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

* Claude review: drm/tegra: gr2d/gr3d: Move pm_runtime_enable to gr*d_probe
  2026-05-17  9:14 [PATCH v3 0/2] drm/tegra: gr2d/gr3d: Move pm_runtime_enable to gr*d_probe Svyatoslav Ryhel
  2026-05-17  9:14 ` [PATCH v3 1/2] drm/tegra: gr2d/gr3d: Initialize address register map before HOST1X client is registered Svyatoslav Ryhel
  2026-05-17  9:14 ` [PATCH v3 2/2] drm/tegra: gr2d/gr3d: Contain PM in the gr*d_probe/gr*d_remove Svyatoslav Ryhel
@ 2026-05-18  6:14 ` Claude Code Review Bot
  2 siblings, 0 replies; 7+ messages in thread
From: Claude Code Review Bot @ 2026-05-18  6:14 UTC (permalink / raw)
  To: dri-devel-reviews

Overall Series Review

Subject: drm/tegra: gr2d/gr3d: Move pm_runtime_enable to gr*d_probe
Author: Svyatoslav Ryhel <clamor95@gmail.com>
Patches: 3
Reviewed: 2026-05-18T16:14:38.227738

---

This is a clean 2-patch series fixing power management lifecycle issues in the Tegra gr2d and gr3d DRM drivers. The changes are straightforward and well-motivated: patch 1 fixes a race between address register map initialization and userspace visibility, and patch 2 moves PM runtime enable/disable from the wrong callbacks (runtime_resume/client_exit) into probe/remove where they belong. The series has an Acked-by from Mikko Perttunen.

The series is correct and should fix the reported resume malfunction. I have a few minor observations but nothing blocking.

---
Generated by Claude Code Patch Reviewer

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

* Claude review: drm/tegra: gr2d/gr3d: Initialize address register map before HOST1X client is registered
  2026-05-17  9:14 ` [PATCH v3 1/2] drm/tegra: gr2d/gr3d: Initialize address register map before HOST1X client is registered Svyatoslav Ryhel
@ 2026-05-18  6:14   ` Claude Code Review Bot
  0 siblings, 0 replies; 7+ messages in thread
From: Claude Code Review Bot @ 2026-05-18  6:14 UTC (permalink / raw)
  To: dri-devel-reviews

Patch Review

**Assessment: Good, no issues.**

This patch moves the `set_bit` loop that populates `addr_regs` from after `host1x_client_register()` to before it, in both gr2d.c and gr3d.c. The rationale is sound: `host1x_client_register()` can make the device available to userspace, and `gr2d_is_addr_reg()`/`gr3d_is_addr_reg()` consult `addr_regs` during job submission validation. An uninitialized bitmap would fail to flag address registers, potentially allowing userspace to bypass address relocation checks.

The initialization depends only on the static `gr2d_addr_regs[]`/`gr3d_addr_regs[]` arrays and the already-allocated `gr2d->addr_regs`/`gr3d->addr_regs` bitmaps, so moving it earlier has no dependency issues.

The diff for both files is symmetric and minimal. No concerns.

---
Generated by Claude Code Patch Reviewer

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

* Claude review: drm/tegra: gr2d/gr3d: Contain PM in the gr*d_probe/gr*d_remove
  2026-05-17  9:14 ` [PATCH v3 2/2] drm/tegra: gr2d/gr3d: Contain PM in the gr*d_probe/gr*d_remove Svyatoslav Ryhel
@ 2026-05-18  6:14   ` Claude Code Review Bot
  0 siblings, 0 replies; 7+ messages in thread
From: Claude Code Review Bot @ 2026-05-18  6:14 UTC (permalink / raw)
  To: dri-devel-reviews

Patch Review

**Assessment: Correct fix with minor observations.**

This patch makes two changes:

1. **Moves `pm_runtime_enable()`, `pm_runtime_use_autosuspend()`, and `pm_runtime_set_autosuspend_delay()` from `gr*d_runtime_resume()` into `gr*d_probe()`.** Having `pm_runtime_enable()` inside the runtime_resume callback was fundamentally wrong — the PM core needs runtime PM to be enabled *before* it can call the resume callback through normal runtime PM operations. Every resume would also redundantly re-configure autosuspend. Moving this to probe is correct.

2. **Removes `pm_runtime_dont_use_autosuspend()` and `pm_runtime_force_suspend()` from `gr*d_exit()`.** The exit callback no longer manages PM lifecycle; this is handled by `pm_runtime_disable()` in `gr*d_remove()`.

**Observations:**

- **Typo in commit message:** `"GR2G/GR3D"` should be `"GR2D/GR3D"`.

- **Ordering relative to other tegra drivers:** The patches place `pm_runtime_enable()` *before* `host1x_client_register()`, which is the safer ordering (avoids a race where userspace submits before PM is enabled). However, the sibling drivers `nvdec.c` and `vic.c` do the opposite — they call `host1x_client_register()` first, then `pm_runtime_enable()`. The new ordering in gr2d/gr3d is arguably more correct, but the inconsistency across the tegra driver family is worth being aware of.

- **Missing `pm_runtime_dont_use_autosuspend()` in remove:** The patch removes `pm_runtime_dont_use_autosuspend()` from `gr*d_exit()` but doesn't add it to `gr*d_remove()` before `pm_runtime_disable()`. The common pattern for drivers using autosuspend is to call `pm_runtime_dont_use_autosuspend()` then `pm_runtime_disable()` in the remove path, to cancel any pending autosuspend timer. In practice, `pm_runtime_disable()` handles cancellation internally, so this is not a bug — just a deviation from the typical pattern. The pre-existing `gr*d_remove()` also lacked it, so this is not a regression.

- **No explicit suspend on removal:** The original `gr*d_exit()` called `pm_runtime_force_suspend()` to ensure the hardware was powered down when the client was torn down. After this patch, if the device is runtime-active when `gr*d_remove()` is called, `pm_runtime_disable()` leaves it active — the clocks stay enabled until devm cleanup. This is acceptable for driver removal but is a minor change in teardown behavior worth noting.

- **Error path in probe:** The error path for `host1x_client_register()` failure correctly calls `pm_runtime_disable()`, which is good:
  ```c
  err = host1x_client_register(&gr2d->client.base);
  if (err < 0) {
      pm_runtime_disable(dev);
      ...
  }
  ```

Overall, this is a well-structured fix for a real resume regression. The minor items above are observations, not blockers.

---
Generated by Claude Code Patch Reviewer

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

end of thread, other threads:[~2026-05-18  6:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-17  9:14 [PATCH v3 0/2] drm/tegra: gr2d/gr3d: Move pm_runtime_enable to gr*d_probe Svyatoslav Ryhel
2026-05-17  9:14 ` [PATCH v3 1/2] drm/tegra: gr2d/gr3d: Initialize address register map before HOST1X client is registered Svyatoslav Ryhel
2026-05-18  6:14   ` Claude review: " Claude Code Review Bot
2026-05-17  9:14 ` [PATCH v3 2/2] drm/tegra: gr2d/gr3d: Contain PM in the gr*d_probe/gr*d_remove Svyatoslav Ryhel
2026-05-18  6:14   ` Claude review: " Claude Code Review Bot
2026-05-18  6:14 ` Claude review: drm/tegra: gr2d/gr3d: Move pm_runtime_enable to gr*d_probe Claude Code Review Bot
  -- strict thread matches above, loose matches on Subject: below --
2026-05-03 16:38 [PATCH v2 0/2] " Svyatoslav Ryhel
2026-05-03 16:38 ` [PATCH v2 2/2] drm/tegra: gr2d/gr3d: Contain PM in the gr*d_probe/gr*d_remove Svyatoslav Ryhel
2026-05-04 22:41   ` Claude review: " 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