diff mbox series

[net] net: dpaa2-mac: Get serdes only for backplane links

Message ID 20221227230918.2440351-1-sean.anderson@seco.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net] net: dpaa2-mac: Get serdes only for backplane links | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 0 this patch: 1
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn fail Errors and warnings before: 0 this patch: 1
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 34 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Sean Anderson Dec. 27, 2022, 11:09 p.m. UTC
When commenting on what would become commit 085f1776fa03 ("net: dpaa2-mac:
add backplane link mode support"), Ioana Ciornei said [1]:

> ...DPMACs in TYPE_BACKPLANE can have both their PCS and SerDes managed
> by Linux (since the firmware is not touching these). That being said,
> DPMACs in TYPE_PHY (the type that is already supported in dpaa2-mac) can
> also have their PCS managed by Linux (no interraction from the
> firmware's part with the PCS, just the SerDes).

This implies that Linux only manages the SerDes when the link type is
backplane. From my testing, the link fails to come up when the link type is
phy, but does come up when it is backplane. Modify the condition in
dpaa2_mac_connect to reflect this, moving the existing conditions to more
appropriate places.

[1] https://lore.kernel.org/netdev/20210120221900.i6esmk6uadgqpdtu@skbuf/

Fixes: f978fe85b8d1 ("dpaa2-mac: configure the SerDes phy on a protocol change")
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---
I tested this on an LS1088ARDB. I would appreciate if someone could
verify that this doesn't break anything for the LX2160A.

 drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

Comments

Jakub Kicinski Dec. 30, 2022, 4:09 a.m. UTC | #1
On Tue, 27 Dec 2022 18:09:18 -0500 Sean Anderson wrote:
> +	if (!(mac->features & !DPAA2_MAC_FEATURE_PROTOCOL_CHANGE) ||

This line is odd as sparse points out
Ioana Ciornei Dec. 30, 2022, 1:32 p.m. UTC | #2
Hi Sean,

On Tue, Dec 27, 2022 at 06:09:18PM -0500, Sean Anderson wrote:
> When commenting on what would become commit 085f1776fa03 ("net: dpaa2-mac:
> add backplane link mode support"), Ioana Ciornei said [1]:
> 
> > ...DPMACs in TYPE_BACKPLANE can have both their PCS and SerDes managed
> > by Linux (since the firmware is not touching these). That being said,
> > DPMACs in TYPE_PHY (the type that is already supported in dpaa2-mac) can
> > also have their PCS managed by Linux (no interraction from the
> > firmware's part with the PCS, just the SerDes).
> 
> This implies that Linux only manages the SerDes when the link type is
> backplane. From my testing, the link fails to come up when the link type is
> phy, but does come up when it is backplane. Modify the condition in
> dpaa2_mac_connect to reflect this, moving the existing conditions to more
> appropriate places.
> 

What interface mode, firmware version etc are you testing on LS1088A?
Are you using the SerDes phy driver?

> [1] https://lore.kernel.org/netdev/20210120221900.i6esmk6uadgqpdtu@skbuf/
> 
> Fixes: f978fe85b8d1 ("dpaa2-mac: configure the SerDes phy on a protocol change")
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>
> ---
> I tested this on an LS1088ARDB. I would appreciate if someone could
> verify that this doesn't break anything for the LX2160A.

I will test on a LX2160A but no sooner than next Tuesday. Sorry.

> 
>  drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
> index c886f33f8c6f..0693d3623a76 100644
> --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
> +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
> @@ -179,9 +179,13 @@ static void dpaa2_mac_config(struct phylink_config *config, unsigned int mode,
>  	if (err)
>  		netdev_err(mac->net_dev,  "dpmac_set_protocol() = %d\n", err);
>  
> -	err = phy_set_mode_ext(mac->serdes_phy, PHY_MODE_ETHERNET, state->interface);
> -	if (err)
> -		netdev_err(mac->net_dev, "phy_set_mode_ext() = %d\n", err);
> +	if (!phy_interface_mode_is_rgmii(mode)) {
> +		err = phy_set_mode_ext(mac->serdes_phy, PHY_MODE_ETHERNET,
> +				       state->interface);
> +		if (err)
> +			netdev_err(mac->net_dev, "phy_set_mode_ext() = %d\n",
> +				   err);
> +	}
>  }

This check is not necessary. Just above the snippet shown here is:

	if (!mac->serdes_phy)
		return;

And the 'serdes_phy' is only setup if the interface mode is not a rgmii.
	if (mac->features & DPAA2_MAC_FEATURE_PROTOCOL_CHANGE &&
	    !phy_interface_mode_is_rgmii(mac->if_mode) &&
	    is_of_node(dpmac_node)) {
		serdes_phy = of_phy_get(to_of_node(dpmac_node), NULL);
		
		if (serdes_phy == ERR_PTR(-ENODEV))
			serdes_phy = NULL;
		else if (IS_ERR(serdes_phy))
			return PTR_ERR(serdes_phy);
		else
			phy_init(serdes_phy);
	}
	mac->serdes_phy = serdes_phy;



>  
>  static void dpaa2_mac_link_up(struct phylink_config *config,
> @@ -317,7 +321,8 @@ static void dpaa2_mac_set_supported_interfaces(struct dpaa2_mac *mac)
>  		}
>  	}
>  
> -	if (!mac->serdes_phy)
> +	if (!(mac->features & !DPAA2_MAC_FEATURE_PROTOCOL_CHANGE) ||
> +	    !mac->serdes_phy)
>  		return;
>  
>  	/* In case we have access to the SerDes phy/lane, then ask the SerDes
> @@ -377,8 +382,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
>  		return -EINVAL;
>  	mac->if_mode = err;
>  
> -	if (mac->features & DPAA2_MAC_FEATURE_PROTOCOL_CHANGE &&
> -	    !phy_interface_mode_is_rgmii(mac->if_mode) &&
> +	if (mac->attr.link_type == DPMAC_LINK_TYPE_BACKPLANE &&
>  	    is_of_node(dpmac_node)) {
>  		serdes_phy = of_phy_get(to_of_node(dpmac_node), NULL);
>  

If the goal is to restrict the serdes_phy setup only if in _BACKPLANE
mode, then why not just add another restriction here directly?

What I mean is not to remove any checks from this if statement but
rather add another one. And this would be the only change needed.


Ioana
Sean Anderson Dec. 30, 2022, 3:23 p.m. UTC | #3
On 12/29/22 23:09, Jakub Kicinski wrote:
> On Tue, 27 Dec 2022 18:09:18 -0500 Sean Anderson wrote:
>> +	if (!(mac->features & !DPAA2_MAC_FEATURE_PROTOCOL_CHANGE) ||
> 
> This line is odd as sparse points out

Ah, you're right.

--Sean
Sean Anderson Dec. 30, 2022, 3:29 p.m. UTC | #4
On 12/30/22 08:32, Ioana Ciornei wrote:
> Hi Sean,
> 
> On Tue, Dec 27, 2022 at 06:09:18PM -0500, Sean Anderson wrote:
>> When commenting on what would become commit 085f1776fa03 ("net: dpaa2-mac:
>> add backplane link mode support"), Ioana Ciornei said [1]:
>> 
>> > ...DPMACs in TYPE_BACKPLANE can have both their PCS and SerDes managed
>> > by Linux (since the firmware is not touching these). That being said,
>> > DPMACs in TYPE_PHY (the type that is already supported in dpaa2-mac) can
>> > also have their PCS managed by Linux (no interraction from the
>> > firmware's part with the PCS, just the SerDes).
>> 
>> This implies that Linux only manages the SerDes when the link type is
>> backplane. From my testing, the link fails to come up when the link type is
>> phy, but does come up when it is backplane. Modify the condition in
>> dpaa2_mac_connect to reflect this, moving the existing conditions to more
>> appropriate places.
>> 
> 
> What interface mode, firmware version etc are you testing on LS1088A?

I tried with fixed/phy/backplane link modes. Firmware is

fsl-mc: Management Complex booted (version: 10.34.0, boot status: 0x1)

> Are you using the SerDes phy driver?

I am using [1].

[1] https://lore.kernel.org/linux-phy/20221230000139.2846763-1-sean.anderson@seco.com/T/#t

>> [1] https://lore.kernel.org/netdev/20210120221900.i6esmk6uadgqpdtu@skbuf/
>> 
>> Fixes: f978fe85b8d1 ("dpaa2-mac: configure the SerDes phy on a protocol change")
>> Signed-off-by: Sean Anderson <sean.anderson@seco.com>
>> ---
>> I tested this on an LS1088ARDB. I would appreciate if someone could
>> verify that this doesn't break anything for the LX2160A.
> 
> I will test on a LX2160A but no sooner than next Tuesday. Sorry.
> 
>> 
>>  drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c | 16 ++++++++++------
>>  1 file changed, 10 insertions(+), 6 deletions(-)
>> 
>> diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
>> index c886f33f8c6f..0693d3623a76 100644
>> --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
>> +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
>> @@ -179,9 +179,13 @@ static void dpaa2_mac_config(struct phylink_config *config, unsigned int mode,
>>  	if (err)
>>  		netdev_err(mac->net_dev,  "dpmac_set_protocol() = %d\n", err);
>>  
>> -	err = phy_set_mode_ext(mac->serdes_phy, PHY_MODE_ETHERNET, state->interface);
>> -	if (err)
>> -		netdev_err(mac->net_dev, "phy_set_mode_ext() = %d\n", err);
>> +	if (!phy_interface_mode_is_rgmii(mode)) {
>> +		err = phy_set_mode_ext(mac->serdes_phy, PHY_MODE_ETHERNET,
>> +				       state->interface);
>> +		if (err)
>> +			netdev_err(mac->net_dev, "phy_set_mode_ext() = %d\n",
>> +				   err);
>> +	}
>>  }
> 
> This check is not necessary. Just above the snippet shown here is:
> 
> 	if (!mac->serdes_phy)
> 		return;
> 
> And the 'serdes_phy' is only setup if the interface mode is not a rgmii.

This is changed later on in this patch.

> 	if (mac->features & DPAA2_MAC_FEATURE_PROTOCOL_CHANGE &&
> 	    !phy_interface_mode_is_rgmii(mac->if_mode) &&
> 	    is_of_node(dpmac_node)) {
> 		serdes_phy = of_phy_get(to_of_node(dpmac_node), NULL);
> 		
> 		if (serdes_phy == ERR_PTR(-ENODEV))
> 			serdes_phy = NULL;
> 		else if (IS_ERR(serdes_phy))
> 			return PTR_ERR(serdes_phy);
> 		else
> 			phy_init(serdes_phy);
> 	}
> 	mac->serdes_phy = serdes_phy;
> 
> 
> 
>>  
>>  static void dpaa2_mac_link_up(struct phylink_config *config,
>> @@ -317,7 +321,8 @@ static void dpaa2_mac_set_supported_interfaces(struct dpaa2_mac *mac)
>>  		}
>>  	}
>>  
>> -	if (!mac->serdes_phy)
>> +	if (!(mac->features & !DPAA2_MAC_FEATURE_PROTOCOL_CHANGE) ||
>> +	    !mac->serdes_phy)
>>  		return;
>>  
>>  	/* In case we have access to the SerDes phy/lane, then ask the SerDes
>> @@ -377,8 +382,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
>>  		return -EINVAL;
>>  	mac->if_mode = err;
>>  
>> -	if (mac->features & DPAA2_MAC_FEATURE_PROTOCOL_CHANGE &&
>> -	    !phy_interface_mode_is_rgmii(mac->if_mode) &&
>> +	if (mac->attr.link_type == DPMAC_LINK_TYPE_BACKPLANE &&
>>  	    is_of_node(dpmac_node)) {
>>  		serdes_phy = of_phy_get(to_of_node(dpmac_node), NULL);
>>  
> 
> If the goal is to restrict the serdes_phy setup only if in _BACKPLANE
> mode, then why not just add another restriction here directly?



> What I mean is not to remove any checks from this if statement but
> rather add another one. And this would be the only change needed.

Because the current restriction is wrong.

We will interfere with the firmware if we try to touch the serdes when we have

	mac->features & DPAA2_MAC_FEATURE_PROTOCOL_CHANGE &&
	mac->attr.link_type == DPMAC_LINK_TYPE_BACKPLANE

because we managed the serdes exactly when we have

	mac->attr.link_type == DPMAC_LINK_TYPE_BACKPLANE

mac->features only determines whether we can change protocols.

--Sean
diff mbox series

Patch

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
index c886f33f8c6f..0693d3623a76 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
@@ -179,9 +179,13 @@  static void dpaa2_mac_config(struct phylink_config *config, unsigned int mode,
 	if (err)
 		netdev_err(mac->net_dev,  "dpmac_set_protocol() = %d\n", err);
 
-	err = phy_set_mode_ext(mac->serdes_phy, PHY_MODE_ETHERNET, state->interface);
-	if (err)
-		netdev_err(mac->net_dev, "phy_set_mode_ext() = %d\n", err);
+	if (!phy_interface_mode_is_rgmii(mode)) {
+		err = phy_set_mode_ext(mac->serdes_phy, PHY_MODE_ETHERNET,
+				       state->interface);
+		if (err)
+			netdev_err(mac->net_dev, "phy_set_mode_ext() = %d\n",
+				   err);
+	}
 }
 
 static void dpaa2_mac_link_up(struct phylink_config *config,
@@ -317,7 +321,8 @@  static void dpaa2_mac_set_supported_interfaces(struct dpaa2_mac *mac)
 		}
 	}
 
-	if (!mac->serdes_phy)
+	if (!(mac->features & !DPAA2_MAC_FEATURE_PROTOCOL_CHANGE) ||
+	    !mac->serdes_phy)
 		return;
 
 	/* In case we have access to the SerDes phy/lane, then ask the SerDes
@@ -377,8 +382,7 @@  int dpaa2_mac_connect(struct dpaa2_mac *mac)
 		return -EINVAL;
 	mac->if_mode = err;
 
-	if (mac->features & DPAA2_MAC_FEATURE_PROTOCOL_CHANGE &&
-	    !phy_interface_mode_is_rgmii(mac->if_mode) &&
+	if (mac->attr.link_type == DPMAC_LINK_TYPE_BACKPLANE &&
 	    is_of_node(dpmac_node)) {
 		serdes_phy = of_phy_get(to_of_node(dpmac_node), NULL);