From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: Re: [PATCH v2 1/4] accel: rocket: Add support for Rockchip RK3568
Date: Thu, 04 Jun 2026 16:18:11 +1000 [thread overview]
Message-ID: <review-patch1-5132269.NnENhoQgcM@phil> (raw)
In-Reply-To: <5132269.NnENhoQgcM@phil>
Patch Review
**1. Runtime PM gap — `noc_init` not called on resume (significant)**
The `noc_init` callback runs once during `rocket_core_init()`, after `pm_runtime_resume_and_get()`. But `rocket_device_runtime_resume()` only re-enables clocks — it does not re-run the NOC de-idle sequence. If runtime PM suspends the device (disabling clocks), and the NOC bus re-idles or the PVTPLL state is lost, the next `pm_runtime_resume_and_get()` will not re-initialize the bus.
The cover letter says `RK3568_PD_NPU` is `always_on` so genpd never powers it off, which might save you here for runtime PM. But for system suspend/resume (`pm_runtime_force_suspend` / `pm_runtime_force_resume`), the hardware state is very likely lost. This should be addressed — either by hooking `noc_init` into the runtime resume path, or by documenting why it's not needed.
**2. `clk_set_rate()` return values unchecked**
```c
clk_set_rate(core->clks[ROCKET_CLK_NPU_IDX].clk, 600000000UL);
clk_set_rate(core->clks[ROCKET_CLK_NPU_IDX].clk, 1000000000UL);
```
Both calls return `int` but the return is ignored. If the SCMI clock set fails (e.g., TF-A doesn't support the rate), the function silently proceeds to PMU writes on a bus that may not be ready. Check and propagate the error.
**3. `regmap_write()` return values unchecked**
```c
regmap_write(pmu, 0x70, BIT(2 + 16));
regmap_write(pmu, 0xa0, BIT(1 + 16));
regmap_write(pmu, 0x50, BIT(2 + 16));
```
`regmap_write()` can fail. While failures on MMIO-backed regmaps are rare, checking returns is good practice, especially for a sequence where ordering matters.
**4. Hardcoded PMU register offsets**
The magic numbers `0x70`, `0xa0`, `0x50`, `0x60` are explained in comments but should be `#define` constants:
```c
#define RK3568_PMU_BUS_IDLE_SFTCON0 0x50
#define RK3568_PMU_BUS_IDLE_ST 0x60
#define RK3568_PMU_NOC_AUTO_CON0 0x70
#define RK3568_PMU_PWR_GATE_SFTCON 0xa0
```
This makes the code self-documenting and greppable.
**5. Fragile PVTPLL two-step clock workaround**
```c
clk_set_rate(core->clks[ROCKET_CLK_NPU_IDX].clk, 600000000UL);
clk_set_rate(core->clks[ROCKET_CLK_NPU_IDX].clk, 1000000000UL);
```
This depends on the kernel clock framework treating 600 MHz → 1 GHz as a real rate change that triggers an SCMI call. If the clock framework or SCMI driver optimizes this differently in the future (e.g., cached rate tracking changes), this breaks silently. The comment explains the rationale well, but this is inherently fragile. Consider whether the SCMI clock driver exposes a way to force a firmware call, or whether `clk_set_rate(0)` + `clk_set_rate(target)` is more robust.
**6. Scoped block in `rocket_device_init` — non-idiomatic kernel style**
```c
{
struct device_node *n;
unsigned int dma_bits = 40;
for_each_compatible_node(n, NULL, "rockchip,rk3568-rknn-core")
...
}
```
Linux kernel style discourages bare scoped blocks for variable scoping. Extract this into a small helper function (e.g., `rocket_get_dma_bits()`) or declare variables at function scope.
**7. `ROCKET_CLK_NPU_IDX` relies on implicit array ordering**
```c
#define ROCKET_CLK_NPU_IDX 2
```
The `clks[]` array is populated by `devm_clk_bulk_get()` which fills entries by DT index. This works today because the DT binding mandates `clock-names = "aclk", "hclk", "npu", "pclk"` in that order. But the coupling between a `#define` in `rocket_drv.c` and the DT binding ordering is fragile and not obvious. A comment cross-referencing the binding, or better yet using `devm_clk_get(dev, "npu")` for just this one clock, would be safer.
**8. Cleanup path after `noc_init` failure**
```c
if (core->soc_data->noc_init) {
err = core->soc_data->noc_init(core);
if (err) {
pm_runtime_put_sync(dev);
rocket_job_fini(core);
return err;
}
}
```
This cleans up `rocket_job` and drops the runtime PM ref, but doesn't clean up IOMMU group (`iommu_group_put`) or disable runtime PM (`pm_runtime_disable`). Compare the existing error path after `pm_runtime_resume_and_get()` fails, which calls `rocket_core_fini()` — the `noc_init` failure path should be consistent.
---
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-06-04 6:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-29 15:58 [PATCH v2 0/4] accel: rocket: Add RK3568 NPU support MidG971
2026-05-29 15:58 ` [PATCH v2 1/4] accel: rocket: Add support for Rockchip RK3568 MidG971
2026-05-29 18:19 ` Heiko Stuebner
2026-06-04 6:18 ` Claude Code Review Bot [this message]
2026-05-29 15:58 ` [PATCH v2 2/4] dt-bindings: npu: rockchip, rk3588-rknn-core: Add RK3568 support MidG971
2026-05-29 16:18 ` [PATCH v2 2/4] dt-bindings: npu: rockchip,rk3588-rknn-core: " Krzysztof Kozlowski
2026-06-04 6:18 ` Claude review: " Claude Code Review Bot
2026-05-29 15:58 ` [PATCH v2 3/4] arm64: dts: rockchip: rk356x: Add NPU and its IOMMU MidG971
2026-06-04 6:18 ` Claude review: " Claude Code Review Bot
2026-05-29 15:58 ` [PATCH v2 4/4] arm64: dts: rockchip: rk3568-rock-3b: Enable NPU MidG971
2026-06-04 6:18 ` Claude review: " Claude Code Review Bot
2026-05-29 16:17 ` [PATCH v2 0/4] accel: rocket: Add RK3568 NPU support Krzysztof Kozlowski
2026-06-04 6:18 ` Claude review: " Claude Code Review Bot
2026-05-29 18:04 ` Heiko Stuebner
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-patch1-5132269.NnENhoQgcM@phil \
--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