From patchwork Tue Dec 8 05:49:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanley Chu X-Patchwork-Id: 340137 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61C7AC4361B for ; Tue, 8 Dec 2020 05:51:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1FBA623A68 for ; Tue, 8 Dec 2020 05:51:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726621AbgLHFun (ORCPT ); Tue, 8 Dec 2020 00:50:43 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:33695 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726338AbgLHFun (ORCPT ); Tue, 8 Dec 2020 00:50:43 -0500 X-UUID: ccabb92cb51d4d8eb6a95319ccbc93ab-20201208 X-UUID: ccabb92cb51d4d8eb6a95319ccbc93ab-20201208 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1708644948; Tue, 08 Dec 2020 13:49:57 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs02n2.mediatek.inc (172.21.101.101) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 8 Dec 2020 13:49:42 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 8 Dec 2020 13:49:42 +0800 From: Stanley Chu To: , , , , CC: , , , , , , , , , , , , , , , , Stanley Chu Subject: [PATCH v1] scsi: ufs: Ensure WriteBooster to be re-enabled after device reset Date: Tue, 8 Dec 2020 13:49:40 +0800 Message-ID: <20201208054940.1855-1-stanley.chu@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-TM-SNTS-SMTP: EE9471868BCE6F5EBDE13344911B30D28E13E0E7A3F5D3E610102976C6D9DA642000:8 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org UFS 3.1 specification mentions that below WriteBooster flags will be set to default value, say disabled, after power cycle or any type of reset event. Thus we need to reset those flag variables kept in struct hba to align the device status and ensure WriteBooster related functions being configured properly after device reset. Without this fix, WriteBooster will not be enabled successfully by ufshcd_wb_ctrl() after device reset because hba->wb_enabled remains as true. Flags required to be reset to default values: - fWriteBoosterEn: hba->wb_enabled - fWriteBoosterBufferFlushEn: hba->wb_buf_flush_enabled - fWriteBoosterBufferFlushDuringHibernate: No variable mapped Signed-off-by: Stanley Chu --- drivers/scsi/ufs/ufshcd.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 7a7e056a33a9..c22887bee788 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -1218,8 +1218,11 @@ static inline void ufshcd_vops_device_reset(struct ufs_hba *hba) if (hba->vops && hba->vops->device_reset) { int err = hba->vops->device_reset(hba); - if (!err) + if (!err) { ufshcd_set_ufs_dev_active(hba); + hba->wb_enabled = false; + hba->wb_buf_flush_enabled = false; + } if (err != -EOPNOTSUPP) ufshcd_update_reg_hist(&hba->ufs_stats.dev_reset, err); }