Commit 96583ddb authored by Daniel Vetter's avatar Daniel Vetter

Merge remote-tracking branch 'airlied/drm-next' into drm-intel-next-queued

Backmerge latest drm-next to pull in the s/fence/dma_fence/ rework,
needed before we merge more i915 fencing patches.
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
parents 1353ec38 fb422950
Silicon Image SiI8620 HDMI/MHL bridge bindings
Required properties:
- compatible: "sil,sii8620"
- reg: i2c address of the bridge
- cvcc10-supply: Digital Core Supply Voltage (1.0V)
- iovcc18-supply: I/O Supply Voltage (1.8V)
- interrupts, interrupt-parent: interrupt specifier of INT pin
- reset-gpios: gpio specifier of RESET pin
- clocks, clock-names: specification and name of "xtal" clock
- video interfaces: Device node can contain video interface port
node for HDMI encoder according to [1].
[1]: Documentation/devicetree/bindings/media/video-interfaces.txt
Example:
sii8620@39 {
reg = <0x39>;
compatible = "sil,sii8620";
cvcc10-supply = <&ldo36_reg>;
iovcc18-supply = <&ldo34_reg>;
interrupt-parent = <&gpf0>;
interrupts = <2 0>;
reset-gpio = <&gpv7 0 0>;
clocks = <&pmu_system_controller 0>;
clock-names = "xtal";
port {
mhl_to_hdmi: endpoint {
remote-endpoint = <&hdmi_to_mhl>;
};
};
};
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
This document serves as a guide for device drivers writers on what the This document serves as a guide for device drivers writers on what the
sync_file API is, and how drivers can support it. Sync file is the carrier of sync_file API is, and how drivers can support it. Sync file is the carrier of
the fences(struct fence) that are needed to synchronize between drivers or the fences(struct dma_fence) that are needed to synchronize between drivers or
across process boundaries. across process boundaries.
The sync_file API is meant to be used to send and receive fence information The sync_file API is meant to be used to send and receive fence information
...@@ -32,9 +32,9 @@ in-fences and out-fences ...@@ -32,9 +32,9 @@ in-fences and out-fences
Sync files can go either to or from userspace. When a sync_file is sent from Sync files can go either to or from userspace. When a sync_file is sent from
the driver to userspace we call the fences it contains 'out-fences'. They are the driver to userspace we call the fences it contains 'out-fences'. They are
related to a buffer that the driver is processing or is going to process, so related to a buffer that the driver is processing or is going to process, so
the driver creates an out-fence to be able to notify, through fence_signal(), the driver creates an out-fence to be able to notify, through
when it has finished using (or processing) that buffer. Out-fences are fences dma_fence_signal(), when it has finished using (or processing) that buffer.
that the driver creates. Out-fences are fences that the driver creates.
On the other hand if the driver receives fence(s) through a sync_file from On the other hand if the driver receives fence(s) through a sync_file from
userspace we call these fence(s) 'in-fences'. Receiveing in-fences means that userspace we call these fence(s) 'in-fences'. Receiveing in-fences means that
...@@ -47,7 +47,7 @@ Creating Sync Files ...@@ -47,7 +47,7 @@ Creating Sync Files
When a driver needs to send an out-fence userspace it creates a sync_file. When a driver needs to send an out-fence userspace it creates a sync_file.
Interface: Interface:
struct sync_file *sync_file_create(struct fence *fence); struct sync_file *sync_file_create(struct dma_fence *fence);
The caller pass the out-fence and gets back the sync_file. That is just the The caller pass the out-fence and gets back the sync_file. That is just the
first step, next it needs to install an fd on sync_file->file. So it gets an first step, next it needs to install an fd on sync_file->file. So it gets an
...@@ -72,11 +72,11 @@ of the Sync File to the kernel. The kernel can then retrieve the fences ...@@ -72,11 +72,11 @@ of the Sync File to the kernel. The kernel can then retrieve the fences
from it. from it.
Interface: Interface:
struct fence *sync_file_get_fence(int fd); struct dma_fence *sync_file_get_fence(int fd);
The returned reference is owned by the caller and must be disposed of The returned reference is owned by the caller and must be disposed of
afterwards using fence_put(). In case of error, a NULL is returned instead. afterwards using dma_fence_put(). In case of error, a NULL is returned instead.
References: References:
[1] struct sync_file in include/linux/sync_file.h [1] struct sync_file in include/linux/sync_file.h
......
...@@ -248,11 +248,11 @@ config DMA_SHARED_BUFFER ...@@ -248,11 +248,11 @@ config DMA_SHARED_BUFFER
APIs extension; the file's descriptor can then be passed on to other APIs extension; the file's descriptor can then be passed on to other
driver. driver.
config FENCE_TRACE config DMA_FENCE_TRACE
bool "Enable verbose FENCE_TRACE messages" bool "Enable verbose DMA_FENCE_TRACE messages"
depends on DMA_SHARED_BUFFER depends on DMA_SHARED_BUFFER
help help
Enable the FENCE_TRACE printks. This will add extra Enable the DMA_FENCE_TRACE printks. This will add extra
spam to the console log, but will make it easier to diagnose spam to the console log, but will make it easier to diagnose
lockup related problems for dma-buffers shared across multiple lockup related problems for dma-buffers shared across multiple
devices. devices.
......
...@@ -7,7 +7,7 @@ config SYNC_FILE ...@@ -7,7 +7,7 @@ config SYNC_FILE
select DMA_SHARED_BUFFER select DMA_SHARED_BUFFER
---help--- ---help---
The Sync File Framework adds explicit syncronization via The Sync File Framework adds explicit syncronization via
userspace. It enables send/receive 'struct fence' objects to/from userspace. It enables send/receive 'struct dma_fence' objects to/from
userspace via Sync File fds for synchronization between drivers via userspace via Sync File fds for synchronization between drivers via
userspace components. It has been ported from Android. userspace components. It has been ported from Android.
......
obj-y := dma-buf.o fence.o reservation.o seqno-fence.o fence-array.o obj-y := dma-buf.o dma-fence.o dma-fence-array.o reservation.o seqno-fence.o
obj-$(CONFIG_SYNC_FILE) += sync_file.o obj-$(CONFIG_SYNC_FILE) += sync_file.o
obj-$(CONFIG_SW_SYNC) += sw_sync.o sync_debug.o obj-$(CONFIG_SW_SYNC) += sw_sync.o sync_debug.o
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/dma-buf.h> #include <linux/dma-buf.h>
#include <linux/fence.h> #include <linux/dma-fence.h>
#include <linux/anon_inodes.h> #include <linux/anon_inodes.h>
#include <linux/export.h> #include <linux/export.h>
#include <linux/debugfs.h> #include <linux/debugfs.h>
...@@ -124,7 +124,7 @@ static loff_t dma_buf_llseek(struct file *file, loff_t offset, int whence) ...@@ -124,7 +124,7 @@ static loff_t dma_buf_llseek(struct file *file, loff_t offset, int whence)
return base + offset; return base + offset;
} }
static void dma_buf_poll_cb(struct fence *fence, struct fence_cb *cb) static void dma_buf_poll_cb(struct dma_fence *fence, struct dma_fence_cb *cb)
{ {
struct dma_buf_poll_cb_t *dcb = (struct dma_buf_poll_cb_t *)cb; struct dma_buf_poll_cb_t *dcb = (struct dma_buf_poll_cb_t *)cb;
unsigned long flags; unsigned long flags;
...@@ -140,7 +140,7 @@ static unsigned int dma_buf_poll(struct file *file, poll_table *poll) ...@@ -140,7 +140,7 @@ static unsigned int dma_buf_poll(struct file *file, poll_table *poll)
struct dma_buf *dmabuf; struct dma_buf *dmabuf;
struct reservation_object *resv; struct reservation_object *resv;
struct reservation_object_list *fobj; struct reservation_object_list *fobj;
struct fence *fence_excl; struct dma_fence *fence_excl;
unsigned long events; unsigned long events;
unsigned shared_count, seq; unsigned shared_count, seq;
...@@ -187,20 +187,20 @@ static unsigned int dma_buf_poll(struct file *file, poll_table *poll) ...@@ -187,20 +187,20 @@ static unsigned int dma_buf_poll(struct file *file, poll_table *poll)
spin_unlock_irq(&dmabuf->poll.lock); spin_unlock_irq(&dmabuf->poll.lock);
if (events & pevents) { if (events & pevents) {
if (!fence_get_rcu(fence_excl)) { if (!dma_fence_get_rcu(fence_excl)) {
/* force a recheck */ /* force a recheck */
events &= ~pevents; events &= ~pevents;
dma_buf_poll_cb(NULL, &dcb->cb); dma_buf_poll_cb(NULL, &dcb->cb);
} else if (!fence_add_callback(fence_excl, &dcb->cb, } else if (!dma_fence_add_callback(fence_excl, &dcb->cb,
dma_buf_poll_cb)) { dma_buf_poll_cb)) {
events &= ~pevents; events &= ~pevents;
fence_put(fence_excl); dma_fence_put(fence_excl);
} else { } else {
/* /*
* No callback queued, wake up any additional * No callback queued, wake up any additional
* waiters. * waiters.
*/ */
fence_put(fence_excl); dma_fence_put(fence_excl);
dma_buf_poll_cb(NULL, &dcb->cb); dma_buf_poll_cb(NULL, &dcb->cb);
} }
} }
...@@ -222,9 +222,9 @@ static unsigned int dma_buf_poll(struct file *file, poll_table *poll) ...@@ -222,9 +222,9 @@ static unsigned int dma_buf_poll(struct file *file, poll_table *poll)
goto out; goto out;
for (i = 0; i < shared_count; ++i) { for (i = 0; i < shared_count; ++i) {
struct fence *fence = rcu_dereference(fobj->shared[i]); struct dma_fence *fence = rcu_dereference(fobj->shared[i]);
if (!fence_get_rcu(fence)) { if (!dma_fence_get_rcu(fence)) {
/* /*
* fence refcount dropped to zero, this means * fence refcount dropped to zero, this means
* that fobj has been freed * that fobj has been freed
...@@ -235,13 +235,13 @@ static unsigned int dma_buf_poll(struct file *file, poll_table *poll) ...@@ -235,13 +235,13 @@ static unsigned int dma_buf_poll(struct file *file, poll_table *poll)
dma_buf_poll_cb(NULL, &dcb->cb); dma_buf_poll_cb(NULL, &dcb->cb);
break; break;
} }
if (!fence_add_callback(fence, &dcb->cb, if (!dma_fence_add_callback(fence, &dcb->cb,
dma_buf_poll_cb)) { dma_buf_poll_cb)) {
fence_put(fence); dma_fence_put(fence);
events &= ~POLLOUT; events &= ~POLLOUT;
break; break;
} }
fence_put(fence); dma_fence_put(fence);
} }
/* No callback queued, wake up any additional waiters. */ /* No callback queued, wake up any additional waiters. */
......
/* /*
* fence-array: aggregate fences to be waited together * dma-fence-array: aggregate fences to be waited together
* *
* Copyright (C) 2016 Collabora Ltd * Copyright (C) 2016 Collabora Ltd
* Copyright (C) 2016 Advanced Micro Devices, Inc. * Copyright (C) 2016 Advanced Micro Devices, Inc.
...@@ -19,35 +19,34 @@ ...@@ -19,35 +19,34 @@
#include <linux/export.h> #include <linux/export.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/fence-array.h> #include <linux/dma-fence-array.h>
static void fence_array_cb_func(struct fence *f, struct fence_cb *cb); static const char *dma_fence_array_get_driver_name(struct dma_fence *fence)
static const char *fence_array_get_driver_name(struct fence *fence)
{ {
return "fence_array"; return "dma_fence_array";
} }
static const char *fence_array_get_timeline_name(struct fence *fence) static const char *dma_fence_array_get_timeline_name(struct dma_fence *fence)
{ {
return "unbound"; return "unbound";
} }
static void fence_array_cb_func(struct fence *f, struct fence_cb *cb) static void dma_fence_array_cb_func(struct dma_fence *f,
struct dma_fence_cb *cb)
{ {
struct fence_array_cb *array_cb = struct dma_fence_array_cb *array_cb =
container_of(cb, struct fence_array_cb, cb); container_of(cb, struct dma_fence_array_cb, cb);
struct fence_array *array = array_cb->array; struct dma_fence_array *array = array_cb->array;
if (atomic_dec_and_test(&array->num_pending)) if (atomic_dec_and_test(&array->num_pending))
fence_signal(&array->base); dma_fence_signal(&array->base);
fence_put(&array->base); dma_fence_put(&array->base);
} }
static bool fence_array_enable_signaling(struct fence *fence) static bool dma_fence_array_enable_signaling(struct dma_fence *fence)
{ {
struct fence_array *array = to_fence_array(fence); struct dma_fence_array *array = to_dma_fence_array(fence);
struct fence_array_cb *cb = (void *)(&array[1]); struct dma_fence_array_cb *cb = (void *)(&array[1]);
unsigned i; unsigned i;
for (i = 0; i < array->num_fences; ++i) { for (i = 0; i < array->num_fences; ++i) {
...@@ -60,10 +59,10 @@ static bool fence_array_enable_signaling(struct fence *fence) ...@@ -60,10 +59,10 @@ static bool fence_array_enable_signaling(struct fence *fence)
* until we signal the array as complete (but that is now * until we signal the array as complete (but that is now
* insufficient). * insufficient).
*/ */
fence_get(&array->base); dma_fence_get(&array->base);
if (fence_add_callback(array->fences[i], &cb[i].cb, if (dma_fence_add_callback(array->fences[i], &cb[i].cb,
fence_array_cb_func)) { dma_fence_array_cb_func)) {
fence_put(&array->base); dma_fence_put(&array->base);
if (atomic_dec_and_test(&array->num_pending)) if (atomic_dec_and_test(&array->num_pending))
return false; return false;
} }
...@@ -72,68 +71,70 @@ static bool fence_array_enable_signaling(struct fence *fence) ...@@ -72,68 +71,70 @@ static bool fence_array_enable_signaling(struct fence *fence)
return true; return true;
} }
static bool fence_array_signaled(struct fence *fence) static bool dma_fence_array_signaled(struct dma_fence *fence)
{ {
struct fence_array *array = to_fence_array(fence); struct dma_fence_array *array = to_dma_fence_array(fence);
return atomic_read(&array->num_pending) <= 0; return atomic_read(&array->num_pending) <= 0;
} }
static void fence_array_release(struct fence *fence) static void dma_fence_array_release(struct dma_fence *fence)
{ {
struct fence_array *array = to_fence_array(fence); struct dma_fence_array *array = to_dma_fence_array(fence);
unsigned i; unsigned i;
for (i = 0; i < array->num_fences; ++i) for (i = 0; i < array->num_fences; ++i)
fence_put(array->fences[i]); dma_fence_put(array->fences[i]);
kfree(array->fences); kfree(array->fences);
fence_free(fence); dma_fence_free(fence);
} }
const struct fence_ops fence_array_ops = { const struct dma_fence_ops dma_fence_array_ops = {
.get_driver_name = fence_array_get_driver_name, .get_driver_name = dma_fence_array_get_driver_name,
.get_timeline_name = fence_array_get_timeline_name, .get_timeline_name = dma_fence_array_get_timeline_name,
.enable_signaling = fence_array_enable_signaling, .enable_signaling = dma_fence_array_enable_signaling,
.signaled = fence_array_signaled, .signaled = dma_fence_array_signaled,
.wait = fence_default_wait, .wait = dma_fence_default_wait,
.release = fence_array_release, .release = dma_fence_array_release,
}; };
EXPORT_SYMBOL(fence_array_ops); EXPORT_SYMBOL(dma_fence_array_ops);
/** /**
* fence_array_create - Create a custom fence array * dma_fence_array_create - Create a custom fence array
* @num_fences: [in] number of fences to add in the array * @num_fences: [in] number of fences to add in the array
* @fences: [in] array containing the fences * @fences: [in] array containing the fences
* @context: [in] fence context to use * @context: [in] fence context to use
* @seqno: [in] sequence number to use * @seqno: [in] sequence number to use
* @signal_on_any: [in] signal on any fence in the array * @signal_on_any: [in] signal on any fence in the array
* *
* Allocate a fence_array object and initialize the base fence with fence_init(). * Allocate a dma_fence_array object and initialize the base fence with
* dma_fence_init().
* In case of error it returns NULL. * In case of error it returns NULL.
* *
* The caller should allocate the fences array with num_fences size * The caller should allocate the fences array with num_fences size
* and fill it with the fences it wants to add to the object. Ownership of this * and fill it with the fences it wants to add to the object. Ownership of this
* array is taken and fence_put() is used on each fence on release. * array is taken and dma_fence_put() is used on each fence on release.
* *
* If @signal_on_any is true the fence array signals if any fence in the array * If @signal_on_any is true the fence array signals if any fence in the array
* signals, otherwise it signals when all fences in the array signal. * signals, otherwise it signals when all fences in the array signal.
*/ */
struct fence_array *fence_array_create(int num_fences, struct fence **fences, struct dma_fence_array *dma_fence_array_create(int num_fences,
struct dma_fence **fences,
u64 context, unsigned seqno, u64 context, unsigned seqno,
bool signal_on_any) bool signal_on_any)
{ {
struct fence_array *array; struct dma_fence_array *array;
size_t size = sizeof(*array); size_t size = sizeof(*array);
/* Allocate the callback structures behind the array. */ /* Allocate the callback structures behind the array. */
size += num_fences * sizeof(struct fence_array_cb); size += num_fences * sizeof(struct dma_fence_array_cb);
array = kzalloc(size, GFP_KERNEL); array = kzalloc(size, GFP_KERNEL);
if (!array) if (!array)
return NULL; return NULL;
spin_lock_init(&array->lock); spin_lock_init(&array->lock);
fence_init(&array->base, &fence_array_ops, &array->lock, dma_fence_init(&array->base, &dma_fence_array_ops, &array->lock,
context, seqno); context, seqno);
array->num_fences = num_fences; array->num_fences = num_fences;
...@@ -142,4 +143,4 @@ struct fence_array *fence_array_create(int num_fences, struct fence **fences, ...@@ -142,4 +143,4 @@ struct fence_array *fence_array_create(int num_fences, struct fence **fences,
return array; return array;
} }
EXPORT_SYMBOL(fence_array_create); EXPORT_SYMBOL(dma_fence_array_create);
...@@ -102,17 +102,17 @@ EXPORT_SYMBOL(reservation_object_reserve_shared); ...@@ -102,17 +102,17 @@ EXPORT_SYMBOL(reservation_object_reserve_shared);
static void static void
reservation_object_add_shared_inplace(struct reservation_object *obj, reservation_object_add_shared_inplace(struct reservation_object *obj,
struct reservation_object_list *fobj, struct reservation_object_list *fobj,
struct fence *fence) struct dma_fence *fence)
{ {
u32 i; u32 i;
fence_get(fence); dma_fence_get(fence);
preempt_disable(); preempt_disable();
write_seqcount_begin(&obj->seq); write_seqcount_begin(&obj->seq);
for (i = 0; i < fobj->shared_count; ++i) { for (i = 0; i < fobj->shared_count; ++i) {
struct fence *old_fence; struct dma_fence *old_fence;
old_fence = rcu_dereference_protected(fobj->shared[i], old_fence = rcu_dereference_protected(fobj->shared[i],
reservation_object_held(obj)); reservation_object_held(obj));
...@@ -123,7 +123,7 @@ reservation_object_add_shared_inplace(struct reservation_object *obj, ...@@ -123,7 +123,7 @@ reservation_object_add_shared_inplace(struct reservation_object *obj,
write_seqcount_end(&obj->seq); write_seqcount_end(&obj->seq);
preempt_enable(); preempt_enable();
fence_put(old_fence); dma_fence_put(old_fence);
return; return;
} }
} }
...@@ -143,12 +143,12 @@ static void ...@@ -143,12 +143,12 @@ static void
reservation_object_add_shared_replace(struct reservation_object *obj, reservation_object_add_shared_replace(struct reservation_object *obj,
struct reservation_object_list *old, struct reservation_object_list *old,
struct reservation_object_list *fobj, struct reservation_object_list *fobj,
struct fence *fence) struct dma_fence *fence)
{ {
unsigned i; unsigned i;
struct fence *old_fence = NULL; struct dma_fence *old_fence = NULL;
fence_get(fence); dma_fence_get(fence);
if (!old) { if (!old) {
RCU_INIT_POINTER(fobj->shared[0], fence); RCU_INIT_POINTER(fobj->shared[0], fence);
...@@ -165,7 +165,7 @@ reservation_object_add_shared_replace(struct reservation_object *obj, ...@@ -165,7 +165,7 @@ reservation_object_add_shared_replace(struct reservation_object *obj,
fobj->shared_count = old->shared_count; fobj->shared_count = old->shared_count;
for (i = 0; i < old->shared_count; ++i) { for (i = 0; i < old->shared_count; ++i) {
struct fence *check; struct dma_fence *check;
check = rcu_dereference_protected(old->shared[i], check = rcu_dereference_protected(old->shared[i],
reservation_object_held(obj)); reservation_object_held(obj));
...@@ -196,7 +196,7 @@ reservation_object_add_shared_replace(struct reservation_object *obj, ...@@ -196,7 +196,7 @@ reservation_object_add_shared_replace(struct reservation_object *obj,
kfree_rcu(old, rcu); kfree_rcu(old, rcu);
if (old_fence) if (old_fence)
fence_put(old_fence); dma_fence_put(old_fence);
} }
/** /**
...@@ -208,7 +208,7 @@ reservation_object_add_shared_replace(struct reservation_object *obj, ...@@ -208,7 +208,7 @@ reservation_object_add_shared_replace(struct reservation_object *obj,
* reservation_object_reserve_shared() has been called. * reservation_object_reserve_shared() has been called.
*/ */
void reservation_object_add_shared_fence(struct reservation_object *obj, void reservation_object_add_shared_fence(struct reservation_object *obj,
struct fence *fence) struct dma_fence *fence)
{ {
struct reservation_object_list *old, *fobj = obj->staged; struct reservation_object_list *old, *fobj = obj->staged;
...@@ -231,9 +231,9 @@ EXPORT_SYMBOL(reservation_object_add_shared_fence); ...@@ -231,9 +231,9 @@ EXPORT_SYMBOL(reservation_object_add_shared_fence);
* Add a fence to the exclusive slot. The obj->lock must be held. * Add a fence to the exclusive slot. The obj->lock must be held.
*/ */
void reservation_object_add_excl_fence(struct reservation_object *obj, void reservation_object_add_excl_fence(struct reservation_object *obj,
struct fence *fence) struct dma_fence *fence)
{ {
struct fence *old_fence = reservation_object_get_excl(obj); struct dma_fence *old_fence = reservation_object_get_excl(obj);
struct reservation_object_list *old; struct reservation_object_list *old;
u32 i = 0; u32 i = 0;
...@@ -242,7 +242,7 @@ void reservation_object_add_excl_fence(struct reservation_object *obj, ...@@ -242,7 +242,7 @@ void reservation_object_add_excl_fence(struct reservation_object *obj,
i = old->shared_count; i = old->shared_count;
if (fence) if (fence)
fence_get(fence); dma_fence_get(fence);
preempt_disable(); preempt_disable();
write_seqcount_begin(&obj->seq); write_seqcount_begin(&obj->seq);
...@@ -255,11 +255,11 @@ void reservation_object_add_excl_fence(struct reservation_object *obj, ...@@ -255,11 +255,11 @@ void reservation_object_add_excl_fence(struct reservation_object *obj,
/* inplace update, no shared fences */ /* inplace update, no shared fences */
while (i--) while (i--)
fence_put(rcu_dereference_protected(old->shared[i], dma_fence_put(rcu_dereference_protected(old->shared[i],
reservation_object_held(obj))); reservation_object_held(obj)));
if (old_fence) if (old_fence)
fence_put(old_fence); dma_fence_put(old_fence);
} }
EXPORT_SYMBOL(reservation_object_add_excl_fence); EXPORT_SYMBOL(reservation_object_add_excl_fence);
...@@ -276,12 +276,12 @@ EXPORT_SYMBOL(reservation_object_add_excl_fence); ...@@ -276,12 +276,12 @@ EXPORT_SYMBOL(reservation_object_add_excl_fence);
* Zero or -errno * Zero or -errno
*/ */
int reservation_object_get_fences_rcu(struct reservation_object *obj, int reservation_object_get_fences_rcu(struct reservation_object *obj,
struct fence **pfence_excl, struct dma_fence **pfence_excl,
unsigned *pshared_count, unsigned *pshared_count,
struct fence ***pshared) struct dma_fence ***pshared)
{ {
struct fence **shared = NULL; struct dma_fence **shared = NULL;
struct fence *fence_excl; struct dma_fence *fence_excl;
unsigned int shared_count; unsigned int shared_count;
int ret = 1; int ret = 1;
...@@ -296,12 +296,12 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj, ...@@ -296,12 +296,12 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj,
seq = read_seqcount_begin(&obj->seq); seq = read_seqcount_begin(&obj->seq);
fence_excl = rcu_dereference(obj->fence_excl); fence_excl = rcu_dereference(obj->fence_excl);
if (fence_excl && !fence_get_rcu(fence_excl)) if (fence_excl && !dma_fence_get_rcu(fence_excl))
goto unlock; goto unlock;
fobj = rcu_dereference(obj->fence); fobj = rcu_dereference(obj->fence);
if (fobj) { if (fobj) {
struct fence **nshared; struct dma_fence **nshared;
size_t sz = sizeof(*shared) * fobj->shared_max; size_t sz = sizeof(*shared) * fobj->shared_max;
nshared = krealloc(shared, sz, nshared = krealloc(shared, sz,
...@@ -322,15 +322,15 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj, ...@@ -322,15 +322,15 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj,
for (i = 0; i < shared_count; ++i) { for (i = 0; i < shared_count; ++i) {
shared[i] = rcu_dereference(fobj->shared[i]); shared[i] = rcu_dereference(fobj->shared[i]);
if (!fence_get_rcu(shared[i])) if (!dma_fence_get_rcu(shared[i]))
break; break;
} }
} }
if (i != shared_count || read_seqcount_retry(&obj->seq, seq)) { if (i != shared_count || read_seqcount_retry(&obj->seq, seq)) {
while (i--) while (i--)
fence_put(shared[i]); dma_fence_put(shared[i]);
fence_put(fence_excl); dma_fence_put(fence_excl);
goto unlock; goto unlock;
} }
...@@ -368,7 +368,7 @@ long reservation_object_wait_timeout_rcu(struct reservation_object *obj, ...@@ -368,7 +368,7 @@ long reservation_object_wait_timeout_rcu(struct reservation_object *obj,
bool wait_all, bool intr, bool wait_all, bool intr,
unsigned long timeout) unsigned long timeout)
{ {
struct fence *fence; struct dma_fence *fence;
unsigned seq, shared_count, i = 0; unsigned seq, shared_count, i = 0;
long ret = timeout; long ret = timeout;
...@@ -389,16 +389,17 @@ long reservation_object_wait_timeout_rcu(struct reservation_object *obj, ...@@ -389,16 +389,17 @@ long reservation_object_wait_timeout_rcu(struct reservation_object *obj,
shared_count = fobj->shared_count; shared_count = fobj->shared_count;
for (i = 0; i < shared_count; ++i) { for (i = 0; i < shared_count; ++i) {
struct fence *lfence = rcu_dereference(fobj->shared[i]); struct dma_fence *lfence = rcu_dereference(fobj->shared[i]);
if (test_bit(FENCE_FLAG_SIGNALED_BIT, &lfence->flags)) if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT,
&lfence->flags))
continue; continue;
if (!fence_get_rcu(lfence)) if (!dma_fence_get_rcu(lfence))
goto unlock_retry; goto unlock_retry;
if (fence_is_signaled(lfence)) { if (dma_fence_is_signaled(lfence)) {
fence_put(lfence); dma_fence_put(lfence);
continue; continue;
} }
...@@ -408,15 +409,16 @@ long reservation_object_wait_timeout_rcu(struct reservation_object *obj, ...@@ -408,15 +409,16 @@ long reservation_object_wait_timeout_rcu(struct reservation_object *obj,
} }
if (!shared_count) { if (!shared_count) {
struct fence *fence_excl = rcu_dereference(obj->fence_excl); struct dma_fence *fence_excl = rcu_dereference(obj->fence_excl);
if (fence_excl && if (fence_excl &&
!test_bit(FENCE_FLAG_SIGNALED_BIT, &fence_excl->flags)) { !test_bit(DMA_FENCE_FLAG_SIGNALED_BIT,
if (!fence_get_rcu(fence_excl)) &fence_excl->flags)) {
if (!dma_fence_get_rcu(fence_excl))
goto unlock_retry; goto unlock_retry;
if (fence_is_signaled(fence_excl)) if (dma_fence_is_signaled(fence_excl))
fence_put(fence_excl); dma_fence_put(fence_excl);
else else
fence = fence_excl; fence = fence_excl;
} }
...@@ -425,12 +427,12 @@ long reservation_object_wait_timeout_rcu(struct reservation_object *obj, ...@@ -425,12 +427,12 @@ long reservation_object_wait_timeout_rcu(struct reservation_object *obj,
rcu_read_unlock(); rcu_read_unlock();
if (fence) { if (fence) {
if (read_seqcount_retry(&obj->seq, seq)) { if (read_seqcount_retry(&obj->seq, seq)) {
fence_put(fence); dma_fence_put(fence);
goto retry; goto retry;
} }
ret = fence_wait_timeout(fence, intr, ret); ret = dma_fence_wait_timeout(fence, intr, ret);
fence_put(fence); dma_fence_put(fence);
if (ret > 0 && wait_all && (i + 1 < shared_count)) if (ret > 0 && wait_all && (i + 1 < shared_count))
goto retry; goto retry;
} }
...@@ -444,18 +446,18 @@ EXPORT_SYMBOL_GPL(reservation_object_wait_timeout_rcu); ...@@ -444,18 +446,18 @@ EXPORT_SYMBOL_GPL(reservation_object_wait_timeout_rcu);
static inline int static inline int
reservation_object_test_signaled_single(struct fence *passed_fence) reservation_object_test_signaled_single(struct dma_fence *passed_fence)
{ {
struct fence *fence, *lfence = passed_fence; struct dma_fence *fence, *lfence = passed_fence;
int ret = 1; int ret = 1;
if (!test_bit(FENCE_FLAG_SIGNALED_BIT, &lfence->flags)) { if (!test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &lfence->flags)) {
fence = fence_get_rcu(lfence); fence = dma_fence_get_rcu(lfence);
if (!fence) if (!fence)
return -1; return -1;
ret = !!fence_is_signaled(fence); ret = !!dma_fence_is_signaled(fence);
fence_put(fence); dma_fence_put(fence);
} }
return ret; return ret;
} }
...@@ -492,7 +494,7 @@ bool reservation_object_test_signaled_rcu(struct reservation_object *obj, ...@@ -492,7 +494,7 @@ bool reservation_object_test_signaled_rcu(struct reservation_object *obj,
shared_count = fobj->shared_count; shared_count = fobj->shared_count;
for (i = 0; i < shared_count; ++i) { for (i = 0; i < shared_count; ++i) {
struct fence *fence = rcu_dereference(fobj->shared[i]); struct dma_fence *fence = rcu_dereference(fobj->shared[i]);
ret = reservation_object_test_signaled_single(fence); ret = reservation_object_test_signaled_single(fence);
if (ret < 0) if (ret < 0)
...@@ -506,7 +508,7 @@ bool reservation_object_test_signaled_rcu(struct reservation_object *obj, ...@@ -506,7 +508,7 @@ bool reservation_object_test_signaled_rcu(struct reservation_object *obj,
} }
if (!shared_count) { if (!shared_count) {
struct fence *fence_excl = rcu_dereference(obj->fence_excl); struct dma_fence *fence_excl = rcu_dereference(obj->fence_excl);
if (fence_excl) { if (fence_excl) {
ret = reservation_object_test_signaled_single( ret = reservation_object_test_signaled_single(
......
...@@ -21,35 +21,35 @@ ...@@ -21,35 +21,35 @@
#include <linux/export.h> #include <linux/export.h>
#include <linux/seqno-fence.h> #include <linux/seqno-fence.h>
static const char *seqno_fence_get_driver_name(struct fence *fence) static const char *seqno_fence_get_driver_name(struct dma_fence *fence)
{ {
struct seqno_fence *seqno_fence = to_seqno_fence(fence); struct seqno_fence *seqno_fence = to_seqno_fence(fence);
return seqno_fence->ops->get_driver_name(fence); return seqno_fence->ops->get_driver_name(fence);
} }
static const char *seqno_fence_get_timeline_name(struct fence *fence) static const char *seqno_fence_get_timeline_name(struct dma_fence *fence)
{ {
struct seqno_fence *seqno_fence = to_seqno_fence(fence); struct seqno_fence *seqno_fence = to_seqno_fence(fence);
return seqno_fence->ops->get_timeline_name(fence); return seqno_fence->ops->get_timeline_name(fence);
} }
static bool seqno_enable_signaling(struct fence *fence) static bool seqno_enable_signaling(struct dma_fence *fence)
{ {
struct seqno_fence *seqno_fence = to_seqno_fence(fence); struct seqno_fence *seqno_fence = to_seqno_fence(fence);
return seqno_fence->ops->enable_signaling(fence); return seqno_fence->ops->enable_signaling(fence);
} }
static bool seqno_signaled(struct fence *fence) static bool seqno_signaled(struct dma_fence *fence)
{ {
struct seqno_fence *seqno_fence = to_seqno_fence(fence); struct seqno_fence *seqno_fence = to_seqno_fence(fence);
return seqno_fence->ops->signaled && seqno_fence->ops->signaled(fence); return seqno_fence->ops->signaled && seqno_fence->ops->signaled(fence);
} }
static void seqno_release(struct fence *fence) static void seqno_release(struct dma_fence *fence)
{ {
struct seqno_fence *f = to_seqno_fence(fence); struct seqno_fence *f = to_seqno_fence(fence);
...@@ -57,10 +57,10 @@ static void seqno_release(struct fence *fence) ...@@ -57,10 +57,10 @@ static void seqno_release(struct fence *fence)
if (f->ops->release) if (f->ops->release)
f->ops->release(fence); f->ops->release(fence);
else else
fence_free(&f->base); dma_fence_free(&f->base);
} }
static signed long seqno_wait(struct fence *fence, bool intr, static signed long seqno_wait(struct dma_fence *fence, bool intr,
signed long timeout) signed long timeout)
{ {
struct seqno_fence *f = to_seqno_fence(fence); struct seqno_fence *f = to_seqno_fence(fence);
...@@ -68,7 +68,7 @@ static signed long seqno_wait(struct fence *fence, bool intr, ...@@ -68,7 +68,7 @@ static signed long seqno_wait(struct fence *fence, bool intr,
return f->ops->wait(fence, intr, timeout); return f->ops->wait(fence, intr, timeout);
} }
const struct fence_ops seqno_fence_ops = { const struct dma_fence_ops seqno_fence_ops = {
.get_driver_name = seqno_fence_get_driver_name, .get_driver_name = seqno_fence_get_driver_name,
.get_timeline_name = seqno_fence_get_timeline_name, .get_timeline_name = seqno_fence_get_timeline_name,
.enable_signaling = seqno_enable_signaling, .enable_signaling = seqno_enable_signaling,
......
...@@ -68,9 +68,9 @@ struct sw_sync_create_fence_data { ...@@ -68,9 +68,9 @@ struct sw_sync_create_fence_data {
#define SW_SYNC_IOC_INC _IOW(SW_SYNC_IOC_MAGIC, 1, __u32) #define SW_SYNC_IOC_INC _IOW(SW_SYNC_IOC_MAGIC, 1, __u32)
static const struct fence_ops timeline_fence_ops; static const struct dma_fence_ops timeline_fence_ops;
static inline struct sync_pt *fence_to_sync_pt(struct fence *fence) static inline struct sync_pt *dma_fence_to_sync_pt(struct dma_fence *fence)
{ {
if (fence->ops != &timeline_fence_ops) if (fence->ops != &timeline_fence_ops)
return NULL; return NULL;
...@@ -93,7 +93,7 @@ struct sync_timeline *sync_timeline_create(const char *name) ...@@ -93,7 +93,7 @@ struct sync_timeline *sync_timeline_create(const char *name)
return NULL; return NULL;
kref_init(&obj->kref); kref_init(&obj->kref);
obj->context = fence_context_alloc(1); obj->context = dma_fence_context_alloc(1);
strlcpy(obj->name, name, sizeof(obj->name)); strlcpy(obj->name, name, sizeof(obj->name));
INIT_LIST_HEAD(&obj->child_list_head); INIT_LIST_HEAD(&obj->child_list_head);
...@@ -146,7 +146,7 @@ static void sync_timeline_signal(struct sync_timeline *obj, unsigned int inc) ...@@ -146,7 +146,7 @@ static void sync_timeline_signal(struct sync_timeline *obj, unsigned int inc)
list_for_each_entry_safe(pt, next, &obj->active_list_head, list_for_each_entry_safe(pt, next, &obj->active_list_head,
active_list) { active_list) {
if (fence_is_signaled_locked(&pt->base)) if (dma_fence_is_signaled_locked(&pt->base))
list_del_init(&pt->active_list); list_del_init(&pt->active_list);
} }
...@@ -179,7 +179,7 @@ static struct sync_pt *sync_pt_create(struct sync_timeline *obj, int size, ...@@ -179,7 +179,7 @@ static struct sync_pt *sync_pt_create(struct sync_timeline *obj, int size,
spin_lock_irqsave(&obj->child_list_lock, flags); spin_lock_irqsave(&obj->child_list_lock, flags);
sync_timeline_get(obj); sync_timeline_get(obj);
fence_init(&pt->base, &timeline_fence_ops, &obj->child_list_lock, dma_fence_init(&pt->base, &timeline_fence_ops, &obj->child_list_lock,
obj->context, value); obj->context, value);
list_add_tail(&pt->child_list, &obj->child_list_head); list_add_tail(&pt->child_list, &obj->child_list_head);
INIT_LIST_HEAD(&pt->active_list); INIT_LIST_HEAD(&pt->active_list);
...@@ -187,22 +187,22 @@ static struct sync_pt *sync_pt_create(struct sync_timeline *obj, int size, ...@@ -187,22 +187,22 @@ static struct sync_pt *sync_pt_create(struct sync_timeline *obj, int size,
return pt; return pt;
} }
static const char *timeline_fence_get_driver_name(struct fence *fence) static const char *timeline_fence_get_driver_name(struct dma_fence *fence)
{ {
return "sw_sync"; return "sw_sync";
} }
static const char *timeline_fence_get_timeline_name(struct fence *fence) static const char *timeline_fence_get_timeline_name(struct dma_fence *fence)
{ {
struct sync_timeline *parent = fence_parent(fence); struct sync_timeline *parent = dma_fence_parent(fence);
return parent->name; return parent->name;
} }
static void timeline_fence_release(struct fence *fence) static void timeline_fence_release(struct dma_fence *fence)
{ {
struct sync_pt *pt = fence_to_sync_pt(fence); struct sync_pt *pt = dma_fence_to_sync_pt(fence);
struct sync_timeline *parent = fence_parent(fence); struct sync_timeline *parent = dma_fence_parent(fence);
unsigned long flags; unsigned long flags;
spin_lock_irqsave(fence->lock, flags); spin_lock_irqsave(fence->lock, flags);
...@@ -212,20 +212,20 @@ static void timeline_fence_release(struct fence *fence) ...@@ -212,20 +212,20 @@ static void timeline_fence_release(struct fence *fence)
spin_unlock_irqrestore(fence->lock, flags); spin_unlock_irqrestore(fence->lock, flags);
sync_timeline_put(parent); sync_timeline_put(parent);
fence_free(fence); dma_fence_free(fence);
} }
static bool timeline_fence_signaled(struct fence *fence) static bool timeline_fence_signaled(struct dma_fence *fence)
{ {
struct sync_timeline *parent = fence_parent(fence); struct sync_timeline *parent = dma_fence_parent(fence);
return (fence->seqno > parent->value) ? false : true; return (fence->seqno > parent->value) ? false : true;
} }
static bool timeline_fence_enable_signaling(struct fence *fence) static bool timeline_fence_enable_signaling(struct dma_fence *fence)
{ {
struct sync_pt *pt = fence_to_sync_pt(fence); struct sync_pt *pt = dma_fence_to_sync_pt(fence);
struct sync_timeline *parent = fence_parent(fence); struct sync_timeline *parent = dma_fence_parent(fence);
if (timeline_fence_signaled(fence)) if (timeline_fence_signaled(fence))
return false; return false;
...@@ -234,26 +234,26 @@ static bool timeline_fence_enable_signaling(struct fence *fence) ...@@ -234,26 +234,26 @@ static bool timeline_fence_enable_signaling(struct fence *fence)
return true; return true;
} }
static void timeline_fence_value_str(struct fence *fence, static void timeline_fence_value_str(struct dma_fence *fence,
char *str, int size) char *str, int size)
{ {
snprintf(str, size, "%d", fence->seqno); snprintf(str, size, "%d", fence->seqno);
} }
static void timeline_fence_timeline_value_str(struct fence *fence, static void timeline_fence_timeline_value_str(struct dma_fence *fence,
char *str, int size) char *str, int size)
{ {
struct sync_timeline *parent = fence_parent(fence); struct sync_timeline *parent = dma_fence_parent(fence);
snprintf(str, size, "%d", parent->value); snprintf(str, size, "%d", parent->value);
} }
static const struct fence_ops timeline_fence_ops = { static const struct dma_fence_ops timeline_fence_ops = {
.get_driver_name = timeline_fence_get_driver_name, .get_driver_name = timeline_fence_get_driver_name,
.get_timeline_name = timeline_fence_get_timeline_name, .get_timeline_name = timeline_fence_get_timeline_name,
.enable_signaling = timeline_fence_enable_signaling, .enable_signaling = timeline_fence_enable_signaling,
.signaled = timeline_fence_signaled, .signaled = timeline_fence_signaled,
.wait = fence_default_wait, .wait = dma_fence_default_wait,
.release = timeline_fence_release, .release = timeline_fence_release,
.fence_value_str = timeline_fence_value_str, .fence_value_str = timeline_fence_value_str,
.timeline_value_str = timeline_fence_timeline_value_str, .timeline_value_str = timeline_fence_timeline_value_str,
...@@ -317,7 +317,7 @@ static long sw_sync_ioctl_create_fence(struct sync_timeline *obj, ...@@ -317,7 +317,7 @@ static long sw_sync_ioctl_create_fence(struct sync_timeline *obj,
sync_file = sync_file_create(&pt->base); sync_file = sync_file_create(&pt->base);
if (!sync_file) { if (!sync_file) {
fence_put(&pt->base); dma_fence_put(&pt->base);
err = -ENOMEM; err = -ENOMEM;
goto err; goto err;
} }
......
...@@ -71,12 +71,13 @@ static const char *sync_status_str(int status) ...@@ -71,12 +71,13 @@ static const char *sync_status_str(int status)
return "error"; return "error";
} }
static void sync_print_fence(struct seq_file *s, struct fence *fence, bool show) static void sync_print_fence(struct seq_file *s,
struct dma_fence *fence, bool show)
{ {
int status = 1; int status = 1;
struct sync_timeline *parent = fence_parent(fence); struct sync_timeline *parent = dma_fence_parent(fence);
if (fence_is_signaled_locked(fence)) if (dma_fence_is_signaled_locked(fence))
status = fence->status; status = fence->status;
seq_printf(s, " %s%sfence %s", seq_printf(s, " %s%sfence %s",
...@@ -135,10 +136,10 @@ static void sync_print_sync_file(struct seq_file *s, ...@@ -135,10 +136,10 @@ static void sync_print_sync_file(struct seq_file *s,
int i; int i;
seq_printf(s, "[%p] %s: %s\n", sync_file, sync_file->name, seq_printf(s, "[%p] %s: %s\n", sync_file, sync_file->name,
sync_status_str(!fence_is_signaled(sync_file->fence))); sync_status_str(!dma_fence_is_signaled(sync_file->fence)));
if (fence_is_array(sync_file->fence)) { if (dma_fence_is_array(sync_file->fence)) {
struct fence_array *array = to_fence_array(sync_file->fence); struct dma_fence_array *array = to_dma_fence_array(sync_file->fence);
for (i = 0; i < array->num_fences; ++i) for (i = 0; i < array->num_fences; ++i)
sync_print_fence(s, array->fences[i], true); sync_print_fence(s, array->fences[i], true);
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include <linux/list.h> #include <linux/list.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/fence.h> #include <linux/dma-fence.h>
#include <linux/sync_file.h> #include <linux/sync_file.h>
#include <uapi/linux/sync_file.h> #include <uapi/linux/sync_file.h>
...@@ -45,10 +45,9 @@ struct sync_timeline { ...@@ -45,10 +45,9 @@ struct sync_timeline {
struct list_head sync_timeline_list; struct list_head sync_timeline_list;
}; };
static inline struct sync_timeline *fence_parent(struct fence *fence) static inline struct sync_timeline *dma_fence_parent(struct dma_fence *fence)
{ {
return container_of(fence->lock, struct sync_timeline, return container_of(fence->lock, struct sync_timeline, child_list_lock);
child_list_lock);
} }
/** /**
...@@ -58,7 +57,7 @@ static inline struct sync_timeline *fence_parent(struct fence *fence) ...@@ -58,7 +57,7 @@ static inline struct sync_timeline *fence_parent(struct fence *fence)
* @active_list: sync timeline active child's list * @active_list: sync timeline active child's list
*/ */
struct sync_pt { struct sync_pt {
struct fence base; struct dma_fence base;
struct list_head child_list; struct list_head child_list;
struct list_head active_list; struct list_head active_list;
}; };
......
...@@ -54,7 +54,7 @@ static struct sync_file *sync_file_alloc(void) ...@@ -54,7 +54,7 @@ static struct sync_file *sync_file_alloc(void)
return NULL; return NULL;
} }
static void fence_check_cb_func(struct fence *f, struct fence_cb *cb) static void fence_check_cb_func(struct dma_fence *f, struct dma_fence_cb *cb)
{ {
struct sync_file *sync_file; struct sync_file *sync_file;
...@@ -71,7 +71,7 @@ static void fence_check_cb_func(struct fence *f, struct fence_cb *cb) ...@@ -71,7 +71,7 @@ static void fence_check_cb_func(struct fence *f, struct fence_cb *cb)
* takes ownership of @fence. The sync_file can be released with * takes ownership of @fence. The sync_file can be released with
* fput(sync_file->file). Returns the sync_file or NULL in case of error. * fput(sync_file->file). Returns the sync_file or NULL in case of error.
*/ */
struct sync_file *sync_file_create(struct fence *fence) struct sync_file *sync_file_create(struct dma_fence *fence)
{ {
struct sync_file *sync_file; struct sync_file *sync_file;
...@@ -79,7 +79,7 @@ struct sync_file *sync_file_create(struct fence *fence) ...@@ -79,7 +79,7 @@ struct sync_file *sync_file_create(struct fence *fence)
if (!sync_file) if (!sync_file)
return NULL; return NULL;
sync_file->fence = fence_get(fence); sync_file->fence = dma_fence_get(fence);
snprintf(sync_file->name, sizeof(sync_file->name), "%s-%s%llu-%d", snprintf(sync_file->name, sizeof(sync_file->name), "%s-%s%llu-%d",
fence->ops->get_driver_name(fence), fence->ops->get_driver_name(fence),
...@@ -121,16 +121,16 @@ static struct sync_file *sync_file_fdget(int fd) ...@@ -121,16 +121,16 @@ static struct sync_file *sync_file_fdget(int fd)
* Ensures @fd references a valid sync_file and returns a fence that * Ensures @fd references a valid sync_file and returns a fence that
* represents all fence in the sync_file. On error NULL is returned. * represents all fence in the sync_file. On error NULL is returned.
*/ */
struct fence *sync_file_get_fence(int fd) struct dma_fence *sync_file_get_fence(int fd)
{ {
struct sync_file *sync_file; struct sync_file *sync_file;
struct fence *fence; struct dma_fence *fence;
sync_file = sync_file_fdget(fd); sync_file = sync_file_fdget(fd);
if (!sync_file) if (!sync_file)
return NULL; return NULL;
fence = fence_get(sync_file->fence); fence = dma_fence_get(sync_file->fence);
fput(sync_file->file); fput(sync_file->file);
return fence; return fence;
...@@ -138,22 +138,23 @@ struct fence *sync_file_get_fence(int fd) ...@@ -138,22 +138,23 @@ struct fence *sync_file_get_fence(int fd)
EXPORT_SYMBOL(sync_file_get_fence); EXPORT_SYMBOL(sync_file_get_fence);
static int sync_file_set_fence(struct sync_file *sync_file, static int sync_file_set_fence(struct sync_file *sync_file,
struct fence **fences, int num_fences) struct dma_fence **fences, int num_fences)
{ {
struct fence_array *array; struct dma_fence_array *array;
/* /*
* The reference for the fences in the new sync_file and held * The reference for the fences in the new sync_file and held
* in add_fence() during the merge procedure, so for num_fences == 1 * in add_fence() during the merge procedure, so for num_fences == 1
* we already own a new reference to the fence. For num_fence > 1 * we already own a new reference to the fence. For num_fence > 1
* we own the reference of the fence_array creation. * we own the reference of the dma_fence_array creation.
*/ */
if (num_fences == 1) { if (num_fences == 1) {
sync_file->fence = fences[0]; sync_file->fence = fences[0];
kfree(fences); kfree(fences);
} else { } else {
array = fence_array_create(num_fences, fences, array = dma_fence_array_create(num_fences, fences,
fence_context_alloc(1), 1, false); dma_fence_context_alloc(1),
1, false);
if (!array) if (!array)
return -ENOMEM; return -ENOMEM;
...@@ -163,10 +164,11 @@ static int sync_file_set_fence(struct sync_file *sync_file, ...@@ -163,10 +164,11 @@ static int sync_file_set_fence(struct sync_file *sync_file,
return 0; return 0;
} }
static struct fence **get_fences(struct sync_file *sync_file, int *num_fences) static struct dma_fence **get_fences(struct sync_file *sync_file,
int *num_fences)
{ {
if (fence_is_array(sync_file->fence)) { if (dma_fence_is_array(sync_file->fence)) {
struct fence_array *array = to_fence_array(sync_file->fence); struct dma_fence_array *array = to_dma_fence_array(sync_file->fence);
*num_fences = array->num_fences; *num_fences = array->num_fences;
return array->fences; return array->fences;
...@@ -176,12 +178,13 @@ static struct fence **get_fences(struct sync_file *sync_file, int *num_fences) ...@@ -176,12 +178,13 @@ static struct fence **get_fences(struct sync_file *sync_file, int *num_fences)
return &sync_file->fence; return &sync_file->fence;
} }
static void add_fence(struct fence **fences, int *i, struct fence *fence) static void add_fence(struct dma_fence **fences,
int *i, struct dma_fence *fence)
{ {
fences[*i] = fence; fences[*i] = fence;
if (!fence_is_signaled(fence)) { if (!dma_fence_is_signaled(fence)) {
fence_get(fence); dma_fence_get(fence);
(*i)++; (*i)++;
} }
} }
...@@ -200,7 +203,7 @@ static struct sync_file *sync_file_merge(const char *name, struct sync_file *a, ...@@ -200,7 +203,7 @@ static struct sync_file *sync_file_merge(const char *name, struct sync_file *a,
struct sync_file *b) struct sync_file *b)
{ {
struct sync_file *sync_file; struct sync_file *sync_file;
struct fence **fences, **nfences, **a_fences, **b_fences; struct dma_fence **fences, **nfences, **a_fences, **b_fences;
int i, i_a, i_b, num_fences, a_num_fences, b_num_fences; int i, i_a, i_b, num_fences, a_num_fences, b_num_fences;
sync_file = sync_file_alloc(); sync_file = sync_file_alloc();
...@@ -226,8 +229,8 @@ static struct sync_file *sync_file_merge(const char *name, struct sync_file *a, ...@@ -226,8 +229,8 @@ static struct sync_file *sync_file_merge(const char *name, struct sync_file *a,
* and sync_file_create, this is a reasonable assumption. * and sync_file_create, this is a reasonable assumption.
*/ */
for (i = i_a = i_b = 0; i_a < a_num_fences && i_b < b_num_fences; ) { for (i = i_a = i_b = 0; i_a < a_num_fences && i_b < b_num_fences; ) {
struct fence *pt_a = a_fences[i_a]; struct dma_fence *pt_a = a_fences[i_a];
struct fence *pt_b = b_fences[i_b]; struct dma_fence *pt_b = b_fences[i_b];
if (pt_a->context < pt_b->context) { if (pt_a->context < pt_b->context) {
add_fence(fences, &i, pt_a); add_fence(fences, &i, pt_a);
...@@ -255,7 +258,7 @@ static struct sync_file *sync_file_merge(const char *name, struct sync_file *a, ...@@ -255,7 +258,7 @@ static struct sync_file *sync_file_merge(const char *name, struct sync_file *a,
add_fence(fences, &i, b_fences[i_b]); add_fence(fences, &i, b_fences[i_b]);
if (i == 0) if (i == 0)
fences[i++] = fence_get(a_fences[0]); fences[i++] = dma_fence_get(a_fences[0]);
if (num_fences > i) { if (num_fences > i) {
nfences = krealloc(fences, i * sizeof(*fences), nfences = krealloc(fences, i * sizeof(*fences),
...@@ -286,8 +289,8 @@ static void sync_file_free(struct kref *kref) ...@@ -286,8 +289,8 @@ static void sync_file_free(struct kref *kref)
kref); kref);
if (test_bit(POLL_ENABLED, &sync_file->fence->flags)) if (test_bit(POLL_ENABLED, &sync_file->fence->flags))
fence_remove_callback(sync_file->fence, &sync_file->cb); dma_fence_remove_callback(sync_file->fence, &sync_file->cb);
fence_put(sync_file->fence); dma_fence_put(sync_file->fence);
kfree(sync_file); kfree(sync_file);
} }
...@@ -307,12 +310,12 @@ static unsigned int sync_file_poll(struct file *file, poll_table *wait) ...@@ -307,12 +310,12 @@ static unsigned int sync_file_poll(struct file *file, poll_table *wait)
if (!poll_does_not_wait(wait) && if (!poll_does_not_wait(wait) &&
!test_and_set_bit(POLL_ENABLED, &sync_file->fence->flags)) { !test_and_set_bit(POLL_ENABLED, &sync_file->fence->flags)) {
if (fence_add_callback(sync_file->fence, &sync_file->cb, if (dma_fence_add_callback(sync_file->fence, &sync_file->cb,
fence_check_cb_func) < 0) fence_check_cb_func) < 0)
wake_up_all(&sync_file->wq); wake_up_all(&sync_file->wq);
} }
return fence_is_signaled(sync_file->fence) ? POLLIN : 0; return dma_fence_is_signaled(sync_file->fence) ? POLLIN : 0;
} }
static long sync_file_ioctl_merge(struct sync_file *sync_file, static long sync_file_ioctl_merge(struct sync_file *sync_file,
...@@ -370,14 +373,14 @@ static long sync_file_ioctl_merge(struct sync_file *sync_file, ...@@ -370,14 +373,14 @@ static long sync_file_ioctl_merge(struct sync_file *sync_file,
return err; return err;
} }
static void sync_fill_fence_info(struct fence *fence, static void sync_fill_fence_info(struct dma_fence *fence,
struct sync_fence_info *info) struct sync_fence_info *info)
{ {
strlcpy(info->obj_name, fence->ops->get_timeline_name(fence), strlcpy(info->obj_name, fence->ops->get_timeline_name(fence),
sizeof(info->obj_name)); sizeof(info->obj_name));
strlcpy(info->driver_name, fence->ops->get_driver_name(fence), strlcpy(info->driver_name, fence->ops->get_driver_name(fence),
sizeof(info->driver_name)); sizeof(info->driver_name));
if (fence_is_signaled(fence)) if (dma_fence_is_signaled(fence))
info->status = fence->status >= 0 ? 1 : fence->status; info->status = fence->status >= 0 ? 1 : fence->status;
else else
info->status = 0; info->status = 0;
...@@ -389,7 +392,7 @@ static long sync_file_ioctl_fence_info(struct sync_file *sync_file, ...@@ -389,7 +392,7 @@ static long sync_file_ioctl_fence_info(struct sync_file *sync_file,
{ {
struct sync_file_info info; struct sync_file_info info;
struct sync_fence_info *fence_info = NULL; struct sync_fence_info *fence_info = NULL;
struct fence **fences; struct dma_fence **fences;
__u32 size; __u32 size;
int num_fences, ret, i; int num_fences, ret, i;
...@@ -429,7 +432,7 @@ static long sync_file_ioctl_fence_info(struct sync_file *sync_file, ...@@ -429,7 +432,7 @@ static long sync_file_ioctl_fence_info(struct sync_file *sync_file,
no_fences: no_fences:
strlcpy(info.name, sync_file->name, sizeof(info.name)); strlcpy(info.name, sync_file->name, sizeof(info.name));
info.status = fence_is_signaled(sync_file->fence); info.status = dma_fence_is_signaled(sync_file->fence);
info.num_fences = num_fences; info.num_fences = num_fences;
if (copy_to_user((void __user *)arg, &info, sizeof(info))) if (copy_to_user((void __user *)arg, &info, sizeof(info)))
......
...@@ -24,7 +24,7 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \ ...@@ -24,7 +24,7 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \
atombios_encoders.o amdgpu_sa.o atombios_i2c.o \ atombios_encoders.o amdgpu_sa.o atombios_i2c.o \
amdgpu_prime.o amdgpu_vm.o amdgpu_ib.o amdgpu_pll.o \ amdgpu_prime.o amdgpu_vm.o amdgpu_ib.o amdgpu_pll.o \
amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \ amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \
amdgpu_gtt_mgr.o amdgpu_gtt_mgr.o amdgpu_vram_mgr.o
# add asic specific block # add asic specific block
amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \ amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \
......
...@@ -90,7 +90,6 @@ ...@@ -90,7 +90,6 @@
#define ENCODER_OBJECT_ID_INTERNAL_VCE 0x24 #define ENCODER_OBJECT_ID_INTERNAL_VCE 0x24
#define ENCODER_OBJECT_ID_INTERNAL_UNIPHY3 0x25 #define ENCODER_OBJECT_ID_INTERNAL_UNIPHY3 0x25
#define ENCODER_OBJECT_ID_INTERNAL_AMCLK 0x27 #define ENCODER_OBJECT_ID_INTERNAL_AMCLK 0x27
#define ENCODER_OBJECT_ID_VIRTUAL 0x28
#define ENCODER_OBJECT_ID_GENERAL_EXTERNAL_DVO 0xFF #define ENCODER_OBJECT_ID_GENERAL_EXTERNAL_DVO 0xFF
...@@ -120,7 +119,6 @@ ...@@ -120,7 +119,6 @@
#define CONNECTOR_OBJECT_ID_eDP 0x14 #define CONNECTOR_OBJECT_ID_eDP 0x14
#define CONNECTOR_OBJECT_ID_MXM 0x15 #define CONNECTOR_OBJECT_ID_MXM 0x15
#define CONNECTOR_OBJECT_ID_LVDS_eDP 0x16 #define CONNECTOR_OBJECT_ID_LVDS_eDP 0x16
#define CONNECTOR_OBJECT_ID_VIRTUAL 0x17
/* deleted */ /* deleted */
...@@ -149,7 +147,6 @@ ...@@ -149,7 +147,6 @@
#define GRAPH_OBJECT_ENUM_ID5 0x05 #define GRAPH_OBJECT_ENUM_ID5 0x05
#define GRAPH_OBJECT_ENUM_ID6 0x06 #define GRAPH_OBJECT_ENUM_ID6 0x06
#define GRAPH_OBJECT_ENUM_ID7 0x07 #define GRAPH_OBJECT_ENUM_ID7 0x07
#define GRAPH_OBJECT_ENUM_VIRTUAL 0x08
/****************************************************/ /****************************************************/
/* Graphics Object ID Bit definition */ /* Graphics Object ID Bit definition */
...@@ -411,10 +408,6 @@ ...@@ -411,10 +408,6 @@
GRAPH_OBJECT_ENUM_ID1 << ENUM_ID_SHIFT |\ GRAPH_OBJECT_ENUM_ID1 << ENUM_ID_SHIFT |\
ENCODER_OBJECT_ID_HDMI_ANX9805 << OBJECT_ID_SHIFT) ENCODER_OBJECT_ID_HDMI_ANX9805 << OBJECT_ID_SHIFT)
#define ENCODER_VIRTUAL_ENUM_VIRTUAL ( GRAPH_OBJECT_TYPE_ENCODER << OBJECT_TYPE_SHIFT |\
GRAPH_OBJECT_ENUM_VIRTUAL << ENUM_ID_SHIFT |\
ENCODER_OBJECT_ID_VIRTUAL << OBJECT_ID_SHIFT)
/****************************************************/ /****************************************************/
/* Connector Object ID definition - Shared with BIOS */ /* Connector Object ID definition - Shared with BIOS */
/****************************************************/ /****************************************************/
......
This diff is collapsed.
...@@ -265,14 +265,14 @@ static int acp_hw_init(void *handle) ...@@ -265,14 +265,14 @@ static int acp_hw_init(void *handle)
struct amdgpu_device *adev = (struct amdgpu_device *)handle; struct amdgpu_device *adev = (struct amdgpu_device *)handle;
const struct amdgpu_ip_block_version *ip_version = const struct amdgpu_ip_block *ip_block =
amdgpu_get_ip_block(adev, AMD_IP_BLOCK_TYPE_ACP); amdgpu_get_ip_block(adev, AMD_IP_BLOCK_TYPE_ACP);
if (!ip_version) if (!ip_block)
return -EINVAL; return -EINVAL;
r = amd_acp_hw_init(adev->acp.cgs_device, r = amd_acp_hw_init(adev->acp.cgs_device,
ip_version->major, ip_version->minor); ip_block->version->major, ip_block->version->minor);
/* -ENODEV means board uses AZ rather than ACP */ /* -ENODEV means board uses AZ rather than ACP */
if (r == -ENODEV) if (r == -ENODEV)
return 0; return 0;
...@@ -456,7 +456,7 @@ static int acp_set_powergating_state(void *handle, ...@@ -456,7 +456,7 @@ static int acp_set_powergating_state(void *handle,
return 0; return 0;
} }
const struct amd_ip_funcs acp_ip_funcs = { static const struct amd_ip_funcs acp_ip_funcs = {
.name = "acp_ip", .name = "acp_ip",
.early_init = acp_early_init, .early_init = acp_early_init,
.late_init = NULL, .late_init = NULL,
...@@ -472,3 +472,12 @@ const struct amd_ip_funcs acp_ip_funcs = { ...@@ -472,3 +472,12 @@ const struct amd_ip_funcs acp_ip_funcs = {
.set_clockgating_state = acp_set_clockgating_state, .set_clockgating_state = acp_set_clockgating_state,
.set_powergating_state = acp_set_powergating_state, .set_powergating_state = acp_set_powergating_state,
}; };
const struct amdgpu_ip_block_version acp_ip_block =
{
.type = AMD_IP_BLOCK_TYPE_ACP,
.major = 2,
.minor = 2,
.rev = 0,
.funcs = &acp_ip_funcs,
};
...@@ -37,6 +37,6 @@ struct amdgpu_acp { ...@@ -37,6 +37,6 @@ struct amdgpu_acp {
struct acp_pm_domain *acp_genpd; struct acp_pm_domain *acp_genpd;
}; };
extern const struct amd_ip_funcs acp_ip_funcs; extern const struct amdgpu_ip_block_version acp_ip_block;
#endif /* __AMDGPU_ACP_H__ */ #endif /* __AMDGPU_ACP_H__ */
...@@ -1115,49 +1115,6 @@ int amdgpu_atombios_get_memory_pll_dividers(struct amdgpu_device *adev, ...@@ -1115,49 +1115,6 @@ int amdgpu_atombios_get_memory_pll_dividers(struct amdgpu_device *adev,
return 0; return 0;
} }
uint32_t amdgpu_atombios_get_engine_clock(struct amdgpu_device *adev)
{
GET_ENGINE_CLOCK_PS_ALLOCATION args;
int index = GetIndexIntoMasterTable(COMMAND, GetEngineClock);
amdgpu_atom_execute_table(adev->mode_info.atom_context, index, (uint32_t *)&args);
return le32_to_cpu(args.ulReturnEngineClock);
}
uint32_t amdgpu_atombios_get_memory_clock(struct amdgpu_device *adev)
{
GET_MEMORY_CLOCK_PS_ALLOCATION args;
int index = GetIndexIntoMasterTable(COMMAND, GetMemoryClock);
amdgpu_atom_execute_table(adev->mode_info.atom_context, index, (uint32_t *)&args);
return le32_to_cpu(args.ulReturnMemoryClock);
}
void amdgpu_atombios_set_engine_clock(struct amdgpu_device *adev,
uint32_t eng_clock)
{
SET_ENGINE_CLOCK_PS_ALLOCATION args;
int index = GetIndexIntoMasterTable(COMMAND, SetEngineClock);
args.ulTargetEngineClock = cpu_to_le32(eng_clock); /* 10 khz */
amdgpu_atom_execute_table(adev->mode_info.atom_context, index, (uint32_t *)&args);
}
void amdgpu_atombios_set_memory_clock(struct amdgpu_device *adev,
uint32_t mem_clock)
{
SET_MEMORY_CLOCK_PS_ALLOCATION args;
int index = GetIndexIntoMasterTable(COMMAND, SetMemoryClock);
if (adev->flags & AMD_IS_APU)
return;
args.ulTargetMemoryClock = cpu_to_le32(mem_clock); /* 10 khz */
amdgpu_atom_execute_table(adev->mode_info.atom_context, index, (uint32_t *)&args);
}
void amdgpu_atombios_set_engine_dram_timings(struct amdgpu_device *adev, void amdgpu_atombios_set_engine_dram_timings(struct amdgpu_device *adev,
u32 eng_clock, u32 mem_clock) u32 eng_clock, u32 mem_clock)
{ {
...@@ -1256,45 +1213,6 @@ int amdgpu_atombios_get_leakage_vddc_based_on_leakage_idx(struct amdgpu_device * ...@@ -1256,45 +1213,6 @@ int amdgpu_atombios_get_leakage_vddc_based_on_leakage_idx(struct amdgpu_device *
return amdgpu_atombios_get_max_vddc(adev, VOLTAGE_TYPE_VDDC, leakage_idx, voltage); return amdgpu_atombios_get_max_vddc(adev, VOLTAGE_TYPE_VDDC, leakage_idx, voltage);
} }
void amdgpu_atombios_set_voltage(struct amdgpu_device *adev,
u16 voltage_level,
u8 voltage_type)
{
union set_voltage args;
int index = GetIndexIntoMasterTable(COMMAND, SetVoltage);
u8 frev, crev, volt_index = voltage_level;
if (!amdgpu_atom_parse_cmd_header(adev->mode_info.atom_context, index, &frev, &crev))
return;
/* 0xff01 is a flag rather then an actual voltage */
if (voltage_level == 0xff01)
return;
switch (crev) {
case 1:
args.v1.ucVoltageType = voltage_type;
args.v1.ucVoltageMode = SET_ASIC_VOLTAGE_MODE_ALL_SOURCE;
args.v1.ucVoltageIndex = volt_index;
break;
case 2:
args.v2.ucVoltageType = voltage_type;
args.v2.ucVoltageMode = SET_ASIC_VOLTAGE_MODE_SET_VOLTAGE;
args.v2.usVoltageLevel = cpu_to_le16(voltage_level);
break;
case 3:
args.v3.ucVoltageType = voltage_type;
args.v3.ucVoltageMode = ATOM_SET_VOLTAGE;
args.v3.usVoltageLevel = cpu_to_le16(voltage_level);
break;
default:
DRM_ERROR("Unknown table version %d, %d\n", frev, crev);
return;
}
amdgpu_atom_execute_table(adev->mode_info.atom_context, index, (uint32_t *)&args);
}
int amdgpu_atombios_get_leakage_id_from_vbios(struct amdgpu_device *adev, int amdgpu_atombios_get_leakage_id_from_vbios(struct amdgpu_device *adev,
u16 *leakage_id) u16 *leakage_id)
{ {
...@@ -1784,6 +1702,19 @@ void amdgpu_atombios_scratch_regs_restore(struct amdgpu_device *adev) ...@@ -1784,6 +1702,19 @@ void amdgpu_atombios_scratch_regs_restore(struct amdgpu_device *adev)
WREG32(mmBIOS_SCRATCH_0 + i, adev->bios_scratch[i]); WREG32(mmBIOS_SCRATCH_0 + i, adev->bios_scratch[i]);
} }
void amdgpu_atombios_scratch_regs_engine_hung(struct amdgpu_device *adev,
bool hung)
{
u32 tmp = RREG32(mmBIOS_SCRATCH_3);
if (hung)
tmp |= ATOM_S3_ASIC_GUI_ENGINE_HUNG;
else
tmp &= ~ATOM_S3_ASIC_GUI_ENGINE_HUNG;
WREG32(mmBIOS_SCRATCH_3, tmp);
}
/* Atom needs data in little endian format /* Atom needs data in little endian format
* so swap as appropriate when copying data to * so swap as appropriate when copying data to
* or from atom. Note that atom operates on * or from atom. Note that atom operates on
......
...@@ -163,16 +163,6 @@ int amdgpu_atombios_get_memory_pll_dividers(struct amdgpu_device *adev, ...@@ -163,16 +163,6 @@ int amdgpu_atombios_get_memory_pll_dividers(struct amdgpu_device *adev,
bool strobe_mode, bool strobe_mode,
struct atom_mpll_param *mpll_param); struct atom_mpll_param *mpll_param);
uint32_t amdgpu_atombios_get_engine_clock(struct amdgpu_device *adev);
uint32_t amdgpu_atombios_get_memory_clock(struct amdgpu_device *adev);
void amdgpu_atombios_set_engine_clock(struct amdgpu_device *adev,
uint32_t eng_clock);
void amdgpu_atombios_set_memory_clock(struct amdgpu_device *adev,
uint32_t mem_clock);
void amdgpu_atombios_set_voltage(struct amdgpu_device *adev,
u16 voltage_level,
u8 voltage_type);
void amdgpu_atombios_set_engine_dram_timings(struct amdgpu_device *adev, void amdgpu_atombios_set_engine_dram_timings(struct amdgpu_device *adev,
u32 eng_clock, u32 mem_clock); u32 eng_clock, u32 mem_clock);
...@@ -206,6 +196,8 @@ void amdgpu_atombios_scratch_regs_lock(struct amdgpu_device *adev, bool lock); ...@@ -206,6 +196,8 @@ void amdgpu_atombios_scratch_regs_lock(struct amdgpu_device *adev, bool lock);
void amdgpu_atombios_scratch_regs_init(struct amdgpu_device *adev); void amdgpu_atombios_scratch_regs_init(struct amdgpu_device *adev);
void amdgpu_atombios_scratch_regs_save(struct amdgpu_device *adev); void amdgpu_atombios_scratch_regs_save(struct amdgpu_device *adev);
void amdgpu_atombios_scratch_regs_restore(struct amdgpu_device *adev); void amdgpu_atombios_scratch_regs_restore(struct amdgpu_device *adev);
void amdgpu_atombios_scratch_regs_engine_hung(struct amdgpu_device *adev,
bool hung);
void amdgpu_atombios_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le); void amdgpu_atombios_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le);
int amdgpu_atombios_get_max_vddc(struct amdgpu_device *adev, u8 voltage_type, int amdgpu_atombios_get_max_vddc(struct amdgpu_device *adev, u8 voltage_type,
......
...@@ -33,7 +33,7 @@ static int amdgpu_benchmark_do_move(struct amdgpu_device *adev, unsigned size, ...@@ -33,7 +33,7 @@ static int amdgpu_benchmark_do_move(struct amdgpu_device *adev, unsigned size,
{ {
unsigned long start_jiffies; unsigned long start_jiffies;
unsigned long end_jiffies; unsigned long end_jiffies;
struct fence *fence = NULL; struct dma_fence *fence = NULL;
int i, r; int i, r;
start_jiffies = jiffies; start_jiffies = jiffies;
...@@ -43,17 +43,17 @@ static int amdgpu_benchmark_do_move(struct amdgpu_device *adev, unsigned size, ...@@ -43,17 +43,17 @@ static int amdgpu_benchmark_do_move(struct amdgpu_device *adev, unsigned size,
false); false);
if (r) if (r)
goto exit_do_move; goto exit_do_move;
r = fence_wait(fence, false); r = dma_fence_wait(fence, false);
if (r) if (r)
goto exit_do_move; goto exit_do_move;
fence_put(fence); dma_fence_put(fence);
} }
end_jiffies = jiffies; end_jiffies = jiffies;
r = jiffies_to_msecs(end_jiffies - start_jiffies); r = jiffies_to_msecs(end_jiffies - start_jiffies);
exit_do_move: exit_do_move:
if (fence) if (fence)
fence_put(fence); dma_fence_put(fence);
return r; return r;
} }
......
...@@ -146,7 +146,8 @@ static int amdgpu_cgs_alloc_gpu_mem(struct cgs_device *cgs_device, ...@@ -146,7 +146,8 @@ static int amdgpu_cgs_alloc_gpu_mem(struct cgs_device *cgs_device,
switch(type) { switch(type) {
case CGS_GPU_MEM_TYPE__VISIBLE_CONTIG_FB: case CGS_GPU_MEM_TYPE__VISIBLE_CONTIG_FB:
case CGS_GPU_MEM_TYPE__VISIBLE_FB: case CGS_GPU_MEM_TYPE__VISIBLE_FB:
flags = AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED; flags = AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
domain = AMDGPU_GEM_DOMAIN_VRAM; domain = AMDGPU_GEM_DOMAIN_VRAM;
if (max_offset > adev->mc.real_vram_size) if (max_offset > adev->mc.real_vram_size)
return -EINVAL; return -EINVAL;
...@@ -157,7 +158,8 @@ static int amdgpu_cgs_alloc_gpu_mem(struct cgs_device *cgs_device, ...@@ -157,7 +158,8 @@ static int amdgpu_cgs_alloc_gpu_mem(struct cgs_device *cgs_device,
break; break;
case CGS_GPU_MEM_TYPE__INVISIBLE_CONTIG_FB: case CGS_GPU_MEM_TYPE__INVISIBLE_CONTIG_FB:
case CGS_GPU_MEM_TYPE__INVISIBLE_FB: case CGS_GPU_MEM_TYPE__INVISIBLE_FB:
flags = AMDGPU_GEM_CREATE_NO_CPU_ACCESS; flags = AMDGPU_GEM_CREATE_NO_CPU_ACCESS |
AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
domain = AMDGPU_GEM_DOMAIN_VRAM; domain = AMDGPU_GEM_DOMAIN_VRAM;
if (adev->mc.visible_vram_size < adev->mc.real_vram_size) { if (adev->mc.visible_vram_size < adev->mc.real_vram_size) {
place.fpfn = place.fpfn =
...@@ -240,7 +242,7 @@ static int amdgpu_cgs_gmap_gpu_mem(struct cgs_device *cgs_device, cgs_handle_t h ...@@ -240,7 +242,7 @@ static int amdgpu_cgs_gmap_gpu_mem(struct cgs_device *cgs_device, cgs_handle_t h
r = amdgpu_bo_reserve(obj, false); r = amdgpu_bo_reserve(obj, false);
if (unlikely(r != 0)) if (unlikely(r != 0))
return r; return r;
r = amdgpu_bo_pin_restricted(obj, AMDGPU_GEM_DOMAIN_GTT, r = amdgpu_bo_pin_restricted(obj, obj->prefered_domains,
min_offset, max_offset, mcaddr); min_offset, max_offset, mcaddr);
amdgpu_bo_unreserve(obj); amdgpu_bo_unreserve(obj);
return r; return r;
...@@ -624,11 +626,11 @@ static int amdgpu_cgs_set_clockgating_state(struct cgs_device *cgs_device, ...@@ -624,11 +626,11 @@ static int amdgpu_cgs_set_clockgating_state(struct cgs_device *cgs_device,
int i, r = -1; int i, r = -1;
for (i = 0; i < adev->num_ip_blocks; i++) { for (i = 0; i < adev->num_ip_blocks; i++) {
if (!adev->ip_block_status[i].valid) if (!adev->ip_blocks[i].status.valid)
continue; continue;
if (adev->ip_blocks[i].type == block_type) { if (adev->ip_blocks[i].version->type == block_type) {
r = adev->ip_blocks[i].funcs->set_clockgating_state( r = adev->ip_blocks[i].version->funcs->set_clockgating_state(
(void *)adev, (void *)adev,
state); state);
break; break;
...@@ -645,11 +647,11 @@ static int amdgpu_cgs_set_powergating_state(struct cgs_device *cgs_device, ...@@ -645,11 +647,11 @@ static int amdgpu_cgs_set_powergating_state(struct cgs_device *cgs_device,
int i, r = -1; int i, r = -1;
for (i = 0; i < adev->num_ip_blocks; i++) { for (i = 0; i < adev->num_ip_blocks; i++) {
if (!adev->ip_block_status[i].valid) if (!adev->ip_blocks[i].status.valid)
continue; continue;
if (adev->ip_blocks[i].type == block_type) { if (adev->ip_blocks[i].version->type == block_type) {
r = adev->ip_blocks[i].funcs->set_powergating_state( r = adev->ip_blocks[i].version->funcs->set_powergating_state(
(void *)adev, (void *)adev,
state); state);
break; break;
...@@ -685,15 +687,21 @@ static uint32_t fw_type_convert(struct cgs_device *cgs_device, uint32_t fw_type) ...@@ -685,15 +687,21 @@ static uint32_t fw_type_convert(struct cgs_device *cgs_device, uint32_t fw_type)
result = AMDGPU_UCODE_ID_CP_MEC1; result = AMDGPU_UCODE_ID_CP_MEC1;
break; break;
case CGS_UCODE_ID_CP_MEC_JT2: case CGS_UCODE_ID_CP_MEC_JT2:
if (adev->asic_type == CHIP_TONGA || adev->asic_type == CHIP_POLARIS11 /* for VI. JT2 should be the same as JT1, because:
|| adev->asic_type == CHIP_POLARIS10) 1, MEC2 and MEC1 use exactly same FW.
result = AMDGPU_UCODE_ID_CP_MEC2; 2, JT2 is not pached but JT1 is.
else */
if (adev->asic_type >= CHIP_TOPAZ)
result = AMDGPU_UCODE_ID_CP_MEC1; result = AMDGPU_UCODE_ID_CP_MEC1;
else
result = AMDGPU_UCODE_ID_CP_MEC2;
break; break;
case CGS_UCODE_ID_RLC_G: case CGS_UCODE_ID_RLC_G:
result = AMDGPU_UCODE_ID_RLC_G; result = AMDGPU_UCODE_ID_RLC_G;
break; break;
case CGS_UCODE_ID_STORAGE:
result = AMDGPU_UCODE_ID_STORAGE;
break;
default: default:
DRM_ERROR("Firmware type not supported\n"); DRM_ERROR("Firmware type not supported\n");
} }
...@@ -776,12 +784,18 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device, ...@@ -776,12 +784,18 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
if ((type == CGS_UCODE_ID_CP_MEC_JT1) || if ((type == CGS_UCODE_ID_CP_MEC_JT1) ||
(type == CGS_UCODE_ID_CP_MEC_JT2)) { (type == CGS_UCODE_ID_CP_MEC_JT2)) {
gpu_addr += le32_to_cpu(header->jt_offset) << 2; gpu_addr += ALIGN(le32_to_cpu(header->header.ucode_size_bytes), PAGE_SIZE);
data_size = le32_to_cpu(header->jt_size) << 2; data_size = le32_to_cpu(header->jt_size) << 2;
} }
info->mc_addr = gpu_addr;
info->kptr = ucode->kaddr;
info->image_size = data_size; info->image_size = data_size;
info->mc_addr = gpu_addr;
info->version = (uint16_t)le32_to_cpu(header->header.ucode_version); info->version = (uint16_t)le32_to_cpu(header->header.ucode_version);
if (CGS_UCODE_ID_CP_MEC == type)
info->image_size = (header->jt_offset) << 2;
info->fw_version = amdgpu_get_firmware_version(cgs_device, type); info->fw_version = amdgpu_get_firmware_version(cgs_device, type);
info->feature_version = (uint16_t)le32_to_cpu(header->ucode_feature_version); info->feature_version = (uint16_t)le32_to_cpu(header->ucode_feature_version);
} else { } else {
...@@ -851,6 +865,12 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device, ...@@ -851,6 +865,12 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
return 0; return 0;
} }
static int amdgpu_cgs_is_virtualization_enabled(void *cgs_device)
{
CGS_FUNC_ADEV;
return amdgpu_sriov_vf(adev);
}
static int amdgpu_cgs_query_system_info(struct cgs_device *cgs_device, static int amdgpu_cgs_query_system_info(struct cgs_device *cgs_device,
struct cgs_system_info *sys_info) struct cgs_system_info *sys_info)
{ {
...@@ -1204,6 +1224,7 @@ static const struct cgs_ops amdgpu_cgs_ops = { ...@@ -1204,6 +1224,7 @@ static const struct cgs_ops amdgpu_cgs_ops = {
amdgpu_cgs_notify_dpm_enabled, amdgpu_cgs_notify_dpm_enabled,
amdgpu_cgs_call_acpi_method, amdgpu_cgs_call_acpi_method,
amdgpu_cgs_query_system_info, amdgpu_cgs_query_system_info,
amdgpu_cgs_is_virtualization_enabled
}; };
static const struct cgs_os_ops amdgpu_cgs_os_ops = { static const struct cgs_os_ops amdgpu_cgs_os_ops = {
......
...@@ -1517,88 +1517,6 @@ static const struct drm_connector_funcs amdgpu_connector_edp_funcs = { ...@@ -1517,88 +1517,6 @@ static const struct drm_connector_funcs amdgpu_connector_edp_funcs = {
.force = amdgpu_connector_dvi_force, .force = amdgpu_connector_dvi_force,
}; };
static struct drm_encoder *
amdgpu_connector_virtual_encoder(struct drm_connector *connector)
{
int enc_id = connector->encoder_ids[0];
struct drm_encoder *encoder;
int i;
for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
if (connector->encoder_ids[i] == 0)
break;
encoder = drm_encoder_find(connector->dev, connector->encoder_ids[i]);
if (!encoder)
continue;
if (encoder->encoder_type == DRM_MODE_ENCODER_VIRTUAL)
return encoder;
}
/* pick the first one */
if (enc_id)
return drm_encoder_find(connector->dev, enc_id);
return NULL;
}
static int amdgpu_connector_virtual_get_modes(struct drm_connector *connector)
{
struct drm_encoder *encoder = amdgpu_connector_best_single_encoder(connector);
if (encoder) {
amdgpu_connector_add_common_modes(encoder, connector);
}
return 0;
}
static int amdgpu_connector_virtual_mode_valid(struct drm_connector *connector,
struct drm_display_mode *mode)
{
return MODE_OK;
}
static int
amdgpu_connector_virtual_dpms(struct drm_connector *connector, int mode)
{
return 0;
}
static enum drm_connector_status
amdgpu_connector_virtual_detect(struct drm_connector *connector, bool force)
{
return connector_status_connected;
}
static int
amdgpu_connector_virtual_set_property(struct drm_connector *connector,
struct drm_property *property,
uint64_t val)
{
return 0;
}
static void amdgpu_connector_virtual_force(struct drm_connector *connector)
{
return;
}
static const struct drm_connector_helper_funcs amdgpu_connector_virtual_helper_funcs = {
.get_modes = amdgpu_connector_virtual_get_modes,
.mode_valid = amdgpu_connector_virtual_mode_valid,
.best_encoder = amdgpu_connector_virtual_encoder,
};
static const struct drm_connector_funcs amdgpu_connector_virtual_funcs = {
.dpms = amdgpu_connector_virtual_dpms,
.detect = amdgpu_connector_virtual_detect,
.fill_modes = drm_helper_probe_single_connector_modes,
.set_property = amdgpu_connector_virtual_set_property,
.destroy = amdgpu_connector_destroy,
.force = amdgpu_connector_virtual_force,
};
void void
amdgpu_connector_add(struct amdgpu_device *adev, amdgpu_connector_add(struct amdgpu_device *adev,
uint32_t connector_id, uint32_t connector_id,
...@@ -1983,17 +1901,6 @@ amdgpu_connector_add(struct amdgpu_device *adev, ...@@ -1983,17 +1901,6 @@ amdgpu_connector_add(struct amdgpu_device *adev,
connector->interlace_allowed = false; connector->interlace_allowed = false;
connector->doublescan_allowed = false; connector->doublescan_allowed = false;
break; break;
case DRM_MODE_CONNECTOR_VIRTUAL:
amdgpu_dig_connector = kzalloc(sizeof(struct amdgpu_connector_atom_dig), GFP_KERNEL);
if (!amdgpu_dig_connector)
goto failed;
amdgpu_connector->con_priv = amdgpu_dig_connector;
drm_connector_init(dev, &amdgpu_connector->base, &amdgpu_connector_virtual_funcs, connector_type);
drm_connector_helper_add(&amdgpu_connector->base, &amdgpu_connector_virtual_helper_funcs);
subpixel_order = SubPixelHorizontalRGB;
connector->interlace_allowed = false;
connector->doublescan_allowed = false;
break;
} }
} }
......
...@@ -355,6 +355,7 @@ static void amdgpu_cs_report_moved_bytes(struct amdgpu_device *adev, ...@@ -355,6 +355,7 @@ static void amdgpu_cs_report_moved_bytes(struct amdgpu_device *adev,
static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p, static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p,
struct amdgpu_bo *bo) struct amdgpu_bo *bo)
{ {
struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
u64 initial_bytes_moved; u64 initial_bytes_moved;
uint32_t domain; uint32_t domain;
int r; int r;
...@@ -372,9 +373,9 @@ static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p, ...@@ -372,9 +373,9 @@ static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p,
retry: retry:
amdgpu_ttm_placement_from_domain(bo, domain); amdgpu_ttm_placement_from_domain(bo, domain);
initial_bytes_moved = atomic64_read(&bo->adev->num_bytes_moved); initial_bytes_moved = atomic64_read(&adev->num_bytes_moved);
r = ttm_bo_validate(&bo->tbo, &bo->placement, true, false); r = ttm_bo_validate(&bo->tbo, &bo->placement, true, false);
p->bytes_moved += atomic64_read(&bo->adev->num_bytes_moved) - p->bytes_moved += atomic64_read(&adev->num_bytes_moved) -
initial_bytes_moved; initial_bytes_moved;
if (unlikely(r == -ENOMEM) && domain != bo->allowed_domains) { if (unlikely(r == -ENOMEM) && domain != bo->allowed_domains) {
...@@ -387,9 +388,9 @@ static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p, ...@@ -387,9 +388,9 @@ static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p,
/* Last resort, try to evict something from the current working set */ /* Last resort, try to evict something from the current working set */
static bool amdgpu_cs_try_evict(struct amdgpu_cs_parser *p, static bool amdgpu_cs_try_evict(struct amdgpu_cs_parser *p,
struct amdgpu_bo_list_entry *lobj) struct amdgpu_bo *validated)
{ {
uint32_t domain = lobj->robj->allowed_domains; uint32_t domain = validated->allowed_domains;
int r; int r;
if (!p->evictable) if (!p->evictable)
...@@ -400,11 +401,12 @@ static bool amdgpu_cs_try_evict(struct amdgpu_cs_parser *p, ...@@ -400,11 +401,12 @@ static bool amdgpu_cs_try_evict(struct amdgpu_cs_parser *p,
struct amdgpu_bo_list_entry *candidate = p->evictable; struct amdgpu_bo_list_entry *candidate = p->evictable;
struct amdgpu_bo *bo = candidate->robj; struct amdgpu_bo *bo = candidate->robj;
struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
u64 initial_bytes_moved; u64 initial_bytes_moved;
uint32_t other; uint32_t other;
/* If we reached our current BO we can forget it */ /* If we reached our current BO we can forget it */
if (candidate == lobj) if (candidate->robj == validated)
break; break;
other = amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type); other = amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type);
...@@ -420,9 +422,9 @@ static bool amdgpu_cs_try_evict(struct amdgpu_cs_parser *p, ...@@ -420,9 +422,9 @@ static bool amdgpu_cs_try_evict(struct amdgpu_cs_parser *p,
/* Good we can try to move this BO somewhere else */ /* Good we can try to move this BO somewhere else */
amdgpu_ttm_placement_from_domain(bo, other); amdgpu_ttm_placement_from_domain(bo, other);
initial_bytes_moved = atomic64_read(&bo->adev->num_bytes_moved); initial_bytes_moved = atomic64_read(&adev->num_bytes_moved);
r = ttm_bo_validate(&bo->tbo, &bo->placement, true, false); r = ttm_bo_validate(&bo->tbo, &bo->placement, true, false);
p->bytes_moved += atomic64_read(&bo->adev->num_bytes_moved) - p->bytes_moved += atomic64_read(&adev->num_bytes_moved) -
initial_bytes_moved; initial_bytes_moved;
if (unlikely(r)) if (unlikely(r))
...@@ -437,6 +439,23 @@ static bool amdgpu_cs_try_evict(struct amdgpu_cs_parser *p, ...@@ -437,6 +439,23 @@ static bool amdgpu_cs_try_evict(struct amdgpu_cs_parser *p,
return false; return false;
} }
static int amdgpu_cs_validate(void *param, struct amdgpu_bo *bo)
{
struct amdgpu_cs_parser *p = param;
int r;
do {
r = amdgpu_cs_bo_validate(p, bo);
} while (r == -ENOMEM && amdgpu_cs_try_evict(p, bo));
if (r)
return r;
if (bo->shadow)
r = amdgpu_cs_bo_validate(p, bo);
return r;
}
static int amdgpu_cs_list_validate(struct amdgpu_cs_parser *p, static int amdgpu_cs_list_validate(struct amdgpu_cs_parser *p,
struct list_head *validated) struct list_head *validated)
{ {
...@@ -464,18 +483,10 @@ static int amdgpu_cs_list_validate(struct amdgpu_cs_parser *p, ...@@ -464,18 +483,10 @@ static int amdgpu_cs_list_validate(struct amdgpu_cs_parser *p,
if (p->evictable == lobj) if (p->evictable == lobj)
p->evictable = NULL; p->evictable = NULL;
do { r = amdgpu_cs_validate(p, bo);
r = amdgpu_cs_bo_validate(p, bo);
} while (r == -ENOMEM && amdgpu_cs_try_evict(p, lobj));
if (r) if (r)
return r; return r;
if (bo->shadow) {
r = amdgpu_cs_bo_validate(p, bo);
if (r)
return r;
}
if (binding_userptr) { if (binding_userptr) {
drm_free_large(lobj->user_pages); drm_free_large(lobj->user_pages);
lobj->user_pages = NULL; lobj->user_pages = NULL;
...@@ -593,14 +604,19 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p, ...@@ -593,14 +604,19 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
list_splice(&need_pages, &p->validated); list_splice(&need_pages, &p->validated);
} }
amdgpu_vm_get_pt_bos(p->adev, &fpriv->vm, &duplicates);
p->bytes_moved_threshold = amdgpu_cs_get_threshold_for_moves(p->adev); p->bytes_moved_threshold = amdgpu_cs_get_threshold_for_moves(p->adev);
p->bytes_moved = 0; p->bytes_moved = 0;
p->evictable = list_last_entry(&p->validated, p->evictable = list_last_entry(&p->validated,
struct amdgpu_bo_list_entry, struct amdgpu_bo_list_entry,
tv.head); tv.head);
r = amdgpu_vm_validate_pt_bos(p->adev, &fpriv->vm,
amdgpu_cs_validate, p);
if (r) {
DRM_ERROR("amdgpu_vm_validate_pt_bos() failed.\n");
goto error_validate;
}
r = amdgpu_cs_list_validate(p, &duplicates); r = amdgpu_cs_list_validate(p, &duplicates);
if (r) { if (r) {
DRM_ERROR("amdgpu_cs_list_validate(duplicates) failed.\n"); DRM_ERROR("amdgpu_cs_list_validate(duplicates) failed.\n");
...@@ -719,7 +735,7 @@ static void amdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser, int error, bo ...@@ -719,7 +735,7 @@ static void amdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser, int error, bo
ttm_eu_backoff_reservation(&parser->ticket, ttm_eu_backoff_reservation(&parser->ticket,
&parser->validated); &parser->validated);
} }
fence_put(parser->fence); dma_fence_put(parser->fence);
if (parser->ctx) if (parser->ctx)
amdgpu_ctx_put(parser->ctx); amdgpu_ctx_put(parser->ctx);
...@@ -756,7 +772,7 @@ static int amdgpu_bo_vm_update_pte(struct amdgpu_cs_parser *p, ...@@ -756,7 +772,7 @@ static int amdgpu_bo_vm_update_pte(struct amdgpu_cs_parser *p,
if (p->bo_list) { if (p->bo_list) {
for (i = 0; i < p->bo_list->num_entries; i++) { for (i = 0; i < p->bo_list->num_entries; i++) {
struct fence *f; struct dma_fence *f;
/* ignore duplicates */ /* ignore duplicates */
bo = p->bo_list->array[i].robj; bo = p->bo_list->array[i].robj;
...@@ -806,13 +822,14 @@ static int amdgpu_cs_ib_vm_chunk(struct amdgpu_device *adev, ...@@ -806,13 +822,14 @@ static int amdgpu_cs_ib_vm_chunk(struct amdgpu_device *adev,
/* Only for UVD/VCE VM emulation */ /* Only for UVD/VCE VM emulation */
if (ring->funcs->parse_cs) { if (ring->funcs->parse_cs) {
p->job->vm = NULL;
for (i = 0; i < p->job->num_ibs; i++) { for (i = 0; i < p->job->num_ibs; i++) {
r = amdgpu_ring_parse_cs(ring, p, i); r = amdgpu_ring_parse_cs(ring, p, i);
if (r) if (r)
return r; return r;
} }
} else { }
if (p->job->vm) {
p->job->vm_pd_addr = amdgpu_bo_gpu_offset(vm->page_directory); p->job->vm_pd_addr = amdgpu_bo_gpu_offset(vm->page_directory);
r = amdgpu_bo_vm_update_pte(p, vm); r = amdgpu_bo_vm_update_pte(p, vm);
...@@ -901,7 +918,7 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev, ...@@ -901,7 +918,7 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev,
offset = ((uint64_t)m->it.start) * AMDGPU_GPU_PAGE_SIZE; offset = ((uint64_t)m->it.start) * AMDGPU_GPU_PAGE_SIZE;
kptr += chunk_ib->va_start - offset; kptr += chunk_ib->va_start - offset;
r = amdgpu_ib_get(adev, NULL, chunk_ib->ib_bytes, ib); r = amdgpu_ib_get(adev, vm, chunk_ib->ib_bytes, ib);
if (r) { if (r) {
DRM_ERROR("Failed to get ib !\n"); DRM_ERROR("Failed to get ib !\n");
return r; return r;
...@@ -916,9 +933,9 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev, ...@@ -916,9 +933,9 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev,
return r; return r;
} }
ib->gpu_addr = chunk_ib->va_start;
} }
ib->gpu_addr = chunk_ib->va_start;
ib->length_dw = chunk_ib->ib_bytes / 4; ib->length_dw = chunk_ib->ib_bytes / 4;
ib->flags = chunk_ib->flags; ib->flags = chunk_ib->flags;
j++; j++;
...@@ -926,8 +943,8 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev, ...@@ -926,8 +943,8 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev,
/* UVD & VCE fw doesn't support user fences */ /* UVD & VCE fw doesn't support user fences */
if (parser->job->uf_addr && ( if (parser->job->uf_addr && (
parser->job->ring->type == AMDGPU_RING_TYPE_UVD || parser->job->ring->funcs->type == AMDGPU_RING_TYPE_UVD ||
parser->job->ring->type == AMDGPU_RING_TYPE_VCE)) parser->job->ring->funcs->type == AMDGPU_RING_TYPE_VCE))
return -EINVAL; return -EINVAL;
return 0; return 0;
...@@ -956,7 +973,7 @@ static int amdgpu_cs_dependencies(struct amdgpu_device *adev, ...@@ -956,7 +973,7 @@ static int amdgpu_cs_dependencies(struct amdgpu_device *adev,
for (j = 0; j < num_deps; ++j) { for (j = 0; j < num_deps; ++j) {
struct amdgpu_ring *ring; struct amdgpu_ring *ring;
struct amdgpu_ctx *ctx; struct amdgpu_ctx *ctx;
struct fence *fence; struct dma_fence *fence;
r = amdgpu_cs_get_ring(adev, deps[j].ip_type, r = amdgpu_cs_get_ring(adev, deps[j].ip_type,
deps[j].ip_instance, deps[j].ip_instance,
...@@ -978,7 +995,7 @@ static int amdgpu_cs_dependencies(struct amdgpu_device *adev, ...@@ -978,7 +995,7 @@ static int amdgpu_cs_dependencies(struct amdgpu_device *adev,
} else if (fence) { } else if (fence) {
r = amdgpu_sync_fence(adev, &p->job->sync, r = amdgpu_sync_fence(adev, &p->job->sync,
fence); fence);
fence_put(fence); dma_fence_put(fence);
amdgpu_ctx_put(ctx); amdgpu_ctx_put(ctx);
if (r) if (r)
return r; return r;
...@@ -1008,7 +1025,7 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, ...@@ -1008,7 +1025,7 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
job->owner = p->filp; job->owner = p->filp;
job->fence_ctx = entity->fence_context; job->fence_ctx = entity->fence_context;
p->fence = fence_get(&job->base.s_fence->finished); p->fence = dma_fence_get(&job->base.s_fence->finished);
cs->out.handle = amdgpu_ctx_add_fence(p->ctx, ring, p->fence); cs->out.handle = amdgpu_ctx_add_fence(p->ctx, ring, p->fence);
job->uf_sequence = cs->out.handle; job->uf_sequence = cs->out.handle;
amdgpu_job_free_resources(job); amdgpu_job_free_resources(job);
...@@ -1091,7 +1108,7 @@ int amdgpu_cs_wait_ioctl(struct drm_device *dev, void *data, ...@@ -1091,7 +1108,7 @@ int amdgpu_cs_wait_ioctl(struct drm_device *dev, void *data,
unsigned long timeout = amdgpu_gem_timeout(wait->in.timeout); unsigned long timeout = amdgpu_gem_timeout(wait->in.timeout);
struct amdgpu_ring *ring = NULL; struct amdgpu_ring *ring = NULL;
struct amdgpu_ctx *ctx; struct amdgpu_ctx *ctx;
struct fence *fence; struct dma_fence *fence;
long r; long r;
r = amdgpu_cs_get_ring(adev, wait->in.ip_type, wait->in.ip_instance, r = amdgpu_cs_get_ring(adev, wait->in.ip_type, wait->in.ip_instance,
...@@ -1107,8 +1124,8 @@ int amdgpu_cs_wait_ioctl(struct drm_device *dev, void *data, ...@@ -1107,8 +1124,8 @@ int amdgpu_cs_wait_ioctl(struct drm_device *dev, void *data,
if (IS_ERR(fence)) if (IS_ERR(fence))
r = PTR_ERR(fence); r = PTR_ERR(fence);
else if (fence) { else if (fence) {
r = fence_wait_timeout(fence, true, timeout); r = dma_fence_wait_timeout(fence, true, timeout);
fence_put(fence); dma_fence_put(fence);
} else } else
r = 1; r = 1;
...@@ -1195,6 +1212,15 @@ int amdgpu_cs_sysvm_access_required(struct amdgpu_cs_parser *parser) ...@@ -1195,6 +1212,15 @@ int amdgpu_cs_sysvm_access_required(struct amdgpu_cs_parser *parser)
r = amdgpu_ttm_bind(&bo->tbo, &bo->tbo.mem); r = amdgpu_ttm_bind(&bo->tbo, &bo->tbo.mem);
if (unlikely(r)) if (unlikely(r))
return r; return r;
if (bo->flags & AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS)
continue;
bo->flags |= AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
amdgpu_ttm_placement_from_domain(bo, bo->allowed_domains);
r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false);
if (unlikely(r))
return r;
} }
return 0; return 0;
......
...@@ -35,7 +35,7 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev, struct amdgpu_ctx *ctx) ...@@ -35,7 +35,7 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev, struct amdgpu_ctx *ctx)
kref_init(&ctx->refcount); kref_init(&ctx->refcount);
spin_lock_init(&ctx->ring_lock); spin_lock_init(&ctx->ring_lock);
ctx->fences = kcalloc(amdgpu_sched_jobs * AMDGPU_MAX_RINGS, ctx->fences = kcalloc(amdgpu_sched_jobs * AMDGPU_MAX_RINGS,
sizeof(struct fence*), GFP_KERNEL); sizeof(struct dma_fence*), GFP_KERNEL);
if (!ctx->fences) if (!ctx->fences)
return -ENOMEM; return -ENOMEM;
...@@ -55,18 +55,18 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev, struct amdgpu_ctx *ctx) ...@@ -55,18 +55,18 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev, struct amdgpu_ctx *ctx)
r = amd_sched_entity_init(&ring->sched, &ctx->rings[i].entity, r = amd_sched_entity_init(&ring->sched, &ctx->rings[i].entity,
rq, amdgpu_sched_jobs); rq, amdgpu_sched_jobs);
if (r) if (r)
break; goto failed;
} }
if (i < adev->num_rings) { return 0;
failed:
for (j = 0; j < i; j++) for (j = 0; j < i; j++)
amd_sched_entity_fini(&adev->rings[j]->sched, amd_sched_entity_fini(&adev->rings[j]->sched,
&ctx->rings[j].entity); &ctx->rings[j].entity);
kfree(ctx->fences); kfree(ctx->fences);
ctx->fences = NULL; ctx->fences = NULL;
return r; return r;
}
return 0;
} }
static void amdgpu_ctx_fini(struct amdgpu_ctx *ctx) static void amdgpu_ctx_fini(struct amdgpu_ctx *ctx)
...@@ -79,7 +79,7 @@ static void amdgpu_ctx_fini(struct amdgpu_ctx *ctx) ...@@ -79,7 +79,7 @@ static void amdgpu_ctx_fini(struct amdgpu_ctx *ctx)
for (i = 0; i < AMDGPU_MAX_RINGS; ++i) for (i = 0; i < AMDGPU_MAX_RINGS; ++i)
for (j = 0; j < amdgpu_sched_jobs; ++j) for (j = 0; j < amdgpu_sched_jobs; ++j)
fence_put(ctx->rings[i].fences[j]); dma_fence_put(ctx->rings[i].fences[j]);
kfree(ctx->fences); kfree(ctx->fences);
ctx->fences = NULL; ctx->fences = NULL;
...@@ -241,39 +241,39 @@ int amdgpu_ctx_put(struct amdgpu_ctx *ctx) ...@@ -241,39 +241,39 @@ int amdgpu_ctx_put(struct amdgpu_ctx *ctx)
} }
uint64_t amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx, struct amdgpu_ring *ring, uint64_t amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx, struct amdgpu_ring *ring,
struct fence *fence) struct dma_fence *fence)
{ {
struct amdgpu_ctx_ring *cring = & ctx->rings[ring->idx]; struct amdgpu_ctx_ring *cring = & ctx->rings[ring->idx];
uint64_t seq = cring->sequence; uint64_t seq = cring->sequence;
unsigned idx = 0; unsigned idx = 0;
struct fence *other = NULL; struct dma_fence *other = NULL;
idx = seq & (amdgpu_sched_jobs - 1); idx = seq & (amdgpu_sched_jobs - 1);
other = cring->fences[idx]; other = cring->fences[idx];
if (other) { if (other) {
signed long r; signed long r;
r = fence_wait_timeout(other, false, MAX_SCHEDULE_TIMEOUT); r = dma_fence_wait_timeout(other, false, MAX_SCHEDULE_TIMEOUT);
if (r < 0) if (r < 0)
DRM_ERROR("Error (%ld) waiting for fence!\n", r); DRM_ERROR("Error (%ld) waiting for fence!\n", r);
} }
fence_get(fence); dma_fence_get(fence);
spin_lock(&ctx->ring_lock); spin_lock(&ctx->ring_lock);
cring->fences[idx] = fence; cring->fences[idx] = fence;
cring->sequence++; cring->sequence++;
spin_unlock(&ctx->ring_lock); spin_unlock(&ctx->ring_lock);
fence_put(other); dma_fence_put(other);
return seq; return seq;
} }
struct fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx, struct dma_fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx,
struct amdgpu_ring *ring, uint64_t seq) struct amdgpu_ring *ring, uint64_t seq)
{ {
struct amdgpu_ctx_ring *cring = & ctx->rings[ring->idx]; struct amdgpu_ctx_ring *cring = & ctx->rings[ring->idx];
struct fence *fence; struct dma_fence *fence;
spin_lock(&ctx->ring_lock); spin_lock(&ctx->ring_lock);
...@@ -288,7 +288,7 @@ struct fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx, ...@@ -288,7 +288,7 @@ struct fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx,
return NULL; return NULL;
} }
fence = fence_get(cring->fences[seq & (amdgpu_sched_jobs - 1)]); fence = dma_fence_get(cring->fences[seq & (amdgpu_sched_jobs - 1)]);
spin_unlock(&ctx->ring_lock); spin_unlock(&ctx->ring_lock);
return fence; return fence;
......
This diff is collapsed.
...@@ -35,29 +35,29 @@ ...@@ -35,29 +35,29 @@
#include <drm/drm_crtc_helper.h> #include <drm/drm_crtc_helper.h>
#include <drm/drm_edid.h> #include <drm/drm_edid.h>
static void amdgpu_flip_callback(struct fence *f, struct fence_cb *cb) static void amdgpu_flip_callback(struct dma_fence *f, struct dma_fence_cb *cb)
{ {
struct amdgpu_flip_work *work = struct amdgpu_flip_work *work =
container_of(cb, struct amdgpu_flip_work, cb); container_of(cb, struct amdgpu_flip_work, cb);
fence_put(f); dma_fence_put(f);
schedule_work(&work->flip_work.work); schedule_work(&work->flip_work.work);
} }
static bool amdgpu_flip_handle_fence(struct amdgpu_flip_work *work, static bool amdgpu_flip_handle_fence(struct amdgpu_flip_work *work,
struct fence **f) struct dma_fence **f)
{ {
struct fence *fence= *f; struct dma_fence *fence= *f;
if (fence == NULL) if (fence == NULL)
return false; return false;
*f = NULL; *f = NULL;
if (!fence_add_callback(fence, &work->cb, amdgpu_flip_callback)) if (!dma_fence_add_callback(fence, &work->cb, amdgpu_flip_callback))
return true; return true;
fence_put(fence); dma_fence_put(fence);
return false; return false;
} }
...@@ -68,9 +68,9 @@ static void amdgpu_flip_work_func(struct work_struct *__work) ...@@ -68,9 +68,9 @@ static void amdgpu_flip_work_func(struct work_struct *__work)
struct amdgpu_flip_work *work = struct amdgpu_flip_work *work =
container_of(delayed_work, struct amdgpu_flip_work, flip_work); container_of(delayed_work, struct amdgpu_flip_work, flip_work);
struct amdgpu_device *adev = work->adev; struct amdgpu_device *adev = work->adev;
struct amdgpu_crtc *amdgpuCrtc = adev->mode_info.crtcs[work->crtc_id]; struct amdgpu_crtc *amdgpu_crtc = adev->mode_info.crtcs[work->crtc_id];
struct drm_crtc *crtc = &amdgpuCrtc->base; struct drm_crtc *crtc = &amdgpu_crtc->base;
unsigned long flags; unsigned long flags;
unsigned i; unsigned i;
int vpos, hpos; int vpos, hpos;
...@@ -85,14 +85,14 @@ static void amdgpu_flip_work_func(struct work_struct *__work) ...@@ -85,14 +85,14 @@ static void amdgpu_flip_work_func(struct work_struct *__work)
/* Wait until we're out of the vertical blank period before the one /* Wait until we're out of the vertical blank period before the one
* targeted by the flip * targeted by the flip
*/ */
if (amdgpuCrtc->enabled && if (amdgpu_crtc->enabled &&
(amdgpu_get_crtc_scanoutpos(adev->ddev, work->crtc_id, 0, (amdgpu_get_crtc_scanoutpos(adev->ddev, work->crtc_id, 0,
&vpos, &hpos, NULL, NULL, &vpos, &hpos, NULL, NULL,
&crtc->hwmode) &crtc->hwmode)
& (DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_IN_VBLANK)) == & (DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_IN_VBLANK)) ==
(DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_IN_VBLANK) && (DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_IN_VBLANK) &&
(int)(work->target_vblank - (int)(work->target_vblank -
amdgpu_get_vblank_counter_kms(adev->ddev, amdgpuCrtc->crtc_id)) > 0) { amdgpu_get_vblank_counter_kms(adev->ddev, amdgpu_crtc->crtc_id)) > 0) {
schedule_delayed_work(&work->flip_work, usecs_to_jiffies(1000)); schedule_delayed_work(&work->flip_work, usecs_to_jiffies(1000));
return; return;
} }
...@@ -104,12 +104,12 @@ static void amdgpu_flip_work_func(struct work_struct *__work) ...@@ -104,12 +104,12 @@ static void amdgpu_flip_work_func(struct work_struct *__work)
adev->mode_info.funcs->page_flip(adev, work->crtc_id, work->base, work->async); adev->mode_info.funcs->page_flip(adev, work->crtc_id, work->base, work->async);
/* Set the flip status */ /* Set the flip status */
amdgpuCrtc->pflip_status = AMDGPU_FLIP_SUBMITTED; amdgpu_crtc->pflip_status = AMDGPU_FLIP_SUBMITTED;
spin_unlock_irqrestore(&crtc->dev->event_lock, flags); spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
DRM_DEBUG_DRIVER("crtc:%d[%p], pflip_stat:AMDGPU_FLIP_SUBMITTED, work: %p,\n", DRM_DEBUG_DRIVER("crtc:%d[%p], pflip_stat:AMDGPU_FLIP_SUBMITTED, work: %p,\n",
amdgpuCrtc->crtc_id, amdgpuCrtc, work); amdgpu_crtc->crtc_id, amdgpu_crtc, work);
} }
...@@ -244,9 +244,9 @@ int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc, ...@@ -244,9 +244,9 @@ int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc,
cleanup: cleanup:
amdgpu_bo_unref(&work->old_abo); amdgpu_bo_unref(&work->old_abo);
fence_put(work->excl); dma_fence_put(work->excl);
for (i = 0; i < work->shared_count; ++i) for (i = 0; i < work->shared_count; ++i)
fence_put(work->shared[i]); dma_fence_put(work->shared[i]);
kfree(work->shared); kfree(work->shared);
kfree(work); kfree(work);
......
...@@ -553,9 +553,10 @@ int amdgpu_parse_extended_power_table(struct amdgpu_device *adev) ...@@ -553,9 +553,10 @@ int amdgpu_parse_extended_power_table(struct amdgpu_device *adev)
entry = (ATOM_PPLIB_VCE_Clock_Voltage_Limit_Record *) entry = (ATOM_PPLIB_VCE_Clock_Voltage_Limit_Record *)
((u8 *)entry + sizeof(ATOM_PPLIB_VCE_Clock_Voltage_Limit_Record)); ((u8 *)entry + sizeof(ATOM_PPLIB_VCE_Clock_Voltage_Limit_Record));
} }
for (i = 0; i < states->numEntries; i++) { adev->pm.dpm.num_of_vce_states =
if (i >= AMDGPU_MAX_VCE_LEVELS) states->numEntries > AMD_MAX_VCE_LEVELS ?
break; AMD_MAX_VCE_LEVELS : states->numEntries;
for (i = 0; i < adev->pm.dpm.num_of_vce_states; i++) {
vce_clk = (VCEClockInfo *) vce_clk = (VCEClockInfo *)
((u8 *)&array->entries[0] + ((u8 *)&array->entries[0] +
(state_entry->ucVCEClockInfoIndex * sizeof(VCEClockInfo))); (state_entry->ucVCEClockInfoIndex * sizeof(VCEClockInfo)));
...@@ -955,3 +956,12 @@ u8 amdgpu_encode_pci_lane_width(u32 lanes) ...@@ -955,3 +956,12 @@ u8 amdgpu_encode_pci_lane_width(u32 lanes)
return encoded_lanes[lanes]; return encoded_lanes[lanes];
} }
struct amd_vce_state*
amdgpu_get_vce_clock_state(struct amdgpu_device *adev, unsigned idx)
{
if (idx < adev->pm.dpm.num_of_vce_states)
return &adev->pm.dpm.vce_states[idx];
return NULL;
}
This diff is collapsed.
...@@ -58,9 +58,10 @@ ...@@ -58,9 +58,10 @@
* - 3.6.0 - kmd involves use CONTEXT_CONTROL in ring buffer. * - 3.6.0 - kmd involves use CONTEXT_CONTROL in ring buffer.
* - 3.7.0 - Add support for VCE clock list packet * - 3.7.0 - Add support for VCE clock list packet
* - 3.8.0 - Add support raster config init in the kernel * - 3.8.0 - Add support raster config init in the kernel
* - 3.9.0 - Add support for memory query info about VRAM and GTT.
*/ */
#define KMS_DRIVER_MAJOR 3 #define KMS_DRIVER_MAJOR 3
#define KMS_DRIVER_MINOR 8 #define KMS_DRIVER_MINOR 9
#define KMS_DRIVER_PATCHLEVEL 0 #define KMS_DRIVER_PATCHLEVEL 0
int amdgpu_vram_limit = 0; int amdgpu_vram_limit = 0;
...@@ -85,6 +86,7 @@ int amdgpu_vm_size = 64; ...@@ -85,6 +86,7 @@ int amdgpu_vm_size = 64;
int amdgpu_vm_block_size = -1; int amdgpu_vm_block_size = -1;
int amdgpu_vm_fault_stop = 0; int amdgpu_vm_fault_stop = 0;
int amdgpu_vm_debug = 0; int amdgpu_vm_debug = 0;
int amdgpu_vram_page_split = 1024;
int amdgpu_exp_hw_support = 0; int amdgpu_exp_hw_support = 0;
int amdgpu_sched_jobs = 32; int amdgpu_sched_jobs = 32;
int amdgpu_sched_hw_submission = 2; int amdgpu_sched_hw_submission = 2;
...@@ -165,6 +167,9 @@ module_param_named(vm_fault_stop, amdgpu_vm_fault_stop, int, 0444); ...@@ -165,6 +167,9 @@ module_param_named(vm_fault_stop, amdgpu_vm_fault_stop, int, 0444);
MODULE_PARM_DESC(vm_debug, "Debug VM handling (0 = disabled (default), 1 = enabled)"); MODULE_PARM_DESC(vm_debug, "Debug VM handling (0 = disabled (default), 1 = enabled)");
module_param_named(vm_debug, amdgpu_vm_debug, int, 0644); module_param_named(vm_debug, amdgpu_vm_debug, int, 0644);
MODULE_PARM_DESC(vram_page_split, "Number of pages after we split VRAM allocations (default 1024, -1 = disable)");
module_param_named(vram_page_split, amdgpu_vram_page_split, int, 0444);
MODULE_PARM_DESC(exp_hw_support, "experimental hw support (1 = enable, 0 = disable (default))"); MODULE_PARM_DESC(exp_hw_support, "experimental hw support (1 = enable, 0 = disable (default))");
module_param_named(exp_hw_support, amdgpu_exp_hw_support, int, 0444); module_param_named(exp_hw_support, amdgpu_exp_hw_support, int, 0444);
...@@ -201,7 +206,8 @@ module_param_named(pg_mask, amdgpu_pg_mask, uint, 0444); ...@@ -201,7 +206,8 @@ module_param_named(pg_mask, amdgpu_pg_mask, uint, 0444);
MODULE_PARM_DESC(disable_cu, "Disable CUs (se.sh.cu,...)"); MODULE_PARM_DESC(disable_cu, "Disable CUs (se.sh.cu,...)");
module_param_named(disable_cu, amdgpu_disable_cu, charp, 0444); module_param_named(disable_cu, amdgpu_disable_cu, charp, 0444);
MODULE_PARM_DESC(virtual_display, "Enable virtual display feature (the virtual_display will be set like xxxx:xx:xx.x;xxxx:xx:xx.x)"); MODULE_PARM_DESC(virtual_display,
"Enable virtual display feature (the virtual_display will be set like xxxx:xx:xx.x,x;xxxx:xx:xx.x,x)");
module_param_named(virtual_display, amdgpu_virtual_display, charp, 0444); module_param_named(virtual_display, amdgpu_virtual_display, charp, 0444);
static const struct pci_device_id pciidlist[] = { static const struct pci_device_id pciidlist[] = {
...@@ -381,6 +387,7 @@ static const struct pci_device_id pciidlist[] = { ...@@ -381,6 +387,7 @@ static const struct pci_device_id pciidlist[] = {
{0x1002, 0x6939, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA}, {0x1002, 0x6939, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},
/* fiji */ /* fiji */
{0x1002, 0x7300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI}, {0x1002, 0x7300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI},
{0x1002, 0x730F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI},
/* carrizo */ /* carrizo */
{0x1002, 0x9870, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CARRIZO|AMD_IS_APU}, {0x1002, 0x9870, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CARRIZO|AMD_IS_APU},
{0x1002, 0x9874, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CARRIZO|AMD_IS_APU}, {0x1002, 0x9874, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CARRIZO|AMD_IS_APU},
......
...@@ -152,7 +152,8 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev, ...@@ -152,7 +152,8 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
aligned_size = ALIGN(size, PAGE_SIZE); aligned_size = ALIGN(size, PAGE_SIZE);
ret = amdgpu_gem_object_create(adev, aligned_size, 0, ret = amdgpu_gem_object_create(adev, aligned_size, 0,
AMDGPU_GEM_DOMAIN_VRAM, AMDGPU_GEM_DOMAIN_VRAM,
AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED, AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS,
true, &gobj); true, &gobj);
if (ret) { if (ret) {
printk(KERN_ERR "failed to allocate framebuffer (%d)\n", printk(KERN_ERR "failed to allocate framebuffer (%d)\n",
......
This diff is collapsed.
...@@ -126,7 +126,8 @@ int amdgpu_gart_table_vram_alloc(struct amdgpu_device *adev) ...@@ -126,7 +126,8 @@ int amdgpu_gart_table_vram_alloc(struct amdgpu_device *adev)
if (adev->gart.robj == NULL) { if (adev->gart.robj == NULL) {
r = amdgpu_bo_create(adev, adev->gart.table_size, r = amdgpu_bo_create(adev, adev->gart.table_size,
PAGE_SIZE, true, AMDGPU_GEM_DOMAIN_VRAM, PAGE_SIZE, true, AMDGPU_GEM_DOMAIN_VRAM,
AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED, AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS,
NULL, NULL, &adev->gart.robj); NULL, NULL, &adev->gart.robj);
if (r) { if (r) {
return r; return r;
......
...@@ -116,10 +116,11 @@ void amdgpu_gem_force_release(struct amdgpu_device *adev) ...@@ -116,10 +116,11 @@ void amdgpu_gem_force_release(struct amdgpu_device *adev)
* Call from drm_gem_handle_create which appear in both new and open ioctl * Call from drm_gem_handle_create which appear in both new and open ioctl
* case. * case.
*/ */
int amdgpu_gem_object_open(struct drm_gem_object *obj, struct drm_file *file_priv) int amdgpu_gem_object_open(struct drm_gem_object *obj,
struct drm_file *file_priv)
{ {
struct amdgpu_bo *abo = gem_to_amdgpu_bo(obj); struct amdgpu_bo *abo = gem_to_amdgpu_bo(obj);
struct amdgpu_device *adev = abo->adev; struct amdgpu_device *adev = amdgpu_ttm_adev(abo->tbo.bdev);
struct amdgpu_fpriv *fpriv = file_priv->driver_priv; struct amdgpu_fpriv *fpriv = file_priv->driver_priv;
struct amdgpu_vm *vm = &fpriv->vm; struct amdgpu_vm *vm = &fpriv->vm;
struct amdgpu_bo_va *bo_va; struct amdgpu_bo_va *bo_va;
...@@ -142,7 +143,7 @@ void amdgpu_gem_object_close(struct drm_gem_object *obj, ...@@ -142,7 +143,7 @@ void amdgpu_gem_object_close(struct drm_gem_object *obj,
struct drm_file *file_priv) struct drm_file *file_priv)
{ {
struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj); struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj);
struct amdgpu_device *adev = bo->adev; struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
struct amdgpu_fpriv *fpriv = file_priv->driver_priv; struct amdgpu_fpriv *fpriv = file_priv->driver_priv;
struct amdgpu_vm *vm = &fpriv->vm; struct amdgpu_vm *vm = &fpriv->vm;
...@@ -468,6 +469,16 @@ int amdgpu_gem_metadata_ioctl(struct drm_device *dev, void *data, ...@@ -468,6 +469,16 @@ int amdgpu_gem_metadata_ioctl(struct drm_device *dev, void *data,
return r; return r;
} }
static int amdgpu_gem_va_check(void *param, struct amdgpu_bo *bo)
{
unsigned domain = amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type);
/* if anything is swapped out don't swap it in here,
just abort and wait for the next CS */
return domain == AMDGPU_GEM_DOMAIN_CPU ? -ERESTARTSYS : 0;
}
/** /**
* amdgpu_gem_va_update_vm -update the bo_va in its VM * amdgpu_gem_va_update_vm -update the bo_va in its VM
* *
...@@ -478,7 +489,8 @@ int amdgpu_gem_metadata_ioctl(struct drm_device *dev, void *data, ...@@ -478,7 +489,8 @@ int amdgpu_gem_metadata_ioctl(struct drm_device *dev, void *data,
* vital here, so they are not reported back to userspace. * vital here, so they are not reported back to userspace.
*/ */
static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev, static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev,
struct amdgpu_bo_va *bo_va, uint32_t operation) struct amdgpu_bo_va *bo_va,
uint32_t operation)
{ {
struct ttm_validate_buffer tv, *entry; struct ttm_validate_buffer tv, *entry;
struct amdgpu_bo_list_entry vm_pd; struct amdgpu_bo_list_entry vm_pd;
...@@ -501,7 +513,6 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev, ...@@ -501,7 +513,6 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev,
if (r) if (r)
goto error_print; goto error_print;
amdgpu_vm_get_pt_bos(adev, bo_va->vm, &duplicates);
list_for_each_entry(entry, &list, head) { list_for_each_entry(entry, &list, head) {
domain = amdgpu_mem_type_to_domain(entry->bo->mem.mem_type); domain = amdgpu_mem_type_to_domain(entry->bo->mem.mem_type);
/* if anything is swapped out don't swap it in here, /* if anything is swapped out don't swap it in here,
...@@ -509,13 +520,10 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev, ...@@ -509,13 +520,10 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev,
if (domain == AMDGPU_GEM_DOMAIN_CPU) if (domain == AMDGPU_GEM_DOMAIN_CPU)
goto error_unreserve; goto error_unreserve;
} }
list_for_each_entry(entry, &duplicates, head) { r = amdgpu_vm_validate_pt_bos(adev, bo_va->vm, amdgpu_gem_va_check,
domain = amdgpu_mem_type_to_domain(entry->bo->mem.mem_type); NULL);
/* if anything is swapped out don't swap it in here, if (r)
just abort and wait for the next CS */
if (domain == AMDGPU_GEM_DOMAIN_CPU)
goto error_unreserve; goto error_unreserve;
}
r = amdgpu_vm_update_page_directory(adev, bo_va->vm); r = amdgpu_vm_update_page_directory(adev, bo_va->vm);
if (r) if (r)
...@@ -536,8 +544,6 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev, ...@@ -536,8 +544,6 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev,
DRM_ERROR("Couldn't update BO_VA (%d)\n", r); DRM_ERROR("Couldn't update BO_VA (%d)\n", r);
} }
int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data, int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
struct drm_file *filp) struct drm_file *filp)
{ {
...@@ -547,7 +553,8 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data, ...@@ -547,7 +553,8 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
struct amdgpu_fpriv *fpriv = filp->driver_priv; struct amdgpu_fpriv *fpriv = filp->driver_priv;
struct amdgpu_bo *abo; struct amdgpu_bo *abo;
struct amdgpu_bo_va *bo_va; struct amdgpu_bo_va *bo_va;
struct ttm_validate_buffer tv, tv_pd; struct amdgpu_bo_list_entry vm_pd;
struct ttm_validate_buffer tv;
struct ww_acquire_ctx ticket; struct ww_acquire_ctx ticket;
struct list_head list, duplicates; struct list_head list, duplicates;
uint32_t invalid_flags, va_flags = 0; uint32_t invalid_flags, va_flags = 0;
...@@ -592,9 +599,7 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data, ...@@ -592,9 +599,7 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
tv.shared = true; tv.shared = true;
list_add(&tv.head, &list); list_add(&tv.head, &list);
tv_pd.bo = &fpriv->vm.page_directory->tbo; amdgpu_vm_get_pd_bo(&fpriv->vm, &list, &vm_pd);
tv_pd.shared = true;
list_add(&tv_pd.head, &list);
r = ttm_eu_reserve_buffers(&ticket, &list, true, &duplicates); r = ttm_eu_reserve_buffers(&ticket, &list, true, &duplicates);
if (r) { if (r) {
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
*/ */
#include <drm/drmP.h> #include <drm/drmP.h>
#include "amdgpu.h" #include "amdgpu.h"
#include "amdgpu_gfx.h"
/* /*
* GPU scratch registers helpers function. * GPU scratch registers helpers function.
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
int amdgpu_gfx_scratch_get(struct amdgpu_device *adev, uint32_t *reg); int amdgpu_gfx_scratch_get(struct amdgpu_device *adev, uint32_t *reg);
void amdgpu_gfx_scratch_free(struct amdgpu_device *adev, uint32_t reg); void amdgpu_gfx_scratch_free(struct amdgpu_device *adev, uint32_t reg);
unsigned amdgpu_gfx_parse_disable_cu(unsigned *mask, unsigned max_se, unsigned max_sh); void amdgpu_gfx_parse_disable_cu(unsigned *mask, unsigned max_se,
unsigned max_sh);
#endif #endif
...@@ -168,6 +168,7 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man, ...@@ -168,6 +168,7 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man,
return -ENOMEM; return -ENOMEM;
node->start = AMDGPU_BO_INVALID_OFFSET; node->start = AMDGPU_BO_INVALID_OFFSET;
node->size = mem->num_pages;
mem->mm_node = node; mem->mm_node = node;
if (place->fpfn || place->lpfn || place->flags & TTM_PL_FLAG_TOPDOWN) { if (place->fpfn || place->lpfn || place->flags & TTM_PL_FLAG_TOPDOWN) {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -285,7 +285,7 @@ static struct amdgpu_mn *amdgpu_mn_get(struct amdgpu_device *adev) ...@@ -285,7 +285,7 @@ static struct amdgpu_mn *amdgpu_mn_get(struct amdgpu_device *adev)
int amdgpu_mn_register(struct amdgpu_bo *bo, unsigned long addr) int amdgpu_mn_register(struct amdgpu_bo *bo, unsigned long addr)
{ {
unsigned long end = addr + amdgpu_bo_size(bo) - 1; unsigned long end = addr + amdgpu_bo_size(bo) - 1;
struct amdgpu_device *adev = bo->adev; struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
struct amdgpu_mn *rmn; struct amdgpu_mn *rmn;
struct amdgpu_mn_node *node = NULL; struct amdgpu_mn_node *node = NULL;
struct list_head bos; struct list_head bos;
...@@ -340,7 +340,7 @@ int amdgpu_mn_register(struct amdgpu_bo *bo, unsigned long addr) ...@@ -340,7 +340,7 @@ int amdgpu_mn_register(struct amdgpu_bo *bo, unsigned long addr)
*/ */
void amdgpu_mn_unregister(struct amdgpu_bo *bo) void amdgpu_mn_unregister(struct amdgpu_bo *bo)
{ {
struct amdgpu_device *adev = bo->adev; struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
struct amdgpu_mn *rmn; struct amdgpu_mn *rmn;
struct list_head *head; struct list_head *head;
......
...@@ -341,8 +341,6 @@ struct amdgpu_mode_info { ...@@ -341,8 +341,6 @@ struct amdgpu_mode_info {
int num_dig; /* number of dig blocks */ int num_dig; /* number of dig blocks */
int disp_priority; int disp_priority;
const struct amdgpu_display_funcs *funcs; const struct amdgpu_display_funcs *funcs;
struct hrtimer vblank_timer;
enum amdgpu_interrupt_state vsync_timer_enabled;
}; };
#define AMDGPU_MAX_BL_LEVEL 0xFF #define AMDGPU_MAX_BL_LEVEL 0xFF
...@@ -413,6 +411,9 @@ struct amdgpu_crtc { ...@@ -413,6 +411,9 @@ struct amdgpu_crtc {
u32 wm_high; u32 wm_high;
u32 lb_vblank_lead_lines; u32 lb_vblank_lead_lines;
struct drm_display_mode hw_mode; struct drm_display_mode hw_mode;
/* for virtual dce */
struct hrtimer vblank_timer;
enum amdgpu_interrupt_state vsync_timer_enabled;
}; };
struct amdgpu_encoder_atom_dig { struct amdgpu_encoder_atom_dig {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment