Lines Matching +full:dev +full:- +full:ctrl
1 // SPDX-License-Identifier: GPL-2.0+
6 * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
8 * Copyright (C) 2003-2004 Intel Corporation
25 * pciehp_configure_device() - enumerate PCI devices below a hotplug bridge
26 * @ctrl: PCIe hotplug controller
29 * Return 0 on success, %-EEXIST if the devices are already enumerated or
30 * %-ENODEV if enumeration failed.
32 int pciehp_configure_device(struct controller *ctrl) in pciehp_configure_device() argument
34 struct pci_dev *dev; in pciehp_configure_device() local
35 struct pci_dev *bridge = ctrl->pcie->port; in pciehp_configure_device()
36 struct pci_bus *parent = bridge->subordinate; in pciehp_configure_device()
41 dev = pci_get_slot(parent, PCI_DEVFN(0, 0)); in pciehp_configure_device()
42 if (dev) { in pciehp_configure_device()
47 ctrl_dbg(ctrl, "Device %s already exists at %04x:%02x:00, skipping hot-add\n", in pciehp_configure_device()
48 pci_name(dev), pci_domain_nr(parent), parent->number); in pciehp_configure_device()
49 pci_dev_put(dev); in pciehp_configure_device()
50 ret = -EEXIST; in pciehp_configure_device()
56 ctrl_err(ctrl, "No new device found\n"); in pciehp_configure_device()
57 ret = -ENODEV; in pciehp_configure_device()
61 for_each_pci_bridge(dev, parent) in pciehp_configure_device()
62 pci_hp_add_bridge(dev); in pciehp_configure_device()
69 * to avoid AB-BA deadlock with device_lock. in pciehp_configure_device()
71 up_read(&ctrl->reset_lock); in pciehp_configure_device()
73 down_read_nested(&ctrl->reset_lock, ctrl->depth); in pciehp_configure_device()
75 dev = pci_get_slot(parent, PCI_DEVFN(0, 0)); in pciehp_configure_device()
76 ctrl->dsn = pci_get_dsn(dev); in pciehp_configure_device()
77 pci_dev_put(dev); in pciehp_configure_device()
85 * pciehp_unconfigure_device() - remove PCI devices below a hotplug bridge
86 * @ctrl: PCIe hotplug controller
95 void pciehp_unconfigure_device(struct controller *ctrl, bool presence) in pciehp_unconfigure_device() argument
97 struct pci_dev *dev, *temp; in pciehp_unconfigure_device() local
98 struct pci_bus *parent = ctrl->pcie->port->subordinate; in pciehp_unconfigure_device()
101 ctrl_dbg(ctrl, "%s: domain:bus:dev = %04x:%02x:00\n", in pciehp_unconfigure_device()
102 __func__, pci_domain_nr(parent), parent->number); in pciehp_unconfigure_device()
110 * Stopping an SR-IOV PF device removes all the associated VFs, in pciehp_unconfigure_device()
111 * which will update the bus->devices list and confuse the in pciehp_unconfigure_device()
115 list_for_each_entry_safe_reverse(dev, temp, &parent->devices, in pciehp_unconfigure_device()
117 pci_dev_get(dev); in pciehp_unconfigure_device()
121 * to avoid AB-BA deadlock with device_lock. in pciehp_unconfigure_device()
123 up_read(&ctrl->reset_lock); in pciehp_unconfigure_device()
124 pci_stop_and_remove_bus_device(dev); in pciehp_unconfigure_device()
125 down_read_nested(&ctrl->reset_lock, ctrl->depth); in pciehp_unconfigure_device()
132 pci_read_config_word(dev, PCI_COMMAND, &command); in pciehp_unconfigure_device()
135 pci_write_config_word(dev, PCI_COMMAND, command); in pciehp_unconfigure_device()
137 pci_dev_put(dev); in pciehp_unconfigure_device()