mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
drm/i915/perf: Replace gt->perf.lock with stream->lock for file ops
With multi-gt, user can access multiple OA buffers concurrently. Use stream->lock instead of gt->perf.lock to serialize file operations. Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com> Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com> Signed-off-by: John Harrison <John.C.Harrison@Intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20221026222102.5526-9-umesh.nerlige.ramappa@intel.com
This commit is contained in:
committed by
John Harrison
parent
9677a9f3b1
commit
2db609c014
@@ -3231,6 +3231,7 @@ static int i915_oa_stream_init(struct i915_perf_stream *stream,
|
|||||||
stream->poll_check_timer.function = oa_poll_check_timer_cb;
|
stream->poll_check_timer.function = oa_poll_check_timer_cb;
|
||||||
init_waitqueue_head(&stream->poll_wq);
|
init_waitqueue_head(&stream->poll_wq);
|
||||||
spin_lock_init(&stream->oa_buffer.ptr_lock);
|
spin_lock_init(&stream->oa_buffer.ptr_lock);
|
||||||
|
mutex_init(&stream->lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -3294,7 +3295,6 @@ static ssize_t i915_perf_read(struct file *file,
|
|||||||
loff_t *ppos)
|
loff_t *ppos)
|
||||||
{
|
{
|
||||||
struct i915_perf_stream *stream = file->private_data;
|
struct i915_perf_stream *stream = file->private_data;
|
||||||
struct intel_gt *gt = stream->engine->gt;
|
|
||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -3318,14 +3318,14 @@ static ssize_t i915_perf_read(struct file *file,
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
mutex_lock(>->perf.lock);
|
mutex_lock(&stream->lock);
|
||||||
ret = stream->ops->read(stream, buf, count, &offset);
|
ret = stream->ops->read(stream, buf, count, &offset);
|
||||||
mutex_unlock(>->perf.lock);
|
mutex_unlock(&stream->lock);
|
||||||
} while (!offset && !ret);
|
} while (!offset && !ret);
|
||||||
} else {
|
} else {
|
||||||
mutex_lock(>->perf.lock);
|
mutex_lock(&stream->lock);
|
||||||
ret = stream->ops->read(stream, buf, count, &offset);
|
ret = stream->ops->read(stream, buf, count, &offset);
|
||||||
mutex_unlock(>->perf.lock);
|
mutex_unlock(&stream->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We allow the poll checking to sometimes report false positive EPOLLIN
|
/* We allow the poll checking to sometimes report false positive EPOLLIN
|
||||||
@@ -3372,9 +3372,6 @@ static enum hrtimer_restart oa_poll_check_timer_cb(struct hrtimer *hrtimer)
|
|||||||
* &i915_perf_stream_ops->poll_wait to call poll_wait() with a wait queue that
|
* &i915_perf_stream_ops->poll_wait to call poll_wait() with a wait queue that
|
||||||
* will be woken for new stream data.
|
* will be woken for new stream data.
|
||||||
*
|
*
|
||||||
* Note: The >->perf.lock mutex has been taken to serialize
|
|
||||||
* with any non-file-operation driver hooks.
|
|
||||||
*
|
|
||||||
* Returns: any poll events that are ready without sleeping
|
* Returns: any poll events that are ready without sleeping
|
||||||
*/
|
*/
|
||||||
static __poll_t i915_perf_poll_locked(struct i915_perf_stream *stream,
|
static __poll_t i915_perf_poll_locked(struct i915_perf_stream *stream,
|
||||||
@@ -3413,12 +3410,11 @@ static __poll_t i915_perf_poll_locked(struct i915_perf_stream *stream,
|
|||||||
static __poll_t i915_perf_poll(struct file *file, poll_table *wait)
|
static __poll_t i915_perf_poll(struct file *file, poll_table *wait)
|
||||||
{
|
{
|
||||||
struct i915_perf_stream *stream = file->private_data;
|
struct i915_perf_stream *stream = file->private_data;
|
||||||
struct intel_gt *gt = stream->engine->gt;
|
|
||||||
__poll_t ret;
|
__poll_t ret;
|
||||||
|
|
||||||
mutex_lock(>->perf.lock);
|
mutex_lock(&stream->lock);
|
||||||
ret = i915_perf_poll_locked(stream, file, wait);
|
ret = i915_perf_poll_locked(stream, file, wait);
|
||||||
mutex_unlock(>->perf.lock);
|
mutex_unlock(&stream->lock);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -3517,9 +3513,6 @@ static long i915_perf_config_locked(struct i915_perf_stream *stream,
|
|||||||
* @cmd: the ioctl request
|
* @cmd: the ioctl request
|
||||||
* @arg: the ioctl data
|
* @arg: the ioctl data
|
||||||
*
|
*
|
||||||
* Note: The >->perf.lock mutex has been taken to serialize
|
|
||||||
* with any non-file-operation driver hooks.
|
|
||||||
*
|
|
||||||
* Returns: zero on success or a negative error code. Returns -EINVAL for
|
* Returns: zero on success or a negative error code. Returns -EINVAL for
|
||||||
* an unknown ioctl request.
|
* an unknown ioctl request.
|
||||||
*/
|
*/
|
||||||
@@ -3557,12 +3550,11 @@ static long i915_perf_ioctl(struct file *file,
|
|||||||
unsigned long arg)
|
unsigned long arg)
|
||||||
{
|
{
|
||||||
struct i915_perf_stream *stream = file->private_data;
|
struct i915_perf_stream *stream = file->private_data;
|
||||||
struct intel_gt *gt = stream->engine->gt;
|
|
||||||
long ret;
|
long ret;
|
||||||
|
|
||||||
mutex_lock(>->perf.lock);
|
mutex_lock(&stream->lock);
|
||||||
ret = i915_perf_ioctl_locked(stream, cmd, arg);
|
ret = i915_perf_ioctl_locked(stream, cmd, arg);
|
||||||
mutex_unlock(>->perf.lock);
|
mutex_unlock(&stream->lock);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -3608,6 +3600,11 @@ static int i915_perf_release(struct inode *inode, struct file *file)
|
|||||||
struct i915_perf *perf = stream->perf;
|
struct i915_perf *perf = stream->perf;
|
||||||
struct intel_gt *gt = stream->engine->gt;
|
struct intel_gt *gt = stream->engine->gt;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Within this call, we know that the fd is being closed and we have no
|
||||||
|
* other user of stream->lock. Use the perf lock to destroy the stream
|
||||||
|
* here.
|
||||||
|
*/
|
||||||
mutex_lock(>->perf.lock);
|
mutex_lock(>->perf.lock);
|
||||||
i915_perf_destroy_locked(stream);
|
i915_perf_destroy_locked(stream);
|
||||||
mutex_unlock(>->perf.lock);
|
mutex_unlock(>->perf.lock);
|
||||||
|
|||||||
@@ -146,6 +146,11 @@ struct i915_perf_stream {
|
|||||||
*/
|
*/
|
||||||
struct intel_engine_cs *engine;
|
struct intel_engine_cs *engine;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Lock associated with operations on stream
|
||||||
|
*/
|
||||||
|
struct mutex lock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @sample_flags: Flags representing the `DRM_I915_PERF_PROP_SAMPLE_*`
|
* @sample_flags: Flags representing the `DRM_I915_PERF_PROP_SAMPLE_*`
|
||||||
* properties given when opening a stream, representing the contents
|
* properties given when opening a stream, representing the contents
|
||||||
|
|||||||
Reference in New Issue
Block a user