mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-07-25 10:55:58 +00:00
benchmarks/gem_latency: Serialise mmio reads
The joy of our hardware; don't let two threads attempt to read the same register at the same time. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
parent
3ebce37b65
commit
a1d465a3c5
@ -46,10 +46,29 @@
|
|||||||
static int done;
|
static int done;
|
||||||
static int fd;
|
static int fd;
|
||||||
static volatile uint32_t *timestamp_reg;
|
static volatile uint32_t *timestamp_reg;
|
||||||
|
static pthread_spinlock_t timestamp_lock;
|
||||||
|
|
||||||
#define REG(x) (volatile uint32_t *)((volatile char *)igt_global_mmio + x)
|
#define REG(x) (volatile uint32_t *)((volatile char *)igt_global_mmio + x)
|
||||||
#define REG_OFFSET(x) ((volatile char *)(x) - (volatile char *)igt_global_mmio)
|
#define REG_OFFSET(x) ((volatile char *)(x) - (volatile char *)igt_global_mmio)
|
||||||
|
|
||||||
|
static uint32_t read_timestamp_unlocked(void)
|
||||||
|
{
|
||||||
|
return *timestamp_reg;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint32_t read_timestamp_locked(void)
|
||||||
|
{
|
||||||
|
uint32_t t;
|
||||||
|
|
||||||
|
pthread_spin_lock(×tamp_lock);
|
||||||
|
t = *timestamp_reg;
|
||||||
|
pthread_spin_unlock(×tamp_lock);
|
||||||
|
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint32_t (*read_timestamp)(void) = read_timestamp_unlocked;
|
||||||
|
|
||||||
struct consumer {
|
struct consumer {
|
||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
|
|
||||||
@ -247,7 +266,7 @@ static void setup_nop(struct producer *p, uint32_t batch)
|
|||||||
static void measure_latency(struct producer *p, igt_stats_t *stats)
|
static void measure_latency(struct producer *p, igt_stats_t *stats)
|
||||||
{
|
{
|
||||||
gem_sync(fd, p->latency_dispatch.exec[0].handle);
|
gem_sync(fd, p->latency_dispatch.exec[0].handle);
|
||||||
igt_stats_push(stats, *timestamp_reg - *p->last_timestamp);
|
igt_stats_push(stats, read_timestamp() - *p->last_timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *producer(void *arg)
|
static void *producer(void *arg)
|
||||||
@ -256,7 +275,7 @@ static void *producer(void *arg)
|
|||||||
int n;
|
int n;
|
||||||
|
|
||||||
while (!done) {
|
while (!done) {
|
||||||
uint32_t start = *timestamp_reg;
|
uint32_t start = read_timestamp();
|
||||||
int batches;
|
int batches;
|
||||||
|
|
||||||
/* Control the amount of work we do, similar to submitting
|
/* Control the amount of work we do, similar to submitting
|
||||||
@ -391,9 +410,14 @@ static int run(int seconds,
|
|||||||
else
|
else
|
||||||
timestamp_reg = REG(BCS_TIMESTAMP);
|
timestamp_reg = REG(BCS_TIMESTAMP);
|
||||||
|
|
||||||
nrun = *timestamp_reg;
|
if (gen < 8) {
|
||||||
|
pthread_spin_init(×tamp_lock, 0);
|
||||||
|
read_timestamp = read_timestamp_locked;
|
||||||
|
}
|
||||||
|
|
||||||
|
nrun = read_timestamp();
|
||||||
usleep(1);
|
usleep(1);
|
||||||
if (*timestamp_reg == nrun)
|
if (read_timestamp() == nrun)
|
||||||
return 77;
|
return 77;
|
||||||
|
|
||||||
scratch = gem_create(fd, 4*WIDTH*HEIGHT);
|
scratch = gem_create(fd, 4*WIDTH*HEIGHT);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user