/* * We do not need this actually. The MSIR register has been read once * in the cascade interrupt. So, this MSI interrupt has been acked
*/ staticvoid fsl_msi_end_irq(struct irq_data *d)
{
}
staticint fsl_msi_init_allocator(struct fsl_msi *msi_data)
{ int rc, hwirq;
rc = msi_bitmap_alloc(&msi_data->bitmap, NR_MSI_IRQS_MAX,
irq_domain_get_of_node(msi_data->irqhost)); if (rc) return rc;
/* * Reserve all the hwirqs * The available hwirqs will be released in fsl_msi_setup_hwirq()
*/ for (hwirq = 0; hwirq < NR_MSI_IRQS_MAX; hwirq++)
msi_bitmap_reserve_hwirq(&msi_data->bitmap, hwirq);
staticvoid fsl_compose_msi_msg(struct pci_dev *pdev, int hwirq, struct msi_msg *msg, struct fsl_msi *fsl_msi_data)
{ struct fsl_msi *msi_data = fsl_msi_data; struct pci_controller *hose = pci_bus_to_host(pdev->bus);
u64 address; /* Physical address of the MSIIR */ int len; const __be64 *reg;
/* If the msi-address-64 property exists, then use it */
reg = of_get_property(hose->dn, "msi-address-64", &len); if (reg && (len == sizeof(u64)))
address = be64_to_cpup(reg); else
address = fsl_pci_immrbar_base(hose) + msi_data->msiir_offset;
/* * MPIC version 2.0 has erratum PIC1. It causes * that neither MSI nor MSI-X can work fine. * This is a workaround to allow MSI-X to function * properly. It only works for MSI-X, we prevent * MSI on buggy chips in fsl_setup_msi_irqs().
*/ if (msi_data->feature & MSI_HW_ERRATA_ENDIAN)
msg->data = __swab32(hwirq); else
msg->data = hwirq;
if (type == PCI_CAP_ID_MSI) { /* * MPIC version 2.0 has erratum PIC1. For now MSI * could not work. So check to prevent MSI from * being used on the board with this erratum.
*/
list_for_each_entry(msi_data, &msi_head, list) if (msi_data->feature & MSI_HW_ERRATA_ENDIAN) return -EINVAL;
}
/* * If the PCI node has an fsl,msi property, then we need to use it * to find the specific MSI.
*/
np = of_parse_phandle(hose->dn, "fsl,msi", 0); if (np) { if (of_device_is_compatible(np, "fsl,mpic-msi") ||
of_device_is_compatible(np, "fsl,vmpic-msi") ||
of_device_is_compatible(np, "fsl,vmpic-msi-v4.3"))
phandle = np->phandle; else {
dev_err(&pdev->dev, "node %pOF has an invalid fsl,msi phandle %u\n",
hose->dn, np->phandle);
of_node_put(np); return -EINVAL;
}
of_node_put(np);
}
msi_for_each_desc(entry, &pdev->dev, MSI_DESC_NOTASSOCIATED) { /* * Loop over all the MSI devices until we find one that has an * available interrupt.
*/
list_for_each_entry(msi_data, &msi_head, list) { /* * If the PCI node has an fsl,msi property, then we * restrict our search to the corresponding MSI node. * The simplest way is to skip over MSI nodes with the * wrong phandle. Under the Freescale hypervisor, this * has the additional benefit of skipping over MSI * nodes that are not mapped in the PAMU.
*/ if (phandle && (phandle != msi_data->phandle)) continue;
hwirq = msi_bitmap_alloc_hwirqs(&msi_data->bitmap, 1); if (hwirq >= 0) break;
}
if (hwirq < 0) {
rc = hwirq;
dev_err(&pdev->dev, "could not allocate MSI interrupt\n"); goto out_free;
}
if (msi->list.prev != NULL)
list_del(&msi->list); for (i = 0; i < NR_MSI_REG_MAX; i++) { if (msi->cascade_array[i]) {
virq = msi->cascade_array[i]->virq;
BUG_ON(!virq);
free_irq(virq, msi->cascade_array[i]);
kfree(msi->cascade_array[i]);
irq_dispose_mapping(virq);
}
} if (msi->bitmap.bitmap)
msi_bitmap_free(&msi->bitmap); if ((msi->feature & FSL_PIC_IP_MASK) != FSL_PIC_IP_VMPIC)
iounmap(msi->msi_regs);
kfree(msi);
}
ret = request_irq(virt_msir, fsl_msi_cascade, IRQF_NO_THREAD, "fsl-msi-cascade", cascade_data); if (ret) {
dev_err(&dev->dev, "failed to request_irq(%d), ret = %d\n",
virt_msir, ret); return ret;
}
/* Release the hwirqs corresponding to this MSI register */ for (i = 0; i < IRQS_PER_MSI_REG; i++)
msi_bitmap_free_hwirqs(&msi->bitmap,
msi_hwirq(msi, offset, i), 1);
printk(KERN_DEBUG "Setting up Freescale MSI support\n");
msi = kzalloc(sizeof(struct fsl_msi), GFP_KERNEL); if (!msi) {
dev_err(&dev->dev, "No memory for MSI structure\n"); return -ENOMEM;
}
platform_set_drvdata(dev, msi);
msi->irqhost = irq_domain_create_linear(dev_fwnode(&dev->dev), NR_MSI_IRQS_MAX,
&fsl_msi_host_ops, msi); if (msi->irqhost == NULL) {
dev_err(&dev->dev, "No memory for MSI irqhost\n");
err = -ENOMEM; goto error_out;
}
/* * Under the Freescale hypervisor, the msi nodes don't have a 'reg' * property. Instead, we use hypercalls to access the MSI.
*/ if ((features->fsl_pic_ip & FSL_PIC_IP_MASK) != FSL_PIC_IP_VMPIC) {
err = of_address_to_resource(dev->dev.of_node, 0, &res); if (err) {
dev_err(&dev->dev, "invalid resource for node %pOF\n",
dev->dev.of_node); goto error_out;
}
/* * Apply the MSI ops to all the controllers. * It doesn't hurt to reassign the same ops, * but bail out if we find another MSI driver.
*/
list_for_each_entry(phb, &hose_list, list_node) { if (!phb->controller_ops.setup_msi_irqs) {
phb->controller_ops.setup_msi_irqs = fsl_setup_msi_irqs;
phb->controller_ops.teardown_msi_irqs = fsl_teardown_msi_irqs;
} elseif (phb->controller_ops.setup_msi_irqs != fsl_setup_msi_irqs) {
dev_err(&dev->dev, "Different MSI driver already installed!\n");
err = -ENODEV; goto error_out;
}
} return 0;
error_out:
fsl_of_msi_remove(dev); return err;
}
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.