Page MenuHomeFreeBSD

linuxkpi: Fix DMA_BIDIRECTIONAL mapping
Needs ReviewPublic

Authored by zishun.yi.dev_gmail.com on Wed, Feb 25, 5:28 AM.
Tags
None
Referenced Files
F146349320: D55497.diff
Sun, Mar 1, 11:32 PM
Unknown Object (File)
Sun, Mar 1, 2:24 PM
Unknown Object (File)
Sun, Mar 1, 2:25 AM
Unknown Object (File)
Fri, Feb 27, 7:26 PM
Unknown Object (File)
Fri, Feb 27, 11:26 AM
Unknown Object (File)
Fri, Feb 27, 4:55 AM
Unknown Object (File)
Thu, Feb 26, 7:29 PM
Unknown Object (File)
Thu, Feb 26, 4:40 PM
Subscribers

Details

Reviewers
None
Group Reviewers
linuxkpi
Summary

In dma_sync_single_for_cpu(), the DMA_BIDIRECTIONAL direction currently
performs BUS_DMASYNC_POSTREAD followed by BUS_DMASYNC_PREREAD. This
patch corrects the mapping to use BUS_DMASYNC_POSTREAD |
BUS_DMASYNC_POSTWRITE.

When ownership of the DMA area is transferred to the CPU, we must assume
the previous device access was bidirectional. Both POST operations are
necessary to ensure the CPU sees a consistent view of memory after
potential device reads and writes. A PREREAD is unnecessary here because
the device will no longer access the memory since ownership has been
transferred to the CPU.

Conversely, for dma_sync_single_for_device(), ownership is being
transferred back to the hardware. The buffer must be prepared for
potential bidirectional access by the device, requiring
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE.

PR: 293381
Reported by: Zishun Yi <zishun.yi.dev@gmail.com>
Fixes: 95edb10b47fc ("LinuxKPI: implement dma_sync_single_for_*, apply to (un)map single/sg")
Signed-off-by: Zishun Yi <zishun.yi.dev@gmail.com>

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 70977
Build 67860: arc lint + arc unit