Skip to content

Commit

Permalink
drm/i915/gt: Declare timeline.lock to be irq-free
Browse files Browse the repository at this point in the history
Now that we never allow the intel_wakeref callbacks to be invoked from
interrupt context, we do not need the irqsafe spinlock for the timeline.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191120170858.3965380-1-chris@chris-wilson.co.uk
  • Loading branch information
Chris Wilson committed Nov 20, 2019
1 parent 5cba288 commit 88cec49
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
9 changes: 4 additions & 5 deletions drivers/gpu/drm/i915/gt/intel_gt_requests.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ long intel_gt_retire_requests_timeout(struct intel_gt *gt, long timeout)
{
struct intel_gt_timelines *timelines = &gt->timelines;
struct intel_timeline *tl, *tn;
unsigned long flags;
bool interruptible;
LIST_HEAD(free);

Expand All @@ -43,15 +42,15 @@ long intel_gt_retire_requests_timeout(struct intel_gt *gt, long timeout)

flush_submission(gt); /* kick the ksoftirqd tasklets */

spin_lock_irqsave(&timelines->lock, flags);
spin_lock(&timelines->lock);
list_for_each_entry_safe(tl, tn, &timelines->active_list, link) {
if (!mutex_trylock(&tl->mutex))
continue;

intel_timeline_get(tl);
GEM_BUG_ON(!atomic_read(&tl->active_count));
atomic_inc(&tl->active_count); /* pin the list element */
spin_unlock_irqrestore(&timelines->lock, flags);
spin_unlock(&timelines->lock);

if (timeout > 0) {
struct dma_fence *fence;
Expand All @@ -67,7 +66,7 @@ long intel_gt_retire_requests_timeout(struct intel_gt *gt, long timeout)

retire_requests(tl);

spin_lock_irqsave(&timelines->lock, flags);
spin_lock(&timelines->lock);

/* Resume iteration after dropping lock */
list_safe_reset_next(tl, tn, link);
Expand All @@ -82,7 +81,7 @@ long intel_gt_retire_requests_timeout(struct intel_gt *gt, long timeout)
list_add(&tl->link, &free);
}
}
spin_unlock_irqrestore(&timelines->lock, flags);
spin_unlock(&timelines->lock);

list_for_each_entry_safe(tl, tn, &free, link)
__intel_timeline_free(&tl->kref);
Expand Down
9 changes: 4 additions & 5 deletions drivers/gpu/drm/i915/gt/intel_reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,6 @@ static bool __intel_gt_unset_wedged(struct intel_gt *gt)
{
struct intel_gt_timelines *timelines = &gt->timelines;
struct intel_timeline *tl;
unsigned long flags;
bool ok;

if (!test_bit(I915_WEDGED, &gt->reset.flags))
Expand All @@ -853,15 +852,15 @@ static bool __intel_gt_unset_wedged(struct intel_gt *gt)
*
* No more can be submitted until we reset the wedged bit.
*/
spin_lock_irqsave(&timelines->lock, flags);
spin_lock(&timelines->lock);
list_for_each_entry(tl, &timelines->active_list, link) {
struct dma_fence *fence;

fence = i915_active_fence_get(&tl->last_request);
if (!fence)
continue;

spin_unlock_irqrestore(&timelines->lock, flags);
spin_unlock(&timelines->lock);

/*
* All internal dependencies (i915_requests) will have
Expand All @@ -874,10 +873,10 @@ static bool __intel_gt_unset_wedged(struct intel_gt *gt)
dma_fence_put(fence);

/* Restart iteration after droping lock */
spin_lock_irqsave(&timelines->lock, flags);
spin_lock(&timelines->lock);
tl = list_entry(&timelines->active_list, typeof(*tl), link);
}
spin_unlock_irqrestore(&timelines->lock, flags);
spin_unlock(&timelines->lock);

/* We must reset pending GPU events before restoring our submission */
ok = !HAS_EXECLISTS(gt->i915); /* XXX better agnosticism desired */
Expand Down
10 changes: 4 additions & 6 deletions drivers/gpu/drm/i915/gt/intel_timeline.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ int intel_timeline_pin(struct intel_timeline *tl)
void intel_timeline_enter(struct intel_timeline *tl)
{
struct intel_gt_timelines *timelines = &tl->gt->timelines;
unsigned long flags;

/*
* Pretend we are serialised by the timeline->mutex.
Expand All @@ -358,16 +357,15 @@ void intel_timeline_enter(struct intel_timeline *tl)
if (atomic_add_unless(&tl->active_count, 1, 0))
return;

spin_lock_irqsave(&timelines->lock, flags);
spin_lock(&timelines->lock);
if (!atomic_fetch_inc(&tl->active_count))
list_add_tail(&tl->link, &timelines->active_list);
spin_unlock_irqrestore(&timelines->lock, flags);
spin_unlock(&timelines->lock);
}

void intel_timeline_exit(struct intel_timeline *tl)
{
struct intel_gt_timelines *timelines = &tl->gt->timelines;
unsigned long flags;

/* See intel_timeline_enter() */
lockdep_assert_held(&tl->mutex);
Expand All @@ -376,10 +374,10 @@ void intel_timeline_exit(struct intel_timeline *tl)
if (atomic_add_unless(&tl->active_count, -1, 1))
return;

spin_lock_irqsave(&timelines->lock, flags);
spin_lock(&timelines->lock);
if (atomic_dec_and_test(&tl->active_count))
list_del(&tl->link);
spin_unlock_irqrestore(&timelines->lock, flags);
spin_unlock(&timelines->lock);

/*
* Since this timeline is idle, all bariers upon which we were waiting
Expand Down

0 comments on commit 88cec49

Please sign in to comment.