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.
13 #include <asm/rtas.h>
15 #include <asm/ppc-pci.h>
31 /* RTAS Helpers */
39 addr = rtas_config_addr(pdn->busno, pdn->devfn, 0); in rtas_change_msi()
40 buid = pdn->phb->buid; in rtas_change_msi()
58 * If the RTAS call succeeded, return the number of irqs allocated. in rtas_change_msi()
64 rc = -rc; in rtas_change_msi()
81 * disabling MSI with the explicit interface also disables MSI-X in rtas_disable_msi()
100 addr = rtas_config_addr(pdn->busno, pdn->devfn, 0); in rtas_query_irq_number()
101 buid = pdn->phb->buid; in rtas_query_irq_number()
127 return -ENOENT; in check_req()
135 return -ENOSPC; in check_req()
150 return check_req(pdev, nvec, "ibm,req#msi-x"); in check_req_msix()
162 p = of_get_property(dn, "ibm,pe-total-#msi", NULL); in __find_pe_total_msi()
194 if (edev->pe) in find_pe_dn()
195 edev = list_first_entry(&edev->pe->edevs, struct eeh_dev, in find_pe_dn()
197 dn = pci_device_to_OF_node(edev->pdev); in find_pe_dn()
230 p = of_get_property(dn, "class-code", NULL); in count_non_bridge_devices()
234 counts->num_devices++; in count_non_bridge_devices()
245 if (dn == counts->requestor) in count_spare_msis()
246 req = counts->request; in count_spare_msis()
248 /* We don't know if a driver will try to use MSI or MSI-X, in count_spare_msis()
255 p = of_get_property(dn, "ibm,req#msi-x", NULL); in count_spare_msis()
260 if (req < counts->quota) in count_spare_msis()
261 counts->spare += counts->quota - req; in count_spare_msis()
262 else if (req > counts->quota) in count_spare_msis()
263 counts->over_quota++; in count_spare_msis()
312 /* Divide any spare by the number of over-quota requestors */ in msi_quota_for_device()
332 * fact that we using RTAS for MSIs, we don't have the 32 bit MSI RTAS in rtas_hack_32bit_msi_gen2()
335 dev_info(&pdev->dev, in rtas_hack_32bit_msi_gen2()
337 pci_read_config_dword(pdev, pdev->msi_cap + PCI_MSI_ADDRESS_HI, &addr_hi); in rtas_hack_32bit_msi_gen2()
338 addr_lo = 0xffff0000 | ((addr_hi >> (48 - 32)) << 4); in rtas_hack_32bit_msi_gen2()
339 pci_write_config_dword(pdev, pdev->msi_cap + PCI_MSI_ADDRESS_LO, addr_lo); in rtas_hack_32bit_msi_gen2()
340 pci_write_config_dword(pdev, pdev->msi_cap + PCI_MSI_ADDRESS_HI, 0); in rtas_hack_32bit_msi_gen2()
381 * return MSI-Xs. in rtas_prepare_msi_irqs()
385 if (pdev->no_64bit_msi) { in rtas_prepare_msi_irqs()
392 if (pdev->bus->max_bus_speed != PCIE_SPEED_5_0GT) in rtas_prepare_msi_irqs()
398 rc = -1; in rtas_prepare_msi_irqs()
411 if (pdev->no_64bit_msi) in rtas_prepare_msi_irqs()
433 int type = pdev->msix_enabled ? PCI_CAP_ID_MSIX : PCI_CAP_ID_MSI; in pseries_msi_ops_prepare()
439 * ->msi_free() is called before irq_domain_free_irqs_top() when the
452 * RTAS can not disable one MSI at a time. It's all or nothing. Do it
471 d = d->parent_data; in pseries_msi_shutdown()
472 if (d->chip->irq_shutdown) in pseries_msi_shutdown()
473 d->chip->irq_shutdown(d); in pseries_msi_shutdown()
494 * because the table is initialized by the underlying hypervisor, PowerVM in pseries_msi_write_msg()
497 * deactivate an IRQ used for testing MSI support. in pseries_msi_write_msg()
499 entry->msg = *msg; in pseries_msi_write_msg()
503 .name = "pSeries-PCI-MSI",
514 * firmware to request a discontiguous or non-zero based range of
515 * MSI-X entries. Core code will reject such setup attempts.
531 .name = "pSeries-MSI",
546 parent_fwspec.fwnode = domain->parent->fwnode; in pseries_irq_parent_domain_alloc()
561 struct pci_controller *phb = domain->host_data; in pseries_irq_domain_alloc()
563 struct msi_desc *desc = info->desc; in pseries_irq_domain_alloc()
568 hwirq = rtas_query_irq_number(pci_get_pdn(pdev), desc->msi_index); in pseries_irq_domain_alloc()
570 dev_err(&pdev->dev, "Failed to query HW IRQ: %d\n", hwirq); in pseries_irq_domain_alloc()
574 dev_dbg(&pdev->dev, "%s bridge %pOF %d/%x #%d\n", __func__, in pseries_irq_domain_alloc()
575 phb->dn, virq, hwirq, nr_irqs); in pseries_irq_domain_alloc()
583 &pseries_msi_irq_chip, domain->host_data); in pseries_irq_domain_alloc()
589 /* TODO: handle RTAS cleanup in ->msi_finish() ? */ in pseries_irq_domain_alloc()
590 irq_domain_free_irqs_parent(domain, virq, i - 1); in pseries_irq_domain_alloc()
600 pr_debug("%s bridge %pOF %d #%d\n", __func__, phb->dn, virq, nr_irqs); in pseries_irq_domain_free()
602 /* XIVE domain data is cleared through ->msi_free() */ in pseries_irq_domain_free()
615 phb->fwnode = irq_domain_alloc_named_id_fwnode("pSeries-MSI", in __pseries_msi_allocate_domains()
616 phb->global_number); in __pseries_msi_allocate_domains()
617 if (!phb->fwnode) in __pseries_msi_allocate_domains()
618 return -ENOMEM; in __pseries_msi_allocate_domains()
620 phb->dev_domain = irq_domain_create_hierarchy(parent, 0, count, in __pseries_msi_allocate_domains()
621 phb->fwnode, in __pseries_msi_allocate_domains()
623 if (!phb->dev_domain) { in __pseries_msi_allocate_domains()
625 phb->dn, phb->global_number); in __pseries_msi_allocate_domains()
626 irq_domain_free_fwnode(phb->fwnode); in __pseries_msi_allocate_domains()
627 return -ENOMEM; in __pseries_msi_allocate_domains()
630 phb->msi_domain = pci_msi_create_irq_domain(of_node_to_fwnode(phb->dn), in __pseries_msi_allocate_domains()
632 phb->dev_domain); in __pseries_msi_allocate_domains()
633 if (!phb->msi_domain) { in __pseries_msi_allocate_domains()
635 phb->dn, phb->global_number); in __pseries_msi_allocate_domains()
636 irq_domain_free_fwnode(phb->fwnode); in __pseries_msi_allocate_domains()
637 irq_domain_remove(phb->dev_domain); in __pseries_msi_allocate_domains()
638 return -ENOMEM; in __pseries_msi_allocate_domains()
648 if (!__find_pe_total_msi(phb->dn, &count)) { in pseries_msi_allocate_domains()
650 phb->dn, phb->global_number); in pseries_msi_allocate_domains()
651 return -ENOSPC; in pseries_msi_allocate_domains()
659 if (phb->msi_domain) in pseries_msi_free_domains()
660 irq_domain_remove(phb->msi_domain); in pseries_msi_free_domains()
661 if (phb->dev_domain) in pseries_msi_free_domains()
662 irq_domain_remove(phb->dev_domain); in pseries_msi_free_domains()
663 if (phb->fwnode) in pseries_msi_free_domains()
664 irq_domain_free_fwnode(phb->fwnode); in pseries_msi_free_domains()
669 /* No LSI -> leave MSIs (if any) configured */ in rtas_msi_pci_irq_fixup()
670 if (!pdev->irq) { in rtas_msi_pci_irq_fixup()
671 dev_dbg(&pdev->dev, "rtas_msi: no LSI, nothing to do.\n"); in rtas_msi_pci_irq_fixup()
675 /* No MSI -> MSIs can't have been assigned by fw, leave LSI */ in rtas_msi_pci_irq_fixup()
677 dev_dbg(&pdev->dev, "rtas_msi: no req#msi/x, nothing to do.\n"); in rtas_msi_pci_irq_fixup()
681 dev_dbg(&pdev->dev, "rtas_msi: disabling existing MSI.\n"); in rtas_msi_pci_irq_fixup()
692 pr_debug("rtas_msi: no RTAS tokens, no MSI support.\n"); in rtas_msi_init()
693 return -1; in rtas_msi_init()
696 pr_debug("rtas_msi: Registering RTAS MSI callbacks.\n"); in rtas_msi_init()