linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Daniel Golle <daniel@makrotopia.org>
Cc: Felix Fietkau <nbd@nbd.name>, John Crispin <john@phrozen.org>,
	Sean Wang <sean.wang@mediatek.com>,
	Mark Lee <Mark-MC.Lee@mediatek.com>,
	Lorenzo Bianconi <lorenzo@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org
Subject: Re: [PATCH net] net: ethernet: mtk_eth_soc: add reset bits for MT7988
Date: Sat, 19 Aug 2023 16:41:09 +0200	[thread overview]
Message-ID: <ZODUhbw9SDOifv49@vergenet.net> (raw)
In-Reply-To: <b983a3adf5184a30e4ce620fbbf028c9c76648ae.1692382239.git.daniel@makrotopia.org>

On Fri, Aug 18, 2023 at 07:15:24PM +0100, Daniel Golle wrote:
> Add bits needed to reset the frame engine on MT7988.
> 
> Fixes: 445eb6448ed3 ("net: ethernet: mtk_eth_soc: add basic support for MT7988 SoC")
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> ---
>  drivers/net/ethernet/mediatek/mtk_eth_soc.c | 76 +++++++++++++++------
>  drivers/net/ethernet/mediatek/mtk_eth_soc.h | 11 ++-
>  2 files changed, 64 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> index fe05c90202699..2482f47313085 100644
> --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> @@ -3613,19 +3613,34 @@ static void mtk_hw_reset(struct mtk_eth *eth)
>  {
>  	u32 val;
>  
> -	if (mtk_is_netsys_v2_or_greater(eth)) {
> +	if (mtk_is_netsys_v2_or_greater(eth))
>  		regmap_write(eth->ethsys, ETHSYS_FE_RST_CHK_IDLE_EN, 0);
> +
> +	if (mtk_is_netsys_v3_or_greater(eth)) {
> +		val = RSTCTRL_PPE0_V3;
> +
> +		if (MTK_HAS_CAPS(eth->soc->caps, MTK_RSTCTRL_PPE1))
> +			val |= RSTCTRL_PPE1_V3;
> +
> +		if (MTK_HAS_CAPS(eth->soc->caps, MTK_RSTCTRL_PPE2))
> +			val |= RSTCTRL_PPE2;
> +
> +		val |= RSTCTRL_WDMA0 | RSTCTRL_WDMA1 | RSTCTRL_WDMA2;
> +	} else if (mtk_is_netsys_v2_or_greater(eth)) {
>  		val = RSTCTRL_PPE0_V2;
> +
> +		if (MTK_HAS_CAPS(eth->soc->caps, MTK_RSTCTRL_PPE1))
> +			val |= RSTCTRL_PPE1;
>  	} else {
>  		val = RSTCTRL_PPE0;
>  	}
>  
> -	if (MTK_HAS_CAPS(eth->soc->caps, MTK_RSTCTRL_PPE1))
> -		val |= RSTCTRL_PPE1;
> -
>  	ethsys_reset(eth, RSTCTRL_ETH | RSTCTRL_FE | val);
>  
> -	if (mtk_is_netsys_v2_or_greater(eth))
> +	if (mtk_is_netsys_v3_or_greater(eth))
> +		regmap_write(eth->ethsys, ETHSYS_FE_RST_CHK_IDLE_EN,
> +			     0x6f8ff);
> +	else if (mtk_is_netsys_v2_or_greater(eth))
>  		regmap_write(eth->ethsys, ETHSYS_FE_RST_CHK_IDLE_EN,
>  			     0x3ffffff);
>  }
> @@ -3651,13 +3666,21 @@ static void mtk_hw_warm_reset(struct mtk_eth *eth)
>  		return;
>  	}
>  
> -	if (mtk_is_netsys_v2_or_greater(eth))
> +	if (mtk_is_netsys_v3_or_greater(eth)) {
> +		rst_mask = RSTCTRL_ETH | RSTCTRL_PPE0_V3;
> +		if (MTK_HAS_CAPS(eth->soc->caps, MTK_RSTCTRL_PPE1))
> +			rst_mask |= RSTCTRL_PPE1_V3;
> +		if (MTK_HAS_CAPS(eth->soc->caps, MTK_RSTCTRL_PPE2))
> +			rst_mask |= RSTCTRL_PPE2;
> +
> +		rst_mask |= RSTCTRL_WDMA0 | RSTCTRL_WDMA1 | RSTCTRL_WDMA2;
> +	} else if (mtk_is_netsys_v2_or_greater(eth)) {
>  		rst_mask = RSTCTRL_ETH | RSTCTRL_PPE0_V2;
> -	else
> +		if (MTK_HAS_CAPS(eth->soc->caps, MTK_RSTCTRL_PPE1))
> +			rst_mask |= RSTCTRL_PPE1;
> +	} else {
>  		rst_mask = RSTCTRL_ETH | RSTCTRL_PPE0;
> -
> -	if (MTK_HAS_CAPS(eth->soc->caps, MTK_RSTCTRL_PPE1))
> -		rst_mask |= RSTCTRL_PPE1;
> +	}
>  
>  	regmap_update_bits(eth->ethsys, ETHSYS_RSTCTRL, rst_mask, rst_mask);
>  

Hi Daniel,

The bits set by the code in the above two hunks seem both complex
and similar. At the risk of suggesting excessive complexity,
I do wonder if they can be consolidated somehow.

Maybe the approach you have taken is best as a fix for net.
But a follow-up could be considered for net-next.
Just an idea.

...


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-08-19 14:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-18 18:15 [PATCH net] net: ethernet: mtk_eth_soc: add reset bits for MT7988 Daniel Golle
2023-08-19 14:41 ` Simon Horman [this message]
2023-08-21 18:38 ` kernel test robot

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=ZODUhbw9SDOifv49@vergenet.net \
    --to=horms@kernel.org \
    --cc=Mark-MC.Lee@mediatek.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=daniel@makrotopia.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=john@phrozen.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=lorenzo@kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=nbd@nbd.name \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sean.wang@mediatek.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;
as well as URLs for NNTP newsgroup(s).