[PATCH] net: stmmac: add support for platform specific config.

Xandy.Xiong posted 1 patch 6 months, 2 weeks ago
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++++
include/linux/stmmac.h                            | 1 +
2 files changed, 5 insertions(+)
[PATCH] net: stmmac: add support for platform specific config.
Posted by Xandy.Xiong 6 months, 2 weeks ago
This patch adds support for platform-specific init config in the
stmmac driver. As SMMU remap, must after dma descriptor setup,
and same mac link caps must init before phy init. To support these feature,
a new function pointer 'fix_mac_config' is added to the
plat_stmmacenet_data structure.
And call the function pointer 'fix_mac_config' in the __stmmac_open().

Signed-off-by: Xandy.Xiong <xiongliang@xiaomi.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++++
 include/linux/stmmac.h                            | 1 +
 2 files changed, 5 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 085c09039af4..8d629a3c2237 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -4041,6 +4041,10 @@ static int __stmmac_open(struct net_device *dev,
 	if (ret < 0)
 		return ret;
 
+	/* Same mac config must before phy init and after stmmac_setup_dma_desc */
+	if (priv->plat->fix_mac_config)
+		priv->plat->fix_mac_config(dev, priv->plat->bsp_priv);
+
 	if ((!priv->hw->xpcs ||
 	     xpcs_get_an_mode(priv->hw->xpcs, mode) != DW_AN_C73)) {
 		ret = stmmac_init_phy(dev);
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index 26ddf95d23f9..0a6021e5b932 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -239,6 +239,7 @@ struct plat_stmmacenet_data {
 			       phy_interface_t interface, int speed);
 	void (*fix_mac_speed)(void *priv, int speed, unsigned int mode);
 	int (*fix_soc_reset)(void *priv, void __iomem *ioaddr);
+	int (*fix_mac_config)(struct net_device *ndev, void *priv);
 	int (*serdes_powerup)(struct net_device *ndev, void *priv);
 	void (*serdes_powerdown)(struct net_device *ndev, void *priv);
 	int (*mac_finish)(struct net_device *ndev,
-- 
2.25.1
Re: [PATCH] net: stmmac: add support for platform specific config.
Posted by Russell King (Oracle) 6 months, 2 weeks ago
On Fri, Jun 06, 2025 at 07:41:55PM +0800, Xandy.Xiong wrote:
> This patch adds support for platform-specific init config in the
> stmmac driver. As SMMU remap, must after dma descriptor setup,
> and same mac link caps must init before phy init. To support these feature,
> a new function pointer 'fix_mac_config' is added to the
> plat_stmmacenet_data structure.
> And call the function pointer 'fix_mac_config' in the __stmmac_open().

We need to see the use case for any new hook.

I'm afraid we've seen way too many cases of new hooks added to the
kernel tree only to never see their corresponding implementations
come along, so now there's a requirement to post an implementation
along with a hook.

Also, please review the netdev FAQ, if you can find it... I can't
anymore. It'll tell you how to submit patches, when to submit them,
how to indicate which tree, etc.

You can find the source file for what I think _was_ the FAQ at:

Documentation/process/maintainer-netdev.rst

but this doesn't seem to be in the documentation tree on kernel.org
(or at least is not in an obvious place.)

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Re: [PATCH] net: stmmac: add support for platform specific config.
Posted by Andrew Lunn 6 months, 2 weeks ago
> Also, please review the netdev FAQ, if you can find it...

https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html

It got renamed, since it is no longer a set of questions and answers.

	Andrew
Re: [PATCH] net: stmmac: add support for platform specific config.
Posted by Simon Horman 6 months, 2 weeks ago
On Fri, Jun 06, 2025 at 07:41:55PM +0800, Xandy.Xiong wrote:
> This patch adds support for platform-specific init config in the
> stmmac driver. As SMMU remap, must after dma descriptor setup,
> and same mac link caps must init before phy init. To support these feature,
> a new function pointer 'fix_mac_config' is added to the
> plat_stmmacenet_data structure.
> And call the function pointer 'fix_mac_config' in the __stmmac_open().
> 
> Signed-off-by: Xandy.Xiong <xiongliang@xiaomi.com>

Hi,

I think that there needs to be an in-tree user of this callback
for it to be added. And that such a user should be included
in the same patch-set that adds the callback.

Moreover...

## Form letter - net-next-closed

The merge window for v6.16 has begun and therefore net-next is closed
for new drivers, features, code refactoring and optimizations. We are
currently accepting bug fixes only.

Please repost when net-next reopens after June 8th.

RFC patches sent for review only are obviously welcome at any time.

-- 
pw-bot: changes-requested