From patchwork Mon Oct 28 03:50:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 11214579 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 E76E7112B for ; Mon, 28 Oct 2019 03:50:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C296520659 for ; Mon, 28 Oct 2019 03:50: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="DBF0dwhJ"; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="DBF0dwhJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731185AbfJ1DuY (ORCPT ); Sun, 27 Oct 2019 23:50:24 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:44456 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729328AbfJ1DuY (ORCPT ); Sun, 27 Oct 2019 23:50:24 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 95D4860923; Mon, 28 Oct 2019 03:50:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1572234623; bh=nYsj8+XlqvZXU8+YArrtKzF6E8RdJ5PaJUfkJ9li9Nc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DBF0dwhJW1mCqXixjsvO69nPsuKT6OB8rKfTQBYQSJfsw1kfKxN2+Nj2+Od29NMR4 MZoZCPkZBVyWXfmQtFyEnSG5pKDI+/UfdmN7R1+pnQSPxRSAwM65zfcrdtW/ZBfLd0 kqtdRF2TDYG+kpyrBmzxEijEEGYE7V1Xxl+SMOq8= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED,SPF_NONE autolearn=no autolearn_force=no version=3.4.0 Received: from pacamara-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: cang@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id C5BA060863; Mon, 28 Oct 2019 03:50:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1572234623; bh=nYsj8+XlqvZXU8+YArrtKzF6E8RdJ5PaJUfkJ9li9Nc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DBF0dwhJW1mCqXixjsvO69nPsuKT6OB8rKfTQBYQSJfsw1kfKxN2+Nj2+Od29NMR4 MZoZCPkZBVyWXfmQtFyEnSG5pKDI+/UfdmN7R1+pnQSPxRSAwM65zfcrdtW/ZBfLd0 kqtdRF2TDYG+kpyrBmzxEijEEGYE7V1Xxl+SMOq8= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org C5BA060863 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.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 v1 1/5] scsi: Adjust DBD setting in mode sense for caching mode page per LLD Date: Sun, 27 Oct 2019 20:50:03 -0700 Message-Id: <1572234608-32654-2-git-send-email-cang@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1572234608-32654-1-git-send-email-cang@codeaurora.org> References: <1572234608-32654-1-git-send-email-cang@codeaurora.org> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Host sends MODE_SENSE_10 with caching mode page, to check if the device supports the cache feature. Some LLD standards requires DBD field to be set to 1. This patch allows LLD to define the setting of DBD if required. Change-Id: I0c8752c1888654942d6d7e6e0f6dc197033ac326 Signed-off-by: Can Guo --- drivers/scsi/sd.c | 6 +++++- include/scsi/scsi_host.h | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index aab4ed8..6d8194f 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2629,6 +2629,7 @@ static int sd_try_rc16_first(struct scsi_device *sdp) { int len = 0, res; struct scsi_device *sdp = sdkp->device; + struct Scsi_Host *host = sdp->host; int dbd; int modepage; @@ -2660,7 +2661,10 @@ static int sd_try_rc16_first(struct scsi_device *sdp) dbd = 8; } else { modepage = 8; - dbd = 0; + if (host->set_dbd_for_caching) + dbd = 8; + else + dbd = 0; } /* cautiously ask */ diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 2c3f0c5..3900987 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -650,6 +650,12 @@ struct Scsi_Host { unsigned no_scsi2_lun_in_cdb:1; /* + * Set "DBD" field in mode_sense caching mode page in case it is + * mandatory by LLD standard. + */ + unsigned set_dbd_for_caching:1; + + /* * Optional work queue to be utilized by the transport */ char work_q_name[20]; From patchwork Mon Oct 28 03:50: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: 11214581 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 1FB6A1920 for ; Mon, 28 Oct 2019 03:50:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EF41C20659 for ; Mon, 28 Oct 2019 03:50: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="Q13ynTwv"; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="SzzhX6Mn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731228AbfJ1Dud (ORCPT ); Sun, 27 Oct 2019 23:50:33 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:44698 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729328AbfJ1Duc (ORCPT ); Sun, 27 Oct 2019 23:50:32 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id E807060A64; Mon, 28 Oct 2019 03:50:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1572234631; bh=uEBoBrBG5ktqI6Dtolluu4zSzdP5Q/x7XfLs0sadKIE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q13ynTwvz9GayVSjY+MrLwlkN3rZac/Lc2i21n5oqTzXvfmq6dJhh5xI6ARHQG5St k483XE+BqGYTzGpG4Ujga8DcIqDjijxCQxLpBOp740Srj0RYyknxiVPlLEPezthrnS vRvFcIeXXSe1hZXaIEytX78CZfRQIbK1cHDGDcQA= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED,SPF_NONE autolearn=no autolearn_force=no version=3.4.0 Received: from pacamara-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: cang@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 316C060930; Mon, 28 Oct 2019 03:50:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1572234630; bh=uEBoBrBG5ktqI6Dtolluu4zSzdP5Q/x7XfLs0sadKIE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SzzhX6MnHtotIxzXcAYPx4Z8BoCwTQSo54CGIAv4xpL/4skiQST0TTV6cPFFgEjTe Vn9DSZPv1NsEecsFchQBS8IZXW6qcgyZFT1vTSrSWG6c5ws22pqNYeMMC1Pci5qSre 10ihH70G1XzH0viveRiCDQ3n/3PONNrDIyh63GTY= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 316C060930 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.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 , Subhash Jadavani , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 2/5] scsi: ufs: Set DBD setting in mode sense for caching mode page Date: Sun, 27 Oct 2019 20:50:04 -0700 Message-Id: <1572234608-32654-3-git-send-email-cang@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1572234608-32654-1-git-send-email-cang@codeaurora.org> References: <1572234608-32654-1-git-send-email-cang@codeaurora.org> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Host sends MODE_SENSE_10 with caching mode page, to check if the device supports the cache feature. UFS standards requires DBD field to be set to 1. 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). As a result of the CHECK_CONDITION response, host assumes that the device doesn't support the cache feature and doesn't send SYNCHORONIZE_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 in case of caching mode page. Change-Id: Ifb674dfcc497a2c9dd9b49556f86979d9a3e4acf Signed-off-by: Can Guo --- 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 c28c144..101b4d0 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -8329,6 +8329,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) host->max_channel = UFSHCD_MAX_CHANNEL; host->unique_id = host->host_no; host->max_cmd_len = UFS_CDB_SIZE; + host->set_dbd_for_caching = 1; hba->max_pwr_info.is_valid = false; From patchwork Mon Oct 28 03:50:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 11214583 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 1EBD81747 for ; Mon, 28 Oct 2019 03:50:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ED0F720873 for ; Mon, 28 Oct 2019 03:50: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="ky5pIumV"; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="cA8REEa9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731267AbfJ1Duk (ORCPT ); Sun, 27 Oct 2019 23:50:40 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:44934 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729328AbfJ1Duj (ORCPT ); Sun, 27 Oct 2019 23:50:39 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 4920660B6E; Mon, 28 Oct 2019 03:50:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1572234639; bh=RJ5p8lSM8JQFxANAulacrnApspWJ3qXOe0QjHj7b2DA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ky5pIumVxXOkyNCgoqhY2mvkXmkC8SPawKc8E4M2bG8ooVBlFIkMqN8j5SiI2WMTR D2NC4El1Dl+VdReqrCUak7EkoFmbdwYeimPJZ06yE6p2UtCYP1RLI7QX/RgBgTIl75 TPFoZoQ3868v7iLa5+fu4YhzizIEAyepaj+B5rLc= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED,SPF_NONE autolearn=no autolearn_force=no version=3.4.0 Received: from pacamara-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: cang@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 73B3660A34; Mon, 28 Oct 2019 03:50:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1572234638; bh=RJ5p8lSM8JQFxANAulacrnApspWJ3qXOe0QjHj7b2DA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cA8REEa9z7q9Zr3rffjSbzulfZwcqlpk0OOKCWGmklooeo7eFhCp4Eoz9op1ns4QE thcGRdaXM24xSovDayg2HH2nh5Y8IBX05d/Rw4NLozJdAkHUCbfS4c6xcl1RpILf1Y QJefrDuF49vfubM9zMqEeSIEUAcX+GffwhTCZ6RU= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 73B3660A34 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.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 , Subhash Jadavani , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 3/5] scsi: ufs: Release clock if DMA map fails Date: Sun, 27 Oct 2019 20:50:05 -0700 Message-Id: <1572234608-32654-4-git-send-email-cang@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1572234608-32654-1-git-send-email-cang@codeaurora.org> References: <1572234608-32654-1-git-send-email-cang@codeaurora.org> 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. Change-Id: Ia3e3e19086c58a27ed2a794fcbbac341e584a474 Signed-off-by: Can Guo --- 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 101b4d0..6e9236a 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 Mon Oct 28 03:50:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 11214585 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 0D0EC1747 for ; Mon, 28 Oct 2019 03:50:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D2DE720873 for ; Mon, 28 Oct 2019 03:50:53 +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="n6f+P6jK"; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="EvILnX+z" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731308AbfJ1Duu (ORCPT ); Sun, 27 Oct 2019 23:50:50 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:45166 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729328AbfJ1Duu (ORCPT ); Sun, 27 Oct 2019 23:50:50 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 05D1F607C3; Mon, 28 Oct 2019 03:50:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1572234649; bh=2CeJJiynBfiiPtkhT7KuxPuZD1ERpgqHk8mmRQakQ0Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n6f+P6jK/V/8/IbIPvRVa67o6nXGMO7y+RcGl7KVylER+7cd9mE5TCziSw+Y8F0CV /hDwylCW7CSVBIjAS5oUwu1/UWiYyXoG9wPjMbpBV1WFi+Osbt/c/7V5zuzqyo9265 23vmXwPhKirEJ23RGVrw6yQ4g/Euyx2wy5/DdPfk= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED,SPF_NONE autolearn=no autolearn_force=no version=3.4.0 Received: from pacamara-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: cang@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 4D7E2602DA; Mon, 28 Oct 2019 03:50:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1572234647; bh=2CeJJiynBfiiPtkhT7KuxPuZD1ERpgqHk8mmRQakQ0Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EvILnX+zrqGP0AaTtuOzEl+rz/bulC8ONZduPcwlda5OAbMRNZ5tFrdTyZZThAbwj STnfsS3sxc9CCUWpDu51VFGeNauaawJZabupDQj8wpTnrxRlLrKU+N3m61Ws1y599C lPGmoIKUJ2CaLRSDpgfSkdxnAgV0unSiBvcqmrUc= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 4D7E2602DA Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.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 , Subhash Jadavani , Greg Kroah-Hartman , Allison Randal , Thomas Gleixner , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 4/5] scsi: ufs: Do not clear the DL layer timers Date: Sun, 27 Oct 2019 20:50:06 -0700 Message-Id: <1572234608-32654-5-git-send-email-cang@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1572234608-32654-1-git-send-email-cang@codeaurora.org> References: <1572234608-32654-1-git-send-email-cang@codeaurora.org> 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. Change-Id: I1a8c02832a185dc4ce9043eee6572ddee89bdcdb Signed-off-by: Can Guo --- 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 6e9236a..34efa8a 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 Mon Oct 28 03:50:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 11214589 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 5A7A41747 for ; Mon, 28 Oct 2019 03:50:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 355DA20873 for ; Mon, 28 Oct 2019 03:50:59 +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="Jb0nUPHo"; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="b0l3abc9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731376AbfJ1Du4 (ORCPT ); Sun, 27 Oct 2019 23:50:56 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:45348 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729328AbfJ1Duz (ORCPT ); Sun, 27 Oct 2019 23:50:55 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 908F060D7C; Mon, 28 Oct 2019 03:50:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1572234654; bh=EIWkMT3gvUX77BQCTSbURXZVaTuCAlizzMnxoMOJpxY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jb0nUPHo/HP9yct2/dEgm2s3/I5D+uEBJKXr+BE4Vp/Oe5OXOHTBxJaMpszaojwYb y9eZOZ+qeNs8pL8EI+RxuqFAGtkTD6sGB+Zi3cKUNwGY5qCkiPjKMAn7qQS1Q16mT1 mDZY58KLMekSmsESJFsNgKyssx1RTaxgzDO8H+sI= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED,SPF_NONE autolearn=no autolearn_force=no version=3.4.0 Received: from pacamara-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: cang@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 3DB4960C8C; Mon, 28 Oct 2019 03:50:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1572234652; bh=EIWkMT3gvUX77BQCTSbURXZVaTuCAlizzMnxoMOJpxY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b0l3abc9+fvuRDskRPFggtCHfHL5cqLcrcdM7F+ORdRLy5hXk/kI8WvWZkdPhXqBd rtrM0EcCBLQ34RX2iufIQHNupaykftPlfY4c315b97hpJs2SV0ueruHyu4BQ7DoUh2 dAzOegsK8G/vzhiol6y6Id03KP8ya0vYFsEOXeK0= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 3DB4960C8C Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.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 , Subhash Jadavani , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 5/5] scsi: ufs: Do not free irq in suspend Date: Sun, 27 Oct 2019 20:50:07 -0700 Message-Id: <1572234608-32654-6-git-send-email-cang@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1572234608-32654-1-git-send-email-cang@codeaurora.org> References: <1572234608-32654-1-git-send-email-cang@codeaurora.org> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org If PM QoS is enabled and we set request type to PM_QOS_REQ_AFFINE_IRQ then freeing up the irq makes the free_irq() print out warning with call stack. We don't really need to free up irq during suspend, disabling it during suspend and reenabling it during resume should be good enough. Change-Id: I4c4033552ae2cd849aeccd98dd517fdeb91c5cb7 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 34efa8a..fb36a51 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; } } @@ -7927,9 +7919,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)