From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Christian Marangi <ansuelsmth@gmail.com>
Cc: 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>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
Philipp Zabel <p.zabel@pengutronix.de>,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
Bill Wendling <morbo@google.com>,
Justin Stitt <justinstitt@google.com>,
Daniel Golle <daniel@makrotopia.org>,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, llvm@lists.linux.dev
Subject: Re: [net-next PATCH v4 11/11] net: airoha: add phylink support for GDM2/3/4
Date: Mon, 12 May 2025 14:53:18 +0200 [thread overview]
Message-ID: <aCHvPoZDGUrCVif1@lore-desk> (raw)
In-Reply-To: <6821bef5.5d0a0220.319347.d533@mx.google.com>
[-- Attachment #1: Type: text/plain, Size: 5881 bytes --]
[...]
> >
> > I guess you can use devm_kcalloc() and get rid of kfree() here.
> >
>
> I forgot to answer to this in the previous revision. No devm can't be
> used there available_pcs is just an array allocated for phylink_config.
>
> Phylink then copy the data in it and doesn't use it anymore hence it
> just needs to be allocated here and doesn't need to stay till the driver
> gets removed.
I guess this is exactly the point. Since available_pcs is used just here and
this is not a hot-path, I think the code would be simpler, but I do not have
a strong opinion about it.
>
> > > + if (!available_pcs)
> > > + return -ENOMEM;
> > > +
> > > + err = fwnode_phylink_pcs_parse(dev_fwnode(&dev->dev), available_pcs,
> > > + &num_pcs);
> > > + if (err)
> > > + goto out;
> > > +
> > > + port->phylink_config.available_pcs = available_pcs;
> > > + port->phylink_config.num_available_pcs = num_pcs;
> > > +
> > > + __set_bit(PHY_INTERFACE_MODE_SGMII,
> > > + port->phylink_config.supported_interfaces);
> > > + __set_bit(PHY_INTERFACE_MODE_1000BASEX,
> > > + port->phylink_config.supported_interfaces);
> > > + __set_bit(PHY_INTERFACE_MODE_2500BASEX,
> > > + port->phylink_config.supported_interfaces);
> > > + __set_bit(PHY_INTERFACE_MODE_USXGMII,
> > > + port->phylink_config.supported_interfaces);
> > > +
> > > + phy_interface_copy(port->phylink_config.pcs_interfaces,
> > > + port->phylink_config.supported_interfaces);
> > > +
> > > + phylink = phylink_create(&port->phylink_config,
> > > + of_fwnode_handle(np),
> > > + phy_mode, &airoha_phylink_ops);
> > > + if (IS_ERR(phylink)) {
> > > + err = PTR_ERR(phylink);
> > > + goto out;
> > > + }
> > > +
> > > + port->phylink = phylink;
> > > +out:
> > > + kfree(available_pcs);
> > > +
> > > + return err;
> > > +}
> > > +
> > > static int airoha_alloc_gdm_port(struct airoha_eth *eth,
> > > struct device_node *np, int index)
> > > {
> > > @@ -2873,7 +3004,23 @@ static int airoha_alloc_gdm_port(struct airoha_eth *eth,
> > > if (err)
> > > return err;
> > >
> > > - return register_netdev(dev);
> > > + if (airhoa_is_phy_external(port)) {
> > > + err = airoha_setup_phylink(dev);
> >
> > This will re-introduce the issue reported here:
> > https://lore.kernel.org/netdev/5c94b9b3850f7f29ed653e2205325620df28c3ff.1746715755.git.christophe.jaillet@wanadoo.fr/
> >
>
> I'm confused about this. The suggestion wasn't that register_netdev
> might fail and I need to destroy phylink? Or the linked patch was merged
> and I need to rebase on top of net-next?
what I mean here is if register_netdev() or airoha_setup_phylink() fails, we
should free metadata_dst running airoha_metadata_dst_free() as pointed out by
Christophe. I think this path depends on Christophe's one.
Regards,
Lorenzo
>
> I didn't include that change to not cause conflicts but once it's merged
> I will rebase and include that fix.
>
> > > + if (err)
> > > + return err;
> > > + }
> > > +
> > > + err = register_netdev(dev);
> > > + if (err)
> > > + goto free_phylink;
> > > +
> > > + return 0;
> > > +
> > > +free_phylink:
> > > + if (airhoa_is_phy_external(port))
> > > + phylink_destroy(port->phylink);
> > > +
> > > + return err;
> > > }
> > >
> > > static int airoha_probe(struct platform_device *pdev)
> > > @@ -2967,6 +3114,9 @@ static int airoha_probe(struct platform_device *pdev)
> > > struct airoha_gdm_port *port = eth->ports[i];
> > >
> > > if (port && port->dev->reg_state == NETREG_REGISTERED) {
> > > + if (airhoa_is_phy_external(port))
> > > + phylink_destroy(port->phylink);
> > > +
> > > unregister_netdev(port->dev);
> > > airoha_metadata_dst_free(port);
> > > }
> > > @@ -2994,6 +3144,9 @@ static void airoha_remove(struct platform_device *pdev)
> > > continue;
> > >
> > > airoha_dev_stop(port->dev);
> > > + if (airhoa_is_phy_external(port))
> > > + phylink_destroy(port->phylink);
> > > +
> > > unregister_netdev(port->dev);
> > > airoha_metadata_dst_free(port);
> > > }
> > > diff --git a/drivers/net/ethernet/airoha/airoha_eth.h b/drivers/net/ethernet/airoha/airoha_eth.h
> > > index 53f39083a8b0..73a500474076 100644
> > > --- a/drivers/net/ethernet/airoha/airoha_eth.h
> > > +++ b/drivers/net/ethernet/airoha/airoha_eth.h
> > > @@ -498,6 +498,9 @@ struct airoha_gdm_port {
> > > struct net_device *dev;
> > > int id;
> > >
> > > + struct phylink *phylink;
> > > + struct phylink_config phylink_config;
> > > +
> > > struct airoha_hw_stats stats;
> > >
> > > DECLARE_BITMAP(qos_sq_bmap, AIROHA_NUM_QOS_CHANNELS);
> > > diff --git a/drivers/net/ethernet/airoha/airoha_regs.h b/drivers/net/ethernet/airoha/airoha_regs.h
> > > index d931530fc96f..54f7079b28b0 100644
> > > --- a/drivers/net/ethernet/airoha/airoha_regs.h
> > > +++ b/drivers/net/ethernet/airoha/airoha_regs.h
> > > @@ -357,6 +357,18 @@
> > > #define IP_FRAGMENT_PORT_MASK GENMASK(8, 5)
> > > #define IP_FRAGMENT_NBQ_MASK GENMASK(4, 0)
> > >
> > > +#define REG_GDMA4_TMBI_FRAG 0x2028
> > > +#define GDMA4_SGMII1_TX_WEIGHT_MASK GENMASK(31, 26)
> > > +#define GDMA4_SGMII1_TX_FRAG_SIZE_MASK GENMASK(25, 16)
> > > +#define GDMA4_SGMII0_TX_WEIGHT_MASK GENMASK(15, 10)
> > > +#define GDMA4_SGMII0_TX_FRAG_SIZE_MASK GENMASK(9, 0)
> > > +
> > > +#define REG_GDMA4_RMBI_FRAG 0x202c
> > > +#define GDMA4_SGMII1_RX_WEIGHT_MASK GENMASK(31, 26)
> > > +#define GDMA4_SGMII1_RX_FRAG_SIZE_MASK GENMASK(25, 16)
> > > +#define GDMA4_SGMII0_RX_WEIGHT_MASK GENMASK(15, 10)
> > > +#define GDMA4_SGMII0_RX_FRAG_SIZE_MASK GENMASK(9, 0)
> > > +
> > > #define REG_MC_VLAN_EN 0x2100
> > > #define MC_VLAN_EN_MASK BIT(0)
> > >
> > > --
> > > 2.48.1
> > >
>
>
>
> --
> Ansuel
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2025-05-12 13:28 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-11 20:12 [net-next PATCH v4 00/11] net: pcs: Introduce support for fwnode PCS Christian Marangi
2025-05-11 20:12 ` [net-next PATCH v4 01/11] net: phy: introduce phy_interface_copy helper Christian Marangi
2025-05-13 18:18 ` Sean Anderson
2025-05-11 20:12 ` [net-next PATCH v4 02/11] net: phylink: keep and use MAC supported_interfaces in phylink struct Christian Marangi
2025-05-11 20:12 ` [net-next PATCH v4 03/11] net: phylink: introduce internal phylink PCS handling Christian Marangi
2025-05-13 18:18 ` Sean Anderson
2025-05-13 19:03 ` Daniel Golle
2025-05-13 19:23 ` Sean Anderson
2025-05-13 19:42 ` Sean Anderson
2025-05-14 3:00 ` Daniel Golle
2025-05-19 18:10 ` Sean Anderson
2025-05-19 23:28 ` Sean Anderson
2025-05-11 20:12 ` [net-next PATCH v4 04/11] net: phylink: add phylink_release_pcs() to externally release a PCS Christian Marangi
2025-05-11 20:12 ` [net-next PATCH v4 05/11] net: pcs: implement Firmware node support for PCS driver Christian Marangi
2025-05-13 18:40 ` Sean Anderson
2025-05-11 20:12 ` [net-next PATCH v4 06/11] net: phylink: support late PCS provider attach Christian Marangi
2025-05-11 20:12 ` [net-next PATCH v4 07/11] dt-bindings: net: ethernet-controller: permit to define multiple PCS Christian Marangi
2025-05-13 18:16 ` Sean Anderson
2025-05-14 21:32 ` Rob Herring
2025-05-11 20:12 ` [net-next PATCH v4 08/11] net: phylink: add .pcs_link_down PCS OP Christian Marangi
2025-05-13 18:44 ` Sean Anderson
2025-05-11 20:12 ` [net-next PATCH v4 09/11] dt-bindings: net: pcs: Document support for Airoha Ethernet PCS Christian Marangi
2025-05-13 18:25 ` Sean Anderson
2025-05-11 20:12 ` [net-next PATCH v4 10/11] net: pcs: airoha: add PCS driver for Airoha SoC Christian Marangi
2025-05-13 4:04 ` kernel test robot
2025-05-11 20:12 ` [net-next PATCH v4 11/11] net: airoha: add phylink support for GDM2/3/4 Christian Marangi
2025-05-12 9:21 ` Lorenzo Bianconi
2025-05-12 9:27 ` Christian Marangi
2025-05-12 12:53 ` Lorenzo Bianconi [this message]
2025-05-13 18:50 ` Sean Anderson
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=aCHvPoZDGUrCVif1@lore-desk \
--to=lorenzo@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=ansuelsmth@gmail.com \
--cc=conor+dt@kernel.org \
--cc=daniel@makrotopia.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=justinstitt@google.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux@armlinux.org.uk \
--cc=llvm@lists.linux.dev \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=p.zabel@pengutronix.de \
--cc=pabeni@redhat.com \
--cc=robh@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.