mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Arınç ÜNAL" <arinc.unal@arinc9.com>
To: "Russell King (Oracle)" <linux@armlinux.org.uk>
Cc: Vladimir Oltean <olteanv@gmail.com>,
	Sean Wang <sean.wang@mediatek.com>,
	Landen Chao <Landen.Chao@mediatek.com>,
	DENG Qingfang <dqfext@gmail.com>,
	Daniel Golle <daniel@makrotopia.org>,
	Andrew Lunn <andrew@lunn.ch>,
	Florian Fainelli <f.fainelli@gmail.com>,
	"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>,
	Richard van Schagen <richard@routerhints.com>,
	Richard van Schagen <vschagen@cs.com>,
	Frank Wunderlich <frank-w@public-files.de>,
	Bartel Eerdekens <bartel.eerdekens@constell8.be>,
	erkin.bozoglu@xeront.com, mithat.guner@xeront.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-next 08/30] net: dsa: mt7530: change p{5,6}_interface to p{5,6}_configured
Date: Mon, 5 Jun 2023 17:36:56 +0300	[thread overview]
Message-ID: <e2865f69-3254-4768-7a7a-bb84d76a85eb@arinc9.com> (raw)
In-Reply-To: <ZHyqI2oOI4KkvgB8@shell.armlinux.org.uk>

On 4.06.2023 18:13, Russell King (Oracle) wrote:
> On Sun, Jun 04, 2023 at 04:14:31PM +0300, Arınç ÜNAL wrote:
>> On 4.06.2023 16:07, Russell King (Oracle) wrote:
>>> On Sun, Jun 04, 2023 at 03:55:17PM +0300, Vladimir Oltean wrote:
>>>> On Sun, Jun 04, 2023 at 01:18:04PM +0100, Russell King (Oracle) wrote:
>>>>> I don't remember whether Vladimir's firmware validator will fail for
>>>>> mt753x if CPU ports are not fully described, but that would be well
>>>>> worth checking. If it does, then we can be confident that phylink
>>>>> will always be used, and those bypassing calls should not be necessary.
>>>>
>>>> It does, I've just retested this:
>>>>
>>>> [    8.469152] mscc_felix 0000:00:00.5: OF node /soc/pcie@1f0000000/ethernet-switch@0,5/ports/port@4 of CPU port 4 lacks the required "phy-handle", "fixed-link" or "managed" properties
>>>> [    8.494571] mscc_felix 0000:00:00.5: error -EINVAL: Failed to register DSA switch
>>>> [    8.502151] mscc_felix: probe of 0000:00:00.5 failed with error -22
>>>
>>> ... which isn't listed in dsa_switches_apply_workarounds[], and
>>> neither is mt753x. Thanks.
>>>
>>> So, that should be sufficient to know that the CPU port will always
>>> properly described, and thus bypassing phylink in mt753x for the CPU
>>> port should not be necessary.
>>
>> Perfect! If I understand correctly, there's this code - specific to MT7531
>> and MT7988 ports being used as CPU ports - which runs in addition to what's
>> in mt753x_phylink_mac_config():
>>
>> 	mt7530_write(priv, MT7530_PMCR_P(port),
>> 		     PMCR_CPU_PORT_SETTING(priv->id));
>>
>> This should be put on mt753x_phylink_mac_config(), under priv->id ==
>> ID_MT7531, priv->id == ID_MT7988, and dsa_is_cpu_port(ds, port) checks?
> 
> Please remember that I have very little knowledge of MT753x, so in
> order to answer this question, I've read through the mt7530 driver
> code.
> 
> Looking at mt7530.h:
> 
> #define  PMCR_CPU_PORT_SETTING(id)      (PMCR_FORCE_MODE_ID((id)) | \
>                                           PMCR_IFG_XMIT(1) | PMCR_MAC_MODE | \
>                                           PMCR_BACKOFF_EN | PMCR_BACKPR_EN | \
>                                           PMCR_TX_EN | PMCR_RX_EN | \
>                                           PMCR_TX_FC_EN | PMCR_RX_FC_EN | \
>                                           PMCR_FORCE_SPEED_1000 | \
>                                           PMCR_FORCE_FDX | PMCR_FORCE_LNK)
> 
> This seems to be some kind of port control register that sets amongst
> other things parameters such as whether flow control is enabled, the
> port speed, the duplex setting, whether link is forced up, etc.
> 
> Looking at what mt753x_phylink_mac_link_up() does:
> 
> 1. it sets PMCR_RX_EN | PMCR_TX_EN | PMCR_FORCE_LNK.
> 2. it sets PMCR_FORCE_SPEED_1000 if speed was 1000Mbps, or if using
>     an internal, TRGMII, 1000base-X or 2500base-X phy interface mode.
> 3. it sets PMCR_FORCE_FDX if full duplex was requested.
> 4. it sets PMCR_TX_FC_EN if full duplex was requested with tx pause.
> 5. it sets PMCR_RX_FC_EN if full duplex was requested with rx pause.
> 
> So, provided this is called with the appropriate parameters, for a
> fixed link, that will leave the following:
> 
> 	PMCR_FORCE_MODE_ID(id)
> 	PMCR_IFG_XMIT(1)
> 	PMCR_MAC_MODE
> 	PMCR_BACKOFF_EN
> 	PMCR_BACKPR_EN
> 
> If we now look at mt753x_phylink_mac_config(), this sets
> PMCR_IFG_XMIT(1), PMCR_MAC_MODE, PMCR_BACKOFF_EN, PMCR_BACKPR_EN,
> and PMCR_FORCE_MODE_ID(priv->id), which I believe is everything that
> PMCR_CPU_PORT_SETTING(priv->id) is doing.
> 
> So, Wouldn't a fixed-link description indicating 1Gbps, full duplex
> with pause cause phylink to call both mt753x_phylink_mac_config() and
> mt753x_phylink_mac_link_up() with appropriate arguments to set all
> of these parameters in PMCR?
> 
> Now, I'm going to analyse something else. mt7531_cpu_port_config()
> is called from mt753x_cpu_port_enable(), which is itself called from
> mt7531_setup_common(). That is ultimately called from the DSA switch
> ops .setup() method.
> 
> This method is called from dsa_switch_setup() for each switch in the
> DSA tree. dsa_tree_setup_switches() calls this, and is called from
> dsa_tree_setup().  Once dsa_tree_setup_switches() finishes
> successfully, dsa_tree_setup_ports() will be called. This will then
> setup DSA and CPU ports, which will then setup a phylink instance
> for these ports. phylink will parse the firmware description for
> the port. DSA will then call dsa_port_enable().
> 
> dsa_port_enable() will then call any port_enable() method in the
> mt7530.c driver, which will be mt7530_port_enable(). This then...
> 
>          mt7530_clear(priv, MT7530_PMCR_P(port), PMCR_LINK_SETTINGS_MASK);
> 
> which is:
> 
> #define  PMCR_LINK_SETTINGS_MASK        (PMCR_TX_EN | PMCR_FORCE_SPEED_1000 | \
>                                           PMCR_RX_EN | PMCR_FORCE_SPEED_100 | \
>                                           PMCR_TX_FC_EN | PMCR_RX_FC_EN | \
>                                           PMCR_FORCE_FDX | PMCR_FORCE_LNK | \
>                                           PMCR_FORCE_EEE1G | PMCR_FORCE_EEE100)
> 
> So it wipes out all the PMCR settings that mt7531_cpu_port_config()
> performed - undoing *everything* below that switch() statement in
> mt7531_cpu_port_config()!
> 
> Once the port_enable() method returns, DSA will then call
> phylink_start(), which will trigger phylink to bring up the link
> according to the settings it has, which will mean phylink calls
> the mac_config(), pcs_config(), pcs_link_up() and mac_link_up()
> with the appropriate parameters for the firmware described link.

I'm slowly learning how DSA and phylink works, this is the full code
path I could make up for the MT7530 DSA subdriver:

mt7530_probe() & mt7988_probe()
    -> mt7530_probe_common()
    -> dsa_register_switch()
       -> dsa_switch_probe()
          -> dsa_tree_setup()
             -> dsa_tree_setup_switches()
                -> dsa_switch_setup()
                   -> ds->ops->setup(): mt753x_setup()
                      -> mt7530_setup()
                         -> mt753x_cpu_port_enable()
                      -> mt7531_setup()
                         -> mt7531_setup_common()
                            -> mt753x_cpu_port_enable()
                               -> priv->info->cpu_port_config():
                                  mt7531_cpu_port_config()
                      -> mt7988_setup()
                         -> mt7531_setup_common()
                            -> mt753x_cpu_port_enable()
                               -> priv->info->cpu_port_config():
                                  mt7988_cpu_port_config()
             -> dsa_tree_setup_ports()
                -> dsa_port_setup()
                   -> dsa_shared_port_link_register_of()
                      -> dsa_shared_port_link_register_of()
                         -> dsa_shared_port_phylink_register()
                            -> dsa_port_phylink_create()
                               -> ds->ops->phylink_get_caps():
                                  mt753x_phylink_get_caps()
                               -> phylink_create()
                                  -> INIT_WORK(&pl->resolve, phylink_resolve)
                   -> dsa_port_enable()
                      -> dsa_port_enable_rt()
                         -> ds->ops->port_enable():
                            mt7530_port_enable()
                         -> phylink_start()
                            -> phylink_mac_initial_config()
                               -> phylink_major_config()
                                  -> phylink_mac_config()
                                     -> pl->mac_ops->mac_config():
                                        dsa_port_phylink_mac_config()
                                        -> ds->ops->phylink_mac_config():
                                           mt753x_phylink_mac_config()
                                  -> pl->pcs->ops->pcs_config():
                                     mt753x_pcs_config()
                            -> phylink_enable_and_run_resolve()
                               -> phylink_run_resolve()
                                  -> queue_work(system_power_efficient_wq, &pl->resolve)
                                     -> phylink_link_up()
                                        -> pl->pcs->ops->pcs_link_up():
                                           mtk_pcs_lynxi_link_up()
                                        -> pl->mac_ops->mac_link_up():
                                           dsa_port_phylink_mac_link_up()
                                           -> ds->ops->phylink_mac_link_up():
                                              mt753x_phylink_mac_link_up()

