mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-08 07:35:04 +00:00
drm/amdgpu: allow multiple sessions in the same VCE IB
We always used updated firmware for amdgpu, so this actually should work fine. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
182830a178
commit
e5223214b2
1 changed files with 27 additions and 26 deletions
|
@ -575,12 +575,10 @@ static int amdgpu_vce_cs_reloc(struct amdgpu_cs_parser *p, uint32_t ib_idx,
|
||||||
* we we don't have another free session index.
|
* we we don't have another free session index.
|
||||||
*/
|
*/
|
||||||
static int amdgpu_vce_validate_handle(struct amdgpu_cs_parser *p,
|
static int amdgpu_vce_validate_handle(struct amdgpu_cs_parser *p,
|
||||||
uint32_t handle, bool *allocated)
|
uint32_t handle, uint32_t *allocated)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
*allocated = false;
|
|
||||||
|
|
||||||
/* validate the handle */
|
/* validate the handle */
|
||||||
for (i = 0; i < AMDGPU_MAX_VCE_HANDLES; ++i) {
|
for (i = 0; i < AMDGPU_MAX_VCE_HANDLES; ++i) {
|
||||||
if (atomic_read(&p->adev->vce.handles[i]) == handle) {
|
if (atomic_read(&p->adev->vce.handles[i]) == handle) {
|
||||||
|
@ -597,7 +595,7 @@ static int amdgpu_vce_validate_handle(struct amdgpu_cs_parser *p,
|
||||||
if (!atomic_cmpxchg(&p->adev->vce.handles[i], 0, handle)) {
|
if (!atomic_cmpxchg(&p->adev->vce.handles[i], 0, handle)) {
|
||||||
p->adev->vce.filp[i] = p->filp;
|
p->adev->vce.filp[i] = p->filp;
|
||||||
p->adev->vce.img_size[i] = 0;
|
p->adev->vce.img_size[i] = 0;
|
||||||
*allocated = true;
|
*allocated |= 1 << i;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -617,9 +615,9 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, uint32_t ib_idx)
|
||||||
struct amdgpu_ib *ib = &p->job->ibs[ib_idx];
|
struct amdgpu_ib *ib = &p->job->ibs[ib_idx];
|
||||||
unsigned fb_idx = 0, bs_idx = 0;
|
unsigned fb_idx = 0, bs_idx = 0;
|
||||||
int session_idx = -1;
|
int session_idx = -1;
|
||||||
bool destroyed = false;
|
uint32_t destroyed = 0;
|
||||||
bool created = false;
|
uint32_t created = 0;
|
||||||
bool allocated = false;
|
uint32_t allocated = 0;
|
||||||
uint32_t tmp, handle = 0;
|
uint32_t tmp, handle = 0;
|
||||||
uint32_t *size = &tmp;
|
uint32_t *size = &tmp;
|
||||||
int i, r = 0, idx = 0;
|
int i, r = 0, idx = 0;
|
||||||
|
@ -636,19 +634,15 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, uint32_t ib_idx)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (destroyed) {
|
|
||||||
DRM_ERROR("No other command allowed after destroy!\n");
|
|
||||||
r = -EINVAL;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case 0x00000001: /* session */
|
case 0x00000001: /* session */
|
||||||
handle = amdgpu_get_ib_value(p, ib_idx, idx + 2);
|
handle = amdgpu_get_ib_value(p, ib_idx, idx + 2);
|
||||||
session_idx = amdgpu_vce_validate_handle(p, handle,
|
session_idx = amdgpu_vce_validate_handle(p, handle,
|
||||||
&allocated);
|
&allocated);
|
||||||
if (session_idx < 0)
|
if (session_idx < 0) {
|
||||||
return session_idx;
|
r = session_idx;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
size = &p->adev->vce.img_size[session_idx];
|
size = &p->adev->vce.img_size[session_idx];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -658,8 +652,12 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, uint32_t ib_idx)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x01000001: /* create */
|
case 0x01000001: /* create */
|
||||||
created = true;
|
created |= 1 << session_idx;
|
||||||
if (!allocated) {
|
if (destroyed & (1 << session_idx)) {
|
||||||
|
destroyed &= ~(1 << session_idx);
|
||||||
|
allocated |= 1 << session_idx;
|
||||||
|
|
||||||
|
} else if (!(allocated & (1 << session_idx))) {
|
||||||
DRM_ERROR("Handle already in use!\n");
|
DRM_ERROR("Handle already in use!\n");
|
||||||
r = -EINVAL;
|
r = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -692,7 +690,7 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, uint32_t ib_idx)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x02000001: /* destroy */
|
case 0x02000001: /* destroy */
|
||||||
destroyed = true;
|
destroyed |= 1 << session_idx;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x05000001: /* context buffer */
|
case 0x05000001: /* context buffer */
|
||||||
|
@ -732,21 +730,24 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, uint32_t ib_idx)
|
||||||
idx += len / 4;
|
idx += len / 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allocated && !created) {
|
if (allocated & ~created) {
|
||||||
DRM_ERROR("New session without create command!\n");
|
DRM_ERROR("New session without create command!\n");
|
||||||
r = -ENOENT;
|
r = -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if ((!r && destroyed) || (r && allocated)) {
|
if (!r) {
|
||||||
/*
|
/* No error, free all destroyed handle slots */
|
||||||
* IB contains a destroy msg or we have allocated an
|
tmp = destroyed;
|
||||||
* handle and got an error, anyway free the handle
|
} else {
|
||||||
*/
|
/* Error during parsing, free all allocated handle slots */
|
||||||
for (i = 0; i < AMDGPU_MAX_VCE_HANDLES; ++i)
|
tmp = allocated;
|
||||||
atomic_cmpxchg(&p->adev->vce.handles[i], handle, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < AMDGPU_MAX_VCE_HANDLES; ++i)
|
||||||
|
if (tmp & (1 << i))
|
||||||
|
atomic_set(&p->adev->vce.handles[i], 0);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue