diff mbox series

iommu/riscv: Fixup compile warning

Message ID 20250103024616.3359159-1-guoren@kernel.org (mailing list archive)
State New
Headers show
Series iommu/riscv: Fixup compile warning | expand

Checks

Context Check Description
conchuod/vmtest-for-next-PR success PR summary
conchuod/patch-1-test-1 success .github/scripts/patches/tests/build_rv32_defconfig.sh took 104.28s
conchuod/patch-1-test-2 success .github/scripts/patches/tests/build_rv64_clang_allmodconfig.sh took 1036.21s
conchuod/patch-1-test-3 success .github/scripts/patches/tests/build_rv64_gcc_allmodconfig.sh took 1223.26s
conchuod/patch-1-test-4 success .github/scripts/patches/tests/build_rv64_nommu_k210_defconfig.sh took 16.27s
conchuod/patch-1-test-5 success .github/scripts/patches/tests/build_rv64_nommu_virt_defconfig.sh took 17.74s
conchuod/patch-1-test-6 success .github/scripts/patches/tests/checkpatch.sh took 0.39s
conchuod/patch-1-test-7 success .github/scripts/patches/tests/dtb_warn_rv64.sh took 36.76s
conchuod/patch-1-test-8 success .github/scripts/patches/tests/header_inline.sh took 0.00s
conchuod/patch-1-test-9 success .github/scripts/patches/tests/kdoc.sh took 0.53s
conchuod/patch-1-test-10 success .github/scripts/patches/tests/module_param.sh took 0.01s
conchuod/patch-1-test-11 success .github/scripts/patches/tests/verify_fixes.sh took 0.02s
conchuod/patch-1-test-12 success .github/scripts/patches/tests/verify_signedoff.sh took 0.02s

Commit Message

Guo Ren Jan. 3, 2025, 2:46 a.m. UTC
From: Guo Ren <guoren@linux.alibaba.com>

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")
Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
Signed-off-by: Guo Ren <guoren@kernel.org>
Cc: Tomasz Jeznach <tjeznach@rivosinc.com>
---
 drivers/iommu/riscv/iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alexandre Ghiti Jan. 6, 2025, 10:31 a.m. UTC | #1
Hi Guo,

On 03/01/2025 03:46, guoren@kernel.org wrote:
> From: Guo Ren <guoren@linux.alibaba.com>
>
> 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


> than unsigned long. Therefore, we should use size_t to avoid
> type-checking errors.
>
> Fixes: 488ffbf18171 ("iommu/riscv: Paging domain support")
> Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
> Signed-off-by: Guo Ren <guoren@kernel.org>
> Cc: Tomasz Jeznach <tjeznach@rivosinc.com>
> ---
>   drivers/iommu/riscv/iommu.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/riscv/iommu.c b/drivers/iommu/riscv/iommu.c
> index 8a05def774bd..38d381164385 100644
> --- a/drivers/iommu/riscv/iommu.c
> +++ b/drivers/iommu/riscv/iommu.c
> @@ -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);
Samuel Holland Jan. 6, 2025, 5:47 p.m. UTC | #2
Hi Alex,

On 2025-01-06 4:31 AM, Alexandre Ghiti wrote:
> On 03/01/2025 03:46, guoren@kernel.org wrote:
>> From: Guo Ren <guoren@linux.alibaba.com>
>>
>> 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

>> than unsigned long. Therefore, we should use size_t to avoid
>> type-checking errors.
>>
>> Fixes: 488ffbf18171 ("iommu/riscv: Paging domain support")
>> Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
>> Signed-off-by: Guo Ren <guoren@kernel.org>
>> Cc: Tomasz Jeznach <tjeznach@rivosinc.com>
>> ---
>>   drivers/iommu/riscv/iommu.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/iommu/riscv/iommu.c b/drivers/iommu/riscv/iommu.c
>> index 8a05def774bd..38d381164385 100644
>> --- a/drivers/iommu/riscv/iommu.c
>> +++ b/drivers/iommu/riscv/iommu.c
>> @@ -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);
Guo Ren Jan. 8, 2025, 6:47 a.m. UTC | #3
Hi Samuel & Alexandre,

On Tue, Jan 7, 2025 at 1:47 AM Samuel Holland <samuel.holland@sifive.com> wrote:
>
> Hi Alex,
>
> On 2025-01-06 4:31 AM, Alexandre Ghiti wrote:
> > On 03/01/2025 03:46, guoren@kernel.org wrote:
> >> From: Guo Ren <guoren@linux.alibaba.com>
> >>
> >> 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.
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()".

>
> Regards,
> Samuel
>
> >> than unsigned long. Therefore, we should use size_t to avoid
> >> type-checking errors.
> >>
> >> Fixes: 488ffbf18171 ("iommu/riscv: Paging domain support")
> >> Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
> >> Signed-off-by: Guo Ren <guoren@kernel.org>
> >> Cc: Tomasz Jeznach <tjeznach@rivosinc.com>
> >> ---
> >>   drivers/iommu/riscv/iommu.c | 2 +-
> >>   1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/iommu/riscv/iommu.c b/drivers/iommu/riscv/iommu.c
> >> index 8a05def774bd..38d381164385 100644
> >> --- a/drivers/iommu/riscv/iommu.c
> >> +++ b/drivers/iommu/riscv/iommu.c
> >> @@ -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);
>
diff mbox series

Patch

diff --git a/drivers/iommu/riscv/iommu.c b/drivers/iommu/riscv/iommu.c
index 8a05def774bd..38d381164385 100644
--- a/drivers/iommu/riscv/iommu.c
+++ b/drivers/iommu/riscv/iommu.c
@@ -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);