mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Biao Huang <biao.huang@mediatek.com>
To: Matthias Brugger <matthias.bgg@gmail.com>,
	David Miller <davem@davemloft.net>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Jose Abreu <joabreu@synopsys.com>,
	"Eric Dumazet" <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	AngeloGioacchino Del Regno 
	<angelogioacchino.delregno@collabora.com>,
	<netdev@vger.kernel.org>,
	<linux-stm32@st-md-mailman.stormreply.com>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>,
	<linux-mediatek@lists.infradead.org>, <macpaul.lin@mediatek.com>,
	Jisheng Zhang <jszhang@kernel.org>,
	Mohammad Athari Bin Ismail <mohammad.athari.ismail@intel.com>
Subject: Re: [PATCH net v4 1/3] stmmac: dwmac-mediatek: fix clock issue
Date: Thu, 14 Jul 2022 09:18:54 +0800	[thread overview]
Message-ID: <1d30edbe1761bea511f6619d934e550e05ac4f7a.camel@mediatek.com> (raw)
In-Reply-To: <c8fdfa7b-f4eb-8308-4064-b868ce945e3a@gmail.com>

Dear Matthias,
	Thanks for your comments~

On Wed, 2022-07-13 at 14:11 +0200, Matthias Brugger wrote:
> 
> On 13/07/2022 12:10, Biao Huang wrote:
> > The pm_runtime takes care of the clock handling in current
> > stmmac drivers, and dwmac-mediatek implement the
> > mediatek_dwmac_clks_config() as the callback for pm_runtime.
> > 
> > Then, stripping duplicated clocks handling in old init()/exit()
> > to fix clock issue in suspend/resume test.
> > 
> > As to clocks in probe/remove, vendor need symmetric handling to
> > ensure clocks balance.
> > 
> > Test pass, including suspend/resume and ko insertion/remove.
> > 
> > Fixes: 3186bdad97d5 ("stmmac: dwmac-mediatek: add platform level
> > clocks management")
> > Signed-off-by: Biao Huang <biao.huang@mediatek.com>
> > ---
> >   .../ethernet/stmicro/stmmac/dwmac-mediatek.c  | 49 ++++++++----
> > -------
> >   1 file changed, 21 insertions(+), 28 deletions(-)
> > 
> > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
> > b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
> > index 6ff88df58767..ca8ab290013c 100644
> > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
> > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
> > @@ -576,32 +576,7 @@ static int mediatek_dwmac_init(struct
> > platform_device *pdev, void *priv)
> >   		}
> >   	}
> >   
> > -	ret = clk_bulk_prepare_enable(variant->num_clks, plat->clks);
> > -	if (ret) {
> > -		dev_err(plat->dev, "failed to enable clks, err = %d\n",
> > ret);
> > -		return ret;
> > -	}
> > -
> > -	ret = clk_prepare_enable(plat->rmii_internal_clk);
> > -	if (ret) {
> > -		dev_err(plat->dev, "failed to enable rmii internal clk,
> > err = %d\n", ret);
> > -		goto err_clk;
> > -	}
> > -
> >   	return 0;
> > -
> > -err_clk:
> > -	clk_bulk_disable_unprepare(variant->num_clks, plat->clks);
> > -	return ret;
> > -}
> > -
> > -static void mediatek_dwmac_exit(struct platform_device *pdev, void
> > *priv)
> > -{
> > -	struct mediatek_dwmac_plat_data *plat = priv;
> > -	const struct mediatek_dwmac_variant *variant = plat->variant;
> > -
> > -	clk_disable_unprepare(plat->rmii_internal_clk);
> > -	clk_bulk_disable_unprepare(variant->num_clks, plat->clks);
> >   }
> >   
> >   static int mediatek_dwmac_clks_config(void *priv, bool enabled)
> > @@ -643,7 +618,6 @@ static int mediatek_dwmac_common_data(struct
> > platform_device *pdev,
> >   	plat->addr64 = priv_plat->variant->dma_bit_mask;
> >   	plat->bsp_priv = priv_plat;
> >   	plat->init = mediatek_dwmac_init;
> > -	plat->exit = mediatek_dwmac_exit;
> >   	plat->clks_config = mediatek_dwmac_clks_config;
> >   	if (priv_plat->variant->dwmac_fix_mac_speed)
> >   		plat->fix_mac_speed = priv_plat->variant-
> > >dwmac_fix_mac_speed;
> > @@ -712,13 +686,32 @@ static int mediatek_dwmac_probe(struct
> > platform_device *pdev)
> >   	mediatek_dwmac_common_data(pdev, plat_dat, priv_plat);
> >   	mediatek_dwmac_init(pdev, priv_plat);
> >   
> > +	ret = mediatek_dwmac_clks_config(priv_plat, true);
> > +	if (ret)
> > +		return ret;
> > +
> >   	ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
> >   	if (ret) {
> >   		stmmac_remove_config_dt(pdev, plat_dat);
> > -		return ret;
> > +		goto err_drv_probe;
> >   	}
> >   
> >   	return 0;
> > +
> > +err_drv_probe:
> > +	mediatek_dwmac_clks_config(priv_plat, false);
> > +	return ret;
> > +}
> > +
> > +static int mediatek_dwmac_remove(struct platform_device *pdev)
> > +{
> > +	struct mediatek_dwmac_plat_data *priv_plat =
> > get_stmmac_bsp_priv(&pdev->dev);
> > +	int ret;
> > +
> > +	ret = stmmac_pltfr_remove(pdev);
> > +	mediatek_dwmac_clks_config(priv_plat, false);
> > +
> 
> We enalbe the clocks after calling stmmac_probe_config_dt(), so we
> should 
> disable them before calling stmmac_pltfr_remove(), correct?
> 
> Other then that:
> Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>

To ensure the hw configuration in stmmac_pltfr_remove behavior
normally, we should disable clocks after stmmac_pltfr_remove.

And there is no order requirement between clocks configured by 
stmmac_probe_config_dt/stmmac_remove_config_dt and clocks
configured by mediatek_dwmac_clks_config, so it's safe for
current snippet.

Best Regards!
Biao

> 
> > +	return ret;
> >   }
> >   
> >   static const struct of_device_id mediatek_dwmac_match[] = {
> > @@ -733,7 +726,7 @@ MODULE_DEVICE_TABLE(of, mediatek_dwmac_match);
> >   
> >   static struct platform_driver mediatek_dwmac_driver = {
> >   	.probe  = mediatek_dwmac_probe,
> > -	.remove = stmmac_pltfr_remove,
> > +	.remove = mediatek_dwmac_remove,
> >   	.driver = {
> >   		.name           = "dwmac-mediatek",
> >   		.pm		= &stmmac_pltfr_pm_ops,


  reply	other threads:[~2022-07-14  1:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-13 10:09 [PATCH net v4 0/3] " Biao Huang
2022-07-13 10:10 ` [PATCH net v4 1/3] " Biao Huang
2022-07-13 12:11   ` Matthias Brugger
2022-07-14  1:18     ` Biao Huang [this message]
2022-07-13 10:10 ` [PATCH net v4 2/3] net: stmmac: fix pm runtime issue in stmmac_dvr_remove() Biao Huang
2022-07-13 10:10 ` [PATCH net v4 3/3] net: stmmac: fix unbalanced ptp clock issue in suspend/resume flow Biao Huang
2022-07-14  3:39   ` Jakub Kicinski
2022-07-14  5:37     ` Biao Huang
2022-07-14 22:40   ` kernel test robot
2022-07-15  7:52     ` Biao Huang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1d30edbe1761bea511f6619d934e550e05ac4f7a.camel@mediatek.com \
    --to=biao.huang@mediatek.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=joabreu@synopsys.com \
    --cc=jszhang@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=macpaul.lin@mediatek.com \
    --cc=matthias.bgg@gmail.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=mohammad.athari.ismail@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=peppe.cavallaro@st.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®