From patchwork Tue Dec 15 23:05:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bean Huo X-Patchwork-Id: 344245 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 A9356C3526A for ; Wed, 16 Dec 2020 00:08:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E9FC22D05 for ; Wed, 16 Dec 2020 00:08:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727402AbgLPAAs (ORCPT ); Tue, 15 Dec 2020 19:00:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731098AbgLOXGN (ORCPT ); Tue, 15 Dec 2020 18:06:13 -0500 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F64CC061794; Tue, 15 Dec 2020 15:05:33 -0800 (PST) Received: by mail-ed1-x544.google.com with SMTP id j16so411391edr.0; Tue, 15 Dec 2020 15:05:33 -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=oJnf3OFO0XClYikA9ANVukXEGShzeRAmdEjfXqQ0FLg=; b=NOLVav7C+5Y4INpJRWqh5mcXQUAuBGeVUpcEFK7XN7fZdsR/5+EcirjqcwMReohzid 7GRXtJXbDRLsDvy3NH+qKqbe84e09eu4ONiBaqFcNTJP+KQLoSV/XzHasRL3YFLYoiOf Zf9LVWZDAaQUMxKt8mysNXL0XNbLPb9/vypTND6ASL9UqxssOiyte4t4jXL5hdl4Zhk/ 7kFU4Znocnzkvvmm8aI/cWp0XIlrtSh0ZSPUVi9I/IH6eXa9IDdmTH1BJg8g4+/kzVf7 V61m2AcDa2fH7Izo9WbQ1AyeZNyAd0vUIx2kIeDYpU+/Y5km+rHSYM5i0go0nV94rfDq 3BEw== 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=oJnf3OFO0XClYikA9ANVukXEGShzeRAmdEjfXqQ0FLg=; b=t0rG5y+jGyidPQzbkWBJEhFbbvd0tGy1esnckNJ2IesXMIWzVJ+Dty1Yb7mZQrr+JN w7srlUF9uw6fYQLH78MDrUy9W9PKXilIbqN8CbORTa5xmAvbe0cx3BP1iInOWtigUl8l Pb9WEpUSz9UAeH0LlX/6CpYdfRuRrPu92o0aKb7UQsglgSpOM61RLkGtsLW+g961p2g4 nbvYN6HROzZqpXCvuXD5cJNjnf4XzdEt8m3LGYNOMrqhKC/KZqcvN47375uSag2isNoM yTStpFYcyRNOJdBVhuzYwY/ZusWCY+7hA731U8sDKKMdrO56Ft0HKTf0kDVPrtzySmmj oIiA== X-Gm-Message-State: AOAM5317oCzviP2JFGZWFCUC6euQ6V0/Ck4mOJu9O6WfHiAm9rPmpaIi 0yZolSuB+1BT+VWy0ZQSfr8= X-Google-Smtp-Source: ABdhPJxpJwrTZ1KEOg4YS4/Ven+uNCxhkC2F/AoKAPzXf3tiCmHwJ8BJV9qN/Z6gIzo539MQku2d8w== X-Received: by 2002:a05:6402:1caa:: with SMTP id cz10mr31856890edb.345.1608073531959; Tue, 15 Dec 2020 15:05:31 -0800 (PST) Received: from localhost.localdomain (ip5f5bfce9.dynamic.kabel-deutschland.de. [95.91.252.233]) by smtp.gmail.com with ESMTPSA id e11sm19280455edj.44.2020.12.15.15.05.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Dec 2020 15:05:31 -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 v5 1/7] scsi: ufs: Add "wb_on" sysfs node to control WB on/off Date: Wed, 16 Dec 2020 00:05:13 +0100 Message-Id: <20201215230519.15158-2-huobean@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201215230519.15158-1-huobean@gmail.com> References: <20201215230519.15158-1-huobean@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Bean Huo Currently UFS WriteBooster driver uses clock scaling up/down to set WB on/off, for the platform which doesn't support UFSHCD_CAP_CLK_SCALING, WB will be always on. Provide a sysfs attribute to enable/disable WB during runtime. Write 1/0 to "wb_on" sysfs node to enable/disable UFS WB. Reviewed-by: Avri Altman Reviewed-by: Stanley Chu Signed-off-by: Bean Huo --- drivers/scsi/ufs/ufs-sysfs.c | 41 ++++++++++++++++++++++++++++++++++++ drivers/scsi/ufs/ufshcd.c | 3 +-- drivers/scsi/ufs/ufshcd.h | 2 ++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c index 08e72b7eef6a..f3ca3d6b82c4 100644 --- a/drivers/scsi/ufs/ufs-sysfs.c +++ b/drivers/scsi/ufs/ufs-sysfs.c @@ -189,6 +189,45 @@ static ssize_t auto_hibern8_store(struct device *dev, return count; } +static ssize_t wb_on_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct ufs_hba *hba = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", hba->wb_enabled); +} + +static ssize_t wb_on_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct ufs_hba *hba = dev_get_drvdata(dev); + unsigned int wb_enable; + ssize_t res; + + if (ufshcd_is_clkscaling_supported(hba)) { + /* + * If the platform supports UFSHCD_CAP_CLK_SCALING, turn WB + * on/off will be done while clock scaling up/down. + */ + dev_warn(dev, "To control WB through wb_on is not allowed!\n"); + return -EOPNOTSUPP; + } + if (!ufshcd_is_wb_allowed(hba)) + return -EOPNOTSUPP; + + if (kstrtouint(buf, 0, &wb_enable)) + return -EINVAL; + + if (wb_enable != 0 && wb_enable != 1) + return -EINVAL; + + pm_runtime_get_sync(hba->dev); + res = ufshcd_wb_ctrl(hba, wb_enable); + pm_runtime_put_sync(hba->dev); + + return res < 0 ? res : count; +} + static DEVICE_ATTR_RW(rpm_lvl); static DEVICE_ATTR_RO(rpm_target_dev_state); static DEVICE_ATTR_RO(rpm_target_link_state); @@ -196,6 +235,7 @@ static DEVICE_ATTR_RW(spm_lvl); static DEVICE_ATTR_RO(spm_target_dev_state); static DEVICE_ATTR_RO(spm_target_link_state); static DEVICE_ATTR_RW(auto_hibern8); +static DEVICE_ATTR_RW(wb_on); static struct attribute *ufs_sysfs_ufshcd_attrs[] = { &dev_attr_rpm_lvl.attr, @@ -205,6 +245,7 @@ static struct attribute *ufs_sysfs_ufshcd_attrs[] = { &dev_attr_spm_target_dev_state.attr, &dev_attr_spm_target_link_state.attr, &dev_attr_auto_hibern8.attr, + &dev_attr_wb_on.attr, NULL }; diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index e221add25a7e..5e1dcf4de67e 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -246,7 +246,6 @@ static inline int ufshcd_config_vreg_hpm(struct ufs_hba *hba, static int ufshcd_try_to_abort_task(struct ufs_hba *hba, int tag); static int ufshcd_wb_buf_flush_enable(struct ufs_hba *hba); static int ufshcd_wb_buf_flush_disable(struct ufs_hba *hba); -static int ufshcd_wb_ctrl(struct ufs_hba *hba, bool enable); static int ufshcd_wb_toggle_flush_during_h8(struct ufs_hba *hba, bool set); static inline void ufshcd_wb_toggle_flush(struct ufs_hba *hba, bool enable); static void ufshcd_hba_vreg_set_lpm(struct ufs_hba *hba); @@ -5351,7 +5350,7 @@ static void ufshcd_bkops_exception_event_handler(struct ufs_hba *hba) __func__, err); } -static int ufshcd_wb_ctrl(struct ufs_hba *hba, bool enable) +int ufshcd_wb_ctrl(struct ufs_hba *hba, bool enable) { int ret; u8 index; diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 9bb5f0ed4124..2a97006a2c93 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -1068,6 +1068,8 @@ int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba, u8 *desc_buff, int *buff_len, enum query_opcode desc_op); +int ufshcd_wb_ctrl(struct ufs_hba *hba, bool enable); + /* Wrapper functions for safely calling variant operations */ static inline const char *ufshcd_get_var_name(struct ufs_hba *hba) { From patchwork Tue Dec 15 23:05:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bean Huo X-Patchwork-Id: 344756 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 BDB81C3526B for ; Wed, 16 Dec 2020 00:08:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9564D22D07 for ; Wed, 16 Dec 2020 00:08:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727406AbgLPAAt (ORCPT ); Tue, 15 Dec 2020 19:00:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731224AbgLOXGO (ORCPT ); Tue, 15 Dec 2020 18:06:14 -0500 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E51CC06179C; Tue, 15 Dec 2020 15:05:34 -0800 (PST) Received: by mail-ej1-x641.google.com with SMTP id q22so12314705eja.2; Tue, 15 Dec 2020 15:05:34 -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=UA9lHOsQsRrkKAcdZ8/uAX/YO+6TM8c289Nn7aSmqEg=; b=VOGv5uDHRJKxSSjAac0HWnwkGX0jib/wf6oafOg+aJl30V/K7X9QDWUA1bxRlEA9Va qbVSJOgBBHSHTN1eF5lYj86uI5WQvED3wEuXhjGYaVJk8BbiGbsHZnbg4rLy0xaCroeQ ZY40B+2sj/XRoYKTNJTO7dY4imH83uaXibnj62Vh+mT4L71s75Lrfl6FIy6tOwEQrK5k Xumcsui8Dc0JA4diHUaDLZXDWcBXTkHX6fAj2eT5vQVTcTBa/ouwB1jxnWyrox7FnRmu Rubptq1Yao+4Qwj7XFfvgwGGI7+cuHXfagoIkrBMxacKgzN5f6hvDoE70fPtu3KpZ8dJ mcmA== 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=UA9lHOsQsRrkKAcdZ8/uAX/YO+6TM8c289Nn7aSmqEg=; b=B95kH1j6oJaGPGi5yEpD3hUZCJwkzTNkYFvkBAuhAono9l6rDnBngsyK0Aa+VTKdKk sH5um5KTW/gGYv7cDMP9v5gIIl5WKVUctPnhU9xnaC7j1hJ2R5K/iluZOf6w35G+BhNP krH3eBybD6bYTWWcmKxR0nQI610KioFMOVpXx2ciDlq786T5GNMbED7C9qMm9jV41W5C sqXYCO97ZxX3/8cSzNB2yy39xKlZLTiBUc0kQslEEaUzmiU4PDpZdP9ASoB7JOulV4FF oemcbT2ks9XEDZ64x34I+vXwaRxq+TWvMBmoFY322E6D+oQimJzLEfGKMAxVfUAuuExn Ir4w== X-Gm-Message-State: AOAM5301XTD8nm5pr6pf+AApRGRWqCVyoT+bqWOGH2DIwJQmiWI99119 lYlTVywo4ZBdAF7/x2yVfcs= X-Google-Smtp-Source: ABdhPJyvslV0GKJwsm2/Oggw/x+4kQhfQO4gMgXIoCDvtb0U25TgFt95ts4guUArXt6+Ww7xain7OA== X-Received: by 2002:a17:906:cd14:: with SMTP id oz20mr26773171ejb.99.1608073532980; Tue, 15 Dec 2020 15:05:32 -0800 (PST) Received: from localhost.localdomain (ip5f5bfce9.dynamic.kabel-deutschland.de. [95.91.252.233]) by smtp.gmail.com with ESMTPSA id e11sm19280455edj.44.2020.12.15.15.05.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Dec 2020 15:05:32 -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 v5 2/7] docs: ABI: Add wb_on documentation for UFS sysfs Date: Wed, 16 Dec 2020 00:05:14 +0100 Message-Id: <20201215230519.15158-3-huobean@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201215230519.15158-1-huobean@gmail.com> References: <20201215230519.15158-1-huobean@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Bean Huo Adds UFS sysfs documentation for new entry wb_on. Signed-off-by: Bean Huo --- Documentation/ABI/testing/sysfs-driver-ufs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-driver-ufs b/Documentation/ABI/testing/sysfs-driver-ufs index d1a352194d2e..5a70d541b2f2 100644 --- a/Documentation/ABI/testing/sysfs-driver-ufs +++ b/Documentation/ABI/testing/sysfs-driver-ufs @@ -1019,3 +1019,11 @@ Contact: Asutosh Das Description: This entry shows the configured size of WriteBooster buffer. 0400h corresponds to 4GB. The file is read only. + +What: /sys/bus/platform/drivers/ufshcd/*/wb_on +Date: December 2020 +Contact: Bean Huo +Description: This sets or displays whether UFS WriteBooster is enabled. Echo + 0 into this file to disable UFS WriteBooster or 1 to enable it. Note, + this is only allowed for the platform doesen't support + UFSHCD_CAP_CLK_SCALING. From patchwork Tue Dec 15 23:05:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bean Huo X-Patchwork-Id: 344246 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 13F98C2BBCA for ; Tue, 15 Dec 2020 23:21:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DAADE23716 for ; Tue, 15 Dec 2020 23:21:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730173AbgLOXOi (ORCPT ); Tue, 15 Dec 2020 18:14:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731267AbgLOXG3 (ORCPT ); Tue, 15 Dec 2020 18:06:29 -0500 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C969C0617A6; Tue, 15 Dec 2020 15:05:35 -0800 (PST) Received: by mail-ed1-x544.google.com with SMTP id v22so22812834edt.9; Tue, 15 Dec 2020 15:05:35 -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 :mime-version:content-transfer-encoding; bh=U7gSLsQcFEBe8WcOSAmmf0rsSetrSeSprNaqCiGaY3w=; b=p7QZrjOWEW1fKm2OJzcU0KfGZJMFzjwomRtDwiT6mPvlxnm2fz8Mg21qMrtI/Sc8mc bQ5pubBuIQzwQdz3V4QOw7i0A5kwtqA7p41k0oRZRzZti5KBwDA64TPqxX00hrVV0J4M WUnlIjsSWJVE/bfD5q4/NRN/BjgoYEj8FO7CnAjTHugtijJny151JHZ3jHgQ/z26abQ1 St5vhcznMdYM50kdZCN2qzShyYbxyvcnD81bWqW0QFCnY4IqLDcySVao0IE9esRCMElo jpr7Crk4vN3AGwWB8G23+UjXTCWS5mX6LhvAAorD2gd2W73CRVqq1EwQtDCkPgXSrKJh 4pXQ== 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:mime-version:content-transfer-encoding; bh=U7gSLsQcFEBe8WcOSAmmf0rsSetrSeSprNaqCiGaY3w=; b=MrtbYM9jivun2mEbAFYTgI6kp6++skyARctAyv2vasxQfgPe3S6tBIxUjwcQZhr+0F nEPTDIS8KFq9e77d2Xkky3ynrZZ1YU5QmgeYQoZwTMNYfR2k0omLWLYL8QOxvuLquV2m nIgqGZcR/+AJWDSkV3G0gaxLHNmbpdfdrKvDBkR463HcE6BcmI1TS6pzYG/9g7ohY74w nVWvauaMxJ9gv8s2Qxv0kwk977Fr2wQ2NbYljvqtpmp5fkX4fivH/paAepvPA/Zbyrv9 uxrk6Ic0yhXKfzBtFJXGDRbA1rVLGYVP7wIzV9JCOIPEPDMX3R6eetfafRB3DaXATgqc Uq7A== X-Gm-Message-State: AOAM532XJDgktQ5JDMga0vhQBANg8ZfqtBAgsSLgiustc5dd9mq+Axe6 0Gx5WHeLLCvY114/STrizBffLFiAxQxLGg== X-Google-Smtp-Source: ABdhPJzlbCm1Ix7xpZSKUCODk/9+hASTPRadOFNIXfBJn/05Q8v99p12SqQqW4/kudJzfllprV8nKA== X-Received: by 2002:aa7:c0d6:: with SMTP id j22mr16783093edp.31.1608073533984; Tue, 15 Dec 2020 15:05:33 -0800 (PST) Received: from localhost.localdomain (ip5f5bfce9.dynamic.kabel-deutschland.de. [95.91.252.233]) by smtp.gmail.com with ESMTPSA id e11sm19280455edj.44.2020.12.15.15.05.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Dec 2020 15:05:33 -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 v5 3/7] scsi: ufs: Changes comment in the function ufshcd_wb_probe() Date: Wed, 16 Dec 2020 00:05:15 +0100 Message-Id: <20201215230519.15158-4-huobean@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201215230519.15158-1-huobean@gmail.com> References: <20201215230519.15158-1-huobean@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Bean Huo USFHCD supports WriteBooster "LU dedicated buffer” mode and “shared buffer” mode both, so changes the comment in the function ufshcd_wb_probe(). Reviewed-by: Can Guo Reviewed-by: Stanley Chu Signed-off-by: Bean Huo --- drivers/scsi/ufs/ufshcd.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 5e1dcf4de67e..6a5532b752aa 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -7232,10 +7232,9 @@ static void ufshcd_wb_probe(struct ufs_hba *hba, u8 *desc_buf) goto wb_disabled; /* - * WB may be supported but not configured while provisioning. - * The spec says, in dedicated wb buffer mode, - * a max of 1 lun would have wb buffer configured. - * Now only shared buffer mode is supported. + * WB may be supported but not configured while provisioning. The spec + * says, in dedicated wb buffer mode, a max of 1 lun would have wb + * buffer configured. */ dev_info->b_wb_buffer_type = desc_buf[DEVICE_DESC_PARAM_WB_TYPE]; From patchwork Tue Dec 15 23:05:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bean Huo X-Patchwork-Id: 344759 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 237B2C4361B for ; Tue, 15 Dec 2020 23:14:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D944F22D02 for ; Tue, 15 Dec 2020 23:14:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727841AbgLOXOf (ORCPT ); Tue, 15 Dec 2020 18:14:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731252AbgLOXG3 (ORCPT ); Tue, 15 Dec 2020 18:06:29 -0500 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C8D7C0617A7; Tue, 15 Dec 2020 15:05:36 -0800 (PST) Received: by mail-ed1-x544.google.com with SMTP id p22so22794169edu.11; Tue, 15 Dec 2020 15:05:36 -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=hfStZcmj6KeW2zkSZcYnBiE6Gi5znfpneu3gU+gm3Ms=; b=JS9wwCE3n53YJbbqCNVUqTP6v+7T2q9D9natTb+Qhk82C8DmcQBjUSyJaJYy8L7v00 QjMqZKdrQuM/li3FmMB0Xk1I9pahd787WtutVhLE2qjNncq2dqKUwYzJg8keuxghCuza nccxhLUCTGLMeqy4xE64CQY2Fa/p/7Xxxye9X8lNbfhv8M+2LpWqf2Hoj0oDqadJOjXv +RyntaJic1WKg46bl4glZ9K1IIgOCY7I1UoWeutIWBHtqcxIWyo/jeNrdfOuVOG/6sZt OG212VhQsRgykK3BFITTvlx7kPpThqGc/DdKVEuayzV4eLDpC3WfTjzWvyWn2o4OkVuD 3qvw== 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=hfStZcmj6KeW2zkSZcYnBiE6Gi5znfpneu3gU+gm3Ms=; b=Mbc9c3uuPYjJjGDF/h2RgMrJ7fJipDRzdbe0LKpjZGw8V3z3Uwo8Ybt+T82EfHKNl6 U7eGa+4m9AjNxal5Rnr12u2+ucVmiMfvNFh52/Kdid5CVDMl93ktiV2OGLbmVJ9F6SGb /37gYDMiqGo/GBKxxULo48Hs6mKLtn7Bq2lO/njO9wLPSiiQDWwV9Pqav2gS2uep+Wk7 WXoHqHnf9Ak+b0jH5dJOlDg27FX4IErIpTPwvg6o62/F4M5ARVnix5ulfYbO6SgyBmgo c6a4V14ZDEApkeHxf/ZRaHZAIkXzGDZK1oGX6Vmm9EPGWnMhYw1zvRysQIKlCS4MTT9Z HoIw== X-Gm-Message-State: AOAM530QHf4JuHmllvd7rMNHe1AYLWV4VkCfTECCLMu4JGYom7TIyVZW To9ZuHNSQZVn2WJxat1Brc0= X-Google-Smtp-Source: ABdhPJxptQIHrQQy8Ik5bKwyfUmKxTKId3Zzso6A03IVgc0alcr2+q8z+ngyeLM1qKsxr4w37EoRQA== X-Received: by 2002:a05:6402:d09:: with SMTP id eb9mr31073849edb.71.1608073535037; Tue, 15 Dec 2020 15:05:35 -0800 (PST) Received: from localhost.localdomain (ip5f5bfce9.dynamic.kabel-deutschland.de. [95.91.252.233]) by smtp.gmail.com with ESMTPSA id e11sm19280455edj.44.2020.12.15.15.05.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Dec 2020 15:05:34 -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 v5 4/7] scsi: ufs: Remove two WB related fields from struct ufs_dev_info Date: Wed, 16 Dec 2020 00:05:16 +0100 Message-Id: <20201215230519.15158-5-huobean@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201215230519.15158-1-huobean@gmail.com> References: <20201215230519.15158-1-huobean@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Bean Huo d_wb_alloc_units and d_ext_ufs_feature_sup only be used while WB probe. They are just used to confirm the condition that "if bWriteBoosterBufferType is set to 01h but dNumSharedWriteBoosterBufferAllocUnits is set to zero, the WriteBooster feature is disabled", and if UFS device supports WB. After that, no user uses them any more. So, don't need to keep time in runtime. Signed-off-by: Bean Huo Reviewed-by: Stanley Chu --- drivers/scsi/ufs/ufs.h | 2 -- drivers/scsi/ufs/ufshcd.c | 14 ++++++-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h index 14dfda735adf..a789e074ae3f 100644 --- a/drivers/scsi/ufs/ufs.h +++ b/drivers/scsi/ufs/ufs.h @@ -538,9 +538,7 @@ struct ufs_dev_info { u8 *model; u16 wspecversion; u32 clk_gating_wait_us; - u32 d_ext_ufs_feature_sup; u8 b_wb_buffer_type; - u32 d_wb_alloc_units; bool b_rpm_dev_flush_capable; u8 b_presrv_uspc_en; }; diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 6a5532b752aa..5f08f4a59a17 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -7207,6 +7207,7 @@ static void ufshcd_wb_probe(struct ufs_hba *hba, u8 *desc_buf) struct ufs_dev_info *dev_info = &hba->dev_info; u8 lun; u32 d_lu_wb_buf_alloc; + u32 ext_ufs_feature; if (!ufshcd_is_wb_allowed(hba)) return; @@ -7224,11 +7225,10 @@ static void ufshcd_wb_probe(struct ufs_hba *hba, u8 *desc_buf) DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP + 4) goto wb_disabled; - dev_info->d_ext_ufs_feature_sup = - get_unaligned_be32(desc_buf + - DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP); + ext_ufs_feature = get_unaligned_be32(desc_buf + + DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP); - if (!(dev_info->d_ext_ufs_feature_sup & UFS_DEV_WRITE_BOOSTER_SUP)) + if (!(ext_ufs_feature & UFS_DEV_WRITE_BOOSTER_SUP)) goto wb_disabled; /* @@ -7243,10 +7243,8 @@ static void ufshcd_wb_probe(struct ufs_hba *hba, u8 *desc_buf) desc_buf[DEVICE_DESC_PARAM_WB_PRESRV_USRSPC_EN]; if (dev_info->b_wb_buffer_type == WB_BUF_MODE_SHARED) { - dev_info->d_wb_alloc_units = - get_unaligned_be32(desc_buf + - DEVICE_DESC_PARAM_WB_SHARED_ALLOC_UNITS); - if (!dev_info->d_wb_alloc_units) + if (!get_unaligned_be32(desc_buf + + DEVICE_DESC_PARAM_WB_SHARED_ALLOC_UNITS)) goto wb_disabled; } else { for (lun = 0; lun < UFS_UPIU_MAX_WB_LUN_ID; lun++) { From patchwork Tue Dec 15 23:05:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bean Huo X-Patchwork-Id: 344758 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 2A64DC2BBCF for ; Tue, 15 Dec 2020 23:21:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F2B0423718 for ; Tue, 15 Dec 2020 23:21:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729624AbgLOXOh (ORCPT ); Tue, 15 Dec 2020 18:14:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731269AbgLOXG3 (ORCPT ); Tue, 15 Dec 2020 18:06:29 -0500 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E184C0617B0; Tue, 15 Dec 2020 15:05:37 -0800 (PST) Received: by mail-ed1-x544.google.com with SMTP id cm17so22855893edb.4; Tue, 15 Dec 2020 15:05:37 -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=qJVIUYjiIMDP3ufzjlA1AMlylGNTKsAGLwNk6au5m3A=; b=ltb4vz86FRnKJFLBpaB+UgoxVwCSZc//5z6LA5UbrILd4AecMhSSwi/CQLTeneEcZN 0IklsvQ6oXlV8CCQS9e7mEQUOSqeodias+tDrl882L4+P+Kjwy7rNpoepfqV8Dq2CzDv sfo8+tLBRUtW16kSUu9C/2BgXecJs8BcyuXqWuokp2i2lgfJl00Qd8HgAMgaocXXmuEA zfcFGEhrXlSoF5qcy01QbRJeP1iQSdWMMRjfs0m8wwFzWiHAYhnFEkijQpGbi4scYlWo WmfIxvpNpFiervHOSB5ZmM7jJXx0uyT4hZ5dlsnDvdMOr+Nu5pjRCMUEHzxzp4wLgzgk v5VA== 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=qJVIUYjiIMDP3ufzjlA1AMlylGNTKsAGLwNk6au5m3A=; b=cVf21KMOrROiqecHODcc5p/7k9tfiOlmW384q8FpDKQysO1vKJp1guPbW2a00METME aq3l2VVRCDghBuo6jKsjwSebQfX18WlzsyzLhKDgwxrBAQkKstD+SSuxmhDhsXGKgqUo pGQjlWKXezr2sGKvq3p3Hm+Qks81KchF3ZNAIUDVhkxJlLdZLsDzpGWL4dNv3lmwR7th vxH/4MlA08CWINKOaN7SwP2uNeM/WqhkKHNfDk/pORBv6HxQZW9jOfHgx7qT9gF4wus2 D66iEckvhT8RcriZGOrPKZtkC8Gai+AlrN54BYhygDmS/IPVpdUUf3f4bUQYI6cEGrmP lRgA== X-Gm-Message-State: AOAM5326h96W5s8poHWoZZwTSZ0H4lEyythiC2e59EzDq+Pn3seZJ4JG QuYrbcF1EdkWFSw+6EpvPcQ= X-Google-Smtp-Source: ABdhPJx8n2tt99c7wQqBpQI0GD+jaIMSHkIicqWSGZY/CCBNYTIl+EPZ6nH5akRhLP+AOGIV9wLotA== X-Received: by 2002:a05:6402:139a:: with SMTP id b26mr31613765edv.47.1608073536068; Tue, 15 Dec 2020 15:05:36 -0800 (PST) Received: from localhost.localdomain (ip5f5bfce9.dynamic.kabel-deutschland.de. [95.91.252.233]) by smtp.gmail.com with ESMTPSA id e11sm19280455edj.44.2020.12.15.15.05.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Dec 2020 15:05:35 -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 v5 5/7] scsi: ufs: Group UFS WB related flags to struct ufs_dev_info Date: Wed, 16 Dec 2020 00:05:17 +0100 Message-Id: <20201215230519.15158-6-huobean@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201215230519.15158-1-huobean@gmail.com> References: <20201215230519.15158-1-huobean@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Bean Huo UFS device-related flags should be grouped in ufs_dev_info. Take wb_enabled and wb_buf_flush_enabled out from the struct ufs_hba, group them to struct ufs_dev_info, and align the names of the structure members vertically. Signed-off-by: Bean Huo Reviewed-by: Can Guo --- drivers/scsi/ufs/ufs-sysfs.c | 2 +- drivers/scsi/ufs/ufs.h | 27 ++++++++++++++++----------- drivers/scsi/ufs/ufshcd.c | 21 ++++++++++----------- drivers/scsi/ufs/ufshcd.h | 4 +--- 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c index f3ca3d6b82c4..9a9acc722a37 100644 --- a/drivers/scsi/ufs/ufs-sysfs.c +++ b/drivers/scsi/ufs/ufs-sysfs.c @@ -194,7 +194,7 @@ static ssize_t wb_on_show(struct device *dev, struct device_attribute *attr, { struct ufs_hba *hba = dev_get_drvdata(dev); - return sysfs_emit(buf, "%d\n", hba->wb_enabled); + return sysfs_emit(buf, "%d\n", hba->dev_info.wb_enabled); } static ssize_t wb_on_store(struct device *dev, struct device_attribute *attr, diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h index a789e074ae3f..ec74cf360b1f 100644 --- a/drivers/scsi/ufs/ufs.h +++ b/drivers/scsi/ufs/ufs.h @@ -527,20 +527,25 @@ struct ufs_vreg_info { }; struct ufs_dev_info { - bool f_power_on_wp_en; + bool f_power_on_wp_en; /* Keeps information if any of the LU is power on write protected */ - bool is_lu_power_on_wp; + bool is_lu_power_on_wp; /* Maximum number of general LU supported by the UFS device */ - u8 max_lu_supported; - u8 wb_dedicated_lu; - u16 wmanufacturerid; + u8 max_lu_supported; + u16 wmanufacturerid; /*UFS device Product Name */ - u8 *model; - u16 wspecversion; - u32 clk_gating_wait_us; - u8 b_wb_buffer_type; - bool b_rpm_dev_flush_capable; - u8 b_presrv_uspc_en; + u8 *model; + u16 wspecversion; + u32 clk_gating_wait_us; + + /* UFS WB related flags */ + bool wb_enabled; + bool wb_buf_flush_enabled; + u8 wb_dedicated_lu; + u8 wb_buffer_type; + + bool b_rpm_dev_flush_capable; + u8 b_presrv_uspc_en; }; /** diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 5f08f4a59a17..466a85051d54 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -589,8 +589,8 @@ static void ufshcd_device_reset(struct ufs_hba *hba) if (!err) { ufshcd_set_ufs_dev_active(hba); if (ufshcd_is_wb_allowed(hba)) { - hba->wb_enabled = false; - hba->wb_buf_flush_enabled = false; + hba->dev_info.wb_enabled = false; + hba->dev_info.wb_buf_flush_enabled = false; } } if (err != -EOPNOTSUPP) @@ -5359,7 +5359,7 @@ int ufshcd_wb_ctrl(struct ufs_hba *hba, bool enable) if (!ufshcd_is_wb_allowed(hba)) return 0; - if (!(enable ^ hba->wb_enabled)) + if (!(enable ^ hba->dev_info.wb_enabled)) return 0; if (enable) opcode = UPIU_QUERY_OPCODE_SET_FLAG; @@ -5375,7 +5375,7 @@ int ufshcd_wb_ctrl(struct ufs_hba *hba, bool enable) return ret; } - hba->wb_enabled = enable; + hba->dev_info.wb_enabled = enable; dev_dbg(hba->dev, "%s write booster %s %d\n", __func__, enable ? "enable" : "disable", ret); @@ -5415,7 +5415,7 @@ static int ufshcd_wb_buf_flush_enable(struct ufs_hba *hba) int ret; u8 index; - if (!ufshcd_is_wb_allowed(hba) || hba->wb_buf_flush_enabled) + if (!ufshcd_is_wb_allowed(hba) || hba->dev_info.wb_buf_flush_enabled) return 0; index = ufshcd_wb_get_query_index(hba); @@ -5426,7 +5426,7 @@ static int ufshcd_wb_buf_flush_enable(struct ufs_hba *hba) dev_err(hba->dev, "%s WB - buf flush enable failed %d\n", __func__, ret); else - hba->wb_buf_flush_enabled = true; + hba->dev_info.wb_buf_flush_enabled = true; dev_dbg(hba->dev, "WB - Flush enabled: %d\n", ret); return ret; @@ -5437,7 +5437,7 @@ static int ufshcd_wb_buf_flush_disable(struct ufs_hba *hba) int ret; u8 index; - if (!ufshcd_is_wb_allowed(hba) || !hba->wb_buf_flush_enabled) + if (!ufshcd_is_wb_allowed(hba) || !hba->dev_info.wb_buf_flush_enabled) return 0; index = ufshcd_wb_get_query_index(hba); @@ -5448,7 +5448,7 @@ static int ufshcd_wb_buf_flush_disable(struct ufs_hba *hba) dev_warn(hba->dev, "%s: WB - buf flush disable failed %d\n", __func__, ret); } else { - hba->wb_buf_flush_enabled = false; + hba->dev_info.wb_buf_flush_enabled = false; dev_dbg(hba->dev, "WB - Flush disabled: %d\n", ret); } @@ -7236,13 +7236,12 @@ static void ufshcd_wb_probe(struct ufs_hba *hba, u8 *desc_buf) * says, in dedicated wb buffer mode, a max of 1 lun would have wb * buffer configured. */ - dev_info->b_wb_buffer_type = - desc_buf[DEVICE_DESC_PARAM_WB_TYPE]; + dev_info->wb_buffer_type = desc_buf[DEVICE_DESC_PARAM_WB_TYPE]; dev_info->b_presrv_uspc_en = desc_buf[DEVICE_DESC_PARAM_WB_PRESRV_USRSPC_EN]; - if (dev_info->b_wb_buffer_type == WB_BUF_MODE_SHARED) { + if (dev_info->wb_buffer_type == WB_BUF_MODE_SHARED) { if (!get_unaligned_be32(desc_buf + DEVICE_DESC_PARAM_WB_SHARED_ALLOC_UNITS)) goto wb_disabled; diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 2a97006a2c93..ee97068158e2 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -805,8 +805,6 @@ struct ufs_hba { struct device bsg_dev; struct request_queue *bsg_queue; - bool wb_buf_flush_enabled; - bool wb_enabled; struct delayed_work rpm_dev_flush_recheck_work; #ifdef CONFIG_SCSI_UFS_CRYPTO @@ -946,7 +944,7 @@ static inline bool ufshcd_keep_autobkops_enabled_except_suspend( static inline u8 ufshcd_wb_get_query_index(struct ufs_hba *hba) { - if (hba->dev_info.b_wb_buffer_type == WB_BUF_MODE_LU_DEDICATED) + if (hba->dev_info.wb_buffer_type == WB_BUF_MODE_LU_DEDICATED) return hba->dev_info.wb_dedicated_lu; return 0; } From patchwork Tue Dec 15 23:05:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bean Huo X-Patchwork-Id: 344247 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 32225C4361B for ; Tue, 15 Dec 2020 23:14:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 045A822D03 for ; Tue, 15 Dec 2020 23:14:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730358AbgLOXOt (ORCPT ); Tue, 15 Dec 2020 18:14:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731272AbgLOXG3 (ORCPT ); Tue, 15 Dec 2020 18:06:29 -0500 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48CAFC06138C; Tue, 15 Dec 2020 15:05:38 -0800 (PST) Received: by mail-ed1-x544.google.com with SMTP id c7so22823373edv.6; Tue, 15 Dec 2020 15:05:38 -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=r4FGDCmd+0tOnQUnhUjyrOq68wQ6sbCmcoaPkblTkR4=; b=SJK4VON4/+ArqS95wzCeyGs8tfpxllXc2Ib6ixSipQ6rDcD9br/DB4LtUVYwLfSiRH 1z1WixGmki5TgSPAorMTGttULKDvMU09XCXElZd1fqXxHI63TP5agReIGhVeik5W33ll IHp2kIPVL9SzDJ1fpm7WJE/R0mgNlXtuA2L1TBh3hNvmDIiCTP59p7CuHwpAzmMBBNZ+ a5yByLWAGvccISFga7gB6sfOe/wlHM89L8L1H6m2BCexDsUgvgSJ+2xmEYNm/qKXv66i KhH4ktJvqxM7q5F2qvlXPhdVhI4ORcmz1V2KJ9jlNijJBDh+2Y3z3CZPU40PCsbjOYy1 8sCw== 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=r4FGDCmd+0tOnQUnhUjyrOq68wQ6sbCmcoaPkblTkR4=; b=YJPjCKT71vOELCQrk5m6TzQLNMYxjZI981q+WdQ09RkqDjfWGlXklE73Tkw/zsTbzu KURmwfg0utp5maIw9pRu5JiDWXRLxRImsI6LoHz6mzUZM7C+0JenK6gxXl1h9zJwvWUT 1iJFtv0sjCPRwjLm4QGhROACqDgP+E8SpsTu0vehmnpzFPDhdqdcuhxmbb0VkjeEyCm5 eTz4NP6py7FzR6RKJz10458Zh2ros43dDDQC5zYVUkGJi4OMzx6U6gIAlsMB3J0SvmST wfqPLBQjdOh7veYw+lQLrMe5GMv6Z0gFJJmyg+CKnCXpEQmcxOJST2Y4hGgCjKm4my23 DkEA== X-Gm-Message-State: AOAM530Ip124JIA0T+zPyT1aTv4mfOMPM4Or7D9vFrKXo5is+cH+UI72 Yyhgi0TOEzqjdOxkMrYf39Y= X-Google-Smtp-Source: ABdhPJzObl9SHeHT0XSe0Qpl97mPQeJb9b5r1dk+z0mrWrJ9ywQUSpiALXbO6rftdANXuu+luCRAIw== X-Received: by 2002:aa7:dc0d:: with SMTP id b13mr31773026edu.170.1608073537030; Tue, 15 Dec 2020 15:05:37 -0800 (PST) Received: from localhost.localdomain (ip5f5bfce9.dynamic.kabel-deutschland.de. [95.91.252.233]) by smtp.gmail.com with ESMTPSA id e11sm19280455edj.44.2020.12.15.15.05.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Dec 2020 15:05:36 -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 v5 6/7] scsi: ufs: Cleanup WB buffer flush toggle implementation Date: Wed, 16 Dec 2020 00:05:18 +0100 Message-Id: <20201215230519.15158-7-huobean@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201215230519.15158-1-huobean@gmail.com> References: <20201215230519.15158-1-huobean@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Bean Huo Delete ufshcd_wb_buf_flush_enable() and ufshcd_wb_buf_flush_disable(), move the implementation into ufshcd_wb_toggle_flush(). Signed-off-by: Bean Huo Reviewed-by: Stanley Chu Reviewed-by: Can Guo --- drivers/scsi/ufs/ufshcd.c | 66 +++++++++++++-------------------------- 1 file changed, 21 insertions(+), 45 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 466a85051d54..ba8298f0d017 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -244,10 +244,8 @@ static int ufshcd_setup_vreg(struct ufs_hba *hba, bool on); static inline int ufshcd_config_vreg_hpm(struct ufs_hba *hba, struct ufs_vreg *vreg); static int ufshcd_try_to_abort_task(struct ufs_hba *hba, int tag); -static int ufshcd_wb_buf_flush_enable(struct ufs_hba *hba); -static int ufshcd_wb_buf_flush_disable(struct ufs_hba *hba); static int ufshcd_wb_toggle_flush_during_h8(struct ufs_hba *hba, bool set); -static inline void ufshcd_wb_toggle_flush(struct ufs_hba *hba, bool enable); +static inline int ufshcd_wb_toggle_flush(struct ufs_hba *hba, bool enable); static void ufshcd_hba_vreg_set_lpm(struct ufs_hba *hba); static void ufshcd_hba_vreg_set_hpm(struct ufs_hba *hba); @@ -5398,60 +5396,38 @@ static int ufshcd_wb_toggle_flush_during_h8(struct ufs_hba *hba, bool set) index, NULL); } -static inline void ufshcd_wb_toggle_flush(struct ufs_hba *hba, bool enable) -{ - if (hba->quirks & UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL) - return; - - if (enable) - ufshcd_wb_buf_flush_enable(hba); - else - ufshcd_wb_buf_flush_disable(hba); - -} - -static int ufshcd_wb_buf_flush_enable(struct ufs_hba *hba) +static inline int ufshcd_wb_toggle_flush(struct ufs_hba *hba, bool enable) { int ret; u8 index; + enum query_opcode opcode; - if (!ufshcd_is_wb_allowed(hba) || hba->dev_info.wb_buf_flush_enabled) + if (hba->quirks & UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL) return 0; - index = ufshcd_wb_get_query_index(hba); - ret = ufshcd_query_flag_retry(hba, UPIU_QUERY_OPCODE_SET_FLAG, - QUERY_FLAG_IDN_WB_BUFF_FLUSH_EN, - index, NULL); - if (ret) - dev_err(hba->dev, "%s WB - buf flush enable failed %d\n", - __func__, ret); - else - hba->dev_info.wb_buf_flush_enabled = true; - - dev_dbg(hba->dev, "WB - Flush enabled: %d\n", ret); - return ret; -} - -static int ufshcd_wb_buf_flush_disable(struct ufs_hba *hba) -{ - int ret; - u8 index; - - if (!ufshcd_is_wb_allowed(hba) || !hba->dev_info.wb_buf_flush_enabled) + if (!ufshcd_is_wb_allowed(hba) || + hba->dev_info.wb_buf_flush_enabled == enable) return 0; + if (enable) + opcode = UPIU_QUERY_OPCODE_SET_FLAG; + else + opcode = UPIU_QUERY_OPCODE_CLEAR_FLAG; + index = ufshcd_wb_get_query_index(hba); - ret = ufshcd_query_flag_retry(hba, UPIU_QUERY_OPCODE_CLEAR_FLAG, - QUERY_FLAG_IDN_WB_BUFF_FLUSH_EN, - index, NULL); + ret = ufshcd_query_flag_retry(hba, opcode, + QUERY_FLAG_IDN_WB_BUFF_FLUSH_EN, index, + NULL); if (ret) { - dev_warn(hba->dev, "%s: WB - buf flush disable failed %d\n", - __func__, ret); - } else { - hba->dev_info.wb_buf_flush_enabled = false; - dev_dbg(hba->dev, "WB - Flush disabled: %d\n", ret); + dev_err(hba->dev, "%s WB-Buf Flush %s failed %d\n", __func__, + enable ? "enable" : "disable", ret); + goto out; } + hba->dev_info.wb_buf_flush_enabled = enable; + + dev_dbg(hba->dev, "WB-Buf Flush %s\n", enable ? "enabled" : "disabled"); +out: return ret; } From patchwork Tue Dec 15 23:05:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bean Huo X-Patchwork-Id: 344248 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 D07DAC4361B for ; Tue, 15 Dec 2020 23:12:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8874022D03 for ; Tue, 15 Dec 2020 23:12:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731471AbgLOXHA (ORCPT ); Tue, 15 Dec 2020 18:07:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730679AbgLOXG5 (ORCPT ); Tue, 15 Dec 2020 18:06:57 -0500 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FF02C061282; Tue, 15 Dec 2020 15:05:39 -0800 (PST) Received: by mail-ed1-x542.google.com with SMTP id cm17so22855954edb.4; Tue, 15 Dec 2020 15:05:39 -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=K3MOm2Pa8a6n6GbvdDyE1PLoBtq3ydXsNpuVZ9ruIkY=; b=LeBj1IEeeI0EuHsDSjJXjs+OrZNmvjWfffinsIOMf2Vz+RmbymgkNgOkGC4/jwtD/I 6EcpXwR1ZIFUIFkviNWw5Ib5qAvaEJhmR/YNKDcXQphu4TofcUUaDlDQwew+VzstfD62 F6Rf/fITIsKMjKHXCR2ENzBkMsbuGuLtVACaDV7FE7qkqQOJYB2Ljd+rsjnbqCslQMLi JPNShsQLcWl07msW/6ZzJUacZLY92UVcd/bbe/eOyf4LuClDo4tQezWXTmJkBYWdcWA8 ZKcTXXZn/DvQJPEmsVrjhfY3NCN6OvUZEjwOG9HbKr2eL7LkYlKo7pzV8wQp4t7VxNm2 MuLg== 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=K3MOm2Pa8a6n6GbvdDyE1PLoBtq3ydXsNpuVZ9ruIkY=; b=rlwgzaD2O6oTePk+J1qvMzlrCVHS5f+IPwRQaOlFxUeiSZ2+bwFkjXfY3vEJ4RmaLV aIApeYeCY4yRv5ncbDx2xHGKFUctu0MungKOTx3cfyR2GJJ+psThNX7DpLMfbdA/QNyl tED3cf8LKl4j5wGOL3kbzCCUxohghbKdkt1HXNDwaIOqouP+y599LXUzOGR67usIjaZv N2m817zN1rzSmT2+T9W/reaCeX54kJkCdNx5R8DUgZSJdmFAAPZvPhAwmRaL2I060qfS XqscTYchlsYjnowT70epiCK3Vq8LvCQgLNS40txKB8be4NCfbc7pli5gCkPPs1s/70hc qJug== X-Gm-Message-State: AOAM5317+bQ85lQe6nhcDMiypPjG+T4rVAmSGsw7B6R9cEzS5DnNdzo2 COZxqNIGxlqn2Fs4g3wjV6M= X-Google-Smtp-Source: ABdhPJyGAjtQeHhLwngoeVLYr3HHgzUUzR0GNDGD5TZX3av3EJ7j3ijAuUV/tpJNgXlEp5mzpj05Fg== X-Received: by 2002:a50:d5c1:: with SMTP id g1mr32331785edj.299.1608073538042; Tue, 15 Dec 2020 15:05:38 -0800 (PST) Received: from localhost.localdomain (ip5f5bfce9.dynamic.kabel-deutschland.de. [95.91.252.233]) by smtp.gmail.com with ESMTPSA id e11sm19280455edj.44.2020.12.15.15.05.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Dec 2020 15:05:37 -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 v5 7/7] scsi: ufs: Keep device active mode only fWriteBoosterBufferFlushDuringHibernate == 1 Date: Wed, 16 Dec 2020 00:05:19 +0100 Message-Id: <20201215230519.15158-8-huobean@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201215230519.15158-1-huobean@gmail.com> References: <20201215230519.15158-1-huobean@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Bean Huo According to the JEDEC UFS 3.1 Spec, If fWriteBoosterBufferFlushDuringHibernate is set to one, the device flushes the WriteBooster Buffer data automatically whenever the link enters the hibernate (HIBERN8) state. While the flushing operation is in progress, the device should be kept in Active power mode. Currently, we set this flag during the UFSHCD probe stage, but we didn't deal with its programming failure. Even this failure is less likely to occur, but still it is possible. This patch is to add checkup of fWriteBoosterBufferFlushDuringHibernate setting, keep the device as "active power mode" only when this flag be successfully set to 1. Fixes: 51dd905bd2f6 ("scsi: ufs: Fix WriteBooster flush during runtime suspend") Signed-off-by: Bean Huo --- drivers/scsi/ufs/ufs.h | 1 + drivers/scsi/ufs/ufshcd.c | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h index ec74cf360b1f..506ae8fab558 100644 --- a/drivers/scsi/ufs/ufs.h +++ b/drivers/scsi/ufs/ufs.h @@ -541,6 +541,7 @@ struct ufs_dev_info { /* UFS WB related flags */ bool wb_enabled; bool wb_buf_flush_enabled; + bool wb_buf_flush_in_hibern8; u8 wb_dedicated_lu; u8 wb_buffer_type; diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index ba8298f0d017..3d9e6f5a7ffe 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -282,10 +282,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.wb_buf_flush_in_hibern8 = false; + } else { + hba->dev_info.wb_buf_flush_in_hibern8 = true; + } + ufshcd_wb_toggle_flush(hba, true); } @@ -589,6 +595,7 @@ static void ufshcd_device_reset(struct ufs_hba *hba) if (ufshcd_is_wb_allowed(hba)) { hba->dev_info.wb_enabled = false; hba->dev_info.wb_buf_flush_enabled = false; + hba->dev_info.wb_buf_flush_in_hibern8 = false; } } if (err != -EOPNOTSUPP) @@ -5468,6 +5475,7 @@ static bool ufshcd_wb_need_flush(struct ufs_hba *hba) if (!ufshcd_is_wb_allowed(hba)) return false; + /* * The ufs device needs the vcc to be ON to flush. * With user-space reduction enabled, it's enough to enable flush @@ -8567,6 +8575,7 @@ static int ufshcd_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) enum ufs_pm_level pm_lvl; enum ufs_dev_pwr_mode req_dev_pwr_mode; enum uic_link_state req_link_state; + bool hibern8; hba->pm_op_in_progress = 1; if (!ufshcd_is_shutdown_pm(pm_op)) { @@ -8626,11 +8635,13 @@ static int ufshcd_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) * Hibern8, keep device power mode as "active power mode" * and VCC supply. */ + hibern8 = req_link_state == UIC_LINK_HIBERN8_STATE || + (req_link_state == UIC_LINK_ACTIVE_STATE && + ufshcd_is_auto_hibern8_enabled(hba)); + hba->dev_info.b_rpm_dev_flush_capable = - hba->auto_bkops_enabled || - (((req_link_state == UIC_LINK_HIBERN8_STATE) || - ((req_link_state == UIC_LINK_ACTIVE_STATE) && - ufshcd_is_auto_hibern8_enabled(hba))) && + hba->auto_bkops_enabled || (hibern8 && + hba->dev_info.wb_buf_flush_in_hibern8 && ufshcd_wb_need_flush(hba)); }