Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp984322pxa; Wed, 12 Aug 2020 19:29:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxq8qo6Pezr7nj+oeuaw2tjrzcBbArFPoh4jeCO+xzCMGwU9Us0bbA9Fee3kRiPIUEHKeXB X-Received: by 2002:a17:906:6406:: with SMTP id d6mr2682702ejm.30.1597285740752; Wed, 12 Aug 2020 19:29:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597285740; cv=none; d=google.com; s=arc-20160816; b=s6o1Kwf0B1lVpKYMuqBhTEwzC1qRjEL+hDHTyZPDyrbGYV2WD4GSjquY8qEkLKRNuK 22ngR1gdC5jT3w6TZkSFbvdqv+Q8hBcs0NDPp0BxtkSWZUKD42whRfHFrA4iEbGSLIqh EWzGhDNDn+KRBTYEDTct1ErXLoPL1YJNQ5DjMl/8qAaVa4Kej7m1+OnF8CcxOR3FrPgW pO43DBm4T4+v4IU34HvKOAgDcqwmNvP9pjz1yaMSdzdeTDP7M8+q1WuDhz07VDHIFyii A+KKtk3waP41+AOzmW9y8SblB+J8EV0ISNPe74jNUMIm9WzyXL7Dt2HlGhCagPgBUPpi iTHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:content-transfer-encoding:date :message-id:in-reply-to:cc:to:from:reply-to:subject:mime-version :dkim-signature:dkim-filter; bh=bBoSIYfYUVBe91z7Hl3yBvlXhwhzlVC2LnJY5UtikfE=; b=rhusIeuV+7a+KXOgCqQePhuqUhmM1W063l2SSQocMGIVZ97Q24tZwr5AkMMRQXSfqf aEgUUErj17DQ5TSGuZWHMR4d/Q33y43aaOJ2iWip9nTpZmkTkA8lLWn7Ax0Ia8z+I6NR fd1TOP0ahQ8rLJrKZixP4u8Cj1fZDbSJkkVGj3//6g4CTrCXK4pFbAAiOL/9kbqLaCBc 3XlV5cRop8fHLUSfY26UYvQQgdEC1J/9n4EiEf/2+HXR9J9eqNC3tmFwSYKmRsWMBRQN wWYORsaESES7AQFEfbXW4qaa0ljzHtIkZ88fDkN4SCCSSvhJgmJWvZMdzOGrLdUqqqlP Wg0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=s9iB4hk7; 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 e11si2313051ejc.49.2020.08.12.19.28.37; Wed, 12 Aug 2020 19:29:00 -0700 (PDT) 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=s9iB4hk7; 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 S1726691AbgHMCZJ (ORCPT + 99 others); Wed, 12 Aug 2020 22:25:09 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:20081 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726419AbgHMCZH (ORCPT ); Wed, 12 Aug 2020 22:25:07 -0400 Received: from epcas1p3.samsung.com (unknown [182.195.41.47]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20200813022504epoutp0420dc90287d97cc2f7b7dade922b75335~qsrQGNz2i2335623356epoutp04c for ; Thu, 13 Aug 2020 02:25:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20200813022504epoutp0420dc90287d97cc2f7b7dade922b75335~qsrQGNz2i2335623356epoutp04c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1597285504; bh=bBoSIYfYUVBe91z7Hl3yBvlXhwhzlVC2LnJY5UtikfE=; h=Subject:Reply-To:From:To:CC:In-Reply-To:Date:References:From; b=s9iB4hk7yXizxTQtC9T5ImjEwFr9TW4T2/lS/JSMaBdzdD5eOBD9xlGIrt1BJ8zqV p2Jfh2rCP8flZAu1TCPibyLeG4lxsl9S/DYn6o7UQ6lJTAONAldAFartLdm4zDKWZ4 fMuF2k11XzVUzUOxpfO1rkPVmVRlOvgAg1wv14PU= Received: from epcpadp1 (unknown [182.195.40.11]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20200813022503epcas1p1d9386e2dfbde1e0d35e9c397f0670723~qsrPo9Klz3219232192epcas1p1K; Thu, 13 Aug 2020 02:25:03 +0000 (GMT) Mime-Version: 1.0 Subject: Re: [PATCH v8 2/4] scsi: ufs: Introduce HPB feature Reply-To: daejun7.park@samsung.com From: Daejun Park To: Bart Van Assche , Daejun Park , "avri.altman@wdc.com" , "jejb@linux.ibm.com" , "martin.petersen@oracle.com" , "asutoshd@codeaurora.org" , "beanhuo@micron.com" , "stanley.chu@mediatek.com" , "cang@codeaurora.org" , "tomas.winkler@intel.com" , ALIM AKHTAR CC: "linux-scsi@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Sang-yoon Oh , Sung-Jun Park , yongmyung lee , Jinyoung CHOI , Adel Choi , BoRam Shin X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <4a91d02c-488c-86cd-325c-5e0ad9addd0b@acm.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: <1239183618.61597285503620.JavaMail.epsvc@epcpadp1> Date: Thu, 13 Aug 2020 11:13:09 +0900 X-CMS-MailID: 20200813021309epcms2p3d87ce0c4c54389cc3d30b876684936d0 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: 20200806073257epcms2p61564ed62e02fc42fc3c2b18fa92a038d References: <4a91d02c-488c-86cd-325c-5e0ad9addd0b@acm.org> <231786897.01596705001840.JavaMail.epsvc@epcpadp1> <231786897.01596704281715.JavaMail.epsvc@epcpadp2> <231786897.01596705302142.JavaMail.epsvc@epcpadp1> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Bart, On 2020-08-06 02:11, Daejun Park wrote: > > +static void ufshpb_issue_hpb_reset_query(struct ufs_hba *hba) > > +{ > > + int err; > > + int retries; > > + > > + for (retries = 0; retries < HPB_RESET_REQ_RETRIES; retries++) { > > + err = ufshcd_query_flag(hba, UPIU_QUERY_OPCODE_SET_FLAG, > > + QUERY_FLAG_IDN_HPB_RESET, 0, NULL); > > + if (err) > > + dev_dbg(hba->dev, > > + "%s: failed with error %d, retries %d\n", > > + __func__, err, retries); > > + else > > + break; > > + } > > + > > + if (err) { > > + dev_err(hba->dev, > > + "%s setting fHpbReset flag failed with error %d\n", > > + __func__, err); > > + return; > > + } > > +} > > Please change the "break" into an early return, remove the last > occurrence "if (err)" and remove the final return statement. OK, I will. > > > +static void ufshpb_check_hpb_reset_query(struct ufs_hba *hba) > > +{ > > + int err; > > + bool flag_res = true; > > + int try = 0; > > + > > + /* wait for the device to complete HPB reset query */ > > + do { > > + if (++try == HPB_RESET_REQ_RETRIES) > > + break; > > + > > + dev_info(hba->dev, > > + "%s start flag reset polling %d times\n", > > + __func__, try); > > + > > + /* Poll fHpbReset flag to be cleared */ > > + err = ufshcd_query_flag(hba, UPIU_QUERY_OPCODE_READ_FLAG, > > + QUERY_FLAG_IDN_HPB_RESET, 0, &flag_res); > > + usleep_range(1000, 1100); > > + } while (flag_res); > > + > > + if (err) { > > + dev_err(hba->dev, > > + "%s reading fHpbReset flag failed with error %d\n", > > + __func__, err); > > + return; > > + } > > + > > + if (flag_res) { > > + dev_err(hba->dev, > > + "%s fHpbReset was not cleared by the device\n", > > + __func__); > > + } > > +} > > Should "polling %d times" perhaps be changed into "attempt %d"? I will change it. > The "if (err)" statement may be reached without "err" having been > initialized. Please fix. OK, I will initialize err to 0. > Additionally, please change the do-while loop into a for-loop, e.g. as > follows: > > for (try = 0; try < HPB_RESET_REQ_RETRIES; try++) > ... OK, I will change do-while to for-loop. Thanks, Daejun