cell: fix a number of fence issues

Plus add assertions to check status, alignment, etc.
This commit is contained in:
Brian Paul 2008-10-28 14:03:51 -06:00
parent c46583416a
commit db680ac0e3
4 changed files with 30 additions and 7 deletions

View file

@ -100,12 +100,23 @@ emit_fence(struct cell_context *cell)
const uint batch = cell->cur_batch;
const uint size = cell->buffer_size[batch];
struct cell_command_fence *fence_cmd;
struct cell_fence *fence = &cell->fenced_buffers[batch].fence;
uint i;
/* set fence status to emitted, not yet signalled */
for (i = 0; i < cell->num_spus; i++) {
fence->status[i][0] = CELL_FENCE_EMITTED;
}
ASSERT(size + sizeof(struct cell_command_fence) <= CELL_BUFFER_SIZE);
fence_cmd = (struct cell_command_fence *) (cell->buffer[batch] + size);
fence_cmd->opcode = CELL_CMD_FENCE;
fence_cmd->fence = &cell->fenced_buffers[batch].fence;
fence_cmd->fence = fence;
/* update batch buffer size */
cell->buffer_size[batch] = size + sizeof(struct cell_command_fence);
assert(sizeof(struct cell_command_fence) % 8 == 0);
}
@ -119,7 +130,7 @@ cell_batch_flush(struct cell_context *cell)
{
static boolean flushing = FALSE;
uint batch = cell->cur_batch;
const uint size = cell->buffer_size[batch];
uint size = cell->buffer_size[batch];
uint spu, cmd_word;
assert(!flushing);
@ -130,8 +141,10 @@ cell_batch_flush(struct cell_context *cell)
/* Before we use this batch buffer, make sure any fenced texture buffers
* are released.
*/
if (cell->fenced_buffers[batch].head)
if (cell->fenced_buffers[batch].head) {
emit_fence(cell);
size = cell->buffer_size[batch];
}
flushing = TRUE;

View file

@ -89,7 +89,7 @@ struct cell_buffer_node;
*/
struct cell_buffer_list
{
struct cell_fence fence;
struct cell_fence fence ALIGN16_ATTRIB;
struct cell_buffer_node *head;
};

View file

@ -38,6 +38,7 @@ void
cell_fence_init(struct cell_fence *fence)
{
uint i;
ASSERT_ALIGN16(fence->status);
for (i = 0; i < CELL_MAX_SPUS; i++) {
fence->status[i][0] = CELL_FENCE_IDLE;
}
@ -50,9 +51,9 @@ cell_fence_signalled(const struct cell_context *cell,
{
uint i;
for (i = 0; i < cell->num_spus; i++) {
//ASSERT(fence->status[i][0] != CELL_FENCE_IDLE);
if (fence->status[i][0] == CELL_FENCE_EMITTED)
if (fence->status[i][0] != CELL_FENCE_SIGNALLED)
return FALSE;
/*assert(fence->status[i][0] == CELL_FENCE_EMITTED);*/
}
return TRUE;
}
@ -65,6 +66,15 @@ cell_fence_finish(const struct cell_context *cell,
while (!cell_fence_signalled(cell, fence)) {
usleep(10);
}
#ifdef DEBUG
{
uint i;
for (i = 0; i < cell->num_spus; i++) {
assert(fence->status[i][0] == CELL_FENCE_SIGNALLED);
}
}
#endif
}

View file

@ -107,7 +107,7 @@ cmd_fence(struct cell_command_fence *fence_cmd)
CELL_FENCE_SIGNALLED};
uint *dst = (uint *) fence_cmd->fence;
dst += 4 * spu.init.id; /* main store/memory address, not local store */
ASSERT_ALIGN16(dst);
mfc_put((void *) &status, /* src in local memory */
(unsigned int) dst, /* dst in main memory */
sizeof(status), /* size */