iommu/riscv: Fixup compile warning
Subsystems (3)
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.
--- drivers/iommu/riscv/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
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;unsigned long *ptr; ptr =riscv_iommu_pte_fetch (domain, iova, &pte_size);
Signature · 1 line
2.40.1
Alexandre Ghiti
reviewerHi Guo,
Quoted 3 lines · On 03/01/2025 03:46, [email protected] wrote:
From: Guo Ren <[email protected]>
When
__BITS_PER_LONG== 32,size_tis 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_tto avoid type-checking errors.Fixes 488ffbf18171 ("iommu/riscv: Paging domain support")Signed-off-by Guo Ren <[email protected]>Signed-off-by Guo Ren <[email protected]>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@@ -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);
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_tis defined as unsigned int rather
RISCV_IOMMUdepends 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_tto avoid type-checking errors.Fixes 488ffbf18171 ("iommu/riscv: Paging domain support")Signed-off-by Guo Ren <[email protected]>Signed-off-by Guo Ren <[email protected]>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@@ -1270,7 +1270,7 @@ static phys_addr_t riscv_iommu_iova_to_phys(structiommu_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);
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_tis defined as unsigned int rather
Quoted 6 lines
Quoted 1 line
RISCV_IOMMUdepends 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_tis the nominal type used in bothriscv_iommu_pte_fetch()and above iniommu_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,
SamuelQuoted 24 lines
Quoted 24 lines
than unsigned long. Therefore, we should use
size_tto avoid type-checking errors.Fixes 488ffbf18171 ("iommu/riscv: Paging domain support")Signed-off-by Guo Ren <[email protected]>Signed-off-by Guo Ren <[email protected]>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@@ -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
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_tis defined as unsigned int rather than unsigned long. Therefore, we should usesize_tto avoid type-checking errors.Fixes 488ffbf18171 ("iommu/riscv: Paging domain support")Signed-off-by Guo Ren <[email protected]>Signed-off-by Guo Ren <[email protected]>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
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
-0unsigned 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
Tomasz Jeznach
Reviewed-byQuoted 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_tis defined as unsigned int ratherQuoted 6 lines
Quoted 1 line
RISCV_IOMMUdepends 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_tis the nominal type used in bothriscv_iommu_pte_fetch()and above iniommu_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_tpte_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,
SamuelQuoted 11 lines
Quoted 11 lines
than unsigned long. Therefore, we should use
size_tto avoid type-checking errors.Fixes 488ffbf18171 ("iommu/riscv: Paging domain support")Signed-off-by Guo Ren <[email protected]>Signed-off-by Guo Ren <[email protected]>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@@ -1270,7 +1270,7 @@ static phys_addr_t riscv_iommu_iova_to_phys(structQuoted 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
-1iommu_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
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_tis defined as unsigned int rather than unsigned long. Therefore, we should usesize_tto avoid type-checking errors.
Quoted 7 lines
Fixes 488ffbf18171 ("iommu/riscv: Paging domain support")Signed-off-by Guo Ren <[email protected]>Signed-off-by Guo Ren <[email protected]>Cc Tomasz Jeznach <[email protected]>--- drivers/iommu/riscv/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks.
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_tis defined as unsigned int rather than unsigned long. Therefore, we should usesize_tto avoid type-checking errors.
Quoted 6 lines
Fixes 488ffbf18171 ("iommu/riscv: Paging domain support")Signed-off-by Guo Ren <[email protected]>Signed-off-by Guo Ren <[email protected]>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