Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libpci: use "brute force" scan for devices #132

Merged
merged 1 commit into from Aug 10, 2022
Merged

libpci: use "brute force" scan for devices #132

merged 1 commit into from Aug 10, 2022

Conversation

abrandnewusername
Copy link
Contributor

To handle cases where PCI or PCIe buses are not accessible via
a bridge from bus 0, We use "brute force" scan instead of recursive
scan here. Details of these methods can be found on
https://wiki.osdev.org/PCI#.22Brute_Force.22_Scan.

Signed-off-by: Jingyao Zhou jingyao.zhou@unsw.edu.au

This is not the ideal solution, but a workaround for this issue: #131

libpci/src/pci.c Outdated Show resolved Hide resolved
@kent-mcleod
Copy link
Member

This is not the ideal solution, but a workaround for this issue: #131

Would it be possible to implement this alternate scanning approach as a separate function to maintain the existing functionality for clients that already depend on it?

@wom-bat
Copy link
Member

wom-bat commented Jul 20, 2022

Would it be possible to implement this alternate scanning approach as a separate function to maintain the existing functionality for clients that already depend on it?

The existing functionality is just an optimisation to avoid scanning everything. The new code brute-force scans every possible bus, and will pick up any that have been configured by the BIOS.

The existing code is wrong when:
--- some buses are not attached via bridges but have a separate root complex
--- the BIOS doesn't enable the bus (the new code won't work for this case either)
--- where there is more than one PCI domain.

@kent-mcleod
Copy link
Member

The existing functionality is just an optimisation to avoid scanning everything. The new code brute-force scans every possible bus, and will pick up any that have been configured by the BIOS.

Is the brute force approach noticeably slower to execute?

@wom-bat
Copy link
Member

wom-bat commented Jul 27, 2022

Is the brute force approach noticeably slower to execute?

Not that I can tell with a single PCI domain (and we don't deal with more than a single PCI domain at the moment).
Of course, to do it properly, you'd parse the DSDT and use the full 4k config space for each device.

To handle cases where PCI or PCIe buses are not accessible via
a bridge from bus 0, We use "brute force" scan instead of recursive
scan here. Details of these methods can be found on
https://wiki.osdev.org/PCI#.22Brute_Force.22_Scan.

Signed-off-by: Jingyao Zhou <jingyao.zhou@unsw.edu.au>
Copy link
Member

@wom-bat wom-bat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me now.

@wom-bat wom-bat merged commit 7c30656 into master Aug 10, 2022
@wom-bat wom-bat deleted the jade/pciscan branch August 10, 2022 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants