Lines Matching +full:used +full:- +full:by +full:- +full:rtas
1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright 2006-2007 Michael Ellerman, IBM Corp.
14 #include <asm/rtas.h>
16 #include <asm/ppc-pci.h>
32 /* RTAS Helpers */
40 addr = rtas_config_addr(pdn->busno, pdn->devfn, 0); in rtas_change_msi()
41 buid = pdn->phb->buid; in rtas_change_msi()
59 * If the RTAS call succeeded, return the number of irqs allocated. in rtas_change_msi()
65 rc = -rc; in rtas_change_msi()
82 * disabling MSI with the explicit interface also disables MSI-X in rtas_disable_msi()
101 addr = rtas_config_addr(pdn->busno, pdn->devfn, 0); in rtas_query_irq_number()
102 buid = pdn->phb->buid; in rtas_query_irq_number()
128 return -ENOENT; in check_req()
136 return -ENOSPC; in check_req()
151 return check_req(pdev, nvec, "ibm,req#msi-x"); in check_req_msix()
163 p = of_get_property(dn, "ibm,pe-total-#msi", NULL); in __find_pe_total_msi()
195 if (edev->pe) in find_pe_dn()
196 edev = list_first_entry(&edev->pe->edevs, struct eeh_dev, in find_pe_dn()
198 dn = pci_device_to_OF_node(edev->pdev); in find_pe_dn()
231 p = of_get_property(dn, "class-code", NULL); in count_non_bridge_devices()
235 counts->num_devices++; in count_non_bridge_devices()
246 if (dn == counts->requestor) in count_spare_msis()
247 req = counts->request; in count_spare_msis()
249 /* We don't know if a driver will try to use MSI or MSI-X, in count_spare_msis()
256 p = of_get_property(dn, "ibm,req#msi-x", NULL); in count_spare_msis()
261 if (req < counts->quota) in count_spare_msis()
262 counts->spare += counts->quota - req; in count_spare_msis()
263 else if (req > counts->quota) in count_spare_msis()
264 counts->over_quota++; in count_spare_msis()
313 /* Divide any spare by the number of over-quota requestors */ in msi_quota_for_device()
333 * fact that we using RTAS for MSIs, we don't have the 32 bit MSI RTAS in rtas_hack_32bit_msi_gen2()
336 dev_info(&pdev->dev, in rtas_hack_32bit_msi_gen2()
338 pci_read_config_dword(pdev, pdev->msi_cap + PCI_MSI_ADDRESS_HI, &addr_hi); in rtas_hack_32bit_msi_gen2()
339 addr_lo = 0xffff0000 | ((addr_hi >> (48 - 32)) << 4); in rtas_hack_32bit_msi_gen2()
340 pci_write_config_dword(pdev, pdev->msi_cap + PCI_MSI_ADDRESS_LO, addr_lo); in rtas_hack_32bit_msi_gen2()
341 pci_write_config_dword(pdev, pdev->msi_cap + PCI_MSI_ADDRESS_HI, 0); in rtas_hack_32bit_msi_gen2()
382 * return MSI-Xs. in rtas_prepare_msi_irqs()
386 if (pdev->no_64bit_msi) { in rtas_prepare_msi_irqs()
393 if (pdev->bus->max_bus_speed != PCIE_SPEED_5_0GT) in rtas_prepare_msi_irqs()
399 rc = -1; in rtas_prepare_msi_irqs()
412 if (pdev->no_64bit_msi) in rtas_prepare_msi_irqs()
434 int type = pdev->msix_enabled ? PCI_CAP_ID_MSIX : PCI_CAP_ID_MSI; in pseries_msi_ops_prepare()
440 * ->msi_free() is called before irq_domain_free_irqs_top() when the
453 * RTAS can not disable one MSI at a time. It's all or nothing. Do it
472 d = d->parent_data; in pseries_msi_shutdown()
473 if (d->chip->irq_shutdown) in pseries_msi_shutdown()
474 d->chip->irq_shutdown(d); in pseries_msi_shutdown()
495 * because the table is initialized by the underlying hypervisor, PowerVM in pseries_msi_write_msg()
498 * deactivate an IRQ used for testing MSI support. in pseries_msi_write_msg()
500 entry->msg = *msg; in pseries_msi_write_msg()
504 .name = "pSeries-PCI-MSI",
515 * firmware to request a discontiguous or non-zero based range of
516 * MSI-X entries. Core code will reject such setup attempts.
532 .name = "pSeries-MSI",
547 parent_fwspec.fwnode = domain->parent->fwnode; in pseries_irq_parent_domain_alloc()
562 struct pci_controller *phb = domain->host_data; in pseries_irq_domain_alloc()
564 struct msi_desc *desc = info->desc; in pseries_irq_domain_alloc()
569 hwirq = rtas_query_irq_number(pci_get_pdn(pdev), desc->msi_index); in pseries_irq_domain_alloc()
571 dev_err(&pdev->dev, "Failed to query HW IRQ: %d\n", hwirq); in pseries_irq_domain_alloc()
575 dev_dbg(&pdev->dev, "%s bridge %pOF %d/%x #%d\n", __func__, in pseries_irq_domain_alloc()
576 phb->dn, virq, hwirq, nr_irqs); in pseries_irq_domain_alloc()
584 &pseries_msi_irq_chip, domain->host_data); in pseries_irq_domain_alloc()
590 /* TODO: handle RTAS cleanup in ->msi_finish() ? */ in pseries_irq_domain_alloc()
591 irq_domain_free_irqs_parent(domain, virq, i - 1); in pseries_irq_domain_alloc()
601 pr_debug("%s bridge %pOF %d #%d\n", __func__, phb->dn, virq, nr_irqs); in pseries_irq_domain_free()
603 /* XIVE domain data is cleared through ->msi_free() */ in pseries_irq_domain_free()
616 phb->fwnode = irq_domain_alloc_named_id_fwnode("pSeries-MSI", in __pseries_msi_allocate_domains()
617 phb->global_number); in __pseries_msi_allocate_domains()
618 if (!phb->fwnode) in __pseries_msi_allocate_domains()
619 return -ENOMEM; in __pseries_msi_allocate_domains()
621 phb->dev_domain = irq_domain_create_hierarchy(parent, 0, count, in __pseries_msi_allocate_domains()
622 phb->fwnode, in __pseries_msi_allocate_domains()
624 if (!phb->dev_domain) { in __pseries_msi_allocate_domains()
626 phb->dn, phb->global_number); in __pseries_msi_allocate_domains()
627 irq_domain_free_fwnode(phb->fwnode); in __pseries_msi_allocate_domains()
628 return -ENOMEM; in __pseries_msi_allocate_domains()
631 phb->msi_domain = pci_msi_create_irq_domain(of_node_to_fwnode(phb->dn), in __pseries_msi_allocate_domains()
633 phb->dev_domain); in __pseries_msi_allocate_domains()
634 if (!phb->msi_domain) { in __pseries_msi_allocate_domains()
636 phb->dn, phb->global_number); in __pseries_msi_allocate_domains()
637 irq_domain_free_fwnode(phb->fwnode); in __pseries_msi_allocate_domains()
638 irq_domain_remove(phb->dev_domain); in __pseries_msi_allocate_domains()
639 return -ENOMEM; in __pseries_msi_allocate_domains()
649 if (!__find_pe_total_msi(phb->dn, &count)) { in pseries_msi_allocate_domains()
651 phb->dn, phb->global_number); in pseries_msi_allocate_domains()
652 return -ENOSPC; in pseries_msi_allocate_domains()
660 if (phb->msi_domain) in pseries_msi_free_domains()
661 irq_domain_remove(phb->msi_domain); in pseries_msi_free_domains()
662 if (phb->dev_domain) in pseries_msi_free_domains()
663 irq_domain_remove(phb->dev_domain); in pseries_msi_free_domains()
664 if (phb->fwnode) in pseries_msi_free_domains()
665 irq_domain_free_fwnode(phb->fwnode); in pseries_msi_free_domains()
670 /* No LSI -> leave MSIs (if any) configured */ in rtas_msi_pci_irq_fixup()
671 if (!pdev->irq) { in rtas_msi_pci_irq_fixup()
672 dev_dbg(&pdev->dev, "rtas_msi: no LSI, nothing to do.\n"); in rtas_msi_pci_irq_fixup()
676 /* No MSI -> MSIs can't have been assigned by fw, leave LSI */ in rtas_msi_pci_irq_fixup()
678 dev_dbg(&pdev->dev, "rtas_msi: no req#msi/x, nothing to do.\n"); in rtas_msi_pci_irq_fixup()
682 dev_dbg(&pdev->dev, "rtas_msi: disabling existing MSI.\n"); in rtas_msi_pci_irq_fixup()
693 pr_debug("rtas_msi: no RTAS tokens, no MSI support.\n"); in rtas_msi_init()
694 return -1; in rtas_msi_init()
697 pr_debug("rtas_msi: Registering RTAS MSI callbacks.\n"); in rtas_msi_init()