Skip to content

bcm2712: Use all 20 MIP1 outputs - #7729

Merged
pelwell merged 5 commits into
raspberrypi:rpi-7.4.yfrom
nbuchwitz:devel/pcie-mip1-bump
Nov 13, 2026
Merged

pelwell merged 5 commits into
raspberrypi:rpi-7.4.yfrom
nbuchwitz:devel/pcie-mip1-bump

Conversation

@nbuchwitz

Copy link
Copy Markdown
Contributor

I've been experimenting with more MSI vectors on MIP1, as our RevPi Connect 5 has 3x LAN7430s on pcie1. They don't fit into the 8 MIP1 outputs (each tries to claim 6 outputs), so our DT uses the rc MSI controller instead. Unfortunately it can't pin IRQs, which is not great in most industrial fieldbus setups.

The patches seem to work for my limited PCIe knowledge, but I'd really value @P33M's (and others) feedback on it. If this can work, I'd try to upstream the patches as usual.

@nbuchwitz nbuchwitz changed the title Devel/pcie mip1 bump bcm2712: Use all 20 MIP1 outputs Oct 31, 2026
@nbuchwitz
nbuchwitz force-pushed the devel/pcie-mip1-bump branch from 55e66be to b789b8b Compare October 31, 2026 21:28
@nbuchwitz
nbuchwitz force-pushed the devel/pcie-mip1-bump branch from b789b8b to ba5b936 Compare November 2, 2026 15:34
@P33M

P33M commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

From the incomplete Broadcom documentation that I have, the MIP to SPI mappings look correct. There was a register bit on 2712C1 that the firmware always sets to enable this (expanded but discontiguous) mapping, I believe it's hardcoded to a 1 in 2712D0.

@nbuchwitz

Copy link
Copy Markdown
Contributor Author

Thanks! Has the firmware always set that bit on C1, or is there a minimum version?

@P33M

P33M commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

All rpi-eeprom releases supporting Pi 5 set this bit on C1.

@nbuchwitz
nbuchwitz force-pushed the devel/pcie-mip1-bump branch from ba5b936 to 9c77be0 Compare November 7, 2026 10:41
@nbuchwitz
nbuchwitz changed the base branch from rpi-7.3.y to rpi-7.4.y November 7, 2026 10:43
MIP1, the MSI controller behind pcie1 on BCM2712, only describes 8
outputs. I measured the wiring on a CM5 and found 20, routed to GIC
SPIs that are not contiguous.

Patch 1 documents multiple msi-ranges entries. Patch 2 fixes multi-MSI
blocks for non-power-of-two counts and is meant for stable. Patch 3
lets the driver take several ranges. Patch 4 adds the outputs and
depends on patch 3.

Tested on rpi-7.3.y on a Revolution Pi Connect 5 (CM5) with three
LAN7430 NICs behind a PCIe switch, 6 MSI-X vectors each. DPC on the
switch ports uses another 6 outputs. Vectors per NIC:

                  8 outputs         20 outputs
  --------------------------------------------
  without DPC     6, 2, INTx        6, 6, 6
  with DPC        2, INTx, INTx     6, 6, 2

Industrial Ethernet setups often pin each NIC's interrupts to its own
CPU. That only works on MIP1. The RC MSI target keeps everything on
CPU0. Two NVMe drives behind a switch or an FPGA design [1] hit the
same limit.

A test module requesting 3 MSI vectors per NIC gets aligned blocks with
the series. Without patch 2 the block is misaligned, its last vector
lands outside the described outputs and the device's own MSI never
arrives. The old single-range node still works.

[1] https://forums.raspberrypi.com/viewtopic.php?t=398134

Signed-off-by: Nicolai Buchwitz <[email protected]>

--- b4-submit-tracking ---
# This section is used internally by b4 prep for tracking purposes.
{
  "series": {
    "revision": 1,
    "change-id": "20261030-investigate-bcm2712-mip1-v2-4ff97c32b04a",
    "prefixes": [],
    "presubject": ""
  }
}
…msi-ranges

The MIP outputs are not wired to one contiguous block of GIC SPIs, so a
single msi-ranges entry cannot describe all of them. Define how several
entries map to the outputs, and limit the legacy brcm,msi-offset to a
single entry, the only case the driver has ever handled.

Signed-off-by: Nicolai Buchwitz <[email protected]>
…unts

Multi-message MSI needs a naturally aligned block of message data, but
ilog2() rounds the request size down. A request for three vectors
reserves two slots and maps the third onto the next slot, which may
already belong to another device.

Reserve exactly the requested number of slots at a start aligned to the
next power of two.

Fixes: 32c6c05 ("irqchip: Add Broadcom BCM2712 MSI-X interrupt controller")
Cc: [email protected]
Signed-off-by: Nicolai Buchwitz <[email protected]>
The MIP outputs are not wired to one contiguous block of GIC SPIs, so a
single msi-ranges entry can only describe part of a MIP. Accept one
entry per contiguous run, in output order, and look up the SPI for each
message.

