2019-06-03 07:44:50 +02:00
/* SPDX-License-Identifier: GPL-2.0-only */
2016-03-15 15:35:08 -04:00
/*
* Copyright ( C ) 2013 - 2016 Red Hat
* Author : Rob Clark < robdclark @ gmail . com >
*/
# ifndef __MSM_FENCE_H__
# define __MSM_FENCE_H__
# include "msm_drv.h"
2021-07-26 07:43:57 -07:00
/**
* struct msm_fence_context - fence context for gpu
*
* Each ringbuffer has a single fence context , with the GPU writing an
* incrementing fence seqno at the end of each submit
*/
2016-03-15 17:22:13 -04:00
struct msm_fence_context {
struct drm_device * dev ;
2021-07-26 07:43:57 -07:00
/** name: human readable name for fence timeline */
2017-10-20 11:06:57 -06:00
char name [ 32 ] ;
2021-07-26 07:43:57 -07:00
/** context: see dma_fence_context_alloc() */
2016-03-15 18:26:28 -04:00
unsigned context ;
2021-07-26 07:43:57 -07:00
/**
* last_fence :
*
* Last assigned fence , incremented each time a fence is created
* on this fence context . If last_fence = = completed_fence ,
* there is no remaining pending work
*/
uint32_t last_fence ;
/**
* completed_fence :
*
* The last completed fence , updated from the CPU after interrupt
* from GPU
*/
uint32_t completed_fence ;
/**
* fenceptr :
*
* The address that the GPU directly writes with completed fence
* seqno . This can be ahead of completed_fence . We can peek at
* this to see if a fence has already signaled but the CPU hasn ' t
* gotten around to handling the irq and updating completed_fence
*/
volatile uint32_t * fenceptr ;
2016-03-15 18:26:28 -04:00
spinlock_t spinlock ;
2016-03-15 17:22:13 -04:00
} ;
struct msm_fence_context * msm_fence_context_alloc ( struct drm_device * dev ,
2021-07-26 07:43:57 -07:00
volatile uint32_t * fenceptr , const char * name ) ;
2016-03-15 17:22:13 -04:00
void msm_fence_context_free ( struct msm_fence_context * fctx ) ;
void msm_update_fence ( struct msm_fence_context * fctx , uint32_t fence ) ;
2016-03-15 15:35:08 -04:00
2016-10-25 13:00:45 +01:00
struct dma_fence * msm_fence_alloc ( struct msm_fence_context * fctx ) ;
2016-03-15 18:26:28 -04:00
2016-03-15 15:35:08 -04:00
# endif