Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2715226pxb; Mon, 25 Apr 2022 00:17:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQOSvO7sj1oAw3u9azdg83ujS8GWCzMkz8IzbQSwhqWJojJGY9g7m8BjbYov5U5mHMsllH X-Received: by 2002:a05:6402:50cb:b0:423:d7a8:719e with SMTP id h11-20020a05640250cb00b00423d7a8719emr17202791edb.37.1650871053253; Mon, 25 Apr 2022 00:17:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650871053; cv=none; d=google.com; s=arc-20160816; b=BLRjyBrres2z/dOGnA9M2WDOr16rDLbknONLfF5VoCkgXvrWcDEmmNYTjxJJSqyYZ6 IG7tpWSfZ+/QyOtFqyY6kg+N+Gzf4NM6V4iazfM2LNcJ2KkHz7bBtiC9UgWrGEv9z7g2 +Y0KWoC3VAlZ1mgc7x/j7hFjt2khNb6bV3GCE6eik6Nx538zV1cA1StFoJKpzcajUQsJ MaEcYRE6n2IaENftJE66D2ZZU85H873AUWWI56kxnJtPbBcH0A5NLkjtkLXVKxlkHsGp 2x3sQz3WiO8exe88uCH1IytSZZpjNfMo5UdBTDyuVvceqVRIj1bSY3QxHUqIH1Ovp9Lo 6HNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=d8fPGHGP26naPx3u4XdY7A6QtBbwdMGar9P7tHUKzWY=; b=irAXqgNHVSncLUmstMPv5WiHLexkLRV178VP8pBaeTwtTBmcwQ0FcmzcceVJIBVVKE k7xDi6FS7wpGgL/7G5SgYB3PIQ9H6j25XgkebT8WLBkMg/DwCb5DEl8kl9DZMPjQzT5f ChWXTVhcyggRgRW5a/ZJga2CvsehZE/pstousQN3TaXQYmTQ7ABya1ibmIshrLar7BeJ oWM4ykQJaYu2Tl25XsUWLZB9DMQDFaWXUCOlP/ogccOq6MuV4CEl0I/TzFy03BpTwh0k 9R3it0bMGWYsYKQT9rmytAaduTbVy6UNiebRuyxbuy15jpLvi+N97Vzrr4+EnVvk+wUq rNTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=nP1sYMmn; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gl16-20020a170906e0d000b006e87a026d42si11320516ejb.261.2022.04.25.00.17.03; Mon, 25 Apr 2022 00:17:33 -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=@gmail.com header.s=20210112 header.b=nP1sYMmn; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239754AbiDXWKe (ORCPT + 99 others); Sun, 24 Apr 2022 18:10:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234833AbiDXWKZ (ORCPT ); Sun, 24 Apr 2022 18:10:25 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA94A5E163; Sun, 24 Apr 2022 15:07:23 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id k27so1241731edk.4; Sun, 24 Apr 2022 15:07:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=d8fPGHGP26naPx3u4XdY7A6QtBbwdMGar9P7tHUKzWY=; b=nP1sYMmnWbNppTXXX2B2OPNnPRJkP+Tm9m8BWqvf7b4hN2n2SCo8EIxdtSGOn+dU9G hH/4tcYNsgx9PhBZTfTKrI5fqxnGx6dY92FZaL/CmZrH3ywj0lTBLnB8K6AFNF8Q0vWu kflRGklvsmPKmv4l0TDldBad/MvmsvFPXZvaIqC5yr0BVMrhWFO/e3rNDp8E+h+D6Kx4 y7zb0L/og/oCSToVeBc7gA8e/CCow6wnxvj6T+jt05PMldK2qBb+wvpJBgBW7BrWqnQ8 c4tzsZPrIE5kgyZRnxeQH/k3PByq7huOcgXocmU9ufI5K1LlLrHQuyqTWbyeKC8vnqgv 3x4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=d8fPGHGP26naPx3u4XdY7A6QtBbwdMGar9P7tHUKzWY=; b=zEz8r3hidMFdAd6cc78qMxxO1Msj0oc7OtVEGQfTyhMAgKM9w62JoDUso+fRPfE56X yMeV9bvGzlPCZggW4UZ+htPXfkt6V2apTVhdKZBKNU84XTpPeIT5jJYyIB7pU43Gmsih OLBW9EHmBDvR5VhA/t5XCX5tVp86tBxy0pvZZ+67FgYz6tBcAygw6TCNOcw7D3KFx/5f Adx2dQBuPaI5Shz+qcpzBV1dttT7TsWgqidPsBCeM+0/0dZm039fF8GSly9bH/TXn8AW zmwH6joAAn0EQcsNAzfSOPikNnfeak03i9gaEbmFUp9oOYz4EY3OEg9YRmC5d6Q6mESq AdoQ== X-Gm-Message-State: AOAM530PcV/cwz5+SuV9rhgoepbHxoBztit2zeezXT7ix+rQf306N+wJ SpPrCJqwhFHAdm5mLWsZ8PKXf6gF9ckdkw== X-Received: by 2002:a05:6402:11cb:b0:423:d7b9:109b with SMTP id j11-20020a05640211cb00b00423d7b9109bmr15967730edw.70.1650838042412; Sun, 24 Apr 2022 15:07:22 -0700 (PDT) Received: from linux.. (p5dd1ed70.dip0.t-ipconnect.de. [93.209.237.112]) by smtp.gmail.com with ESMTPSA id s14-20020aa7cb0e000000b00410bf015567sm3672948edt.92.2022.04.24.15.07.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Apr 2022 15:07:22 -0700 (PDT) From: Bean Huo To: alim.akhtar@samsung.com, 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, daejun7.park@samsung.com, keosung.park@samsung.com, peter.wang@mediatek.com, powen.kao@mediatek.com Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/6] scsi: ufshpb: Merge ufshpb_reset() and ufshpb_reset_host() Date: Mon, 25 Apr 2022 00:07:08 +0200 Message-Id: <20220424220713.1253049-2-huobean@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220424220713.1253049-1-huobean@gmail.com> References: <20220424220713.1253049-1-huobean@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,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 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 --- 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