Skip to contentSkip to conversation

kernel/dma/mapping.c:785:61: sparse: sparse: incorrect type in argument 5 (different base types)

PATCH kernel test robot 2 participants 2 messages Oct 30, 2024 – Oct 31, 2024

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   86e3904dcdc7e70e3257fc1de294a1b75f3d8d04
commit: 68b6dbf1f441c4eba3b8511728a41cf9b01dca35 [7444/8186] dma-mapping: trace more error paths
config: csky-randconfig-r111-20241030 (https://download.01.org/0day-ci/archive/20241030/[email protected]/config)
compiler: csky-linux-gcc (GCC) 14.1.0
reproduce: (https://download.01.org/0day-ci/archive/20241030/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

sparse warnings: (new ones prefixed by >>)

>> kernel/dma/mapping.c:785:61: sparse: sparse: incorrect type in argument 5 (different base types) @@     expected unsigned int enum dma_data_direction dir @@     got restricted gfp_t [usertype] gfp @@
   kernel/dma/mapping.c:785:61: sparse:     expected unsigned int enum dma_data_direction dir
   kernel/dma/mapping.c:785:61: sparse:     got restricted gfp_t [usertype] gfp
>> kernel/dma/mapping.c:785:66: sparse: sparse: incorrect type in argument 6 (different base types) @@     expected restricted gfp_t [usertype] flags @@     got unsigned int enum dma_data_direction dir @@

kernel/dma/mapping.c:785:66: sparse: expected restricted gfp_t [usertype] flags
kernel/dma/mapping.c:785:66: sparse: got unsigned int enum dma_data_direction dir

vim +785 kernel/dma/mapping.c

764
765 struct sg_table *dma_alloc_noncontiguous(struct device *dev, size_t size,
766 enum dma_data_direction dir, gfp_t gfp, unsigned long attrs)
767 {
768 struct sg_table *sgt;
769
770 if (WARN_ON_ONCE(attrs & ~DMA_ATTR_ALLOC_SINGLE_PAGES))
771 return NULL;
772 if (WARN_ON_ONCE(gfp & __GFP_COMP))
773 return NULL;
774
775 if (use_dma_iommu(dev))
776 sgt = iommu_dma_alloc_noncontiguous(dev, size, dir, gfp, attrs);
777 else
778 sgt = alloc_single_sgt(dev, size, dir, gfp);
779
780 if (sgt) {
781 sgt->nents = 1;
782 trace_dma_alloc_sgt(dev, sgt, size, dir, gfp, attrs);
783 debug_dma_map_sg(dev, sgt->sgl, sgt->orig_nents, 1, dir, attrs);
784 } else {

 > 785			trace_dma_alloc_sgt_err(dev, NULL, 0, size, gfp, dir, attrs);

786 }
787 return sgt;
788 }
789 EXPORT_SYMBOL_GPL(dma_alloc_noncontiguous);
790

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#1 lore raw
Quoted 43 lines · kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   86e3904dcdc7e70e3257fc1de294a1b75f3d8d04
commit: 68b6dbf1f441c4eba3b8511728a41cf9b01dca35 [7444/8186] dma-mapping: trace more error paths
config: csky-randconfig-r111-20241030 (https://download.01.org/0day-ci/archive/20241030/[email protected]/config)
compiler: csky-linux-gcc (GCC) 14.1.0
reproduce: (https://download.01.org/0day-ci/archive/20241030/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

sparse warnings: (new ones prefixed by >>)

Quoted 1 line
Quoted 1 line

kernel/dma/mapping.c:785:61: sparse: sparse: incorrect type in argument 5 (different base types) @@ expected unsigned int enum dma_data_direction dir @@ got restricted gfp_t [usertype] gfp @@

kernel/dma/mapping.c:785:61: sparse: expected unsigned int enum dma_data_direction dir
kernel/dma/mapping.c:785:61: sparse: got restricted gfp_t [usertype] gfp

Quoted 1 line
Quoted 1 line

kernel/dma/mapping.c:785:66: sparse: sparse: incorrect type in argument 6 (different base types) @@ expected restricted gfp_t [usertype] flags @@ got unsigned int enum dma_data_direction dir @@

kernel/dma/mapping.c:785:66: sparse: expected restricted gfp_t [usertype] flags
kernel/dma/mapping.c:785:66: sparse: got unsigned int enum dma_data_direction dir

vim +785 kernel/dma/mapping.c

   764	
   765	struct sg_table *dma_alloc_noncontiguous(struct device *dev, size_t size,
   766			enum dma_data_direction dir, gfp_t gfp, unsigned long attrs)
   767	{
   768		struct sg_table *sgt;
   769	
   770		if (WARN_ON_ONCE(attrs & ~DMA_ATTR_ALLOC_SINGLE_PAGES))
   771			return NULL;
   772		if (WARN_ON_ONCE(gfp & __GFP_COMP))
   773			return NULL;
   774	
   775		if (use_dma_iommu(dev))
   776			sgt = iommu_dma_alloc_noncontiguous(dev, size, dir, gfp, attrs);
   777		else
   778			sgt = alloc_single_sgt(dev, size, dir, gfp);
   779	
   780		if (sgt) {
   781			sgt->nents = 1;
   782			trace_dma_alloc_sgt(dev, sgt, size, dir, gfp, attrs);
   783			debug_dma_map_sg(dev, sgt->sgl, sgt->orig_nents, 1, dir, attrs);
   784		} else {
Quoted 7 lines
Quoted 1 line

785 trace_dma_alloc_sgt_err(dev, NULL, 0, size, gfp, dir, attrs);

786 }

   787		return sgt;
   788	}
   789	EXPORT_SYMBOL_GPL(dma_alloc_noncontiguous);
   790	

I'll send a patch for this, but oddly enough I don't see this error with C=1:

CHECK ../kernel/dma/mapping.c
../kernel/dma/mapping.c: note: in included file (through ../include/trace/trace_events.h, ../include/trace/define_trace.h, ../include/trace/events/dma.h):
../include/trace/events/dma.h:115:1: sparse: error: too long token expansion
../include/trace/events/dma.h:161:1: sparse: error: too long token expansion

I'm using sparse 0.6.4, which seems to be the same as the bot.

--Sean