Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9125566pxu; Mon, 28 Dec 2020 07:14:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJzbCyJdM7ePoe4eOkbzrB4+MgO/ZcaeBzQZM7+P7exUdw9QtFbh687qUoEnIUu6drWIDew8 X-Received: by 2002:a17:906:3781:: with SMTP id n1mr12260096ejc.296.1609168494262; Mon, 28 Dec 2020 07:14:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609168494; cv=none; d=google.com; s=arc-20160816; b=wK6A7m8gOpcvat/qeyt3x8OFOn/zr3D0rbeyZsoOYOXg+IniH7nxVxdGGso560j2kw db01zCghH/602MJsCiVTdKj3ypND9EdHPZIl877Uqe/5xkiJ/hyZ4CK7ZnejNd2j3gTw 30F/vrE69+qjzmkODrOaF0nGlWQ9O5bLRyVukH8F7Pir9A68IVhBfDgEfU0FKt2xp+qm d79BHGS/sFm+gKAlQGLIAMxzpjnnZMtkP/rS7qa3ttPMsjDzw+8D5qiCAKMpRcNgVgrA w+WwIByj7xrO8l2XE4ZI740nUjLPfN5Jo5bKlJf3e36dUN70aUSjGnjYyf1O79+Cx/6u CVJg== 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=cUD0mPqFzF7DegT8qsdwCqzreMUBsdyyHw5ejcg6CGY=; b=o1wdU4lCEWWIQfhkKI+QOk+8nlcZf2dYL2o+t6rncQUWoPNAki0NzDDwqWkrRH+iz7 nxCrW7pjMbcnZrP3UkpVPambzJvvEq4nho1pKOiGFomDG8CFNB1sK+3z/lglKXnXvmVm VucWDbPnjWugWt30+45XBBYFq1OR9YcTxcPfjNEldj9+TUZg5x7bS5yCEgATR1mYeMpK Ziz9F4ihbVkVTygdDsyUgf3dwZsWh8Uy9LxBQdmXmFd5CWCJd56O5z9vcfNSgWe/czV+ VjTkTiPL4TDqYLgfMUI7+80UsBwYXLf/4DI1JWhUGk0XEDoIER0mVRyMEJurIAt2agfm 0GVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=doYYQamt; 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 zc2si18232376ejb.427.2020.12.28.07.14.30; Mon, 28 Dec 2020 07:14:54 -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=doYYQamt; 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 S2438366AbgL1OHO (ORCPT + 99 others); Mon, 28 Dec 2020 09:07:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:40882 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438256AbgL1OGx (ORCPT ); Mon, 28 Dec 2020 09:06:53 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9E7F52063A; Mon, 28 Dec 2020 14:06:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609164398; bh=CImXwjZ5kicmSfGd16UneT6nC4Z6JBmbZMY8SmL1zJk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=doYYQamt7Q85Vdk8wIpdRtWyXQg4cHIe789Yo8+NN5tJ3Pq5IBuB2ihfTRYxfTGfD COzMSGvWfubtJ8vV0KFbtifsXivuT7ausMAe0fyCBYPglI4PT5ParD2trcYOd6v8cJ nHbSkMyNgLLZXlIqNATfyPc7liSkq0RHAY/Ct/ms= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Asutosh Das , Can Guo , Jaegeuk Kim , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.10 166/717] scsi: ufs: Fix clkgating on/off Date: Mon, 28 Dec 2020 13:42:44 +0100 Message-Id: <20201228125028.910146440@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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: Jaegeuk Kim [ Upstream commit 8eb456be75af7e5a7ac0cd223eaa198cf7ee2ac1 ] The following call stack prevents clk_gating at every I/O completion. We can remove the condition, ufshcd_any_tag_in_use(), since clkgating_work will check it again. ufshcd_complete_requests(struct ufs_hba *hba) ufshcd_transfer_req_compl() __ufshcd_transfer_req_compl() __ufshcd_release(hba) if (ufshcd_any_tag_in_use() == 1) return; ufshcd_tmc_handler(hba); blk_mq_tagset_busy_iter(); Note that this still requires work to deal with a potential race condition when user sets clkgating.delay_ms to very small value. That can cause preventing clkgating by the check of ufshcd_any_tag_in_use() in gate_work. Link: https://lore.kernel.org/r/20201117165839.1643377-7-jaegeuk@kernel.org Fixes: 7252a3603015 ("scsi: ufs: Avoid busy-waiting by eliminating tag conflicts") Reviewed-by: Asutosh Das Reviewed-by: Can Guo Signed-off-by: Jaegeuk Kim Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/ufs/ufshcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 1ad7d6c130f5b..911aba3e7675c 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -1751,7 +1751,7 @@ static void __ufshcd_release(struct ufs_hba *hba) if (hba->clk_gating.active_reqs || hba->clk_gating.is_suspended || hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL || - ufshcd_any_tag_in_use(hba) || hba->outstanding_tasks || + hba->outstanding_tasks || hba->active_uic_cmd || hba->uic_async_done || hba->clk_gating.state == CLKS_OFF) return; -- 2.27.0