Repository navigation
Use OHCI physical DMA for SBP-2 command data - #213
mhellevang wants to merge 3 commits into
Conversation
PhocusPocus — PR #213 hardware testingTesting performed on 21 October 2026, approximately 01:18–02:55 London BST (UTC+1), before the separate experimental investigation. Setup
Results
The logged capture-transfer rate increased by approximately 2.10× in these samples. Import and thumbnail timings were user estimates and did not show a comparable doubling of the complete workflow. The driver logged physical DMA activation at 02:42:05.019 BST:
Remaining observations
Interpretation and limitationsThe speed result is encouraging but preliminary. The candidate was 63 commits ahead of the old baseline, exposure/image content differed, and repeat counts and cache controls were limited. This does not isolate the physical-DMA change alone. The candidate CF import also landed in the baseline destination folder rather than the planned fresh candidate folder. Independent speed lines were not recorded for the second Single or four-shot capture in these snapshots. Viewable output was confirmed, but full pixel-integrity and image-quality validation was not performed. Normal logging was requested but not independently confirmed, and the baseline stream reported dropped messages. The attachment is retained evidence, not a complete bus trace or ASFW in-app ring export. Data-out, cancellation, unplug-during-transfer, timeout recovery, node-ID changes and multi-LUN safety were not validated by this run. AttachmentThe attached ZIP contains scoped driver/Phocus logs, observations, a hang sample, disk records, build identity/configuration, capture-file metadata and SHA256 checksums. Later experimental work and original photographs are excluded. |
|
Thanks, this is really useful. The capture speedup and a completed MultiShot are exactly what this PR was meant to show. A few notes from the logs:
If you get a chance on the iMac/Sequoia setup, timing the same folder's thumbnail load and the same CF import there would tell us whether there's anything to gain on our side. That's optional and doesn't block this PR. |
|
Thanks @mhellevang, and thanks @un4tun8ly for the careful test run. 22.9 → 48 MB/s on the H4D is a great result, and physical DMA is the right direction: it's how both Apple and Linux carry SBP-2 data. I'm not ready to merge it as is, though. Mostly not because of single bugs, but because of how the PR solves problems. Main concern: mechanisms copied, reasons not askedThe wire behavior is right: per-node filter, generation check, The clearest example is the reset chain:
Asking "why free it now?" at step 1 makes steps 2–4 unnecessary. SBP-2 already says to keep the memory until a stop point (§10.4.1–10.4.3: "the initiator shall not reuse the system memory … until completion status is returned"). With the IOMMU, keeping a buffer mapped a bit longer is cheap and safe. A smaller example: Second concern: scopeThis PR changes behavior well outside SBP-2:
The test evidence covers one SBP-2 camera and one scanner. Each of those areas needs its own review against its own reference and its own test. That's the main reason I'm asking for the split below. The generation change is a good example. It turned out to be correct (see below), but confirming that took the OHCI spec and Apple's reset ordering. And it changes stale-work handling for the whole bus. That shouldn't ride along in an SBP-2 perf PR. Blocking
Should fix
Left halfway (not blocking, but this is a perf PR)The software per-block path is gone, but the data path keeps its old shape: per-command DMA buffer + The SDK says Good fixes in here
The
|
|
Thanks for the feedback, you're right - I'll address your concerns 👌 |
|
Plan, so it's on record before I start: I'll split this into the PRs you listed, with one ordering change. Reconnect-after-rediscovery (your item 4) has to land before the physical-DMA PR, not after: Order:
1–3 are independent and go against main; 4 will be opened as a draft on top of 2 and 3. HW: I'll test 1–3 in one build on the LS-9000 (scan, unplug/replug with Discovery/ROMScanner logging), and 4–6 in a second build (scan, cancel, client exit and unplug during READ). I don't have an audio device, so a run with one streaming on the same bus is open to anyone who does. I'll close this PR once 4 is up. |
Background
Hasselblad H40d user un4tun8ly reported slow transfers over SBP-2.
Previously, each block transfer went through the software async-request handler. This moves command data into OHCI physical memory so the controller can handle the transfers directly. ORBs, page tables and status FIFOs still use software address space.
What changed
Physical access is restricted to the logged-in target and current bus generation, with register readback to check that the filter was applied. LUNs on the same node share access. Software requests into physical buffers return
TYPE_ERROR, so transfers can't quietly fall back to the old path.Command buffers stay mapped until timeout recovery has reset the LUN and fetch agent. If recovery fails or an active command is released, access is revoked before the buffers are freed and a bus reset is requested. This also fixes related MMIO/reset ordering, filter cleanup, payload limits and DMA address validation.
Testing
I've tested with my CoolScan 9000 as a regression check. It still scans fine, and the logs confirm that physical DMA is enabled.
In the main transfer phase on October 20, 1,212 larger commands completed in 40.58 seconds with successful SBP-2 status and no logged transport errors, timeouts or fetch-agent resets. Median command time was 25 ms; 95% completed within 89 ms.
That works out to roughly 3.7–5.5 MB/s. It's a range because the logs record page-table counts rather than exact payload lengths: each command used three entries of at most 60 KiB. The timing includes scanner waits and command processing. These figures describe the CoolScan regression test.
The scanner may not saturate FireWire, so a camera or hard drive is better suited to benchmarking throughput.
Hasselblad H4D-50MS (un4tun8ly, Phocus 3.8.4, macOS 27.0.1, build
6922e922): capture transfer went from 22.9 to 48.0 MB/s (~2.1×) compared with the #207 baseline. Two Single captures and a four-shot MultiShot completed and produced viewable images, and the log shows physical DMA being enabled. CF import and thumbnail loading were unchanged. They look latency-bound rather than bandwidth-bound and are out of scope here.Other checks:
x86_64andarm64e.git diff --checkpass.Still to test
Data-out, cancellation, client exit, unplug during a read, timeout recovery, node-ID changes after reset and multi-LUN operation still need hardware testing. An abort that can't be confirmed blocks every LUN on that node until reset. Host tests also can't prove DMA coherence or that outstanding writes have drained after access is revoked.