Message ID | 20241205072048.1397570-4-jacky_chou@aspeedtech.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | Add Aspeed G7 FTGMAC100 support | expand |
On Thu, Dec 05, 2024 at 03:20:44PM +0800, Jacky Chou wrote: > Toggle the SCU reset before hardware initialization. > > Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com> > --- > drivers/net/ethernet/faraday/ftgmac100.c | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c > index 17ec35e75a65..96c1eee547c4 100644 > --- a/drivers/net/ethernet/faraday/ftgmac100.c > +++ b/drivers/net/ethernet/faraday/ftgmac100.c > @@ -9,6 +9,7 @@ > #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt > > #include <linux/clk.h> > +#include <linux/reset.h> > #include <linux/dma-mapping.h> > #include <linux/etherdevice.h> > #include <linux/ethtool.h> > @@ -98,6 +99,7 @@ struct ftgmac100 { > struct work_struct reset_task; > struct mii_bus *mii_bus; > struct clk *clk; > + struct reset_control *rst; > > /* AST2500/AST2600 RMII ref clock gate */ > struct clk *rclk; > @@ -1979,6 +1981,22 @@ static int ftgmac100_probe(struct platform_device *pdev) > priv->base + FTGMAC100_OFFSET_TM); > } > > + priv->rst = devm_reset_control_get_optional_exclusive(priv->dev, NULL); > + if (IS_ERR(priv->rst)) > + goto err_register_netdev; Hi Jacky, The goto on the line above will result in this function returning err. However, it seems that err is set to 0 here. And perhaps it should be set to PTR_ERR(priv->rst). Flagged by Smatch. > + > + err = reset_control_assert(priv->rst); > + if (err) { > + dev_err(priv->dev, "Failed to reset mac (%d)\n", err); > + goto err_register_netdev; > + } > + usleep_range(10000, 20000); > + err = reset_control_deassert(priv->rst); > + if (err) { > + dev_err(priv->dev, "Failed to deassert mac reset (%d)\n", err); > + goto err_register_netdev; > + } > + > /* Default ring sizes */ > priv->rx_q_entries = priv->new_rx_q_entries = DEF_RX_QUEUE_ENTRIES; > priv->tx_q_entries = priv->new_tx_q_entries = DEF_TX_QUEUE_ENTRIES; > -- > 2.25.1 > >
Hi Smatch Thank you for your reply. > > + struct reset_control *rst; > > > > /* AST2500/AST2600 RMII ref clock gate */ > > struct clk *rclk; > > @@ -1979,6 +1981,22 @@ static int ftgmac100_probe(struct > platform_device *pdev) > > priv->base + FTGMAC100_OFFSET_TM); > > } > > > > + priv->rst = devm_reset_control_get_optional_exclusive(priv->dev, NULL); > > + if (IS_ERR(priv->rst)) > > + goto err_register_netdev; > > Hi Jacky, > > The goto on the line above will result in this function returning err. > However, it seems that err is set to 0 here. > And perhaps it should be set to PTR_ERR(priv->rst). > > Flagged by Smatch. Agree. I will add that err is assigned by PTR_ERR(priv->rst) for error handling in next version. priv->rst = devm_reset_control_get_optional_exclusive(priv->dev, NULL); if (IS_ERR(priv->rst)) { err = PTR_ERR(priv->rst); goto err_register_netdev; } Otherwise, err may be zero when getting an error from devm_reset_control_get_Optional_exclusive(). Thank you for your kind reminder. Thanks, Jacky
diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c index 17ec35e75a65..96c1eee547c4 100644 --- a/drivers/net/ethernet/faraday/ftgmac100.c +++ b/drivers/net/ethernet/faraday/ftgmac100.c @@ -9,6 +9,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/clk.h> +#include <linux/reset.h> #include <linux/dma-mapping.h> #include <linux/etherdevice.h> #include <linux/ethtool.h> @@ -98,6 +99,7 @@ struct ftgmac100 { struct work_struct reset_task; struct mii_bus *mii_bus; struct clk *clk; + struct reset_control *rst; /* AST2500/AST2600 RMII ref clock gate */ struct clk *rclk; @@ -1979,6 +1981,22 @@ static int ftgmac100_probe(struct platform_device *pdev) priv->base + FTGMAC100_OFFSET_TM); } + priv->rst = devm_reset_control_get_optional_exclusive(priv->dev, NULL); + if (IS_ERR(priv->rst)) + goto err_register_netdev; + + err = reset_control_assert(priv->rst); + if (err) { + dev_err(priv->dev, "Failed to reset mac (%d)\n", err); + goto err_register_netdev; + } + usleep_range(10000, 20000); + err = reset_control_deassert(priv->rst); + if (err) { + dev_err(priv->dev, "Failed to deassert mac reset (%d)\n", err); + goto err_register_netdev; + } + /* Default ring sizes */ priv->rx_q_entries = priv->new_rx_q_entries = DEF_RX_QUEUE_ENTRIES; priv->tx_q_entries = priv->new_tx_q_entries = DEF_TX_QUEUE_ENTRIES;
Toggle the SCU reset before hardware initialization. Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com> --- drivers/net/ethernet/faraday/ftgmac100.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)