From patchwork Wed Nov 13 06:00:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 11241143 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 BCB7C13BD for ; Wed, 13 Nov 2019 06:00:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9D242222D3 for ; Wed, 13 Nov 2019 06:00:42 +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="VNqbWqVY"; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="cE3LIukx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726165AbfKMGAh (ORCPT ); Wed, 13 Nov 2019 01:00:37 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:34510 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725858AbfKMGAg (ORCPT ); Wed, 13 Nov 2019 01:00:36 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id A08976085C; Wed, 13 Nov 2019 06:00:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1573624835; bh=sN9HQYh6wIVagBIBwBcjFatf2XSTX81OaYD+RTbaeUs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VNqbWqVY/bmzctdrVnkZSUYUle6FSwHzelkaTp7nCr8zdpQnw+WmkmwU32T0GMK+s l+cPbHishAB5bUBn3rWMI2335jm/yNQWfhKEVYMKJ8nSuFsbCNiMfhbxmFEwcAqwn2 +5lp44/NutUc14EVC/5wzk1DYJ5ykHJc+qZjpKv0= 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 368B46085C; Wed, 13 Nov 2019 06:00:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1573624834; bh=sN9HQYh6wIVagBIBwBcjFatf2XSTX81OaYD+RTbaeUs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cE3LIukxnPXlR2D8LxaC1rc2/L2i/wL+rsdNdnqmdde97hKM+kq4n6AMuxbe//EiD 73CD9CvhxW2hNYgm8r8XqliYwhwa8TcKdi4PkNFeJTL2//cbbLpHDMe4OL+Czhr8tz x12ublCLHJy05tgGyhpiO8glnSTKWC0Qm1ZUnDpE= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 368B46085C 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 v4 1/5] scsi: Adjust DBD setting in mode sense for caching mode page per LLD Date: Tue, 12 Nov 2019 22:00:19 -0800 Message-Id: <1573624824-671-2-git-send-email-cang@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1573624824-671-1-git-send-email-cang@codeaurora.org> References: <1573624824-671-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 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 Wed Nov 13 06:00:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 11241145 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 E426314ED for ; Wed, 13 Nov 2019 06:00:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C51BC222CD for ; Wed, 13 Nov 2019 06:00:42 +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="VMka4P0e"; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="PhgUWHIa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726270AbfKMGAm (ORCPT ); Wed, 13 Nov 2019 01:00:42 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:34808 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725858AbfKMGAl (ORCPT ); Wed, 13 Nov 2019 01:00:41 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 27760609CA; Wed, 13 Nov 2019 06:00:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1573624841; bh=Lpc1vPlBXIBVaSueTeC6tHlXeDwYV/+8vGhGZ8ayr4k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VMka4P0er2vaK8jmpvxZPIApaclYofjWrg8DBh3mg3UUgNgfzFyI8bR0rteAcN34h Zh8aT3zn17A7LkqHuJJtHpGb3DYE2S+I0iCglc/XEfjEQAUf8D8hkT1j2lQxbU5t2g ZDcZASaurVqqy5FmyhQnz5wuNCreK+Y6pvQ0/zKw= 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 0C2DD609CA; Wed, 13 Nov 2019 06:00:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1573624839; bh=Lpc1vPlBXIBVaSueTeC6tHlXeDwYV/+8vGhGZ8ayr4k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PhgUWHIavGRVrM8bRR2hXLYKwr9VXJfdYN6QQPlTqznGzmoWnjLzpyZIBJAG6zHSZ lSfu1WuEoDoDru/bJ/+fB5jcqiU0yo7HIr5a/3PdjInYq6IkXkbJBtEliBHnJm86Ur dDq7L6z8Hjmr/K9YWfObZ6goNBtZ7q0VhJ41I+xw= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 0C2DD609CA 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 , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 2/5] scsi: ufs: Use DBD setting in mode sense Date: Tue, 12 Nov 2019 22:00:20 -0800 Message-Id: <1573624824-671-3-git-send-email-cang@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1573624824-671-1-git-send-email-cang@codeaurora.org> References: <1573624824-671-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 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 Wed Nov 13 06:00:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 11241147 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 EC16813BD for ; Wed, 13 Nov 2019 06:00:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CC505222D3 for ; Wed, 13 Nov 2019 06:00:49 +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="o5KllZa6"; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="Rie3pc0v" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726389AbfKMGAq (ORCPT ); Wed, 13 Nov 2019 01:00:46 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:35266 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725858AbfKMGAp (ORCPT ); Wed, 13 Nov 2019 01:00:45 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 52D5860AD9; Wed, 13 Nov 2019 06:00:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1573624845; bh=SbJuVvaOrF0yE78HlWlTZZYlmd3w34F0ZH9Nsx1B6+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o5KllZa6sDsqBPEiz9vBKlUtP5C9ApJLBmWGlV+uGbU5e8WAzA2e+8sBbBexzCIoZ J4kBZdi94avskbYDH7c0qkpUtBXnUBbkjO/uX8IiNsCdSZw/quowBT0bh9vCyVUo9q h/vsoAhdCjJ7CO9GcAjO6KTaPvMJeNSQLLkcYuSM= 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 29C2560A61; Wed, 13 Nov 2019 06:00:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1573624843; bh=SbJuVvaOrF0yE78HlWlTZZYlmd3w34F0ZH9Nsx1B6+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rie3pc0vM+K4KJX7dAzmUl83qy9kKTjmS3BHZ1/KQ8XnCf9FyJnr/P1+tNnRTOljH zh7yroo6Zt+b6hHsVGyztVOBJSuRS50oRgW4TBrN/+6BeV+B6wwm+O78CoGiqpLZda YPFxHglAHoyi29XplDNY4glmuOZdzKelTTuti/fQ= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 29C2560A61 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 , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 3/5] scsi: ufs: Release clock if DMA map fails Date: Tue, 12 Nov 2019 22:00:21 -0800 Message-Id: <1573624824-671-4-git-send-email-cang@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1573624824-671-1-git-send-email-cang@codeaurora.org> References: <1573624824-671-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. 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 Wed Nov 13 06:00:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 11241149 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 D1D5713BD for ; Wed, 13 Nov 2019 06:00:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B09BE222CD for ; Wed, 13 Nov 2019 06:00:57 +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="ZpmK77HP"; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="JgyBd6Nm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726473AbfKMGAy (ORCPT ); Wed, 13 Nov 2019 01:00:54 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:35992 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725858AbfKMGAx (ORCPT ); Wed, 13 Nov 2019 01:00:53 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id CFA9460D7C; Wed, 13 Nov 2019 06:00:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1573624852; bh=zJ/sdUT9LdfUduAIerBsTnBGlicQBgtK9DzFB+Isqqs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZpmK77HPrgeHQdSNABY2KAPkwN3jGi5VePZanfhgA81QWGnFAyWdhUa1zjp6ms2WA 61i2eKaOoBfhwK614a5V0wAuD2UyiLvwNHsVCrmoIIIS4vBv8sVC1lYOqDLux1AcQ5 LWgflp4X00eGezlAMii9B5seiL8Jd/695otmeOdA= 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 98FCC60D37; Wed, 13 Nov 2019 06:00:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1573624850; bh=zJ/sdUT9LdfUduAIerBsTnBGlicQBgtK9DzFB+Isqqs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JgyBd6Nm2mWqVzSwviHmgx1WmWRziSBEIp9WBcDjttf+QZE0vtOMFRQVHBy+toFXH yT4Tyw/7ROL6XY1yjVO/wX2q6wogDN3mMIdxnUKzvittfDe8FVD+krdhHmqvTpGJtT AOHnrKnggpX2Xcx0wRPAr0j7KWkPVbZW/31tyVSQ= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 98FCC60D37 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 , Thomas Gleixner , Allison Randal , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 4/5] scsi: ufs: Do not clear the DL layer timers Date: Tue, 12 Nov 2019 22:00:22 -0800 Message-Id: <1573624824-671-5-git-send-email-cang@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1573624824-671-1-git-send-email-cang@codeaurora.org> References: <1573624824-671-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. 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 Wed Nov 13 06:00:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 11241151 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 3D0CD14ED for ; Wed, 13 Nov 2019 06:01:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1C6C6222D3 for ; Wed, 13 Nov 2019 06:01:04 +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="iAcAbSuh"; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="WxsQl55y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726548AbfKMGBB (ORCPT ); Wed, 13 Nov 2019 01:01:01 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:36260 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725858AbfKMGBA (ORCPT ); Wed, 13 Nov 2019 01:01:00 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 19DA460D88; Wed, 13 Nov 2019 06:00:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1573624859; bh=wj+AeBWg49YIiNe7g8iPRpcUQczXBC+cdiu8/3qKz5g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iAcAbSuh78IQ6HqNYl5XPIW9z3UW1xlFdYr5B5HWke9YexP9g0twSbQSuD9VrXl86 OnmRbOvPAjI3Ky/v8amhPO0X0Hj05dZNlYg4FgAGS4SDRzkNgTdu4IHXrnk5LmNijb EOk5hgx98pi5Nr/4fbG0sp3kisofUHPKRLJN9rMs= 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 4F7E960D7D; Wed, 13 Nov 2019 06:00:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1573624856; bh=wj+AeBWg49YIiNe7g8iPRpcUQczXBC+cdiu8/3qKz5g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WxsQl55y22Fo511ZW/WsyyebKmlwx7MMePxdpFUEevooVZzK0WdySjufi5XEiPF1Y NImbYtm5Y5DLYg+xzc9OvAU/V61mulCrDnbfIKv6fu+4j2QtX3yUGYwwXPd4PQN4QW LWHyVGdrG4QBs3wmTGXftt5lGlQaSJEAQoCpnQA4= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 4F7E960D7D 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 , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 5/5] scsi: ufs: Do not free irq in suspend Date: Tue, 12 Nov 2019 22:00:23 -0800 Message-Id: <1573624824-671-6-git-send-email-cang@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1573624824-671-1-git-send-email-cang@codeaurora.org> References: <1573624824-671-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. 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)