drm/panthor: Allow exporting BOs with an exclusive VM
Subsystems (3)
PATCH 1/1 drm/panthor: Allow exporting BOs with an exclusive VM
Panthor currently does not allow exporting BOs with an exclusive VM. However, VDRM (native context) drivers export BOs for import by the guest VM, which does not attempt to bind them to any GPU VM.
Allow these BOs to be exported and rely on panthor_vm_prepare_map_op_ctx() to reject attempts to bind them to a different GPU VM.
--- drivers/gpu/drm/panthor/panthor_gem.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/gpu/drm/panthor/panthor_gem.c +0 -4
@@ -573,10 +573,6 @@ panthor_gem_prime_export(struct drm_gem_object *obj, int flags) .resv = obj->resv, }; -/* We can't export GEMs that have an exclusive VM. */ -if (to_panthor_bo (obj)->exclusive_vm_root_gem) -return ERR_PTR (-EINVAL ); -return drm_gem_dmabuf_export (dev, &exp_info); }
Signature · 1 line
2.55.0
Hi Igor,
Quoted 7 lines · Igor Torrente
Panthor currently does not allow exporting BOs with an exclusive VM. However, VDRM (native context) drivers export BOs for import by the guest VM, which does not attempt to bind them to any GPU VM.
Allow these BOs to be exported and rely on
panthor_vm_prepare_map_op_ctx()to reject attempts to bind them to a different GPU VM.
I'm having a little trouble parsing this.
Is the problem that:
- the guest requests allocation of a BO with exclusive_vm_root_gem = guest_vm
- the host passes that allocation through
- the host exports a dmabuf from the allocation (which fails)
- the host imports a dmabuf from the allocation (?)
- the guest requests the BO be attached to guest_vm
i.e. is the problem that some host implementations (virglrenderer) handle BO allocation exclusively via an export/import interface?
If that is the problem, it seems like it would be cleaner to have the host implementation strip the exclusive VM ID from the request, until they can be fixed to not require the export/import dance.
Cheers,
Daniel
Boris Brezillon
maintainerQuoted 20 lines · On Mon, 9 Nov 2026 17:38:57 +0000 Daniel Stone <[email protected]> wrote:
Hi Igor,
Quoted 7 lines · Igor Torrente
Panthor currently does not allow exporting BOs with an exclusive VM. However, VDRM (native context) drivers export BOs for import by the guest VM, which does not attempt to bind them to any GPU VM.
Allow these BOs to be exported and rely on
panthor_vm_prepare_map_op_ctx()to reject attempts to bind them to a different GPU VM.I'm having a little trouble parsing this.
Is the problem that:
- the guest requests allocation of a BO withexclusive_vm_root_gem=guest_vm
- the host passes that allocation through
- the host exports a dmabuf from the allocation (which fails)
- the host imports a dmabuf from the allocation (?)
- the guest requests the BO be attached toguest_vm
Quoted 6 lines
i.e. is the problem that some host implementations (virglrenderer) handle BO allocation exclusively via an export/import interface?
If that is the problem, it seems like it would be cleaner to have the host implementation strip the exclusive VM ID from the request, until they can be fixed to not require the export/import dance.
Dropping the exclusive_vm assignment is indeed an option. The big issue comes from the overhead incurred by BO access tracking when the BO is shared:
- bo_wait() has to do a HANDLE_TO_FD + EXPORT_SYNC dance
- attach_sync_point() has to do an EXPORT_SYNC_FILE + HANDLE_TO_FD + IMPORT_SYNC_FILE dance
- the locking of shared BOs in the GROUP_SUBMIT path is more costly (one lock per shared BO instead of one lock for all private BOs)
I don't have numbers, but I suspect lowering all private BOs to shared ones will have a noticeable impact on perfs.
De: Boris Brezillon <[email protected]>
Para: "Daniel Stone"<[email protected]>
Cc: "Igor Torrente"<[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>
Fecha: mar, 10 nov. 2026 05:10:06 -0300
Asunto: Re: [PATCH] drm/panthor: Allow exporting BOs with an exclusive VM
Quoted 34 lines
Quoted 20 lines · On Mon, 9 Nov 2026 17:38:57 +0000 Daniel Stone <[email protected]> wrote:
Hi Igor,
Quoted 7 lines · Igor Torrente
Panthor currently does not allow exporting BOs with an exclusive VM. However, VDRM (native context) drivers export BOs for import by the guest VM, which does not attempt to bind them to any GPU VM.
Allow these BOs to be exported and rely on
panthor_vm_prepare_map_op_ctx()to reject attempts to bind them to a different GPU VM.I'm having a little trouble parsing this.
Is the problem that:
- the guest requests allocation of a BO withexclusive_vm_root_gem=guest_vm
- the host passes that allocation through
- the host exports a dmabuf from the allocation (which fails)
- the host imports a dmabuf from the allocation (?)
- the guest requests the BO be attached toguest_vmQuoted 6 lines
i.e. is the problem that some host implementations (virglrenderer) handle BO allocation exclusively via an export/import interface?
If that is the problem, it seems like it would be cleaner to have the host implementation strip the exclusive VM ID from the request, until they can be fixed to not require the export/import dance.
Dropping the
exclusive_vmassignment is indeed an option. The big issue comes from the overhead incurred by BO access tracking when the BO is shared:
Quoted 9 lines
-
bo_wait()has to do aHANDLE_TO_FD+EXPORT_SYNCdance
-attach_sync_point()has to do anEXPORT_SYNC_FILE+HANDLE_TO_FD+IMPORT_SYNC_FILEdance
- the locking of shared BOs in theGROUP_SUBMITpath is more costly (one lock per shared BO instead of one lock for all private BOs)I don't have numbers, but I suspect lowering all private BOs to shared ones will have a noticeable impact on perfs.
Continuing from the previous response:
Changing Vpipe won’t work. We still need to import the exclusive-VM blob to the Vpipe client, and the only way I’m aware of is by exporting the BO.
This leaves us with two possibilities: continue with this patch or strip the exclusive-VM.
I ran benchmarks, and to my surprise, the results were very similar.
### Virtio_gpu
| Exclusive-vm | Masked | Masked[1] | Non-masked | |--------------|--------|-----------------|------------| | vkmark | 1689 | 1702 | 1760 | | glmark | 874 | black screen[2] | 909 | | paraview | 13.04 | 13.29 | 13.44 |
[1] Setting exclusive_vm_id as 0, but initializing pan_kmod_bo_init with the exclusive_vm_id
[2] GROUP_SUBMIT failed: 22 (probably fixable)
### Vpipe
| Exclusive-vm | Masked | Masked[1] | Non-masked | |--------------|--------|-----------|------------| | vkmark | 999 | 1003 | 1033 | | glmark | 768 | 867 | 869 | | paraview | 13.87 | 14 | 13.73 |
If these results are correct and representative, stripping exclusive_vm seems like a viable option.
Boris Brezillon
maintainerQuoted 74 lines · On Tue, 10 Nov 2026 19:59:10 -0300 Igor Torrente <[email protected]>…
De: Boris Brezillon <[email protected]>
Para: "Daniel Stone"<[email protected]>
Cc: "Igor Torrente"<[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>
Fecha: mar, 10 nov. 2026 05:10:06 -0300
Asunto: Re: [PATCH] drm/panthor: Allow exporting BOs with an exclusive VMQuoted 34 lines
Quoted 20 lines · On Mon, 9 Nov 2026 17:38:57 +0000 Daniel Stone <[email protected]> wrote:
Hi Igor,
Quoted 7 lines · Igor Torrente
Panthor currently does not allow exporting BOs with an exclusive VM. However, VDRM (native context) drivers export BOs for import by the guest VM, which does not attempt to bind them to any GPU VM.
Allow these BOs to be exported and rely on
panthor_vm_prepare_map_op_ctx()to reject attempts to bind them to a different GPU VM.I'm having a little trouble parsing this.
Is the problem that:
- the guest requests allocation of a BO withexclusive_vm_root_gem=guest_vm
- the host passes that allocation through
- the host exports a dmabuf from the allocation (which fails)
- the host imports a dmabuf from the allocation (?)
- the guest requests the BO be attached toguest_vmQuoted 6 lines
i.e. is the problem that some host implementations (virglrenderer) handle BO allocation exclusively via an export/import interface?
If that is the problem, it seems like it would be cleaner to have the host implementation strip the exclusive VM ID from the request, until they can be fixed to not require the export/import dance.
Dropping the
exclusive_vmassignment is indeed an option. The big issue comes from the overhead incurred by BO access tracking when the BO is shared:Quoted 9 lines
-
bo_wait()has to do aHANDLE_TO_FD+EXPORT_SYNCdance
-attach_sync_point()has to do anEXPORT_SYNC_FILE+HANDLE_TO_FD+IMPORT_SYNC_FILEdance
- the locking of shared BOs in theGROUP_SUBMITpath is more costly (one lock per shared BO instead of one lock for all private BOs)I don't have numbers, but I suspect lowering all private BOs to shared ones will have a noticeable impact on perfs.
Continuing from the previous response:
Changing Vpipe won’t work. We still need to import the exclusive-VM blob to the Vpipe client, and the only way I’m aware of is by exporting the BO.
This leaves us with two possibilities: continue with this patch or strip the exclusive-VM.
I ran benchmarks, and to my surprise, the results were very similar.
###
Virtio_gpu| Exclusive-vm | Masked | Masked[1] | Non-masked | |--------------|--------|-----------------|------------| | vkmark | 1689 | 1702 | 1760 | | glmark | 874 | black screen[2] | 909 | | paraview | 13.04 | 13.29 | 13.44 |[1] Setting
exclusive_vm_idas 0, but initializingpan_kmod_bo_initwith theexclusive_vm_id
[2]GROUP_SUBMIT failed: 22(probably fixable)### Vpipe
Quoted 9 lines
| Exclusive-vm | Masked | Masked[1] | Non-masked | |--------------|--------|-----------|------------| | vkmark | 999 | 1003 | 1033 | | glmark | 768 | 867 | 869 | | paraview | 13.87 | 14 | 13.73 |If these results are correct and representative, stripping
exclusive_vmseems like a viable option.
Well, yeah, if it's doesn't make a difference, I'd go for the second option (making all BOs shared by dropping the exclusive_vm).
Hi Daniel,
De: Daniel Stone <[email protected]>
Para: "Igor Torrente"<[email protected]>
Cc: <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>
Fecha: lun, 09 nov. 2026 14:38:57 -0300
Asunto: Re: [PATCH] drm/panthor: Allow exporting BOs with an exclusive VM
Quoted 20 lines
Hi Igor,
Quoted 7 lines · Igor Torrente
Panthor currently does not allow exporting BOs with an exclusive VM. However, VDRM (native context) drivers export BOs for import by the guest VM, which does not attempt to bind them to any GPU VM.
Allow these BOs to be exported and rely on
panthor_vm_prepare_map_op_ctx()to reject attempts to bind them to a different GPU VM.I'm having a little trouble parsing this.
Is the problem that:
- the guest requests allocation of a BO withexclusive_vm_root_gem=guest_vm
- the host passes that allocation through
- the host exports a dmabuf from the allocation (which fails)
- the host imports a dmabuf from the allocation (?)
- the guest requests the BO be attached toguest_vm
Quoted 2 lines
i.e. is the problem that some host implementations (virglrenderer) handle BO allocation exclusively via an export/import interface?
I was testing and checking a few things. This patch needs at least a rewording, but maybe we can drop it entirely.
The virtio_gpu part of Virglrenderer used to create a transitory export to mmap the BO and attach it to the guest VM (not import, as I previously wrote). With resource_map, this transitory mapping is now obsolete.
Vpipe still shares buffers with the client through FDs (even non-shareable BOs). It seems that this is an expectation of the protocol. I will check to see if we can avoid this for non-shareable (exclusive-VM) cases.
Lastly, if I’m not mistaken, CrosVM’s sandbox separates the GPU device into another process, making the export necessary (possibly even for non-shareable BOs). This may or may not be an issue.
BR,
Igor
Quoted 8 lines
If that is the problem, it seems like it would be cleaner to have the host implementation strip the exclusive VM ID from the request, until they can be fixed to not require the export/import dance.
Cheers,
Daniel
Hi,
Quoted 13 lines · Igor Torrente
Quoted 9 lines
Is the problem that:
- the guest requests allocation of a BO withexclusive_vm_root_gem=guest_vm
- the host passes that allocation through
- the host exports a dmabuf from the allocation (which fails)
- the host imports a dmabuf from the allocation (?)
- the guest requests the BO be attached toguest_vmi.e. is the problem that some host implementations (virglrenderer) handle BO allocation exclusively via an export/import interface?
I was testing and checking a few things. This patch needs at least a rewording, but maybe we can drop it entirely.
Quoted 7 lines
The
virtio_gpupart of Virglrenderer used to create a transitory export to mmap the BO and attach it to the guest VM (not import, as I previously wrote). Withresource_map, this transitory mapping is now obsolete.Vpipe still shares buffers with the client through FDs (even non-shareable BOs). It seems that this is an expectation of the protocol. I will check to see if we can avoid this for non-shareable (exclusive-VM) cases.
Yeah. If we can/should extend vpipe to not do this, that seems like a better path forward.
Quoted 3 lines
Lastly, if I’m not mistaken, CrosVM’s sandbox separates the GPU device into another process, making the export necessary (possibly even for non-shareable BOs). This may or may not be an issue.
If allocation and rendering are performed by two separate processes, then either they share a VM, in which case they can pass GEM handles rather than FDs - or they don't share a VM, in which case the buffer isn't exclusive to a single VM.
In either case, I'm glad the performance delta is pretty small. I would be in favour of masking it out from userspace: when we get to the point where we need to improve performance, we can look at doing something structurally different. Allowing exports of 'private' BOs from the kernel feels like opening a door we'll regret later.
Cheers,
Daniel