pan/bit: Submit a WRITE_VALUE job as a sanity check

If this fails, everything else probably will too.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4382>
This commit is contained in:
Alyssa Rosenzweig 2020-03-24 14:08:16 -04:00 committed by Marge Bot
parent 97029c773e
commit a0d1be30e1
3 changed files with 69 additions and 1 deletions

View file

@ -96,7 +96,8 @@ static void
test(void)
{
void *memctx = NULL; /* TODO */
bit_initialize(memctx);
struct panfrost_device *dev = bit_initialize(memctx);
bit_sanity_check(dev);
}
int

View file

@ -26,6 +26,7 @@
#include "bit.h"
#include "panfrost/pandecode/decode.h"
#include "drm-uapi/panfrost_drm.h"
/* Standalone compiler tests submitting jobs directly to the hardware. Uses the
* `bit` prefix for `BIfrost Tests` and because bit sounds wicked cool. */
@ -54,3 +55,67 @@ bit_initialize(void *memctx)
return dev;
}
static bool
bit_submit(struct panfrost_device *dev,
enum mali_job_type T,
void *payload, size_t payload_size,
struct panfrost_bo *bos, size_t bo_count)
{
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);
uint32_t *bo_handles = calloc(sizeof(uint32_t), bo_count);
for (unsigned i = 0; i < bo_count; ++i)
bo_handles[i] = bos[i].gem_handle;
uint32_t syncobj = 0;
int ret = 0;
ret = drmSyncobjCreate(dev->fd, DRM_SYNCOBJ_CREATE_SIGNALED, &syncobj);
assert(!ret);
struct drm_panfrost_submit submit = {
.jc = job->gpu,
.bo_handles = (uintptr_t) bo_handles,
.bo_handle_count = bo_count,
.out_sync = syncobj,
};
ret = drmIoctl(dev->fd, DRM_IOCTL_PANFROST_SUBMIT, &submit);
assert(!ret);
free(bo_handles);
drmSyncobjWait(dev->fd, &syncobj, 1, INT64_MAX, 0, NULL);
pandecode_jc(submit.jc, true, dev->gpu_id, false);
return true;
}
/* Checks that the device is alive and responding to basic jobs as a sanity
* check - prerequisite to running code on the device. We test this via a
* WRITE_VALUE job */
bool
bit_sanity_check(struct panfrost_device *dev)
{
struct panfrost_bo *scratch = bit_bo_create(dev, 4096);
((uint32_t *) scratch->cpu)[0] = 0xAA;
struct mali_payload_write_value payload = {
.address = scratch->gpu,
.value_descriptor = MALI_WRITE_VALUE_ZERO
};
bool success = bit_submit(dev, JOB_TYPE_WRITE_VALUE,
&payload, sizeof(payload), scratch, 1);
return success && (((uint8_t *) scratch->cpu)[0] == 0x0);
}

View file

@ -34,6 +34,8 @@
struct panfrost_device *
bit_initialize(void *memctx);
bool bit_sanity_check(struct panfrost_device *dev);
#endif