From nobody Tue Feb 10 11:24:00 2026 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 70A4D1D63C9 for ; Sun, 2 Feb 2025 13:45:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.63.210.85 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738503916; cv=none; b=nGWNLPy+2PM44ydKC6HKz0LhzNkZNiqCCO1dbO9rt4pDtib72y83pTKnomm2ka30qN9d9ldBryxTR/T2wIYtMCh2bbqtGeh/QtuuIYjys0lbRG4KU/+kLET2fe+Vc+z4lKibYwC0cFOyFH3ZHvFF6r/3YUaj/r72hVTlEeI4DLk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738503916; c=relaxed/simple; bh=uu52xMGokrDDgENtthfQJ71LyZloD14w6rOxRrrh344=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Atq0bQO4N1hGPDgobIdLQzuyXOC6//kr+YPJybUDvW4GCapSsCcjCeDXKtDrNhKYDsnhqKCaTGP513CZgt4TKeaGnR2faJ3kMJRNvW85DrDIMFqRM5msSaO2u2V4LGs7ml6phd1VaONc0naDgBpgsqi+DKhBVMoLoj5bSQLg+rA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=asahilina.net; spf=pass smtp.mailfrom=asahilina.net; dkim=pass (2048-bit key) header.d=asahilina.net header.i=@asahilina.net header.b=uD0v39eA; arc=none smtp.client-ip=212.63.210.85 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=asahilina.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=asahilina.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=asahilina.net header.i=@asahilina.net header.b="uD0v39eA" Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sendonly@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id 9CE30426E2; Sun, 2 Feb 2025 13:45:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=asahilina.net; s=default; t=1738503912; bh=uu52xMGokrDDgENtthfQJ71LyZloD14w6rOxRrrh344=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=uD0v39eASsjcf1/3SXk5cmzdi4EhXYnO7sVMISYU13gDT7VcjsfmoLzKdqlUGLKHj PtSwxIcHvYP17ei55bcX+FvkNaA1p61nuMtlbVQN3PzN4Ltm+nwo47Yt/iS1dkZ1pa j68AmpGGGIZFcRZy71jFo9A2nVRnPpynE/Upt+PfYBNK44u0b0SUGoxQFgIxPqt3r0 lJwDu5st9ljEUeI5DJT3bfiDXF3+xzt9LjQ5NprGlwhdyC98KaKvCYSOdb1SDFcMzX CW69PJpAh8I2fLvbOa6nAHHxUUzXgeRoTt0guPesw5bquoouV6kVd11pgWOVNB5h5Z vjjeEswiIKQDQ== From: Asahi Lina Date: Sun, 02 Feb 2025 22:34:50 +0900 Subject: [PATCH 1/4] drm/gpuvm: Add a flags argument to drm_gpuvm_sm_map[_*] Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250202-gpuvm-single-page-v1-1-8cbd44fdcbd4@asahilina.net> References: <20250202-gpuvm-single-page-v1-0-8cbd44fdcbd4@asahilina.net> In-Reply-To: <20250202-gpuvm-single-page-v1-0-8cbd44fdcbd4@asahilina.net> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Frank Binns , Matt Coster , Karol Herbst , Lyude Paul , Danilo Krummrich , Boris Brezillon , Steven Price , Liviu Dudau , Lucas De Marchi , =?utf-8?q?Thomas_Hellstr=C3=B6m?= , Rodrigo Vivi Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org, intel-xe@lists.freedesktop.org, asahi@lists.linux.dev, Asahi Lina X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1738503908; l=5456; i=lina@asahilina.net; s=20240902; h=from:subject:message-id; bh=uu52xMGokrDDgENtthfQJ71LyZloD14w6rOxRrrh344=; b=C9WT1JzSXVS8oXNUsibvBt3bied9shp4kP5FTP0VMuo5Qk8Rez4F3DdxZyQlD5cqz2SnBJ2kF UCP+cz0Ar4xBqSxG/kmEYB912yJQDgnkqlN1duZfiu1GFLzqraxIwCC X-Developer-Key: i=lina@asahilina.net; a=ed25519; pk=tpv7cWfUnHNw5jwf6h4t0gGgglt3/xcwlfs0+A/uUu8= drm_gpuva objects have a flags field. Currently, this can be managed by drivers out-of-band, without any special handling in drm_gpuvm. To be able to introduce flags that do affect the logic in the drm_gpuvm core, we need to plumb it through the map calls. This will allow the core to check the flags on map and alter the merge/split logic depending on the requested flags and the flags of the existing drm_gpuva ranges that are being split. First, just add the argument to the API and do nothing with it. Signed-off-by: Asahi Lina --- drivers/gpu/drm/drm_gpuvm.c | 6 ++++-- drivers/gpu/drm/imagination/pvr_vm.c | 3 ++- drivers/gpu/drm/nouveau/nouveau_uvmm.c | 3 ++- drivers/gpu/drm/panthor/panthor_mmu.c | 3 ++- drivers/gpu/drm/xe/xe_vm.c | 3 ++- include/drm/drm_gpuvm.h | 6 ++++-- 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/drm_gpuvm.c b/drivers/gpu/drm/drm_gpuvm.c index f9eb56f24bef291e084a15d844d4ececda8412d9..9733460d737667035541b488657= 154afb56872e3 100644 --- a/drivers/gpu/drm/drm_gpuvm.c +++ b/drivers/gpu/drm/drm_gpuvm.c @@ -2333,7 +2333,8 @@ __drm_gpuvm_sm_unmap(struct drm_gpuvm *gpuvm, int drm_gpuvm_sm_map(struct drm_gpuvm *gpuvm, void *priv, u64 req_addr, u64 req_range, - struct drm_gem_object *req_obj, u64 req_offset) + struct drm_gem_object *req_obj, u64 req_offset, + enum drm_gpuva_flags req_flags) { const struct drm_gpuvm_ops *ops =3D gpuvm->ops; =20 @@ -2516,7 +2517,8 @@ static const struct drm_gpuvm_ops gpuvm_list_ops =3D { struct drm_gpuva_ops * drm_gpuvm_sm_map_ops_create(struct drm_gpuvm *gpuvm, u64 req_addr, u64 req_range, - struct drm_gem_object *req_obj, u64 req_offset) + struct drm_gem_object *req_obj, u64 req_offset, + enum drm_gpuva_flags req_flags) { struct drm_gpuva_ops *ops; struct { diff --git a/drivers/gpu/drm/imagination/pvr_vm.c b/drivers/gpu/drm/imagina= tion/pvr_vm.c index 363f885a709826efa3d45a906c5f65131f7ed7b9..c57c7adcbe987dfc559bc00fc24= 862f5d99bbc0e 100644 --- a/drivers/gpu/drm/imagination/pvr_vm.c +++ b/drivers/gpu/drm/imagination/pvr_vm.c @@ -190,7 +190,8 @@ static int pvr_vm_bind_op_exec(struct pvr_vm_bind_op *b= ind_op) bind_op, bind_op->device_addr, bind_op->size, gem_from_pvr_gem(bind_op->pvr_obj), - bind_op->offset); + bind_op->offset, + 0); =20 case PVR_VM_BIND_TYPE_UNMAP: return drm_gpuvm_sm_unmap(&bind_op->vm_ctx->gpuvm_mgr, diff --git a/drivers/gpu/drm/nouveau/nouveau_uvmm.c b/drivers/gpu/drm/nouve= au/nouveau_uvmm.c index 48f105239f42d8ffa3cefd253bd83d52dbb3255f..d548154c0a38c08c74cfbb9c66d= 703699d8d882b 100644 --- a/drivers/gpu/drm/nouveau/nouveau_uvmm.c +++ b/drivers/gpu/drm/nouveau/nouveau_uvmm.c @@ -1304,7 +1304,8 @@ nouveau_uvmm_bind_job_submit(struct nouveau_job *job, op->va.addr, op->va.range, op->gem.obj, - op->gem.offset); + op->gem.offset, + 0); if (IS_ERR(op->ops)) { ret =3D PTR_ERR(op->ops); goto unwind_continue; diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/pantho= r/panthor_mmu.c index a49132f3778b3a7a0855de37e4ab008e9476f740..ebfb399af8752afdd26c33723b8= ac6f616d02fc5 100644 --- a/drivers/gpu/drm/panthor/panthor_mmu.c +++ b/drivers/gpu/drm/panthor/panthor_mmu.c @@ -2155,7 +2155,8 @@ panthor_vm_exec_op(struct panthor_vm *vm, struct pant= hor_vm_op_ctx *op, } =20 ret =3D drm_gpuvm_sm_map(&vm->base, vm, op->va.addr, op->va.range, - op->map.vm_bo->obj, op->map.bo_offset); + op->map.vm_bo->obj, op->map.bo_offset, + 0); break; =20 case DRM_PANTHOR_VM_BIND_OP_TYPE_UNMAP: diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c index c99380271de62f8659fdd909a5bd9980d09de4d9..2d1fde089c382c363e354200cfb= 0281869b97f56 100644 --- a/drivers/gpu/drm/xe/xe_vm.c +++ b/drivers/gpu/drm/xe/xe_vm.c @@ -1926,7 +1926,8 @@ vm_bind_ioctl_ops_create(struct xe_vm *vm, struct xe_= bo *bo, case DRM_XE_VM_BIND_OP_MAP: case DRM_XE_VM_BIND_OP_MAP_USERPTR: ops =3D drm_gpuvm_sm_map_ops_create(&vm->gpuvm, addr, range, - obj, bo_offset_or_userptr); + obj, bo_offset_or_userptr, + 0); break; case DRM_XE_VM_BIND_OP_UNMAP: ops =3D drm_gpuvm_sm_unmap_ops_create(&vm->gpuvm, addr, range); diff --git a/include/drm/drm_gpuvm.h b/include/drm/drm_gpuvm.h index 00d4e43b76b6c12e10e422d250ab0ac1c9009bc5..cb045378803646a9645c002c571= 83c915d35befb 100644 --- a/include/drm/drm_gpuvm.h +++ b/include/drm/drm_gpuvm.h @@ -1056,7 +1056,8 @@ struct drm_gpuva_ops { struct drm_gpuva_ops * drm_gpuvm_sm_map_ops_create(struct drm_gpuvm *gpuvm, u64 addr, u64 range, - struct drm_gem_object *obj, u64 offset); + struct drm_gem_object *obj, u64 offset, + enum drm_gpuva_flags flags); struct drm_gpuva_ops * drm_gpuvm_sm_unmap_ops_create(struct drm_gpuvm *gpuvm, u64 addr, u64 range); @@ -1201,7 +1202,8 @@ struct drm_gpuvm_ops { =20 int drm_gpuvm_sm_map(struct drm_gpuvm *gpuvm, void *priv, u64 addr, u64 range, - struct drm_gem_object *obj, u64 offset); + struct drm_gem_object *obj, u64 offset, + enum drm_gpuva_flags flags); =20 int drm_gpuvm_sm_unmap(struct drm_gpuvm *gpuvm, void *priv, u64 addr, u64 range); --=20 2.47.1