Skip to content
Naveen Naidu

Pathway to get started with PCI Subsytem

lkmp, linux, kernel, pci4 min read

Heyoo Folks!

For the last few months, I have been working on understanding PCI, PCIE specifications and how the PCI subsystem works in the Linux Kernel. Why? Beause, that's the subsystem I am working on as part of Linux Kernel mentorship program.

PCI subsystem is very vast and in order to understand the code and why's, you need an adequate amount of knowledge. If you dive into reading the code headfirst - You'll find yourself in a situation similar to that of a person jumping from a building without safety line attached.

I did the above mistake and that cost me a lot of hair xD

I now realize that there a lot of moving parts to get stared with PCI subsystem. And during that time, I've read a lot (I literally mean a lot) of random blogs and spec sheets etc. And the jumbled reading of various things messed up my head more :p

But luckily, I somehow sifted through all those and I am now capable of understanding the code and also follow along atleast some of the conversations that happen on the Mailing list.

I would love to write a series of blog posts explaining my understanding, but currently I am very busy handling both my job at Hasura and Linux Kernel Mentorship so I do not have any free time to do so.

So I decided, I can atleast make up a list of resources and provide a structured pathway which people could use to start their adventure with PCI subsystem and hopeful, help save people form getting bald ^^

TL;DR - This is infact a list, I wish I had when I started out, which would have saved me from a lot of frustation - but I must admit, I did enjoy the eureka moment after the all the frustation :)

Note: The following list might not suite to everyone's liking, if the list was not helpful. I apologize for the inconvenience caused ^^'

You can read the content in any order you want, but I would personally suggest that you go through it in the order

NOTE: Don't worry if you do not understand everything there is in the links. I had to read through these things twice or thrice to even understand what's happening, so do not fret if nothing makes sense. Just push through it - All of this is getting registered in some corner of your memory. You will recall these sections when the time arises :)

The goal here is to first get a breadth first view into everything necessary, that way you atleast know something of everything. And while working on a particular part of PCI subsystem, if you ever feel you need to know more, you would always know where to refer back to.

Honestly, consuming everything given down would easily take atleast a month or two. So it's totally okay. No need to rush through it :D

1. Brief PCI, PCIE Introduction

Let's start with getting an high overview of what this giant beast is.

  1. How PCI works
  2. PCI - Wikipedia
  3. PCIE - Wikipedia
  4. Video Series - GNU/Linux &P PCIE - This is a really good video series which gives you a glimpse into how the software interacts with the PCI hardware.

For the wiki links, please don't go down the rabbit hole of clicking all the links present there, REMEMBER all we are trying to do right now is trying to get a very very brief overview of what the heck PCI is :)

Note: Linux Device Drivers, Third Edition book is from now refered as LDD

2. Linux Device Drivers

In this section, let's understand how does the software and hardware interact with each other in an Operating system.

  1. LDD - Chapter 1 and 2
  2. Linux Device Drivers for your GF - Chapter 1
  3. LDD - Chapter 3
  4. Linux Device Drivers for your GF - Chapter 2 to 6

3. Linux Device Drivers - PCI

  1. LDD - Chapter 8 to 12
  2. Linux Device Drivers for your GF - Chapter 7 to 9

4. Understanding PCI/PCIe at more basic level

In this section, we will learn a little more about how do PCIe devices work at the hardware layer and also start getting a better understanding of PCI subsystem in linux.

This understanding will help you understand why a particular section of code in PCI subsystem might have been written the way it was.

First, let me provide you with the specifications you would generally have to keep referring to, in order to get a more detailed understanding of any specific section. I really would not recommend that you sit down and read the entire specification at one go (It is very huge) - you'll end confusing yourself. (Atleast that’s what happened when I dared to do that ^^')



Back to the list now :)

  1. PCI - OS Dev Wiki
  2. TLDP - PCI
  3. Video Series -PCIeArchitecture: Start watching from PCIe Architecture: Lecture 1, If you really wish to - you might wanna read the first 4 chapters in PCIe Base Spec v2.0
  4. Down to the TLP: How PCI express devices talk: There are two parts in the tutorial. I would definitely recomment reading both :)
  5. PCI subsystem: This gives a very brief intro to how the code flows in PCI subsystem. It is a little outdated, but it should give you a really good idea of how to read the code.

That's it folks, That's the end of the list :)

There is so much more to learn and I'm coming across new things every day as I work during the mentorship. But fear not! The above knowledge would help you equip you with the necessary tools needed to win the warfare xD

Once I get more free time, I would definitely - write more stuff regarding the tasks I am working on the resources I am using. But until then, Take care - Have Fun with your journey \o/

Sayonara Hooomansss!