From 902c0c5fd8ff49830dd67059c6631211196d81ee Mon Sep 17 00:00:00 2001 From: Vaggelis Date: Mon, 24 Aug 2026 11:48:35 -0400 Subject: [PATCH] nvidia-drm: return -ENOSYS when PRIME sg_table is unavailable Vidmem-backed NvKmsKapiMemory has no struct pages, so __nv_drm_gem_nvkms_memory_prime_get_sg_table() can never build an sg_table for it. It returned ERR_PTR(-ENOMEM), which propagates unchanged through dma_buf_map_attachment() to the importing driver, so a cross-device PRIME import of a vidmem GEM object reports an out-of-memory condition that never happened. On multi-GPU systems this makes compositors treat an unsupported export as memory exhaustion and abort (#1302). Return -ENOSYS instead, matching the value drm_prime.c uses when a GEM object has no get_sg_table implementation. The errno is the only change: no caller in nvidia-drm switches on the old value, and real allocation failures on this path still return -ENOMEM from their own sites. Test Plan: No build or runtime test possible in the preparation environment (no Linux kernel toolchain, no NVIDIA GPU). Verified statically: git diff --stat : 1 file changed, 1 insertion(+), 1 deletion(-) pages_count == 0 occurs only for vidmem-backed objects; sysmem objects whose page list cannot be built fail at object init. No caller under kernel-open/nvidia-drm branches on the errno value; DRM core forwards PTR_ERR unchanged to the importer. --- kernel-open/nvidia-drm/nvidia-drm-gem-nvkms-memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel-open/nvidia-drm/nvidia-drm-gem-nvkms-memory.c b/kernel-open/nvidia-drm/nvidia-drm-gem-nvkms-memory.c index 0785dddf2a..bb91c6fcb7 100644 --- a/kernel-open/nvidia-drm/nvidia-drm-gem-nvkms-memory.c +++ b/kernel-open/nvidia-drm/nvidia-drm-gem-nvkms-memory.c @@ -381,7 +381,7 @@ static struct sg_table *__nv_drm_gem_nvkms_memory_prime_get_sg_table( nv_dev, "Cannot create sg_table for NvKmsKapiMemory 0x%p", nv_gem->pMemory); - return ERR_PTR(-ENOMEM); + return ERR_PTR(-ENOSYS); } sg_table = nv_drm_prime_pages_to_sg(nv_dev->dev,