Skip to contentSkip to conversation

RDMA/umem: fix missing automated rename

PATCH In review Christian König 3 participants 5 messages Jun 7, 2021 InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/umem: fix missing automated rename

This occasions was missed during the recent rename of the function.

---
 drivers/infiniband/core/umem_dmabuf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/umem_dmabuf.c +1 -1
index 0d65ce146fc4..c6e875619fac 100644
@@ -66,7 +66,7 @@ int ib_umem_dmabuf_map_pages(struct ib_umem_dmabuf *umem_dmabuf)
 	 * may be not up-to-date. Wait for the exporter to finish
 	 * the migration.
 	 */
-	fence = dma_resv_get_excl(umem_dmabuf->attach->dmabuf->resv);
+	fence = dma_resv_excl_fence(umem_dmabuf->attach->dmabuf->resv);
 	if (fence)
 		return dma_fence_wait(fence, false);
 
Signature · 1 line
2.25.1
#1 lore raw
I love your patch! Yet something to improve:

Hi "Christian,

I love your patch! Yet something to improve:

[auto build test ERROR on rdma/for-next]
[also build test ERROR on tegra-drm/drm/tegra/for-next v5.13-rc5 next-20210604] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Christian-K-nig/RDMA-umem-fix-missing-automated-rename/20210607-150846
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git for-next
config: powerpc-randconfig-r035-20210607 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project ae973380c5f6be77ce395022be40350942260be9)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install powerpc cross compiling tool for clang build
# apt-get install binutils-powerpc-linux-gnu
# https://github.com/0day-ci/linux/commit/6a174683a13a824a00a001d656d1a1c2fb469ab8
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Christian-K-nig/RDMA-umem-fix-missing-automated-rename/20210607-150846 git checkout 6a174683a13a824a00a001d656d1a1c2fb469ab8
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

