From: sashiko-bot@kernel.org
To: "Alan Previn" <alan.previn.teres.alexis@intel.com>
Cc: dri-devel@lists.freedesktop.org, intel-xe@lists.freedesktop.org
Subject: Re: [PATCH] drm/xe/mmio: Fix xe_mmio_wait32() to honor delay/sleep maximums
Date: Tue, 08 Sep 2026 19:03:56 +0000 [thread overview]
Message-ID: <20260908190356.7CACF1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260908185609.359565-2-alan.previn.teres.alexis@intel.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] The custom helper `__div_round_up64` silently truncates 64-bit divisors to 32 bits, creating a mathematically unsound helper.
- [Low] Inverted architecture check for 64-bit division causes a `__divdi3` link error on 32-bit builds, and needlessly uses a custom fallback on 64-bit builds.
--
commit 2d4751e6d3870228fa27b4fdbbb10070a48ae9ce
Author: Alan Previn <alan.previn.teres.alexis@intel.com>
drm/xe/mmio: Fix xe_mmio_wait32() to honor delay/sleep maximums
This commit fixes xe_mmio_wait32() to honor delay and sleep maximums by
checking for overflow in udelay and usleep_range. It also adds a custom
64-bit division helper and caps the in-loop wait time to prevent
intolerably large delays.
> diff --git a/drivers/gpu/drm/xe/xe_mmio.c b/drivers/gpu/drm/xe/xe_mmio.c
> index 7fa18dfcb5a28..1ae382f009de5 100644
> --- a/drivers/gpu/drm/xe/xe_mmio.c
> +++ b/drivers/gpu/drm/xe/xe_mmio.c
[ ... ]
> +static inline s64 __div_round_up64(s64 dividend, s64 divisor)
> +{
> + u64 abs_dividend = abs(dividend);
> + u64 abs_divisor = abs(divisor);
> + u64 result = abs_dividend + abs_divisor - 1;
> +
> + do_div(result, abs_divisor);
[Severity: Medium]
Does passing a 64-bit divisor to do_div() cause silent truncation here?
The do_div() macro is strictly designed for 32-bit divisors and will
silently truncate the 64-bit abs_divisor parameter. While the current caller
in __xe_mmio_wait32() only passes USEC_PER_MSEC (which fits in 32 bits),
creating a generic helper that accepts an s64 divisor is structurally
unsafe.
Could this use DIV64_U64_ROUND_UP() from linux/math64.h instead?
> + /* dont check for negative values as local caller only uses positive numbers */
> + return (s64)result;
> +}
[ ... ]
> @@ -349,11 +375,25 @@ static int __xe_mmio_wait32(struct xe_mmio *mmio, struct xe_reg reg, u32 mask, u
[ ... ]
> - if (atomic)
> - udelay(wait);
> - else
> - usleep_range(wait, wait << 1);
> - wait <<= 1;
> +#define __XE_MMIO_WAIT_MAX_INLOOP_100MS (100 * USEC_PER_MSEC)
> + if (atomic) {
> + if (wait <= MAX_UDELAY_MS * USEC_PER_MSEC)
> + udelay(wait);
> + else if (BITS_PER_LONG == 32)
> + mdelay(DIV_ROUND_UP(wait, USEC_PER_MSEC));
[Severity: Low]
Does this architecture check invert the intended 64-bit division logic?
When BITS_PER_LONG == 32, this branch executes the native 64-bit division
DIV_ROUND_UP(wait, USEC_PER_MSEC). This causes a __divdi3 unresolved symbol
link error on 32-bit builds, which appears to be the exact build break this
helper was intended to avoid.
> + else
> + mdelay(__div_round_up64(wait, USEC_PER_MSEC));
Consequently, 64-bit builds will take this else branch and needlessly use
the custom division helper instead of the native division macro.
> + } else {
> + usleep_range(wait, wait + (wait >> 2)); /* range till wait + 25% */
> + }
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260908185609.359565-2-alan.previn.teres.alexis@intel.com?part=1
next prev parent reply other threads:[~2026-09-08 19:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 18:56 [PATCH] drm/xe/mmio: Fix xe_mmio_wait32() to honor delay/sleep maximums Alan Previn
2026-09-08 19:03 ` sashiko-bot [this message]
2026-09-08 19:30 ` ✓ CI.KUnit: success for drm/xe/mmio: Fix xe_mmio_wait32() to honor delay/sleep maximums (rev2) Patchwork
2026-09-08 20:17 ` ✓ Xe.CI.BAT: " Patchwork
2026-09-09 8:00 ` [PATCH] drm/xe/mmio: Fix xe_mmio_wait32() to honor delay/sleep maximums Jani Nikula
2026-09-11 0:05 ` Teres Alexis, Alan Previn
-- strict thread matches above, loose matches on Subject: below --
2026-09-08 20:33 Alan Previn
2026-09-07 23:55 Alan Previn
2026-09-08 0:02 ` sashiko-bot
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=20260908190356.7CACF1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alan.previn.teres.alexis@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
/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