* [PATCH net-next v4 0/3] Unify platform suspend/resume routines for PCI DWMAC glue
@ 2025-11-11 10:07 Yao Zi
2025-11-11 10:07 ` [PATCH net-next v4 1/3] net: stmmac: Add generic suspend/resume helper for PCI-based controllers Yao Zi
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Yao Zi @ 2025-11-11 10:07 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Yanteng Si, Huacai Chen, Russell King (Oracle),
Philipp Stanner, Tiezhu Yang, Qunqin Zhao, Yao Zi,
Vladimir Oltean, Furong Xu, Kunihiko Hayashi, Jacob Keller
Cc: netdev, linux-kernel
There are currently three PCI-based DWMAC glue drivers in tree,
stmmac_pci.c, dwmac-intel.c, and dwmac-loongson.c. Both stmmac_pci.c and
dwmac-intel.c implements the same and duplicated platform suspend/resume
routines.
This series introduces a new PCI helper library, stmmac_libpci.c,
providing a pair of helpers, stmmac_pci_plat_{suspend,resume}, and
replaces the driver-specific implementation with the helpers to reduce
code duplication. The helper will also simplify the Motorcomm DWMAC glue
driver which I'm working on.
The glue driver for Intel controllers isn't covered by the series, since
its suspend routine doesn't call pci_disable_device() and thus is a
little different from the new generic helpers.
I only have Loongson hardware on hand, thus the series is only tested on
Loongson 3A5000 machine. I could confirm the controller works after
resume, and WoL works as expected. This shouldn't break stmmac_pci.c,
either, since the new helpers have the exactly same code as the old
driver-specific suspend/resume hooks.
Changed from v3
- Drop (now) redundant Kconfig depends for DWMAC_LOONGSON and STMMAC_PCI
- Collect review tags
- Link to v3: https://lore.kernel.org/netdev/20251104151647.3125-1-ziyao@disroot.org/
Changed from v2
- Drop unnecessary "depends on STMMAC_ETH" from STMMAC_LIBPCI
- Enclose DWMAC_LOONGSON and STMMAC_PCI within "if STMMAC_LIBPCI",
instead of depends on the option.
- Link to v2: https://lore.kernel.org/netdev/20251030041916.19905-1-ziyao@disroot.org/
Changed from v1
- Separate the new suspend/resume helpers into a new file,
stmmac_libpci.c, and provide Kconfig symbol for it
- Link to v1: https://lore.kernel.org/netdev/20251028154332.59118-1-ziyao@disroot.org/
Yao Zi (3):
net: stmmac: Add generic suspend/resume helper for PCI-based
controllers
net: stmmac: loongson: Use generic PCI suspend/resume routines
net: stmmac: pci: Use generic PCI suspend/resume routines
drivers/net/ethernet/stmicro/stmmac/Kconfig | 16 ++++++-
drivers/net/ethernet/stmicro/stmmac/Makefile | 1 +
.../ethernet/stmicro/stmmac/dwmac-loongson.c | 36 ++------------
.../ethernet/stmicro/stmmac/stmmac_libpci.c | 48 +++++++++++++++++++
.../ethernet/stmicro/stmmac/stmmac_libpci.h | 12 +++++
.../net/ethernet/stmicro/stmmac/stmmac_pci.c | 36 ++------------
6 files changed, 81 insertions(+), 68 deletions(-)
create mode 100644 drivers/net/ethernet/stmicro/stmmac/stmmac_libpci.c
create mode 100644 drivers/net/ethernet/stmicro/stmmac/stmmac_libpci.h
--
2.51.2
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH net-next v4 1/3] net: stmmac: Add generic suspend/resume helper for PCI-based controllers
2025-11-11 10:07 [PATCH net-next v4 0/3] Unify platform suspend/resume routines for PCI DWMAC glue Yao Zi
@ 2025-11-11 10:07 ` Yao Zi
2025-11-12 1:22 ` Yanteng Si
2025-11-12 14:57 ` Jakub Kicinski
2025-11-11 10:07 ` [PATCH net-next v4 2/3] net: stmmac: loongson: Use generic PCI suspend/resume routines Yao Zi
2025-11-11 10:11 ` [PATCH net-next v4 3/3] net: stmmac: pci: " Yao Zi
2 siblings, 2 replies; 12+ messages in thread
From: Yao Zi @ 2025-11-11 10:07 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Yanteng Si, Huacai Chen, Russell King (Oracle),
Philipp Stanner, Tiezhu Yang, Qunqin Zhao, Yao Zi,
Vladimir Oltean, Furong Xu, Kunihiko Hayashi, Jacob Keller
Cc: netdev, linux-kernel
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>
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/ethernet/stmicro/stmmac/Kconfig | 8 ++++
drivers/net/ethernet/stmicro/stmmac/Makefile | 1 +
.../ethernet/stmicro/stmmac/stmmac_libpci.c | 48 +++++++++++++++++++
.../ethernet/stmicro/stmmac/stmmac_libpci.h | 12 +++++
4 files changed, 69 insertions(+)
create mode 100644 drivers/net/ethernet/stmicro/stmmac/stmmac_libpci.c
create mode 100644 drivers/net/ethernet/stmicro/stmmac/stmmac_libpci.h
diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
index 87c5bea6c2a2..1350f16f7138 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
+++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
@@ -349,6 +349,14 @@ config DWMAC_VISCONTI
endif
+config STMMAC_LIBPCI
+ tristate "STMMAC PCI helper library"
+ depends on PCI
+ default y
+ help
+ This selects the PCI bus helpers for the stmmac driver. If you
+ have a controller with PCI interface, say Y or M here.
+
config DWMAC_INTEL
tristate "Intel GMAC support"
default X86
diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile
index 1681a8a28313..7bf528731034 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Makefile
+++ b/drivers/net/ethernet/stmicro/stmmac/Makefile
@@ -44,6 +44,7 @@ obj-$(CONFIG_DWMAC_VISCONTI) += dwmac-visconti.o
stmmac-platform-objs:= stmmac_platform.o
dwmac-altr-socfpga-objs := dwmac-socfpga.o
+obj-$(CONFIG_STMMAC_LIBPCI) += stmmac_libpci.o
obj-$(CONFIG_STMMAC_PCI) += stmmac-pci.o
obj-$(CONFIG_DWMAC_INTEL) += dwmac-intel.o
obj-$(CONFIG_DWMAC_LOONGSON) += dwmac-loongson.o
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_libpci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_libpci.c
new file mode 100644
index 000000000000..5c5dd502f79a
--- /dev/null
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_libpci.c
@@ -0,0 +1,48 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * PCI bus helpers for STMMAC driver
+ * Copyright (C) 2025 Yao Zi <ziyao@disroot.org>
+ */
+
+#include <linux/device.h>
+#include <linux/pci.h>
+
+#include "stmmac_libpci.h"
+
+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);
+
+MODULE_DESCRIPTION("STMMAC PCI helper library");
+MODULE_AUTHOR("Yao Zi <ziyao@disroot.org>");
+MODULE_LICENSE("GPL");
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_libpci.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_libpci.h
new file mode 100644
index 000000000000..71553184f982
--- /dev/null
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_libpci.h
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2025 Yao Zi <ziyao@disroot.org>
+ */
+
+#ifndef __STMMAC_LIBPCI_H__
+#define __STMMAC_LIBPCI_H__
+
+int stmmac_pci_plat_suspend(struct device *dev, void *bsp_priv);
+int stmmac_pci_plat_resume(struct device *dev, void *bsp_priv);
+
+#endif /* __STMMAC_LIBPCI_H__ */
--
2.51.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH net-next v4 2/3] net: stmmac: loongson: Use generic PCI suspend/resume routines
2025-11-11 10:07 [PATCH net-next v4 0/3] Unify platform suspend/resume routines for PCI DWMAC glue Yao Zi
2025-11-11 10:07 ` [PATCH net-next v4 1/3] net: stmmac: Add generic suspend/resume helper for PCI-based controllers Yao Zi
@ 2025-11-11 10:07 ` Yao Zi
2025-11-11 10:23 ` Russell King (Oracle)
2025-11-12 1:23 ` Yanteng Si
2025-11-11 10:11 ` [PATCH net-next v4 3/3] net: stmmac: pci: " Yao Zi
2 siblings, 2 replies; 12+ messages in thread
From: Yao Zi @ 2025-11-11 10:07 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Yanteng Si, Huacai Chen, Russell King (Oracle),
Philipp Stanner, Tiezhu Yang, Qunqin Zhao, Yao Zi,
Vladimir Oltean, Furong Xu, Kunihiko Hayashi, Jacob Keller
Cc: netdev, linux-kernel
Convert glue driver for Loongson DWMAC controller to use the generic
platform suspend/resume routines for PCI controllers, instead of
implementing its own one.
Signed-off-by: Yao Zi <ziyao@disroot.org>
---
drivers/net/ethernet/stmicro/stmmac/Kconfig | 6 +++-
.../ethernet/stmicro/stmmac/dwmac-loongson.c | 36 ++-----------------
2 files changed, 8 insertions(+), 34 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
index 1350f16f7138..d2bff28fe409 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
+++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
@@ -367,15 +367,19 @@ config DWMAC_INTEL
This selects the Intel platform specific bus support for the
stmmac driver. This driver is used for Intel Quark/EHL/TGL.
+if STMMAC_LIBPCI
+
config DWMAC_LOONGSON
tristate "Loongson PCI DWMAC support"
default MACH_LOONGSON64
- depends on (MACH_LOONGSON64 || COMPILE_TEST) && STMMAC_ETH && PCI
+ depends on MACH_LOONGSON64 || COMPILE_TEST
depends on COMMON_CLK
help
This selects the LOONGSON PCI bus support for the stmmac driver,
Support for ethernet controller on Loongson-2K1000 SoC and LS7A1000 bridge.
+endif
+
config STMMAC_PCI
tristate "STMMAC PCI bus support"
depends on STMMAC_ETH && PCI
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
index 2a3ac0136cdb..584dc4ff8320 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
@@ -8,6 +8,7 @@
#include <linux/device.h>
#include <linux/of_irq.h>
#include "stmmac.h"
+#include "stmmac_libpci.h"
#include "dwmac_dma.h"
#include "dwmac1000.h"
@@ -525,37 +526,6 @@ static int loongson_dwmac_fix_reset(struct stmmac_priv *priv, void __iomem *ioad
10000, 2000000);
}
-static int loongson_dwmac_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;
-}
-
-static int loongson_dwmac_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;
-}
-
static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
struct plat_stmmacenet_data *plat;
@@ -600,8 +570,8 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
plat->bsp_priv = ld;
plat->setup = loongson_dwmac_setup;
plat->fix_soc_reset = loongson_dwmac_fix_reset;
- plat->suspend = loongson_dwmac_suspend;
- plat->resume = loongson_dwmac_resume;
+ plat->suspend = stmmac_pci_plat_suspend;
+ plat->resume = stmmac_pci_plat_resume;
ld->dev = &pdev->dev;
ld->loongson_id = readl(res.addr + GMAC_VERSION) & 0xff;
--
2.51.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH net-next v4 3/3] net: stmmac: pci: Use generic PCI suspend/resume routines
2025-11-11 10:07 [PATCH net-next v4 0/3] Unify platform suspend/resume routines for PCI DWMAC glue Yao Zi
2025-11-11 10:07 ` [PATCH net-next v4 1/3] net: stmmac: Add generic suspend/resume helper for PCI-based controllers Yao Zi
2025-11-11 10:07 ` [PATCH net-next v4 2/3] net: stmmac: loongson: Use generic PCI suspend/resume routines Yao Zi
@ 2025-11-11 10:11 ` Yao Zi
2025-11-11 10:24 ` Russell King (Oracle)
2025-11-12 1:24 ` Yanteng Si
2 siblings, 2 replies; 12+ messages in thread
From: Yao Zi @ 2025-11-11 10:11 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Yanteng Si, Huacai Chen, Russell King (Oracle),
Philipp Stanner, Tiezhu Yang, Qunqin Zhao, Yao Zi,
Vladimir Oltean, Furong Xu, Kunihiko Hayashi, Jacob Keller
Cc: netdev, linux-kernel
Convert STMMAC PCI glue driver to use the generic platform
suspend/resume routines for PCI controllers, instead of implementing its
own one.
Signed-off-by: Yao Zi <ziyao@disroot.org>
---
drivers/net/ethernet/stmicro/stmmac/Kconfig | 6 ++--
.../net/ethernet/stmicro/stmmac/stmmac_pci.c | 36 ++-----------------
2 files changed, 6 insertions(+), 36 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
index d2bff28fe409..00df980fd4e0 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
+++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
@@ -378,11 +378,8 @@ config DWMAC_LOONGSON
This selects the LOONGSON PCI bus support for the stmmac driver,
Support for ethernet controller on Loongson-2K1000 SoC and LS7A1000 bridge.
-endif
-
config STMMAC_PCI
tristate "STMMAC PCI bus support"
- depends on STMMAC_ETH && PCI
depends on COMMON_CLK
help
This selects the platform specific bus support for the stmmac driver.
@@ -392,4 +389,7 @@ config STMMAC_PCI
If you have a controller with this interface, say Y or M here.
If unsure, say N.
+
+endif
+
endif
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index 94b3a3b27270..fa92be672c54 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -14,6 +14,7 @@
#include <linux/dmi.h>
#include "stmmac.h"
+#include "stmmac_libpci.h"
struct stmmac_pci_info {
int (*setup)(struct pci_dev *pdev, struct plat_stmmacenet_data *plat);
@@ -139,37 +140,6 @@ static const struct stmmac_pci_info snps_gmac5_pci_info = {
.setup = snps_gmac5_default_data,
};
-static int stmmac_pci_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;
-}
-
-static int stmmac_pci_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;
-}
-
/**
* stmmac_pci_probe
*
@@ -249,8 +219,8 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
plat->safety_feat_cfg->prtyen = 1;
plat->safety_feat_cfg->tmouten = 1;
- plat->suspend = stmmac_pci_suspend;
- plat->resume = stmmac_pci_resume;
+ plat->suspend = stmmac_pci_plat_suspend;
+ plat->resume = stmmac_pci_plat_resume;
return stmmac_dvr_probe(&pdev->dev, plat, &res);
}
--
2.51.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH net-next v4 2/3] net: stmmac: loongson: Use generic PCI suspend/resume routines
2025-11-11 10:07 ` [PATCH net-next v4 2/3] net: stmmac: loongson: Use generic PCI suspend/resume routines Yao Zi
@ 2025-11-11 10:23 ` Russell King (Oracle)
2025-11-12 1:23 ` Yanteng Si
1 sibling, 0 replies; 12+ messages in thread
From: Russell King (Oracle) @ 2025-11-11 10:23 UTC (permalink / raw)
To: Yao Zi
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Yanteng Si, Huacai Chen, Philipp Stanner,
Tiezhu Yang, Qunqin Zhao, Vladimir Oltean, Furong Xu,
Kunihiko Hayashi, Jacob Keller, netdev, linux-kernel
On Tue, Nov 11, 2025 at 10:07:27AM +0000, Yao Zi wrote:
> Convert glue driver for Loongson DWMAC controller to use the generic
> platform suspend/resume routines for PCI controllers, instead of
> implementing its own one.
>
> Signed-off-by: Yao Zi <ziyao@disroot.org>
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Thanks!
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next v4 3/3] net: stmmac: pci: Use generic PCI suspend/resume routines
2025-11-11 10:11 ` [PATCH net-next v4 3/3] net: stmmac: pci: " Yao Zi
@ 2025-11-11 10:24 ` Russell King (Oracle)
2025-11-12 1:24 ` Yanteng Si
1 sibling, 0 replies; 12+ messages in thread
From: Russell King (Oracle) @ 2025-11-11 10:24 UTC (permalink / raw)
To: Yao Zi
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Yanteng Si, Huacai Chen, Philipp Stanner,
Tiezhu Yang, Qunqin Zhao, Vladimir Oltean, Furong Xu,
Kunihiko Hayashi, Jacob Keller, netdev, linux-kernel
On Tue, Nov 11, 2025 at 10:11:58AM +0000, Yao Zi wrote:
> Convert STMMAC PCI glue driver to use the generic platform
> suspend/resume routines for PCI controllers, instead of implementing its
> own one.
>
> Signed-off-by: Yao Zi <ziyao@disroot.org>
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Thanks!
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next v4 1/3] net: stmmac: Add generic suspend/resume helper for PCI-based controllers
2025-11-11 10:07 ` [PATCH net-next v4 1/3] net: stmmac: Add generic suspend/resume helper for PCI-based controllers Yao Zi
@ 2025-11-12 1:22 ` Yanteng Si
2025-11-12 14:57 ` Jakub Kicinski
1 sibling, 0 replies; 12+ messages in thread
From: Yanteng Si @ 2025-11-12 1:22 UTC (permalink / raw)
To: Yao Zi, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Huacai Chen, Russell King (Oracle),
Philipp Stanner, Tiezhu Yang, Qunqin Zhao, Vladimir Oltean,
Furong Xu, Kunihiko Hayashi, Jacob Keller
Cc: netdev, linux-kernel
在 2025/11/11 18:07, Yao Zi 写道:
> 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>
> Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Yanteng Si <siyanteng@cqsoftware.com.cn
Thanks,
Yanteng
> ---
> drivers/net/ethernet/stmicro/stmmac/Kconfig | 8 ++++
> drivers/net/ethernet/stmicro/stmmac/Makefile | 1 +
> .../ethernet/stmicro/stmmac/stmmac_libpci.c | 48 +++++++++++++++++++
> .../ethernet/stmicro/stmmac/stmmac_libpci.h | 12 +++++
> 4 files changed, 69 insertions(+)
> create mode 100644 drivers/net/ethernet/stmicro/stmmac/stmmac_libpci.c
> create mode 100644 drivers/net/ethernet/stmicro/stmmac/stmmac_libpci.h
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
> index 87c5bea6c2a2..1350f16f7138 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
> +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
> @@ -349,6 +349,14 @@ config DWMAC_VISCONTI
>
> endif
>
> +config STMMAC_LIBPCI
> + tristate "STMMAC PCI helper library"
> + depends on PCI
> + default y
> + help
> + This selects the PCI bus helpers for the stmmac driver. If you
> + have a controller with PCI interface, say Y or M here.
> +
> config DWMAC_INTEL
> tristate "Intel GMAC support"
> default X86
> diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile
> index 1681a8a28313..7bf528731034 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/Makefile
> +++ b/drivers/net/ethernet/stmicro/stmmac/Makefile
> @@ -44,6 +44,7 @@ obj-$(CONFIG_DWMAC_VISCONTI) += dwmac-visconti.o
> stmmac-platform-objs:= stmmac_platform.o
> dwmac-altr-socfpga-objs := dwmac-socfpga.o
>
> +obj-$(CONFIG_STMMAC_LIBPCI) += stmmac_libpci.o
> obj-$(CONFIG_STMMAC_PCI) += stmmac-pci.o
> obj-$(CONFIG_DWMAC_INTEL) += dwmac-intel.o
> obj-$(CONFIG_DWMAC_LOONGSON) += dwmac-loongson.o
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_libpci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_libpci.c
> new file mode 100644
> index 000000000000..5c5dd502f79a
> --- /dev/null
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_libpci.c
> @@ -0,0 +1,48 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * PCI bus helpers for STMMAC driver
> + * Copyright (C) 2025 Yao Zi <ziyao@disroot.org>
> + */
> +
> +#include <linux/device.h>
> +#include <linux/pci.h>
> +
> +#include "stmmac_libpci.h"
> +
> +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);
> +
> +MODULE_DESCRIPTION("STMMAC PCI helper library");
> +MODULE_AUTHOR("Yao Zi <ziyao@disroot.org>");
> +MODULE_LICENSE("GPL");
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_libpci.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_libpci.h
> new file mode 100644
> index 000000000000..71553184f982
> --- /dev/null
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_libpci.h
> @@ -0,0 +1,12 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * Copyright (C) 2025 Yao Zi <ziyao@disroot.org>
> + */
> +
> +#ifndef __STMMAC_LIBPCI_H__
> +#define __STMMAC_LIBPCI_H__
> +
> +int stmmac_pci_plat_suspend(struct device *dev, void *bsp_priv);
> +int stmmac_pci_plat_resume(struct device *dev, void *bsp_priv);
> +
> +#endif /* __STMMAC_LIBPCI_H__ */
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next v4 2/3] net: stmmac: loongson: Use generic PCI suspend/resume routines
2025-11-11 10:07 ` [PATCH net-next v4 2/3] net: stmmac: loongson: Use generic PCI suspend/resume routines Yao Zi
2025-11-11 10:23 ` Russell King (Oracle)
@ 2025-11-12 1:23 ` Yanteng Si
1 sibling, 0 replies; 12+ messages in thread
From: Yanteng Si @ 2025-11-12 1:23 UTC (permalink / raw)
To: Yao Zi, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Huacai Chen, Russell King (Oracle),
Philipp Stanner, Tiezhu Yang, Qunqin Zhao, Vladimir Oltean,
Furong Xu, Kunihiko Hayashi, Jacob Keller
Cc: netdev, linux-kernel
在 2025/11/11 18:07, Yao Zi 写道:
> Convert glue driver for Loongson DWMAC controller to use the generic
> platform suspend/resume routines for PCI controllers, instead of
> implementing its own one.
>
> Signed-off-by: Yao Zi <ziyao@disroot.org>
Acked-by: Yanteng Si <siyanteng@cqsoftware.com.cn
Thanks,
Yanteng
> ---
> drivers/net/ethernet/stmicro/stmmac/Kconfig | 6 +++-
> .../ethernet/stmicro/stmmac/dwmac-loongson.c | 36 ++-----------------
> 2 files changed, 8 insertions(+), 34 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
> index 1350f16f7138..d2bff28fe409 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
> +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
> @@ -367,15 +367,19 @@ config DWMAC_INTEL
> This selects the Intel platform specific bus support for the
> stmmac driver. This driver is used for Intel Quark/EHL/TGL.
>
> +if STMMAC_LIBPCI
> +
> config DWMAC_LOONGSON
> tristate "Loongson PCI DWMAC support"
> default MACH_LOONGSON64
> - depends on (MACH_LOONGSON64 || COMPILE_TEST) && STMMAC_ETH && PCI
> + depends on MACH_LOONGSON64 || COMPILE_TEST
> depends on COMMON_CLK
> help
> This selects the LOONGSON PCI bus support for the stmmac driver,
> Support for ethernet controller on Loongson-2K1000 SoC and LS7A1000 bridge.
>
> +endif
> +
> config STMMAC_PCI
> tristate "STMMAC PCI bus support"
> depends on STMMAC_ETH && PCI
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> index 2a3ac0136cdb..584dc4ff8320 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> @@ -8,6 +8,7 @@
> #include <linux/device.h>
> #include <linux/of_irq.h>
> #include "stmmac.h"
> +#include "stmmac_libpci.h"
> #include "dwmac_dma.h"
> #include "dwmac1000.h"
>
> @@ -525,37 +526,6 @@ static int loongson_dwmac_fix_reset(struct stmmac_priv *priv, void __iomem *ioad
> 10000, 2000000);
> }
>
> -static int loongson_dwmac_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;
> -}
> -
> -static int loongson_dwmac_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;
> -}
> -
> static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> {
> struct plat_stmmacenet_data *plat;
> @@ -600,8 +570,8 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
> plat->bsp_priv = ld;
> plat->setup = loongson_dwmac_setup;
> plat->fix_soc_reset = loongson_dwmac_fix_reset;
> - plat->suspend = loongson_dwmac_suspend;
> - plat->resume = loongson_dwmac_resume;
> + plat->suspend = stmmac_pci_plat_suspend;
> + plat->resume = stmmac_pci_plat_resume;
> ld->dev = &pdev->dev;
> ld->loongson_id = readl(res.addr + GMAC_VERSION) & 0xff;
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next v4 3/3] net: stmmac: pci: Use generic PCI suspend/resume routines
2025-11-11 10:11 ` [PATCH net-next v4 3/3] net: stmmac: pci: " Yao Zi
2025-11-11 10:24 ` Russell King (Oracle)
@ 2025-11-12 1:24 ` Yanteng Si
1 sibling, 0 replies; 12+ messages in thread
From: Yanteng Si @ 2025-11-12 1:24 UTC (permalink / raw)
To: Yao Zi, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Huacai Chen, Russell King (Oracle),
Philipp Stanner, Tiezhu Yang, Qunqin Zhao, Vladimir Oltean,
Furong Xu, Kunihiko Hayashi, Jacob Keller
Cc: netdev, linux-kernel
在 2025/11/11 18:11, Yao Zi 写道:
> Convert STMMAC PCI glue driver to use the generic platform
> suspend/resume routines for PCI controllers, instead of implementing its
> own one.
>
> Signed-off-by: Yao Zi <ziyao@disroot.org>
Reviewed-by: Yanteng Si <siyanteng@cqsoftware.com.cn>
Thanks,
Yanteng
> ---
> drivers/net/ethernet/stmicro/stmmac/Kconfig | 6 ++--
> .../net/ethernet/stmicro/stmmac/stmmac_pci.c | 36 ++-----------------
> 2 files changed, 6 insertions(+), 36 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
> index d2bff28fe409..00df980fd4e0 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
> +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
> @@ -378,11 +378,8 @@ config DWMAC_LOONGSON
> This selects the LOONGSON PCI bus support for the stmmac driver,
> Support for ethernet controller on Loongson-2K1000 SoC and LS7A1000 bridge.
>
> -endif
> -
> config STMMAC_PCI
> tristate "STMMAC PCI bus support"
> - depends on STMMAC_ETH && PCI
> depends on COMMON_CLK
> help
> This selects the platform specific bus support for the stmmac driver.
> @@ -392,4 +389,7 @@ config STMMAC_PCI
> If you have a controller with this interface, say Y or M here.
>
> If unsure, say N.
> +
> +endif
> +
> endif
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> index 94b3a3b27270..fa92be672c54 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> @@ -14,6 +14,7 @@
> #include <linux/dmi.h>
>
> #include "stmmac.h"
> +#include "stmmac_libpci.h"
>
> struct stmmac_pci_info {
> int (*setup)(struct pci_dev *pdev, struct plat_stmmacenet_data *plat);
> @@ -139,37 +140,6 @@ static const struct stmmac_pci_info snps_gmac5_pci_info = {
> .setup = snps_gmac5_default_data,
> };
>
> -static int stmmac_pci_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;
> -}
> -
> -static int stmmac_pci_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;
> -}
> -
> /**
> * stmmac_pci_probe
> *
> @@ -249,8 +219,8 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
> plat->safety_feat_cfg->prtyen = 1;
> plat->safety_feat_cfg->tmouten = 1;
>
> - plat->suspend = stmmac_pci_suspend;
> - plat->resume = stmmac_pci_resume;
> + plat->suspend = stmmac_pci_plat_suspend;
> + plat->resume = stmmac_pci_plat_resume;
>
> return stmmac_dvr_probe(&pdev->dev, plat, &res);
> }
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next v4 1/3] net: stmmac: Add generic suspend/resume helper for PCI-based controllers
2025-11-11 10:07 ` [PATCH net-next v4 1/3] net: stmmac: Add generic suspend/resume helper for PCI-based controllers Yao Zi
2025-11-12 1:22 ` Yanteng Si
@ 2025-11-12 14:57 ` Jakub Kicinski
2025-11-12 15:15 ` Russell King (Oracle)
1 sibling, 1 reply; 12+ messages in thread
From: Jakub Kicinski @ 2025-11-12 14:57 UTC (permalink / raw)
To: Yao Zi
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni,
Yanteng Si, Huacai Chen, Russell King (Oracle), Philipp Stanner,
Tiezhu Yang, Qunqin Zhao, Vladimir Oltean, Furong Xu,
Kunihiko Hayashi, Jacob Keller, netdev, linux-kernel
On Tue, 11 Nov 2025 10:07:26 +0000 Yao Zi wrote:
> +config STMMAC_LIBPCI
> + tristate "STMMAC PCI helper library"
> + depends on PCI
> + default y
> + help
> + This selects the PCI bus helpers for the stmmac driver. If you
> + have a controller with PCI interface, say Y or M here.
I didn't pay enough attention to the discussion on v2, sorry.
I understand that there's precedent for a library symbol hiding
real symbols in this driver but it really makes for a poor user
experience.
The symbol should be hidden, and select'ed by what needs it.
With the PCI dependency on the real symbol, not here.
The "default y" may draw the attention of the Superior Penguin.
He may have quite a lot to criticize in this area, so let's
not risk it..
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next v4 1/3] net: stmmac: Add generic suspend/resume helper for PCI-based controllers
2025-11-12 14:57 ` Jakub Kicinski
@ 2025-11-12 15:15 ` Russell King (Oracle)
2025-11-15 9:37 ` Yao Zi
0 siblings, 1 reply; 12+ messages in thread
From: Russell King (Oracle) @ 2025-11-12 15:15 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Yao Zi, Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni,
Yanteng Si, Huacai Chen, Philipp Stanner, Tiezhu Yang,
Qunqin Zhao, Vladimir Oltean, Furong Xu, Kunihiko Hayashi,
Jacob Keller, netdev, linux-kernel
On Wed, Nov 12, 2025 at 06:57:20AM -0800, Jakub Kicinski wrote:
> On Tue, 11 Nov 2025 10:07:26 +0000 Yao Zi wrote:
> > +config STMMAC_LIBPCI
> > + tristate "STMMAC PCI helper library"
> > + depends on PCI
> > + default y
> > + help
> > + This selects the PCI bus helpers for the stmmac driver. If you
> > + have a controller with PCI interface, say Y or M here.
>
> I didn't pay enough attention to the discussion on v2, sorry.
> I understand that there's precedent for a library symbol hiding
> real symbols in this driver but it really makes for a poor user
> experience.
>
> The symbol should be hidden, and select'ed by what needs it.
> With the PCI dependency on the real symbol, not here.
>
> The "default y" may draw the attention of the Superior Penguin.
> He may have quite a lot to criticize in this area, so let's
> not risk it..
Okay, should we also convert STMMAC_PLATFORM to behave the same way,
because it's odd to have one bus type acting one way and the other
differently.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next v4 1/3] net: stmmac: Add generic suspend/resume helper for PCI-based controllers
2025-11-12 15:15 ` Russell King (Oracle)
@ 2025-11-15 9:37 ` Yao Zi
0 siblings, 0 replies; 12+ messages in thread
From: Yao Zi @ 2025-11-15 9:37 UTC (permalink / raw)
To: Russell King (Oracle), Jakub Kicinski
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni,
Yanteng Si, Huacai Chen, Philipp Stanner, Tiezhu Yang,
Qunqin Zhao, Vladimir Oltean, Furong Xu, Kunihiko Hayashi,
Jacob Keller, netdev, linux-kernel
On Wed, Nov 12, 2025 at 03:15:45PM +0000, Russell King (Oracle) wrote:
> On Wed, Nov 12, 2025 at 06:57:20AM -0800, Jakub Kicinski wrote:
> > On Tue, 11 Nov 2025 10:07:26 +0000 Yao Zi wrote:
> > > +config STMMAC_LIBPCI
> > > + tristate "STMMAC PCI helper library"
> > > + depends on PCI
> > > + default y
> > > + help
> > > + This selects the PCI bus helpers for the stmmac driver. If you
> > > + have a controller with PCI interface, say Y or M here.
> >
> > I didn't pay enough attention to the discussion on v2, sorry.
> > I understand that there's precedent for a library symbol hiding
> > real symbols in this driver but it really makes for a poor user
> > experience.
> >
> > The symbol should be hidden, and select'ed by what needs it.
> > With the PCI dependency on the real symbol, not here.
> >
> > The "default y" may draw the attention of the Superior Penguin.
> > He may have quite a lot to criticize in this area, so let's
> > not risk it..
>
> Okay, should we also convert STMMAC_PLATFORM to behave the same way,
> because it's odd to have one bus type acting one way and the other
> differently.
I don't have a strong opinion about the Kconfig style, so should I go
back to make drivers select STMMAC_LIBPCI as suggested by Maxime in
v2[1], and drop the "default y" statement from STMMAC_LIBPCI?
Best regards,
Yao Zi
[1]: https://lore.kernel.org/netdev/da8d9585-d464-4611-98c0-a10d84874297@bootlin.com/
> --
> RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
> FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2025-11-15 9:38 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-11 10:07 [PATCH net-next v4 0/3] Unify platform suspend/resume routines for PCI DWMAC glue Yao Zi
2025-11-11 10:07 ` [PATCH net-next v4 1/3] net: stmmac: Add generic suspend/resume helper for PCI-based controllers Yao Zi
2025-11-12 1:22 ` Yanteng Si
2025-11-12 14:57 ` Jakub Kicinski
2025-11-12 15:15 ` Russell King (Oracle)
2025-11-15 9:37 ` Yao Zi
2025-11-11 10:07 ` [PATCH net-next v4 2/3] net: stmmac: loongson: Use generic PCI suspend/resume routines Yao Zi
2025-11-11 10:23 ` Russell King (Oracle)
2025-11-12 1:23 ` Yanteng Si
2025-11-11 10:11 ` [PATCH net-next v4 3/3] net: stmmac: pci: " Yao Zi
2025-11-11 10:24 ` Russell King (Oracle)
2025-11-12 1:24 ` Yanteng Si
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).