Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1701758rwn; Fri, 9 Sep 2022 02:43:07 -0700 (PDT) X-Google-Smtp-Source: AA6agR6/wx/EhWKd6/kVBR36sq9nj0ivi6wTWJ7lifSarpKFGPb+kL3u3FDyv4wcfABBZv2PfNuk X-Received: by 2002:a05:6a00:1145:b0:52b:78c:fa26 with SMTP id b5-20020a056a00114500b0052b078cfa26mr13435477pfm.27.1662716587389; Fri, 09 Sep 2022 02:43:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662716587; cv=none; d=google.com; s=arc-20160816; b=UQSNevcac5Mzds/i9PgDl4BX4t0oQfByPay3lfx2ArIWPy9RC7DGY7nCbAJM79YPB4 e8E/Pz/tpYuSgekWR0DtbS1XJoMSZsgy2HPf/4HlOFdeqOAe43GcRvvghls50rs57iVk nvunK8BTRHT0JjusXv4JFlZqQFoxwDl+bhQ1QOhSFV8366+8vHngKNNbzdw1CqJnWHu6 pR2j7U3Iugs9eXedPiY0qflZCSuK9i4Wu43O5klfi4QS9EXjwLG5Zu6Ou2Fx13HC4183 xM/xYY171yM+qAObbNNEY+OrE9PW58uzHGRmZ1LXwshGmd/ypQEygaT/056vup3nWFq+ yDVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=e9oyM6c9eO+oX1i0ikmglldoQMouIxTI5tr1NuI9GT8=; b=wTUYbWhsdqY+S5eGkpol/bbJ0TxlxSfySoxFMIJ3Jg+n3UGOmVaq4h/8fbRBml2gJr yTbluYwybkLnYWx2Ka+KHcAwSynsrQNVMlNLX4TYOti4kFA4fklRIusKzPT4qGZFbuVQ C0q7pnBVxDIRhzKJKP1vqBqJWcBGqU+X0n9KU3ag8XvqPEQQ2MQd+Gca0HdqjJuTrMzy toJ9YzUR03YrGUodwHRicWU17DjFVC7aPoIxsoextB777ShjeBdGaFjpuC44V5HpYaZL wSHkPQ5HYXsygUuaRMVK+jL2T3UnzhFsXE4Fy8UVZKmg3AR+mZvME0J3O+VgTaTyDITt 4DzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=da8jwOMf; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pc18-20020a17090b3b9200b001fe2e0ed1d6si85527pjb.89.2022.09.09.02.42.55; Fri, 09 Sep 2022 02:43:07 -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=@linaro.org header.s=google header.b=da8jwOMf; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232063AbiIIJGM (ORCPT + 99 others); Fri, 9 Sep 2022 05:06:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231933AbiIIJFp (ORCPT ); Fri, 9 Sep 2022 05:05:45 -0400 Received: from mail-yb1-xb30.google.com (mail-yb1-xb30.google.com [IPv6:2607:f8b0:4864:20::b30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A4BBA99CD for ; Fri, 9 Sep 2022 02:05:05 -0700 (PDT) Received: by mail-yb1-xb30.google.com with SMTP id t184so1744566yba.4 for ; Fri, 09 Sep 2022 02:05:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=e9oyM6c9eO+oX1i0ikmglldoQMouIxTI5tr1NuI9GT8=; b=da8jwOMfsx5H05oRncihV5aFvyzpldWnjk6VRzdiJdjoiXpY+fCe9JssN6Nz9r+L+j l9E4JVcp5pgWrIuipD6Pi6wcKO+xD+VxeNwfuFt6elE6UHvSev+WLO0vDrW/tLIznTIL pDhzZzNph135gYHY2wx3yRTUBfbkz92m+AjchB4HbzuOoSIKq8dgKb1WAhflDbgHEbXY ftwjMPa5bH9X96v79lvW7Je1K0OWgSPjvuOcjVadzfvMMakdATI1M68Gg6PzbT1hBWxD jvBtOUUvWy5eJT0Fdxqw789DmY2q4uFclRA5L54De5cA0Z1HPHPMcwjpwr5m28TWxGz6 s6Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=e9oyM6c9eO+oX1i0ikmglldoQMouIxTI5tr1NuI9GT8=; b=WGxrYI+QXBymZ7GDRCTxyDdYE9DaKqNq517BmAKp05MJv+hCMJPfAF7X9KO44LRLd8 5HSIpLpTZtE+bMq2S6eLPqitcmkRALGtfzdHTMcktZvIFS51T369slXqj6ZxxtNKhrYJ 3DXeY+gmI8hmLNZRure211CDWPyAvePFNZhMQMjhl2I1w+sWPRxP/PZqb8A+AN9Rjwaz igTIPKDtcBqTY1CS+o2hyoM636DgTx1EEeNrlRsyRtzvX8ngGUw0DNXVoh3QVApdtPZY /o1gnbI1HQeIAzGXN+UN4xOlEYpptMV6oZFNWwi7ZkuEI9/Uj/v3J4wHLQ0WhYpGrldX ltIA== X-Gm-Message-State: ACgBeo179nImqOfds+9VqkSb6zC8ASbi493h0Xx1zLUjeB2iC5/XP5U2 +UXcFFFbv+VhN/SrD7WaggflY3TIwf5jrRXNRLIQCQ== X-Received: by 2002:a25:5c3:0:b0:6a9:90fb:c9e6 with SMTP id 186-20020a2505c3000000b006a990fbc9e6mr10891297ybf.152.1662714304890; Fri, 09 Sep 2022 02:05:04 -0700 (PDT) MIME-Version: 1.0 References: <1662713084-8106-1-git-send-email-quic_krichai@quicinc.com> <1662713084-8106-4-git-send-email-quic_krichai@quicinc.com> In-Reply-To: <1662713084-8106-4-git-send-email-quic_krichai@quicinc.com> From: Dmitry Baryshkov Date: Fri, 9 Sep 2022 12:04:53 +0300 Message-ID: Subject: Re: [PATCH v6 3/5] phy: core: Add support for phy power down & power up To: Krishna chaitanya chundru Cc: helgaas@kernel.org, linux-pci@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, mka@chromium.org, quic_vbadigan@quicinc.com, quic_hemantk@quicinc.com, quic_nitegupt@quicinc.com, quic_skananth@quicinc.com, quic_ramkri@quicinc.com, manivannan.sadhasivam@linaro.org, swboyd@chromium.org, Kishon Vijay Abraham I , Vinod Koul , "open list:GENERIC PHY FRAMEWORK" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 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. > +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 > -- With best wishes Dmitry