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

From: Linus Walleij
Date: Sun Sep 18 2022 - 10:33:54 EST


On Fri, Sep 16, 2022 at 8:19 PM kernel test robot <lkp@xxxxxxxxx> 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@xxxxxxxxx/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