From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72A93C433B4 for ; Wed, 31 Mar 2021 16:07:02 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D76A96100A for ; Wed, 31 Mar 2021 16:07:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D76A96100A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4F9WR83jqGz3bnr for ; Thu, 1 Apr 2021 03:07:00 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=VE6FDj6N; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::32e; helo=mail-ot1-x32e.google.com; envelope-from=tmaimon77@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=VE6FDj6N; dkim-atps=neutral Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4F9WQh6jQfz2yRF for ; Thu, 1 Apr 2021 03:06:35 +1100 (AEDT) Received: by mail-ot1-x32e.google.com with SMTP id 91-20020a9d08640000b0290237d9c40382so19409984oty.12 for ; Wed, 31 Mar 2021 09:06:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=krFY72HjGOlAMWSoGc1ZqjvWty+ZQ/wgAi03WDQ54sM=; b=VE6FDj6Nos0e5ipfyWUkgOcaW/iFGrP511sdp4RrMuvSsyDufHbdaJRe9aWTVFFxE+ f47elu4wAIzhaF5v46aBY/9j2jGCB6Xn/AVsauMkQzWm9SmOBf3K1qCDhQktpzLGTAEt +r/3F407hQBrDI2ImF0it/iFF5MKYc0ZszXrUUe/LgULajjtyFxkHYXGcUp4pPY1jncG Sp+ylgkndIAH2q0lM+5B2Dg9u5RyF5Qmi+kcV2HLW0wqODnIELRw/3KcuwDDcJCewFtg 7W/DWNREeAfqly2kGGuePMVNLkFAxfAlAiam70KsGMaygMrjSvsDBMhbjhQsf6Hf+aIz P4wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=krFY72HjGOlAMWSoGc1ZqjvWty+ZQ/wgAi03WDQ54sM=; b=Y+vbrQRF5xTBW8i8bnUne09ytS+KAzOT5KBAD7W0rNIboTE7bu9bli3iODK3m1xHJS zY7McHCqNPd7hGoqj+YFLJTz0hUXjs2tzBJVeCW8ICCyKYE61BCa/KRaMkjIhpnjfa5Q n+HMYKMVFFtnVV7apzEpyoWiMtFjFxRe1DsuPsFZbWFqBMN+Bd5vSZPQzc/Kl2b7pBUz 86JDS8+wJ2OK2PuJ3EJGlDrjTI2WeZpSqY8jnXQ+3muD8SpNwchs1Lexfdk4p1wDG0+E FZYHGXrLzPXxbhZxX+MKHDewGhSAsCxN1DW2zE7RitJFFOZSNqKZGRiNaUGGlUW2mYtx z5lg== X-Gm-Message-State: AOAM532wgYMsbFefTy+KkB276qzNkrvt7HHEiRSq6LKzLNcav6hv0/I4 NyFFVMuz4VHUhR1geWeeAdKfezf1V4wld9CMA9g= X-Google-Smtp-Source: ABdhPJwVztz3RtiA3OLrzu2ZiV/IEoUwl1HXuCupXdSAXYi4z+6xrPcYhGi1OwAY5aO0gU6z48FrnoRSeUVCV8HhsYU= X-Received: by 2002:a05:6830:1e03:: with SMTP id s3mr3327042otr.321.1617206792574; Wed, 31 Mar 2021 09:06:32 -0700 (PDT) MIME-Version: 1.0 References: <20210327004920.388957-1-wak@google.com> In-Reply-To: From: Tomer Maimon Date: Wed, 31 Mar 2021 19:06:21 +0300 Message-ID: Subject: Re: [[PATCH linux dev-5.10] net: npcm: Support for fixed PHYs To: Joel Stanley Content-Type: multipart/alternative; boundary="00000000000066594005bed74cca" X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Avi Fishman , OpenBMC Maillist , "William A. Kennington III" Errors-To: openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org Sender: "openbmc" --00000000000066594005bed74cca Content-Type: text/plain; charset="UTF-8" Looks fine to me, Reviewed-by : Tomer Maimon cheers, Tomer On Tue, 30 Mar 2021 at 01:37, Joel Stanley wrote: > On Sat, 27 Mar 2021 at 00:49, William A. Kennington III > wrote: > > > > Most of our machines don't have PHYs between the NIC and the BMC over > > their NC-SI port. We don't want to use the kernel NC-SI machinery, but > > we do want phyless support. > > > > Signed-off-by: William A. Kennington III > > This looks fine to me. Tomer, Avi, can I please get a review from > someone at Nuvoton? > > Reviewed-by: Joel Stanley > > It would be great to see this driver submitted upstream too! > > --- > > drivers/net/ethernet/nuvoton/npcm7xx_emc.c | 31 +++++++++++++++++++++- > > 1 file changed, 30 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/net/ethernet/nuvoton/npcm7xx_emc.c > b/drivers/net/ethernet/nuvoton/npcm7xx_emc.c > > index f07449e2f68d..1dc871a72180 100644 > > --- a/drivers/net/ethernet/nuvoton/npcm7xx_emc.c > > +++ b/drivers/net/ethernet/nuvoton/npcm7xx_emc.c > > @@ -26,6 +26,7 @@ > > #include > > #include > > #include > > +#include > > #include > > > > #include > > @@ -242,6 +243,7 @@ struct npcm7xx_ether { > > struct net_device *ndev; > > struct resource *res; > > unsigned int msg_enable; > > + struct device_node *phy_dn; > > struct mii_bus *mii_bus; > > struct phy_device *phy_dev; > > struct napi_struct napi; > > @@ -1774,6 +1776,17 @@ static int npcm7xx_mii_setup(struct net_device > *dev) > > > > pdev = ether->pdev; > > > > + if (ether->phy_dn) { > > + ether->phy_dev = of_phy_connect(dev, ether->phy_dn, > > + &adjust_link, 0, 0); > > + if (!ether->phy_dn) { > > + dev_err(&dev->dev, "could not connect to phy > %pOF\n", > > + ether->phy_dn); > > + return -ENODEV; > > + } > > + return 0; > > + } > > + > > ether->mii_bus = mdiobus_alloc(); > > if (!ether->mii_bus) { > > err = -ENOMEM; > > @@ -2011,6 +2024,15 @@ static int npcm7xx_ether_probe(struct > platform_device *pdev) > > } > > } else { > > ether->use_ncsi = false; > > + > > + ether->phy_dn = of_parse_phandle(np, "phy-handle", 0); > > + if (!ether->phy_dn && of_phy_is_fixed_link(np)) { > > + error = of_phy_register_fixed_link(np); > > + if (error < 0) > > + goto failed_free_napi; > > + ether->phy_dn = of_node_get(np); > > + } > > + > > error = npcm7xx_mii_setup(dev); > > if (error < 0) { > > dev_err(&pdev->dev, "npcm7xx_mii_setup err\n"); > > @@ -2032,6 +2054,9 @@ static int npcm7xx_ether_probe(struct > platform_device *pdev) > > return 0; > > > > failed_free_napi: > > + of_node_put(ether->phy_dn); > > + if (of_phy_is_fixed_link(np)) > > + of_phy_deregister_fixed_link(np); > > netif_napi_del(ðer->napi); > > platform_set_drvdata(pdev, NULL); > > failed_free_io: > > @@ -2048,13 +2073,17 @@ static int npcm7xx_ether_remove(struct > platform_device *pdev) > > { > > struct net_device *dev = platform_get_drvdata(pdev); > > struct npcm7xx_ether *ether = netdev_priv(dev); > > + struct device_node *np = pdev->dev.of_node; > > > > #ifdef CONFIG_DEBUG_FS > > debugfs_remove_recursive(ether->dbgfs_dir); > > #endif > > - > > unregister_netdev(dev); > > > > + of_node_put(ether->phy_dn); > > + if (of_phy_is_fixed_link(np)) > > + of_phy_deregister_fixed_link(np); > > + > > free_irq(ether->txirq, dev); > > free_irq(ether->rxirq, dev); > > > > -- > > 2.31.0.291.g576ba9dcdaf-goog > > > --00000000000066594005bed74cca Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Looks fine to me,
Reviewed-by= =C2=A0: Tomer Maimon <tmaimon77@gmail.com>

cheers,

Tomer

On Tue, 30 Mar 2021 at 01:37, Joel Stanley <<= a href=3D"mailto:joel@jms.id.au">joel@jms.id.au> wrote:
On Sat, 27 Mar 2021 at 00:49= , William A. Kennington III <wak@google.com> wrote:
>
> Most of our machines don't have PHYs between the NIC and the BMC o= ver
> their NC-SI port. We don't want to use the kernel NC-SI machinery,= but
> we do want phyless support.
>
> Signed-off-by: William A. Kennington III <wak@google.com>

This looks fine to me. Tomer, Avi, can I please get a review from
someone at Nuvoton?

Reviewed-by: Joel Stanley <joel@jms.id.au>

It would be great to see this driver submitted upstream too!=C2=A0
> ---
>=C2=A0 drivers/net/ethernet/nuvoton/npcm7xx_emc.c | 31 ++++++++++++++++= +++++-
>=C2=A0 1 file changed, 30 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/nuvoton/npcm7xx_emc.c b/drivers/net/= ethernet/nuvoton/npcm7xx_emc.c
> index f07449e2f68d..1dc871a72180 100644
> --- a/drivers/net/ethernet/nuvoton/npcm7xx_emc.c
> +++ b/drivers/net/ethernet/nuvoton/npcm7xx_emc.c
> @@ -26,6 +26,7 @@
>=C2=A0 #include <linux/of.h>
>=C2=A0 #include <linux/of_net.h>
>=C2=A0 #include <linux/of_device.h>
> +#include <linux/of_mdio.h>
>=C2=A0 #include <linux/dma-mapping.h>
>
>=C2=A0 #include <linux/regmap.h>
> @@ -242,6 +243,7 @@ struct=C2=A0 npcm7xx_ether {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0struct net_device *ndev;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0struct resource *res;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0unsigned int msg_enable;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0struct device_node *phy_dn;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0struct mii_bus *mii_bus;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0struct phy_device *phy_dev;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0struct napi_struct napi;
> @@ -1774,6 +1776,17 @@ static int npcm7xx_mii_setup(struct net_device = *dev)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pdev =3D ether->pdev;
>
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0if (ether->phy_dn) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ether->phy_= dev =3D of_phy_connect(dev, ether->phy_dn,
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&= adjust_link, 0, 0);
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!ether->= ;phy_dn) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0dev_err(&dev->dev, "could not connect to phy %pOF= \n",
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ether->phy_dn);
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0return -ENODEV;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return 0;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0}
> +
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ether->mii_bus =3D mdiobus_alloc()= ;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!ether->mii_bus) {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0err =3D -= ENOMEM;
> @@ -2011,6 +2024,15 @@ static int npcm7xx_ether_probe(struct platform_= device *pdev)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0} else {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ether->= ;use_ncsi =3D false;
> +
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ether->phy_= dn =3D of_parse_phandle(np, "phy-handle", 0);
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!ether->= ;phy_dn && of_phy_is_fixed_link(np)) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0error =3D of_phy_register_fixed_link(np);
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0if (error < 0)
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0goto failed_free_napi;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0ether->phy_dn =3D of_node_get(np);
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
> +
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0error =3D npcm7xx_mii_setup(dev);
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (error < 0) {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0dev_err(&= amp;pdev->dev, "npcm7xx_mii_setup err\n");
> @@ -2032,6 +2054,9 @@ static int npcm7xx_ether_probe(struct platform_d= evice *pdev)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return 0;
>
>=C2=A0 failed_free_napi:
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0of_node_put(ether->phy_dn);
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0if (of_phy_is_fixed_link(np))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0of_phy_deregis= ter_fixed_link(np);
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0netif_napi_del(&ether->napi);<= br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0platform_set_drvdata(pdev, NULL);
>=C2=A0 failed_free_io:
> @@ -2048,13 +2073,17 @@ static int npcm7xx_ether_remove(struct platfor= m_device *pdev)
>=C2=A0 {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0struct net_device *dev =3D platform_g= et_drvdata(pdev);
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0struct npcm7xx_ether *ether =3D netde= v_priv(dev);
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0struct device_node *np =3D pdev->dev.of= _node;
>
>=C2=A0 #ifdef CONFIG_DEBUG_FS
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0debugfs_remove_recursive(ether->db= gfs_dir);
>=C2=A0 #endif
> -
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0unregister_netdev(dev);
>
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0of_node_put(ether->phy_dn);
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0if (of_phy_is_fixed_link(np))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0of_phy_deregis= ter_fixed_link(np);
> +
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0free_irq(ether->txirq, dev);
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0free_irq(ether->rxirq, dev);
>
> --
> 2.31.0.291.g576ba9dcdaf-goog
>
--00000000000066594005bed74cca--