drm/amdgpu: userq_va_mapped should remain true once done
Subsystems (2)
PATCH v2 1/1 drm/amdgpu: userq_va_mapped should remain true once done
Multiple queues needs these bo_va objects belonging to the same uq_mgr. So once they are mapped lets not unmap them as at any point of time any of the queues might be using it.
Also userq_va_mapped should be a boolean than atomic.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 6 ++---- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +2 -1
@@ -96,7 +96,8 @@ struct amdgpu_bo_va {* if non-zero, cannot unmap from GPU because user queues may still access it */ unsigned int queue_refcount; -atomic_t userq_va_mapped; +/* Indicates if this buffer is mapped for any user queue. Once set, never reset. */ +bool userq_va_mapped; };struct amdgpu_bo {
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +2 -4
@@ -227,7 +227,7 @@ static int amdgpu_userq_buffer_va_list_add(struct amdgpu_usermode_queue *queue,INIT_LIST_HEAD (&va_cursor->list); va_cursor->gpu_addr = addr; -atomic_set (&va_map->bo_va->userq_va_mapped,1 ); + va_map->bo_va->userq_va_mapped = true;list_add (&va_cursor->list, &queue->userq_va_list);return 0 ;
@@ -274,7 +274,7 @@ static bool amdgpu_userq_buffer_va_mapped(struct amdgpu_vm *vm, u64 addr)dma_resv_assert_held (vm->root.bo->tbo.base.resv); mapping =amdgpu_vm_bo_lookup_mapping (vm, addr); -if (!IS_ERR_OR_NULL (mapping) &&atomic_read (&mapping->bo_va->userq_va_mapped)) +if (!IS_ERR_OR_NULL (mapping) && mapping->bo_va->userq_va_mapped) r = true;else r = false;
@@ -303,8 +303,6 @@ static bool amdgpu_userq_buffer_vas_mapped(struct amdgpu_usermode_queue *queue)static void amdgpu_userq_buffer_va_list_del (struct amdgpu_bo_va_mapping *mapping,struct amdgpu_userq_va_cursor *va_cursor) { -if (mapping) -atomic_set (&mapping->bo_va->userq_va_mapped,0 );list_del (&va_cursor->list);kfree (va_cursor); }
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -1
@@ -2002,7 +2002,7 @@ int amdgpu_vm_bo_unmap(struct amdgpu_device *adev,* during user requests GEM unmap IOCTL except for forcing the unmap * from user space. */ -if (unlikely (atomic_read (&bo_va->userq_va_mapped) >0 )) +if (unlikely (bo_va->userq_va_mapped >0 ))amdgpu_userq_gem_va_unmap_validate (adev, mapping, saddr);list_del (&mapping->list);
Signature · 1 line
2.34.1
Quoted 8 lines · Sunil Khatri
Multiple queues needs these
bo_vaobjects belonging to the sameuq_mgr. So once they are mapped lets not unmap them as at any point of time any of the queues might be using it.Also
userq_va_mappedshould be a boolean than atomic.Signed-off-by Sunil Khatri <[email protected]>
What is the userq_va_cursor actually used for?
Regards,
Christian.
Quoted 64 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 6 ++---- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +2
-1@@ -96,7 +96,8 @@ struct amdgpu_bo_va {* if non-zero, cannot unmap from GPU because user queues may still access it */ unsigned int queue_refcount; -atomic_t userq_va_mapped; +/* Indicates if this buffer is mapped for any user queue. Once set, never reset. */ +bool userq_va_mapped; };struct amdgpu_bo {drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +2
-4@@ -227,7 +227,7 @@ static int amdgpu_userq_buffer_va_list_add(struct amdgpu_usermode_queue *queue,INIT_LIST_HEAD (&va_cursor->list); va_cursor->gpu_addr = addr; -atomic_set (&va_map->bo_va->userq_va_mapped,1 ); + va_map->bo_va->userq_va_mapped = true;list_add (&va_cursor->list, &queue->userq_va_list);return 0 ;@@ -274,7 +274,7 @@ static bool amdgpu_userq_buffer_va_mapped(struct amdgpu_vm *vm, u64 addr)dma_resv_assert_held (vm->root.bo->tbo.base.resv); mapping =amdgpu_vm_bo_lookup_mapping (vm, addr); -if (!IS_ERR_OR_NULL (mapping) &&atomic_read (&mapping->bo_va->userq_va_mapped)) +if (!IS_ERR_OR_NULL (mapping) && mapping->bo_va->userq_va_mapped) r = true;else r = false;@@ -303,8 +303,6 @@ static bool amdgpu_userq_buffer_vas_mapped(struct amdgpu_usermode_queue *queue)static void amdgpu_userq_buffer_va_list_del (struct amdgpu_bo_va_mapping *mapping,struct amdgpu_userq_va_cursor *va_cursor) { -if (mapping) -atomic_set (&mapping->bo_va->userq_va_mapped,0 );list_del (&va_cursor->list);kfree (va_cursor); }drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1
-1@@ -2002,7 +2002,7 @@ int amdgpu_vm_bo_unmap(struct amdgpu_device *adev,* during user requests GEM unmap IOCTL except for forcing the unmap * from user space. */ -if (unlikely (atomic_read (&bo_va->userq_va_mapped) >0 )) +if (unlikely (bo_va->userq_va_mapped >0 ))amdgpu_userq_gem_va_unmap_validate (adev, mapping, saddr);list_del (&mapping->list);
Quoted 6 lines · Christian König
Quoted 5 lines · Sunil Khatri
Multiple queues needs these
bo_vaobjects belonging to the sameuq_mgr. So once they are mapped lets not unmap them as at any point of time any of the queues might be using it.
Quoted 6 lines
Quoted 3 lines
Also
userq_va_mappedshould be a boolean than atomic.Signed-off-by Sunil Khatri <[email protected]>What is the
userq_va_cursoractually used for?
It holds the gpu address and the membership to the list. we just add the gpu address from the mapping of the buffers of interest from queue like wptr rptr etc. struct amdgpu_userq_va_cursor {
u64 gpu_addr;
struct list_head list;
};
Regards
Sunil Khatri
Quoted 68 lines
Regards,
Christian.Quoted 64 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 6 ++---- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +2
-1@@ -96,7 +96,8 @@ struct amdgpu_bo_va {* if non-zero, cannot unmap from GPU because user queues may still access it */ unsigned int queue_refcount; -atomic_t userq_va_mapped; +/* Indicates if this buffer is mapped for any user queue. Once set, never reset. */ +bool userq_va_mapped; };struct amdgpu_bo {drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +2
-4@@ -227,7 +227,7 @@ static int amdgpu_userq_buffer_va_list_add(struct amdgpu_usermode_queue *queue,INIT_LIST_HEAD (&va_cursor->list); va_cursor->gpu_addr = addr; -atomic_set (&va_map->bo_va->userq_va_mapped,1 ); + va_map->bo_va->userq_va_mapped = true;list_add (&va_cursor->list, &queue->userq_va_list);return 0 ;@@ -274,7 +274,7 @@ static bool amdgpu_userq_buffer_va_mapped(struct amdgpu_vm *vm, u64 addr)dma_resv_assert_held (vm->root.bo->tbo.base.resv); mapping =amdgpu_vm_bo_lookup_mapping (vm, addr); -if (!IS_ERR_OR_NULL (mapping) &&atomic_read (&mapping->bo_va->userq_va_mapped)) +if (!IS_ERR_OR_NULL (mapping) && mapping->bo_va->userq_va_mapped) r = true;else r = false;@@ -303,8 +303,6 @@ static bool amdgpu_userq_buffer_vas_mapped(struct amdgpu_usermode_queue *queue)static void amdgpu_userq_buffer_va_list_del (struct amdgpu_bo_va_mapping *mapping,struct amdgpu_userq_va_cursor *va_cursor) { -if (mapping) -atomic_set (&mapping->bo_va->userq_va_mapped,0 );list_del (&va_cursor->list);kfree (va_cursor); }drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1
-1@@ -2002,7 +2002,7 @@ int amdgpu_vm_bo_unmap(struct amdgpu_device *adev,* during user requests GEM unmap IOCTL except for forcing the unmap * from user space. */ -if (unlikely (atomic_read (&bo_va->userq_va_mapped) >0 )) +if (unlikely (bo_va->userq_va_mapped >0 ))amdgpu_userq_gem_va_unmap_validate (adev, mapping, saddr);list_del (&mapping->list);
Christian König
maintainerQuoted 10 lines · Sunil
Quoted 9 lines · Christian König
Quoted 8 lines · Sunil Khatri
Multiple queues needs these
bo_vaobjects belonging to the sameuq_mgr. So once they are mapped lets not unmap them as at any point of time any of the queues might be using it.Also
userq_va_mappedshould be a boolean than atomic.Signed-off-by Sunil Khatri <[email protected]>
Quoted 8 lines
Quoted 3 lines
What is the
userq_va_cursoractually used for?It holds the gpu address and the membership to the list. we just add the gpu address from the mapping of the buffers of interest from queue like wptr rptr etc. struct
amdgpu_userq_va_cursor{
u64gpu_addr;
struct list_head list;
};
Mhm, that's a bit overkill. We could use an array instead since the number of VA addresses is pretty fixed.
But yeah something for the nice to have list.
Thanks,
Christian.
Quoted 66 lines
Regards
Sunil KhatriQuoted 63 lines
Regards,
Christian.Quoted 59 lines
---
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h| 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 6 ++---- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +-3 files changed, 5 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +2
-1@@ -96,7 +96,8 @@ struct amdgpu_bo_va {* if non-zero, cannot unmap from GPU because user queues may still access it */ unsigned int queue_refcount; - atomic_t userq_va_mapped; + /* Indicates if this buffer is mapped for any user queue. Once set, never reset. */ + bool userq_va_mapped; }; struct amdgpu_bo {drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +2
-2@@ -227,7 +227,7 @@ static int amdgpu_userq_buffer_va_list_add(struct amdgpu_usermode_queue *queue, INIT_LIST_HEAD(&va_cursor->list); va_cursor->gpu_addr = addr; - atomic_set(&va_map->bo_va->userq_va_mapped, 1); + va_map->bo_va->userq_va_mapped = true; list_add(&va_cursor->list, &queue->userq_va_list); return 0;@@ -274,7 +274,7 @@ static bool amdgpu_userq_buffer_va_mapped(struct amdgpu_vm *vm, u64 addr) dma_resv_assert_held(vm->root.bo->tbo.base.resv); mapping = amdgpu_vm_bo_lookup_mapping(vm, addr); - if (!IS_ERR_OR_NULL(mapping) && atomic_read(&mapping->bo_va->userq_va_mapped)) + if (!IS_ERR_OR_NULL(mapping) && mapping->bo_va->userq_va_mapped) r = true;else
r = false;drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0
-2@@ -303,8 +303,6 @@ static bool amdgpu_userq_buffer_vas_mapped(struct amdgpu_usermode_queue *queue) static void amdgpu_userq_buffer_va_list_del(struct amdgpu_bo_va_mapping *mapping, struct amdgpu_userq_va_cursor *va_cursor) { - if (mapping) - atomic_set(&mapping->bo_va->userq_va_mapped, 0); list_del(&va_cursor->list); kfree(va_cursor); }drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1
-1@@ -2002,7 +2002,7 @@ int amdgpu_vm_bo_unmap(struct amdgpu_device *adev,* during user requests GEM unmap IOCTL except for forcing the unmap * from user space. */ - if (unlikely(atomic_read(&bo_va->userq_va_mapped) > 0)) + if (unlikely(bo_va->userq_va_mapped > 0)) amdgpu_userq_gem_va_unmap_validate(adev, mapping, saddr); list_del(&mapping->list);