Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3856695pxb; Mon, 8 Feb 2021 01:43:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJzGnRirC/ksdQvZsUdofO+d/JvuxnYclcYe37daGVUDr00VWzBHvK7CfC4Tq65or/LDEELs X-Received: by 2002:a17:906:d8b5:: with SMTP id qc21mr15394933ejb.62.1612777387811; Mon, 08 Feb 2021 01:43:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612777387; cv=none; d=google.com; s=arc-20160816; b=UIldfProhB8Hjoe4lId4vLZj8TwehDux2rYc6Oeasq5KSepCq9cw+o5O6T//61wzVW 2QlwuqndIMBqh1SQDWmUzF5HJoUhyJJCVXHWT5wT/wsr2iJXCcUaN1k9pk0kmc1llW97 POriWadDBfTFdgVfKgReOGWxeC61pyGOZ2lJicTwLKkeHHaBU/bSPprvyeHmKG9baDU1 neb9W4OIV+zGAK+Z5QZ7CBM8A9BLoVAVOmjibZQNzJVzv38CAUt4+zsnaaEpR6l4f0cW CYIQR2JUob1o8KdjTaI+driFpX+KUwVUlWeI5JrOc20sX0usPnYF8qKx6qPb1jxec9fp SHrg== 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=I/bB5csHyQa5LojQBmfZSqE+Dm4Nn4V/dZ5cfnA1UYE=; b=Y6kPTWqMeoJT4r/Tf4jDe2Kh0RVJiz1xdy/M9sqfu7pySl1U8BqJ6wrKPTu9NKLgZX l4iW++SbWDf+9A9kADOCNySc0ix38mIoXopLlInHUDQfNi/fepruqi7YNENwDuXXSFx3 1hEnRgEUpNEy3fsMuELgcApS4+5/Oc5N30/ZADy/5bd4r5pLuklJrC+AD2V3wzQNS8NM dV1klfxm9Nrjy0I5ivXbok2PEHEH0yC0BDlGUDCR/b2JT6QxYK5J/1yjhYO2nBfl83nI iZl6JbVDGARJtrx2v2fmanNkdogf0bJWogRUxgy/A2mqc4eYp78NG0LwpgqRvYJMjdb1 bZzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=T7wF63BJ; 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 ay19si10668680ejb.621.2021.02.08.01.42.44; Mon, 08 Feb 2021 01:43:07 -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=T7wF63BJ; 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 S231748AbhBHJj0 (ORCPT + 99 others); Mon, 8 Feb 2021 04:39:26 -0500 Received: from mail29.static.mailgun.info ([104.130.122.29]:17871 "EHLO mail29.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230218AbhBHJYH (ORCPT ); Mon, 8 Feb 2021 04:24:07 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1612776228; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=I/bB5csHyQa5LojQBmfZSqE+Dm4Nn4V/dZ5cfnA1UYE=; b=T7wF63BJP0J3c8RUmhw1AhynIoJ+UHUUwAC7u3dqs22RZYJg4upVi8hOHVjRCL3hISRqkk4j KfCkVybmFdjab1bguc2UStAzTRx5rDyPCxUUJXw8EYfcder4/2MJWGaQwvXgbrZVxB4XiKFD R9y6Mln4GEKt2r2HpyzDldgxk/0= 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-n07.prod.us-west-2.postgun.com with SMTP id 6021030134db06ef790e834c (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 08 Feb 2021 09:23:13 GMT Sender: cang=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 108FEC43464; Mon, 8 Feb 2021 09:23:12 +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 23D27C433CA; Mon, 8 Feb 2021 09:23:12 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 08 Feb 2021 17:23:12 +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: <20210208085346epcms2p1c11b70be9d258df66cb2ca4542835fac@epcms2p1> References: <88b608e2e133ba7ccd5bb452898848fd@codeaurora.org> <5bd43da52369a56f18867fa18efb3020@codeaurora.org> <20210129052848epcms2p6e5797efd94e6282b76ad9ae6c99e3ab5@epcms2p6> <20210129053005epcms2p323338fbb83459d2786fc0ef92701b147@epcms2p3> <20210208080333epcms2p59403f0acbc9730c9a605d265836a956d@epcms2p5> <20210208085346epcms2p1c11b70be9d258df66cb2ca4542835fac@epcms2p1> Message-ID: <5b9f5edbe26930765ee4adaa786db7da@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-08 16:53, 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... Can Guo. > > int blk_queue_enter(struct request_queue *q, blk_mq_req_flags_t flags) > { > const bool pm = flags & BLK_MQ_REQ_PM; > > while (true) { > bool success = false; > > rcu_read_lock(); > if (percpu_ref_tryget_live(&q->q_usage_counter)) { > /* > * The code that increments the pm_only counter is > * responsible for ensuring that that counter is > * globally visible before the queue is unfrozen. > */ > if ((pm && queue_rpm_status(q) != RPM_SUSPENDED) || > !blk_queue_pm_only(q)) { > success = true; > } else { > percpu_ref_put(&q->q_usage_counter); > } > } > rcu_read_unlock(); > > if (success) > return 0; > > if (flags & BLK_MQ_REQ_NOWAIT) > return -EBUSY; <-- out from the function. > > Thanks, > Daejun