From patchwork Tue Aug 2 08:08:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyoung CHOI X-Patchwork-Id: 595054 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59B14C00140 for ; Tue, 2 Aug 2022 08:08:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236383AbiHBIIi (ORCPT ); Tue, 2 Aug 2022 04:08:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236388AbiHBIIg (ORCPT ); Tue, 2 Aug 2022 04:08:36 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B0BE4D4DB for ; Tue, 2 Aug 2022 01:08:34 -0700 (PDT) Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20220802080832epoutp044136d017b440933e0ca9109ecd8bb932~HeLZ9jeI40240202402epoutp040 for ; Tue, 2 Aug 2022 08:08:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20220802080832epoutp044136d017b440933e0ca9109ecd8bb932~HeLZ9jeI40240202402epoutp040 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1659427712; bh=oszOItcMjMeNHkWQ68yMN7/6C0T1+pTNlDcShYoGYbg=; h=Subject:Reply-To:From:To:In-Reply-To:Date:References:From; b=J1vG3ytQMIun0b3JMQZrHmzmUeDCS8F8sRXn0wVc1Qa3Gpf63qpe7+xF93s8uQK+X 1ZJ/UfVxgJEdgod8UmsMGCi4QdCggvbs6b3pAQSDTmjX+OQXzBZ908BBE6Fonj8KPO oHTaCm+zVjBHLwRnLL/h2MSo0ay625U/cm8WNWVo= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas2p2.samsung.com (KnoxPortal) with ESMTP id 20220802080832epcas2p293fd0586ea433a8e1e69772c24da0566~HeLZuprL00074300743epcas2p2B; Tue, 2 Aug 2022 08:08:32 +0000 (GMT) Received: from epsmges2p3.samsung.com (unknown [182.195.36.68]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4LxngN0QZ9z4x9Pw; Tue, 2 Aug 2022 08:08:32 +0000 (GMT) X-AuditID: b6c32a47-5e1ff700000025aa-ef-62e8db7f677a Received: from epcas2p4.samsung.com ( [182.195.41.56]) by epsmges2p3.samsung.com (Symantec Messaging Gateway) with SMTP id 30.06.09642.F7BD8E26; Tue, 2 Aug 2022 17:08:31 +0900 (KST) Mime-Version: 1.0 Subject: [PATCH v6 4/6] scsi: ufs: wb: Add ufshcd_is_wb_buf_flush_allowed() Reply-To: j-young.choi@samsung.com Sender: Jinyoung CHOI From: Jinyoung CHOI To: ALIM AKHTAR , "avri.altman@wdc.com" , "bvanassche@acm.org" , "jejb@linux.ibm.com" , "martin.petersen@oracle.com" , "beanhuo@micron.com" , "adrian.hunter@intel.com" , "linux-scsi@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "stanley.chu@mediatek.com" X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <20220802080146epcms2p24b86bfce3d3c09c79b91d861cb3b2cce@epcms2p2> X-CPGS-Detection: blocking_info_exchange X-Drm-Type: N,general X-Msg-Generator: Mail X-Msg-Type: PERSONAL X-Reply-Demand: N Message-ID: <20220802080831epcms2p2c2b9f94e2f450a6a772a193d9720b650@epcms2p2> Date: Tue, 02 Aug 2022 17:08:31 +0900 X-CMS-MailID: 20220802080831epcms2p2c2b9f94e2f450a6a772a193d9720b650 X-Sendblock-Type: AUTO_CONFIDENT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ZcH+qbMexz6/6VPydOfxxB8+W/eEL5G/cW1jranu/2dKxRdZX07/Kbonm/2QkX7okp8BR5dV L13zXHj9lTsXvFo7F/Grqz+0PXRpn9qhyj+bQ9cfcdG8afLfSzvSdNvsp9M/7DbWtvnf/f1+ CKvhh8MaO0X6Dv5Kt7jp0GyZf57X19hMsDh4H8db1v4/i1Zx+Z7gPzL5nfEEqeQXvCtVt147 3fs0Pu/Hy8Kgd55v/D0FhUu+cpRsfd+cHa7ctcZificD+9fJ/FMObVFiKc5INNRiLipOBAA6 UzIIPAQAAA== DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220802080146epcms2p24b86bfce3d3c09c79b91d861cb3b2cce References: <20220802080146epcms2p24b86bfce3d3c09c79b91d861cb3b2cce@epcms2p2> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The explicit flushing should check the following. - UFSHCD_CAP_WB_EN - UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL Changed to improve readability. Acked-by: Bean Huo Reviewed-by: Avri Altman Reviewed-by: Bart Van Assche Signed-off-by: Jinyoung Choi --- drivers/ufs/core/ufs-sysfs.c | 3 +-- drivers/ufs/core/ufshcd-priv.h | 6 ++++++ drivers/ufs/core/ufshcd.c | 5 +++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/ufs/core/ufs-sysfs.c b/drivers/ufs/core/ufs-sysfs.c index 69cc9b26c762..2c0b7f45de4b 100644 --- a/drivers/ufs/core/ufs-sysfs.c +++ b/drivers/ufs/core/ufs-sysfs.c @@ -271,8 +271,7 @@ static ssize_t wb_buf_flush_en_store(struct device *dev, unsigned int wb_buf_flush_en; ssize_t res; - if (!ufshcd_is_wb_allowed(hba) || - (hba->quirks & UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL)) { + if (!ufshcd_is_wb_buf_flush_allowed(hba)) { dev_warn(dev, "It is not allowed to configure WB buf flushing!\n"); return -EOPNOTSUPP; } diff --git a/drivers/ufs/core/ufshcd-priv.h b/drivers/ufs/core/ufshcd-priv.h index 8f67db202d7b..d00dba17297d 100644 --- a/drivers/ufs/core/ufshcd-priv.h +++ b/drivers/ufs/core/ufshcd-priv.h @@ -26,6 +26,12 @@ static inline u8 ufshcd_wb_get_query_index(struct ufs_hba *hba) return 0; } +static inline bool ufshcd_is_wb_buf_flush_allowed(struct ufs_hba *hba) +{ + return ufshcd_is_wb_allowed(hba) && + !(hba->quirks & UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL); +} + #ifdef CONFIG_SCSI_UFS_HWMON void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask); void ufs_hwmon_remove(struct ufs_hba *hba); diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index b7b8efd17659..5099d161f115 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -294,7 +294,8 @@ static void ufshcd_configure_wb(struct ufs_hba *hba) ufshcd_wb_toggle(hba, true); ufshcd_wb_toggle_buf_flush_during_h8(hba, true); - if (!(hba->quirks & UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL)) + + if (ufshcd_is_wb_buf_flush_allowed(hba)) ufshcd_wb_toggle_buf_flush(hba, true); } @@ -5815,7 +5816,7 @@ static bool ufshcd_wb_presrv_usrspc_keep_vcc_on(struct ufs_hba *hba, static void ufshcd_wb_force_disable(struct ufs_hba *hba) { - if (!(hba->quirks & UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL)) + if (ufshcd_is_wb_buf_flush_allowed(hba)) ufshcd_wb_toggle_buf_flush(hba, false); ufshcd_wb_toggle_buf_flush_during_h8(hba, false);