From 90df54a245506fceb93abca411643031019741cc Mon Sep 17 00:00:00 2001 From: Henry Wang Date: Sun, 28 Nov 2021 01:47:09 -0500 Subject: [PATCH] aarch64: fdt: Create MSI mapping for PCI nodes Each PCI device under a root complex is uniquely identified by its Requester ID (AKA RID). A Requester ID is a triplet of a Bus number, Device number, and Function number. MSIs may be distinguished in part through the use of sideband data accompanying writes. In the case of PCI devices, this sideband data may be derived from the Requester ID. A mechanism is required to associate a device with both the MSI controllers it can address, and the sideband data that will be associated with its writes to those controllers. This commit adds the `msi-map` property for PCI nodes, therefore creating MSI mapping for each PCI device. Signed-off-by: Henry Wang --- arch/src/aarch64/fdt.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/src/aarch64/fdt.rs b/arch/src/aarch64/fdt.rs index bf4696ced..36cf59053 100644 --- a/arch/src/aarch64/fdt.rs +++ b/arch/src/aarch64/fdt.rs @@ -608,6 +608,19 @@ fn create_pci_nodes( pci_device_info_elem.mmio_config_address, PCI_MMIO_CONFIG_SIZE_PER_SEGMENT, ]; + // See kernel document Documentation/devicetree/bindings/pci/pci-msi.txt + let msi_map = [ + // rid-base: A single cell describing the first RID matched by the entry. + 0x0, + // msi-controller: A single phandle to an MSI controller. + MSI_PHANDLE, + // msi-base: An msi-specifier describing the msi-specifier produced for the + // first RID matched by the entry. + (pci_device_info_elem.pci_segment_id as u32) << 8, + // length: A single cell describing how many consecutive RIDs are matched + // following the rid-base. + 0x100, + ]; let pci_node_name = format!("pci@{:x}", pci_device_info_elem.mmio_config_address); let pci_node = fdt.begin_node(&pci_node_name)?; @@ -627,6 +640,7 @@ fn create_pci_nodes( fdt.property_null("interrupt-map")?; fdt.property_null("interrupt-map-mask")?; fdt.property_null("dma-coherent")?; + fdt.property_array_u32("msi-map", &msi_map)?; fdt.property_u32("msi-parent", MSI_PHANDLE)?; if pci_device_info_elem.pci_segment_id == 0 {