Skip to content

Commit

Permalink
Minimising gpu driver vm on qemu, and changing from virtio-gpu-pci to…
Browse files Browse the repository at this point in the history
… mmio

Signed-off-by: Eric Chan <[email protected]>
  • Loading branch information
erichchan999 committed Oct 10, 2024
1 parent 56ad2ab commit ecdf7ec
Show file tree
Hide file tree
Showing 4 changed files with 173 additions and 38 deletions.
186 changes: 165 additions & 21 deletions examples/kitty/board/qemu_virt_aarch64/framebuffer_vmm_images/linux.dts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/ {
interrupt-parent = <0x8002>;
dma-coherent;
model = "linux,dummy-virt";
#size-cells = <0x02>;
#address-cells = <0x02>;
Expand All @@ -13,11 +14,11 @@
cpu_off = <0x84000002>;
cpu_suspend = <0xc4000001>;
method = "smc";
compatible = "arm,psci-1.0\0arm,psci-0.2\0arm,psci";
compatible = "arm,psci-1.0", "arm,psci-0.2", "arm,psci";
};

memory@40000000 {
reg = <0x00 0x40000000 0x00 0x10000000>;
reg = <0x00 0x40000000 0x00 0x80000000>;
device_type = "memory";
};

Expand All @@ -26,7 +27,7 @@
ranges = <0x00 0x00 0xc000000 0x2000000>;
#address-cells = <0x01>;
#size-cells = <0x01>;
compatible = "qemu,platform\0simple-bus";
compatible = "qemu,platform", "simple-bus";
};

fw-cfg@9020000 {
Expand All @@ -49,12 +50,12 @@
compatible = "virtio,mmio";
};

// virtio_mmio@a000400 {
// dma-coherent;
// interrupts = <0x00 0x12 0x01>;
// reg = <0x00 0xa000400 0x00 0x200>;
// compatible = "virtio,mmio";
// };
virtio_mmio@a000400 {
dma-coherent;
interrupts = <0x00 0x12 0x01>;
reg = <0x00 0xa000400 0x00 0x200>;
compatible = "virtio,mmio";
};

virtio_mmio@a000600 {
dma-coherent;
Expand Down Expand Up @@ -203,6 +204,62 @@
compatible = "virtio,mmio";
};

virtio_mmio@a003000 {
dma-coherent;
interrupts = <0x00 0x28 0x01>;
reg = <0x00 0xa003000 0x00 0x200>;
compatible = "virtio,mmio";
};

virtio_mmio@a003200 {
dma-coherent;
interrupts = <0x00 0x29 0x01>;
reg = <0x00 0xa003200 0x00 0x200>;
compatible = "virtio,mmio";
};

virtio_mmio@a003400 {
dma-coherent;
interrupts = <0x00 0x2a 0x01>;
reg = <0x00 0xa003400 0x00 0x200>;
compatible = "virtio,mmio";
};

virtio_mmio@a003600 {
dma-coherent;
interrupts = <0x00 0x2b 0x01>;
reg = <0x00 0xa003600 0x00 0x200>;
compatible = "virtio,mmio";
};

virtio_mmio@a003800 {
dma-coherent;
interrupts = <0x00 0x2c 0x01>;
reg = <0x00 0xa003800 0x00 0x200>;
compatible = "virtio,mmio";
};

virtio_mmio@a003a00 {
dma-coherent;
interrupts = <0x00 0x2d 0x01>;
reg = <0x00 0xa003a00 0x00 0x200>;
compatible = "virtio,mmio";
};

virtio_mmio@a003c00 {
dma-coherent;
interrupts = <0x00 0x2e 0x01>;
reg = <0x00 0xa003c00 0x00 0x200>;
compatible = "virtio,mmio";
};

virtio_mmio@a003e00 {
dma-coherent;
interrupts = <0x00 0x2f 0x01>;
reg = <0x00 0xa003e00 0x00 0x200>;
compatible = "virtio,mmio";
};

