Received: by 10.223.185.116 with SMTP id b49csp7271978wrg; Thu, 1 Mar 2018 02:49:37 -0800 (PST) X-Google-Smtp-Source: AG47ELspoZABcuT49zXx7uh2ENuObuio8d6ZEgkDd4HrglMEINvJM/I6l4Opa/hVxxvENhaim+fG X-Received: by 10.98.202.23 with SMTP id n23mr1513107pfg.52.1519901377146; Thu, 01 Mar 2018 02:49:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519901377; cv=none; d=google.com; s=arc-20160816; b=c7J+M122eKPU8hp2bhhniMUjJ+/5eSmWL+N/ZQ8IuqhQugoAvP7dYjTPzQ9wUivd98 O5MPNkf1YE5i8+r7gPjENFFho5Am1YtLN08XnLUCac5nVwF0v4feyGi8hzKofMMidDfk LXXbZgpmArDj68w7avQXtuB3r6LDNoXZhZbS9wVXEoGUrlC638km1U/gJk7T233Du81N 4lqVROdVS7YRC3kQ6AejKgiW0kYwCH2Wuk2rPl4cUySZ3PzsOG0nzhUCll4AD7zOJS4w LlN30Rl5QloRsfwYlcUDuyLhbd1DT2B/KpmaTylBSPAP0ALNLJC4C6/JZUpF+TnUwqaB e+Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=5f77uBIXHZVWNA7UmXGzJo4Y7snLO4NZTdwexPrHYn8=; b=X+ere5sB7qGFu7FFp4/F3BLvntNa6b71pYnRNcXR5k3KXR8jWQstnuKzpOG54sBWRr S6EmhepnU1fHpmOBEDaQ4ghBRufZADSOZuvAMsLPuRUVVMSAZShB5Li9FFRBMIGj9WlX f59v3C31Se4xQLcI+0o8eKwDORaGWeYV4lpA3ACsRZHP+kwaWf1FvDFqvv7BhIdhsCJD TJCk/1OvtgchMYkExYPD48KzLAUwwBlSsuzeXLTHyToId9irJb8ay7tU4wwlvusNjoLc tFw7GWBitPgPv9JTTAngX9FFEwDVlQLnalLWbBZBn+M2v3orpSOOeYCxBWqM08pg1uFj fzsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=lptXN93F; 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 n3si2326834pgc.12.2018.03.01.02.49.22; Thu, 01 Mar 2018 02:49:37 -0800 (PST) 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; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=lptXN93F; 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 S967571AbeCAKsV (ORCPT + 99 others); Thu, 1 Mar 2018 05:48:21 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:23736 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967461AbeCAKsR (ORCPT ); Thu, 1 Mar 2018 05:48:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1519901961; x=1551437961; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=gLiHo6HhcQTioBPPicVityizchGlvMBRZX/B6stnEDk=; b=lptXN93Fk8MsGyefLoWJxfhZpl6rgU3bIaAr0IEBUyBFMKKZ0rAtXvu4 akKCHxCLND/6DBktqeAV7H2TFhhBi7GK/8g/eFFcsYellaOFjSR2oIqIl fRLFfr9XvvJPIrfxtQ1YZMBZ8Z/YQ2/KiIDZPuf083gNwZz1vyK0xiBaS FpXdgP8GvBB8s8sGfYuiA8FZCy/etTnBdrxD71ullNhG9xnZyCJFeEF3M grhP020JeF9qzWukFo0MR8Dzi6hAuOgNKMFFKrUb1TkKRkl4CAyj1euON 95IV2hKC0/HZaE56QU5Ya8abpt0vvYjt6Voi7/hWItzF6RLQpTOGjT+Ti g==; X-IronPort-AV: E=Sophos;i="5.47,408,1515427200"; d="scan'208";a="169144585" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 01 Mar 2018 18:59:15 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 01 Mar 2018 02:42:18 -0800 Received: from ilb000042.sdcorp.global.sandisk.com ([10.0.231.79]) by uls-op-cesaip02.wdc.com with ESMTP; 01 Mar 2018 02:48:12 -0800 From: Stanislav Nijnikov To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, subhashj@codeaurora.org Cc: alex.lemberg@wdc.com, Stanislav Nijnikov Subject: [PATCH] scsi: ufs: sysfs: reworking of the rpm_lvl and spm_lvl entries Date: Thu, 1 Mar 2018 12:48:06 +0200 Message-Id: <1519901286-17496-2-git-send-email-stanislav.nijnikov@wdc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519901286-17496-1-git-send-email-stanislav.nijnikov@wdc.com> References: <1519901286-17496-1-git-send-email-stanislav.nijnikov@wdc.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 }; -- 2.7.4