From patchwork Fri Dec 23 02:41:11 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: 9487139 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 91FE9601C0 for ; Fri, 23 Dec 2016 02:41:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 851A627D85 for ; Fri, 23 Dec 2016 02:41:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 79CAC27F93; Fri, 23 Dec 2016 02:41:36 +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 3F71027EE9 for ; Fri, 23 Dec 2016 02:41:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965511AbcLWClU (ORCPT ); Thu, 22 Dec 2016 21:41:20 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:46610 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758186AbcLWClR (ORCPT ); Thu, 22 Dec 2016 21:41:17 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id C4592616A6; Fri, 23 Dec 2016 02:41:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1482460876; bh=lLnx6wzfmN9dO6EMrPxaOLbovo6sW6MdUnk4qVg1Pas=; h=From:To:Cc:Subject:Date:From; b=NQtbfCBDwIHOLFl2QKoQLtHnptEXhdUd14Q8CEUc0UtoP5Hldf31E0cB/jlR0uGoR IoMEMzrvwvYKT7WmMQ+ctg7OfCF4wPrmfg0SrenrGMcmQwZuDyHbiQnYRCZKeF3W/K 9N61/z2vBTO+dC8eiFYE6pDWCywbLTEics0Q85JM= 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 D45B16166C; Fri, 23 Dec 2016 02:41:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1482460876; bh=lLnx6wzfmN9dO6EMrPxaOLbovo6sW6MdUnk4qVg1Pas=; h=From:To:Cc:Subject:Date:From; b=NQtbfCBDwIHOLFl2QKoQLtHnptEXhdUd14Q8CEUc0UtoP5Hldf31E0cB/jlR0uGoR IoMEMzrvwvYKT7WmMQ+ctg7OfCF4wPrmfg0SrenrGMcmQwZuDyHbiQnYRCZKeF3W/K 9N61/z2vBTO+dC8eiFYE6pDWCywbLTEics0Q85JM= DMARC-Filter: OpenDMARC Filter v1.3.1 smtp.codeaurora.org D45B16166C 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: linux-scsi@vger.kernel.org, Subhash Jadavani , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 07/12] scsi: ufs: set default UFS power management level Date: Thu, 22 Dec 2016 18:41:11 -0800 Message-Id: <1482460871-6210-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 device and link can be put in multiple different low power modes hence UFS driver supports multiple different low power modes. This change sets the default UFS power management level which should put the link hibernate state and device in sleep state. This default power management level gives good power savings with relatively less enter/exit latencies. Reviewed-by: Yaniv Gardi Signed-off-by: Subhash Jadavani --- Changes from v2 -> v3: - Simplified patch to just set the default power management level. Device tree capability to specify broken hardware will be taken up as separate patch in different patch series than current one. --- drivers/scsi/ufs/ufshcd.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 30ee04a..12a2250 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -191,6 +191,22 @@ enum { return ufs_pm_lvl_states[lvl].link_state; } +static inline enum ufs_pm_level +ufs_get_desired_pm_lvl_for_dev_link_state(enum ufs_dev_pwr_mode dev_state, + enum uic_link_state link_state) +{ + enum ufs_pm_level lvl; + + for (lvl = UFS_PM_LVL_0; lvl < UFS_PM_LVL_MAX; lvl++) { + if ((ufs_pm_lvl_states[lvl].dev_state == dev_state) && + (ufs_pm_lvl_states[lvl].link_state == link_state)) + return lvl; + } + + /* if no match found, return the level 0 */ + return UFS_PM_LVL_0; +} + static struct ufs_dev_fix ufs_fixups[] = { /* UFS cards deviations table */ UFS_FIX(UFS_VENDOR_SAMSUNG, UFS_ANY_MODEL, @@ -7264,6 +7280,18 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) ufshcd_clkscaling_init_sysfs(hba); } + /* + * Set the default power management level for runtime and system PM. + * Default power saving mode is to keep UFS link in Hibern8 state + * and UFS device in sleep state. + */ + hba->rpm_lvl = ufs_get_desired_pm_lvl_for_dev_link_state( + UFS_SLEEP_PWR_MODE, + UIC_LINK_HIBERN8_STATE); + hba->spm_lvl = ufs_get_desired_pm_lvl_for_dev_link_state( + UFS_SLEEP_PWR_MODE, + UIC_LINK_HIBERN8_STATE); + /* Hold auto suspend until async scan completes */ pm_runtime_get_sync(dev);