From: Yao Zi <ziyao@disroot.org>
To: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Yanteng Si <si.yanteng@linux.dev>,
Huacai Chen <chenhuacai@kernel.org>,
"Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>,
Philipp Stanner <phasta@kernel.org>,
Tiezhu Yang <yangtiezhu@loongson.cn>,
Qunqin Zhao <zhaoqunqin@loongson.cn>, Yao Zi <ziyao@disroot.org>,
Vladimir Oltean <vladimir.oltean@nxp.com>,
Furong Xu <0x1207@gmail.com>,
Kunihiko Hayashi <hayashi.kunihiko@socionext.com>,
Jacob Keller <jacob.e.keller@intel.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH net-next 1/3] net: stmmac: Add generic suspend/resume helper for PCI-based controllers
Date: Tue, 28 Oct 2025 15:43:30 +0000 [thread overview]
Message-ID: <20251028154332.59118-2-ziyao@disroot.org> (raw)
In-Reply-To: <20251028154332.59118-1-ziyao@disroot.org>
Most glue driver for PCI-based DWMAC controllers utilize similar
platform suspend/resume routines. Add a generic implementation to reduce
duplicated code.
Signed-off-by: Yao Zi <ziyao@disroot.org>
---
drivers/net/ethernet/stmicro/stmmac/stmmac.h | 2 +
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 37 +++++++++++++++++++
2 files changed, 39 insertions(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index d5af9344dfb0..baa4ff14bdfe 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -395,6 +395,8 @@ int stmmac_xdp_open(struct net_device *dev);
void stmmac_xdp_release(struct net_device *dev);
int stmmac_resume(struct device *dev);
int stmmac_suspend(struct device *dev);
+int stmmac_pci_plat_suspend(struct device *dev, void *bsp_priv);
+int stmmac_pci_plat_resume(struct device *dev, void *bsp_priv);
void stmmac_dvr_remove(struct device *dev);
int stmmac_dvr_probe(struct device *device,
struct plat_stmmacenet_data *plat_dat,
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index fd5106880192..3bd284019ca7 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -28,6 +28,7 @@
#include <linux/if_vlan.h>
#include <linux/dma-mapping.h>
#include <linux/slab.h>
+#include <linux/pci.h>
#include <linux/pm_runtime.h>
#include <linux/pm_wakeirq.h>
#include <linux/prefetch.h>
@@ -7938,6 +7939,42 @@ EXPORT_SYMBOL_GPL(stmmac_resume);
DEFINE_SIMPLE_DEV_PM_OPS(stmmac_simple_pm_ops, stmmac_suspend, stmmac_resume);
EXPORT_SYMBOL_GPL(stmmac_simple_pm_ops);
+#ifdef CONFIG_PCI
+int stmmac_pci_plat_suspend(struct device *dev, void *bsp_priv)
+{
+ struct pci_dev *pdev = to_pci_dev(dev);
+ int ret;
+
+ ret = pci_save_state(pdev);
+ if (ret)
+ return ret;
+
+ pci_disable_device(pdev);
+ pci_wake_from_d3(pdev, true);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(stmmac_pci_plat_suspend);
+
+int stmmac_pci_plat_resume(struct device *dev, void *bsp_priv)
+{
+ struct pci_dev *pdev = to_pci_dev(dev);
+ int ret;
+
+ pci_restore_state(pdev);
+ pci_set_power_state(pdev, PCI_D0);
+
+ ret = pci_enable_device(pdev);
+ if (ret)
+ return ret;
+
+ pci_set_master(pdev);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(stmmac_pci_plat_resume);
+#endif /* CONFIG_PCI */
+
#ifndef MODULE
static int __init stmmac_cmdline_opt(char *str)
{
--
2.50.1
next prev parent reply other threads:[~2025-10-28 15:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-28 15:43 [PATCH net-next 0/3] Unify platform suspend/resume routines for PCI DWMAC glue Yao Zi
2025-10-28 15:43 ` Yao Zi [this message]
2025-10-28 15:59 ` [PATCH net-next 1/3] net: stmmac: Add generic suspend/resume helper for PCI-based controllers Russell King (Oracle)
2025-10-29 2:27 ` Yanteng Si
2025-10-29 2:50 ` Yao Zi
2025-10-29 9:00 ` Russell King (Oracle)
2025-10-29 9:07 ` Yanteng Si
2025-10-28 15:43 ` [PATCH net-next 2/3] net: stmmac: loongson: Use generic PCI suspend/resume routines Yao Zi
2025-10-28 15:43 ` [PATCH net-next 3/3] net: stmmac: pci: " Yao Zi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251028154332.59118-2-ziyao@disroot.org \
--to=ziyao@disroot.org \
--cc=0x1207@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=chenhuacai@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hayashi.kunihiko@socionext.com \
--cc=jacob.e.keller@intel.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=phasta@kernel.org \
--cc=rmk+kernel@armlinux.org.uk \
--cc=si.yanteng@linux.dev \
--cc=vladimir.oltean@nxp.com \
--cc=yangtiezhu@loongson.cn \
--cc=zhaoqunqin@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®