gpio-keys {
compatible = "gpio-keys";

Expand All @@ -213,19 +270,22 @@
};
};

pl061@9030000 {
phandle = <0x8004>;
clock-names = "apb_pclk";
clocks = <0x8000>;
interrupts = <0x00 0x07 0x04>;
gpio-controller;
#gpio-cells = <0x02>;
compatible = "arm,pl061", "arm,primecell";
reg = <0x00 0x9030000 0x00 0x1000>;
};

pcie@10000000 {
interrupt-map-mask = <0x1800 0x00 0x00 0x07>;
interrupt-map = <0x00 0x00 0x00 0x01 0x8002 0x00 0x00 0x00 0x03 0x04 0x00 0x00 0x00 0x02 0x8002 0x00 0x00 0x00 0x04 0x04 0x00 0x00 0x00 0x03 0x8002 0x00 0x00 0x00 0x05 0x04 0x00 0x00 0x00 0x04 0x8002 0x00 0x00 0x00 0x06 0x04 0x800 0x00 0x00 0x01 0x8002 0x00 0x00 0x00 0x04 0x04 0x800 0x00 0x00 0x02 0x8002 0x00 0x00 0x00 0x05 0x04 0x800 0x00 0x00 0x03 0x8002 0x00 0x00 0x00 0x06 0x04 0x800 0x00 0x00 0x04 0x8002 0x00 0x00 0x00 0x03 0x04 0x1000 0x00 0x00 0x01 0x8002 0x00 0x00 0x00 0x05 0x04 0x1000 0x00 0x00 0x02 0x8002 0x00 0x00 0x00 0x06 0x04 0x1000 0x00 0x00 0x03 0x8002 0x00 0x00 0x00 0x03 0x04 0x1000 0x00 0x00 0x04 0x8002 0x00 0x00 0x00 0x04 0x04 0x1800 0x00 0x00 0x01 0x8002 0x00 0x00 0x00 0x06 0x04 0x1800 0x00 0x00 0x02 0x8002 0x00 0x00 0x00 0x03 0x04 0x1800 0x00 0x00 0x03 0x8002 0x00 0x00 0x00 0x04 0x04 0x1800 0x00 0x00 0x04 0x8002 0x00 0x00 0x00 0x05 0x04>;
#interrupt-cells = <0x01>;
ranges = <0x1000000 0x00 0x00
0x00 0x3eff0000
0x00 0x10000
0x2000000 0x00 0x10000000
0x00 0x10000000
0x00 0x2eff0000
0x3000000 0x80 0x00
0x80 0x00
0x80 0x00>;
ranges = <0x1000000 0x00 0x00 0x00 0x3eff0000 0x00 0x10000 0x2000000 0x00 0x10000000 0x00 0x10000000 0x00 0x2eff0000 0x3000000 0x80 0x00 0x80 0x00 0x80 0x00>;
reg = <0x40 0x10000000 0x00 0x10000000>;
msi-map = <0x00 0x8003 0x00 0x10000>;
dma-coherent;
Expand All @@ -237,6 +297,22 @@
compatible = "pci-host-ecam-generic";
};

pl031@9010000 {
clock-names = "apb_pclk";
clocks = <0x8000>;
interrupts = <0x00 0x02 0x04>;
reg = <0x00 0x9010000 0x00 0x1000>;
compatible = "arm,pl031", "arm,primecell";
};

pl011@9000000 {
clock-names = "uartclk", "apb_pclk";
clocks = <0x8000 0x8000>;
interrupts = <0x00 0x01 0x04>;
reg = <0x00 0x9000000 0x00 0x1000>;
compatible = "arm,pl011", "arm,primecell";
};

pmu {
interrupts = <0x01 0x07 0x104>;
compatible = "arm,armv8-pmuv3";
Expand Down Expand Up @@ -265,7 +341,6 @@
bank-width = <0x04>;
reg = <0x00 0x00 0x00 0x4000000 0x00 0x4000000 0x00 0x4000000>;
compatible = "cfi-flash";
status = "disabled";
};

