From d8a800b63de09f41d482d2b3367e4da67ed0f92b Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 15 Aug 2007 21:05:26 -0700 Subject: Implement fence support. --- linux-core/xgi_cmdlist.c | 76 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 16 deletions(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index a728c0ef..5409892a 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -28,8 +28,10 @@ #include "xgi_regs.h" #include "xgi_misc.h" #include "xgi_cmdlist.h" +#include -static void xgi_emit_flush(struct xgi_info * info, bool link); +static void xgi_emit_flush(struct xgi_info * info, bool stop); +static void xgi_emit_nop(struct xgi_info * info); static unsigned int get_batch_command(enum xgi_batch_type type); static void triggerHWCommandList(struct xgi_info * info); static void xgi_cmdlist_reset(struct xgi_info * info); @@ -101,7 +103,7 @@ int xgi_submit_cmdlist(struct drm_device * dev, void * data, begin[0] = (cmd << 24) | BEGIN_VALID_MASK - | (BEGIN_BEGIN_IDENTIFICATION_MASK & pCmdInfo->id); + | (BEGIN_BEGIN_IDENTIFICATION_MASK & info->next_sequence); begin[1] = BEGIN_LINK_ENABLE_MASK | pCmdInfo->size; begin[2] = pCmdInfo->hw_addr >> 4; begin[3] = 0; @@ -134,19 +136,20 @@ int xgi_submit_cmdlist(struct drm_device * dev, void * data, DRM_DEBUG("info->cmdring.last_ptr != NULL\n"); if (pCmdInfo->type == BTYPE_3D) { - xgi_emit_flush(info, TRUE); + xgi_emit_flush(info, FALSE); } info->cmdring.last_ptr[1] = begin[1]; info->cmdring.last_ptr[2] = begin[2]; info->cmdring.last_ptr[3] = begin[3]; - wmb(); + DRM_WRITEMEMORYBARRIER(); info->cmdring.last_ptr[0] = begin[0]; triggerHWCommandList(info); } info->cmdring.last_ptr = xgi_find_pcie_virt(info, pCmdInfo->hw_addr); + drm_fence_flush_old(info->dev, 0, info->next_sequence); return 0; } @@ -213,9 +216,11 @@ void xgi_cmdlist_cleanup(struct xgi_info * info) */ if (info->cmdring.last_ptr != NULL) { xgi_emit_flush(info, FALSE); - xgi_waitfor_pci_idle(info); + xgi_emit_nop(info); } + xgi_waitfor_pci_idle(info); + (void) memset(&info->cmdring, 0, sizeof(info->cmdring)); } } @@ -233,23 +238,25 @@ static void triggerHWCommandList(struct xgi_info * info) /** * Emit a flush to the CRTL command stream. * @info XGI info structure - * @link Emit (or don't emit) link information at start of flush command. * * This function assumes info->cmdring.ptr is non-NULL. */ -static void xgi_emit_flush(struct xgi_info * info, bool link) +void xgi_emit_flush(struct xgi_info * info, bool stop) { - static const u32 flush_command[8] = { - (0x10 << 24), + const u32 flush_command[8] = { + ((0x10 << 24) + | (BEGIN_BEGIN_IDENTIFICATION_MASK & info->next_sequence)), BEGIN_LINK_ENABLE_MASK | (0x00004), 0x00000000, 0x00000000, - /* Flush everything with the default 32 clock delay. + /* Flush the 2D engine with the default 32 clock delay. */ - 0x003fffff, 0x003fffff, 0x003fffff, 0x003fffff + M2REG_FLUSH_ENGINE_COMMAND | M2REG_FLUSH_2D_ENGINE_MASK, + M2REG_FLUSH_ENGINE_COMMAND | M2REG_FLUSH_2D_ENGINE_MASK, + M2REG_FLUSH_ENGINE_COMMAND | M2REG_FLUSH_2D_ENGINE_MASK, + M2REG_FLUSH_ENGINE_COMMAND | M2REG_FLUSH_2D_ENGINE_MASK, }; - const unsigned int base = (link) ? 0 : 4; - const unsigned int flush_size = (8 - base) * sizeof(u32); + const unsigned int flush_size = sizeof(flush_command); u32 *batch_addr; u32 hw_addr; @@ -263,17 +270,54 @@ static void xgi_emit_flush(struct xgi_info * info, bool link) batch_addr = info->cmdring.ptr + (info->cmdring.ring_offset / 4); - (void) memcpy(batch_addr, & flush_command[base], flush_size); + (void) memcpy(batch_addr, flush_command, flush_size); + + if (stop) { + *batch_addr |= BEGIN_STOP_STORE_CURRENT_POINTER_MASK; + } info->cmdring.last_ptr[1] = BEGIN_LINK_ENABLE_MASK | (flush_size / 4); info->cmdring.last_ptr[2] = hw_addr >> 4; info->cmdring.last_ptr[3] = 0; - wmb(); + DRM_WRITEMEMORYBARRIER(); info->cmdring.last_ptr[0] = (get_batch_command(BTYPE_CTRL) << 24) | (BEGIN_VALID_MASK); triggerHWCommandList(info); info->cmdring.ring_offset += flush_size; - info->cmdring.last_ptr = (link) ? batch_addr : NULL; + info->cmdring.last_ptr = batch_addr; +} + + +/** + * Emit an empty command to the CRTL command stream. + * @info XGI info structure + * + * This function assumes info->cmdring.ptr is non-NULL. In addition, since + * this function emits a command that does not have linkage information, + * it sets info->cmdring.ptr to NULL. + */ +void xgi_emit_nop(struct xgi_info * info) +{ + info->cmdring.last_ptr[1] = BEGIN_LINK_ENABLE_MASK + | (BEGIN_BEGIN_IDENTIFICATION_MASK & info->next_sequence); + info->cmdring.last_ptr[2] = 0; + info->cmdring.last_ptr[3] = 0; + DRM_WRITEMEMORYBARRIER(); + info->cmdring.last_ptr[0] = (get_batch_command(BTYPE_CTRL) << 24) + | (BEGIN_VALID_MASK); + + triggerHWCommandList(info); + + info->cmdring.last_ptr = NULL; +} + + +void xgi_emit_irq(struct xgi_info * info) +{ + if (info->cmdring.last_ptr == NULL) + return; + + xgi_emit_flush(info, TRUE); } -- cgit v1.2.3