Skip to content

Add GAS-based firmware download for cascaded devices#402

Open
BenReed161 wants to merge 1 commit into
Microsemi:masterfrom
BenReed161:cascade-fw-download-gas-fix
Open

Add GAS-based firmware download for cascaded devices#402
BenReed161 wants to merge 1 commit into
Microsemi:masterfrom
BenReed161:cascade-fw-download-gas-fix

Conversation

@BenReed161

Copy link
Copy Markdown
Collaborator

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.

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 lsgunth left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a lot to review in one patch, but a quick scan shows nothing objectionable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants