linux-next: manual merge of the drm tree with the origin tree

From: Mark Brown

Date: Fri Jul 31 2026 - 10:01:28 EST


Hi all,

Today's linux-next merge of the drm tree got a conflict in:

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

between commit:

04cc4aa3617b0 ("drm/amdgpu: fix lifetime issue of amdgpu_vm_get_task_info_pasid()")

from the origin tree and commit:

b0ae60ea3f3f1 ("drm/amdgpu: Resolve VM through DRM PASID ownership")

from the drm tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging. You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

diff --combined drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index dc6a9d7dd0b28,aac8ace9d7a63..0000000000000
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@@ -2506,14 -2506,16 +2506,16 @@@ amdgpu_vm_get_task_info_vm(struct amdgp
struct amdgpu_task_info *
amdgpu_vm_get_task_info_pasid(struct amdgpu_device *adev, u32 pasid)
{
+ struct amdgpu_fpriv *fpriv;
struct amdgpu_task_info *ti;
struct amdgpu_vm *vm;
unsigned long flags;

- xa_lock_irqsave(&adev->vm_manager.pasids, flags);
- vm = xa_load(&adev->vm_manager.pasids, pasid);
+ amdgpu_pasid_lock(&flags);
+ fpriv = amdgpu_pasid_get_fpriv_locked(pasid);
+ vm = fpriv ? &fpriv->vm : NULL;
ti = amdgpu_vm_get_task_info_vm(vm);
- xa_unlock_irqrestore(&adev->vm_manager.pasids, flags);
+ amdgpu_pasid_unlock(flags);

return ti;
}
@@@ -2554,7 -2556,6 +2556,6 @@@ void amdgpu_vm_set_task_info(struct amd
* @adev: amdgpu_device pointer
* @vm: requested vm
* @xcp_id: GPU partition selection id
- * @pasid: the pasid the VM is using on this GPU
*
* Init @vm fields.
*
@@@ -2562,7 -2563,7 +2563,7 @@@
* 0 for success, error for failure.
*/
int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
- int32_t xcp_id, uint32_t pasid)
+ int32_t xcp_id)
{
struct amdgpu_bo *root_bo;
struct amdgpu_bo_vm *root;
@@@ -2637,26 -2638,12 +2638,12 @@@
if (r)
dev_dbg(adev->dev, "Failed to create task info for VM\n");

- /* Store new PASID in XArray (if non-zero) */
- if (pasid != 0) {
- r = xa_err(xa_store_irq(&adev->vm_manager.pasids, pasid, vm, GFP_KERNEL));
- if (r < 0)
- goto error_free_root;
-
- vm->pasid = pasid;
- }
-
amdgpu_bo_unreserve(vm->root.bo);
amdgpu_bo_unref(&root_bo);

return 0;

error_free_root:
- /* If PASID was partially set, erase it from XArray before failing */
- if (vm->pasid != 0) {
- xa_erase_irq(&adev->vm_manager.pasids, vm->pasid);
- vm->pasid = 0;
- }
amdgpu_vm_pt_free_root(adev, vm);
amdgpu_bo_unreserve(vm->root.bo);
amdgpu_bo_unref(&root_bo);
@@@ -2763,11 -2750,6 +2750,6 @@@ void amdgpu_vm_fini(struct amdgpu_devic

root = amdgpu_bo_ref(vm->root.bo);
amdgpu_bo_reserve(root, true);
- /* Remove PASID mapping before destroying VM */
- if (vm->pasid != 0) {
- xa_erase_irq(&adev->vm_manager.pasids, vm->pasid);
- vm->pasid = 0;
- }
dma_fence_wait(vm->last_unlocked, false);
dma_fence_put(vm->last_unlocked);
dma_fence_wait(vm->last_tlb_flush, false);
@@@ -2863,8 -2845,6 +2845,6 @@@ void amdgpu_vm_manager_init(struct amdg
#else
adev->vm_manager.vm_update_mode = 0;
#endif
-
- xa_init_flags(&adev->vm_manager.pasids, XA_FLAGS_LOCK_IRQ);
}

/**
@@@ -2876,9 -2856,6 +2856,6 @@@
*/
void amdgpu_vm_manager_fini(struct amdgpu_device *adev)
{
- WARN_ON(!xa_empty(&adev->vm_manager.pasids));
- xa_destroy(&adev->vm_manager.pasids);
-
amdgpu_vmid_mgr_fini(adev);
amdgpu_pasid_mgr_cleanup();
}
@@@ -2935,14 -2912,16 +2912,16 @@@ struct amdgpu_vm *amdgpu_vm_lock_by_pas
u32 pasid, struct drm_exec *exec)
{
unsigned long irqflags;
+ struct amdgpu_fpriv *fpriv;
struct amdgpu_bo *root;
struct amdgpu_vm *vm;
int r;

- xa_lock_irqsave(&adev->vm_manager.pasids, irqflags);
- vm = xa_load(&adev->vm_manager.pasids, pasid);
- root = vm ? amdgpu_bo_ref(vm->root.bo) : NULL;
- xa_unlock_irqrestore(&adev->vm_manager.pasids, irqflags);
+ amdgpu_pasid_lock(&irqflags);
+ fpriv = amdgpu_pasid_get_fpriv_locked(pasid);
+ vm = fpriv ? &fpriv->vm : NULL;
+ root = vm && vm->root.bo ? amdgpu_bo_ref(vm->root.bo) : NULL;
+ amdgpu_pasid_unlock(irqflags);

if (!root)
return NULL;
@@@ -2954,11 -2933,17 +2933,17 @@@
}

/* Double check that the VM still exists */
- xa_lock_irqsave(&adev->vm_manager.pasids, irqflags);
- vm = xa_load(&adev->vm_manager.pasids, pasid);
- if (vm && vm->root.bo != root)
+ amdgpu_pasid_lock(&irqflags);
+ fpriv = amdgpu_pasid_get_fpriv_locked(pasid);
+ if (!fpriv) {
vm = NULL;
- xa_unlock_irqrestore(&adev->vm_manager.pasids, irqflags);
+ } else {
+ vm = &fpriv->vm;
+ if (vm->root.bo != root)
+ vm = NULL;
+ }
+ amdgpu_pasid_unlock(irqflags);
+
if (!vm) {
drm_exec_unlock_obj(exec, &root->tbo.base);
amdgpu_bo_unref(&root);
@@@ -3010,8 -2995,6 +2995,8 @@@ bool amdgpu_vm_handle_fault(struct amdg
is_compute_context = vm->is_compute_context;

if (is_compute_context) {
+ __label__ drm_exec_retry;
+
/* Release the root PD lock since svm_range_restore_pages
* might try to take it.
* TODO: rework svm_range_restore_pages so that this isn't
@@@ -3157,12 -3140,14 +3142,14 @@@ void amdgpu_vm_update_fault_cache(struc
uint32_t status,
unsigned int vmhub)
{
+ struct amdgpu_fpriv *fpriv;
struct amdgpu_vm *vm;
unsigned long flags;

- xa_lock_irqsave(&adev->vm_manager.pasids, flags);
+ amdgpu_pasid_lock(&flags);

- vm = xa_load(&adev->vm_manager.pasids, pasid);
+ fpriv = amdgpu_pasid_get_fpriv_locked(pasid);
+ vm = fpriv ? &fpriv->vm : NULL;
/* Don't update the fault cache if status is 0. In the multiple
* fault case, subsequent faults will return a 0 status which is
* useless for userspace and replaces the useful fault status, so
@@@ -3195,7 -3180,7 +3182,7 @@@
WARN_ONCE(1, "Invalid vmhub %u\n", vmhub);
}
}
- xa_unlock_irqrestore(&adev->vm_manager.pasids, flags);
+ amdgpu_pasid_unlock(flags);
}

void amdgpu_vm_print_task_info(struct amdgpu_device *adev,

Attachment: signature.asc
Description: PGP signature