linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommu/riscv: Fixup compile warning
@ 2025-01-03  2:46 guoren
  2025-01-06 10:31 ` Alexandre Ghiti
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: guoren @ 2025-01-03  2:46 UTC (permalink / raw)
  To: tjeznach
  Cc: joro, will, robin.murphy, paul.walmsley, palmer, baolu.lu,
	zong.li, iommu, linux-riscv, linux-kernel, Guo Ren, Guo Ren

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(-)

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);
-- 
2.40.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] iommu/riscv: Fixup compile warning
  2025-01-03  2:46 [PATCH] iommu/riscv: Fixup compile warning guoren
@ 2025-01-06 10:31 ` Alexandre Ghiti
  2025-01-06 17:47   ` Samuel Holland
  2025-01-10  2:44 ` Charlie Jenkins
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Alexandre Ghiti @ 2025-01-06 10:31 UTC (permalink / raw)
  To: guoren, tjeznach
  Cc: joro, will, robin.murphy, paul.walmsley, palmer, baolu.lu,
	zong.li, iommu, linux-riscv, linux-kernel, Guo Ren

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);

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] iommu/riscv: Fixup compile warning
  2025-01-06 10:31 ` Alexandre Ghiti
@ 2025-01-06 17:47   ` Samuel Holland
  2025-01-08  6:47     ` Guo Ren
  0 siblings, 1 reply; 8+ messages in thread
From: Samuel Holland @ 2025-01-06 17:47 UTC (permalink / raw)
  To: Alexandre Ghiti, guoren, tjeznach
  Cc: joro, will, robin.murphy, paul.walmsley, palmer, baolu.lu,
	zong.li, iommu, linux-riscv, linux-kernel, Guo Ren

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);


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] iommu/riscv: Fixup compile warning
  2025-01-06 17:47   ` Samuel Holland
@ 2025-01-08  6:47     ` Guo Ren
  2025-01-10 20:48       ` Tomasz Jeznach
  0 siblings, 1 reply; 8+ messages in thread
From: Guo Ren @ 2025-01-08  6:47 UTC (permalink / raw)
  To: Samuel Holland
  Cc: Alexandre Ghiti, tjeznach, joro, will, robin.murphy,
	paul.walmsley, palmer, baolu.lu, zong.li, iommu, linux-riscv,
	linux-kernel, Guo Ren

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);
>


-- 
Best Regards
 Guo Ren

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] iommu/riscv: Fixup compile warning
  2025-01-03  2:46 [PATCH] iommu/riscv: Fixup compile warning guoren
  2025-01-06 10:31 ` Alexandre Ghiti
@ 2025-01-10  2:44 ` Charlie Jenkins
  2025-01-17  7:58 ` Joerg Roedel
  2025-02-03 19:16 ` patchwork-bot+linux-riscv
  3 siblings, 0 replies; 8+ messages in thread
From: Charlie Jenkins @ 2025-01-10  2:44 UTC (permalink / raw)
  To: guoren
  Cc: tjeznach, joro, will, robin.murphy, paul.walmsley, palmer,
	baolu.lu, zong.li, iommu, linux-riscv, linux-kernel, Guo Ren

On Thu, Jan 02, 2025 at 09:46:16PM -0500, guoren@kernel.org wrote:
> 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(-)
> 
> 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;

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

Reviewed-by: Charlie Jenkins <charlie@rivosinc.com>

>  	unsigned long *ptr;
>  
>  	ptr = riscv_iommu_pte_fetch(domain, iova, &pte_size);
> -- 
> 2.40.1
> 
> 
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] iommu/riscv: Fixup compile warning
  2025-01-08  6:47     ` Guo Ren
@ 2025-01-10 20:48       ` Tomasz Jeznach
  0 siblings, 0 replies; 8+ messages in thread
From: Tomasz Jeznach @ 2025-01-10 20:48 UTC (permalink / raw)
  To: Guo Ren
  Cc: Samuel Holland, Alexandre Ghiti, joro, will, robin.murphy,
	paul.walmsley, palmer, baolu.lu, zong.li, iommu, linux-riscv,
	linux-kernel, Guo Ren

On Tue, Jan 7, 2025 at 10:48 PM Guo Ren <guoren@kernel.org> wrote:
>
> 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()".
>

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:
Reviewed-by: Tomasz Jeznach <tjeznach@rivosinc.com>

> >
> > 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);
> >
>
>
> --
> Best Regards
>  Guo Ren

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] iommu/riscv: Fixup compile warning
  2025-01-03  2:46 [PATCH] iommu/riscv: Fixup compile warning guoren
  2025-01-06 10:31 ` Alexandre Ghiti
  2025-01-10  2:44 ` Charlie Jenkins
@ 2025-01-17  7:58 ` Joerg Roedel
  2025-02-03 19:16 ` patchwork-bot+linux-riscv
  3 siblings, 0 replies; 8+ messages in thread
From: Joerg Roedel @ 2025-01-17  7:58 UTC (permalink / raw)
  To: guoren
  Cc: tjeznach, will, robin.murphy, paul.walmsley, palmer, baolu.lu,
	zong.li, iommu, linux-riscv, linux-kernel, Guo Ren

On Thu, Jan 02, 2025 at 09:46:16PM -0500, guoren@kernel.org wrote:
> 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(-)

Applied, thanks.

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] iommu/riscv: Fixup compile warning
  2025-01-03  2:46 [PATCH] iommu/riscv: Fixup compile warning guoren
                   ` (2 preceding siblings ...)
  2025-01-17  7:58 ` Joerg Roedel
@ 2025-02-03 19:16 ` patchwork-bot+linux-riscv
  3 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+linux-riscv @ 2025-02-03 19:16 UTC (permalink / raw)
  To: Guo Ren
  Cc: linux-riscv, tjeznach, joro, will, robin.murphy, paul.walmsley,
	palmer, baolu.lu, zong.li, iommu, linux-kernel, guoren

Hello:

This patch was applied to riscv/linux.git (fixes)
by Joerg Roedel <jroedel@suse.de>:

On Thu,  2 Jan 2025 21:46:16 -0500 you wrote:
> 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>
> 
> [...]

Here is the summary with links:
  - iommu/riscv: Fixup compile warning
    https://git.kernel.org/riscv/c/10c62c38b073

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

end of thread, other threads:[~2025-02-03 21:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-03  2:46 [PATCH] iommu/riscv: Fixup compile warning guoren
2025-01-06 10:31 ` Alexandre Ghiti
2025-01-06 17:47   ` Samuel Holland
2025-01-08  6:47     ` Guo Ren
2025-01-10 20:48       ` Tomasz Jeznach
2025-01-10  2:44 ` Charlie Jenkins
2025-01-17  7:58 ` Joerg Roedel
2025-02-03 19:16 ` patchwork-bot+linux-riscv

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).