Lines Matching +full:msi +full:- +full:x
1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright 2006-2007 Michael Ellerman, IBM Corp.
11 #include <linux/msi.h>
15 #include <asm/ppc-pci.h>
38 addr = rtas_config_addr(pdn->busno, pdn->devfn, 0); in rtas_change_msi()
39 buid = pdn->phb->buid; in rtas_change_msi()
63 rc = -rc; in rtas_change_msi()
80 * disabling MSI with the explicit interface also disables MSI-X in rtas_disable_msi()
99 addr = rtas_config_addr(pdn->busno, pdn->devfn, 0); in rtas_query_irq_number()
100 buid = pdn->phb->buid; in rtas_query_irq_number()
126 return -ENOENT; in check_req()
134 return -ENOSPC; in check_req()
144 return check_req(pdev, nvec, "ibm,req#msi"); in check_req_msi()
149 return check_req(pdev, nvec, "ibm,req#msi-x"); in check_req_msix()
161 p = of_get_property(dn, "ibm,pe-total-#msi", NULL); in __find_pe_total_msi()
193 if (edev->pe) in find_pe_dn()
194 edev = list_first_entry(&edev->pe->edevs, struct eeh_dev, in find_pe_dn()
196 dn = pci_device_to_OF_node(edev->pdev); in find_pe_dn()
229 p = of_get_property(dn, "class-code", NULL); in count_non_bridge_devices()
233 counts->num_devices++; in count_non_bridge_devices()
244 if (dn == counts->requestor) in count_spare_msis()
245 req = counts->request; in count_spare_msis()
247 /* We don't know if a driver will try to use MSI or MSI-X, in count_spare_msis()
250 p = of_get_property(dn, "ibm,req#msi", NULL); in count_spare_msis()
254 p = of_get_property(dn, "ibm,req#msi-x", NULL); in count_spare_msis()
259 if (req < counts->quota) in count_spare_msis()
260 counts->spare += counts->quota - req; in count_spare_msis()
261 else if (req > counts->quota) in count_spare_msis()
262 counts->over_quota++; in count_spare_msis()
311 /* Divide any spare by the number of over-quota requestors */ in msi_quota_for_device()
331 * fact that we using RTAS for MSIs, we don't have the 32 bit MSI RTAS in rtas_hack_32bit_msi_gen2()
334 dev_info(&pdev->dev, in rtas_hack_32bit_msi_gen2()
335 "rtas_msi: No 32 bit MSI firmware support, forcing 32 bit MSI\n"); in rtas_hack_32bit_msi_gen2()
336 pci_read_config_dword(pdev, pdev->msi_cap + PCI_MSI_ADDRESS_HI, &addr_hi); in rtas_hack_32bit_msi_gen2()
337 addr_lo = 0xffff0000 | ((addr_hi >> (48 - 32)) << 4); in rtas_hack_32bit_msi_gen2()
338 pci_write_config_dword(pdev, pdev->msi_cap + PCI_MSI_ADDRESS_LO, addr_lo); in rtas_hack_32bit_msi_gen2()
339 pci_write_config_dword(pdev, pdev->msi_cap + PCI_MSI_ADDRESS_HI, 0); in rtas_hack_32bit_msi_gen2()
380 * return MSI-Xs. in rtas_prepare_msi_irqs()
384 if (pdev->no_64bit_msi) { in rtas_prepare_msi_irqs()
388 * We only want to run the 32 bit MSI hack below if in rtas_prepare_msi_irqs()
391 if (pdev->bus->max_bus_speed != PCIE_SPEED_5_0GT) in rtas_prepare_msi_irqs()
397 rc = -1; in rtas_prepare_msi_irqs()
428 int type = pdev->msix_enabled ? PCI_CAP_ID_MSIX : PCI_CAP_ID_MSI; in pseries_msi_ops_prepare()
434 * ->msi_free() is called before irq_domain_free_irqs_top() when the
447 * RTAS can not disable one MSI at a time. It's all or nothing. Do it
469 d = d->parent_data; in pseries_msi_shutdown()
470 if (d->chip->irq_shutdown) in pseries_msi_shutdown()
471 d->chip->irq_shutdown(d); in pseries_msi_shutdown()
495 * deactivate an IRQ used for testing MSI support. in pseries_msi_write_msg()
497 entry->msg = *msg; in pseries_msi_write_msg()
501 .name = "pSeries-PCI-MSI",
512 * firmware to request a discontiguous or non-zero based range of
513 * MSI-X entries. Core code will reject such setup attempts.
529 .name = "pSeries-MSI",
544 parent_fwspec.fwnode = domain->parent->fwnode; in pseries_irq_parent_domain_alloc()
559 struct pci_controller *phb = domain->host_data; in pseries_irq_domain_alloc()
561 struct msi_desc *desc = info->desc; in pseries_irq_domain_alloc()
566 hwirq = rtas_query_irq_number(pci_get_pdn(pdev), desc->msi_index); in pseries_irq_domain_alloc()
568 dev_err(&pdev->dev, "Failed to query HW IRQ: %d\n", hwirq); in pseries_irq_domain_alloc()
572 dev_dbg(&pdev->dev, "%s bridge %pOF %d/%x #%d\n", __func__, in pseries_irq_domain_alloc()
573 phb->dn, virq, hwirq, nr_irqs); in pseries_irq_domain_alloc()
581 &pseries_msi_irq_chip, domain->host_data); in pseries_irq_domain_alloc()
587 /* TODO: handle RTAS cleanup in ->msi_finish() ? */ in pseries_irq_domain_alloc()
588 irq_domain_free_irqs_parent(domain, virq, i - 1); in pseries_irq_domain_alloc()
598 pr_debug("%s bridge %pOF %d #%d\n", __func__, phb->dn, virq, nr_irqs); in pseries_irq_domain_free()
600 /* XIVE domain data is cleared through ->msi_free() */ in pseries_irq_domain_free()
613 phb->fwnode = irq_domain_alloc_named_id_fwnode("pSeries-MSI", in __pseries_msi_allocate_domains()
614 phb->global_number); in __pseries_msi_allocate_domains()
615 if (!phb->fwnode) in __pseries_msi_allocate_domains()
616 return -ENOMEM; in __pseries_msi_allocate_domains()
618 phb->dev_domain = irq_domain_create_hierarchy(parent, 0, count, in __pseries_msi_allocate_domains()
619 phb->fwnode, in __pseries_msi_allocate_domains()
621 if (!phb->dev_domain) { in __pseries_msi_allocate_domains()
623 phb->dn, phb->global_number); in __pseries_msi_allocate_domains()
624 irq_domain_free_fwnode(phb->fwnode); in __pseries_msi_allocate_domains()
625 return -ENOMEM; in __pseries_msi_allocate_domains()
628 phb->msi_domain = pci_msi_create_irq_domain(of_node_to_fwnode(phb->dn), in __pseries_msi_allocate_domains()
630 phb->dev_domain); in __pseries_msi_allocate_domains()
631 if (!phb->msi_domain) { in __pseries_msi_allocate_domains()
632 pr_err("PCI: failed to create MSI IRQ domain bridge %pOF (domain %d)\n", in __pseries_msi_allocate_domains()
633 phb->dn, phb->global_number); in __pseries_msi_allocate_domains()
634 irq_domain_free_fwnode(phb->fwnode); in __pseries_msi_allocate_domains()
635 irq_domain_remove(phb->dev_domain); in __pseries_msi_allocate_domains()
636 return -ENOMEM; in __pseries_msi_allocate_domains()
646 if (!__find_pe_total_msi(phb->dn, &count)) { in pseries_msi_allocate_domains()
648 phb->dn, phb->global_number); in pseries_msi_allocate_domains()
649 return -ENOSPC; in pseries_msi_allocate_domains()
657 if (phb->msi_domain) in pseries_msi_free_domains()
658 irq_domain_remove(phb->msi_domain); in pseries_msi_free_domains()
659 if (phb->dev_domain) in pseries_msi_free_domains()
660 irq_domain_remove(phb->dev_domain); in pseries_msi_free_domains()
661 if (phb->fwnode) in pseries_msi_free_domains()
662 irq_domain_free_fwnode(phb->fwnode); in pseries_msi_free_domains()
667 /* No LSI -> leave MSIs (if any) configured */ in rtas_msi_pci_irq_fixup()
668 if (!pdev->irq) { in rtas_msi_pci_irq_fixup()
669 dev_dbg(&pdev->dev, "rtas_msi: no LSI, nothing to do.\n"); in rtas_msi_pci_irq_fixup()
673 /* No MSI -> MSIs can't have been assigned by fw, leave LSI */ in rtas_msi_pci_irq_fixup()
675 dev_dbg(&pdev->dev, "rtas_msi: no req#msi/x, nothing to do.\n"); in rtas_msi_pci_irq_fixup()
679 dev_dbg(&pdev->dev, "rtas_msi: disabling existing MSI.\n"); in rtas_msi_pci_irq_fixup()
685 query_token = rtas_token("ibm,query-interrupt-source-number"); in rtas_msi_init()
686 change_token = rtas_token("ibm,change-msi"); in rtas_msi_init()
690 pr_debug("rtas_msi: no RTAS tokens, no MSI support.\n"); in rtas_msi_init()
691 return -1; in rtas_msi_init()
694 pr_debug("rtas_msi: Registering RTAS MSI callbacks.\n"); in rtas_msi_init()