2009-06-05 20:42:42 +08:00
|
|
|
/*
|
|
|
|
* Copyright 2009 Jerome Glisse.
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sub license, and/or sell copies of the Software, and to
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
* the following conditions:
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
|
|
|
|
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
|
|
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
|
* USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the
|
|
|
|
* next paragraph) shall be included in all copies or substantial portions
|
|
|
|
* of the Software.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* Authors:
|
|
|
|
* Jerome Glisse <glisse@freedesktop.org>
|
|
|
|
* Dave Airlie
|
|
|
|
*/
|
2019-06-08 16:02:37 +08:00
|
|
|
|
2011-07-27 07:09:06 +08:00
|
|
|
#include <linux/atomic.h>
|
2019-06-08 16:02:37 +08:00
|
|
|
#include <linux/firmware.h>
|
2009-06-05 20:42:42 +08:00
|
|
|
#include <linux/kref.h>
|
2019-06-08 16:02:37 +08:00
|
|
|
#include <linux/sched/signal.h>
|
|
|
|
#include <linux/seq_file.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2019-06-08 16:02:37 +08:00
|
|
|
#include <linux/wait.h>
|
|
|
|
|
2019-06-08 16:02:40 +08:00
|
|
|
#include <drm/drm_debugfs.h>
|
|
|
|
#include <drm/drm_device.h>
|
|
|
|
#include <drm/drm_file.h>
|
2019-06-08 16:02:37 +08:00
|
|
|
|
2009-06-05 20:42:42 +08:00
|
|
|
#include "radeon.h"
|
2019-06-08 16:02:40 +08:00
|
|
|
#include "radeon_reg.h"
|
2010-11-23 09:47:49 +08:00
|
|
|
#include "radeon_trace.h"
|
2009-06-05 20:42:42 +08:00
|
|
|
|
2012-07-18 02:02:37 +08:00
|
|
|
/*
|
|
|
|
* Fences
|
|
|
|
* Fences mark an event in the GPUs pipeline and are used
|
|
|
|
* for GPU/CPU synchronization. When the fence is written,
|
|
|
|
* it is expected that all buffers associated with that fence
|
|
|
|
* are no longer in use by the associated ring on the GPU and
|
|
|
|
* that the the relevant GPU caches have been flushed. Whether
|
|
|
|
* we use a scratch register or memory location depends on the asic
|
|
|
|
* and whether writeback is enabled.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* radeon_fence_write - write a fence value
|
|
|
|
*
|
|
|
|
* @rdev: radeon_device pointer
|
|
|
|
* @seq: sequence number to write
|
|
|
|
* @ring: ring index the fence is associated with
|
|
|
|
*
|
|
|
|
* Writes a fence value to memory or a scratch register (all asics).
|
|
|
|
*/
|
2011-08-26 01:39:48 +08:00
|
|
|
static void radeon_fence_write(struct radeon_device *rdev, u32 seq, int ring)
|
2011-06-14 05:39:06 +08:00
|
|
|
{
|
2012-07-09 16:52:39 +08:00
|
|
|
struct radeon_fence_driver *drv = &rdev->fence_drv[ring];
|
|
|
|
if (likely(rdev->wb.enabled || !drv->scratch_reg)) {
|
2013-06-07 05:51:21 +08:00
|
|
|
if (drv->cpu_addr) {
|
|
|
|
*drv->cpu_addr = cpu_to_le32(seq);
|
|
|
|
}
|
2011-11-21 04:45:34 +08:00
|
|
|
} else {
|
2012-07-09 16:52:39 +08:00
|
|
|
WREG32(drv->scratch_reg, seq);
|
2011-11-21 04:45:34 +08:00
|
|
|
}
|
2011-06-14 05:39:06 +08:00
|
|
|
}
|
|
|
|
|
2012-07-18 02:02:37 +08:00
|
|
|
/**
|
|
|
|
* radeon_fence_read - read a fence value
|
|
|
|
*
|
|
|
|
* @rdev: radeon_device pointer
|
|
|
|
* @ring: ring index the fence is associated with
|
|
|
|
*
|
|
|
|
* Reads a fence value from memory or a scratch register (all asics).
|
|
|
|
* Returns the value of the fence read from memory or register.
|
|
|
|
*/
|
2011-08-26 01:39:48 +08:00
|
|
|
static u32 radeon_fence_read(struct radeon_device *rdev, int ring)
|
2011-06-14 05:39:06 +08:00
|
|
|
{
|
2012-07-09 16:52:39 +08:00
|
|
|
struct radeon_fence_driver *drv = &rdev->fence_drv[ring];
|
2011-08-26 01:39:48 +08:00
|
|
|
u32 seq = 0;
|
2011-06-14 05:39:06 +08:00
|
|
|
|
2012-07-09 16:52:39 +08:00
|
|
|
if (likely(rdev->wb.enabled || !drv->scratch_reg)) {
|
2013-06-07 05:51:21 +08:00
|
|
|
if (drv->cpu_addr) {
|
|
|
|
seq = le32_to_cpu(*drv->cpu_addr);
|
|
|
|
} else {
|
|
|
|
seq = lower_32_bits(atomic64_read(&drv->last_seq));
|
|
|
|
}
|
2011-11-21 04:45:34 +08:00
|
|
|
} else {
|
2012-07-09 16:52:39 +08:00
|
|
|
seq = RREG32(drv->scratch_reg);
|
2011-11-21 04:45:34 +08:00
|
|
|
}
|
2011-06-14 05:39:06 +08:00
|
|
|
return seq;
|
|
|
|
}
|
|
|
|
|
2014-08-27 21:21:58 +08:00
|
|
|
/**
|
|
|
|
* radeon_fence_schedule_check - schedule lockup check
|
|
|
|
*
|
|
|
|
* @rdev: radeon_device pointer
|
|
|
|
* @ring: ring index we should work with
|
|
|
|
*
|
|
|
|
* Queues a delayed work item to check for lockups.
|
|
|
|
*/
|
|
|
|
static void radeon_fence_schedule_check(struct radeon_device *rdev, int ring)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Do not reset the timer here with mod_delayed_work,
|
|
|
|
* this can livelock in an interaction with TTM delayed destroy.
|
|
|
|
*/
|
|
|
|
queue_delayed_work(system_power_efficient_wq,
|
|
|
|
&rdev->fence_drv[ring].lockup_work,
|
|
|
|
RADEON_FENCE_JIFFIES_TIMEOUT);
|
|
|
|
}
|
|
|
|
|
2012-07-18 02:02:37 +08:00
|
|
|
/**
|
|
|
|
* radeon_fence_emit - emit a fence on the requested ring
|
|
|
|
*
|
|
|
|
* @rdev: radeon_device pointer
|
|
|
|
* @fence: radeon fence object
|
|
|
|
* @ring: ring index the fence is associated with
|
|
|
|
*
|
|
|
|
* Emits a fence command on the requested ring (all asics).
|
|
|
|
* Returns 0 on success, -ENOMEM on failure.
|
|
|
|
*/
|
2012-05-08 20:24:01 +08:00
|
|
|
int radeon_fence_emit(struct radeon_device *rdev,
|
|
|
|
struct radeon_fence **fence,
|
|
|
|
int ring)
|
2009-06-05 20:42:42 +08:00
|
|
|
{
|
2015-12-13 00:42:25 +08:00
|
|
|
u64 seq;
|
2014-01-09 18:03:12 +08:00
|
|
|
|
2012-05-09 21:34:47 +08:00
|
|
|
/* we are protected by the ring emission mutex */
|
2012-05-08 20:24:01 +08:00
|
|
|
*fence = kmalloc(sizeof(struct radeon_fence), GFP_KERNEL);
|
|
|
|
if ((*fence) == NULL) {
|
|
|
|
return -ENOMEM;
|
2009-06-05 20:42:42 +08:00
|
|
|
}
|
2012-05-08 20:24:01 +08:00
|
|
|
(*fence)->rdev = rdev;
|
2015-12-13 00:42:25 +08:00
|
|
|
(*fence)->seq = seq = ++rdev->fence_drv[ring].sync_seq[ring];
|
2012-05-08 20:24:01 +08:00
|
|
|
(*fence)->ring = ring;
|
2014-11-19 21:01:24 +08:00
|
|
|
(*fence)->is_vm_update = false;
|
2016-10-25 20:00:45 +08:00
|
|
|
dma_fence_init(&(*fence)->base, &radeon_fence_ops,
|
|
|
|
&rdev->fence_queue.lock,
|
|
|
|
rdev->fence_context + ring,
|
|
|
|
seq);
|
2012-05-08 20:24:01 +08:00
|
|
|
radeon_fence_ring_emit(rdev, ring, *fence);
|
2014-01-23 21:24:17 +08:00
|
|
|
trace_radeon_fence_emit(rdev->ddev, ring, (*fence)->seq);
|
2014-08-27 21:21:58 +08:00
|
|
|
radeon_fence_schedule_check(rdev, ring);
|
2009-06-05 20:42:42 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-01-09 18:03:12 +08:00
|
|
|
/**
|
|
|
|
* radeon_fence_check_signaled - callback from fence_queue
|
|
|
|
*
|
|
|
|
* this function is called with fence_queue lock held, which is also used
|
|
|
|
* for the fence locking itself, so unlocked variants are used for
|
|
|
|
* fence_signal, and remove_wait_queue.
|
|
|
|
*/
|
2017-06-20 18:06:13 +08:00
|
|
|
static int radeon_fence_check_signaled(wait_queue_entry_t *wait, unsigned mode, int flags, void *key)
|
2014-01-09 18:03:12 +08:00
|
|
|
{
|
|
|
|
struct radeon_fence *fence;
|
|
|
|
u64 seq;
|
|
|
|
|
|
|
|
fence = container_of(wait, struct radeon_fence, fence_wake);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We cannot use radeon_fence_process here because we're already
|
|
|
|
* in the waitqueue, in a call from wake_up_all.
|
|
|
|
*/
|
|
|
|
seq = atomic64_read(&fence->rdev->fence_drv[fence->ring].last_seq);
|
|
|
|
if (seq >= fence->seq) {
|
2016-10-25 20:00:45 +08:00
|
|
|
int ret = dma_fence_signal_locked(&fence->base);
|
2014-01-09 18:03:12 +08:00
|
|
|
|
|
|
|
if (!ret)
|
2016-10-25 20:00:45 +08:00
|
|
|
DMA_FENCE_TRACE(&fence->base, "signaled from irq context\n");
|
2014-01-09 18:03:12 +08:00
|
|
|
else
|
2016-10-25 20:00:45 +08:00
|
|
|
DMA_FENCE_TRACE(&fence->base, "was already signaled\n");
|
2014-01-09 18:03:12 +08:00
|
|
|
|
|
|
|
radeon_irq_kms_sw_irq_put(fence->rdev, fence->ring);
|
|
|
|
__remove_wait_queue(&fence->rdev->fence_queue, &fence->fence_wake);
|
2016-10-25 20:00:45 +08:00
|
|
|
dma_fence_put(&fence->base);
|
2014-01-09 18:03:12 +08:00
|
|
|
} else
|
2016-10-25 20:00:45 +08:00
|
|
|
DMA_FENCE_TRACE(&fence->base, "pending\n");
|
2014-01-09 18:03:12 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-07-18 02:02:37 +08:00
|
|
|
/**
|
2014-08-27 21:21:58 +08:00
|
|
|
* radeon_fence_activity - check for fence activity
|
2012-07-18 02:02:37 +08:00
|
|
|
*
|
|
|
|
* @rdev: radeon_device pointer
|
|
|
|
* @ring: ring index the fence is associated with
|
|
|
|
*
|
2014-08-27 21:21:58 +08:00
|
|
|
* Checks the current fence value and calculates the last
|
|
|
|
* signalled fence value. Returns true if activity occured
|
|
|
|
* on the ring, and the fence_queue should be waken up.
|
2012-07-18 02:02:37 +08:00
|
|
|
*/
|
2014-08-27 21:21:58 +08:00
|
|
|
static bool radeon_fence_activity(struct radeon_device *rdev, int ring)
|
2009-06-05 20:42:42 +08:00
|
|
|
{
|
2012-09-13 16:33:47 +08:00
|
|
|
uint64_t seq, last_seq, last_emitted;
|
2012-05-09 21:34:46 +08:00
|
|
|
unsigned count_loop = 0;
|
2009-06-05 20:42:42 +08:00
|
|
|
bool wake = false;
|
|
|
|
|
2012-05-09 21:34:46 +08:00
|
|
|
/* Note there is a scenario here for an infinite loop but it's
|
|
|
|
* very unlikely to happen. For it to happen, the current polling
|
|
|
|
* process need to be interrupted by another process and another
|
|
|
|
* process needs to update the last_seq btw the atomic read and
|
|
|
|
* xchg of the current process.
|
|
|
|
*
|
|
|
|
* More over for this to go in infinite loop there need to be
|
|
|
|
* continuously new fence signaled ie radeon_fence_read needs
|
|
|
|
* to return a different value each time for both the currently
|
|
|
|
* polling process and the other process that xchg the last_seq
|
|
|
|
* btw atomic read and xchg of the current process. And the
|
|
|
|
* value the other process set as last seq must be higher than
|
|
|
|
* the seq value we just read. Which means that current process
|
|
|
|
* need to be interrupted after radeon_fence_read and before
|
|
|
|
* atomic xchg.
|
|
|
|
*
|
|
|
|
* To be even more safe we count the number of time we loop and
|
|
|
|
* we bail after 10 loop just accepting the fact that we might
|
|
|
|
* have temporarly set the last_seq not to the true real last
|
|
|
|
* seq but to an older one.
|
|
|
|
*/
|
|
|
|
last_seq = atomic64_read(&rdev->fence_drv[ring].last_seq);
|
|
|
|
do {
|
2012-09-13 16:33:47 +08:00
|
|
|
last_emitted = rdev->fence_drv[ring].sync_seq[ring];
|
2012-05-09 21:34:46 +08:00
|
|
|
seq = radeon_fence_read(rdev, ring);
|
|
|
|
seq |= last_seq & 0xffffffff00000000LL;
|
|
|
|
if (seq < last_seq) {
|
2012-09-13 16:33:47 +08:00
|
|
|
seq &= 0xffffffff;
|
|
|
|
seq |= last_emitted & 0xffffffff00000000LL;
|
2012-05-09 21:34:46 +08:00
|
|
|
}
|
2012-05-02 21:11:13 +08:00
|
|
|
|
2012-09-13 16:33:47 +08:00
|
|
|
if (seq <= last_seq || seq > last_emitted) {
|
2012-05-09 21:34:47 +08:00
|
|
|
break;
|
2012-05-09 21:34:46 +08:00
|
|
|
}
|
|
|
|
/* If we loop over we don't want to return without
|
|
|
|
* checking if a fence is signaled as it means that the
|
|
|
|
* seq we just read is different from the previous on.
|
|
|
|
*/
|
|
|
|
wake = true;
|
2012-05-09 21:34:47 +08:00
|
|
|
last_seq = seq;
|
2012-05-09 21:34:46 +08:00
|
|
|
if ((count_loop++) > 10) {
|
|
|
|
/* We looped over too many time leave with the
|
|
|
|
* fact that we might have set an older fence
|
|
|
|
* seq then the current real last seq as signaled
|
|
|
|
* by the hw.
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (atomic64_xchg(&rdev->fence_drv[ring].last_seq, seq) > seq);
|
|
|
|
|
2014-08-27 21:21:58 +08:00
|
|
|
if (seq < last_emitted)
|
|
|
|
radeon_fence_schedule_check(rdev, ring);
|
|
|
|
|
|
|
|
return wake;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* radeon_fence_check_lockup - check for hardware lockup
|
|
|
|
*
|
|
|
|
* @work: delayed work item
|
|
|
|
*
|
|
|
|
* Checks for fence activity and if there is none probe
|
|
|
|
* the hardware if a lockup occured.
|
|
|
|
*/
|
|
|
|
static void radeon_fence_check_lockup(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct radeon_fence_driver *fence_drv;
|
|
|
|
struct radeon_device *rdev;
|
|
|
|
int ring;
|
|
|
|
|
|
|
|
fence_drv = container_of(work, struct radeon_fence_driver,
|
|
|
|
lockup_work.work);
|
|
|
|
rdev = fence_drv->rdev;
|
|
|
|
ring = fence_drv - &rdev->fence_drv[0];
|
|
|
|
|
|
|
|
if (!down_read_trylock(&rdev->exclusive_lock)) {
|
|
|
|
/* just reschedule the check if a reset is going on */
|
|
|
|
radeon_fence_schedule_check(rdev, ring);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-01-09 18:03:12 +08:00
|
|
|
if (fence_drv->delayed_irq && rdev->ddev->irq_enabled) {
|
|
|
|
unsigned long irqflags;
|
|
|
|
|
|
|
|
fence_drv->delayed_irq = false;
|
|
|
|
spin_lock_irqsave(&rdev->irq.lock, irqflags);
|
|
|
|
radeon_irq_set(rdev);
|
|
|
|
spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
|
|
|
|
}
|
|
|
|
|
2014-08-27 21:21:58 +08:00
|
|
|
if (radeon_fence_activity(rdev, ring))
|
|
|
|
wake_up_all(&rdev->fence_queue);
|
|
|
|
|
|
|
|
else if (radeon_ring_is_lockup(rdev, ring, &rdev->ring[ring])) {
|
|
|
|
|
|
|
|
/* good news we believe it's a lockup */
|
|
|
|
dev_warn(rdev->dev, "GPU lockup (current fence id "
|
|
|
|
"0x%016llx last fence id 0x%016llx on ring %d)\n",
|
|
|
|
(uint64_t)atomic64_read(&fence_drv->last_seq),
|
|
|
|
fence_drv->sync_seq[ring], ring);
|
|
|
|
|
|
|
|
/* remember that we need an reset */
|
|
|
|
rdev->needs_reset = true;
|
|
|
|
wake_up_all(&rdev->fence_queue);
|
|
|
|
}
|
|
|
|
up_read(&rdev->exclusive_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* radeon_fence_process - process a fence
|
|
|
|
*
|
|
|
|
* @rdev: radeon_device pointer
|
|
|
|
* @ring: ring index the fence is associated with
|
|
|
|
*
|
|
|
|
* Checks the current fence value and wakes the fence queue
|
|
|
|
* if the sequence number has increased (all asics).
|
|
|
|
*/
|
|
|
|
void radeon_fence_process(struct radeon_device *rdev, int ring)
|
|
|
|
{
|
|
|
|
if (radeon_fence_activity(rdev, ring))
|
2012-05-09 21:34:55 +08:00
|
|
|
wake_up_all(&rdev->fence_queue);
|
2009-06-05 20:42:42 +08:00
|
|
|
}
|
|
|
|
|
2012-07-18 02:02:37 +08:00
|
|
|
/**
|
2013-10-30 03:14:47 +08:00
|
|
|
* radeon_fence_seq_signaled - check if a fence sequence number has signaled
|
2012-07-18 02:02:37 +08:00
|
|
|
*
|
|
|
|
* @rdev: radeon device pointer
|
|
|
|
* @seq: sequence number
|
|
|
|
* @ring: ring index the fence is associated with
|
|
|
|
*
|
2013-10-30 03:14:47 +08:00
|
|
|
* Check if the last signaled fence sequnce number is >= the requested
|
2012-07-18 02:02:37 +08:00
|
|
|
* sequence number (all asics).
|
|
|
|
* Returns true if the fence has signaled (current fence value
|
|
|
|
* is >= requested value) or false if it has not (current fence
|
|
|
|
* value is < the requested value. Helper function for
|
|
|
|
* radeon_fence_signaled().
|
|
|
|
*/
|
2012-05-09 21:34:47 +08:00
|
|
|
static bool radeon_fence_seq_signaled(struct radeon_device *rdev,
|
|
|
|
u64 seq, unsigned ring)
|
2009-06-05 20:42:42 +08:00
|
|
|
{
|
2012-05-09 21:34:47 +08:00
|
|
|
if (atomic64_read(&rdev->fence_drv[ring].last_seq) >= seq) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
/* poll new last sequence at least once */
|
|
|
|
radeon_fence_process(rdev, ring);
|
|
|
|
if (atomic64_read(&rdev->fence_drv[ring].last_seq) >= seq) {
|
2009-06-05 20:42:42 +08:00
|
|
|
return true;
|
2012-05-09 21:34:47 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2009-12-30 09:20:05 +08:00
|
|
|
|
2016-10-25 20:00:45 +08:00
|
|
|
static bool radeon_fence_is_signaled(struct dma_fence *f)
|
2014-01-09 18:03:12 +08:00
|
|
|
{
|
|
|
|
struct radeon_fence *fence = to_radeon_fence(f);
|
|
|
|
struct radeon_device *rdev = fence->rdev;
|
|
|
|
unsigned ring = fence->ring;
|
|
|
|
u64 seq = fence->seq;
|
|
|
|
|
|
|
|
if (atomic64_read(&rdev->fence_drv[ring].last_seq) >= seq) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (down_read_trylock(&rdev->exclusive_lock)) {
|
|
|
|
radeon_fence_process(rdev, ring);
|
|
|
|
up_read(&rdev->exclusive_lock);
|
|
|
|
|
|
|
|
if (atomic64_read(&rdev->fence_drv[ring].last_seq) >= seq) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* radeon_fence_enable_signaling - enable signalling on fence
|
|
|
|
* @fence: fence
|
|
|
|
*
|
|
|
|
* This function is called with fence_queue lock held, and adds a callback
|
|
|
|
* to fence_queue that checks if this fence is signaled, and if so it
|
|
|
|
* signals the fence and removes itself.
|
|
|
|
*/
|
2016-10-25 20:00:45 +08:00
|
|
|
static bool radeon_fence_enable_signaling(struct dma_fence *f)
|
2014-01-09 18:03:12 +08:00
|
|
|
{
|
|
|
|
struct radeon_fence *fence = to_radeon_fence(f);
|
|
|
|
struct radeon_device *rdev = fence->rdev;
|
|
|
|
|
|
|
|
if (atomic64_read(&rdev->fence_drv[fence->ring].last_seq) >= fence->seq)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (down_read_trylock(&rdev->exclusive_lock)) {
|
|
|
|
radeon_irq_kms_sw_irq_get(rdev, fence->ring);
|
|
|
|
|
|
|
|
if (radeon_fence_activity(rdev, fence->ring))
|
|
|
|
wake_up_all_locked(&rdev->fence_queue);
|
|
|
|
|
|
|
|
/* did fence get signaled after we enabled the sw irq? */
|
|
|
|
if (atomic64_read(&rdev->fence_drv[fence->ring].last_seq) >= fence->seq) {
|
|
|
|
radeon_irq_kms_sw_irq_put(rdev, fence->ring);
|
|
|
|
up_read(&rdev->exclusive_lock);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
up_read(&rdev->exclusive_lock);
|
|
|
|
} else {
|
|
|
|
/* we're probably in a lockup, lets not fiddle too much */
|
|
|
|
if (radeon_irq_kms_sw_irq_get_delayed(rdev, fence->ring))
|
|
|
|
rdev->fence_drv[fence->ring].delayed_irq = true;
|
|
|
|
radeon_fence_schedule_check(rdev, fence->ring);
|
|
|
|
}
|
|
|
|
|
|
|
|
fence->fence_wake.flags = 0;
|
|
|
|
fence->fence_wake.private = NULL;
|
|
|
|
fence->fence_wake.func = radeon_fence_check_signaled;
|
|
|
|
__add_wait_queue(&rdev->fence_queue, &fence->fence_wake);
|
2016-10-25 20:00:45 +08:00
|
|
|
dma_fence_get(f);
|
2014-01-09 18:03:12 +08:00
|
|
|
|
2016-10-25 20:00:45 +08:00
|
|
|
DMA_FENCE_TRACE(&fence->base, "armed on ring %i!\n", fence->ring);
|
2014-01-09 18:03:12 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-18 02:02:37 +08:00
|
|
|
/**
|
|
|
|
* radeon_fence_signaled - check if a fence has signaled
|
|
|
|
*
|
|
|
|
* @fence: radeon fence object
|
|
|
|
*
|
|
|
|
* Check if the requested fence has signaled (all asics).
|
|
|
|
* Returns true if the fence has signaled or false if it has not.
|
|
|
|
*/
|
2012-05-09 21:34:47 +08:00
|
|
|
bool radeon_fence_signaled(struct radeon_fence *fence)
|
|
|
|
{
|
2014-08-27 21:22:00 +08:00
|
|
|
if (!fence)
|
2012-05-09 21:34:47 +08:00
|
|
|
return true;
|
2014-01-09 18:03:12 +08:00
|
|
|
|
|
|
|
if (radeon_fence_seq_signaled(fence->rdev, fence->seq, fence->ring)) {
|
|
|
|
int ret;
|
|
|
|
|
2016-10-25 20:00:45 +08:00
|
|
|
ret = dma_fence_signal(&fence->base);
|
2014-01-09 18:03:12 +08:00
|
|
|
if (!ret)
|
2016-10-25 20:00:45 +08:00
|
|
|
DMA_FENCE_TRACE(&fence->base, "signaled from radeon_fence_signaled\n");
|
2012-05-09 21:34:47 +08:00
|
|
|
return true;
|
2014-01-09 18:03:12 +08:00
|
|
|
}
|
2012-05-09 21:34:47 +08:00
|
|
|
return false;
|
2009-06-05 20:42:42 +08:00
|
|
|
}
|
|
|
|
|
2012-07-18 02:02:37 +08:00
|
|
|
/**
|
2013-10-30 03:14:47 +08:00
|
|
|
* radeon_fence_any_seq_signaled - check if any sequence number is signaled
|
2012-07-18 02:02:37 +08:00
|
|
|
*
|
|
|
|
* @rdev: radeon device pointer
|
2013-10-30 03:14:47 +08:00
|
|
|
* @seq: sequence numbers
|
|
|
|
*
|
|
|
|
* Check if the last signaled fence sequnce number is >= the requested
|
|
|
|
* sequence number (all asics).
|
|
|
|
* Returns true if any has signaled (current value is >= requested value)
|
|
|
|
* or false if it has not. Helper function for radeon_fence_wait_seq.
|
|
|
|
*/
|
|
|
|
static bool radeon_fence_any_seq_signaled(struct radeon_device *rdev, u64 *seq)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
for (i = 0; i < RADEON_NUM_RINGS; ++i) {
|
|
|
|
if (seq[i] && radeon_fence_seq_signaled(rdev, seq[i], i))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-08-27 21:21:59 +08:00
|
|
|
* radeon_fence_wait_seq_timeout - wait for a specific sequence numbers
|
2013-10-30 03:14:47 +08:00
|
|
|
*
|
|
|
|
* @rdev: radeon device pointer
|
|
|
|
* @target_seq: sequence number(s) we want to wait for
|
2012-07-18 02:02:37 +08:00
|
|
|
* @intr: use interruptable sleep
|
2014-08-27 21:21:59 +08:00
|
|
|
* @timeout: maximum time to wait, or MAX_SCHEDULE_TIMEOUT for infinite wait
|
2012-07-18 02:02:37 +08:00
|
|
|
*
|
2013-10-30 03:14:47 +08:00
|
|
|
* Wait for the requested sequence number(s) to be written by any ring
|
|
|
|
* (all asics). Sequnce number array is indexed by ring id.
|
2012-07-18 02:02:37 +08:00
|
|
|
* @intr selects whether to use interruptable (true) or non-interruptable
|
|
|
|
* (false) sleep when waiting for the sequence number. Helper function
|
2013-10-30 03:14:47 +08:00
|
|
|
* for radeon_fence_wait_*().
|
2014-08-27 21:21:59 +08:00
|
|
|
* Returns remaining time if the sequence number has passed, 0 when
|
|
|
|
* the wait timeout, or an error for all other cases.
|
2013-10-30 03:14:47 +08:00
|
|
|
* -EDEADLK is returned when a GPU lockup has been detected.
|
2012-07-18 02:02:37 +08:00
|
|
|
*/
|
2014-08-27 21:21:59 +08:00
|
|
|
static long radeon_fence_wait_seq_timeout(struct radeon_device *rdev,
|
|
|
|
u64 *target_seq, bool intr,
|
|
|
|
long timeout)
|
2009-06-05 20:42:42 +08:00
|
|
|
{
|
2014-08-27 21:21:58 +08:00
|
|
|
long r;
|
|
|
|
int i;
|
2013-10-30 03:14:47 +08:00
|
|
|
|
2014-08-27 21:21:58 +08:00
|
|
|
if (radeon_fence_any_seq_signaled(rdev, target_seq))
|
2014-08-27 21:21:59 +08:00
|
|
|
return timeout;
|
2009-06-05 20:42:42 +08:00
|
|
|
|
2014-08-27 21:21:58 +08:00
|
|
|
/* enable IRQs and tracing */
|
|
|
|
for (i = 0; i < RADEON_NUM_RINGS; ++i) {
|
|
|
|
if (!target_seq[i])
|
|
|
|
continue;
|
2012-05-02 21:11:13 +08:00
|
|
|
|
2014-08-27 21:21:58 +08:00
|
|
|
trace_radeon_fence_wait_begin(rdev->ddev, i, target_seq[i]);
|
|
|
|
radeon_irq_kms_sw_irq_get(rdev, i);
|
|
|
|
}
|
2012-05-02 21:11:13 +08:00
|
|
|
|
2014-08-27 21:21:58 +08:00
|
|
|
if (intr) {
|
|
|
|
r = wait_event_interruptible_timeout(rdev->fence_queue, (
|
|
|
|
radeon_fence_any_seq_signaled(rdev, target_seq)
|
2014-08-27 21:21:59 +08:00
|
|
|
|| rdev->needs_reset), timeout);
|
2014-08-27 21:21:58 +08:00
|
|
|
} else {
|
|
|
|
r = wait_event_timeout(rdev->fence_queue, (
|
|
|
|
radeon_fence_any_seq_signaled(rdev, target_seq)
|
2014-08-27 21:21:59 +08:00
|
|
|
|| rdev->needs_reset), timeout);
|
2014-08-27 21:21:58 +08:00
|
|
|
}
|
2013-10-30 03:14:47 +08:00
|
|
|
|
2014-08-27 21:21:58 +08:00
|
|
|
if (rdev->needs_reset)
|
|
|
|
r = -EDEADLK;
|
2013-10-30 03:14:47 +08:00
|
|
|
|
2014-08-27 21:21:58 +08:00
|
|
|
for (i = 0; i < RADEON_NUM_RINGS; ++i) {
|
|
|
|
if (!target_seq[i])
|
|
|
|
continue;
|
2012-05-02 21:11:10 +08:00
|
|
|
|
2014-08-27 21:21:58 +08:00
|
|
|
radeon_irq_kms_sw_irq_put(rdev, i);
|
|
|
|
trace_radeon_fence_wait_end(rdev->ddev, i, target_seq[i]);
|
2009-06-05 20:42:42 +08:00
|
|
|
}
|
2014-08-27 21:21:58 +08:00
|
|
|
|
2014-08-27 21:21:59 +08:00
|
|
|
return r;
|
2009-06-05 20:42:42 +08:00
|
|
|
}
|
|
|
|
|
2012-07-18 02:02:37 +08:00
|
|
|
/**
|
2016-02-08 05:51:12 +08:00
|
|
|
* radeon_fence_wait_timeout - wait for a fence to signal with timeout
|
2012-07-18 02:02:37 +08:00
|
|
|
*
|
|
|
|
* @fence: radeon fence object
|
2014-08-27 21:21:59 +08:00
|
|
|
* @intr: use interruptible sleep
|
2012-07-18 02:02:37 +08:00
|
|
|
*
|
|
|
|
* Wait for the requested fence to signal (all asics).
|
|
|
|
* @intr selects whether to use interruptable (true) or non-interruptable
|
|
|
|
* (false) sleep when waiting for the fence.
|
2016-02-08 05:51:12 +08:00
|
|
|
* @timeout: maximum time to wait, or MAX_SCHEDULE_TIMEOUT for infinite wait
|
|
|
|
* Returns remaining time if the sequence number has passed, 0 when
|
|
|
|
* the wait timeout, or an error for all other cases.
|
2012-07-18 02:02:37 +08:00
|
|
|
*/
|
2016-02-08 05:51:12 +08:00
|
|
|
long radeon_fence_wait_timeout(struct radeon_fence *fence, bool intr, long timeout)
|
2009-06-05 20:42:42 +08:00
|
|
|
{
|
2013-10-30 03:14:47 +08:00
|
|
|
uint64_t seq[RADEON_NUM_RINGS] = {};
|
2014-08-27 21:21:59 +08:00
|
|
|
long r;
|
2016-02-08 05:51:12 +08:00
|
|
|
int r_sig;
|
2009-06-05 20:42:42 +08:00
|
|
|
|
2014-09-25 18:39:38 +08:00
|
|
|
/*
|
|
|
|
* This function should not be called on !radeon fences.
|
|
|
|
* If this is the case, it would mean this function can
|
|
|
|
* also be called on radeon fences belonging to another card.
|
|
|
|
* exclusive_lock is not held in that case.
|
|
|
|
*/
|
|
|
|
if (WARN_ON_ONCE(!to_radeon_fence(&fence->base)))
|
2016-10-25 20:00:45 +08:00
|
|
|
return dma_fence_wait(&fence->base, intr);
|
2014-09-25 18:39:38 +08:00
|
|
|
|
2013-10-30 03:14:47 +08:00
|
|
|
seq[fence->ring] = fence->seq;
|
2016-02-08 05:51:12 +08:00
|
|
|
r = radeon_fence_wait_seq_timeout(fence->rdev, seq, intr, timeout);
|
|
|
|
if (r <= 0) {
|
2013-10-30 03:14:47 +08:00
|
|
|
return r;
|
2014-08-27 21:21:59 +08:00
|
|
|
}
|
2012-05-09 21:34:55 +08:00
|
|
|
|
2016-10-25 20:00:45 +08:00
|
|
|
r_sig = dma_fence_signal(&fence->base);
|
2016-02-08 05:51:12 +08:00
|
|
|
if (!r_sig)
|
2016-10-25 20:00:45 +08:00
|
|
|
DMA_FENCE_TRACE(&fence->base, "signaled from fence_wait\n");
|
2016-02-08 05:51:12 +08:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* radeon_fence_wait - wait for a fence to signal
|
|
|
|
*
|
|
|
|
* @fence: radeon fence object
|
|
|
|
* @intr: use interruptible sleep
|
|
|
|
*
|
|
|
|
* Wait for the requested fence to signal (all asics).
|
|
|
|
* @intr selects whether to use interruptable (true) or non-interruptable
|
|
|
|
* (false) sleep when waiting for the fence.
|
|
|
|
* Returns 0 if the fence has passed, error for all other cases.
|
|
|
|
*/
|
|
|
|
int radeon_fence_wait(struct radeon_fence *fence, bool intr)
|
|
|
|
{
|
|
|
|
long r = radeon_fence_wait_timeout(fence, intr, MAX_SCHEDULE_TIMEOUT);
|
|
|
|
if (r > 0) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return r;
|
|
|
|
}
|
2012-05-09 21:34:55 +08:00
|
|
|
}
|
|
|
|
|
2012-07-18 02:02:37 +08:00
|
|
|
/**
|
|
|
|
* radeon_fence_wait_any - wait for a fence to signal on any ring
|
|
|
|
*
|
|
|
|
* @rdev: radeon device pointer
|
|
|
|
* @fences: radeon fence object(s)
|
|
|
|
* @intr: use interruptable sleep
|
|
|
|
*
|
|
|
|
* Wait for any requested fence to signal (all asics). Fence
|
|
|
|
* array is indexed by ring id. @intr selects whether to use
|
|
|
|
* interruptable (true) or non-interruptable (false) sleep when
|
|
|
|
* waiting for the fences. Used by the suballocator.
|
|
|
|
* Returns 0 if any fence has passed, error for all other cases.
|
|
|
|
*/
|
2012-05-09 21:34:55 +08:00
|
|
|
int radeon_fence_wait_any(struct radeon_device *rdev,
|
|
|
|
struct radeon_fence **fences,
|
|
|
|
bool intr)
|
|
|
|
{
|
|
|
|
uint64_t seq[RADEON_NUM_RINGS];
|
2013-10-30 03:14:47 +08:00
|
|
|
unsigned i, num_rings = 0;
|
2014-08-27 21:21:59 +08:00
|
|
|
long r;
|
2012-05-09 21:34:55 +08:00
|
|
|
|
|
|
|
for (i = 0; i < RADEON_NUM_RINGS; ++i) {
|
|
|
|
seq[i] = 0;
|
|
|
|
|
|
|
|
if (!fences[i]) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2012-05-08 20:24:01 +08:00
|
|
|
seq[i] = fences[i]->seq;
|
2013-10-30 03:14:47 +08:00
|
|
|
++num_rings;
|
2012-05-09 21:34:55 +08:00
|
|
|
}
|
|
|
|
|
2013-10-30 03:14:47 +08:00
|
|
|
/* nothing to wait for ? */
|
|
|
|
if (num_rings == 0)
|
|
|
|
return -ENOENT;
|
|
|
|
|
2014-08-27 21:21:59 +08:00
|
|
|
r = radeon_fence_wait_seq_timeout(rdev, seq, intr, MAX_SCHEDULE_TIMEOUT);
|
|
|
|
if (r < 0) {
|
2012-05-09 21:34:55 +08:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-11-12 19:58:05 +08:00
|
|
|
/**
|
2014-02-18 22:58:31 +08:00
|
|
|
* radeon_fence_wait_next - wait for the next fence to signal
|
2012-07-18 02:02:37 +08:00
|
|
|
*
|
|
|
|
* @rdev: radeon device pointer
|
|
|
|
* @ring: ring index the fence is associated with
|
|
|
|
*
|
|
|
|
* Wait for the next fence on the requested ring to signal (all asics).
|
|
|
|
* Returns 0 if the next fence has passed, error for all other cases.
|
|
|
|
* Caller must hold ring lock.
|
|
|
|
*/
|
2014-02-18 22:58:31 +08:00
|
|
|
int radeon_fence_wait_next(struct radeon_device *rdev, int ring)
|
2009-06-05 20:42:42 +08:00
|
|
|
{
|
2013-10-30 03:14:47 +08:00
|
|
|
uint64_t seq[RADEON_NUM_RINGS] = {};
|
2014-08-27 21:21:59 +08:00
|
|
|
long r;
|
2009-06-05 20:42:42 +08:00
|
|
|
|
2013-10-30 03:14:47 +08:00
|
|
|
seq[ring] = atomic64_read(&rdev->fence_drv[ring].last_seq) + 1ULL;
|
|
|
|
if (seq[ring] >= rdev->fence_drv[ring].sync_seq[ring]) {
|
2012-05-09 21:34:48 +08:00
|
|
|
/* nothing to wait for, last_seq is
|
|
|
|
already the last emited fence */
|
|
|
|
return -ENOENT;
|
2009-06-05 20:42:42 +08:00
|
|
|
}
|
2014-08-27 21:21:59 +08:00
|
|
|
r = radeon_fence_wait_seq_timeout(rdev, seq, false, MAX_SCHEDULE_TIMEOUT);
|
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
return 0;
|
2012-05-09 21:34:47 +08:00
|
|
|
}
|
|
|
|
|
2012-07-18 02:02:37 +08:00
|
|
|
/**
|
2014-02-18 22:58:31 +08:00
|
|
|
* radeon_fence_wait_empty - wait for all fences to signal
|
2012-07-18 02:02:37 +08:00
|
|
|
*
|
|
|
|
* @rdev: radeon device pointer
|
|
|
|
* @ring: ring index the fence is associated with
|
|
|
|
*
|
|
|
|
* Wait for all fences on the requested ring to signal (all asics).
|
|
|
|
* Returns 0 if the fences have passed, error for all other cases.
|
|
|
|
* Caller must hold ring lock.
|
|
|
|
*/
|
2014-02-18 22:58:31 +08:00
|
|
|
int radeon_fence_wait_empty(struct radeon_device *rdev, int ring)
|
2012-05-09 21:34:47 +08:00
|
|
|
{
|
2013-10-30 03:14:47 +08:00
|
|
|
uint64_t seq[RADEON_NUM_RINGS] = {};
|
2014-08-27 21:21:59 +08:00
|
|
|
long r;
|
2012-06-29 17:33:12 +08:00
|
|
|
|
2013-10-30 03:14:47 +08:00
|
|
|
seq[ring] = rdev->fence_drv[ring].sync_seq[ring];
|
2013-11-05 21:09:54 +08:00
|
|
|
if (!seq[ring])
|
|
|
|
return 0;
|
|
|
|
|
2014-08-27 21:21:59 +08:00
|
|
|
r = radeon_fence_wait_seq_timeout(rdev, seq, false, MAX_SCHEDULE_TIMEOUT);
|
|
|
|
if (r < 0) {
|
2013-10-30 03:14:47 +08:00
|
|
|
if (r == -EDEADLK)
|
2012-12-18 00:04:32 +08:00
|
|
|
return -EDEADLK;
|
2013-10-30 03:14:47 +08:00
|
|
|
|
2014-08-27 21:21:59 +08:00
|
|
|
dev_err(rdev->dev, "error waiting for ring[%d] to become idle (%ld)\n",
|
2012-12-18 00:04:32 +08:00
|
|
|
ring, r);
|
2012-06-29 17:33:12 +08:00
|
|
|
}
|
2012-12-18 00:04:32 +08:00
|
|
|
return 0;
|
2009-06-05 20:42:42 +08:00
|
|
|
}
|
|
|
|
|
2012-07-18 02:02:37 +08:00
|
|
|
/**
|
|
|
|
* radeon_fence_ref - take a ref on a fence
|
|
|
|
*
|
|
|
|
* @fence: radeon fence object
|
|
|
|
*
|
|
|
|
* Take a reference on a fence (all asics).
|
|
|
|
* Returns the fence.
|
|
|
|
*/
|
2009-06-05 20:42:42 +08:00
|
|
|
struct radeon_fence *radeon_fence_ref(struct radeon_fence *fence)
|
|
|
|
{
|
2016-10-25 20:00:45 +08:00
|
|
|
dma_fence_get(&fence->base);
|
2009-06-05 20:42:42 +08:00
|
|
|
return fence;
|
|
|
|
}
|
|
|
|
|
2012-07-18 02:02:37 +08:00
|
|
|
/**
|
|
|
|
* radeon_fence_unref - remove a ref on a fence
|
|
|
|
*
|
|
|
|
* @fence: radeon fence object
|
|
|
|
*
|
|
|
|
* Remove a reference on a fence (all asics).
|
|
|
|
*/
|
2009-06-05 20:42:42 +08:00
|
|
|
void radeon_fence_unref(struct radeon_fence **fence)
|
|
|
|
{
|
|
|
|
struct radeon_fence *tmp = *fence;
|
|
|
|
|
|
|
|
*fence = NULL;
|
|
|
|
if (tmp) {
|
2016-10-25 20:00:45 +08:00
|
|
|
dma_fence_put(&tmp->base);
|
2009-06-05 20:42:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-18 02:02:37 +08:00
|
|
|
/**
|
|
|
|
* radeon_fence_count_emitted - get the count of emitted fences
|
|
|
|
*
|
|
|
|
* @rdev: radeon device pointer
|
|
|
|
* @ring: ring index the fence is associated with
|
|
|
|
*
|
|
|
|
* Get the number of fences emitted on the requested ring (all asics).
|
|
|
|
* Returns the number of emitted fences on the ring. Used by the
|
|
|
|
* dynpm code to ring track activity.
|
|
|
|
*/
|
2012-05-09 21:34:47 +08:00
|
|
|
unsigned radeon_fence_count_emitted(struct radeon_device *rdev, int ring)
|
2009-06-05 20:42:42 +08:00
|
|
|
{
|
2012-05-09 21:34:47 +08:00
|
|
|
uint64_t emitted;
|
2009-06-05 20:42:42 +08:00
|
|
|
|
2012-05-09 21:34:47 +08:00
|
|
|
/* We are not protected by ring lock when reading the last sequence
|
|
|
|
* but it's ok to report slightly wrong fence count here.
|
|
|
|
*/
|
2012-05-09 21:34:55 +08:00
|
|
|
radeon_fence_process(rdev, ring);
|
2012-05-10 21:57:31 +08:00
|
|
|
emitted = rdev->fence_drv[ring].sync_seq[ring]
|
|
|
|
- atomic64_read(&rdev->fence_drv[ring].last_seq);
|
2012-05-09 21:34:47 +08:00
|
|
|
/* to avoid 32bits warp around */
|
|
|
|
if (emitted > 0x10000000) {
|
|
|
|
emitted = 0x10000000;
|
2011-10-20 18:38:09 +08:00
|
|
|
}
|
2012-05-09 21:34:47 +08:00
|
|
|
return (unsigned)emitted;
|
2011-10-20 18:38:09 +08:00
|
|
|
}
|
|
|
|
|
2012-07-18 02:02:37 +08:00
|
|
|
/**
|
|
|
|
* radeon_fence_need_sync - do we need a semaphore
|
|
|
|
*
|
|
|
|
* @fence: radeon fence object
|
|
|
|
* @dst_ring: which ring to check against
|
|
|
|
*
|
|
|
|
* Check if the fence needs to be synced against another ring
|
|
|
|
* (all asics). If so, we need to emit a semaphore.
|
|
|
|
* Returns true if we need to sync with another ring, false if
|
|
|
|
* not.
|
|
|
|
*/
|
2012-05-10 21:57:31 +08:00
|
|
|
bool radeon_fence_need_sync(struct radeon_fence *fence, int dst_ring)
|
|
|
|
{
|
|
|
|
struct radeon_fence_driver *fdrv;
|
|
|
|
|
|
|
|
if (!fence) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fence->ring == dst_ring) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we are protected by the ring mutex */
|
|
|
|
fdrv = &fence->rdev->fence_drv[dst_ring];
|
|
|
|
if (fence->seq <= fdrv->sync_seq[fence->ring]) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-18 02:02:37 +08:00
|
|
|
/**
|
|
|
|
* radeon_fence_note_sync - record the sync point
|
|
|
|
*
|
|
|
|
* @fence: radeon fence object
|
|
|
|
* @dst_ring: which ring to check against
|
|
|
|
*
|
|
|
|
* Note the sequence number at which point the fence will
|
|
|
|
* be synced with the requested ring (all asics).
|
|
|
|
*/
|
2012-05-10 21:57:31 +08:00
|
|
|
void radeon_fence_note_sync(struct radeon_fence *fence, int dst_ring)
|
|
|
|
{
|
|
|
|
struct radeon_fence_driver *dst, *src;
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
if (!fence) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fence->ring == dst_ring) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we are protected by the ring mutex */
|
|
|
|
src = &fence->rdev->fence_drv[fence->ring];
|
|
|
|
dst = &fence->rdev->fence_drv[dst_ring];
|
|
|
|
for (i = 0; i < RADEON_NUM_RINGS; ++i) {
|
|
|
|
if (i == dst_ring) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
dst->sync_seq[i] = max(dst->sync_seq[i], src->sync_seq[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-18 02:02:37 +08:00
|
|
|
/**
|
|
|
|
* radeon_fence_driver_start_ring - make the fence driver
|
|
|
|
* ready for use on the requested ring.
|
|
|
|
*
|
|
|
|
* @rdev: radeon device pointer
|
|
|
|
* @ring: ring index to start the fence driver on
|
|
|
|
*
|
|
|
|
* Make the fence driver ready for processing (all asics).
|
|
|
|
* Not all asics have all rings, so each asic will only
|
|
|
|
* start the fence driver on the rings it has.
|
|
|
|
* Returns 0 for success, errors for failure.
|
|
|
|
*/
|
2011-11-21 04:45:34 +08:00
|
|
|
int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring)
|
2009-06-05 20:42:42 +08:00
|
|
|
{
|
2011-11-21 04:45:34 +08:00
|
|
|
uint64_t index;
|
|
|
|
int r;
|
2009-06-05 20:42:42 +08:00
|
|
|
|
2011-11-21 04:45:34 +08:00
|
|
|
radeon_scratch_free(rdev, rdev->fence_drv[ring].scratch_reg);
|
2012-12-13 05:43:15 +08:00
|
|
|
if (rdev->wb.use_event || !radeon_ring_supports_scratch_reg(rdev, &rdev->ring[ring])) {
|
2013-04-24 20:11:09 +08:00
|
|
|
rdev->fence_drv[ring].scratch_reg = 0;
|
2013-04-08 18:41:29 +08:00
|
|
|
if (ring != R600_RING_TYPE_UVD_INDEX) {
|
|
|
|
index = R600_WB_EVENT_OFFSET + ring * 4;
|
|
|
|
rdev->fence_drv[ring].cpu_addr = &rdev->wb.wb[index/4];
|
|
|
|
rdev->fence_drv[ring].gpu_addr = rdev->wb.gpu_addr +
|
|
|
|
index;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
/* put fence directly behind firmware */
|
2013-08-05 20:10:55 +08:00
|
|
|
index = ALIGN(rdev->uvd_fw->size, 8);
|
2013-04-14 18:47:59 +08:00
|
|
|
rdev->fence_drv[ring].cpu_addr = rdev->uvd.cpu_addr + index;
|
|
|
|
rdev->fence_drv[ring].gpu_addr = rdev->uvd.gpu_addr + index;
|
2013-04-08 18:41:29 +08:00
|
|
|
}
|
|
|
|
|
2011-11-21 04:45:34 +08:00
|
|
|
} else {
|
2011-08-26 01:39:48 +08:00
|
|
|
r = radeon_scratch_get(rdev, &rdev->fence_drv[ring].scratch_reg);
|
|
|
|
if (r) {
|
|
|
|
dev_err(rdev->dev, "fence failed to get scratch register\n");
|
|
|
|
return r;
|
|
|
|
}
|
2011-11-21 04:45:34 +08:00
|
|
|
index = RADEON_WB_SCRATCH_OFFSET +
|
|
|
|
rdev->fence_drv[ring].scratch_reg -
|
|
|
|
rdev->scratch.reg_base;
|
2013-04-08 18:41:29 +08:00
|
|
|
rdev->fence_drv[ring].cpu_addr = &rdev->wb.wb[index/4];
|
|
|
|
rdev->fence_drv[ring].gpu_addr = rdev->wb.gpu_addr + index;
|
2011-08-26 01:39:48 +08:00
|
|
|
}
|
2012-07-07 19:10:39 +08:00
|
|
|
radeon_fence_write(rdev, atomic64_read(&rdev->fence_drv[ring].last_seq), ring);
|
2011-11-21 04:45:34 +08:00
|
|
|
rdev->fence_drv[ring].initialized = true;
|
2020-07-02 10:27:43 +08:00
|
|
|
dev_info(rdev->dev, "fence driver on ring %d use gpu addr 0x%016llx\n",
|
|
|
|
ring, rdev->fence_drv[ring].gpu_addr);
|
2011-11-21 04:45:34 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-07-18 02:02:37 +08:00
|
|
|
/**
|
|
|
|
* radeon_fence_driver_init_ring - init the fence driver
|
|
|
|
* for the requested ring.
|
|
|
|
*
|
|
|
|
* @rdev: radeon device pointer
|
|
|
|
* @ring: ring index to start the fence driver on
|
|
|
|
*
|
|
|
|
* Init the fence driver for the requested ring (all asics).
|
|
|
|
* Helper function for radeon_fence_driver_init().
|
|
|
|
*/
|
2011-11-21 04:45:34 +08:00
|
|
|
static void radeon_fence_driver_init_ring(struct radeon_device *rdev, int ring)
|
|
|
|
{
|
2012-05-10 21:57:31 +08:00
|
|
|
int i;
|
|
|
|
|
2011-11-21 04:45:34 +08:00
|
|
|
rdev->fence_drv[ring].scratch_reg = -1;
|
|
|
|
rdev->fence_drv[ring].cpu_addr = NULL;
|
|
|
|
rdev->fence_drv[ring].gpu_addr = 0;
|
2012-05-10 21:57:31 +08:00
|
|
|
for (i = 0; i < RADEON_NUM_RINGS; ++i)
|
|
|
|
rdev->fence_drv[ring].sync_seq[i] = 0;
|
2012-05-09 21:34:46 +08:00
|
|
|
atomic64_set(&rdev->fence_drv[ring].last_seq, 0);
|
2011-11-21 04:45:34 +08:00
|
|
|
rdev->fence_drv[ring].initialized = false;
|
2014-08-27 21:21:58 +08:00
|
|
|
INIT_DELAYED_WORK(&rdev->fence_drv[ring].lockup_work,
|
|
|
|
radeon_fence_check_lockup);
|
|
|
|
rdev->fence_drv[ring].rdev = rdev;
|
2011-11-21 04:45:34 +08:00
|
|
|
}
|
|
|
|
|
2012-07-18 02:02:37 +08:00
|
|
|
/**
|
|
|
|
* radeon_fence_driver_init - init the fence driver
|
|
|
|
* for all possible rings.
|
|
|
|
*
|
|
|
|
* @rdev: radeon device pointer
|
|
|
|
*
|
|
|
|
* Init the fence driver for all possible rings (all asics).
|
|
|
|
* Not all asics have all rings, so each asic will only
|
|
|
|
* start the fence driver on the rings it has using
|
|
|
|
* radeon_fence_driver_start_ring().
|
|
|
|
* Returns 0 for success.
|
|
|
|
*/
|
2011-11-21 04:45:34 +08:00
|
|
|
int radeon_fence_driver_init(struct radeon_device *rdev)
|
|
|
|
{
|
|
|
|
int ring;
|
|
|
|
|
2012-05-09 21:34:55 +08:00
|
|
|
init_waitqueue_head(&rdev->fence_queue);
|
2011-11-21 04:45:34 +08:00
|
|
|
for (ring = 0; ring < RADEON_NUM_RINGS; ring++) {
|
|
|
|
radeon_fence_driver_init_ring(rdev, ring);
|
2009-06-05 20:42:42 +08:00
|
|
|
}
|
|
|
|
if (radeon_debugfs_fence_init(rdev)) {
|
2009-12-12 03:36:19 +08:00
|
|
|
dev_err(rdev->dev, "fence debugfs file creation failed\n");
|
2009-06-05 20:42:42 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-07-18 02:02:37 +08:00
|
|
|
/**
|
|
|
|
* radeon_fence_driver_fini - tear down the fence driver
|
|
|
|
* for all possible rings.
|
|
|
|
*
|
|
|
|
* @rdev: radeon device pointer
|
|
|
|
*
|
|
|
|
* Tear down the fence driver for all possible rings (all asics).
|
|
|
|
*/
|
2009-06-05 20:42:42 +08:00
|
|
|
void radeon_fence_driver_fini(struct radeon_device *rdev)
|
|
|
|
{
|
2012-12-18 00:04:32 +08:00
|
|
|
int ring, r;
|
2011-08-26 01:39:48 +08:00
|
|
|
|
2012-05-09 21:34:48 +08:00
|
|
|
mutex_lock(&rdev->ring_lock);
|
2011-08-26 01:39:48 +08:00
|
|
|
for (ring = 0; ring < RADEON_NUM_RINGS; ring++) {
|
|
|
|
if (!rdev->fence_drv[ring].initialized)
|
|
|
|
continue;
|
2014-02-18 22:58:31 +08:00
|
|
|
r = radeon_fence_wait_empty(rdev, ring);
|
2012-12-18 00:04:32 +08:00
|
|
|
if (r) {
|
|
|
|
/* no need to trigger GPU reset as we are unloading */
|
2014-08-27 21:21:56 +08:00
|
|
|
radeon_fence_driver_force_completion(rdev, ring);
|
2012-12-18 00:04:32 +08:00
|
|
|
}
|
2014-08-27 21:21:58 +08:00
|
|
|
cancel_delayed_work_sync(&rdev->fence_drv[ring].lockup_work);
|
2012-05-09 21:34:55 +08:00
|
|
|
wake_up_all(&rdev->fence_queue);
|
2011-08-26 01:39:48 +08:00
|
|
|
radeon_scratch_free(rdev, rdev->fence_drv[ring].scratch_reg);
|
|
|
|
rdev->fence_drv[ring].initialized = false;
|
|
|
|
}
|
2012-05-09 21:34:48 +08:00
|
|
|
mutex_unlock(&rdev->ring_lock);
|
2009-06-05 20:42:42 +08:00
|
|
|
}
|
|
|
|
|
2012-12-17 23:29:06 +08:00
|
|
|
/**
|
|
|
|
* radeon_fence_driver_force_completion - force all fence waiter to complete
|
|
|
|
*
|
|
|
|
* @rdev: radeon device pointer
|
2014-08-27 21:21:56 +08:00
|
|
|
* @ring: the ring to complete
|
2012-12-17 23:29:06 +08:00
|
|
|
*
|
|
|
|
* In case of GPU reset failure make sure no process keep waiting on fence
|
|
|
|
* that will never complete.
|
|
|
|
*/
|
2014-08-27 21:21:56 +08:00
|
|
|
void radeon_fence_driver_force_completion(struct radeon_device *rdev, int ring)
|
2012-12-17 23:29:06 +08:00
|
|
|
{
|
2014-08-27 21:21:58 +08:00
|
|
|
if (rdev->fence_drv[ring].initialized) {
|
2012-12-17 23:29:06 +08:00
|
|
|
radeon_fence_write(rdev, rdev->fence_drv[ring].sync_seq[ring], ring);
|
2014-08-27 21:21:58 +08:00
|
|
|
cancel_delayed_work_sync(&rdev->fence_drv[ring].lockup_work);
|
|
|
|
}
|
2012-12-17 23:29:06 +08:00
|
|
|
}
|
|
|
|
|
2009-06-05 20:42:42 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Fence debugfs
|
|
|
|
*/
|
|
|
|
#if defined(CONFIG_DEBUG_FS)
|
|
|
|
static int radeon_debugfs_fence_info(struct seq_file *m, void *data)
|
|
|
|
{
|
|
|
|
struct drm_info_node *node = (struct drm_info_node *)m->private;
|
|
|
|
struct drm_device *dev = node->minor->dev;
|
|
|
|
struct radeon_device *rdev = dev->dev_private;
|
2012-05-10 21:57:31 +08:00
|
|
|
int i, j;
|
2011-08-26 01:39:48 +08:00
|
|
|
|
|
|
|
for (i = 0; i < RADEON_NUM_RINGS; ++i) {
|
|
|
|
if (!rdev->fence_drv[i].initialized)
|
|
|
|
continue;
|
|
|
|
|
2013-12-12 16:42:39 +08:00
|
|
|
radeon_fence_process(rdev, i);
|
|
|
|
|
2011-08-26 01:39:48 +08:00
|
|
|
seq_printf(m, "--- ring %d ---\n", i);
|
2012-05-10 00:27:29 +08:00
|
|
|
seq_printf(m, "Last signaled fence 0x%016llx\n",
|
|
|
|
(unsigned long long)atomic64_read(&rdev->fence_drv[i].last_seq));
|
2012-05-10 21:57:31 +08:00
|
|
|
seq_printf(m, "Last emitted 0x%016llx\n",
|
|
|
|
rdev->fence_drv[i].sync_seq[i]);
|
|
|
|
|
|
|
|
for (j = 0; j < RADEON_NUM_RINGS; ++j) {
|
|
|
|
if (i != j && rdev->fence_drv[j].initialized)
|
|
|
|
seq_printf(m, "Last sync to ring %d 0x%016llx\n",
|
|
|
|
j, rdev->fence_drv[i].sync_seq[j]);
|
|
|
|
}
|
2009-06-05 20:42:42 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-06-02 23:33:10 +08:00
|
|
|
/**
|
|
|
|
* radeon_debugfs_gpu_reset - manually trigger a gpu reset
|
|
|
|
*
|
|
|
|
* Manually trigger a gpu reset at the next fence wait.
|
|
|
|
*/
|
|
|
|
static int radeon_debugfs_gpu_reset(struct seq_file *m, void *data)
|
|
|
|
{
|
|
|
|
struct drm_info_node *node = (struct drm_info_node *) m->private;
|
|
|
|
struct drm_device *dev = node->minor->dev;
|
|
|
|
struct radeon_device *rdev = dev->dev_private;
|
|
|
|
|
|
|
|
down_read(&rdev->exclusive_lock);
|
|
|
|
seq_printf(m, "%d\n", rdev->needs_reset);
|
|
|
|
rdev->needs_reset = true;
|
2014-08-27 21:21:53 +08:00
|
|
|
wake_up_all(&rdev->fence_queue);
|
2014-06-02 23:33:10 +08:00
|
|
|
up_read(&rdev->exclusive_lock);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-06-05 20:42:42 +08:00
|
|
|
static struct drm_info_list radeon_debugfs_fence_list[] = {
|
|
|
|
{"radeon_fence_info", &radeon_debugfs_fence_info, 0, NULL},
|
2014-06-02 23:33:10 +08:00
|
|
|
{"radeon_gpu_reset", &radeon_debugfs_gpu_reset, 0, NULL}
|
2009-06-05 20:42:42 +08:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int radeon_debugfs_fence_init(struct radeon_device *rdev)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_DEBUG_FS)
|
2014-06-02 23:33:10 +08:00
|
|
|
return radeon_debugfs_add_files(rdev, radeon_debugfs_fence_list, 2);
|
2009-06-05 20:42:42 +08:00
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
2014-01-09 18:03:12 +08:00
|
|
|
|
2016-10-25 20:00:45 +08:00
|
|
|
static const char *radeon_fence_get_driver_name(struct dma_fence *fence)
|
2014-01-09 18:03:12 +08:00
|
|
|
{
|
|
|
|
return "radeon";
|
|
|
|
}
|
|
|
|
|
2016-10-25 20:00:45 +08:00
|
|
|
static const char *radeon_fence_get_timeline_name(struct dma_fence *f)
|
2014-01-09 18:03:12 +08:00
|
|
|
{
|
|
|
|
struct radeon_fence *fence = to_radeon_fence(f);
|
|
|
|
switch (fence->ring) {
|
|
|
|
case RADEON_RING_TYPE_GFX_INDEX: return "radeon.gfx";
|
|
|
|
case CAYMAN_RING_TYPE_CP1_INDEX: return "radeon.cp1";
|
|
|
|
case CAYMAN_RING_TYPE_CP2_INDEX: return "radeon.cp2";
|
|
|
|
case R600_RING_TYPE_DMA_INDEX: return "radeon.dma";
|
|
|
|
case CAYMAN_RING_TYPE_DMA1_INDEX: return "radeon.dma1";
|
|
|
|
case R600_RING_TYPE_UVD_INDEX: return "radeon.uvd";
|
|
|
|
case TN_RING_TYPE_VCE1_INDEX: return "radeon.vce1";
|
|
|
|
case TN_RING_TYPE_VCE2_INDEX: return "radeon.vce2";
|
|
|
|
default: WARN_ON_ONCE(1); return "radeon.unk";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool radeon_test_signaled(struct radeon_fence *fence)
|
|
|
|
{
|
2016-10-25 20:00:45 +08:00
|
|
|
return test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->base.flags);
|
2014-01-09 18:03:12 +08:00
|
|
|
}
|
|
|
|
|
2015-03-03 16:56:42 +08:00
|
|
|
struct radeon_wait_cb {
|
2016-10-25 20:00:45 +08:00
|
|
|
struct dma_fence_cb base;
|
2015-03-03 16:56:42 +08:00
|
|
|
struct task_struct *task;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2016-10-25 20:00:45 +08:00
|
|
|
radeon_fence_wait_cb(struct dma_fence *fence, struct dma_fence_cb *cb)
|
2015-03-03 16:56:42 +08:00
|
|
|
{
|
|
|
|
struct radeon_wait_cb *wait =
|
|
|
|
container_of(cb, struct radeon_wait_cb, base);
|
|
|
|
|
|
|
|
wake_up_process(wait->task);
|
|
|
|
}
|
|
|
|
|
2016-10-25 20:00:45 +08:00
|
|
|
static signed long radeon_fence_default_wait(struct dma_fence *f, bool intr,
|
2014-01-09 18:03:12 +08:00
|
|
|
signed long t)
|
|
|
|
{
|
|
|
|
struct radeon_fence *fence = to_radeon_fence(f);
|
|
|
|
struct radeon_device *rdev = fence->rdev;
|
2015-03-03 16:56:42 +08:00
|
|
|
struct radeon_wait_cb cb;
|
2014-01-09 18:03:12 +08:00
|
|
|
|
2015-03-03 16:56:42 +08:00
|
|
|
cb.task = current;
|
2014-01-09 18:03:12 +08:00
|
|
|
|
2016-10-25 20:00:45 +08:00
|
|
|
if (dma_fence_add_callback(f, &cb.base, radeon_fence_wait_cb))
|
2015-03-03 16:56:42 +08:00
|
|
|
return t;
|
|
|
|
|
|
|
|
while (t > 0) {
|
|
|
|
if (intr)
|
|
|
|
set_current_state(TASK_INTERRUPTIBLE);
|
|
|
|
else
|
|
|
|
set_current_state(TASK_UNINTERRUPTIBLE);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* radeon_test_signaled must be called after
|
|
|
|
* set_current_state to prevent a race with wake_up_process
|
|
|
|
*/
|
|
|
|
if (radeon_test_signaled(fence))
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (rdev->needs_reset) {
|
|
|
|
t = -EDEADLK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
t = schedule_timeout(t);
|
|
|
|
|
|
|
|
if (t > 0 && intr && signal_pending(current))
|
|
|
|
t = -ERESTARTSYS;
|
|
|
|
}
|
|
|
|
|
|
|
|
__set_current_state(TASK_RUNNING);
|
2016-10-25 20:00:45 +08:00
|
|
|
dma_fence_remove_callback(f, &cb.base);
|
2014-01-09 18:03:12 +08:00
|
|
|
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
2016-10-25 20:00:45 +08:00
|
|
|
const struct dma_fence_ops radeon_fence_ops = {
|
2014-01-09 18:03:12 +08:00
|
|
|
.get_driver_name = radeon_fence_get_driver_name,
|
|
|
|
.get_timeline_name = radeon_fence_get_timeline_name,
|
|
|
|
.enable_signaling = radeon_fence_enable_signaling,
|
|
|
|
.signaled = radeon_fence_is_signaled,
|
|
|
|
.wait = radeon_fence_default_wait,
|
|
|
|
.release = NULL,
|
|
|
|
};
|