[Mesa-dev] [PATCH 1/3] r600g: fix CP DMA hazard with index buffer fetches

Marek Olšák maraeo at gmail.com
Fri May 27 19:44:37 UTC 2016


On Fri, May 27, 2016 at 9:03 PM, Alex Deucher <alexdeucher at gmail.com> wrote:
> On Fri, May 27, 2016 at 2:18 PM, Marek Olšák <maraeo at gmail.com> wrote:
>> From: Marek Olšák <marek.olsak at amd.com>
>>
>> R600-R700 used a bad workaround. Now only R600 has to use it.
>> ---
>>  src/gallium/drivers/r600/evergreen_hw_context.c | 13 +++++++++++--
>>  src/gallium/drivers/r600/evergreend.h           |  1 +
>>  src/gallium/drivers/r600/r600_blit.c            |  6 ------
>>  src/gallium/drivers/r600/r600_hw_context.c      | 25 ++++++++++++++++++++-----
>>  src/gallium/drivers/r600/r600d.h                |  1 +
>>  5 files changed, 33 insertions(+), 13 deletions(-)
>>
>> diff --git a/src/gallium/drivers/r600/evergreen_hw_context.c b/src/gallium/drivers/r600/evergreen_hw_context.c
>> index f456696..14877ae 100644
>> --- a/src/gallium/drivers/r600/evergreen_hw_context.c
>> +++ b/src/gallium/drivers/r600/evergreen_hw_context.c
>> @@ -117,7 +117,7 @@ void evergreen_cp_dma_clear_buffer(struct r600_context *rctx,
>>                 unsigned byte_count = MIN2(size, CP_DMA_MAX_BYTE_COUNT);
>>                 unsigned reloc;
>>
>> -               r600_need_cs_space(rctx, 10 + (rctx->b.flags ? R600_MAX_FLUSH_CS_DWORDS : 0), FALSE);
>> +               r600_need_cs_space(rctx, 2 + 10 + (rctx->b.flags ? R600_MAX_FLUSH_CS_DWORDS : 0), FALSE);
>>
>>                 /* Flush the caches for the first copy only. */
>>                 if (rctx->b.flags) {
>> @@ -148,9 +148,18 @@ void evergreen_cp_dma_clear_buffer(struct r600_context *rctx,
>>                 offset += byte_count;
>>         }
>>
>> +       /* CP DMA is executed in ME, but index buffers are read by PFP.
>> +        * This ensures that ME (CP DMA) is idle before PFP starts fetching
>> +        * indices. If we wanted to execute CP DMA in PFP, this packet
>> +        * should precede it.
>> +        */
>> +       if (coher == R600_COHERENCY_SHADER) {
>> +               radeon_emit(cs, PKT3(PKT3_PFP_SYNC_ME, 0, 0));
>> +               radeon_emit(cs, 0);
>> +       }
>
> Did you test this on 7xx?  I don't think this works on 7xx despite

No yet.

> what the documentation says.  See this kernel commit:
> http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=b6c2b4faf90230ef9cf1a81f36cbccda4a606c59
> I think this packet only works on evergreen and newer.

It should work on R700 according to my docs. The only explanation why
it hangs is that our CP firmware is too old.

Marek


More information about the mesa-dev mailing list