From: Adrian Hunter <adrian.hunter@intel.com>
To: "Martin K . Petersen" <martin.petersen@oracle.com>
Cc: "James E . J . Bottomley" <jejb@linux.ibm.com>,
Bart Van Assche <bvanassche@acm.org>,
Avri Altman <avri.altman@wdc.com>, Bean Huo <huobean@gmail.com>,
Can Guo <cang@codeaurora.org>,
Asutosh Das <asutoshd@codeaurora.org>,
linux-scsi@vger.kernel.org
Subject: [PATCH V2] scsi: ufs: Fix ufshcd_request_sense_async() for Samsung KLUFG8RHDA-B2D1
Date: Mon, 23 Aug 2021 08:01:17 +0300 [thread overview]
Message-ID: <20210823050117.11608-1-adrian.hunter@intel.com> (raw)
From: Adrian Hunter <ajhmls@gmail.com>
Samsung KLUFG8RHDA-B2D1 does not clear the unit attention condition if the
length is zero. So go back to requesting all the sense data, as it was
before patch "scsi: ufs: Request sense data asynchronously". That is
simpler than creating and maintaining a quirk for affected devices.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
Changes in V2
Alter comment to note the need for non-zero sense size.
drivers/scsi/ufs/ufshcd.c | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index a3b419848f0a..9d6207f7cf6d 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -7937,7 +7937,8 @@ static int ufshcd_add_lus(struct ufs_hba *hba)
static void ufshcd_request_sense_done(struct request *rq, blk_status_t error)
{
if (error != BLK_STS_OK)
- pr_err("%s: REQUEST SENSE failed (%d)", __func__, error);
+ pr_err("%s: REQUEST SENSE failed (%d)\n", __func__, error);
+ kfree(rq->end_io_data);
blk_put_request(rq);
}
@@ -7945,23 +7946,39 @@ static int
ufshcd_request_sense_async(struct ufs_hba *hba, struct scsi_device *sdev)
{
/*
- * From SPC-6: the REQUEST SENSE command with any allocation length
- * clears the sense data.
+ * Some UFS devices clear unit attention condition only if the sense
+ * size used (UFS_SENSE_SIZE in this case) is non-zero.
*/
- static const u8 cmd[6] = {REQUEST_SENSE, 0, 0, 0, 0, 0};
+ static const u8 cmd[6] = {REQUEST_SENSE, 0, 0, 0, UFS_SENSE_SIZE, 0};
struct scsi_request *rq;
struct request *req;
+ char *buffer;
+ int ret;
+
+ buffer = kzalloc(UFS_SENSE_SIZE, GFP_KERNEL);
+ if (!buffer)
+ return -ENOMEM;
- req = blk_get_request(sdev->request_queue, REQ_OP_DRV_IN, /*flags=*/0);
+ req = blk_get_request(sdev->request_queue, REQ_OP_DRV_IN,
+ /*flags=*/BLK_MQ_REQ_PM);
if (IS_ERR(req))
return PTR_ERR(req);
+ ret = blk_rq_map_kern(sdev->request_queue, req,
+ buffer, UFS_SENSE_SIZE, GFP_NOIO);
+ if (ret) {
+ blk_put_request(req);
+ kfree(buffer);
+ return ret;
+ }
+
rq = scsi_req(req);
rq->cmd_len = ARRAY_SIZE(cmd);
memcpy(rq->cmd, cmd, rq->cmd_len);
rq->retries = 3;
req->timeout = 1 * HZ;
req->rq_flags |= RQF_PM | RQF_QUIET;
+ req->end_io_data = buffer;
blk_execute_rq_nowait(/*bd_disk=*/NULL, req, /*at_head=*/true,
ufshcd_request_sense_done);
--
2.17.1
next reply other threads:[~2021-08-23 5:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-23 5:01 Adrian Hunter [this message]
2021-08-24 2:27 ` [PATCH V2] scsi: ufs: Fix ufshcd_request_sense_async() for Samsung KLUFG8RHDA-B2D1 Bart Van Assche
2021-08-24 3:34 ` Martin K. Petersen
2021-08-24 11:34 ` Adrian Hunter
2021-08-24 11:41 ` [PATCH V3] " Adrian Hunter
2021-08-25 2:59 ` Martin K. Petersen
2021-08-28 2:31 ` Martin K. Petersen
2021-09-02 10:18 ` [PATCH 0/3] scsi: ufs: Let devices remain runtime suspended during system suspend Adrian Hunter
2021-09-02 10:18 ` [PATCH 1/3] scsi: ufs: Fix error handler clear ua deadlock Adrian Hunter
2021-09-02 16:53 ` Asutosh Das (asd)
2021-09-02 10:18 ` [PATCH 2/3] scsi: ufs: Fix runtime PM dependencies getting broken Adrian Hunter
2021-09-02 10:18 ` [PATCH 3/3] scsi: ufs: Let devices remain runtime suspended during system suspend Adrian Hunter
2021-09-02 17:07 ` Asutosh Das (asd)
2021-09-03 9:55 ` Adrian Hunter
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=20210823050117.11608-1-adrian.hunter@intel.com \
--to=adrian.hunter@intel.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