drm/amdgpu/gfx9: support the amdgpu.disable_cu option
Subsystems (3)
PATCH 1/1 drm/amdgpu/gfx9: support the amdgpu.disable_cu option
From: Nicolai Hähnle <[email protected]>
This is ported from gfx8.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +20 -0
@@ -4409,51 +4409,71 @@ static void gfx_v9_0_set_gds_init(struct amdgpu_device *adev) adev->gds.mem.cs_partition_size =1024 ; adev->gds.gws.gfx_partition_size =16 ; adev->gds.gws.cs_partition_size =16 ; adev->gds.oa.gfx_partition_size =4 ; adev->gds.oa.cs_partition_size =4 ; } } +static void gfx_v9_0_set_user_cu_inactive_bitmap (struct amdgpu_device *adev, +u32 bitmap) +{ +u32 data; + +if (!bitmap) +return ; + + data = bitmap <<GC_USER_SHADER_ARRAY_CONFIG__INACTIVE_CUS__SHIFT ; + data &=GC_USER_SHADER_ARRAY_CONFIG__INACTIVE_CUS_MASK ; + +WREG32_SOC15 (GC ,0 , mmGC_USER_SHADER_ARRAY_CONFIG, data); +} +static u32 gfx_v9_0_get_cu_active_bitmap (struct amdgpu_device *adev) {u32 data, mask; data =RREG32_SOC15 (GC ,0 , mmCC_GC_SHADER_ARRAY_CONFIG); data |=RREG32_SOC15 (GC ,0 , mmGC_USER_SHADER_ARRAY_CONFIG); data &=CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS_MASK ; data >>=CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS__SHIFT ; mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_cu_per_sh);return (~data) & mask; }static int gfx_v9_0_get_cu_info (struct amdgpu_device *adev,struct amdgpu_cu_info *cu_info) {int i, j, k, counter, active_cu_number =0 ;u32 mask, bitmap, ao_bitmap, ao_cu_mask =0 ; +unsigned disable_masks[4 *2 ];if (!adev || !cu_info)return -EINVAL ; +amdgpu_gfx_parse_disable_cu (disable_masks,4 ,2 ); +mutex_lock (&adev->grbm_idx_mutex);for (i =0 ; i < adev->gfx.config.max_shader_engines; i++) {for (j =0 ; j < adev->gfx.config.max_sh_per_se; j++) { mask =1 ; ao_bitmap =0 ; counter =0 ;gfx_v9_0_select_se_sh (adev, i, j,0xffffffff ); +if (i <4 && j <2 ) +gfx_v9_0_set_user_cu_inactive_bitmap ( + adev, disable_masks[i *2 + j]); bitmap =gfx_v9_0_get_cu_active_bitmap (adev); cu_info->bitmap[i][j] = bitmap;for (k =0 ; k < adev->gfx.config.max_cu_per_sh; k ++) {if (bitmap & mask) {if (counter < adev->gfx.config.max_cu_per_sh) ao_bitmap |= mask; counter ++; } mask <<=1 ;
Signature · 6 lines
2.9.3 _______________________________________________ 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): 20170613201205.21138-1-nhaehnle-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
upsteam find bo api
Hi all,
Since patches are one feature, and contain kernel and libdrm, I attached them not by send-mail. Hope not inconvenience.
0001-drm-amdgpu-return-bo-itself-if-userptr-is-cpu-addr-o.patch is kernel patch. Other three is libdrm patches including unit test.
please review.
Regards,
David Zhou
Quoted 1 line
From
a388eeb1b1f59db55743407989d539bc3d546b82Mon Sep 17 00:00:00 2001
From: Chunming Zhou <[email protected]>
Date: Wed, 25 Nov 2015 18:09:10 +0800
Subject: [PATCH] drm/amdgpu: return bo itself if userptr is cpu addr of bo V2
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
V2: get original gem handle from gobj
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 59 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 3 +- include/uapi/drm/amdgpu_drm.h | 12 +++++++ 4 files changed, 75 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
@@ -1389,6 +1389,8 @@ int amdgpu_gem_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp);int amdgpu_gem_userptr_ioctl (struct drm_device *dev,void *data,struct drm_file *filp); +int amdgpu_gem_find_bo_by_cpu_mapping_ioctl (struct drm_device *dev,void *data, +struct drm_file *filp);int amdgpu_gem_mmap_ioctl (struct drm_device *dev,void *data,struct drm_file *filp); int amdgpu_gem_wait_idle_ioctl(struct drm_device *dev, void *data,
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +59 -0
65 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +2 -1
@@ -1069,7 +1069,8 @@ int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,DRM_IOCTL_DEF_DRV (AMDGPU_GEM_VA , amdgpu_gem_va_ioctl,DRM_AUTH |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF_DRV (AMDGPU_GEM_OP , amdgpu_gem_op_ioctl,DRM_AUTH |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF_DRV (AMDGPU_GEM_USERPTR , amdgpu_gem_userptr_ioctl,DRM_AUTH |DRM_RENDER_ALLOW ), - DRM_IOCTL_DEF_DRV(AMDGPU_FREESYNC, amdgpu_freesync_ioctl, DRM_MASTER) +DRM_IOCTL_DEF_DRV (AMDGPU_FREESYNC , amdgpu_freesync_ioctl,DRM_MASTER ), + DRM_IOCTL_DEF_DRV(AMDGPU_GEM_FIND_BO, amdgpu_gem_find_bo_by_cpu_mapping_ioctl, DRM_AUTH|DRM_RENDER_ALLOW) };const int amdgpu_max_kms_ioctl =ARRAY_SIZE (amdgpu_ioctls_kms);
include/uapi/drm/amdgpu_drm.h +12 -0
@@ -53,6 +53,7 @@#define DRM_AMDGPU_WAIT_FENCES 0x12#define DRM_AMDGPU_VM 0x13#define DRM_AMDGPU_FREESYNC 0x14 +#define DRM_AMDGPU_GEM_FIND_BO 0x15#define DRM_IOCTL_AMDGPU_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)#define DRM_IOCTL_AMDGPU_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)
@@ -69,6 +70,7 @@#define DRM_IOCTL_AMDGPU_WAIT_FENCES DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_FENCES, union drm_amdgpu_wait_fences)#define DRM_IOCTL_AMDGPU_VM DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_VM, union drm_amdgpu_vm)#define DRM_IOCTL_AMDGPU_FREESYNC DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_FREESYNC, struct drm_amdgpu_freesync) +#define DRM_IOCTL_AMDGPU_GEM_FIND_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_FIND_BO, struct drm_amdgpu_gem_find_bo)#define AMDGPU_GEM_DOMAIN_CPU 0x1#define AMDGPU_GEM_DOMAIN_GTT 0x2
@@ -233,6 +235,16 @@ struct drm_amdgpu_gem_userptr {__u32 handle; }; +struct drm_amdgpu_gem_find_bo { +uint64_t addr; +uint64_t size; +uint32_t flags; +/* Resulting GEM handle */ +uint32_t handle; +/* offset in bo */ +uint64_t offset; +}; +/* SI-CI-VI: */ /* same meaning as the GB_TILE_MODE and GL_MACRO_TILE_MODE fields */ #define AMDGPU_TILING_ARRAY_MODE_SHIFT 0
Signature · 1 line
1.9.1
Quoted 1 line
From
108cdd7f8685521481a01db91433a5dcc938687dMon Sep 17 00:00:00 2001
From: Chunming Zhou <[email protected]>
Date: Thu, 26 Nov 2015 17:01:07 +0800
Subject: [PATCH] amdgpu: add amdgpu_find_bo_by_cpu_mapping interface
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
userspace needs to know if the user memory is from BO or malloc.
--- amdgpu/amdgpu.h | 24 ++++++++++++++++++++++++ amdgpu/amdgpu_bo.c | 37 +++++++++++++++++++++++++++++++++++++ include/drm/amdgpu_drm.h | 12 ++++++++++++ 3 files changed, 73 insertions(+)
amdgpu/amdgpu.h +24 -0
@@ -672,6 +672,30 @@ int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev, amdgpu_bo_handle *buf_handle);/** +* Validate if the user memory comes from BO +* +* \param dev - [in] Device handle. See #amdgpu_device_initialize() +* \param cpu - [in] CPU address of user allocated memory which we +* want to map to GPU address space (make GPU accessible) +* (This address must be correctly aligned). +* \param size - [in] Size of allocation (must be correctly aligned) +* \param buf_handle - [out] Buffer handle for the userptr memory +* if the user memory is not from BO, the buf_handle will be NULL. +* \param offset_in_bo - [out] offset in this BO for this user memory +* +* +* \return 0 on success\n +* <0 - Negative POSIX Error code +* +*/ +int amdgpu_find_bo_by_cpu_mapping (amdgpu_device_handle dev, +void *cpu, +uint64_t size, +amdgpu_bo_handle *buf_handle, +uint64_t *offset_in_bo); + + +/** * Free previosuly allocated memory * * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
amdgpu/amdgpu_bo.c +37 -0
@@ -529,6 +529,43 @@ int amdgpu_bo_wait_for_idle(amdgpu_bo_handle bo, } } +int amdgpu_find_bo_by_cpu_mapping (amdgpu_device_handle dev, +void *cpu, +uint64_t size, +amdgpu_bo_handle *buf_handle, +uint64_t *offset_in_bo) +{ +int r; +struct amdgpu_bo *bo; +struct drm_amdgpu_gem_find_bo args; + + args.addr = (uintptr_t )cpu; + args.size = size; + r =drmCommandWriteRead (dev->fd,DRM_AMDGPU_GEM_FIND_BO , + &args,sizeof (args)); +if (r) +return r; +if (args.handle ==0 ) +return -EINVAL ; + bo =util_hash_table_get (dev->bo_handles, + (void *)(uintptr_t )args.handle); +if (!bo) { + bo =calloc (1 ,sizeof (struct amdgpu_bo )); +if (!bo) +return -ENOMEM ; +atomic_set (&bo->refcount,1 ); + bo->dev = dev; + bo->alloc_size = size; + bo->handle = args.handle; + }else +atomic_inc (&bo->refcount); + + *buf_handle = bo; + *offset_in_bo = args.offset; +return r; +} + + int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev, void *cpu, uint64_t size,
include/drm/amdgpu_drm.h +12 -0
@@ -47,6 +47,7 @@#define DRM_AMDGPU_GEM_OP 0x10#define DRM_AMDGPU_GEM_USERPTR 0x11#define DRM_AMDGPU_WAIT_FENCES 0x12 +#define DRM_AMDGPU_GEM_FIND_BO 0x15#define DRM_IOCTL_AMDGPU_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)#define DRM_IOCTL_AMDGPU_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)
@@ -61,6 +62,7 @@#define DRM_IOCTL_AMDGPU_GEM_OP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_OP, struct drm_amdgpu_gem_op)#define DRM_IOCTL_AMDGPU_GEM_USERPTR DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_USERPTR, struct drm_amdgpu_gem_userptr)#define DRM_IOCTL_AMDGPU_WAIT_FENCES DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_FENCES, union drm_amdgpu_wait_fences) +#define DRM_IOCTL_AMDGPU_GEM_FIND_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_FIND_BO, struct drm_amdgpu_gem_find_bo)#define AMDGPU_GEM_DOMAIN_CPU 0x1#define AMDGPU_GEM_DOMAIN_GTT 0x2
@@ -201,6 +203,16 @@ struct drm_amdgpu_gem_userptr {uint32_t handle; }; +struct drm_amdgpu_gem_find_bo { +uint64_t addr; +uint64_t size; +uint32_t flags; +/* Resulting GEM handle */ +uint32_t handle; +/* offset in bo */ +uint64_t offset; +}; +/* same meaning as the GB_TILE_MODE and GL_MACRO_TILE_MODE fields */ #define AMDGPU_TILING_ARRAY_MODE_SHIFT 0#define AMDGPU_TILING_ARRAY_MODE_MASK 0xf
Signature · 1 line
1.9.1
Quoted 1 line
From
f953cc6627fa4928d39d3de7c0e0f6a89c1e18ecMon Sep 17 00:00:00 2001
From: Chunming Zhou <[email protected]>
Date: Thu, 3 Dec 2015 16:52:33 +0800
Subject: [PATCH] amdgpu: add bo handle to hash table when cpu mapping
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
--- amdgpu/amdgpu_bo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
amdgpu/amdgpu_bo.c +1 -1
@@ -463,7 +463,7 @@ int amdgpu_bo_cpu_map(amdgpu_bo_handle bo, void **cpu)pthread_mutex_unlock (&bo->cpu_access_mutex);return -errno; } - +amdgpu_add_handle_to_table (bo); bo->cpu_ptr = ptr; bo->cpu_map_count =1 ;pthread_mutex_unlock (&bo->cpu_access_mutex);
Signature · 1 line
1.9.1
Quoted 1 line
From
e08a265eeaf810d20c672c3e26f1c127b83debe9Mon Sep 17 00:00:00 2001
From: Chunming Zhou <[email protected]>
Date: Wed, 14 Jun 2017 18:09:23 +0800
Subject: [PATCH] amdgpu: add find bo api unit test
--- tests/amdgpu/basic_tests.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
tests/amdgpu/basic_tests.c +24 -0
@@ -49,6 +49,7 @@ static void amdgpu_command_submission_compute(void);static void amdgpu_command_submission_sdma (void );static void amdgpu_command_submission_multi_fence (void );static void amdgpu_userptr_test (void ); +static void amdgpu_find_bo_test (void );static void amdgpu_semaphore_test (void );static void amdgpu_svm_test (void );static void amdgpu_multi_svm_test (void );
@@ -62,6 +63,7 @@ CU_TestInfo basic_tests[] = { { "Query Info Test", amdgpu_query_info_test }, { "Memory alloc Test", amdgpu_memory_alloc }, { "Userptr Test", amdgpu_userptr_test }, + { "Find bo Test", amdgpu_find_bo_test }, { "Command submission Test (GFX)", amdgpu_command_submission_gfx }, { "Command submission Test (Compute)", amdgpu_command_submission_compute }, { "Command submission Test (SDMA)", amdgpu_command_submission_sdma },
@@ -1591,6 +1593,28 @@ static void amdgpu_userptr_test(void)CU_ASSERT_EQUAL (r,0 ); } +static void amdgpu_find_bo_test (void ) +{ +amdgpu_bo_handle bo_handle, bo_handle1; +void *cpu_addr; +uint64_t mc_address, offset_in_bo; +amdgpu_va_handle va_handle; +int r; + + r =amdgpu_bo_alloc_and_map (device_handle,4096 ,4096 , +AMDGPU_GEM_DOMAIN_GTT ,0 , + &bo_handle, &cpu_addr, + &mc_address, &va_handle); +CU_ASSERT_EQUAL (r,0 ); + + r =amdgpu_find_bo_by_cpu_mapping (device_handle, + cpu_addr, +4096 , + &bo_handle1, &offset_in_bo); +CU_ASSERT_EQUAL (r,0 ); +CU_ASSERT_EQUAL (bo_handle, bo_handle1); +} +static void amdgpu_svm_test (void ) {int r;
Signature · 1 line
1.9.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]
Fwd: upsteam find bo api
ping...?
-------- Forwarded Message --------
Subject: upsteam find bo api
Date: Wed, 14 Jun 2017 18:16:24 +0800
From: zhoucm1 <[email protected]>
To: [email protected]
Hi all,
Since patches are one feature, and contain kernel and libdrm, I attached them not by send-mail. Hope not inconvenience.
0001-drm-amdgpu-return-bo-itself-if-userptr-is-cpu-addr-o.patch is kernel patch.
Other three is libdrm patches including unit test.
please review.
Regards,
David Zhou
Quoted 1 line
From
a388eeb1b1f59db55743407989d539bc3d546b82Mon Sep 17 00:00:00 2001
From: Chunming Zhou <[email protected]>
Date: Wed, 25 Nov 2015 18:09:10 +0800
Subject: [PATCH] drm/amdgpu: return bo itself if userptr is cpu addr of bo V2
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
V2: get original gem handle from gobj
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 59 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 3 +- include/uapi/drm/amdgpu_drm.h | 12 +++++++ 4 files changed, 75 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
@@ -1389,6 +1389,8 @@ int amdgpu_gem_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp);int amdgpu_gem_userptr_ioctl (struct drm_device *dev,void *data,struct drm_file *filp); +int amdgpu_gem_find_bo_by_cpu_mapping_ioctl (struct drm_device *dev,void *data, +struct drm_file *filp);int amdgpu_gem_mmap_ioctl (struct drm_device *dev,void *data,struct drm_file *filp); int amdgpu_gem_wait_idle_ioctl(struct drm_device *dev, void *data,
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +59 -0
65 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +2 -1
@@ -1069,7 +1069,8 @@ int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,DRM_IOCTL_DEF_DRV (AMDGPU_GEM_VA , amdgpu_gem_va_ioctl,DRM_AUTH |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF_DRV (AMDGPU_GEM_OP , amdgpu_gem_op_ioctl,DRM_AUTH |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF_DRV (AMDGPU_GEM_USERPTR , amdgpu_gem_userptr_ioctl,DRM_AUTH |DRM_RENDER_ALLOW ), - DRM_IOCTL_DEF_DRV(AMDGPU_FREESYNC, amdgpu_freesync_ioctl, DRM_MASTER) +DRM_IOCTL_DEF_DRV (AMDGPU_FREESYNC , amdgpu_freesync_ioctl,DRM_MASTER ), + DRM_IOCTL_DEF_DRV(AMDGPU_GEM_FIND_BO, amdgpu_gem_find_bo_by_cpu_mapping_ioctl, DRM_AUTH|DRM_RENDER_ALLOW) };const int amdgpu_max_kms_ioctl =ARRAY_SIZE (amdgpu_ioctls_kms);
include/uapi/drm/amdgpu_drm.h +12 -0
@@ -53,6 +53,7 @@#define DRM_AMDGPU_WAIT_FENCES 0x12#define DRM_AMDGPU_VM 0x13#define DRM_AMDGPU_FREESYNC 0x14 +#define DRM_AMDGPU_GEM_FIND_BO 0x15#define DRM_IOCTL_AMDGPU_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)#define DRM_IOCTL_AMDGPU_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)
@@ -69,6 +70,7 @@#define DRM_IOCTL_AMDGPU_WAIT_FENCES DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_FENCES, union drm_amdgpu_wait_fences)#define DRM_IOCTL_AMDGPU_VM DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_VM, union drm_amdgpu_vm)#define DRM_IOCTL_AMDGPU_FREESYNC DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_FREESYNC, struct drm_amdgpu_freesync) +#define DRM_IOCTL_AMDGPU_GEM_FIND_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_FIND_BO, struct drm_amdgpu_gem_find_bo)#define AMDGPU_GEM_DOMAIN_CPU 0x1#define AMDGPU_GEM_DOMAIN_GTT 0x2
@@ -233,6 +235,16 @@ struct drm_amdgpu_gem_userptr {__u32 handle; }; +struct drm_amdgpu_gem_find_bo { +uint64_t addr; +uint64_t size; +uint32_t flags; +/* Resulting GEM handle */ +uint32_t handle; +/* offset in bo */ +uint64_t offset; +}; +/* SI-CI-VI: */ /* same meaning as the GB_TILE_MODE and GL_MACRO_TILE_MODE fields */ #define AMDGPU_TILING_ARRAY_MODE_SHIFT 0
Signature · 1 line
1.9.1
Quoted 1 line
From
108cdd7f8685521481a01db91433a5dcc938687dMon Sep 17 00:00:00 2001
From: Chunming Zhou <[email protected]>
Date: Thu, 26 Nov 2015 17:01:07 +0800
Subject: [PATCH] amdgpu: add amdgpu_find_bo_by_cpu_mapping interface
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
userspace needs to know if the user memory is from BO or malloc.
--- amdgpu/amdgpu.h | 24 ++++++++++++++++++++++++ amdgpu/amdgpu_bo.c | 37 +++++++++++++++++++++++++++++++++++++ include/drm/amdgpu_drm.h | 12 ++++++++++++ 3 files changed, 73 insertions(+)
amdgpu/amdgpu.h +24 -0
@@ -672,6 +672,30 @@ int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev, amdgpu_bo_handle *buf_handle);/** +* Validate if the user memory comes from BO +* +* \param dev - [in] Device handle. See #amdgpu_device_initialize() +* \param cpu - [in] CPU address of user allocated memory which we +* want to map to GPU address space (make GPU accessible) +* (This address must be correctly aligned). +* \param size - [in] Size of allocation (must be correctly aligned) +* \param buf_handle - [out] Buffer handle for the userptr memory +* if the user memory is not from BO, the buf_handle will be NULL. +* \param offset_in_bo - [out] offset in this BO for this user memory +* +* +* \return 0 on success\n +* <0 - Negative POSIX Error code +* +*/ +int amdgpu_find_bo_by_cpu_mapping (amdgpu_device_handle dev, +void *cpu, +uint64_t size, +amdgpu_bo_handle *buf_handle, +uint64_t *offset_in_bo); + + +/** * Free previosuly allocated memory * * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
amdgpu/amdgpu_bo.c +37 -0
@@ -529,6 +529,43 @@ int amdgpu_bo_wait_for_idle(amdgpu_bo_handle bo, } } +int amdgpu_find_bo_by_cpu_mapping (amdgpu_device_handle dev, +void *cpu, +uint64_t size, +amdgpu_bo_handle *buf_handle, +uint64_t *offset_in_bo) +{ +int r; +struct amdgpu_bo *bo; +struct drm_amdgpu_gem_find_bo args; + + args.addr = (uintptr_t )cpu; + args.size = size; + r =drmCommandWriteRead (dev->fd,DRM_AMDGPU_GEM_FIND_BO , + &args,sizeof (args)); +if (r) +return r; +if (args.handle ==0 ) +return -EINVAL ; + bo =util_hash_table_get (dev->bo_handles, + (void *)(uintptr_t )args.handle); +if (!bo) { + bo =calloc (1 ,sizeof (struct amdgpu_bo )); +if (!bo) +return -ENOMEM ; +atomic_set (&bo->refcount,1 ); + bo->dev = dev; + bo->alloc_size = size; + bo->handle = args.handle; + }else +atomic_inc (&bo->refcount); + + *buf_handle = bo; + *offset_in_bo = args.offset; +return r; +} + + int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev, void *cpu, uint64_t size,
include/drm/amdgpu_drm.h +12 -0
@@ -47,6 +47,7 @@#define DRM_AMDGPU_GEM_OP 0x10#define DRM_AMDGPU_GEM_USERPTR 0x11#define DRM_AMDGPU_WAIT_FENCES 0x12 +#define DRM_AMDGPU_GEM_FIND_BO 0x15#define DRM_IOCTL_AMDGPU_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)#define DRM_IOCTL_AMDGPU_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)
@@ -61,6 +62,7 @@#define DRM_IOCTL_AMDGPU_GEM_OP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_OP, struct drm_amdgpu_gem_op)#define DRM_IOCTL_AMDGPU_GEM_USERPTR DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_USERPTR, struct drm_amdgpu_gem_userptr)#define DRM_IOCTL_AMDGPU_WAIT_FENCES DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_FENCES, union drm_amdgpu_wait_fences) +#define DRM_IOCTL_AMDGPU_GEM_FIND_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_FIND_BO, struct drm_amdgpu_gem_find_bo)#define AMDGPU_GEM_DOMAIN_CPU 0x1#define AMDGPU_GEM_DOMAIN_GTT 0x2
@@ -201,6 +203,16 @@ struct drm_amdgpu_gem_userptr {uint32_t handle; }; +struct drm_amdgpu_gem_find_bo { +uint64_t addr; +uint64_t size; +uint32_t flags; +/* Resulting GEM handle */ +uint32_t handle; +/* offset in bo */ +uint64_t offset; +}; +/* same meaning as the GB_TILE_MODE and GL_MACRO_TILE_MODE fields */ #define AMDGPU_TILING_ARRAY_MODE_SHIFT 0#define AMDGPU_TILING_ARRAY_MODE_MASK 0xf
Signature · 1 line
1.9.1
Quoted 1 line
From
f953cc6627fa4928d39d3de7c0e0f6a89c1e18ecMon Sep 17 00:00:00 2001
From: Chunming Zhou <[email protected]>
Date: Thu, 3 Dec 2015 16:52:33 +0800
Subject: [PATCH] amdgpu: add bo handle to hash table when cpu mapping
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
--- amdgpu/amdgpu_bo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
amdgpu/amdgpu_bo.c +1 -1
@@ -463,7 +463,7 @@ int amdgpu_bo_cpu_map(amdgpu_bo_handle bo, void **cpu)pthread_mutex_unlock (&bo->cpu_access_mutex);return -errno; } - +amdgpu_add_handle_to_table (bo); bo->cpu_ptr = ptr; bo->cpu_map_count =1 ;pthread_mutex_unlock (&bo->cpu_access_mutex);
Signature · 1 line
1.9.1
Quoted 1 line
From
e08a265eeaf810d20c672c3e26f1c127b83debe9Mon Sep 17 00:00:00 2001
From: Chunming Zhou <[email protected]>
Date: Wed, 14 Jun 2017 18:09:23 +0800
Subject: [PATCH] amdgpu: add find bo api unit test
--- tests/amdgpu/basic_tests.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
tests/amdgpu/basic_tests.c +24 -0
@@ -49,6 +49,7 @@ static void amdgpu_command_submission_compute(void);static void amdgpu_command_submission_sdma (void );static void amdgpu_command_submission_multi_fence (void );static void amdgpu_userptr_test (void ); +static void amdgpu_find_bo_test (void );static void amdgpu_semaphore_test (void );static void amdgpu_svm_test (void );static void amdgpu_multi_svm_test (void );
@@ -62,6 +63,7 @@ CU_TestInfo basic_tests[] = { { "Query Info Test", amdgpu_query_info_test }, { "Memory alloc Test", amdgpu_memory_alloc }, { "Userptr Test", amdgpu_userptr_test }, + { "Find bo Test", amdgpu_find_bo_test }, { "Command submission Test (GFX)", amdgpu_command_submission_gfx }, { "Command submission Test (Compute)", amdgpu_command_submission_compute }, { "Command submission Test (SDMA)", amdgpu_command_submission_sdma },
@@ -1591,6 +1593,28 @@ static void amdgpu_userptr_test(void)CU_ASSERT_EQUAL (r,0 ); } +static void amdgpu_find_bo_test (void ) +{ +amdgpu_bo_handle bo_handle, bo_handle1; +void *cpu_addr; +uint64_t mc_address, offset_in_bo; +amdgpu_va_handle va_handle; +int r; + + r =amdgpu_bo_alloc_and_map (device_handle,4096 ,4096 , +AMDGPU_GEM_DOMAIN_GTT ,0 , + &bo_handle, &cpu_addr, + &mc_address, &va_handle); +CU_ASSERT_EQUAL (r,0 ); + + r =amdgpu_find_bo_by_cpu_mapping (device_handle, + cpu_addr, +4096 , + &bo_handle1, &offset_in_bo); +CU_ASSERT_EQUAL (r,0 ); +CU_ASSERT_EQUAL (bo_handle, bo_handle1); +} +static void amdgpu_svm_test (void ) {int r;
Signature · 1 line
1.9.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
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]
RE: upsteam find bo api
What is the background or what is it for?
Thanks
Roger(Hongbo.He)
From: amd-gfx [mailto:[email protected]] On Behalf Of zhoucm1
Sent: Friday, June 16, 2017 4:09 PM
To: [email protected]
Subject: Fwd: upsteam find bo api
ping...?
-------- Forwarded Message --------
Subject:
upsteam find bo api
Date:
Wed, 14 Jun 2017 18:16:24 +0800
From:
zhoucm1 <[email protected]><mailto:[email protected]>
To:
[email protected]<mailto:[email protected]>
Hi all,
Since patches are one feature, and contain kernel and libdrm, I attached
them not by send-mail. Hope not inconvenience.
0001-drm-amdgpu-return-bo-itself-if-userptr-is-cpu-addr-o.patch is
kernel patch.
Other three is libdrm patches including unit test.
please review.
Regards,
David Zhou
_______________________________________________
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): BN6PR1201MB01146CE5D18B1D3AB252A235FDC10-6iU6OBHu2P8MH+E/uqw63WrFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/[email protected]
回复: upsteam find bo api
find bo API is used by vulkan, which is being in hybrid only previous, but now,they want to upstream.
Sent from my Huawei Mobile
-------- 原始邮件 --------
主题:RE: upsteam find bo api
发件人:"He, Roger"
收件人:"Zhou, David(ChunMing)" ,[email protected] 抄送:
What is the background or what is it for?
Thanks
Roger(Hongbo.He)
From: amd-gfx [mailto:[email protected]] On Behalf Of zhoucm1
Sent: Friday, June 16, 2017 4:09 PM
To: [email protected]
Subject: Fwd: upsteam find bo api
ping...?
-------- Forwarded Message --------
Subject:
upsteam find bo api
Date:
Wed, 14 Jun 2017 18:16:24 +0800
From:
zhoucm1 <[email protected]><mailto:[email protected]>
To:
[email protected]<mailto:[email protected]>
Hi all,
Since patches are one feature, and contain kernel and libdrm, I attached
them not by send-mail. Hope not inconvenience.
0001-drm-amdgpu-return-bo-itself-if-userptr-is-cpu-addr-o.patch is
kernel patch.
Other three is libdrm patches including unit test.
please review.
Regards,
David Zhou
_______________________________________________
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): MWHPR1201MB02069C5081958567754E38CCB4C10-3iK1xFAIwjrUF/YbdlDdgWrFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/[email protected]
RE: upsteam find bo api
Patches Look good to me in itself. Acked-by: Roger.He <[email protected]<mailto:[email protected]>> But of course you should double confirm if there is Christian’s concern.
Thanks
Roger(Hongbo.He)
From: Zhou, David(ChunMing)
Sent: Friday, June 16, 2017 7:18 PM
To: He, Roger <[email protected]>; [email protected]
Subject: 回复: upsteam find bo api
find bo API is used by vulkan, which is being in hybrid only previous, but now,they want to upstream.
Sent from my Huawei Mobile
-------- 原始邮件 --------
主题:RE: upsteam find bo api
发件人:"He, Roger"
收件人:"Zhou, David(ChunMing)" ,[email protected] 抄送:
What is the background or what is it for?
Thanks
Roger(Hongbo.He)
From: amd-gfx [mailto:[email protected]] On Behalf Of zhoucm1
Sent: Friday, June 16, 2017 4:09 PM
To: [email protected]<mailto:[email protected]>
Subject: Fwd: upsteam find bo api
ping...?
-------- Forwarded Message --------
Subject:
upsteam find bo api
Date:
Wed, 14 Jun 2017 18:16:24 +0800
From:
zhoucm1 <[email protected]><mailto:[email protected]>
To:
[email protected]<mailto:[email protected]>
Hi all,
Since patches are one feature, and contain kernel and libdrm, I attached
them not by send-mail. Hope not inconvenience.
0001-drm-amdgpu-return-bo-itself-if-userptr-is-cpu-addr-o.patch is
kernel patch.
Other three is libdrm patches including unit test.
please review.
Regards,
David Zhou
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: upsteam find bo api
In reply to a message not in the archiveWe are getting the patches out in preparation for open source vulkan. Additionally Christian has plans to use them in mesa as well.
Alex
Quoted 72 lines · Roger
What is the background or what is it for?
Thanks
Roger(Hongbo.He)
*From:* amd-gfx [mailto:amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org] *On Behalf Of *zhoucm1
*Sent:* Friday, June 16, 2017 4:09 PM
*To:* [email protected]
*Subject:* Fwd: upsteam find bo apiping...?
-------- Forwarded Message --------
*Subject: *
upsteam find bo api
*Date: *
Wed, 14 Jun 2017 18:16:24 +0800
*From: *
zhoucm1 <[email protected]> <[email protected]>
*To: *
Hi all,
Since patches are one feature, and contain kernel and libdrm, I attached
them not by send-mail. Hope not inconvenience.
0001-drm-amdgpu-return-bo-itself-if-userptr-is-cpu-addr-o.patch is
kernel patch.
Other three is libdrm patches including unit test.
please review.
Regards,
David Zhou
Quoted 6 lines
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: upsteam find bo api
In reply to a message not in the archiveQuoted 3 lines · On 16 June 2017 at 09:08, zhoucm1 <[email protected]> wrote:
ping...?
Normally you want to send patches as plain text (ideally git send-email), so that people can reply/comment inline.
But above all a summary of the "requirements" and "how it's achieved" helps your colleagues, amongst others ;-)
-Emil
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Alex Deucher
Acked-byRe: upsteam find bo api
In reply to a message not in the archiveThe patches look good to me. Christian what did you have in mind?
Alex
Quoted 28 lines · On Fri, Jun 16, 2017 at 4:08 AM, zhoucm1…
ping...?
-------- Forwarded Message --------
Subject: upsteam find bo api
Date: Wed, 14 Jun 2017 18:16:24 +0800
From: zhoucm1 <[email protected]> <[email protected]>
To: [email protected]Hi all,
Since patches are one feature, and contain kernel and libdrm, I attached them not by send-mail. Hope not inconvenience.
0001-drm-amdgpu-return-bo-itself-if-userptr-is-cpu-addr-o.patch is kernel patch.
Other three is libdrm patches including unit test.please review.
Regards,
David Zhou
Quoted 6 lines
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
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): CADnq5_NY8pZr6JbD8GrUQatiFGz6J1dU9ug2TiFiyN+6kxozeg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: upsteam find bo api
The patch should still work on amd-staging-4.11, but drm-next has seen some changes on how the handles are stored for dma-buf.
This can potentially break the implementation and I think we need to adapt before pushing it upstream, but I'm not 100% sure.
Christian.
Am 16.06.2017 um 22:35 schrieb Alex Deucher:
Quoted 46 lines
The patches look good to me. Christian what did you have in mind?
Acked-by Alex Deucher <[email protected] <mailto:[email protected]>>Alex
On Fri, Jun 16, 2017 at 4:08 AM, zhoucm1 <[email protected] <mailto:[email protected]>> wrote:
ping...?
-------- Forwarded Message --------
Subject: upsteam find bo api
Date: Wed, 14 Jun 2017 18:16:24 +0800
From: zhoucm1 <[email protected]> <mailto:[email protected]>
To: [email protected]
<mailto:[email protected]>Hi all,
Since patches are one feature, and contain kernel and libdrm, I attached them not by send-mail. Hope not inconvenience.
0001-drm-amdgpu-return-bo-itself-if-userptr-is-cpu-addr-o.patch is kernel patch.
Other three is libdrm patches including unit test.please review.
Regards,
David Zhou_______________________________________________
amd-gfx mailing list
[email protected] <mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
<https://lists.freedesktop.org/mailman/listinfo/amd-gfx>
Quoted 4 lines
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
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): 431202a9-c20d-fc67-9e70-26dfb67a3792-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Re: upsteam find bo api
Quoted 3 lines · Christian König
The patch should still work on amd-staging-4.11, but drm-next has seen some changes on how the handles are stored for dma-buf.
This can potentially break the implementation and I think we need to adapt before pushing it upstream, but I'm not 100% sure.
Do you mean the patch needs to wait for next kernel promotion? 4.12? 4.13?
Regards,
David Zhou
Quoted 56 lines
Christian.
Am 16.06.2017 um 22:35 schrieb Alex Deucher:
Quoted 50 lines
The patches look good to me. Christian what did you have in mind?
Acked-by Alex Deucher <[email protected] <mailto:[email protected]>>Alex
On Fri, Jun 16, 2017 at 4:08 AM, zhoucm1 <[email protected] <mailto:[email protected]>> wrote:
ping...?
-------- Forwarded Message --------
Subject: upsteam find bo api
Date: Wed, 14 Jun 2017 18:16:24 +0800
From: zhoucm1 <[email protected]> <mailto:[email protected]>
To: [email protected]
<mailto:[email protected]>Hi all,
Since patches are one feature, and contain kernel and libdrm, I attached them not by send-mail. Hope not inconvenience.
0001-drm-amdgpu-return-bo-itself-if-userptr-is-cpu-addr-o.patch is kernel patch.
Other three is libdrm patches including unit test.please review.
Regards,
David Zhou_______________________________________________
amd-gfx mailing list
[email protected] <mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
<https://lists.freedesktop.org/mailman/listinfo/amd-gfx>_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
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]
Re: upsteam find bo api
Am 19.06.2017 um 04:23 schrieb zhoucm1:
Quoted 7 lines · Christian König
Quoted 3 lines
The patch should still work on amd-staging-4.11, but drm-next has seen some changes on how the handles are stored for dma-buf.
This can potentially break the implementation and I think we need to adapt before pushing it upstream, but I'm not 100% sure.
Do you mean the patch needs to wait for next kernel promotion? 4.12? 4.13?
No, well maybe. The problem is that I'm not 100% sure if there isn't anything in drm-next which breaks this.
The easiest way to figure that out is to try to apply the patch to Dave's current drm-next branch and see if it still works as expected.
I think Alex plan was to setup an amd-staging-next branch to solve such problems, but that hasn't got very far I think.
Regards,
Christian.
Quoted 60 lines
Regards,
David ZhouQuoted 56 lines
Christian.
Am 16.06.2017 um 22:35 schrieb Alex Deucher:
Quoted 50 lines
The patches look good to me. Christian what did you have in mind?
Acked-by Alex Deucher <[email protected] <mailto:[email protected]>>Alex
On Fri, Jun 16, 2017 at 4:08 AM, zhoucm1 <[email protected] <mailto:[email protected]>> wrote:
ping...?
-------- Forwarded Message --------
Subject: upsteam find bo api
Date: Wed, 14 Jun 2017 18:16:24 +0800
From: zhoucm1 <[email protected]> <mailto:[email protected]>
To: [email protected]
<mailto:[email protected]>Hi all,
Since patches are one feature, and contain kernel and libdrm, I attached them not by send-mail. Hope not inconvenience.
0001-drm-amdgpu-return-bo-itself-if-userptr-is-cpu-addr-o.patch is kernel patch.
Other three is libdrm patches including unit test.please review.
Regards,
David Zhou_______________________________________________
amd-gfx mailing list
[email protected] <mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
<https://lists.freedesktop.org/mailman/listinfo/amd-gfx>_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
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): 6ce7c117-99d8-36b5-31cf-cc8689ed8a38-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Deucher, Alexander
Acked-by Alex DeucherRE: upsteam find bo api
I actually have a branch of amd-staging based on drm-next. See the amd-staging-drm-next branch.
Alex
From: amd-gfx [mailto:[email protected]] On Behalf Of Christian König
Sent: Monday, June 19, 2017 4:50 AM
To: Zhou, David(ChunMing); Alex Deucher
Cc: [email protected]
Subject: Re: upsteam find bo api
Am 19.06.2017 um 04:23 schrieb zhoucm1:
On 2017年06月17日 18:09, Christian König wrote:
The patch should still work on amd-staging-4.11, but drm-next has seen some changes on how the handles are stored for dma-buf.
This can potentially break the implementation and I think we need to adapt before pushing it upstream, but I'm not 100% sure. Do you mean the patch needs to wait for next kernel promotion? 4.12? 4.13?
No, well maybe. The problem is that I'm not 100% sure if there isn't anything in drm-next which breaks this.
The easiest way to figure that out is to try to apply the patch to Dave's current drm-next branch and see if it still works as expected.
I think Alex plan was to setup an amd-staging-next branch to solve such problems, but that hasn't got very far I think.
Regards,
Christian.
Regards,
David Zhou
Christian.
Am 16.06.2017 um 22:35 schrieb Alex Deucher:
The patches look good to me. Christian what did you have in mind?
Alex
On Fri, Jun 16, 2017 at 4:08 AM, zhoucm1 <[email protected]<mailto:[email protected]>> wrote:
ping...?
-------- Forwarded Message --------
Subject:
upsteam find bo api
Date:
Wed, 14 Jun 2017 18:16:24 +0800
From:
zhoucm1 <[email protected]><mailto:[email protected]>
To:
[email protected]<mailto:[email protected]>
Hi all,
Since patches are one feature, and contain kernel and libdrm, I attached
them not by send-mail. Hope not inconvenience.
0001-drm-amdgpu-return-bo-itself-if-userptr-is-cpu-addr-o.patch is
kernel patch.
Other three is libdrm patches including unit test.
please review.
Regards,
David Zhou
_______________________________________________
amd-gfx mailing list [email protected]<mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]<mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Deucher, Alexander
Reviewed-by Alex DeucherQuoted 8 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Nicolai Hähnle
Sent: Tuesday, June 13, 2017 4:12 PM
To: [email protected]
Cc: Haehnle, Nicolai
Subject: [PATCH] drm/amdgpu/gfx9: support the amdgpu.disable_cu option
Quoted 5 lines
From: Nicolai Hähnle <[email protected]>
This is ported from gfx8.
Signed-off-by Nicolai Hähnle <[email protected]>
Quoted 94 lines
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +20
-0@@ -4409,51 +4409,71 @@ static void gfx_v9_0_set_gds_init(struct amdgpu_device *adev) adev->gds.mem.cs_partition_size = 1024; adev->gds.gws.gfx_partition_size =16 ; adev->gds.gws.cs_partition_size =16 ; adev->gds.oa.gfx_partition_size =4 ; adev->gds.oa.cs_partition_size =4 ; } } +static void gfx_v9_0_set_user_cu_inactive_bitmap (struct amdgpu_device *adev, +u32 bitmap) +{ +u32 data; + +if (!bitmap) +return ; + + data = bitmap <<GC_USER_SHADER_ARRAY_CONFIG__INACTIVE_CUS__SHIFT ; + data &=GC_USER_SHADER_ARRAY_CONFIG__INACTIVE_CUS_MASK ; + +WREG32_SOC15 (GC ,0 , mmGC_USER_SHADER_ARRAY_CONFIG, data); +} +static u32 gfx_v9_0_get_cu_active_bitmap (struct amdgpu_device *adev) {u32 data, mask; data =RREG32_SOC15 (GC ,0 , mmCC_GC_SHADER_ARRAY_CONFIG); data |=RREG32_SOC15 (GC ,0 , mmGC_USER_SHADER_ARRAY_CONFIG); data &=CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS_MASK ; data >>=CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS__SHIFT ; mask =amdgpu_gfx_create_bitmask (adev- >gfx.config.max_cu_per_sh);return (~data) & mask; }static int gfx_v9_0_get_cu_info (struct amdgpu_device *adev,struct amdgpu_cu_info *cu_info) {int i, j, k, counter, active_cu_number =0 ;u32 mask, bitmap, ao_bitmap, ao_cu_mask =0 ; +unsigned disable_masks[4 *2 ];if (!adev || !cu_info)return -EINVAL ; +amdgpu_gfx_parse_disable_cu (disable_masks,4 ,2 ); +mutex_lock (&adev->grbm_idx_mutex);for (i =0 ; i < adev->gfx.config.max_shader_engines; i++) {for (j =0 ; j < adev->gfx.config.max_sh_per_se; j++) { mask =1 ; ao_bitmap =0 ; counter =0 ;gfx_v9_0_select_se_sh (adev, i, j,0xffffffff ); +if (i <4 && j <2 ) +gfx_v9_0_set_user_cu_inactive_bitmap ( + adev, disable_masks[i *2 + j]); bitmap =gfx_v9_0_get_cu_active_bitmap (adev); cu_info->bitmap[i][j] = bitmap;for (k = 0; k <
adev->gfx.config.max_cu_per_sh; k ++)
{drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0
-0if (bitmap & mask) { if (counter < adev-Quoted 1 line
gfx.config.max_cu_per_sh)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0
-1ao_bitmap |= mask; counter ++; } mask <<=1 ; --2.9.3
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx