AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: Felix Kuehling <felix.kuehling@amd.com>,
	philip yang <yangp@amd.com>, Philip Yang <Philip.Yang@amd.com>,
	amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH 1/5] drm/amdgpu: handle IH ring1 overflow
Date: Thu, 11 Nov 2021 14:43:01 +0100	[thread overview]
Message-ID: <f2005799-7371-9cfd-d3bb-7a531914175e@gmail.com> (raw)
In-Reply-To: <865585bf-84ac-ea2b-7e1d-a13aca7e4caf@amd.com>

Am 11.11.21 um 13:13 schrieb Felix Kuehling:
> Am 2021-11-11 um 2:00 a.m. schrieb Christian König:
>> Am 11.11.21 um 00:36 schrieb Felix Kuehling:
>>> On 2021-11-10 9:31 a.m., Christian König wrote:
>>> [SNIP]
>>> Aren't we processing interrupts out-of-order in this case. We're
>>> processing newer ones before older ones. Is that the root of the
>>> problem because it confuses our interrupt draining function?
>> Good point.
>>
>>> Maybe we need to detect overflows in the interrupt draining function
>>> to make it wait longer in that case.
>> Ideally we should use something which is completely separate from all
>> those implementation details.
>>
>> Like for example using the timestamp or a separate indicator/counter
>> instead.
> Even a timestamp will be broken if the interrupt processing function
> handles interrupts out of order.

We can easily detect if the timestamp is going backwards and so filter 
out stale entries.

> I think we need a different amdgpu_ih_process function for IH ring 1 the
> way we set it up to handle overflows. Because IH is just overwriting
> older entries, and we can't read entire IH entries atomically, we have
> to use a watermark. If IH WPTR passes the watermark, we have to consider
> the ring overflowed and reset our RPTR. We have to set RPTR far enough
> "ahead" of the current WPTR to make sure WPTR is under the watermark.
> And the watermark needs to be low enough to ensure amdgpu_irq_dispatch
> can read out the next IH entry before the WPTR catches up with the RPTR.
>
> Since we don't read the WPTR on every iteration, and out page fault
> handling code can take quite a while to process one fault, the watermark
> needs to provide a lot of buffer. Maybe we also need to read the WPTR
> register more frequently if the last read was more than a jiffy ago.

I think trying to solve that with the IH code or hardware is the 
completely wrong approach.

As I said before we need to something more robust and using the 
timestamp sounds like the most logical approach to me.

The only alternative I can see would be to have a hardware assisted flag 
which tells you if you had an overflow or not like we have for IH ring 0.

E.g. something like the following:
1. Copy the next N IV from the RPTR location.
2. Get the current WPTR.
3. If the overflow bit in the WPTR is set update the RPTR to something 
like WPTR+window, clear the overflow bit and repeat at #1.
4. Process the valid IVs.

The down side is that we are loosing a lot of IVs with that. That is 
probably ok for the current approach, but most likely a bad idea if we 
enable the CAM.

Regards,
Christian.

>
> Whenever an overflow (over the watermark) is detected, we can set a
> sticky overflow bit that our page fault handling code can use to clean
> up. E.g. once we start using the CAM filter, we'll have to invalidate
> all CAM entries when this happens (although I'd expect overflows to
> become impossible once we enable the CAM filter).
>
> Thanks,
>    Felix
>


  reply	other threads:[~2021-11-11 13:43 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-09 23:04 [PATCH 1/5] drm/amdgpu: handle IH ring1 overflow Philip Yang
2021-11-09 23:04 ` [PATCH 2/5] drm/amdkfd: check child range to drain retry fault Philip Yang
2021-11-10  3:26   ` Felix Kuehling
2021-11-11 21:55     ` philip yang
2021-11-09 23:04 ` [PATCH 3/5] drm/amdkfd: restore pages race with vma remove Philip Yang
2021-11-10  3:52   ` Felix Kuehling
2021-11-09 23:04 ` [PATCH 4/5] drm/amdkfd: restore pages race with process termination Philip Yang
2021-11-10  4:16   ` Felix Kuehling
2021-11-15 20:50     ` philip yang
2021-11-09 23:04 ` [PATCH 5/5] drm/amdkfd: svm deferred work pin mm Philip Yang
2021-11-10  4:51   ` Felix Kuehling
2021-11-10 10:15 ` [PATCH 1/5] drm/amdgpu: handle IH ring1 overflow Christian König
2021-11-10 13:59   ` philip yang
2021-11-10 14:31     ` Christian König
2021-11-10 14:44       ` philip yang
2021-11-10 14:54         ` Christian König
2021-11-10 15:45           ` philip yang
2021-11-10 15:48             ` Christian König
2021-11-10 23:36       ` Felix Kuehling
2021-11-11  7:00         ` Christian König
2021-11-11 12:13           ` Felix Kuehling
2021-11-11 13:43             ` Christian König [this message]
2021-11-11 13:57               ` Felix Kuehling
2021-11-11 21:31                 ` philip yang

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=f2005799-7371-9cfd-d3bb-7a531914175e@gmail.com \
    --to=ckoenig.leichtzumerken@gmail.com \
    --cc=Philip.Yang@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=felix.kuehling@amd.com \
    --cc=yangp@amd.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