Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1009971ybh; Wed, 22 Jul 2020 20:23:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqQRIcLk+yukM34YlVtfoNnMLrHhZZt2yV3muK4cBUjgzg/ZVGXjRxQlm3Qr7bcy8qzzGA X-Received: by 2002:a17:906:408c:: with SMTP id u12mr2418974ejj.162.1595474620722; Wed, 22 Jul 2020 20:23:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595474620; cv=none; d=google.com; s=arc-20160816; b=Wr9NXtppwIU9tq9oP1DAgE3S8Z2z8u4tySvXa8XC/NjSo/7s3YmO3ydIhMMy39bkDM 7KLjNuN6pL/jb5cVgpWWY0/s9ADW+frfB5+2CUWvAHcpwYmAz4ZEs+PfApsqrBGPfh47 bhG2qn/PcS2LHEMn8qsLvVuNcQgKbeOG/r1yOhYZSJfGgch8GDJHphe6iwdTS+vHAQ4P UNyT8sScqP0uZC5I3yJcGC3n9/7iD9KaGcBhWZV5FXBtaGmLcPgeJzG6fPMzEZm7Mskd Xu8w5m0IDDU5dfngcGWaLe/NPwpxLynHn07FcdTdMGfrQE/giC7j7lBRnLZeUpUO1LLz jwng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature; bh=GYUHQD9UFJd3/Ug179wafi2cUgd7wUBMj5u8vpLP3qU=; b=vvmjQ997n3gpz7n/erYusiJjzI+riO4vm9X1XGJISA/HuEgkQK80gyQO1J1f6m5tZe mAbfeo4WeGaqO3p3AbqLSAwcZor9xiDtc9cFLVuIPlZoDi2z84LA9ifGq7FzRTuic6K3 7zAJ4iv48oL6wScbYSdgltdfGkoHhjaPShvOYs8ZSojORdcuxZuNkrW13PuU0vIyCiDR NRAM4q8Ozk/YKQTVOK7qaHjHYH/NS+KVWNlbVImoZktEYVyeGKlAOQKZPvSur3qhJHmM i7oJ7VOnZ/DmPURYB0QZdw+CYMbHWSUjKyajVbCY0gDP3qeEGQmgRBZzG0nEj70VwjiT IvsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=TvV+b3pR; 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 v19si1119075ejj.608.2020.07.22.20.23.18; Wed, 22 Jul 2020 20:23:40 -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=fail header.i=@mg.codeaurora.org header.s=smtp header.b=TvV+b3pR; 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 S1733229AbgGWDVG (ORCPT + 99 others); Wed, 22 Jul 2020 23:21:06 -0400 Received: from mail29.static.mailgun.info ([104.130.122.29]:39341 "EHLO mail29.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728902AbgGWDVF (ORCPT ); Wed, 22 Jul 2020 23:21:05 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1595474465; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=GYUHQD9UFJd3/Ug179wafi2cUgd7wUBMj5u8vpLP3qU=; b=TvV+b3pRCLmWR0mkIEuKLKlxNcvjPEMq3eH+J/Q/dabzUFa6xGiYylcs0j1P1TnfdGTtHJmV h1zB5VK4sAR5oDuo00Er9tAmReHv5vA9tYTZj1/kRaXlFQGQNmCLnueuwUejRJ+e91f8O1WW hr/C78xIarsLtuaipNrpEUlqcbM= 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-n12.prod.us-east-1.postgun.com with SMTP id 5f190214f9ca681bd095ffe3 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Thu, 23 Jul 2020 03:20:52 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 1BF0EC43391; Thu, 23 Jul 2020 03:20:52 +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=-1.0 required=2.0 tests=ALL_TRUSTED 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: hongwus) by smtp.codeaurora.org (Postfix) with ESMTPSA id 22B10C433C9; Thu, 23 Jul 2020 03:20:50 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 23 Jul 2020 11:20:50 +0800 From: hongwus@codeaurora.org To: Can Guo Cc: asutoshd@codeaurora.org, nguyenb@codeaurora.org, rnayak@codeaurora.org, sh425.lee@samsung.com, linux-scsi@vger.kernel.org, kernel-team@android.com, saravanak@google.com, salyzyn@google.com, Alim Akhtar , Avri Altman , "James E.J. Bottomley" , "Martin K. Petersen" , Stanley Chu , Bean Huo , Bart Van Assche , linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 2/9] scsi: ufs: Fix imbalanced scsi_block_reqs_cnt caused by ufshcd_hold() In-Reply-To: <1595471649-25675-3-git-send-email-cang@codeaurora.org> References: <1595471649-25675-1-git-send-email-cang@codeaurora.org> <1595471649-25675-3-git-send-email-cang@codeaurora.org> Message-ID: <307b91fd2d7a59a3e1caa1819e2593e5@codeaurora.org> X-Sender: hongwus@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Can, On 2020-07-23 10:34, Can Guo wrote: > The scsi_block_reqs_cnt increased in ufshcd_hold() is supposed to be > decreased back in ufshcd_ungate_work() in a paired way. However, if > specific ufshcd_hold/release sequences are met, it is possible that > scsi_block_reqs_cnt is increased twice but only one ungate work is > queued. To make sure scsi_block_reqs_cnt is handled by ufshcd_hold() > and > ufshcd_ungate_work() in a paired way, increase it only if queue_work() > returns true. > > Signed-off-by: Can Guo > --- > drivers/scsi/ufs/ufshcd.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index 99bd3e4..2907828 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -1611,12 +1611,12 @@ int ufshcd_hold(struct ufs_hba *hba, bool > async) > */ > /* fallthrough */ > case CLKS_OFF: > - ufshcd_scsi_block_requests(hba); > hba->clk_gating.state = REQ_CLKS_ON; > trace_ufshcd_clk_gating(dev_name(hba->dev), > hba->clk_gating.state); > - queue_work(hba->clk_gating.clk_gating_workq, > - &hba->clk_gating.ungate_work); > + if (queue_work(hba->clk_gating.clk_gating_workq, > + &hba->clk_gating.ungate_work)) > + ufshcd_scsi_block_requests(hba); > /* > * fall through to check if we should wait for this > * work to be done or not. Yes, queue_work() may fail for some reasons. We should make sure scsi_block_reqs_cnt is balanced. Your change looks good to me since it touches scsi_block_reqs_cnt only when the condition is met. Reviewed-by: Hongwu Su