From patchwork Tue Oct 18 00:11:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: subhashj@codeaurora.org X-Patchwork-Id: 9380903 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5DFCF600CA for ; Tue, 18 Oct 2016 00:11:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D887289EB for ; Tue, 18 Oct 2016 00:11:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4230528FF0; Tue, 18 Oct 2016 00:11:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3977289EB for ; Tue, 18 Oct 2016 00:11:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757655AbcJRALZ (ORCPT ); Mon, 17 Oct 2016 20:11:25 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:44090 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755209AbcJRALO (ORCPT ); Mon, 17 Oct 2016 20:11:14 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 268E1617BF; Tue, 18 Oct 2016 00:11:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1476749473; bh=60yl2CuS1xyymjVoOvYjFkSAHbz5dpOg8wWhg10XYlg=; h=From:To:Cc:Subject:Date:From; b=NZhnpXdx7vB/K/6YRBdlQ/+gFfrA76HhCKAWuwgP6Gl4hEXJNT/drvggJ85nOa7Qr G9KXtlt8sFpHQSfhjyewk3nDcsOSaCyD6PAiFvQ5JYcaJ2uAWiB6DF7Z0SdyViaDaK YkPipZFGhcScUy86fjvXzfo9QVuJQnEMBjFvmSzY= Received: from subhashj-linux1.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: subhashj@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 5A492617C4; Tue, 18 Oct 2016 00:11:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1476749472; bh=60yl2CuS1xyymjVoOvYjFkSAHbz5dpOg8wWhg10XYlg=; h=From:To:Cc:Subject:Date:From; b=CgYiBa7GJHo1Xa844/RNCT/65k4qcL2PrSEDje0tvbl6ukgoJVLnVT4sF7KUxjQKY XUE6cletSU8OMIgOzDsj41+BemQ+DfAR4IES8RjeeLvwaYppGSrRGvYPEKkmBBFCAz V1k5pc+ffa9oR745p3hDtoHLhlSYN3M40o4I7JoA= DMARC-Filter: OpenDMARC Filter v1.3.1 smtp.codeaurora.org 5A492617C4 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=pass smtp.mailfrom=subhashj@codeaurora.org From: Subhash Jadavani To: vinholikatti@gmail.com, jejb@linux.vnet.ibm.com, martin.petersen@oracle.com Cc: Venkat Gopalakrishnan , Subhash Jadavani , linux-scsi@vger.kernel.org (open list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 11/11] scsi: ufs: optimize clock gate work Date: Mon, 17 Oct 2016 17:11:07 -0700 Message-Id: <1476749468-11486-1-git-send-email-subhashj@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Venkat Gopalakrishnan In a case where gate work is called as part of cancel work from ungate path the clk state would be marked as REQ_CLKS_ON. There is no point gating the clocks and then end up turning them ON immediately in ungate work, save time by skipping the gate work and change the clk state to CLKS_ON as they are not turned off yet. Signed-off-by: Venkat Gopalakrishnan Signed-off-by: Subhash Jadavani --- drivers/scsi/ufs/ufshcd.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 7959793..8cf5d8f 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -739,7 +739,14 @@ static void ufshcd_gate_work(struct work_struct *work) unsigned long flags; spin_lock_irqsave(hba->host->host_lock, flags); - if (hba->clk_gating.is_suspended) { + /* + * In case you are here to cancel this work the gating state + * would be marked as REQ_CLKS_ON. In this case save time by + * skipping the gating work and exit after changing the clock + * state to CLKS_ON. + */ + if (hba->clk_gating.is_suspended || + (hba->clk_gating.state == REQ_CLKS_ON)) { hba->clk_gating.state = CLKS_ON; goto rel_lock; }