From 7af9d670371de868f0642148fe2d594bc9a7dea3 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 26 Jun 2007 13:05:29 -0700 Subject: Initial XP10 code drop from XGI. See attachment 10246 on https://bugs.freedesktop.org/show_bug.cgi?id=5921 --- linux-core/xgi_cmdlist.c | 348 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 348 insertions(+) create mode 100644 linux-core/xgi_cmdlist.c (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c new file mode 100644 index 00000000..024b021c --- /dev/null +++ b/linux-core/xgi_cmdlist.c @@ -0,0 +1,348 @@ + +/**************************************************************************** + * Copyright (C) 2003-2006 by XGI Technology, Taiwan. + * * + * All Rights Reserved. * + * * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL XGI AND/OR + * ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + ***************************************************************************/ + + +#include "xgi_types.h" +#include "xgi_linux.h" +#include "xgi_drv.h" +#include "xgi_regs.h" +#include "xgi_misc.h" +#include "xgi_cmdlist.h" + + + +U32 s_emptyBegin[AGPCMDLIST_BEGIN_SIZE] = +{ + 0x10000000, // 3D Type Begin, Invalid + 0x80000004, // Length = 4; + 0x00000000, + 0x00000000 +}; + +U32 s_flush2D[AGPCMDLIST_FLUSH_CMD_LEN] = +{ + FLUSH_2D, + FLUSH_2D, + FLUSH_2D, + FLUSH_2D +}; + +xgi_cmdring_info_t s_cmdring; + +static void addFlush2D(xgi_info_t *info); +static U32 getCurBatchBeginPort(xgi_cmd_info_t *pCmdInfo); +static void triggerHWCommandList(xgi_info_t *info, U32 triggerCounter); +static void xgi_cmdlist_reset(void); + +int xgi_cmdlist_initialize(xgi_info_t *info, U32 size) +{ + //xgi_mem_req_t mem_req; + xgi_mem_alloc_t mem_alloc; + + //mem_req.size = size; + + xgi_pcie_alloc(info, size, PCIE_2D, &mem_alloc); + + if ((mem_alloc.size == 0) && (mem_alloc.hw_addr == 0)) + { + return -1; + } + + s_cmdring._cmdRingSize = mem_alloc.size; + s_cmdring._cmdRingBuffer = mem_alloc.hw_addr; + s_cmdring._cmdRingBusAddr = mem_alloc.bus_addr; + s_cmdring._lastBatchStartAddr = 0; + s_cmdring._cmdRingOffset = 0; + + return 1; +} + +void xgi_submit_cmdlist(xgi_info_t *info, xgi_cmd_info_t *pCmdInfo) +{ + U32 beginPort; + /** XGI_INFO("Jong-xgi_submit_cmdlist-Begin \n"); **/ + + /* Jong 05/25/2006 */ + /* return; */ + + beginPort = getCurBatchBeginPort(pCmdInfo); + XGI_INFO("Jong-xgi_submit_cmdlist-After getCurBatchBeginPort() \n"); + + /* Jong 05/25/2006 */ + /* return; */ + + if (s_cmdring._lastBatchStartAddr == 0) + { + U32 portOffset; + + /* Jong 06/13/2006; remove marked for system hang test */ + /* xgi_waitfor_pci_idle(info); */ + + /* Jong 06132006; BASE_3D_ENG=0x2800 */ + /* beginPort: 2D: 0x30 */ + portOffset = BASE_3D_ENG + beginPort; + + // Enable PCI Trigger Mode + XGI_INFO("Jong-xgi_submit_cmdlist-Enable PCI Trigger Mode \n"); + + /* Jong 05/25/2006 */ + /* return; */ + + /* Jong 06/13/2006; M2REG_AUTO_LINK_SETTING_ADDRESS=0x10 */ + XGI_INFO("Jong-M2REG_AUTO_LINK_SETTING_ADDRESS=0x%lx \n", M2REG_AUTO_LINK_SETTING_ADDRESS); + XGI_INFO("Jong-M2REG_CLEAR_COUNTERS_MASK=0x%lx \n", M2REG_CLEAR_COUNTERS_MASK); + XGI_INFO("Jong-(M2REG_AUTO_LINK_SETTING_ADDRESS << 22)=0x%lx \n", (M2REG_AUTO_LINK_SETTING_ADDRESS << 22)); + XGI_INFO("Jong-M2REG_PCI_TRIGGER_MODE_MASK=0x%lx \n\n", M2REG_PCI_TRIGGER_MODE_MASK); + + /* Jong 06/14/2006; 0x400001a */ + XGI_INFO("Jong-(M2REG_AUTO_LINK_SETTING_ADDRESS << 22)|M2REG_CLEAR_COUNTERS_MASK|0x08|M2REG_PCI_TRIGGER_MODE_MASK=0x%lx \n", + (M2REG_AUTO_LINK_SETTING_ADDRESS << 22)|M2REG_CLEAR_COUNTERS_MASK|0x08|M2REG_PCI_TRIGGER_MODE_MASK); + dwWriteReg(BASE_3D_ENG + M2REG_AUTO_LINK_SETTING_ADDRESS, + (M2REG_AUTO_LINK_SETTING_ADDRESS << 22) | + M2REG_CLEAR_COUNTERS_MASK | + 0x08 | + M2REG_PCI_TRIGGER_MODE_MASK); + + /* Jong 05/25/2006 */ + XGI_INFO("Jong-xgi_submit_cmdlist-After dwWriteReg() \n"); + /* return; */ /* OK */ + + /* Jong 06/14/2006; 0x400000a */ + XGI_INFO("Jong-(M2REG_AUTO_LINK_SETTING_ADDRESS << 22)|0x08|M2REG_PCI_TRIGGER_MODE_MASK=0x%lx \n", + (M2REG_AUTO_LINK_SETTING_ADDRESS << 22)|0x08|M2REG_PCI_TRIGGER_MODE_MASK); + dwWriteReg(BASE_3D_ENG + M2REG_AUTO_LINK_SETTING_ADDRESS, + (M2REG_AUTO_LINK_SETTING_ADDRESS << 22) | + 0x08 | + M2REG_PCI_TRIGGER_MODE_MASK); + + // Send PCI begin command + XGI_INFO("Jong-xgi_submit_cmdlist-Send PCI begin command \n"); + /* return; */ + + XGI_INFO("Jong-xgi_submit_cmdlist-portOffset=%d \n", portOffset); + XGI_INFO("Jong-xgi_submit_cmdlist-beginPort=%d \n", beginPort); + + /* beginPort = 48; */ + /* 0xc100000 */ + dwWriteReg(portOffset, (beginPort<<22) + (BEGIN_VALID_MASK) + pCmdInfo->_curDebugID); + XGI_INFO("Jong-(beginPort<<22)=0x%lx \n", (beginPort<<22)); + XGI_INFO("Jong-(BEGIN_VALID_MASK)=0x%lx \n", BEGIN_VALID_MASK); + XGI_INFO("Jong- pCmdInfo->_curDebugID=0x%lx \n", pCmdInfo->_curDebugID); + XGI_INFO("Jong- (beginPort<<22) + (BEGIN_VALID_MASK) + pCmdInfo->_curDebugID=0x%lx \n", (beginPort<<22) + (BEGIN_VALID_MASK) + pCmdInfo->_curDebugID); + XGI_INFO("Jong-xgi_submit_cmdlist-Send PCI begin command- After \n"); + /* return; */ /* OK */ + + /* 0x80000024 */ + dwWriteReg(portOffset+4, BEGIN_LINK_ENABLE_MASK + pCmdInfo->_firstSize); + XGI_INFO("Jong- BEGIN_LINK_ENABLE_MASK=0x%lx \n", BEGIN_LINK_ENABLE_MASK); + XGI_INFO("Jong- pCmdInfo->_firstSize=0x%lx \n", pCmdInfo->_firstSize); + XGI_INFO("Jong- BEGIN_LINK_ENABLE_MASK + pCmdInfo->_firstSize=0x%lx \n", BEGIN_LINK_ENABLE_MASK + pCmdInfo->_firstSize); + XGI_INFO("Jong-xgi_submit_cmdlist-dwWriteReg-1 \n"); + + /* 0x1010000 */ + dwWriteReg(portOffset+8, (pCmdInfo->_firstBeginAddr >> 4)); + XGI_INFO("Jong- pCmdInfo->_firstBeginAddr=0x%lx \n", pCmdInfo->_firstBeginAddr); + XGI_INFO("Jong- (pCmdInfo->_firstBeginAddr >> 4)=0x%lx \n", (pCmdInfo->_firstBeginAddr >> 4)); + XGI_INFO("Jong-xgi_submit_cmdlist-dwWriteReg-2 \n"); + + /* Jong 06/13/2006 */ + xgi_dump_register(info); + + /* Jong 06/12/2006; system hang; marked for test */ + dwWriteReg(portOffset+12, 0); + XGI_INFO("Jong-xgi_submit_cmdlist-dwWriteReg-3 \n"); + + /* Jong 06/13/2006; remove marked for system hang test */ + /* xgi_waitfor_pci_idle(info); */ + } + else + { + XGI_INFO("Jong-xgi_submit_cmdlist-s_cmdring._lastBatchStartAddr != 0 \n"); + U32 *lastBatchVirtAddr; + + /* Jong 05/25/2006 */ + /* return; */ + + if (pCmdInfo->_firstBeginType == BTYPE_3D) + { + addFlush2D(info); + } + + lastBatchVirtAddr = (U32*) xgi_find_pcie_virt(info, s_cmdring._lastBatchStartAddr); + + lastBatchVirtAddr[1] = BEGIN_LINK_ENABLE_MASK + pCmdInfo->_firstSize; + lastBatchVirtAddr[2] = pCmdInfo->_firstBeginAddr >> 4; + lastBatchVirtAddr[3] = 0; + //barrier(); + lastBatchVirtAddr[0] = (beginPort<<22) + (BEGIN_VALID_MASK) + (0xffff & pCmdInfo->_curDebugID); + + /* Jong 06/12/2006; system hang; marked for test */ + triggerHWCommandList(info, pCmdInfo->_beginCount); + + XGI_INFO("Jong-xgi_submit_cmdlist-s_cmdring._lastBatchStartAddr != 0 - End\n"); + } + + s_cmdring._lastBatchStartAddr = pCmdInfo->_lastBeginAddr; + XGI_INFO("Jong-xgi_submit_cmdlist-End \n"); +} + + +/* + state: 0 - console + 1 - graphic + 2 - fb + 3 - logout +*/ +void xgi_state_change(xgi_info_t *info, xgi_state_info_t *pStateInfo) +{ +#define STATE_CONSOLE 0 +#define STATE_GRAPHIC 1 +#define STATE_FBTERM 2 +#define STATE_LOGOUT 3 +#define STATE_REBOOT 4 +#define STATE_SHUTDOWN 5 + + if ((pStateInfo->_fromState == STATE_GRAPHIC) + && (pStateInfo->_toState == STATE_CONSOLE)) + { + XGI_INFO("[kd] I see, now is to leaveVT\n"); + // stop to received batch + } + else if ((pStateInfo->_fromState == STATE_CONSOLE) + && (pStateInfo->_toState == STATE_GRAPHIC)) + { + XGI_INFO("[kd] I see, now is to enterVT\n"); + xgi_cmdlist_reset(); + } + else if ((pStateInfo->_fromState == STATE_GRAPHIC) + && ( (pStateInfo->_toState == STATE_LOGOUT) + ||(pStateInfo->_toState == STATE_REBOOT) + ||(pStateInfo->_toState == STATE_SHUTDOWN))) + { + XGI_INFO("[kd] I see, not is to exit from X\n"); + // stop to received batch + } + else + { + XGI_ERROR("[kd] Should not happen\n"); + } + +} + +void xgi_cmdlist_reset(void) +{ + s_cmdring._lastBatchStartAddr = 0; + s_cmdring._cmdRingOffset = 0; +} + +void xgi_cmdlist_cleanup(xgi_info_t *info) +{ + if (s_cmdring._cmdRingBuffer != 0) + { + xgi_pcie_free(info, s_cmdring._cmdRingBusAddr); + s_cmdring._cmdRingBuffer = 0; + s_cmdring._cmdRingOffset = 0; + s_cmdring._cmdRingSize = 0; + } +} + +static void triggerHWCommandList(xgi_info_t *info, U32 triggerCounter) +{ + static U32 s_triggerID = 1; + + //Fix me, currently we just trigger one time + while (triggerCounter--) + { + dwWriteReg(BASE_3D_ENG + M2REG_PCI_TRIGGER_REGISTER_ADDRESS, + 0x05000000 + (0xffff & s_triggerID++)); + // xgi_waitfor_pci_idle(info); + } +} + +static U32 getCurBatchBeginPort(xgi_cmd_info_t *pCmdInfo) +{ + // Convert the batch type to begin port ID + switch(pCmdInfo->_firstBeginType) + { + case BTYPE_2D: + return 0x30; + case BTYPE_3D: + return 0x40; + case BTYPE_FLIP: + return 0x50; + case BTYPE_CTRL: + return 0x20; + default: + //ASSERT(0); + return 0xff; + } +} + +static void addFlush2D(xgi_info_t *info) +{ + U32 *flushBatchVirtAddr; + U32 flushBatchHWAddr; + + U32 *lastBatchVirtAddr; + + /* check buf is large enough to contain a new flush batch */ + if ((s_cmdring._cmdRingOffset + 0x20) >= s_cmdring._cmdRingSize) + { + s_cmdring._cmdRingOffset = 0; + } + + flushBatchHWAddr = s_cmdring._cmdRingBuffer + s_cmdring._cmdRingOffset; + flushBatchVirtAddr = (U32*) xgi_find_pcie_virt(info, flushBatchHWAddr); + + /* not using memcpy for I assume the address is discrete */ + *(flushBatchVirtAddr + 0) = 0x10000000; + *(flushBatchVirtAddr + 1) = 0x80000004; /* size = 0x04 dwords */ + *(flushBatchVirtAddr + 2) = 0x00000000; + *(flushBatchVirtAddr + 3) = 0x00000000; + *(flushBatchVirtAddr + 4) = FLUSH_2D; + *(flushBatchVirtAddr + 5) = FLUSH_2D; + *(flushBatchVirtAddr + 6) = FLUSH_2D; + *(flushBatchVirtAddr + 7) = FLUSH_2D; + + // ASSERT(s_cmdring._lastBatchStartAddr != NULL); + lastBatchVirtAddr = (U32*) xgi_find_pcie_virt(info, s_cmdring._lastBatchStartAddr); + + lastBatchVirtAddr[1] = BEGIN_LINK_ENABLE_MASK + 0x08; + lastBatchVirtAddr[2] = flushBatchHWAddr >> 4; + lastBatchVirtAddr[3] = 0; + + //barrier(); + + // BTYPE_CTRL & NO debugID + lastBatchVirtAddr[0] = (0x20<<22) + (BEGIN_VALID_MASK); + + triggerHWCommandList(info, 1); + + s_cmdring._cmdRingOffset += 0x20; + s_cmdring._lastBatchStartAddr = flushBatchHWAddr; +} -- cgit v1.2.3 From 434657a2582362367ba2a94f827511252001368f Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 26 Jun 2007 13:10:30 -0700 Subject: dos2unix and Lindent --- linux-core/xgi_cmdlist.c | 705 ++++++++++++++++++++++++----------------------- 1 file changed, 357 insertions(+), 348 deletions(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index 024b021c..e00ea228 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -1,348 +1,357 @@ - -/**************************************************************************** - * Copyright (C) 2003-2006 by XGI Technology, Taiwan. - * * - * All Rights Reserved. * - * * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation on the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial - * portions of the Software. - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NON-INFRINGEMENT. IN NO EVENT SHALL XGI AND/OR - * ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - ***************************************************************************/ - - -#include "xgi_types.h" -#include "xgi_linux.h" -#include "xgi_drv.h" -#include "xgi_regs.h" -#include "xgi_misc.h" -#include "xgi_cmdlist.h" - - - -U32 s_emptyBegin[AGPCMDLIST_BEGIN_SIZE] = -{ - 0x10000000, // 3D Type Begin, Invalid - 0x80000004, // Length = 4; - 0x00000000, - 0x00000000 -}; - -U32 s_flush2D[AGPCMDLIST_FLUSH_CMD_LEN] = -{ - FLUSH_2D, - FLUSH_2D, - FLUSH_2D, - FLUSH_2D -}; - -xgi_cmdring_info_t s_cmdring; - -static void addFlush2D(xgi_info_t *info); -static U32 getCurBatchBeginPort(xgi_cmd_info_t *pCmdInfo); -static void triggerHWCommandList(xgi_info_t *info, U32 triggerCounter); -static void xgi_cmdlist_reset(void); - -int xgi_cmdlist_initialize(xgi_info_t *info, U32 size) -{ - //xgi_mem_req_t mem_req; - xgi_mem_alloc_t mem_alloc; - - //mem_req.size = size; - - xgi_pcie_alloc(info, size, PCIE_2D, &mem_alloc); - - if ((mem_alloc.size == 0) && (mem_alloc.hw_addr == 0)) - { - return -1; - } - - s_cmdring._cmdRingSize = mem_alloc.size; - s_cmdring._cmdRingBuffer = mem_alloc.hw_addr; - s_cmdring._cmdRingBusAddr = mem_alloc.bus_addr; - s_cmdring._lastBatchStartAddr = 0; - s_cmdring._cmdRingOffset = 0; - - return 1; -} - -void xgi_submit_cmdlist(xgi_info_t *info, xgi_cmd_info_t *pCmdInfo) -{ - U32 beginPort; - /** XGI_INFO("Jong-xgi_submit_cmdlist-Begin \n"); **/ - - /* Jong 05/25/2006 */ - /* return; */ - - beginPort = getCurBatchBeginPort(pCmdInfo); - XGI_INFO("Jong-xgi_submit_cmdlist-After getCurBatchBeginPort() \n"); - - /* Jong 05/25/2006 */ - /* return; */ - - if (s_cmdring._lastBatchStartAddr == 0) - { - U32 portOffset; - - /* Jong 06/13/2006; remove marked for system hang test */ - /* xgi_waitfor_pci_idle(info); */ - - /* Jong 06132006; BASE_3D_ENG=0x2800 */ - /* beginPort: 2D: 0x30 */ - portOffset = BASE_3D_ENG + beginPort; - - // Enable PCI Trigger Mode - XGI_INFO("Jong-xgi_submit_cmdlist-Enable PCI Trigger Mode \n"); - - /* Jong 05/25/2006 */ - /* return; */ - - /* Jong 06/13/2006; M2REG_AUTO_LINK_SETTING_ADDRESS=0x10 */ - XGI_INFO("Jong-M2REG_AUTO_LINK_SETTING_ADDRESS=0x%lx \n", M2REG_AUTO_LINK_SETTING_ADDRESS); - XGI_INFO("Jong-M2REG_CLEAR_COUNTERS_MASK=0x%lx \n", M2REG_CLEAR_COUNTERS_MASK); - XGI_INFO("Jong-(M2REG_AUTO_LINK_SETTING_ADDRESS << 22)=0x%lx \n", (M2REG_AUTO_LINK_SETTING_ADDRESS << 22)); - XGI_INFO("Jong-M2REG_PCI_TRIGGER_MODE_MASK=0x%lx \n\n", M2REG_PCI_TRIGGER_MODE_MASK); - - /* Jong 06/14/2006; 0x400001a */ - XGI_INFO("Jong-(M2REG_AUTO_LINK_SETTING_ADDRESS << 22)|M2REG_CLEAR_COUNTERS_MASK|0x08|M2REG_PCI_TRIGGER_MODE_MASK=0x%lx \n", - (M2REG_AUTO_LINK_SETTING_ADDRESS << 22)|M2REG_CLEAR_COUNTERS_MASK|0x08|M2REG_PCI_TRIGGER_MODE_MASK); - dwWriteReg(BASE_3D_ENG + M2REG_AUTO_LINK_SETTING_ADDRESS, - (M2REG_AUTO_LINK_SETTING_ADDRESS << 22) | - M2REG_CLEAR_COUNTERS_MASK | - 0x08 | - M2REG_PCI_TRIGGER_MODE_MASK); - - /* Jong 05/25/2006 */ - XGI_INFO("Jong-xgi_submit_cmdlist-After dwWriteReg() \n"); - /* return; */ /* OK */ - - /* Jong 06/14/2006; 0x400000a */ - XGI_INFO("Jong-(M2REG_AUTO_LINK_SETTING_ADDRESS << 22)|0x08|M2REG_PCI_TRIGGER_MODE_MASK=0x%lx \n", - (M2REG_AUTO_LINK_SETTING_ADDRESS << 22)|0x08|M2REG_PCI_TRIGGER_MODE_MASK); - dwWriteReg(BASE_3D_ENG + M2REG_AUTO_LINK_SETTING_ADDRESS, - (M2REG_AUTO_LINK_SETTING_ADDRESS << 22) | - 0x08 | - M2REG_PCI_TRIGGER_MODE_MASK); - - // Send PCI begin command - XGI_INFO("Jong-xgi_submit_cmdlist-Send PCI begin command \n"); - /* return; */ - - XGI_INFO("Jong-xgi_submit_cmdlist-portOffset=%d \n", portOffset); - XGI_INFO("Jong-xgi_submit_cmdlist-beginPort=%d \n", beginPort); - - /* beginPort = 48; */ - /* 0xc100000 */ - dwWriteReg(portOffset, (beginPort<<22) + (BEGIN_VALID_MASK) + pCmdInfo->_curDebugID); - XGI_INFO("Jong-(beginPort<<22)=0x%lx \n", (beginPort<<22)); - XGI_INFO("Jong-(BEGIN_VALID_MASK)=0x%lx \n", BEGIN_VALID_MASK); - XGI_INFO("Jong- pCmdInfo->_curDebugID=0x%lx \n", pCmdInfo->_curDebugID); - XGI_INFO("Jong- (beginPort<<22) + (BEGIN_VALID_MASK) + pCmdInfo->_curDebugID=0x%lx \n", (beginPort<<22) + (BEGIN_VALID_MASK) + pCmdInfo->_curDebugID); - XGI_INFO("Jong-xgi_submit_cmdlist-Send PCI begin command- After \n"); - /* return; */ /* OK */ - - /* 0x80000024 */ - dwWriteReg(portOffset+4, BEGIN_LINK_ENABLE_MASK + pCmdInfo->_firstSize); - XGI_INFO("Jong- BEGIN_LINK_ENABLE_MASK=0x%lx \n", BEGIN_LINK_ENABLE_MASK); - XGI_INFO("Jong- pCmdInfo->_firstSize=0x%lx \n", pCmdInfo->_firstSize); - XGI_INFO("Jong- BEGIN_LINK_ENABLE_MASK + pCmdInfo->_firstSize=0x%lx \n", BEGIN_LINK_ENABLE_MASK + pCmdInfo->_firstSize); - XGI_INFO("Jong-xgi_submit_cmdlist-dwWriteReg-1 \n"); - - /* 0x1010000 */ - dwWriteReg(portOffset+8, (pCmdInfo->_firstBeginAddr >> 4)); - XGI_INFO("Jong- pCmdInfo->_firstBeginAddr=0x%lx \n", pCmdInfo->_firstBeginAddr); - XGI_INFO("Jong- (pCmdInfo->_firstBeginAddr >> 4)=0x%lx \n", (pCmdInfo->_firstBeginAddr >> 4)); - XGI_INFO("Jong-xgi_submit_cmdlist-dwWriteReg-2 \n"); - - /* Jong 06/13/2006 */ - xgi_dump_register(info); - - /* Jong 06/12/2006; system hang; marked for test */ - dwWriteReg(portOffset+12, 0); - XGI_INFO("Jong-xgi_submit_cmdlist-dwWriteReg-3 \n"); - - /* Jong 06/13/2006; remove marked for system hang test */ - /* xgi_waitfor_pci_idle(info); */ - } - else - { - XGI_INFO("Jong-xgi_submit_cmdlist-s_cmdring._lastBatchStartAddr != 0 \n"); - U32 *lastBatchVirtAddr; - - /* Jong 05/25/2006 */ - /* return; */ - - if (pCmdInfo->_firstBeginType == BTYPE_3D) - { - addFlush2D(info); - } - - lastBatchVirtAddr = (U32*) xgi_find_pcie_virt(info, s_cmdring._lastBatchStartAddr); - - lastBatchVirtAddr[1] = BEGIN_LINK_ENABLE_MASK + pCmdInfo->_firstSize; - lastBatchVirtAddr[2] = pCmdInfo->_firstBeginAddr >> 4; - lastBatchVirtAddr[3] = 0; - //barrier(); - lastBatchVirtAddr[0] = (beginPort<<22) + (BEGIN_VALID_MASK) + (0xffff & pCmdInfo->_curDebugID); - - /* Jong 06/12/2006; system hang; marked for test */ - triggerHWCommandList(info, pCmdInfo->_beginCount); - - XGI_INFO("Jong-xgi_submit_cmdlist-s_cmdring._lastBatchStartAddr != 0 - End\n"); - } - - s_cmdring._lastBatchStartAddr = pCmdInfo->_lastBeginAddr; - XGI_INFO("Jong-xgi_submit_cmdlist-End \n"); -} - - -/* - state: 0 - console - 1 - graphic - 2 - fb - 3 - logout -*/ -void xgi_state_change(xgi_info_t *info, xgi_state_info_t *pStateInfo) -{ -#define STATE_CONSOLE 0 -#define STATE_GRAPHIC 1 -#define STATE_FBTERM 2 -#define STATE_LOGOUT 3 -#define STATE_REBOOT 4 -#define STATE_SHUTDOWN 5 - - if ((pStateInfo->_fromState == STATE_GRAPHIC) - && (pStateInfo->_toState == STATE_CONSOLE)) - { - XGI_INFO("[kd] I see, now is to leaveVT\n"); - // stop to received batch - } - else if ((pStateInfo->_fromState == STATE_CONSOLE) - && (pStateInfo->_toState == STATE_GRAPHIC)) - { - XGI_INFO("[kd] I see, now is to enterVT\n"); - xgi_cmdlist_reset(); - } - else if ((pStateInfo->_fromState == STATE_GRAPHIC) - && ( (pStateInfo->_toState == STATE_LOGOUT) - ||(pStateInfo->_toState == STATE_REBOOT) - ||(pStateInfo->_toState == STATE_SHUTDOWN))) - { - XGI_INFO("[kd] I see, not is to exit from X\n"); - // stop to received batch - } - else - { - XGI_ERROR("[kd] Should not happen\n"); - } - -} - -void xgi_cmdlist_reset(void) -{ - s_cmdring._lastBatchStartAddr = 0; - s_cmdring._cmdRingOffset = 0; -} - -void xgi_cmdlist_cleanup(xgi_info_t *info) -{ - if (s_cmdring._cmdRingBuffer != 0) - { - xgi_pcie_free(info, s_cmdring._cmdRingBusAddr); - s_cmdring._cmdRingBuffer = 0; - s_cmdring._cmdRingOffset = 0; - s_cmdring._cmdRingSize = 0; - } -} - -static void triggerHWCommandList(xgi_info_t *info, U32 triggerCounter) -{ - static U32 s_triggerID = 1; - - //Fix me, currently we just trigger one time - while (triggerCounter--) - { - dwWriteReg(BASE_3D_ENG + M2REG_PCI_TRIGGER_REGISTER_ADDRESS, - 0x05000000 + (0xffff & s_triggerID++)); - // xgi_waitfor_pci_idle(info); - } -} - -static U32 getCurBatchBeginPort(xgi_cmd_info_t *pCmdInfo) -{ - // Convert the batch type to begin port ID - switch(pCmdInfo->_firstBeginType) - { - case BTYPE_2D: - return 0x30; - case BTYPE_3D: - return 0x40; - case BTYPE_FLIP: - return 0x50; - case BTYPE_CTRL: - return 0x20; - default: - //ASSERT(0); - return 0xff; - } -} - -static void addFlush2D(xgi_info_t *info) -{ - U32 *flushBatchVirtAddr; - U32 flushBatchHWAddr; - - U32 *lastBatchVirtAddr; - - /* check buf is large enough to contain a new flush batch */ - if ((s_cmdring._cmdRingOffset + 0x20) >= s_cmdring._cmdRingSize) - { - s_cmdring._cmdRingOffset = 0; - } - - flushBatchHWAddr = s_cmdring._cmdRingBuffer + s_cmdring._cmdRingOffset; - flushBatchVirtAddr = (U32*) xgi_find_pcie_virt(info, flushBatchHWAddr); - - /* not using memcpy for I assume the address is discrete */ - *(flushBatchVirtAddr + 0) = 0x10000000; - *(flushBatchVirtAddr + 1) = 0x80000004; /* size = 0x04 dwords */ - *(flushBatchVirtAddr + 2) = 0x00000000; - *(flushBatchVirtAddr + 3) = 0x00000000; - *(flushBatchVirtAddr + 4) = FLUSH_2D; - *(flushBatchVirtAddr + 5) = FLUSH_2D; - *(flushBatchVirtAddr + 6) = FLUSH_2D; - *(flushBatchVirtAddr + 7) = FLUSH_2D; - - // ASSERT(s_cmdring._lastBatchStartAddr != NULL); - lastBatchVirtAddr = (U32*) xgi_find_pcie_virt(info, s_cmdring._lastBatchStartAddr); - - lastBatchVirtAddr[1] = BEGIN_LINK_ENABLE_MASK + 0x08; - lastBatchVirtAddr[2] = flushBatchHWAddr >> 4; - lastBatchVirtAddr[3] = 0; - - //barrier(); - - // BTYPE_CTRL & NO debugID - lastBatchVirtAddr[0] = (0x20<<22) + (BEGIN_VALID_MASK); - - triggerHWCommandList(info, 1); - - s_cmdring._cmdRingOffset += 0x20; - s_cmdring._lastBatchStartAddr = flushBatchHWAddr; -} + +/**************************************************************************** + * Copyright (C) 2003-2006 by XGI Technology, Taiwan. + * * + * All Rights Reserved. * + * * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL XGI AND/OR + * ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + ***************************************************************************/ + +#include "xgi_types.h" +#include "xgi_linux.h" +#include "xgi_drv.h" +#include "xgi_regs.h" +#include "xgi_misc.h" +#include "xgi_cmdlist.h" + +U32 s_emptyBegin[AGPCMDLIST_BEGIN_SIZE] = { + 0x10000000, // 3D Type Begin, Invalid + 0x80000004, // Length = 4; + 0x00000000, + 0x00000000 +}; + +U32 s_flush2D[AGPCMDLIST_FLUSH_CMD_LEN] = { + FLUSH_2D, + FLUSH_2D, + FLUSH_2D, + FLUSH_2D +}; + +xgi_cmdring_info_t s_cmdring; + +static void addFlush2D(xgi_info_t * info); +static U32 getCurBatchBeginPort(xgi_cmd_info_t * pCmdInfo); +static void triggerHWCommandList(xgi_info_t * info, U32 triggerCounter); +static void xgi_cmdlist_reset(void); + +int xgi_cmdlist_initialize(xgi_info_t * info, U32 size) +{ + //xgi_mem_req_t mem_req; + xgi_mem_alloc_t mem_alloc; + + //mem_req.size = size; + + xgi_pcie_alloc(info, size, PCIE_2D, &mem_alloc); + + if ((mem_alloc.size == 0) && (mem_alloc.hw_addr == 0)) { + return -1; + } + + s_cmdring._cmdRingSize = mem_alloc.size; + s_cmdring._cmdRingBuffer = mem_alloc.hw_addr; + s_cmdring._cmdRingBusAddr = mem_alloc.bus_addr; + s_cmdring._lastBatchStartAddr = 0; + s_cmdring._cmdRingOffset = 0; + + return 1; +} + +void xgi_submit_cmdlist(xgi_info_t * info, xgi_cmd_info_t * pCmdInfo) +{ + U32 beginPort; + /** XGI_INFO("Jong-xgi_submit_cmdlist-Begin \n"); **/ + + /* Jong 05/25/2006 */ + /* return; */ + + beginPort = getCurBatchBeginPort(pCmdInfo); + XGI_INFO("Jong-xgi_submit_cmdlist-After getCurBatchBeginPort() \n"); + + /* Jong 05/25/2006 */ + /* return; */ + + if (s_cmdring._lastBatchStartAddr == 0) { + U32 portOffset; + + /* Jong 06/13/2006; remove marked for system hang test */ + /* xgi_waitfor_pci_idle(info); */ + + /* Jong 06132006; BASE_3D_ENG=0x2800 */ + /* beginPort: 2D: 0x30 */ + portOffset = BASE_3D_ENG + beginPort; + + // Enable PCI Trigger Mode + XGI_INFO("Jong-xgi_submit_cmdlist-Enable PCI Trigger Mode \n"); + + /* Jong 05/25/2006 */ + /* return; */ + + /* Jong 06/13/2006; M2REG_AUTO_LINK_SETTING_ADDRESS=0x10 */ + XGI_INFO("Jong-M2REG_AUTO_LINK_SETTING_ADDRESS=0x%lx \n", + M2REG_AUTO_LINK_SETTING_ADDRESS); + XGI_INFO("Jong-M2REG_CLEAR_COUNTERS_MASK=0x%lx \n", + M2REG_CLEAR_COUNTERS_MASK); + XGI_INFO + ("Jong-(M2REG_AUTO_LINK_SETTING_ADDRESS << 22)=0x%lx \n", + (M2REG_AUTO_LINK_SETTING_ADDRESS << 22)); + XGI_INFO("Jong-M2REG_PCI_TRIGGER_MODE_MASK=0x%lx \n\n", + M2REG_PCI_TRIGGER_MODE_MASK); + + /* Jong 06/14/2006; 0x400001a */ + XGI_INFO + ("Jong-(M2REG_AUTO_LINK_SETTING_ADDRESS << 22)|M2REG_CLEAR_COUNTERS_MASK|0x08|M2REG_PCI_TRIGGER_MODE_MASK=0x%lx \n", + (M2REG_AUTO_LINK_SETTING_ADDRESS << 22) | + M2REG_CLEAR_COUNTERS_MASK | 0x08 | + M2REG_PCI_TRIGGER_MODE_MASK); + dwWriteReg(BASE_3D_ENG + M2REG_AUTO_LINK_SETTING_ADDRESS, + (M2REG_AUTO_LINK_SETTING_ADDRESS << 22) | + M2REG_CLEAR_COUNTERS_MASK | 0x08 | + M2REG_PCI_TRIGGER_MODE_MASK); + + /* Jong 05/25/2006 */ + XGI_INFO("Jong-xgi_submit_cmdlist-After dwWriteReg() \n"); + /* return; *//* OK */ + + /* Jong 06/14/2006; 0x400000a */ + XGI_INFO + ("Jong-(M2REG_AUTO_LINK_SETTING_ADDRESS << 22)|0x08|M2REG_PCI_TRIGGER_MODE_MASK=0x%lx \n", + (M2REG_AUTO_LINK_SETTING_ADDRESS << 22) | 0x08 | + M2REG_PCI_TRIGGER_MODE_MASK); + dwWriteReg(BASE_3D_ENG + M2REG_AUTO_LINK_SETTING_ADDRESS, + (M2REG_AUTO_LINK_SETTING_ADDRESS << 22) | 0x08 | + M2REG_PCI_TRIGGER_MODE_MASK); + + // Send PCI begin command + XGI_INFO("Jong-xgi_submit_cmdlist-Send PCI begin command \n"); + /* return; */ + + XGI_INFO("Jong-xgi_submit_cmdlist-portOffset=%d \n", + portOffset); + XGI_INFO("Jong-xgi_submit_cmdlist-beginPort=%d \n", beginPort); + + /* beginPort = 48; */ + /* 0xc100000 */ + dwWriteReg(portOffset, + (beginPort << 22) + (BEGIN_VALID_MASK) + + pCmdInfo->_curDebugID); + XGI_INFO("Jong-(beginPort<<22)=0x%lx \n", (beginPort << 22)); + XGI_INFO("Jong-(BEGIN_VALID_MASK)=0x%lx \n", BEGIN_VALID_MASK); + XGI_INFO("Jong- pCmdInfo->_curDebugID=0x%lx \n", + pCmdInfo->_curDebugID); + XGI_INFO + ("Jong- (beginPort<<22) + (BEGIN_VALID_MASK) + pCmdInfo->_curDebugID=0x%lx \n", + (beginPort << 22) + (BEGIN_VALID_MASK) + + pCmdInfo->_curDebugID); + XGI_INFO + ("Jong-xgi_submit_cmdlist-Send PCI begin command- After \n"); + /* return; *//* OK */ + + /* 0x80000024 */ + dwWriteReg(portOffset + 4, + BEGIN_LINK_ENABLE_MASK + pCmdInfo->_firstSize); + XGI_INFO("Jong- BEGIN_LINK_ENABLE_MASK=0x%lx \n", + BEGIN_LINK_ENABLE_MASK); + XGI_INFO("Jong- pCmdInfo->_firstSize=0x%lx \n", + pCmdInfo->_firstSize); + XGI_INFO + ("Jong- BEGIN_LINK_ENABLE_MASK + pCmdInfo->_firstSize=0x%lx \n", + BEGIN_LINK_ENABLE_MASK + pCmdInfo->_firstSize); + XGI_INFO("Jong-xgi_submit_cmdlist-dwWriteReg-1 \n"); + + /* 0x1010000 */ + dwWriteReg(portOffset + 8, (pCmdInfo->_firstBeginAddr >> 4)); + XGI_INFO("Jong- pCmdInfo->_firstBeginAddr=0x%lx \n", + pCmdInfo->_firstBeginAddr); + XGI_INFO("Jong- (pCmdInfo->_firstBeginAddr >> 4)=0x%lx \n", + (pCmdInfo->_firstBeginAddr >> 4)); + XGI_INFO("Jong-xgi_submit_cmdlist-dwWriteReg-2 \n"); + + /* Jong 06/13/2006 */ + xgi_dump_register(info); + + /* Jong 06/12/2006; system hang; marked for test */ + dwWriteReg(portOffset + 12, 0); + XGI_INFO("Jong-xgi_submit_cmdlist-dwWriteReg-3 \n"); + + /* Jong 06/13/2006; remove marked for system hang test */ + /* xgi_waitfor_pci_idle(info); */ + } else { + XGI_INFO + ("Jong-xgi_submit_cmdlist-s_cmdring._lastBatchStartAddr != 0 \n"); + U32 *lastBatchVirtAddr; + + /* Jong 05/25/2006 */ + /* return; */ + + if (pCmdInfo->_firstBeginType == BTYPE_3D) { + addFlush2D(info); + } + + lastBatchVirtAddr = + (U32 *) xgi_find_pcie_virt(info, + s_cmdring._lastBatchStartAddr); + + lastBatchVirtAddr[1] = + BEGIN_LINK_ENABLE_MASK + pCmdInfo->_firstSize; + lastBatchVirtAddr[2] = pCmdInfo->_firstBeginAddr >> 4; + lastBatchVirtAddr[3] = 0; + //barrier(); + lastBatchVirtAddr[0] = + (beginPort << 22) + (BEGIN_VALID_MASK) + + (0xffff & pCmdInfo->_curDebugID); + + /* Jong 06/12/2006; system hang; marked for test */ + triggerHWCommandList(info, pCmdInfo->_beginCount); + + XGI_INFO + ("Jong-xgi_submit_cmdlist-s_cmdring._lastBatchStartAddr != 0 - End\n"); + } + + s_cmdring._lastBatchStartAddr = pCmdInfo->_lastBeginAddr; + XGI_INFO("Jong-xgi_submit_cmdlist-End \n"); +} + +/* + state: 0 - console + 1 - graphic + 2 - fb + 3 - logout +*/ +void xgi_state_change(xgi_info_t * info, xgi_state_info_t * pStateInfo) +{ +#define STATE_CONSOLE 0 +#define STATE_GRAPHIC 1 +#define STATE_FBTERM 2 +#define STATE_LOGOUT 3 +#define STATE_REBOOT 4 +#define STATE_SHUTDOWN 5 + + if ((pStateInfo->_fromState == STATE_GRAPHIC) + && (pStateInfo->_toState == STATE_CONSOLE)) { + XGI_INFO("[kd] I see, now is to leaveVT\n"); + // stop to received batch + } else if ((pStateInfo->_fromState == STATE_CONSOLE) + && (pStateInfo->_toState == STATE_GRAPHIC)) { + XGI_INFO("[kd] I see, now is to enterVT\n"); + xgi_cmdlist_reset(); + } else if ((pStateInfo->_fromState == STATE_GRAPHIC) + && ((pStateInfo->_toState == STATE_LOGOUT) + || (pStateInfo->_toState == STATE_REBOOT) + || (pStateInfo->_toState == STATE_SHUTDOWN))) { + XGI_INFO("[kd] I see, not is to exit from X\n"); + // stop to received batch + } else { + XGI_ERROR("[kd] Should not happen\n"); + } + +} + +void xgi_cmdlist_reset(void) +{ + s_cmdring._lastBatchStartAddr = 0; + s_cmdring._cmdRingOffset = 0; +} + +void xgi_cmdlist_cleanup(xgi_info_t * info) +{ + if (s_cmdring._cmdRingBuffer != 0) { + xgi_pcie_free(info, s_cmdring._cmdRingBusAddr); + s_cmdring._cmdRingBuffer = 0; + s_cmdring._cmdRingOffset = 0; + s_cmdring._cmdRingSize = 0; + } +} + +static void triggerHWCommandList(xgi_info_t * info, U32 triggerCounter) +{ + static U32 s_triggerID = 1; + + //Fix me, currently we just trigger one time + while (triggerCounter--) { + dwWriteReg(BASE_3D_ENG + M2REG_PCI_TRIGGER_REGISTER_ADDRESS, + 0x05000000 + (0xffff & s_triggerID++)); + // xgi_waitfor_pci_idle(info); + } +} + +static U32 getCurBatchBeginPort(xgi_cmd_info_t * pCmdInfo) +{ + // Convert the batch type to begin port ID + switch (pCmdInfo->_firstBeginType) { + case BTYPE_2D: + return 0x30; + case BTYPE_3D: + return 0x40; + case BTYPE_FLIP: + return 0x50; + case BTYPE_CTRL: + return 0x20; + default: + //ASSERT(0); + return 0xff; + } +} + +static void addFlush2D(xgi_info_t * info) +{ + U32 *flushBatchVirtAddr; + U32 flushBatchHWAddr; + + U32 *lastBatchVirtAddr; + + /* check buf is large enough to contain a new flush batch */ + if ((s_cmdring._cmdRingOffset + 0x20) >= s_cmdring._cmdRingSize) { + s_cmdring._cmdRingOffset = 0; + } + + flushBatchHWAddr = s_cmdring._cmdRingBuffer + s_cmdring._cmdRingOffset; + flushBatchVirtAddr = (U32 *) xgi_find_pcie_virt(info, flushBatchHWAddr); + + /* not using memcpy for I assume the address is discrete */ + *(flushBatchVirtAddr + 0) = 0x10000000; + *(flushBatchVirtAddr + 1) = 0x80000004; /* size = 0x04 dwords */ + *(flushBatchVirtAddr + 2) = 0x00000000; + *(flushBatchVirtAddr + 3) = 0x00000000; + *(flushBatchVirtAddr + 4) = FLUSH_2D; + *(flushBatchVirtAddr + 5) = FLUSH_2D; + *(flushBatchVirtAddr + 6) = FLUSH_2D; + *(flushBatchVirtAddr + 7) = FLUSH_2D; + + // ASSERT(s_cmdring._lastBatchStartAddr != NULL); + lastBatchVirtAddr = + (U32 *) xgi_find_pcie_virt(info, s_cmdring._lastBatchStartAddr); + + lastBatchVirtAddr[1] = BEGIN_LINK_ENABLE_MASK + 0x08; + lastBatchVirtAddr[2] = flushBatchHWAddr >> 4; + lastBatchVirtAddr[3] = 0; + + //barrier(); + + // BTYPE_CTRL & NO debugID + lastBatchVirtAddr[0] = (0x20 << 22) + (BEGIN_VALID_MASK); + + triggerHWCommandList(info, 1); + + s_cmdring._cmdRingOffset += 0x20; + s_cmdring._lastBatchStartAddr = flushBatchHWAddr; +} -- cgit v1.2.3 From b9ef1467fed9e96c5e7bd453d01511f8ce98583c Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 26 Jun 2007 13:39:01 -0700 Subject: Clean up mixed declarations and code. --- linux-core/xgi_cmdlist.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index e00ea228..99be2145 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -196,9 +196,10 @@ void xgi_submit_cmdlist(xgi_info_t * info, xgi_cmd_info_t * pCmdInfo) /* Jong 06/13/2006; remove marked for system hang test */ /* xgi_waitfor_pci_idle(info); */ } else { + U32 *lastBatchVirtAddr; + XGI_INFO ("Jong-xgi_submit_cmdlist-s_cmdring._lastBatchStartAddr != 0 \n"); - U32 *lastBatchVirtAddr; /* Jong 05/25/2006 */ /* return; */ -- cgit v1.2.3 From 88328d4ef007c781874aafedfef59aae0d21a37c Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 29 Jun 2007 15:27:38 -0700 Subject: Eliminate structure typedefs Documentation/CodingStyle says that 'typedef struct foo foo_t' is evil. I tend to agree. Elminate all uses of such construct. --- linux-core/xgi_cmdlist.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index 99be2145..2cdf714f 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -47,17 +47,17 @@ U32 s_flush2D[AGPCMDLIST_FLUSH_CMD_LEN] = { FLUSH_2D }; -xgi_cmdring_info_t s_cmdring; +struct xgi_cmdring_info s_cmdring; -static void addFlush2D(xgi_info_t * info); -static U32 getCurBatchBeginPort(xgi_cmd_info_t * pCmdInfo); -static void triggerHWCommandList(xgi_info_t * info, U32 triggerCounter); +static void addFlush2D(struct xgi_info * info); +static U32 getCurBatchBeginPort(struct xgi_cmd_info * pCmdInfo); +static void triggerHWCommandList(struct xgi_info * info, U32 triggerCounter); static void xgi_cmdlist_reset(void); -int xgi_cmdlist_initialize(xgi_info_t * info, U32 size) +int xgi_cmdlist_initialize(struct xgi_info * info, U32 size) { - //xgi_mem_req_t mem_req; - xgi_mem_alloc_t mem_alloc; + //struct xgi_mem_req mem_req; + struct xgi_mem_alloc mem_alloc; //mem_req.size = size; @@ -76,7 +76,7 @@ int xgi_cmdlist_initialize(xgi_info_t * info, U32 size) return 1; } -void xgi_submit_cmdlist(xgi_info_t * info, xgi_cmd_info_t * pCmdInfo) +void xgi_submit_cmdlist(struct xgi_info * info, struct xgi_cmd_info * pCmdInfo) { U32 beginPort; /** XGI_INFO("Jong-xgi_submit_cmdlist-Begin \n"); **/ @@ -238,7 +238,7 @@ void xgi_submit_cmdlist(xgi_info_t * info, xgi_cmd_info_t * pCmdInfo) 2 - fb 3 - logout */ -void xgi_state_change(xgi_info_t * info, xgi_state_info_t * pStateInfo) +void xgi_state_change(struct xgi_info * info, struct xgi_state_info * pStateInfo) { #define STATE_CONSOLE 0 #define STATE_GRAPHIC 1 @@ -273,7 +273,7 @@ void xgi_cmdlist_reset(void) s_cmdring._cmdRingOffset = 0; } -void xgi_cmdlist_cleanup(xgi_info_t * info) +void xgi_cmdlist_cleanup(struct xgi_info * info) { if (s_cmdring._cmdRingBuffer != 0) { xgi_pcie_free(info, s_cmdring._cmdRingBusAddr); @@ -283,7 +283,7 @@ void xgi_cmdlist_cleanup(xgi_info_t * info) } } -static void triggerHWCommandList(xgi_info_t * info, U32 triggerCounter) +static void triggerHWCommandList(struct xgi_info * info, U32 triggerCounter) { static U32 s_triggerID = 1; @@ -295,7 +295,7 @@ static void triggerHWCommandList(xgi_info_t * info, U32 triggerCounter) } } -static U32 getCurBatchBeginPort(xgi_cmd_info_t * pCmdInfo) +static U32 getCurBatchBeginPort(struct xgi_cmd_info * pCmdInfo) { // Convert the batch type to begin port ID switch (pCmdInfo->_firstBeginType) { @@ -313,7 +313,7 @@ static U32 getCurBatchBeginPort(xgi_cmd_info_t * pCmdInfo) } } -static void addFlush2D(xgi_info_t * info) +static void addFlush2D(struct xgi_info * info) { U32 *flushBatchVirtAddr; U32 flushBatchHWAddr; -- cgit v1.2.3 From 37733786582d04f072178949cc9e31225abf5577 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 29 Jun 2007 20:49:21 -0700 Subject: Delete unused arrays s_emptyBegin and s_flush2D. --- linux-core/xgi_cmdlist.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index 2cdf714f..b67a40f6 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -33,20 +33,6 @@ #include "xgi_misc.h" #include "xgi_cmdlist.h" -U32 s_emptyBegin[AGPCMDLIST_BEGIN_SIZE] = { - 0x10000000, // 3D Type Begin, Invalid - 0x80000004, // Length = 4; - 0x00000000, - 0x00000000 -}; - -U32 s_flush2D[AGPCMDLIST_FLUSH_CMD_LEN] = { - FLUSH_2D, - FLUSH_2D, - FLUSH_2D, - FLUSH_2D -}; - struct xgi_cmdring_info s_cmdring; static void addFlush2D(struct xgi_info * info); -- cgit v1.2.3 From 4c4780bc8e5bf01b2b920c6b8de4ddbd0256c81f Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 29 Jun 2007 21:05:16 -0700 Subject: Stop-gap fix in xgi_submit_cmdlist Comment in the code explains it. Basically, I put an if-statement around a block of code to prevent a NULL pointer dereference that should never happen in the first place. Eventually, this will need to come out. --- linux-core/xgi_cmdlist.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index b67a40f6..f8aacea2 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -198,17 +198,24 @@ void xgi_submit_cmdlist(struct xgi_info * info, struct xgi_cmd_info * pCmdInfo) (U32 *) xgi_find_pcie_virt(info, s_cmdring._lastBatchStartAddr); - lastBatchVirtAddr[1] = - BEGIN_LINK_ENABLE_MASK + pCmdInfo->_firstSize; - lastBatchVirtAddr[2] = pCmdInfo->_firstBeginAddr >> 4; - lastBatchVirtAddr[3] = 0; - //barrier(); - lastBatchVirtAddr[0] = - (beginPort << 22) + (BEGIN_VALID_MASK) + - (0xffff & pCmdInfo->_curDebugID); - - /* Jong 06/12/2006; system hang; marked for test */ - triggerHWCommandList(info, pCmdInfo->_beginCount); + /* lastBatchVirtAddr should *never* be NULL. However, there + * are currently some bugs that cause this to happen. The + * if-statement here prevents some fatal (i.e., hard lock + * requiring the reset button) oopses. + */ + if (lastBatchVirtAddr) { + lastBatchVirtAddr[1] = + BEGIN_LINK_ENABLE_MASK + pCmdInfo->_firstSize; + lastBatchVirtAddr[2] = pCmdInfo->_firstBeginAddr >> 4; + lastBatchVirtAddr[3] = 0; + //barrier(); + lastBatchVirtAddr[0] = + (beginPort << 22) + (BEGIN_VALID_MASK) + + (0xffff & pCmdInfo->_curDebugID); + + /* Jong 06/12/2006; system hang; marked for test */ + triggerHWCommandList(info, pCmdInfo->_beginCount); + } XGI_INFO ("Jong-xgi_submit_cmdlist-s_cmdring._lastBatchStartAddr != 0 - End\n"); -- cgit v1.2.3 From fc37781dd30b53815dd71ce576eb2147d23f0914 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 29 Jun 2007 21:48:31 -0700 Subject: Convert a few more U32 variables to more appropriate, generic types. --- linux-core/xgi_cmdlist.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index f8aacea2..04ee6e82 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -36,11 +36,11 @@ struct xgi_cmdring_info s_cmdring; static void addFlush2D(struct xgi_info * info); -static U32 getCurBatchBeginPort(struct xgi_cmd_info * pCmdInfo); +static unsigned int getCurBatchBeginPort(struct xgi_cmd_info * pCmdInfo); static void triggerHWCommandList(struct xgi_info * info, U32 triggerCounter); static void xgi_cmdlist_reset(void); -int xgi_cmdlist_initialize(struct xgi_info * info, U32 size) +int xgi_cmdlist_initialize(struct xgi_info * info, size_t size) { //struct xgi_mem_req mem_req; struct xgi_mem_alloc mem_alloc; @@ -64,7 +64,7 @@ int xgi_cmdlist_initialize(struct xgi_info * info, U32 size) void xgi_submit_cmdlist(struct xgi_info * info, struct xgi_cmd_info * pCmdInfo) { - U32 beginPort; + unsigned int beginPort; /** XGI_INFO("Jong-xgi_submit_cmdlist-Begin \n"); **/ /* Jong 05/25/2006 */ @@ -77,7 +77,7 @@ void xgi_submit_cmdlist(struct xgi_info * info, struct xgi_cmd_info * pCmdInfo) /* return; */ if (s_cmdring._lastBatchStartAddr == 0) { - U32 portOffset; + unsigned int portOffset; /* Jong 06/13/2006; remove marked for system hang test */ /* xgi_waitfor_pci_idle(info); */ @@ -278,17 +278,17 @@ void xgi_cmdlist_cleanup(struct xgi_info * info) static void triggerHWCommandList(struct xgi_info * info, U32 triggerCounter) { - static U32 s_triggerID = 1; + static unsigned int s_triggerID = 1; //Fix me, currently we just trigger one time while (triggerCounter--) { dwWriteReg(BASE_3D_ENG + M2REG_PCI_TRIGGER_REGISTER_ADDRESS, - 0x05000000 + (0xffff & s_triggerID++)); + 0x05000000 + (0x0ffff & s_triggerID++)); // xgi_waitfor_pci_idle(info); } } -static U32 getCurBatchBeginPort(struct xgi_cmd_info * pCmdInfo) +static unsigned int getCurBatchBeginPort(struct xgi_cmd_info * pCmdInfo) { // Convert the batch type to begin port ID switch (pCmdInfo->_firstBeginType) { -- cgit v1.2.3 From 2f2d8b9688743ac6367bf13c3c023310a257ceb7 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 9 Jul 2007 15:59:09 -0700 Subject: Merge xgi_mem_req and xgi_mem_alloc into a single type. These two structures were used as the request and reply for certain ioctls. Having a different type for an ioctl's input and output is just wierd. In addition, each structure contained fields (e.g., pid) that had no business being there. This change requires updates to user-space. --- linux-core/xgi_cmdlist.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index 04ee6e82..f7730d89 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -42,12 +42,12 @@ static void xgi_cmdlist_reset(void); int xgi_cmdlist_initialize(struct xgi_info * info, size_t size) { - //struct xgi_mem_req mem_req; - struct xgi_mem_alloc mem_alloc; + struct xgi_mem_alloc mem_alloc = { + .size = size, + .owner = PCIE_2D, + }; - //mem_req.size = size; - - xgi_pcie_alloc(info, size, PCIE_2D, &mem_alloc); + xgi_pcie_alloc(info, &mem_alloc, 0); if ((mem_alloc.size == 0) && (mem_alloc.hw_addr == 0)) { return -1; -- cgit v1.2.3 From 7268b65d5ce804713c12b8fadc42f9a086cdfe14 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 9 Jul 2007 16:22:48 -0700 Subject: Correct types that are shared with user mode. --- linux-core/xgi_cmdlist.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index f7730d89..ee53d30c 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -37,7 +37,8 @@ struct xgi_cmdring_info s_cmdring; static void addFlush2D(struct xgi_info * info); static unsigned int getCurBatchBeginPort(struct xgi_cmd_info * pCmdInfo); -static void triggerHWCommandList(struct xgi_info * info, U32 triggerCounter); +static void triggerHWCommandList(struct xgi_info * info, + unsigned int triggerCounter); static void xgi_cmdlist_reset(void); int xgi_cmdlist_initialize(struct xgi_info * info, size_t size) @@ -276,7 +277,8 @@ void xgi_cmdlist_cleanup(struct xgi_info * info) } } -static void triggerHWCommandList(struct xgi_info * info, U32 triggerCounter) +static void triggerHWCommandList(struct xgi_info * info, + unsigned int triggerCounter) { static unsigned int s_triggerID = 1; -- cgit v1.2.3 From 76ca1e858fb8e1a65ea49c0c62350d7ca91044a2 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 9 Jul 2007 18:54:25 -0700 Subject: Convert occurances of U32 to other types. Most occurances of U32 were converted to u32. These are cases where the data represents something that will be written to the hardware. Other cases were converted to 'unsigned int'. U32 was the last type in xgi_types.h, so that file is removed. --- linux-core/xgi_cmdlist.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index ee53d30c..7be0ac48 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -26,7 +26,6 @@ * DEALINGS IN THE SOFTWARE. ***************************************************************************/ -#include "xgi_types.h" #include "xgi_linux.h" #include "xgi_drv.h" #include "xgi_regs.h" @@ -183,7 +182,7 @@ void xgi_submit_cmdlist(struct xgi_info * info, struct xgi_cmd_info * pCmdInfo) /* Jong 06/13/2006; remove marked for system hang test */ /* xgi_waitfor_pci_idle(info); */ } else { - U32 *lastBatchVirtAddr; + u32 *lastBatchVirtAddr; XGI_INFO ("Jong-xgi_submit_cmdlist-s_cmdring._lastBatchStartAddr != 0 \n"); @@ -195,9 +194,9 @@ void xgi_submit_cmdlist(struct xgi_info * info, struct xgi_cmd_info * pCmdInfo) addFlush2D(info); } - lastBatchVirtAddr = - (U32 *) xgi_find_pcie_virt(info, - s_cmdring._lastBatchStartAddr); + lastBatchVirtAddr = + xgi_find_pcie_virt(info, + s_cmdring._lastBatchStartAddr); /* lastBatchVirtAddr should *never* be NULL. However, there * are currently some bugs that cause this to happen. The @@ -310,10 +309,9 @@ static unsigned int getCurBatchBeginPort(struct xgi_cmd_info * pCmdInfo) static void addFlush2D(struct xgi_info * info) { - U32 *flushBatchVirtAddr; - U32 flushBatchHWAddr; - - U32 *lastBatchVirtAddr; + u32 *flushBatchVirtAddr; + u32 flushBatchHWAddr; + u32 *lastBatchVirtAddr; /* check buf is large enough to contain a new flush batch */ if ((s_cmdring._cmdRingOffset + 0x20) >= s_cmdring._cmdRingSize) { @@ -321,7 +319,7 @@ static void addFlush2D(struct xgi_info * info) } flushBatchHWAddr = s_cmdring._cmdRingBuffer + s_cmdring._cmdRingOffset; - flushBatchVirtAddr = (U32 *) xgi_find_pcie_virt(info, flushBatchHWAddr); + flushBatchVirtAddr = xgi_find_pcie_virt(info, flushBatchHWAddr); /* not using memcpy for I assume the address is discrete */ *(flushBatchVirtAddr + 0) = 0x10000000; @@ -335,7 +333,7 @@ static void addFlush2D(struct xgi_info * info) // ASSERT(s_cmdring._lastBatchStartAddr != NULL); lastBatchVirtAddr = - (U32 *) xgi_find_pcie_virt(info, s_cmdring._lastBatchStartAddr); + xgi_find_pcie_virt(info, s_cmdring._lastBatchStartAddr); lastBatchVirtAddr[1] = BEGIN_LINK_ENABLE_MASK + 0x08; lastBatchVirtAddr[2] = flushBatchHWAddr >> 4; -- cgit v1.2.3 From 4575d5b8f18fef8cd19e7884bf8dab5e8f71ec9e Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 16 Jul 2007 20:56:11 -0700 Subject: Massive log message clean up in xgi_submit_cmdlist. --- linux-core/xgi_cmdlist.c | 99 +++++++----------------------------------------- 1 file changed, 14 insertions(+), 85 deletions(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index 7be0ac48..61373469 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -64,131 +64,61 @@ int xgi_cmdlist_initialize(struct xgi_info * info, size_t size) void xgi_submit_cmdlist(struct xgi_info * info, struct xgi_cmd_info * pCmdInfo) { - unsigned int beginPort; - /** XGI_INFO("Jong-xgi_submit_cmdlist-Begin \n"); **/ + const unsigned int beginPort = getCurBatchBeginPort(pCmdInfo); - /* Jong 05/25/2006 */ - /* return; */ - - beginPort = getCurBatchBeginPort(pCmdInfo); - XGI_INFO("Jong-xgi_submit_cmdlist-After getCurBatchBeginPort() \n"); - - /* Jong 05/25/2006 */ - /* return; */ + XGI_INFO("After getCurBatchBeginPort()\n"); if (s_cmdring._lastBatchStartAddr == 0) { - unsigned int portOffset; + const unsigned int portOffset = BASE_3D_ENG + beginPort; /* Jong 06/13/2006; remove marked for system hang test */ /* xgi_waitfor_pci_idle(info); */ - /* Jong 06132006; BASE_3D_ENG=0x2800 */ - /* beginPort: 2D: 0x30 */ - portOffset = BASE_3D_ENG + beginPort; - // Enable PCI Trigger Mode - XGI_INFO("Jong-xgi_submit_cmdlist-Enable PCI Trigger Mode \n"); - - /* Jong 05/25/2006 */ - /* return; */ - - /* Jong 06/13/2006; M2REG_AUTO_LINK_SETTING_ADDRESS=0x10 */ - XGI_INFO("Jong-M2REG_AUTO_LINK_SETTING_ADDRESS=0x%lx \n", - M2REG_AUTO_LINK_SETTING_ADDRESS); - XGI_INFO("Jong-M2REG_CLEAR_COUNTERS_MASK=0x%lx \n", - M2REG_CLEAR_COUNTERS_MASK); - XGI_INFO - ("Jong-(M2REG_AUTO_LINK_SETTING_ADDRESS << 22)=0x%lx \n", - (M2REG_AUTO_LINK_SETTING_ADDRESS << 22)); - XGI_INFO("Jong-M2REG_PCI_TRIGGER_MODE_MASK=0x%lx \n\n", - M2REG_PCI_TRIGGER_MODE_MASK); + XGI_INFO("Enable PCI Trigger Mode \n"); + /* Jong 06/14/2006; 0x400001a */ - XGI_INFO - ("Jong-(M2REG_AUTO_LINK_SETTING_ADDRESS << 22)|M2REG_CLEAR_COUNTERS_MASK|0x08|M2REG_PCI_TRIGGER_MODE_MASK=0x%lx \n", - (M2REG_AUTO_LINK_SETTING_ADDRESS << 22) | - M2REG_CLEAR_COUNTERS_MASK | 0x08 | - M2REG_PCI_TRIGGER_MODE_MASK); dwWriteReg(BASE_3D_ENG + M2REG_AUTO_LINK_SETTING_ADDRESS, (M2REG_AUTO_LINK_SETTING_ADDRESS << 22) | M2REG_CLEAR_COUNTERS_MASK | 0x08 | M2REG_PCI_TRIGGER_MODE_MASK); - /* Jong 05/25/2006 */ - XGI_INFO("Jong-xgi_submit_cmdlist-After dwWriteReg() \n"); - /* return; *//* OK */ - /* Jong 06/14/2006; 0x400000a */ - XGI_INFO - ("Jong-(M2REG_AUTO_LINK_SETTING_ADDRESS << 22)|0x08|M2REG_PCI_TRIGGER_MODE_MASK=0x%lx \n", - (M2REG_AUTO_LINK_SETTING_ADDRESS << 22) | 0x08 | - M2REG_PCI_TRIGGER_MODE_MASK); dwWriteReg(BASE_3D_ENG + M2REG_AUTO_LINK_SETTING_ADDRESS, (M2REG_AUTO_LINK_SETTING_ADDRESS << 22) | 0x08 | M2REG_PCI_TRIGGER_MODE_MASK); // Send PCI begin command - XGI_INFO("Jong-xgi_submit_cmdlist-Send PCI begin command \n"); - /* return; */ + XGI_INFO("Send PCI begin command \n"); - XGI_INFO("Jong-xgi_submit_cmdlist-portOffset=%d \n", - portOffset); - XGI_INFO("Jong-xgi_submit_cmdlist-beginPort=%d \n", beginPort); + XGI_INFO("portOffset=%d, beginPort=%d\n", + portOffset, beginPort); /* beginPort = 48; */ /* 0xc100000 */ dwWriteReg(portOffset, (beginPort << 22) + (BEGIN_VALID_MASK) + pCmdInfo->_curDebugID); - XGI_INFO("Jong-(beginPort<<22)=0x%lx \n", (beginPort << 22)); - XGI_INFO("Jong-(BEGIN_VALID_MASK)=0x%lx \n", BEGIN_VALID_MASK); - XGI_INFO("Jong- pCmdInfo->_curDebugID=0x%lx \n", - pCmdInfo->_curDebugID); - XGI_INFO - ("Jong- (beginPort<<22) + (BEGIN_VALID_MASK) + pCmdInfo->_curDebugID=0x%lx \n", - (beginPort << 22) + (BEGIN_VALID_MASK) + - pCmdInfo->_curDebugID); - XGI_INFO - ("Jong-xgi_submit_cmdlist-Send PCI begin command- After \n"); - /* return; *//* OK */ + + XGI_INFO("Send PCI begin command- After\n"); /* 0x80000024 */ dwWriteReg(portOffset + 4, BEGIN_LINK_ENABLE_MASK + pCmdInfo->_firstSize); - XGI_INFO("Jong- BEGIN_LINK_ENABLE_MASK=0x%lx \n", - BEGIN_LINK_ENABLE_MASK); - XGI_INFO("Jong- pCmdInfo->_firstSize=0x%lx \n", - pCmdInfo->_firstSize); - XGI_INFO - ("Jong- BEGIN_LINK_ENABLE_MASK + pCmdInfo->_firstSize=0x%lx \n", - BEGIN_LINK_ENABLE_MASK + pCmdInfo->_firstSize); - XGI_INFO("Jong-xgi_submit_cmdlist-dwWriteReg-1 \n"); /* 0x1010000 */ dwWriteReg(portOffset + 8, (pCmdInfo->_firstBeginAddr >> 4)); - XGI_INFO("Jong- pCmdInfo->_firstBeginAddr=0x%lx \n", - pCmdInfo->_firstBeginAddr); - XGI_INFO("Jong- (pCmdInfo->_firstBeginAddr >> 4)=0x%lx \n", - (pCmdInfo->_firstBeginAddr >> 4)); - XGI_INFO("Jong-xgi_submit_cmdlist-dwWriteReg-2 \n"); - - /* Jong 06/13/2006 */ - xgi_dump_register(info); /* Jong 06/12/2006; system hang; marked for test */ dwWriteReg(portOffset + 12, 0); - XGI_INFO("Jong-xgi_submit_cmdlist-dwWriteReg-3 \n"); /* Jong 06/13/2006; remove marked for system hang test */ /* xgi_waitfor_pci_idle(info); */ } else { u32 *lastBatchVirtAddr; - XGI_INFO - ("Jong-xgi_submit_cmdlist-s_cmdring._lastBatchStartAddr != 0 \n"); - - /* Jong 05/25/2006 */ - /* return; */ + XGI_INFO("s_cmdring._lastBatchStartAddr != 0\n"); if (pCmdInfo->_firstBeginType == BTYPE_3D) { addFlush2D(info); @@ -215,14 +145,13 @@ void xgi_submit_cmdlist(struct xgi_info * info, struct xgi_cmd_info * pCmdInfo) /* Jong 06/12/2006; system hang; marked for test */ triggerHWCommandList(info, pCmdInfo->_beginCount); + } else { + XGI_ERROR("lastBatchVirtAddr is NULL\n"); } - - XGI_INFO - ("Jong-xgi_submit_cmdlist-s_cmdring._lastBatchStartAddr != 0 - End\n"); } s_cmdring._lastBatchStartAddr = pCmdInfo->_lastBeginAddr; - XGI_INFO("Jong-xgi_submit_cmdlist-End \n"); + XGI_INFO("End\n"); } /* -- cgit v1.2.3 From 5ba94c2ab8be350fee495e5cfe94afb8f663956a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 19 Jul 2007 10:29:18 -0700 Subject: Initial pass at converting driver to DRM infrastructure. --- linux-core/xgi_cmdlist.c | 99 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 67 insertions(+), 32 deletions(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index 61373469..d2018057 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -26,7 +26,6 @@ * DEALINGS IN THE SOFTWARE. ***************************************************************************/ -#include "xgi_linux.h" #include "xgi_drv.h" #include "xgi_regs.h" #include "xgi_misc.h" @@ -55,18 +54,19 @@ int xgi_cmdlist_initialize(struct xgi_info * info, size_t size) s_cmdring._cmdRingSize = mem_alloc.size; s_cmdring._cmdRingBuffer = mem_alloc.hw_addr; - s_cmdring._cmdRingBusAddr = mem_alloc.bus_addr; + s_cmdring._cmdRingAllocOffset = mem_alloc.offset; s_cmdring._lastBatchStartAddr = 0; s_cmdring._cmdRingOffset = 0; return 1; } -void xgi_submit_cmdlist(struct xgi_info * info, struct xgi_cmd_info * pCmdInfo) +static void xgi_submit_cmdlist(struct xgi_info * info, + struct xgi_cmd_info * pCmdInfo) { const unsigned int beginPort = getCurBatchBeginPort(pCmdInfo); - XGI_INFO("After getCurBatchBeginPort()\n"); + DRM_INFO("After getCurBatchBeginPort()\n"); if (s_cmdring._lastBatchStartAddr == 0) { const unsigned int portOffset = BASE_3D_ENG + beginPort; @@ -75,50 +75,53 @@ void xgi_submit_cmdlist(struct xgi_info * info, struct xgi_cmd_info * pCmdInfo) /* xgi_waitfor_pci_idle(info); */ // Enable PCI Trigger Mode - XGI_INFO("Enable PCI Trigger Mode \n"); + DRM_INFO("Enable PCI Trigger Mode \n"); /* Jong 06/14/2006; 0x400001a */ - dwWriteReg(BASE_3D_ENG + M2REG_AUTO_LINK_SETTING_ADDRESS, + dwWriteReg(info->mmio_map, + BASE_3D_ENG + M2REG_AUTO_LINK_SETTING_ADDRESS, (M2REG_AUTO_LINK_SETTING_ADDRESS << 22) | M2REG_CLEAR_COUNTERS_MASK | 0x08 | M2REG_PCI_TRIGGER_MODE_MASK); /* Jong 06/14/2006; 0x400000a */ - dwWriteReg(BASE_3D_ENG + M2REG_AUTO_LINK_SETTING_ADDRESS, + dwWriteReg(info->mmio_map, + BASE_3D_ENG + M2REG_AUTO_LINK_SETTING_ADDRESS, (M2REG_AUTO_LINK_SETTING_ADDRESS << 22) | 0x08 | M2REG_PCI_TRIGGER_MODE_MASK); // Send PCI begin command - XGI_INFO("Send PCI begin command \n"); + DRM_INFO("Send PCI begin command \n"); - XGI_INFO("portOffset=%d, beginPort=%d\n", + DRM_INFO("portOffset=%d, beginPort=%d\n", portOffset, beginPort); /* beginPort = 48; */ /* 0xc100000 */ - dwWriteReg(portOffset, + dwWriteReg(info->mmio_map, portOffset, (beginPort << 22) + (BEGIN_VALID_MASK) + pCmdInfo->_curDebugID); - XGI_INFO("Send PCI begin command- After\n"); + DRM_INFO("Send PCI begin command- After\n"); /* 0x80000024 */ - dwWriteReg(portOffset + 4, + dwWriteReg(info->mmio_map, portOffset + 4, BEGIN_LINK_ENABLE_MASK + pCmdInfo->_firstSize); /* 0x1010000 */ - dwWriteReg(portOffset + 8, (pCmdInfo->_firstBeginAddr >> 4)); + dwWriteReg(info->mmio_map, portOffset + 8, + (pCmdInfo->_firstBeginAddr >> 4)); /* Jong 06/12/2006; system hang; marked for test */ - dwWriteReg(portOffset + 12, 0); + dwWriteReg(info->mmio_map, portOffset + 12, 0); /* Jong 06/13/2006; remove marked for system hang test */ /* xgi_waitfor_pci_idle(info); */ } else { u32 *lastBatchVirtAddr; - XGI_INFO("s_cmdring._lastBatchStartAddr != 0\n"); + DRM_INFO("s_cmdring._lastBatchStartAddr != 0\n"); if (pCmdInfo->_firstBeginType == BTYPE_3D) { addFlush2D(info); @@ -146,21 +149,38 @@ void xgi_submit_cmdlist(struct xgi_info * info, struct xgi_cmd_info * pCmdInfo) /* Jong 06/12/2006; system hang; marked for test */ triggerHWCommandList(info, pCmdInfo->_beginCount); } else { - XGI_ERROR("lastBatchVirtAddr is NULL\n"); + DRM_ERROR("lastBatchVirtAddr is NULL\n"); } } s_cmdring._lastBatchStartAddr = pCmdInfo->_lastBeginAddr; - XGI_INFO("End\n"); + DRM_INFO("End\n"); } + +int xgi_submit_cmdlist_ioctl(DRM_IOCTL_ARGS) +{ + DRM_DEVICE; + struct xgi_cmd_info cmd_list; + struct xgi_info *info = dev->dev_private; + + DRM_COPY_FROM_USER_IOCTL(cmd_list, + (struct xgi_cmd_info __user *) data, + sizeof(cmd_list)); + + xgi_submit_cmdlist(info, &cmd_list); + return 0; +} + + /* state: 0 - console 1 - graphic 2 - fb 3 - logout */ -void xgi_state_change(struct xgi_info * info, struct xgi_state_info * pStateInfo) +int xgi_state_change(struct xgi_info * info, unsigned int to, + unsigned int from) { #define STATE_CONSOLE 0 #define STATE_GRAPHIC 1 @@ -169,26 +189,40 @@ void xgi_state_change(struct xgi_info * info, struct xgi_state_info * pStateInfo #define STATE_REBOOT 4 #define STATE_SHUTDOWN 5 - if ((pStateInfo->_fromState == STATE_GRAPHIC) - && (pStateInfo->_toState == STATE_CONSOLE)) { - XGI_INFO("[kd] I see, now is to leaveVT\n"); + if ((from == STATE_GRAPHIC) && (to == STATE_CONSOLE)) { + DRM_INFO("[kd] I see, now is to leaveVT\n"); // stop to received batch - } else if ((pStateInfo->_fromState == STATE_CONSOLE) - && (pStateInfo->_toState == STATE_GRAPHIC)) { - XGI_INFO("[kd] I see, now is to enterVT\n"); + } else if ((from == STATE_CONSOLE) && (to == STATE_GRAPHIC)) { + DRM_INFO("[kd] I see, now is to enterVT\n"); xgi_cmdlist_reset(); - } else if ((pStateInfo->_fromState == STATE_GRAPHIC) - && ((pStateInfo->_toState == STATE_LOGOUT) - || (pStateInfo->_toState == STATE_REBOOT) - || (pStateInfo->_toState == STATE_SHUTDOWN))) { - XGI_INFO("[kd] I see, not is to exit from X\n"); + } else if ((from == STATE_GRAPHIC) + && ((to == STATE_LOGOUT) + || (to == STATE_REBOOT) + || (to == STATE_SHUTDOWN))) { + DRM_INFO("[kd] I see, not is to exit from X\n"); // stop to received batch } else { - XGI_ERROR("[kd] Should not happen\n"); + DRM_ERROR("[kd] Should not happen\n"); + return DRM_ERR(EINVAL); } + return 0; } + +int xgi_state_change_ioctl(DRM_IOCTL_ARGS) +{ + DRM_DEVICE; + struct xgi_state_info state; + struct xgi_info *info = dev->dev_private; + + DRM_COPY_FROM_USER_IOCTL(state, (struct xgi_state_info __user *) data, + sizeof(state)); + + return xgi_state_change(info, state._toState, state._fromState); +} + + void xgi_cmdlist_reset(void) { s_cmdring._lastBatchStartAddr = 0; @@ -198,7 +232,7 @@ void xgi_cmdlist_reset(void) void xgi_cmdlist_cleanup(struct xgi_info * info) { if (s_cmdring._cmdRingBuffer != 0) { - xgi_pcie_free(info, s_cmdring._cmdRingBusAddr); + xgi_pcie_free(info, s_cmdring._cmdRingAllocOffset, NULL); s_cmdring._cmdRingBuffer = 0; s_cmdring._cmdRingOffset = 0; s_cmdring._cmdRingSize = 0; @@ -212,7 +246,8 @@ static void triggerHWCommandList(struct xgi_info * info, //Fix me, currently we just trigger one time while (triggerCounter--) { - dwWriteReg(BASE_3D_ENG + M2REG_PCI_TRIGGER_REGISTER_ADDRESS, + dwWriteReg(info->mmio_map, + BASE_3D_ENG + M2REG_PCI_TRIGGER_REGISTER_ADDRESS, 0x05000000 + (0x0ffff & s_triggerID++)); // xgi_waitfor_pci_idle(info); } -- cgit v1.2.3 From a33f5487296eacf503f5b27ba829f5fbdae8e63b Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 19 Jul 2007 19:05:52 -0700 Subject: Debug message and comment clean up in xgi_submit_cmdlist. --- linux-core/xgi_cmdlist.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index d2018057..2fdfcc91 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -66,58 +66,43 @@ static void xgi_submit_cmdlist(struct xgi_info * info, { const unsigned int beginPort = getCurBatchBeginPort(pCmdInfo); - DRM_INFO("After getCurBatchBeginPort()\n"); if (s_cmdring._lastBatchStartAddr == 0) { const unsigned int portOffset = BASE_3D_ENG + beginPort; - /* Jong 06/13/2006; remove marked for system hang test */ - /* xgi_waitfor_pci_idle(info); */ - // Enable PCI Trigger Mode + /* Enable PCI Trigger Mode + */ DRM_INFO("Enable PCI Trigger Mode \n"); - - /* Jong 06/14/2006; 0x400001a */ dwWriteReg(info->mmio_map, BASE_3D_ENG + M2REG_AUTO_LINK_SETTING_ADDRESS, (M2REG_AUTO_LINK_SETTING_ADDRESS << 22) | M2REG_CLEAR_COUNTERS_MASK | 0x08 | M2REG_PCI_TRIGGER_MODE_MASK); - /* Jong 06/14/2006; 0x400000a */ dwWriteReg(info->mmio_map, BASE_3D_ENG + M2REG_AUTO_LINK_SETTING_ADDRESS, (M2REG_AUTO_LINK_SETTING_ADDRESS << 22) | 0x08 | M2REG_PCI_TRIGGER_MODE_MASK); - // Send PCI begin command - DRM_INFO("Send PCI begin command \n"); + /* Send PCI begin command + */ DRM_INFO("portOffset=%d, beginPort=%d\n", portOffset, beginPort); - /* beginPort = 48; */ - /* 0xc100000 */ dwWriteReg(info->mmio_map, portOffset, (beginPort << 22) + (BEGIN_VALID_MASK) + pCmdInfo->_curDebugID); - DRM_INFO("Send PCI begin command- After\n"); - - /* 0x80000024 */ dwWriteReg(info->mmio_map, portOffset + 4, BEGIN_LINK_ENABLE_MASK + pCmdInfo->_firstSize); - /* 0x1010000 */ dwWriteReg(info->mmio_map, portOffset + 8, (pCmdInfo->_firstBeginAddr >> 4)); - /* Jong 06/12/2006; system hang; marked for test */ dwWriteReg(info->mmio_map, portOffset + 12, 0); - - /* Jong 06/13/2006; remove marked for system hang test */ - /* xgi_waitfor_pci_idle(info); */ } else { u32 *lastBatchVirtAddr; @@ -154,7 +139,7 @@ static void xgi_submit_cmdlist(struct xgi_info * info, } s_cmdring._lastBatchStartAddr = pCmdInfo->_lastBeginAddr; - DRM_INFO("End\n"); + DRM_INFO("%s: exit\n", __func__); } -- cgit v1.2.3 From 970674f4867d65bd16cf3585d46930b72a827cce Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 19 Jul 2007 19:08:47 -0700 Subject: Fix error handing related to xgi_cmdlist_initialize. xgi_cmdlist_initialize wasn't correctly checking for errors from xgi_pcie_alloc. Furthermore, xgi_bootstrap, the one caller of xgi_cmdlist_initialize, wasn't check its return value. --- linux-core/xgi_cmdlist.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index 2fdfcc91..885b5066 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -45,11 +45,11 @@ int xgi_cmdlist_initialize(struct xgi_info * info, size_t size) .size = size, .owner = PCIE_2D, }; + int err; - xgi_pcie_alloc(info, &mem_alloc, 0); - - if ((mem_alloc.size == 0) && (mem_alloc.hw_addr == 0)) { - return -1; + err = xgi_pcie_alloc(info, &mem_alloc, 0); + if (err) { + return err; } s_cmdring._cmdRingSize = mem_alloc.size; @@ -58,7 +58,7 @@ int xgi_cmdlist_initialize(struct xgi_info * info, size_t size) s_cmdring._lastBatchStartAddr = 0; s_cmdring._cmdRingOffset = 0; - return 1; + return 0; } static void xgi_submit_cmdlist(struct xgi_info * info, -- cgit v1.2.3 From 6bd848307485f678915913f282e2ea59ae3ca1a8 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 20 Jul 2007 10:57:40 -0700 Subject: Change handling of begin types slightly. Moved the getCurBatchBeginPort before its only caller. Modified function to return the command ID instead of the port offset. Function also now assumes input begin type is value. Added code to ioctl handler to validate begin type. --- linux-core/xgi_cmdlist.c | 54 +++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 24 deletions(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index 885b5066..6cc4c142 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -34,7 +34,7 @@ struct xgi_cmdring_info s_cmdring; static void addFlush2D(struct xgi_info * info); -static unsigned int getCurBatchBeginPort(struct xgi_cmd_info * pCmdInfo); +static unsigned int get_batch_command(enum xgi_batch_type type); static void triggerHWCommandList(struct xgi_info * info, unsigned int triggerCounter); static void xgi_cmdlist_reset(void); @@ -61,14 +61,33 @@ int xgi_cmdlist_initialize(struct xgi_info * info, size_t size) return 0; } + +/** + * get_batch_command - Get the command ID for the current begin type. + * @type: Type of the current batch + * + * See section 3.2.2 "Begin" (page 15) of the 3D SPG. + * + * This function assumes that @type is on the range [0,3]. + */ +unsigned int get_batch_command(enum xgi_batch_type type) +{ + static const unsigned int ports[4] = { + 0x30 >> 2, 0x40 >> 2, 0x50 >> 2, 0x20 >> 2 + }; + + return ports[type]; +} + + static void xgi_submit_cmdlist(struct xgi_info * info, - struct xgi_cmd_info * pCmdInfo) + const struct xgi_cmd_info * pCmdInfo) { - const unsigned int beginPort = getCurBatchBeginPort(pCmdInfo); + const unsigned int cmd = get_batch_command(pCmdInfo->_firstBeginType); if (s_cmdring._lastBatchStartAddr == 0) { - const unsigned int portOffset = BASE_3D_ENG + beginPort; + const unsigned int portOffset = BASE_3D_ENG + (cmd << 2); /* Enable PCI Trigger Mode @@ -90,10 +109,10 @@ static void xgi_submit_cmdlist(struct xgi_info * info, /* Send PCI begin command */ DRM_INFO("portOffset=%d, beginPort=%d\n", - portOffset, beginPort); + portOffset, cmd << 2); dwWriteReg(info->mmio_map, portOffset, - (beginPort << 22) + (BEGIN_VALID_MASK) + + (cmd << 24) + (BEGIN_VALID_MASK) + pCmdInfo->_curDebugID); dwWriteReg(info->mmio_map, portOffset + 4, @@ -128,7 +147,7 @@ static void xgi_submit_cmdlist(struct xgi_info * info, lastBatchVirtAddr[3] = 0; //barrier(); lastBatchVirtAddr[0] = - (beginPort << 22) + (BEGIN_VALID_MASK) + + (cmd << 24) + (BEGIN_VALID_MASK) + (0xffff & pCmdInfo->_curDebugID); /* Jong 06/12/2006; system hang; marked for test */ @@ -153,6 +172,10 @@ int xgi_submit_cmdlist_ioctl(DRM_IOCTL_ARGS) (struct xgi_cmd_info __user *) data, sizeof(cmd_list)); + if (cmd_list._firstBeginType > BTYPE_CTRL) { + return DRM_ERR(EINVAL); + } + xgi_submit_cmdlist(info, &cmd_list); return 0; } @@ -238,23 +261,6 @@ static void triggerHWCommandList(struct xgi_info * info, } } -static unsigned int getCurBatchBeginPort(struct xgi_cmd_info * pCmdInfo) -{ - // Convert the batch type to begin port ID - switch (pCmdInfo->_firstBeginType) { - case BTYPE_2D: - return 0x30; - case BTYPE_3D: - return 0x40; - case BTYPE_FLIP: - return 0x50; - case BTYPE_CTRL: - return 0x20; - default: - //ASSERT(0); - return 0xff; - } -} static void addFlush2D(struct xgi_info * info) { -- cgit v1.2.3 From 659209cb2d59c7b25df58d130d0649f8f899b693 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 20 Jul 2007 11:29:16 -0700 Subject: Clean up generation of begin commands in xgi_submit_cmdlist Generate the begin command once in a temporary buffer. Then, depending on whether the command is to be written directly to the hardware or to a secondary buffer, copy to command to the correct place. --- linux-core/xgi_cmdlist.c | 49 ++++++++++++++++++------------------------------ 1 file changed, 18 insertions(+), 31 deletions(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index 6cc4c142..682c4ac1 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -84,8 +84,15 @@ static void xgi_submit_cmdlist(struct xgi_info * info, const struct xgi_cmd_info * pCmdInfo) { const unsigned int cmd = get_batch_command(pCmdInfo->_firstBeginType); + u32 begin[4]; + begin[0] = (cmd << 24) | (BEGIN_VALID_MASK) | + (BEGIN_BEGIN_IDENTIFICATION_MASK & pCmdInfo->_curDebugID); + begin[1] = BEGIN_LINK_ENABLE_MASK | pCmdInfo->_firstSize; + begin[2] = pCmdInfo->_firstBeginAddr >> 4; + begin[3] = 0; + if (s_cmdring._lastBatchStartAddr == 0) { const unsigned int portOffset = BASE_3D_ENG + (cmd << 2); @@ -111,17 +118,10 @@ static void xgi_submit_cmdlist(struct xgi_info * info, DRM_INFO("portOffset=%d, beginPort=%d\n", portOffset, cmd << 2); - dwWriteReg(info->mmio_map, portOffset, - (cmd << 24) + (BEGIN_VALID_MASK) + - pCmdInfo->_curDebugID); - - dwWriteReg(info->mmio_map, portOffset + 4, - BEGIN_LINK_ENABLE_MASK + pCmdInfo->_firstSize); - - dwWriteReg(info->mmio_map, portOffset + 8, - (pCmdInfo->_firstBeginAddr >> 4)); - - dwWriteReg(info->mmio_map, portOffset + 12, 0); + dwWriteReg(info->mmio_map, portOffset, begin[0]); + dwWriteReg(info->mmio_map, portOffset + 4, begin[1]); + dwWriteReg(info->mmio_map, portOffset + 8, begin[2]); + dwWriteReg(info->mmio_map, portOffset + 12, begin[3]); } else { u32 *lastBatchVirtAddr; @@ -135,26 +135,13 @@ static void xgi_submit_cmdlist(struct xgi_info * info, xgi_find_pcie_virt(info, s_cmdring._lastBatchStartAddr); - /* lastBatchVirtAddr should *never* be NULL. However, there - * are currently some bugs that cause this to happen. The - * if-statement here prevents some fatal (i.e., hard lock - * requiring the reset button) oopses. - */ - if (lastBatchVirtAddr) { - lastBatchVirtAddr[1] = - BEGIN_LINK_ENABLE_MASK + pCmdInfo->_firstSize; - lastBatchVirtAddr[2] = pCmdInfo->_firstBeginAddr >> 4; - lastBatchVirtAddr[3] = 0; - //barrier(); - lastBatchVirtAddr[0] = - (cmd << 24) + (BEGIN_VALID_MASK) + - (0xffff & pCmdInfo->_curDebugID); - - /* Jong 06/12/2006; system hang; marked for test */ - triggerHWCommandList(info, pCmdInfo->_beginCount); - } else { - DRM_ERROR("lastBatchVirtAddr is NULL\n"); - } + lastBatchVirtAddr[1] = begin[1]; + lastBatchVirtAddr[2] = begin[2]; + lastBatchVirtAddr[3] = begin[3]; + wmb(); + lastBatchVirtAddr[0] = begin[0]; + + triggerHWCommandList(info, pCmdInfo->_beginCount); } s_cmdring._lastBatchStartAddr = pCmdInfo->_lastBeginAddr; -- cgit v1.2.3 From ed82d5398a751cf755cf4168cbb79b181facc86f Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 20 Jul 2007 11:31:01 -0700 Subject: Clean up flush command generation in addFlush2D. --- linux-core/xgi_cmdlist.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index 682c4ac1..b93541f3 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -280,11 +280,9 @@ static void addFlush2D(struct xgi_info * info) lastBatchVirtAddr[1] = BEGIN_LINK_ENABLE_MASK + 0x08; lastBatchVirtAddr[2] = flushBatchHWAddr >> 4; lastBatchVirtAddr[3] = 0; - - //barrier(); - - // BTYPE_CTRL & NO debugID - lastBatchVirtAddr[0] = (0x20 << 22) + (BEGIN_VALID_MASK); + wmb(); + lastBatchVirtAddr[0] = (get_batch_command(BTYPE_CTRL) << 24) + | (BEGIN_VALID_MASK); triggerHWCommandList(info, 1); -- cgit v1.2.3 From 5d6fdd9d7924fde8ce62631e6bdce8d5fe33fc3d Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Sat, 21 Jul 2007 20:34:56 -0700 Subject: Clean up xgi_cmd_info and associated code. There were numerous unnecessary fields in xgi_cmd_info. The remaining fields had pretty crummy names. Cut out the cruft, and rename the rest. As a result, the unused parameter "triggerCounter" to triggerHWCommandList can be removed. --- linux-core/xgi_cmdlist.c | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index b93541f3..5c31fa27 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -35,8 +35,7 @@ struct xgi_cmdring_info s_cmdring; static void addFlush2D(struct xgi_info * info); static unsigned int get_batch_command(enum xgi_batch_type type); -static void triggerHWCommandList(struct xgi_info * info, - unsigned int triggerCounter); +static void triggerHWCommandList(struct xgi_info * info); static void xgi_cmdlist_reset(void); int xgi_cmdlist_initialize(struct xgi_info * info, size_t size) @@ -83,14 +82,14 @@ unsigned int get_batch_command(enum xgi_batch_type type) static void xgi_submit_cmdlist(struct xgi_info * info, const struct xgi_cmd_info * pCmdInfo) { - const unsigned int cmd = get_batch_command(pCmdInfo->_firstBeginType); + const unsigned int cmd = get_batch_command(pCmdInfo->type); u32 begin[4]; - begin[0] = (cmd << 24) | (BEGIN_VALID_MASK) | - (BEGIN_BEGIN_IDENTIFICATION_MASK & pCmdInfo->_curDebugID); - begin[1] = BEGIN_LINK_ENABLE_MASK | pCmdInfo->_firstSize; - begin[2] = pCmdInfo->_firstBeginAddr >> 4; + begin[0] = (cmd << 24) | BEGIN_VALID_MASK + | (BEGIN_BEGIN_IDENTIFICATION_MASK & pCmdInfo->id); + begin[1] = BEGIN_LINK_ENABLE_MASK | pCmdInfo->size; + begin[2] = pCmdInfo->hw_addr >> 4; begin[3] = 0; if (s_cmdring._lastBatchStartAddr == 0) { @@ -127,7 +126,7 @@ static void xgi_submit_cmdlist(struct xgi_info * info, DRM_INFO("s_cmdring._lastBatchStartAddr != 0\n"); - if (pCmdInfo->_firstBeginType == BTYPE_3D) { + if (pCmdInfo->type == BTYPE_3D) { addFlush2D(info); } @@ -141,10 +140,10 @@ static void xgi_submit_cmdlist(struct xgi_info * info, wmb(); lastBatchVirtAddr[0] = begin[0]; - triggerHWCommandList(info, pCmdInfo->_beginCount); + triggerHWCommandList(info); } - s_cmdring._lastBatchStartAddr = pCmdInfo->_lastBeginAddr; + s_cmdring._lastBatchStartAddr = pCmdInfo->hw_addr; DRM_INFO("%s: exit\n", __func__); } @@ -159,7 +158,7 @@ int xgi_submit_cmdlist_ioctl(DRM_IOCTL_ARGS) (struct xgi_cmd_info __user *) data, sizeof(cmd_list)); - if (cmd_list._firstBeginType > BTYPE_CTRL) { + if (cmd_list.type > BTYPE_CTRL) { return DRM_ERR(EINVAL); } @@ -234,18 +233,13 @@ void xgi_cmdlist_cleanup(struct xgi_info * info) } } -static void triggerHWCommandList(struct xgi_info * info, - unsigned int triggerCounter) +static void triggerHWCommandList(struct xgi_info * info) { static unsigned int s_triggerID = 1; - //Fix me, currently we just trigger one time - while (triggerCounter--) { - dwWriteReg(info->mmio_map, - BASE_3D_ENG + M2REG_PCI_TRIGGER_REGISTER_ADDRESS, - 0x05000000 + (0x0ffff & s_triggerID++)); - // xgi_waitfor_pci_idle(info); - } + dwWriteReg(info->mmio_map, + BASE_3D_ENG + M2REG_PCI_TRIGGER_REGISTER_ADDRESS, + 0x05000000 + (0x0ffff & s_triggerID++)); } @@ -284,7 +278,7 @@ static void addFlush2D(struct xgi_info * info) lastBatchVirtAddr[0] = (get_batch_command(BTYPE_CTRL) << 24) | (BEGIN_VALID_MASK); - triggerHWCommandList(info, 1); + triggerHWCommandList(info); s_cmdring._cmdRingOffset += 0x20; s_cmdring._lastBatchStartAddr = flushBatchHWAddr; -- cgit v1.2.3 From 3265a61f895a1d35072984e9cdc71aad898647fa Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Sat, 21 Jul 2007 20:39:22 -0700 Subject: Make s_cmdring a field in the xgi_info structure instead of a global. --- linux-core/xgi_cmdlist.c | 54 +++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 28 deletions(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index 5c31fa27..a040fa15 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -31,12 +31,10 @@ #include "xgi_misc.h" #include "xgi_cmdlist.h" -struct xgi_cmdring_info s_cmdring; - static void addFlush2D(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(void); +static void xgi_cmdlist_reset(struct xgi_info * info); int xgi_cmdlist_initialize(struct xgi_info * info, size_t size) { @@ -51,11 +49,11 @@ int xgi_cmdlist_initialize(struct xgi_info * info, size_t size) return err; } - s_cmdring._cmdRingSize = mem_alloc.size; - s_cmdring._cmdRingBuffer = mem_alloc.hw_addr; - s_cmdring._cmdRingAllocOffset = mem_alloc.offset; - s_cmdring._lastBatchStartAddr = 0; - s_cmdring._cmdRingOffset = 0; + info->cmdring._cmdRingSize = mem_alloc.size; + info->cmdring._cmdRingBuffer = mem_alloc.hw_addr; + info->cmdring._cmdRingAllocOffset = mem_alloc.offset; + info->cmdring._lastBatchStartAddr = 0; + info->cmdring._cmdRingOffset = 0; return 0; } @@ -92,7 +90,7 @@ static void xgi_submit_cmdlist(struct xgi_info * info, begin[2] = pCmdInfo->hw_addr >> 4; begin[3] = 0; - if (s_cmdring._lastBatchStartAddr == 0) { + if (info->cmdring._lastBatchStartAddr == 0) { const unsigned int portOffset = BASE_3D_ENG + (cmd << 2); @@ -124,7 +122,7 @@ static void xgi_submit_cmdlist(struct xgi_info * info, } else { u32 *lastBatchVirtAddr; - DRM_INFO("s_cmdring._lastBatchStartAddr != 0\n"); + DRM_INFO("info->cmdring._lastBatchStartAddr != 0\n"); if (pCmdInfo->type == BTYPE_3D) { addFlush2D(info); @@ -132,7 +130,7 @@ static void xgi_submit_cmdlist(struct xgi_info * info, lastBatchVirtAddr = xgi_find_pcie_virt(info, - s_cmdring._lastBatchStartAddr); + info->cmdring._lastBatchStartAddr); lastBatchVirtAddr[1] = begin[1]; lastBatchVirtAddr[2] = begin[2]; @@ -143,7 +141,7 @@ static void xgi_submit_cmdlist(struct xgi_info * info, triggerHWCommandList(info); } - s_cmdring._lastBatchStartAddr = pCmdInfo->hw_addr; + info->cmdring._lastBatchStartAddr = pCmdInfo->hw_addr; DRM_INFO("%s: exit\n", __func__); } @@ -188,7 +186,7 @@ int xgi_state_change(struct xgi_info * info, unsigned int to, // stop to received batch } else if ((from == STATE_CONSOLE) && (to == STATE_GRAPHIC)) { DRM_INFO("[kd] I see, now is to enterVT\n"); - xgi_cmdlist_reset(); + xgi_cmdlist_reset(info); } else if ((from == STATE_GRAPHIC) && ((to == STATE_LOGOUT) || (to == STATE_REBOOT) @@ -217,19 +215,19 @@ int xgi_state_change_ioctl(DRM_IOCTL_ARGS) } -void xgi_cmdlist_reset(void) +void xgi_cmdlist_reset(struct xgi_info * info) { - s_cmdring._lastBatchStartAddr = 0; - s_cmdring._cmdRingOffset = 0; + info->cmdring._lastBatchStartAddr = 0; + info->cmdring._cmdRingOffset = 0; } void xgi_cmdlist_cleanup(struct xgi_info * info) { - if (s_cmdring._cmdRingBuffer != 0) { - xgi_pcie_free(info, s_cmdring._cmdRingAllocOffset, NULL); - s_cmdring._cmdRingBuffer = 0; - s_cmdring._cmdRingOffset = 0; - s_cmdring._cmdRingSize = 0; + if (info->cmdring._cmdRingBuffer != 0) { + xgi_pcie_free(info, info->cmdring._cmdRingAllocOffset, NULL); + info->cmdring._cmdRingBuffer = 0; + info->cmdring._cmdRingOffset = 0; + info->cmdring._cmdRingSize = 0; } } @@ -250,11 +248,11 @@ static void addFlush2D(struct xgi_info * info) u32 *lastBatchVirtAddr; /* check buf is large enough to contain a new flush batch */ - if ((s_cmdring._cmdRingOffset + 0x20) >= s_cmdring._cmdRingSize) { - s_cmdring._cmdRingOffset = 0; + if ((info->cmdring._cmdRingOffset + 0x20) >= info->cmdring._cmdRingSize) { + info->cmdring._cmdRingOffset = 0; } - flushBatchHWAddr = s_cmdring._cmdRingBuffer + s_cmdring._cmdRingOffset; + flushBatchHWAddr = info->cmdring._cmdRingBuffer + info->cmdring._cmdRingOffset; flushBatchVirtAddr = xgi_find_pcie_virt(info, flushBatchHWAddr); /* not using memcpy for I assume the address is discrete */ @@ -267,9 +265,9 @@ static void addFlush2D(struct xgi_info * info) *(flushBatchVirtAddr + 6) = FLUSH_2D; *(flushBatchVirtAddr + 7) = FLUSH_2D; - // ASSERT(s_cmdring._lastBatchStartAddr != NULL); + // ASSERT(info->cmdring._lastBatchStartAddr != NULL); lastBatchVirtAddr = - xgi_find_pcie_virt(info, s_cmdring._lastBatchStartAddr); + xgi_find_pcie_virt(info, info->cmdring._lastBatchStartAddr); lastBatchVirtAddr[1] = BEGIN_LINK_ENABLE_MASK + 0x08; lastBatchVirtAddr[2] = flushBatchHWAddr >> 4; @@ -280,6 +278,6 @@ static void addFlush2D(struct xgi_info * info) triggerHWCommandList(info); - s_cmdring._cmdRingOffset += 0x20; - s_cmdring._lastBatchStartAddr = flushBatchHWAddr; + info->cmdring._cmdRingOffset += 0x20; + info->cmdring._lastBatchStartAddr = flushBatchHWAddr; } -- cgit v1.2.3 From 1a0775760c0eecbb238f0e928b185c267c1c3783 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Sat, 21 Jul 2007 21:35:06 -0700 Subject: Rename and document fields of xgi_cmdring_info. --- linux-core/xgi_cmdlist.c | 71 +++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 40 deletions(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index a040fa15..53bada50 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -49,11 +49,12 @@ int xgi_cmdlist_initialize(struct xgi_info * info, size_t size) return err; } - info->cmdring._cmdRingSize = mem_alloc.size; - info->cmdring._cmdRingBuffer = mem_alloc.hw_addr; - info->cmdring._cmdRingAllocOffset = mem_alloc.offset; - info->cmdring._lastBatchStartAddr = 0; - info->cmdring._cmdRingOffset = 0; + info->cmdring.ptr = xgi_find_pcie_virt(info, mem_alloc.offset); + info->cmdring.size = mem_alloc.size; + info->cmdring.ring_hw_base = mem_alloc.hw_addr; + info->cmdring.ring_gart_base = mem_alloc.offset; + info->cmdring.last_ptr = NULL; + info->cmdring.ring_offset = 0; return 0; } @@ -90,7 +91,7 @@ static void xgi_submit_cmdlist(struct xgi_info * info, begin[2] = pCmdInfo->hw_addr >> 4; begin[3] = 0; - if (info->cmdring._lastBatchStartAddr == 0) { + if (info->cmdring.last_ptr == NULL) { const unsigned int portOffset = BASE_3D_ENG + (cmd << 2); @@ -120,28 +121,22 @@ static void xgi_submit_cmdlist(struct xgi_info * info, dwWriteReg(info->mmio_map, portOffset + 8, begin[2]); dwWriteReg(info->mmio_map, portOffset + 12, begin[3]); } else { - u32 *lastBatchVirtAddr; - - DRM_INFO("info->cmdring._lastBatchStartAddr != 0\n"); + DRM_INFO("info->cmdring.last_ptr != NULL\n"); if (pCmdInfo->type == BTYPE_3D) { addFlush2D(info); } - lastBatchVirtAddr = - xgi_find_pcie_virt(info, - info->cmdring._lastBatchStartAddr); - - lastBatchVirtAddr[1] = begin[1]; - lastBatchVirtAddr[2] = begin[2]; - lastBatchVirtAddr[3] = begin[3]; + info->cmdring.last_ptr[1] = begin[1]; + info->cmdring.last_ptr[2] = begin[2]; + info->cmdring.last_ptr[3] = begin[3]; wmb(); - lastBatchVirtAddr[0] = begin[0]; + info->cmdring.last_ptr[0] = begin[0]; triggerHWCommandList(info); } - info->cmdring._lastBatchStartAddr = pCmdInfo->hw_addr; + info->cmdring.last_ptr = xgi_find_pcie_virt(info, pCmdInfo->hw_addr); DRM_INFO("%s: exit\n", __func__); } @@ -217,17 +212,17 @@ int xgi_state_change_ioctl(DRM_IOCTL_ARGS) void xgi_cmdlist_reset(struct xgi_info * info) { - info->cmdring._lastBatchStartAddr = 0; - info->cmdring._cmdRingOffset = 0; + info->cmdring.last_ptr = NULL; + info->cmdring.ring_offset = 0; } void xgi_cmdlist_cleanup(struct xgi_info * info) { - if (info->cmdring._cmdRingBuffer != 0) { - xgi_pcie_free(info, info->cmdring._cmdRingAllocOffset, NULL); - info->cmdring._cmdRingBuffer = 0; - info->cmdring._cmdRingOffset = 0; - info->cmdring._cmdRingSize = 0; + if (info->cmdring.ring_hw_base != 0) { + xgi_pcie_free(info, info->cmdring.ring_gart_base, NULL); + info->cmdring.ring_hw_base = 0; + info->cmdring.ring_offset = 0; + info->cmdring.size = 0; } } @@ -245,15 +240,15 @@ static void addFlush2D(struct xgi_info * info) { u32 *flushBatchVirtAddr; u32 flushBatchHWAddr; - u32 *lastBatchVirtAddr; /* check buf is large enough to contain a new flush batch */ - if ((info->cmdring._cmdRingOffset + 0x20) >= info->cmdring._cmdRingSize) { - info->cmdring._cmdRingOffset = 0; + if ((info->cmdring.ring_offset + 0x20) >= info->cmdring.size) { + info->cmdring.ring_offset = 0; } - flushBatchHWAddr = info->cmdring._cmdRingBuffer + info->cmdring._cmdRingOffset; - flushBatchVirtAddr = xgi_find_pcie_virt(info, flushBatchHWAddr); + flushBatchHWAddr = info->cmdring.ring_hw_base + info->cmdring.ring_offset; + flushBatchVirtAddr = info->cmdring.ptr + + (info->cmdring.ring_offset / 4); /* not using memcpy for I assume the address is discrete */ *(flushBatchVirtAddr + 0) = 0x10000000; @@ -265,19 +260,15 @@ static void addFlush2D(struct xgi_info * info) *(flushBatchVirtAddr + 6) = FLUSH_2D; *(flushBatchVirtAddr + 7) = FLUSH_2D; - // ASSERT(info->cmdring._lastBatchStartAddr != NULL); - lastBatchVirtAddr = - xgi_find_pcie_virt(info, info->cmdring._lastBatchStartAddr); - - lastBatchVirtAddr[1] = BEGIN_LINK_ENABLE_MASK + 0x08; - lastBatchVirtAddr[2] = flushBatchHWAddr >> 4; - lastBatchVirtAddr[3] = 0; + info->cmdring.last_ptr[1] = BEGIN_LINK_ENABLE_MASK + 0x08; + info->cmdring.last_ptr[2] = flushBatchHWAddr >> 4; + info->cmdring.last_ptr[3] = 0; wmb(); - lastBatchVirtAddr[0] = (get_batch_command(BTYPE_CTRL) << 24) + info->cmdring.last_ptr[0] = (get_batch_command(BTYPE_CTRL) << 24) | (BEGIN_VALID_MASK); triggerHWCommandList(info); - info->cmdring._cmdRingOffset += 0x20; - info->cmdring._lastBatchStartAddr = flushBatchHWAddr; + info->cmdring.ring_offset += 0x20; + info->cmdring.last_ptr = flushBatchVirtAddr; } -- cgit v1.2.3 From 699207cf2fa0c5255365dd28eeb3dd760f362818 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Sat, 21 Jul 2007 21:37:45 -0700 Subject: Remove some extraneous debug messages. --- linux-core/xgi_cmdlist.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index 53bada50..98d80ef0 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -97,8 +97,6 @@ static void xgi_submit_cmdlist(struct xgi_info * info, /* Enable PCI Trigger Mode */ - DRM_INFO("Enable PCI Trigger Mode \n"); - dwWriteReg(info->mmio_map, BASE_3D_ENG + M2REG_AUTO_LINK_SETTING_ADDRESS, (M2REG_AUTO_LINK_SETTING_ADDRESS << 22) | @@ -113,9 +111,6 @@ static void xgi_submit_cmdlist(struct xgi_info * info, /* Send PCI begin command */ - DRM_INFO("portOffset=%d, beginPort=%d\n", - portOffset, cmd << 2); - dwWriteReg(info->mmio_map, portOffset, begin[0]); dwWriteReg(info->mmio_map, portOffset + 4, begin[1]); dwWriteReg(info->mmio_map, portOffset + 8, begin[2]); -- cgit v1.2.3 From 388a2c54eea7575a5b046da3df09f7a1c63551d6 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 23 Jul 2007 18:50:07 -0700 Subject: Minor log message clean up. --- linux-core/xgi_cmdlist.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index 98d80ef0..f5fc1b94 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -116,7 +116,7 @@ static void xgi_submit_cmdlist(struct xgi_info * info, dwWriteReg(info->mmio_map, portOffset + 8, begin[2]); dwWriteReg(info->mmio_map, portOffset + 12, begin[3]); } else { - DRM_INFO("info->cmdring.last_ptr != NULL\n"); + DRM_DEBUG("info->cmdring.last_ptr != NULL\n"); if (pCmdInfo->type == BTYPE_3D) { addFlush2D(info); @@ -132,7 +132,6 @@ static void xgi_submit_cmdlist(struct xgi_info * info, } info->cmdring.last_ptr = xgi_find_pcie_virt(info, pCmdInfo->hw_addr); - DRM_INFO("%s: exit\n", __func__); } @@ -172,19 +171,17 @@ int xgi_state_change(struct xgi_info * info, unsigned int to, #define STATE_SHUTDOWN 5 if ((from == STATE_GRAPHIC) && (to == STATE_CONSOLE)) { - DRM_INFO("[kd] I see, now is to leaveVT\n"); - // stop to received batch + DRM_INFO("Leaving graphical mode (probably VT switch)\n"); } else if ((from == STATE_CONSOLE) && (to == STATE_GRAPHIC)) { - DRM_INFO("[kd] I see, now is to enterVT\n"); + DRM_INFO("Entering graphical mode (probably VT switch)\n"); xgi_cmdlist_reset(info); } else if ((from == STATE_GRAPHIC) && ((to == STATE_LOGOUT) || (to == STATE_REBOOT) || (to == STATE_SHUTDOWN))) { - DRM_INFO("[kd] I see, not is to exit from X\n"); - // stop to received batch + DRM_INFO("Leaving graphical mode (probably X shutting down)\n"); } else { - DRM_ERROR("[kd] Should not happen\n"); + DRM_ERROR("Invalid state change.\n"); return DRM_ERR(EINVAL); } -- cgit v1.2.3 From 8e64d2ae862d5fa02e23c68db6b55393e1f86005 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 24 Jul 2007 13:36:02 -0700 Subject: Fix license formatting. --- linux-core/xgi_cmdlist.c | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index f5fc1b94..e4f9dbcd 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -1,29 +1,27 @@ - /**************************************************************************** - * Copyright (C) 2003-2006 by XGI Technology, Taiwan. - * * - * All Rights Reserved. * - * * + * Copyright (C) 2003-2006 by XGI Technology, Taiwan. + * + * All Rights Reserved. + * * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation on the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial - * portions of the Software. - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NON-INFRINGEMENT. IN NO EVENT SHALL XGI AND/OR - * ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * XGI AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. ***************************************************************************/ #include "xgi_drv.h" -- cgit v1.2.3 From 75a68635a8f7b0d4fb31031832cc282a39a4a1e7 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 24 Jul 2007 15:53:50 -0700 Subject: Pass correct offset to xgi_find_pcie_virt. The wrong offset was being passed to xgi_find_pcie_virt. This would cause an oops in addFlush2D. --- linux-core/xgi_cmdlist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index e4f9dbcd..8ba8dc75 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -47,7 +47,7 @@ int xgi_cmdlist_initialize(struct xgi_info * info, size_t size) return err; } - info->cmdring.ptr = xgi_find_pcie_virt(info, mem_alloc.offset); + info->cmdring.ptr = xgi_find_pcie_virt(info, mem_alloc.hw_offset); info->cmdring.size = mem_alloc.size; info->cmdring.ring_hw_base = mem_alloc.hw_addr; info->cmdring.ring_gart_base = mem_alloc.offset; -- cgit v1.2.3 From 2bafeb673f14b1e3799bf00817138c0b8211635e Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 24 Jul 2007 16:17:30 -0700 Subject: Fix typo on previous commit. Sigh... --- linux-core/xgi_cmdlist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index 8ba8dc75..490e9f39 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -47,7 +47,7 @@ int xgi_cmdlist_initialize(struct xgi_info * info, size_t size) return err; } - info->cmdring.ptr = xgi_find_pcie_virt(info, mem_alloc.hw_offset); + info->cmdring.ptr = xgi_find_pcie_virt(info, mem_alloc.hw_addr); info->cmdring.size = mem_alloc.size; info->cmdring.ring_hw_base = mem_alloc.hw_addr; info->cmdring.ring_gart_base = mem_alloc.offset; -- cgit v1.2.3 From c37ed9eca57a42b98cc67ca98dbf5135f5ab7aba Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 26 Jul 2007 17:01:16 -0700 Subject: Eliminate use of DRM_ERR. --- linux-core/xgi_cmdlist.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index 490e9f39..10ee9764 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -144,7 +144,7 @@ int xgi_submit_cmdlist_ioctl(DRM_IOCTL_ARGS) sizeof(cmd_list)); if (cmd_list.type > BTYPE_CTRL) { - return DRM_ERR(EINVAL); + return -EINVAL; } xgi_submit_cmdlist(info, &cmd_list); @@ -180,7 +180,7 @@ int xgi_state_change(struct xgi_info * info, unsigned int to, DRM_INFO("Leaving graphical mode (probably X shutting down)\n"); } else { DRM_ERROR("Invalid state change.\n"); - return DRM_ERR(EINVAL); + return -EINVAL; } return 0; -- cgit v1.2.3 From cd51f131389297f923798daef6c734ba93f4422b Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 27 Jul 2007 15:45:59 -0700 Subject: Convert to new ioctl interface between core DRM and device-specific module. --- linux-core/xgi_cmdlist.c | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index 10ee9764..1d0ee754 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -76,9 +76,12 @@ unsigned int get_batch_command(enum xgi_batch_type type) } -static void xgi_submit_cmdlist(struct xgi_info * info, - const struct xgi_cmd_info * pCmdInfo) +int xgi_submit_cmdlist(struct drm_device * dev, void * data, + struct drm_file * filp) { + struct xgi_info *const info = dev->dev_private; + const struct xgi_cmd_info *const pCmdInfo = + (struct xgi_cmd_info *) data; const unsigned int cmd = get_batch_command(pCmdInfo->type); u32 begin[4]; @@ -130,24 +133,6 @@ static void xgi_submit_cmdlist(struct xgi_info * info, } info->cmdring.last_ptr = xgi_find_pcie_virt(info, pCmdInfo->hw_addr); -} - - -int xgi_submit_cmdlist_ioctl(DRM_IOCTL_ARGS) -{ - DRM_DEVICE; - struct xgi_cmd_info cmd_list; - struct xgi_info *info = dev->dev_private; - - DRM_COPY_FROM_USER_IOCTL(cmd_list, - (struct xgi_cmd_info __user *) data, - sizeof(cmd_list)); - - if (cmd_list.type > BTYPE_CTRL) { - return -EINVAL; - } - - xgi_submit_cmdlist(info, &cmd_list); return 0; } @@ -187,16 +172,15 @@ int xgi_state_change(struct xgi_info * info, unsigned int to, } -int xgi_state_change_ioctl(DRM_IOCTL_ARGS) +int xgi_state_change_ioctl(struct drm_device * dev, void * data, + struct drm_file * filp) { - DRM_DEVICE; - struct xgi_state_info state; + struct xgi_state_info *const state = + (struct xgi_state_info *) data; struct xgi_info *info = dev->dev_private; - DRM_COPY_FROM_USER_IOCTL(state, (struct xgi_state_info __user *) data, - sizeof(state)); - return xgi_state_change(info, state._toState, state._fromState); + return xgi_state_change(info, state->_toState, state->_fromState); } -- cgit v1.2.3 From 2fc697a7d270d57463eb5a16a0c65bd8e14c9893 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 30 Jul 2007 10:20:15 -0700 Subject: Fix GE shut-down sequence. When the GE is shut down, an empty command packet without a begin-link must be sent. After this command is sent, wait for the hardware to go idle. Finally, turn off the GE and disable MMIO. --- linux-core/xgi_cmdlist.c | 64 +++++++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 22 deletions(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index 1d0ee754..4bb147c4 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -29,7 +29,7 @@ #include "xgi_misc.h" #include "xgi_cmdlist.h" -static void addFlush2D(struct xgi_info * info); +static void xgi_emit_flush(struct xgi_info * info, bool link); 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); @@ -120,7 +120,7 @@ int xgi_submit_cmdlist(struct drm_device * dev, void * data, DRM_DEBUG("info->cmdring.last_ptr != NULL\n"); if (pCmdInfo->type == BTYPE_3D) { - addFlush2D(info); + xgi_emit_flush(info, TRUE); } info->cmdring.last_ptr[1] = begin[1]; @@ -190,9 +190,18 @@ void xgi_cmdlist_reset(struct xgi_info * info) info->cmdring.ring_offset = 0; } + void xgi_cmdlist_cleanup(struct xgi_info * info) { if (info->cmdring.ring_hw_base != 0) { + /* If command lists have been issued, terminate the command + * list chain with a flush command. + */ + if (info->cmdring.last_ptr != NULL) { + xgi_emit_flush(info, FALSE); + xgi_waitfor_pci_idle(info); + } + xgi_pcie_free(info, info->cmdring.ring_gart_base, NULL); info->cmdring.ring_hw_base = 0; info->cmdring.ring_offset = 0; @@ -210,32 +219,43 @@ static void triggerHWCommandList(struct xgi_info * info) } -static void addFlush2D(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) { - u32 *flushBatchVirtAddr; - u32 flushBatchHWAddr; + static const u32 flush_command[8] = { + (0x10 << 24), + BEGIN_LINK_ENABLE_MASK | (0x00004), + 0x00000000, 0x00000000, + + /* Flush everything with the default 32 clock delay. + */ + 0x003fffff, 0x003fffff, 0x003fffff, 0x003fffff + }; + const unsigned int base = (link) ? 0 : 4; + const unsigned int flush_size = (8 - base) * sizeof(u32); + u32 *batch_addr; + u32 hw_addr; /* check buf is large enough to contain a new flush batch */ - if ((info->cmdring.ring_offset + 0x20) >= info->cmdring.size) { + if ((info->cmdring.ring_offset + flush_size) >= info->cmdring.size) { info->cmdring.ring_offset = 0; } - flushBatchHWAddr = info->cmdring.ring_hw_base + info->cmdring.ring_offset; - flushBatchVirtAddr = info->cmdring.ptr + hw_addr = info->cmdring.ring_hw_base + + info->cmdring.ring_offset; + batch_addr = info->cmdring.ptr + (info->cmdring.ring_offset / 4); - /* not using memcpy for I assume the address is discrete */ - *(flushBatchVirtAddr + 0) = 0x10000000; - *(flushBatchVirtAddr + 1) = 0x80000004; /* size = 0x04 dwords */ - *(flushBatchVirtAddr + 2) = 0x00000000; - *(flushBatchVirtAddr + 3) = 0x00000000; - *(flushBatchVirtAddr + 4) = FLUSH_2D; - *(flushBatchVirtAddr + 5) = FLUSH_2D; - *(flushBatchVirtAddr + 6) = FLUSH_2D; - *(flushBatchVirtAddr + 7) = FLUSH_2D; - - info->cmdring.last_ptr[1] = BEGIN_LINK_ENABLE_MASK + 0x08; - info->cmdring.last_ptr[2] = flushBatchHWAddr >> 4; + (void) memcpy(batch_addr, & flush_command[base], flush_size); + + 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(); info->cmdring.last_ptr[0] = (get_batch_command(BTYPE_CTRL) << 24) @@ -243,6 +263,6 @@ static void addFlush2D(struct xgi_info * info) triggerHWCommandList(info); - info->cmdring.ring_offset += 0x20; - info->cmdring.last_ptr = flushBatchVirtAddr; + info->cmdring.ring_offset += flush_size; + info->cmdring.last_ptr = (link) ? batch_addr : NULL; } -- cgit v1.2.3 From 997a9a738ec26cf0ef2c7dee5e30bb53bd11bf6c Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 6 Aug 2007 15:31:34 -0700 Subject: Eliminate allocation "owner" usage. --- linux-core/xgi_cmdlist.c | 1 - 1 file changed, 1 deletion(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index 4bb147c4..e0ca31f1 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -38,7 +38,6 @@ int xgi_cmdlist_initialize(struct xgi_info * info, size_t size) { struct xgi_mem_alloc mem_alloc = { .size = size, - .owner = PCIE_2D, }; int err; -- cgit v1.2.3 From f96bff9e213a950ab910832908d30e732435e628 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 6 Aug 2007 16:09:05 -0700 Subject: Unify infrastructure for allocating (not yet freeing) on-card / GART memory. --- linux-core/xgi_cmdlist.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index e0ca31f1..33155827 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -37,11 +37,12 @@ static void xgi_cmdlist_reset(struct xgi_info * info); int xgi_cmdlist_initialize(struct xgi_info * info, size_t size) { struct xgi_mem_alloc mem_alloc = { + .location = XGI_MEMLOC_NON_LOCAL, .size = size, }; int err; - err = xgi_pcie_alloc(info, &mem_alloc, 0); + err = xgi_alloc(info, &mem_alloc, 0); if (err) { return err; } -- cgit v1.2.3 From f7ba02b7458823627097a2320bf9befa84fc9c76 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 6 Aug 2007 17:27:15 -0700 Subject: Unify infrastructure for freeing on-card / GART memory. --- linux-core/xgi_cmdlist.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index 33155827..e1653021 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -202,7 +202,9 @@ void xgi_cmdlist_cleanup(struct xgi_info * info) xgi_waitfor_pci_idle(info); } - xgi_pcie_free(info, info->cmdring.ring_gart_base, NULL); + xgi_free(info, (XGI_MEMLOC_NON_LOCAL + | info->cmdring.ring_gart_base), + NULL); info->cmdring.ring_hw_base = 0; info->cmdring.ring_offset = 0; info->cmdring.size = 0; -- cgit v1.2.3 From 25cb876f8513d02d4d189371eaa8b7b9a88e860d Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 9 Aug 2007 15:23:13 -0700 Subject: Associate master file pointer with command list buffer. Pass the master's file pointer, as supplied to xgi_bootstrap, to xgi_cmdlist_initialize. Associate that pointer with the memory allocated for the command list buffer. By doing this the memory will be automatically cleaned up when the master closes the device. This allows the removal of some clean up code. --- linux-core/xgi_cmdlist.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index e1653021..a1ec5720 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -34,7 +34,8 @@ 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); -int xgi_cmdlist_initialize(struct xgi_info * info, size_t size) +int xgi_cmdlist_initialize(struct xgi_info * info, size_t size, + struct drm_file * filp) { struct xgi_mem_alloc mem_alloc = { .location = XGI_MEMLOC_NON_LOCAL, @@ -42,7 +43,7 @@ int xgi_cmdlist_initialize(struct xgi_info * info, size_t size) }; int err; - err = xgi_alloc(info, &mem_alloc, 0); + err = xgi_alloc(info, &mem_alloc, filp); if (err) { return err; } @@ -50,7 +51,6 @@ int xgi_cmdlist_initialize(struct xgi_info * info, size_t size) info->cmdring.ptr = xgi_find_pcie_virt(info, mem_alloc.hw_addr); info->cmdring.size = mem_alloc.size; info->cmdring.ring_hw_base = mem_alloc.hw_addr; - info->cmdring.ring_gart_base = mem_alloc.offset; info->cmdring.last_ptr = NULL; info->cmdring.ring_offset = 0; @@ -202,12 +202,7 @@ void xgi_cmdlist_cleanup(struct xgi_info * info) xgi_waitfor_pci_idle(info); } - xgi_free(info, (XGI_MEMLOC_NON_LOCAL - | info->cmdring.ring_gart_base), - NULL); - info->cmdring.ring_hw_base = 0; - info->cmdring.ring_offset = 0; - info->cmdring.size = 0; + (void) memset(&info->cmdring, 0, sizeof(info->cmdring)); } } -- cgit v1.2.3 From d3c8e98dd9ccc366513c117d032fbf80be4eb06a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 14 Aug 2007 13:20:37 -0700 Subject: Move dwWriteReg to xgi_cmdlist.c, the only file where it is used. --- linux-core/xgi_cmdlist.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index a1ec5720..a728c0ef 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -34,6 +34,20 @@ 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); + +/** + * Graphic engine register (2d/3d) acessing interface + */ +static inline void dwWriteReg(struct drm_map * map, u32 addr, u32 data) +{ +#ifdef XGI_MMIO_DEBUG + DRM_INFO("mmio_map->handle = 0x%p, addr = 0x%x, data = 0x%x\n", + map->handle, addr, data); +#endif + DRM_WRITE32(map, addr, data); +} + + int xgi_cmdlist_initialize(struct xgi_info * info, size_t size, struct drm_file * filp) { -- cgit v1.2.3 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 From 3383e8bd6bcd2323c81252e617c8522593baf818 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 17 Aug 2007 10:53:18 -0700 Subject: Remove unnecessary include. --- linux-core/xgi_cmdlist.c | 1 - 1 file changed, 1 deletion(-) (limited to 'linux-core/xgi_cmdlist.c') diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c index 5409892a..261f4e13 100644 --- a/linux-core/xgi_cmdlist.c +++ b/linux-core/xgi_cmdlist.c @@ -28,7 +28,6 @@ #include "xgi_regs.h" #include "xgi_misc.h" #include "xgi_cmdlist.h" -#include static void xgi_emit_flush(struct xgi_info * info, bool stop); static void xgi_emit_nop(struct xgi_info * info); -- cgit v1.2.3