Add ivshmem devices to root cell and linux-demo for networking purposes. A virtual PCI host is introduced and INTx SPIs are carefully selected for both sides so that they fall into the supported set of the GICD and do not overlap with actually used interrupts.
We need to go the vPCI path because Linux does not allow us to inject any virtual devices into the physical bus, see also https://www.mail-archive.com/[email protected]/msg01015.html. To enable the second PCI host controller, multi-domain PCI support is required for the Jetson, thus a small patch to the related Kconfig file of the kernel. The K1 only supports 160 SPIs, so adjust the root cell mask at this chance as well. Signed-off-by: Jan Kiszka <[email protected]> --- configs/dts/inmate-jetson-tk1.dts | 17 +++++++++++++++ configs/jetson-tk1-linux-demo.c | 37 +++++++++++++++++++++++++++++--- configs/jetson-tk1.c | 45 ++++++++++++++++++++++++++++++++------- 3 files changed, 88 insertions(+), 11 deletions(-) diff --git a/configs/dts/inmate-jetson-tk1.dts b/configs/dts/inmate-jetson-tk1.dts index e8d2a5d..c828b3e 100644 --- a/configs/dts/inmate-jetson-tk1.dts +++ b/configs/dts/inmate-jetson-tk1.dts @@ -77,4 +77,21 @@ clock-frequency = <408000000>; status = "okay"; }; + + vpci@48000000 { + compatible = "pci-host-ecam-generic"; + device_type = "pci"; + bus-range = <0 0>; + #address-cells = <3>; + #size-cells = <2>; + #interrupt-cells = <1>; + interrupt-map-mask = <0 0 0 7>; + interrupt-map = <0 0 0 1 &gic GIC_SPI 152 0>, + <0 0 0 2 &gic GIC_SPI 153 0>, + <0 0 0 3 &gic GIC_SPI 154 0>, + <0 0 0 4 &gic GIC_SPI 155 0>; + reg = <0x48000000 0x100000>; + ranges = + <0x02000000 0x00 0x10000000 0x10000000 0x00 0x10000>; + }; }; diff --git a/configs/jetson-tk1-linux-demo.c b/configs/jetson-tk1-linux-demo.c index 3086153..157edf0 100644 --- a/configs/jetson-tk1-linux-demo.c +++ b/configs/jetson-tk1-linux-demo.c @@ -21,8 +21,9 @@ struct { struct jailhouse_cell_desc cell; __u64 cpus[1]; - struct jailhouse_memory mem_regions[3]; - struct jailhouse_irqchip irqchips[1]; + struct jailhouse_memory mem_regions[4]; + struct jailhouse_irqchip irqchips[2]; + struct jailhouse_pci_device pci_devices[1]; } __attribute__((packed)) config = { .cell = { .signature = JAILHOUSE_CELL_DESC_SIGNATURE, @@ -32,6 +33,9 @@ struct { .cpu_set_size = sizeof(config.cpus), .num_memory_regions = ARRAY_SIZE(config.mem_regions), .num_irqchips = ARRAY_SIZE(config.irqchips), + .num_pci_devices = ARRAY_SIZE(config.pci_devices), + + .vpci_irq_base = 152, }, .cpus = { @@ -63,6 +67,13 @@ struct { JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA | JAILHOUSE_MEM_LOADABLE, }, + /* IVSHMEM shared memory region */ { + .phys_start = 0xfbf00000, + .virt_start = 0xfbf00000, + .size = 0x100000, + .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | + JAILHOUSE_MEM_ROOTSHARED, + }, }, .irqchips = { @@ -70,8 +81,28 @@ struct { .address = 0x50041000, .pin_base = 32, .pin_bitmap = { - 0, 0, 1 << (90 - 64), + 0, 0, 1 << (90+32 - 96) + }, + }, + /* GIC */ { + .address = 0x50041000, + .pin_base = 160, + .pin_bitmap = { + 1 << (152+32 - 160), + }, + }, + }, + + .pci_devices = { + /* 00:00.0 */ { + .type = JAILHOUSE_PCI_TYPE_IVSHMEM, + .bdf = 0x00, + .bar_mask = { + 0xffffff00, 0xffffffff, 0x00000000, + 0x00000000, 0xffffffe0, 0xffffffff, }, + .shmem_region = 3, + .shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH, }, }, }; diff --git a/configs/jetson-tk1.c b/configs/jetson-tk1.c index 37fc46e..9a66a46 100644 --- a/configs/jetson-tk1.c +++ b/configs/jetson-tk1.c @@ -23,8 +23,9 @@ struct { struct jailhouse_system header; __u64 cpus[1]; - struct jailhouse_memory mem_regions[20]; + struct jailhouse_memory mem_regions[21]; struct jailhouse_irqchip irqchips[2]; + struct jailhouse_pci_device pci_devices[1]; } __attribute__((packed)) config = { .header = { .signature = JAILHOUSE_SYSTEM_SIGNATURE, @@ -37,12 +38,17 @@ struct { .size = 0x1000, .flags = JAILHOUSE_MEM_IO, }, - .platform_info.arm = { - .gicd_base = 0x50041000, - .gicc_base = 0x50042000, - .gich_base = 0x50044000, - .gicv_base = 0x50046000, - .maintenance_irq = 25, + .platform_info = { + .pci_mmconfig_base = 0x48000000, + .pci_mmconfig_end_bus = 1, + .pci_is_virtual = 1, + .arm = { + .gicd_base = 0x50041000, + .gicc_base = 0x50042000, + .gich_base = 0x50044000, + .gicv_base = 0x50046000, + .maintenance_irq = 25, + }, }, .root_cell = { .name = "Jetson-TK1", @@ -50,6 +56,9 @@ struct { .cpu_set_size = sizeof(config.cpus), .num_memory_regions = ARRAY_SIZE(config.mem_regions), .num_irqchips = ARRAY_SIZE(config.irqchips), + .num_pci_devices = ARRAY_SIZE(config.pci_devices), + + .vpci_irq_base = 148, }, }, @@ -198,7 +207,14 @@ struct { .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | JAILHOUSE_MEM_EXECUTE, }, + /* IVSHMEM shared memory region */ { + .phys_start = 0xfbf00000, + .virt_start = 0xfbf00000, + .size = 0x100000, + .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE, + }, }, + .irqchips = { /* GIC */ { .address = 0x50041000, @@ -211,8 +227,21 @@ struct { .address = 0x50041000, .pin_base = 160, .pin_bitmap = { - 0xffffffff, 0xffffffff + 0xffffffff + }, + }, + }, + + .pci_devices = { + /* 00:00.0 */ { + .type = JAILHOUSE_PCI_TYPE_IVSHMEM, + .bdf = 0x00, + .bar_mask = { + 0xffffff00, 0xffffffff, 0x00000000, + 0x00000000, 0xffffffe0, 0xffffffff, }, + .shmem_region = 20, + .shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH, }, }, }; -- 2.1.4 -- You received this message because you are subscribed to the Google Groups "Jailhouse" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
