Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4670769rdb; Fri, 15 Sep 2023 08:54:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEbZVIRM/eZKbmGehZxvEdfRJzm36+xoRk8FCsE8wpd18VaQnLCgf59Nkf6i6kjY5ObprRd X-Received: by 2002:a05:6870:8991:b0:1c0:3110:12cc with SMTP id f17-20020a056870899100b001c0311012ccmr2447672oaq.55.1694793279372; Fri, 15 Sep 2023 08:54:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694793279; cv=none; d=google.com; s=arc-20160816; b=atFZPfNi78URLX7yh16x2bVJyakZzkjoGARPKjtXLBypFbFZjLC9jvp7SMEVxKHzX5 R0aN7LCNlrbbj7HjaDUKBuqHsJeAG/rXFp2wyJj2lcqw9X59wpV5pqznZFZ9HMvLjpsX Ulj01+9cDvlTVBRsZJR5udyEl1Iuqz/jEby6jUbMA8LZ1Dq4+ltZpehY4/m2TSRvWamb rdx6Ot/mD3rLY2mGdHGGREF8Dwh2PelAJPd/r8r8rjbOUJO7VvHQst3zaTJ3aBDNb4uD yqe3Sz7NCs/g1OosA2o4/KysmBwHTtNo0YPUon/LYV7nDWnsx1UYAiQFazVaFdRUGl8D QGXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=T3lyDRmRoqcRVHeOnIHhroCoOim+vQ5Xf0/eg7JE03Y=; fh=2I1hTtckEwT/HutmOsO0celQq5vYsN5BuhuIKoxvJ90=; b=EutEMxFZ7eD2eGlzx6h8exresY6wJSgVJzLykFOse5rLRUfjgJPC/v4wPhOEs7dpGR /c6oFumT85l/92M2p73/AqFYaCuc3DHAkAC+9Hoa8tv7ZQwTCywQHJzFmf2IO8oJ3Nss JqG0R3nTjF4uwyyFdZpQAdEYNTO3Ysg8lCqjK7QwaOTcBelJrsx+DMtqrym2Gfa4A88Y ihR0OEJCp3+iX5vLiRdHaj9H7cgHuFCDnCrPGBJcDghF89Pi8CNyHCLBbiCB1MK3HbVo 6DeUEe04RmweccALNgImu4bozzDPd+8r6/PMHCFyjULV4X8Jp/flZ807tXLC8sqNpAAF GPUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=T4dgyeOK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id k127-20020a632485000000b00563da8d8416si3453344pgk.355.2023.09.15.08.54.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 08:54:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=T4dgyeOK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 6C7E08099CF0; Thu, 14 Sep 2023 19:00:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231584AbjIOCAF (ORCPT + 99 others); Thu, 14 Sep 2023 22:00:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231234AbjIOCAE (ORCPT ); Thu, 14 Sep 2023 22:00:04 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B44D26A4; Thu, 14 Sep 2023 19:00:00 -0700 (PDT) Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38F1vfEu031599; Fri, 15 Sep 2023 01:59:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=qcppdkim1; bh=T3lyDRmRoqcRVHeOnIHhroCoOim+vQ5Xf0/eg7JE03Y=; b=T4dgyeOKfM8jVs1L82SoMV5UUjmOeB3KDdgp3zLdMbMKelv3A0iiRWq6JrLEDpcugLpz 10XOD//lsaTQ4/W9MG1+2FyVHi8rJG5JgS1qT4svhBhZU1TVCN/c1dDD7C192FJAlxMW i7D+mRBqz/EpORvmOH4FiqrHU6BVtK/vrsOk6pJxJKC2E5y6TyxoBzPUVDi7DSzuhNyy YjlxfUqkVeqkhegiBK3Z5TLwITLx+8/KSD9IU/S0stfbmtzlc5KVwXIvYG1XoTCtc1R8 DV5qi+z6c1NqaxjC6xF48LepzwWbKsUaI5b7aiqY+ine/YdJokByNqVYuM61fDM0G//o yA== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3t4e2b003p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Sep 2023 01:59:37 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 38F1xZO6028723 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Sep 2023 01:59:35 GMT Received: from [10.253.10.13] (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.36; Thu, 14 Sep 2023 18:59:32 -0700 Message-ID: Date: Fri, 15 Sep 2023 09:59:29 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: Re: [PATCH 5/6] scsi: ufs: ufs-sysfs: Expose UFS power info Content-Language: en-US To: Nitin Rawat , , , CC: , Alim Akhtar , "Avri Altman" , Bart Van Assche , "James E.J. Bottomley" , Bean Huo , "Arthur Simchaev" , Lu Hongfei , "open list" References: <1694411968-14413-1-git-send-email-quic_cang@quicinc.com> <1694411968-14413-6-git-send-email-quic_cang@quicinc.com> <8a9cc52c-9c7d-1f8f-8a98-1a816f59aa79@quicinc.com> From: Can Guo In-Reply-To: <8a9cc52c-9c7d-1f8f-8a98-1a816f59aa79@quicinc.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: VReBpi5Mv-beeZlnPYE8i87XfSAY5lKC X-Proofpoint-ORIG-GUID: VReBpi5Mv-beeZlnPYE8i87XfSAY5lKC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-15_02,2023-09-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 spamscore=0 priorityscore=1501 malwarescore=0 suspectscore=0 adultscore=0 mlxscore=0 lowpriorityscore=0 impostorscore=0 clxscore=1015 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309150015 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 14 Sep 2023 19:00:16 -0700 (PDT) X-Spam-Status: No, score=-2.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Hi Nitin, On 9/14/2023 7:33 PM, Nitin Rawat wrote: > > > On 9/11/2023 11:29 AM, Can Guo wrote: >> Having UFS power info available in sysfs makes it easier to tell the >> state >> of the link during runtime considering we have a bounch of power saving >> features and various combinations for backward compatiblity. > > Please fix spelling mistake - *bounch -> bunch done > > >> >> Signed-off-by: Can Guo >> --- >>   drivers/ufs/core/ufs-sysfs.c | 71 >> ++++++++++++++++++++++++++++++++++++++++++++ >>   1 file changed, 71 insertions(+) >> >> diff --git a/drivers/ufs/core/ufs-sysfs.c b/drivers/ufs/core/ufs-sysfs.c >> index c959064..53af490 100644 >> --- a/drivers/ufs/core/ufs-sysfs.c >> +++ b/drivers/ufs/core/ufs-sysfs.c >> @@ -628,6 +628,76 @@ static const struct attribute_group >> ufs_sysfs_monitor_group = { >>       .attrs = ufs_sysfs_monitor_attrs, >>   }; >>   +static ssize_t gear_show(struct device *dev, struct >> device_attribute *attr, >> +             char *buf) >> +{ >> +    struct ufs_hba *hba = dev_get_drvdata(dev); >> + >> +    return sysfs_emit(buf, "%u\n", hba->pwr_info.gear_rx); >> +} >> + >> +static ssize_t lane_show(struct device *dev, struct device_attribute >> *attr, >> +             char *buf) >> +{ >> +    struct ufs_hba *hba = dev_get_drvdata(dev); >> + >> +    return sysfs_emit(buf, "%u\n", hba->pwr_info.lane_rx); >> +} >> + >> +static ssize_t mode_show(struct device *dev, struct device_attribute >> *attr, >> +             char *buf) >> +{ >> +    struct ufs_hba *hba = dev_get_drvdata(dev); >> + >> +    return sysfs_emit(buf, "%u\n", hba->pwr_info.pwr_rx); >> +} >> + >> +static ssize_t rate_show(struct device *dev, struct device_attribute >> *attr, >> +             char *buf) >> +{ >> +    struct ufs_hba *hba = dev_get_drvdata(dev); >> + >> +    return sysfs_emit(buf, "%u\n", hba->pwr_info.hs_rate); >> +} >> + >> +static ssize_t dev_pm_show(struct device *dev, struct >> device_attribute *attr, >> +               char *buf) >> +{ >> +    struct ufs_hba *hba = dev_get_drvdata(dev); >> + >> +    return sysfs_emit(buf, "%d\n", hba->curr_dev_pwr_mode); >> +} >> + >> +static ssize_t link_state_show(struct device *dev, >> +                   struct device_attribute *attr, char *buf) >> +{ >> +    struct ufs_hba *hba = dev_get_drvdata(dev); >> + >> +    return sysfs_emit(buf, "%d\n", hba->uic_link_state); >> +} >> + >> +static DEVICE_ATTR_RO(gear); >> +static DEVICE_ATTR_RO(lane); >> +static DEVICE_ATTR_RO(mode); >> +static DEVICE_ATTR_RO(rate); >> +static DEVICE_ATTR_RO(dev_pm); >> +static DEVICE_ATTR_RO(link_state); >> + >> +static struct attribute *ufs_power_info_attrs[] = { >> +    &dev_attr_gear.attr, >> +    &dev_attr_lane.attr, >> +    &dev_attr_mode.attr, >> +    &dev_attr_rate.attr, >> +    &dev_attr_dev_pm.attr, >> +    &dev_attr_link_state.attr, >> +    NULL >> +}; >> + >> +static const struct attribute_group ufs_sysfs_power_info_group = { >> +    .name = "power_info", >> +    .attrs = ufs_power_info_attrs, >> +}; >> + >>   static ssize_t ufs_sysfs_read_desc_param(struct ufs_hba *hba, >>                     enum desc_idn desc_id, >>                     u8 desc_index, >> @@ -1233,6 +1303,7 @@ static const struct attribute_group >> *ufs_sysfs_groups[] = { >>       &ufs_sysfs_default_group, >>       &ufs_sysfs_capabilities_group, >>       &ufs_sysfs_monitor_group, >> +    &ufs_sysfs_power_info_group, >>       &ufs_sysfs_device_descriptor_group, >>       &ufs_sysfs_interconnect_descriptor_group, >>       &ufs_sysfs_geometry_descriptor_group, > > > How about having one power mode attribute displaying all useful info > (lane, gear, mode, rate). sysfs entry is meant for printing a single value instead of a line of strings. > > Regards, > Nitin Rawat Thanks, Can Guo.