> 
> So I think I have the answer to my initial thought: do the calls in
> mt7531_cpu_port_config() to the phylink methods have any use what so
> ever? The answer is no, they are entirely useless. The same goes for
> the other cpu_port_config() methods that do something similar. The
> same goes for the PMCR register write that's changing any bits
> included in PMCR_LINK_SETTINGS_MASK.
> 
> What that means is that mt7988_cpu_port_config() can be entirely
> removed, it serves no useful purpose what so ever. For
> mt7531_cpu_port_config(), it only needs to set priv->p[56]_interface
> which, as far as I can see, probably only avoids mac_config() doing
> any pad setup (that's a guess.)

This is what I also believe and the reason why I made this patch to
simplify it. Looks like I'll just remove priv->info->cpu_port_config()
instead.

Arınç

  parent reply	other threads:[~2023-06-05 14:38 UTC|newest]

Thread overview: 121+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-22 12:15 [PATCH net-next 00/30] net: dsa: mt7530: improve, trap BPDU & LLDP, and prefer CPU port arinc9.unal
2023-05-22 12:15 ` [PATCH net-next 01/30] net: dsa: mt7530: add missing @p5_interface to mt7530_priv description arinc9.unal
2023-05-23 23:29   ` Andrew Lunn
2023-05-22 12:15 ` [PATCH net-next 02/30] net: dsa: mt7530: use p5_interface_select as data type for p5_intf_sel arinc9.unal
2023-05-23 23:31   ` Andrew Lunn
2023-05-24  7:41     ` Arınç ÜNAL
2023-05-22 12:15 ` [PATCH net-next 03/30] net: dsa: mt7530: properly support MT7531AE and MT7531BE arinc9.unal
2023-05-24 14:48   ` Vladimir Oltean
2023-05-25  6:00     ` Arınç ÜNAL
2023-05-22 12:15 ` [PATCH net-next 04/30] net: dsa: mt7530: improve comments regarding port 5 and 6 arinc9.unal
2023-05-23 23:35   ` Andrew Lunn
2023-05-24 14:49   ` Vladimir Oltean
2023-05-22 12:15 ` [PATCH net-next 05/30] net: dsa: mt7530: read XTAL value from correct register arinc9.unal
2023-05-23 23:37   ` Andrew Lunn
2023-05-24 16:57   ` Vladimir Oltean
2023-05-25  6:20     ` Arınç ÜNAL
2023-05-25 13:31       ` Vladimir Oltean
2023-06-04  6:34         ` Arınç ÜNAL
2023-06-04  7:11           ` Vladimir Oltean
2023-06-04 16:22             ` Arınç ÜNAL
2023-05-22 12:15 ` [PATCH net-next 06/30] net: dsa: mt7530: improve code path for setting up port 5 arinc9.unal
2023-05-24 17:35   ` Vladimir Oltean
2023-05-25  6:42     ` Arınç ÜNAL
2023-05-22 12:15 ` [PATCH net-next 07/30] net: dsa: mt7530: do not run mt7530_setup_port5() if port 5 is disabled arinc9.unal
2023-05-24 17:45   ` Vladimir Oltean
2023-05-22 12:15 ` [PATCH net-next 08/30] net: dsa: mt7530: change p{5,6}_interface to p{5,6}_configured arinc9.unal
2023-05-24 17:51   ` Vladimir Oltean
2023-05-25  6:49     ` Arınç ÜNAL
2023-05-26 13:01       ` Vladimir Oltean
2023-06-03 12:15         ` Arınç ÜNAL
2023-06-03 12:26           ` Russell King (Oracle)
2023-06-04 10:46             ` Arınç ÜNAL
2023-06-04 12:18               ` Russell King (Oracle)
2023-06-04 12:55                 ` Vladimir Oltean
2023-06-04 13:07                   ` Russell King (Oracle)
2023-06-04 13:14                     ` Arınç ÜNAL
2023-06-04 13:25                       ` Vladimir Oltean
2023-06-04 15:13                       ` Russell King (Oracle)
2023-06-04 16:00                         ` Russell King (Oracle)
2023-06-04 16:06                           ` Russell King (Oracle)
2023-06-04 16:14                             ` Arınç ÜNAL
2023-06-10 10:57                               ` Arınç ÜNAL
2023-06-10 17:55                                 ` Vladimir Oltean
2023-06-11  7:23                                   ` Arınç ÜNAL
2024-01-10 11:15                                     ` Arınç ÜNAL
2024-01-10 14:27                                       ` Vladimir Oltean
2024-01-10 17:15                                         ` Arınç ÜNAL
2024-01-10 18:05                                           ` Vladimir Oltean
2024-01-10 18:31                                             ` Russell King (Oracle)
2024-01-11  9:19                                               ` Vladimir Oltean
2023-06-05 14:36                         ` Arınç ÜNAL [this message]
2023-06-03 12:27           ` Vladimir Oltean
2023-05-22 12:15 ` [PATCH net-next 09/30] net: dsa: mt7530: empty default case on mt7530_setup_port5() arinc9.unal
2023-05-24 18:04   ` Vladimir Oltean
2023-05-24 18:05   ` Vladimir Oltean
2023-05-25  6:51     ` Arınç ÜNAL
2023-05-22 12:15 ` [PATCH net-next 10/30] net: dsa: mt7530: call port 6 setup from mt7530_mac_config() arinc9.unal
2023-05-24 18:08   ` Vladimir Oltean
2023-05-22 12:15 ` [PATCH net-next 11/30] net: dsa: mt7530: remove pad_setup function pointer arinc9.unal
2023-05-24 18:09   ` Vladimir Oltean
2023-05-22 12:15 ` [PATCH net-next 12/30] net: dsa: mt7530: move XTAL check to mt7530_setup() arinc9.unal
2023-05-23 23:40   ` Andrew Lunn
2023-05-24 18:15   ` Vladimir Oltean
2023-05-25  7:04     ` Arınç ÜNAL
2023-05-22 12:15 ` [PATCH net-next 13/30] net: dsa: mt7530: move enabling port 6 to mt7530_setup_port6() arinc9.unal
2023-05-22 12:15 ` [PATCH net-next 14/30] net: dsa: mt7530: switch to if/else statements on mt7530_setup_port6() arinc9.unal
2023-05-26 13:08   ` Vladimir Oltean
2023-05-22 12:15 ` [PATCH net-next 15/30] net: dsa: mt7530: set TRGMII RD TAP if trgmii is being used arinc9.unal
2023-05-26 13:09   ` Vladimir Oltean
2023-05-22 12:15 ` [PATCH net-next 16/30] net: dsa: mt7530: move lowering port 5 RGMII driving to mt7530_setup() arinc9.unal
2023-05-26 13:17   ` Vladimir Oltean
2023-06-04  7:05     ` Arınç ÜNAL
2023-06-04  7:14       ` Vladimir Oltean
2023-05-22 12:15 ` [PATCH net-next 17/30] net: dsa: mt7530: fix port capabilities for MT7988 arinc9.unal
2023-05-26 13:20   ` Vladimir Oltean
2023-05-22 12:15 ` [PATCH net-next 18/30] net: dsa: mt7530: remove .mac_port_config for MT7988 and make it optional arinc9.unal
2023-05-26 13:21   ` Vladimir Oltean
2023-05-22 12:15 ` [PATCH net-next 19/30] net: dsa: mt7530: set interrupt register only for MT7530 arinc9.unal
2023-05-26 13:25   ` Vladimir Oltean
2023-06-04  7:18     ` Arınç ÜNAL
2023-05-22 12:15 ` [PATCH net-next 20/30] net: dsa: mt7530: properly reset MT7531 switch arinc9.unal
2023-05-22 12:15 ` [PATCH net-next 21/30] net: dsa: mt7530: get rid of useless error returns on phylink code path arinc9.unal
2023-05-22 12:15 ` [PATCH net-next 22/30] net: dsa: mt7530: rename p5_intf_sel and use only for MT7530 switch arinc9.unal
2023-05-22 12:15 ` [PATCH net-next 23/30] net: dsa: mt7530: run mt7530_pll_setup() only with 40 MHz XTAL arinc9.unal
2023-05-22 12:15 ` [PATCH net-next 24/30] net: dsa: mt7530: rename MT7530_MFC to MT753X_MFC arinc9.unal
2023-05-26 15:42   ` Vladimir Oltean
2023-05-26 15:50     ` Russell King (Oracle)
2023-06-04  8:06       ` Arınç ÜNAL
2023-06-04 13:17         ` Vladimir Oltean
2023-06-04 13:25           ` Arınç ÜNAL
2023-05-22 12:15 ` [PATCH net-next 25/30] net: dsa: mt7530: properly set MT7531_CPU_PMAP arinc9.unal
2023-05-26 15:51   ` Vladimir Oltean
2023-06-04  8:21     ` Arınç ÜNAL
2023-06-04 13:08       ` Vladimir Oltean
2023-06-04 13:33         ` Arınç ÜNAL
2023-05-22 12:15 ` [PATCH net-next 26/30] net: dsa: mt7530: properly set MT7530_CPU_PORT arinc9.unal
2023-05-26 16:55   ` Vladimir Oltean
2023-06-04  8:33     ` Arınç ÜNAL
2023-05-22 12:15 ` [PATCH net-next 27/30] net: dsa: mt7530: introduce BPDU trapping for MT7530 switch arinc9.unal
2023-05-26 17:02   ` Vladimir Oltean
2023-06-04  8:51     ` Arınç ÜNAL
2023-06-04  9:23       ` Vladimir Oltean
2023-06-04  9:39         ` Arınç ÜNAL
2023-06-04 12:47           ` Vladimir Oltean
2023-06-10  8:32             ` Arınç ÜNAL
2023-06-10 17:57               ` Vladimir Oltean
2023-05-22 12:15 ` [PATCH net-next 28/30] net: dsa: mt7530: introduce LLDP frame trapping arinc9.unal
2023-05-22 12:15 ` [PATCH net-next 29/30] net: dsa: introduce preferred_default_local_cpu_port and use on MT7530 arinc9.unal
2023-05-26 17:17   ` Vladimir Oltean
2023-06-04 10:02     ` Arınç ÜNAL
2023-05-22 12:15 ` [PATCH net-next 30/30] MAINTAINERS: add me as maintainer of MEDIATEK SWITCH DRIVER arinc9.unal
2023-05-24 14:37   ` Vladimir Oltean
2023-05-26 17:38   ` Vladimir Oltean
2023-05-22 12:25 ` [PATCH net-next 00/30] net: dsa: mt7530: improve, trap BPDU & LLDP, and prefer CPU port Andrew Lunn
2023-05-22 13:37   ` Arınç ÜNAL
2023-05-22 15:43     ` Vladimir Oltean
2023-05-22 14:09 ` Horatiu Vultur
2023-05-22 14:35   ` Arınç ÜNAL
2023-05-22 18:13   ` Russell King (Oracle)
2023-05-23  1:54     ` Jakub Kicinski
2023-05-26 17:47 ` Vladimir Oltean

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=e2865f69-3254-4768-7a7a-bb84d76a85eb@arinc9.com \
    --to=arinc.unal@arinc9.com \
    --cc=Landen.Chao@mediatek.com \
    --cc=andrew@lunn.ch \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=bartel.eerdekens@constell8.be \
    --cc=daniel@makrotopia.org \
    --cc=davem@davemloft.net \
    --cc=dqfext@gmail.com \
    --cc=edumazet@google.com \
    --cc=erkin.bozoglu@xeront.com \
    --cc=f.fainelli@gmail.com \
    --cc=frank-w@public-files.de \
    --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@armlinux.org.uk \
    --cc=matthias.bgg@gmail.com \
    --cc=mithat.guner@xeront.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=richard@routerhints.com \
    --cc=sean.wang@mediatek.com \
    --cc=vschagen@cs.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®