[PATCH] DRI2: Don't return junk reply instead of blocking in glXWaitForSbcOML()

Mario Kleiner mario.kleiner at tuebingen.mpg.de
Mon Jun 7 10:33:48 PDT 2010


Hi, just to bump this one, and because i forgot to cc Jesse. This  
patch fixes another "showstopper" bug in glXWaitForSbcOML() for the  
new DRI2 sync & swap bits. I applied it to master and testing showed  
no further bugs in glXWaitForSbcOML().

Jesse, can you do a quick review and add your reviewed-by? It should  
go into master and 1.8.2 before the 1.8 series is done.

best,
-mario

On Jun 5, 2010, at 1:09 PM, Mario Kleiner wrote:

> DRI2WaitSBC() didn't block if requested targetSBC wasn't yet reached.
>
> Instead it returned a xreply with uninitialized junk return values,  
> then
> blocked the connection until targetSBC was reached.
>
> Therefore the client didn't block, but continued with bogus return
> values from glXWaitForSbcOML.
>
> This patch fixes the problem by implementing DRI2WaitSBC similar
> to the clean and proven DRI2WaitMSC implementation.
>
> Signed-off-by: Mario Kleiner <mario.kleiner at tuebingen.mpg.de>
> ---
>  hw/xfree86/dri2/dri2.c    |   10 ++++------
>  hw/xfree86/dri2/dri2.h    |    3 +--
>  hw/xfree86/dri2/dri2ext.c |   16 +++-------------
>  3 files changed, 8 insertions(+), 21 deletions(-)
>
> diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
> index 9ec4caa..23ed3e5 100644
> --- a/hw/xfree86/dri2/dri2.c
> +++ b/hw/xfree86/dri2/dri2.c
> @@ -909,8 +909,7 @@ DRI2WaitMSC(ClientPtr client, DrawablePtr  
> pDraw, CARD64 target_msc,
>  }
>
>  int
> -DRI2WaitSBC(ClientPtr client, DrawablePtr pDraw, CARD64 target_sbc,
> -	    CARD64 *ust, CARD64 *msc, CARD64 *sbc)
> +DRI2WaitSBC(ClientPtr client, DrawablePtr pDraw, CARD64 target_sbc)
>  {
>      DRI2DrawablePtr pPriv;
>
> @@ -924,14 +923,13 @@ DRI2WaitSBC(ClientPtr client, DrawablePtr  
> pDraw, CARD64 target_sbc,
>      if (target_sbc == 0)
>          target_sbc = pPriv->swap_count + pPriv->swapsPending;
>
> -    /* If current swap count already >= target_sbc,
> +    /* If current swap count already >= target_sbc, reply and
>       * return immediately with (ust, msc, sbc) triplet of
>       * most recent completed swap.
>       */
>      if (pPriv->swap_count >= target_sbc) {
> -        *sbc = pPriv->swap_count;
> -        *msc = pPriv->last_swap_msc;
> -        *ust = pPriv->last_swap_ust;
> +        ProcDRI2WaitMSCReply(client, pPriv->last_swap_ust,
> +                             pPriv->last_swap_msc, pPriv- 
> >swap_count);
>          return Success;
>      }
>
> diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
> index f08ca29..fe0bf6c 100644
> --- a/hw/xfree86/dri2/dri2.h
> +++ b/hw/xfree86/dri2/dri2.h
> @@ -265,8 +265,7 @@ extern _X_EXPORT int DRI2WaitMSC(ClientPtr  
> client, DrawablePtr pDrawable,
>  extern _X_EXPORT int ProcDRI2WaitMSCReply(ClientPtr client, CARD64  
> ust,
>  					  CARD64 msc, CARD64 sbc);
>  extern _X_EXPORT int DRI2WaitSBC(ClientPtr client, DrawablePtr pDraw,
> -				 CARD64 target_sbc, CARD64 *ust, CARD64 *msc,
> -				 CARD64 *sbc);
> +				 CARD64 target_sbc);
>  extern _X_EXPORT Bool DRI2ThrottleClient(ClientPtr client,  
> DrawablePtr pDraw);
>
>  extern _X_EXPORT Bool DRI2CanFlip(DrawablePtr pDraw);
> diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c
> index db04268..8016edb 100644
> --- a/hw/xfree86/dri2/dri2ext.c
> +++ b/hw/xfree86/dri2/dri2ext.c
> @@ -520,9 +520,8 @@ static int
>  ProcDRI2WaitSBC(ClientPtr client)
>  {
>      REQUEST(xDRI2WaitSBCReq);
> -    xDRI2MSCReply rep;
>      DrawablePtr pDrawable;
> -    CARD64 target, ust, msc, sbc;
> +    CARD64 target;
>      int status;
>
>      REQUEST_SIZE_MATCH(xDRI2WaitSBCReq);
> @@ -532,18 +531,9 @@ ProcDRI2WaitSBC(ClientPtr client)
>  	return status;
>
>      target = vals_to_card64(stuff->target_sbc_lo, stuff- 
> >target_sbc_hi);
> -    status = DRI2WaitSBC(client, pDrawable, target, &ust, &msc,  
> &sbc);
> -    if (status != Success)
> -	return status;
> +    status = DRI2WaitSBC(client, pDrawable, target);
>
> -    rep.type = X_Reply;
> -    rep.length = 0;
> -    rep.sequenceNumber = client->sequence;
> -    load_msc_reply(&rep, ust, msc, sbc);
> -
> -    WriteToClient(client, sizeof(xDRI2MSCReply), &rep);
> -
> -    return Success;
> +    return status;
>  }
>
>  static int
> -- 
> 1.6.6
>

*********************************************************************
Mario Kleiner
Max Planck Institute for Biological Cybernetics
Spemannstr. 38
72076 Tuebingen
Germany

e-mail: mario.kleiner at tuebingen.mpg.de
office: +49 (0)7071/601-1623
fax:    +49 (0)7071/601-616
www:    http://www.kyb.tuebingen.mpg.de/~kleinerm
*********************************************************************
"For a successful technology, reality must take precedence
over public relations, for Nature cannot be fooled."
(Richard Feynman)



More information about the xorg-devel mailing list