From patchwork Wed Jan 20 15:01:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanley Chu X-Patchwork-Id: 12032603 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E13E6C433DB for ; Wed, 20 Jan 2021 15:02:38 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6F0D323356 for ; Wed, 20 Jan 2021 15:02:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6F0D323356 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=uVQbP4W2VPJYh1uwbIPVuLm+r5TAMkRPh9b//uxmhtI=; b=fXziTdL6uEsAEsHzi3mfVC5Xg MJp8hZ8RoUazfiIBnfli2A1MUhR3o1CEUWJUqka1ZhAn3ftAqLuiIDMcHRdZh50z6RWVQULStGdLe vP3PlFyUoi0ODY7Yo9msdCpyFJz/oIsq9KWnPyGEHS5okfMMQTnCq8/XpRWqU8lF7eSUETb60pKRD cmDPM58r6XaWBZ8rZ2GaHgnYKJPLdWZBsotf3oMgiSi7Hpdu4/EaSiO3FZpqx26SClQIooKZHQcj9 uJIaBDy4h/S/xgOUl0sJhB1uIyfxBHZwI3guY4tZ1rWowSiyIAHNlurvoDkshh4FVDNR4jW+dEMhA QDUbRnnZw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l2F04-0002J3-6j; Wed, 20 Jan 2021 15:02:24 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l2Ezs-0002Eq-AU; Wed, 20 Jan 2021 15:02:13 +0000 X-UUID: bd2e16f53d06424f9c924c394202d2b5-20210120 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=TrzG6rijurgKzvAQn+c+8UAVCHamTfk+6oKc71LR6Nw=; b=cWIu7A+Khw4U4ejZZkoQxSzNDXJYfbOwkfpsemSS5cyt8ul14rAZXgM2Eh9nkDT90zNPXMC90b0EIn0BUHjaDoFMn9ZyZ5IZzWdMjIRftH2XWGtRVS7DolQqpzrq1kwxdHpG2jx94FZRryKT0L0KGX34Po4JHxAZe5kkk5fwbi4=; X-UUID: bd2e16f53d06424f9c924c394202d2b5-20210120 Received: from mtkcas67.mediatek.inc [(172.29.193.45)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1163706765; Wed, 20 Jan 2021 07:02:08 -0800 Received: from mtkmbs08n1.mediatek.inc (172.21.101.55) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 20 Jan 2021 07:02:06 -0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs08n1.mediatek.inc (172.21.101.55) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 20 Jan 2021 23:01:52 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 20 Jan 2021 23:01:52 +0800 From: Stanley Chu To: , , , , Subject: [PATCH v3 1/3] scsi: ufs: Refactor cancelling clkscaling works Date: Wed, 20 Jan 2021 23:01:40 +0800 Message-ID: <20210120150142.5049-2-stanley.chu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210120150142.5049-1-stanley.chu@mediatek.com> References: <20210120150142.5049-1-stanley.chu@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210120_100212_498247_C2ACFD35 X-CRM114-Status: GOOD ( 11.91 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stanley Chu , alice.chao@mediatek.com, bvanassche@acm.org, andy.teng@mediatek.com, cc.chou@mediatek.com, chun-hung.wu@mediatek.com, kuohong.wang@mediatek.com, linux-kernel@vger.kernel.org, jiajie.hao@mediatek.com, cang@codeaurora.org, linux-mediatek@lists.infradead.org, peter.wang@mediatek.com, matthias.bgg@gmail.com, beanhuo@micron.com, chaotian.jing@mediatek.com, linux-arm-kernel@lists.infradead.org, asutoshd@codeaurora.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Cancelling suspend_work and resume_work is only required while suspending clk-scaling. Thus moving these two invokes into ufshcd_suspend_clkscaling() function. Reviewed-by: Can Guo Signed-off-by: Stanley Chu --- drivers/scsi/ufs/ufshcd.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 5450e049d1a9..226504d05c14 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -1503,6 +1503,9 @@ static void ufshcd_suspend_clkscaling(struct ufs_hba *hba) if (!ufshcd_is_clkscaling_supported(hba)) return; + cancel_work_sync(&hba->clk_scaling.suspend_work); + cancel_work_sync(&hba->clk_scaling.resume_work); + spin_lock_irqsave(hba->host->host_lock, flags); if (!hba->clk_scaling.is_suspended) { suspend = true; @@ -1564,9 +1567,6 @@ static ssize_t ufshcd_clkscale_enable_store(struct device *dev, pm_runtime_get_sync(hba->dev); ufshcd_hold(hba, false); - cancel_work_sync(&hba->clk_scaling.suspend_work); - cancel_work_sync(&hba->clk_scaling.resume_work); - hba->clk_scaling.is_enabled = value; if (value) { @@ -5783,11 +5783,8 @@ static void ufshcd_err_handling_prepare(struct ufs_hba *hba) ufshcd_vops_resume(hba, pm_op); } else { ufshcd_hold(hba, false); - if (hba->clk_scaling.is_enabled) { - cancel_work_sync(&hba->clk_scaling.suspend_work); - cancel_work_sync(&hba->clk_scaling.resume_work); + if (hba->clk_scaling.is_enabled) ufshcd_suspend_clkscaling(hba); - } down_write(&hba->clk_scaling_lock); hba->clk_scaling.is_allowed = false; up_write(&hba->clk_scaling_lock); @@ -8707,11 +8704,9 @@ static int ufshcd_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) ufshcd_hold(hba, false); hba->clk_gating.is_suspended = true; - if (hba->clk_scaling.is_enabled) { - cancel_work_sync(&hba->clk_scaling.suspend_work); - cancel_work_sync(&hba->clk_scaling.resume_work); + if (hba->clk_scaling.is_enabled) ufshcd_suspend_clkscaling(hba); - } + down_write(&hba->clk_scaling_lock); hba->clk_scaling.is_allowed = false; up_write(&hba->clk_scaling_lock);