Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 363271
b: refs/heads/master
c: c5b86b7
h: refs/heads/master
i:
  363269: 59a0b70
  363267: 2d2031b
  363263: 2f0623b
v: v3
  • Loading branch information
Erik Gilling authored and Greg Kroah-Hartman committed Mar 4, 2013
1 parent 3a8fb96 commit 60e7405
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 01544170e1959dd261ceec6413674a528221669b
refs/heads/master: c5b86b7418f46220a623277718d6a909f520477b
29 changes: 13 additions & 16 deletions trunk/drivers/staging/android/sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ struct sync_timeline *sync_timeline_create(const struct sync_timeline_ops *ops,
if (obj == NULL)
return NULL;

kref_init(&obj->kref);
obj->ops = ops;
strlcpy(obj->name, name, sizeof(obj->name));

Expand All @@ -68,8 +69,10 @@ struct sync_timeline *sync_timeline_create(const struct sync_timeline_ops *ops,
}
EXPORT_SYMBOL(sync_timeline_create);

static void sync_timeline_free(struct sync_timeline *obj)
static void sync_timeline_free(struct kref *kref)
{
struct sync_timeline *obj =
container_of(kref, struct sync_timeline, kref);
unsigned long flags;

if (obj->ops->release_obj)
Expand All @@ -84,17 +87,14 @@ static void sync_timeline_free(struct sync_timeline *obj)

void sync_timeline_destroy(struct sync_timeline *obj)
{
unsigned long flags;
bool needs_freeing;

spin_lock_irqsave(&obj->child_list_lock, flags);
obj->destroyed = true;
needs_freeing = list_empty(&obj->child_list_head);
spin_unlock_irqrestore(&obj->child_list_lock, flags);

if (needs_freeing)
sync_timeline_free(obj);
else
/*
* If this is not the last reference, signal any children
* that their parent is going away.
*/

if (!kref_put(&obj->kref, sync_timeline_free))
sync_timeline_signal(obj);
}
EXPORT_SYMBOL(sync_timeline_destroy);
Expand All @@ -114,7 +114,6 @@ static void sync_timeline_remove_pt(struct sync_pt *pt)
{
struct sync_timeline *obj = pt->parent;
unsigned long flags;
bool needs_freeing = false;

spin_lock_irqsave(&obj->active_list_lock, flags);
if (!list_empty(&pt->active_list))
Expand All @@ -124,13 +123,8 @@ static void sync_timeline_remove_pt(struct sync_pt *pt)
spin_lock_irqsave(&obj->child_list_lock, flags);
if (!list_empty(&pt->child_list)) {
list_del_init(&pt->child_list);
needs_freeing = obj->destroyed &&
list_empty(&obj->child_list_head);
}
spin_unlock_irqrestore(&obj->child_list_lock, flags);

if (needs_freeing)
sync_timeline_free(obj);
}

void sync_timeline_signal(struct sync_timeline *obj)
Expand Down Expand Up @@ -177,6 +171,7 @@ struct sync_pt *sync_pt_create(struct sync_timeline *parent, int size)
return NULL;

INIT_LIST_HEAD(&pt->active_list);
kref_get(&parent->kref);
sync_timeline_add_pt(parent, pt);

return pt;
Expand All @@ -190,6 +185,8 @@ void sync_pt_free(struct sync_pt *pt)

sync_timeline_remove_pt(pt);

kref_put(&pt->parent->kref, sync_timeline_free);

kfree(pt);
}
EXPORT_SYMBOL(sync_pt_free);
Expand Down
2 changes: 2 additions & 0 deletions trunk/drivers/staging/android/sync.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ struct sync_timeline_ops {

/**
* struct sync_timeline - sync object
* @kref: reference count on fence.
* @ops: ops that define the implementaiton of the sync_timeline
* @name: name of the sync_timeline. Useful for debugging
* @destoryed: set when sync_timeline is destroyed
Expand All @@ -90,6 +91,7 @@ struct sync_timeline_ops {
* @sync_timeline_list: membership in global sync_timeline_list
*/
struct sync_timeline {
struct kref kref;
const struct sync_timeline_ops *ops;
char name[32];

Expand Down

0 comments on commit 60e7405

Please sign in to comment.