Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
From: Sai Krishna <saikrishnag@marvell.com>
To: <davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>,
	<pabeni@redhat.com>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <sgoutham@marvell.com>,
	<gakula@marvell.com>, <lcherian@marvell.com>,
	<jerinj@marvell.com>, <hkelam@marvell.com>, <sbhatta@marvell.com>,
	<andrew+netdev@lunn.ch>, <bbhushan2@marvell.com>,
	<nathan@kernel.org>, <ndesaulniers@google.com>,
	<morbo@google.com>, <justinstitt@google.com>,
	<llvm@lists.linux.dev>, <horms@kernel.org>
Cc: Sai Krishna <saikrishnag@marvell.com>, kernel test robot <lkp@intel.com>
Subject: [net-next PATCH v3 1/2] octeontx2-af: correct __iomem annotations flagged by Sparse
Date: Tue, 11 Mar 2025 23:56:30 +0530	[thread overview]
Message-ID: <20250311182631.3224812-2-saikrishnag@marvell.com> (raw)
In-Reply-To: <20250311182631.3224812-1-saikrishnag@marvell.com>

Sparse flagged a number of inconsistent usage of __iomem annotations.
This patch fixes some of the issues reported by kernel test robot.
These warning messages are address this by proper __iomem
annotations.

Warning messages flagged by Sparse:

drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c:611:24: sparse:
sparse: incorrect type in assignment (different address spaces) @@
expected void [noderef] __iomem *hwbase @@     got void * @@
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c:611:24:
  sparse:     expected void [noderef] __iomem *hwbase
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c:611:24:
  sparse:     got void *
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c:620:56:
  sparse: sparse: cast removes address space '__iomem' of expression
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c:671:35:
  sparse: sparse: incorrect type in argument 1 (different address spaces)
  @@ expected void volatile [noderef] __iomem *addr @@ got void *hwbase @@
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c:671:35:
  sparse:     expected void volatile [noderef] __iomem *addr
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c:671:35:
  sparse:     got void *hwbase
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c:1344:21:
  sparse: sparse: incorrect type in assignment (different address spaces)
  @@ expected unsigned long long [usertype] *ptr @@
  got void [noderef] __iomem * @@
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c:1344:21:
  sparse:     expected unsigned long long [usertype] *ptr
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c:1344:21:
  sparse:     got void [noderef] __iomem *
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c:1383:21:
  sparse: sparse: incorrect type in assignment (different address spaces)
  @@ expected unsigned long long [usertype] *ptr @@
  got void [noderef] __iomem * @@
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c:1383:21:
  sparse:     expected unsigned long long [usertype] *ptr
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c:1383:21:
  sparse:     got void [noderef] __iomem *
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c: note:
  in included file
  (through drivers/net/ethernet/marvell/octeontx2/af/mbox.h,
  drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h):

Flagged by Sparse on x86_64:
 drivers/net/ethernet/marvell/octeontx2/af/common.h:61:26: sparse:
 sparse: cast truncates bits from constant value (10000 becomes 0)

To address this increased the size of entry_sz in qmem_alloc(),
otherwise the value will be truncated to 0.

Reported-by: kernel test robot <lkp@intel.com>
Closes:
https://lore.kernel.org/oe-kbuild-all/202410221614.07o9QVjo-lkp@intel.com/
Signed-off-by: Sai Krishna <saikrishnag@marvell.com>
---
 drivers/net/ethernet/marvell/octeontx2/af/common.h   | 2 +-
 drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 9 ++++-----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/common.h b/drivers/net/ethernet/marvell/octeontx2/af/common.h
index 406c59100a35..8a08bebf08c2 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/common.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/common.h
@@ -39,7 +39,7 @@ struct qmem {
 	void            *base;
 	dma_addr_t	iova;
 	int		alloc_sz;
-	u16		entry_sz;
+	u32		entry_sz;
 	u8		align;
 	u32		qsize;
 };
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
index e1dde93e8af8..6c23d64e81f8 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
@@ -595,8 +595,7 @@ static int otx2_pfvf_mbox_init(struct otx2_nic *pf, int numvfs)
 		base = pci_resource_start(pf->pdev, PCI_MBOX_BAR_NUM) +
 		       MBOX_SIZE;
 	else
-		base = readq((void __iomem *)((u64)pf->reg_base +
-					      RVU_PF_VF_BAR4_ADDR));
+		base = readq(pf->reg_base + RVU_PF_VF_BAR4_ADDR);
 
 	hwbase = ioremap_wc(base, MBOX_SIZE * pf->total_vfs);
 	if (!hwbase) {
@@ -645,7 +644,7 @@ static void otx2_pfvf_mbox_destroy(struct otx2_nic *pf)
 	}
 
 	if (mbox->mbox.hwbase)
-		iounmap(mbox->mbox.hwbase);
+		iounmap((void __iomem *)mbox->mbox.hwbase);
 
 	otx2_mbox_destroy(&mbox->mbox);
 }
@@ -1309,7 +1308,7 @@ static irqreturn_t otx2_q_intr_handler(int irq, void *data)
 
 	/* CQ */
 	for (qidx = 0; qidx < pf->qset.cq_cnt; qidx++) {
-		ptr = otx2_get_regaddr(pf, NIX_LF_CQ_OP_INT);
+		ptr = (__force u64 *)otx2_get_regaddr(pf, NIX_LF_CQ_OP_INT);
 		val = otx2_atomic64_add((qidx << 44), ptr);
 
 		otx2_write64(pf, NIX_LF_CQ_OP_INT, (qidx << 44) |
@@ -1348,7 +1347,7 @@ static irqreturn_t otx2_q_intr_handler(int irq, void *data)
 		 * these are fatal errors.
 		 */
 
-		ptr = otx2_get_regaddr(pf, NIX_LF_SQ_OP_INT);
+		ptr = (__force u64 *)otx2_get_regaddr(pf, NIX_LF_SQ_OP_INT);
 		val = otx2_atomic64_add((qidx << 44), ptr);
 		otx2_write64(pf, NIX_LF_SQ_OP_INT, (qidx << 44) |
 			     (val & NIX_SQINT_BITS));
-- 
2.25.1


  reply	other threads:[~2025-03-11 18:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-11 18:26 [net-next PATCH v3 0/2] octeontx2-af: fix build warnings flagged Sai Krishna
2025-03-11 18:26 ` Sai Krishna [this message]
2025-03-11 21:22   ` [net-next PATCH v3 1/2] octeontx2-af: correct __iomem annotations flagged by Sparse Andrew Lunn
2025-04-14 16:38     ` Sai Krishna Gajula
2025-04-14 17:17       ` Andrew Lunn
2025-03-11 18:26 ` [net-next PATCH v3 2/2] octeontx2-af: fix compiler warnings " Sai Krishna
2025-03-11 21:32   ` Andrew Lunn
2025-05-26  9:15     ` Subbaraya Sundeep

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250311182631.3224812-2-saikrishnag@marvell.com \
    --to=saikrishnag@marvell.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=bbhushan2@marvell.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gakula@marvell.com \
    --cc=hkelam@marvell.com \
    --cc=horms@kernel.org \
    --cc=jerinj@marvell.com \
    --cc=justinstitt@google.com \
    --cc=kuba@kernel.org \
    --cc=lcherian@marvell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=llvm@lists.linux.dev \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sbhatta@marvell.com \
    --cc=sgoutham@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox