Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp43054pxu; Tue, 15 Dec 2020 15:23:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJyGYKUqSSvwaxaXeY5N5Kz6C84bAm01vLqiEoRJHcAhmiRFtaoxXZZDEwv4pEAeqe2rhZke X-Received: by 2002:aa7:cc86:: with SMTP id p6mr8574677edt.289.1608074616609; Tue, 15 Dec 2020 15:23:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608074616; cv=none; d=google.com; s=arc-20160816; b=Ilcp6asFR7BnEezdceArtJv5hEmOWB5l1kUqcqFrGAWip0+GsFsGnXGu0g6vcMTPHg S4XGFnpS9R8hGfH/NnAf56cpOSPFa+qFxXBlT4N1NGVFE1sORjBR+zbDCocqfUuoqa4R tF7WZvzeAiHXdgoI1yNvPI6n7HCW3PvYhKhInlLrSpMTzq4JpCH1jjpSYs9uKqI6TUjZ agXMpa13wmTCKmJ9iK4WczNvcM5U+lG9mI9kalqz5WKREmeKtLYUeDx6aa4+f2/7G1Z/ ZzVIBQIlpreGOJg0lCq0yN0qgMP1lB5Nkc0/drNyH3eK//8ohGuNdvSvRwb/CGkHtCiw x7Jw== 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=r4FGDCmd+0tOnQUnhUjyrOq68wQ6sbCmcoaPkblTkR4=; b=09g74IMAeb8Nfs5oxsh15XSuLegJ4STuI/JksEUdMxRgtk3sJf7dADu3VzAyV9kCZL 17e+kteCpJwbC+MVq7xo5RMehvdl+f05QBjr9BYFZXDE98af7deTqJrWl7nD5v3yTuVp B3BrPSelujQzPdpsWys0+DquFKe3LnutVExCaOMcAVuC7SB+DL0SfyDuD/HxXrWKh+Bt GI/DLhJJG9XPsp1e8IEnhrDBS1+/zP+TIpj/7uv6pVxJKZpObUuvnrzgm+GRv2mVMt6w M9sfNP1HkdyjnOjT+M7ofQkY0pdHPgh7DC3YH01HSiV3rML9Nd3Lw0vSslX924smHrgr 7VYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SJK4VON4; 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 qk27si4934ejb.615.2020.12.15.15.23.13; Tue, 15 Dec 2020 15:23: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=SJK4VON4; 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 S1730824AbgLOXPK (ORCPT + 99 others); Tue, 15 Dec 2020 18:15:10 -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-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-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(). Signed-off-by: Bean Huo --- 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; } -- 2.17.1