Page MenuHomeFreeBSD

LinuxKPI: pci: implement pci_upstream_bridge()
ClosedPublic

Authored by bz on Feb 16 2022, 6:34 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 3, 4:58 AM
Unknown Object (File)
Mon, Oct 14, 5:21 AM
Unknown Object (File)
Oct 3 2024, 11:28 PM
Unknown Object (File)
Oct 3 2024, 11:27 PM
Unknown Object (File)
Oct 3 2024, 11:24 PM
Unknown Object (File)
Oct 3 2024, 11:18 PM
Unknown Object (File)
Oct 1 2024, 2:39 AM
Unknown Object (File)
Sep 27 2024, 9:38 AM

Details

Summary

Currently we point back to ourselves on pdev->bus->self rather than
the parent PCI bridge.

We keep this as status-quo with an extra comment and only on-demand
allocate a pci_dev for the parent bridge if we are asked for in
pci_upstream_bridge().
When releasing the pci_dev we check if pdev->bus->self has changed
and call pci_dev_put() to release the reference count on the parent
bridge as well.

This code moves pci_is_root_bus() higher up in pci.h but no functional
change there.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

Test Plan

Adding x11 to reviewers as this conflicts with the
implementation there.

I'll also need to MFC this.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bz requested review of this revision.Feb 16 2022, 6:35 PM

Sorry to add you here but I know you to know PCI very well; I found pci_find_pcie_root_port() but nothing which just walks up the PCI bridge tree step by step as a function to the next step so I am going with what other people also have done in sys/dev/ and got two up and check the class on that parent. Is that sane? I wonder if we should indeed (in the future) add a function and then replace then 2-3 places throughout the tree with that...?

x11 I opened a pull request which will remove the conflict : https://github.com/freebsd/drm-kmod/pull/152/commits/a35463b86a3babd4b580dab5f447d215478036ee If possible please apply to the devel/current/13 versions so this could proceed once reviewed.

sys/compat/linuxkpi/common/include/linux/pci.h
500

Won't this second case (pdev->bus->self == NULL) never get this far because pci_is_root_bus() would be true and return NULL instead?

sys/compat/linuxkpi/common/include/linux/pci.h
500

Correct; I'll remove the second condition :-)

bz marked an inline comment as done.

Remove 2nd condition from if() clause as it cannot happen here.

Thank you @wulf for handling the drm-kmod bits! Much appreciated.

Anyone any comments on this? If I don't hear back I'll probably commit it Tuesday morning UTC.

This fell through. ANyone trying to use a last chance to review? I'd love to at least get the linux_pci.c part of the change in.

Change looks good. I've added some comments.

sys/compat/linuxkpi/common/include/linux/pci.h
505

goto done;

508

goto done;

511

goto done;

518

done:

Goto done, goto done, goto done, are we done now?

This revision is now accepted and ready to land.Mar 15 2022, 7:56 AM
This revision was automatically updated to reflect the committed changes.