drm/amdgpu: enable bo priority setting from user space
Subsystems (4)
PATCH 1/1 drm/amdgpu: enable bo priority setting from user space
--- drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 13 +++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 1 + include/drm/ttm/ttm_bo_driver.h | 9 ++++++++- include/uapi/drm/amdgpu_drm.h | 3 +++ 7 files changed, 29 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +1 -0
@@ -144,6 +144,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev, size = mode_cmd->pitches[0 ] * height; aligned_size =ALIGN (size,PAGE_SIZE ); ret = amdgpu_gem_object_create(adev, aligned_size, 0, domain, + TTM_BO_PRIORITY_NORMAL, AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS | AMDGPU_GEM_CREATE_VRAM_CLEARED,
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +13 -0
@@ -44,6 +44,7 @@ void amdgpu_gem_object_free(struct drm_gem_object *gobj)int amdgpu_gem_object_create (struct amdgpu_device *adev,unsigned long size,int alignment,u32 initial_domain, +enum ttm_bo_priority priority,u64 flags,enum ttm_bo_type type,struct reservation_object *resv,struct drm_gem_object **obj)
@@ -60,6 +61,7 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, bp.type = type; bp.resv = resv; bp.preferred_domain = initial_domain; + bp.priority = priority; retry: bp.flags = flags; bp.domain = initial_domain;
@@ -229,6 +231,14 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,if (args->in.domains & ~AMDGPU_GEM_DOMAIN_MASK )return -EINVAL ; +/* check priority */ +if (args->in.priority ==0 ) { +/* default is normal */ + args->in.priority =TTM_BO_PRIORITY_NORMAL ; + }else if (args->in.priority >TTM_MAX_BO_PRIORITY ) { + args->in.priority =TTM_MAX_BO_PRIORITY ; +DRM_ERROR ("priority specified from user space is over MAX priority\n" ); + }/* create a gem object to contain this object in */ if (args->in.domains & (AMDGPU_GEM_DOMAIN_GDS |AMDGPU_GEM_DOMAIN_GWS |AMDGPU_GEM_DOMAIN_OA )) {
@@ -252,6 +262,7 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data, r =amdgpu_gem_object_create (adev, size, args->in.alignment, (u32)(0xffffffff & args->in.domains), + args->in.priority -1 , flags, ttm_bo_type_device, resv, &gobj);if (flags &AMDGPU_GEM_CREATE_VM_ALWAYS_VALID ) {if (!r) {
@@ -304,6 +315,7 @@ int amdgpu_gem_userptr_ioctl(struct drm_device *dev, void *data,/* create a gem object to contain this object in */ r =amdgpu_gem_object_create (adev, args->size,0 ,AMDGPU_GEM_DOMAIN_CPU , +TTM_BO_PRIORITY_NORMAL ,0 , ttm_bo_type_device,NULL , &gobj);if (r)return r;
@@ -755,6 +767,7 @@ int amdgpu_mode_dumb_create(struct drm_file *file_priv, domain =amdgpu_bo_get_preferred_pin_domain (adev,amdgpu_display_supported_domains (adev)); r =amdgpu_gem_object_create (adev, args->size,0 , domain, +TTM_BO_PRIORITY_NORMAL ,AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED , ttm_bo_type_device,NULL , &gobj);if (r)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h +1 -1
@@ -61,7 +61,7 @@ extern const struct dma_buf_ops amdgpu_dmabuf_ops;*/ void amdgpu_gem_force_release (struct amdgpu_device *adev);int amdgpu_gem_object_create (struct amdgpu_device *adev,unsigned long size, -int alignment,u32 initial_domain, +int alignment,u32 initial_domain,u32 priority,u64 flags,enum ttm_bo_type type,struct reservation_object *resv,struct drm_gem_object **obj);
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2 -1
@@ -494,8 +494,9 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, bo->tbo.bdev = &adev->mman.bdev;amdgpu_bo_placement_from_domain (bo, bp->domain); + bo->tbo.priority = bp->priority;if (bp->type == ttm_bo_type_kernel) - bo->tbo.priority =1 ; + bo->tbo.priority =TTM_BO_PRIORITY_VERYHIGH ; r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, bp->type, &bo->placement, page_align, &ctx, acc_size,
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +1 -0
@@ -39,6 +39,7 @@ struct amdgpu_bo_param {int byte_align;u32 domain;u32 preferred_domain; +u32 priority;u64 flags;enum ttm_bo_type type;struct reservation_object *resv;
include/drm/ttm/ttm_bo_driver.h +8 -1
@@ -43,7 +43,14 @@#include "ttm_placement.h" #include "ttm_tt.h" -#define TTM_MAX_BO_PRIORITY 4U +enum ttm_bo_priority { +TTM_BO_PRIORITY_VERYLOW =0 , +TTM_BO_PRIORITY_LOW , +TTM_BO_PRIORITY_NORMAL , +TTM_BO_PRIORITY_HIGH , +TTM_BO_PRIORITY_VERYHIGH , +TTM_MAX_BO_PRIORITY +};#define TTM_MEMTYPE_FLAG_FIXED (1 << 0)/* Fixed (on-card) PCI memory */ #define TTM_MEMTYPE_FLAG_MAPPABLE (1 << 1)/* Memory mappable */
include/uapi/drm/amdgpu_drm.h +3 -0
@@ -138,6 +138,9 @@ struct drm_amdgpu_gem_create_in {__u64 domains;/** allocation flags */ __u64 domain_flags; +/** priority */ +__u32 priority; +__u32 pad; };struct drm_amdgpu_gem_create_out {
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 1 line · Chunming Zhou
Signed-off-by Chunming Zhou <[email protected]>
Please provide corresponding UMD patches showing how this is to be used.
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data, · line 235
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2
-0@@ -229,6 +231,14 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,if (args->in.domains & ~AMDGPU_GEM_DOMAIN_MASK )return -EINVAL ; +/* check priority */ +if (args->in.priority ==0 ) {
Did you verify that this is 0 with old userspace compiled against struct drm_amdgpu_gem_create_in without the priority field?
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data, · line 240
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +5
-0+/* default is normal */ + args->in.priority =TTM_BO_PRIORITY_NORMAL ; + }else if (args->in.priority >TTM_MAX_BO_PRIORITY ) { + args->in.priority =TTM_MAX_BO_PRIORITY ; +DRM_ERROR ("priority specified from user space is over MAX priority\n" );
This must be DRM_DEBUG, or buggy/malicious userspace can spam dmesg.
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data, · line 266
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1
-0@@ -252,6 +262,7 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data, r =amdgpu_gem_object_create (adev, size, args->in.alignment, (u32)(0xffffffff & args->in.domains), + args->in.priority -1 , flags, ttm_bo_type_device, resv, &gobj);
It might be less confusing to subtract 1 after checking against TTM_MAX_BO_PRIORITY instead of here. Still kind of confusing though. How about this instead:
Make the priority field of struct drm_amdgpu_gem_create_in signed. In amdgpu_gem_create_ioctl, clamp the priority to the supported range:
args->in.priority += TTM_BO_PRIORITY_NORMAL; args->in.priority = max(args->in.priority, 0); args->in.priority = min(args->in.priority, TTM_BO_PRIORITY_NORMAL - 1);
This way userspace doesn't need to do a weird mapping of the priority values (where 0 and 2 have the same meaning), and the range of supported priorities could at least theoretically be extended without breaking userspace.
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_userptr_ioctl(struct drm_device *dev, void *data, · line 319
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1
-0@@ -304,6 +315,7 @@ int amdgpu_gem_userptr_ioctl(struct drm_device *dev, void *data,/* create a gem object to contain this object in */ r =amdgpu_gem_object_create (adev, args->size,0 ,AMDGPU_GEM_DOMAIN_CPU , +TTM_BO_PRIORITY_NORMAL ,0 , ttm_bo_type_device,NULL , &gobj);
Should the userptr ioctl also allow setting the priority?
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c static int amdgpu_bo_do_create(struct amdgpu_device *adev, · line 499
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2
-1@@ -494,8 +494,9 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, bo->tbo.bdev = &adev->mman.bdev;amdgpu_bo_placement_from_domain (bo, bp->domain); + bo->tbo.priority = bp->priority;if (bp->type == ttm_bo_type_kernel) - bo->tbo.priority =1 ; + bo->tbo.priority =TTM_BO_PRIORITY_VERYHIGH ;
if (bp->type == ttm_bo_type_kernel) bo->tbo.priority = TTM_BO_PRIORITY_VERYHIGH; else bo->tbo.priority = bp->priority;
would be clearer I think.
Signature · 6 lines
Earthling Michel Dänzer | https://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): a8803c5e-d911-992e-2b67-13ed6ca29ccf-otUistvHUpPR7s880joybQ@public.gmane.org
Quoted 3 lines · Michel Dänzer
Quoted 1 line · Chunming Zhou
Signed-off-by Chunming Zhou <[email protected]>Please provide corresponding UMD patches showing how this is to be used.
spec is here:
https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html, please search "|VkMemoryPriorityAllocateInfoEXT|".
Fortunately, Windows guy already implemented it before, otherwise, I cannot find ready code on opensource, I hate this chicken first and egg first question :
https://github.com/GPUOpen-Drivers/pal/blob/dev/src/core/gpuMemory.cpp, please search "createInfo.priority".
https://github.com/GPUOpen-Drivers/pal/blob/dev/inc/core/palGpuMemory.h, priority definition is here.
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data, · line 235
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2
-0@@ -229,6 +231,14 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,if (args->in.domains & ~AMDGPU_GEM_DOMAIN_MASK )return -EINVAL ; +/* check priority */ +if (args->in.priority ==0 ) {Did you verify that this is 0 with old userspace compiled against struct
drm_amdgpu_gem_create_inwithout the priority field?
Without priority field, I don't think we can check here. Do you mean we need to add a new args struct?
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data, · line 240
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +5
-0+/* default is normal */ + args->in.priority =TTM_BO_PRIORITY_NORMAL ; + }else if (args->in.priority >TTM_MAX_BO_PRIORITY ) { + args->in.priority =TTM_MAX_BO_PRIORITY ; +DRM_ERROR ("priority specified from user space is over MAX priority\n" );This must be
DRM_DEBUG, or buggy/malicious userspace can spam dmesg.
Will change.
Quoted 20 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data, · line 266
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1
-0@@ -252,6 +262,7 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data, r =amdgpu_gem_object_create (adev, size, args->in.alignment, (u32)(0xffffffff & args->in.domains), + args->in.priority -1 , flags, ttm_bo_type_device, resv, &gobj);It might be less confusing to subtract 1 after checking against
TTM_MAX_BO_PRIORITYinstead of here. Still kind of confusing though. How about this instead:Make the priority field of struct
drm_amdgpu_gem_create_insigned. Inamdgpu_gem_create_ioctl, clamp the priority to the supported range:args->in.priority += TTM_BO_PRIORITY_NORMAL; args->in.priority = max(args->in.priority, 0); args->in.priority = min(args->in.priority, TTM_BO_PRIORITY_NORMAL - 1);
Quoted 4 lines
This way userspace doesn't need to do a weird mapping of the priority values (where 0 and 2 have the same meaning), and the range of supported priorities could at least theoretically be extended without breaking userspace.
First, I want to explain a bit the priority value from vulkan:
" From Vulkan Spec, 0.0 <= value <= 1.0, and the granularity of the priorities is implementation-dependent. One thing Spec forced is that if VkMemoryPriority not specified as default behavior, it is as if the priority value is 0.5. Our strategy is that map 0.5 to GpuMemPriority::Normal-GpuMemPriorityOffset::Offset0, which is consistent to MemoryPriorityDefault. We adopts GpuMemPriority::VeryLow, GpuMemPriority::Low, GpuMemPriority::Normal, GpuMemPriority::High, 4 priority grades, each of which contains 8 steps of offests. This maps [0.0-1.0) to totally 32 steps. Finally, 1.0 maps to GpuMemPriority::VeryHigh.
"
So my original purpose is directly use Priority enum defined in PAL, like this:
"
/// Specifies Base Level priority per GPU memory allocation as a hint to the memory manager in the event it needs to /// select allocations to page out of their preferred heaps.
enum class GpuMemPriority : uint32
{
Unused = 0x0, ///< Indicates that the allocation is not currently being used at all, and should be the first /// choice to be paged out.
VeryLow = 0x1, ///< Lowest priority to keep in its preferred heap.
Low = 0x2, ///< Low priority to keep in its preferred heap.
Normal = 0x3, ///< Normal priority to keep in its preferred heap.
High = 0x4, ///< High priority to keep in its preferred heap (e.g., render targets). VeryHigh = 0x5, ///< Highest priority to keep in its preferred heap. Last choice to be paged out (e.g., page /// tables, displayable allocations).
Count
};
"
If according your idea, we will need to convert it again when hooking linux implementation. So what do think we still use unsigned?
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_userptr_ioctl(struct drm_device *dev, void *data, · line 319
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1
-0@@ -304,6 +315,7 @@ int amdgpu_gem_userptr_ioctl(struct drm_device *dev, void *data,/* create a gem object to contain this object in */ r =amdgpu_gem_object_create (adev, args->size,0 ,AMDGPU_GEM_DOMAIN_CPU , +TTM_BO_PRIORITY_NORMAL ,0 , ttm_bo_type_device,NULL , &gobj);Should the userptr ioctl also allow setting the priority?
We can.
Quoted 19 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0
-0drivers/gpu/drm/amd/amdgpu/amdgpu_object.c static int amdgpu_bo_do_create(struct amdgpu_device *adev, · line 499
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2
-1@@ -494,8 +494,9 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, bo->tbo.bdev = &adev->mman.bdev;amdgpu_bo_placement_from_domain (bo, bp->domain); + bo->tbo.priority = bp->priority;if (bp->type == ttm_bo_type_kernel) - bo->tbo.priority =1 ; + bo->tbo.priority =TTM_BO_PRIORITY_VERYHIGH ;if (bp->type == ttm_bo_type_kernel) bo->tbo.priority = TTM_BO_PRIORITY_VERYHIGH; else bo->tbo.priority = bp->priority;
Quoted 1 line
would be clearer I think.
Agree.
-David
Quoted 2 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1d4f0b7d-f726-3cad-13c3-36e670f35baf-5C7GfCeVMHo@public.gmane.org
Quoted 11 lines · On 2019-03-07 11:48 a.m., zhoucm1 wrote:
Quoted 3 lines · Michel Dänzer
Quoted 1 line · Chunming Zhou
Signed-off-by Chunming Zhou <[email protected]>Please provide corresponding UMD patches showing how this is to be used.
spec is here:
https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html,
please search "|VkMemoryPriorityAllocateInfoEXT|".Fortunately, Windows guy already implemented it before, otherwise, I cannot find ready code on opensource, I hate this chicken first and egg first question :
Whether you like it or not, the rule documented in Documentation/gpu/drm-uapi.rst is clear: New UAPI cannot go upstream before corresponding userspace patches have been reviewed. This is important to avoid adding broken/unmaintainable UAPI.
Quoted 4 lines
https://github.com/GPUOpen-Drivers/pal/blob/dev/src/core/gpuMemory.cpp,
please search "createInfo.priority".
https://github.com/GPUOpen-Drivers/pal/blob/dev/inc/core/palGpuMemory.h,
priority definition is here.
These don't show how the priority field of structdrm_amdgpu_gem_create_in is used.
Quoted 10 lines
Quoted 8 lines
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-0@@ -229,6 +231,14 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data, if (args->in.domains & ~AMDGPU_GEM_DOMAIN_MASK) return -EINVAL;+ /* check priority */
+ if (args->in.priority== 0) {Did you verify that this is 0 with old userspace compiled against struct
drm_amdgpu_gem_create_inwithout the priority field?Without priority field, I don't think we can check here. Do you mean we need to add a new args struct?
I don't think so. Presumably this will be initialized to 0 if userspace doesn't pass in a value, but this needs to be verified.
Quoted 22 lines
Quoted 18 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_create_ioctl(struct drm_device · line 266
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1
-0@@ -252,6 +262,7 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data, r = amdgpu_gem_object_create(adev, size, args->in.alignment, (u32)(0xffffffff & args->in.domains), + args->in.priority - 1, flags, ttm_bo_type_device, resv, &gobj);It might be less confusing to subtract 1 after checking against
TTM_MAX_BO_PRIORITYinstead of here. Still kind of confusing though. How about this instead:Make the priority field of struct
drm_amdgpu_gem_create_insigned. Inamdgpu_gem_create_ioctl, clamp the priority to the supported range:args->in.priority +=
TTM_BO_PRIORITY_NORMAL;args->in.priority=max(args->in.priority, 0);args->in.priority=min(args->in.priority, TTM_BO_PRIORITY_NORMAL - 1);Quoted 4 lines
This way userspace doesn't need to do a weird mapping of the priority values (where 0 and 2 have the same meaning), and the range of supported priorities could at least theoretically be extended without breaking userspace.
Quoted 14 lines
First, I want to explain a bit the priority value from vulkan:
" From Vulkan Spec, 0.0 <= value <= 1.0, and the granularity of the priorities is implementation-dependent.
One thing Spec forced is that if VkMemoryPriority not specified as default behavior, it is as if the
priority value is 0.5. Our strategy is that map 0.5 to GpuMemPriority::Normal-GpuMemPriorityOffset::Offset0,
which is consistent to MemoryPriorityDefault. We adoptsGpuMemPriority::VeryLow,GpuMemPriority::Low,GpuMemPriority::Normal,GpuMemPriority::High, 4 priority grades, each of which contains 8 steps of offests.
This maps [0.0-1.0) to totally 32 steps. Finally, 1.0 maps toGpuMemPriority::VeryHigh.
"
In that case, I'd suggest making the priority field signed, and mapping the full integer range to the range of supported priorities:
* 0 maps to TTM_BO_PRIORITY_NORMAL
* INT_MIN maps to TTM_BO_PRIORITY_VERYLOW
* INT_MAX maps to TTM_BO_PRIORITY_VERYHIGH
Intermediate values are interpolated appropriately to the supported range of priorities.
This way, the Vulkan float priority value can easily be converted to the integer priority value, and the actual range of priorities used on the kernel side can be changed arbitrarily without breaking userspace.
Quoted 2 lines
So my original purpose is directly use Priority enum defined in PAL, [...]
I don't think it's a good idea to let PAL dictate UAPI.
Quoted 18 lines
Quoted 18 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c static int amdgpu_bo_do_create(struct · line 499
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2
-1@@ -494,8 +494,9 @@ static int amdgpu_bo_do_create(structamdgpu_device *adev, bo->tbo.bdev = &adev->mman.bdev; amdgpu_bo_placement_from_domain(bo, bp->domain); + bo->tbo.priority = bp->priority; if (bp->type == ttm_bo_type_kernel) - bo->tbo.priority = 1; + bo->tbo.priority = TTM_BO_PRIORITY_VERYHIGH;if (
bp->type==ttm_bo_type_kernel)bo->tbo.priority=TTM_BO_PRIORITY_VERYHIGH; else
bo->tbo.priority=bp->priority;
Quoted 2 lines
Quoted 1 line
would be clearer I think.
Agree.
Another question is whether userspace should be allowed to set the same priority as the kernel? I'm inclined to say no, there should be a separate priority for the kernel.
Signature · 6 lines
Earthling Michel Dänzer | https://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 07.03.19 um 10:15 schrieb Chunming Zhou:
Quoted 1 line
Signed-off-by Chunming Zhou <[email protected]>
Well NAK to the whole approach.
The TTM priority is a global priority, but processes are only allowed to specific the priority inside their own allocations. So this approach will never fly upstream.
What you can do is to add a priority for per vm BOs to affect their sort order on the LRU, but I doubt that this will have much of an effect.
Regards,
Christian.
Quoted 146 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 13 +++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 1 + include/drm/ttm/ttm_bo_driver.h | 9 ++++++++- include/uapi/drm/amdgpu_drm.h | 3 +++ 7 files changed, 29 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +1
-0@@ -144,6 +144,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev, size = mode_cmd->pitches[0 ] * height; aligned_size =ALIGN (size,PAGE_SIZE ); ret = amdgpu_gem_object_create(adev, aligned_size, 0, domain, + TTM_BO_PRIORITY_NORMAL, AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS | AMDGPU_GEM_CREATE_VRAM_CLEARED,drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +13
-0@@ -44,6 +44,7 @@ void amdgpu_gem_object_free(struct drm_gem_object *gobj)int amdgpu_gem_object_create (struct amdgpu_device *adev,unsigned long size,int alignment,u32 initial_domain, +enum ttm_bo_priority priority,u64 flags,enum ttm_bo_type type,struct reservation_object *resv,struct drm_gem_object **obj)@@ -60,6 +61,7 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, bp.type = type; bp.resv = resv; bp.preferred_domain = initial_domain; + bp.priority = priority; retry: bp.flags = flags; bp.domain = initial_domain;@@ -229,6 +231,14 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,if (args->in.domains & ~AMDGPU_GEM_DOMAIN_MASK )return -EINVAL ; +/* check priority */ +if (args->in.priority ==0 ) { +/* default is normal */ + args->in.priority =TTM_BO_PRIORITY_NORMAL ; + }else if (args->in.priority >TTM_MAX_BO_PRIORITY ) { + args->in.priority =TTM_MAX_BO_PRIORITY ; +DRM_ERROR ("priority specified from user space is over MAX priority\n" ); + }/* create a gem object to contain this object in */ if (args->in.domains & (AMDGPU_GEM_DOMAIN_GDS |AMDGPU_GEM_DOMAIN_GWS |AMDGPU_GEM_DOMAIN_OA )) {@@ -252,6 +262,7 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data, r =amdgpu_gem_object_create (adev, size, args->in.alignment, (u32)(0xffffffff & args->in.domains), + args->in.priority -1 , flags, ttm_bo_type_device, resv, &gobj);if (flags &AMDGPU_GEM_CREATE_VM_ALWAYS_VALID ) {if (!r) {@@ -304,6 +315,7 @@ int amdgpu_gem_userptr_ioctl(struct drm_device *dev, void *data,/* create a gem object to contain this object in */ r =amdgpu_gem_object_create (adev, args->size,0 ,AMDGPU_GEM_DOMAIN_CPU , +TTM_BO_PRIORITY_NORMAL ,0 , ttm_bo_type_device,NULL , &gobj);if (r)return r;@@ -755,6 +767,7 @@ int amdgpu_mode_dumb_create(struct drm_file *file_priv, domain =amdgpu_bo_get_preferred_pin_domain (adev,amdgpu_display_supported_domains (adev)); r =amdgpu_gem_object_create (adev, args->size,0 , domain, +TTM_BO_PRIORITY_NORMAL ,AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED , ttm_bo_type_device,NULL , &gobj);if (r)drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h +1
-1@@ -61,7 +61,7 @@ extern const struct dma_buf_ops amdgpu_dmabuf_ops;*/ void amdgpu_gem_force_release (struct amdgpu_device *adev);int amdgpu_gem_object_create (struct amdgpu_device *adev,unsigned long size, -int alignment,u32 initial_domain, +int alignment,u32 initial_domain,u32 priority,u64 flags,enum ttm_bo_type type,struct reservation_object *resv,struct drm_gem_object **obj);drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2
-1@@ -494,8 +494,9 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, bo->tbo.bdev = &adev->mman.bdev;amdgpu_bo_placement_from_domain (bo, bp->domain); + bo->tbo.priority = bp->priority;if (bp->type == ttm_bo_type_kernel) - bo->tbo.priority =1 ; + bo->tbo.priority =TTM_BO_PRIORITY_VERYHIGH ; r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, bp->type, &bo->placement, page_align, &ctx, acc_size,drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +1
-0@@ -39,6 +39,7 @@ struct amdgpu_bo_param {int byte_align;u32 domain;u32 preferred_domain; +u32 priority;u64 flags;enum ttm_bo_type type;struct reservation_object *resv;include/drm/ttm/ttm_bo_driver.h +8
-1@@ -43,7 +43,14 @@#include "ttm_placement.h" #include "ttm_tt.h" -#define TTM_MAX_BO_PRIORITY 4U +enum ttm_bo_priority { +TTM_BO_PRIORITY_VERYLOW =0 , +TTM_BO_PRIORITY_LOW , +TTM_BO_PRIORITY_NORMAL , +TTM_BO_PRIORITY_HIGH , +TTM_BO_PRIORITY_VERYHIGH , +TTM_MAX_BO_PRIORITY +};#define TTM_MEMTYPE_FLAG_FIXED (1 << 0)/* Fixed (on-card) PCI memory */ #define TTM_MEMTYPE_FLAG_MAPPABLE (1 << 1)/* Memory mappable */ include/uapi/drm/amdgpu_drm.h +0
-0
include/uapi/drm/amdgpu_drm.h struct drm_amdgpu_gem_create_in { · line 146
Quoted 9 lines
include/uapi/drm/amdgpu_drm.h +3
-0@@ -138,6 +138,9 @@ struct drm_amdgpu_gem_create_in {__u64 domains;/** allocation flags */ __u64 domain_flags; +/** priority */ +__u32 priority; +__u32 pad; };struct drm_amdgpu_gem_create_out {
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): a1efec4e-0cb9-f92f-2688-ecfd4ed7ad12-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Yes, you are right, thanks to point it out. Will see if there is other way.
-David
send from my phone
-------- Original Message --------
Subject: Re: [PATCH] drm/amdgpu: enable bo priority setting from user space
From: Christian König
To: "Zhou, David(ChunMing)" ,[email protected] CC:
Am 07.03.19 um 10:15 schrieb Chunming Zhou:
Quoted 1 line
Signed-off-by Chunming Zhou <[email protected]>
Well NAK to the whole approach.
The TTM priority is a global priority, but processes are only allowed to specific the priority inside their own allocations. So this approach will never fly upstream.
What you can do is to add a priority for per vm BOs to affect their sort order on the LRU, but I doubt that this will have much of an effect.
Regards,
Christian.
Quoted 146 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 13 +++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 1 + include/drm/ttm/ttm_bo_driver.h | 9 ++++++++- include/uapi/drm/amdgpu_drm.h | 3 +++ 7 files changed, 29 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +1
-0@@ -144,6 +144,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev, size = mode_cmd->pitches[0 ] * height; aligned_size =ALIGN (size,PAGE_SIZE ); ret = amdgpu_gem_object_create(adev, aligned_size, 0, domain, + TTM_BO_PRIORITY_NORMAL, AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS | AMDGPU_GEM_CREATE_VRAM_CLEARED,drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +13
-0@@ -44,6 +44,7 @@ void amdgpu_gem_object_free(struct drm_gem_object *gobj)int amdgpu_gem_object_create (struct amdgpu_device *adev,unsigned long size,int alignment,u32 initial_domain, +enum ttm_bo_priority priority,u64 flags,enum ttm_bo_type type,struct reservation_object *resv,struct drm_gem_object **obj)@@ -60,6 +61,7 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, bp.type = type; bp.resv = resv; bp.preferred_domain = initial_domain; + bp.priority = priority; retry: bp.flags = flags; bp.domain = initial_domain;@@ -229,6 +231,14 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,if (args->in.domains & ~AMDGPU_GEM_DOMAIN_MASK )return -EINVAL ; +/* check priority */ +if (args->in.priority ==0 ) { +/* default is normal */ + args->in.priority =TTM_BO_PRIORITY_NORMAL ; + }else if (args->in.priority >TTM_MAX_BO_PRIORITY ) { + args->in.priority =TTM_MAX_BO_PRIORITY ; +DRM_ERROR ("priority specified from user space is over MAX priority\n" ); + }/* create a gem object to contain this object in */ if (args->in.domains & (AMDGPU_GEM_DOMAIN_GDS |AMDGPU_GEM_DOMAIN_GWS |AMDGPU_GEM_DOMAIN_OA )) {@@ -252,6 +262,7 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data, r =amdgpu_gem_object_create (adev, size, args->in.alignment, (u32)(0xffffffff & args->in.domains), + args->in.priority -1 , flags, ttm_bo_type_device, resv, &gobj);if (flags &AMDGPU_GEM_CREATE_VM_ALWAYS_VALID ) {if (!r) {@@ -304,6 +315,7 @@ int amdgpu_gem_userptr_ioctl(struct drm_device *dev, void *data,/* create a gem object to contain this object in */ r =amdgpu_gem_object_create (adev, args->size,0 ,AMDGPU_GEM_DOMAIN_CPU , +TTM_BO_PRIORITY_NORMAL ,0 , ttm_bo_type_device,NULL , &gobj);if (r)return r;@@ -755,6 +767,7 @@ int amdgpu_mode_dumb_create(struct drm_file *file_priv, domain =amdgpu_bo_get_preferred_pin_domain (adev,amdgpu_display_supported_domains (adev)); r =amdgpu_gem_object_create (adev, args->size,0 , domain, +TTM_BO_PRIORITY_NORMAL ,AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED , ttm_bo_type_device,NULL , &gobj);if (r)drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h +1
-1@@ -61,7 +61,7 @@ extern const struct dma_buf_ops amdgpu_dmabuf_ops;*/ void amdgpu_gem_force_release (struct amdgpu_device *adev);int amdgpu_gem_object_create (struct amdgpu_device *adev,unsigned long size, -int alignment,u32 initial_domain, +int alignment,u32 initial_domain,u32 priority,u64 flags,enum ttm_bo_type type,struct reservation_object *resv,struct drm_gem_object **obj);drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2
-1@@ -494,8 +494,9 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, bo->tbo.bdev = &adev->mman.bdev;amdgpu_bo_placement_from_domain (bo, bp->domain); + bo->tbo.priority = bp->priority;if (bp->type == ttm_bo_type_kernel) - bo->tbo.priority =1 ; + bo->tbo.priority =TTM_BO_PRIORITY_VERYHIGH ; r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, bp->type, &bo->placement, page_align, &ctx, acc_size,drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +1
-0@@ -39,6 +39,7 @@ struct amdgpu_bo_param {int byte_align;u32 domain;u32 preferred_domain; +u32 priority;u64 flags;enum ttm_bo_type type;struct reservation_object *resv;include/drm/ttm/ttm_bo_driver.h +8
-1@@ -43,7 +43,14 @@#include "ttm_placement.h" #include "ttm_tt.h" -#define TTM_MAX_BO_PRIORITY 4U +enum ttm_bo_priority { +TTM_BO_PRIORITY_VERYLOW =0 , +TTM_BO_PRIORITY_LOW , +TTM_BO_PRIORITY_NORMAL , +TTM_BO_PRIORITY_HIGH , +TTM_BO_PRIORITY_VERYHIGH , +TTM_MAX_BO_PRIORITY +};#define TTM_MEMTYPE_FLAG_FIXED (1 << 0)/* Fixed (on-card) PCI memory */ #define TTM_MEMTYPE_FLAG_MAPPABLE (1 << 1)/* Memory mappable */ include/uapi/drm/amdgpu_drm.h +0
-0
include/uapi/drm/amdgpu_drm.h struct drm_amdgpu_gem_create_in { · line 146
Quoted 9 lines
include/uapi/drm/amdgpu_drm.h +3
-0@@ -138,6 +138,9 @@ struct drm_amdgpu_gem_create_in {__u64 domains;/** allocation flags */ __u64 domain_flags; +/** priority */ +__u32 priority; +__u32 pad; };struct drm_amdgpu_gem_create_out {
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): -o8xodt-v7ma50s620vm-x3ufrzt16m3ru4l9qc4l8rct-ppumfj-lgzfos2xnj696p97zq-q88klx-1xor439yr648-3s2lfc-pglvz8-9du7dn8goc66-3zd1sv-cy6o2qkurchc-gpwxlg-c9iov0a657ue.1551963984191-2ueSQiBKiTY7tOexoI0I+QC/[email protected]
Well you can already use the per submission priority for the BOs.
Additional to that as I said for per VM BOs we can add a priority to sort them in the LRU.
Not sure how effective both of those actually are.
Regards,
Christian.
Am 07.03.19 um 14:09 schrieb Zhou, David(ChunMing):
Yes, you are right, thanks to point it out. Will see if there is other way.
-David
send from my phone
-------- Original Message --------
Subject: Re: [PATCH] drm/amdgpu: enable bo priority setting from user space
From: Christian König
To: "Zhou, David(ChunMing)" ,[email protected]<mailto:[email protected]> CC:
Am 07.03.19 um 10:15 schrieb Chunming Zhou:
Quoted 1 line
Well NAK to the whole approach.
The TTM priority is a global priority, but processes are only allowed to specific the priority inside their own allocations. So this approach will never fly upstream.
What you can do is to add a priority for per vm BOs to affect their sort order on the LRU, but I doubt that this will have much of an effect.
Regards,
Christian.
Quoted 146 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 13 +++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 1 + include/drm/ttm/ttm_bo_driver.h | 9 ++++++++- include/uapi/drm/amdgpu_drm.h | 3 +++ 7 files changed, 29 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +1
-0@@ -144,6 +144,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev, size = mode_cmd->pitches[0 ] * height; aligned_size =ALIGN (size,PAGE_SIZE ); ret = amdgpu_gem_object_create(adev, aligned_size, 0, domain, + TTM_BO_PRIORITY_NORMAL, AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS | AMDGPU_GEM_CREATE_VRAM_CLEARED,drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +13
-0@@ -44,6 +44,7 @@ void amdgpu_gem_object_free(struct drm_gem_object *gobj)int amdgpu_gem_object_create (struct amdgpu_device *adev,unsigned long size,int alignment,u32 initial_domain, +enum ttm_bo_priority priority,u64 flags,enum ttm_bo_type type,struct reservation_object *resv,struct drm_gem_object **obj)@@ -60,6 +61,7 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, bp.type = type; bp.resv = resv; bp.preferred_domain = initial_domain; + bp.priority = priority; retry: bp.flags = flags; bp.domain = initial_domain;@@ -229,6 +231,14 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,if (args->in.domains & ~AMDGPU_GEM_DOMAIN_MASK )return -EINVAL ; +/* check priority */ +if (args->in.priority ==0 ) { +/* default is normal */ + args->in.priority =TTM_BO_PRIORITY_NORMAL ; + }else if (args->in.priority >TTM_MAX_BO_PRIORITY ) { + args->in.priority =TTM_MAX_BO_PRIORITY ; +DRM_ERROR ("priority specified from user space is over MAX priority\n" ); + }/* create a gem object to contain this object in */ if (args->in.domains & (AMDGPU_GEM_DOMAIN_GDS |AMDGPU_GEM_DOMAIN_GWS |AMDGPU_GEM_DOMAIN_OA )) {@@ -252,6 +262,7 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data, r =amdgpu_gem_object_create (adev, size, args->in.alignment, (u32)(0xffffffff & args->in.domains), + args->in.priority -1 , flags, ttm_bo_type_device, resv, &gobj);if (flags &AMDGPU_GEM_CREATE_VM_ALWAYS_VALID ) {if (!r) {@@ -304,6 +315,7 @@ int amdgpu_gem_userptr_ioctl(struct drm_device *dev, void *data,/* create a gem object to contain this object in */ r =amdgpu_gem_object_create (adev, args->size,0 ,AMDGPU_GEM_DOMAIN_CPU , +TTM_BO_PRIORITY_NORMAL ,0 , ttm_bo_type_device,NULL , &gobj);if (r)return r;@@ -755,6 +767,7 @@ int amdgpu_mode_dumb_create(struct drm_file *file_priv, domain =amdgpu_bo_get_preferred_pin_domain (adev,amdgpu_display_supported_domains (adev)); r =amdgpu_gem_object_create (adev, args->size,0 , domain, +TTM_BO_PRIORITY_NORMAL ,AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED , ttm_bo_type_device,NULL , &gobj);if (r)drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h +1
-1@@ -61,7 +61,7 @@ extern const struct dma_buf_ops amdgpu_dmabuf_ops;*/ void amdgpu_gem_force_release (struct amdgpu_device *adev);int amdgpu_gem_object_create (struct amdgpu_device *adev,unsigned long size, -int alignment,u32 initial_domain, +int alignment,u32 initial_domain,u32 priority,u64 flags,enum ttm_bo_type type,struct reservation_object *resv,struct drm_gem_object **obj);drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2
-1@@ -494,8 +494,9 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, bo->tbo.bdev = &adev->mman.bdev;amdgpu_bo_placement_from_domain (bo, bp->domain); + bo->tbo.priority = bp->priority;if (bp->type == ttm_bo_type_kernel) - bo->tbo.priority =1 ; + bo->tbo.priority =TTM_BO_PRIORITY_VERYHIGH ; r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, bp->type, &bo->placement, page_align, &ctx, acc_size,drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +1
-0@@ -39,6 +39,7 @@ struct amdgpu_bo_param {int byte_align;u32 domain;u32 preferred_domain; +u32 priority;u64 flags;enum ttm_bo_type type;struct reservation_object *resv;include/drm/ttm/ttm_bo_driver.h +8
-1@@ -43,7 +43,14 @@#include "ttm_placement.h" #include "ttm_tt.h" -#define TTM_MAX_BO_PRIORITY 4U +enum ttm_bo_priority { +TTM_BO_PRIORITY_VERYLOW =0 , +TTM_BO_PRIORITY_LOW , +TTM_BO_PRIORITY_NORMAL , +TTM_BO_PRIORITY_HIGH , +TTM_BO_PRIORITY_VERYHIGH , +TTM_MAX_BO_PRIORITY +};#define TTM_MEMTYPE_FLAG_FIXED (1 << 0)/* Fixed (on-card) PCI memory */ #define TTM_MEMTYPE_FLAG_MAPPABLE (1 << 1)/* Memory mappable */ include/uapi/drm/amdgpu_drm.h +0
-0
include/uapi/drm/amdgpu_drm.h struct drm_amdgpu_gem_create_in { · line 146
Quoted 9 lines
include/uapi/drm/amdgpu_drm.h +3
-0@@ -138,6 +138,9 @@ struct drm_amdgpu_gem_create_in {__u64 domains;/** allocation flags */ __u64 domain_flags; +/** priority */ +__u32 priority; +__u32 pad; };struct drm_amdgpu_gem_create_out {
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): b2fed38f-bcc1-07df-625c-fa912022bdd4-5C7GfCeVMHo@public.gmane.org
yes,per submission bo list priority already is used by us. but per vm bo still is in fly, no priority on that.
-David
send from my phone
-------- Original Message --------
Subject: Re: [PATCH] drm/amdgpu: enable bo priority setting from user space
From: "Koenig, Christian"
To: "Zhou, David(ChunMing)" ,[email protected]
CC:
Well you can already use the per submission priority for the BOs.
Additional to that as I said for per VM BOs we can add a priority to sort them in the LRU.
Not sure how effective both of those actually are.
Regards,
Christian.
Am 07.03.19 um 14:09 schrieb Zhou, David(ChunMing):
Yes, you are right, thanks to point it out. Will see if there is other way.
-David
send from my phone
-------- Original Message --------
Subject: Re: [PATCH] drm/amdgpu: enable bo priority setting from user space
From: Christian König
To: "Zhou, David(ChunMing)" ,[email protected]<mailto:[email protected]> CC:
Am 07.03.19 um 10:15 schrieb Chunming Zhou:
Quoted 1 line
Well NAK to the whole approach.
The TTM priority is a global priority, but processes are only allowed to specific the priority inside their own allocations. So this approach will never fly upstream.
What you can do is to add a priority for per vm BOs to affect their sort order on the LRU, but I doubt that this will have much of an effect.
Regards,
Christian.
Quoted 146 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 13 +++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 1 + include/drm/ttm/ttm_bo_driver.h | 9 ++++++++- include/uapi/drm/amdgpu_drm.h | 3 +++ 7 files changed, 29 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +1
-0@@ -144,6 +144,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev, size = mode_cmd->pitches[0 ] * height; aligned_size =ALIGN (size,PAGE_SIZE ); ret = amdgpu_gem_object_create(adev, aligned_size, 0, domain, + TTM_BO_PRIORITY_NORMAL, AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS | AMDGPU_GEM_CREATE_VRAM_CLEARED,drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +13
-0@@ -44,6 +44,7 @@ void amdgpu_gem_object_free(struct drm_gem_object *gobj)int amdgpu_gem_object_create (struct amdgpu_device *adev,unsigned long size,int alignment,u32 initial_domain, +enum ttm_bo_priority priority,u64 flags,enum ttm_bo_type type,struct reservation_object *resv,struct drm_gem_object **obj)@@ -60,6 +61,7 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, bp.type = type; bp.resv = resv; bp.preferred_domain = initial_domain; + bp.priority = priority; retry: bp.flags = flags; bp.domain = initial_domain;@@ -229,6 +231,14 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,if (args->in.domains & ~AMDGPU_GEM_DOMAIN_MASK )return -EINVAL ; +/* check priority */ +if (args->in.priority ==0 ) { +/* default is normal */ + args->in.priority =TTM_BO_PRIORITY_NORMAL ; + }else if (args->in.priority >TTM_MAX_BO_PRIORITY ) { + args->in.priority =TTM_MAX_BO_PRIORITY ; +DRM_ERROR ("priority specified from user space is over MAX priority\n" ); + }/* create a gem object to contain this object in */ if (args->in.domains & (AMDGPU_GEM_DOMAIN_GDS |AMDGPU_GEM_DOMAIN_GWS |AMDGPU_GEM_DOMAIN_OA )) {@@ -252,6 +262,7 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data, r =amdgpu_gem_object_create (adev, size, args->in.alignment, (u32)(0xffffffff & args->in.domains), + args->in.priority -1 , flags, ttm_bo_type_device, resv, &gobj);if (flags &AMDGPU_GEM_CREATE_VM_ALWAYS_VALID ) {if (!r) {@@ -304,6 +315,7 @@ int amdgpu_gem_userptr_ioctl(struct drm_device *dev, void *data,/* create a gem object to contain this object in */ r =amdgpu_gem_object_create (adev, args->size,0 ,AMDGPU_GEM_DOMAIN_CPU , +TTM_BO_PRIORITY_NORMAL ,0 , ttm_bo_type_device,NULL , &gobj);if (r)return r;@@ -755,6 +767,7 @@ int amdgpu_mode_dumb_create(struct drm_file *file_priv, domain =amdgpu_bo_get_preferred_pin_domain (adev,amdgpu_display_supported_domains (adev)); r =amdgpu_gem_object_create (adev, args->size,0 , domain, +TTM_BO_PRIORITY_NORMAL ,AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED , ttm_bo_type_device,NULL , &gobj);if (r)drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h +1
-1@@ -61,7 +61,7 @@ extern const struct dma_buf_ops amdgpu_dmabuf_ops;*/ void amdgpu_gem_force_release (struct amdgpu_device *adev);int amdgpu_gem_object_create (struct amdgpu_device *adev,unsigned long size, -int alignment,u32 initial_domain, +int alignment,u32 initial_domain,u32 priority,u64 flags,enum ttm_bo_type type,struct reservation_object *resv,struct drm_gem_object **obj);drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2
-1@@ -494,8 +494,9 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, bo->tbo.bdev = &adev->mman.bdev;amdgpu_bo_placement_from_domain (bo, bp->domain); + bo->tbo.priority = bp->priority;if (bp->type == ttm_bo_type_kernel) - bo->tbo.priority =1 ; + bo->tbo.priority =TTM_BO_PRIORITY_VERYHIGH ; r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, bp->type, &bo->placement, page_align, &ctx, acc_size,drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +1
-0@@ -39,6 +39,7 @@ struct amdgpu_bo_param {int byte_align;u32 domain;u32 preferred_domain; +u32 priority;u64 flags;enum ttm_bo_type type;struct reservation_object *resv;include/drm/ttm/ttm_bo_driver.h +8
-1@@ -43,7 +43,14 @@#include "ttm_placement.h" #include "ttm_tt.h" -#define TTM_MAX_BO_PRIORITY 4U +enum ttm_bo_priority { +TTM_BO_PRIORITY_VERYLOW =0 , +TTM_BO_PRIORITY_LOW , +TTM_BO_PRIORITY_NORMAL , +TTM_BO_PRIORITY_HIGH , +TTM_BO_PRIORITY_VERYHIGH , +TTM_MAX_BO_PRIORITY +};#define TTM_MEMTYPE_FLAG_FIXED (1 << 0)/* Fixed (on-card) PCI memory */ #define TTM_MEMTYPE_FLAG_MAPPABLE (1 << 1)/* Memory mappable */ include/uapi/drm/amdgpu_drm.h +0
-0
include/uapi/drm/amdgpu_drm.h struct drm_amdgpu_gem_create_in { · line 146
Quoted 9 lines
include/uapi/drm/amdgpu_drm.h +3
-0@@ -138,6 +138,9 @@ struct drm_amdgpu_gem_create_in {__u64 domains;/** allocation flags */ __u64 domain_flags; +/** priority */ +__u32 priority; +__u32 pad; };struct drm_amdgpu_gem_create_out {
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx