static void adf_cleanup_accel(struct adf_accel_dev *accel_dev) { struct adf_accel_pci *accel_pci_dev = &accel_dev->accel_pci_dev; int i; adf_dev_shutdown(accel_dev); for (i = 0; i < ADF_PCI_MAX_BARS; i++) { struct adf_bar *bar = &accel_pci_dev->pci_bars[i]; if (bar->virt_addr) pci_iounmap(accel_pci_dev->pci_dev, bar->virt_addr); } if (accel_dev->hw_device) { switch (accel_dev->hw_device->pci_dev_id) { case ADF_DH895XCC_PCI_DEVICE_ID: adf_clean_hw_data_dh895xcc(accel_dev->hw_device); break; default: break; } kfree(accel_dev->hw_device); } adf_cfg_dev_remove(accel_dev); debugfs_remove(accel_dev->debugfs_dir); adf_devmgr_rm_dev(accel_dev); pci_release_regions(accel_pci_dev->pci_dev); pci_disable_device(accel_pci_dev->pci_dev); kfree(accel_dev); }
static void adf_device_reset_worker(struct work_struct *work) { struct adf_reset_dev_data *reset_data = container_of(work, struct adf_reset_dev_data, reset_work); struct adf_accel_dev *accel_dev = reset_data->accel_dev; adf_dev_restarting_notify(accel_dev); adf_dev_stop(accel_dev); adf_dev_shutdown(accel_dev); if (adf_dev_init(accel_dev) || adf_dev_start(accel_dev)) { /* The device hanged and we can't restart it so stop here */ dev_err(&GET_DEV(accel_dev), "Restart device failed\n"); kfree(reset_data); WARN(1, "QAT: device restart failed. Device is unusable\n"); return; } adf_dev_restarted_notify(accel_dev); clear_bit(ADF_STATUS_RESTARTING, &accel_dev->status); /* The dev is back alive. Notify the caller if in sync mode */ if (reset_data->mode == ADF_DEV_RESET_SYNC) complete(&reset_data->compl); else kfree(reset_data); }
static void adf_dev_stop_async(struct work_struct *work) { struct adf_vf_stop_data *stop_data = container_of(work, struct adf_vf_stop_data, work); struct adf_accel_dev *accel_dev = stop_data->accel_dev; adf_dev_stop(accel_dev); adf_dev_shutdown(accel_dev); /* Re-enable PF2VF interrupts */ adf_enable_pf2vf_interrupts(accel_dev); kfree(stop_data); }
static int adf_ctl_ioctl_dev_start(struct file *fp, unsigned int cmd, unsigned long arg) { int ret; struct adf_user_cfg_ctl_data *ctl_data; struct adf_accel_dev *accel_dev; ret = adf_ctl_alloc_resources(&ctl_data, arg); if (ret) return ret; accel_dev = adf_devmgr_get_dev_by_id(ctl_data->device_id); if (!accel_dev) { pr_err("QAT: Device %d not found\n", ctl_data->device_id); ret = -ENODEV; goto out; } if (!adf_dev_started(accel_dev)) { dev_info(&GET_DEV(accel_dev), "Starting acceleration device qat_dev%d.\n", ctl_data->device_id); ret = adf_dev_init(accel_dev); if (!ret) ret = adf_dev_start(accel_dev); } else { dev_info(&GET_DEV(accel_dev), "Acceleration device qat_dev%d already started.\n", ctl_data->device_id); } if (ret) { dev_err(&GET_DEV(accel_dev), "Failed to start qat_dev%d\n", ctl_data->device_id); adf_dev_stop(accel_dev); adf_dev_shutdown(accel_dev); } out: kfree(ctl_data); return ret; }
static int adf_ctl_stop_devices(uint32_t id) { struct list_head *itr, *head = adf_devmgr_get_head(); int ret = 0; list_for_each(itr, head) { struct adf_accel_dev *accel_dev = list_entry(itr, struct adf_accel_dev, list); if (id == accel_dev->accel_id || id == ADF_CFG_ALL_DEVICES) { if (!adf_dev_started(accel_dev)) continue; if (adf_dev_stop(accel_dev)) { dev_err(&GET_DEV(accel_dev), "Failed to stop qat_dev%d\n", id); ret = -EFAULT; } else { adf_dev_shutdown(accel_dev); } } } return ret; }