Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp359399imm; Wed, 11 Jul 2018 03:53:18 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf0HMCsDPbaexM7qyPbEroUPh0zl1DCmtE3B7Qa6Urd6dU8+e8LlJngPX+WOm0QXSIfdYhL X-Received: by 2002:a63:4703:: with SMTP id u3-v6mr19354394pga.405.1531306398302; Wed, 11 Jul 2018 03:53:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531306398; cv=none; d=google.com; s=arc-20160816; b=bV46MmUkTKfEN+PksjGnkRkKdAInmvxemlijo+JxM67s/SWyufX5FXXAy/fXfHfBni Rq4z/2sNc1SNU2a0PgQNR6xs0krHUGl/rRV3BfsEAWuYTed4eM6E2XjX4WCRgllNzwDf VjwGO8s9JbMYfQr9f5FuJt0VyrajgElQPyB4HX5vzByRRp4ekcBXAJ2R57lCJ2gyzB1S C4v+yWbICeL71YhznFCTk6Y9dQ3t4CneiewMG/VEoaZ3s1wchT6JuRnFDph56INqrEii RZ3HOLkkR20PHSbkwGr29rb6IL0Vv6UGRTulfz7jhWFatRump2BOE6tgTln2CnJS5O4h /4Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :arc-authentication-results; bh=rvgBk1tMOdl8pf2I7GR6u/7SlEZtU6yYWL4j2ELaVN0=; b=M7a0NvkLvLtmouDDRagFeoR3+Ax7UhBjvp9+J5/hMIEcQMNFtqeneKnsIStG1E1/oq sQSfjHz8v1LGgkQJeL0hatP/WoZkDl78qrxBFG87X6PxKSLYcgjhrgUIreUvQMl/5kgv SuRJ0rFmkZCuxWzyItdy8t2KrqBE/L2O7X/TWSTLfsdlm+vzLdVMpt+ET7tEMJQUbwIN ZauHo6VskZWa47GmSIZuE/+DPv7+Pt+wXqEMuueJCQT54C2xJvJvQoZ0Lmgg24+56wbX rn5aT8KFPQSOV2/JIb8YDT5uYZ4o02+zaFIpTaew4XvwrcCHqdBqUCqnyo7UyDkb5ZXl FPmg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h3-v6si18710196plb.100.2018.07.11.03.53.03; Wed, 11 Jul 2018 03:53:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732436AbeGKK4M (ORCPT + 99 others); Wed, 11 Jul 2018 06:56:12 -0400 Received: from mga04.intel.com ([192.55.52.120]:60454 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726487AbeGKK4M (ORCPT ); Wed, 11 Jul 2018 06:56:12 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jul 2018 03:52:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,338,1526367600"; d="scan'208";a="215118828" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.168]) ([10.237.72.168]) by orsmga004.jf.intel.com with ESMTP; 11 Jul 2018 03:52:23 -0700 Subject: Re: [PATCH v1 4/9] scsi: ufs: add option to change default UFS power management level To: Asutosh Das , subhashj@codeaurora.org, cang@codeaurora.org, vivek.gautam@codeaurora.org, rnayak@codeaurora.org, vinholikatti@gmail.com, jejb@linux.vnet.ibm.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org Cc: linux-arm-msm@vger.kernel.org, Venkat Gopalakrishnan , Rob Herring , Mark Rutland , Mathieu Malaterre , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , open list References: From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: <0673f807-bc3c-e401-ae12-07bfafb55bf7@intel.com> Date: Wed, 11 Jul 2018 13:50:51 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/07/18 15:30, Asutosh Das wrote: > From: Subhash Jadavani > > UFS device and link can be put in multiple different low power modes hence > UFS driver supports multiple different low power modes. By default UFS > driver selects the default (optimal) low power mode (which gives moderate > power savings and have relatively less enter and exit latencies) but > we might have to tune this default power mode for different chipset > platforms to meet the low power requirements/goals. Hence this patch > adds option to change default UFS low power mode (level). > > Signed-off-by: Subhash Jadavani > Signed-off-by: Venkat Gopalakrishnan > Signed-off-by: Can Guo > Signed-off-by: Asutosh Das > --- > .../devicetree/bindings/ufs/ufshcd-pltfrm.txt | 11 ++++++++ > drivers/scsi/ufs/ufshcd-pltfrm.c | 14 +++++++++++ > drivers/scsi/ufs/ufshcd.c | 29 +++++++++++++++------- > drivers/scsi/ufs/ufshcd.h | 4 +-- > 4 files changed, 47 insertions(+), 11 deletions(-) > > diff --git a/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt b/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt > index c39dfef..f564d9a 100644 > --- a/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt > +++ b/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt > @@ -38,6 +38,15 @@ Optional properties: > defined or a value in the array is "0" then it is assumed > that the frequency is set by the parent clock or a > fixed rate clock source. > +- rpm-level : UFS Runtime power management level. Following PM levels are supported: > + 0 - Both UFS device and Link in active state (Highest power consumption) > + 1 - UFS device in active state but Link in Hibern8 state > + 2 - UFS device in Sleep state but Link in active state > + 3 - UFS device in Sleep state and Link in hibern8 state (default PM level) > + 4 - UFS device in Power-down state and Link in Hibern8 state > + 5 - UFS device in Power-down state and Link in OFF state (Lowest power consumption) > +- spm-level : UFS System power management level. Allowed PM levels are same as rpm-level. > + > -lanes-per-direction : number of lanes available per direction - either 1 or 2. > Note that it is assume same number of lanes is used both > directions at once. If not specified, default is 2 lanes per direction. > @@ -66,4 +75,6 @@ Example: > freq-table-hz = <100000000 200000000>, <0 0>, <0 0>; > phys = <&ufsphy1>; > phy-names = "ufsphy"; > + rpm-level = <3>; > + spm-level = <5>; > }; > diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c > index e82bde0..7dba799 100644 > --- a/drivers/scsi/ufs/ufshcd-pltfrm.c > +++ b/drivers/scsi/ufs/ufshcd-pltfrm.c > @@ -221,6 +221,19 @@ static int ufshcd_parse_regulator_info(struct ufs_hba *hba) > return err; > } > > +static void ufshcd_parse_pm_levels(struct ufs_hba *hba) > +{ > + struct device *dev = hba->dev; > + struct device_node *np = dev->of_node; > + > + if (np) { > + if (of_property_read_u32(np, "rpm-level", &hba->rpm_lvl)) > + hba->rpm_lvl = -1; > + if (of_property_read_u32(np, "spm-level", &hba->spm_lvl)) > + hba->spm_lvl = -1; These are generically useful to all UFSHC drivers, so they should be device_property_read_u32() and they should be read for all drivers not just pltfrm i.e. move this code into ufshcd.c > + } > +} > + > #ifdef CONFIG_PM > /** > * ufshcd_pltfrm_suspend - suspend power management function > @@ -340,6 +353,7 @@ int ufshcd_pltfrm_init(struct platform_device *pdev, > goto dealloc_host; > } > > + ufshcd_parse_pm_levels(hba); > pm_runtime_set_active(&pdev->dev); > pm_runtime_enable(&pdev->dev); > > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index b03f3ea..e950204 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -192,6 +192,14 @@ struct ufs_pm_lvl_states ufs_pm_lvl_states[] = { > return UFS_PM_LVL_0; > } > > +static inline bool ufshcd_is_valid_pm_lvl(int lvl) > +{ > + if (lvl >= 0 && lvl < ARRAY_SIZE(ufs_pm_lvl_states)) > + return true; > + else > + return false; > +} > + > static struct ufs_dev_fix ufs_fixups[] = { > /* UFS cards deviations table */ > UFS_FIX(UFS_VENDOR_SAMSUNG, UFS_ANY_MODEL, > @@ -8051,16 +8059,19 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) > } > > /* > - * 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. > + * If rpm_lvl and and spm_lvl are not already set to valid levels, > + * set the default power management level for UFS runtime and system > + * suspend. Default power saving mode selected is keeping 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); > + if (!ufshcd_is_valid_pm_lvl(hba->rpm_lvl)) > + hba->rpm_lvl = ufs_get_desired_pm_lvl_for_dev_link_state( > + UFS_SLEEP_PWR_MODE, > + UIC_LINK_HIBERN8_STATE); > + if (!ufshcd_is_valid_pm_lvl(hba->spm_lvl)) > + hba->spm_lvl = ufs_get_desired_pm_lvl_for_dev_link_state( > + UFS_SLEEP_PWR_MODE, > + UIC_LINK_HIBERN8_STATE); > > /* Set the default auto-hiberate idle timer value to 150 ms */ > if (hba->capabilities & MASK_AUTO_HIBERN8_SUPPORT) { > diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h > index e996a08..a2e1d5c 100644 > --- a/drivers/scsi/ufs/ufshcd.h > +++ b/drivers/scsi/ufs/ufshcd.h > @@ -526,9 +526,9 @@ struct ufs_hba { > enum ufs_dev_pwr_mode curr_dev_pwr_mode; > enum uic_link_state uic_link_state; > /* Desired UFS power management level during runtime PM */ > - enum ufs_pm_level rpm_lvl; > + int rpm_lvl; > /* Desired UFS power management level during system PM */ > - enum ufs_pm_level spm_lvl; > + int spm_lvl; > struct device_attribute rpm_lvl_attr; > struct device_attribute spm_lvl_attr; > int pm_op_in_progress; >