Page MenuHomeFreeBSD

linuxkpi: enhance various PCI bits

Authored by bz on Jan 15 2021, 11:44 PM.



linuxkpi: enhance various PCI bits

  • In linux_pci_attach_device() get rid of dinfo apart from the two lines actually needing it. Given we set ivars, we can then use proper pci_get_*() accessor functions instead in either case.

    Move some more of these accessor initialisations to lkpifill_pci_dev(), which also avoids duplicat work for "device" and "vendor".
  • Move pdev->bus allocation common to lkpinew_pci_dev() and linux_pci_attach_device() into lkpifill_pci_dev().
  • Move the pdev->dev.* and kobj initializations from linux_pci_attach_device() into lkpifill_pci_dev() allowing the lkpinew_pci_dev() case to also use them.
  • Add a pdev->dev.release function for the lkpinew_pci_dev() case simply freeing the pdev->bus and the pdev called through the normal logic when the kref of the kobj of the dev of the pdev goes to 0.
  • With pdev->dev.kobj always initialized and the release function, Implement pci_dev_put() in the expected way (previously discussed as part of D27550).

All but the pci_domain_nr() changes are so that DRM will use the
normal dev/kobj refcount logic and common functions without any
special hack for device management. We keep doing this without
actually adding the allocated pci devices (incl. the kobjb satte)
from lkpinew_pci_dev() to the pci_devices list.

Sponsored-by: The FreeBSD Foundation
Obtained-from: bz_iwlwifi (partially)

Test Plan

Loading i915kms and unloading i915kms did work.

Diff Detail

rG FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

bz requested review of this revision.Jan 15 2021, 11:44 PM
bz retitled this revision from linuxkpi: ehance various PCI bits to linuxkpi: enhance various PCI bits.Jan 16 2021, 12:03 AM
bz edited the summary of this revision. (Show Details)

Anyone any last comments; I'd love to commit this before Monday.

This revision was not accepted when it landed; it landed in state Needs Review.Jan 28 2021, 4:47 PM
This revision was automatically updated to reflect the committed changes.