dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] drm/nouveau/dmem: fix DMA unmap size and callocated accounting for THP
@ 2026-08-11 14:28 Zhenhao Wan
  2026-08-11 14:28 ` [PATCH 1/2] drm/nouveau/dmem: fix mismatched DMA unmap size for large folios Zhenhao Wan
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Zhenhao Wan @ 2026-08-11 14:28 UTC (permalink / raw)
  To: Lyude Paul, Danilo Krummrich, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Andrew Morton,
	Balbir Singh
  Cc: dri-devel, nouveau, linux-kernel, Zhenhao Wan, Yuhao Jiang,
	stable

Two independent, stable-worthy fixes to the device-private THP migration
path in nouveau, both introduced by commit c32287471077 ("gpu/drm/nouveau:
enable THP support for GPU memory migration") and still present in
mainline.

Patch 1 fixes two dma_unmap_page() sites that pass a literal PAGE_SIZE
instead of the mapped page_size(). For an order > 0 folio this unmaps
less than was mapped and leaks the remainder of the IOMMU/IOVA mapping.

Patch 2 accounts for large-folio splits in the ->folio_split() hook,
which previously left chunk->callocated unchanged. A folio counted once
at allocation (+1) is later freed as N sub-folios (-N), so the unsigned
counter underflows on the first split/free cycle and the chunk leaks.

Both are confined to nouveau and orthogonal to the in-flight "Remove
device private pages from the physical address space" rework, which
touches nouveau_dmem_page_addr()/nouveau_dmem_chunk_alloc()/
nouveau_dmem_fini() rather than these teardown/accounting sites; they
apply and are needed independently.

Signed-off-by: Zhenhao Wan <whi4ed0g@gmail.com>
---
Zhenhao Wan (2):
      drm/nouveau/dmem: fix mismatched DMA unmap size for large folios
      drm/nouveau/dmem: fix callocated underflow on large folio split

 drivers/gpu/drm/nouveau/nouveau_dmem.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
---
base-commit: db2ddb87143519e20a95aa36c60b36107b736a58
change-id: 20260811-b4-nouveau-dmem-thp-fixes-e8ef1afff282

Best regards,
--  
Zhenhao Wan <whi4ed0g@gmail.com>


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

end of thread, other threads:[~2026-09-01 14:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-11 14:28 [PATCH 0/2] drm/nouveau/dmem: fix DMA unmap size and callocated accounting for THP Zhenhao Wan
2026-08-11 14:28 ` [PATCH 1/2] drm/nouveau/dmem: fix mismatched DMA unmap size for large folios Zhenhao Wan
2026-08-11 14:28 ` [PATCH 2/2] drm/nouveau/dmem: fix callocated underflow on large folio split Zhenhao Wan
2026-08-11 21:14   ` lyude
2026-09-01 14:04 ` [PATCH 0/2] drm/nouveau/dmem: fix DMA unmap size and callocated accounting for THP Danilo Krummrich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox