panfrost: XML-ify the job header descriptor

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6797>
This commit is contained in:
Boris Brezillon
2020-09-08 07:07:41 +02:00
committed by Alyssa Rosenzweig
parent 5d5f7552a5
commit eb923548c5
7 changed files with 99 additions and 128 deletions
+11 -9
View File
@@ -68,12 +68,6 @@ panfrost_fragment_job(struct panfrost_batch *batch, bool has_draws)
if (fb->zsbuf)
panfrost_initialize_surface(batch, fb->zsbuf);
struct mali_job_descriptor_header header = {
.job_type = MALI_JOB_TYPE_FRAGMENT,
.job_index = 1,
.job_descriptor_size = 1
};
/* The passed tile coords can be out of range in some cases, so we need
* to clamp them to the framebuffer size to avoid a TILE_RANGE_FAULT.
* Theoretically we also need to clamp the coordinates positive, but we
@@ -100,8 +94,16 @@ panfrost_fragment_job(struct panfrost_batch *batch, bool has_draws)
.framebuffer = framebuffer,
};
struct panfrost_transfer transfer = panfrost_pool_alloc_aligned(&batch->pool, sizeof(header) + sizeof(payload), 64);
memcpy(transfer.cpu, &header, sizeof(header));
memcpy(transfer.cpu + sizeof(header), &payload, sizeof(payload));
struct panfrost_transfer transfer =
panfrost_pool_alloc_aligned(&batch->pool,
MALI_JOB_HEADER_LENGTH + sizeof(payload),
64);
pan_pack(transfer.cpu, JOB_HEADER, header) {
header.type = MALI_JOB_TYPE_FRAGMENT;
header.index = 1;
}
memcpy(transfer.cpu + MALI_JOB_HEADER_LENGTH, &payload, sizeof(payload));
return transfer.gpu;
}
+5 -8
View File
@@ -63,15 +63,12 @@ bit_submit(struct panfrost_device *dev,
void *payload, size_t payload_size,
struct panfrost_bo **bos, size_t bo_count, enum bit_debug debug)
{
struct mali_job_descriptor_header header = {
.job_descriptor_size = MALI_JOB_64,
.job_type = T,
.job_index = 1
};
struct panfrost_bo *job = bit_bo_create(dev, 4096);
memcpy(job->cpu, &header, sizeof(header));
memcpy(job->cpu + sizeof(header), payload, payload_size);
pan_pack(job->cpu, JOB_HEADER, cfg) {
cfg.type = T;
cfg.index = 1;
}
memcpy(job->cpu + MALI_JOB_HEADER_LENGTH, payload, payload_size);
uint32_t *bo_handles = calloc(sizeof(uint32_t), bo_count);
-19
View File
@@ -238,25 +238,6 @@ struct bifrost_blend_rt {
};
} __attribute__((packed));
/* Possible values for job_descriptor_size */
#define MALI_JOB_32 0
#define MALI_JOB_64 1
struct mali_job_descriptor_header {
u32 exception_status;
u32 first_incomplete_task;
u64 fault_pointer;
u8 job_descriptor_size : 1;
enum mali_job_type job_type : 7;
u8 job_barrier : 1;
u8 unknown_flags : 7;
u16 job_index;
u16 job_dependency_index_1;
u16 job_dependency_index_2;
u64 next_job;
} __attribute__((packed));
/* Details about write_value from panfrost igt tests which use it as a generic
* dword write primitive */
+27 -62
View File
@@ -1324,16 +1324,16 @@ pandecode_primitive_size(union midgard_primitive_size u, bool constant)
}
static int
pandecode_vertex_job_bfr(const struct mali_job_descriptor_header *h,
const struct pandecode_mapped_memory *mem,
mali_ptr payload, int job_no, unsigned gpu_id)
pandecode_vertex_job_bfr(const struct MALI_JOB_HEADER *h,
const struct pandecode_mapped_memory *mem,
mali_ptr payload, int job_no, unsigned gpu_id)
{
struct bifrost_payload_vertex *PANDECODE_PTR_VAR(v, mem, payload);
struct mali_draw_packed draw_packed;
memcpy(&draw_packed, &v->postfix, sizeof(draw_packed));
pan_unpack(&draw_packed, DRAW, draw);
pandecode_vertex_tiler_postfix_pre(&draw, job_no, h->job_type, "", true, gpu_id);
pandecode_vertex_tiler_postfix_pre(&draw, job_no, h->type, "", true, gpu_id);
pandecode_vertex_tiler_prefix(&v->prefix, job_no, false);
DUMP_CL(DRAW, &draw_packed, "Draw:\n");
@@ -1342,16 +1342,16 @@ pandecode_vertex_job_bfr(const struct mali_job_descriptor_header *h,
}
static int
pandecode_tiler_job_bfr(const struct mali_job_descriptor_header *h,
const struct pandecode_mapped_memory *mem,
mali_ptr payload, int job_no, unsigned gpu_id)
pandecode_tiler_job_bfr(const struct MALI_JOB_HEADER *h,
const struct pandecode_mapped_memory *mem,
mali_ptr payload, int job_no, unsigned gpu_id)
{
struct bifrost_payload_tiler *PANDECODE_PTR_VAR(t, mem, payload);
struct mali_draw_packed draw_packed;
memcpy(&draw_packed, &t->postfix, sizeof(draw_packed));
pan_unpack(&draw_packed, DRAW, draw);
pandecode_vertex_tiler_postfix_pre(&draw, job_no, h->job_type, "", true, gpu_id);
pandecode_vertex_tiler_postfix_pre(&draw, job_no, h->type, "", true, gpu_id);
pandecode_bifrost_tiler(t->tiler_meta, job_no);
pandecode_vertex_tiler_prefix(&t->prefix, job_no, false);
@@ -1376,17 +1376,17 @@ pandecode_tiler_job_bfr(const struct mali_job_descriptor_header *h,
}
static int
pandecode_vertex_or_tiler_job_mdg(const struct mali_job_descriptor_header *h,
const struct pandecode_mapped_memory *mem,
mali_ptr payload, int job_no, unsigned gpu_id)
pandecode_vertex_or_tiler_job_mdg(const struct MALI_JOB_HEADER *h,
const struct pandecode_mapped_memory *mem,
mali_ptr payload, int job_no, unsigned gpu_id)
{
struct midgard_payload_vertex_tiler *PANDECODE_PTR_VAR(v, mem, payload);
bool is_graphics = (h->job_type == MALI_JOB_TYPE_VERTEX) || (h->job_type == MALI_JOB_TYPE_TILER);
bool is_graphics = (h->type == MALI_JOB_TYPE_VERTEX) || (h->type == MALI_JOB_TYPE_TILER);
struct mali_draw_packed draw_packed;
memcpy(&draw_packed, &v->postfix, sizeof(draw_packed));
pan_unpack(&draw_packed, DRAW, draw);
pandecode_vertex_tiler_postfix_pre(&draw, job_no, h->job_type, "", false, gpu_id);
pandecode_vertex_tiler_postfix_pre(&draw, job_no, h->type, "", false, gpu_id);
pandecode_vertex_tiler_prefix(&v->prefix, job_no, is_graphics);
DUMP_CL(DRAW, &draw_packed, "Draw:\n");
@@ -1504,65 +1504,30 @@ pandecode_jc(mali_ptr jc_gpu_va, bool bifrost, unsigned gpu_id, bool minimal)
{
pandecode_dump_file_open();
struct mali_job_descriptor_header *h;
unsigned job_descriptor_number = 0;
mali_ptr next_job = 0;
do {
struct pandecode_mapped_memory *mem =
pandecode_find_mapped_gpu_mem_containing(jc_gpu_va);
void *payload;
h = PANDECODE_PTR(mem, jc_gpu_va, struct mali_job_descriptor_header);
mali_ptr payload_ptr = jc_gpu_va + sizeof(*h);
pan_unpack(PANDECODE_PTR(mem, jc_gpu_va, struct mali_job_header_packed),
JOB_HEADER, h);
next_job = h.next;
mali_ptr payload_ptr = jc_gpu_va + MALI_JOB_HEADER_LENGTH;
payload = pandecode_fetch_gpu_mem(mem, payload_ptr, 64);
int job_no = job_descriptor_number++;
/* If the job is good to go, skip it in minimal mode */
if (minimal && (h->exception_status == 0x0 || h->exception_status == 0x1))
if (minimal && (h.exception_status == 0x0 || h.exception_status == 0x1))
continue;
pandecode_log("struct mali_job_descriptor_header job_%"PRIx64"_%d = {\n", jc_gpu_va, job_no);
pandecode_indent++;
DUMP_UNPACKED(JOB_HEADER, h, "Job Header:\n");
pandecode_log("\n");
pandecode_prop("job_type = %s", mali_job_type_as_str(h->job_type));
if (h->job_descriptor_size)
pandecode_prop("job_descriptor_size = %d", h->job_descriptor_size);
if (h->exception_status && h->exception_status != 0x1)
pandecode_prop("exception_status = %x (source ID: 0x%x access: %s exception: 0x%x)",
h->exception_status,
(h->exception_status >> 16) & 0xFFFF,
mali_exception_access_as_str((h->exception_status >> 8) & 0x3),
h->exception_status & 0xFF);
if (h->first_incomplete_task)
pandecode_prop("first_incomplete_task = %d", h->first_incomplete_task);
if (h->fault_pointer)
pandecode_prop("fault_pointer = 0x%" PRIx64, h->fault_pointer);
if (h->job_barrier)
pandecode_prop("job_barrier = %d", h->job_barrier);
pandecode_prop("job_index = %d", h->job_index);
if (h->unknown_flags)
pandecode_prop("unknown_flags = %d", h->unknown_flags);
if (h->job_dependency_index_1)
pandecode_prop("job_dependency_index_1 = %d", h->job_dependency_index_1);
if (h->job_dependency_index_2)
pandecode_prop("job_dependency_index_2 = %d", h->job_dependency_index_2);
pandecode_indent--;
pandecode_log("};\n");
switch (h->job_type) {
switch (h.type) {
case MALI_JOB_TYPE_WRITE_VALUE: {
struct mali_payload_write_value *s = payload;
pandecode_log("struct mali_payload_write_value payload_%"PRIx64"_%d = {\n", payload_ptr, job_no);
@@ -1590,12 +1555,12 @@ pandecode_jc(mali_ptr jc_gpu_va, bool bifrost, unsigned gpu_id, bool minimal)
case MALI_JOB_TYPE_VERTEX:
case MALI_JOB_TYPE_COMPUTE:
if (bifrost) {
if (h->job_type == MALI_JOB_TYPE_TILER)
pandecode_tiler_job_bfr(h, mem, payload_ptr, job_no, gpu_id);
if (h.type == MALI_JOB_TYPE_TILER)
pandecode_tiler_job_bfr(&h, mem, payload_ptr, job_no, gpu_id);
else
pandecode_vertex_job_bfr(h, mem, payload_ptr, job_no, gpu_id);
pandecode_vertex_job_bfr(&h, mem, payload_ptr, job_no, gpu_id);
} else
pandecode_vertex_or_tiler_job_mdg(h, mem, payload_ptr, job_no, gpu_id);
pandecode_vertex_or_tiler_job_mdg(&h, mem, payload_ptr, job_no, gpu_id);
break;
@@ -1606,7 +1571,7 @@ pandecode_jc(mali_ptr jc_gpu_va, bool bifrost, unsigned gpu_id, bool minimal)
default:
break;
}
} while ((jc_gpu_va = h->next_job));
} while ((jc_gpu_va = next_job));
pandecode_map_read_write();
}
+18
View File
@@ -1041,4 +1041,22 @@
<section name="Bifrost Tiler Pointer" offset="56" type="Bifrost Tiler Pointer"/>
<section name="Bifrost Padding" offset="64" type="Bifrost Framebuffer Padding"/>
</aggregate>
<struct name="Job Header">
<field name="Exception Status" size="32" start="0:0" type="uint"/>
<field name="First Incomplete Task" size="32" start="1:0" type="uint"/>
<field name="Fault Pointer" size="64" start="2:0" type="address"/>
<field name="Is 64b" size="1" start="4:0" type="bool" default="true"/>
<field name="Type" size="7" start="4:1" type="Job Type"/>
<field name="Barrier" size="1" start="4:8" type="bool"/>
<field name="Invalidate Cache" size="1" start="4:9" type="bool"/>
<field name="Suppress Prefetch" size="1" start="4:11" type="bool"/>
<field name="Enable Texture Mapper" size="1" start="4:12" type="bool"/>
<field name="Relax Dependency 1" size="1" start="4:14" type="bool"/>
<field name="Relax Dependency 2" size="1" start="4:15" type="bool"/>
<field name="Index" size="16" start="4:16" type="uint"/>
<field name="Dependency 1" size="16" start="5:0" type="uint"/>
<field name="Dependency 2" size="16" start="5:16" type="uint"/>
<field name="Next" size="64" start="6:0" type="address"/>
</struct>
</panxml>
+37 -29
View File
@@ -133,22 +133,21 @@ panfrost_new_job(
/* Assign the index */
unsigned index = ++scoreboard->job_index;
struct mali_job_descriptor_header job = {
.job_descriptor_size = 1,
.job_type = type,
.job_barrier = barrier,
.job_index = index,
.job_dependency_index_1 = local_dep,
.job_dependency_index_2 = global_dep,
};
if (inject)
job.next_job = scoreboard->first_job;
struct panfrost_transfer transfer =
panfrost_pool_alloc_aligned(pool, sizeof(job) + payload_size, 64);
memcpy(transfer.cpu, &job, sizeof(job));
memcpy(transfer.cpu + sizeof(job), payload, payload_size);
panfrost_pool_alloc_aligned(pool, MALI_JOB_HEADER_LENGTH + payload_size, 64);
pan_pack(transfer.cpu, JOB_HEADER, job) {
job.type = type;
job.barrier = barrier;
job.index = index;
job.dependency_1 = local_dep;
job.dependency_2 = global_dep;
if (inject)
job.next = scoreboard->first_job;
}
memcpy(transfer.cpu + MALI_JOB_HEADER_LENGTH, payload, payload_size);
if (inject) {
scoreboard->first_job = transfer.gpu;
@@ -159,12 +158,19 @@ panfrost_new_job(
if (type == MALI_JOB_TYPE_TILER)
scoreboard->tiler_dep = index;
if (scoreboard->prev_job)
scoreboard->prev_job->next_job = transfer.gpu;
else
if (scoreboard->prev_job) {
/* Manual update of the next pointer. This is bad, don't copy
* this pattern.
* TODO: Find a way to defer last job header emission until we
* have a new job to queue or the batch is ready for execution.
*/
scoreboard->prev_job->opaque[6] = transfer.gpu;
scoreboard->prev_job->opaque[7] = transfer.gpu >> 32;
} else {
scoreboard->first_job = transfer.gpu;
}
scoreboard->prev_job = (struct mali_job_descriptor_header *) transfer.cpu;
scoreboard->prev_job = (struct mali_job_header_packed *)transfer.cpu;
return index;
}
@@ -183,21 +189,23 @@ panfrost_scoreboard_initialize_tiler(struct pan_pool *pool,
/* Okay, we do. Let's generate it. We'll need the job's polygon list
* regardless of size. */
struct mali_job_descriptor_header job = {
.job_type = MALI_JOB_TYPE_WRITE_VALUE,
.job_index = scoreboard->write_value_index,
.job_descriptor_size = 1,
.next_job = scoreboard->first_job
};
struct mali_payload_write_value payload = {
.address = polygon_list,
.value_descriptor = MALI_WRITE_VALUE_ZERO,
};
struct panfrost_transfer transfer = panfrost_pool_alloc_aligned(pool, sizeof(job) + sizeof(payload), 64);
memcpy(transfer.cpu, &job, sizeof(job));
memcpy(transfer.cpu + sizeof(job), &payload, sizeof(payload));
struct panfrost_transfer transfer =
panfrost_pool_alloc_aligned(pool,
MALI_JOB_HEADER_LENGTH + sizeof(payload),
64);
pan_pack(transfer.cpu, JOB_HEADER, job) {
job.type = MALI_JOB_TYPE_WRITE_VALUE;
job.index = scoreboard->write_value_index;
job.next = scoreboard->first_job;
}
memcpy(transfer.cpu + MALI_JOB_HEADER_LENGTH, &payload, sizeof(payload));
scoreboard->first_job = transfer.gpu;
}
+1 -1
View File
@@ -38,7 +38,7 @@ struct pan_scoreboard {
unsigned job_index;
/* A CPU-side pointer to the previous job for next_job linking */
struct mali_job_descriptor_header *prev_job;
struct mali_job_header_packed *prev_job;
/* The dependency for tiler jobs (i.e. the index of the last emitted
* tiler job, or zero if none have been emitted) */