From patchwork Sun Apr 24 22:07:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bean Huo X-Patchwork-Id: 565684 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 51BF9C433EF for ; Sun, 24 Apr 2022 22:07:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239747AbiDXWK0 (ORCPT ); Sun, 24 Apr 2022 18:10:26 -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-Google-Smtp-Source: ABdhPJxWD5r4TSjHdo7qJgQXWpGobHIZKMXOJLtKYsvf9D8wS+xjk1/LTEH6QfR3dV2J6wBEN79btA== 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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@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 Reviewed-by: 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); From patchwork Sun Apr 24 22:07:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bean Huo X-Patchwork-Id: 565971 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 EFE24C433F5 for ; Sun, 24 Apr 2022 22:07:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239756AbiDXWK2 (ORCPT ); Sun, 24 Apr 2022 18:10:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239743AbiDXWK0 (ORCPT ); Sun, 24 Apr 2022 18:10:26 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E8335E77B; Sun, 24 Apr 2022 15:07:24 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id bv19so26275648ejb.6; Sun, 24 Apr 2022 15:07:24 -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=wgJcAl0zdpAYB0IRw4jP+ujI4F2jFIRqxBwg3WITVhs=; b=cZ77NACJh5VixU+h1pcfeiY6y7ekGoKIuy5NDHqSRXwlc2y3ZEwCkTQz72ojbxVxOT dmwZW/wDSUDuH9DvwVV80Hg6CjvR/RZZRVd9GKMKHwFvAo0mY1YjHQvE5w+J4fnh6I3q JPX1XeMlGHgiunbzi57c41Rchut1u+PCVOnO2rU/MOrz2GqSnjMUDDo45v8Ska0tiaAh vADZTf0Jy9iFejyonxz2Desz2g6vNtgfX81Z4CRz024yNvanNPqLwka8wCz1y9PdodVZ z/ujNjvU6JRDuQWMcpb8KSOdSYG4eNi1NMjiBbs3GP3Wsn8vje59UNlcyNYnWuI8F2J4 WdJw== 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=wgJcAl0zdpAYB0IRw4jP+ujI4F2jFIRqxBwg3WITVhs=; b=sM3KwdkOrwoLOB/+3rGfadZniG3Enm9HNGOR1XGMMefS23Zl9BnpJqSf3ysbU2326x BqTzPLW4ihoDxrAdtu4CwYFo1u8gq48sbEdLYZ1Y/YQipLZ7CSnbe+p+JsQVfDZqqSr4 mCAzX+zqQ/SmSfQ4Z1y7wlohpUZOlxzhS4Z9t22J9iJQArU2bOX3sEwnv1IZgTEj46QY aPMMVOQZyqR6lU2HhtbGbGOhASoEzCLwBTPpT81BextRVLzUpQ8obz9X/GyasPeF0rDX Y0l6rva4yweRjZ9OA6oCEm0vXgBEPTiLwrcjpUAnowcFKBbLq0jVA9NkvznDk4Y/dxuG DwRg== X-Gm-Message-State: AOAM533OcX9YGEYyvNgS6liDaH+55hecG8US3Dpzhuhaxhcbyxg7sE+V 0lKc9MlmrybPywj+rhFaYqk= X-Google-Smtp-Source: ABdhPJxQxA5FsP+gIegcaQbl4IeReGJ6lg1tXoNsu/iMf2ULGyR2U0DaQ2wvxFILc5eu2iInj+wOSg== X-Received: by 2002:a17:907:d8c:b0:6f0:1091:de34 with SMTP id go12-20020a1709070d8c00b006f01091de34mr13540330ejc.376.1650838043241; Sun, 24 Apr 2022 15:07:23 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Apr 2022 15:07:23 -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 2/6] scsi: ufshpb: Remove 0 assignment for enum value Date: Mon, 25 Apr 2022 00:07:09 +0200 Message-Id: <20220424220713.1253049-3-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Bean Huo If the first enumerator has no initializer, the value of the corresponding constant is zero. Reviewed-by: Keoseong Park Signed-off-by: Bean Huo --- drivers/scsi/ufs/ufshpb.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ufs/ufshpb.h b/drivers/scsi/ufs/ufshpb.h index 7aa0dc58ee9f..b83b9ec9044a 100644 --- a/drivers/scsi/ufs/ufshpb.h +++ b/drivers/scsi/ufs/ufshpb.h @@ -59,8 +59,8 @@ enum UFSHPB_MODE { }; enum UFSHPB_STATE { - HPB_INIT = 0, - HPB_PRESENT = 1, + HPB_INIT, + HPB_PRESENT, HPB_SUSPEND, HPB_FAILED, HPB_RESET, From patchwork Sun Apr 24 22:07:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bean Huo X-Patchwork-Id: 565683 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 4144FC433F5 for ; Sun, 24 Apr 2022 22:07:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239764AbiDXWKd (ORCPT ); Sun, 24 Apr 2022 18:10:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239750AbiDXWK1 (ORCPT ); Sun, 24 Apr 2022 18:10:27 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7185A5DE62; Sun, 24 Apr 2022 15:07:25 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id m20so5534339ejj.10; Sun, 24 Apr 2022 15:07:25 -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=COG2pB7EY8x9qomnPZfOrHzJQwF9/mN/WQraDu1oLko=; b=LoLS5C/AgpN9SECJLmqiFy1WT/xJSXWqfEtdtaeEGNj9uq7SjAo8llXOnr+K8B8GNq zixYmmzBL+TlBT77HCjCPuknMwtws9WizKA/0FVzfXc0nij2R1Ddt0xWbzsmmnPpx3Dz OAT9Z7ZPGW3xs+GEZhyMQrjuYM0r2mntHSmQ1po4MrK9LmdFymGWqMlH5G3IBV12ULOu eixFkdRs1tmVR1Dir7JjHC1VYR+MCReGMeaEQzByOYA8tAccVQd67jpMFcIFQYfoWo7o 7MpH1PHXAiqLaL7TrBdfr648qz7btOUZmCo5cq+BRFjO6CAEFuUT+X+Sjc8PBVcdhub5 ouHQ== 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=COG2pB7EY8x9qomnPZfOrHzJQwF9/mN/WQraDu1oLko=; b=nex/66lGVle1LwrhEH9OjYG9hxXbrR1HLdqNpDgyiA2xdLdNpZQcAsZJiBPAGCaU72 7m5uha06mORoTnQiBsAEhSVLFqjwD+WTEYa+QgYBPVk2q77BZa90esEXF+Z6J1cBsrR1 FYicinDV25cmPXOw/+IuPmqCtqiLKtRm/wihmmZEuJusWlPuX6+truXR/bKB0py8gqsK 4gdgrhBZ3stM5esmsOWLPdDNYlLY3pSzVBMduHtkN0eChc67h/wJbe8UWtO6PTp3uoyY lKz8xizYm9+ExqqqGG/mMXPp9n4AAFPKEYebeslhQ3sIV2z+DeltWqYm6NQ3wEe4cqBy dLWw== X-Gm-Message-State: AOAM530WEJuqgEP7zlESObaTk8iOIWMAPr8j1Qp9jLP97fVgipMhWlBb 7oOu3NKV9kuv/A/SqyuZNEw= X-Google-Smtp-Source: ABdhPJwS0EkNuH4fvQutc2H9LWVZ+hMWeZw/1g2nAPIRo26UYUNvkdgQYM+aa40ajgPP282NDsdCIw== X-Received: by 2002:a17:907:3fa9:b0:6ef:f0e6:7285 with SMTP id hr41-20020a1709073fa900b006eff0e67285mr13753720ejc.350.1650838044045; Sun, 24 Apr 2022 15:07:24 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Apr 2022 15:07:23 -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 3/6] scsi: ufshpb: Cleanup the handler when device reset HPB information Date: Mon, 25 Apr 2022 00:07:10 +0200 Message-Id: <20220424220713.1253049-4-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Bean Huo "When the device is powered off by the host, the device may restore L2P map data upon power up or build from the host’s HPB READ command. In case device powered up and lost HPB information, device can signal to the host through HPB Sense data, by setting HPB Operation as ‘2’ which will inform the host that device reset HPB information." This patch is to clean up the handler and make the intent of this handler more readable, no functional change. Signed-off-by: Bean Huo Reviewed-by: Keoseong Park --- drivers/scsi/ufs/ufshpb.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c index 167643969165..f1f30d4c3d65 100644 --- a/drivers/scsi/ufs/ufshpb.c +++ b/drivers/scsi/ufs/ufshpb.c @@ -1225,7 +1225,10 @@ static void ufshpb_rsp_req_region_update(struct ufshpb_lu *hpb, queue_work(ufshpb_wq, &hpb->map_work); } -static void ufshpb_dev_reset_handler(struct ufshpb_lu *hpb) +/* + * Set the flags of all active regions to RGN_FLAG_UPDATE to let host side reload L2P entries later + */ +static void ufshpb_set_regions_update(struct ufshpb_lu *hpb) { struct victim_select_info *lru_info = &hpb->lru_info; struct ufshpb_region *rgn; @@ -1239,6 +1242,24 @@ static void ufshpb_dev_reset_handler(struct ufshpb_lu *hpb) spin_unlock_irqrestore(&hpb->rgn_state_lock, flags); } +static void ufshpb_dev_reset_handler(struct ufs_hba *hba) +{ + struct scsi_device *sdev; + struct ufshpb_lu *hpb; + + __shost_for_each_device(sdev, hba->host) { + hpb = ufshpb_get_hpb_data(sdev); + if (hpb && hpb->is_hcm) + /* + * For the HPB host mode, in case device powered up and lost HPB + * information, we will set the region flag to be RGN_FLAG_UPDATE, + * it will let host reload its L2P entries(re-activate the region + * in the UFS device). + */ + ufshpb_set_regions_update(hpb); + } +} + /* * This function will parse recommended active subregion information in sense * data field of response UPIU with SAM_STAT_GOOD state. @@ -1313,17 +1334,7 @@ void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) case HPB_RSP_DEV_RESET: dev_warn(&hpb->sdev_ufs_lu->sdev_dev, "UFS device lost HPB information during PM.\n"); - - if (hpb->is_hcm) { - struct scsi_device *sdev; - - __shost_for_each_device(sdev, hba->host) { - struct ufshpb_lu *h = sdev->hostdata; - - if (h) - ufshpb_dev_reset_handler(h); - } - } + ufshpb_dev_reset_handler(hba); break; default: From patchwork Sun Apr 24 22:07:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bean Huo X-Patchwork-Id: 565970 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 179F4C433EF for ; Sun, 24 Apr 2022 22:07:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239768AbiDXWKf (ORCPT ); Sun, 24 Apr 2022 18:10:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239755AbiDXWK2 (ORCPT ); Sun, 24 Apr 2022 18:10:28 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EE2F5E77B; Sun, 24 Apr 2022 15:07:26 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id p4so799850edx.0; Sun, 24 Apr 2022 15:07:26 -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=+jWtMMAHpQUFdLCMp9InOSTuyV28IhzkfaPkZD8ILYI=; b=JYpz3b/jRwqxBUvI1A+yhTwa26Ulxo9/Rlg4YFc9ToE5TvSXyWl3iC4pLL7iJ7zHZQ tluNnXPAIKlEAwzaVmIp1uIFhLX72mtua6WQQllnQdWnp5PvLS4KM3ZLE78VkeBGYZlv 8lWsinYgxM0FADkU7SQJIv8R84MAhNp+jpwGc0U/8TWDxUoednUta74vqtzxlrbmWpYd +CnahLU/zPdjAZ/Ex5CuPNI1wWONFItIsSQ+HRT/olCE/YvEnu6aOrD4glcl9m5FlcSZ gTWnhKfeWzXVmghbBsvIFsYey+UYxPKsgT0bN0ATEjlB2k6YHR3yuQlvUvHJSizn59XJ +ouw== 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=+jWtMMAHpQUFdLCMp9InOSTuyV28IhzkfaPkZD8ILYI=; b=5dEabJUJ4Y24Pld4Sodhf89Tw5NKlEOQL7AdADHNC+/jZk1MrmqlpuSqPxZYUiqIAY vdj6PBmgmgMzjOmoQvNj3Hbjtah1whry82zU4Y01UP/BbxR7Rm1zzacRa4NaHcnxeUZs 0SXzZADEES6BavLc8MHIDXr+uuAnQm96sZRNKtvkEPcff5D1tdV+OMmHLAXPP7fUNNUn nFCeu8EUNwEXvwIDinpP7ZoHroKZQNqpjVwQGcqc/xuoVSD7EQkIqG+4bvTCtn/xLP71 sStDa06fzwkuAcubslPVVsYMpEdytRgkpaFgUsfkG3ZCwRB7hO/rG98eHD46BBiBt87L rA+g== X-Gm-Message-State: AOAM532YAvwFjeyARk9ryR62knxOHmBfFzwlMOOQyQ6hja2RHfTcaApx sW33k/AJ/csDuG4aKpPvgYs= X-Google-Smtp-Source: ABdhPJwty63lWTDhdkVpVAmODNP6+UhFQrpCRN9we0kjerGz72iP42t0wkhPSoH1kK+Sn7N2jPQcnw== X-Received: by 2002:a05:6402:2747:b0:423:88ab:178f with SMTP id z7-20020a056402274700b0042388ab178fmr16067572edd.163.1650838044931; Sun, 24 Apr 2022 15:07:24 -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.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Apr 2022 15:07:24 -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 4/6] scsi: ufshpb: Change sysfs node hpb_stats/rb_* prefix to start with rcmd_* Date: Mon, 25 Apr 2022 00:07:11 +0200 Message-Id: <20220424220713.1253049-5-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Bean Huo According to the documentation of the sysfs nodes rb_noti_cnt, rb_active_cnt and rb_inactive_cnt, they are all related to HPB recommendation in UPIU response packet. I don't know what 'rb' refers to, I think 'rcmd' (recommendation) should be the correct abbreviation. Change the sysfs documentation about these sysfs nodes to highlight what they mean under different HPB control modes. Signed-off-by: Bean Huo Reviewed-by: Keoseong Park --- Documentation/ABI/testing/sysfs-driver-ufs | 18 +++++++++------- drivers/scsi/ufs/ufshpb.c | 24 +++++++++++----------- drivers/scsi/ufs/ufshpb.h | 6 +++--- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-driver-ufs b/Documentation/ABI/testing/sysfs-driver-ufs index a44ef8bfbadf..6b248abb1bd7 100644 --- a/Documentation/ABI/testing/sysfs-driver-ufs +++ b/Documentation/ABI/testing/sysfs-driver-ufs @@ -1518,7 +1518,7 @@ Description: This entry shows the number of reads that cannot be changed to The file is read only. -What: /sys/class/scsi_device/*/device/hpb_stats/rb_noti_cnt +What: /sys/class/scsi_device/*/device/hpb_stats/rcmd_noti_cnt Date: June 2021 Contact: Daejun Park Description: This entry shows the number of response UPIUs that has @@ -1526,19 +1526,23 @@ Description: This entry shows the number of response UPIUs that has The file is read only. -What: /sys/class/scsi_device/*/device/hpb_stats/rb_active_cnt +What: /sys/class/scsi_device/*/device/hpb_stats/rcmd_active_cnt Date: June 2021 Contact: Daejun Park -Description: This entry shows the number of active sub-regions recommended by - response UPIUs. +Description: For the HPB device control mode, this entry shows the number of + active sub-regions recommended by response UPIUs. For the HPB host control + mode, this entry shows the number of active sub-regions recommended by the + HPB host control mode heuristic algorithm. The file is read only. -What: /sys/class/scsi_device/*/device/hpb_stats/rb_inactive_cnt +What: /sys/class/scsi_device/*/device/hpb_stats/rcmd_inactive_cnt Date: June 2021 Contact: Daejun Park -Description: This entry shows the number of inactive regions recommended by - response UPIUs. +Description: For the HPB device control mode, this entry shows the number of + inactive regions recommended by response UPIUs. For the HPB host control + mode, this entry shows the number of inactive regions recommended by the + HPB host control mode heuristic algorithm. The file is read only. diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c index f1f30d4c3d65..e7f311bb4401 100644 --- a/drivers/scsi/ufs/ufshpb.c +++ b/drivers/scsi/ufs/ufshpb.c @@ -563,7 +563,7 @@ static void ufshpb_update_active_info(struct ufshpb_lu *hpb, int rgn_idx, if (list_empty(&srgn->list_act_srgn)) list_add_tail(&srgn->list_act_srgn, &hpb->lh_act_srgn); - hpb->stats.rb_active_cnt++; + hpb->stats.rcmd_active_cnt++; } static void ufshpb_update_inactive_info(struct ufshpb_lu *hpb, int rgn_idx) @@ -580,7 +580,7 @@ static void ufshpb_update_inactive_info(struct ufshpb_lu *hpb, int rgn_idx) if (list_empty(&rgn->list_inact_rgn)) list_add_tail(&rgn->list_inact_rgn, &hpb->lh_inact_rgn); - hpb->stats.rb_inactive_cnt++; + hpb->stats.rcmd_inactive_cnt++; } static void ufshpb_activate_subregion(struct ufshpb_lu *hpb, @@ -1321,7 +1321,7 @@ void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) if (!ufshpb_is_hpb_rsp_valid(hba, lrbp, rsp_field)) return; - hpb->stats.rb_noti_cnt++; + hpb->stats.rcmd_noti_cnt++; switch (rsp_field->hpb_op) { case HPB_RSP_REQ_REGION_UPDATE: @@ -1724,18 +1724,18 @@ static DEVICE_ATTR_RO(__name) ufshpb_sysfs_attr_show_func(hit_cnt); ufshpb_sysfs_attr_show_func(miss_cnt); -ufshpb_sysfs_attr_show_func(rb_noti_cnt); -ufshpb_sysfs_attr_show_func(rb_active_cnt); -ufshpb_sysfs_attr_show_func(rb_inactive_cnt); +ufshpb_sysfs_attr_show_func(rcmd_noti_cnt); +ufshpb_sysfs_attr_show_func(rcmd_active_cnt); +ufshpb_sysfs_attr_show_func(rcmd_inactive_cnt); ufshpb_sysfs_attr_show_func(map_req_cnt); ufshpb_sysfs_attr_show_func(umap_req_cnt); static struct attribute *hpb_dev_stat_attrs[] = { &dev_attr_hit_cnt.attr, &dev_attr_miss_cnt.attr, - &dev_attr_rb_noti_cnt.attr, - &dev_attr_rb_active_cnt.attr, - &dev_attr_rb_inactive_cnt.attr, + &dev_attr_rcmd_noti_cnt.attr, + &dev_attr_rcmd_active_cnt.attr, + &dev_attr_rcmd_inactive_cnt.attr, &dev_attr_map_req_cnt.attr, &dev_attr_umap_req_cnt.attr, NULL, @@ -2098,9 +2098,9 @@ static void ufshpb_stat_init(struct ufshpb_lu *hpb) { hpb->stats.hit_cnt = 0; hpb->stats.miss_cnt = 0; - hpb->stats.rb_noti_cnt = 0; - hpb->stats.rb_active_cnt = 0; - hpb->stats.rb_inactive_cnt = 0; + hpb->stats.rcmd_noti_cnt = 0; + hpb->stats.rcmd_active_cnt = 0; + hpb->stats.rcmd_inactive_cnt = 0; hpb->stats.map_req_cnt = 0; hpb->stats.umap_req_cnt = 0; } diff --git a/drivers/scsi/ufs/ufshpb.h b/drivers/scsi/ufs/ufshpb.h index b83b9ec9044a..0d6e6004d783 100644 --- a/drivers/scsi/ufs/ufshpb.h +++ b/drivers/scsi/ufs/ufshpb.h @@ -211,9 +211,9 @@ struct ufshpb_params { struct ufshpb_stats { u64 hit_cnt; u64 miss_cnt; - u64 rb_noti_cnt; - u64 rb_active_cnt; - u64 rb_inactive_cnt; + u64 rcmd_noti_cnt; + u64 rcmd_active_cnt; + u64 rcmd_inactive_cnt; u64 map_req_cnt; u64 pre_req_cnt; u64 umap_req_cnt; From patchwork Sun Apr 24 22:07:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bean Huo X-Patchwork-Id: 565682 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 DBAA3C433EF for ; Sun, 24 Apr 2022 22:07:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239784AbiDXWKn (ORCPT ); Sun, 24 Apr 2022 18:10:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239758AbiDXWK2 (ORCPT ); Sun, 24 Apr 2022 18:10:28 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25FA35EBDF; Sun, 24 Apr 2022 15:07:27 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id u15so26198925ejf.11; Sun, 24 Apr 2022 15:07:27 -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=2vsmiQJUe+L9B4nsSUBR3/boiLV26o4RTxgSYcrElCg=; b=R1nIdsWQoevN7nyqrA+WIkTtJdsnj5lHHy37A/csEUN602nev8gEwR8PEjPRSsBunM a18RfhfkEY//Fm/8U6v1D4MaK+//XmZSQNtMsKDdpz8Gx3HYGkkJUlJt+ICzEywF+rdu FzuQPHNHFP2p4bFiBzyLQbkqXC+xh0HcwQ9XxJK3nX9AqieVa0QAE/0Kbeegbal5FTLK 4ajSnj4MV9NbtsnmEuWErpkWVGUxT3vwBT/c5qdXOSgwZqYmwxebb6eOlyVD8jC3feZ+ TbzGY8STYzQXFQbBabJMHu7Pq/SO3DfQtVDnJob2TvQEcC4/7wNyA1DiH59ymSDTom+t rgAw== 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=2vsmiQJUe+L9B4nsSUBR3/boiLV26o4RTxgSYcrElCg=; b=ZxuqoM58S9RQBBU+RgzGLfAdZTj394RCIy4viCvtmAopKc6jXCdyuVGVdczJbk+f02 m5736JJk0xPHA6ISel5HlHh8+e0MMOg0p1ckGOV57nhk5YZn9LGx+Ic1ksEohGfX0Gu7 R9YLKkT++JTqJtmL+VtoH0olrgnJzb9mgGlMcWlf2hMBJw4YgMmbh/GWo9mommweWn5V WVpffEOKAyshc8NP8rJxWPlQVxG/7WlO6sFBpA5I5YnjuwjWOjIupgMkkSq2cRvTIfX2 kyNivIC84fn1UksA9m4+jdd9OwLih3gE7MABp2k/Qfiq8jN256ghVHR9a+qvNfnyveHe Dbew== X-Gm-Message-State: AOAM530cTJzxiXjJc8L9EC9y+mQ3vhNHPUg7TdvpFE10JIkQt6Jd2YpQ jSvi3b6Yl7Ifj2dRBT7QATM= X-Google-Smtp-Source: ABdhPJycBKJLoUtwndspbnI5de+2qC2qxYm1iMhSKbLhAJccUP7LWrf29CrAHJNdGhXfV0Kri+Z/sA== X-Received: by 2002:a17:907:60d3:b0:6e7:fcd6:7fb4 with SMTP id hv19-20020a17090760d300b006e7fcd67fb4mr14056843ejc.302.1650838045701; Sun, 24 Apr 2022 15:07:25 -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.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Apr 2022 15:07:25 -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 5/6] scsi: ufshpb: Add handing of device reset HPB regions Infos in HPB device mode Date: Mon, 25 Apr 2022 00:07:12 +0200 Message-Id: <20220424220713.1253049-6-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Bean Huo In UFS HPB Spec JESD220-3A, "5.8. Active and inactive information upon power cycle ... When the device is powered off by the host, the device may restore L2P map data upon power up or build from the host’s HPB READ command. In case device powered up and lost HPB information, device can signal to the host through HPB Sense data, by setting HPB Operation as ‘2’ which will inform the host that device reset HPB information." Therefore, for HPB device control mode, if the UFS device is reset via the RST_N pin, the active region information in the device will be reset. If the host side receives this notification from the device side, it is recommended to inactivate all active regions in the host's HPB cache. Signed-off-by: Bean Huo Reviewed-by: Keoseong Park --- drivers/scsi/ufs/ufshpb.c | 82 +++++++++++++++++++++++++++------------ 1 file changed, 58 insertions(+), 24 deletions(-) diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c index e7f311bb4401..7868412054bf 100644 --- a/drivers/scsi/ufs/ufshpb.c +++ b/drivers/scsi/ufs/ufshpb.c @@ -1137,6 +1137,39 @@ static int ufshpb_add_region(struct ufshpb_lu *hpb, struct ufshpb_region *rgn) spin_unlock_irqrestore(&hpb->rgn_state_lock, flags); return ret; } +/** + *ufshpb_submit_region_inactive() - submit a region to be inactivated later + *@hpb: per-LU HPB instance + *@region_index: the index associated with the region that will be inactivated later + */ +static void ufshpb_submit_region_inactive(struct ufshpb_lu *hpb, int region_index) +{ + int subregion_index; + struct ufshpb_region *rgn; + struct ufshpb_subregion *srgn; + + /* + * Remove this region from active region list and add it to inactive list + */ + spin_lock(&hpb->rsp_list_lock); + ufshpb_update_inactive_info(hpb, region_index); + spin_unlock(&hpb->rsp_list_lock); + + rgn = hpb->rgn_tbl + region_index; + + /* + * Set subregion state to be HPB_SRGN_INVALID, there will no HPB read on this subregion + */ + spin_lock(&hpb->rgn_state_lock); + if (rgn->rgn_state != HPB_RGN_INACTIVE) { + for (subregion_index = 0; subregion_index < rgn->srgn_cnt; subregion_index++) { + srgn = rgn->srgn_tbl + subregion_index; + if (srgn->srgn_state == HPB_SRGN_VALID) + srgn->srgn_state = HPB_SRGN_INVALID; + } + } + spin_unlock(&hpb->rgn_state_lock); +} static void ufshpb_rsp_req_region_update(struct ufshpb_lu *hpb, struct utp_hpb_rsp *rsp_field) @@ -1196,25 +1229,8 @@ static void ufshpb_rsp_req_region_update(struct ufshpb_lu *hpb, for (i = 0; i < rsp_field->inactive_rgn_cnt; i++) { rgn_i = be16_to_cpu(rsp_field->hpb_inactive_field[i]); - dev_dbg(&hpb->sdev_ufs_lu->sdev_dev, - "inactivate(%d) region %d\n", i, rgn_i); - - spin_lock(&hpb->rsp_list_lock); - ufshpb_update_inactive_info(hpb, rgn_i); - spin_unlock(&hpb->rsp_list_lock); - - rgn = hpb->rgn_tbl + rgn_i; - - spin_lock(&hpb->rgn_state_lock); - if (rgn->rgn_state != HPB_RGN_INACTIVE) { - for (srgn_i = 0; srgn_i < rgn->srgn_cnt; srgn_i++) { - srgn = rgn->srgn_tbl + srgn_i; - if (srgn->srgn_state == HPB_SRGN_VALID) - srgn->srgn_state = HPB_SRGN_INVALID; - } - } - spin_unlock(&hpb->rgn_state_lock); - + dev_dbg(&hpb->sdev_ufs_lu->sdev_dev, "inactivate(%d) region %d\n", i, rgn_i); + ufshpb_submit_region_inactive(hpb, rgn_i); } out: @@ -1249,14 +1265,32 @@ static void ufshpb_dev_reset_handler(struct ufs_hba *hba) __shost_for_each_device(sdev, hba->host) { hpb = ufshpb_get_hpb_data(sdev); - if (hpb && hpb->is_hcm) + if (!hpb) + continue; + + if (hpb->is_hcm) { /* - * For the HPB host mode, in case device powered up and lost HPB - * information, we will set the region flag to be RGN_FLAG_UPDATE, - * it will let host reload its L2P entries(re-activate the region - * in the UFS device). + * For the HPB host control mode, in case device powered up and lost HPB + * information, we will set the region flag to be RGN_FLAG_UPDATE, it will + * let host reload its L2P entries(reactivate region in the UFS device). */ ufshpb_set_regions_update(hpb); + } else { + /* + * For the HPB device control mode, if host side receives 02h:HPB Operation + * in UPIU response, which means device recommends the host side should + * inactivate all active regions. Here we add all active regions to inactive + * list, they will be inactivated later in ufshpb_map_work_handler(). + */ + struct victim_select_info *lru_info = &hpb->lru_info; + struct ufshpb_region *rgn; + + list_for_each_entry(rgn, &lru_info->lh_lru_rgn, list_lru_rgn) + ufshpb_submit_region_inactive(hpb, rgn->rgn_idx); + + if (ufshpb_get_state(hpb) == HPB_PRESENT) + queue_work(ufshpb_wq, &hpb->map_work); + } } } From patchwork Sun Apr 24 22:07:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bean Huo X-Patchwork-Id: 565969 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 C37C2C433F5 for ; Sun, 24 Apr 2022 22:07:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239760AbiDXWKs (ORCPT ); Sun, 24 Apr 2022 18:10:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239759AbiDXWK3 (ORCPT ); Sun, 24 Apr 2022 18:10:29 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED3565EBE4; Sun, 24 Apr 2022 15:07:27 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id kq17so3122941ejb.4; Sun, 24 Apr 2022 15:07:27 -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=Bs2RZ1HctDBw64PPVPS3C6pCKSaEHfE9IQYgmcStxr8=; b=b2u9VhD247prDS3n7rS0WmOcl/vfomXlP2jbViESjt4BB/UPvIAMLSAS6flZ5Uu7Vx 0cgeZTCmmRQ5oAmTCgIhCh5QNWdthnW+Zc/5F2/gCoKZyQm571V75YL5x8BVE7a32khY nmTlk6poIjwvgOx2G7Qr+0N0MFqtbmJGGvP92cWZXBx29B+PRsO+CtUxqowNJNy21nie +59zDqWA5UlV1yhb9byGWLx8BDMyWWcDCzx8gwdzghYEEpFhT74YJCN4JcqjKGsxEpL2 OEj1ODnfMB3LKqOZVnjagDq/1/s9VKecnlt5UMB91VWc2YSqUJOG7EST6/7dHiwGA5ft Zh8w== 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=Bs2RZ1HctDBw64PPVPS3C6pCKSaEHfE9IQYgmcStxr8=; b=OMwz2MwgWm0Ln5fGccu3nbU1Gwv6awW1qkIFLwd8Br1VDXLs1Mmg1su9xTrp+70cJF iTzaQ5uuMaQvMfOd6+af3R2CIVVskd31L/mvArVmDvvYdf3pn32wDG1luPJZnbDXxt4z 5pOP4tLwr5WBFrySG/NpcfXAaE0AgG/BzOZAozBpIMVCgPN7Q16fDX9UrDSuak22nlwP CDSGueZCE5vlnWyH6WXsdPBkqKLyUpKRXOBFl0tj1Q6QnVTVRzA7aSX8h66jxgVSqZuf efllrDgkad4odAGRxV1QrFGlhdaSs75N9UM8BdfP/8QCEqIQFHseLYZuyKohxkB6QHrB TKpQ== X-Gm-Message-State: AOAM5317JYkuVHTz/0aOHQkdgqVHtYvnM5XZgVGRfKOoPFGHXRTxxD72 ZET6tHAbW5WYyEovkGLIeIA= X-Google-Smtp-Source: ABdhPJxH1PsgGuRfDwnpIh1IDdPTqumcrLEHf2B1k21lgk/TJV9AFAu6jsNrjADnn0nW8ZLvRfa8/w== X-Received: by 2002:a17:907:3ea7:b0:6f3:97f6:611b with SMTP id hs39-20020a1709073ea700b006f397f6611bmr1593071ejc.752.1650838046555; Sun, 24 Apr 2022 15:07:26 -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.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Apr 2022 15:07:26 -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 6/6] scsi: ufshpb: Cleanup ufshpb_suspend/resume Date: Mon, 25 Apr 2022 00:07:13 +0200 Message-Id: <20220424220713.1253049-7-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Bean Huo ufshpb_resume() is only called when the HPB state is HPB_SUSPEND, so the check statement for "ufshpb_get_state(hpb) != HPB_PRESENT" is useless. Signed-off-by: Bean Huo Reviewed-by: Keoseong Park --- drivers/scsi/ufs/ufshpb.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c index 7868412054bf..10f40e390dc5 100644 --- a/drivers/scsi/ufs/ufshpb.c +++ b/drivers/scsi/ufs/ufshpb.c @@ -2349,11 +2349,9 @@ void ufshpb_suspend(struct ufs_hba *hba) shost_for_each_device(sdev, hba->host) { hpb = ufshpb_get_hpb_data(sdev); - if (!hpb) + if (!hpb || ufshpb_get_state(hpb) != HPB_PRESENT) continue; - if (ufshpb_get_state(hpb) != HPB_PRESENT) - continue; ufshpb_set_state(hpb, HPB_SUSPEND); ufshpb_cancel_jobs(hpb); } @@ -2366,20 +2364,15 @@ void ufshpb_resume(struct ufs_hba *hba) shost_for_each_device(sdev, hba->host) { hpb = ufshpb_get_hpb_data(sdev); - if (!hpb) + if (!hpb || ufshpb_get_state(hpb) != HPB_SUSPEND) continue; - if ((ufshpb_get_state(hpb) != HPB_PRESENT) && - (ufshpb_get_state(hpb) != HPB_SUSPEND)) - continue; ufshpb_set_state(hpb, HPB_PRESENT); ufshpb_kick_map_work(hpb); if (hpb->is_hcm) { - unsigned int poll = - hpb->params.timeout_polling_interval_ms; + unsigned int poll = hpb->params.timeout_polling_interval_ms; - schedule_delayed_work(&hpb->ufshpb_read_to_work, - msecs_to_jiffies(poll)); + schedule_delayed_work(&hpb->ufshpb_read_to_work, msecs_to_jiffies(poll)); } } }