Quoting Michał Winiarski (2017-09-12 18:40:55) > @@ -434,11 +430,16 @@ static void guc_wq_item_append(struct i915_guc_client *client, > */ > BUILD_BUG_ON(wqi_size != 16); > > - /* postincrement WQ tail for next time */ > - wq_off = client->wq_tail; > + /* Find our offset and postincrement WQ tail for next time, free space > + * is guaranteed. > + */ > + do { > + wq_off = READ_ONCE(desc->tail); > + wq_next = (wq_off + wqi_size) & (GUC_WQ_SIZE - 1); > + GEM_BUG_ON(CIRC_SPACE(wq_off, READ_ONCE(desc->head), > + GUC_WQ_SIZE) < wqi_size); > + } while (cmpxchg(&desc->tail, wq_off, wq_next) != wq_off); > GEM_BUG_ON(wq_off & (wqi_size - 1)); I forgot the trick in cmpxchg to avoid the READ_ONCE in every loop: wq_next = READ_ONCE(desc->tail); do { wq_off = wq_next; wq_next = (wq_off + wqi_size) & (GUC_WQ_SIZE - 1); GEM_BUG_ON(...); } while ((wq_next = cmpxchg(&desc->tail, wq_off, wq_next) != wq_off); -Chris _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx