kernel: hold off bus mastering until DMA buffers are (re)mapped#145
Merged
enjoy-digital merged 1 commit intoJul 13, 2026
Merged
Conversation
Clear PCI Bus Master Enable at probe until the core has been reset and its DMA buffers are mapped (enable it only after litepcie_dma_init), and clear it FIRST on remove before stopping the DMAs. Otherwise a device left bus-mastering by an unclean teardown DMAs into stale/freed addresses and faults the IOMMU (IO_PAGE_FAULT) before the driver is ready, which can escalate to a probe soft-lockup / D3cold wedge that only a power cycle clears. In-flight transactions complete cleanly; only new ones are blocked.
Owner
|
This makes sense, thanks @simonerni! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A device left bus-mastering by an unclean teardown keeps issuing DMA into
stale/freed addresses and faults the IOMMU (
IO_PAGE_FAULT) before the driver isready. On our setup this escalated to a probe soft-lockup / D3cold wedge that only
a power cycle cleared.
Change
pci_clear_master()asserted until afterlitepcie_dma_init()has (re)mapped the DMA buffers and the core is reset; enable bus mastering only
then, instead of right after reading the version.
pci_clear_master()first, beforelitepcie_stop_dma(), so thedevice stops issuing new DMA immediately even if the MMIO stop can't reach a
wedged core. In-flight transactions complete cleanly; only new ones are blocked.
Impact
Eliminates the IOMMU-fault-on-teardown class of wedge (
IO_PAGE_FAULTstorm +probe hang). Independent robustness fix, not tied to any streaming feature.
Testing
make -C litex_m2sdr/software/kernel clean all. Verified on hardware acrossrmmod/insmodcycles: teardown no longer leaves the device bus-mastering, proberecovers and re-creates
/dev/m2sdr0.