Skip to content

Compiler read/write reorderings make DMA flaky #6

@ayrtonm

Description

@ayrtonm

DMA transfers can be flaky due to compiler misoptimizations. The problem is that llvm emits a MIPS-II instruction for the compiler_fence. So rustc gives the following error when I try adding the fence. Afaiu other llvm backends implement compiler fences without emitting instructions so it should be possible to fix this codegen issue.

LLVM ERROR: Cannot select: 0x7f26902f1f88: ch = MipsISD::Sync 0x7f269009e838, Constant:i32<0>
  0x7f269026b230: i32 = Constant<0>
In function: _ZN3psx11framebuffer11Framebuffer4swap17h0b2ca510268f3486E

For now the least flaky solution seems to be calling black_box on the pointer passed to the DMA channel (even though it shouldn't be relied on for correctness). I still get builds where DMA doesn't work (usually when toggling LTO or the min-panic feature), but it seems less frequent than with the llvm_asm("":::"memory", "volatile") hack.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions