On Thu, Nov 12, 2026 at 01:58:22PM +0100, Christian König wrote: > On 11/12/26 13:20, Matthew Auld wrote: > > Every GEM/TTM buffer object, including imported dma-bufs, allocates a > > fake mmap offset from the per-device drm_vma_offset_manager. On multi-GPU > > systems with large VRAM, peer-to-peer dma-buf imports across devices and > > processes can exhaust the current 1 TiB 64-bit range and fail BO creation > > or PRIME import with -ENOSPC. Skipping mmap offset allocation for > > imported sg buffers is not straightforward without risking userspace > > regressions, as existing userspace (such as Intel compute-runtime) still > > queries mmap_offset on imported host dma-bufs even when mapping the > > dma-buf fd directly. > > I was just about to ask why the heck we grab mmap offsets for imported > DMA-bufs :) > > > Increase DRM_FILE_PAGE_OFFSET_SIZE on 64-bit kernels so the fake offset > > range spans up to 8 TiB (SZ_8T). This stays strictly below panthor's > > DRM_PANTHOR_USER_MMIO_OFFSET_32BIT (1ULL << 43) carveout and within > > 32-bit compat mmap2's pgoff limit (16 TiB with 4K pages). > > > > Signed-off-by: Matthew Auld <[email protected]> > > Cc: Thomas Hellström <[email protected]> > > Cc: Christian König <[email protected]> > > Cc: Matthew Brost <[email protected]>
Reviewed-by: Matthew Brost <[email protected]> > > Acked-by: Christian König <[email protected]> > > > --- > > include/drm/drm_vma_manager.h | 13 ++++++++++--- > > 1 file changed, 10 insertions(+), 3 deletions(-) > > > > diff --git a/include/drm/drm_vma_manager.h b/include/drm/drm_vma_manager.h > > index 6c2a2f21dbf0..2c3233f9dec4 100644 > > --- a/include/drm/drm_vma_manager.h > > +++ b/include/drm/drm_vma_manager.h > > @@ -26,16 +26,23 @@ > > #include <drm/drm_mm.h> > > #include <linux/mm.h> > > #include <linux/rbtree.h> > > +#include <linux/sizes.h> > > #include <linux/spinlock.h> > > #include <linux/types.h> > > > > -/* We make up offsets for buffer objects so we can recognize them at > > +/* > > + * We make up offsets for buffer objects so we can recognize them at > > * mmap time. pgoff in mmap is an unsigned long, so we need to make sure > > - * that the faked up offset will fit > > + * that the faked up offset will fit. > > + * > > + * On 64-bit, cap the range at 8 TiB (SZ_8T) so offsets remain below both > > + * panthor's DRM_PANTHOR_USER_MMIO_OFFSET_32BIT (1ULL << 43) and 32-bit > > + * compat mmap2's pgoff ceiling (16 TiB with 4K pages). > > */ > > #if BITS_PER_LONG == 64 > > #define DRM_FILE_PAGE_OFFSET_START ((0xFFFFFFFFUL >> PAGE_SHIFT) + 1) > > -#define DRM_FILE_PAGE_OFFSET_SIZE ((0xFFFFFFFFUL >> PAGE_SHIFT) * 256) > > +#define DRM_FILE_PAGE_OFFSET_SIZE ((SZ_8T >> PAGE_SHIFT) - \ > > + DRM_FILE_PAGE_OFFSET_START) > > #else > > #define DRM_FILE_PAGE_OFFSET_START ((0xFFFFFFFUL >> PAGE_SHIFT) + 1) > > #define DRM_FILE_PAGE_OFFSET_SIZE ((0xFFFFFFFUL >> PAGE_SHIFT) * 16) >
