From: sashiko-bot@kernel.org
To: "Mikko Perttunen" <mperttunen@nvidia.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 06/19] drm/nouveau/mmu: Set cpu_coherent flag at runtime for Tegra
Date: Wed, 02 Dec 2026 05:47:11 +0000 [thread overview]
Message-ID: <sashiko-outbox-244925@kernel.org> (raw)
In-Reply-To: <20261202-nouveau-gv11b-v1-6-758af3553ef6@nvidia.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] drm/nouveau: nouveau_mem_host() strips tiling kind when
cpu_coherent is true
- [Medium] drm/nouveau: O(num_pages) BO sync walk on coherent Tegra GPUs
--
commit 6e65389fed688faafffbc080e5859978ba3c0045
Author: Mikko Perttunen <mperttunen@nvidia.com>
drm/nouveau/mmu: Set cpu_coherent flag at runtime for Tegra
This commit moves cpu_coherent from nvkm_device_func to nvkm_device and
sets it at runtime on Tegra based on the device's DMA coherency attribute.
> diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c
> index 74b292659ee9a..c04006d38c64f 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c
[ ... ]
> @@ -339,6 +340,9 @@ nvkm_device_tegra_new(const struct nvkm_device_tegra_func *func,
>
> tdev->gpu_speedo = tegra_sku_info.gpu_speedo_value;
> tdev->gpu_speedo_id = tegra_sku_info.gpu_speedo_id;
> + tdev->device.cpu_coherent =
> + device_get_dma_attr(&pdev->dev) == DEV_DMA_COHERENT;
> +
> ret = nvkm_device_ctor(&nvkm_device_tegra_func, NULL, &pdev->dev,
> NVKM_DEVICE_TEGRA, pdev->id, NULL,
> cfg, dbg, &tdev->device);
[Severity: High]
Does setting cpu_coherent = true on Tegra cause nouveau_mem_host() to
strip mem->kind and mem->comp from tiled buffers?
When device->cpu_coherent is true, nvkm_mmu_host() registers the coherent
cached host memory type (drm->ttm.type_host[0]) with NVKM_MEM_KIND masked
off and without NVKM_MEM_UNCACHED, which makes
nouveau_drm_use_coherent_gpu_mapping(drm) return true. Because Tegra has
no dedicated VRAM, all buffers are bound via nouveau_mem_host():
drivers/gpu/drm/nouveau/nouveau_mem.c:nouveau_mem_host() {
...
if (!nouveau_drm_use_coherent_gpu_mapping(drm))
type = drm->ttm.type_ncoh[!!mem->kind];
else
type = drm->ttm.type_host[0];
if (mem->kind && !(mmu->type[type].type & NVIF_MEM_KIND))
mem->comp = mem->kind = 0;
...
}
Instead of selecting drm->ttm.type_ncoh[1] for tiled buffers,
nouveau_mem_host() picks drm->ttm.type_host[0] and clears mem->kind and
mem->comp to 0, mapping block-linear buffers as linear in the GPU MMU and
causing misrendering.
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c
> index df86214183cc7..7c45efdf3952b 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c
> @@ -304,7 +304,7 @@ nvkm_mmu_host(struct nvkm_mmu *mmu)
> * done through BAR1.
> */
> type |= NVKM_MEM_COHERENT;
> - if (device->func->cpu_coherent)
> + if (device->cpu_coherent)
> nvkm_mmu_type(mmu, heap, type & ~NVKM_MEM_KIND);
>
> /* Uncached system memory. */
[Severity: Medium]
When device->cpu_coherent makes nouveau_drm_use_coherent_gpu_mapping(drm)
return true on Tegra, do nouveau_bo_sync_for_device() and
nouveau_bo_sync_for_cpu() end up walking every page of
NOUVEAU_GEM_DOMAIN_COHERENT buffers?
In nouveau_bo_alloc(), nvbo->force_coherent is only set when
!nouveau_drm_use_coherent_gpu_mapping(drm):
drivers/gpu/drm/nouveau/nouveau_bo.c:nouveau_bo_alloc() {
...
if (domain & NOUVEAU_GEM_DOMAIN_COHERENT) {
/* Determine if we can get a cache-coherent map, forcing
* uncached mapping if we can't.
*/
if (!nouveau_drm_use_coherent_gpu_mapping(drm))
nvbo->force_coherent = true;
}
...
}
However, nouveau_bo_sync_for_device() and nouveau_bo_sync_for_cpu() only
check if (nvbo->force_coherent) for their early return. With
nvbo->force_coherent left false on coherent Tegra GPUs, coherent buffer
objects fall through to the loop over all ttm_dma->num_pages pages on
every BO validation and CPU prep/fini ioctl.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202-nouveau-gv11b-v1-0-758af3553ef6@nvidia.com?part=6
next prev parent reply other threads:[~2026-12-02 5:47 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 5:24 [PATCH 00/19] drm/nouveau: Enable the GV11B GPU on Tegra194 Mikko Perttunen
2026-12-02 5:24 ` [PATCH 01/19] drm/nouveau/fault: Widen engine field Mikko Perttunen
2026-12-02 5:43 ` sashiko-bot
2026-12-02 5:24 ` [PATCH 02/19] drm/nouveau/fault: Mask off instance aperture bits in GV100 fault-buffer entries Mikko Perttunen
2026-12-02 5:33 ` sashiko-bot
2026-12-02 5:24 ` [PATCH 03/19] drm/nouveau: Add helpers for getting memory target's aperture Mikko Perttunen
2026-12-02 5:24 ` [PATCH 04/19] drm/nouveau: Program aperture field where necessary Mikko Perttunen
2026-12-02 5:24 ` [PATCH 05/19] drm/nouveau: Supply aperture to FECS context methods Mikko Perttunen
2026-12-02 5:24 ` [PATCH 06/19] drm/nouveau/mmu: Set cpu_coherent flag at runtime for Tegra Mikko Perttunen
2026-12-02 5:47 ` sashiko-bot [this message]
2026-12-02 5:24 ` [PATCH 07/19] drm/nouveau/instmem: Use the coherent aperture for DMA-coherent Tegra allocations Mikko Perttunen
2026-12-02 5:24 ` [PATCH 08/19] drm/nouveau: Use coherent firmware mappings on coherent Tegra devices Mikko Perttunen
2026-12-02 5:24 ` [PATCH 09/19] drm/nouveau/fifo: Allow coherent host pages for USERD Mikko Perttunen
2026-12-02 5:24 ` [PATCH 10/19] drm/nouveau: Allocate Volta USERD in host memory on VRAM-less GPUs Mikko Perttunen
2026-12-02 5:24 ` [PATCH 11/19] drm/nouveau/bar: Add a GPU-only BAR2 address space for GV11B Mikko Perttunen
2026-12-02 5:24 ` [PATCH 12/19] drm/nouveau/fifo: Map Volta copy-engine method buffers in GPU-only BAR2 Mikko Perttunen
2026-12-02 5:24 ` [PATCH 13/19] drm/nouveau/fault: Support physical addresses for GV100 fault buffers Mikko Perttunen
2026-12-02 5:24 ` [PATCH 14/19] drm/nouveau: Add GV11B chipset/MMU/devfreq configuration data Mikko Perttunen
2026-12-02 5:24 ` [PATCH 15/19] drm/nouveau: Add ACR loader and PMU firmware boot on GV11B Mikko Perttunen
2026-12-02 5:24 ` [PATCH 16/19] drm/nouveau/gr: Wait for FECS watchdog timeout init completion Mikko Perttunen
2026-12-02 5:24 ` [PATCH 17/19] drm/nouveau: Add GR firmware and context support for GV11B Mikko Perttunen
2026-12-02 5:24 ` [PATCH 18/19] drm/nouveau/tegra: Separate DMA mask width from the IOMMU address bit Mikko Perttunen
2026-12-02 5:24 ` [PATCH 19/19] drm/nouveau/tegra: Add device tree compatible for GV11B Mikko Perttunen
2026-12-02 5:51 ` sashiko-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=sashiko-outbox-244925@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=mperttunen@nvidia.com \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.