seq_num = rtas_ret[1];
} while (rtas_busy_delay(rc));
/* * If the RTAS call succeeded, return the number of irqs allocated. * If not, make sure we return a negative error code.
*/ if (rc == 0)
rc = rtas_ret[0]; elseif (rc > 0)
rc = -rc;
/* * disabling MSI with the explicit interface also disables MSI-X
*/ if (rtas_change_msi(pdn, RTAS_CHANGE_MSI_FN, 0) != 0) { /* * may have failed because explicit interface is not * present
*/ if (rtas_change_msi(pdn, RTAS_CHANGE_FN, 0) != 0) {
pr_debug("rtas_msi: Setting MSIs to 0 failed!\n");
}
}
}
staticint rtas_query_irq_number(struct pci_dn *pdn, int offset)
{
u32 addr, rtas_ret[2]; unsignedlong buid; int rc;
dn = pci_device_to_OF_node(dev); if (!dn) return NULL;
/* Get the top level device in the PE */
edev = pdn_to_eeh_dev(PCI_DN(dn)); if (edev->pe)
edev = list_first_entry(&edev->pe->edevs, struct eeh_dev,
entry);
dn = pci_device_to_OF_node(edev->pdev); if (!dn) return NULL;
/* We actually want the parent */
dn = of_get_parent(dn); if (!dn) return NULL;
/* Hardcode of 8 for old firmwares */
*total = 8;
pr_debug("rtas_msi: using PE dn %pOF\n", dn);
return dn;
}
struct msi_counts { struct device_node *requestor; int num_devices; int request; int quota; int spare; int over_quota;
};
if (dn == counts->requestor)
req = counts->request; else { /* We don't know if a driver will try to use MSI or MSI-X,
* so we just have to punt and use the larger of the two. */
req = 0;
p = of_get_property(dn, "ibm,req#msi", NULL); if (p)
req = be32_to_cpup(p);
p = of_get_property(dn, "ibm,req#msi-x", NULL); if (p)
req = max(req, (int)be32_to_cpup(p));
}
staticint msi_quota_for_device(struct pci_dev *dev, int request)
{ struct device_node *pe_dn; struct msi_counts counts; int total;
pr_debug("rtas_msi: calc quota for %s, request %d\n", pci_name(dev),
request);
pe_dn = find_pe_total_msi(dev, &total); if (!pe_dn)
pe_dn = find_pe_dn(dev, &total);
if (!pe_dn) {
pr_err("rtas_msi: couldn't find PE for %s\n", pci_name(dev)); goto out;
}
pr_debug("rtas_msi: found PE %pOF\n", pe_dn);
memset(&counts, 0, sizeof(struct msi_counts));
/* Work out how many devices we have below this PE */
pci_traverse_device_nodes(pe_dn, count_non_bridge_devices, &counts);
if (counts.num_devices == 0) {
pr_err("rtas_msi: found 0 devices under PE for %s\n",
pci_name(dev)); goto out;
}
counts.quota = total / counts.num_devices; if (request <= counts.quota) goto out;
/* else, we have some more calculating to do */
counts.requestor = pci_device_to_OF_node(dev);
counts.request = request;
pci_traverse_device_nodes(pe_dn, count_spare_msis, &counts);
/* If the quota isn't an integer multiple of the total, we can
* use the remainder as spare MSIs for anyone that wants them. */
counts.spare += total % counts.num_devices;
/* Divide any spare by the number of over-quota requestors */ if (counts.over_quota)
counts.quota += counts.spare / counts.over_quota;
/* And finally clamp the request to the possibly adjusted quota */
request = min(counts.quota, request);
pr_debug("rtas_msi: request clamped to quota %d\n", request);
out:
of_node_put(pe_dn);
/* * We should only get in here for IODA1 configs. This is based on the * fact that we using RTAS for MSIs, we don't have the 32 bit MSI RTAS * support, and we are in a PCIe Gen2 slot.
*/
dev_info(&pdev->dev, "rtas_msi: No 32 bit MSI firmware support, forcing 32 bit MSI\n");
pci_read_config_dword(pdev, pdev->msi_cap + PCI_MSI_ADDRESS_HI, &addr_hi);
addr_lo = 0xffff0000 | ((addr_hi >> (48 - 32)) << 4);
pci_write_config_dword(pdev, pdev->msi_cap + PCI_MSI_ADDRESS_LO, addr_lo);
pci_write_config_dword(pdev, pdev->msi_cap + PCI_MSI_ADDRESS_HI, 0);
}
staticint rtas_prepare_msi_irqs(struct pci_dev *pdev, int nvec_in, int type,
msi_alloc_info_t *arg)
{ struct pci_dn *pdn; int quota, rc; int nvec = nvec_in; int use_32bit_msi_hack = 0;
/* * Firmware currently refuse any non power of two allocation * so we round up if the quota will allow it.
*/ if (type == PCI_CAP_ID_MSIX) { int m = roundup_pow_of_two(nvec);
quota = msi_quota_for_device(pdev, m);
if (quota >= m)
nvec = m;
}
pdn = pci_get_pdn(pdev);
/* * Try the new more explicit firmware interface, if that fails fall * back to the old interface. The old interface is known to never * return MSI-Xs.
*/
again: if (type == PCI_CAP_ID_MSI) { if (pdev->no_64bit_msi) {
rc = rtas_change_msi(pdn, RTAS_CHANGE_32MSI_FN, nvec); if (rc < 0) { /* * We only want to run the 32 bit MSI hack below if * the max bus speed is Gen2 speed
*/ if (pdev->bus->max_bus_speed != PCIE_SPEED_5_0GT) return rc;
use_32bit_msi_hack = 1;
}
} else
rc = -1;
if (rc < 0)
rc = rtas_change_msi(pdn, RTAS_CHANGE_MSI_FN, nvec);
if (rc < 0) {
pr_debug("rtas_msi: trying the old firmware call.\n");
rc = rtas_change_msi(pdn, RTAS_CHANGE_FN, nvec);
}
/* * ->msi_free() is called before irq_domain_free_irqs_top() when the * handler data is still available. Use that to clear the XIVE * controller data.
*/ staticvoid pseries_msi_ops_msi_free(struct irq_domain *domain, struct msi_domain_info *info, unsignedint irq)
{ if (xive_enabled())
xive_irq_free_data(irq);
}
/* * RTAS can not disable one MSI at a time. It's all or nothing. Do it * at the end after all IRQs have been freed.
*/ staticvoid pseries_msi_post_free(struct irq_domain *domain, struct device *dev)
{ if (WARN_ON_ONCE(!dev_is_pci(dev))) return;
/* * Do not update the MSIx vector table. It's not strictly necessary * because the table is initialized by the underlying hypervisor, PowerVM * or QEMU/KVM. However, if the MSIx vector entry is cleared, any further * activation will fail. This can happen in some drivers (eg. IPR) which * deactivate an IRQ used for testing MSI support.
*/
entry->msg = *msg;
}
/* * Set MSI_FLAG_MSIX_CONTIGUOUS as there is no way to express to * firmware to request a discontiguous or non-zero based range of * MSI-X entries. Core code will reject such setup attempts.
*/ staticstruct msi_domain_info pseries_msi_domain_info = {
.flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS |
MSI_FLAG_MULTI_PCI_MSI | MSI_FLAG_PCI_MSIX |
MSI_FLAG_MSIX_CONTIGUOUS),
.ops = &pseries_pci_msi_domain_ops,
.chip = &pseries_pci_msi_irq_chip,
};
void pseries_msi_free_domains(struct pci_controller *phb)
{ if (phb->msi_domain)
irq_domain_remove(phb->msi_domain); if (phb->dev_domain)
irq_domain_remove(phb->dev_domain); if (phb->fwnode)
irq_domain_free_fwnode(phb->fwnode);
}
staticvoid rtas_msi_pci_irq_fixup(struct pci_dev *pdev)
{ /* No LSI -> leave MSIs (if any) configured */ if (!pdev->irq) {
dev_dbg(&pdev->dev, "rtas_msi: no LSI, nothing to do.\n"); return;
}
/* No MSI -> MSIs can't have been assigned by fw, leave LSI */ if (check_req_msi(pdev, 1) && check_req_msix(pdev, 1)) {
dev_dbg(&pdev->dev, "rtas_msi: no req#msi/x, nothing to do.\n"); return;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.