diff mbox series

[V3,09/10] staging: vchiq_arm: Don't cast scatter-gather elements

Message ID 20240621131958.98208-10-wahrenst@gmx.net (mailing list archive)
State New, archived
Headers show
Series staging: vc04_services: Random cleanups | expand

Commit Message

Stefan Wahren June 21, 2024, 1:19 p.m. UTC
The kernel uses different types for DMA length & address,
so better use them.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 .../staging/vc04_services/interface/vchiq_arm/vchiq_arm.c   | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--
2.34.1

Comments

Dan Carpenter June 21, 2024, 2:31 p.m. UTC | #1
On Fri, Jun 21, 2024 at 03:19:57PM +0200, Stefan Wahren wrote:
> The kernel uses different types for DMA length & address,
> so better use them.
> 
> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  .../staging/vc04_services/interface/vchiq_arm/vchiq_arm.c   | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> index e3d49d4bdb1d..9e6102c43e00 100644
> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> @@ -162,7 +162,7 @@ cleanup_pagelistinfo(struct vchiq_instance *instance, struct vchiq_pagelist_info
>  }
> 
>  static inline bool
> -is_adjacent_block(u32 *addrs, u32 addr, unsigned int k)
> +is_adjacent_block(u32 *addrs, dma_addr_t addr, unsigned int k)
>  {
>  	u32 tmp;
> 

You can't actually use more than 32bits because *addrs is u32 and it's
part of the UAPI.

regards,
dan carpenter
Stefan Wahren June 22, 2024, 1:34 p.m. UTC | #2
Hi Dan,

Am 21.06.24 um 16:31 schrieb Dan Carpenter:
> On Fri, Jun 21, 2024 at 03:19:57PM +0200, Stefan Wahren wrote:
>> The kernel uses different types for DMA length & address,
>> so better use them.
>>
>> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>> ---
>>   .../staging/vc04_services/interface/vchiq_arm/vchiq_arm.c   | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
>> index e3d49d4bdb1d..9e6102c43e00 100644
>> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
>> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
>> @@ -162,7 +162,7 @@ cleanup_pagelistinfo(struct vchiq_instance *instance, struct vchiq_pagelist_info
>>   }
>>
>>   static inline bool
>> -is_adjacent_block(u32 *addrs, u32 addr, unsigned int k)
>> +is_adjacent_block(u32 *addrs, dma_addr_t addr, unsigned int k)
>>   {
>>   	u32 tmp;
>>
> You can't actually use more than 32bits because *addrs is u32 and it's
> part of the UAPI.

i'm aware that we cannot use more than 32bits and AFAIK the VPU is not
able to handle that. The intention of this change was to use the special
Linux datatype as much as possible to signalize the special meaning and
allow to use the special format specificier in case we want to introduce
debug logs later.

Or do you mean this change possibly breaks something?
>
> regards,
> dan carpenter
>
>
diff mbox series

Patch

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index e3d49d4bdb1d..9e6102c43e00 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -162,7 +162,7 @@  cleanup_pagelistinfo(struct vchiq_instance *instance, struct vchiq_pagelist_info
 }

 static inline bool
-is_adjacent_block(u32 *addrs, u32 addr, unsigned int k)
+is_adjacent_block(u32 *addrs, dma_addr_t addr, unsigned int k)
 {
 	u32 tmp;

@@ -377,8 +377,8 @@  create_pagelist(struct vchiq_instance *instance, char *buf, char __user *ubuf,
 	/* Combine adjacent blocks for performance */
 	k = 0;
 	for_each_sg(scatterlist, sg, dma_buffers, i) {
-		u32 len = sg_dma_len(sg);
-		u32 addr = sg_dma_address(sg);
+		unsigned int len = sg_dma_len(sg);
+		dma_addr_t addr = sg_dma_address(sg);

 		/* Note: addrs is the address + page_count - 1
 		 * The firmware expects blocks after the first to be page-