Fix: fix PCI MSI-X support#6
Merged
differrari merged 2 commits intodifferrari:mainfrom Jun 12, 2025
Merged
Conversation
- check return value of pci_setup_msi, if it fails try to use msix - intilizate pci_setup_bar before using msix, as msix uses the bars memory address - add support for multiple interrupts in the pci_setup_msix function, as msix supports that
Owner
|
This is great, I noticed this but haven't gotten around to fixing it. Have you tried it on linux? Seems to keep detecting port change interrupts with MSIX |
Contributor
Author
I tried it on linux and it worked. I newer saw a port change (at least I think i never saw one), this was my log in case it helps: |
Owner
|
I'll look into it if the issue persists |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi me again, I noticed, that my local qemu doesn't support the device options
msi=on,msix=offfor theqemu-xhcidevice.So I removed them, but then my keyboard didn't work. So there was this issue in your existing code:
You didn't check the return code of
pci_setup_msi, if that returns false, no interrupts are enabled and the keyboard doesn't work.So I added a function, that tries to initialize MSI and if that fails it tries to use MSI-X. While doing that I found some more bugs introduced by this behavior. If you don't call
pci_setup_barbefore callingpci_setup_msixthe table pointer for the MSIX interrupts is null, which didn't throw an error before, but it is an error, as this should point to valid memory. So I fixed the order, and also added the assertion for the table to never be null.I also improved a few things in the pci code, that I found. So I replaced hard coded values with named constants (e.g.
#define PCI_CAPABILITY_MSI 0x05)I also added the capability of multiple interrupts to the MSI-X function, as msix support that.
I also added a small detection of the qemu device features, you can get them with
qemu-system-aarch64 -device qemu-xhci,helpso that if your qemu (as it may differ from distro to distro or if you compiled it yourself) options are supported.It is a little more than just fixing the bug and making msix work but i debugged it for quite some time, as the issue was not that easy to find, so I added some more checks and improvements and I just didn't wanted to remove them just now.
So if you don't want to accept this exact code just let me know 😄
At least now the keyboard works with my qemu on my machine 😄