* [PATCH 1/2] net: fec: Don't use disabled phys
@ 2021-04-08 21:10 Sean Anderson
2021-04-08 21:10 ` [PATCH 2/2] net: fec: Only unregister MII bus if we registered it Sean Anderson
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Sean Anderson @ 2021-04-08 21:10 UTC (permalink / raw)
To: u-boot
If a phy is disabled, don't use it. This matches Linux's behavior.
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---
drivers/net/fec_mxc.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index ec21157d71..37eb894248 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -1299,15 +1299,18 @@ static const struct eth_ops fecmxc_ops = {
static int device_get_phy_addr(struct fec_priv *priv, struct udevice *dev)
{
struct ofnode_phandle_args phandle_args;
- int reg;
+ int reg, ret;
- if (dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
- &phandle_args)) {
- debug("Failed to find phy-handle");
- return -ENODEV;
+ ret = dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
+ &phandle_args);
+ if (ret) {
+ debug("Failed to find phy-handle (err = %d\n)");
+ return ret;
}
priv->phy_of_node = phandle_args.node;
+ if (!ofnode_is_available(phandle_args.node))
+ return -ENOENT;
reg = ofnode_read_u32_default(phandle_args.node, "reg", 0);
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] net: fec: Only unregister MII bus if we registered it
2021-04-08 21:10 [PATCH 1/2] net: fec: Don't use disabled phys Sean Anderson
@ 2021-04-08 21:10 ` Sean Anderson
2021-04-12 3:57 ` Ramon Fried
2021-04-12 3:56 ` [PATCH 1/2] net: fec: Don't use disabled phys Ramon Fried
2021-04-15 16:50 ` Sean Anderson
2 siblings, 1 reply; 5+ messages in thread
From: Sean Anderson @ 2021-04-08 21:10 UTC (permalink / raw)
To: u-boot
If we fail to probe for whatever reason, we cannot unregister/free the
MII bus unless we registered it with fec_get_miibus. This fixes FECs
sharing an MDIO bus from destroying it, preventing the other FEC from
using it.
Fixes: 6a895d039b ("net: Update eQos driver and FEC driver to use eth phy interfaces")
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---
drivers/net/fec_mxc.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 37eb894248..a64ba955a5 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -1355,6 +1355,7 @@ static void fec_gpio_reset(struct fec_priv *priv)
static int fecmxc_probe(struct udevice *dev)
{
+ bool dm_mii_bus = true;
struct eth_pdata *pdata = dev_get_plat(dev);
struct fec_priv *priv = dev_get_priv(dev);
struct mii_dev *bus = NULL;
@@ -1462,6 +1463,7 @@ static int fecmxc_probe(struct udevice *dev)
#endif
if (!bus) {
+ dm_mii_bus = false;
#ifdef CONFIG_FEC_MXC_MDIO_BASE
bus = fec_get_miibus((ulong)CONFIG_FEC_MXC_MDIO_BASE,
dev_seq(dev));
@@ -1507,8 +1509,10 @@ static int fecmxc_probe(struct udevice *dev)
return 0;
err_phy:
- mdio_unregister(bus);
- free(bus);
+ if (!dm_mii_bus) {
+ mdio_unregister(bus);
+ free(bus);
+ }
err_mii:
err_timeout:
fec_free_descs(priv);
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 1/2] net: fec: Don't use disabled phys
2021-04-08 21:10 [PATCH 1/2] net: fec: Don't use disabled phys Sean Anderson
2021-04-08 21:10 ` [PATCH 2/2] net: fec: Only unregister MII bus if we registered it Sean Anderson
@ 2021-04-12 3:56 ` Ramon Fried
2021-04-15 16:50 ` Sean Anderson
2 siblings, 0 replies; 5+ messages in thread
From: Ramon Fried @ 2021-04-12 3:56 UTC (permalink / raw)
To: u-boot
On Fri, Apr 9, 2021 at 12:10 AM Sean Anderson <sean.anderson@seco.com> wrote:
>
> If a phy is disabled, don't use it. This matches Linux's behavior.
>
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>
> ---
>
> drivers/net/fec_mxc.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
> index ec21157d71..37eb894248 100644
> --- a/drivers/net/fec_mxc.c
> +++ b/drivers/net/fec_mxc.c
> @@ -1299,15 +1299,18 @@ static const struct eth_ops fecmxc_ops = {
> static int device_get_phy_addr(struct fec_priv *priv, struct udevice *dev)
> {
> struct ofnode_phandle_args phandle_args;
> - int reg;
> + int reg, ret;
>
> - if (dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
> - &phandle_args)) {
> - debug("Failed to find phy-handle");
> - return -ENODEV;
> + ret = dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
> + &phandle_args);
> + if (ret) {
> + debug("Failed to find phy-handle (err = %d\n)");
> + return ret;
> }
>
> priv->phy_of_node = phandle_args.node;
> + if (!ofnode_is_available(phandle_args.node))
> + return -ENOENT;
>
> reg = ofnode_read_u32_default(phandle_args.node, "reg", 0);
>
> --
> 2.25.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] net: fec: Only unregister MII bus if we registered it
2021-04-08 21:10 ` [PATCH 2/2] net: fec: Only unregister MII bus if we registered it Sean Anderson
@ 2021-04-12 3:57 ` Ramon Fried
0 siblings, 0 replies; 5+ messages in thread
From: Ramon Fried @ 2021-04-12 3:57 UTC (permalink / raw)
To: u-boot
On Fri, Apr 9, 2021 at 12:10 AM Sean Anderson <sean.anderson@seco.com> wrote:
>
> If we fail to probe for whatever reason, we cannot unregister/free the
> MII bus unless we registered it with fec_get_miibus. This fixes FECs
> sharing an MDIO bus from destroying it, preventing the other FEC from
> using it.
>
> Fixes: 6a895d039b ("net: Update eQos driver and FEC driver to use eth phy interfaces")
>
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>
> ---
>
> drivers/net/fec_mxc.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
> index 37eb894248..a64ba955a5 100644
> --- a/drivers/net/fec_mxc.c
> +++ b/drivers/net/fec_mxc.c
> @@ -1355,6 +1355,7 @@ static void fec_gpio_reset(struct fec_priv *priv)
>
> static int fecmxc_probe(struct udevice *dev)
> {
> + bool dm_mii_bus = true;
> struct eth_pdata *pdata = dev_get_plat(dev);
> struct fec_priv *priv = dev_get_priv(dev);
> struct mii_dev *bus = NULL;
> @@ -1462,6 +1463,7 @@ static int fecmxc_probe(struct udevice *dev)
> #endif
>
> if (!bus) {
> + dm_mii_bus = false;
> #ifdef CONFIG_FEC_MXC_MDIO_BASE
> bus = fec_get_miibus((ulong)CONFIG_FEC_MXC_MDIO_BASE,
> dev_seq(dev));
> @@ -1507,8 +1509,10 @@ static int fecmxc_probe(struct udevice *dev)
> return 0;
>
> err_phy:
> - mdio_unregister(bus);
> - free(bus);
> + if (!dm_mii_bus) {
> + mdio_unregister(bus);
> + free(bus);
> + }
> err_mii:
> err_timeout:
> fec_free_descs(priv);
> --
> 2.25.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] net: fec: Don't use disabled phys
2021-04-08 21:10 [PATCH 1/2] net: fec: Don't use disabled phys Sean Anderson
2021-04-08 21:10 ` [PATCH 2/2] net: fec: Only unregister MII bus if we registered it Sean Anderson
2021-04-12 3:56 ` [PATCH 1/2] net: fec: Don't use disabled phys Ramon Fried
@ 2021-04-15 16:50 ` Sean Anderson
2 siblings, 0 replies; 5+ messages in thread
From: Sean Anderson @ 2021-04-15 16:50 UTC (permalink / raw)
To: u-boot
On 4/8/21 5:10 PM, Sean Anderson wrote:
> If a phy is disabled, don't use it. This matches Linux's behavior.
>
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>
> ---
>
> drivers/net/fec_mxc.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
> index ec21157d71..37eb894248 100644
> --- a/drivers/net/fec_mxc.c
> +++ b/drivers/net/fec_mxc.c
> @@ -1299,15 +1299,18 @@ static const struct eth_ops fecmxc_ops = {
> static int device_get_phy_addr(struct fec_priv *priv, struct udevice *dev)
> {
> struct ofnode_phandle_args phandle_args;
> - int reg;
> + int reg, ret;
>
> - if (dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
> - &phandle_args)) {
> - debug("Failed to find phy-handle");
> - return -ENODEV;
> + ret = dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
> + &phandle_args);
> + if (ret) {
> + debug("Failed to find phy-handle (err = %d\n)");
This is missing the ret parameter; will send a v2.
--Sean
> + return ret;
> }
>
> priv->phy_of_node = phandle_args.node;
> + if (!ofnode_is_available(phandle_args.node))
> + return -ENOENT;
>
> reg = ofnode_read_u32_default(phandle_args.node, "reg", 0);
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-04-15 16:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-08 21:10 [PATCH 1/2] net: fec: Don't use disabled phys Sean Anderson
2021-04-08 21:10 ` [PATCH 2/2] net: fec: Only unregister MII bus if we registered it Sean Anderson
2021-04-12 3:57 ` Ramon Fried
2021-04-12 3:56 ` [PATCH 1/2] net: fec: Don't use disabled phys Ramon Fried
2021-04-15 16:50 ` Sean Anderson
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.