Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
* [PATCH] accel/qaic: Fix mismatched types in min()
@ 2025-10-15 15:37 Youssef Samir
  2025-10-15 16:02 ` Carl Vanderlip
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Youssef Samir @ 2025-10-15 15:37 UTC (permalink / raw)
  To: jeff.hugo, carl.vanderlip, troy.hanson, zachary.mckevitt
  Cc: ogabbay, lizhi.hou, karol.wachowski, linux-arm-msm, dri-devel

From: Zack McKevitt <zmckevit@qti.qualcomm.com>

Use min_t() instead of min() to resolve compiler warnings for mismatched
types.

Signed-off-by: Zack McKevitt <zmckevit@qti.qualcomm.com>
Signed-off-by: Youssef Samir <youssef.abdulrahman@oss.qualcomm.com>
---
 drivers/accel/qaic/sahara.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/accel/qaic/sahara.c b/drivers/accel/qaic/sahara.c
index 3ebcc1f7ff58..ed24417d4c8a 100644
--- a/drivers/accel/qaic/sahara.c
+++ b/drivers/accel/qaic/sahara.c
@@ -615,7 +615,7 @@ static void sahara_parse_dump_table(struct sahara_context *context)
 
 	/* Request the first chunk of the first image */
 	context->dump_image = &image_out_table[0];
-	dump_length = min(context->dump_image->length, SAHARA_READ_MAX_SIZE);
+	dump_length = min_t(u64, context->dump_image->length, SAHARA_READ_MAX_SIZE);
 	/* Avoid requesting EOI sized data so that we can identify errors */
 	if (dump_length == SAHARA_END_OF_IMAGE_LENGTH)
 		dump_length = SAHARA_END_OF_IMAGE_LENGTH / 2;
@@ -663,7 +663,7 @@ static void sahara_parse_dump_image(struct sahara_context *context)
 
 	/* Get next image chunk */
 	dump_length = context->dump_image->length - context->dump_image_offset;
-	dump_length = min(dump_length, SAHARA_READ_MAX_SIZE);
+	dump_length = min_t(u64, dump_length, SAHARA_READ_MAX_SIZE);
 	/* Avoid requesting EOI sized data so that we can identify errors */
 	if (dump_length == SAHARA_END_OF_IMAGE_LENGTH)
 		dump_length = SAHARA_END_OF_IMAGE_LENGTH / 2;
-- 
2.43.0


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

* Re: [PATCH] accel/qaic: Fix mismatched types in min()
  2025-10-15 15:37 [PATCH] accel/qaic: Fix mismatched types in min() Youssef Samir
@ 2025-10-15 16:02 ` Carl Vanderlip
  2025-10-15 16:44 ` Jeff Hugo
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Carl Vanderlip @ 2025-10-15 16:02 UTC (permalink / raw)
  To: Youssef Samir, jeff.hugo, troy.hanson, zachary.mckevitt
  Cc: ogabbay, lizhi.hou, karol.wachowski, linux-arm-msm, dri-devel

On 10/15/2025 8:37 AM, Youssef Samir wrote:
> From: Zack McKevitt <zmckevit@qti.qualcomm.com>
> 
> Use min_t() instead of min() to resolve compiler warnings for mismatched
> types.
> 
> Signed-off-by: Zack McKevitt <zmckevit@qti.qualcomm.com>
> Signed-off-by: Youssef Samir <youssef.abdulrahman@oss.qualcomm.com>
> ---

Reviewed-by: Carl Vanderlip <carl.vanderlip@oss.qualcomm.com>

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

* Re: [PATCH] accel/qaic: Fix mismatched types in min()
  2025-10-15 15:37 [PATCH] accel/qaic: Fix mismatched types in min() Youssef Samir
  2025-10-15 16:02 ` Carl Vanderlip
@ 2025-10-15 16:44 ` Jeff Hugo
  2025-10-17 15:14 ` Falkowski, Maciej
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Jeff Hugo @ 2025-10-15 16:44 UTC (permalink / raw)
  To: Youssef Samir, carl.vanderlip, troy.hanson, zachary.mckevitt
  Cc: ogabbay, lizhi.hou, karol.wachowski, linux-arm-msm, dri-devel

On 10/15/2025 9:37 AM, Youssef Samir wrote:
> From: Zack McKevitt <zmckevit@qti.qualcomm.com>
> 
> Use min_t() instead of min() to resolve compiler warnings for mismatched
> types.
> 
> Signed-off-by: Zack McKevitt <zmckevit@qti.qualcomm.com>
> Signed-off-by: Youssef Samir <youssef.abdulrahman@oss.qualcomm.com>

Reviewed-by: Jeff Hugo <jeff.hugo@oss.qualcomm.com>

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

* Re: [PATCH] accel/qaic: Fix mismatched types in min()
  2025-10-15 15:37 [PATCH] accel/qaic: Fix mismatched types in min() Youssef Samir
  2025-10-15 16:02 ` Carl Vanderlip
  2025-10-15 16:44 ` Jeff Hugo
