PCI IRQ routing via ACPI (acpica)

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
shmx
Member
Member
Posts: 68
Joined: Sat Jan 16, 2016 10:43 am

PCI IRQ routing via ACPI (acpica)

Post by shmx »

Hi all
I want to make PCI IRQ routing for IOAPIC. I understand that this isn't possible without ACPI, so I integrated ACPICA into my project. Moreover, I tried to implement getting routing table by recursively searching for PCI bridges (starting from PCI root PNP0A03) and calling _PRT method on them. This actually works on most real computers, but there were problems with B450 chipset + AMI BIOS.
There are two problems:
1. All non-root bridges without _BBN method. I solved this problem by reading bus number directly from PCI configuration space.
2. Some bridges don't have routing table (_PRT method). I don't know what to do with it. I noticed that there are devices on these buses that are connected to PCI-e expansion slots. However, routing table is present for all devices integrated into chipset.
Octocontrabass
Member
Member
Posts: 5560
Joined: Mon Mar 25, 2013 7:01 pm

Re: PCI IRQ routing via ACPI (acpica)

Post by Octocontrabass »

shmx wrote:1. All non-root bridges without _BBN method. I solved this problem by reading bus number directly from PCI configuration space.
I don't think _BBN is supposed to tell you the current bus number, just the one that was in use when the ACPI tables were built. The ACPI spec seems to suggest that _BBN is only used to assist routing PCI_Config Operation Region accesses, which means it's not necessary if no such accesses will occur.
shmx wrote:2. Some bridges don't have routing table (_PRT method). I don't know what to do with it. I noticed that there are devices on these buses that are connected to PCI-e expansion slots. However, routing table is present for all devices integrated into chipset.
If no routing table is present, use the default routing described in the PCI-to-PCI Bridge Architecture Specification.
shmx
Member
Member
Posts: 68
Joined: Sat Jan 16, 2016 10:43 am

Re: PCI IRQ routing via ACPI (acpica)

Post by shmx »

Thk, Octocontrabass
I thought about native routing, but it seemed to me that it isn't used in modern chipsets. It mechanism is really used for buses connected to expansion slots. I read PСI spec, but all I saw was an explicit description of how IRQ rotation was within single bus. Problem is that even parent bus doesn't have routing table. My bus topology is like this:

Code: Select all

       [0]
        |
       [1] - [6]
        |
       [2]
     /  |  \
  [3] [4] [5]
Buses 0, 1, 6 contain routing table. External devices are connected to buses 3, 4, 5. Experimentally, I managed to come up algorithm:
1. Recursively find first parent bus in chain with complete routing table for device 0.
2. Remeber IRQ for all pins (A - D).
3. irq = save_irq[(pci_dev_addr + (pci_irq_pin - 1) + parent_bus_dev_addr) % 4]

I'm not sure that this algorithm is correct.
Octocontrabass
Member
Member
Posts: 5560
Joined: Mon Mar 25, 2013 7:01 pm

Re: PCI IRQ routing via ACPI (acpica)

Post by Octocontrabass »

Isn't that exactly the same as the algorithm described in the PCI-to-PCI Bridge Architecture Specification?
shmx
Member
Member
Posts: 68
Joined: Sat Jan 16, 2016 10:43 am

Re: PCI IRQ routing via ACPI (acpica)

Post by shmx »

I have carefully read sections 9.1 and 11.2.3. It seemed to me that some actions were not described and I had to think out.
devc1
Member
Member
Posts: 439
Joined: Fri Feb 11, 2022 4:55 am
Location: behind the keyboard

Re: PCI IRQ routing via ACPI (acpica)

Post by devc1 »

I am going through the same thing, I recently added the ACPICA to my OS to get the IRQ Pins values. Can you please provide me with the code you use to resolve interrupt pins.
devc1
Member
Member
Posts: 439
Joined: Fri Feb 11, 2022 4:55 am
Location: behind the keyboard

Re: PCI IRQ routing via ACPI (acpica)

Post by devc1 »

AcpiGetDevices with the PNP0A... Bridge returns nothing. And when I call it with NULL it returns _SB and _ZT on QEMU.

And how do I use AcpiGetIrqRoutingTable
devc1
Member
Member
Posts: 439
Joined: Fri Feb 11, 2022 4:55 am
Location: behind the keyboard

Re: PCI IRQ routing via ACPI (acpica)

Post by devc1 »

Edit : sorry I missed some initialization functions. That maybe explains why its returning nothing and triple faulting on my pc and vmware. Thanks for your reference, I can now understand alot by reading your driver.

I will try fixing this as soon as I get up from bed lol
Post Reply