drivers/staging/wfx/fwio.c:88:7: note: in expansion of macro 'virt_addr_valid'

From: kernel test robot
Date: Fri Jun 19 2020 - 04:04:32 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 5e857ce6eae7ca21b2055cca4885545e29228fe2
commit: 652b4afb240e5dc196995597942309e89e89c767 staging: wfx: load firmware
date: 9 months ago
config: m68k-randconfig-r004-20200619 (attached as .config)
compiler: m68k-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
git checkout 652b4afb240e5dc196995597942309e89e89c767
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=m68k

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>, old ones prefixed by <<):

drivers/staging/wfx/fwio.c:83:5: warning: no previous prototype for 'sram_write_dma_safe' [-Wmissing-prototypes]
83 | int sram_write_dma_safe(struct wfx_dev *wdev, u32 addr, const u8 *buf, size_t len)
| ^~~~~~~~~~~~~~~~~~~
In file included from arch/m68k/include/asm/page.h:49,
from arch/m68k/include/asm/thread_info.h:6,
from include/linux/thread_info.h:38,
from include/asm-generic/preempt.h:5,
from ./arch/m68k/include/generated/asm/preempt.h:1,
from include/linux/preempt.h:78,
from include/linux/spinlock.h:51,
from include/linux/mmzone.h:8,
from include/linux/gfp.h:6,
from include/linux/firmware.h:7,
from drivers/staging/wfx/fwio.c:8:
drivers/staging/wfx/fwio.c: In function 'sram_write_dma_safe':
arch/m68k/include/asm/page_no.h:33:50: warning: ordered comparison of pointer with null pointer [-Wextra]
33 | #define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && | ^~
>> drivers/staging/wfx/fwio.c:88:7: note: in expansion of macro 'virt_addr_valid'
88 | if (!virt_addr_valid(buf)) {
| ^~~~~~~~~~~~~~~
arch/m68k/include/asm/page_no.h:33:50: warning: ordered comparison of pointer with null pointer [-Wextra]
33 | #define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && | ^~
drivers/staging/wfx/fwio.c:96:7: note: in expansion of macro 'virt_addr_valid'
96 | if (!virt_addr_valid(buf))
| ^~~~~~~~~~~~~~~
drivers/staging/wfx/fwio.c: At top level:
drivers/staging/wfx/fwio.c:101:5: warning: no previous prototype for 'get_firmware' [-Wmissing-prototypes]
101 | int get_firmware(struct wfx_dev *wdev, u32 keyset_chip,
| ^~~~~~~~~~~~
drivers/staging/wfx/fwio.c:229:5: warning: no previous prototype for 'load_firmware_secure' [-Wmissing-prototypes]
229 | int load_firmware_secure(struct wfx_dev *wdev)
| ^~~~~~~~~~~~~~~~~~~~

vim +/virt_addr_valid +88 drivers/staging/wfx/fwio.c

71
72 /*
73 * request_firmware() allocate data using vmalloc(). It is not compatible with
74 * underlying hardware that use DMA. Function below detect this case and
75 * allocate a bounce buffer if necessary.
76 *
77 * Notice that, in doubt, you can enable CONFIG_DEBUG_SG to ask kernel to
78 * detect this problem at runtime (else, kernel silently fail).
79 *
80 * NOTE: it may also be possible to use 'pages' from struct firmware and avoid
81 * bounce buffer
82 */
83 int sram_write_dma_safe(struct wfx_dev *wdev, u32 addr, const u8 *buf, size_t len)
84 {
85 int ret;
86 const u8 *tmp;
87
> 88 if (!virt_addr_valid(buf)) {
89 tmp = kmemdup(buf, len, GFP_KERNEL);
90 if (!tmp)
91 return -ENOMEM;
92 } else {
93 tmp = buf;
94 }
95 ret = sram_buf_write(wdev, addr, tmp, len);
96 if (!virt_addr_valid(buf))
97 kfree(tmp);
98 return ret;
99 }
100

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

Attachment: .config.gz
Description: application/gzip