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:
@@ -209,8 +209,6 @@ iris_init_batch(struct iris_batch *batch,
|
|||||||
iris_batch_reset(batch);
|
iris_batch_reset(batch);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define READ_ONCE(x) (*(volatile __typeof__(x) *)&(x))
|
|
||||||
|
|
||||||
static struct drm_i915_gem_exec_object2 *
|
static struct drm_i915_gem_exec_object2 *
|
||||||
find_validation_entry(struct iris_batch *batch, struct iris_bo *bo)
|
find_validation_entry(struct iris_batch *batch, struct iris_bo *bo)
|
||||||
{
|
{
|
||||||
|
@@ -787,7 +787,7 @@ iris_begin_query(struct pipe_context *ctx, struct pipe_query *query)
|
|||||||
|
|
||||||
q->result = 0ull;
|
q->result = 0ull;
|
||||||
q->ready = false;
|
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) {
|
if (q->type == PIPE_QUERY_PRIMITIVES_GENERATED && q->index == 0) {
|
||||||
ice->state.prims_generated_query_active = true;
|
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;
|
struct iris_screen *screen = (void *) ice->ctx.screen;
|
||||||
const struct gen_device_info *devinfo = &screen->devinfo;
|
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);
|
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))
|
if (iris_batch_references(&ice->batches[q->batch_idx], bo))
|
||||||
iris_batch_flush(&ice->batches[q->batch_idx]);
|
iris_batch_flush(&ice->batches[q->batch_idx]);
|
||||||
|
|
||||||
while (!q->map->snapshots_landed) {
|
while (!READ_ONCE(q->map->snapshots_landed)) {
|
||||||
if (wait)
|
if (wait)
|
||||||
iris_wait_syncpt(ctx->screen, q->syncpt, INT64_MAX);
|
iris_wait_syncpt(ctx->screen, q->syncpt, INT64_MAX);
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(q->map->snapshots_landed);
|
assert(READ_ONCE(q->map->snapshots_landed));
|
||||||
calculate_result_on_cpu(devinfo, q);
|
calculate_result_on_cpu(devinfo, q);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -927,7 +927,7 @@ iris_get_query_result_resource(struct pipe_context *ctx,
|
|||||||
return;
|
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 final snapshots happen to have landed, so let's just compute
|
||||||
* the result on the CPU now...
|
* the result on the CPU now...
|
||||||
*/
|
*/
|
||||||
|
@@ -33,6 +33,9 @@
|
|||||||
|
|
||||||
struct iris_bo;
|
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_TEXTURE_SAMPLERS 32
|
||||||
#define IRIS_MAX_SOL_BUFFERS 4
|
#define IRIS_MAX_SOL_BUFFERS 4
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user