Skip to content

Commit

Permalink
dma-buf/sw-sync: Reduce irqsave/irqrestore from known context
Browse files Browse the repository at this point in the history
If we know the context under which we are called, then we can use the
simpler form of spin_lock_irq (saving the save/restore).

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Gustavo Padovan <gustavo@padovan.org>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170629125930.821-4-chris@chris-wilson.co.uk
  • Loading branch information
Chris Wilson authored and Gustavo Padovan committed Jun 29, 2017
1 parent 8f66d3a commit a6aa8fc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
15 changes: 9 additions & 6 deletions drivers/dma-buf/sw_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,11 @@ static void sync_timeline_put(struct sync_timeline *obj)
*/
static void sync_timeline_signal(struct sync_timeline *obj, unsigned int inc)
{
unsigned long flags;
struct sync_pt *pt, *next;

trace_sync_timeline(obj);

spin_lock_irqsave(&obj->child_list_lock, flags);
spin_lock_irq(&obj->child_list_lock);

obj->value += inc;

Expand All @@ -150,7 +149,7 @@ static void sync_timeline_signal(struct sync_timeline *obj, unsigned int inc)
list_del_init(&pt->active_list);
}

spin_unlock_irqrestore(&obj->child_list_lock, flags);
spin_unlock_irq(&obj->child_list_lock);
}

/**
Expand All @@ -167,7 +166,6 @@ static void sync_timeline_signal(struct sync_timeline *obj, unsigned int inc)
static struct sync_pt *sync_pt_create(struct sync_timeline *obj, int size,
unsigned int value)
{
unsigned long flags;
struct sync_pt *pt;

if (size < sizeof(*pt))
Expand All @@ -177,13 +175,16 @@ static struct sync_pt *sync_pt_create(struct sync_timeline *obj, int size,
if (!pt)
return NULL;

spin_lock_irqsave(&obj->child_list_lock, flags);
spin_lock_irq(&obj->child_list_lock);

sync_timeline_get(obj);
dma_fence_init(&pt->base, &timeline_fence_ops, &obj->child_list_lock,
obj->context, value);
list_add_tail(&pt->child_list, &obj->child_list_head);
INIT_LIST_HEAD(&pt->active_list);
spin_unlock_irqrestore(&obj->child_list_lock, flags);

spin_unlock_irq(&obj->child_list_lock);

return pt;
}

Expand All @@ -206,9 +207,11 @@ static void timeline_fence_release(struct dma_fence *fence)
unsigned long flags;

spin_lock_irqsave(fence->lock, flags);

list_del(&pt->child_list);
if (!list_empty(&pt->active_list))
list_del(&pt->active_list);

spin_unlock_irqrestore(fence->lock, flags);

sync_timeline_put(parent);
Expand Down
14 changes: 6 additions & 8 deletions drivers/dma-buf/sync_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,16 @@ static void sync_print_fence(struct seq_file *s,
static void sync_print_obj(struct seq_file *s, struct sync_timeline *obj)
{
struct list_head *pos;
unsigned long flags;

seq_printf(s, "%s: %d\n", obj->name, obj->value);

spin_lock_irqsave(&obj->child_list_lock, flags);
spin_lock_irq(&obj->child_list_lock);
list_for_each(pos, &obj->child_list_head) {
struct sync_pt *pt =
container_of(pos, struct sync_pt, child_list);
sync_print_fence(s, &pt->base, false);
}
spin_unlock_irqrestore(&obj->child_list_lock, flags);
spin_unlock_irq(&obj->child_list_lock);
}

static void sync_print_sync_file(struct seq_file *s,
Expand All @@ -151,12 +150,11 @@ static void sync_print_sync_file(struct seq_file *s,

static int sync_debugfs_show(struct seq_file *s, void *unused)
{
unsigned long flags;
struct list_head *pos;

seq_puts(s, "objs:\n--------------\n");

spin_lock_irqsave(&sync_timeline_list_lock, flags);
spin_lock_irq(&sync_timeline_list_lock);
list_for_each(pos, &sync_timeline_list_head) {
struct sync_timeline *obj =
container_of(pos, struct sync_timeline,
Expand All @@ -165,19 +163,19 @@ static int sync_debugfs_show(struct seq_file *s, void *unused)
sync_print_obj(s, obj);
seq_putc(s, '\n');
}
spin_unlock_irqrestore(&sync_timeline_list_lock, flags);
spin_unlock_irq(&sync_timeline_list_lock);

seq_puts(s, "fences:\n--------------\n");

spin_lock_irqsave(&sync_file_list_lock, flags);
spin_lock_irq(&sync_file_list_lock);
list_for_each(pos, &sync_file_list_head) {
struct sync_file *sync_file =
container_of(pos, struct sync_file, sync_file_list);

sync_print_sync_file(s, sync_file);
seq_putc(s, '\n');
}
spin_unlock_irqrestore(&sync_file_list_lock, flags);
spin_unlock_irq(&sync_file_list_lock);
return 0;
}

Expand Down

0 comments on commit a6aa8fc

Please sign in to comment.