<!-- @page { margin: 0.79in } P { margin-bottom: 0.08in } -->
Implementation of misc/pcicfg
This module provids below two interfaces to configure/unconfigure pci devices (include the children).
540 /*
541 * This entry point is called to configure a device (and
542 * all its children) on the given bus. It is called when
543 * a new device is added to the PCI domain. This routine
544 * will create the device tree and program the devices
545 * registers.
546 */
547 int
548 pcicfg_configure(dev_info_t *devi, uint_t device, uint_t function,
549 pcicfg_flags_t flags)
In pcicfg_configure(), the following procedures followed:
-
probe the device (include children), create devinfo node for each PCI device, and bind it to driver if below configuration is successful.
-
Allocate and program the resourses for both bridges and leaf devices.
-
Update standard and specific properties.
1422 /*
1423 * This will turn resources allocated by pcicfg_configure()
1424 * and remove the device tree from the Hotplug Connection (CN)
1425 * and below. The routine assumes the devices have their
1426 * drivers detached.
1427 */
1428 int
1429 pcicfg_unconfigure(dev_info_t *devi, uint_t device, uint_t function,
1430 pcicfg_flags_t flags)
In pcicfg_unconfigure(), the following procedures followed:
-
Offline the devinfo nodes, that means detaching the device driver and preventing it from reattaching.
-
Free up resources the devices consumed, disable the device and tear down the devinfo node (include children).
By the way, this should be a bug in code.
code review comments:
585 |_______|_______if ((function != PCICFG_ALL_FUNC) && (function != func))
586 |_______|_______|_______goto next;
… ...
657 next:
658 |_______|_______/*
659 |_______|_______ * Determine if ARI Forwarding should be enabled.
660 |_______|_______ */
661 |_______|_______if (func == 0) {
662 |_______|_______|_______if ((pcie_ari_supported(devi)
663 |_______|_______|_______ == PCIE_ARI_FORW_SUPPORTED) &&
664 |_______|_______|_______ (pcie_ari_device(new_device) == PCIE_ARI_DEVICE)) {
new_device could be used here before initialized.