Lines Matching +full:pcie +full:- +full:root +full:- +full:port +full:- +full:2

1 // SPDX-License-Identifier: GPL-2.0
3 * Purpose: PCI Express Port Bus Driver
26 * The PCIe Capability Interrupt Message Number (PCIe r3.1, sec 7.8.2) must
27 * be one of the first 32 MSI-X entries. Per PCI r3.0, sec 6.8.3.1, MSI
32 #define get_descriptor_id(type, service) (((type - 4) << 8) | service)
41 * release_pcie_device - free PCI Express port service device structure
42 * @dev: Port service device to release
54 * services are enabled in "mask". Return the number of MSI/MSI-X vectors
65 * the MSI-X table entry or the MSI offset between the base Message
66 * Data and the generated interrupt message. See PCIe r3.1, sec
67 * 7.8.2, 7.10.10, 7.31.2.
81 pos = dev->aer_cap;
105 * pcie_port_enable_irq_vec - try to set up MSI-X or MSI as interrupt mode
106 * for given port
107 * @dev: PCI Express port to handle
109 * @mask: Bitmask of port capabilities returned by get_port_device_capability()
118 /* Allocate the maximum possible number of MSI/MSI-X vectors */
128 return -EIO;
151 /* PME, hotplug and bandwidth notification share an MSI/MSI-X vector */
170 * pcie_init_service_irqs - initialize irqs for PCI Express port services
171 * @dev: PCI Express port to handle
173 * @mask: Bitmask of port capabilities returned by get_port_device_capability()
175 * Return value: Interrupt mode associated with the port
182 irqs[i] = -1;
185 * If we support PME but can't use MSI/MSI-X for it, we have to
192 /* Try to use MSI-X or MSI if supported */
200 return -ENODEV;
209 * get_port_device_capability - discover capabilities of a PCI Express port
210 * @dev: PCI Express port to examine
212 * The capabilities are read from the port's PCI Express configuration registers
213 * as described in PCI Express Base Specification 1.0a sections 7.8.2, 7.8.9 and
214 * 7.9 - 7.11.
216 * Return value: Bitmask of discovered port capabilities
220 struct pci_host_bridge *host = pci_find_host_bridge(dev->bus);
223 if (dev->is_pciehp &&
226 (pcie_ports_native || host->native_pcie_hotplug)) {
230 * Disable hot-plug interrupts in case they have been enabled
231 * by the BIOS and the hot-plug service driver won't be loaded
242 dev->aer_cap && pci_aer_available() &&
243 (pcie_ports_native || host->native_aer))
247 /* Root Ports and Root Complex Event Collectors may generate PMEs */
250 (pcie_ports_native || host->native_pme)) {
254 * Disable PME interrupt on this port in case it's been enabled
262 * With dpc-native, allow Linux to use DPC even if it doesn't have
277 hweight8(dev->supported_speeds) > 1)
285 * pcie_device_init - allocate and initialize PCI Express port service device
286 * @pdev: PCI Express port to associate the service device with
293 struct pcie_device *pcie;
296 pcie = kzalloc(sizeof(*pcie), GFP_KERNEL);
297 if (!pcie)
298 return -ENOMEM;
299 pcie->port = pdev;
300 pcie->irq = irq;
301 pcie->service = service;
304 device = &pcie->device;
305 device->bus = &pcie_port_bus_type;
306 device->release = release_pcie_device; /* callback to free pcie dev */
307 dev_set_name(device, "%s:pcie%03x",
310 device->parent = &pdev->dev;
325 * pcie_port_device_register - register PCI Express port
326 * @dev: PCI Express port to register
328 * Allocate the port extension structure and register services associated with
329 * the port.
336 /* Enable PCI Express port device */
341 /* Get and check PCI Express port services */
362 status = -ENODEV;
391 if ((dev->bus == &pcie_port_bus_type) && dev->driver) {
392 service_driver = to_service_driver(dev->driver);
402 * pcie_port_device_suspend - suspend port services associated with a PCIe port
403 * @dev: PCI Express port to handle
418 * pcie_port_device_resume - resume port services associated with a PCIe port
419 * @dev: PCI Express port to handle
428 * pcie_port_device_runtime_suspend - runtime suspend port services
429 * @dev: PCI Express port to handle
438 * pcie_port_device_runtime_resume - runtime resume port services
439 * @dev: PCI Express port to handle
450 if (dev->bus == &pcie_port_bus_type)
462 service = pdrvs->service;
464 if (device->bus == &pcie_port_bus_type && device->driver) {
465 service_driver = to_service_driver(device->driver);
466 if (service_driver->service == service) {
467 pdrvs->drv = service_driver;
468 pdrvs->dev = device;
477 * pcie_port_find_device - find the struct device
478 * @dev: PCI Express port the service is associated with
491 device_for_each_child(&dev->dev, &pdrvs, find_service_iter);
499 * pcie_port_device_remove - unregister PCI Express port service devices
500 * @dev: PCI Express port the service devices to unregister are associated with
502 * Remove PCI Express port service devices associated with given port and
503 * disable MSI-X or MSI for the port.
507 device_for_each_child(&dev->dev, NULL, remove_iter);
512 * pcie_port_probe_service - probe driver for given PCI Express port service
513 * @dev: PCI Express port service device to probe against
515 * If PCI Express port service driver is registered with
517 * whenever match is found between the driver and a port service device.
525 if (!dev || !dev->driver)
526 return -ENODEV;
528 driver = to_service_driver(dev->driver);
529 if (!driver || !driver->probe)
530 return -ENODEV;
533 status = driver->probe(pciedev);
542 * pcie_port_remove_service - detach driver from given PCI Express port service
543 * @dev: PCI Express port service device to handle
545 * If PCI Express port service driver is registered with
547 * when device_unregister() is called for the port service device associated
555 if (!dev || !dev->driver)
559 driver = to_service_driver(dev->driver);
560 if (driver && driver->remove) {
561 driver->remove(pciedev);
568 * pcie_port_shutdown_service - shut down given PCI Express port service
569 * @dev: PCI Express port service device to handle
571 * If PCI Express port service driver is registered with
573 * when device_shutdown() is called for the port service device associated
579 * pcie_port_service_register - register PCI Express port service driver
580 * @new: PCI Express port service driver to register
585 return -ENODEV;
587 new->driver.name = new->name;
588 new->driver.bus = &pcie_port_bus_type;
589 new->driver.probe = pcie_port_probe_service;
590 new->driver.remove = pcie_port_remove_service;
591 new->driver.shutdown = pcie_port_shutdown_service;
593 return driver_register(&new->driver);
597 * pcie_port_service_unregister - unregister PCI Express port service driver
598 * @drv: PCI Express port service driver to unregister
602 driver_unregister(&drv->driver);
605 /* If this switch is set, PCIe port native services should not be enabled. */
609 * If the user specified "pcie_ports=native", use the PCIe services regardless
616 * If the user specified "pcie_ports=dpc-native", use the Linux DPC PCIe
627 else if (!strncmp(str, "dpc-native", 10))
639 if (!to_pci_dev(dev)->bridge_d3)
640 return -EBUSY;
648 * Assume the PCI core has set bridge_d3 whenever it thinks the port
650 * the port to D3, is handled by the PCI core.
652 return to_pci_dev(dev)->bridge_d3 ? 0 : -EBUSY;
677 * pcie_portdrv_probe - Probe PCI-Express port devices
678 * @dev: PCI-Express port device being probed
681 * this port device.
695 return -ENODEV;
706 dev_pm_set_driver_flags(&dev->dev, DPM_FLAG_NO_DIRECT_COMPLETE |
711 * Keep the port resumed 100ms to make sure things like
713 * cause the port to repeatedly suspend and resume.
715 pm_runtime_set_autosuspend_delay(&dev->dev, 100);
716 pm_runtime_use_autosuspend(&dev->dev);
717 pm_runtime_mark_last_busy(&dev->dev);
718 pm_runtime_put_autosuspend(&dev->dev);
719 pm_runtime_allow(&dev->dev);
728 pm_runtime_forbid(&dev->dev);
729 pm_runtime_get_noresume(&dev->dev);
730 pm_runtime_dont_use_autosuspend(&dev->dev);
741 pm_runtime_forbid(&dev->dev);
742 pm_runtime_get_noresume(&dev->dev);
743 pm_runtime_dont_use_autosuspend(&dev->dev);
760 device_for_each_child(&dev->dev, &off, pcie_port_device_iter);
775 /* handle any PCI-Express port */
777 /* subtractive decode PCI-to-PCI bridge, class type is 060401h */
779 /* handle any Root Complex Event Collector */
807 pr_notice("%s detected: will not use MSI for PCIe PME signaling\n",
808 d->ident);
815 * Boxes that should not use MSI for PCIe PME signaling.
819 .ident = "MSI Wind U-100",
822 "MICRO-STAR INTERNATIONAL CO., LTD"),
823 DMI_MATCH(DMI_PRODUCT_NAME, "U-100"),
841 return -EACCES;