public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/v3d: Allocate all resources before enabling the clock
Date: Sat, 14 Feb 2026 07:21:53 +1000	[thread overview]
Message-ID: <review-patch6-20260213-v3d-power-management-v5-6-7a8b381eb379@igalia.com> (raw)
In-Reply-To: <20260213-v3d-power-management-v5-6-7a8b381eb379@igalia.com>

Patch Review

This is the key restructuring patch. It reorders probe so that resource allocation happens before clock enable, and hardware initialization happens after.

Looking at the new probe ordering:
1. Register mappings (hub, core0, sms, gca, bridge)
2. Reset control and clock acquisition
3. `v3d_irq_init()` -- requests IRQs but no longer clears pending or enables
4. `v3d_perfmon_init()`
5. MMU scratch page allocation
6. `v3d_gem_init()` -- no longer does HW init
7. `clk_prepare_enable()` -- hardware access begins here
8. SMS idle, HW ident reads, `v3d_init_hw_state()`, `v3d_mmu_set_page_table()`, `v3d_irq_enable()`
9. `drm_dev_register()`

The separation of `v3d_irq_init()` (IRQ request only) from `v3d_irq_enable()` (HW register writes) is well done:

> -	/* Clear any pending interrupts someone might have left around
> -	 * for us.
> -	 */
> -	for (core = 0; core < v3d->cores; core++)
> -		V3D_CORE_WRITE(core, V3D_CTL_INT_CLR, V3D_CORE_IRQS(v3d->ver));
> -	V3D_WRITE(V3D_HUB_INT_CLR, V3D_HUB_IRQS(v3d->ver));

This pending interrupt clear is moved into `v3d_irq_enable()`:

> +	/* Clear any pending interrupts someone might have left around for us. */
> +	for (core = 0; core < v3d->cores; core++)
> +		V3D_CORE_WRITE(core, V3D_CTL_INT_CLR, V3D_CORE_IRQS(v3d->ver));
> +	V3D_WRITE(V3D_HUB_INT_CLR, V3D_HUB_IRQS(v3d->ver));

This is correct because `v3d_irq_enable()` is now called after `v3d->cores` is set from the hardware ident register.

However, there is a concern about the error cleanup path:

> +clk_disable:
> +	v3d_power_off_sms(v3d);
> +	clk_disable_unprepare(v3d->clk);
>  gem_destroy:
>  	v3d_gem_destroy(drm);
>  dma_free:
>  	dma_free_wc(dev, 4096, v3d->mmu_scratch, v3d->mmu_scratch_paddr);
> -clk_disable:
> -	clk_disable_unprepare(v3d->clk);
>  	return ret;

If `drm_dev_register()` or `v3d_sysfs_init()` fails, the error path jumps to `irq_disable` then falls through to `clk_disable`, `gem_destroy`, `dma_free`. But if `dma_set_mask_and_coherent()` fails (which goes to `clk_disable`), the path is `clk_disable` -> `gem_destroy` -> `dma_free`. This ordering is correct: clock off, then gem destroy, then free DMA memory.

The remove function ordering also matches:

> +	v3d_power_off_sms(v3d);
> +	clk_disable_unprepare(v3d->clk);
> +	v3d_gem_destroy(drm);
> +	dma_free_wc(dev, 4096, v3d->mmu_scratch, v3d->mmu_scratch_paddr);

This looks correct -- power off before freeing software resources.

One small note: there's a double blank line after the new `v3d_init_hw_state()` function definition in v3d_gem.c:

> +void
> +v3d_init_hw_state(struct v3d_dev *v3d)
> +{
> +	v3d_init_core(v3d, 0);
> +}
> +
> +

Minor style nit, not a correctness issue.

---
Generated by Claude Code Patch Reviewer

  reply	other threads:[~2026-02-13 21:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-13 18:52 [PATCH v5 0/7] Power Management for Raspberry Pi V3D GPU Maíra Canal
2026-02-13 18:52 ` [PATCH v5 1/7] clk: bcm: rpi: Let V3D consumers manage clock rate Maíra Canal
2026-02-13 21:21   ` Claude review: " Claude Code Review Bot
2026-02-13 18:52 ` [PATCH v5 2/7] clk: bcm: rpi: Add a comment about RPI_FIRMWARE_SET_CLOCK_STATE behavior Maíra Canal
2026-02-13 21:21   ` Claude review: " Claude Code Review Bot
2026-02-13 18:52 ` [PATCH v5 3/7] clk: bcm: rpi: Mark PIXEL_CLK and HEVC_CLK as CLK_IGNORE_UNUSED Maíra Canal
2026-02-13 21:21   ` Claude review: " Claude Code Review Bot
2026-02-13 18:52 ` [PATCH v5 4/7] pmdomain: bcm: bcm2835-power: Increase ASB control timeout Maíra Canal
2026-02-13 21:21   ` Claude review: " Claude Code Review Bot
2026-02-13 18:52 ` [PATCH v5 5/7] drm/v3d: Use devm_reset_control_get_optional_exclusive() Maíra Canal
2026-02-13 21:21   ` Claude review: " Claude Code Review Bot
2026-02-13 18:52 ` [PATCH v5 6/7] drm/v3d: Allocate all resources before enabling the clock Maíra Canal
2026-02-13 21:21   ` Claude Code Review Bot [this message]
2026-02-13 18:53 ` [PATCH v5 7/7] drm/v3d: Introduce Runtime Power Management Maíra Canal
2026-02-13 21:21   ` Claude review: " Claude Code Review Bot
2026-02-13 21:21 ` Claude review: Power Management for Raspberry Pi V3D GPU Claude Code Review Bot
  -- strict thread matches above, loose matches on Subject: below --
2026-03-12 21:34 [PATCH v7 0/5] " Maíra Canal
2026-03-12 21:34 ` [PATCH v7 4/5] drm/v3d: Allocate all resources before enabling the clock Maíra Canal
2026-03-13  3:47   ` 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-patch6-20260213-v3d-power-management-v5-6-7a8b381eb379@igalia.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