Message ID | 20240127130327.22443-1-quic_snehshah@quicinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-41186-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2395:b0:106:343:edcb with SMTP id gw21csp475201dyb; Sat, 27 Jan 2024 05:04:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IFVs1J9lhXZXlA8qcmob0c+l2upzVblv7HZ8mT3nG6SHSrOOuRSp7Y12FEB2+Edt3AdbvkI X-Received: by 2002:a17:906:b741:b0:a30:3863:333d with SMTP id fx1-20020a170906b74100b00a303863333dmr912529ejb.75.1706360697181; Sat, 27 Jan 2024 05:04:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706360697; cv=pass; d=google.com; s=arc-20160816; b=mjCS/tL6xqb6pMu0QqtPHb+4wimwln2B9WpJ2syZPLV0OvXZub2Ys4SgfK6vVB/C+9 zKe527X18ssyskJo8wUiTb8+4LtOF69NVU/tlOXDb5kqZpZqnZ9WjgUapZXFo14S1sh+ MyJrTpgHaxpnJs14C901nTXp+SQeUAqjgsi+G4384Y0I6izHPwa5dwAo8YqfWn+A2fAv ohlMb4gMdrHtYiC7wgxwSglFgVZYIh0pAWhRGIpF5rkUi6mWAxd/K2c/WNAGP1rcuIHB 7czqg6F/6GnRFqky8g59tvKAgUWp+QMmyEHSM2IDiUEBwE431vRlMor+Xf48RgNRWX82 3vVw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from:dkim-signature; bh=6oebARhWnbWUR8eKVVvlJcocYHJTcYCqahQxWhiBad0=; fh=1Jy5qpJ7e4FuBmQkVP0GCA4F+wDSel+w4r34NwoYij8=; b=VfUAMp7YiXkeWY7roky437EQNHDIhdOL04hdqj0aAVUdjF2Jl2o4OLXRU4EW7GH06f hG6tBJvU2lZS1O6eCHv1iaSVaL616J12bQ/Aidih21z5OQ95n5rANEsPUm/g2gZFanp4 Iv7sevAlKFIRYEE09itXbsPmcCQ7cwOFdpgYCsopTdVXZ4QSF2qN9GrebLGPn89d03nV CdZnrKU7dbhPeCfzODaGINwCfM2/2QTB9zdMWRT8bn0fuk7F/s2GI6aHO1IUvnwM1xxs rzEUPhh1h1i+4t7CzyEkEag0egtF9Zv+mWbkK3ar66QPa8tV11GdZ1+AGyiE/aHbuz8L tprA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=HMaB8xqJ; arc=pass (i=1 spf=pass spfdomain=qualcomm.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-41186-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41186-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id v17-20020a17090606d100b00a3176023c73si1749303ejb.211.2024.01.27.05.04.56 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Jan 2024 05:04:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-41186-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=HMaB8xqJ; arc=pass (i=1 spf=pass spfdomain=qualcomm.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-41186-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41186-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A14351F22FCD for <ouuuleilei@gmail.com>; Sat, 27 Jan 2024 13:04:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 022C425767; Sat, 27 Jan 2024 13:04:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="HMaB8xqJ" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F4789470; Sat, 27 Jan 2024 13:04:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706360669; cv=none; b=OHzOpGkdKpt3V4ExIJqDUvmnZbEoiiNLdtF5nOuzWJuXkfMkb7jTkPP2z+6dn+FmtvZ5wpCAxic+P0TjUhE12xHg1aP3qRc/akL1aS1pddV0iDJj5haRC93XdPhLy7izmyiSvw3o9tvY/8OBcTQN/2TdVpBofQKxuNvTBfNnZXE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706360669; c=relaxed/simple; bh=ezGjLX/KGCvKrdFlYhkTSrLIz9F/ChMEXBwpfDh019g=; h=From:To:Cc:Subject:Date:Message-Id; b=H3jNEHXT1z/xCmGkGtH5s1xeaR/IVLkWiKWSI9Dl8MSDrO+OIpzaPuME7H7W8LbuFPGB0N7LLk+DypvqKG5hn2PnJmn9mu9uwsTjVE9/ho1mgg2mWv9FzRzQ4nW1C5ATkWSA82r0YiHOpafca3OMdqfKjYiRIkI7kZesaq+5g4w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=qualcomm.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=HMaB8xqJ; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=qualcomm.com Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40RCxpbl001346; Sat, 27 Jan 2024 13:04:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id; s=qcppdkim1; bh=6oebARhWnbWU R8eKVVvlJcocYHJTcYCqahQxWhiBad0=; b=HMaB8xqJ9VBO09LxitQsHPjqo4eU nHql5VcTIerEBoOYBhoEy5mfoDQ5DnM5+htqCHATo4CvqHduCjbjjR/yAEGrrbcX WbWjbbbU2G0JahoXEi07W84d619FI5TWonzTuc4MM3yYYgPwjGtGc31cY3uaR6n1 U0WFs3x9EWXGCk8nIWyJ/j+c9UzI/tgXH4KLjynl7YIS2B7sKNj5fjQ7of9UrYW/ cCXBUGxAvqDT1N5FgQbeAHF8NNHN1iTu86NBtVHfWFPTtHF8Fl48DqGRUA+SpKvi MUwlak0zHdSPnECgXS9HR+LL49GqmB5Rg/A6RyD+6UFzKb5Flp6kjBCRVQ== Received: from apblrppmta02.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vvq6sgrrm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 27 Jan 2024 13:04:07 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 40RD44xr032026; Sat, 27 Jan 2024 13:04:04 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTP id 3vvtwkh1yy-1; Sat, 27 Jan 2024 13:04:04 +0000 Received: from APBLRPPMTA02.qualcomm.com (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 40RD43ad032020; Sat, 27 Jan 2024 13:04:03 GMT Received: from hu-maiyas-hyd.qualcomm.com (hu-snehshah-hyd.qualcomm.com [10.147.246.35]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTP id 40RD43rP032019; Sat, 27 Jan 2024 13:04:03 +0000 Received: by hu-maiyas-hyd.qualcomm.com (Postfix, from userid 2319345) id A7D185013A4; Sat, 27 Jan 2024 18:34:02 +0530 (+0530) From: Sneh Shah <quic_snehshah@quicinc.com> To: Vinod Koul <vkoul@kernel.org>, Bhupesh Sharma <bhupesh.sharma@linaro.org>, Alexandre Torgue <alexandre.torgue@foss.st.com>, Jose Abreu <joabreu@synopsys.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Maxime Coquelin <mcoquelin.stm32@gmail.com>, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Sneh Shah <quic_snehshah@quicinc.com>, kernel@quicinc.com, Andrew Halaney <ahalaney@redhat.com> Subject: [PATCH net-next] net: stmmac: dwmac-qcom-ethqos: Add support for pm ops Date: Sat, 27 Jan 2024 18:33:27 +0530 Message-Id: <20240127130327.22443-1-quic_snehshah@quicinc.com> X-Mailer: git-send-email 2.17.1 X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: hfW17_9FU6EIZ5OE24pmXqy0sXMCugSJ X-Proofpoint-ORIG-GUID: hfW17_9FU6EIZ5OE24pmXqy0sXMCugSJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-25_14,2024-01-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 spamscore=0 phishscore=0 adultscore=0 clxscore=1015 malwarescore=0 priorityscore=1501 suspectscore=0 mlxscore=0 lowpriorityscore=0 mlxlogscore=999 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401190000 definitions=main-2401270097 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789248874476321038 X-GMAIL-MSGID: 1789248874476321038 |
Series |
[net-next] net: stmmac: dwmac-qcom-ethqos: Add support for pm ops
|
|
Commit Message
Sneh Shah
Jan. 27, 2024, 1:03 p.m. UTC
Add qcom ethqos specific runtime and system sleep pm ops.
As part of system sleep qcom ethqos needs to disable all clocks.
This ops will be extended further with qcom specific features.
Signed-off-by: Sneh Shah <quic_snehshah@quicinc.com>
---
.../stmicro/stmmac/dwmac-qcom-ethqos.c | 51 ++++++++++++++++++-
1 file changed, 50 insertions(+), 1 deletion(-)
Comments
On Sat, Jan 27, 2024 at 06:33:27PM +0530, Sneh Shah wrote: > Add qcom ethqos specific runtime and system sleep pm ops. > As part of system sleep qcom ethqos needs to disable all clocks. > This ops will be extended further with qcom specific features. This last sentence sounds like this series is incomplete, I'd avoid such wording if its untrue. Upstream typically won't accept things that are building infrastructure for patches that will "eventually be posted". You state in your commit what the code does (really it replaces the stmmac_pltfrm_ops with its own), but only gloss over the why. I'd lead with the "why". i.e. I'd say something like "net: stmmac: dwmac-qcom-ethqos: Turn clocks off/on during suspend/resume" Since there's already a handler installed for PM ops, I'd explain why you need to change to new ones as well. > > Signed-off-by: Sneh Shah <quic_snehshah@quicinc.com> > --- > .../stmicro/stmmac/dwmac-qcom-ethqos.c | 51 ++++++++++++++++++- > 1 file changed, 50 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c > index 31631e3f89d0..cba601ee9e01 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c > @@ -720,6 +720,55 @@ static void ethqos_ptp_clk_freq_config(struct stmmac_priv *priv) > netdev_dbg(priv->dev, "PTP rate %d\n", plat_dat->clk_ptp_rate); > } > > +static int qcom_ethqos_runtime_suspend(struct device *dev) > +{ > + struct net_device *ndev = dev_get_drvdata(dev); > + struct stmmac_priv *priv = netdev_priv(ndev); > + > + return stmmac_bus_clks_config(priv, false); > +} > + This perfectly matches the stmmac_runtime_suspend() function installed originally. I don't see why you couldn't at a minimum reuse that function instead of writing your own. > +static int qcom_ethqos_runtime_resume(struct device *dev) > +{ > + struct net_device *ndev = dev_get_drvdata(dev); > + struct stmmac_priv *priv = netdev_priv(ndev); > + > + return stmmac_bus_clks_config(priv, true); > +} Same idea as the stmmac_runtime_suspend() comment above! > + > +static int qcom_ethqos_suspend(struct device *dev) > +{ > + struct net_device *ndev = dev_get_drvdata(dev); > + struct stmmac_priv *priv = netdev_priv(ndev); > + int ret; > + > + if (!ndev || !netif_running(ndev)) > + return -EINVAL; > + > + ret = stmmac_suspend(dev); ret here is ignored. > + > + return stmmac_bus_clks_config(priv, false); > +} > + > +static int qcom_ethqos_resume(struct device *dev) > +{ > + struct net_device *ndev = dev_get_drvdata(dev); > + struct stmmac_priv *priv = netdev_priv(ndev); > + int ret; unused ret. > + > + if (!ndev || !netif_running(ndev)) > + return -EINVAL; > + > + stmmac_bus_clks_config(priv, true); Probably should check this. > + > + return stmmac_resume(dev); > +} Both the new system sleep ops installed here basically match the stmmac_pltfrm_suspend/resume() functions that were already installed. The only difference I'm noting is that you want to call stmmac_bus_clks_config() in your implementation, whereas the originals call the exit()/init() callbacks if they exist in the platform driver. I would say "let's just make a exit()/init() callback for Qualcomm", but looking further... (see below) > + > +const struct dev_pm_ops qcom_ethqos_pm_ops = { > + SET_SYSTEM_SLEEP_PM_OPS(qcom_ethqos_suspend, qcom_ethqos_resume) > + SET_RUNTIME_PM_OPS(qcom_ethqos_runtime_suspend, qcom_ethqos_runtime_resume, NULL) > +}; > + > static int qcom_ethqos_probe(struct platform_device *pdev) > { > struct device_node *np = pdev->dev.of_node; > @@ -838,7 +887,7 @@ static struct platform_driver qcom_ethqos_driver = { > .probe = qcom_ethqos_probe, > .driver = { > .name = "qcom-ethqos", > - .pm = &stmmac_pltfr_pm_ops, > + .pm = &qcom_ethqos_pm_ops, You effectively remove the stmmac_pltfr_noirq_suspend()/resume() callbacks here, which do the stmmac_bus_clks_config() via pm_runtime_force_suspend() etc during late suspend/early resume. I do see this if statement, but I believe !device_may_wakeup() is true here, so the clocks should get killed. static int __maybe_unused stmmac_pltfr_noirq_suspend(struct device *dev) { struct net_device *ndev = dev_get_drvdata(dev); struct stmmac_priv *priv = netdev_priv(ndev); int ret; if (!netif_running(ndev)) return 0; if (!device_may_wakeup(priv->device) || !priv->plat->pmt) { /* Disable clock in case of PWM is off */ clk_disable_unprepare(priv->plat->clk_ptp_ref); ret = pm_runtime_force_suspend(dev); if (ret) return ret; } return 0; } Right now I'm of the opinion that this patch shouldn't really change much based on that digging. Please let me know if I'm missing something but it appears to me this should already be working. > .of_match_table = qcom_ethqos_match, > }, > }; > -- > 2.17.1 >
On 1/30/2024 1:12 AM, Andrew Halaney wrote: > On Sat, Jan 27, 2024 at 06:33:27PM +0530, Sneh Shah wrote: >> Add qcom ethqos specific runtime and system sleep pm ops. >> As part of system sleep qcom ethqos needs to disable all clocks. >> This ops will be extended further with qcom specific features. > > This last sentence sounds like this series is incomplete, I'd avoid such > wording if its untrue. Upstream typically won't accept things that are > building infrastructure for patches that will "eventually be posted". > > You state in your commit what the code does (really it replaces the > stmmac_pltfrm_ops with its own), but only gloss over the why. I'd lead > with the "why". i.e. I'd say something like > "net: stmmac: dwmac-qcom-ethqos: Turn clocks off/on during suspend/resume" > > Since there's already a handler installed for PM ops, I'd explain why > you need to change to new ones as well. > >> >> Signed-off-by: Sneh Shah <quic_snehshah@quicinc.com> >> --- >> .../stmicro/stmmac/dwmac-qcom-ethqos.c | 51 ++++++++++++++++++- >> 1 file changed, 50 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c >> index 31631e3f89d0..cba601ee9e01 100644 >> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c >> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c >> @@ -720,6 +720,55 @@ static void ethqos_ptp_clk_freq_config(struct stmmac_priv *priv) >> netdev_dbg(priv->dev, "PTP rate %d\n", plat_dat->clk_ptp_rate); >> } >> >> +static int qcom_ethqos_runtime_suspend(struct device *dev) >> +{ >> + struct net_device *ndev = dev_get_drvdata(dev); >> + struct stmmac_priv *priv = netdev_priv(ndev); >> + >> + return stmmac_bus_clks_config(priv, false); >> +} >> + > > This perfectly matches the stmmac_runtime_suspend() function installed > originally. I don't see why you couldn't at a minimum reuse > that function instead of writing your own. > >> +static int qcom_ethqos_runtime_resume(struct device *dev) >> +{ >> + struct net_device *ndev = dev_get_drvdata(dev); >> + struct stmmac_priv *priv = netdev_priv(ndev); >> + >> + return stmmac_bus_clks_config(priv, true); >> +} > > Same idea as the stmmac_runtime_suspend() comment above! > >> + >> +static int qcom_ethqos_suspend(struct device *dev) >> +{ >> + struct net_device *ndev = dev_get_drvdata(dev); >> + struct stmmac_priv *priv = netdev_priv(ndev); >> + int ret; >> + >> + if (!ndev || !netif_running(ndev)) >> + return -EINVAL; >> + >> + ret = stmmac_suspend(dev); > > ret here is ignored. > >> + >> + return stmmac_bus_clks_config(priv, false); >> +} >> + >> +static int qcom_ethqos_resume(struct device *dev) >> +{ >> + struct net_device *ndev = dev_get_drvdata(dev); >> + struct stmmac_priv *priv = netdev_priv(ndev); >> + int ret; > > unused ret. > >> + >> + if (!ndev || !netif_running(ndev)) >> + return -EINVAL; >> + >> + stmmac_bus_clks_config(priv, true); > > Probably should check this. > >> + >> + return stmmac_resume(dev); >> +} > > Both the new system sleep ops installed here basically match the > stmmac_pltfrm_suspend/resume() functions that were already installed. > The only difference I'm noting is that you want to call > stmmac_bus_clks_config() in your implementation, whereas the originals call > the exit()/init() callbacks if they exist in the platform driver. > > I would say "let's just make a exit()/init() callback for Qualcomm", but > looking further... (see below) > >> + >> +const struct dev_pm_ops qcom_ethqos_pm_ops = { >> + SET_SYSTEM_SLEEP_PM_OPS(qcom_ethqos_suspend, qcom_ethqos_resume) >> + SET_RUNTIME_PM_OPS(qcom_ethqos_runtime_suspend, qcom_ethqos_runtime_resume, NULL) >> +}; >> + >> static int qcom_ethqos_probe(struct platform_device *pdev) >> { >> struct device_node *np = pdev->dev.of_node; >> @@ -838,7 +887,7 @@ static struct platform_driver qcom_ethqos_driver = { >> .probe = qcom_ethqos_probe, >> .driver = { >> .name = "qcom-ethqos", >> - .pm = &stmmac_pltfr_pm_ops, >> + .pm = &qcom_ethqos_pm_ops, > > You effectively remove the stmmac_pltfr_noirq_suspend()/resume() > callbacks here, which do the stmmac_bus_clks_config() via > pm_runtime_force_suspend() etc during late suspend/early resume. > > I do see this if statement, but I believe !device_may_wakeup() is true here, > so the clocks should get killed. > > static int __maybe_unused stmmac_pltfr_noirq_suspend(struct device *dev) > { > struct net_device *ndev = dev_get_drvdata(dev); > struct stmmac_priv *priv = netdev_priv(ndev); > int ret; > > if (!netif_running(ndev)) > return 0; > > if (!device_may_wakeup(priv->device) || !priv->plat->pmt) { > /* Disable clock in case of PWM is off */ > clk_disable_unprepare(priv->plat->clk_ptp_ref); > > ret = pm_runtime_force_suspend(dev); > if (ret) > return ret; > } > > return 0; > } > > Right now I'm of the opinion that this patch shouldn't really change > much based on that digging. Please let me know if I'm missing something > but it appears to me this should already be working. I agree with all the points above. The reason we were still pushing qcom specific changes is we wanted a PM wrapper function to add qcom specific changes for features such as deep sleep. Looks like I had overlooked exit()/init() platform callbacks you have correctly pointed out. I can use this callbacks to do all the ethqos specific operations. Considering this point, the current patch is unnecessary. Thanks for pointing this out! > >> .of_match_table = qcom_ethqos_match, >> }, >> }; >> -- >> 2.17.1 >> >
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c index 31631e3f89d0..cba601ee9e01 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c @@ -720,6 +720,55 @@ static void ethqos_ptp_clk_freq_config(struct stmmac_priv *priv) netdev_dbg(priv->dev, "PTP rate %d\n", plat_dat->clk_ptp_rate); } +static int qcom_ethqos_runtime_suspend(struct device *dev) +{ + struct net_device *ndev = dev_get_drvdata(dev); + struct stmmac_priv *priv = netdev_priv(ndev); + + return stmmac_bus_clks_config(priv, false); +} + +static int qcom_ethqos_runtime_resume(struct device *dev) +{ + struct net_device *ndev = dev_get_drvdata(dev); + struct stmmac_priv *priv = netdev_priv(ndev); + + return stmmac_bus_clks_config(priv, true); +} + +static int qcom_ethqos_suspend(struct device *dev) +{ + struct net_device *ndev = dev_get_drvdata(dev); + struct stmmac_priv *priv = netdev_priv(ndev); + int ret; + + if (!ndev || !netif_running(ndev)) + return -EINVAL; + + ret = stmmac_suspend(dev); + + return stmmac_bus_clks_config(priv, false); +} + +static int qcom_ethqos_resume(struct device *dev) +{ + struct net_device *ndev = dev_get_drvdata(dev); + struct stmmac_priv *priv = netdev_priv(ndev); + int ret; + + if (!ndev || !netif_running(ndev)) + return -EINVAL; + + stmmac_bus_clks_config(priv, true); + + return stmmac_resume(dev); +} + +const struct dev_pm_ops qcom_ethqos_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(qcom_ethqos_suspend, qcom_ethqos_resume) + SET_RUNTIME_PM_OPS(qcom_ethqos_runtime_suspend, qcom_ethqos_runtime_resume, NULL) +}; + static int qcom_ethqos_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -838,7 +887,7 @@ static struct platform_driver qcom_ethqos_driver = { .probe = qcom_ethqos_probe, .driver = { .name = "qcom-ethqos", - .pm = &stmmac_pltfr_pm_ops, + .pm = &qcom_ethqos_pm_ops, .of_match_table = qcom_ethqos_match, }, };