netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yanteng Si <si.yanteng@linux.dev>
To: Yao Zi <ziyao@disroot.org>, 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>,
	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>,
	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: Re: [PATCH net-next v4 1/3] net: stmmac: Add generic suspend/resume helper for PCI-based controllers
Date: Wed, 12 Nov 2025 09:22:08 +0800	[thread overview]
Message-ID: <bac94701-273d-4ffe-b9ec-fcfcad1dfbfd@linux.dev> (raw)
In-Reply-To: <20251111100727.15560-3-ziyao@disroot.org>


在 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__ */

  reply	other threads:[~2025-11-12  1:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=bac94701-273d-4ffe-b9ec-fcfcad1dfbfd@linux.dev \
    --to=si.yanteng@linux.dev \
    --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=vladimir.oltean@nxp.com \
    --cc=yangtiezhu@loongson.cn \
    --cc=zhaoqunqin@loongson.cn \
    --cc=ziyao@disroot.org \
    /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;
as well as URLs for NNTP newsgroup(s).