Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2726788pxb; Mon, 25 Apr 2022 00:37:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzZo1J3lTwzaMQi0ZjKQJELFoE4deBHB6WKTJLgbOKx7TzJOph8+tD9ib54byr1ttqpM0y X-Received: by 2002:a17:907:7f8f:b0:6f0:e67:e3a7 with SMTP id qk15-20020a1709077f8f00b006f00e67e3a7mr15592601ejc.517.1650872235083; Mon, 25 Apr 2022 00:37:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650872235; cv=none; d=google.com; s=arc-20160816; b=GAdHdLsEK2sMbVpzkL3W0yGPuHzQaW8/0Z2kM1uH3npwP83a/ujnWigUiRVAfRh4HW PPrd5hVPZZekIckZCqSHP3RGIlZ5Q8sDsV1d9thXvTtmxHywKo9qYfCVCldKS476nS1S 1XPnnvtEOnD2ASSz+nj7EZZ0Ymr/Jqomw9KDgoSoNwoZW1x0b+EXgkoR3WpqM1+v60M2 8et944XGQ2EjBtpkc2d2uCZK8joG8Nky/gfiFouaTsb2luIIeAH0iXVoWgASeOZRbyFT 46E+5jLN6A4/8LzKJmFrD2/dLWjlw4WjXj3CxNco7aG0B5J7HXtR02mRqaQwkIFe8fy1 3p9w== 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=kLLPKOJheZoOZst7vOsZrRhAcfeNzU817A4tSgnfK0o=; b=GOOMeKL4kVvQkTCzPOV0XX/jPPylD3jiH0R9TTLg0j2nwx2yvMXXDX7rmYOhJwDyiF 6TbgKtgFEOwYGQz3BRSH5sn7NGTZyskaW0OJc9ZRE12oC4QIJsPuDjAtCec933mdf3Us KCWdyaKLhpDLC130u+Ar0DN8VGiiHmxbAiCJrGSZ7IUuTq9h9vUCJfhVJTPrvscJCuFI hWH+afvx65fEwuYEEAdPjMUhCfTNX3G6xTtDDwjDOeLdFtiJEFrc7wie8wrrSo8GbiM/ bFkfYkZwf6CvSCSSmyIOVRIm0I1gKZC4SXN3wCVCh4tDL+RG4GsENHgIT4HnJIiG0E/r u4pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=N8+1pfH+; 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 t9-20020a170906608900b006e6d9d0bce6si12941660ejj.427.2022.04.25.00.36.50; Mon, 25 Apr 2022 00:37:15 -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=N8+1pfH+; 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 S240663AbiDYDlS (ORCPT + 99 others); Sun, 24 Apr 2022 23:41:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234525AbiDYDlQ (ORCPT ); Sun, 24 Apr 2022 23:41:16 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19C2E1A81B for ; Sun, 24 Apr 2022 20:38:09 -0700 (PDT) Received: from epcas3p4.samsung.com (unknown [182.195.41.22]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20220425033802epoutp03a5cfba1cd164148d7373962cb7250c71~pBn9rryAq1023310233epoutp03H for ; Mon, 25 Apr 2022 03:38:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20220425033802epoutp03a5cfba1cd164148d7373962cb7250c71~pBn9rryAq1023310233epoutp03H DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1650857882; bh=kLLPKOJheZoOZst7vOsZrRhAcfeNzU817A4tSgnfK0o=; h=Subject:Reply-To:From:To:CC:In-Reply-To:Date:References:From; b=N8+1pfH+xTmEcOLEQ0R7cUIMBH84clMQLovgLoY6j5v65ymtD+OvaOvPk/Hxzmron yXTzWlV/ePr9dYvl5eu2+4alQR1VCDbBLyTPPqXHWrHghlA/ghN39gsP0kH2fkeOwz rfHeU0tCjZrdnad+Xem7QBXOQYpbQUtxXo0M1S8I= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas3p1.samsung.com (KnoxPortal) with ESMTP id 20220425033802epcas3p15634c5ad5d04c529fc8c036a2dab9b25~pBn9Me9Ek1747617476epcas3p1K; Mon, 25 Apr 2022 03:38:02 +0000 (GMT) Received: from epcpadp4 (unknown [182.195.40.18]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4KmrLy1B7wz4x9Q0; Mon, 25 Apr 2022 03:38:02 +0000 (GMT) Mime-Version: 1.0 Subject: RE: [PATCH v3 3/6] scsi: ufshpb: Cleanup the handler when device reset HPB information 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-4-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: <1889248251.21650857882164.JavaMail.epsvc@epcpadp4> Date: Mon, 25 Apr 2022 12:23:46 +0900 X-CMS-MailID: 20220425032346epcms2p17f067428de98f364f97be8eb5381d9dc Content-Transfer-Encoding: quoted-printable 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: 20220424220758epcas2p1c518cbee68ebefaf1565909f60711561 References: <20220424220713.1253049-4-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 >From: Bean Huo >=20 >"When the device is powered off by the host, the device may restore L2P ma= p data >upon power up or build from the host=E2=80=99s HPB READ command. In case d= evice powered >up and lost HPB information, device can signal to the host through HPB Sen= se data, >by setting HPB Operation as =E2=80=982=E2=80=99 which will inform the host= that device reset HPB >information." >=20 >This patch is to clean up the handler and make the intent of this handler = more >readable, no functional change. >=20 >Signed-off-by: Bean Huo Reviewed-by: Keoseong Park Best Regards, Keoseong Park >--- > drivers/scsi/ufs/ufshpb.c | 35 +++++++++++++++++++++++------------ > 1 file changed, 23 insertions(+), 12 deletions(-) >=20 >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 ufs= hpb_lu *hpb, > queue_work(ufshpb_wq, &hpb->map_work); > } >=20 >-static void ufshpb_dev_reset_handler(struct ufshpb_lu *hpb) >+/* >+ * Set the flags of all active regions to RGN_FLAG_UPDATE to let host sid= e reload L2P entries later >+ */ >+static void ufshpb_set_regions_update(struct ufshpb_lu *hpb) > { > struct victim_select_info *lru_info =3D &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); > } >=20 >+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 =3D 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-act= ivate the region >+ * in the UFS device). >+ */ >+ ufshpb_set_regions_update(hpb); >+ } >+} >+ > /* > * This function will parse recommended active subregion information in s= ense > * data field of response UPIU with SAM_STAT_GOOD state. >@@ -1313,17 +1334,7 @@ void ufshpb_rsp_upiu(struct ufs_hba *hba, struct uf= shcd_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 =3D sdev->hostdata; >- >- if (h) >- ufshpb_dev_reset_handler(h); >- } >- } >+ ufshpb_dev_reset_handler(hba); >=20 > break; > default: >--=20 >2.34.1 >=20 >