dev-amdgpu: Fix SDMA ring buffer wrap around

The current SDMA wrap around handling only considers the ring buffer
location as seen by the GPU. Eventually when the end of the SDMA ring
buffer is reached, the driver waits until the rptr written back to the
host catches up to what the driver sees before wrapping around back to
the beginning of the buffer. This writeback currently does not happen at
all, causing hangs for applications with a lot of SDMA commands.

This changeset first fixes the sizes of the queues, especially RLC
queues, so that the wrap around occurs in the correct place. Second, we
now store the rptr writeback address and the absoluate (unwrapped) rptr
value in each SDMA queue. The absolulte rptr is what the driver sends to
the device and what it expects to be written back.

This was tested with an application which basically does a few hundred
thousand hipMemcpy() calls in a loop. It should also fix the issue with
pannotia BC in fullsystem mode.

Change-Id: I53ebdcc6b02fb4eb4da435c9a509544066a97069
Maintainer: Jason Lowe-Power <>
Tested-by: kokoro <>
Reviewed-by: Jason Lowe-Power <>
Reviewed-by: Matt Sinclair <>
Maintainer: Matt Sinclair <>
(cherry picked from commit c8d687b05c803e3b358014e7f729a5700a003552)
Maintainer: Bobby Bruce <>
Reviewed-by: Bobby Bruce <>
Reviewed-by: Matthew Poremba <>
3 files changed