void
tu_cs_reset(struct tu_device *dev, struct tu_cs *cs);
+/**
+ * Discard all entries. This allows \a cs to be reused while keeping the
+ * existing BOs and command packets intact.
+ */
+static inline void
+tu_cs_discard_entries(struct tu_cs *cs)
+{
+ assert(cs->mode == TU_CS_MODE_GROW);
+ cs->entry_count = 0;
+}
+
/**
* Get the size needed for tu_cs_emit_call.
*/
static inline void
tu_cs_emit(struct tu_cs *cs, uint32_t value)
{
- assert(cs->cur < cs->end);
+ assert(cs->cur < cs->reserved_end);
*cs->cur = value;
++cs->cur;
}
+/**
+ * Emit an array of uint32_t into a command stream, without boundary checking.
+ */
+static inline void
+tu_cs_emit_array(struct tu_cs *cs, const uint32_t *values, uint32_t length)
+{
+ assert(cs->cur + length <= cs->reserved_end);
+ memcpy(cs->cur, values, sizeof(uint32_t) * length);
+ cs->cur += length;
+}
+
static inline unsigned
tu_odd_parity_bit(unsigned val)
{
static inline void
tu_cs_emit_ib(struct tu_cs *cs, const struct tu_cs_entry *entry)
{
- assert(entry->offset % sizeof(uint32_t) == 0);
+ assert(entry->bo);
+ assert(entry->size && entry->offset + entry->size <= entry->bo->size);
assert(entry->size % sizeof(uint32_t) == 0);
+ assert(entry->offset % sizeof(uint32_t) == 0);
tu_cs_emit_pkt7(cs, CP_INDIRECT_BUFFER, 3);
tu_cs_emit_qw(cs, entry->bo->iova + entry->offset);