diff options
author | Christian König <christian.koenig@amd.com> | 2016-06-01 09:10:02 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2016-06-02 02:27:41 -0400 |
commit | 76bf0db5543976ef50362db7071da367cb118532 (patch) | |
tree | c8f94084239df5d095c80d87d423d44d95081379 /drivers/dma-buf | |
parent | 3377900791ea48a638fb9b70869258332951271d (diff) |
dma-buf/fence: make fence context 64 bit v2
Fence contexts are created on the fly (for example) by the GPU scheduler used
in the amdgpu driver as a result of an userspace request. Because of this
userspace could in theory force a wrap around of the 32bit context number
if it doesn't behave well.
Avoid this by increasing the context number to 64bits. This way even when
userspace manages to allocate a billion contexts per second it takes more
than 500 years for the context number to wrap around.
v2: fix printf formats as well.
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Acked-by: Sumit Semwal <sumit.semwal@linaro.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1464786612-5010-2-git-send-email-deathsimple@vodafone.de
Diffstat (limited to 'drivers/dma-buf')
-rw-r--r-- | drivers/dma-buf/fence.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/dma-buf/fence.c b/drivers/dma-buf/fence.c index 7b05dbe9b296..4d51f9e83fa8 100644 --- a/drivers/dma-buf/fence.c +++ b/drivers/dma-buf/fence.c | |||
@@ -35,7 +35,7 @@ EXPORT_TRACEPOINT_SYMBOL(fence_emit); | |||
35 | * context or not. One device can have multiple separate contexts, | 35 | * context or not. One device can have multiple separate contexts, |
36 | * and they're used if some engine can run independently of another. | 36 | * and they're used if some engine can run independently of another. |
37 | */ | 37 | */ |
38 | static atomic_t fence_context_counter = ATOMIC_INIT(0); | 38 | static atomic64_t fence_context_counter = ATOMIC64_INIT(0); |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * fence_context_alloc - allocate an array of fence contexts | 41 | * fence_context_alloc - allocate an array of fence contexts |
@@ -44,10 +44,10 @@ static atomic_t fence_context_counter = ATOMIC_INIT(0); | |||
44 | * This function will return the first index of the number of fences allocated. | 44 | * This function will return the first index of the number of fences allocated. |
45 | * The fence context is used for setting fence->context to a unique number. | 45 | * The fence context is used for setting fence->context to a unique number. |
46 | */ | 46 | */ |
47 | unsigned fence_context_alloc(unsigned num) | 47 | u64 fence_context_alloc(unsigned num) |
48 | { | 48 | { |
49 | BUG_ON(!num); | 49 | BUG_ON(!num); |
50 | return atomic_add_return(num, &fence_context_counter) - num; | 50 | return atomic64_add_return(num, &fence_context_counter) - num; |
51 | } | 51 | } |
52 | EXPORT_SYMBOL(fence_context_alloc); | 52 | EXPORT_SYMBOL(fence_context_alloc); |
53 | 53 | ||
@@ -513,7 +513,7 @@ EXPORT_SYMBOL(fence_wait_any_timeout); | |||
513 | */ | 513 | */ |
514 | void | 514 | void |
515 | fence_init(struct fence *fence, const struct fence_ops *ops, | 515 | fence_init(struct fence *fence, const struct fence_ops *ops, |
516 | spinlock_t *lock, unsigned context, unsigned seqno) | 516 | spinlock_t *lock, u64 context, unsigned seqno) |
517 | { | 517 | { |
518 | BUG_ON(!lock); | 518 | BUG_ON(!lock); |
519 | BUG_ON(!ops || !ops->wait || !ops->enable_signaling || | 519 | BUG_ON(!ops || !ops->wait || !ops->enable_signaling || |