[PATCH] xfree: dri2: add AuthMagic hook for driver side support

Aaron Plattner aplattner at nvidia.com
Sat Jan 23 12:43:13 PST 2010


On Fri, Jan 22, 2010 at 09:04:26AM -0800, Tiago Vignatti wrote:
> With this new hook drmAuthMagic becomes useless and should be deprecated.
> You might want to implement AuthMagic on driver side instead.
> 
> Attention: ABI being break.

I'll leave the review to the DRI2 experts, but I think you should either
keep the server compatible with DRI2INFOREC_VERSION 3 and 4 drivers, or
remove the compatibility code to deal with the new fields Jesse added being
missing.  Also, I don't think you need to bump DRI2INFOREC_VERSION again
since Jesse already raised it to 4 and there hasn't been a release since.

You can't just unconditionally copy AuthMagic out of the structure passed
in by the driver, because if it's version 3 or 4, that will read past the
end of what the driver allocated.

Finally, you'll need to resolve your chanage against my changes in "[PATCH]
DRI2: Allow multiple driver names."

-- Aaron

> Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
> ---
>  hw/xfree86/dri2/dri2.c |   13 +++++++++++--
>  hw/xfree86/dri2/dri2.h |    5 ++++-
>  2 files changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
> index 3db826e..9505401 100644
> --- a/hw/xfree86/dri2/dri2.c
> +++ b/hw/xfree86/dri2/dri2.c
> @@ -81,6 +81,7 @@ typedef struct _DRI2Screen {
>      DRI2ScheduleSwapProcPtr	 ScheduleSwap;
>      DRI2GetMSCProcPtr		 GetMSC;
>      DRI2ScheduleWaitMSCProcPtr	 ScheduleWaitMSC;
> +    DRI2AuthMagicProcPtr	 AuthMagic;
>  
>      HandleExposuresProcPtr       HandleExposures;
>  } DRI2ScreenRec;
> @@ -790,8 +791,15 @@ DRI2Authenticate(ScreenPtr pScreen, drm_magic_t magic)
>  {
>      DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
>  
> -    if (ds == NULL || drmAuthMagic(ds->fd, magic))
> -	return FALSE;
> +    if (ds == NULL)
> +    return FALSE;
> +
> +    if (ds->AuthMagic) {
> +        if ((*ds->AuthMagic)(ds->fd, magic))
> +            return FALSE;
> +    }
> +    else if (drmAuthMagic(ds->fd, magic))
> +        return FALSE;
>  
>      return TRUE;
>  }
> @@ -821,6 +829,7 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
>      ds->CreateBuffer   = info->CreateBuffer;
>      ds->DestroyBuffer  = info->DestroyBuffer;
>      ds->CopyRegion     = info->CopyRegion;
> +    ds->AuthMagic      = info->AuthMagic;
>  
>      if (info->version >= 4) {
>  	ds->ScheduleSwap = info->ScheduleSwap;
> diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
> index dd59297..0bec2c8 100644
> --- a/hw/xfree86/dri2/dri2.h
> +++ b/hw/xfree86/dri2/dri2.h
> @@ -63,6 +63,8 @@ typedef void		(*DRI2CopyRegionProcPtr)(DrawablePtr pDraw,
>  						 DRI2BufferPtr pSrcBuffer);
>  typedef void		(*DRI2WaitProcPtr)(WindowPtr pWin,
>  					   unsigned int sequence);
> +typedef int			(*DRI2AuthMagicProcPtr)(int fd, uint32_t magic);
> +
>  /**
>   * Schedule a buffer swap
>   *
> @@ -152,7 +154,7 @@ typedef int		(*DRI2ScheduleWaitMSCProcPtr)(ClientPtr client,
>  /**
>   * Version of the DRI2InfoRec structure defined in this header
>   */
> -#define DRI2INFOREC_VERSION 4
> +#define DRI2INFOREC_VERSION 5
>  
>  typedef struct {
>      unsigned int version;	/**< Version of this struct */
> @@ -167,6 +169,7 @@ typedef struct {
>      DRI2ScheduleSwapProcPtr	ScheduleSwap;
>      DRI2GetMSCProcPtr		GetMSC;
>      DRI2ScheduleWaitMSCProcPtr	ScheduleWaitMSC;
> +    DRI2AuthMagicProcPtr		AuthMagic;
>  }  DRI2InfoRec, *DRI2InfoPtr;
>  
>  extern _X_EXPORT int DRI2EventBase;
> -- 
> 1.6.0.4
> 


More information about the xorg-devel mailing list