Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3806807pxb; Mon, 8 Feb 2021 00:04:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJx9AvS45z7bx9VqnitwboOVwEcS9dLzyvEsgkKKHzr+U0SLlb7EoByfgH8cYVt0z8ECJbvv X-Received: by 2002:a17:907:78d5:: with SMTP id kv21mr15873018ejc.461.1612771488942; Mon, 08 Feb 2021 00:04:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612771488; cv=none; d=google.com; s=arc-20160816; b=afYeYUsXmM4XbbiGL5cOU65xS7f+PoobLffLRJHSrvVuk+nKCkD5EhrIU174j6U3Gb oCYOEbeb58/RHEw51i5JpVOAbVeyHk7TETTyx7+tI466Ldd3/tF+Wruus9Ml8mSJKyhX CZTABPZdlJ621tgHkx8yZl/10lKI9wBhpwK2urPnUQfWCWwf2gV+dfKR31yfQpVQxkb3 pMv0wEfUqYKSA6UHkv2jYXzvgY0XZ3mkq+Vl2IRXxyy+Q4g/Rj4IPV2sZafULO7i3wVR pXlSjwB8Chz/i4R7hq6gC1LfmETiD8L+HGUbB6K+/8mxVD0Jmo0VY8nKB1sqhHQcUx55 WQlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:dlp-filter:cms-type :content-transfer-encoding:date:message-id:in-reply-to:cc:to:from :sender:reply-to:subject:mime-version:dkim-signature:dkim-filter; bh=ze1z1lQbFdnnFuFNdA6+aObS93VSOFjbwRiBaL0SMrM=; b=TOD3IKoI0aL7HO54hXsMYFXEgJ+qo17eDb7C9Nj0+snwEd9Em+WdF1O+xNSKUUsUdW t+UZUqikZiEOQ8etRD37OzCErmzvIpjgFztD7s15QYOlPoN75yMzVpzB7+VBHmrw7E7G ULQrFbrm+Dymv3Kj2zuHjaHSGrhFKeVt0MINAuq5hXw3lxJ/okk55rm78KgF7Ys76MiF CNzIidqoh9rPcCnFQxDOvm1WQ2eISPnd+8GxaD5TaWAQTRZmKTd1xdq/kB/R7zV4v/ZJ TJKm498Wfbb3dcxMMhod93IsvFaY8IgU3OHn60X6QERnsO6e6yeCMKV8FQGbnQwWtMr5 pHkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=e6bwgNL9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o19si12061410edz.565.2021.02.08.00.04.24; Mon, 08 Feb 2021 00:04:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=e6bwgNL9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S230153AbhBHICN (ORCPT + 99 others); Mon, 8 Feb 2021 03:02:13 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:47269 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230154AbhBHIB5 (ORCPT ); Mon, 8 Feb 2021 03:01:57 -0500 Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20210208080114epoutp01e9a51a5da06adcc08950c71e13e3718e~htu3hH6FI0305403054epoutp01S for ; Mon, 8 Feb 2021 08:01:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20210208080114epoutp01e9a51a5da06adcc08950c71e13e3718e~htu3hH6FI0305403054epoutp01S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1612771274; bh=ze1z1lQbFdnnFuFNdA6+aObS93VSOFjbwRiBaL0SMrM=; h=Subject:Reply-To:From:To:CC:In-Reply-To:Date:References:From; b=e6bwgNL9VyTpSuuDnPg+3JEB0+zKdzR4yvAwkMpwjhY4q+G9I/4Yd22BhZoMuKTQm 6CzIE2A4F4Ri4m/ieCP3mGn0dpI2d/UqhylDfzk+M1E4ARG3w6XiT2aHMdSpYIh62h vEm4n7TDkLT/HJnSnyZ36z+27VeHoK3MyvbQzlck= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas2p1.samsung.com (KnoxPortal) with ESMTP id 20210208080112epcas2p1e1368084510f791f633dcf2681a1271d~htu2Ec_Cs0326103261epcas2p1L; Mon, 8 Feb 2021 08:01:12 +0000 (GMT) Received: from epsmges2p1.samsung.com (unknown [182.195.40.185]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4DYz461TFZz4x9Q9; Mon, 8 Feb 2021 08:01:10 +0000 (GMT) X-AuditID: b6c32a45-337ff7000001297d-85-6020efc6dd8b Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id B8.D7.10621.6CFE0206; Mon, 8 Feb 2021 17:01:10 +0900 (KST) Mime-Version: 1.0 Subject: RE: Re: [PATCH v19 2/3] scsi: ufs: L2P map management for HPB read Reply-To: daejun7.park@samsung.com Sender: Daejun Park From: Daejun Park To: Can Guo , Daejun Park CC: Greg KH , "avri.altman@wdc.com" , "jejb@linux.ibm.com" , "martin.petersen@oracle.com" , "asutoshd@codeaurora.org" , "stanley.chu@mediatek.com" , "huobean@gmail.com" , "bvanassche@acm.org" , ALIM AKHTAR , "linux-scsi@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Sung-Jun Park , yongmyung lee , Jinyoung CHOI , BoRam Shin , SEUNGUK SHIN X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <652fa8013c26df497049abe923eb1b97@codeaurora.org> 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: <20210208080109epcms2p6ec657586e6afa269876d4f6205af2a3c@epcms2p6> Date: Mon, 08 Feb 2021 17:01:09 +0900 X-CMS-MailID: 20210208080109epcms2p6ec657586e6afa269876d4f6205af2a3c Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: AUTO_CONFIDENTIAL X-CPGSPASS: Y X-CPGSPASS: Y CMS-TYPE: 102P X-Brightmail-Tracker: H4sIAAAAAAAAA52TbUxTVxjHd+4tbUFKLgXngfFSLtEIkdIWWk83avwwlxowY86NbMbBTbmh TGib3qKOfbAZUJAXlSGwsIobcyJY1sFaqBAja5GBmdk6BiovwiImA2EwjRFwLKMvTLOP+/bL P8/z/J+Xc7g438aJ5OZrDLReQxWQ7CBWtytBljS4JMgR9U8FoJnmbja6ZhrioLnVUTZyTfzB QQ3Lqzh6ZL0UgOacCah9JguVfGVlI/MtI4ZqztjZqOVON4ZGes1sVHXbwUatP/yNoQlbEPra fhegU40WFmr5so+1N0w58mu6cuR0Daa82jTFUZ5t6QfK6+ctHGXp8HWW8s8H4yzlaVs7UD7u ilGW91dhmUHvG0EapVep84/RAlqj0ubma/IU5DuH3khCpECtZQwK8rAYSYRiuVSYKhdKdh95 VSwSSaSkQEMV0gryRJI/mxToVbqNaAPNGPS0it6Q9HsZA5VHCxmqkCnS5AlV2kJScIwqKNrI I5P3pKlpKpfWC3Jmgbpz8ltc92nsie/MTtwI1sMrQSAXEqmw1l7FqgRBXD7hALCk0RJQCbhc HhEK1x1hnpgwIh2uVX2CeZhPkNDqbuL4dCEc/80CPMwmdsHGoWmvHk7sh0/qrgR4auKEkQ1N N1sDfGY8+Fn5A5aPX4E9rXZvciCxBw5Pz/n1nXDlUg3u463w7pVFziYvDV4APg6HZfdu+WNC 4cxqn1+PgIN9y5iPT0L75BrwNAGJagBdV8f9TSTDsYpOrxmPOADXZi97C7GI7fDiwvd+s9eh qXTAyzgRC3sWzbhnKTiRAK29yR6ERDwcGGdtjmXsfMb5L+NECKxwrf+rO5pn/a3tgN+sWrGz IL7p+aabXvBqeu71BcDbwcu0jinMoxmJTvziobuA9+Un7nOAusVloRNgXOAEkIuT4by3TsXk 8Hm51EfFtF6brS8qoBknKN6YshaP3KrSbnwdjSFbLBNJZNKU1JQUaar0f8tSiUwmkkuRVCZB 5DYeI5rJ5hN5lIE+StM6Wr9pjnEDI42YreLh/rJSdUhRmzpq6Oi8gnIPPBNVr52vnLKWLB+6 nz2QM9FPKl6aX5kdS+vaNfq0s8J8s6zn/gIWQZbM2DJj6890DNcsnVyQh3NWZJGfm5o76lGr a+pGFkYMjp37UeEObeHjwRFP322zHXZn1gyb2NWxdXEfHr8Dln+pm3dIC7hxTMPvtWGBT+L5 pqyP3Tv3YZz6ZMHj97KiJ8t29FpGyi+k9zXUZVgy8+NUB2XSgzq37YDgtdtOsbnt2o3L0dPy 5o4tguAOqXY0TZS4JThkLSbDnnzxXuIH8owjiuCO3W9H8QNjUBIIe1Tx5rao9OhuQ+fPxYsN 23/6i3QtH39Ishg1JU7E9Qz1D18NDtDHBAAA DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20210129052848epcms2p6e5797efd94e6282b76ad9ae6c99e3ab5 References: <652fa8013c26df497049abe923eb1b97@codeaurora.org> <20210129052848epcms2p6e5797efd94e6282b76ad9ae6c99e3ab5@epcms2p6> <20210129053005epcms2p323338fbb83459d2786fc0ef92701b147@epcms2p3> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > + > > +static void ufshpb_kick_map_work(struct ufshpb_lu *hpb) > > +{ > > + bool ret = true; > > -> ret = false; > > > + unsigned long flags; > > + > > + spin_lock_irqsave(&hpb->rsp_list_lock, flags); > > + if (!list_empty(&hpb->lh_inact_rgn) || > > !list_empty(&hpb->lh_act_srgn)) > > + ret = false; > > -> ret = true; Thanks, I will fix it. > > + spin_unlock_irqrestore(&hpb->rsp_list_lock, flags); > > + > > + if (ret) > > + queue_work(ufshpb_wq, &hpb->map_work); > > +} > > + > > +static bool ufshpb_is_hpb_rsp_valid(struct ufs_hba *hba, > > + struct ufshcd_lrb *lrbp, > > + struct utp_hpb_rsp *rsp_field) > > +{ > > + if (be16_to_cpu(rsp_field->sense_data_len) != DEV_SENSE_SEG_LEN || > > + rsp_field->desc_type != DEV_DES_TYPE || > > + rsp_field->additional_len != DEV_ADDITIONAL_LEN || > > + rsp_field->hpb_op == HPB_RSP_NONE || > > HPB_RSP_NONE is checked again in switch-case, no need of this line. OK, I agree. > > +static void ufshpb_rsp_req_region_update(struct ufshpb_lu *hpb, > > + struct utp_hpb_rsp *rsp_field) > > +{ > > + int i, rgn_idx, srgn_idx; > > + > > + BUILD_BUG_ON(sizeof(struct ufshpb_active_field) != > > HPB_ACT_FIELD_SIZE); > > + /* > > + * If the active region and the inactive region are the same, > > + * we will inactivate this region. > > + * The device could check this (region inactivated) and > > + * will response the proper active region information > > + */ > > + spin_lock(&hpb->rsp_list_lock); > > + for (i = 0; i < rsp_field->active_rgn_cnt; i++) { > > + rgn_idx = > > + be16_to_cpu(rsp_field->hpb_active_field[i].active_rgn); > > + srgn_idx = > > + be16_to_cpu(rsp_field->hpb_active_field[i].active_srgn); > > + > > + dev_dbg(&hpb->sdev_ufs_lu->sdev_dev, > > + "activate(%d) region %d - %d\n", i, rgn_idx, srgn_idx); > > + ufshpb_update_active_info(hpb, rgn_idx, srgn_idx); > > + hpb->stats.rb_active_cnt++; > > + } > > + > > + for (i = 0; i < rsp_field->inactive_rgn_cnt; i++) { > > + rgn_idx = be16_to_cpu(rsp_field->hpb_inactive_field[i]); > > + dev_dbg(&hpb->sdev_ufs_lu->sdev_dev, > > + "inactivate(%d) region %d\n", i, rgn_idx); > > + ufshpb_update_inactive_info(hpb, rgn_idx); > > + hpb->stats.rb_inactive_cnt++; > > + } > > + spin_unlock(&hpb->rsp_list_lock); > > + > > + dev_dbg(&hpb->sdev_ufs_lu->sdev_dev, "Noti: #ACT %u #INACT %u\n", > > + rsp_field->active_rgn_cnt, rsp_field->inactive_rgn_cnt); > > + > > + queue_work(ufshpb_wq, &hpb->map_work); > > +} > > + > > +/* > > + * This function will parse recommended active subregion information > > in sense > > + * data field of response UPIU with SAM_STAT_GOOD state. > > + */ > > +void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) > > +{ > > + struct ufshpb_lu *hpb = ufshpb_get_hpb_data(lrbp->cmd->device); > > + struct utp_hpb_rsp *rsp_field; > > + int data_seg_len; > > + > > + if (!hpb) > > + return; > > You are assuming HPB recommandations only come in responses to LUs > with HPB enabled, but the specs says the recommandations can come > in any responses with GOOD status, meaning you should check the *hpb > which belongs to the LUN in res_field, but not the one belongs to > lrbp->cmd->device. I will add codes for checking lun to prevent getting wrong HPB recommandations. Thanks, Daejun