Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp463515pxb; Thu, 21 Jan 2021 11:13:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJxM1D1o0tiqUw5nhY+BX82goXWcZMpLGeIeClEHaoQ7HTYO5nWmPojU1W4lfdWrPXCh/k+f X-Received: by 2002:aa7:d0cf:: with SMTP id u15mr495601edo.115.1611256416781; Thu, 21 Jan 2021 11:13:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611256416; cv=none; d=google.com; s=arc-20160816; b=fAmj/B1qvzP5p7WXALZ/qFR0eZegP2hxt1qsvQ5ZvfeSZ3vQi9J2IM0NZeAU5x7V0a NOXdiVia8abaKy4+2A/KRlhpYrviJm2/JDix8esmfx0/P3gwsnvAGlnyXF558NFhYr6c lOup3yflDQKbLM+d/4pTkv3VJXnhy6Weyqu08aiCumqs/TFUXjJ43d31w6QsnQajsa8v f7B3WdZRUKNuT2o99TKkxiN1C+H5slKMeKo8GNpqtiWmWfk7ccjAcjiqyWNqeFH4tgQ5 tcSA6JRzXxMc1TDgXM5HY2j/zkjFU1eL7KEtP8ZvIHtKiUBnqw8XFaljczMBmhV171o8 G6MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=DWKkorkSuzcODZKyQLmKsJHfB0QKivboYyFeNZx/BBE=; b=nwHPND6hJNcphr63IM3SV4xuVAKxy9SCJkT14vObXMZygCzYcYtUH61TiFoB38iWlX LO/OgCqJuZNkgN+E9WIrZct/6r47exJGp8XpKVG62NiwSvOA6NkI7vkRDqFvoabNgZ25 nzxbflHMHDYfd0sF3l7nUCBN4CvTDd02l+yQaugOG9SnF31Ag67mcRyy/Ge/9rPhr/Gm kMPxNZkMiHnzKuenMbjgBAUeJo4gZBAAmPKaegBBcuWf8buQR5BDCLxvarmN3ZTc2ggZ 2HYxLleAzB1KjzVcwlABL0uWgPugr9aPT+cIgB1aHGdJ1250hblt5crw0JEk8RP6ZNYN V+gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JKvmrraD; 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 q7si2512379edt.86.2021.01.21.11.13.12; Thu, 21 Jan 2021 11:13:36 -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=JKvmrraD; 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 S1726847AbhAUTK6 (ORCPT + 99 others); Thu, 21 Jan 2021 14:10:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726939AbhAUTJz (ORCPT ); Thu, 21 Jan 2021 14:09:55 -0500 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C16CC06178A; Thu, 21 Jan 2021 10:57:50 -0800 (PST) Received: by mail-ed1-x530.google.com with SMTP id n6so3738799edt.10; Thu, 21 Jan 2021 10:57:50 -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; bh=DWKkorkSuzcODZKyQLmKsJHfB0QKivboYyFeNZx/BBE=; b=JKvmrraDWtUR4zoZKRUWKidZHOGdk8rx58ra0Wox7icgpShUwOUhosEB0FnyaDnjJE fQhu+M8aUfN3TfoVNWjvXa25QIEW093x0V0u1pIIs5fOeju32nk5JUud4K/AIfNJ1DaQ xnAGRZwHJ78aRNeBRgZtsims9OmZYFpbIkzy4N7tAJi2MYeqMi+HIgpcLzhZHUneE2I8 kxPmUetJxGNFu8tjTDsLoStxIqrv72bBX0XUpRqFJfp4FzZ5LvuVGTeYOs9y9ZQSU3So x0iIIBHktQv+usBGOe2564XaAdMHSYbRX77fY2WORrWbNGp50WuxbZonbKpDJLNcDoq/ GaZQ== 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; bh=DWKkorkSuzcODZKyQLmKsJHfB0QKivboYyFeNZx/BBE=; b=sPNy4dNWImcNtbEmnsSKlFpqG1NgwpybOPS/2/+FBsuyEFK3b2CAjAV7SoqbzDyufo k5bR+lHZ3uoedo3fSvoFzzNW7BUAMwRR1DjZw1FOmhzdoiVlOAqR6xjle2TDn98n+kKJ OkBWJRAaeThf3L9Fyu4zNcGVTrzXvvtfyE/EHzmwNb1nZLOiQIfWMcUJfk7NnDEafyi4 S99AjkfILQd8Tq9ih77/L18hduLAzhUpDaKX/grDUfqKTKfEwi+emiTjGzyDXboH2KhA MToM7RzhSvfrTD5x8T3/toP0NLjGo0DLQ5TTQb53Z5o6UAsxYnFkCbxht2/uAjLvvhAJ GmBA== X-Gm-Message-State: AOAM5327Tf7aaY3UlcE+Aejy90DlpQzGGEr0Y8x4dcDr04POJOCAJFEO h8Ad4MdkTWBveZtvzfj+ihI= X-Received: by 2002:a05:6402:d1:: with SMTP id i17mr432284edu.85.1611255469368; Thu, 21 Jan 2021 10:57:49 -0800 (PST) Received: from localhost.localdomain (ip5f5bee1b.dynamic.kabel-deutschland.de. [95.91.238.27]) by smtp.gmail.com with ESMTPSA id x17sm3236491edq.77.2021.01.21.10.57.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jan 2021 10:57:48 -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] scsi: ufs: Cleanup WB buffer flush toggle implementation Date: Thu, 21 Jan 2021 19:57:36 +0100 Message-Id: <20210121185736.12471-1-huobean@gmail.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(). Reviewed-by: Stanley Chu Reviewed-by: Can Guo Signed-off-by: Bean Huo --- Changelog: 1. Rebased the patch onto 5.12/scsi-staging, since existing one conflict with commit 21acf4601cc6 ("scsi: ufs: Relax the condition of UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL"), which results in applying failure. --- drivers/scsi/ufs/ufshcd.c | 61 ++++++++++++--------------------------- 1 file changed, 19 insertions(+), 42 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 9c691e4ab490..c8a862aa1f87 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -247,10 +247,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); @@ -5476,58 +5474,37 @@ 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 (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 (!ufshcd_is_wb_allowed(hba) || + hba->dev_info.wb_buf_flush_enabled == enable) 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); + if (enable) + opcode = UPIU_QUERY_OPCODE_SET_FLAG; 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) - return 0; + 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; + } static bool ufshcd_wb_presrv_usrspc_keep_vcc_on(struct ufs_hba *hba, -- 2.17.1