blob: 3353d32ceda86f438a56eae6edac278c7b8b0e78 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
/* SPDX-License-Identifier: MIT */
/*
* Copyright © 2021 Intel Corporation
*/
#ifndef __I915_VMA_RESOURCE_H__
#define __I915_VMA_RESOURCE_H__
#include <linux/dma-fence.h>
#include <linux/refcount.h>
/**
* struct i915_vma_resource - Snapshotted unbind information.
* @unbind_fence: Fence to mark unbinding complete. Note that this fence
* is not considered published until unbind is scheduled, and as such it
* is illegal to access this fence before scheduled unbind other than
* for refcounting.
* @lock: The @unbind_fence lock.
* @hold_count: Number of holders blocking the fence from finishing.
* The vma itself is keeping a hold, which is released when unbind
* is scheduled.
*
* The lifetime of a struct i915_vma_resource is from a binding request to
* the actual possible asynchronous unbind has completed.
*/
struct i915_vma_resource {
struct dma_fence unbind_fence;
/* See above for description of the lock. */
spinlock_t lock;
refcount_t hold_count;
};
bool i915_vma_resource_hold(struct i915_vma_resource *vma_res,
bool *lockdep_cookie);
void i915_vma_resource_unhold(struct i915_vma_resource *vma_res,
bool lockdep_cookie);
struct i915_vma_resource *i915_vma_resource_alloc(void);
struct dma_fence *i915_vma_resource_unbind(struct i915_vma_resource *vma_res);
/**
* i915_vma_resource_get - Take a reference on a vma resource
* @vma_res: The vma resource on which to take a reference.
*
* Return: The @vma_res pointer
*/
static inline struct i915_vma_resource
*i915_vma_resource_get(struct i915_vma_resource *vma_res)
{
dma_fence_get(&vma_res->unbind_fence);
return vma_res;
}
/**
* i915_vma_resource_put - Release a reference to a struct i915_vma_resource
* @vma_res: The resource
*/
static inline void i915_vma_resource_put(struct i915_vma_resource *vma_res)
{
dma_fence_put(&vma_res->unbind_fence);
}
#if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
void i915_vma_resource_init(struct i915_vma_resource *vma_res);
#endif
#endif
|