All of lore.kernel.org
 help / color / mirror / Atom feed
* [openeuler:openEuler-1.0-LTS 1932/1932] drivers/char/svm.c:366:43: sparse: sparse: incorrect type in argument 1 (different address spaces)
@ 2025-11-05 23:49 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2025-11-05 23:49 UTC (permalink / raw)
  To: kernel, Yang Yingliang; +Cc: oe-kbuild-all

tree:   https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head:   27e321784c005c852ca4b3a2d146547deac0698f
commit: 51d0e1a742714b2599d54fd92a71bd2998b01084 [1932/1932] support multiple node for getting phys interface
config: arm64-randconfig-r132-20251106 (https://download.01.org/0day-ci/archive/20251106/202511060739.4h8XJsMM-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 11.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251106/202511060739.4h8XJsMM-lkp@intel.com/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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202511060739.4h8XJsMM-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
   drivers/char/svm.c:248:20: sparse: sparse: symbol 'svm_find_mem_reg_node' was not declared. Should it be static?
   drivers/char/svm.c:325:14: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct svm_va2pa_slot *slot @@     got void [noderef] <asn:2> * @@
   drivers/char/svm.c:325:14: sparse:     expected struct svm_va2pa_slot *slot
   drivers/char/svm.c:325:14: sparse:     got void [noderef] <asn:2> *
>> drivers/char/svm.c:366:43: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void volatile [noderef] <asn:2> *addr @@     got struct svm_va2pa_slot *slots @@
   drivers/char/svm.c:366:43: sparse:     expected void volatile [noderef] <asn:2> *addr
   drivers/char/svm.c:366:43: sparse:     got struct svm_va2pa_slot *slots
   drivers/char/svm.c:449:6: sparse: sparse: symbol 'sysrq_sched_debug_show_export' was not declared. Should it be static?
   drivers/char/svm.c:1272:35: sparse: sparse: Using plain integer as NULL pointer
   drivers/char/svm.c:248:21: warning: no previous prototype for 'svm_find_mem_reg_node' [-Wmissing-prototypes]
     248 | struct device_node *svm_find_mem_reg_node(struct device *dev, const char *compat)
         |                     ^~~~~~~~~~~~~~~~~~~~~
   drivers/char/svm.c:449:6: warning: no previous prototype for 'sysrq_sched_debug_show_export' [-Wmissing-prototypes]
     449 | void sysrq_sched_debug_show_export(void)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/char/svm.c:1476:5: warning: no previous prototype for 'svm_get_pasid' [-Wmissing-prototypes]
    1476 | int svm_get_pasid(pid_t vpid, int dev_id __maybe_unused)
         |     ^~~~~~~~~~~~~
   drivers/char/svm.c:2269:36: warning: 'svm_acpi_match' defined but not used [-Wunused-const-variable=]
    2269 | static const struct acpi_device_id svm_acpi_match[] = {
         |                                    ^~~~~~~~~~~~~~
   In file included from arch/arm64/include/asm/atomic.h:34,
                    from include/linux/atomic.h:7,
                    from include/asm-generic/bitops/atomic.h:5,
                    from arch/arm64/include/asm/bitops.h:37,
                    from include/linux/bitops.h:19,
                    from include/linux/kernel.h:11,
                    from include/asm-generic/bug.h:18,
                    from arch/arm64/include/asm/bug.h:37,
                    from arch/arm64/include/asm/memory.h:27,
                    from arch/arm64/include/asm/esr.h:21,
                    from drivers/char/svm.c:10:
   drivers/char/svm.c: In function 'svm_proc_load_flag':
   arch/arm64/include/asm/atomic_lse.h:492:9: warning: array subscript 'long unsigned int[0]' is partly outside array bounds of 'atomic_t[1]' [-Warray-bounds]
     492 |         asm volatile(                                                   37-      |         ^~~
   arch/arm64/include/asm/atomic_lse.h:523:1: note: in expansion of macro '__CMPXCHG_CASE'
     523 | __CMPXCHG_CASE(w,  ,  mb_4, al, "memory")
         | ^~~~~~~~~~~~~~
   drivers/char/svm.c:1796:25: note: while referencing 'l2buf_load_flag'
    1796 |         static atomic_t l2buf_load_flag = ATOMIC_INIT(0);
         |                         ^~~~~~~~~~~~~~~
   In file included from arch/arm64/include/asm/atomic.h:34,
                    from include/linux/atomic.h:7,
                    from include/asm-generic/bitops/atomic.h:5,
                    from arch/arm64/include/asm/bitops.h:37,
                    from include/linux/bitops.h:19,
                    from include/linux/kernel.h:11,
                    from include/asm-generic/bug.h:18,
                    from arch/arm64/include/asm/bug.h:37,
                    from arch/arm64/include/asm/memory.h:27,
                    from arch/arm64/include/asm/esr.h:21,
                    from drivers/char/svm.c:10:
   arch/arm64/include/asm/atomic_lse.h:492:9: warning: array subscript 'long unsigned int[0]' is partly outside array bounds of 'atomic_t[1]' [-Warray-bounds]
     492 |         asm volatile(                                                   57-      |         ^~~
   arch/arm64/include/asm/atomic_lse.h:523:1: note: in expansion of macro '__CMPXCHG_CASE'
     523 | __CMPXCHG_CASE(w,  ,  mb_4, al, "memory")
         | ^~~~~~~~~~~~~~
   drivers/char/svm.c:1796:25: note: while referencing 'l2buf_load_flag'
    1796 |         static atomic_t l2buf_load_flag = ATOMIC_INIT(0);
         |                         ^~~~~~~~~~~~~~~

vim +366 drivers/char/svm.c

   247	
 > 248	struct device_node *svm_find_mem_reg_node(struct device *dev, const char *compat)
   249	{
   250		int index = 0;
   251		struct device_node *tmp = NULL;
   252		struct device_node *np = dev->of_node;
   253	
   254		for (; ; index++) {
   255			tmp = of_parse_phandle(np, "memory-region", index);
   256			if (!tmp)
   257				break;
   258	
   259			if (of_device_is_compatible(tmp, compat))
   260				return tmp;
   261	
   262			of_node_put(tmp);
   263		}
   264	
   265		return NULL;
   266	}
   267	
   268	static int svm_parse_trunk_memory(struct device *dev)
   269	{
   270		int err, count;
   271		struct resource r;
   272		struct device_node *trunk = NULL;
   273	
   274		trunk = svm_find_mem_reg_node(dev, SVM_MEM_REG);
   275		if (!trunk) {
   276			dev_err(dev, "Didn't find reserved memory\n");
   277			return -EINVAL;
   278		}
   279	
   280		for (count = 0; count < SVM_VA2PA_TRUNK_COUNT_MAX; count++) {
   281			err = of_address_to_resource(trunk, count, &r);
   282			if (err)
   283				break;
   284	
   285			va2pa_trunk[count].base = r.start;
   286			va2pa_trunk[count].size = resource_size(&r);
   287		}
   288	
   289		if (!count) {
   290			dev_err(dev, "Couldn't address to resource for reserved memory\n");
   291			return -ENODEV;
   292		}
   293	
   294		return 0;
   295	}
   296	
   297	static int __svm_setup_trunk(struct device *dev, struct svm_va2pa_trunk *trunk)
   298	{
   299		int slot_total;
   300		unsigned long *bitmap = NULL;
   301		struct svm_va2pa_slot *slot = NULL;
   302		phys_addr_t base = trunk->base;
   303		unsigned long size = trunk->size;
   304	
   305		if (!IS_ALIGNED(base, SVM_VA2PA_MEMORY_ALIGN)) {
   306			dev_err(dev, "Didn't aligned to %u\n", SVM_VA2PA_MEMORY_ALIGN);
   307			return -EINVAL;
   308		}
   309	
   310		if ((size == 0) || (size > SVM_VA2PA_TRUNK_SIZE_MAX)) {
   311			dev_err(dev, "Size of reserved memory is not right\n");
   312			return -EINVAL;
   313		}
   314	
   315		slot_total = size / SVM_VA2PA_SLOT_SIZE;
   316		if (slot_total < BITS_PER_LONG)
   317			return -EINVAL;
   318	
   319		bitmap = kvcalloc(slot_total / BITS_PER_LONG, sizeof(unsigned long), GFP_KERNEL);
   320		if (!bitmap) {
   321			dev_err(dev, "alloc memory failed\n");
   322			return -ENOMEM;
   323		}
   324	
   325		slot = ioremap(base, size);
   326		if (!slot) {
   327			kvfree(bitmap);
   328			dev_err(dev, "Ioremap trunk failed\n");
   329			return -ENXIO;
   330		}
   331	
   332		trunk->slots = slot;
   333		trunk->slot_used = 0;
   334		trunk->slot_total = slot_total;
   335		trunk->bitmap = bitmap;
   336		mutex_init(&trunk->mutex);
   337	
   338		return 0;
   339	}
   340	
   341	static int svm_setup_trunk(struct device *dev)
   342	{
   343		int err = 0;
   344		int count;
   345	
   346		for (count = 0; count < SVM_VA2PA_TRUNK_COUNT_MAX; count++) {
   347			if (!va2pa_trunk[count].base)
   348				break;
   349	
   350			err = __svm_setup_trunk(dev, &va2pa_trunk[count]);
   351			if (err)
   352				break;
   353		}
   354	
   355		return err;
   356	}
   357	
   358	static void svm_remove_trunk(struct device *dev)
   359	{
   360		int count;
   361	
   362		for (count = 0; count < SVM_VA2PA_TRUNK_COUNT_MAX; count++) {
   363			if (!va2pa_trunk[count].base)
   364				break;
   365	
 > 366			iounmap(va2pa_trunk[count].slots);
   367			kvfree(va2pa_trunk[count].bitmap);
   368			va2pa_trunk[count].slots = NULL;
   369			va2pa_trunk[count].bitmap = NULL;
   370		}
   371	}
   372	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-11-05 23:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-05 23:49 [openeuler:openEuler-1.0-LTS 1932/1932] drivers/char/svm.c:366:43: sparse: sparse: incorrect type in argument 1 (different address spaces) kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.