Skip to content

Commit

Permalink
scsi: ufs: Fix ufshcd_request_sense_async() for Samsung KLUFG8RHDA-B2D1
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ahunter6 authored and intel-lab-lkp committed Aug 19, 2021
1 parent 848ade9 commit f923de9
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions drivers/scsi/ufs/ufshcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -7946,22 +7947,38 @@ 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.
* clears the sense data, but not all UFS devices behave that way.
*/
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);
Expand Down

0 comments on commit f923de9

Please sign in to comment.