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

Commit 78920828 authored by Yaniv Gardi's avatar Yaniv Gardi
Browse files

scsi: ufs: replace debugfs mutex with spinlock



Using a mutex is problematic if the code can run in interrupt context.
In this patch we replace the ufs debugfs synchronization mechanism
from mutex to spinlock, which doesn't go to sleep.

Change-Id: I4e258898ed0ddf5b84d955fabd4354c2d2891c3d
Signed-off-by: default avatarLee Susman <lsusman@codeaurora.org>
Signed-off-by: default avatarYaniv Gardi <ygardi@codeaurora.org>
parent 3392f4d9
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ static int ufsdbg_tag_stats_show(struct seq_file *file, void *data)
	int i;
	int max_depth;
	bool is_tag_empty = true;
	unsigned long flags;

	if (!hba)
		goto exit;
@@ -41,12 +42,12 @@ static int ufsdbg_tag_stats_show(struct seq_file *file, void *data)

	max_depth = hba->nutrs;

	mutex_lock(&ufs_stats->lock);

	pr_debug("%s: UFS tag statistics:\n", __func__);
	pr_debug("%s: Max tagged command queue depth is %d",
		__func__, max_depth);

	spin_lock_irqsave(hba->host->host_lock, flags);

	for (i = 0 ; i < max_depth ; ++i) {
		if (hba->ufs_stats.tag_stats[i] != 0) {
			is_tag_empty = false;
@@ -58,7 +59,7 @@ static int ufsdbg_tag_stats_show(struct seq_file *file, void *data)
				__func__, i, ufs_stats->tag_stats[i]);
		}
	}
	mutex_unlock(&ufs_stats->lock);
	spin_unlock_irqrestore(hba->host->host_lock, flags);

	if (is_tag_empty)
		pr_debug("%s: All tags statistics are empty", __func__);
@@ -80,6 +81,7 @@ static ssize_t ufsdbg_tag_stats_write(struct file *filp,
	struct ufs_stats *ufs_stats;
	int val = 0;
	int ret;
	unsigned long flags;

	ret = kstrtoint_from_user(ubuf, cnt, 0, &val);
	if (ret) {
@@ -88,7 +90,7 @@ static ssize_t ufsdbg_tag_stats_write(struct file *filp,
	}

	ufs_stats = &hba->ufs_stats;
	mutex_lock(&ufs_stats->lock);
	spin_lock_irqsave(hba->host->host_lock, flags);

	if (!val) {
		ufs_stats->enabled = false;
@@ -101,7 +103,7 @@ static ssize_t ufsdbg_tag_stats_write(struct file *filp,
		       sizeof(unsigned int) * hba->nutrs);
	}

	mutex_unlock(&ufs_stats->lock);
	spin_unlock_irqrestore(hba->host->host_lock, flags);
	return cnt;
}

@@ -115,8 +117,6 @@ static int ufshcd_init_tag_statistics(struct ufs_hba *hba)
{
	int ret = 0;

	mutex_init(&hba->ufs_stats.lock);

	hba->ufs_stats.tag_stats = kzalloc(hba->nutrs * sizeof(u64),
					   GFP_KERNEL);
	if (!hba->ufs_stats.tag_stats) {
+0 −2
Original line number Diff line number Diff line
@@ -44,9 +44,7 @@
#define UFSHCD_UPDATE_TAG_STATS(hba, tag)			\
	do {							\
		if (hba->ufs_stats.enabled) {			\
			mutex_lock(&hba->ufs_stats.lock);	\
			hba->ufs_stats.tag_stats[tag]++;	\
			mutex_unlock(&hba->ufs_stats.lock);	\
		}						\
	} while (0);

+0 −1
Original line number Diff line number Diff line
@@ -203,7 +203,6 @@ struct ufs_dev_cmd {
#ifdef CONFIG_DEBUG_FS
struct ufs_stats {
	u64 *tag_stats;
	struct mutex lock;
	bool enabled;
};