Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Teres Alexis, Alan Previn" <alan.previn.teres.alexis@intel.com>
To: "Vivi, Rodrigo" <rodrigo.vivi@intel.com>
Cc: "intel-xe@lists.freedesktop.org" <intel-xe@lists.freedesktop.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"Nikula,  Jani" <jani.nikula@intel.com>,
	"Roper, Matthew D" <matthew.d.roper@intel.com>
Subject: Re: [PATCH] drm/xe/mmio: Fix xe_mmio_wait32() to honor delay/sleep maximums
Date: Thu, 17 Sep 2026 18:49:19 +0000	[thread overview]
Message-ID: <9e129e0348ced40800e5071d288654480d9517b4.camel@intel.com> (raw)
In-Reply-To: <f4f3390fe950479cd6ef9367924861a3ec74ee95.camel@intel.com>

> > 
Actually, hold off further review. let me post a new series with 2 patches
- first patch = re-rev of this one - but aligned to Rodrigo's direction to keep
it simple (for "fixes" management) with simple intra-loop caps. 
- second patch to align with Jani's (as well as other offline inputs) that
we SHOULD actually be using the kernel polling helpers.

but i think i wont update all callers to separate atomic vs non-atomic (as per Jani's)
request. I agree with him, but needs to be a separate series because since i see
us using those param-based-atomic-separation elsewhere in the driver in other subsystems.


thanks again everyone for all the inputs. will work on the re-rev.


alan:snip
> > > alan: i dont understand your this comment on the increasing the "wait by x2" in the loop after agreeing with Jani on the earlier statement.
> > 
> > What I agreed with Jani was that a hardcoded 10us poll interval against
> > a 2s timeout is bad. That was all.
> > 
> > > Some historical context:
> > > 
> > >  1. current baseline code it stands to day IS in violation of linux rules for how to use those sleep/delay functions
> > 
> > right, and I believe that this single line change is enough to fix this
> > violation.
> > 
> > The problem is that we double wait every loop 10, 20, 40, 80 … 20480, 40960 and
> > never stops doubling. udelay() is only legal up to ~5000us (perhaps 1000?!),
> > so once the doubling passes that, we're breaking the rule.
> > 
> > Same on the sleeping side: it ends up asking usleep_range() to sleep 1.3 s,
> > which is not what that function is for.
> > 
> > The one line just stops the doubling at 1000us:
> > 
> > wait = min_t(s64, wait << 1, 1000);
> > 
> > After that, the wait can be 10, 20, 40 … up to 1000, and then it stays at
> > 1000 forever. It can never reach 20480 or 1300000.
> > 
> > So the illegal value never gets passed to udelay() or usleep_range() — ever.
> > 
> > >  2. my initial revs on fixing this was to minimize the changes so its not complicated by simply fixing the code in place.
> > 
> > I believe this simple line alings with your v1, but just simpler.
> > 
> > >  3. Jani said we really should use the proper linux kernel helpers: poll_timeout_us / poll_timeout_us_atomic.
> > >  4. Those helpers have the "timeout_us" and the "intra-loop-wait-us" period. I hardcoded to 10 usec.
> > > 	- Jani said i should not hardcode and ensure all up-the-stack callers of the xe_mmio_wait32 function passes in the intra-wait-loop
> > > value. 
> > > 	- Then you (Rodrigo) agreed with his request but go on to propose going back to exponential 2x intra-wait-loop.
> > > 		- but that contradicts Jani's request u agreed to and also that means we implement the intra-wait-loop? (i.e. dont use the
> > > proper linux helper?)
> > 
> > sorry for not being clear on my previous response. Perhaps we have a cleaner
> > end code with the poll_timeout_us and poll_timeout_us_atomic indeed.
> > 
> > Then perhaps we have this single fixes patch and do other attempts in get
> > cleaner loops?
> > 
> > Thanks,
> > Rodrigo.
> > 
> alan: I think i understand what u mean. But i believe a single line patch will NOT suffice
> to maintain existing behavior for the non-atomic case. In the old code, if caller was
> requesting for non-atomic, 'wait' would continue doubling in usleep_range (which has no
> overflow limit for its params) so we actually CAN keep doubling. Thus callers that have
> very large timeouts, we'll be saving on CPU cycles as it increases. But with a 1 ms change
> as you proposed, we'd be increasing CPU cycles to get us to the end. Ofc I agree that
> doubling forever is not ideal even for the non-atomic usleep_range case, (kernel
> documentation stating that its good for both short and long timeouts), however kernel
> documentation DOES state it's an expensive operation with the hrttimer, which is why
> i wanted to allow the doubling of 'wait' for usleep_range case (like original code) but
> cap it to 25% of the caller provided final timeout. (while capping the atomic version to
> MAX_UDELAY_MS for short delays or the same 25% for long delays). This will ensure the
> overall behavior in terms of cpu cyles and expensive hrttimer calls are similiar as before
> AND also fixing in accordance to the rules. Actually if u see rev3, this is what i mean
> Its not 1 line but its much simpler fix and does I believe it does align with your vision.
> 
> > > 
> > >  ...alan
> > > 
> > > 
> > > > Also the Fixes tag is not the right one... the bug was there before...
> > > > 
> > > > > 
> > > > > ...alan
> > > 
> 


  reply	other threads:[~2026-09-17 18:49 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14 21:57 [PATCH] drm/xe/mmio: Fix xe_mmio_wait32() to honor delay/sleep maximums Alan Previn
2026-09-14 22:16 ` sashiko-bot
2026-09-14 22:40 ` ✓ CI.KUnit: success for drm/xe/mmio: Fix xe_mmio_wait32() to honor delay/sleep maximums (rev4) Patchwork
2026-09-14 23:39 ` ✓ Xe.CI.BAT: " Patchwork
2026-09-15  4:17 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-09-15  7:34 ` [PATCH] drm/xe/mmio: Fix xe_mmio_wait32() to honor delay/sleep maximums Jani Nikula
2026-09-15 16:00   ` Teres Alexis, Alan Previn
2026-09-15 16:43     ` Jani Nikula
2026-09-15 22:51     ` Rodrigo Vivi
2026-09-16 19:10       ` Teres Alexis, Alan Previn
2026-09-17  0:54         ` Rodrigo Vivi
2026-09-17  2:07           ` Teres Alexis, Alan Previn
2026-09-17 18:49             ` Teres Alexis, Alan Previn [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-09-29 19:20 Alan Previn
2026-09-30  3:51 ` Rodrigo Vivi
2026-09-29 15:25 Alan Previn
2026-09-29 16:18 ` sashiko-bot
2026-09-29 19:07   ` Teres Alexis, Alan Previn
2026-09-29  5:44 Alan Previn
2026-09-29  5:49 ` sashiko-bot
2026-09-29 17:51 ` Rodrigo Vivi
2026-09-08 20:33 Alan Previn
2026-09-08 18:56 Alan Previn
2026-09-08 19:03 ` sashiko-bot
2026-09-09  8:00 ` Jani Nikula
2026-09-11  0:05   ` Teres Alexis, 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=9e129e0348ced40800e5071d288654480d9517b4.camel@intel.com \
    --to=alan.previn.teres.alexis@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jani.nikula@intel.com \
    --cc=matthew.d.roper@intel.com \
    --cc=rodrigo.vivi@intel.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