nouveau_ws_push_destroy(struct nouveau_ws_push *push)
{
util_dynarray_foreach(&push->pushs, struct nouveau_ws_push_buffer, buf) {
- nouveau_ws_bo_unmap(buf->bo, buf->push.orig_map);
+ nouveau_ws_bo_unmap(buf->bo, buf->push.start);
nouveau_ws_bo_destroy(buf->bo);
}
if (!count)
return &buf->push;
- if (buf->push.map + count < buf->push.orig_map + (buf->bo->size / 4)) {
- buf->push.end = buf->push.map + count;
+ if (buf->push.end + count < buf->push.start + (buf->bo->size / 4)) {
+ buf->push.limit = buf->push.end + count;
return &buf->push;
}
/* We don't support BO refs for now */
assert(other->bos.size == 0);
- memcpy(p->map, other_buf->push.orig_map, count * sizeof(*p->map));
- p->map += count;
+ memcpy(p->end, other_buf->push.start, count * sizeof(*p->end));
+ p->end += count;
p->last_size = NULL;
return 0;
util_dynarray_foreach(&push->pushs, struct nouveau_ws_push_buffer, buf) {
struct nouveau_ws_push_buffer *buf = _nouveau_ws_push_top(push);
- uint32_t *cur = buf->push.orig_map;
+ uint32_t *cur = buf->push.start;
/* submitting empty push buffers is probably a bug */
- assert(buf->push.map != buf->push.orig_map);
+ assert(buf->push.end != buf->push.start);
/* make sure we don't overrun the bo */
- assert(buf->push.map <= buf->push.end);
+ assert(buf->push.end <= buf->push.limit);
/* parse all the headers to see if we get to buf->map */
- while (cur < buf->push.map) {
+ while (cur < buf->push.end) {
uint32_t hdr = *cur;
uint32_t mthd = hdr >> 29;
}
cur++;
- assert(cur <= buf->push.map);
+ assert(cur <= buf->push.end);
}
}
}
nouveau_ws_push_dump(struct nouveau_ws_push *push, struct nouveau_ws_context *ctx)
{
util_dynarray_foreach(&push->pushs, struct nouveau_ws_push_buffer, buf) {
- uint32_t *cur = buf->push.orig_map;
+ uint32_t *cur = buf->push.start;
- while (cur < buf->push.map) {
+ while (cur < buf->push.end) {
uint32_t hdr = *cur;
uint32_t type = hdr >> 29;
uint32_t inc;
uint32_t value = 0;
bool is_immd = false;
- printf("[0x%08" PRIxPTR "] HDR %x subch %i", cur - buf->push.orig_map, hdr, subchan);
+ printf("[0x%08" PRIxPTR "] HDR %x subch %i", cur - buf->push.start, hdr, subchan);
cur++;
switch (type) {
/* Can't submit a CPU push */
assert(buf->bo);
- if (buf->push.map == buf->push.orig_map)
+ if (buf->push.end == buf->push.start)
continue;
req_bo[i].handle = buf->bo->handle;
bool first = true;
util_dynarray_foreach(&push->pushs, struct nouveau_ws_push_buffer, buf) {
if (first) {
- buf->push.map = buf->push.orig_map;
+ buf->push.end = buf->push.start;
first = false;
continue;
}
- nouveau_ws_bo_unmap(buf->bo, buf->push.orig_map);
+ nouveau_ws_bo_unmap(buf->bo, buf->push.start);
nouveau_ws_bo_destroy(buf->bo);
}
};
struct nv_push {
- uint32_t *orig_map;
- uint32_t *map;
+ uint32_t *start;
uint32_t *end;
+ uint32_t *limit;
uint32_t *last_size;
};
static inline void
nv_push_init(struct nv_push *push, uint32_t *start, size_t dw_count)
{
- push->orig_map = start;
- push->map = start;
- push->end = start + dw_count;
+ push->start = start;
+ push->end = start;
+ push->limit = start + dw_count;
push->last_size = NULL;
}
static inline size_t
nv_push_dw_count(struct nv_push *push)
{
- assert(push->orig_map <= push->map);
- assert(push->map <= push->end);
- return push->map - push->orig_map;
+ assert(push->start <= push->end);
+ assert(push->end <= push->limit);
+ return push->end - push->start;
}
struct nouveau_ws_push_buffer {
{
__push_verify(push);
- push->last_size = push->map;
- *push->map = NVC0_FIFO_PKHDR_SQ(subc, mthd, size);
- push->map++;
+ push->last_size = push->end;
+ *push->end = NVC0_FIFO_PKHDR_SQ(subc, mthd, size);
+ push->end++;
}
static inline void
__push_immd(struct nv_push *push, int subc, uint32_t mthd, uint32_t val)
{
__push_verify(push);
- push->last_size = push->map;
- *push->map = NVC0_FIFO_PKHDR_IL(subc, mthd, val);
- push->map++;
+ push->last_size = push->end;
+ *push->end = NVC0_FIFO_PKHDR_IL(subc, mthd, val);
+ push->end++;
}
#define P_IMMD(push, class, mthd, args...) do { \
__push_1inc(struct nv_push *push, int subc, uint32_t mthd)
{
__push_verify(push);
- push->last_size = push->map;
- *push->map = NVC0_FIFO_PKHDR_1I(subc, mthd, 0);
- push->map++;
+ push->last_size = push->end;
+ *push->end = NVC0_FIFO_PKHDR_1I(subc, mthd, 0);
+ push->end++;
}
#define P_1INC(push, class, mthd) __push_1inc(push, SUBC_##class, class##_##mthd)
__push_0inc(struct nv_push *push, int subc, uint32_t mthd)
{
__push_verify(push);
- push->last_size = push->map;
- *push->map = NVC0_FIFO_PKHDR_0I(subc, mthd, 0);
- push->map++;
+ push->last_size = push->end;
+ *push->end = NVC0_FIFO_PKHDR_0I(subc, mthd, 0);
+ push->end++;
}
#define P_0INC(push, class, mthd) __push_0inc(push, SUBC_##class, class##_##mthd)
{
if (nvk_push_update_count(push, 1)) {
/* push new value */
- *push->map = value;
- push->map++;
+ *push->end = value;
+ push->end++;
}
}
{
if (nvk_push_update_count(push, 1)) {
/* push new value */
- *(float *)push->map = value;
- push->map++;
+ *(float *)push->end = value;
+ push->end++;
}
}
{
if (nvk_push_update_count(push, num_dw)) {
/* push new value */
- memcpy(push->map, data, num_dw * 4);
- push->map += num_dw;
+ memcpy(push->end, data, num_dw * 4);
+ push->end += num_dw;
}
}
UNUSED bool is_immd = (last_hdr_val & 0xe0000000) == 0x80000000;
UNUSED uint16_t last_method = (last_hdr_val & 0x1fff) << 2;
- uint16_t distance = push->map - push->last_size - 1;
+ uint16_t distance = push->end - push->last_size - 1;
if (is_0inc)
distance = 0;
else if (is_1inc)
assert(last_hdr_val);
assert(!is_immd);
assert(last_method == idx);
- assert(push->map < push->end);
+ assert(push->end < push->limit);
P_INLINE_DATA(push, val);
}