Add GAS-based firmware download for cascaded devices#402
Open
BenReed161 wants to merge 1 commit into
Open
Conversation
Firmware download to cascaded Switchtec devices fails because the kernel's MRPC path (both DMA and interrupt-based) is unreliable through cascade fabric. Additionally, the kernel ISR races with userspace when both access the MRPC mailbox registers simultaneously. Add a direct GAS register polling path that bypasses the kernel MRPC entirely. When GAS BAR mapping is available, fw_gasop_cmd() writes commands directly to MRPC registers, uses sfence to flush write-combining buffers, and polls status with a 120s timeout treating 0xffffffff reads as "device busy". Before starting the GAS-based download, mask EN_IRQ (bit 3) on the mrpc_comp_hdr and mrpc_comp_async_hdr event registers. This prevents the firmware from generating MSI-X completions that would trigger the kernel's switchtec_event_isr, which otherwise reads/writes the same MRPC registers and can submit queued kernel commands that corrupt the download state. Original IRQ settings are restored on exit. Falls back transparently to the kernel MRPC path if GAS mapping fails. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lsgunth
approved these changes
Jul 23, 2026
lsgunth
left a comment
Collaborator
There was a problem hiding this comment.
This is a lot to review in one patch, but a quick scan shows nothing objectionable.
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.
Firmware download to cascaded Switchtec devices fails because the kernel's MRPC path (both DMA and interrupt-based) is unreliable through cascade fabric. Additionally, the kernel ISR races with userspace when both access the MRPC mailbox registers simultaneously.
Add a direct GAS register polling path that bypasses the kernel MRPC entirely. When GAS BAR mapping is available, fw_gasop_cmd() writes commands directly to MRPC registers, uses sfence to flush write-combining buffers, and polls status with a 120s timeout treating 0xffffffff reads as "device busy".
Before starting the GAS-based download, mask EN_IRQ (bit 3) on the mrpc_comp_hdr and mrpc_comp_async_hdr event registers. This prevents the firmware from generating MSI-X completions that would trigger the kernel's switchtec_event_isr, which otherwise reads/writes the same MRPC registers and can submit queued kernel commands that corrupt the download state. Original IRQ settings are restored on exit.
Falls back transparently to the kernel MRPC path if GAS mapping fails.