Re: kernel/dma/pool.c:79 cma_in_zone() warn: always true condition '(end <= ((((32) == 64)) << (32)) - 1))) => (0-u32max <= u32max)'

2020-08-25 Thread Christoph Hellwig
Looks like we might have to replace the IS_ENABLED with an ifdef to
cater for the 32-bit phys_addr_t and overzealous compilers.

On Tue, Aug 25, 2020 at 01:45:38PM +0800, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
> master
> head:   6a9dc5fd6170d0a41c8a14eb19e63d94bea5705a
> commit: d7e673ec2c8e0ea39c4c70fc490d67d7fbda869d dma-pool: Only allocate from 
> CMA when in same memory zone
> date:   11 days ago
> config: arc-randconfig-m031-20200824 (attached as .config)
> compiler: arc-elf-gcc (GCC) 9.3.0
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot 
> 
> New smatch warnings:
> kernel/dma/pool.c:79 cma_in_zone() warn: always true condition '(end <= 
> 32) == 64)) ?~0:((1 << (32)) - 1))) => (0-u32max <= u32max)'
> 
> Old smatch warnings:
> arch/arc/include/asm/thread_info.h:65 current_thread_info() error: 
> uninitialized symbol 'sp'.
> 
> # 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d7e673ec2c8e0ea39c4c70fc490d67d7fbda869d
> git remote add linus 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> git fetch --no-tags linus master
> git checkout d7e673ec2c8e0ea39c4c70fc490d67d7fbda869d
> vim +79 kernel/dma/pool.c
> 
> 59
> 60static bool cma_in_zone(gfp_t gfp)
> 61{
> 62unsigned long size;
> 63phys_addr_t end;
> 64struct cma *cma;
> 65
> 66cma = dev_get_cma_area(NULL);
> 67if (!cma)
> 68return false;
> 69
> 70size = cma_get_size(cma);
> 71if (!size)
> 72return false;
> 73
> 74/* CMA can't cross zone boundaries, see 
> cma_activate_area() */
> 75end = cma_get_base(cma) + size - 1;
> 76if (IS_ENABLED(CONFIG_ZONE_DMA) && (gfp & GFP_DMA))
> 77return end <= DMA_BIT_MASK(zone_dma_bits);
> 78if (IS_ENABLED(CONFIG_ZONE_DMA32) && (gfp & GFP_DMA32))
>   > 79return end <= DMA_BIT_MASK(32);
> 80return true;
> 81}
> 82
> 
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


---end quoted text---


kernel/dma/pool.c:79 cma_in_zone() warn: always true condition '(end <= ((((32) == 64)) << (32)) - 1))) => (0-u32max <= u32max)'

2020-08-24 Thread kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   6a9dc5fd6170d0a41c8a14eb19e63d94bea5705a
commit: d7e673ec2c8e0ea39c4c70fc490d67d7fbda869d dma-pool: Only allocate from 
CMA when in same memory zone
date:   11 days ago
config: arc-randconfig-m031-20200824 (attached as .config)
compiler: arc-elf-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

New smatch warnings:
kernel/dma/pool.c:79 cma_in_zone() warn: always true condition '(end <= 32) 
== 64)) ?~0:((1 << (32)) - 1))) => (0-u32max <= u32max)'

Old smatch warnings:
arch/arc/include/asm/thread_info.h:65 current_thread_info() error: 
uninitialized symbol 'sp'.

# 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d7e673ec2c8e0ea39c4c70fc490d67d7fbda869d
git remote add linus 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout d7e673ec2c8e0ea39c4c70fc490d67d7fbda869d
vim +79 kernel/dma/pool.c

59  
60  static bool cma_in_zone(gfp_t gfp)
61  {
62  unsigned long size;
63  phys_addr_t end;
64  struct cma *cma;
65  
66  cma = dev_get_cma_area(NULL);
67  if (!cma)
68  return false;
69  
70  size = cma_get_size(cma);
71  if (!size)
72  return false;
73  
74  /* CMA can't cross zone boundaries, see cma_activate_area() */
75  end = cma_get_base(cma) + size - 1;
76  if (IS_ENABLED(CONFIG_ZONE_DMA) && (gfp & GFP_DMA))
77  return end <= DMA_BIT_MASK(zone_dma_bits);
78  if (IS_ENABLED(CONFIG_ZONE_DMA32) && (gfp & GFP_DMA32))
  > 79  return end <= DMA_BIT_MASK(32);
80  return true;
81  }
82  

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


.config.gz
Description: application/gzip