diff mbox series

[v4,1/2] net: stmmac: add support for platform specific reset

Message ID 20230331212250.103017-1-shenwei.wang@nxp.com (mailing list archive)
State New, archived
Headers show
Series [v4,1/2] net: stmmac: add support for platform specific reset | expand

Commit Message

Shenwei Wang March 31, 2023, 9:22 p.m. UTC
This patch adds support for platform-specific reset logic in the
stmmac driver. Some SoCs require a different reset mechanism than
the standard dwmac IP reset. To support these platforms, a new function
pointer 'fix_soc_reset' is added to the plat_stmmacenet_data structure.
The stmmac_reset macro in hwif.h is modified to call the 'fix_soc_reset'
function if it exists. This enables the driver to use the platform-specific
reset logic when necessary.

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Shenwei Wang <shenwei.wang@nxp.com>
---
 drivers/net/ethernet/stmicro/stmmac/hwif.c | 10 ++++++++++
 drivers/net/ethernet/stmicro/stmmac/hwif.h |  3 +--
 include/linux/stmmac.h                     |  1 +
 3 files changed, 12 insertions(+), 2 deletions(-)

--
2.34.1

Comments

Jakub Kicinski April 1, 2023, 4:58 a.m. UTC | #1
On Fri, 31 Mar 2023 16:22:49 -0500 Shenwei Wang wrote:
> diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
> index 16a7421715cb..47a68f506c10 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
> +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
> @@ -214,8 +214,6 @@ struct stmmac_dma_ops {
>  	int (*enable_tbs)(void __iomem *ioaddr, bool en, u32 chan);
>  };
> 
> -#define stmmac_reset(__priv, __args...) \
> -	stmmac_do_callback(__priv, dma, reset, __args)
>  #define stmmac_dma_init(__priv, __args...) \
>  	stmmac_do_void_callback(__priv, dma, init, __args)
>  #define stmmac_init_chan(__priv, __args...) \
> @@ -640,6 +638,7 @@ extern const struct stmmac_mmc_ops dwxgmac_mmc_ops;
>  #define GMAC_VERSION		0x00000020	/* GMAC CORE Version */
>  #define GMAC4_VERSION		0x00000110	/* GMAC4+ CORE Version */
> 
> +int stmmac_reset(struct stmmac_priv *priv, void *ioaddr);

sparse reports missing annotation, I think it's this line.
It should have a __iomem tag. Try building with C=1
Also please take a look at:
https://www.kernel.org/doc/html/next/process/maintainer-netdev.html

>  int stmmac_hwif_init(struct stmmac_priv *priv);
Shenwei Wang April 3, 2023, 1:53 p.m. UTC | #2
> -----Original Message-----
> From: Jakub Kicinski <kuba@kernel.org>
> Sent: Friday, March 31, 2023 11:58 PM
> To: Shenwei Wang <shenwei.wang@nxp.com>
> Cc: David S. Miller <davem@davemloft.net>; Eric Dumazet
> <edumazet@google.com>; Paolo Abeni <pabeni@redhat.com>; Shawn Guo
> <shawnguo@kernel.org>; Sascha Hauer <s.hauer@pengutronix.de>; Maxime
> Coquelin <mcoquelin.stm32@gmail.com>; Giuseppe Cavallaro
> <peppe.cavallaro@st.com>; Alexandre Torgue <alexandre.torgue@foss.st.com>;
> Jose Abreu <joabreu@synopsys.com>; Pengutronix Kernel Team
> <kernel@pengutronix.de>; Fabio Estevam <festevam@gmail.com>; dl-linux-imx
> <linux-imx@nxp.com>; Wong Vee Khee <veekhee@apple.com>; Kurt
> Kanzenbach <kurt@linutronix.de>; Revanth Kumar Uppala
> <ruppala@nvidia.com>; Andrey Konovalov <andrey.konovalov@linaro.org>; Tan
> Tee Min <tee.min.tan@linux.intel.com>; netdev@vger.kernel.org; linux-arm-
> kernel@lists.infradead.org; linux-stm32@st-md-mailman.stormreply.com;
> imx@lists.linux.dev
> Subject: [EXT] Re: [PATCH v4 1/2] net: stmmac: add support for platform specific
> reset
> 
> Caution: EXT Email
> 
> On Fri, 31 Mar 2023 16:22:49 -0500 Shenwei Wang wrote:
> > diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h
> > b/drivers/net/ethernet/stmicro/stmmac/hwif.h
> > index 16a7421715cb..47a68f506c10 100644
> > --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
> > +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
> > @@ -214,8 +214,6 @@ struct stmmac_dma_ops {
> >       int (*enable_tbs)(void __iomem *ioaddr, bool en, u32 chan);  };
> >
> > -#define stmmac_reset(__priv, __args...) \
> > -     stmmac_do_callback(__priv, dma, reset, __args)
> >  #define stmmac_dma_init(__priv, __args...) \
> >       stmmac_do_void_callback(__priv, dma, init, __args)  #define
> > stmmac_init_chan(__priv, __args...) \ @@ -640,6 +638,7 @@ extern const
> > struct stmmac_mmc_ops dwxgmac_mmc_ops;
> >  #define GMAC_VERSION         0x00000020      /* GMAC CORE Version */
> >  #define GMAC4_VERSION                0x00000110      /* GMAC4+ CORE Version
> */
> >
> > +int stmmac_reset(struct stmmac_priv *priv, void *ioaddr);
> 
> sparse reports missing annotation, I think it's this line.
> It should have a __iomem tag. Try building with C=1 Also please take a look at:

