GitHub - Zain-Naqvi-tech/linux-pci-dma-driver

QEMU EDU Linux Kernel PCI Driver

Platform: QEMU EDU virtual PCI device (1234:11e8), x86-64 guest, Linux 6.8 Toolchain: Kbuild out-of-tree module, gcc for userspace, WSL2 host running a QEMU guest Language: C, kernel space and userspace


Overview

An out-of-tree Linux kernel PCI driver written from scratch against QEMU’s EDU device. It enumerates the device, maps its registers, exposes it to userspace as a character device, handles MSI interrupts, and runs DMA transfers into and out of the device’s internal buffer. On top of that sits a benchmark that compares programmed I/O against DMA across eleven transfer sizes.

The reason I picked this instead of another bare-metal board project: kernel space is a different set of rules. Nothing I had written before had to worry about which context a function runs in, whether a pointer is safe to dereference, or what a device is allowed to do to system memory without asking. I wanted to learn more about the userspace/kernel difference and how working with linux feels. Everything runs inside a VM


The short version


The stack, top to bottom

  1. Userspace test app and benchmark harness. open, read, write, ioctl, timing, CSV output.
  2. /dev/edu. The character device. My file_operations table.