From: Adrian Hunter <adrian.hunter@intel.com>
To: "Martin K . Petersen" <martin.petersen@oracle.com>
Cc: "James E . J . Bottomley" <jejb@linux.ibm.com>,
Bean Huo <huobean@gmail.com>, Avri Altman <avri.altman@wdc.com>,
Alim Akhtar <alim.akhtar@samsung.com>,
Can Guo <cang@codeaurora.org>,
Asutosh Das <asutoshd@codeaurora.org>,
Bart Van Assche <bvanassche@acm.org>,
linux-scsi@vger.kernel.org
Subject: [PATCH V2 2/2] scsi: ufs: core: Fix another task management completion race
Date: Mon, 8 Nov 2021 08:48:15 +0200 [thread overview]
Message-ID: <20211108064815.569494-3-adrian.hunter@intel.com> (raw)
In-Reply-To: <20211108064815.569494-1-adrian.hunter@intel.com>
hba->outstanding_tasks, which is read under host_lock spinlock, tells
the interrupt handler what task management tags are in use by the driver.
The doorbell register bits indicate which tags are in use by the hardware.
A doorbell bit that is 0 is because the bit has yet to be set by the
driver, or because the task is complete. It is only possible to
disambiguate the 2 cases, if reading/writing the doorbell register is
synchronized with reading/writing hba->outstanding_tasks.
For that reason, reading REG_UTP_TASK_REQ_DOOR_BELL must be done under
spinlock.
Fixes: f5ef336fd2e4c3 ("scsi: ufs: core: Fix task management completion")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
drivers/scsi/ufs/ufshcd.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index a904531ba528..a1519b2b6cfe 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -6453,9 +6453,8 @@ static irqreturn_t ufshcd_tmc_handler(struct ufs_hba *hba)
irqreturn_t ret = IRQ_NONE;
int tag;
- pending = ufshcd_readl(hba, REG_UTP_TASK_REQ_DOOR_BELL);
-
spin_lock_irqsave(hba->host->host_lock, flags);
+ pending = ufshcd_readl(hba, REG_UTP_TASK_REQ_DOOR_BELL);
issued = hba->outstanding_tasks & ~pending;
for_each_set_bit(tag, &issued, hba->nutmrs) {
struct request *req = hba->tmf_rqs[tag];
--
2.25.1
next prev parent reply other threads:[~2021-11-08 6:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-08 6:48 [PATCH V2 0/2] scsi: ufs: core: Fix task management completion timeout race Adrian Hunter
2021-11-08 6:48 ` [PATCH V2 1/2] " Adrian Hunter
2021-11-08 6:48 ` Adrian Hunter [this message]
2021-11-08 17:33 ` [PATCH V2 2/2] scsi: ufs: core: Fix another task management completion race Bart Van Assche
2021-11-09 4:13 ` [PATCH V2 0/2] scsi: ufs: core: Fix task management completion timeout race Martin K. Petersen
2021-11-19 4:16 ` Martin K. Petersen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211108064815.569494-3-adrian.hunter@intel.com \
--to=adrian.hunter@intel.com \
--cc=alim.akhtar@samsung.com \
--cc=asutoshd@codeaurora.org \
--cc=avri.altman@wdc.com \
--cc=bvanassche@acm.org \
--cc=cang@codeaurora.org \
--cc=huobean@gmail.com \
--cc=jejb@linux.ibm.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).