Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp833580pxu; Mon, 23 Nov 2020 05:27:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJzNADMj5y78GHlUUkHN83NksgN8HS3iLZY2oLq2QGFGFO0fBDTvM8q4XQw00Rf8W8mWjgJO X-Received: by 2002:a17:906:d72:: with SMTP id s18mr44088043ejh.110.1606138077861; Mon, 23 Nov 2020 05:27:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606138077; cv=none; d=google.com; s=arc-20160816; b=gPbjVcxq0CfDW2CwYCwa2QdkLgKh4VT7wj2MQ2iveCiVfdAWqWGujzScMu05Lj6LpK 7DGD4oTVYDfKBw/c4GIm/JkCi9BBly1EbbbhdE/Cci19mmti96ImlJANgn0FG2aQ2PDh JCXvF1/94aX97pY3J60WGlHDSvkPSBVq6FHOBgDX4Mch5Pst1kHsWYxMTM/GvT2PLS4+ SSrKzTOxvR01OG/u/KlGmx8tpEdTox4YVDeOgd1HKMLjCKpuaosCBtCfNRqNrdEq5xQ1 nYWss3oP1eSOZdRySse95usVKkXrKH9iEGSq+mmKnzxmeZKhbE0QTBdSLjlNRz+02LEd NF5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NocfZRT9E7E4VHMvm8CJt6DvfRHkPUUP3UEsLtC0RMM=; b=TFlPPTxqRGpdWshrQ89JiWZWMzgREwnN1eX72kSQbj/u1SKUcxQSCEZMBi8mKDbhbW C0P//5hiFhLlwGxrJHC+WeqPPxI4q6GfjckM2L+4mqeVp/I2YKKl+gSyBPniaaEF9IOC k5DZw1bT9ls/rB4/SsopoR04ESHjbZXz+P7oKB28nro74mFkcgZIlHTcTy2zpjoMd1n8 eJUXnh2Yoqv2P1U6hw7pNeDyXSaO9txTFD1DNtASy8BuNxGv41ODQMBfvsohOJFh4HuU mzP75ROHYLCYzbaBSjXI/wmqAGpj8UxF6wb8SI5SgY/FDeDU01+bi0z8rrx7tGVIcSh5 puOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YmZLiakj; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qu18si6331466ejb.438.2020.11.23.05.27.34; Mon, 23 Nov 2020 05:27:57 -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=@linuxfoundation.org header.s=korg header.b=YmZLiakj; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389029AbgKWNXi (ORCPT + 99 others); Mon, 23 Nov 2020 08:23:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:47108 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731482AbgKWMfG (ORCPT ); Mon, 23 Nov 2020 07:35:06 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 23BD2221F9; Mon, 23 Nov 2020 12:35:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606134905; bh=rZhCcoxyzUhsV6+Tfjb0wBJ4sLCM3axaR3A755iBjDg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YmZLiakjGcYA7ZpJJNKZ1lEuguX8CqQ40KZUY7tUBzf9acMkeMrB2MyNpPltoNPAX zj1gX/RODnwZ7gRnO5uvT60ohIxLAxRN7NucMsHnrTIiqDcDwysP9wuA7Fkz5Yr69c uN1lZwqxWVOd3yDdfGHGh0CGT0dMlG4GZEwUeXtI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hongwu Su , Stanley Chu , Bean Huo , Can Guo , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.4 035/158] scsi: ufs: Fix unbalanced scsi_block_reqs_cnt caused by ufshcd_hold() Date: Mon, 23 Nov 2020 13:21:03 +0100 Message-Id: <20201123121821.629106688@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121819.943135899@linuxfoundation.org> References: <20201123121819.943135899@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Can Guo [ Upstream commit da3fecb0040324c08f1587e5bff1f15f36be1872 ] 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. Link: https://lore.kernel.org/r/1604384682-15837-2-git-send-email-cang@codeaurora.org Reviewed-by: Hongwu Su Reviewed-by: Stanley Chu Reviewed-by: Bean Huo Signed-off-by: Can Guo Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- 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 d538b3d4f74a5..0772327f87d93 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -1569,12 +1569,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. -- 2.27.0