Skip to contentSkip to conversation

iommu/riscv: Fixup compile warning

PATCH Applied [email protected] 7 participants 8 messages Jan 3, 2025 – Feb 3, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu/riscv: Fixup compile warning

From: Guo Ren <[email protected]>

When __BITS_PER_LONG == 32, size_t is defined as unsigned int rather than unsigned long. Therefore, we should use size_t to avoid type-checking errors.

Fixes 488ffbf18171 ("iommu/riscv: Paging domain support")
Cc Tomasz Jeznach <[email protected]>
---
 drivers/iommu/riscv/iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/riscv/iommu.c +1 -1
index 8a05def774bd..38d381164385 100644
@@ -1270,7 +1270,7 @@ static phys_addr_t riscv_iommu_iova_to_phys(struct iommu_domain *iommu_domain,
 					    dma_addr_t iova)
 {
 	struct riscv_iommu_domain *domain = iommu_domain_to_riscv(iommu_domain);
-	unsigned long pte_size;
+	size_t pte_size;
 	unsigned long *ptr;
 
 	ptr = riscv_iommu_pte_fetch(domain, iova, &pte_size);
Signature · 1 line
2.40.1
#1 lore raw

Hi Guo,

Quoted 3 lines · On 03/01/2025 03:46, [email protected] wrote:

From: Guo Ren <[email protected]>

When __BITS_PER_LONG == 32, size_t is defined as unsigned int rather

RISCV_IOMMU depends on 64BIT so how do you get __BITS_PER_LONG == 32?

Thanks,

Alex

Quoted 24 lines

than unsigned long. Therefore, we should use size_t to avoid type-checking errors.

Fixes 488ffbf18171 ("iommu/riscv: Paging domain support")
Cc Tomasz Jeznach <[email protected]>
---
  drivers/iommu/riscv/iommu.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/riscv/iommu.c +1 -1
index 8a05def774bd..38d381164385 100644
@@ -1270,7 +1270,7 @@ static phys_addr_t riscv_iommu_iova_to_phys(struct iommu_domain *iommu_domain,
  					    dma_addr_t iova)
  {
  	struct riscv_iommu_domain *domain = iommu_domain_to_riscv(iommu_domain);
-	unsigned long pte_size;
+	size_t pte_size;
  	unsigned long *ptr;
 
  	ptr = riscv_iommu_pte_fetch(domain, iova, &pte_size);
#2 lore raw

Hi Alex,

Quoted 7 lines · Alexandre Ghiti
Quoted 3 lines · On 03/01/2025 03:46, [email protected] wrote:

From: Guo Ren <[email protected]>

When __BITS_PER_LONG == 32, size_t is defined as unsigned int rather

RISCV_IOMMU depends on 64BIT so how do you get __BITS_PER_LONG == 32?

I am guessing this is from some downstream effort to compile a 64-bit kernel with an ILP32 ABI. However unsupported that may be, size_t is the nominal type used in both riscv_iommu_pte_fetch() and above in iommu_iotlb_gather_add_page(), so the change does make sense.

Regards,
Samuel

Quoted 24 lines
Quoted 24 lines

than unsigned long. Therefore, we should use size_t to avoid type-checking errors.

Fixes 488ffbf18171 ("iommu/riscv: Paging domain support")
Cc Tomasz Jeznach <[email protected]>

---
  drivers/iommu/riscv/iommu.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/riscv/iommu.c +1 -1
index 8a05def774bd..38d381164385 100644
@@ -1270,7 +1270,7 @@ static phys_addr_t riscv_iommu_iova_to_phys(struct
 iommu_domain *iommu_domain,
                           dma_addr_t iova)
   {
       struct riscv_iommu_domain *domain = iommu_domain_to_riscv(iommu_domain);
-    unsigned long pte_size;
+    size_t pte_size;
       unsigned long *ptr;
         ptr = riscv_iommu_pte_fetch(domain, iova, &pte_size);
author
#3 lore raw

Hi Samuel & Alexandre,

Quoted 10 lines · Samuel Holland

Hi Alex,

Quoted 6 lines · Alexandre Ghiti
Quoted 3 lines · On 03/01/2025 03:46, [email protected] wrote:

From: Guo Ren <[email protected]>

When __BITS_PER_LONG == 32, size_t is defined as unsigned int rather

Quoted 6 lines
Quoted 1 line

RISCV_IOMMU depends on 64BIT so how do you get __BITS_PER_LONG == 32?

I am guessing this is from some downstream effort to compile a 64-bit kernel with an ILP32 ABI. However unsupported that may be, size_t is the nominal type used in both riscv_iommu_pte_fetch() and above in iommu_iotlb_gather_add_page(), so the change does make sense.

Yes, I'm working on ILP32 ABI on CONFIG_64BIT=y. So, I got the warning when __BITS_PER_LONG == 32.

In riscv_iommu_unmap_pages(), we've written "size_t pte_size;." So, we should do that in "riscv_iommu_iova_to_phys()".

Quoted 29 lines

Regards,
Samuel

Quoted 24 lines
Quoted 24 lines

than unsigned long. Therefore, we should use size_t to avoid type-checking errors.

Fixes 488ffbf18171 ("iommu/riscv: Paging domain support")
Cc Tomasz Jeznach <[email protected]>
---
  drivers/iommu/riscv/iommu.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/riscv/iommu.c +1 -1
index 8a05def774bd..38d381164385 100644
@@ -1270,7 +1270,7 @@ static phys_addr_t riscv_iommu_iova_to_phys(struct
 iommu_domain *iommu_domain,
                          dma_addr_t iova)
  {
      struct riscv_iommu_domain *domain = iommu_domain_to_riscv(iommu_domain);
-    unsigned long pte_size;
+    size_t pte_size;
      unsigned long *ptr;
        ptr = riscv_iommu_pte_fetch(domain, iova, &pte_size);
Signature · 2 lines
Best Regards
 Guo Ren
Reviewed-by on v1 1/1
#5 lore raw
In reply to [email protected]
Quoted 19 lines · On Thu, Jan 02, 2025 at 09:46:16PM -0500, [email protected] wrote:

From: Guo Ren <[email protected]>

When __BITS_PER_LONG == 32, size_t is defined as unsigned int rather than unsigned long. Therefore, we should use size_t to avoid type-checking errors.

Fixes 488ffbf18171 ("iommu/riscv: Paging domain support")
Cc Tomasz Jeznach <[email protected]>
---
 drivers/iommu/riscv/iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/riscv/iommu.c +0 -0
index 8a05def774bd..38d381164385 100644

drivers/iommu/riscv/iommu.c static phys_addr_t riscv_iommu_iova_to_phys(struct iommu_domain *iommu_domain, · line 1273

Quoted 5 lines
drivers/iommu/riscv/iommu.c +1 -1
@@ -1270,7 +1270,7 @@ static phys_addr_t riscv_iommu_iova_to_phys(struct iommu_domain *iommu_domain,
 					    dma_addr_t iova)
 {
 	struct riscv_iommu_domain *domain = iommu_domain_to_riscv(iommu_domain);
-	unsigned long pte_size;
+	size_t pte_size;

riscv_iommu_pte_fetch() expects size_t so even though ILP32 isn't currently supported in the kernel, this change makes sense.

Quoted 11 lines
drivers/iommu/riscv/iommu.c +0 -0
 	unsigned long *ptr;
 
 	ptr = riscv_iommu_pte_fetch(domain, iova, &pte_size);
Signature · 7 lines
2.40.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Reviewed-by
#4 lore raw
In reply to Guo Ren
Quoted 20 lines · Guo Ren

Hi Samuel & Alexandre,

Quoted 10 lines · Samuel Holland

Hi Alex,

Quoted 6 lines · Alexandre Ghiti
Quoted 3 lines · On 03/01/2025 03:46, [email protected] wrote:

From: Guo Ren <[email protected]>

When __BITS_PER_LONG == 32, size_t is defined as unsigned int rather

Quoted 6 lines
Quoted 1 line

RISCV_IOMMU depends on 64BIT so how do you get __BITS_PER_LONG == 32?

I am guessing this is from some downstream effort to compile a 64-bit kernel with an ILP32 ABI. However unsupported that may be, size_t is the nominal type used in both riscv_iommu_pte_fetch() and above in iommu_iotlb_gather_add_page(), so the change does make sense.

Quoted 6 lines

Yes, I'm working on ILP32 ABI on CONFIG_64BIT=y. So, I got the warning when __BITS_PER_LONG == 32.

In riscv_iommu_unmap_pages(), we've written "size_t pte_size;." So, we should do that in "riscv_iommu_iova_to_phys()".

Thanks for pointing this out.
Do we have to change other relevant uses of unsigned long to either phys_addr_t or dma_addr_t to avoid type mismatch and get ILP32 working correctly?

Anyway, for quick warning fix:

Quoted 34 lines
Quoted 15 lines

Regards,
Samuel

Quoted 11 lines
Quoted 11 lines

than unsigned long. Therefore, we should use size_t to avoid type-checking errors.

Fixes 488ffbf18171 ("iommu/riscv: Paging domain support")
Cc Tomasz Jeznach <[email protected]>
---
  drivers/iommu/riscv/iommu.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
drivers/iommu/riscv/iommu.c +0 -0
index 8a05def774bd..38d381164385 100644
@@ -1270,7 +1270,7 @@ static phys_addr_t riscv_iommu_iova_to_phys(struct
Quoted 8 lines

drivers/iommu/riscv/iommu.c static phys_addr_t riscv_iommu_iova_to_phys(struct iommu_domain *iommu_domain, · line 1276

Quoted 8 lines
drivers/iommu/riscv/iommu.c +1 -1
 iommu_domain *iommu_domain,
                          dma_addr_t iova)
  {
      struct riscv_iommu_domain *domain = iommu_domain_to_riscv(iommu_domain);
-    unsigned long pte_size;
+    size_t pte_size;
      unsigned long *ptr;
        ptr = riscv_iommu_pte_fetch(domain, iova, &pte_size);

--
Best Regards
Guo Ren

maintainer Applied
#6 lore raw
In reply to [email protected]
Quoted 6 lines · On Thu, Jan 02, 2025 at 09:46:16PM -0500, [email protected] wrote:

From: Guo Ren <[email protected]>

When __BITS_PER_LONG == 32, size_t is defined as unsigned int rather than unsigned long. Therefore, we should use size_t to avoid type-checking errors.

Quoted 7 lines
Fixes 488ffbf18171 ("iommu/riscv: Paging domain support")
Cc Tomasz Jeznach <[email protected]>
---
 drivers/iommu/riscv/iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.

#7 lore raw
In reply to [email protected]
This patch was applied to riscv/linux.git (fixes) by Joerg Roedel <[email protected]>:

Hello:

This patch was applied to riscv/linux.git (fixes)
by Joerg Roedel <[email protected]>:

Quoted 6 lines · On Thu, 2 Jan 2025 21:46:16 -0500 you wrote:

From: Guo Ren <[email protected]>

When __BITS_PER_LONG == 32, size_t is defined as unsigned int rather than unsigned long. Therefore, we should use size_t to avoid type-checking errors.

Quoted 6 lines
Fixes 488ffbf18171 ("iommu/riscv: Paging domain support")
Cc Tomasz Jeznach <[email protected]>

[...]

Here is the summary with links:
- iommu/riscv: Fixup compile warning

    https://git.kernel.org/riscv/c/10c62c38b073

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html