@ 2025-10-17 15:14 ` Falkowski, Maciej
  2025-10-20 14:41 ` Jeff Hugo
  2025-11-25 20:07 ` Andy Shevchenko
  4 siblings, 0 replies; 7+ messages in thread
From: Falkowski, Maciej @ 2025-10-17 15:14 UTC (permalink / raw)
  To: Youssef Samir, jeff.hugo, carl.vanderlip, troy.hanson,
	zachary.mckevitt
  Cc: ogabbay, lizhi.hou, karol.wachowski, linux-arm-msm, dri-devel

Reviewed-by: Maciej Falkowski <maciej.falkowski@linux.intel.com>

On 10/15/2025 5:37 PM, Youssef Samir wrote:
> From: Zack McKevitt <zmckevit@qti.qualcomm.com>
>
> Use min_t() instead of min() to resolve compiler warnings for mismatched
> types.
>
> Signed-off-by: Zack McKevitt <zmckevit@qti.qualcomm.com>
> Signed-off-by: Youssef Samir <youssef.abdulrahman@oss.qualcomm.com>
> ---
>   drivers/accel/qaic/sahara.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/accel/qaic/sahara.c b/drivers/accel/qaic/sahara.c
> index 3ebcc1f7ff58..ed24417d4c8a 100644
> --- a/drivers/accel/qaic/sahara.c
> +++ b/drivers/accel/qaic/sahara.c
> @@ -615,7 +615,7 @@ static void sahara_parse_dump_table(struct sahara_context *context)
>   
>   	/* Request the first chunk of the first image */
>   	context->dump_image = &image_out_table[0];
> -	dump_length = min(context->dump_image->length, SAHARA_READ_MAX_SIZE);
> +	dump_length = min_t(u64, context->dump_image->length, SAHARA_READ_MAX_SIZE);
>   	/* Avoid requesting EOI sized data so that we can identify errors */
>   	if (dump_length == SAHARA_END_OF_IMAGE_LENGTH)
>   		dump_length = SAHARA_END_OF_IMAGE_LENGTH / 2;
> @@ -663,7 +663,7 @@ static void sahara_parse_dump_image(struct sahara_context *context)
>   
>   	/* Get next image chunk */
>   	dump_length = context->dump_image->length - context->dump_image_offset;
> -	dump_length = min(dump_length, SAHARA_READ_MAX_SIZE);
> +	dump_length = min_t(u64, dump_length, SAHARA_READ_MAX_SIZE);
>   	/* Avoid requesting EOI sized data so that we can identify errors */
>   	if (dump_length == SAHARA_END_OF_IMAGE_LENGTH)
>   		dump_length = SAHARA_END_OF_IMAGE_LENGTH / 2;

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

* Re: [PATCH] accel/qaic: Fix mismatched types in min()
  2025-10-15 15:37 [PATCH] accel/qaic: Fix mismatched types in min() Youssef Samir
                   ` (2 preceding siblings ...)
  2025-10-17 15:14 ` Falkowski, Maciej
@ 2025-10-20 14:41 ` Jeff Hugo
  2025-11-25 20:07 ` Andy Shevchenko
  4 siblings, 0 replies; 7+ messages in thread
From: Jeff Hugo @ 2025-10-20 14:41 UTC (permalink / raw)
  To: Youssef Samir, carl.vanderlip, troy.hanson, zachary.mckevitt
  Cc: ogabbay, lizhi.hou, karol.wachowski, linux-arm-msm, dri-devel

On 10/15/2025 9:37 AM, Youssef Samir wrote:
> From: Zack McKevitt <zmckevit@qti.qualcomm.com>
> 
> Use min_t() instead of min() to resolve compiler warnings for mismatched
> types.
> 
> Signed-off-by: Zack McKevitt <zmckevit@qti.qualcomm.com>
> Signed-off-by: Youssef Samir <youssef.abdulrahman@oss.qualcomm.com>

Pushed to drm-misc-next

-Jeff

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

* Re: [PATCH] accel/qaic: Fix mismatched types in min()
  2025-10-15 15:37 [PATCH] accel/qaic: Fix mismatched types in min() Youssef Samir
                   ` (3 preceding siblings ...)
  2025-10-20 14:41 ` Jeff Hugo
@ 2025-11-25 20:07 ` Andy Shevchenko
  2025-11-25 22:28   ` David Laight
  4 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2025-11-25 20:07 UTC (permalink / raw)
  To: Youssef Samir, David Laight
  Cc: jeff.hugo, carl.vanderlip, troy.hanson, zachary.mckevitt, ogabbay,
	lizhi.hou, karol.wachowski, linux-arm-msm, dri-devel

+Cc: David

On Wed, Oct 15, 2025 at 05:37:15PM +0200, Youssef Samir wrote:
> 
> Use min_t() instead of min() to resolve compiler warnings for mismatched
> types.

I believe it's the opposite to what has to be done here.
At first glance it should be umin(), but I Cc'ed David
who is the expert in this topic.

> --- a/drivers/accel/qaic/sahara.c
> +++ b/drivers/accel/qaic/sahara.c
> @@ -615,7 +615,7 @@ static void sahara_parse_dump_table(struct sahara_context *context)
>  
>  	/* Request the first chunk of the first image */
>  	context->dump_image = &image_out_table[0];
> -	dump_length = min(context->dump_image->length, SAHARA_READ_MAX_SIZE);
> +	dump_length = min_t(u64, context->dump_image->length, SAHARA_READ_MAX_SIZE);
>  	/* Avoid requesting EOI sized data so that we can identify errors */
>  	if (dump_length == SAHARA_END_OF_IMAGE_LENGTH)
>  		dump_length = SAHARA_END_OF_IMAGE_LENGTH / 2;
> @@ -663,7 +663,7 @@ static void sahara_parse_dump_image(struct sahara_context *context)
>  
>  	/* Get next image chunk */
>  	dump_length = context->dump_image->length - context->dump_image_offset;
> -	dump_length = min(dump_length, SAHARA_READ_MAX_SIZE);
> +	dump_length = min_t(u64, dump_length, SAHARA_READ_MAX_SIZE);
>  	/* Avoid requesting EOI sized data so that we can identify errors */
>  	if (dump_length == SAHARA_END_OF_IMAGE_LENGTH)
>  		dump_length = SAHARA_END_OF_IMAGE_LENGTH / 2;

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH] accel/qaic: Fix mismatched types in min()
  2025-11-25 20:07 ` Andy Shevchenko