brcm,msi-offset keeps its meaning for the existing single range and is
rejected when more than one range is given.

Signed-off-by: Nicolai Buchwitz <[email protected]>
MIP1 serves pcie1, the external PCIe x1 port on Pi 5 and CM5, but only
8 of its outputs are described. A single multi-queue device can use
most of them, and further devices get fewer vectors or none.

The remaining wiring was measured on a CM5 by raising each MIP output
and checking which SPI became pending. 20 outputs are wired, the others
showed no route. The wiring is assumed to be the same on all BCM2712
steppings but has only been verified on CM5.

  MIP output    GIC SPI
   0..1         196..197
   2..3         200..201
   4..5         206..207
   6            240
   7            246
   8..15        255..262
  16            275
  17            282
  18            263
  19            283

Signed-off-by: Nicolai Buchwitz <[email protected]>
@nbuchwitz
nbuchwitz force-pushed the devel/pcie-mip1-bump branch from 9c77be0 to bd378e6 Compare November 12, 2026 10:53
@P33M

P33M commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

I have a big chungus dual SFP+ 10GbE network card, served by the bnx2x driver. The driver has a useful feature where you can specify the number of queues per interface - and an MSIx interrupt gets assigned per-queue. With bnx2x.num_queues=8, 18 vectors are assigned. With bnx2x.num_queues=9, it still gets 18 vectors and eth2 has a truncated set.

/proc/interrupts

cat /proc/interrupts
            CPU0       CPU1       CPU2       CPU3
   9:          0          0          0          0  GICv2                           25 Level     vgic
  11:          0          0          0          0  GICv2                           30 Level     kvm guest ptimer
  12:          0          0          0          0  GICv2                           27 Level     kvm guest vtimer
  13:       3843       3441       3902       4017  GICv2                           26 Level     arch_timer
  14:        451          0          0          0  GICv2                           65 Level     107c013880.mailbox
  15:        823          0          0          0  GICv2                          152 Level     uart-pl011
  21:          0          0          0          0  GICv2                          119 Level     DMA IRQ
  22:          0          0          0          0  GICv2                          120 Level     DMA IRQ
  23:          0          0          0          0  GICv2                          121 Level     DMA IRQ
  24:          0          0          0          0  GICv2                          122 Level     DMA IRQ
  32:       2731          0          0          0  GICv2                          308 Level     ttyS0
  33:          0          0          0          0  GICv2                           48 Level     arm-pmu
  34:          0          0          0          0  GICv2                           49 Level     arm-pmu
  35:          0          0          0          0  GICv2                           50 Level     arm-pmu
  36:          0          0          0          0  GICv2                           51 Level     arm-pmu
  37:          0          0          0          0  GICv2                          251 Level     PCIe PME, aerdrv, PCIe bwctrl
  38:          0          0          0          0  GICv2                          261 Level     PCIe PME, aerdrv, PCIe bwctrl
 106:          0          0          0          0  rp1_irq_chip                     6 Level     eth0
 108:          0          0          0          0  rp1_irq_chip                     8 Level     1f00074000.i2c
 131:          1          0          0          0  rp1_irq_chip                    31 Edge      xhci-hcd:usb1
 136:          1          0          0          0  rp1_irq_chip                    36 Edge      xhci-hcd:usb3
 140:          0          0          0          0  rp1_irq_chip                    40 Level     dw_axi_dmac_platform
 150:          0          0          0          0  rp1_irq_chip                    50 Edge      1f00178000.pio
 151:          0          0          0          0  rp1_irq_chip                    51 Edge      1f00178000.pio
 158:          2          0          0          0  rp1_irq_chip                    58 Level     1f00008000.mailbox
 161:       9245          0          0          0  GICv2                          305 Level     mmc0
 162:      18667          0          0          0  GICv2                          306 Level     mmc1
 163:          0          0          0          0  107d508500.gpio                 20 Edge      pwr_button
 164:          0          0          0          0  GICv2                          150 Level     107d004000.spi
 165:          0          0          0          0  interrupt-controller@7d508380    1 Level     107d508200.i2c
 166:          0          0          0          0  interrupt-controller@7d508380    2 Level     107d508280.i2c
 167:         17          0          0          0  GICv2                          281 Level     v3d_core0
 168:          0          0          0          0  GICv2                          282 Level     v3d_hub
 169:          0          0          0          0  GICv2                          104 Level     pispbe
 170:          0          0          0          0  GICv2                          130 Level     1000800000.codec
 171:          5          0          0          0  MIP-MSI-PCI-MSIX-0001:01:00.0    0 Edge      eth1
 173:          3          0          0          0  MIP-MSI-PCI-MSIX-0001:01:00.0    2 Edge      eth1-fp-0
 174:          3          0          0          0  MIP-MSI-PCI-MSIX-0001:01:00.0    3 Edge      eth1-fp-1
 175:          3          0          0          0  MIP-MSI-PCI-MSIX-0001:01:00.0    4 Edge      eth1-fp-2
 176:          3          0          0          0  MIP-MSI-PCI-MSIX-0001:01:00.0    5 Edge      eth1-fp-3
 177:          3          0          0          0  MIP-MSI-PCI-MSIX-0001:01:00.0    6 Edge      eth1-fp-4
 178:          3          0          0          0  MIP-MSI-PCI-MSIX-0001:01:00.0    7 Edge      eth1-fp-5
 179:          3          0          0          0  MIP-MSI-PCI-MSIX-0001:01:00.0    8 Edge      eth1-fp-6
 180:          3          0          0          0  MIP-MSI-PCI-MSIX-0001:01:00.0    9 Edge      eth1-fp-7
 181:          3          0          0          0  MIP-MSI-PCI-MSIX-0001:01:00.0   10 Edge      eth1-fp-8
 183:          0          0          0          0  interrupt-controller@7d510600    7 Level     vc4 hdmi hpd connected
 184:          0          0          0          0  interrupt-controller@7d510600    8 Level     vc4 hdmi hpd disconnected
 185:          0          0          0          0  interrupt-controller@7d510600    2 Level     vc4 hdmi cec rx
 186:          0          0          0          0  interrupt-controller@7d510600    1 Level     vc4 hdmi cec tx
 187:          5          0          0          0  MIP-MSI-PCI-MSIX-0001:01:00.1    0 Edge      eth2
 189:          3          0          0          0  MIP-MSI-PCI-MSIX-0001:01:00.1    2 Edge      eth2-fp-0
 190:          3          0          0          0  MIP-MSI-PCI-MSIX-0001:01:00.1    3 Edge      eth2-fp-1
 191:          3          0          0          0  MIP-MSI-PCI-MSIX-0001:01:00.1    4 Edge      eth2-fp-2
 192:          0          0          0          0  interrupt-controller@7c502000    2 Level     107c580000.hvs
 193:          0          0          0          0  interrupt-controller@7c502000    9 Level     107c580000.hvs
 194:          0          0          0          0  interrupt-controller@7c502000   16 Level     107c580000.hvs
 195:          3          0          0          0  MIP-MSI-PCI-MSIX-0001:01:00.1    5 Edge      eth2-fp-3
 196:          3          0          0          0  MIP-MSI-PCI-MSIX-0001:01:00.1    6 Edge      eth2-fp-4
 197:          3          0          0          0  MIP-MSI-PCI-MSIX-0001:01:00.1    7 Edge      eth2-fp-5
 198:          3          0          0          0  MIP-MSI-PCI-MSIX-0001:01:00.1    8 Edge      eth2-fp-6
 199:          0          0          0          0  interrupt-controller@7d510600   14 Level     vc4 hdmi hpd connected
 200:          0          0          0          0  interrupt-controller@7d510600   15 Level     vc4 hdmi hpd disconnected
 201:          0          0          0          0  interrupt-controller@7d510600   12 Level     vc4 hdmi cec rx
 202:          0          0          0          0  interrupt-controller@7d510600   11 Level     vc4 hdmi cec tx
 203:          0          0          0          0  interrupt-controller@7c502000    1 Level     107c500000.mop
 204:          0          0          0          0  interrupt-controller@7c502000    0 Level     107c501000.moplet
 205:          0          0          0          0  GICv2                          133 Level     vc4 crtc
 206:          0          0          0          0  GICv2                          142 Level     vc4 crtc
IPI0:        727        605        796        906  Rescheduling interrupts
IPI1:       3851       6051       7619       5740  Function call interrupts
IPI2:          0          0          0          0  CPU stop interrupts
IPI3:          0          0          0          0  CPU stop NMIs
IPI4:          0          0          0          0  Timer broadcast interrupts
IPI5:        294        185        242        339  IRQ work interrupts
IPI6:          0          0          0          0  CPU backtrace interrupts
IPI7:          0          0          0          0  KGDB roundup interrupts

There's some cryptic commentary in dmesg -
[    9.062162] bnx2x 0001:01:00.0 eth1: using MSI-X  IRQs: sp 171  fp[0] 173 ... fp[8] 181
[    9.741725] bnx2x 0001:01:00.1 eth2: using MSI-X  IRQs: sp 187  fp[0] 189 ... fp[6] 198

So it's dynamically sizing - is it a bug in this driver or the MIP allocation?

@P33M

P33M commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Ah, there's a hidden reservation for a "CNIC" vector, whatever that is. Note the MIP-MSI domain index going from 0 - 2...8. So it's allocating 20 vectors when 8 queues are enabled. Works on my machine.

@nbuchwitz

Copy link
Copy Markdown
Contributor Author

Thanks for testing!

Earlier today I've sent the msi allocation bugfix upstream and once it is merged I will send the rest too.

@pelwell
pelwell merged commit d9a4bcd into raspberrypi:rpi-7.4.y Nov 13, 2026
12 checks passed
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.

3 participants