cpus {
Expand Down Expand Up @@ -296,7 +371,7 @@
timer {
interrupts = <0x01 0x0d 0x104 0x01 0x0e 0x104 0x01 0x0b 0x104 0x01 0x0a 0x104>;
always-on;
compatible = "arm,armv8-timer\0arm,armv7-timer";
compatible = "arm,armv8-timer", "arm,armv7-timer";
};

apb-pclk {
Expand All @@ -307,16 +382,85 @@
compatible = "fixed-clock";
};

aliases {
serial0 = "/pl011@9000000";
};

chosen {
stdout-path = "/pl011@9000000";
rng-seed = <0x44f12b71 0x29e46ae4 0xa3e78714 0x5540132d 0xac25914b 0x1fc92c3c 0xe8b6abea 0xa3335de7>;
kaslr-seed = <0x12f0cbff 0x99fc6530>;
};
};

/*
* Overlay
*/
/ {
/delete-node/ virtio_mmio@a000000;
/delete-node/ virtio_mmio@a000200;
/delete-node/ virtio_mmio@a000400;
/delete-node/ virtio_mmio@a000600;
/delete-node/ virtio_mmio@a000800;
/delete-node/ virtio_mmio@a000a00;
/delete-node/ virtio_mmio@a000c00;
/delete-node/ virtio_mmio@a000e00;
/delete-node/ virtio_mmio@a001000;
/delete-node/ virtio_mmio@a001200;
/delete-node/ virtio_mmio@a001400;
/delete-node/ virtio_mmio@a001600;
/delete-node/ virtio_mmio@a001800;
/delete-node/ virtio_mmio@a001a00;
/delete-node/ virtio_mmio@a001c00;
/delete-node/ virtio_mmio@a001e00;
/delete-node/ virtio_mmio@a002000;
/delete-node/ virtio_mmio@a002200;
/delete-node/ virtio_mmio@a002400;
/delete-node/ virtio_mmio@a002600;
/delete-node/ virtio_mmio@a002800;
/delete-node/ virtio_mmio@a002a00;
/delete-node/ virtio_mmio@a002c00;
/delete-node/ virtio_mmio@a002e00;
/delete-node/ virtio_mmio@a003000;
/delete-node/ virtio_mmio@a003200;
/delete-node/ virtio_mmio@a003400;
/delete-node/ virtio_mmio@a003600;
/delete-node/ virtio_mmio@a003800;
/delete-node/ virtio_mmio@a003a00;
/delete-node/ virtio_mmio@a003e00;

flash@0 {
status = "disabled";
};

pcie@10000000 {
status = "disabled";
};

pl031@9010000 {
status = "disabled";
};

pl061@9030000 {
status = "disabled";
};

/delete-node/ pl011@9000000;

uio {
compatible = "generic-uio\0uio";
reg = <0x00 0x30000000 0x00 0x2000000>;
interrupts = <0x00 0x12 0x04>;
};

memory@40000000 {
reg = <0x00 0x40000000 0x00 0x10000000>;
device_type = "memory";
};

chosen {
bootargs = "console=ttynull uio_pdrv_genirq.of_id=generic-uio pci=nomsi vt.global_cursor_default=0 logo.nologo";
linux,initrd-start = <0x4d000000>;
linux,initrd-end = <0x4f000000>;
// vt.global_cursor_default=0 logo.nologo
};
};
19 changes: 5 additions & 14 deletions examples/kitty/board/qemu_virt_aarch64/kitty.system
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
-->
<system>
<memory_region name="uart" size="0x1_000" phys_addr="0x9000000" />
<memory_region name="eth_regs" size="0x1000" phys_addr="0xa003000" />
<memory_region name="virtio_regs" size="0x1000" phys_addr="0xa003000" />

<!-- UIO framebuffer-->
<memory_region name="uio_framebuffer" size="0x2_000_000" page_size="0x200_000" />
Expand Down Expand Up @@ -72,7 +72,7 @@

