[RFC v2 04/12] sync: Add support for DMA fences
Adam Jackson
ajax at nwnk.net
Fri Oct 20 18:36:51 UTC 2017
On Wed, 2017-09-27 at 01:19 -0400, Louis-Francis Ratté-Boulianne wrote:
> @@ -1931,6 +1959,9 @@ ProcSyncTriggerFence(ClientPtr client)
> if (rc != Success)
> return rc;
>
> + if (pFence->type == SYNC_FENCE_DMA)
> + return BadMatch;
> +
> miSyncTriggerFence(pFence);
>
> return Success;
This is a bad pattern, the dispatch code shouldn't need to know
anything about fence types. I think this should instead change
miSyncTriggerFence (and pFence->funcs.SetTriggered) to return a Status,
and have ProcSyncTriggerFence end with 'return miSyncTriggerFence()'.
> @@ -1950,7 +1981,8 @@ ProcSyncResetFence(ClientPtr client)
> if (rc != Success)
> return rc;
>
> - if (pFence->funcs.CheckTriggered(pFence) != TRUE)
> + if (pFence->type == SYNC_FENCE_DMA ||
> + pFence->funcs.CheckTriggered(pFence) != TRUE)
> return BadMatch;
>
> pFence->funcs.Reset(pFence);
Likewise here.
> diff --git a/miext/sync/misync.h b/miext/sync/misync.h
> index b3838f1e2..c32e4c961 100644
> --- a/miext/sync/misync.h
> +++ b/miext/sync/misync.h
> @@ -28,6 +28,10 @@
> #ifndef _MISYNC_H_
> #define _MISYNC_H_
>
> +/* Sync fence types */
> +#define SYNC_FENCE_SHM 0
> +#define SYNC_FENCE_DMA 1
> +
> typedef struct _SyncFence SyncFence;
> typedef struct _SyncTrigger SyncTrigger;
>
> @@ -73,6 +77,9 @@ extern _X_EXPORT SyncScreenFuncsPtr miSyncGetScreenFuncs(ScreenPtr pScreen);
> extern _X_EXPORT Bool
> miSyncSetup(ScreenPtr pScreen);
>
> +extern _X_EXPORT int
> +miSyncGetFenceType(SyncFence * pFence);
> +
> Bool
> miSyncFenceCheckTriggered(SyncFence * pFence);
>
... and ...
> diff --git a/miext/sync/misyncstr.h b/miext/sync/misyncstr.h
> index 2eab2aa57..6d97894f0 100644
> --- a/miext/sync/misyncstr.h
> +++ b/miext/sync/misyncstr.h
> @@ -57,6 +57,7 @@ struct _SyncFence {
> ScreenPtr pScreen; /* Screen of this fence object */
> SyncFenceFuncsRec funcs; /* Funcs for performing ops on fence */
> Bool triggered; /* fence state */
> + unsigned char type; /* fence type */
> PrivateRec *devPrivates; /* driver-specific per-fence data */
> };
>
... with all that changed, I think you can avoid needing to add the
'type' field and GetFenceType accessor at all.
- ajax
More information about the xorg-devel
mailing list