@ 2025-11-25 22:28   ` David Laight
  0 siblings, 0 replies; 7+ messages in thread
From: David Laight @ 2025-11-25 22:28 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Youssef Samir, jeff.hugo, carl.vanderlip, troy.hanson,
	zachary.mckevitt, ogabbay, lizhi.hou, karol.wachowski,
	linux-arm-msm, dri-devel

On Tue, 25 Nov 2025 21:07:11 +0100
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> +Cc: David
> 
> On Wed, Oct 15, 2025 at 05:37:15PM +0200, Youssef Samir wrote:
> > 
> > Use min_t() instead of min() to resolve compiler warnings for mismatched
> > types.  
> 
> I believe it's the opposite to what has to be done here.
> At first glance it should be umin(), but I Cc'ed David
> who is the expert in this topic.

The old code should compile fine - and did for my x86-64 'allmodconfig' build.
Both values are 'unsigned' types; one is u64 the other 0xfff0u - so unsigned int.

What are you compiling it for? and is it an old kernel with the old minmax.h?
I think the new minmax.h has been backported to quite a few of the stable kernels.

The correct 'fix' for the old min() is to change the type of SAHARA_READ_MAX_SIZE
to be u64 - the same as the LHS (so 0xfff0ull).
This probably has other repercussions.

Just adding 0ull will change integer type without any danger of changing the value.
so (to me at least):
	min(dump_length, SAHARA_MAX_READ + 0ull)
is actually much better than a (u64) cast.
(even if the value is a pointer, it is still one afterwards...)

But this shouldn't need changing for the current kernel.

	David

> 
> > --- a/drivers/accel/qaic/sahara.c
> > +++ b/drivers/accel/qaic/sahara.c
> > @@ -615,7 +615,7 @@ static void sahara_parse_dump_table(struct sahara_context *context)
> >  
> >  	/* Request the first chunk of the first image */
> >  	context->dump_image = &image_out_table[0];
> > -	dump_length = min(context->dump_image->length, SAHARA_READ_MAX_SIZE);
> > +	dump_length = min_t(u64, context->dump_image->length, SAHARA_READ_MAX_SIZE);
> >  	/* Avoid requesting EOI sized data so that we can identify errors */
> >  	if (dump_length == SAHARA_END_OF_IMAGE_LENGTH)
> >  		dump_length = SAHARA_END_OF_IMAGE_LENGTH / 2;
> > @@ -663,7 +663,7 @@ static void sahara_parse_dump_image(struct sahara_context *context)
> >  
> >  	/* Get next image chunk */
> >  	dump_length = context->dump_image->length - context->dump_image_offset;
> > -	dump_length = min(dump_length, SAHARA_READ_MAX_SIZE);
> > +	dump_length = min_t(u64, dump_length, SAHARA_READ_MAX_SIZE);
> >  	/* Avoid requesting EOI sized data so that we can identify errors */
> >  	if (dump_length == SAHARA_END_OF_IMAGE_LENGTH)
> >  		dump_length = SAHARA_END_OF_IMAGE_LENGTH / 2;  
> 


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

end of thread, other threads:[~2025-11-25 22:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-15 15:37 [PATCH] accel/qaic: Fix mismatched types in min() Youssef Samir
2025-10-15 16:02 ` Carl Vanderlip
2025-10-15 16:44 ` Jeff Hugo
2025-10-17 15:14 ` Falkowski, Maciej
2025-10-20 14:41 ` Jeff Hugo
2025-11-25 20:07 ` Andy Shevchenko
2025-11-25 22:28   ` David Laight

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox