iris: Use READ_ONCE and WRITE_ONCE for snapshots_landed

Suggested by Chris Wilson, if only to make it obvious to the human
readers that these are volatile reads.  It may also be necessary for
the compiler in a few cases.
This commit is contained in:
Kenneth Graunke
2019-02-07 08:42:50 -08:00
parent 18e31a9b31
commit 9376799bd6
3 changed files with 8 additions and 7 deletions

View File

@@ -209,8 +209,6 @@ iris_init_batch(struct iris_batch *batch,
iris_batch_reset(batch);
}
#define READ_ONCE(x) (*(volatile __typeof__(x) *)&(x))
static struct drm_i915_gem_exec_object2 *
find_validation_entry(struct iris_batch *batch, struct iris_bo *bo)
{

View File

@@ -787,7 +787,7 @@ iris_begin_query(struct pipe_context *ctx, struct pipe_query *query)
q->result = 0ull;
q->ready = false;
q->map->snapshots_landed = false;
WRITE_ONCE(q->map->snapshots_landed, false);
if (q->type == PIPE_QUERY_PRIMITIVES_GENERATED && q->index == 0) {
ice->state.prims_generated_query_active = true;
@@ -853,7 +853,7 @@ iris_check_query_no_flush(struct iris_context *ice, struct iris_query *q)
struct iris_screen *screen = (void *) ice->ctx.screen;
const struct gen_device_info *devinfo = &screen->devinfo;
if (!q->ready && q->map->snapshots_landed) {
if (!q->ready && READ_ONCE(q->map->snapshots_landed)) {
calculate_result_on_cpu(devinfo, q);
}
}
@@ -874,14 +874,14 @@ iris_get_query_result(struct pipe_context *ctx,
if (iris_batch_references(&ice->batches[q->batch_idx], bo))
iris_batch_flush(&ice->batches[q->batch_idx]);
while (!q->map->snapshots_landed) {
while (!READ_ONCE(q->map->snapshots_landed)) {
if (wait)
iris_wait_syncpt(ctx->screen, q->syncpt, INT64_MAX);
else
return false;
}
assert(q->map->snapshots_landed);
assert(READ_ONCE(q->map->snapshots_landed));
calculate_result_on_cpu(devinfo, q);
}
@@ -927,7 +927,7 @@ iris_get_query_result_resource(struct pipe_context *ctx,
return;
}
if (!q->ready && q->map->snapshots_landed) {
if (!q->ready && READ_ONCE(q->map->snapshots_landed)) {
/* The final snapshots happen to have landed, so let's just compute
* the result on the CPU now...
*/

View File

@@ -33,6 +33,9 @@
struct iris_bo;
#define READ_ONCE(x) (*(volatile __typeof__(x) *)&(x))
#define WRITE_ONCE(x, v) *(volatile __typeof__(x) *)&(x) = (v)
#define IRIS_MAX_TEXTURE_SAMPLERS 32
#define IRIS_MAX_SOL_BUFFERS 4