drm/amdgpu: remove superflous UVD encode entity
Subsystems (2)
PATCH 1/2 drm/amdgpu: remove superflous UVD encode entity
Not sure what that was every used for, but now it is completely unused.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h | 1 - drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 12 ------------ drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c | 14 -------------- 3 files changed, 27 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h +0 -1
@@ -48,7 +48,6 @@ struct amdgpu_uvd_inst {struct amdgpu_ring ring_enc[AMDGPU_MAX_UVD_ENC_RINGS ];struct amdgpu_irq_src irq;struct drm_sched_entity entity; -struct drm_sched_entity entity_enc;uint32_t srbm_soft_reset; };
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +0 -12
@@ -418,16 +418,6 @@ static int uvd_v6_0_sw_init(void *handle) adev->uvd.num_enc_rings =0 ;DRM_INFO ("UVD ENC is disabled\n" ); - }else { -struct drm_sched_rq *rq; - ring = &adev->uvd.inst->ring_enc[0 ]; - rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL ]; - r =drm_sched_entity_init (&adev->uvd.inst->entity_enc, - &rq,1 ,NULL ); -if (r) { -DRM_ERROR ("Failed setting up UVD ENC run queue.\n" ); -return r; - } } r =amdgpu_uvd_resume (adev);
@@ -463,8 +453,6 @@ static int uvd_v6_0_sw_fini(void *handle)return r;if (uvd_v6_0_enc_support (adev)) { -drm_sched_entity_destroy (&adev->uvd.inst->ring_enc[0 ].sched, &adev->uvd.inst->entity_enc); -for (i =0 ; i < adev->uvd.num_enc_rings; ++i)amdgpu_ring_fini (&adev->uvd.inst->ring_enc[i]); }
drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c +0 -14
@@ -389,7 +389,6 @@ static int uvd_v7_0_early_init(void *handle)static int uvd_v7_0_sw_init (void *handle) {struct amdgpu_ring *ring; -struct drm_sched_rq *rq;int i, j, r;struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -421,17 +420,6 @@ static int uvd_v7_0_sw_init(void *handle)DRM_INFO ("PSP loading UVD firmware\n" ); } -for (j =0 ; j < adev->uvd.num_uvd_inst; j++) { - ring = &adev->uvd.inst[j].ring_enc[0 ]; - rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL ]; - r =drm_sched_entity_init (&adev->uvd.inst[j].entity_enc, - &rq,1 ,NULL ); -if (r) { -DRM_ERROR ("(%d)Failed setting up UVD ENC run queue.\n" , j); -return r; - } - } - r =amdgpu_uvd_resume (adev);if (r)return r;
@@ -484,8 +472,6 @@ static int uvd_v7_0_sw_fini(void *handle)return r;for (j =0 ; j < adev->uvd.num_uvd_inst; ++j) { -drm_sched_entity_destroy (&adev->uvd.inst[j].ring_enc[0 ].sched, &adev->uvd.inst[j].entity_enc); -for (i =0 ; i < adev->uvd.num_enc_rings; ++i)amdgpu_ring_fini (&adev->uvd.inst[j].ring_enc[i]); }
Signature · 6 lines
2.14.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): 20180718184441.75624-1-christian.koenig-5C7GfCeVMHo@public.gmane.org
PATCH 2/2 drm/amdgpu: clean up UVD instance handling v2
The whole handle, filp and entity handling is superfluous here.
We should have reviewed that more thoughtfully. It looks like somebody just made the code instance aware without knowing the background.
v2: fix one more missed case in amdgpu_uvd_suspend
--- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 121 ++++++++++++++++---------------- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h | 10 +-- 2 files changed, 64 insertions(+), 67 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +59 -62
@@ -263,21 +263,20 @@ int amdgpu_uvd_sw_init(struct amdgpu_device *adev)dev_err (adev->dev,"(%d) failed to allocate UVD bo\n" , r);return r; } + } - ring = &adev->uvd.inst[j].ring; - rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL ]; - r =drm_sched_entity_init (&adev->uvd.inst[j].entity, &rq, -1 ,NULL ); -if (r !=0 ) { -DRM_ERROR ("Failed setting up UVD(%d) run queue.\n" , j); -return r; - } - -for (i =0 ; i < adev->uvd.max_handles; ++i) { -atomic_set (&adev->uvd.inst[j].handles[i],0 ); - adev->uvd.inst[j].filp[i] =NULL ; - } + ring = &adev->uvd.inst[0 ].ring; + rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL ]; + r =drm_sched_entity_init (&adev->uvd.entity, &rq,1 ,NULL ); +if (r) { +DRM_ERROR ("Failed setting up UVD kernel entity.\n" ); +return r; } +for (i =0 ; i < adev->uvd.max_handles; ++i) { +atomic_set (&adev->uvd.handles[i],0 ); + adev->uvd.filp[i] =NULL ; + } +/* from uvd v5.0 HW addressing capacity increased to 64 bits */ if (!amdgpu_device_ip_block_version_cmp (adev,AMD_IP_BLOCK_TYPE_UVD ,5 ,0 )) adev->uvd.address_64_bit = true;
@@ -306,11 +305,12 @@ int amdgpu_uvd_sw_fini(struct amdgpu_device *adev) {int i, j; +drm_sched_entity_destroy (&adev->uvd.inst->ring.sched, + &adev->uvd.entity); +for (j =0 ; j < adev->uvd.num_uvd_inst; ++j) {kfree (adev->uvd.inst[j].saved_bo); -drm_sched_entity_destroy (&adev->uvd.inst[j].ring.sched, &adev->uvd.inst[j].entity); -amdgpu_bo_free_kernel (&adev->uvd.inst[j].vcpu_bo, &adev->uvd.inst[j].gpu_addr, (void **)&adev->uvd.inst[j].cpu_addr);
@@ -333,20 +333,20 @@ int amdgpu_uvd_suspend(struct amdgpu_device *adev)cancel_delayed_work_sync (&adev->uvd.idle_work); +/* only valid for physical mode */ +if (adev->asic_type <CHIP_POLARIS10 ) { +for (i =0 ; i < adev->uvd.max_handles; ++i) +if (atomic_read (&adev->uvd.handles[i])) +break ; + +if (i == adev->uvd.max_handles) +return 0 ; + } +for (j =0 ; j < adev->uvd.num_uvd_inst; ++j) {if (adev->uvd.inst[j].vcpu_bo ==NULL )continue ; -/* only valid for physical mode */ -if (adev->asic_type <CHIP_POLARIS10 ) { -for (i =0 ; i < adev->uvd.max_handles; ++i) -if (atomic_read (&adev->uvd.inst[j].handles[i])) -break ; - -if (i == adev->uvd.max_handles) -continue ; - } - size =amdgpu_bo_size (adev->uvd.inst[j].vcpu_bo); ptr = adev->uvd.inst[j].cpu_addr;
@@ -398,30 +398,27 @@ int amdgpu_uvd_resume(struct amdgpu_device *adev)void amdgpu_uvd_free_handles (struct amdgpu_device *adev,struct drm_file *filp) { -struct amdgpu_ring *ring; -int i, j, r; - -for (j =0 ; j < adev->uvd.num_uvd_inst; j++) { - ring = &adev->uvd.inst[j].ring; +struct amdgpu_ring *ring = &adev->uvd.inst[0 ].ring; +int i, r; -for (i =0 ; i < adev->uvd.max_handles; ++i) { -uint32_t handle =atomic_read (&adev->uvd.inst[j].handles[i]); -if (handle !=0 && adev->uvd.inst[j].filp[i] == filp) { -struct dma_fence *fence; - - r =amdgpu_uvd_get_destroy_msg (ring, handle, - false, &fence); -if (r) { -DRM_ERROR ("Error destroying UVD(%d) %d!\n" , j, r); -continue ; - } +for (i =0 ; i < adev->uvd.max_handles; ++i) { +uint32_t handle =atomic_read (&adev->uvd.handles[i]); -dma_fence_wait (fence, false); -dma_fence_put (fence); +if (handle !=0 && adev->uvd.filp[i] == filp) { +struct dma_fence *fence; - adev->uvd.inst[j].filp[i] =NULL ; -atomic_set (&adev->uvd.inst[j].handles[i],0 ); + r =amdgpu_uvd_get_destroy_msg (ring, handle, false, + &fence); +if (r) { +DRM_ERROR ("Error destroying UVD %d!\n" , r); +continue ; } + +dma_fence_wait (fence, false); +dma_fence_put (fence); + + adev->uvd.filp[i] =NULL ; +atomic_set (&adev->uvd.handles[i],0 ); } } }
@@ -692,20 +689,19 @@ static int amdgpu_uvd_cs_msg(struct amdgpu_uvd_cs_ctx *ctx, struct amdgpu_bo *bo, unsigned offset) {struct amdgpu_device *adev = ctx->parser->adev; -uint32_t ip_instance = ctx->parser->ring->me;int32_t *msg, msg_type, handle;void *ptr;long r;int i;if (offset &0x3F ) { -DRM_ERROR ("UVD(%d) messages must be 64 byte aligned!\n" , ip_instance); +DRM_ERROR ("UVD messages must be 64 byte aligned!\n" );return -EINVAL ; } r =amdgpu_bo_kmap (bo, &ptr);if (r) { -DRM_ERROR ("Failed mapping the UVD(%d) message (%ld)!\n" , ip_instance, r); +DRM_ERROR ("Failed mapping the UVD) message (%ld)!\n" , r);return r; }
@@ -715,7 +711,7 @@ static int amdgpu_uvd_cs_msg(struct amdgpu_uvd_cs_ctx *ctx, handle = msg[2 ];if (handle ==0 ) { -DRM_ERROR ("Invalid UVD(%d) handle!\n" , ip_instance); +DRM_ERROR ("Invalid UVD handle!\n" );return -EINVAL ; }
@@ -726,18 +722,19 @@ static int amdgpu_uvd_cs_msg(struct amdgpu_uvd_cs_ctx *ctx,/* try to alloc a new handle */ for (i =0 ; i < adev->uvd.max_handles; ++i) { -if (atomic_read (&adev->uvd.inst[ip_instance].handles[i]) == handle) { -DRM_ERROR ("(%d)Handle 0x%x already in use!\n" , ip_instance, handle); +if (atomic_read (&adev->uvd.handles[i]) == handle) { +DRM_ERROR (")Handle 0x%x already in use!\n" , + handle);return -EINVAL ; } -if (!atomic_cmpxchg (&adev->uvd.inst[ip_instance].handles[i],0 , handle)) { - adev->uvd.inst[ip_instance].filp[i] = ctx->parser->filp; +if (!atomic_cmpxchg (&adev->uvd.handles[i],0 , handle)) { + adev->uvd.filp[i] = ctx->parser->filp;return 0 ; } } -DRM_ERROR ("No more free UVD(%d) handles!\n" , ip_instance); +DRM_ERROR ("No more free UVD handles!\n" );return -ENOSPC ;case 1 :
@@ -749,27 +746,27 @@ static int amdgpu_uvd_cs_msg(struct amdgpu_uvd_cs_ctx *ctx,/* validate the handle */ for (i =0 ; i < adev->uvd.max_handles; ++i) { -if (atomic_read (&adev->uvd.inst[ip_instance].handles[i]) == handle) { -if (adev->uvd.inst[ip_instance].filp[i] != ctx->parser->filp) { -DRM_ERROR ("UVD(%d) handle collision detected!\n" , ip_instance); +if (atomic_read (&adev->uvd.handles[i]) == handle) { +if (adev->uvd.filp[i] != ctx->parser->filp) { +DRM_ERROR ("UVD handle collision detected!\n" );return -EINVAL ; }return 0 ; } } -DRM_ERROR ("Invalid UVD(%d) handle 0x%x!\n" , ip_instance, handle); +DRM_ERROR ("Invalid UVD handle 0x%x!\n" , handle);return -ENOENT ;case 2 :/* it's a destroy msg, free the handle */ for (i =0 ; i < adev->uvd.max_handles; ++i) -atomic_cmpxchg (&adev->uvd.inst[ip_instance].handles[i], handle,0 ); +atomic_cmpxchg (&adev->uvd.handles[i], handle,0 );amdgpu_bo_kunmap (bo);return 0 ;default : -DRM_ERROR ("Illegal UVD(%d) message type (%d)!\n" , ip_instance, msg_type); +DRM_ERROR ("Illegal UVD message type (%d)!\n" , msg_type);return -EINVAL ; }BUG ();
@@ -1071,7 +1068,7 @@ static int amdgpu_uvd_send_msg(struct amdgpu_ring *ring, struct amdgpu_bo *bo,if (r) goto err_free; - r =amdgpu_job_submit (job, &adev->uvd.inst[ring->me].entity, + r =amdgpu_job_submit (job, &adev->uvd.entity,AMDGPU_FENCE_OWNER_UNDEFINED , &f);if (r) goto err_free;
@@ -1273,7 +1270,7 @@ uint32_t amdgpu_uvd_used_handles(struct amdgpu_device *adev)* necessarily linear. So we need to count * all non-zero handles. */ -if (atomic_read (&adev->uvd.inst->handles[i])) +if (atomic_read (&adev->uvd.handles[i])) used_handles++; }
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h +5 -5
@@ -42,12 +42,9 @@ struct amdgpu_uvd_inst {void *cpu_addr;uint64_t gpu_addr;void *saved_bo; -atomic_t handles[AMDGPU_MAX_UVD_HANDLES ]; -struct drm_file *filp[AMDGPU_MAX_UVD_HANDLES ];struct amdgpu_ring ring;struct amdgpu_ring ring_enc[AMDGPU_MAX_UVD_ENC_RINGS ];struct amdgpu_irq_src irq; -struct drm_sched_entity entity;uint32_t srbm_soft_reset; };
@@ -56,10 +53,13 @@ struct amdgpu_uvd {unsigned fw_version;unsigned max_handles;unsigned num_enc_rings; -uint8_t num_uvd_inst; +uint8_t num_uvd_inst;bool address_64_bit;bool use_ctx_buf; -struct amdgpu_uvd_inst inst[AMDGPU_MAX_UVD_INSTANCES ]; +struct amdgpu_uvd_inst inst[AMDGPU_MAX_UVD_INSTANCES ]; +struct drm_file *filp[AMDGPU_MAX_UVD_HANDLES ]; +atomic_t handles[AMDGPU_MAX_UVD_HANDLES ]; +struct drm_sched_entity entity;struct delayed_work idle_work; };
Signature · 6 lines
2.14.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): 20180718184441.75624-2-christian.koenig-5C7GfCeVMHo@public.gmane.org
Zhou, David(ChunMing)
Acked-by Chunming ZhouRE: [PATCH 2/2] drm/amdgpu: clean up UVD instance handling v2
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Christian K?nig
Sent: Thursday, July 19, 2018 2:45 AM
To: [email protected]
Subject: [PATCH 2/2] drm/amdgpu: clean up UVD instance handling v2
The whole handle, filp and entity handling is superfluous here.
We should have reviewed that more thoughtfully. It looks like somebody just made the code instance aware without knowing the background.
v2: fix one more missed case in amdgpu_uvd_suspend
--- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 121 ++++++++++++++++---------------- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h | 10 +-- 2 files changed, 64 insertions(+), 67 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +15 -15
@@ -263,21 +263,20 @@ int amdgpu_uvd_sw_init(struct amdgpu_device *adev)dev_err (adev->dev,"(%d) failed to allocate UVD bo\n" , r);return r; } + } - ring = &adev->uvd.inst[j].ring; - rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL ]; - r =drm_sched_entity_init (&adev->uvd.inst[j].entity, &rq, -1 ,NULL ); -if (r !=0 ) { -DRM_ERROR ("Failed setting up UVD(%d) run queue.\n" , j); -return r; - } - -for (i =0 ; i < adev->uvd.max_handles; ++i) { -atomic_set (&adev->uvd.inst[j].handles[i],0 ); - adev->uvd.inst[j].filp[i] =NULL ; - } + ring = &adev->uvd.inst[0 ].ring; + rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL ]; + r =drm_sched_entity_init (&adev->uvd.entity, &rq,1 ,NULL ); +if (r) { +DRM_ERROR ("Failed setting up UVD kernel entity.\n" ); +return r; } +for (i =0 ; i < adev->uvd.max_handles; ++i) { +atomic_set (&adev->uvd.handles[i],0 ); + adev->uvd.filp[i] =NULL ; + } +/* from uvd v5.0 HW addressing capacity increased to 64 bits */ if (!amdgpu_device_ip_block_version_cmp (adev,AMD_IP_BLOCK_TYPE_UVD ,5 ,0 )) adev->uvd.address_64_bit = true;
@@ -306,11 +305,12 @@ int amdgpu_uvd_sw_fini(struct amdgpu_device *adev) {int i, j; +drm_sched_entity_destroy (&adev->uvd.inst->ring.sched, + &adev->uvd.entity); +for (j =0 ; j < adev->uvd.num_uvd_inst; ++j) {kfree (adev->uvd.inst[j].saved_bo); -drm_sched_entity_destroy (&adev->uvd.inst[j].ring.sched, &adev->uvd.inst[j].entity); -amdgpu_bo_free_kernel (&adev->uvd.inst[j].vcpu_bo, &adev->uvd.inst[j].gpu_addr, (void **)&adev->uvd.inst[j].cpu_addr); @@ -333,20 +333,20 @@ int amdgpu_uvd_suspend(struct amdgpu_device *adev)
cancel_delayed_work_sync(&adev->uvd.idle_work);
+ /* only valid for physical mode */
+ if (adev->asic_type < CHIP_POLARIS10) {
+ for (i = 0; i < adev->uvd.max_handles; ++i)
+ if (atomic_read(&adev->uvd.handles[i]))
+ break;
+
+ if (i == adev->uvd.max_handles)
+ return 0;
+ }
+
for (j = 0; j < adev->uvd.num_uvd_inst; ++j) {
if (adev->uvd.inst[j].vcpu_bo == NULL)
continue;
- /* only valid for physical mode */
- if (adev->asic_type < CHIP_POLARIS10) {
- for (i = 0; i < adev->uvd.max_handles; ++i)
- if (atomic_read(&adev->uvd.inst[j].handles[i]))
- break;
-
- if (i == adev->uvd.max_handles)
- continue;
- }
-
size = amdgpu_bo_size(adev->uvd.inst[j].vcpu_bo); ptr = adev->uvd.inst[j].cpu_addr;
@@ -398,30 +398,27 @@ int amdgpu_uvd_resume(struct amdgpu_device *adev)
void amdgpu_uvd_free_handles(struct amdgpu_device *adev, struct drm_file *filp) {
- struct amdgpu_ring *ring;
- int i, j, r;
-
- for (j = 0; j < adev->uvd.num_uvd_inst; j++) {
- ring = &adev->uvd.inst[j].ring;
+ struct amdgpu_ring *ring = &adev->uvd.inst[0].ring;
+ int i, r;
- for (i = 0; i < adev->uvd.max_handles; ++i) {
- uint32_t handle = atomic_read(&adev->uvd.inst[j].handles[i]);
- if (handle != 0 && adev->uvd.inst[j].filp[i] == filp) {
- struct dma_fence *fence;
-
- r = amdgpu_uvd_get_destroy_msg(ring, handle,
- false, &fence);
- if (r) {
- DRM_ERROR("Error destroying UVD(%d) %d!\n", j, r);
- continue;
- }
+ for (i = 0; i < adev->uvd.max_handles; ++i) {
+ uint32_t handle = atomic_read(&adev->uvd.handles[i]);
- dma_fence_wait(fence, false);
- dma_fence_put(fence);
+ if (handle != 0 && adev->uvd.filp[i] == filp) {
+ struct dma_fence *fence;
- adev->uvd.inst[j].filp[i] = NULL;
- atomic_set(&adev->uvd.inst[j].handles[i], 0);
+ r = amdgpu_uvd_get_destroy_msg(ring, handle, false,
+ &fence);
+ if (r) {
+ DRM_ERROR("Error destroying UVD %d!\n", r);
+ continue;
}
+
+ dma_fence_wait(fence, false);
+ dma_fence_put(fence);
+
+ adev->uvd.filp[i] = NULL;
+ atomic_set(&adev->uvd.handles[i], 0);
}
}
}
@@ -692,20 +689,19 @@ static int amdgpu_uvd_cs_msg(struct amdgpu_uvd_cs_ctx *ctx,
struct amdgpu_bo *bo, unsigned offset) {
struct amdgpu_device *adev = ctx->parser->adev;
- uint32_t ip_instance = ctx->parser->ring->me;
int32_t *msg, msg_type, handle;
void *ptr;
long r;
int i;
if (offset & 0x3F) {
- DRM_ERROR("UVD(%d) messages must be 64 byte aligned!\n", ip_instance);
+ DRM_ERROR("UVD messages must be 64 byte aligned!\n");
return -EINVAL;
}
r = amdgpu_bo_kmap(bo, &ptr);
if (r) {
- DRM_ERROR("Failed mapping the UVD(%d) message (%ld)!\n", ip_instance, r);
+ DRM_ERROR("Failed mapping the UVD) message (%ld)!\n", r);
return r;
}
@@ -715,7 +711,7 @@ static int amdgpu_uvd_cs_msg(struct amdgpu_uvd_cs_ctx *ctx,
handle = msg[2];
if (handle == 0) {
- DRM_ERROR("Invalid UVD(%d) handle!\n", ip_instance);
+ DRM_ERROR("Invalid UVD handle!\n");
return -EINVAL;
}
@@ -726,18 +722,19 @@ static int amdgpu_uvd_cs_msg(struct amdgpu_uvd_cs_ctx *ctx,
/* try to alloc a new handle */
for (i = 0; i < adev->uvd.max_handles; ++i) {
- if (atomic_read(&adev->uvd.inst[ip_instance].handles[i]) == handle) {
- DRM_ERROR("(%d)Handle 0x%x already in use!\n", ip_instance, handle);
+ if (atomic_read(&adev->uvd.handles[i]) == handle) {
+ DRM_ERROR(")Handle 0x%x already in use!\n",
+ handle);
return -EINVAL;
}
- if (!atomic_cmpxchg(&adev->uvd.inst[ip_instance].handles[i], 0, handle)) {
- adev->uvd.inst[ip_instance].filp[i] = ctx->parser->filp;
+ if (!atomic_cmpxchg(&adev->uvd.handles[i], 0, handle)) {
+ adev->uvd.filp[i] = ctx->parser->filp;
return 0;
}
}
- DRM_ERROR("No more free UVD(%d) handles!\n", ip_instance);
+ DRM_ERROR("No more free UVD handles!\n");
return -ENOSPC;
case 1:
@@ -749,27 +746,27 @@ static int amdgpu_uvd_cs_msg(struct amdgpu_uvd_cs_ctx *ctx,
/* validate the handle */
for (i = 0; i < adev->uvd.max_handles; ++i) {
- if (atomic_read(&adev->uvd.inst[ip_instance].handles[i]) == handle) {
- if (adev->uvd.inst[ip_instance].filp[i] != ctx->parser->filp) {
- DRM_ERROR("UVD(%d) handle collision detected!\n", ip_instance);
+ if (atomic_read(&adev->uvd.handles[i]) == handle) {
+ if (adev->uvd.filp[i] != ctx->parser->filp) {
+ DRM_ERROR("UVD handle collision detected!\n");
return -EINVAL;
}
return 0;
}
}
- DRM_ERROR("Invalid UVD(%d) handle 0x%x!\n", ip_instance, handle);
+ DRM_ERROR("Invalid UVD handle 0x%x!\n", handle);
return -ENOENT;
case 2:
/* it's a destroy msg, free the handle */ for (i = 0; i < adev->uvd.max_handles; ++i)
- atomic_cmpxchg(&adev->uvd.inst[ip_instance].handles[i], handle, 0);
+ atomic_cmpxchg(&adev->uvd.handles[i], handle, 0);
amdgpu_bo_kunmap(bo);
return 0;
default:
- DRM_ERROR("Illegal UVD(%d) message type (%d)!\n", ip_instance, msg_type);
+ DRM_ERROR("Illegal UVD message type (%d)!\n", msg_type);
return -EINVAL;
}
BUG();
@@ -1071,7 +1068,7 @@ static int amdgpu_uvd_send_msg(struct amdgpu_ring *ring, struct amdgpu_bo *bo,
if (r)
goto err_free;
- r = amdgpu_job_submit(job, &adev->uvd.inst[ring->me].entity,
+ r = amdgpu_job_submit(job, &adev->uvd.entity,
AMDGPU_FENCE_OWNER_UNDEFINED, &f);
if (r)
goto err_free;
@@ -1273,7 +1270,7 @@ uint32_t amdgpu_uvd_used_handles(struct amdgpu_device *adev)
* necessarily linear. So we need to count
* all non-zero handles.
*/
- if (atomic_read(&adev->uvd.inst->handles[i]))
+ if (atomic_read(&adev->uvd.handles[i]))
used_handles++;
}
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h +5 -5
@@ -42,12 +42,9 @@ struct amdgpu_uvd_inst {void *cpu_addr;uint64_t gpu_addr;void *saved_bo; -atomic_t handles[AMDGPU_MAX_UVD_HANDLES ]; -struct drm_file *filp[AMDGPU_MAX_UVD_HANDLES ];struct amdgpu_ring ring;struct amdgpu_ring ring_enc[AMDGPU_MAX_UVD_ENC_RINGS ];struct amdgpu_irq_src irq; -struct drm_sched_entity entity;uint32_t srbm_soft_reset; };
@@ -56,10 +53,13 @@ struct amdgpu_uvd {unsigned fw_version;unsigned max_handles;unsigned num_enc_rings; -uint8_t num_uvd_inst; +uint8_t num_uvd_inst;bool address_64_bit;bool use_ctx_buf; -struct amdgpu_uvd_inst inst[AMDGPU_MAX_UVD_INSTANCES ]; +struct amdgpu_uvd_inst inst[AMDGPU_MAX_UVD_INSTANCES ]; +struct drm_file *filp[AMDGPU_MAX_UVD_HANDLES ]; +atomic_t handles[AMDGPU_MAX_UVD_HANDLES ]; +struct drm_sched_entity entity;struct delayed_work idle_work; };
--
2.14.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
Leo Liu
Reviewed-byRe: [PATCH 2/2] drm/amdgpu: clean up UVD instance handling v2
In reply to a message not in the archiveQuoted 4 lines · Christian König
The whole handle, filp and entity handling is superfluous here.
We should have reviewed that more thoughtfully. It looks like somebody just made the code instance aware without knowing the background.
Yeah It's only required for UVD without VMID support.
Quoted 272 lines
v2: fix one more missed case in
amdgpu_uvd_suspendSigned-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 121 ++++++++++++++++---------------- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h | 10 +-- 2 files changed, 64 insertions(+), 67 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +59
-62@@ -263,21 +263,20 @@ int amdgpu_uvd_sw_init(struct amdgpu_device *adev)dev_err (adev->dev,"(%d) failed to allocate UVD bo\n" , r);return r; } + } - ring = &adev->uvd.inst[j].ring; - rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL ]; - r =drm_sched_entity_init (&adev->uvd.inst[j].entity, &rq, -1 ,NULL ); -if (r !=0 ) { -DRM_ERROR ("Failed setting up UVD(%d) run queue.\n" , j); -return r; - } - -for (i =0 ; i < adev->uvd.max_handles; ++i) { -atomic_set (&adev->uvd.inst[j].handles[i],0 ); - adev->uvd.inst[j].filp[i] =NULL ; - } + ring = &adev->uvd.inst[0 ].ring; + rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL ]; + r =drm_sched_entity_init (&adev->uvd.entity, &rq,1 ,NULL ); +if (r) { +DRM_ERROR ("Failed setting up UVD kernel entity.\n" ); +return r; } +for (i =0 ; i < adev->uvd.max_handles; ++i) { +atomic_set (&adev->uvd.handles[i],0 ); + adev->uvd.filp[i] =NULL ; + } +/* from uvd v5.0 HW addressing capacity increased to 64 bits */ if (!amdgpu_device_ip_block_version_cmp (adev,AMD_IP_BLOCK_TYPE_UVD ,5 ,0 )) adev->uvd.address_64_bit = true;@@ -306,11 +305,12 @@ int amdgpu_uvd_sw_fini(struct amdgpu_device *adev) {int i, j; +drm_sched_entity_destroy (&adev->uvd.inst->ring.sched, + &adev->uvd.entity); +for (j =0 ; j < adev->uvd.num_uvd_inst; ++j) {kfree (adev->uvd.inst[j].saved_bo); -drm_sched_entity_destroy (&adev->uvd.inst[j].ring.sched, &adev->uvd.inst[j].entity); -amdgpu_bo_free_kernel (&adev->uvd.inst[j].vcpu_bo, &adev->uvd.inst[j].gpu_addr, (void **)&adev->uvd.inst[j].cpu_addr);@@ -333,20 +333,20 @@ int amdgpu_uvd_suspend(struct amdgpu_device *adev)cancel_delayed_work_sync (&adev->uvd.idle_work); +/* only valid for physical mode */ +if (adev->asic_type <CHIP_POLARIS10 ) { +for (i =0 ; i < adev->uvd.max_handles; ++i) +if (atomic_read (&adev->uvd.handles[i])) +break ; + +if (i == adev->uvd.max_handles) +return 0 ; + } +for (j =0 ; j < adev->uvd.num_uvd_inst; ++j) {if (adev->uvd.inst[j].vcpu_bo ==NULL )continue ; -/* only valid for physical mode */ -if (adev->asic_type <CHIP_POLARIS10 ) { -for (i =0 ; i < adev->uvd.max_handles; ++i) -if (atomic_read (&adev->uvd.inst[j].handles[i])) -break ; - -if (i == adev->uvd.max_handles) -continue ; - } - size =amdgpu_bo_size (adev->uvd.inst[j].vcpu_bo); ptr = adev->uvd.inst[j].cpu_addr;@@ -398,30 +398,27 @@ int amdgpu_uvd_resume(struct amdgpu_device *adev)void amdgpu_uvd_free_handles (struct amdgpu_device *adev,struct drm_file *filp) { -struct amdgpu_ring *ring; -int i, j, r; - -for (j =0 ; j < adev->uvd.num_uvd_inst; j++) { - ring = &adev->uvd.inst[j].ring; +struct amdgpu_ring *ring = &adev->uvd.inst[0 ].ring; +int i, r; -for (i =0 ; i < adev->uvd.max_handles; ++i) { -uint32_t handle =atomic_read (&adev->uvd.inst[j].handles[i]); -if (handle !=0 && adev->uvd.inst[j].filp[i] == filp) { -struct dma_fence *fence; - - r =amdgpu_uvd_get_destroy_msg (ring, handle, - false, &fence); -if (r) { -DRM_ERROR ("Error destroying UVD(%d) %d!\n" , j, r); -continue ; - } +for (i =0 ; i < adev->uvd.max_handles; ++i) { +uint32_t handle =atomic_read (&adev->uvd.handles[i]); -dma_fence_wait (fence, false); -dma_fence_put (fence); +if (handle !=0 && adev->uvd.filp[i] == filp) { +struct dma_fence *fence; - adev->uvd.inst[j].filp[i] =NULL ; -atomic_set (&adev->uvd.inst[j].handles[i],0 ); + r =amdgpu_uvd_get_destroy_msg (ring, handle, false, + &fence); +if (r) { +DRM_ERROR ("Error destroying UVD %d!\n" , r); +continue ; } + +dma_fence_wait (fence, false); +dma_fence_put (fence); + + adev->uvd.filp[i] =NULL ; +atomic_set (&adev->uvd.handles[i],0 ); } } }@@ -692,20 +689,19 @@ static int amdgpu_uvd_cs_msg(struct amdgpu_uvd_cs_ctx *ctx, struct amdgpu_bo *bo, unsigned offset) {struct amdgpu_device *adev = ctx->parser->adev; -uint32_t ip_instance = ctx->parser->ring->me;int32_t *msg, msg_type, handle;void *ptr;long r;int i;if (offset &0x3F ) { -DRM_ERROR ("UVD(%d) messages must be 64 byte aligned!\n" , ip_instance); +DRM_ERROR ("UVD messages must be 64 byte aligned!\n" );return -EINVAL ; } r =amdgpu_bo_kmap (bo, &ptr);if (r) { -DRM_ERROR ("Failed mapping the UVD(%d) message (%ld)!\n" , ip_instance, r); +DRM_ERROR ("Failed mapping the UVD) message (%ld)!\n" , r);return r; }@@ -715,7 +711,7 @@ static int amdgpu_uvd_cs_msg(struct amdgpu_uvd_cs_ctx *ctx, handle = msg[2 ];if (handle ==0 ) { -DRM_ERROR ("Invalid UVD(%d) handle!\n" , ip_instance); +DRM_ERROR ("Invalid UVD handle!\n" );return -EINVAL ; }@@ -726,18 +722,19 @@ static int amdgpu_uvd_cs_msg(struct amdgpu_uvd_cs_ctx *ctx,/* try to alloc a new handle */ for (i =0 ; i < adev->uvd.max_handles; ++i) { -if (atomic_read (&adev->uvd.inst[ip_instance].handles[i]) == handle) { -DRM_ERROR ("(%d)Handle 0x%x already in use!\n" , ip_instance, handle); +if (atomic_read (&adev->uvd.handles[i]) == handle) { +DRM_ERROR (")Handle 0x%x already in use!\n" , + handle);return -EINVAL ; } -if (!atomic_cmpxchg (&adev->uvd.inst[ip_instance].handles[i],0 , handle)) { - adev->uvd.inst[ip_instance].filp[i] = ctx->parser->filp; +if (!atomic_cmpxchg (&adev->uvd.handles[i],0 , handle)) { + adev->uvd.filp[i] = ctx->parser->filp;return 0 ; } } -DRM_ERROR ("No more free UVD(%d) handles!\n" , ip_instance); +DRM_ERROR ("No more free UVD handles!\n" );return -ENOSPC ;case 1 :@@ -749,27 +746,27 @@ static int amdgpu_uvd_cs_msg(struct amdgpu_uvd_cs_ctx *ctx,/* validate the handle */ for (i =0 ; i < adev->uvd.max_handles; ++i) { -if (atomic_read (&adev->uvd.inst[ip_instance].handles[i]) == handle) { -if (adev->uvd.inst[ip_instance].filp[i] != ctx->parser->filp) { -DRM_ERROR ("UVD(%d) handle collision detected!\n" , ip_instance); +if (atomic_read (&adev->uvd.handles[i]) == handle) { +if (adev->uvd.filp[i] != ctx->parser->filp) { +DRM_ERROR ("UVD handle collision detected!\n" );return -EINVAL ; }return 0 ; } } -DRM_ERROR ("Invalid UVD(%d) handle 0x%x!\n" , ip_instance, handle); +DRM_ERROR ("Invalid UVD handle 0x%x!\n" , handle);return -ENOENT ;case 2 :/* it's a destroy msg, free the handle */ for (i =0 ; i < adev->uvd.max_handles; ++i) -atomic_cmpxchg (&adev->uvd.inst[ip_instance].handles[i], handle,0 ); +atomic_cmpxchg (&adev->uvd.handles[i], handle,0 );amdgpu_bo_kunmap (bo);return 0 ;default : -DRM_ERROR ("Illegal UVD(%d) message type (%d)!\n" , ip_instance, msg_type); +DRM_ERROR ("Illegal UVD message type (%d)!\n" , msg_type);return -EINVAL ; }BUG ();@@ -1071,7 +1068,7 @@ static int amdgpu_uvd_send_msg(struct amdgpu_ring *ring, struct amdgpu_bo *bo,if (r) goto err_free; - r =amdgpu_job_submit (job, &adev->uvd.inst[ring->me].entity, + r =amdgpu_job_submit (job, &adev->uvd.entity,AMDGPU_FENCE_OWNER_UNDEFINED , &f);if (r) goto err_free;@@ -1273,7 +1270,7 @@ uint32_t amdgpu_uvd_used_handles(struct amdgpu_device *adev)* necessarily linear. So we need to count * all non-zero handles. */ -if (atomic_read (&adev->uvd.inst->handles[i])) +if (atomic_read (&adev->uvd.handles[i])) used_handles++; }drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h +1
-4@@ -42,12 +42,9 @@ struct amdgpu_uvd_inst {void *cpu_addr;uint64_t gpu_addr;void *saved_bo; -atomic_t handles[AMDGPU_MAX_UVD_HANDLES ]; -struct drm_file *filp[AMDGPU_MAX_UVD_HANDLES ];struct amdgpu_ring ring;struct amdgpu_ring ring_enc[AMDGPU_MAX_UVD_ENC_RINGS ];struct amdgpu_irq_src irq; -struct drm_sched_entity entity;uint32_t srbm_soft_reset; };@@ -56,10 +53,13 @@ struct amdgpu_uvd {unsigned fw_version;unsigned max_handles;unsigned num_enc_rings; -uint8_t num_uvd_inst; +uint8_t num_uvd_inst;
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h struct amdgpu_uvd { · line 65
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h +4
-1bool address_64_bit;bool use_ctx_buf; -struct amdgpu_uvd_inst inst[AMDGPU_MAX_UVD_INSTANCES ]; +struct amdgpu_uvd_inst inst[AMDGPU_MAX_UVD_INSTANCES ]; +struct drm_file *filp[AMDGPU_MAX_UVD_HANDLES ]; +atomic_t handles[AMDGPU_MAX_UVD_HANDLES ]; +struct drm_sched_entity entity;struct delayed_work idle_work; };
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Zhou, David(ChunMing)
Acked-by Chunming Zhou-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Christian K?nig
Sent: Thursday, July 19, 2018 2:45 AM
To: [email protected]
Subject: [PATCH 1/2] drm/amdgpu: remove superflous UVD encode entity
Not sure what that was every used for, but now it is completely unused.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h | 1 - drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 12 ------------ drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c | 14 -------------- 3 files changed, 27 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h +0 -1
@@ -48,7 +48,6 @@ struct amdgpu_uvd_inst {struct amdgpu_ring ring_enc[AMDGPU_MAX_UVD_ENC_RINGS ];struct amdgpu_irq_src irq;struct drm_sched_entity entity; -struct drm_sched_entity entity_enc;uint32_t srbm_soft_reset; };
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +0 -12
@@ -418,16 +418,6 @@ static int uvd_v6_0_sw_init(void *handle) adev->uvd.num_enc_rings =0 ;DRM_INFO ("UVD ENC is disabled\n" ); - }else { -struct drm_sched_rq *rq; - ring = &adev->uvd.inst->ring_enc[0 ]; - rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL ]; - r =drm_sched_entity_init (&adev->uvd.inst->entity_enc, - &rq,1 ,NULL ); -if (r) { -DRM_ERROR ("Failed setting up UVD ENC run queue.\n" ); -return r; - } } r =amdgpu_uvd_resume (adev);
@@ -463,8 +453,6 @@ static int uvd_v6_0_sw_fini(void *handle)return r;if (uvd_v6_0_enc_support (adev)) { -drm_sched_entity_destroy (&adev->uvd.inst->ring_enc[0 ].sched, &adev->uvd.inst->entity_enc); -for (i =0 ; i < adev->uvd.num_enc_rings; ++i)amdgpu_ring_fini (&adev->uvd.inst->ring_enc[i]); }
drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c +0 -14
@@ -389,7 +389,6 @@ static int uvd_v7_0_early_init(void *handle) static int uvd_v7_0_sw_init(void *handle) {struct amdgpu_ring *ring; -struct drm_sched_rq *rq;int i, j, r;struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -421,17 +420,6 @@ static int uvd_v7_0_sw_init(void *handle)DRM_INFO ("PSP loading UVD firmware\n" ); } -for (j =0 ; j < adev->uvd.num_uvd_inst; j++) { - ring = &adev->uvd.inst[j].ring_enc[0 ]; - rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL ]; - r =drm_sched_entity_init (&adev->uvd.inst[j].entity_enc, - &rq,1 ,NULL ); -if (r) { -DRM_ERROR ("(%d)Failed setting up UVD ENC run queue.\n" , j); -return r; - } - } - r =amdgpu_uvd_resume (adev);if (r)return r;
@@ -484,8 +472,6 @@ static int uvd_v7_0_sw_fini(void *handle)return r;for (j =0 ; j < adev->uvd.num_uvd_inst; ++j) { -drm_sched_entity_destroy (&adev->uvd.inst[j].ring_enc[0 ].sched, &adev->uvd.inst[j].entity_enc); -for (i =0 ; i < adev->uvd.num_enc_rings; ++i)amdgpu_ring_fini (&adev->uvd.inst[j].ring_enc[i]); }
--
2.14.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
Leo Liu
Reviewed-byQuoted 1 line · Christian König
Not sure what that was every used for, but now it is completely unused.
UVD having it's own scheduler entity is inherited from UVD physical mode, which need send session destroy ib when session is done to free the handle in firmware. Because we cannot call amdgpu_ib_schedule directly, so need the entity to put this job to the scheduler.
The patch is:
Quoted 81 lines
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h | 1 - drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 12 ------------ drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c | 14 -------------- 3 files changed, 27 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h +0
-1@@ -48,7 +48,6 @@ struct amdgpu_uvd_inst {struct amdgpu_ring ring_enc[AMDGPU_MAX_UVD_ENC_RINGS ];struct amdgpu_irq_src irq;struct drm_sched_entity entity; -struct drm_sched_entity entity_enc;uint32_t srbm_soft_reset; };drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +0
-12@@ -418,16 +418,6 @@ static int uvd_v6_0_sw_init(void *handle) adev->uvd.num_enc_rings =0 ;DRM_INFO ("UVD ENC is disabled\n" ); - }else { -struct drm_sched_rq *rq; - ring = &adev->uvd.inst->ring_enc[0 ]; - rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL ]; - r =drm_sched_entity_init (&adev->uvd.inst->entity_enc, - &rq,1 ,NULL ); -if (r) { -DRM_ERROR ("Failed setting up UVD ENC run queue.\n" ); -return r; - } } r =amdgpu_uvd_resume (adev);@@ -463,8 +453,6 @@ static int uvd_v6_0_sw_fini(void *handle)return r;if (uvd_v6_0_enc_support (adev)) { -drm_sched_entity_destroy (&adev->uvd.inst->ring_enc[0 ].sched, &adev->uvd.inst->entity_enc); -for (i =0 ; i < adev->uvd.num_enc_rings; ++i)amdgpu_ring_fini (&adev->uvd.inst->ring_enc[i]); }drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c +0
-12@@ -389,7 +389,6 @@ static int uvd_v7_0_early_init(void *handle)static int uvd_v7_0_sw_init (void *handle) {struct amdgpu_ring *ring; -struct drm_sched_rq *rq;int i, j, r;struct amdgpu_device *adev = (struct amdgpu_device *)handle;@@ -421,17 +420,6 @@ static int uvd_v7_0_sw_init(void *handle)DRM_INFO ("PSP loading UVD firmware\n" ); } -for (j =0 ; j < adev->uvd.num_uvd_inst; j++) { - ring = &adev->uvd.inst[j].ring_enc[0 ]; - rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL ]; - r =drm_sched_entity_init (&adev->uvd.inst[j].entity_enc, - &rq,1 ,NULL ); -if (r) { -DRM_ERROR ("(%d)Failed setting up UVD ENC run queue.\n" , j); -return r; - } - } - r =amdgpu_uvd_resume (adev);if (r)return r;
drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c static int uvd_v7_0_sw_fini(void *handle) · line 477
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c +0
-2@@ -484,8 +472,6 @@ static int uvd_v7_0_sw_fini(void *handle)return r;for (j =0 ; j < adev->uvd.num_uvd_inst; ++j) { -drm_sched_entity_destroy (&adev->uvd.inst[j].ring_enc[0 ].sched, &adev->uvd.inst[j].entity_enc); -for (i =0 ; i < adev->uvd.num_enc_rings; ++i)amdgpu_ring_fini (&adev->uvd.inst[j].ring_enc[i]); }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx