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: dma: coherent: register to coherent heap
Date: Wed, 04 Mar 2026 07:19:21 +1000	[thread overview]
Message-ID: <review-patch5-20260303-b4-dmabuf-heap-coherent-rmem-v2-5-65a4653b3378@redhat.com> (raw)
In-Reply-To: <20260303-b4-dmabuf-heap-coherent-rmem-v2-5-65a4653b3378@redhat.com>

Patch Review

Adds a static array `rmem_coherent_areas[MAX_COHERENT_REGIONS]` in `kernel/dma/coherent.c` to record reserved regions during early boot, then exposes them via `dma_coherent_get_reserved_region()`.

**Issues:**

1. **Fixed-size static array of 64 entries is a design concern.** The `MAX_COHERENT_REGIONS` of 64 is hardcoded with no Kconfig tunability:
```c
+#define MAX_COHERENT_REGIONS 64
+static struct reserved_mem *rmem_coherent_areas[MAX_COHERENT_REGIONS];
```
This wastes memory when unused (most systems have 0-2 coherent regions) and is an arbitrary limit. A dynamic list or leveraging the existing reserved_mem infrastructure would be cleaner. This is similar to how `cma_heap.c` uses `MAX_CMA_AREAS`, but `MAX_CMA_AREAS` is a well-known kernel-wide constant, while `MAX_COHERENT_REGIONS` is newly invented here.

2. **`rmem_coherent_insert_area()` returns `-EINVAL` on overflow** but `-ENOSPC` or `-ENOMEM` would be more semantically correct.

3. **The array is not `__initdata`.** Unlike the CMA heap's `dma_areas` which is `__initdata` (freed after init), `rmem_coherent_areas` persists forever. Since `dma_coherent_get_reserved_region()` is called from `module_init` (which could be called after `__init` section is freed if built as a module), this is actually necessary, but worth noting the permanent memory cost.

4. **`IS_ENABLED(CONFIG_DMABUF_HEAPS_COHERENT)` guard in `rmem_dma_setup()`:**
```c
+	if (IS_ENABLED(CONFIG_DMABUF_HEAPS_COHERENT)) {
```
This is `__init` code. If the coherent heap is built as a module (`=m`), `IS_ENABLED()` returns true, so regions are collected. Good -- this is the correct behavior to support the modular case.

---
Generated by Claude Code Patch Reviewer

  reply	other threads:[~2026-03-03 21:19 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-03 12:33 [PATCH v2 0/6] dma-buf: heaps: add coherent reserved-memory heap Albert Esteve
2026-03-03 12:33 ` [PATCH v2 1/6] dma-buf: dma-heap: Keep track of the heap device struct Albert Esteve
2026-03-03 13:10   ` Maxime Ripard
2026-03-03 21:19   ` Claude review: " Claude Code Review Bot
2026-03-03 12:33 ` [PATCH v2 2/6] dma-buf: dma-heap: split dma_heap_add Albert Esteve
2026-03-03 21:19   ` Claude review: " Claude Code Review Bot
2026-03-03 12:33 ` [PATCH v2 3/6] of_reserved_mem: add a helper for rmem device_init op Albert Esteve
2026-03-03 13:13   ` Maxime Ripard
2026-03-03 21:19   ` Claude review: " Claude Code Review Bot
2026-03-03 12:33 ` [PATCH v2 4/6] dma-buf: heaps: Add Coherent heap to dmabuf heaps Albert Esteve
2026-03-03 13:20   ` Maxime Ripard
2026-03-03 14:47     ` Albert Esteve
2026-03-03 21:19   ` Claude review: " Claude Code Review Bot
2026-03-03 12:33 ` [PATCH v2 5/6] dma: coherent: register to coherent heap Albert Esteve
2026-03-03 21:19   ` Claude Code Review Bot [this message]
2026-03-03 12:33 ` [PATCH v2 6/6] dma-buf: heaps: coherent: Turn heap into a module Albert Esteve
2026-03-03 21:19   ` Claude review: " Claude Code Review Bot
2026-03-03 20:55 ` [PATCH v2 0/6] dma-buf: heaps: add coherent reserved-memory heap John Stultz
2026-03-03 21:19 ` 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-patch5-20260303-b4-dmabuf-heap-coherent-rmem-v2-5-65a4653b3378@redhat.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