![Eric Anholt](/assets/img/avatar_default.png)
Daniel suggested I submit this, since we're still seeing regressions
from it. This is a revert to before 48197bc564
("drm: add syncobj
timeline support v9") and its followon fixes.
Fixes this on first V3D testcase execution:
[ 48.767088] ============================================
[ 48.772410] WARNING: possible recursive locking detected
[ 48.777739] 4.19.0-rc6+ #489 Not tainted
[ 48.781668] --------------------------------------------
[ 48.786993] shader_runner/3284 is trying to acquire lock:
[ 48.792408] ce309d7f (&(&array->lock)->rlock){....}, at: dma_fence_add_callback+0x30/0x23c
[ 48.800714]
[ 48.800714] but task is already holding lock:
[ 48.806559] c5952bd3 (&(&array->lock)->rlock){....}, at: dma_fence_add_callback+0x30/0x23c
[ 48.814862]
[ 48.814862] other info that might help us debug this:
[ 48.821410] Possible unsafe locking scenario:
[ 48.821410]
[ 48.827338] CPU0
[ 48.829788] ----
[ 48.832239] lock(&(&array->lock)->rlock);
[ 48.836434] lock(&(&array->lock)->rlock);
[ 48.840640]
[ 48.840640] *** DEADLOCK ***
[ 48.840640]
[ 48.846582] May be due to missing lock nesting notation
[ 130.763560] 1 lock held by cts-runner/3270:
[ 130.767745] #0: 7834b793 (&(&array->lock)->rlock){-...}, at: dma_fence_add_callback+0x30/0x23c
[ 130.776461]
stack backtrace:
[ 130.780825] CPU: 1 PID: 3270 Comm: cts-runner Not tainted 4.19.0-rc6+ #486
[ 130.787706] Hardware name: Broadcom STB (Flattened Device Tree)
[ 130.793645] [<c021269c>] (unwind_backtrace) from [<c020db1c>] (show_stack+0x10/0x14)
[ 130.801404] [<c020db1c>] (show_stack) from [<c0c2c4b0>] (dump_stack+0xa8/0xd4)
[ 130.808642] [<c0c2c4b0>] (dump_stack) from [<c0281a84>] (__lock_acquire+0x848/0x1a68)
[ 130.816483] [<c0281a84>] (__lock_acquire) from [<c02835d8>] (lock_acquire+0xd8/0x22c)
[ 130.824326] [<c02835d8>] (lock_acquire) from [<c0c49948>] (_raw_spin_lock_irqsave+0x54/0x68)
[ 130.832777] [<c0c49948>] (_raw_spin_lock_irqsave) from [<c086bf54>] (dma_fence_add_callback+0x30/0x23c)
[ 130.842183] [<c086bf54>] (dma_fence_add_callback) from [<c086d4c8>] (dma_fence_array_enable_signaling+0x58/0xec)
[ 130.852371] [<c086d4c8>] (dma_fence_array_enable_signaling) from [<c086c00c>] (dma_fence_add_callback+0xe8/0x23c)
[ 130.862647] [<c086c00c>] (dma_fence_add_callback) from [<c06d8774>] (drm_syncobj_wait_ioctl+0x518/0x614)
[ 130.872143] [<c06d8774>] (drm_syncobj_wait_ioctl) from [<c06b8458>] (drm_ioctl_kernel+0xb0/0xf0)
[ 130.880940] [<c06b8458>] (drm_ioctl_kernel) from [<c06b8818>] (drm_ioctl+0x1d8/0x390)
[ 130.888782] [<c06b8818>] (drm_ioctl) from [<c03a4510>] (do_vfs_ioctl+0xb0/0x8ac)
[ 130.896187] [<c03a4510>] (do_vfs_ioctl) from [<c03a4d40>] (ksys_ioctl+0x34/0x60)
[ 130.903593] [<c03a4d40>] (ksys_ioctl) from [<c0201000>] (ret_fast_syscall+0x0/0x28)
Cc: Chunming Zhou <david1.zhou@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Eric Anholt <eric@anholt.net>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/261044/
147 lines
4.3 KiB
C
147 lines
4.3 KiB
C
/*
|
|
* Copyright © 2017 Red Hat
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
* to deal in the Software without restriction, including without limitation
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice (including the next
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
* Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
* IN THE SOFTWARE.
|
|
*
|
|
* Authors:
|
|
*
|
|
*/
|
|
#ifndef __DRM_SYNCOBJ_H__
|
|
#define __DRM_SYNCOBJ_H__
|
|
|
|
#include "linux/dma-fence.h"
|
|
|
|
struct drm_syncobj_cb;
|
|
|
|
/**
|
|
* struct drm_syncobj - sync object.
|
|
*
|
|
* This structure defines a generic sync object which wraps a &dma_fence.
|
|
*/
|
|
struct drm_syncobj {
|
|
/**
|
|
* @refcount: Reference count of this object.
|
|
*/
|
|
struct kref refcount;
|
|
/**
|
|
* @fence:
|
|
* NULL or a pointer to the fence bound to this object.
|
|
*
|
|
* This field should not be used directly. Use drm_syncobj_fence_get()
|
|
* and drm_syncobj_replace_fence() instead.
|
|
*/
|
|
struct dma_fence __rcu *fence;
|
|
/**
|
|
* @cb_list: List of callbacks to call when the &fence gets replaced.
|
|
*/
|
|
struct list_head cb_list;
|
|
/**
|
|
* @lock: Protects &cb_list and write-locks &fence.
|
|
*/
|
|
spinlock_t lock;
|
|
/**
|
|
* @file: A file backing for this syncobj.
|
|
*/
|
|
struct file *file;
|
|
};
|
|
|
|
typedef void (*drm_syncobj_func_t)(struct drm_syncobj *syncobj,
|
|
struct drm_syncobj_cb *cb);
|
|
|
|
/**
|
|
* struct drm_syncobj_cb - callback for drm_syncobj_add_callback
|
|
* @node: used by drm_syncob_add_callback to append this struct to
|
|
* &drm_syncobj.cb_list
|
|
* @func: drm_syncobj_func_t to call
|
|
*
|
|
* This struct will be initialized by drm_syncobj_add_callback, additional
|
|
* data can be passed along by embedding drm_syncobj_cb in another struct.
|
|
* The callback will get called the next time drm_syncobj_replace_fence is
|
|
* called.
|
|
*/
|
|
struct drm_syncobj_cb {
|
|
struct list_head node;
|
|
drm_syncobj_func_t func;
|
|
};
|
|
|
|
void drm_syncobj_free(struct kref *kref);
|
|
|
|
/**
|
|
* drm_syncobj_get - acquire a syncobj reference
|
|
* @obj: sync object
|
|
*
|
|
* This acquires an additional reference to @obj. It is illegal to call this
|
|
* without already holding a reference. No locks required.
|
|
*/
|
|
static inline void
|
|
drm_syncobj_get(struct drm_syncobj *obj)
|
|
{
|
|
kref_get(&obj->refcount);
|
|
}
|
|
|
|
/**
|
|
* drm_syncobj_put - release a reference to a sync object.
|
|
* @obj: sync object.
|
|
*/
|
|
static inline void
|
|
drm_syncobj_put(struct drm_syncobj *obj)
|
|
{
|
|
kref_put(&obj->refcount, drm_syncobj_free);
|
|
}
|
|
|
|
/**
|
|
* drm_syncobj_fence_get - get a reference to a fence in a sync object
|
|
* @syncobj: sync object.
|
|
*
|
|
* This acquires additional reference to &drm_syncobj.fence contained in @obj,
|
|
* if not NULL. It is illegal to call this without already holding a reference.
|
|
* No locks required.
|
|
*
|
|
* Returns:
|
|
* Either the fence of @obj or NULL if there's none.
|
|
*/
|
|
static inline struct dma_fence *
|
|
drm_syncobj_fence_get(struct drm_syncobj *syncobj)
|
|
{
|
|
struct dma_fence *fence;
|
|
|
|
rcu_read_lock();
|
|
fence = dma_fence_get_rcu_safe(&syncobj->fence);
|
|
rcu_read_unlock();
|
|
|
|
return fence;
|
|
}
|
|
|
|
struct drm_syncobj *drm_syncobj_find(struct drm_file *file_private,
|
|
u32 handle);
|
|
void drm_syncobj_replace_fence(struct drm_syncobj *syncobj, u64 point,
|
|
struct dma_fence *fence);
|
|
int drm_syncobj_find_fence(struct drm_file *file_private,
|
|
u32 handle, u64 point, u64 flags,
|
|
struct dma_fence **fence);
|
|
void drm_syncobj_free(struct kref *kref);
|
|
int drm_syncobj_create(struct drm_syncobj **out_syncobj, uint32_t flags,
|
|
struct dma_fence *fence);
|
|
int drm_syncobj_get_handle(struct drm_file *file_private,
|
|
struct drm_syncobj *syncobj, u32 *handle);
|
|
int drm_syncobj_get_fd(struct drm_syncobj *syncobj, int *p_fd);
|
|
|
|
#endif
|