mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* drivers/iommu/riscv/iommu.c:164:29: sparse: sparse: incorrect type in assignment (different address spaces)
@ 2026-12-06 11:28 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2026-12-06 11:28 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: oe-kbuild-all, linux-kernel, Joerg Roedel, Tomasz Jeznach

Hi Jason,

First bad commit (maybe != root cause):

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   5dff0c81e94cd72d52bdfbb6044462c1be10f8d0
commit: 7cd0c655f02f08a5de851059ac8360e5d10fae62 iommu/riscv: Allow RISC_VIOMMU to COMPILE_TEST
date:   9 months ago
config: powerpc64-randconfig-r2308-20261203 (https://download.01.org/0day-ci/archive/20261204/20261204213420.lxpla6QX-lkp@intel.com/config)
compiler: powerpc64-linux-gcc (GCC) 11.5.0
sparse: v0.6.5-rc1-94-g0d159c10
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261204/20261204213420.lxpla6QX-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
| Fixes: 7cd0c655f02f ("iommu/riscv: Allow RISC_VIOMMU to COMPILE_TEST")
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/20261204213420.lxpla6QX-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
>> drivers/iommu/riscv/iommu.c:164:29: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected void *base @@     got void [noderef] __iomem * @@
   drivers/iommu/riscv/iommu.c:164:29: sparse:     expected void *base
   drivers/iommu/riscv/iommu.c:164:29: sparse:     got void [noderef] __iomem *
>> drivers/iommu/riscv/iommu.c:700:41: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected unsigned long long [usertype] *ddt_root @@     got void [noderef] __iomem * @@
   drivers/iommu/riscv/iommu.c:700:41: sparse:     expected unsigned long long [usertype] *ddt_root
   drivers/iommu/riscv/iommu.c:700:41: sparse:     got void [noderef] __iomem *
   drivers/iommu/riscv/iommu.c:859:16: sparse: sparse: Initializer entry defined twice
   drivers/iommu/riscv/iommu.c:859:16: sparse:   also defined here
   drivers/iommu/riscv/iommu.c:1184:18: sparse: sparse: Initializer entry defined twice
   drivers/iommu/riscv/iommu.c:1184:18: sparse:   also defined here
   drivers/iommu/riscv/iommu.c:1293:16: sparse: sparse: Initializer entry defined twice
   drivers/iommu/riscv/iommu.c:1293:16: sparse:   also defined here

vim +164 drivers/iommu/riscv/iommu.c

856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  123  
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  124  /*
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  125   * Discover queue ring buffer hardware configuration, allocate in-memory
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  126   * ring buffer or use fixed I/O memory location, configure queue base register.
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  127   * Must be called before hardware queue is enabled.
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  128   *
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  129   * @queue - data structure, configured with RISCV_IOMMU_QUEUE_INIT()
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  130   * @entry_size - queue single element size in bytes.
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  131   */
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  132  static int riscv_iommu_queue_alloc(struct riscv_iommu_device *iommu,
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  133  				   struct riscv_iommu_queue *queue,
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  134  				   size_t entry_size)
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  135  {
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  136  	unsigned int logsz;
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  137  	u64 qb, rb;
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  138  
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  139  	/*
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  140  	 * Use WARL base register property to discover maximum allowed
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  141  	 * number of entries and optional fixed IO address for queue location.
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  142  	 */
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  143  	riscv_iommu_writeq(iommu, queue->qbr, RISCV_IOMMU_QUEUE_LOG2SZ_FIELD);
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  144  	qb = riscv_iommu_readq(iommu, queue->qbr);
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  145  
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  146  	/*
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  147  	 * Calculate and verify hardware supported queue length, as reported
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  148  	 * by the field LOG2SZ, where max queue length is equal to 2^(LOG2SZ + 1).
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  149  	 * Update queue size based on hardware supported value.
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  150  	 */
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  151  	logsz = ilog2(queue->mask);
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  152  	if (logsz > FIELD_GET(RISCV_IOMMU_QUEUE_LOG2SZ_FIELD, qb))
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  153  		logsz = FIELD_GET(RISCV_IOMMU_QUEUE_LOG2SZ_FIELD, qb);
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  154  
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  155  	/*
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  156  	 * Use WARL base register property to discover an optional fixed IO
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  157  	 * address for queue ring buffer location. Otherwise allocate contiguous
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  158  	 * system memory.
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  159  	 */
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  160  	if (FIELD_GET(RISCV_IOMMU_PPN_FIELD, qb)) {
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  161  		const size_t queue_size = entry_size << (logsz + 1);
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  162  
7cd0c655f02f08a Jason Gunthorpe 2026-02-27  163  		queue->phys = PFN_PHYS(FIELD_GET(RISCV_IOMMU_PPN_FIELD, qb));
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15 @164  		queue->base = devm_ioremap(iommu->dev, queue->phys, queue_size);
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  165  	} else {
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  166  		do {
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  167  			const size_t queue_size = entry_size << (logsz + 1);
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  168  
9dda3f01ddf056e Jason Gunthorpe 2025-04-08  169  			queue->base = riscv_iommu_get_pages(
9dda3f01ddf056e Jason Gunthorpe 2025-04-08  170  				iommu, max(queue_size, SZ_4K));
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  171  			queue->phys = __pa(queue->base);
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  172  		} while (!queue->base && logsz-- > 0);
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  173  	}
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  174  
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  175  	if (!queue->base)
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  176  		return -ENOMEM;
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  177  
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  178  	qb = phys_to_ppn(queue->phys) |
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  179  	     FIELD_PREP(RISCV_IOMMU_QUEUE_LOG2SZ_FIELD, logsz);
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  180  
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  181  	/* Update base register and read back to verify hw accepted our write */
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  182  	riscv_iommu_writeq(iommu, queue->qbr, qb);
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  183  	rb = riscv_iommu_readq(iommu, queue->qbr);
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  184  	if (rb != qb) {
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  185  		dev_err(iommu->dev, "queue #%u allocation failed\n", queue->qid);
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  186  		return -ENODEV;
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  187  	}
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  188  
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  189  	/* Update actual queue mask */
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  190  	queue->mask = (2U << logsz) - 1;
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  191  
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  192  	dev_dbg(iommu->dev, "queue #%u allocated 2^%u entries",
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  193  		queue->qid, logsz + 1);
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  194  
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  195  	return 0;
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  196  }
856c0cfe5c5f6a2 Tomasz Jeznach  2024-10-15  197  

:::::: The code at line 164 was first introduced by commit
:::::: 856c0cfe5c5f6a2cc8d995872eb67bff9c68c57c iommu/riscv: Command and fault queue support

:::::: TO: Tomasz Jeznach <tjeznach@rivosinc.com>
:::::: CC: Joerg Roedel <jroedel@suse.de>

-- 
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:[~2026-12-06 11:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-06 11:28 drivers/iommu/riscv/iommu.c:164:29: sparse: sparse: incorrect type in assignment (different address spaces) kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®