Page 1 of 1
PCI IRQ routing via ACPI (acpica)
Posted: Wed May 24, 2023 1:25 pm
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.
Re: PCI IRQ routing via ACPI (acpica)
Posted: Wed May 24, 2023 3:38 pm
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.
Re: PCI IRQ routing via ACPI (acpica)
Posted: Thu May 25, 2023 8:46 am
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.
Re: PCI IRQ routing via ACPI (acpica)
Posted: Thu May 25, 2023 10:26 am
by Octocontrabass
Isn't that exactly the same as the algorithm described in the PCI-to-PCI Bridge Architecture Specification?
Re: PCI IRQ routing via ACPI (acpica)
Posted: Fri May 26, 2023 12:23 pm
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.
Re: PCI IRQ routing via ACPI (acpica)
Posted: Mon May 29, 2023 3:25 pm
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.
Re: PCI IRQ routing via ACPI (acpica)
Posted: Thu Jun 01, 2023 7:02 am
by shmx
Re: PCI IRQ routing via ACPI (acpica)
Posted: Sat Jun 03, 2023 4:09 am
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
Re: PCI IRQ routing via ACPI (acpica)
Posted: Sun Jun 04, 2023 4:37 am
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