In file included from include/linux/dma-buf-map.h:9:
In file included from include/linux/io.h:13:
In file included from arch/powerpc/include/asm/io.h:619:
arch/powerpc/include/asm/io-defs.h:43:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] DEF_PCI_AC_NORET(insb, (unsigned long p, void *b, unsigned long c), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'

                   __do_##name al;                                 \
                   ^~~~~~~~~~~~~~
   <scratch space>:175:1: note: expanded from here
   __do_insb
   ^
   arch/powerpc/include/asm/io.h:556:56: note: expanded from macro '__do_insb'
   #define __do_insb(p, b, n)      readsb((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
                                          ~~~~~~~~~~~~~~~~~~~~~^
   In file included from drivers/infiniband/core/umem_dmabuf.c:6:
   In file included from include/linux/dma-buf.h:16:
   In file included from include/linux/dma-buf-map.h:9:
   In file included from include/linux/io.h:13:
   In file included from arch/powerpc/include/asm/io.h:619:
   arch/powerpc/include/asm/io-defs.h:45:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
   DEF_PCI_AC_NORET(insw, (unsigned long p, void *b, unsigned long c),
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
                   __do_##name al;                                 \
                   ^~~~~~~~~~~~~~
   <scratch space>:179:1: note: expanded from here
   __do_insw
   ^
   arch/powerpc/include/asm/io.h:557:56: note: expanded from macro '__do_insw'
   #define __do_insw(p, b, n)      readsw((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
                                          ~~~~~~~~~~~~~~~~~~~~~^
   In file included from drivers/infiniband/core/umem_dmabuf.c:6:
   In file included from include/linux/dma-buf.h:16:
   In file included from include/linux/dma-buf-map.h:9:
   In file included from include/linux/io.h:13:
   In file included from arch/powerpc/include/asm/io.h:619:
   arch/powerpc/include/asm/io-defs.h:47:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
   DEF_PCI_AC_NORET(insl, (unsigned long p, void *b, unsigned long c),
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
                   __do_##name al;                                 \
                   ^~~~~~~~~~~~~~
   <scratch space>:183:1: note: expanded from here
   __do_insl
   ^
   arch/powerpc/include/asm/io.h:558:56: note: expanded from macro '__do_insl'
   #define __do_insl(p, b, n)      readsl((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
                                          ~~~~~~~~~~~~~~~~~~~~~^
   In file included from drivers/infiniband/core/umem_dmabuf.c:6:
   In file included from include/linux/dma-buf.h:16:
   In file included from include/linux/dma-buf-map.h:9:
   In file included from include/linux/io.h:13:
   In file included from arch/powerpc/include/asm/io.h:619:
   arch/powerpc/include/asm/io-defs.h:49:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
   DEF_PCI_AC_NORET(outsb, (unsigned long p, const void *b, unsigned long c),
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
                   __do_##name al;                                 \
                   ^~~~~~~~~~~~~~
   <scratch space>:187:1: note: expanded from here
   __do_outsb
   ^
   arch/powerpc/include/asm/io.h:559:58: note: expanded from macro '__do_outsb'
   #define __do_outsb(p, b, n)     writesb((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
                                           ~~~~~~~~~~~~~~~~~~~~~^
   In file included from drivers/infiniband/core/umem_dmabuf.c:6:
   In file included from include/linux/dma-buf.h:16:
   In file included from include/linux/dma-buf-map.h:9:
   In file included from include/linux/io.h:13:
   In file included from arch/powerpc/include/asm/io.h:619:
   arch/powerpc/include/asm/io-defs.h:51:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
   DEF_PCI_AC_NORET(outsw, (unsigned long p, const void *b, unsigned long c),
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
                   __do_##name al;                                 \
                   ^~~~~~~~~~~~~~
   <scratch space>:191:1: note: expanded from here
   __do_outsw
   ^
   arch/powerpc/include/asm/io.h:560:58: note: expanded from macro '__do_outsw'
   #define __do_outsw(p, b, n)     writesw((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
                                           ~~~~~~~~~~~~~~~~~~~~~^
   In file included from drivers/infiniband/core/umem_dmabuf.c:6:
   In file included from include/linux/dma-buf.h:16:
   In file included from include/linux/dma-buf-map.h:9:
   In file included from include/linux/io.h:13:
   In file included from arch/powerpc/include/asm/io.h:619:
   arch/powerpc/include/asm/io-defs.h:53:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
   DEF_PCI_AC_NORET(outsl, (unsigned long p, const void *b, unsigned long c),
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
                   __do_##name al;                                 \
                   ^~~~~~~~~~~~~~
   <scratch space>:195:1: note: expanded from here
   __do_outsl
   ^
   arch/powerpc/include/asm/io.h:561:58: note: expanded from macro '__do_outsl'
   #define __do_outsl(p, b, n)     writesl((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
                                           ~~~~~~~~~~~~~~~~~~~~~^
>> drivers/infiniband/core/umem_dmabuf.c:69:10: error: implicit declaration of function 'dma_resv_excl_fence' [-Werror,-Wimplicit-function-declaration]
           fence = dma_resv_excl_fence(umem_dmabuf->attach->dmabuf->resv);
                   ^
   drivers/infiniband/core/umem_dmabuf.c:69:10: note: did you mean 'dma_resv_add_excl_fence'?
   include/linux/dma-resv.h:279:6: note: 'dma_resv_add_excl_fence' declared here
   void dma_resv_add_excl_fence(struct dma_resv *obj, struct dma_fence *fence);
        ^
   drivers/infiniband/core/umem_dmabuf.c:69:8: warning: incompatible integer to pointer conversion assigning to 'struct dma_fence *' from 'int' [-Wint-conversion]
           fence = dma_resv_excl_fence(umem_dmabuf->attach->dmabuf->resv);
                 ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

14 warnings and 1 error generated.

vim +/dma_resv_excl_fence +69 drivers/infiniband/core/umem_dmabuf.c

    11	
    12	int ib_umem_dmabuf_map_pages(struct ib_umem_dmabuf *umem_dmabuf)
    13	{
    14		struct sg_table *sgt;
    15		struct scatterlist *sg;
    16		struct dma_fence *fence;
    17		unsigned long start, end, cur = 0;
    18		unsigned int nmap = 0;
    19		int i;
    20	
    21		dma_resv_assert_held(umem_dmabuf->attach->dmabuf->resv);
    22	
    23		if (umem_dmabuf->sgt)
    24			goto wait_fence;
    25	
    26		sgt = dma_buf_map_attachment(umem_dmabuf->attach, DMA_BIDIRECTIONAL);
    27		if (IS_ERR(sgt))
    28			return PTR_ERR(sgt);
    29	
    30		/* modify the sg list in-place to match umem address and length */
    31	
    32		start = ALIGN_DOWN(umem_dmabuf->umem.address, PAGE_SIZE);
    33		end = ALIGN(umem_dmabuf->umem.address + umem_dmabuf->umem.length,
    34			    PAGE_SIZE);
    35		for_each_sgtable_dma_sg(sgt, sg, i) {
    36			if (start < cur + sg_dma_len(sg) && cur < end)
    37				nmap++;
    38			if (cur <= start && start < cur + sg_dma_len(sg)) {
    39				unsigned long offset = start - cur;
    40	
    41				umem_dmabuf->first_sg = sg;
    42				umem_dmabuf->first_sg_offset = offset;
    43				sg_dma_address(sg) += offset;
    44				sg_dma_len(sg) -= offset;
    45				cur += offset;
    46			}
    47			if (cur < end && end <= cur + sg_dma_len(sg)) {
    48				unsigned long trim = cur + sg_dma_len(sg) - end;
    49	
    50				umem_dmabuf->last_sg = sg;
    51				umem_dmabuf->last_sg_trim = trim;
    52				sg_dma_len(sg) -= trim;
    53				break;
    54			}
    55			cur += sg_dma_len(sg);
    56		}
    57	
    58		umem_dmabuf->umem.sg_head.sgl = umem_dmabuf->first_sg;
    59		umem_dmabuf->umem.sg_head.nents = nmap;
    60		umem_dmabuf->umem.nmap = nmap;
    61		umem_dmabuf->sgt = sgt;
    62	
    63	wait_fence:
    64		/*
    65		 * Although the sg list is valid now, the content of the pages
    66		 * may be not up-to-date. Wait for the exporter to finish
    67		 * the migration.
    68		 */
  > 69		fence = dma_resv_excl_fence(umem_dmabuf->attach->dmabuf->resv);
    70		if (fence)
    71			return dma_fence_wait(fence, false);
    72	
    73		return 0;
    74	}
    75	EXPORT_SYMBOL(ib_umem_dmabuf_map_pages);
    76	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#2 lore raw
In reply to Christian König
I love your patch! Yet something to improve:

Hi "Christian,

I love your patch! Yet something to improve:

[auto build test ERROR on rdma/for-next]
[also build test ERROR on tegra-drm/drm/tegra/for-next v5.13-rc5 next-20210604] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Christian-K-nig/RDMA-umem-fix-missing-automated-rename/20210607-150846
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git for-next
config: mips-randconfig-r031-20210607 (attached as .config)
compiler: mipsel-linux-gcc (GCC) 9.3.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/6a174683a13a824a00a001d656d1a1c2fb469ab8
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Christian-K-nig/RDMA-umem-fix-missing-automated-rename/20210607-150846 git checkout 6a174683a13a824a00a001d656d1a1c2fb469ab8
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=mips

If you fix the issue, kindly add following tag as appropriate

All error/warnings (new ones prefixed by >>):

drivers/infiniband/core/umem_dmabuf.c: In function 'ib_umem_dmabuf_map_pages':

>> drivers/infiniband/core/umem_dmabuf.c:69:10: error: implicit declaration of function 'dma_resv_excl_fence'; did you mean 'dma_resv_add_excl_fence'? [-Werror=implicit-function-declaration]
      69 |  fence = dma_resv_excl_fence(umem_dmabuf->attach->dmabuf->resv);
         |          ^~~~~~~~~~~~~~~~~~~
         |          dma_resv_add_excl_fence
>> drivers/infiniband/core/umem_dmabuf.c:69:8: warning: assignment to 'struct dma_fence *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
      69 |  fence = dma_resv_excl_fence(umem_dmabuf->attach->dmabuf->resv);
         |        ^

cc1: some warnings being treated as errors

vim +69 drivers/infiniband/core/umem_dmabuf.c

    11	
    12	int ib_umem_dmabuf_map_pages(struct ib_umem_dmabuf *umem_dmabuf)
    13	{
    14		struct sg_table *sgt;
    15		struct scatterlist *sg;
    16		struct dma_fence *fence;
    17		unsigned long start, end, cur = 0;
    18		unsigned int nmap = 0;
    19		int i;
    20	
    21		dma_resv_assert_held(umem_dmabuf->attach->dmabuf->resv);
    22	
    23		if (umem_dmabuf->sgt)
    24			goto wait_fence;
    25	
    26		sgt = dma_buf_map_attachment(umem_dmabuf->attach, DMA_BIDIRECTIONAL);
    27		if (IS_ERR(sgt))
    28			return PTR_ERR(sgt);
    29	
    30		/* modify the sg list in-place to match umem address and length */
    31	
    32		start = ALIGN_DOWN(umem_dmabuf->umem.address, PAGE_SIZE);
    33		end = ALIGN(umem_dmabuf->umem.address + umem_dmabuf->umem.length,
    34			    PAGE_SIZE);
    35		for_each_sgtable_dma_sg(sgt, sg, i) {
    36			if (start < cur + sg_dma_len(sg) && cur < end)
    37				nmap++;
    38			if (cur <= start && start < cur + sg_dma_len(sg)) {
    39				unsigned long offset = start - cur;
    40	
    41				umem_dmabuf->first_sg = sg;
    42				umem_dmabuf->first_sg_offset = offset;
    43				sg_dma_address(sg) += offset;
    44				sg_dma_len(sg) -= offset;
    45				cur += offset;
    46			}
    47			if (cur < end && end <= cur + sg_dma_len(sg)) {
    48				unsigned long trim = cur + sg_dma_len(sg) - end;
    49	
    50				umem_dmabuf->last_sg = sg;
    51				umem_dmabuf->last_sg_trim = trim;
    52				sg_dma_len(sg) -= trim;
    53				break;
    54			}
    55			cur += sg_dma_len(sg);
    56		}
    57	
    58		umem_dmabuf->umem.sg_head.sgl = umem_dmabuf->first_sg;
    59		umem_dmabuf->umem.sg_head.nents = nmap;
    60		umem_dmabuf->umem.nmap = nmap;
    61		umem_dmabuf->sgt = sgt;
    62	
    63	wait_fence:
    64		/*
    65		 * Although the sg list is valid now, the content of the pages
    66		 * may be not up-to-date. Wait for the exporter to finish
    67		 * the migration.
    68		 */
  > 69		fence = dma_resv_excl_fence(umem_dmabuf->attach->dmabuf->resv);
    70		if (fence)
    71			return dma_fence_wait(fence, false);
    72	
    73		return 0;
    74	}
    75	EXPORT_SYMBOL(ib_umem_dmabuf_map_pages);
    76	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#3 lore raw
In reply to Christian König

Ping. Can anybody give me a quick rb or ack-by?

The driver currently doesn't compile without this on the drm-misc-next branch.

Thanks,
Christian.

Am 07.06.21 um 09:06 schrieb Christian König:

Quoted 22 lines

This occasions was missed during the recent rename of the function.

---
  drivers/infiniband/core/umem_dmabuf.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/umem_dmabuf.c +1 -1
index 0d65ce146fc4..c6e875619fac 100644
@@ -66,7 +66,7 @@ int ib_umem_dmabuf_map_pages(struct ib_umem_dmabuf *umem_dmabuf)
  	 * may be not up-to-date. Wait for the exporter to finish
  	 * the migration.
  	 */
-	fence = dma_resv_get_excl(umem_dmabuf->attach->dmabuf->resv);
+	fence = dma_resv_excl_fence(umem_dmabuf->attach->dmabuf->resv);
  	if (fence)
  		return dma_fence_wait(fence, false);
 
Reviewed-by
#4 lore raw
Quoted 33 lines · Christian König

Ping. Can anybody give me a quick rb or ack-by?

The driver currently doesn't compile without this on the drm-misc-next branch.

Thanks,
Christian.

Am 07.06.21 um 09:06 schrieb Christian König:

Quoted 22 lines

This occasions was missed during the recent rename of the function.

---
  drivers/infiniband/core/umem_dmabuf.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/umem_dmabuf.c +1 -1
index 0d65ce146fc4..c6e875619fac 100644
@@ -66,7 +66,7 @@ int ib_umem_dmabuf_map_pages(struct ib_umem_dmabuf *umem_dmabuf)
       * may be not up-to-date. Wait for the exporter to finish
       * the migration.
       */
-     fence = dma_resv_get_excl(umem_dmabuf->attach->dmabuf->resv);
+     fence = dma_resv_excl_fence(umem_dmabuf->attach->dmabuf->resv);
      if (fence)
              return dma_fence_wait(fence, false);