Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6edac89e authored by Neeraj Soni's avatar Neeraj Soni Committed by Gerrit - the friendly Code Review server
Browse files

scsi: ufs: release spinlock and fix workqueue allocation



This fixes synchronization issue introduced with
commit b557a6117a2b
("scsi: ufs: ice: propagate memeory allocation failure error")
Also in low end ufs targets crypto engine is initialized in
every resume operation. This will endup allocating memory
for crypto worker queue in every resume. Check for queue pointer
before allocating the memory for work queue.

Change-Id: I919a6cbfc418de335e797d4fd724cd3c63bace55
Signed-off-by: default avatarNeeraj Soni <neersoni@codeaurora.org>
parent 9338f951
Loading
Loading
Loading
Loading
+17 −21
Original line number Diff line number Diff line
/*
 * Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2014-2019, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -226,6 +226,7 @@ int ufs_qcom_ice_init(struct ufs_qcom_host *qcom_host)
	}

	qcom_host->dbg_print_en |= UFS_QCOM_ICE_DEFAULT_DBG_PRINT_EN;
	if (!ice_workqueue) {
		ice_workqueue = alloc_workqueue("ice-set-key",
			WQ_MEM_RECLAIM | WQ_HIGHPRI, 0);
		if (!ice_workqueue) {
@@ -235,6 +236,7 @@ int ufs_qcom_ice_init(struct ufs_qcom_host *qcom_host)
			goto out;
		}
		INIT_WORK(&qcom_host->ice_cfg_work, ufs_qcom_ice_cfg_work);
	}

out:
	return err;
@@ -288,16 +290,13 @@ int ufs_qcom_ice_req_setup(struct ufs_qcom_host *qcom_host,
			 */
			if (err == -EAGAIN) {
				if (!ice_workqueue) {
					spin_unlock_irqrestore(
					&qcom_host->ice_work_lock,
					flags);

					dev_err(qcom_host->hba->dev,
						"%s: error %d workqueue NULL\n",
						__func__, err);
					/*
					 * over write the error code to halt
					 * the request from upper layer as
					 * system is possibly in low memory
					 * state. Give system a chance to
					 * recover and reinitialize ice driver.
					 */
					return -EINVAL;
				}

@@ -421,16 +420,13 @@ int ufs_qcom_ice_cfg_start(struct ufs_qcom_host *qcom_host,
			 */
			if (err == -EAGAIN) {
				if (!ice_workqueue) {
					spin_unlock_irqrestore(
					&qcom_host->ice_work_lock,
					flags);

					dev_err(qcom_host->hba->dev,
						"%s: error %d workqueue NULL\n",
						__func__, err);
					/*
					 * over write the error code to halt
					 * the request from upper layer as
					 * system is possibly in low memory
					 * state. Give system a chance to
					 * recover and reinitialize ice driver.
					 */
					return -EINVAL;
				}