From: David Laight <david.laight.linux@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: Youssef Samir <youssef.abdulrahman@oss.qualcomm.com>,
jeff.hugo@oss.qualcomm.com, carl.vanderlip@oss.qualcomm.com,
troy.hanson@oss.qualcomm.com, zachary.mckevitt@oss.qualcomm.com,
ogabbay@kernel.org, lizhi.hou@amd.com,
karol.wachowski@linux.intel.com, linux-arm-msm@vger.kernel.org,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] accel/qaic: Fix mismatched types in min()
Date: Tue, 25 Nov 2025 22:28:29 +0000 [thread overview]
Message-ID: <20251125222829.28ea138a@pumpkin> (raw)
In-Reply-To: <aSYMb4EKFCaYrWTI@black.igk.intel.com>
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;
>
prev parent reply other threads:[~2025-11-25 22:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251125222829.28ea138a@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=andriy.shevchenko@intel.com \
--cc=carl.vanderlip@oss.qualcomm.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jeff.hugo@oss.qualcomm.com \
--cc=karol.wachowski@linux.intel.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=lizhi.hou@amd.com \
--cc=ogabbay@kernel.org \
--cc=troy.hanson@oss.qualcomm.com \
--cc=youssef.abdulrahman@oss.qualcomm.com \
--cc=zachary.mckevitt@oss.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox