Received: by 10.213.65.68 with SMTP id h4csp423520imn; Fri, 16 Mar 2018 07:21:08 -0700 (PDT) X-Google-Smtp-Source: AG47ELt5IihpM9qy7EMwoArsS8esL3CCL6CeDIZWNDH8v+Pi6zDnH6pFB7UiDeydqchPnaH0vN8B X-Received: by 2002:a17:902:467:: with SMTP id 94-v6mr2321364ple.57.1521210068759; Fri, 16 Mar 2018 07:21:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521210068; cv=none; d=google.com; s=arc-20160816; b=C4XysVbQIH0W70nqVVM0jiQqgiDh2Z4trgre8LJKmQhv/LLCetcLtdOdGZjrUTr9H9 UWyWtSu0GBp0J9ynmNnomA2LIaN0UY26GEwGFSvwVx70hKgPNQ/UnF15wJPbMDNO0A3v XcKatUc9QRo9qBSs1+OCBwgiRYg91eOEgkSzTmLMGEeB29cN5EW+0kUyDTh5V6nIc9LP yhpgeJyI3iFw9vqDQbwDjgdRKKmx2qTxROTle+n2RqZ0yRU8jlU03zWOwlBRw1TDQsyN R5MvYVQYLl9A3B3RU/qsEItq5dqGY7L8/tPWR0OyK0zJGSCWsqCRO0o2pcZJ4q4N+VrM vm/A== 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=p5GsyNIs1ghs0QcX5trl5as51/OcktlNMfrI3CVGjHE=; b=uYo7XoEoRni3ncwxDthczOGp17BCVIQx/g0fRO2GzZHLcumnIpnbBPTWDfPaHhc/5E XmPAh9cS+d302Yk+6DFs3vbNpdIef0wFd3QSqQ1oOdUxsicX1lBS4qW+Qj8K+/EGDk21 aXWDLtkmpWfGiN6m8kkBaDyQ1I3xLd7Lq7Xf6REOVgFRajaEIxsc/jWFxyVP1pYu0o4U 4zdYYvw+QCVrjsszyxYCJq5JDQ0EnjET7lpJJwIEBrBMOlqDGrfVNzcrF0mf3eofsno3 MtkEtxrOvSasSPgTS+0VF/cVJLD/ZhEIH+Vl760zGIpHQp66CN/EknUMdNUuljEOoYfx 10xw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n127si5094071pga.398.2018.03.16.07.20.53; Fri, 16 Mar 2018 07:21:08 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752984AbeCPOUC (ORCPT + 99 others); Fri, 16 Mar 2018 10:20:02 -0400 Received: from mga06.intel.com ([134.134.136.31]:2361 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752697AbeCPOUB (ORCPT ); Fri, 16 Mar 2018 10:20:01 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Mar 2018 07:20:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,316,1517904000"; d="scan'208";a="28539402" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.168]) ([10.237.72.168]) by fmsmga002.fm.intel.com with ESMTP; 16 Mar 2018 07:19:57 -0700 Subject: Re: [PATCH] scsi: ufs: sysfs: reworking of the rpm_lvl and spm_lvl entries To: Stanislav Nijnikov , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, subhashj@codeaurora.org Cc: alex.lemberg@wdc.com References: <1519901286-17496-1-git-send-email-stanislav.nijnikov@wdc.com> <1519901286-17496-2-git-send-email-stanislav.nijnikov@wdc.com> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: Date: Fri, 16 Mar 2018 16:19:08 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <1519901286-17496-2-git-send-email-stanislav.nijnikov@wdc.com> 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 01/03/18 12:48, Stanislav Nijnikov wrote: > Read from these files will return the integed value of the chosen power > management level now. Separate entries were added to show the target > UFS device and UIC link states. The description of the possible power > managements levels was added to the ABI file. The on-write behaviour of > these entries wasn't changed. > > Signed-off-by: Stanislav Nijnikov Acked-by: Adrian Hunter > --- > Documentation/ABI/testing/sysfs-driver-ufs | 67 ++++++++++++++++++++++ > drivers/scsi/ufs/ufs-sysfs.c | 92 +++++++++++++++--------------- > 2 files changed, 114 insertions(+), 45 deletions(-) > > diff --git a/Documentation/ABI/testing/sysfs-driver-ufs b/Documentation/ABI/testing/sysfs-driver-ufs > index 07f1c2f..83735f7 100644 > --- a/Documentation/ABI/testing/sysfs-driver-ufs > +++ b/Documentation/ABI/testing/sysfs-driver-ufs > @@ -802,3 +802,70 @@ Description: This file shows the The amount of physical memory needed > the particular logical unit. The full information about > the attribute could be found at UFS specifications 2.1. > The file is read only. > + > + > +What: /sys/bus/platform/drivers/ufshcd/*/rpm_lvl > +Date: September 2014 > +Contact: Subhash Jadavani > +Description: This entry could be used to set or show the UFS device > + runtime power management level. The current driver > + implementation supports 6 levels with next target states: > + 0 - an UFS device will stay active, an UIC link will > + stay active > + 1 - an UFS device will stay active, an UIC link will > + hibernate > + 2 - an UFS device will moved to sleep, an UIC link will > + stay active > + 3 - an UFS device will moved to sleep, an UIC link will > + hibernate > + 4 - an UFS device will be powered off, an UIC link will > + hibernate > + 5 - an UFS device will be powered off, an UIC link will > + be powered off > + > +What: /sys/bus/platform/drivers/ufshcd/*/rpm_target_dev_state > +Date: February 2018 > +Contact: Subhash Jadavani > +Description: This entry shows the target power mode of an UFS device > + for the chosen runtime power management level. > + The file is read only. > + > +What: /sys/bus/platform/drivers/ufshcd/*/rpm_target_link_state > +Date: February 2018 > +Contact: Subhash Jadavani > +Description: This entry shows the target state of an UFS UIC link > + for the chosen runtime power management level. > + The file is read only. > + > +What: /sys/bus/platform/drivers/ufshcd/*/spm_lvl > +Date: September 2014 > +Contact: Subhash Jadavani > +Description: This entry could be used to set or show the UFS device > + system power management level. The current driver > + implementation supports 6 levels with next target states: > + 0 - an UFS device will stay active, an UIC link will > + stay active > + 1 - an UFS device will stay active, an UIC link will > + hibernate > + 2 - an UFS device will moved to sleep, an UIC link will > + stay active > + 3 - an UFS device will moved to sleep, an UIC link will > + hibernate > + 4 - an UFS device will be powered off, an UIC link will > + hibernate > + 5 - an UFS device will be powered off, an UIC link will > + be powered off > + > +What: /sys/bus/platform/drivers/ufshcd/*/spm_target_dev_state > +Date: February 2018 > +Contact: Subhash Jadavani > +Description: This entry shows the target power mode of an UFS device > + for the chosen system power management level. > + The file is read only. > + > +What: /sys/bus/platform/drivers/ufshcd/*/spm_target_link_state > +Date: February 2018 > +Contact: Subhash Jadavani > +Description: This entry shows the target state of an UFS UIC link > + for the chosen system power management level. > + The file is read only. > diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c > index cd7174d..4ff9e0b 100644 > --- a/drivers/scsi/ufs/ufs-sysfs.c > +++ b/drivers/scsi/ufs/ufs-sysfs.c > @@ -57,29 +57,8 @@ static ssize_t rpm_lvl_show(struct device *dev, > struct device_attribute *attr, char *buf) > { > struct ufs_hba *hba = dev_get_drvdata(dev); > - int curr_len; > - u8 lvl; > - > - curr_len = snprintf(buf, PAGE_SIZE, > - "\nCurrent Runtime PM level [%d] => dev_state [%s] link_state [%s]\n", > - hba->rpm_lvl, > - ufschd_ufs_dev_pwr_mode_to_string( > - ufs_pm_lvl_states[hba->rpm_lvl].dev_state), > - ufschd_uic_link_state_to_string( > - ufs_pm_lvl_states[hba->rpm_lvl].link_state)); > - > - curr_len += snprintf((buf + curr_len), (PAGE_SIZE - curr_len), > - "\nAll available Runtime PM levels info:\n"); > - for (lvl = UFS_PM_LVL_0; lvl < UFS_PM_LVL_MAX; lvl++) > - curr_len += snprintf((buf + curr_len), (PAGE_SIZE - curr_len), > - "\tRuntime PM level [%d] => dev_state [%s] link_state [%s]\n", > - lvl, > - ufschd_ufs_dev_pwr_mode_to_string( > - ufs_pm_lvl_states[lvl].dev_state), > - ufschd_uic_link_state_to_string( > - ufs_pm_lvl_states[lvl].link_state)); > - > - return curr_len; > + > + return sprintf(buf, "%d\n", hba->rpm_lvl); > } > > static ssize_t rpm_lvl_store(struct device *dev, > @@ -88,33 +67,30 @@ static ssize_t rpm_lvl_store(struct device *dev, > return ufs_sysfs_pm_lvl_store(dev, attr, buf, count, true); > } > > +static ssize_t rpm_target_dev_state_show(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + struct ufs_hba *hba = dev_get_drvdata(dev); > + > + return sprintf(buf, "%s\n", ufschd_ufs_dev_pwr_mode_to_string( > + ufs_pm_lvl_states[hba->rpm_lvl].dev_state)); > +} > + > +static ssize_t rpm_target_link_state_show(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + struct ufs_hba *hba = dev_get_drvdata(dev); > + > + return sprintf(buf, "%s\n", ufschd_uic_link_state_to_string( > + ufs_pm_lvl_states[hba->rpm_lvl].link_state)); > +} > + > static ssize_t spm_lvl_show(struct device *dev, > struct device_attribute *attr, char *buf) > { > struct ufs_hba *hba = dev_get_drvdata(dev); > - int curr_len; > - u8 lvl; > - > - curr_len = snprintf(buf, PAGE_SIZE, > - "\nCurrent System PM level [%d] => dev_state [%s] link_state [%s]\n", > - hba->spm_lvl, > - ufschd_ufs_dev_pwr_mode_to_string( > - ufs_pm_lvl_states[hba->spm_lvl].dev_state), > - ufschd_uic_link_state_to_string( > - ufs_pm_lvl_states[hba->spm_lvl].link_state)); > > - curr_len += snprintf((buf + curr_len), (PAGE_SIZE - curr_len), > - "\nAll available System PM levels info:\n"); > - for (lvl = UFS_PM_LVL_0; lvl < UFS_PM_LVL_MAX; lvl++) > - curr_len += snprintf((buf + curr_len), (PAGE_SIZE - curr_len), > - "\tSystem PM level [%d] => dev_state [%s] link_state [%s]\n", > - lvl, > - ufschd_ufs_dev_pwr_mode_to_string( > - ufs_pm_lvl_states[lvl].dev_state), > - ufschd_uic_link_state_to_string( > - ufs_pm_lvl_states[lvl].link_state)); > - > - return curr_len; > + return sprintf(buf, "%d\n", hba->spm_lvl); > } > > static ssize_t spm_lvl_store(struct device *dev, > @@ -123,12 +99,38 @@ static ssize_t spm_lvl_store(struct device *dev, > return ufs_sysfs_pm_lvl_store(dev, attr, buf, count, false); > } > > +static ssize_t spm_target_dev_state_show(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + struct ufs_hba *hba = dev_get_drvdata(dev); > + > + return sprintf(buf, "%s\n", ufschd_ufs_dev_pwr_mode_to_string( > + ufs_pm_lvl_states[hba->spm_lvl].dev_state)); > +} > + > +static ssize_t spm_target_link_state_show(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + struct ufs_hba *hba = dev_get_drvdata(dev); > + > + return sprintf(buf, "%s\n", ufschd_uic_link_state_to_string( > + ufs_pm_lvl_states[hba->spm_lvl].link_state)); > +} > + > static DEVICE_ATTR_RW(rpm_lvl); > +static DEVICE_ATTR_RO(rpm_target_dev_state); > +static DEVICE_ATTR_RO(rpm_target_link_state); > static DEVICE_ATTR_RW(spm_lvl); > +static DEVICE_ATTR_RO(spm_target_dev_state); > +static DEVICE_ATTR_RO(spm_target_link_state); > > static struct attribute *ufs_sysfs_ufshcd_attrs[] = { > &dev_attr_rpm_lvl.attr, > + &dev_attr_rpm_target_dev_state.attr, > + &dev_attr_rpm_target_link_state.attr, > &dev_attr_spm_lvl.attr, > + &dev_attr_spm_target_dev_state.attr, > + &dev_attr_spm_target_link_state.attr, > NULL > }; > >