<protection_domain name="eth" priority="110" budget="100" period="400">
<program_image path="eth_driver.elf" />
<map mr="eth_regs" vaddr="0x2_000_000" perms="rw" cached="false" setvar_vaddr="eth_regs"/>
<map mr="virtio_regs" vaddr="0x2_000_000" perms="rw" cached="false" setvar_vaddr="eth_regs"/>

<map mr="eth_rx_free_drv" vaddr="0x2_400_000" perms="rw" cached="true" setvar_vaddr="rx_free" />
<map mr="eth_rx_active_drv" vaddr="0x2_600_000" perms="rw" cached="true" setvar_vaddr="rx_active" />
Expand Down Expand Up @@ -213,11 +213,7 @@
</protection_domain>

<memory_region name="framebuffer_guest_ram" size="0x10000000" page_size="0x200_000" phys_addr="0x40000000" />
<memory_region name="virtio_mmio" size="0x3000" phys_addr="0xa000000" />
<memory_region name="gic_vcpu" size="0x1_000" phys_addr="0x8040000" />
<memory_region name="pcie_config" size="0x1000000" phys_addr="0x10000000" />
<memory_region name="pcie" size="0x1000000" phys_addr="0x4010000000" />
<memory_region name="pcie_bus" size="0x1000000" phys_addr="0x8000000000" />
<memory_region name="gic_v2m" size="0x1000" phys_addr="0x8020000" />

<protection_domain name="framebuffer_vmm" priority="1">
Expand All @@ -227,18 +223,13 @@
<vcpu id="0" />
<map mr="framebuffer_guest_ram" vaddr="0x40000000" perms="rwx" />
<map mr="uio_framebuffer" vaddr="0x30000000" perms="rw" cached="true" />
<map mr="virtio_mmio" vaddr="0xa000000" perms="rw" cached="false" />
<map mr="gic_vcpu" vaddr="0x8010000" perms="rw" cached="false" />
<map mr="pcie" vaddr="0x4010000000" perms="rw" cached="false" />
<map mr="pcie_config" vaddr="0x10000000" perms="rw" cached="false" />
<map mr="pcie_bus" vaddr="0x8000000000" perms="rw" cached="false" />
<map mr="gic_v2m" vaddr="0x8020000" perms="rw" cached="false" />
<map mr="virtio_regs" vaddr="0xa003000" perms="rw" cached="false" />
<!-- <map mr="uart" vaddr="0x9000000" perms="rw" cached="false" /> -->
</virtual_machine>
<!-- IRQ for pass-through graphics -->
<irq irq="35" id="10" />
<irq irq="36" id="11" />
<irq irq="37" id="12" />
<irq irq="38" id="13" />
<irq irq="78" id="10" trigger="edge" />
</protection_domain>

<channel>
Expand Down
4 changes: 2 additions & 2 deletions examples/kitty/kitty.mk
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,10 @@ qemu: $(IMAGE_FILE)
-serial mon:stdio \
-device loader,file=$(IMAGE_FILE),addr=0x70000000,cpu-num=0 \
-m size=2G \
-global virtio-mmio.force-legacy=false \
-device virtio-net-device,netdev=netdev0 \
-netdev user,id=netdev0 \
-global virtio-mmio.force-legacy=false \
-device virtio-gpu-pci
-device virtio-gpu-device,edid=off,blob=off,max_outputs=1,indirect_desc=off,event_idx=off

clean::
${RM} -f *.elf .depend* $
Expand Down
2 changes: 1 addition & 1 deletion examples/kitty/src/vmm/vmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ uintptr_t guest_ram_vaddr;
#if defined(CONFIG_PLAT_ODROIDC4)
uint32_t irqs[] = { 192, 193, 194, 5, 246, 89, 35 };
#elif defined(CONFIG_PLAT_QEMU_ARM_VIRT)
uint32_t irqs[] = { 35, 36, 37, 38 };
uint32_t irqs[] = { 78 };
#else
#error "Need to define platform specific pass-through IRQs"
#endif
Expand Down

0 comments on commit ecdf7ec

Please sign in to comment.