[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZvWsUxyBoiHws1TE@x1>
Date: Thu, 26 Sep 2024 11:47:47 -0700
From: Drew Fustini <dfustini@...storrent.com>
To: Andrew Lunn <andrew@...n.ch>
Cc: "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
Alexandre Torgue <alexandre.torgue@...s.st.com>,
Giuseppe Cavallaro <peppe.cavallaro@...com>,
Jose Abreu <joabreu@...opsys.com>,
Jisheng Zhang <jszhang@...nel.org>,
Maxime Coquelin <mcoquelin.stm32@...il.com>,
Emil Renner Berthing <emil.renner.berthing@...onical.com>,
Drew Fustini <drew@...7.com>, Guo Ren <guoren@...nel.org>,
Fu Wei <wefu@...hat.com>, Conor Dooley <conor@...nel.org>,
Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>,
Albert Ou <aou@...s.berkeley.edu>, netdev@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-stm32@...md-mailman.stormreply.com,
linux-arm-kernel@...ts.infradead.org,
linux-riscv@...ts.infradead.org
Subject: Re: [PATCH v2 2/3] net: stmmac: Add glue layer for T-HEAD TH1520 SoC
On Thu, Sep 26, 2024 at 08:32:00PM +0200, Andrew Lunn wrote:
> > +static int thead_dwmac_init(struct platform_device *pdev, void *priv)
> > +{
> > + struct thead_dwmac *dwmac = priv;
> > + int ret;
> > +
> > + ret = thead_dwmac_set_phy_if(dwmac->plat);
> > + if (ret)
> > + return ret;
> > +
> > + ret = thead_dwmac_set_txclk_dir(dwmac->plat);
> > + if (ret)
> > + return ret;
> > +
> > + ret = regmap_write(dwmac->apb_regmap, GMAC_RXCLK_DELAY_CTRL,
> > + GMAC_RXCLK_DELAY_VAL(dwmac->rx_delay));
> > + if (ret)
> > + return dev_err_probe(dwmac->dev, ret,
> > + "failed to set GMAC RX clock delay\n");
> > +
> > + ret = regmap_write(dwmac->apb_regmap, GMAC_TXCLK_DELAY_CTRL,
> > + GMAC_TXCLK_DELAY_VAL(dwmac->tx_delay));
> > + if (ret)
> > + return dev_err_probe(dwmac->dev, ret,
> > + "failed to set GMAC TX clock delay\n");
> > +
> > + thead_dwmac_fix_speed(dwmac, SPEED_1000, 0);
>
> Is this needed? I would expect this to be called when the PHY has link
> and you know the link speed. So why set it here?
Good point. I've removed this line and the probe still completes okay
and the Ethernet connection is working okay.
> > +
> > + return thead_dwmac_enable_clk(dwmac->plat);
> > +}
> > +
> > +static int thead_dwmac_probe(struct platform_device *pdev)
> > +{
> > + struct device_node *np = pdev->dev.of_node;
> > + struct stmmac_resources stmmac_res;
> > + struct plat_stmmacenet_data *plat;
> > + struct thead_dwmac *dwmac;
> > + void __iomem *apb;
> > + u32 delay;
> > + int ret;
> > +
> > + ret = stmmac_get_platform_resources(pdev, &stmmac_res);
> > + if (ret)
> > + return dev_err_probe(&pdev->dev, ret,
> > + "failed to get resources\n");
> > +
> > + plat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
> > + if (IS_ERR(plat))
> > + return dev_err_probe(&pdev->dev, PTR_ERR(plat),
> > + "dt configuration failed\n");
> > +
> > + dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
> > + if (!dwmac)
> > + return -ENOMEM;
> > +
> > + /* hardware default is 0 for the rx and tx internal clock delay */
> > + dwmac->rx_delay = 0;
> > + dwmac->tx_delay = 0;
> > +
> > + /* rx and tx internal delay properties are optional */
> > + if (!of_property_read_u32(np, "thead,rx-internal-delay", &delay)) {
> > + if (delay > GMAC_RXCLK_DELAY_MASK)
> > + dev_warn(&pdev->dev,
> > + "thead,rx-internal-delay (%u) exceeds max (%lu)\n",
> > + delay, GMAC_RXCLK_DELAY_MASK);
> > + else
> > + dwmac->rx_delay = delay;
> > + }
> > +
>
> So you keep going, with an invalid value? It is better to use
> dev_err() and return -EINVAL. The DT write will then correct their
> error when the device fails to probe.
My intention was to keep the default of 0 if the dt property exists and
exceeds the max value. I had considered failing the probe but I wasn't
sure that was too severe of a reaction to a bad value for the delay.
>
> If you decide to keep this... I'm not sure these properties are
> needed.
Given your reply to the cover letter, I think it does make sense for me
to remove handling of these delay properties since the units of the
delay bit field are unknown and the hardware I have is okay with the
default delay.
>
> > +MODULE_AUTHOR("Jisheng Zhang <jszhang@...nel.org>");
>
> Please add a second author, if you have taken over this driver.
Yes, Jisheng is no longer working on it, so I will add myself.
Thanks,
Drew
Powered by blists - more mailing lists