module_param(reset_on_lockup, int, 0444);
MODULE_PARM_DESC(reset_on_lockup, "Do device reset on lockup (0 = no, 1 = yes, default yes)");
module_param(memory_scrub, int, 0444);
MODULE_PARM_DESC(memory_scrub, "Scrub device memory in various states (0 = no, 1 = yes, default no)");
module_param(boot_error_status_mask, ulong, 0444);
MODULE_PARM_DESC(boot_error_status_mask, "Mask of the error status during device CPU boot (If bitX is cleared then error X is masked. Default all 1's)");
if (!hl_device_operational(hdev, &status)) {
dev_dbg_ratelimited(hdev->dev, "Can't open %s because it is %s\n",
dev_name(hdev->dev), hdev->status[status]);
if (status == HL_DEVICE_STATUS_IN_RESET ||
status == HL_DEVICE_STATUS_IN_RESET_AFTER_DEVICE_RELEASE)
rc = -EAGAIN; else
rc = -EPERM;
goto out_err;
}
if (hdev->is_in_dram_scrub) {
dev_dbg_ratelimited(hdev->dev, "Can't open %s during dram scrub\n",
dev_name(hdev->dev));
rc = -EAGAIN; goto out_err;
}
if (hdev->compute_ctx_in_release) {
dev_dbg_ratelimited(hdev->dev, "Can't open %s because another user is still releasing it\n",
dev_name(hdev->dev));
rc = -EAGAIN; goto out_err;
}
if (hdev->is_compute_ctx_active) {
dev_dbg_ratelimited(hdev->dev, "Can't open %s because another user is working on it\n",
dev_name(hdev->dev));
rc = -EBUSY; goto out_err;
}
rc = hl_ctx_create(hdev, hpriv); if (rc) {
dev_err(hdev->dev, "Failed to create context %d\n", rc); goto out_err;
}
hpriv = kzalloc(sizeof(*hpriv), GFP_KERNEL); if (!hpriv) return -ENOMEM;
/* Prevent other routines from reading partial hpriv data by *initializinghprivfieldsbeforeinsertingittothelist
*/
hpriv->hdev = hdev;
filp->private_data = hpriv;
if (!hl_ctrl_device_operational(hdev, NULL)) {
dev_dbg_ratelimited(hdev->dev_ctrl, "Can't open %s because it is disabled\n",
dev_name(hdev->dev_ctrl));
rc = -EPERM; goto out_err;
}
staticvoid fixup_device_params_per_asic(struct hl_device *hdev, int timeout)
{ switch (hdev->asic_type) { case ASIC_GAUDI: case ASIC_GAUDI_SEC: /* If user didn't request a different timeout than the default one, we have *adifferentdefaulttimeoutforGaudi
*/ if (timeout == HL_DEFAULT_TIMEOUT_LOCKED)
hdev->timeout_jiffies = secs_to_jiffies(GAUDI_DEFAULT_TIMEOUT_LOCKED);
hdev->reset_upon_device_release = 0; break;
case ASIC_GOYA:
hdev->reset_upon_device_release = 0; break;
/* Enable only after the initialization of the device */
hdev->disabled = true;
if (!(hdev->fw_components & FW_TYPE_PREBOOT_CPU) &&
(hdev->fw_components & ~FW_TYPE_PREBOOT_CPU)) {
pr_err("Preboot must be set along with other components"); return -EINVAL;
}
/* If CPU queues not enabled, no way to do heartbeat */ if (!hdev->cpu_queues_enable)
hdev->heartbeat = 0;
fixup_device_params_per_asic(hdev, tmp_timeout);
return0;
}
staticint allocate_device_id(struct hl_device *hdev)
{ int id;
mutex_lock(&hl_devs_idr_lock);
id = idr_alloc(&hl_devs_idr, hdev, 0, HL_MAX_MINORS, GFP_KERNEL);
mutex_unlock(&hl_devs_idr_lock);
if (id < 0) { if (id == -ENOSPC)
pr_err("too many devices in the system\n"); return -EBUSY;
}
/* Will be NULL in case of simulator device */
hdev->pdev = pdev;
/* Assign status description string */
strscpy(hdev->status[HL_DEVICE_STATUS_OPERATIONAL], "operational", HL_STR_MAX);
strscpy(hdev->status[HL_DEVICE_STATUS_IN_RESET], "in reset", HL_STR_MAX);
strscpy(hdev->status[HL_DEVICE_STATUS_MALFUNCTION], "disabled", HL_STR_MAX);
strscpy(hdev->status[HL_DEVICE_STATUS_NEEDS_RESET], "needs reset", HL_STR_MAX);
strscpy(hdev->status[HL_DEVICE_STATUS_IN_DEVICE_CREATION], "in device creation", HL_STR_MAX);
strscpy(hdev->status[HL_DEVICE_STATUS_IN_RESET_AFTER_DEVICE_RELEASE], "in reset after device release", HL_STR_MAX);
/* First, we must find out which ASIC are we handling. This is needed *toconfigurethebehaviorofthedriver(kernelparameters)
*/
hdev->asic_type = get_asic_type(hdev); if (hdev->asic_type == ASIC_INVALID) {
dev_err(&pdev->dev, "Unsupported ASIC\n");
rc = -ENODEV; goto out_err;
}
copy_kernel_module_params_to_device(hdev);
set_driver_behavior_per_device(hdev);
fixup_device_params(hdev);
rc = allocate_device_id(hdev); if (rc) goto out_err;
*dev = hdev;
return0;
out_err: return rc;
}
/* *destroy_hdev-destroyhabanalabsdeviceinstance * *@dev:pointertothehabanalabsdevicestructure *
*/ staticvoid destroy_hdev(struct hl_device *hdev)
{ /* Remove device from the device list */
mutex_lock(&hl_devs_idr_lock);
idr_remove(&hl_devs_idr, hdev->id);
mutex_unlock(&hl_devs_idr_lock);
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.