scsi: ufs: Get a TM service response from the correct offset
authorKiwoong Kim <kwmad.kim@samsung.com>
Thu, 8 Sep 2016 23:22:22 +0000 (08:22 +0900)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 21 Sep 2016 20:28:57 +0000 (16:28 -0400)
When any UFS host controller receives a TM(Task Management) response
from a UFS device, UFS driver has been recognize like receiving a
message of "Task Management Function Complete"(00h) in all cases, so
far.  That means there is no pending task for a tag of the TM request
sent before in the UFS device.  That's because the byte offset 6 in TM
response which has been used to get a TM service response so far
represents just whether or not a TM transmission passes.

Regarding UFS spec, the correct byte offset to get TM service response
is 15, not 6.

I tested that UFS driver responds properly for the TM response from a
UFS device with an reference board with exynos8890, as follow: No
pending task -> Task Management Function Complete (00h) Pending task ->
Task Management Function Succeeded (08h)

[mkp: applied by hand]

Signed-off-by: Kiwoong Kim <kwmad.kim@samsung.com>
Signed-off-by: HeonGwang Chu <hg.chu@samsung.com>
Tested-by: : Kiwoong Kim <kwmad.kim@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/ufs/ufs.h
drivers/scsi/ufs/ufshcd.c

index b291fa6..845b874 100644 (file)
@@ -327,6 +327,7 @@ enum {
        MASK_QUERY_DATA_SEG_LEN         = 0xFFFF,
        MASK_RSP_UPIU_DATA_SEG_LEN      = 0xFFFF,
        MASK_RSP_EXCEPTION_EVENT        = 0x10000,
+       MASK_TM_SERVICE_RESP            = 0xFF,
 };
 
 /* Task management service response */
index 66f0eb8..37f3c51 100644 (file)
@@ -3364,8 +3364,8 @@ static int ufshcd_task_req_compl(struct ufs_hba *hba, u32 index, u8 *resp)
        if (ocs_value == OCS_SUCCESS) {
                task_rsp_upiup = (struct utp_upiu_task_rsp *)
                                task_req_descp[index].task_rsp_upiu;
-               task_result = be32_to_cpu(task_rsp_upiup->header.dword_1);
-               task_result = ((task_result & MASK_TASK_RESPONSE) >> 8);
+               task_result = be32_to_cpu(task_rsp_upiup->output_param1);
+               task_result = task_result & MASK_TM_SERVICE_RESP;
                if (resp)
                        *resp = (u8)task_result;
        } else {