diff mbox series

[1/2] dma-fence: Propagate errors to dma-fence-array container

Message ID 20190324131831.11317-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series [1/2] dma-fence: Propagate errors to dma-fence-array container | expand

Commit Message

Chris Wilson March 24, 2019, 1:18 p.m. UTC
When one of the array of fences is signaled, propagate its errors to the
parent fence-array (keeping the first error to be raised).

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Gustavo Padovan <gustavo@padovan.org>
---
 drivers/dma-buf/dma-fence-array.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

kernel test robot March 25, 2019, 2:21 a.m. UTC | #1
Hi Chris,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.1-rc1 next-20190322]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Chris-Wilson/dma-fence-Propagate-errors-to-dma-fence-array-container/20190325-074009
config: sparc64-allmodconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.2.0 make.cross ARCH=sparc64 

All warnings (new ones prefixed by >>):

   In file included from arch/sparc/include/asm/cmpxchg.h:5:0,
                    from arch/sparc/include/asm/atomic_64.h:12,
                    from arch/sparc/include/asm/atomic.h:5,
                    from include/linux/atomic.h:7,
                    from include/asm-generic/bitops/lock.h:5,
                    from arch/sparc/include/asm/bitops_64.h:52,
                    from arch/sparc/include/asm/bitops.h:5,
                    from include/linux/bitops.h:19,
                    from include/linux/kernel.h:12,
                    from include/asm-generic/bug.h:18,
                    from arch/sparc/include/asm/bug.h:25,
                    from include/linux/bug.h:5,
                    from include/linux/mmdebug.h:5,
                    from include/linux/gfp.h:5,
                    from include/linux/slab.h:15,
                    from drivers/dma-buf/dma-fence-array.c:21:
   drivers/dma-buf/dma-fence-array.c: In function 'dma_fence_array_cb_func':
   arch/sparc/include/asm/cmpxchg_64.h:199:3: warning: value computed is not used [-Wunused-value]
     ((__typeof__(*(ptr)))__cmpxchg_local((ptr), (unsigned long)(o), \
     ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       (unsigned long)(n), sizeof(*(ptr))))
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/dma-buf/dma-fence-array.c:50:3: note: in expansion of macro 'cmpxchg_local'
      cmpxchg_local(&array->base.error, 0, f->error);
      ^~~~~~~~~~~~~

vim +/cmpxchg_local +50 drivers/dma-buf/dma-fence-array.c

  > 21	#include <linux/slab.h>
    22	#include <linux/dma-fence-array.h>
    23	
    24	static const char *dma_fence_array_get_driver_name(struct dma_fence *fence)
    25	{
    26		return "dma_fence_array";
    27	}
    28	
    29	static const char *dma_fence_array_get_timeline_name(struct dma_fence *fence)
    30	{
    31		return "unbound";
    32	}
    33	
    34	static void irq_dma_fence_array_work(struct irq_work *wrk)
    35	{
    36		struct dma_fence_array *array = container_of(wrk, typeof(*array), work);
    37	
    38		dma_fence_signal(&array->base);
    39		dma_fence_put(&array->base);
    40	}
    41	
    42	static void dma_fence_array_cb_func(struct dma_fence *f,
    43					    struct dma_fence_cb *cb)
    44	{
    45		struct dma_fence_array_cb *array_cb =
    46			container_of(cb, struct dma_fence_array_cb, cb);
    47		struct dma_fence_array *array = array_cb->array;
    48	
    49		if (atomic_read(&array->num_pending) > 0)
  > 50			cmpxchg_local(&array->base.error, 0, f->error);
    51	
    52		if (atomic_dec_and_test(&array->num_pending))
    53			irq_work_queue(&array->work);
    54		else
    55			dma_fence_put(&array->base);
    56	}
    57	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot March 25, 2019, 11:08 a.m. UTC | #2
Hi Chris,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.1-rc2 next-20190325]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Chris-Wilson/dma-fence-Propagate-errors-to-dma-fence-array-container/20190325-074009
config: sh-allyesconfig (attached as .config)
compiler: sh4-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.2.0 make.cross ARCH=sh 

All errors (new ones prefixed by >>):

   drivers/dma-buf/dma-fence-array.c: In function 'dma_fence_array_cb_func':
>> drivers/dma-buf/dma-fence-array.c:50:3: error: implicit declaration of function 'cmpxchg_local'; did you mean 'cmpxchg_relaxed'? [-Werror=implicit-function-declaration]
      cmpxchg_local(&array->base.error, 0, f->error);
      ^~~~~~~~~~~~~
      cmpxchg_relaxed
   cc1: some warnings being treated as errors

vim +50 drivers/dma-buf/dma-fence-array.c

    41	
    42	static void dma_fence_array_cb_func(struct dma_fence *f,
    43					    struct dma_fence_cb *cb)
    44	{
    45		struct dma_fence_array_cb *array_cb =
    46			container_of(cb, struct dma_fence_array_cb, cb);
    47		struct dma_fence_array *array = array_cb->array;
    48	
    49		if (atomic_read(&array->num_pending) > 0)
  > 50			cmpxchg_local(&array->base.error, 0, f->error);
    51	
    52		if (atomic_dec_and_test(&array->num_pending))
    53			irq_work_queue(&array->work);
    54		else
    55			dma_fence_put(&array->base);
    56	}
    57	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox series

Patch

diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c
index a8c254497251..f931226616c0 100644
--- a/drivers/dma-buf/dma-fence-array.c
+++ b/drivers/dma-buf/dma-fence-array.c
@@ -46,6 +46,9 @@  static void dma_fence_array_cb_func(struct dma_fence *f,
 		container_of(cb, struct dma_fence_array_cb, cb);
 	struct dma_fence_array *array = array_cb->array;
 
+	if (atomic_read(&array->num_pending) > 0)
+		cmpxchg_local(&array->base.error, 0, f->error);
+
 	if (atomic_dec_and_test(&array->num_pending))
 		irq_work_queue(&array->work);
 	else
@@ -71,6 +74,7 @@  static bool dma_fence_array_enable_signaling(struct dma_fence *fence)
 		dma_fence_get(&array->base);
 		if (dma_fence_add_callback(array->fences[i], &cb[i].cb,
 					   dma_fence_array_cb_func)) {
+			cmpxchg(&array->base.error, 0, array->fences[i]->error);
 			dma_fence_put(&array->base);
 			if (atomic_dec_and_test(&array->num_pending))
 				return false;