Yuri Nudelman 17ab47d2d6 habanalabs/gaudi: fix a race condition causing DMAR error
There is a rare race condition in CB completion mechanism, that can
occur under a very high pressure of command submissions.
The preconditions for this to happen are:

 1. There should be enough command submissions for the pre-allocated
    patched CB pool to run out of commands. At this stage we start
    allocating new patched CBs as they arrive.
 2. CB size has to be exactly (128*n + 104)B for some n, i.e. 24B below
    a cache line end.

The flow:

 1. Two command buffers being completed on different streams, at the
    same time. Denote those CB1 and CB2.
 2. Each command buffer is injected with two messages, 16B each - one
    for a HBW update of the completion queue, another to raise
    interrupt.
 3. Assume CB1 updated the completion queue and raise the interrupt.
 4. Assume CB2 updated the completion queue but did not raise the
    interrupt yet.
 5. The host receives the interrupt. It goes over the completion queue
    and sees two completions - CB1 and CB2. Release them both.
 6. CB2 performs the last command. The problem is that the last command
    is split between 2 cache lines. So to read the last 8B of the last
    command, it has to access the host again. Problem is - CB2 is
    already released. This causes a DMAR error.

The solution to this problem is simply to make sure the last two
commands in the CB are always in the same cache line, using NOP padding.

Signed-off-by: Yuri Nudelman <ynudelman@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2022-07-12 09:09:24 +03:00
..
2022-06-03 11:48:47 -07:00
2022-06-30 08:21:43 +09:00
2022-07-11 12:28:46 +02:00
2022-05-15 18:31:28 -06:00
2022-06-28 17:56:57 +02:00
2022-06-20 08:38:29 -05:00
2022-07-04 10:41:59 -07:00
2022-06-07 15:00:29 -07:00
2022-06-02 15:23:54 -07:00
2022-07-11 08:32:58 +02:00
2022-05-25 16:18:27 -07:00
2022-05-25 15:02:26 +02:00
2022-06-03 11:48:47 -07:00
2022-06-02 15:23:54 -07:00
2022-05-23 21:06:11 -07:00
2022-05-19 16:56:17 +02:00
2022-06-29 09:32:06 -07:00
2022-05-09 23:09:10 +02:00
2022-06-03 11:48:47 -07:00
2022-06-02 15:23:54 -07:00
2022-07-01 11:19:14 -07:00
2022-05-11 08:29:11 +03:00
2022-06-01 13:49:15 -07:00
2022-06-05 09:25:12 -07:00
2022-07-01 10:41:09 +02:00