if (num_possible_nodes() > 1 && dev_to_node(&pdev->dev) < 0) { /* * If the accelerator is connected to a node with no memory * there is no point in using the accelerator since the remote * memory transaction will be very slow.
*/
dev_err(&pdev->dev, "Invalid NUMA configuration.\n"); return -EINVAL;
}
accel_dev = devm_kzalloc(&pdev->dev, sizeof(*accel_dev), GFP_KERNEL); if (!accel_dev) return -ENOMEM;
/* * Add accel device to accel table * This should be called before adf_cleanup_accel is called
*/ if (adf_devmgr_add_dev(accel_dev, NULL)) {
dev_err(&pdev->dev, "Failed to add new accelerator device.\n"); return -EFAULT;
}
accel_dev->owner = THIS_MODULE; /* Allocate and initialise device hardware meta-data structure */
hw_data = devm_kzalloc(&pdev->dev, sizeof(*hw_data), GFP_KERNEL); if (!hw_data) {
ret = -ENOMEM; goto out_err;
}
/* Get Accelerators and Accelerators Engines masks */
hw_data->accel_mask = hw_data->get_accel_mask(hw_data);
hw_data->ae_mask = hw_data->get_ae_mask(hw_data);
accel_pci_dev->sku = hw_data->get_sku(hw_data); /* If the device has no acceleration engines then ignore it */ if (!hw_data->accel_mask || !hw_data->ae_mask ||
(~hw_data->ae_mask & 0x01)) {
dev_err(&pdev->dev, "No acceleration units found.\n");
ret = -EFAULT; goto out_err;
}
/* Create device configuration table */
ret = adf_cfg_dev_add(accel_dev); if (ret) goto out_err;
/* Enable PCI device */
ret = pcim_enable_device(pdev); if (ret) {
dev_err(&pdev->dev, "Can't enable PCI device.\n"); goto out_err;
}
/* Set DMA identifier */
ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); if (ret) {
dev_err(&pdev->dev, "No usable DMA configuration.\n"); goto out_err;
}
ret = adf_gen4_cfg_dev_init(accel_dev); if (ret) {
dev_err(&pdev->dev, "Failed to initialize configuration.\n"); goto out_err;
}
/* Get accelerator capabilities mask */
hw_data->accel_capabilities_mask = hw_data->get_accel_cap(accel_dev); if (!hw_data->accel_capabilities_mask) {
dev_err(&pdev->dev, "Failed to get capabilities mask.\n");
ret = -EINVAL; goto out_err;
}
/* Find and map all the device's BARS */
bar_mask = pci_select_bars(pdev, IORESOURCE_MEM) & ADF_GEN4_BAR_MASK;
ret = pcim_request_all_regions(pdev, pci_name(pdev)); if (ret) {
dev_err(&pdev->dev, "Failed to request PCI regions.\n"); goto out_err;
}
i = 0;
for_each_set_bit(bar_nr, &bar_mask, PCI_STD_NUM_BARS) {
bar = &accel_pci_dev->pci_bars[i++];
bar->virt_addr = pcim_iomap(pdev, bar_nr, 0); if (!bar->virt_addr) {
dev_err(&pdev->dev, "Failed to ioremap PCI region.\n");
ret = -ENOMEM; goto out_err;
}
}
pci_set_master(pdev);
if (pci_save_state(pdev)) {
dev_err(&pdev->dev, "Failed to save pci state.\n");
ret = -ENOMEM; goto out_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.