linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [linux-stable-rc:linux-5.4.y 5364/5387] drivers/infiniband/sw/siw/siw_qp_tx.c:32:37: warning: cast to pointer from integer of different size
@ 2022-09-16 18:18 kernel test robot
  2022-09-18 14:33 ` Linus Walleij
  0 siblings, 1 reply; 2+ messages in thread
From: kernel test robot @ 2022-09-16 18:18 UTC (permalink / raw)
  To: Linus Walleij
  Cc: kbuild-all, linux-kernel, Greg Kroah-Hartman, Leon Romanovsky,
	Sasha Levin

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-5.4.y
head:   ba0de553122f5be5dde3102746a1060fd2737e63
commit: e7f78835d551bb2deb5aa3346d84c8f03ade313d [5364/5387] RDMA/siw: Pass a pointer to virt_to_page()
config: riscv-randconfig-r013-20220916 (https://download.01.org/0day-ci/archive/20220917/202209170232.grVMomkJ-lkp@intel.com/config)
compiler: riscv32-linux-gcc (GCC) 12.1.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://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git/commit/?id=e7f78835d551bb2deb5aa3346d84c8f03ade313d
        git remote add linux-stable-rc https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
        git fetch --no-tags linux-stable-rc linux-5.4.y
        git checkout e7f78835d551bb2deb5aa3346d84c8f03ade313d
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash drivers/infiniband/sw/siw/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from arch/riscv/include/asm/page.h:130,
                    from arch/riscv/include/asm/thread_info.h:11,
                    from include/linux/thread_info.h:39,
                    from include/asm-generic/preempt.h:5,
                    from ./arch/riscv/include/generated/asm/preempt.h:1,
                    from include/linux/preempt.h:78,
                    from include/linux/percpu.h:6,
                    from include/linux/prandom.h:12,
                    from include/linux/random.h:101,
                    from include/linux/net.h:18,
                    from drivers/infiniband/sw/siw/siw_qp_tx.c:8:
   drivers/infiniband/sw/siw/siw_qp_tx.c: In function 'siw_get_pblpage':
>> drivers/infiniband/sw/siw/siw_qp_tx.c:32:37: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
      32 |                 return virt_to_page((void *)paddr);
         |                                     ^
   include/asm-generic/memory_model.h:69:32: note: in definition of macro '__pfn_to_page'
      69 | ({      unsigned long __pfn = (pfn);                    \
         |                                ^~~
   arch/riscv/include/asm/page.h:100:34: note: in expansion of macro 'PFN_DOWN'
     100 | #define phys_to_pfn(phys)       (PFN_DOWN(phys))
         |                                  ^~~~~~~~
   arch/riscv/include/asm/page.h:103:34: note: in expansion of macro 'phys_to_pfn'
     103 | #define virt_to_pfn(vaddr)      (phys_to_pfn(__pa(vaddr)))
         |                                  ^~~~~~~~~~~
   arch/riscv/include/asm/page.h:103:46: note: in expansion of macro '__pa'
     103 | #define virt_to_pfn(vaddr)      (phys_to_pfn(__pa(vaddr)))
         |                                              ^~~~
   arch/riscv/include/asm/page.h:106:46: note: in expansion of macro 'virt_to_pfn'
     106 | #define virt_to_page(vaddr)     (pfn_to_page(virt_to_pfn(vaddr)))
         |                                              ^~~~~~~~~~~
   drivers/infiniband/sw/siw/siw_qp_tx.c:32:24: note: in expansion of macro 'virt_to_page'
      32 |                 return virt_to_page((void *)paddr);
         |                        ^~~~~~~~~~~~


vim +32 drivers/infiniband/sw/siw/siw_qp_tx.c

     5	
     6	#include <linux/errno.h>
     7	#include <linux/types.h>
   > 8	#include <linux/net.h>
     9	#include <linux/scatterlist.h>
    10	#include <linux/highmem.h>
    11	#include <net/tcp.h>
    12	
    13	#include <rdma/iw_cm.h>
    14	#include <rdma/ib_verbs.h>
    15	#include <rdma/ib_user_verbs.h>
    16	
    17	#include "siw.h"
    18	#include "siw_verbs.h"
    19	#include "siw_mem.h"
    20	
    21	#define MAX_HDR_INLINE					\
    22		(((uint32_t)(sizeof(struct siw_rreq_pkt) -	\
    23			     sizeof(struct iwarp_send))) & 0xF8)
    24	
    25	static struct page *siw_get_pblpage(struct siw_mem *mem, u64 addr, int *idx)
    26	{
    27		struct siw_pbl *pbl = mem->pbl;
    28		u64 offset = addr - mem->va;
    29		dma_addr_t paddr = siw_pbl_get_buffer(pbl, offset, NULL, idx);
    30	
    31		if (paddr)
  > 32			return virt_to_page((void *)paddr);
    33	
    34		return NULL;
    35	}
    36	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [linux-stable-rc:linux-5.4.y 5364/5387] drivers/infiniband/sw/siw/siw_qp_tx.c:32:37: warning: cast to pointer from integer of different size
  2022-09-16 18:18 [linux-stable-rc:linux-5.4.y 5364/5387] drivers/infiniband/sw/siw/siw_qp_tx.c:32:37: warning: cast to pointer from integer of different size kernel test robot
@ 2022-09-18 14:33 ` Linus Walleij
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2022-09-18 14:33 UTC (permalink / raw)
  To: kernel test robot
  Cc: kbuild-all, linux-kernel, Greg Kroah-Hartman, Leon Romanovsky,
	Sasha Levin

On Fri, Sep 16, 2022 at 8:19 PM kernel test robot <lkp@intel.com> wrote:

> commit: e7f78835d551bb2deb5aa3346d84c8f03ade313d [5364/5387] RDMA/siw: Pass a pointer to virt_to_page()
> config: riscv-randconfig-r013-20220916 (https://download.01.org/0day-ci/archive/20220917/202209170232.grVMomkJ-lkp@intel.com/config)
> compiler: riscv32-linux-gcc (GCC) 12.1.0

So if RISCV32 ...

>     31          if (paddr)
>   > 32                  return virt_to_page((void *)paddr);

Think that passing a (void *) to virt_to_page() is a problem:

> warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
>       32 |                 return virt_to_page((void *)paddr);

I would think this is a problem with RISCV32.

What has this arch done?

This is a few lines up:

> dma_addr_t paddr = siw_pbl_get_buffer(pbl, offset, NULL, idx);

dma_addr_t is a different size than (void *)?

Given that the patch raising this problem looked like this:

-               return virt_to_page(paddr);
+               return virt_to_page((void *)paddr);

I doubt that it has created a bug that wasn't there before. Passing
a dma_addr_t to virt_to_page() might be wrong, but that is what the
driver has been doing all the time.

siw_pbl_get_buffer() claims to
"Gets physical address backed by PBL element."
Why is that even passed to virt_to_page() if it's no virtual address
but a dma_addr_t to begin with?

I certainly don't understand SIW, but this bug, if it is a bug (or a type and
documentation bug) is clearly not new.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-18 14:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-16 18:18 [linux-stable-rc:linux-5.4.y 5364/5387] drivers/infiniband/sw/siw/siw_qp_tx.c:32:37: warning: cast to pointer from integer of different size kernel test robot
2022-09-18 14:33 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).