Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4279366rdb; Thu, 14 Sep 2023 18:36:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEJPLM6lkxp5afzo8WclEG92Mz0+4mcWweBgnfItz1DRj6a6OttxwxzxzJrElC92RL7W26r X-Received: by 2002:a05:6a00:1992:b0:68e:3bc8:17d1 with SMTP id d18-20020a056a00199200b0068e3bc817d1mr309037pfl.29.1694741793716; Thu, 14 Sep 2023 18:36:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694741793; cv=none; d=google.com; s=arc-20160816; b=02HbC6dvhSbp+Ozsbvhvl1CfQb6mWWIL5v+IskNHQvDPDLmb8OvwQ9AQ5SSVC4eIaG GIQ02hz8S9K0e9tBxC+soQxrYpvANH7Q4RA9Wewv1jYsOPDIuIaPx0KP0wMkbqluRLGI gy8kd8ZASfypjFnJgtc7RjoEQKyUYmMIQ5QrN0tnrleG4lllECboC5wW3weiTKUJiUzY mcQSSe9B3mZQlVhBcyY4AQM3sE2cF2U1ujiGmwLkDCfwJOebeirx2sCz+NFrBvPmlW2J 5VuTjM9UtM8NWh2nT3MApL6gUV4Dh+9xJrkFl1/tF9IqXyah+snmBB815nNeTAPgiMys hwsQ== 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 :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=v/rgcR0kkyQPdpyr7j0ww+hfbXTrJx0WvQpvJwPUWPI=; fh=VX/QzNYLMDo6aWrRcKRJ3brg+DhkDVE395yMaX9LTAU=; b=Gpn40ocBDlTht7DChYoc9Tokvc1XFdC5MbRwhdBF7AoXKWpXlu8H3YbgIzrhUDAm1X /vxHH/qdbxLWIuX02ISjBePgt70ggVaHRXBd+I8t48D2bEHM4t7AaobHMysj0g6jb4Nv PHDGYNT7jvenOvj7oimtd+OPWPFDrCNvwyrYtLKLRwgP1q3zTrdS+oO+bAgce+QPuvvr dw8IdzxlxRQ5MDVdRkDlAJmwsf87cwMFwOyisRDGVHIo3B+nSvXWDPr1gUFBEL2gsyYK mteA+YtMUyW0hECZsMnPth7hpjqF8H1NSfwzlN3l59A6liqfKZXNbSP0gLE2thdKr6k+ I22A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Ced2txkv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id z1-20020a056a00240100b0068a6eb3b548si2449491pfh.401.2023.09.14.18.36.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 18:36:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Ced2txkv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 8300A82A38D3; Thu, 14 Sep 2023 04:34:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237455AbjINLeW (ORCPT + 99 others); Thu, 14 Sep 2023 07:34:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235307AbjINLeV (ORCPT ); Thu, 14 Sep 2023 07:34:21 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFF811FC9; Thu, 14 Sep 2023 04:34:16 -0700 (PDT) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38EBOZ2p011614; Thu, 14 Sep 2023 11:33:34 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=v/rgcR0kkyQPdpyr7j0ww+hfbXTrJx0WvQpvJwPUWPI=; b=Ced2txkveHOCo78dV1YmnFJi6JFO7m2vMd3GxbSoDqUK5z9ti88yGjGdh6Lp7Kr5ThST 9BjFuXOQdIpQ/Y7YpoTYGCgnRFjwRyVx6olghbQYs1pOwaq4Ibei+wrnl4ftZNNgLEmg j3ECyPTVE0BuqwdA792jekhXVPKx/UlFhJ8Bo23zxFqYKpdqZmW1LBgZswRkxX7O14xV VGaTLRxMVksPw8Iy9SfRbmHKEqtrySckoQBdYDBKLDelMUCQ2xTlexHWhWgu7mmWnWWu OccHa3fWtz3iTnGFLa134C+0VXr8m85r90KBzLBChxpoplrCSqhijqOGhHg5x6I8i5ys TQ== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3t3r15sart-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 Sep 2023 11:33:33 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 38EBXWBD030265 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 Sep 2023 11:33:32 GMT Received: from [10.218.45.181] (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 04:33:27 -0700 Message-ID: <8a9cc52c-9c7d-1f8f-8a98-1a816f59aa79@quicinc.com> Date: Thu, 14 Sep 2023 17:03:24 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.2 Subject: Re: [PATCH 5/6] scsi: ufs: ufs-sysfs: Expose UFS power info To: Can Guo , , , 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> Content-Language: en-US From: Nitin Rawat In-Reply-To: <1694411968-14413-6-git-send-email-quic_cang@quicinc.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit 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: XIyqZAed4Z4Jm6wGSYLkz5OKfSPiDUvD X-Proofpoint-ORIG-GUID: XIyqZAed4Z4Jm6wGSYLkz5OKfSPiDUvD 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-14_09,2023-09-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 impostorscore=0 malwarescore=0 adultscore=0 spamscore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 priorityscore=1501 mlxlogscore=999 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309140098 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 (snail.vger.email [0.0.0.0]); Thu, 14 Sep 2023 04:34:27 -0700 (PDT) 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 > > 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). Regards, Nitin Rawat