Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2755650pxb; Mon, 25 Apr 2022 01:29:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5ckPZtzaKt8/V2MEwJDMXAdd7V1xgY0I13zKL8oIMZTY4hoYQadXbS8LIyB9sDNKdFl74 X-Received: by 2002:a17:902:a712:b0:158:9e75:686c with SMTP id w18-20020a170902a71200b001589e75686cmr17791378plq.56.1650875357905; Mon, 25 Apr 2022 01:29:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650875357; cv=none; d=google.com; s=arc-20160816; b=g2ZX07DFI7a5L+lox8D6u6FeRg6Q4jvPtGi0NQ3VM0CqU3dx301PDcVqMicyWZOIXC /SQIBnn62sXpPB0KaF3mo8FRJ0p3SxxS5ha+NEVIKrdvwFkZGRCSg3quGlFzGIJ+wd5q 3uexQHjirZ4qaKmvQj87BqNohoJslQcINsqc1erLK6MRYoZncFwBg8PYVUbJqukz9CMr PkHvo2VWiuTGguKybD/iZs0mWhUNidjedWEVJJMTFaF6/TcXsVi+kAyoUq4rZlVzsXfV Nz1RkEqV0LII/7u1A/t+ubGvBoc4PmUDsEbsuQA/OG/jw9fvCg3kfE7dKeF4zHyUldgb /2eA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:content-transfer-encoding:date :message-id:in-reply-to:cc:to:from:sender:reply-to:subject :mime-version:dkim-signature:dkim-filter; bh=5EKRymzxC5Y24lGXxfIm4R/GuoFHPSZl5W8D6LBGYmA=; b=TF13S6mAXaN1d2e1yq0tGXYHgv0s7KP7iDMUG6xhnduhSkRjTHfxgOQUiCmZYEptvv wfSrmeEVt/gcKHP+w95aiFDiLhBvSPk+93R3jepkbVK7QPIjh5qayuHoAp+c2zphLUnD Gn5N0KzoMPnFcJCJFFd+jDH85nHnfGpgc08Hll4Dq1/5Vm0beRoqaqqCSkeL3Oh1ZoAl u1ZoBMT1YYwYcDw3BOVB3NTKoowID/wgIO1Ht7ORR7I/DS4HeeBtKC7NAPE75OIv9XTA Kq3vxGYeIACPOBQ1qdaEM0Kx4+lKj6CV3Co9L9eRCzpAV6eKVRP4uYMIlYmttQCJV+t/ zmQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=He9QXote; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z190-20020a6265c7000000b004fabd831538si15452650pfb.196.2022.04.25.01.29.03; Mon, 25 Apr 2022 01:29:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=He9QXote; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238870AbiDYCGK (ORCPT + 99 others); Sun, 24 Apr 2022 22:06:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236668AbiDYCGI (ORCPT ); Sun, 24 Apr 2022 22:06:08 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 490321D0DF for ; Sun, 24 Apr 2022 19:03:05 -0700 (PDT) Received: from epcas3p1.samsung.com (unknown [182.195.41.19]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20220425020302epoutp0452c65309fd2bb07ae922f614a3cc2123~pAVAu4xOl1490314903epoutp04X for ; Mon, 25 Apr 2022 02:03:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20220425020302epoutp0452c65309fd2bb07ae922f614a3cc2123~pAVAu4xOl1490314903epoutp04X DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1650852182; bh=5EKRymzxC5Y24lGXxfIm4R/GuoFHPSZl5W8D6LBGYmA=; h=Subject:Reply-To:From:To:CC:In-Reply-To:Date:References:From; b=He9QXoteCUweiuvEFaM4lohaE7IFwVW31TzJu/fhn8XQqVsUpBJY8rd1o8plLPBgJ niBuB74mXNvBRHX2sRau9n356g94i+rF0LWOx6VrHvakcOleZ1DCg1iDNV5ED0QBE3 PD67ai3K0NL3fyM2euvKbwzlpnwcN75v1NSeCZ5Q= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas3p2.samsung.com (KnoxPortal) with ESMTP id 20220425020301epcas3p28794e2186e7c53a1c105ce4c136461b4~pAVAImHx82393723937epcas3p2k; Mon, 25 Apr 2022 02:03:01 +0000 (GMT) Received: from epcpadp4 (unknown [182.195.40.18]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4KmpFK4Q9fz4x9QK; Mon, 25 Apr 2022 02:03:01 +0000 (GMT) Mime-Version: 1.0 Subject: RE: [PATCH v3 1/6] scsi: ufshpb: Merge ufshpb_reset() and ufshpb_reset_host() Reply-To: keosung.park@samsung.com Sender: Keoseong Park From: Keoseong Park To: Bean Huo , ALIM AKHTAR , "avri.altman@wdc.com" , "jejb@linux.ibm.com" , "martin.petersen@oracle.com" , "stanley.chu@mediatek.com" , "beanhuo@micron.com" , "bvanassche@acm.org" , "tomas.winkler@intel.com" , Daejun Park , Keoseong Park , "peter.wang@mediatek.com" , "powen.kao@mediatek.com" , cpgsproxy3 CC: "linux-scsi@vger.kernel.org" , "linux-kernel@vger.kernel.org" X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <20220424220713.1253049-2-huobean@gmail.com> 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: <1891546521.01650852181605.JavaMail.epsvc@epcpadp4> Date: Mon, 25 Apr 2022 11:00:46 +0900 X-CMS-MailID: 20220425020046epcms2p1d8b984fc67793254397c4846010e1834 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: AUTO_CONFIDENTIAL X-CPGSPASS: Y X-CPGSPASS: Y X-Hop-Count: 3 X-CMS-RootMailID: 20220424220726epcas2p2a4824a1c187680fe519bfba447e23b32 References: <20220424220713.1253049-2-huobean@gmail.com> <20220424220713.1253049-1-huobean@gmail.com> X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Bean, >From: Bean Huo > >There is no functional change in this patch, just merge ufshpb_reset() >and ufshpb_reset_host() into one function ufshpb_toggle_state(). > >Signed-off-by: Bean Huo Looks good to me. Reviewed-by: Keoseong Park Best Regards, Keoseong Park >--- > drivers/scsi/ufs/ufshcd.c | 4 ++-- > drivers/scsi/ufs/ufshpb.c | 36 +++++++++++++----------------------- > drivers/scsi/ufs/ufshpb.h | 6 ++---- > 3 files changed, 17 insertions(+), 29 deletions(-) > >diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c >index 3f9caafa91bf..62c7f5404353 100644 >--- a/drivers/scsi/ufs/ufshcd.c >+++ b/drivers/scsi/ufs/ufshcd.c >@@ -7223,7 +7223,7 @@ static int ufshcd_host_reset_and_restore(struct ufs_hba *hba) > * Stop the host controller and complete the requests > * cleared by h/w > */ >- ufshpb_reset_host(hba); >+ ufshpb_toggle_state(hba, HPB_PRESENT, HPB_RESET); > ufshcd_hba_stop(hba); > hba->silence_err_logs = true; > ufshcd_complete_requests(hba); >@@ -8184,7 +8184,7 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params) > /* Enable Auto-Hibernate if configured */ > ufshcd_auto_hibern8_enable(hba); > >- ufshpb_reset(hba); >+ ufshpb_toggle_state(hba, HPB_RESET, HPB_PRESENT); > out: > spin_lock_irqsave(hba->host->host_lock, flags); > if (ret) >diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c >index fd31e516e491..167643969165 100644 >--- a/drivers/scsi/ufs/ufshpb.c >+++ b/drivers/scsi/ufs/ufshpb.c >@@ -2272,38 +2272,28 @@ static bool ufshpb_check_hpb_reset_query(struct ufs_hba *hba) > return flag_res; > } > >-void ufshpb_reset(struct ufs_hba *hba) >+/** >+ * ufshpb_toggle_state - switch HPB state of all LUs >+ * @hba: per-adapter instance >+ * @src: expected current HPB state >+ * @dest: target HPB state to switch to >+ */ >+void ufshpb_toggle_state(struct ufs_hba *hba, enum UFSHPB_STATE src, enum UFSHPB_STATE dest) > { > struct ufshpb_lu *hpb; > struct scsi_device *sdev; > > shost_for_each_device(sdev, hba->host) { > hpb = ufshpb_get_hpb_data(sdev); >- if (!hpb) >- continue; >- >- if (ufshpb_get_state(hpb) != HPB_RESET) >- continue; >- >- ufshpb_set_state(hpb, HPB_PRESENT); >- } >-} >- >-void ufshpb_reset_host(struct ufs_hba *hba) >-{ >- struct ufshpb_lu *hpb; >- struct scsi_device *sdev; > >- shost_for_each_device(sdev, hba->host) { >- hpb = ufshpb_get_hpb_data(sdev); >- if (!hpb) >+ if (!hpb || ufshpb_get_state(hpb) != src) > continue; >+ ufshpb_set_state(hpb, dest); > >- if (ufshpb_get_state(hpb) != HPB_PRESENT) >- continue; >- ufshpb_set_state(hpb, HPB_RESET); >- ufshpb_cancel_jobs(hpb); >- ufshpb_discard_rsp_lists(hpb); >+ if (dest == HPB_RESET) { >+ ufshpb_cancel_jobs(hpb); >+ ufshpb_discard_rsp_lists(hpb); >+ } > } > } > >diff --git a/drivers/scsi/ufs/ufshpb.h b/drivers/scsi/ufs/ufshpb.h >index b475dbd78988..7aa0dc58ee9f 100644 >--- a/drivers/scsi/ufs/ufshpb.h >+++ b/drivers/scsi/ufs/ufshpb.h >@@ -288,8 +288,7 @@ static int ufshpb_prep(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) { return 0; > static void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) {} > static void ufshpb_resume(struct ufs_hba *hba) {} > static void ufshpb_suspend(struct ufs_hba *hba) {} >-static void ufshpb_reset(struct ufs_hba *hba) {} >-static void ufshpb_reset_host(struct ufs_hba *hba) {} >+static void ufshpb_toggle_state(struct ufs_hba *hba, enum UFSHPB_STATE src, enum UFSHPB_STATE dest) {} > static void ufshpb_init(struct ufs_hba *hba) {} > static void ufshpb_init_hpb_lu(struct ufs_hba *hba, struct scsi_device *sdev) {} > static void ufshpb_destroy_lu(struct ufs_hba *hba, struct scsi_device *sdev) {} >@@ -303,8 +302,7 @@ int ufshpb_prep(struct ufs_hba *hba, struct ufshcd_lrb *lrbp); > void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp); > void ufshpb_resume(struct ufs_hba *hba); > void ufshpb_suspend(struct ufs_hba *hba); >-void ufshpb_reset(struct ufs_hba *hba); >-void ufshpb_reset_host(struct ufs_hba *hba); >+void ufshpb_toggle_state(struct ufs_hba *hba, enum UFSHPB_STATE src, enum UFSHPB_STATE dest); > void ufshpb_init(struct ufs_hba *hba); > void ufshpb_init_hpb_lu(struct ufs_hba *hba, struct scsi_device *sdev); > void ufshpb_destroy_lu(struct ufs_hba *hba, struct scsi_device *sdev); >-- >2.34.1 > >