dma-buf: explicitely note that dma-fence-chains use 64bit seqno
Subsystems (2)
PATCH 1/1 dma-buf: explicitely note that dma-fence-chains use 64bit seqno
Instead of checking the upper values of the sequence number use an explicit field in the dma_fence_ops structure to note if a sequence should be 32bit or 64bit.
Signed-off-by Christian König <[email protected]>
--- drivers/dma-buf/dma-fence-chain.c | 3 ++- drivers/dma-buf/sw_sync.c | 2 +- drivers/dma-buf/sync_file.c | 3 ++- include/linux/dma-fence.h | 21 +++++++++++++++------ 4 files changed, 20 insertions(+), 9 deletions(-)
drivers/dma-buf/dma-fence-chain.c +2 -1
@@ -193,6 +193,7 @@ static void dma_fence_chain_release(struct dma_fence *fence) }const struct dma_fence_ops dma_fence_chain_ops = { + .use_64bit_seqno = true, .get_driver_name = dma_fence_chain_get_driver_name, .get_timeline_name = dma_fence_chain_get_timeline_name, .enable_signaling = dma_fence_chain_enable_signaling,
@@ -225,7 +226,7 @@ void dma_fence_chain_init(struct dma_fence_chain *chain,init_irq_work (&chain->work, dma_fence_chain_irq_work);/* Try to reuse the context of the previous chain node. */ -if (prev_chain &&__dma_fence_is_later (seqno, prev->seqno)) { +if (prev_chain &&__dma_fence_is_later (seqno, prev->seqno, prev->ops)) { context = prev->context; chain->prev_seqno = prev->seqno; }else {
drivers/dma-buf/sw_sync.c +1 -1
@@ -161,7 +161,7 @@ static bool timeline_fence_signaled(struct dma_fence *fence) {struct sync_timeline *parent =dma_fence_parent (fence); -return !__dma_fence_is_later (fence->seqno, parent->value); +return !__dma_fence_is_later (fence->seqno, parent->value, fence->ops); }static bool timeline_fence_enable_signaling (struct dma_fence *fence)
drivers/dma-buf/sync_file.c +2 -1
@@ -258,7 +258,8 @@ static struct sync_file *sync_file_merge(const char *name, struct sync_file *a, i_b++; }else { -if (__dma_fence_is_later (pt_a->seqno, pt_b->seqno)) +if (__dma_fence_is_later (pt_a->seqno, pt_b->seqno, + pt_a->ops))add_fence (fences, &i, pt_a);else add_fence (fences, &i, pt_b);
include/linux/dma-fence.h +15 -6
@@ -111,6 +111,14 @@ struct dma_fence_cb {* */ struct dma_fence_ops { +/** +* @use_64bit_seqno: +* +* True if this dma_fence implementation uses 64bit seqno, false +* otherwise. +*/ +bool use_64bit_seqno; +/** * @get_driver_name: *
@@ -410,18 +418,19 @@ dma_fence_is_signaled(struct dma_fence *fence)* __dma_fence_is_later - return if f1 is chronologically later than f2 * @f1: the first fence's seqno * @f2: the second fence's seqno from the same context +* @ops: dma_fence_ops associated with the seqno * * Returns true if f1 is chronologically later than f2. Both fences must be * from the same context, since a seqno is not common across contexts. */ -static inline bool __dma_fence_is_later (u64 f1,u64 f2) +static inline bool __dma_fence_is_later (u64 f1,u64 f2, +const struct dma_fence_ops *ops) {/* This is for backward compatibility with drivers which can only handle -* 32bit sequence numbers. Use a 64bit compare when any of the higher -* bits are none zero, otherwise use a 32bit compare with wrap around -* handling. +* 32bit sequence numbers. Use a 64bit compare when the driver says to +* do so. */ -if (upper_32_bits (f1) ||upper_32_bits (f2)) +if (ops->use_64bit_seqno)return f1 > f2;return (int )(lower_32_bits (f1) -lower_32_bits (f2)) >0 ;
@@ -441,7 +450,7 @@ static inline bool dma_fence_is_later(struct dma_fence *f1,if (WARN_ON (f1->context != f2->context))return false; -return __dma_fence_is_later (f1->seqno, f2->seqno); +return __dma_fence_is_later (f1->seqno, f2->seqno, f1->ops); }/**
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 5 lines · Christian König
Instead of checking the upper values of the sequence number use an explicit field in the
dma_fence_opsstructure to note if a sequence should be 32bit or 64bit.Signed-off-by Christian König <[email protected]>
That works for me :)
Reviewed-by Lionel Landwerlin <[email protected]>
Thanks!
Quoted 100 lines
--- drivers/dma-buf/dma-fence-chain.c | 3 ++- drivers/dma-buf/sw_sync.c | 2 +- drivers/dma-buf/sync_file.c | 3 ++- include/linux/dma-fence.h | 21 +++++++++++++++------ 4 files changed, 20 insertions(+), 9 deletions(-)drivers/dma-buf/dma-fence-chain.c +2
-1@@ -193,6 +193,7 @@ static void dma_fence_chain_release(struct dma_fence *fence) }const struct dma_fence_ops dma_fence_chain_ops = { + .use_64bit_seqno = true, .get_driver_name = dma_fence_chain_get_driver_name, .get_timeline_name = dma_fence_chain_get_timeline_name, .enable_signaling = dma_fence_chain_enable_signaling,@@ -225,7 +226,7 @@ void dma_fence_chain_init(struct dma_fence_chain *chain,init_irq_work (&chain->work, dma_fence_chain_irq_work);/* Try to reuse the context of the previous chain node. */ -if (prev_chain &&__dma_fence_is_later (seqno, prev->seqno)) { +if (prev_chain &&__dma_fence_is_later (seqno, prev->seqno, prev->ops)) { context = prev->context; chain->prev_seqno = prev->seqno; }else {drivers/dma-buf/sw_sync.c +1
-1@@ -161,7 +161,7 @@ static bool timeline_fence_signaled(struct dma_fence *fence) {struct sync_timeline *parent =dma_fence_parent (fence); -return !__dma_fence_is_later (fence->seqno, parent->value); +return !__dma_fence_is_later (fence->seqno, parent->value, fence->ops); }static bool timeline_fence_enable_signaling (struct dma_fence *fence)drivers/dma-buf/sync_file.c +2
-1@@ -258,7 +258,8 @@ static struct sync_file *sync_file_merge(const char *name, struct sync_file *a, i_b++; }else { -if (__dma_fence_is_later (pt_a->seqno, pt_b->seqno)) +if (__dma_fence_is_later (pt_a->seqno, pt_b->seqno, + pt_a->ops))add_fence (fences, &i, pt_a);else add_fence (fences, &i, pt_b);include/linux/dma-fence.h +14
-5@@ -111,6 +111,14 @@ struct dma_fence_cb {* */ struct dma_fence_ops { +/** +* @use_64bit_seqno: +* +* True if this dma_fence implementation uses 64bit seqno, false +* otherwise. +*/ +bool use_64bit_seqno; +/** * @get_driver_name: * @@ -410,18 +418,19 @@ dma_fence_is_signaled(struct dma_fence *fence)* __dma_fence_is_later - return if f1 is chronologically later than f2 * @f1: the first fence's seqno * @f2: the second fence's seqno from the same context +* @ops: dma_fence_ops associated with the seqno * * Returns true if f1 is chronologically later than f2. Both fences must be * from the same context, since a seqno is not common across contexts. */ -static inline bool __dma_fence_is_later (u64 f1,u64 f2) +static inline bool __dma_fence_is_later (u64 f1,u64 f2, +const struct dma_fence_ops *ops) {/* This is for backward compatibility with drivers which can only handle -* 32bit sequence numbers. Use a 64bit compare when any of the higher -* bits are none zero, otherwise use a 32bit compare with wrap around -* handling. +* 32bit sequence numbers. Use a 64bit compare when the driver says to +* do so. */ -if (upper_32_bits (f1) ||upper_32_bits (f2)) +if (ops->use_64bit_seqno)return f1 > f2;return (int )(lower_32_bits (f1) -lower_32_bits (f2)) >0 ;
include/linux/dma-fence.h static inline bool dma_fence_is_later(struct dma_fence *f1, · line 456
Quoted 8 lines
include/linux/dma-fence.h +1
-1@@ -441,7 +450,7 @@ static inline bool dma_fence_is_later(struct dma_fence *f1,if (WARN_ON (f1->context != f2->context))return false; -return __dma_fence_is_later (f1->seqno, f2->seqno); +return __dma_fence_is_later (f1->seqno, f2->seqno, f1->ops); }/**
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel