From patchwork Thu Dec 5 02:14:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 11274055 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1CD0513B6 for ; Thu, 5 Dec 2019 02:14:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EF65721835 for ; Thu, 5 Dec 2019 02:14:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="GflQBvIF"; dkim=pass (1024-bit key) header.d=amazonses.com header.i=@amazonses.com header.b="UNDyhtjZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728604AbfLECOZ (ORCPT ); Wed, 4 Dec 2019 21:14:25 -0500 Received: from a27-55.smtp-out.us-west-2.amazonses.com ([54.240.27.55]:44650 "EHLO a27-55.smtp-out.us-west-2.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728393AbfLECOZ (ORCPT ); Wed, 4 Dec 2019 21:14:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=zsmsymrwgfyinv5wlfyidntwsjeeldzt; d=codeaurora.org; t=1575512065; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; bh=sN9HQYh6wIVagBIBwBcjFatf2XSTX81OaYD+RTbaeUs=; b=GflQBvIFyXKw+XPR+/HIYL99fNjT3AfVf0QTd0Jm9UVn/SzNY1SxkgCoME4DVM9r 4xuJWn4Q6888r/v9nbrMatan9S92R5ohzvnXbe5lLSTjXlvg6NkjetTy02mXAhkE24B ybY0d6CZkUOZo4ps4xmuNe+csbBbjeqX+lhLbdtY= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=gdwg2y3kokkkj5a55z2ilkup5wp5hhxx; d=amazonses.com; t=1575512065; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:Feedback-ID; bh=sN9HQYh6wIVagBIBwBcjFatf2XSTX81OaYD+RTbaeUs=; b=UNDyhtjZe6DF+H4AXuE5OkFRH3grYEMaBUNzW2p9rvBxogPisOI2NGvAR1a1k5Sa 9HdE94WtZGP32gMg6BfnryoiEPMS1wFDOS+sPFpAnTKGKFVyTvB0zOnZHZhfrN4WDSl klyKsyb/eaZeZVvYz/pqHExTAg6JYSvtQg634QpM= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.0 DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 244C2C6430B Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=cang@codeaurora.org From: Can Guo To: asutoshd@codeaurora.org, nguyenb@codeaurora.org, rnayak@codeaurora.org, linux-scsi@vger.kernel.org, kernel-team@android.com, saravanak@google.com, salyzyn@google.com, cang@codeaurora.org Cc: "James E.J. Bottomley" , "Martin K. Petersen" , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v6 1/5] scsi: Adjust DBD setting in mode sense for caching mode page per LLD Date: Thu, 5 Dec 2019 02:14:25 +0000 Message-ID: <0101016ed3d643f9-ffd45d6c-c593-4a13-a18f-a32da3d3bb97-000000@us-west-2.amazonses.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1575512052-15999-1-git-send-email-cang@codeaurora.org> References: <1575512052-15999-1-git-send-email-cang@codeaurora.org> X-SES-Outgoing: 2019.12.05-54.240.27.55 Feedback-ID: 1.us-west-2.CZuq2qbDmUIuT3qdvXlRHZZCpfZqZ4GtG9v3VKgRyF0=:AmazonSES Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org UFS JEDEC standards require DBD field to be set to 1 in mode sense command. This patch allows LLD to define the setting of DBD if required. Signed-off-by: Can Guo Reviewed-by: Avri Altman --- drivers/scsi/scsi_lib.c | 2 ++ include/scsi/scsi_device.h | 1 + 2 files changed, 3 insertions(+) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 5447738..3812e90 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -2108,6 +2108,8 @@ void scsi_exit_queue(void) memset(data, 0, sizeof(*data)); memset(&cmd[0], 0, 12); + + dbd = sdev->set_dbd_for_ms ? 8 : dbd; cmd[1] = dbd & 0x18; /* allows DBD and LLBA bits */ cmd[2] = modepage; diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 3ed836d..f8312a3 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -172,6 +172,7 @@ struct scsi_device { * because we did a bus reset. */ unsigned use_10_for_rw:1; /* first try 10-byte read / write */ unsigned use_10_for_ms:1; /* first try 10-byte mode sense/select */ + unsigned set_dbd_for_ms:1; /* Set "DBD" field in mode sense */ unsigned no_report_opcodes:1; /* no REPORT SUPPORTED OPERATION CODES */ unsigned no_write_same:1; /* no WRITE SAME command */ unsigned use_16_for_rw:1; /* Use read/write(16) over read/write(10) */ From patchwork Thu Dec 5 02:14:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 11274059 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 19E2E13B6 for ; Thu, 5 Dec 2019 02:14:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EB66721744 for ; Thu, 5 Dec 2019 02:14:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="KP/xWTND"; dkim=pass (1024-bit key) header.d=amazonses.com header.i=@amazonses.com header.b="FJD45MDe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728774AbfLECOb (ORCPT ); Wed, 4 Dec 2019 21:14:31 -0500 Received: from a27-11.smtp-out.us-west-2.amazonses.com ([54.240.27.11]:42796 "EHLO a27-11.smtp-out.us-west-2.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728393AbfLECOa (ORCPT ); Wed, 4 Dec 2019 21:14:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=zsmsymrwgfyinv5wlfyidntwsjeeldzt; d=codeaurora.org; t=1575512070; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; bh=gngtc14NVRoJKKuDG0wSfRUd5NMYGXYWK/InKVDZAXs=; b=KP/xWTNDfqon+PpROO6jEbhUfq75BBRH9UfgR6kOvyPuzqxz/3WZfdKwRSkqxPfX ZmVx2V7zfeXE7Ru6e8ZPSSQWEOEj44i5CPpUmvB+25/mH8GbdgIb5L3pP+/rkIsVIW0 X0vDBfhjdYyyCn0QTcYcCljYlfUcMEz+oB67ZTVo= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=gdwg2y3kokkkj5a55z2ilkup5wp5hhxx; d=amazonses.com; t=1575512070; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:Feedback-ID; bh=gngtc14NVRoJKKuDG0wSfRUd5NMYGXYWK/InKVDZAXs=; b=FJD45MDenzrwxtsD15ERNqEqF3QKKcT/11pl2QR5JtU0iI+wr61e0bYAZ+o4vFMI kKnINPJsB870fasqjsMTiXuQLwpRaT2iAHQ1T+XexgwvIYKfB8uFrR0iOsNy4HzDKMy liXBV90cBJbjxBy4qomx4PfUHFlow7x995BkBlYg= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.0 DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org BCCE9C6430B Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=cang@codeaurora.org From: Can Guo To: asutoshd@codeaurora.org, nguyenb@codeaurora.org, rnayak@codeaurora.org, linux-scsi@vger.kernel.org, kernel-team@android.com, saravanak@google.com, salyzyn@google.com, cang@codeaurora.org Cc: Alim Akhtar , Avri Altman , Pedro Sousa , "James E.J. Bottomley" , "Martin K. Petersen" , Stanley Chu , Bean Huo , Tomas Winkler , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v6 2/5] scsi: ufs: Use DBD setting in mode sense Date: Thu, 5 Dec 2019 02:14:30 +0000 Message-ID: <0101016ed3d657e4-32a6dd52-1505-4312-97ff-2bd3bee59eb7-000000@us-west-2.amazonses.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1575512052-15999-1-git-send-email-cang@codeaurora.org> References: <1575512052-15999-1-git-send-email-cang@codeaurora.org> X-SES-Outgoing: 2019.12.05-54.240.27.11 Feedback-ID: 1.us-west-2.CZuq2qbDmUIuT3qdvXlRHZZCpfZqZ4GtG9v3VKgRyF0=:AmazonSES Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org UFS standards requires DBD field to be set to 1 in mode sense(10). Some card vendors are more strict and check the DBD field, hence respond with CHECK_CONDITION (Sense key set to ILLEGAL_REQUEST and ASC set to INVALID FIELD IN CDB). When host send mode sense for page caching, as a result of the CHECK_CONDITION response, host assumes that the device doesn't support the cache feature and doesn't send SYNCHRONIZE_CACHE commands to flush the device cache. This can result in data corruption in case of sudden power down, when there is data stored in the device cache. This patch fixes the DBD field setting as required in UFS standards. Signed-off-by: Can Guo Reviewed-by: Bean Huo --- drivers/scsi/ufs/ufshcd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index c28c144..5484177 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -4596,6 +4596,9 @@ static int ufshcd_slave_alloc(struct scsi_device *sdev) /* Mode sense(6) is not supported by UFS, so use Mode sense(10) */ sdev->use_10_for_ms = 1; + /* DBD field should be set to 1 in mode sense(10) */ + sdev->set_dbd_for_ms = 1; + /* allow SCSI layer to restart the device in case of errors */ sdev->allow_restart = 1; From patchwork Thu Dec 5 02:14:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 11274057 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D00D4139A for ; Thu, 5 Dec 2019 02:14:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ADEB321744 for ; Thu, 5 Dec 2019 02:14:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="ngwdT4FJ"; dkim=pass (1024-bit key) header.d=amazonses.com header.i=@amazonses.com header.b="Hj8AV1Ac" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728818AbfLECOe (ORCPT ); Wed, 4 Dec 2019 21:14:34 -0500 Received: from a27-21.smtp-out.us-west-2.amazonses.com ([54.240.27.21]:42018 "EHLO a27-21.smtp-out.us-west-2.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728393AbfLECOd (ORCPT ); Wed, 4 Dec 2019 21:14:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=zsmsymrwgfyinv5wlfyidntwsjeeldzt; d=codeaurora.org; t=1575512073; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; bh=Sz6ApVmorzrVOvF1+bAfAiw7lYE6hdq0udIrhD+HFGg=; b=ngwdT4FJ6KGLf53dVpAgmxf3R18LgVnmgR38p2vIOF9qdCcXp/AfddSShTphseKR FLovq62s8LLLtrRoUkDQBqgj9YWLQ+u5A6LN7e+AaIc7kBfY1A7ir+t4819mVvgztGI e7ArysNgnAujpwGLbhtak8pPK+9R6AfuGokw8NVI= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=gdwg2y3kokkkj5a55z2ilkup5wp5hhxx; d=amazonses.com; t=1575512073; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:Feedback-ID; bh=Sz6ApVmorzrVOvF1+bAfAiw7lYE6hdq0udIrhD+HFGg=; b=Hj8AV1AccDmrNVHRYNkANTo2xIOo8ZfH14s9QECxBFHp91gzAyWjYxIAAgKMFIpm ubQ6S9nLp9sCw/HtX2Bds+CpW9AaFsmj5HPxGIywXcm+vnj7r+QdhiRLRL8z+LBpm+E Psuy5PZd4upuGg2fwu/rSXPft4D6uvZrZLwmiJUA= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.0 DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org A604AC44BE6 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=cang@codeaurora.org From: Can Guo To: asutoshd@codeaurora.org, nguyenb@codeaurora.org, rnayak@codeaurora.org, linux-scsi@vger.kernel.org, kernel-team@android.com, saravanak@google.com, salyzyn@google.com, cang@codeaurora.org Cc: Alim Akhtar , Avri Altman , Pedro Sousa , "James E.J. Bottomley" , "Martin K. Petersen" , Stanley Chu , Bean Huo , Tomas Winkler , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v6 3/5] scsi: ufs: Release clock if DMA map fails Date: Thu, 5 Dec 2019 02:14:33 +0000 Message-ID: <0101016ed3d66395-1b7e7fce-b74d-42ca-a88a-4db78b795d3b-000000@us-west-2.amazonses.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1575512052-15999-1-git-send-email-cang@codeaurora.org> References: <1575512052-15999-1-git-send-email-cang@codeaurora.org> X-SES-Outgoing: 2019.12.05-54.240.27.21 Feedback-ID: 1.us-west-2.CZuq2qbDmUIuT3qdvXlRHZZCpfZqZ4GtG9v3VKgRyF0=:AmazonSES Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org In queuecommand path, if DMA map fails, it bails out with clock held. In this case, release the clock to keep its usage paired. Signed-off-by: Can Guo Reviewed-by: Bean Huo --- drivers/scsi/ufs/ufshcd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 5484177..9e44506 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -2480,6 +2480,7 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) if (err) { lrbp->cmd = NULL; clear_bit_unlock(tag, &hba->lrb_in_use); + ufshcd_release(hba); goto out; } /* Make sure descriptors are ready before ringing the doorbell */ From patchwork Thu Dec 5 02:14:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 11274061 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0CC9B13B6 for ; Thu, 5 Dec 2019 02:14:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DED1D224F8 for ; Thu, 5 Dec 2019 02:14:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="gNZvpa9H"; dkim=pass (1024-bit key) header.d=amazonses.com header.i=@amazonses.com header.b="RA4m0tCo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728849AbfLECOn (ORCPT ); Wed, 4 Dec 2019 21:14:43 -0500 Received: from a27-18.smtp-out.us-west-2.amazonses.com ([54.240.27.18]:52482 "EHLO a27-18.smtp-out.us-west-2.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728393AbfLECOn (ORCPT ); Wed, 4 Dec 2019 21:14:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=zsmsymrwgfyinv5wlfyidntwsjeeldzt; d=codeaurora.org; t=1575512082; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; bh=3BmlSqDZ/c76uJvMJBqsZlxszKJC6+iSVGfJOfIeKoY=; b=gNZvpa9HBN2piPrVw/JA64nrz97xuMpwt2LpDgkW1qRaoHC/wQ/lxp6FAXp5IIBx ZrhXfhuc1OpiIUIudcCqLCrKIBO576jIjDma+pv+M67nQYVAhj4EbLbYQX0W/bbOPFo 2aMvz+ot27DRVYq7umxw5MPlP71Q9AEyD2dT9Y5A= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=gdwg2y3kokkkj5a55z2ilkup5wp5hhxx; d=amazonses.com; t=1575512082; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:Feedback-ID; bh=3BmlSqDZ/c76uJvMJBqsZlxszKJC6+iSVGfJOfIeKoY=; b=RA4m0tCoarBPcdK1eQGioa4rDrTpO3XVSDBjDRoXlinVbBc7UhsJOcN0RYLYXbnR COQqi+LSXqz0HlQznc39953lXv1xNnAMegh4peG1ClIP7/VKX2jGLBLpFTywaCcd+yN M/YuspotV/I5z4H4gu+1U4XkgGOQGq9OPpmObTXM= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.0 DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 16070C64330 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=cang@codeaurora.org From: Can Guo To: asutoshd@codeaurora.org, nguyenb@codeaurora.org, rnayak@codeaurora.org, linux-scsi@vger.kernel.org, kernel-team@android.com, saravanak@google.com, salyzyn@google.com, cang@codeaurora.org Cc: Alim Akhtar , Avri Altman , Pedro Sousa , "James E.J. Bottomley" , "Martin K. Petersen" , Stanley Chu , Bean Huo , Tomas Winkler , Thomas Gleixner , Allison Randal , Greg Kroah-Hartman , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v6 4/5] scsi: ufs: Do not clear the DL layer timers Date: Thu, 5 Dec 2019 02:14:42 +0000 Message-ID: <0101016ed3d688a4-cfaeb1c9-238b-46c4-9c89-d48c410ba325-000000@us-west-2.amazonses.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1575512052-15999-1-git-send-email-cang@codeaurora.org> References: <1575512052-15999-1-git-send-email-cang@codeaurora.org> X-SES-Outgoing: 2019.12.05-54.240.27.18 Feedback-ID: 1.us-west-2.CZuq2qbDmUIuT3qdvXlRHZZCpfZqZ4GtG9v3VKgRyF0=:AmazonSES Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org During power mode change, PACP_PWR_Req frame sends PAPowerModeUserData parameters (and they are considered valid by device if Flags[4] - UserDataValid bit is set in the same frame). Currently we don't set these PAPowerModeUserData parameters and hardware always sets UserDataValid bit which would clear all the DL layer timeout values of the peer device after the power mode change. This change sets the PAPowerModeUserData[0..5] to UniPro specification recommended default values, in addition we are also setting the relevant DME_LOCAL_* timer attributes as required by UFS HCI specification. Signed-off-by: Can Guo Reviewed-by: Avri Altman Reviewed-by: Bean Huo --- drivers/scsi/ufs/ufshcd.c | 20 ++++++++++++++++++++ drivers/scsi/ufs/unipro.h | 11 +++++++++++ 2 files changed, 31 insertions(+) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 9e44506..086d359 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -4084,6 +4084,26 @@ static int ufshcd_change_power_mode(struct ufs_hba *hba, ufshcd_dme_set(hba, UIC_ARG_MIB(PA_HSSERIES), pwr_mode->hs_rate); + ufshcd_dme_set(hba, UIC_ARG_MIB(PA_PWRMODEUSERDATA0), + DL_FC0ProtectionTimeOutVal_Default); + ufshcd_dme_set(hba, UIC_ARG_MIB(PA_PWRMODEUSERDATA1), + DL_TC0ReplayTimeOutVal_Default); + ufshcd_dme_set(hba, UIC_ARG_MIB(PA_PWRMODEUSERDATA2), + DL_AFC0ReqTimeOutVal_Default); + ufshcd_dme_set(hba, UIC_ARG_MIB(PA_PWRMODEUSERDATA3), + DL_FC1ProtectionTimeOutVal_Default); + ufshcd_dme_set(hba, UIC_ARG_MIB(PA_PWRMODEUSERDATA4), + DL_TC1ReplayTimeOutVal_Default); + ufshcd_dme_set(hba, UIC_ARG_MIB(PA_PWRMODEUSERDATA5), + DL_AFC1ReqTimeOutVal_Default); + + ufshcd_dme_set(hba, UIC_ARG_MIB(DME_LocalFC0ProtectionTimeOutVal), + DL_FC0ProtectionTimeOutVal_Default); + ufshcd_dme_set(hba, UIC_ARG_MIB(DME_LocalTC0ReplayTimeOutVal), + DL_TC0ReplayTimeOutVal_Default); + ufshcd_dme_set(hba, UIC_ARG_MIB(DME_LocalAFC0ReqTimeOutVal), + DL_AFC0ReqTimeOutVal_Default); + ret = ufshcd_uic_change_pwr_mode(hba, pwr_mode->pwr_rx << 4 | pwr_mode->pwr_tx); diff --git a/drivers/scsi/ufs/unipro.h b/drivers/scsi/ufs/unipro.h index f539f87..3dc4d8b 100644 --- a/drivers/scsi/ufs/unipro.h +++ b/drivers/scsi/ufs/unipro.h @@ -161,6 +161,17 @@ /* PHY Adapter Protocol Constants */ #define PA_MAXDATALANES 4 +#define DL_FC0ProtectionTimeOutVal_Default 8191 +#define DL_TC0ReplayTimeOutVal_Default 65535 +#define DL_AFC0ReqTimeOutVal_Default 32767 +#define DL_FC1ProtectionTimeOutVal_Default 8191 +#define DL_TC1ReplayTimeOutVal_Default 65535 +#define DL_AFC1ReqTimeOutVal_Default 32767 + +#define DME_LocalFC0ProtectionTimeOutVal 0xD041 +#define DME_LocalTC0ReplayTimeOutVal 0xD042 +#define DME_LocalAFC0ReqTimeOutVal 0xD043 + /* PA power modes */ enum { FAST_MODE = 1, From patchwork Thu Dec 5 02:14:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 11274063 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C830A139A for ; Thu, 5 Dec 2019 02:14:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A499321744 for ; Thu, 5 Dec 2019 02:14:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="XaNDv1c+"; dkim=pass (1024-bit key) header.d=amazonses.com header.i=@amazonses.com header.b="gjxkCTNn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728882AbfLECOr (ORCPT ); Wed, 4 Dec 2019 21:14:47 -0500 Received: from a27-21.smtp-out.us-west-2.amazonses.com ([54.240.27.21]:42018 "EHLO a27-21.smtp-out.us-west-2.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728393AbfLECOr (ORCPT ); Wed, 4 Dec 2019 21:14:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=zsmsymrwgfyinv5wlfyidntwsjeeldzt; d=codeaurora.org; t=1575512086; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; bh=eV5UQc0Nv02TJNdhFWZaDHRnQ93t5irlSEirUDqpNEo=; b=XaNDv1c+Yk569dGWAo/WWngrs5HEjWN2FQw53yJ7eaq1lnLtyXTlf60nQZcZ6TMk olZWkHS0NnYwot3yPPRSo3+b+l5VTHNJRonNftCHBUFy/3MQboD1+seN/V3vfR+voyt 4Djd/cs8+Ri2lcLjoi5IwuG+a9oNmHcllB6bS+/8= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=gdwg2y3kokkkj5a55z2ilkup5wp5hhxx; d=amazonses.com; t=1575512086; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:Feedback-ID; bh=eV5UQc0Nv02TJNdhFWZaDHRnQ93t5irlSEirUDqpNEo=; b=gjxkCTNnhyXecF354e9NmbcrcfNv0HjrnTLPiqPbgvCazs1FWm9O/L4nI0fEinSG yULVrOMcJ7xw2y8ALu/QdufcYM+E+BYdwAg6cUUAy7sUQdqNSB9EfB2IgIg+pnkjNhP NLyaDvMGPoXPv2kZ0miPhm/5flKJAcxBN7mH4NVs= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.0 DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 6B3EAC41635 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=cang@codeaurora.org From: Can Guo To: asutoshd@codeaurora.org, nguyenb@codeaurora.org, rnayak@codeaurora.org, linux-scsi@vger.kernel.org, kernel-team@android.com, saravanak@google.com, salyzyn@google.com, cang@codeaurora.org Cc: Alim Akhtar , Avri Altman , Pedro Sousa , "James E.J. Bottomley" , "Martin K. Petersen" , Stanley Chu , Bean Huo , Tomas Winkler , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v6 5/5] scsi: ufs: Do not free irq in suspend Date: Thu, 5 Dec 2019 02:14:46 +0000 Message-ID: <0101016ed3d69793-22918f99-23bf-495d-8a36-a9c108d1cbce-000000@us-west-2.amazonses.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1575512052-15999-1-git-send-email-cang@codeaurora.org> References: <1575512052-15999-1-git-send-email-cang@codeaurora.org> X-SES-Outgoing: 2019.12.05-54.240.27.21 Feedback-ID: 1.us-west-2.CZuq2qbDmUIuT3qdvXlRHZZCpfZqZ4GtG9v3VKgRyF0=:AmazonSES Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Since ufshcd irq resource is allocated with the device resource management aware IRQ request implementation, we don't really need to free up irq during suspend, disabling it during suspend and reenabling it during resume should be good enough. Signed-off-by: Can Guo Reviewed-by: Stanley Chu --- drivers/scsi/ufs/ufshcd.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 086d359..c449b68 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -266,26 +266,18 @@ static inline bool ufshcd_valid_tag(struct ufs_hba *hba, int tag) return tag >= 0 && tag < hba->nutrs; } -static inline int ufshcd_enable_irq(struct ufs_hba *hba) +static inline void ufshcd_enable_irq(struct ufs_hba *hba) { - int ret = 0; - if (!hba->is_irq_enabled) { - ret = request_irq(hba->irq, ufshcd_intr, IRQF_SHARED, UFSHCD, - hba); - if (ret) - dev_err(hba->dev, "%s: request_irq failed, ret=%d\n", - __func__, ret); + enable_irq(hba->irq); hba->is_irq_enabled = true; } - - return ret; } static inline void ufshcd_disable_irq(struct ufs_hba *hba) { if (hba->is_irq_enabled) { - free_irq(hba->irq, hba); + disable_irq(hba->irq); hba->is_irq_enabled = false; } } @@ -7930,9 +7922,7 @@ static int ufshcd_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op) goto out; /* enable the host irq as host controller would be active soon */ - ret = ufshcd_enable_irq(hba); - if (ret) - goto disable_irq_and_vops_clks; + ufshcd_enable_irq(hba); ret = ufshcd_vreg_set_hpm(hba); if (ret)