#include <linux/delay.h>
#include <linux/dma-fence.h>
#include <linux/dma-fence-chain.h>
#include <linux/kernel.h>
#include <linux/kthread.h>
#include <linux/mm.h>
#include <linux/sched/signal.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/random.h>
#include "selftest.h"
#define CHAIN_SZ …
static struct kmem_cache *slab_fences;
static inline struct mock_fence { … }
static const char *mock_name(struct dma_fence *f)
{ … }
static void mock_fence_release(struct dma_fence *f)
{ … }
static const struct dma_fence_ops mock_ops = …;
static struct dma_fence *mock_fence(void)
{ … }
static struct dma_fence *mock_chain(struct dma_fence *prev,
struct dma_fence *fence,
u64 seqno)
{ … }
static int sanitycheck(void *arg)
{ … }
struct fence_chains { … };
static uint64_t seqno_inc(unsigned int i)
{ … }
static int fence_chains_init(struct fence_chains *fc, unsigned int count,
uint64_t (*seqno_fn)(unsigned int))
{ … }
static void fence_chains_fini(struct fence_chains *fc)
{ … }
static int find_seqno(void *arg)
{ … }
static int find_signaled(void *arg)
{ … }
static int find_out_of_order(void *arg)
{ … }
static uint64_t seqno_inc2(unsigned int i)
{ … }
static int find_gap(void *arg)
{ … }
struct find_race { … };
static int __find_race(void *arg)
{ … }
static int find_race(void *arg)
{ … }
static int signal_forward(void *arg)
{ … }
static int signal_backward(void *arg)
{ … }
static int __wait_fence_chains(void *arg)
{ … }
static int wait_forward(void *arg)
{ … }
static int wait_backward(void *arg)
{ … }
static void randomise_fences(struct fence_chains *fc)
{ … }
static int wait_random(void *arg)
{ … }
int dma_fence_chain(void)
{ … }