Skip to content

Commit 8048e5a

Browse files
skjamadaralexdeucher
authored andcommitted
drm/amdgpu/vcn: enable AV1 on both instances
v1 - remove cs parse code (Christian) On VCN v4_0_6 AV1 is supported on both the instances. Remove cs IB parse code since explict handling of AV1 schedule is not required. Signed-off-by: Saleemkhan Jamadar <[email protected]> Reviewed-by: Leo Liu <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Cc: [email protected]
1 parent e45b011 commit 8048e5a

File tree

1 file changed

+0
-165
lines changed

1 file changed

+0
-165
lines changed

drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c

Lines changed: 0 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,178 +1395,13 @@ static void vcn_v4_0_5_unified_ring_set_wptr(struct amdgpu_ring *ring)
13951395
}
13961396
}
13971397

1398-
static int vcn_v4_0_5_limit_sched(struct amdgpu_cs_parser *p,
1399-
struct amdgpu_job *job)
1400-
{
1401-
struct drm_gpu_scheduler **scheds;
1402-
1403-
/* The create msg must be in the first IB submitted */
1404-
if (atomic_read(&job->base.entity->fence_seq))
1405-
return -EINVAL;
1406-
1407-
/* if VCN0 is harvested, we can't support AV1 */
1408-
if (p->adev->vcn.harvest_config & AMDGPU_VCN_HARVEST_VCN0)
1409-
return -EINVAL;
1410-
1411-
scheds = p->adev->gpu_sched[AMDGPU_HW_IP_VCN_ENC]
1412-
[AMDGPU_RING_PRIO_0].sched;
1413-
drm_sched_entity_modify_sched(job->base.entity, scheds, 1);
1414-
return 0;
1415-
}
1416-
1417-
static int vcn_v4_0_5_dec_msg(struct amdgpu_cs_parser *p, struct amdgpu_job *job,
1418-
uint64_t addr)
1419-
{
1420-
struct ttm_operation_ctx ctx = { false, false };
1421-
struct amdgpu_bo_va_mapping *map;
1422-
uint32_t *msg, num_buffers;
1423-
struct amdgpu_bo *bo;
1424-
uint64_t start, end;
1425-
unsigned int i;
1426-
void *ptr;
1427-
int r;
1428-
1429-
addr &= AMDGPU_GMC_HOLE_MASK;
1430-
r = amdgpu_cs_find_mapping(p, addr, &bo, &map);
1431-
if (r) {
1432-
DRM_ERROR("Can't find BO for addr 0x%08llx\n", addr);
1433-
return r;
1434-
}
1435-
1436-
start = map->start * AMDGPU_GPU_PAGE_SIZE;
1437-
end = (map->last + 1) * AMDGPU_GPU_PAGE_SIZE;
1438-
if (addr & 0x7) {
1439-
DRM_ERROR("VCN messages must be 8 byte aligned!\n");
1440-
return -EINVAL;
1441-
}
1442-
1443-
bo->flags |= AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;
1444-
amdgpu_bo_placement_from_domain(bo, bo->allowed_domains);
1445-
r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
1446-
if (r) {
1447-
DRM_ERROR("Failed validating the VCN message BO (%d)!\n", r);
1448-
return r;
1449-
}
1450-
1451-
r = amdgpu_bo_kmap(bo, &ptr);
1452-
if (r) {
1453-
DRM_ERROR("Failed mapping the VCN message (%d)!\n", r);
1454-
return r;
1455-
}
1456-
1457-
msg = ptr + addr - start;
1458-
1459-
/* Check length */
1460-
if (msg[1] > end - addr) {
1461-
r = -EINVAL;
1462-
goto out;
1463-
}
1464-
1465-
if (msg[3] != RDECODE_MSG_CREATE)
1466-
goto out;
1467-
1468-
num_buffers = msg[2];
1469-
for (i = 0, msg = &msg[6]; i < num_buffers; ++i, msg += 4) {
1470-
uint32_t offset, size, *create;
1471-
1472-
if (msg[0] != RDECODE_MESSAGE_CREATE)
1473-
continue;
1474-
1475-
offset = msg[1];
1476-
size = msg[2];
1477-
1478-
if (offset + size > end) {
1479-
r = -EINVAL;
1480-
goto out;
1481-
}
1482-
1483-
create = ptr + addr + offset - start;
1484-
1485-
/* H264, HEVC and VP9 can run on any instance */
1486-
if (create[0] == 0x7 || create[0] == 0x10 || create[0] == 0x11)
1487-
continue;
1488-
1489-
r = vcn_v4_0_5_limit_sched(p, job);
1490-
if (r)
1491-
goto out;
1492-
}
1493-
1494-
out:
1495-
amdgpu_bo_kunmap(bo);
1496-
return r;
1497-
}
1498-
1499-
#define RADEON_VCN_ENGINE_TYPE_ENCODE (0x00000002)
1500-
#define RADEON_VCN_ENGINE_TYPE_DECODE (0x00000003)
1501-
1502-
#define RADEON_VCN_ENGINE_INFO (0x30000001)
1503-
#define RADEON_VCN_ENGINE_INFO_MAX_OFFSET 16
1504-
1505-
#define RENCODE_ENCODE_STANDARD_AV1 2
1506-
#define RENCODE_IB_PARAM_SESSION_INIT 0x00000003
1507-
#define RENCODE_IB_PARAM_SESSION_INIT_MAX_OFFSET 64
1508-
1509-
/* return the offset in ib if id is found, -1 otherwise
1510-
* to speed up the searching we only search upto max_offset
1511-
*/
1512-
static int vcn_v4_0_5_enc_find_ib_param(struct amdgpu_ib *ib, uint32_t id, int max_offset)
1513-
{
1514-
int i;
1515-
1516-
for (i = 0; i < ib->length_dw && i < max_offset && ib->ptr[i] >= 8; i += ib->ptr[i]/4) {
1517-
if (ib->ptr[i + 1] == id)
1518-
return i;
1519-
}
1520-
return -1;
1521-
}
1522-
1523-
static int vcn_v4_0_5_ring_patch_cs_in_place(struct amdgpu_cs_parser *p,
1524-
struct amdgpu_job *job,
1525-
struct amdgpu_ib *ib)
1526-
{
1527-
struct amdgpu_ring *ring = amdgpu_job_ring(job);
1528-
struct amdgpu_vcn_decode_buffer *decode_buffer;
1529-
uint64_t addr;
1530-
uint32_t val;
1531-
int idx;
1532-
1533-
/* The first instance can decode anything */
1534-
if (!ring->me)
1535-
return 0;
1536-
1537-
/* RADEON_VCN_ENGINE_INFO is at the top of ib block */
1538-
idx = vcn_v4_0_5_enc_find_ib_param(ib, RADEON_VCN_ENGINE_INFO,
1539-
RADEON_VCN_ENGINE_INFO_MAX_OFFSET);
1540-
if (idx < 0) /* engine info is missing */
1541-
return 0;
1542-
1543-
val = amdgpu_ib_get_value(ib, idx + 2); /* RADEON_VCN_ENGINE_TYPE */
1544-
if (val == RADEON_VCN_ENGINE_TYPE_DECODE) {
1545-
decode_buffer = (struct amdgpu_vcn_decode_buffer *)&ib->ptr[idx + 6];
1546-
1547-
if (!(decode_buffer->valid_buf_flag & 0x1))
1548-
return 0;
1549-
1550-
addr = ((u64)decode_buffer->msg_buffer_address_hi) << 32 |
1551-
decode_buffer->msg_buffer_address_lo;
1552-
return vcn_v4_0_5_dec_msg(p, job, addr);
1553-
} else if (val == RADEON_VCN_ENGINE_TYPE_ENCODE) {
1554-
idx = vcn_v4_0_5_enc_find_ib_param(ib, RENCODE_IB_PARAM_SESSION_INIT,
1555-
RENCODE_IB_PARAM_SESSION_INIT_MAX_OFFSET);
1556-
if (idx >= 0 && ib->ptr[idx + 2] == RENCODE_ENCODE_STANDARD_AV1)
1557-
return vcn_v4_0_5_limit_sched(p, job);
1558-
}
1559-
return 0;
1560-
}
1561-
15621398
static const struct amdgpu_ring_funcs vcn_v4_0_5_unified_ring_vm_funcs = {
15631399
.type = AMDGPU_RING_TYPE_VCN_ENC,
15641400
.align_mask = 0x3f,
15651401
.nop = VCN_ENC_CMD_NO_OP,
15661402
.get_rptr = vcn_v4_0_5_unified_ring_get_rptr,
15671403
.get_wptr = vcn_v4_0_5_unified_ring_get_wptr,
15681404
.set_wptr = vcn_v4_0_5_unified_ring_set_wptr,
1569-
.patch_cs_in_place = vcn_v4_0_5_ring_patch_cs_in_place,
15701405
.emit_frame_size =
15711406
SOC15_FLUSH_GPU_TLB_NUM_WREG * 3 +
15721407
SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT * 4 +

0 commit comments

Comments
 (0)