[PATCH] Remove spurious use of MI_SET_CONTEXT.

Keith Whitwell keith at tungstengraphics.com
Mon Dec 3 11:22:08 PST 2007


It is necessary to do at least on MI_SET_CONTEXT on driver 
initialization, otherwise hardware will hang.  Possibly you've only 
tested on hardware that has run an older version of the driver once 
already, or possibly there is now another component (eg the EXA driver) 
emitting these.

It is also necessary to do an MI_SET_CONTEXT in case there is a 3d 
client out there *really using* MI_SET_CONTEXT.

IE. if I modify the EXA driver to use MI_SET_CONTEXT, and you remove 
this code from the 3d driver, you will get unexpected results.  This 
MI_SET_CONTEXT would cause the other context to be saved -- ie the 
hardware only does something on transitions between different hardware 
contexts, and it is only with this packet that it knows there is a 
context switch...

In other words, I don't think this is a good idea...

Keith

Kristian Høgsberg wrote:
> From: Kristian Høgsberg <krh at temari.boston.redhat.com>
> 
> The driver uses MI_SET_CONTEXT to save the current state before
> emitting the invariant 3d state.  Nothing ever restores this state though,
> so this patch removes that.  This was also the only remaining use of
> the ring buffer in TTM mode, so we're one step closer to a ring-buffer
> free DDX driver.
> ---
>  src/common.h      |    2 +-
>  src/i830.h        |    2 --
>  src/i830_driver.c |   11 -----------
>  src/i830_memory.c |   10 ----------
>  4 files changed, 1 insertions(+), 24 deletions(-)
> 
> diff --git a/src/common.h b/src/common.h
> index f558e8f..46bfa8e 100644
> --- a/src/common.h
> +++ b/src/common.h
> @@ -232,7 +232,7 @@ union intfloat {
>  
>  #define BEGIN_LP_RING(n)						\
>  	RING_LOCALS							\
> -	DO_LP_RING(n)							\
> +	DO_LP_RING(n)
>  
>  /* Memory mapped register access macros */
>  #define INREG8(addr)        *(volatile CARD8  *)(RecPtr->MMIOBase + (addr))
> diff --git a/src/i830.h b/src/i830.h
> index 9387651..cbc1b93 100644
> --- a/src/i830.h
> +++ b/src/i830.h
> @@ -404,8 +404,6 @@ typedef struct _I830Rec {
>     void (*PointerMoved)(int, int, int);
>     CreateScreenResourcesProcPtr    CreateScreenResources;
>  
> -   i830_memory *logical_context;
> -
>  #ifdef XF86DRI
>     i830_memory *back_buffer;
>     i830_memory *third_buffer;
> diff --git a/src/i830_driver.c b/src/i830_driver.c
> index 6393a61..27df05b 100644
> --- a/src/i830_driver.c
> +++ b/src/i830_driver.c
> @@ -2254,17 +2254,6 @@ IntelEmitInvarientState(ScrnInfoPtr pScrn)
>     if (*pI830->last_3d != LAST_3D_OTHER)
>        return;
>  
> -   ctx_addr = pI830->logical_context->offset;
> -   assert((pI830->logical_context->offset & 2047) == 0);
> -   {
> -      BEGIN_LP_RING(2);
> -      OUT_RING(MI_SET_CONTEXT);
> -      OUT_RING(pI830->logical_context->offset |
> -	       CTXT_NO_RESTORE |
> -	       CTXT_PALETTE_SAVE_DISABLE | CTXT_PALETTE_RESTORE_DISABLE);
> -      ADVANCE_LP_RING();
> -   }
> -
>     if (!IS_I965G(pI830))
>     {
>        if (IS_I9XX(pI830))
> diff --git a/src/i830_memory.c b/src/i830_memory.c
> index 85b6528..6287bab 100644
> --- a/src/i830_memory.c
> +++ b/src/i830_memory.c
> @@ -347,7 +347,6 @@ i830_reset_allocations(ScrnInfoPtr pScrn)
>      pI830->exa_offscreen = NULL;
>      pI830->exa_965_state = NULL;
>      pI830->overlay_regs = NULL;
> -    pI830->logical_context = NULL;
>  #ifdef XF86DRI
>      pI830->back_buffer = NULL;
>      pI830->third_buffer = NULL;
> @@ -1356,15 +1355,6 @@ i830_allocate_2d_memory(ScrnInfoPtr pScrn)
>  	pI830->SWCursor = TRUE;
>      }
>  
> -    /* Space for the X Server's 3D context.  32k is fine for right now. */
> -    pI830->logical_context = i830_allocate_memory(pScrn, "logical 3D context",
> -						  KB(32), GTT_PAGE_SIZE, 0);
> -    if (pI830->logical_context == NULL) {
> -	xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
> -		   "Failed to allocate logical context space.\n");
> -	return FALSE;
> -    }
> -
>      /* even in XAA, 965G needs state mem buffer for rendering */
>      if (IS_I965G(pI830) && !pI830->noAccel && pI830->exa_965_state == NULL) {
>  	pI830->exa_965_state =





More information about the xorg mailing list