On Tue, 25 Nov 2025 21:07:11 +0100
Andy Shevchenko <[email protected]> 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;  
> 

Reply via email to