Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp155629pxb; Mon, 8 Feb 2021 18:32:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJzOmXLa27FUZuCZa3RjcjGM3Iev/4hBcotkXVZUabrIN2J7qorwUkx5vFBW2uRp04Qeq1Sg X-Received: by 2002:a05:6402:31a3:: with SMTP id dj3mr19952253edb.172.1612837923053; Mon, 08 Feb 2021 18:32:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612837923; cv=none; d=google.com; s=arc-20160816; b=od3GJn86SwzTdBdaFauPuJ5+qFO1up+yHes/9Uo3KLjvUbSgm+T7++qxnEpkCxHrUx GdzRkQWw+4hcCM8oa9y4J6GMJK5eYCraX6u1oUMFT+C3NH9oN/2dqSczioJPJtpQQqYG 2C5/zZUfIgbE9e6cvZ0d+lWUgPv7lQxU+YuVFtttRFhPdRA8W7adWiq9zR2umUTM0CT2 gtuj9tien6QE7f7qx0gttMk3IRIJGtdmfVOln10rGVr/pmCBorQNn3iSl/gEGIMpcWoG CQk9Km/P23CZebyPMJmC0m+8ysgNC6mLOoVG4e0hdAQbFV1QAkXvxkPTPOp4PXZY1IwS HxSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:message-id:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :sender:dkim-signature; bh=N5MkOy+dItUMJzDjFfLkpv3cK/NtA8m2zIRGjlV7V2w=; b=fhO5lfPRBSKjgtvD+4rxrEj/xdQanNJxvEmFJo88ATFwljUGPPQDPd9ENMPSy1XdmW gPknVNHUlO5ax3TZY2u0guALvNw22F1+urc3ASMNL/4YEU3GsMy6AmNXtA/Of78dKia4 qG3v4XZ4LmxcsF5EWbt6sVePYOOIRhl7KgnpQFfj22qK1l5Ozu9YxisastZcid8iBF0r +ZGgXK/Oxpi7b2q+WpeqxwY+6ev0iHSu0UxQDKkRsHE5Ww/NhLCIu7gEcpWLDsCYmeGh W5yuNDlIe1CZL0ArWlX1Rq5lelmS8c/wxVrKjD8c7KMGvyKcXCyY8kvstCX30TGPOx6R t7ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=FJmaFIBG; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i9si12349137ejy.32.2021.02.08.18.31.22; Mon, 08 Feb 2021 18:32:03 -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=@mg.codeaurora.org header.s=smtp header.b=FJmaFIBG; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230320AbhBIC25 (ORCPT + 99 others); Mon, 8 Feb 2021 21:28:57 -0500 Received: from mail29.static.mailgun.info ([104.130.122.29]:21799 "EHLO mail29.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230149AbhBIC24 (ORCPT ); Mon, 8 Feb 2021 21:28:56 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1612837708; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=N5MkOy+dItUMJzDjFfLkpv3cK/NtA8m2zIRGjlV7V2w=; b=FJmaFIBGAmjxv/VuDXQEI98kf1ayN1fghIEZRmkj9UgccSB+aRA7xr5/+XTc7/KNQXnl3gnx +4kaQzM7cwPDibot5CwETk+e69KJgHCi83urP/HBGAPEmij9+IKNYN75JrkSGBPMpDJ7aGeO b9OKfmMt2J5JOW9e/SxNCBDo7ak= X-Mailgun-Sending-Ip: 104.130.122.29 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n01.prod.us-east-1.postgun.com with SMTP id 6021f333e3df861f4b98bc8c (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 09 Feb 2021 02:28:03 GMT Sender: cang=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id AAD94C43465; Tue, 9 Feb 2021 02:28:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: cang) by smtp.codeaurora.org (Postfix) with ESMTPSA id C1375C433CA; Tue, 9 Feb 2021 02:28:01 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 09 Feb 2021 10:28:01 +0800 From: Can Guo To: daejun7.park@samsung.com 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 Subject: Re: [PATCH v19 2/3] scsi: ufs: L2P map management for HPB read In-Reply-To: <20210209012734epcms2p8354347b1dd71601e74b505c715d36af0@epcms2p8> References: <5b9f5edbe26930765ee4adaa786db7da@codeaurora.org> <88b608e2e133ba7ccd5bb452898848fd@codeaurora.org> <5bd43da52369a56f18867fa18efb3020@codeaurora.org> <20210129052848epcms2p6e5797efd94e6282b76ad9ae6c99e3ab5@epcms2p6> <20210129053005epcms2p323338fbb83459d2786fc0ef92701b147@epcms2p3> <20210208080333epcms2p59403f0acbc9730c9a605d265836a956d@epcms2p5> <20210208085346epcms2p1c11b70be9d258df66cb2ca4542835fac@epcms2p1> <20210209012734epcms2p8354347b1dd71601e74b505c715d36af0@epcms2p8> Message-ID: <4bc9f6ea1189cffa92e70a9afbb95e9f@codeaurora.org> X-Sender: cang@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-02-09 09:27, Daejun Park wrote: >>>>>> @@ -342,13 +1208,14 @@ void ufshpb_suspend(struct ufs_hba *hba) >>>>>> > struct scsi_device *sdev; >>>>>> > >>>>>> > shost_for_each_device(sdev, hba->host) { >>>>>> > - hpb = sdev->hostdata; >>>>>> > + hpb = ufshpb_get_hpb_data(sdev); >>>>>> > if (!hpb) >>>>>> > continue; >>>>>> > >>>>>> > if (ufshpb_get_state(hpb) != HPB_PRESENT) >>>>>> > continue; >>>>>> > ufshpb_set_state(hpb, HPB_SUSPEND); >>>>>> > + ufshpb_cancel_jobs(hpb); >>>>>> >>>>>> Here may have a dead lock problem - in the case of runtime >>>>>> suspend, >>>>>> when ufshpb_suspend() is invoked, all of hba's children scsi >>>>>> devices >>>>>> are in RPM_SUSPENDED state. When this line tries to cancel a >>>>>> running >>>>>> map work, i.e. when ufshpb_get_map_req() calls below lines, it >>>>>> will >>>>>> be stuck at blk_queue_enter(). >>>>>> >>>>>> req = blk_get_request(hpb->sdev_ufs_lu->request_queue, >>>>>> REQ_OP_SCSI_IN, 0); >>>>>> >>>>>> Please check block layer power management, and see also commit >>>>>> d55d15a33 >>>>>> ("scsi: block: Do not accept any requests while suspended"). >>>>> >>>>> I am agree with your comment. >>>>> How about add BLK_MQ_REQ_NOWAIT flag on blk_get_request() to avoid >>>>> hang? >>>>> >>>> >>>> That won't work - BLK_MQ_REQ_NOWAIT allows one to fast fail from >>>> blk_mq_get_tag(), >>>> but blk_queue_enter() comes before __blk_mq_alloc_request(); >>>> >>> In blk_queue_enter(), BLK_MQ_REQ_NOWAIT flag can make error than wait >>> rpm >>> resume. Please refer following code. >> >> Oops, sorry, my memory needs to be refreshed on that part. >> >> But will BLK_MQ_REQ_NOWAIT flag breaks your original purpose? When >> runtime suspend is out of the picture, if traffic is heavy on the >> request queue, map_work() will be stopped frequently once it is >> not able to get a request from the queue - that shall pull down the >> efficiency of one map_work(), that may hurt random performance... > > I think deadlock prevention is the most important. So I want to add > BLK_MQ_REQ_NOWAIT flag. > Starvation of map request can be distinguish by return value of > blk_get_request(). -EWOULDBLOCK means there is no available tags for > this > request. -EBUSY means failed on blk_queue_enter(). To overcome > starvation > of map request, we can try N times in heavy traffic situation (maybe > N=3?). > LGTM. You make the call. Regards, Can Guo. > Thanks, > Daejun