Tried to rebuild with C=1 but didn't reproduce the missing annotation issue. However, the __iomem
should be added here.

Thanks,
Shenwei

> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ker
> nel.org%2Fdoc%2Fhtml%2Fnext%2Fprocess%2Fmaintainer-
> netdev.html&data=05%7C01%7Cshenwei.wang%40nxp.com%7Cb0c66303819f4
> c5c2eec08db326db89d%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7
> C638159219052564995%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwM
> DAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C
> &sdata=0j58wSNzzTirX%2FqaJKPxYEDZn6ezs7qC39trHa72YRA%3D&reserved=0
> 
> >  int stmmac_hwif_init(struct stmmac_priv *priv);
>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.c b/drivers/net/ethernet/stmicro/stmmac/hwif.c
index bb7114f970f8..0eefa697ffe8 100644
--- a/drivers/net/ethernet/stmicro/stmmac/hwif.c
+++ b/drivers/net/ethernet/stmicro/stmmac/hwif.c
@@ -87,6 +87,16 @@  static int stmmac_dwxlgmac_quirks(struct stmmac_priv *priv)
 	return 0;
 }

+int stmmac_reset(struct stmmac_priv *priv, void __iomem *ioaddr)
+{
+	struct plat_stmmacenet_data *plat = priv ? priv->plat : NULL;
+
+	if (plat && plat->fix_soc_reset)
+		return plat->fix_soc_reset(plat, ioaddr);
+
+	return stmmac_do_callback(priv, dma, reset, ioaddr);
+}
+
 static const struct stmmac_hwif_entry {
 	bool gmac;
 	bool gmac4;
diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
index 16a7421715cb..47a68f506c10 100644
--- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
+++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
@@ -214,8 +214,6 @@  struct stmmac_dma_ops {
 	int (*enable_tbs)(void __iomem *ioaddr, bool en, u32 chan);
 };

-#define stmmac_reset(__priv, __args...) \
-	stmmac_do_callback(__priv, dma, reset, __args)
 #define stmmac_dma_init(__priv, __args...) \
 	stmmac_do_void_callback(__priv, dma, init, __args)
 #define stmmac_init_chan(__priv, __args...) \
@@ -640,6 +638,7 @@  extern const struct stmmac_mmc_ops dwxgmac_mmc_ops;
 #define GMAC_VERSION		0x00000020	/* GMAC CORE Version */
 #define GMAC4_VERSION		0x00000110	/* GMAC4+ CORE Version */

+int stmmac_reset(struct stmmac_priv *priv, void *ioaddr);
 int stmmac_hwif_init(struct stmmac_priv *priv);

 #endif /* __STMMAC_HWIF_H__ */
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index a152678b82b7..9044477fad61 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -223,6 +223,7 @@  struct plat_stmmacenet_data {
 	struct stmmac_rxq_cfg rx_queues_cfg[MTL_MAX_RX_QUEUES];
 	struct stmmac_txq_cfg tx_queues_cfg[MTL_MAX_TX_QUEUES];
 	void (*fix_mac_speed)(void *priv, unsigned int speed);
+	int (*fix_soc_reset)(void *priv, void __iomem *ioaddr);
 	int (*serdes_powerup)(struct net_device *ndev, void *priv);
 	void (*serdes_powerdown)(struct net_device *ndev, void *priv);
 	void (*speed_mode_2500)(struct net_device *ndev, void *priv);