Message ID | CAABpnA-85QdwoYO5Ldz52bxw1_dWaQz541MjgEGZhwdu+Bhtvw@mail.gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
op 07-11-13 22:11, Rom Lemarchand schreef: > Hi Maarten, I tested your changes and needed the attached patch: behavior > now seems equivalent as android sync. I haven't tested performance. > > The issue resolved by this patch happens when i_b < b->num_fences and > i_a >= a->num_fences (or vice versa). Then, pt_a is invalid and so > dereferencing pt_a->context causes a crash. Oops, thinko. :) Originally I had it correct by doing this: + /* + * Assume sync_fence a and b are both ordered and have no + * duplicates with the same context. + * + * If a sync_fence can only be created with sync_fence_merge + * and sync_fence_create, this is a reasonable assumption. + */ + for (i = i_a = i_b = 0; i_a < a->num_fences && i_b < b->num_fences; ) { + struct fence *pt_a = a->cbs[i_a].sync_pt; + struct fence *pt_b = b->cbs[i_b].sync_pt; + + if (pt_a->context < pt_b->context) { + sync_fence_add_pt(fence, &i, pt_a); + + i_a++; + } else if (pt_a->context > pt_b->context) { + sync_fence_add_pt(fence, &i, pt_b); + + i_b++; + } else { + if (pt_a->seqno - pt_b->seqno <= INT_MAX) + sync_fence_add_pt(fence, &i, pt_a); + else + sync_fence_add_pt(fence, &i, pt_b); + + i_a++; + i_b++; + } + } + + /* Add remaining fences from a or b*/ + for (; i_a < a->num_fences; i_a++) + sync_fence_add_pt(fence, &i, a->cbs[i_a].sync_pt); + + for (; i_b < b->num_fences; i_b++) + sync_fence_add_pt(fence, &i, b->cbs[i_b].sync_pt); Then I thought I could clean it up by merging it, but that ended up being more unreadable and crashing... so I guess I'll revert back to this version. :)
op 07-11-13 22:11, Rom Lemarchand schreef: > Hi Maarten, I tested your changes and needed the attached patch: behavior > now seems equivalent as android sync. I haven't tested performance. > > The issue resolved by this patch happens when i_b < b->num_fences and i_a >> = a->num_fences (or vice versa). Then, pt_a is invalid and so > dereferencing pt_a->context causes a crash. > Yeah, I pushed my original fix. I intended to keep android userspace behavior the same, and I tried to keep the kernelspace the api same as much as I could. If peformance is the same, or not noticeably worse, would there be any objections on the android side about renaming dma-fence to syncpoint, and getting it in mainline? ~Maarten
Let me run some benchmarks today, talk to people internally, and I'll let you know. On Nov 8, 2013 3:43 AM, "Maarten Lankhorst" <maarten.lankhorst@canonical.com> wrote: > op 07-11-13 22:11, Rom Lemarchand schreef: > > Hi Maarten, I tested your changes and needed the attached patch: behavior > > now seems equivalent as android sync. I haven't tested performance. > > > > The issue resolved by this patch happens when i_b < b->num_fences and i_a > >> = a->num_fences (or vice versa). Then, pt_a is invalid and so > > dereferencing pt_a->context causes a crash. > > > Yeah, I pushed my original fix. I intended to keep android userspace > behavior the same, and I tried to keep the kernelspace the api same as much > as I could. If peformance is the same, or not noticeably worse, would there > be any objections on the android side about renaming dma-fence to > syncpoint, and getting it in mainline? > > ~Maarten >
I ran some benchmarks and things seem to be running about the same. No one on our graphics team seemed concerned about the change. The only concern I heard was about the increased complexity of the new sync code as opposed to the old sync framework which tried to keep things straightforward. On Fri, Nov 8, 2013 at 3:43 AM, Maarten Lankhorst < maarten.lankhorst@canonical.com> wrote: > op 07-11-13 22:11, Rom Lemarchand schreef: > > Hi Maarten, I tested your changes and needed the attached patch: behavior > > now seems equivalent as android sync. I haven't tested performance. > > > > The issue resolved by this patch happens when i_b < b->num_fences and i_a > >> = a->num_fences (or vice versa). Then, pt_a is invalid and so > > dereferencing pt_a->context causes a crash. > > > Yeah, I pushed my original fix. I intended to keep android userspace > behavior the same, and I tried to keep the kernelspace the api same as much > as I could. If peformance is the same, or not noticeably worse, would there > be any objections on the android side about renaming dma-fence to > syncpoint, and getting it in mainline? > > ~Maarten >
From a440530a29682c595ad69b8cbb35c568228a8777 Mon Sep 17 00:00:00 2001 From: Rom Lemarchand <romlem@google.com> Date: Thu, 7 Nov 2013 11:36:08 -0800 Subject: [PATCH] fix Change-Id: Ie8a10dc466462835456d12962b378158a917a33e --- drivers/staging/android/sync.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index 1025857..04af0fe 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -266,11 +266,19 @@ struct sync_fence *sync_fence_merge(const char *name, struct fence *pt_a = a->cbs[i_a].sync_pt; struct fence *pt_b = b->cbs[i_b].sync_pt; - if (i_b >= b->num_fences || pt_a->context < pt_b->context) { + if (i_b >= b->num_fences) { sync_fence_add_pt(fence, &i, pt_a); i_a++; - } else if (i_a >= a->num_fences || pt_a->context > pt_b->context) { + } else if (i_a >= a->num_fences) { + sync_fence_add_pt(fence, &i, pt_b); + + i_b++; + } else if (pt_a->context < pt_b->context) { + sync_fence_add_pt(fence, &i, pt_a); + + i_a++; + } else if (pt_a->context > pt_b->context) { sync_fence_add_pt(fence, &i, pt_b); i_b++; -- 1.8.4.1