Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp8027870rwn; Wed, 14 Sep 2022 07:59:35 -0700 (PDT) X-Google-Smtp-Source: AA6agR7NWGuZXDU+LZlAUCAOjwpC7TTa+785Cl4TTkq/sAlFrnOr1Kas1wlqGNGi3QEklEORir/3 X-Received: by 2002:a17:906:9c83:b0:779:c14c:55e4 with SMTP id fj3-20020a1709069c8300b00779c14c55e4mr18032203ejc.619.1663167575615; Wed, 14 Sep 2022 07:59:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663167575; cv=none; d=google.com; s=arc-20160816; b=YVsa44InmbPpuqSXYQ7OiA88uXAfdkx38dJoKUpQXBKcQJyU2A0nJ8IqaIOM5rHk5I Vq7QARXU+w0XvFACUGIXmVr/xxKVsQUE/iO5104WmcZn9EvkoxRink6fSd8cbtR7/kHl 4IRoUbxeX6s1O7VDnaHW2uOZJL/I9tnF465NOexESNTPbKzHOoRoobp++9K8pNGqUcxj VWvI5FgNbY+lgclfQadK+J60S7B2Hu8ewteVhGjBO5EwxV6weVLxtGz4gg7kxmQaX+Pt XRSCR6fQY7Jzp+iAcZ60YXL0nH/tFvhqZNxn/3kMO4QQXMq9W4pGbj/wgXQ8D1taACcu wAgw== 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=OTY8GuPkdqdk8EUNrFn83pUuir/JISykGcAd92LluLU=; b=q8zzBgKh3oj8hmPU5szvRx16pdRQTb0iQDY/fIbzPMJMHNF0eCdxSGAaWK7NGsASI7 6DIuJvt6ZWfcJ2WFaLTY19lBeEct5Bcj4i5Eo5hIhHTXEGVuyqZhcd1eRdHuBGa54ymy nh4KGpeFwkLdKiyJtFrJ419CtAyf2EUL33MhMCXFSdClKwEt0afOVenWMvS7wkzdvIb/ gsfODf7Smlux6qjjqS0DuofX/2IrgtDk1gyM1Ae09u/cIujctPPGU0IERYhkFn2eUuWQ yuyaMhXH2Zqyv0QU+HSGzr/bJSDlL3us+8YAZ8JYyZ+6Qxfx/hQxyZu4Bx0lVPPVtgC2 O4uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=ZgqFrSOy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nd27-20020a170907629b00b0073d62820e42si12770438ejc.288.2022.09.14.07.59.08; Wed, 14 Sep 2022 07:59:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=ZgqFrSOy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229767AbiINOu5 (ORCPT + 99 others); Wed, 14 Sep 2022 10:50:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230174AbiINOul (ORCPT ); Wed, 14 Sep 2022 10:50:41 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7679B2FFFB; Wed, 14 Sep 2022 07:50:39 -0700 (PDT) Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28EEH6KY003237; Wed, 14 Sep 2022 14:50:25 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=OTY8GuPkdqdk8EUNrFn83pUuir/JISykGcAd92LluLU=; b=ZgqFrSOyeyafAKKJaxkUO0G0rd1BuwpZHgTjwNsIyQtfT31waUuVjql+Q/fFuUdKrgP8 nlTgi7coDbrtKB43GU4JOHlSVRUTecjcjsYhubS7z8qYDAg/JZLTNH6HWL/Ijv/EfJDU RisOl2t0JhVAMDUmiAqF33x6eaR0WFLt1X3ywbIFosueIyVvpei/LoOs0k78Y77ihbZP KAi1YAAtopNDYWSWOY7n2Tiy/xhieBYF3kikdny/FF6IvLsJK76QTocjOwhaRmt+m2v5 HE/COrUeoyzxm5MsduQETvOelocutOFztqCjW/TNhLzxsBFlaTvFqTEpnlXVpeIAIGGJ mg== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3jjy0gje8s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 14 Sep 2022 14:50:24 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 28EEoNc7025556 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 14 Sep 2022 14:50:23 GMT Received: from [10.216.1.65] (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.986.29; Wed, 14 Sep 2022 07:50:18 -0700 Message-ID: <87138bc9-2fc0-39fb-89c1-d3826e28594e@quicinc.com> Date: Wed, 14 Sep 2022 20:20:14 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v6 3/5] phy: core: Add support for phy power down & power up Content-Language: en-US To: Dmitry Baryshkov CC: , , , , , , , , , , , , Kishon Vijay Abraham I , Vinod Koul , "open list:GENERIC PHY FRAMEWORK" References: <1662713084-8106-1-git-send-email-quic_krichai@quicinc.com> <1662713084-8106-4-git-send-email-quic_krichai@quicinc.com> From: Krishna Chaitanya Chundru In-Reply-To: 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-ORIG-GUID: TU-05IkEFPn5b2aXCDOWOP7oMH83nch1 X-Proofpoint-GUID: TU-05IkEFPn5b2aXCDOWOP7oMH83nch1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-14_06,2022-09-14_04,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 suspectscore=0 clxscore=1015 adultscore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2208220000 definitions=main-2209140071 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/9/2022 2:34 PM, Dmitry Baryshkov wrote: > On Fri, 9 Sept 2022 at 11:45, Krishna chaitanya chundru > wrote: >> Introducing phy power down/up callbacks for allowing to park the >> link-state in L1ss without holding any PCIe resources during >> system suspend. >> >> Signed-off-by: Krishna chaitanya chundru >> --- >> drivers/phy/phy-core.c | 30 ++++++++++++++++++++++++++++++ >> include/linux/phy/phy.h | 20 ++++++++++++++++++++ >> 2 files changed, 50 insertions(+) >> >> diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c >> index d93ddf1..1b0b757 100644 >> --- a/drivers/phy/phy-core.c >> +++ b/drivers/phy/phy-core.c >> @@ -441,6 +441,36 @@ int phy_set_speed(struct phy *phy, int speed) >> } >> EXPORT_SYMBOL_GPL(phy_set_speed); >> >> +int phy_power_down(struct phy *phy) >> +{ >> + int ret; >> + >> + if (!phy || !phy->ops->power_down) >> + return 0; >> + >> + mutex_lock(&phy->mutex); >> + ret = phy->ops->power_down(phy); >> + mutex_unlock(&phy->mutex); >> + >> + return ret; >> +} >> +EXPORT_SYMBOL_GPL(phy_power_down); >> + >> +int phy_power_up(struct phy *phy) >> +{ >> + int ret; >> + >> + if (!phy || !phy->ops->power_up) >> + return 0; >> + >> + mutex_lock(&phy->mutex); >> + ret = phy->ops->power_up(phy); >> + mutex_unlock(&phy->mutex); >> + >> + return ret; >> +} > As it can be seen from the phy_power_off(), the PHY can be a shared > resource, with the power_count counting the number of users that > requested the PHY to be powered up. By introducing suc calls you break > directly into this by allowing a single user to power down the PHY, no > matter how many other users have requested the PHY to stay alive. can we use same power_count in this function also here and restrict the single user to power down the PHY same like phy_power_off?. >> +EXPORT_SYMBOL_GPL(phy_power_up); >> + >> int phy_reset(struct phy *phy) >> { >> int ret; >> diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h >> index b141375..3a45f4d 100644 >> --- a/include/linux/phy/phy.h >> +++ b/include/linux/phy/phy.h >> @@ -76,6 +76,8 @@ union phy_configure_opts { >> * @set_mode: set the mode of the phy >> * @set_media: set the media type of the phy (optional) >> * @set_speed: set the speed of the phy (optional) >> + * @power_down: parking the phy in power down state >> + * @power_up: pulling back the phy from power down >> * @reset: resetting the phy >> * @calibrate: calibrate the phy >> * @release: ops to be performed while the consumer relinquishes the PHY >> @@ -89,6 +91,8 @@ struct phy_ops { >> int (*set_mode)(struct phy *phy, enum phy_mode mode, int submode); >> int (*set_media)(struct phy *phy, enum phy_media media); >> int (*set_speed)(struct phy *phy, int speed); >> + int (*power_down)(struct phy *phy); >> + int (*power_up)(struct phy *phy); >> >> /** >> * @configure: >> @@ -226,6 +230,8 @@ int phy_init(struct phy *phy); >> int phy_exit(struct phy *phy); >> int phy_power_on(struct phy *phy); >> int phy_power_off(struct phy *phy); >> +int phy_power_down(struct phy *phy); >> +int phy_power_up(struct phy *phy); >> int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode); >> #define phy_set_mode(phy, mode) \ >> phy_set_mode_ext(phy, mode, 0) >> @@ -349,6 +355,20 @@ static inline int phy_power_off(struct phy *phy) >> return -ENOSYS; >> } >> >> +static inline int phy_power_down(struct phy *phy) >> +{ >> + if (!phy) >> + return 0; >> + return -ENOSYS; >> +} >> + >> +static inline int phy_power_up(struct phy *phy) >> +{ >> + if (!phy) >> + return 0; >> + return -ENOSYS; >> +} >> + >> static inline int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, >> int submode) >> { >> -- >> 2.7.4 >> >