Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3789924pxu; Mon, 30 Nov 2020 10:15:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJw2POjnck7YOEaDLggeNaqkyuNNNnddaJAafx7I6sELv0/Ls68IqTHk+1tKPjyWi+kAHlNC X-Received: by 2002:aa7:df86:: with SMTP id b6mr3830568edy.118.1606760156247; Mon, 30 Nov 2020 10:15:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606760156; cv=none; d=google.com; s=arc-20160816; b=Lw1EDmMb1Qa1llkYfaLgboKO71XdGPceb8UBrs5Yy4IO/cALn3rFj3hfLlJg6Sd7TS mt3Q87iA5lqjtxqkWL545HcCfHuH/cvWA/6P64Wm+/CDd1CJz0wH3idVOQUIztllO2ax zz/gnqxeTU7wqviuXfupOoNXZ6+0cAGyfKLYsoUgDHO3J7AL2+dAPPgILiGiAUCkslC5 4JW+cfcFfr4k4SkZPUN51iLFdJEjfXGkcS26XoGu7U++iOehG295eft1qNgMY3AnjOUG 7SbzGzF8h7MewsYuv7d7VQRASsDJSJOkVQo6pqZ8nYTyUk57lXa0WDbheVFPai4lFS2+ 9Q2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=KDipjwWhvzyuf6p2VfgEeN4YKE0FlgZ/bBRgOjYzpyY=; b=AoA85emnitCvTv8wMPtyJG+99XhXs6QJ0U/uJ5jAWMpVSdHrNFlL84t6/RvzzkFrjf vFQu++r1y+ExzHGNKgKa6/allkViXUdekafa0rrantlod08cmmr4OGj9vRH1SJGdlXqY kr/HyE6htzJEUTa8w3fs97VoG0dMN4e0nU3Rh6khz8dvmRoy/qpbOjBjjogFLhqtWH1T npY5e/qNo7DE5j99FaARTdlr8jmnRR9dxBA064C3u1qy0qWmr6npF3/zmzXXSUpAtp7m X5Mnz7WS3MEn/TbslG2nL7PaEUCl6+JcDK996R2nvH80PrmoFj4tvg0Dq/rZUfHdH4Qh Faqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EhmopWP8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v25si11652703edy.23.2020.11.30.10.15.33; Mon, 30 Nov 2020 10:15:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EhmopWP8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729578AbgK3SMn (ORCPT + 99 others); Mon, 30 Nov 2020 13:12:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726614AbgK3SMm (ORCPT ); Mon, 30 Nov 2020 13:12:42 -0500 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33FC9C0613D4; Mon, 30 Nov 2020 10:12:01 -0800 (PST) Received: by mail-ej1-x642.google.com with SMTP id f9so21360177ejw.4; Mon, 30 Nov 2020 10:12:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KDipjwWhvzyuf6p2VfgEeN4YKE0FlgZ/bBRgOjYzpyY=; b=EhmopWP8k+3dyy/ahXG7QVWF5mrm02rm+rJsQknyFAklct2tM8/WXL2TGheNTOpEDJ YLi0WShSj8mlrpM6kMDyXB/FqofFLwGgxQqDlLX4SODZy8A8C0E9Jc3myNJTSYgvtBMH TAAi0MtTCvr97YBhTIZbvaH36WrjDhWv5QS6297qmDbWT5nnveYoZx/9c9tIKEmo2ee3 jdEmFEABsCvYLnjRY5wFaX2tXu8HpEjrU7sfJVRal//Z4zsEs5k/TVUFyNc22D1N77RR cMYR2PoivYihYf0nYlQfCtcjoPt5NFjIqbcFN578obf2097nkVN9fSVxOpTCMidafBCl JELw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KDipjwWhvzyuf6p2VfgEeN4YKE0FlgZ/bBRgOjYzpyY=; b=PLFxLDQTljkQ1yVr7BNU1G5kMxmfhV9POne4P+fWWKW1QM72po1wta34pzl88x9rR/ cQJ34Uor+QeRY7/GoVdp6puRXsPEB3NoqCbGP6qozZ9ye7nzFirg7fpf6xl1L/G9/mHz Lmo4IRmiFpusuO4Z5HmHS+dM22emXrFzZ4+cl+LfuiS29gOohQcjSfLDX272Coz/syXX yXZdW1HcIPFNVvpCZsMlts02GfTnurBfmvHKiQ9YzmAgUmJi1fltKGdbcYFj593f0ch/ t59KnkcawKhVVKF+IGfDFuGeAiwjbnt0MNLTZSr7B+OrH870huJsbtvCaf311wK9bSyA vZmQ== X-Gm-Message-State: AOAM532OqL/AOR9qi/jLlbIQ+HASTxi2X3BZmXMLX5GlbDn5YFjGIxci 37tL0T6AMvJgZWLb6s1QL+s= X-Received: by 2002:a17:906:edca:: with SMTP id sb10mr22038409ejb.284.1606759919976; Mon, 30 Nov 2020 10:11:59 -0800 (PST) Received: from localhost.localdomain (ip5f5bfce9.dynamic.kabel-deutschland.de. [95.91.252.233]) by smtp.gmail.com with ESMTPSA id d14sm2702899edn.31.2020.11.30.10.11.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2020 10:11:59 -0800 (PST) From: Bean Huo To: alim.akhtar@samsung.com, avri.altman@wdc.com, asutoshd@codeaurora.org, jejb@linux.ibm.com, martin.petersen@oracle.com, stanley.chu@mediatek.com, beanhuo@micron.com, bvanassche@acm.org, tomas.winkler@intel.com, cang@codeaurora.org Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] scsi: ufs: Keep device power on only fWriteBoosterBufferFlushDuringHibernate == 1 Date: Mon, 30 Nov 2020 19:11:42 +0100 Message-Id: <20201130181143.5739-3-huobean@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201130181143.5739-1-huobean@gmail.com> References: <20201130181143.5739-1-huobean@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bean Huo Keep device power mode as active power mode and VCC supply only if fWriteBoosterBufferFlushDuringHibernate setting 1 is successful. Signed-off-by: Bean Huo --- drivers/scsi/ufs/ufs.h | 2 ++ drivers/scsi/ufs/ufshcd.c | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h index d593edb48767..311d5f7a024d 100644 --- a/drivers/scsi/ufs/ufs.h +++ b/drivers/scsi/ufs/ufs.h @@ -530,6 +530,8 @@ struct ufs_dev_info { bool f_power_on_wp_en; /* Keeps information if any of the LU is power on write protected */ bool is_lu_power_on_wp; + /* Indicates if flush WB buffer during hibern8 successfully enabled */ + bool is_hibern8_wb_flush; /* Maximum number of general LU supported by the UFS device */ u8 max_lu_supported; u8 wb_dedicated_lu; diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 639ba9d1ccbb..eb7a2534b072 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -285,10 +285,16 @@ static inline void ufshcd_wb_config(struct ufs_hba *hba) dev_err(hba->dev, "%s: Enable WB failed: %d\n", __func__, ret); else dev_info(hba->dev, "%s: Write Booster Configured\n", __func__); + ret = ufshcd_wb_toggle_flush_during_h8(hba, true); - if (ret) + if (ret) { dev_err(hba->dev, "%s: En WB flush during H8: failed: %d\n", __func__, ret); + hba->dev_info.is_hibern8_wb_flush = false; + } else { + hba->dev_info.is_hibern8_wb_flush = true; + } + ufshcd_wb_toggle_flush(hba, true); } @@ -5440,6 +5446,9 @@ static bool ufshcd_wb_need_flush(struct ufs_hba *hba) if (!ufshcd_is_wb_allowed(hba)) return false; + + if (!hba->dev_info.is_hibern8_wb_flush) + return false; /* * The ufs device needs the vcc to be ON to flush. * With user-space reduction enabled, it's enough to enable flush -- 2.17.1