All of lore.kernel.org
 help / color / mirror / Atom feed
* [linux-next:master 5495/7860] drivers/accel/amdxdna/amdxdna_mailbox.c:334:52: sparse: sparse: cast removes address space '__iomem' of expression
@ 2025-01-13  1:21 kernel test robot
  2025-01-13 14:25 ` Mario Limonciello
  0 siblings, 1 reply; 3+ messages in thread
From: kernel test robot @ 2025-01-13  1:21 UTC (permalink / raw)
  To: Lizhi Hou; +Cc: oe-kbuild-all, Mario Limonciello

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   2b88851f583d3c4e40bcd40cfe1965241ec229dd
commit: 3c8cfec3fcc4fe53f2bd87ec91ef31df4fa6dc0d [5495/7860] accel/amdxdna: Declare mailbox register base as __iomem pointer
config: x86_64-randconfig-121-20250113 (https://download.01.org/0day-ci/archive/20250113/202501130921.ktqwsMLH-lkp@intel.com/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250113/202501130921.ktqwsMLH-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/202501130921.ktqwsMLH-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
>> drivers/accel/amdxdna/amdxdna_mailbox.c:334:52: sparse: sparse: cast removes address space '__iomem' of expression

vim +/__iomem +334 drivers/accel/amdxdna/amdxdna_mailbox.c

b87f920b934426 Lizhi Hou 2024-11-18  274  
b87f920b934426 Lizhi Hou 2024-11-18  275  static int mailbox_get_msg(struct mailbox_channel *mb_chann)
b87f920b934426 Lizhi Hou 2024-11-18  276  {
b87f920b934426 Lizhi Hou 2024-11-18  277  	struct xdna_msg_header header;
3c8cfec3fcc4fe Lizhi Hou 2025-01-02  278  	void __iomem *read_addr;
b87f920b934426 Lizhi Hou 2024-11-18  279  	u32 msg_size, rest;
b87f920b934426 Lizhi Hou 2024-11-18  280  	u32 ringbuf_size;
b87f920b934426 Lizhi Hou 2024-11-18  281  	u32 head, tail;
b87f920b934426 Lizhi Hou 2024-11-18  282  	u32 start_addr;
b87f920b934426 Lizhi Hou 2024-11-18  283  	int ret;
b87f920b934426 Lizhi Hou 2024-11-18  284  
b87f920b934426 Lizhi Hou 2024-11-18  285  	if (mailbox_reg_read_non_zero(mb_chann, mb_chann->res[CHAN_RES_I2X].mb_tail_ptr_reg, &tail))
b87f920b934426 Lizhi Hou 2024-11-18  286  		return -EINVAL;
b87f920b934426 Lizhi Hou 2024-11-18  287  	head = mb_chann->i2x_head;
b87f920b934426 Lizhi Hou 2024-11-18  288  	ringbuf_size = mailbox_get_ringbuf_size(mb_chann, CHAN_RES_I2X);
b87f920b934426 Lizhi Hou 2024-11-18  289  	start_addr = mb_chann->res[CHAN_RES_I2X].rb_start_addr;
b87f920b934426 Lizhi Hou 2024-11-18  290  
b87f920b934426 Lizhi Hou 2024-11-18  291  	if (unlikely(tail > ringbuf_size || !IS_ALIGNED(tail, 4))) {
b87f920b934426 Lizhi Hou 2024-11-18  292  		MB_WARN_ONCE(mb_chann, "Invalid tail 0x%x", tail);
b87f920b934426 Lizhi Hou 2024-11-18  293  		return -EINVAL;
b87f920b934426 Lizhi Hou 2024-11-18  294  	}
b87f920b934426 Lizhi Hou 2024-11-18  295  
b87f920b934426 Lizhi Hou 2024-11-18  296  	/* ringbuf empty */
b87f920b934426 Lizhi Hou 2024-11-18  297  	if (head == tail)
b87f920b934426 Lizhi Hou 2024-11-18  298  		return -ENOENT;
b87f920b934426 Lizhi Hou 2024-11-18  299  
b87f920b934426 Lizhi Hou 2024-11-18  300  	if (head == ringbuf_size)
b87f920b934426 Lizhi Hou 2024-11-18  301  		head = 0;
b87f920b934426 Lizhi Hou 2024-11-18  302  
b87f920b934426 Lizhi Hou 2024-11-18  303  	/* Peek size of the message or TOMBSTONE */
b87f920b934426 Lizhi Hou 2024-11-18  304  	read_addr = mb_chann->mb->res.ringbuf_base + start_addr + head;
3c8cfec3fcc4fe Lizhi Hou 2025-01-02  305  	header.total_size = readl(read_addr);
b87f920b934426 Lizhi Hou 2024-11-18  306  	/* size is TOMBSTONE, set next read from 0 */
b87f920b934426 Lizhi Hou 2024-11-18  307  	if (header.total_size == TOMBSTONE) {
b87f920b934426 Lizhi Hou 2024-11-18  308  		if (head < tail) {
b87f920b934426 Lizhi Hou 2024-11-18  309  			MB_WARN_ONCE(mb_chann, "Tombstone, head 0x%x tail 0x%x",
b87f920b934426 Lizhi Hou 2024-11-18  310  				     head, tail);
b87f920b934426 Lizhi Hou 2024-11-18  311  			return -EINVAL;
b87f920b934426 Lizhi Hou 2024-11-18  312  		}
b87f920b934426 Lizhi Hou 2024-11-18  313  		mailbox_set_headptr(mb_chann, 0);
b87f920b934426 Lizhi Hou 2024-11-18  314  		return 0;
b87f920b934426 Lizhi Hou 2024-11-18  315  	}
b87f920b934426 Lizhi Hou 2024-11-18  316  
b87f920b934426 Lizhi Hou 2024-11-18  317  	if (unlikely(!header.total_size || !IS_ALIGNED(header.total_size, 4))) {
b87f920b934426 Lizhi Hou 2024-11-18  318  		MB_WARN_ONCE(mb_chann, "Invalid total size 0x%x", header.total_size);
b87f920b934426 Lizhi Hou 2024-11-18  319  		return -EINVAL;
b87f920b934426 Lizhi Hou 2024-11-18  320  	}
b87f920b934426 Lizhi Hou 2024-11-18  321  	msg_size = sizeof(header) + header.total_size;
b87f920b934426 Lizhi Hou 2024-11-18  322  
b87f920b934426 Lizhi Hou 2024-11-18  323  	if (msg_size > ringbuf_size - head || msg_size > tail - head) {
b87f920b934426 Lizhi Hou 2024-11-18  324  		MB_WARN_ONCE(mb_chann, "Invalid message size %d, tail %d, head %d",
b87f920b934426 Lizhi Hou 2024-11-18  325  			     msg_size, tail, head);
b87f920b934426 Lizhi Hou 2024-11-18  326  		return -EINVAL;
b87f920b934426 Lizhi Hou 2024-11-18  327  	}
b87f920b934426 Lizhi Hou 2024-11-18  328  
b87f920b934426 Lizhi Hou 2024-11-18  329  	rest = sizeof(header) - sizeof(u32);
b87f920b934426 Lizhi Hou 2024-11-18  330  	read_addr += sizeof(u32);
3c8cfec3fcc4fe Lizhi Hou 2025-01-02  331  	memcpy_fromio((u32 *)&header + 1, read_addr, rest);
b87f920b934426 Lizhi Hou 2024-11-18  332  	read_addr += rest;
b87f920b934426 Lizhi Hou 2024-11-18  333  
b87f920b934426 Lizhi Hou 2024-11-18 @334  	ret = mailbox_get_resp(mb_chann, &header, (u32 *)read_addr);
b87f920b934426 Lizhi Hou 2024-11-18  335  
b87f920b934426 Lizhi Hou 2024-11-18  336  	mailbox_set_headptr(mb_chann, head + msg_size);
b87f920b934426 Lizhi Hou 2024-11-18  337  	/* After update head, it can equal to ringbuf_size. This is expected. */
b87f920b934426 Lizhi Hou 2024-11-18  338  	trace_mbox_set_head(MAILBOX_NAME, mb_chann->msix_irq,
b87f920b934426 Lizhi Hou 2024-11-18  339  			    header.opcode, header.id);
b87f920b934426 Lizhi Hou 2024-11-18  340  
b87f920b934426 Lizhi Hou 2024-11-18  341  	return ret;
b87f920b934426 Lizhi Hou 2024-11-18  342  }
b87f920b934426 Lizhi Hou 2024-11-18  343  

:::::: The code at line 334 was first introduced by commit
:::::: b87f920b934426a24d54613f12ed67c03ae05024 accel/amdxdna: Support hardware mailbox

:::::: TO: Lizhi Hou <lizhi.hou@amd.com>
:::::: CC: Jeffrey Hugo <quic_jhugo@quicinc.com>

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-01-13 16:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-13  1:21 [linux-next:master 5495/7860] drivers/accel/amdxdna/amdxdna_mailbox.c:334:52: sparse: sparse: cast removes address space '__iomem' of expression kernel test robot
2025-01-13 14:25 ` Mario Limonciello
2025-01-13 16:35   ` Lizhi Hou

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.