From patchwork Sat Feb 4 00:58:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: subhashj@codeaurora.org X-Patchwork-Id: 9555407 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 13E2C602B7 for ; Sat, 4 Feb 2017 00:58:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F40CC27C0C for ; Sat, 4 Feb 2017 00:58:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E8F4B28478; Sat, 4 Feb 2017 00:58:18 +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=unavailable 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 9748B27C0C for ; Sat, 4 Feb 2017 00:58:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753459AbdBDA6J (ORCPT ); Fri, 3 Feb 2017 19:58:09 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:44542 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753138AbdBDA6H (ORCPT ); Fri, 3 Feb 2017 19:58:07 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 1EAA160910; Sat, 4 Feb 2017 00:58:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1486169887; bh=QneKjhbZ3A4Ta+aBGSPnZC8WnGzbd2lmlCXiAvh9j7I=; h=From:To:Cc:Subject:Date:From; b=Q8T3LTOcpsqbuXURYpiZqaU7HBwFL/6EjdrldPKnY3E/kXkvSXsmwPMAET0UDO2IP 5qiMaZzAMdkt6fQ7KWicaYXNl9E3PRBLbh7fvTgX+gP1nzn7N/IDS8hssrzG5LqyJD qe2vOoBE7b9/RQU15H2itnuGIcQz8yQLFUX9D23g= Received: from pacamara-linux.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 6F2DC6090C; Sat, 4 Feb 2017 00:58:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1486169886; bh=QneKjhbZ3A4Ta+aBGSPnZC8WnGzbd2lmlCXiAvh9j7I=; h=From:To:Cc:Subject:Date:From; b=iQbjuuTChr9Gdtw52F32ltRjEU2WWIKJQDxPtUcQJfpU3RB7KYwHvr0jiUPOKMf+G T3nf5pv2B7ZVEx1b6NcSDTA9NVrexMBmyhhm449DqYC5UP3xaQYanHjaY3/UpKD2NO MTCP6PpbH1tYQNMR6iN2zVtxr3OKFze/qZ8kUfRA= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 6F2DC6090C Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=subhashj@codeaurora.org From: Subhash Jadavani To: vinholikatti@gmail.com, jejb@linux.vnet.ibm.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, Subhash Jadavani , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 6/8] scsi: ufs: kick start clock scaling only after device detection Date: Fri, 3 Feb 2017 16:58:01 -0800 Message-Id: <1486169881-22894-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 UFS clock scaling might start kicking in even before the device is running at the fastest interface speed which is undesirable. This change moves the clock scaling kick start only after the device is detected and running at the fastest interface speed. Signed-off-by: Subhash Jadavani --- drivers/scsi/ufs/ufshcd.c | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 4f6ba24..a99a673 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -6330,19 +6330,31 @@ static int ufshcd_probe_hba(struct ufs_hba *hba) if (ufshcd_scsi_add_wlus(hba)) goto out; + /* Initialize devfreq after UFS device is detected */ + if (ufshcd_is_clkscaling_supported(hba)) { + memcpy(&hba->clk_scaling.saved_pwr_info.info, + &hba->pwr_info, + sizeof(struct ufs_pa_layer_attr)); + hba->clk_scaling.saved_pwr_info.is_valid = true; + if (!hba->devfreq) { + hba->devfreq = devm_devfreq_add_device(hba->dev, + &ufs_devfreq_profile, + "simple_ondemand", + NULL); + if (IS_ERR(hba->devfreq)) { + ret = PTR_ERR(hba->devfreq); + dev_err(hba->dev, "Unable to register with devfreq %d\n", + ret); + goto out; + } + } + hba->clk_scaling.is_allowed = true; + } + scsi_scan_host(hba->host); pm_runtime_put_sync(hba->dev); } - /* Resume devfreq after UFS device is detected */ - if (ufshcd_is_clkscaling_supported(hba)) { - memcpy(&hba->clk_scaling.saved_pwr_info.info, &hba->pwr_info, - sizeof(struct ufs_pa_layer_attr)); - hba->clk_scaling.saved_pwr_info.is_valid = true; - ufshcd_resume_clkscaling(hba); - hba->clk_scaling.is_allowed = true; - } - if (!hba->is_init_prefetch) hba->is_init_prefetch = true; @@ -6865,7 +6877,8 @@ static void ufshcd_hba_exit(struct ufs_hba *hba) ufshcd_setup_vreg(hba, false); ufshcd_suspend_clkscaling(hba); if (ufshcd_is_clkscaling_supported(hba)) { - ufshcd_suspend_clkscaling(hba); + if (hba->devfreq) + ufshcd_suspend_clkscaling(hba); destroy_workqueue(hba->clk_scaling.workq); } ufshcd_setup_clocks(hba, false); @@ -7859,16 +7872,6 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) if (ufshcd_is_clkscaling_supported(hba)) { char wq_name[sizeof("ufs_clkscaling_00")]; - hba->devfreq = devm_devfreq_add_device(dev, &ufs_devfreq_profile, - "simple_ondemand", NULL); - if (IS_ERR(hba->devfreq)) { - dev_err(hba->dev, "Unable to register with devfreq %ld\n", - PTR_ERR(hba->devfreq)); - err = PTR_ERR(hba->devfreq); - goto out_remove_scsi_host; - } - hba->clk_scaling.is_suspended = false; - INIT_WORK(&hba->clk_scaling.suspend_work, ufshcd_clk_scaling_suspend_work); INIT_WORK(&hba->clk_scaling.resume_work, @@ -7878,8 +7881,6 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) host->host_no); hba->clk_scaling.workq = create_singlethread_workqueue(wq_name); - /* Suspend devfreq until the UFS device is detected */ - ufshcd_suspend_clkscaling(hba); ufshcd_clkscaling_init_sysfs(hba); }