From 9eccb6a00d23a69820e18b226e7a9011806b291a Mon Sep 17 00:00:00 2001 From: Gilad Broner Date: Sun, 8 Feb 2015 14:40:10 +0200 Subject: [PATCH] scsi: ufs: fix tag statistics for flush requests rq_data_dir(rq) will always be either READ or WRITE so conditional logic could never classify a request as a flush request causing flush statistics to always be zero. In addition it is neccesary to check the request type is FS in order not to count other request type as read/write. Change-Id: I678203ba47f8296caefa3f197566f2c65abdf059 Signed-off-by: Gilad Broner --- drivers/scsi/ufs/ufs-debugfs.c | 35 +++++++++++++++++++--------------- drivers/scsi/ufs/ufshcd.c | 23 +++++++++------------- drivers/scsi/ufs/ufshcd.h | 7 ++++--- 3 files changed, 33 insertions(+), 32 deletions(-) diff --git a/drivers/scsi/ufs/ufs-debugfs.c b/drivers/scsi/ufs/ufs-debugfs.c index d719f7b5fcae..6d6b82126d6a 100644 --- a/drivers/scsi/ufs/ufs-debugfs.c +++ b/drivers/scsi/ufs/ufs-debugfs.c @@ -209,34 +209,39 @@ static int ufsdbg_tag_stats_show(struct seq_file *file, void *data) spin_lock_irqsave(hba->host->host_lock, flags); /* Header */ - seq_printf(file, " Tag Stat\t\t%s Queue Fullness\n", sep); + seq_printf(file, " Tag Stat\t\t%s Number of pending reqs upon issue (Q fullness)\n", + sep); for (i = 0; i < TAB_CHARS * (TS_NUM_STATS + 4); i++) { seq_puts(file, "-"); if (i == (TAB_CHARS * 3 - 1)) seq_puts(file, sep); } seq_printf(file, - "\n #\tnum uses\t%s\t #\tAll\t Read\t Write\t Urgent\t Flush\n", + "\n #\tnum uses\t%s\t #\tAll\tRead\tWrite\tUrg.R\tUrg.W\tFlush\n", sep); /* values */ for (i = 0; i < max_depth; i++) { - if (ufs_stats->tag_stats[i][0] <= 0 && - ufs_stats->tag_stats[i][1] <= 0 && - ufs_stats->tag_stats[i][2] <= 0 && - ufs_stats->tag_stats[i][3] <= 0 && - ufs_stats->tag_stats[i][4] <= 0) + if (ufs_stats->tag_stats[i][TS_TAG] <= 0 && + ufs_stats->tag_stats[i][TS_READ] <= 0 && + ufs_stats->tag_stats[i][TS_WRITE] <= 0 && + ufs_stats->tag_stats[i][TS_URGENT_READ] <= 0 && + ufs_stats->tag_stats[i][TS_URGENT_WRITE] <= 0 && + ufs_stats->tag_stats[i][TS_FLUSH] <= 0) continue; is_tag_empty = false; seq_printf(file, " %d\t ", i); for (j = 0; j < TS_NUM_STATS; j++) { - seq_printf(file, "%llu\t ", ufs_stats->tag_stats[i][j]); - if (j == 0) - seq_printf(file, "\t%s\t %d\t%llu\t ", sep, i, - ufs_stats->tag_stats[i][j+1] + - ufs_stats->tag_stats[i][j+2] + - ufs_stats->tag_stats[i][j+3]); + seq_printf(file, "%llu\t", ufs_stats->tag_stats[i][j]); + if (j != 0) + continue; + seq_printf(file, "\t%s\t %d\t%llu\t", sep, i, + ufs_stats->tag_stats[i][TS_READ] + + ufs_stats->tag_stats[i][TS_WRITE] + + ufs_stats->tag_stats[i][TS_URGENT_READ] + + ufs_stats->tag_stats[i][TS_URGENT_WRITE] + + ufs_stats->tag_stats[i][TS_FLUSH]); } seq_puts(file, "\n"); } @@ -977,7 +982,7 @@ void ufsdbg_add_debugfs(struct ufs_hba *hba) } hba->debugfs_files.tag_stats = - debugfs_create_file("tag_stats", S_IRUSR, + debugfs_create_file("tag_stats", S_IRUSR | S_IWUSR, hba->debugfs_files.debugfs_root, hba, &ufsdbg_tag_stats_fops); if (!hba->debugfs_files.tag_stats) { @@ -987,7 +992,7 @@ void ufsdbg_add_debugfs(struct ufs_hba *hba) } hba->debugfs_files.err_stats = - debugfs_create_file("err_stats", S_IRUSR, + debugfs_create_file("err_stats", S_IRUSR | S_IWUSR, hba->debugfs_files.debugfs_root, hba, &ufsdbg_err_stats_fops); if (!hba->debugfs_files.err_stats) { diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index be896d233038..7d0902b58d90 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -63,32 +63,27 @@ struct request *rq = hba->lrb[task_tag].cmd ? \ hba->lrb[task_tag].cmd->request : NULL; \ u64 **tag_stats = hba->ufs_stats.tag_stats; \ - int rq_type = -1; \ + int rq_type = TS_WRITE; \ if (!hba->ufs_stats.enabled) \ break; \ tag_stats[tag][TS_TAG]++; \ - if (!rq) \ + if (!rq || !(rq->cmd_type & REQ_TYPE_FS)) \ break; \ WARN_ON(hba->ufs_stats.q_depth > hba->nutrs); \ - if (rq_data_dir(rq) == READ) \ - rq_type = (rq->cmd_flags & REQ_URGENT) ?\ - TS_URGENT : TS_READ; \ - else if (rq_data_dir(rq) == WRITE) \ - rq_type = TS_WRITE; \ - else if (rq->cmd_flags & REQ_FLUSH) \ + if (rq->cmd_flags & REQ_FLUSH) \ rq_type = TS_FLUSH; \ - else \ - break; \ + else if (rq_data_dir(rq) == READ) \ + rq_type = (rq->cmd_flags & REQ_URGENT) ?\ + TS_URGENT_READ : TS_READ; \ + else if (rq->cmd_flags & REQ_URGENT) \ + rq_type = TS_URGENT_WRITE; \ tag_stats[hba->ufs_stats.q_depth++][rq_type]++; \ } while (0) #define UFSHCD_UPDATE_TAG_STATS_COMPLETION(hba, cmd) \ do { \ struct request *rq = cmd ? cmd->request : NULL; \ - if (cmd->request && \ - ((rq_data_dir(rq) == READ) || \ - (rq_data_dir(rq) == WRITE) || \ - (rq->cmd_flags & REQ_FLUSH))) \ + if (rq && rq->cmd_type & REQ_TYPE_FS) \ hba->ufs_stats.q_depth--; \ } while (0) diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index ea90bdf9e715..a0d27d99cd08 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -514,9 +514,10 @@ enum ts_types { TS_TAG = 0, TS_READ = 1, TS_WRITE = 2, - TS_URGENT = 3, - TS_FLUSH = 4, - TS_NUM_STATS = 5, + TS_URGENT_READ = 3, + TS_URGENT_WRITE = 4, + TS_FLUSH = 5, + TS_NUM_STATS = 6, }; #endif