Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2B0E7C433FE for ; Thu, 14 Apr 2022 15:39:34 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2860983D60; Thu, 14 Apr 2022 17:39:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="eeWO7++o"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CAC4583DF7; Thu, 14 Apr 2022 17:39:30 +0200 (CEST) Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5CA9183AD0 for ; Thu, 14 Apr 2022 17:39:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qv1-xf2d.google.com with SMTP id e22so4243989qvf.9 for ; Thu, 14 Apr 2022 08:39:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=juvjY4kamHYqvcKRUrop9soDf+9EyXO0ae4MqiOr0lE=; b=eeWO7++oIy9qU56W4CNdjJdrZMuxbQLxGVh6a1JS9EXPpckQhJLslo/gfjvtM1WbPg Fr8JG+WjJDqV0PP3Dhr9p0NlGjYMDU8XrJm9IIFgzPjeLEYlIWc5fcxFid2jdN9qj585 oWpq1+JaVE7notL9kHvoItpu1hTM35/XKvNBE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=juvjY4kamHYqvcKRUrop9soDf+9EyXO0ae4MqiOr0lE=; b=Hi/0fhCyzLvZNtqXJym2UxXiY/BBCzmF67ipoIfXvBEF4mrYBVliEp+2D8ZvopT1nS O+8srxOTPfAFL3+yCzkkqARKNGAtoO5jcAVJFnCoLVv77DqIyFg1RZDFzmIuwFUHm7zL u2P26EbY+aVxi0WQRRhaqwXm32zXCgLGts5spUpD2VQDgUKuXOWaKMQb5uUpNI9rVzmq K52cJeHz61dDJaizYCA9x4h1XcCp6dIfo8cOM/x3AuY2dXzdCctMSONGWYypVkV8GMNn jTR3GyHjqfTA8IThyBZNZ1edTo2C05DmGl8aZqcTPI1HRvaluwVKt0wJRHjO2Oq8SRDQ z+xQ== X-Gm-Message-State: AOAM5322Li6NQtoZZ/Dcvy8bXF+D8cqt1aBJp0fR8+ta3cr53en6NbPJ cb5qjUB/rnOypyktCYpzwe42oQ== X-Google-Smtp-Source: ABdhPJx0poeN++RcIzDVCiATOaz73hWyjo5/CdiIWWIcJol6z+jpHgiUtG32OqZZSfMMVTbde62vlg== X-Received: by 2002:a05:6214:240c:b0:443:d94f:cc4b with SMTP id fv12-20020a056214240c00b00443d94fcc4bmr3990168qvb.52.1649950766047; Thu, 14 Apr 2022 08:39:26 -0700 (PDT) Received: from bill-the-cat (2603-6081-7b01-cbda-2ef0-5dff-fedb-a8ba.res6.spectrum.com. [2603:6081:7b01:cbda:2ef0:5dff:fedb:a8ba]) by smtp.gmail.com with ESMTPSA id u20-20020a05620a455400b0067ec0628661sm1194048qkp.110.2022.04.14.08.39.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Apr 2022 08:39:25 -0700 (PDT) Date: Thu, 14 Apr 2022 11:39:23 -0400 From: Tom Rini To: Marek =?iso-8859-1?Q?Beh=FAn?= , Simon Glass , q@bill-the-cat Cc: Joe Hershberger , Ramon Fried , u-boot@lists.denx.de, Marek =?iso-8859-1?Q?Beh=FAn?= Subject: Re: [PATCH u-boot-net v4 03/14] net: introduce helpers to get PHY ofnode from MAC Message-ID: <20220414153923.GA14282@bill-the-cat> References: <20220406223308.9833-1-kabel@kernel.org> <20220406223308.9833-4-kabel@kernel.org> <20220413214611.GA2612709@bill-the-cat> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="WT/YhFpXfYWivuXM" Content-Disposition: inline In-Reply-To: <20220413214611.GA2612709@bill-the-cat> X-Clacks-Overhead: GNU Terry Pratchett X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean --WT/YhFpXfYWivuXM Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Apr 13, 2022 at 05:46:11PM -0400, Tom Rini wrote: > On Thu, Apr 07, 2022 at 12:32:57AM +0200, Marek Beh=FAn wrote: >=20 > > From: Marek Beh=FAn > >=20 > > Add helpers ofnode_get_phy_node() and dev_get_phy_node() and use it in > > net/mdio-uclass.c function dm_eth_connect_phy_handle(). Also add > > corresponding UT test. > >=20 > > This is useful because other part's of U-Boot may want to get PHY ofnode > > without connecting a PHY. > >=20 > > Signed-off-by: Marek Beh=FAn > > Reviewed-by: Ramon Fried > > Reviewed-by: Simon Glass > > --- > > arch/sandbox/dts/test.dts | 13 +++++++++++++ > > drivers/core/ofnode.c | 21 +++++++++++++++++++++ > > drivers/core/read.c | 5 +++++ > > include/dm/ofnode.h | 14 ++++++++++++++ > > include/dm/read.h | 19 +++++++++++++++++++ > > net/mdio-uclass.c | 24 ++++++------------------ > > test/dm/ofnode.c | 18 ++++++++++++++++++ > > 7 files changed, 96 insertions(+), 18 deletions(-) > >=20 > > diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts > > index 05c1cd5e1a..e536943503 100644 > > --- a/arch/sandbox/dts/test.dts > > +++ b/arch/sandbox/dts/test.dts > > @@ -530,6 +530,13 @@ > > fake-host-hwaddr =3D [00 00 66 44 22 22]; > > }; > > =20 > > + phy_eth0: phy-test-eth { > > + compatible =3D "sandbox,eth"; > > + reg =3D <0x10007000 0x1000>; > > + fake-host-hwaddr =3D [00 00 66 44 22 77]; > > + phy-handle =3D <ðphy1>; > > + }; > > + > > dsa_eth0: dsa-test-eth { > > compatible =3D "sandbox,eth"; > > reg =3D <0x10006000 0x1000>; > > @@ -1555,6 +1562,12 @@ > > =20 > > mdio: mdio-test { > > compatible =3D "sandbox,mdio"; > > + #address-cells =3D <1>; > > + #size-cells =3D <0>; > > + > > + ethphy1: ethernet-phy@1 { > > + reg =3D <1>; > > + }; > > }; > > =20 > > pm-bus-test { > > diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c > > index 8042847f3c..445b7ad5ad 100644 > > --- a/drivers/core/ofnode.c > > +++ b/drivers/core/ofnode.c > > @@ -1198,3 +1198,24 @@ const char *ofnode_conf_read_str(const char *pro= p_name) > > =20 > > return ofnode_read_string(node, prop_name); > > } > > + > > +ofnode ofnode_get_phy_node(ofnode node) > > +{ > > + /* DT node properties that reference a PHY node */ > > + static const char * const phy_handle_str[] =3D { > > + "phy-handle", "phy", "phy-device", > > + }; > > + struct ofnode_phandle_args args =3D { > > + .node =3D ofnode_null() > > + }; > > + int i; > > + > > + assert(ofnode_valid(node)); > > + > > + for (i =3D 0; i < ARRAY_SIZE(phy_handle_str); i++) > > + if (!ofnode_parse_phandle_with_args(node, phy_handle_str[i], > > + NULL, 0, 0, &args)) > > + break; > > + > > + return args.node; > > +} > > diff --git a/drivers/core/read.c b/drivers/core/read.c > > index 31f9e78a06..7ff100218d 100644 > > --- a/drivers/core/read.c > > +++ b/drivers/core/read.c > > @@ -398,3 +398,8 @@ int dev_decode_display_timing(const struct udevice = *dev, int index, > > { > > return ofnode_decode_display_timing(dev_ofnode(dev), index, config); > > } > > + > > +ofnode dev_get_phy_node(const struct udevice *dev) > > +{ > > + return ofnode_get_phy_node(dev_ofnode(dev)); > > +} > > diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h > > index 744dffe0a2..429aee2812 100644 > > --- a/include/dm/ofnode.h > > +++ b/include/dm/ofnode.h > > @@ -1217,4 +1217,18 @@ int ofnode_conf_read_int(const char *prop_name, = int default_val); > > */ > > const char *ofnode_conf_read_str(const char *prop_name); > > =20 > > +/** > > + * ofnode_get_phy_node() - Get PHY node for a MAC (if not fixed-link) > > + * > > + * This function parses PHY handle from the Ethernet controller's ofno= de > > + * (trying all possible PHY handle property names), and returns the PH= Y ofnode. > > + * > > + * Before this is used, ofnode_phy_is_fixed_link() should be checked f= irst, and > > + * if the result to that is true, this function should not be called. > > + * > > + * @eth_node: ofnode belonging to the Ethernet controller > > + * Return: ofnode of the PHY, if it exists, otherwise an invalid ofnode > > + */ > > +ofnode ofnode_get_phy_node(ofnode eth_node); > > + > > #endif > > diff --git a/include/dm/read.h b/include/dm/read.h > > index 233af3c063..899eb813fd 100644 > > --- a/include/dm/read.h > > +++ b/include/dm/read.h > > @@ -743,6 +743,20 @@ int dev_read_pci_bus_range(const struct udevice *d= ev, struct resource *res); > > int dev_decode_display_timing(const struct udevice *dev, int index, > > struct display_timing *config); > > =20 > > +/** > > + * dev_get_phy_node() - Get PHY node for a MAC (if not fixed-link) > > + * > > + * This function parses PHY handle from the Ethernet controller's ofno= de > > + * (trying all possible PHY handle property names), and returns the PH= Y ofnode. > > + * > > + * Before this is used, ofnode_phy_is_fixed_link() should be checked f= irst, and > > + * if the result to that is true, this function should not be called. > > + * > > + * @dev: device representing the MAC > > + * Return: ofnode of the PHY, if it exists, otherwise an invalid ofnode > > + */ > > +ofnode dev_get_phy_node(const struct udevice *dev); > > + > > #else /* CONFIG_DM_DEV_READ_INLINE is enabled */ > > #include > > =20 > > @@ -1092,6 +1106,11 @@ static inline int dev_decode_display_timing(cons= t struct udevice *dev, > > return ofnode_decode_display_timing(dev_ofnode(dev), index, config); > > } > > =20 > > +static inline ofnode dev_get_phy_node(const struct udevice *dev) > > +{ > > + return ofnode_get_phy_node(dev_ofnode(dev)); > > +} > > + > > #endif /* CONFIG_DM_DEV_READ_INLINE */ > > =20 > > /** > > diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c > > index 649dc60f73..233b70171b 100644 > > --- a/net/mdio-uclass.c > > +++ b/net/mdio-uclass.c > > @@ -20,11 +20,6 @@ static const char * const phy_mode_str[] =3D { > > "phy-mode", "phy-connection-type" > > }; > > =20 > > -/* DT node properties that reference a PHY node */ > > -static const char * const phy_handle_str[] =3D { > > - "phy-handle", "phy", "phy-device" > > -}; > > - > > void dm_mdio_probe_devices(void) > > { > > struct udevice *it; > > @@ -137,23 +132,16 @@ static struct phy_device *dm_eth_connect_phy_hand= le(struct udevice *ethdev, > > u32 phy_addr; > > struct udevice *mdiodev; > > struct phy_device *phy; > > - struct ofnode_phandle_args phandle =3D {.node =3D ofnode_null()}; > > ofnode phynode; > > - int i; > > =20 > > if (CONFIG_IS_ENABLED(PHY_FIXED) && > > ofnode_phy_is_fixed_link(dev_ofnode(ethdev), &phynode)) { > > phy =3D phy_connect(NULL, 0, ethdev, interface); > > - phandle.node =3D phynode; > > goto out; > > } > > =20 > > - for (i =3D 0; i < ARRAY_SIZE(phy_handle_str); i++) > > - if (!dev_read_phandle_with_args(ethdev, phy_handle_str[i], NULL, > > - 0, 0, &phandle)) > > - break; > > - > > - if (!ofnode_valid(phandle.node)) { > > + phynode =3D dev_get_phy_node(ethdev); > > + if (!ofnode_valid(phynode)) { > > dev_dbg(ethdev, "can't find PHY node\n"); > > return NULL; > > } > > @@ -162,16 +150,16 @@ static struct phy_device *dm_eth_connect_phy_hand= le(struct udevice *ethdev, > > * reading 'reg' directly should be fine. This is a PHY node, the > > * address is always size 1 and requires no translation > > */ > > - if (ofnode_read_u32(phandle.node, "reg", &phy_addr)) { > > + if (ofnode_read_u32(phynode, "reg", &phy_addr)) { > > dev_dbg(ethdev, "missing reg property in phy node\n"); > > return NULL; > > } > > =20 > > if (uclass_get_device_by_ofnode(UCLASS_MDIO, > > - ofnode_get_parent(phandle.node), > > + ofnode_get_parent(phynode), > > &mdiodev)) { > > dev_dbg(ethdev, "can't find MDIO bus for node %s\n", > > - ofnode_get_name(ofnode_get_parent(phandle.node))); > > + ofnode_get_name(ofnode_get_parent(phynode))); > > return NULL; > > } > > =20 > > @@ -179,7 +167,7 @@ static struct phy_device *dm_eth_connect_phy_handle= (struct udevice *ethdev, > > =20 > > out: > > if (phy) > > - phy->node =3D phandle.node; > > + phy->node =3D phynode; > > =20 > > return phy; > > } > > diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c > > index dab0480a42..500c63aef5 100644 > > --- a/test/dm/ofnode.c > > +++ b/test/dm/ofnode.c > > @@ -447,3 +447,21 @@ static int dm_test_ofnode_string_err(struct unit_t= est_state *uts) > > return 0; > > } > > DM_TEST(dm_test_ofnode_string_err, UT_TESTF_LIVE_TREE); > > + > > +static int dm_test_ofnode_get_phy(struct unit_test_state *uts) > > +{ > > + ofnode eth_node, phy_node; > > + u32 reg; > > + > > + eth_node =3D ofnode_path("/phy-test-eth"); > > + ut_assert(ofnode_valid(eth_node)); > > + > > + phy_node =3D ofnode_get_phy_node(eth_node); > > + ut_assert(ofnode_valid(phy_node)); > > + > > + reg =3D ofnode_read_u32_default(phy_node, "reg", -1U); > > + ut_asserteq_64(0x1, reg); > > + > > + return 0; > > +} > > +DM_TEST(dm_test_ofnode_get_phy, 0); >=20 > So this patch consistently leads to: > https://source.denx.de/u-boot/u-boot/-/jobs/423690#L222 > on current master. I did have to manually merge a few changes, but I > think I did that correctly. I don't see _why_ this leads to failure. > Simon, any ideas? This is addressed with: https://patchwork.ozlabs.org/project/uboot/patch/20220414153613.3015932-1-t= rini@konsulko.com/ --=20 Tom --WT/YhFpXfYWivuXM Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmJYQCgACgkQFHw5/5Y0 tywQgQwAujbwIl1mK0R1LwXK/5j6p66qmAALtigJkupPVZTsOKGnpXtCDQ6ZLT7t /2Pb2Vyurdrg8OXMvhzom3N8Geby+zf42yfTjmXF/+sUqnYUvU2oS6aQcPITqXTc CztLzGpk6WzFcoWe7Y5zbL4enl1X4JtCjQDdjOfpN9UjLerPbcPtBNeVJ6U5Czx8 ccGpiQgwdi0BP6uOhMeufi9gxz7Otp+A2fPR4wIC+51fYHaeMneXiSASy6z2E2or 7YkU+MkjsfRR5XiaYwIq2xgcy9fOpSLO8Oz8ZhuLlmabMwZgdiXSXtCHlptp6T+U ss8bJ5uetasfmYeAIeZ3CFFRtGyakxf4SsIu9eyf4B/zjRioc8pz49p9jBEZJYqz kRVQCU28SwmL1cY7ISmUB8kgCIeHRBVgkWyqG08YIrPar7hCJc0q0s/l4JWdn1kN y7OlmPWgE69EuzqBdzSY1lgTYofNp7i8FUlB235UtqI8En73LIuDusjEcCnHKNd6 dkgxKCf5 =fwlb -----END PGP SIGNATURE----- --WT/YhFpXfYWivuXM--