From patchwork Thu Dec 5 02:05:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 11274041 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 8A736139A for ; Thu, 5 Dec 2019 02:05:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 68D0621823 for ; Thu, 5 Dec 2019 02:05:09 +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="MEnl6REM"; dkim=pass (1024-bit key) header.d=amazonses.com header.i=@amazonses.com header.b="JcbJwX2m" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728522AbfLECFF (ORCPT ); Wed, 4 Dec 2019 21:05:05 -0500 Received: from a27-21.smtp-out.us-west-2.amazonses.com ([54.240.27.21]:37964 "EHLO a27-21.smtp-out.us-west-2.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728419AbfLECFF (ORCPT ); Wed, 4 Dec 2019 21:05:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=zsmsymrwgfyinv5wlfyidntwsjeeldzt; d=codeaurora.org; t=1575511504; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; bh=sN9HQYh6wIVagBIBwBcjFatf2XSTX81OaYD+RTbaeUs=; b=MEnl6REMwAWupUgIrkziAx7V4m1WceQyy03mLLXcJEoMoR50iTDnyLBiL8e59lUl Zsson7+DjZHBSJ55Vu9M0kBQUEwz83DWy7GS5/krT9Q/P+VTThw5BONLfHYMy726Q6a 1JeUJkYOp6u4dMbTD1I2an5I1M19nmvuS+Pr92Xw= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=gdwg2y3kokkkj5a55z2ilkup5wp5hhxx; d=amazonses.com; t=1575511504; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:Feedback-ID; bh=sN9HQYh6wIVagBIBwBcjFatf2XSTX81OaYD+RTbaeUs=; b=JcbJwX2mEG/7jU6YyaxyUKsPhzpyKNyRe30VD9WnsWS+rIZr/qlba1z/MeqyP4Cn pRyYHA1EFTQkb7Uw0T+q+/PeedT6MDbEldKOGvtf2vuyz3Qjo9wwNbtYc9IqLIE6p5t uL2CUvEJ+zqK8Mkw82ss0QQgH1E0bt51s0nXrSJo= 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 96AE5C447A5 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 v5 1/5] scsi: Adjust DBD setting in mode sense for caching mode page per LLD Date: Thu, 5 Dec 2019 02:05:04 +0000 Message-ID: <0101016ed3cdb63d-06b5ad68-0049-46c5-bb5d-a01866023be5-000000@us-west-2.amazonses.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1575511482-15115-1-git-send-email-cang@codeaurora.org> References: <1575511482-15115-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 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 --- 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:05:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 11274043 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 ABCCA112B for ; Thu, 5 Dec 2019 02:05:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8980D21835 for ; Thu, 5 Dec 2019 02:05:16 +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="N+6NlXe6"; dkim=pass (1024-bit key) header.d=amazonses.com header.i=@amazonses.com header.b="OJucugfE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728470AbfLECFN (ORCPT ); Wed, 4 Dec 2019 21:05:13 -0500 Received: from a27-18.smtp-out.us-west-2.amazonses.com ([54.240.27.18]:48512 "EHLO a27-18.smtp-out.us-west-2.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728393AbfLECFM (ORCPT ); Wed, 4 Dec 2019 21:05:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=zsmsymrwgfyinv5wlfyidntwsjeeldzt; d=codeaurora.org; t=1575511512; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; bh=gngtc14NVRoJKKuDG0wSfRUd5NMYGXYWK/InKVDZAXs=; b=N+6NlXe6bxVdIVKFPic9WCakHsQyBp5MuID+H8t2Dv5wHe6eKpoj5HHdWCxZTlFT 8MUWyzM87NtY4cQcOZpdFbA/h2TQO2RcP/Ban5uiwH4kHgs26Js6KRGPyqmEUSvprdQ g6S3JAOTLGRxwEoze23oRqH5PKTlpwZ7Q7+1cI/I= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=gdwg2y3kokkkj5a55z2ilkup5wp5hhxx; d=amazonses.com; t=1575511512; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:Feedback-ID; bh=gngtc14NVRoJKKuDG0wSfRUd5NMYGXYWK/InKVDZAXs=; b=OJucugfEODHGuLkdGfM/Ua/c0wOjA2r5a2C+wYnzJ4h97S8XheF9QQzGBqmdBj5N ieQ8G/fmDtrA/F1KyiBO21fj2soR3ABvGl04aveIcj5exXR3/fAku4g7HSlD1OChEll lyPIzaNrE7a81kWSQ62sVYhAwGq1U2Iv7/8Bb4gE= 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 D715BC447A5 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 v5 2/5] scsi: ufs: Use DBD setting in mode sense Date: Thu, 5 Dec 2019 02:05:12 +0000 Message-ID: <0101016ed3cdd341-e872a9c6-38be-4169-b284-8c9ab303b85e-000000@us-west-2.amazonses.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1575511482-15115-1-git-send-email-cang@codeaurora.org> References: <1575511482-15115-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 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:05:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 11274045 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 8A570112B for ; Thu, 5 Dec 2019 02:05:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 663472077B for ; Thu, 5 Dec 2019 02:05:22 +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="a3ovsm52"; dkim=pass (1024-bit key) header.d=amazonses.com header.i=@amazonses.com header.b="DPghKjSo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728730AbfLECFS (ORCPT ); Wed, 4 Dec 2019 21:05:18 -0500 Received: from a27-186.smtp-out.us-west-2.amazonses.com ([54.240.27.186]:57050 "EHLO a27-186.smtp-out.us-west-2.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728393AbfLECFS (ORCPT ); Wed, 4 Dec 2019 21:05:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=zsmsymrwgfyinv5wlfyidntwsjeeldzt; d=codeaurora.org; t=1575511517; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; bh=Sz6ApVmorzrVOvF1+bAfAiw7lYE6hdq0udIrhD+HFGg=; b=a3ovsm52YaqnQ04D1NTcQ8/h7Mzns3j51wOYet4kZBQ9loQMpGiCRuFmWr0m2+XN 5ZPf3kMgPl4mTY6QAK/FA2UqtY2A/bIYVHxBFxHmEgpV/wANnfxahKrfbH5LQxEOZYe BGTiaGi4/d7poq7UBmlQ1yAwIQFQQT1A5Jowb+mI= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=gdwg2y3kokkkj5a55z2ilkup5wp5hhxx; d=amazonses.com; t=1575511517; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:Feedback-ID; bh=Sz6ApVmorzrVOvF1+bAfAiw7lYE6hdq0udIrhD+HFGg=; b=DPghKjSowEHZx6SaQwvNrXkHhitDxOaup6wb6ouEW3sEqITlZ4Q1sD0fBvJFYBcW 9XDR/EmKiH2HP0YVTuSaVWFQ0K7U2A0A6IJbrBGvrsYTfcLRtSXpaUzalZcJw3xNmuB dM8+MsOIWju2TgEbx1ALimeV1wgPkZKSS2VyHsH4= 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 0EC44C447A5 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 v5 3/5] scsi: ufs: Release clock if DMA map fails Date: Thu, 5 Dec 2019 02:05:17 +0000 Message-ID: <0101016ed3cde8e5-aa64e1c2-a930-47d4-b91e-2f7cd23f66b0-000000@us-west-2.amazonses.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1575511482-15115-1-git-send-email-cang@codeaurora.org> References: <1575511482-15115-1-git-send-email-cang@codeaurora.org> X-SES-Outgoing: 2019.12.05-54.240.27.186 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:05:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 11274047 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 349AD1593 for ; Thu, 5 Dec 2019 02:05:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 11EB8214B2 for ; Thu, 5 Dec 2019 02:05:33 +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="k09oct53"; dkim=pass (1024-bit key) header.d=amazonses.com header.i=@amazonses.com header.b="bgqtr2an" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728611AbfLECF3 (ORCPT ); Wed, 4 Dec 2019 21:05:29 -0500 Received: from a27-186.smtp-out.us-west-2.amazonses.com ([54.240.27.186]:57050 "EHLO a27-186.smtp-out.us-west-2.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728374AbfLECF3 (ORCPT ); Wed, 4 Dec 2019 21:05:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=zsmsymrwgfyinv5wlfyidntwsjeeldzt; d=codeaurora.org; t=1575511528; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; bh=TqAEjiZ/yXUwqyL2LAGK29kAxt667EFYxtHSpfp5X8I=; b=k09oct53kMI83Mf7eiAi6D5YPCT2fMnr3CO+z+Pa8X+8ItejAfYsfwsNjJ8yVrvj fSsi+N+0B/vcdedByU5hyKPFb7fpgWnAd+Buvzj6C5M2vFHwNRNdtLZTqRQGER7fB9O hCLd5wb/NXgBEOXlxjz41CeX7XtL12U0rMRDQaN4= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=gdwg2y3kokkkj5a55z2ilkup5wp5hhxx; d=amazonses.com; t=1575511528; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:Feedback-ID; bh=TqAEjiZ/yXUwqyL2LAGK29kAxt667EFYxtHSpfp5X8I=; b=bgqtr2anSmwnPNJRGIUTjOyAZjn0Gvlp71lj/4sB1hlP2Q/DXPDG4oW31GYwJ4Re BLp9VD3eKTTawDg5t+yX2M0oYfD0eKs2gBl1DPkawEJ2ebfJKNhkZHhsUORdha6eFyg Ckt2R+ZDYnEkIhceX6Fk0jqq6ueqTNmsA2gEfXDY= 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 1D631C64305 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 , Greg Kroah-Hartman , Thomas Gleixner , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v5 4/5] scsi: ufs: Do not clear the DL layer timers Date: Thu, 5 Dec 2019 02:05:28 +0000 Message-ID: <0101016ed3ce1260-ceeabf76-d40d-4c8d-977a-0a231165bf49-000000@us-west-2.amazonses.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1575511482-15115-1-git-send-email-cang@codeaurora.org> References: <1575511482-15115-1-git-send-email-cang@codeaurora.org> X-SES-Outgoing: 2019.12.05-54.240.27.186 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:05:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 11274049 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 B520C139A for ; Thu, 5 Dec 2019 02:05:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 92B2A214B2 for ; Thu, 5 Dec 2019 02:05:40 +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="jTNEu15A"; dkim=pass (1024-bit key) header.d=amazonses.com header.i=@amazonses.com header.b="McOewTk7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728788AbfLECFg (ORCPT ); Wed, 4 Dec 2019 21:05:36 -0500 Received: from a27-188.smtp-out.us-west-2.amazonses.com ([54.240.27.188]:34968 "EHLO a27-188.smtp-out.us-west-2.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728374AbfLECFg (ORCPT ); Wed, 4 Dec 2019 21:05:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=zsmsymrwgfyinv5wlfyidntwsjeeldzt; d=codeaurora.org; t=1575511535; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; bh=eV5UQc0Nv02TJNdhFWZaDHRnQ93t5irlSEirUDqpNEo=; b=jTNEu15A6/gouO49J5YvppTGbJARs8FLUDiJaGy7+AO8y8LKkfV0JUb3HeMPLBDw QMP4ZSV3E0rAGwsTqg0wvBvnQHLdUAyCQe7vtusVtWAfb+kBK5z0ZWx6XwMGCju88OA ZtBXJH2LfaEQ8ZWPgSxlRv4a/usCjV4mrTyJhxC4= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=gdwg2y3kokkkj5a55z2ilkup5wp5hhxx; d=amazonses.com; t=1575511535; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:Feedback-ID; bh=eV5UQc0Nv02TJNdhFWZaDHRnQ93t5irlSEirUDqpNEo=; b=McOewTk7yM5EDBJ0dvAphAFv4JgZDYecZngrgqgB/zU5F8QMLz8sxCBCTWi0dQ+S lSZH6msWSeT8ZelmX6BSoo5QuI8jmN2mIdzALz7a+rGvZTl9ful6sVHjb5cX98tsSbb sbLS4D8wFa4gl0LB9/h2IuK/chlQbsHDKnFtjLdc= 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 E7974C64313 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 v5 5/5] scsi: ufs: Do not free irq in suspend Date: Thu, 5 Dec 2019 02:05:35 +0000 Message-ID: <0101016ed3ce2e27-04f59930-fe71-4290-a028-c71e8310ca49-000000@us-west-2.amazonses.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1575511482-15115-1-git-send-email-cang@codeaurora.org> References: <1575511482-15115-1-git-send-email-cang@codeaurora.org> X-SES-Outgoing: 2019.12.05-54.240.27.188 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 --- 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)