Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1520806ybh; Sun, 19 Jul 2020 23:38:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQGcOJQ4H3Xz4pc0A81bKpAdmk5EXI2s4TaxtgLi+PU47/Old0jW9bkw3EA+aQkzx46O0I X-Received: by 2002:a17:906:3a04:: with SMTP id z4mr18989291eje.441.1595227098826; Sun, 19 Jul 2020 23:38:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595227098; cv=none; d=google.com; s=arc-20160816; b=ggQls/HrjVAUnh4uwDz0KllMdguIfC4RvU9b4LB9MZIm9x6h1bQnt+xR3GYIv+Fw2w kbXLtK5OxQAvlFcv0HLXSZy+d5hVhTr86LI1O5yNhoJMl+ld13z58EG6FsLsh7bzXOUd TMxzLXZn15HU0FRfmTiZeg0cSzAoYAqhDNA3uQfKpzlgqx2Vack82qLaPaZ8vSBv2hNA p0lekWsVbXQBWpW58P8ciEXKNwu0r/F69rOW0JoGf0/sQu8mwXO+BUeWwWKtBpvFY9B4 encWVQBqsgzHq6hu0KGuyKE56J1BgnpklCPUz1U5OBdHdS7QGOi3aJhpsp4SqxXgkvsL FfsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:ironport-sdr; bh=X7fiqBYlBdqu6UQf6P+4YNNLqe7pF3XG5NzC3dIGZX8=; b=v/QtwtASfUQACO8CCyT3nIZeHyB/qpBcuTvZevyW+tvwPhkGQRAQNGpbkpvsrAzvvK gPwdBtCAa5eVFFUj9B6/69SJS4s6nZV/7Kq/gUuI4CqXvnVRUrf8kmm7BWBk/N7Y6R9W tQ7Pi+r3I5BnOU0pFiqS0NLOttt38+z9/+jrO5Ub1K8eukrV7yq5aHnJYN19qjoS5J4h yMHz+rmuqox9S1vDe5pNnoMpwW6g+JKI4zGSeaqcN5bFWuJekqoq+Rs25QjNy8y9ptGe /yzDmPEcgcqvEPw4bz7coo0Erma/yQhG0+PPC5fw30A9t6P2td2FWN2ZbGLVaP/MOQZs yjVw== ARC-Authentication-Results: i=1; mx.google.com; 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 w17si5651993edx.522.2020.07.19.23.37.56; Sun, 19 Jul 2020 23:38:18 -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; 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 S1727870AbgGTGgJ (ORCPT + 99 others); Mon, 20 Jul 2020 02:36:09 -0400 Received: from labrats.qualcomm.com ([199.106.110.90]:5831 "EHLO labrats.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726612AbgGTGgH (ORCPT ); Mon, 20 Jul 2020 02:36:07 -0400 IronPort-SDR: bA0f+rOOMxZIZUWQsidAv72INfEBHAxg9rtWxwPTbHu6uAeBGSyPDrdV77lU57plbpVvbcyuhU Flp6EUPbi9kNXF9g89XqON2RILUAHdodnJ3Az3hI2aezCjPLtZ3deTYsxyfMzxQIA/2bZ7Xcqo akWtlqj0lHf6yrTO8l2mKPf86csu/V7IPNJK1zCqfq/juvxtAYxsxfirETe4EsVwxm88+5xVZJ L8P2KDZQmLWFKXR7FWMW2hRC913Rkt+Oy6982KTSGBnKOzPB/HV5Vw0ljL21ACf8Bou09rNJ1U 0nE= X-IronPort-AV: E=Sophos;i="5.75,374,1589266800"; d="scan'208";a="47226981" Received: from unknown (HELO ironmsg03-sd.qualcomm.com) ([10.53.140.143]) by labrats.qualcomm.com with ESMTP; 19 Jul 2020 23:36:07 -0700 Received: from pacamara-linux.qualcomm.com ([192.168.140.135]) by ironmsg03-sd.qualcomm.com with ESMTP; 19 Jul 2020 23:36:06 -0700 Received: by pacamara-linux.qualcomm.com (Postfix, from userid 359480) id D891622DA5; Sun, 19 Jul 2020 23:36:06 -0700 (PDT) From: Can Guo To: asutoshd@codeaurora.org, nguyenb@codeaurora.org, hongwus@codeaurora.org, rnayak@codeaurora.org, sh425.lee@samsung.com, linux-scsi@vger.kernel.org, kernel-team@android.com, saravanak@google.com, salyzyn@google.com, cang@codeaurora.org Cc: Alim Akhtar , Avri Altman , "James E.J. Bottomley" , "Martin K. Petersen" , Stanley Chu , Bean Huo , Bart Van Assche , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 2/8] scsi: ufs: Fix imbalanced scsi_block_reqs_cnt caused by ufshcd_hold() Date: Sun, 19 Jul 2020 23:35:49 -0700 Message-Id: <1595226956-7779-3-git-send-email-cang@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1595226956-7779-1-git-send-email-cang@codeaurora.org> References: <1595226956-7779-1-git-send-email-cang@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.