/** * hl_pci_bars_map() - Map PCI BARs. * @hdev: Pointer to hl_device structure. * @name: Array of BAR names. * @is_wc: Array with flag per BAR whether a write-combined mapping is needed. * * Request PCI regions and map them to kernel virtual addresses. * * Return: 0 on success, non-zero for failure.
*/ int hl_pci_bars_map(struct hl_device *hdev, constchar * const name[3], bool is_wc[3])
{ struct pci_dev *pdev = hdev->pdev; int rc, i, bar;
timeout = ktime_add_ms(ktime_get(), msec); for (;;) {
pci_read_config_dword(pdev, mmPCI_CONFIG_ELBI_STS, &val); if (val & PCI_CONFIG_ELBI_STS_MASK) break; if (ktime_compare(ktime_get(), timeout) > 0) {
pci_read_config_dword(pdev, mmPCI_CONFIG_ELBI_STS,
&val); break;
}
usleep_range(300, 500);
}
if ((val & PCI_CONFIG_ELBI_STS_MASK) == PCI_CONFIG_ELBI_STS_DONE) { if (unlikely(trace_habanalabs_elbi_write_enabled()))
trace_habanalabs_elbi_write(&hdev->pdev->dev, (u32) addr, val); return 0;
}
if (val & PCI_CONFIG_ELBI_STS_ERR) return -EIO;
if (!(val & PCI_CONFIG_ELBI_STS_MASK)) {
dev_err(hdev->dev, "ELBI write didn't finish in time\n"); return -EIO;
}
dev_err(hdev->dev, "ELBI write has undefined bits in status\n"); return -EIO;
}
/** * hl_pci_iatu_write() - iatu write routine. * @hdev: Pointer to hl_device structure. * @addr: Address to write to * @data: Data to write * * Return: 0 on success, negative value for failure.
*/ int hl_pci_iatu_write(struct hl_device *hdev, u32 addr, u32 data)
{ struct asic_fixed_properties *prop = &hdev->asic_prop;
u32 dbi_offset; int rc;
dbi_offset = addr & 0xFFF;
/* Ignore result of writing to pcie_aux_dbi_reg_addr as it could fail * in case the firmware security is enabled
*/
hl_pci_elbi_write(hdev, prop->pcie_aux_dbi_reg_addr, 0x00300000);
/* Return the DBI window to the default location * Ignore result of writing to pcie_aux_dbi_reg_addr as it could fail * in case the firmware security is enabled
*/
hl_pci_elbi_write(hdev, prop->pcie_aux_dbi_reg_addr, 0);
if (rc)
dev_err(hdev->dev, "failed to map bar %u to 0x%08llx\n",
pci_region->bar, pci_region->addr);
return rc;
}
/** * hl_pci_set_outbound_region() - Configure outbound region 0 * @hdev: Pointer to hl_device structure. * @pci_region: Outbound region parameters. * * Configure the iATU outbound region 0. * * Return: 0 on success, negative value for failure.
*/ int hl_pci_set_outbound_region(struct hl_device *hdev, struct hl_outbound_pci_region *pci_region)
{ struct asic_fixed_properties *prop = &hdev->asic_prop;
u64 outbound_region_end_address; int rc = 0;
/* Return the DBI window to the default location * Ignore result of writing to pcie_aux_dbi_reg_addr as it could fail * in case the firmware security is enabled
*/
hl_pci_elbi_write(hdev, prop->pcie_aux_dbi_reg_addr, 0);
return rc;
}
/** * hl_get_pci_memory_region() - get PCI region for given address * @hdev: Pointer to hl_device structure. * @addr: device address * * @return region index on success, otherwise PCI_REGION_NUMBER (invalid * region index)
*/ enum pci_region hl_get_pci_memory_region(struct hl_device *hdev, u64 addr)
{ int i;
for (i = 0 ; i < PCI_REGION_NUMBER ; i++) { struct pci_mem_region *region = &hdev->pci_mem_region[i];
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.