Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1236471pxu; Mon, 23 Nov 2020 15:33:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJzm1alq4PJg14a/aiiQkIe4uk9o8qF2D5TqwWXgLT2zV0piCmHTjuVeE/SJlMKcrFYyyNgT X-Received: by 2002:a17:906:f1d8:: with SMTP id gx24mr1757183ejb.73.1606174416107; Mon, 23 Nov 2020 15:33:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606174416; cv=none; d=google.com; s=arc-20160816; b=eIRDL2G5ewi5+51Y0vnsb3/fhfc8Aa2NX9JqxD/xGuS9qeCDtVHqVMhpaWjYuzYovm cAt+Y2w8rWp371uajfFXsn+ClCKqPj0AfMym866kTHNPPVDZF4JGKRR3uqRJCweOjAlq qPr81vE5PYipsraIemuNkIkgC/s8Wa7/i+qZ3EREB0hiKc1T2WO1nvPuVH+epNfzc0MU gzfmhLtf0mpoBJ4mluO5/JZbIPve6mlHijaadU6L6+6DFJ3+UvpwwdKdCqpHkpcuVHCx /3HNTzPz5aHNEyHzNhcRwCuoXukg/2kdc8F9w9VqbJz1Y4POXwlJ3PtZ7khWv9XOAAlR Ca6w== 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=+5rwxgWeBDXAK5SH5dDC6BNhLyxMVrBbeOmmQ69a9B0=; b=rKT6JAAPAnSigmMOk80J6+LQJbEP7pRE+oelb4yybCOrh25POHaxqROKGVI3V1TMgm vROS5mZrX7wAkWFhioOdBBnmpXjDTQpemGWE0m9OgFn6lcKulpohJzST2jf5pBCpFmR5 xKzvaoAQHddmdbVC9/i4sSF/rp+m4SVxacI/19iim4MejXqrTP9iBNTE3VlI0EaOIYHY cJJbZZLX+R8DXcL56XKv2J8PRd08l0V4zGPm3oSISg6vky+ZuOEw+Hpoc7Y2A5qr5vVa MqGqdY5+B0fSdomvepONQXqFxiq0gDatShCUgicex4h8TJAv4WL2/mzrmX0VajrL33d6 YOww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zaxcQydZ; 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 qt10si8566150ejb.44.2020.11.23.15.33.13; Mon, 23 Nov 2020 15:33:36 -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=zaxcQydZ; 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 S1729952AbgKWMaj (ORCPT + 99 others); Mon, 23 Nov 2020 07:30:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:41402 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730260AbgKWMaf (ORCPT ); Mon, 23 Nov 2020 07:30:35 -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 E6ACD221F7; Mon, 23 Nov 2020 12:30:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606134634; bh=/MUdipLcb4JkvDppPS27UAP/oB9I9J9uiNiR54nSO1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zaxcQydZApjPWuI0ZbK/I2qiLaHv84E1+8iiYBG+fURcmuixzBaSl4AlKj1ukfKeJ DTeivLJ7T+Myvxiiku7CyGgY/2BQzz/DTKjBOmap59GGm4X4R/bDeU1upIADUXwp6A 9eBSrTnMy4DkhUbSw4XikKD88YWGJqNyqFdPsWUA= 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 4.19 28/91] scsi: ufs: Fix unbalanced scsi_block_reqs_cnt caused by ufshcd_hold() Date: Mon, 23 Nov 2020 13:21:48 +0100 Message-Id: <20201123121810.692132832@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121809.285416732@linuxfoundation.org> References: <20201123121809.285416732@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 b2cbdd01ab10b..a63119c35fde8 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -1592,12 +1592,12 @@ int ufshcd_hold(struct ufs_hba *hba, bool async) * work and to enable clocks. */ 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