All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net: dsa: mv88e6xxx: fix few issues in mv88e6390x_port_set_cmode
@ 2019-03-23 18:41 Heiner Kallweit
  2019-03-26 18:23 ` David Miller
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Heiner Kallweit @ 2019-03-23 18:41 UTC (permalink / raw)
  To: Vivien Didelot, Andrew Lunn, Florian Fainelli, David Miller; +Cc: netdev

This patches fixes few issues in mv88e6390x_port_set_cmode().

1. When entering the function the old cmode may be 0, in this case
   mv88e6390x_serdes_get_lane() returns -ENODEV. As result we bail
   out and have no chance to set a new mode. Therefore deal properly
   with -ENODEV.

2. Once we have disabled power and irq, let's set the cached cmode to 0.
   This reflects the actual status and is cleaner if we bail out with an
   error in the following function calls.

3. The cached cmode is used by mv88e6390x_serdes_get_lane(),
   mv88e6390_serdes_power_lane() and mv88e6390_serdes_irq_enable().
   Currently we set the cached mode to the new one at the very end of
   the function only, means until then we use the old one what may be
   wrong.

4. When calling mv88e6390_serdes_irq_enable() we use the lane value
   belonging to the old cmode. Get the lane belonging to the new cmode
   before calling this function.

It's hard to provide a good "Fixes" tag because quite a few smaller
changes have been done to the code in question recently.

Fixes: d235c48b40d3 ("net: dsa: mv88e6xxx: power serdes on/off for 10G interfaces on 6390X")
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/dsa/mv88e6xxx/port.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/port.c b/drivers/net/dsa/mv88e6xxx/port.c
index dce84a2a6..c44b2822e 100644
--- a/drivers/net/dsa/mv88e6xxx/port.c
+++ b/drivers/net/dsa/mv88e6xxx/port.c
@@ -427,18 +427,22 @@ int mv88e6390x_port_set_cmode(struct mv88e6xxx_chip *chip, int port,
 		return 0;
 
 	lane = mv88e6390x_serdes_get_lane(chip, port);
-	if (lane < 0)
+	if (lane < 0 && lane != -ENODEV)
 		return lane;
 
-	if (chip->ports[port].serdes_irq) {
-		err = mv88e6390_serdes_irq_disable(chip, port, lane);
+	if (lane >= 0) {
+		if (chip->ports[port].serdes_irq) {
+			err = mv88e6390_serdes_irq_disable(chip, port, lane);
+			if (err)
+				return err;
+		}
+
+		err = mv88e6390x_serdes_power(chip, port, false);
 		if (err)
 			return err;
 	}
 
-	err = mv88e6390x_serdes_power(chip, port, false);
-	if (err)
-		return err;
+	chip->ports[port].cmode = 0;
 
 	if (cmode) {
 		err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_STS, &reg);
@@ -452,6 +456,12 @@ int mv88e6390x_port_set_cmode(struct mv88e6xxx_chip *chip, int port,
 		if (err)
 			return err;
 
+		chip->ports[port].cmode = cmode;
+
+		lane = mv88e6390x_serdes_get_lane(chip, port);
+		if (lane < 0)
+			return lane;
+
 		err = mv88e6390x_serdes_power(chip, port, true);
 		if (err)
 			return err;
@@ -463,8 +473,6 @@ int mv88e6390x_port_set_cmode(struct mv88e6xxx_chip *chip, int port,
 		}
 	}
 
-	chip->ports[port].cmode = cmode;
-
 	return 0;
 }
 
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net] net: dsa: mv88e6xxx: fix few issues in mv88e6390x_port_set_cmode
  2019-03-23 18:41 [PATCH net] net: dsa: mv88e6xxx: fix few issues in mv88e6390x_port_set_cmode Heiner Kallweit
@ 2019-03-26 18:23 ` David Miller
  2019-03-27 20:45 ` David Miller
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2019-03-26 18:23 UTC (permalink / raw)
  To: hkallweit1; +Cc: vivien.didelot, andrew, f.fainelli, netdev

From: Heiner Kallweit <hkallweit1@gmail.com>
Date: Sat, 23 Mar 2019 19:41:32 +0100

> This patches fixes few issues in mv88e6390x_port_set_cmode().
> 
> 1. When entering the function the old cmode may be 0, in this case
>    mv88e6390x_serdes_get_lane() returns -ENODEV. As result we bail
>    out and have no chance to set a new mode. Therefore deal properly
>    with -ENODEV.
> 
> 2. Once we have disabled power and irq, let's set the cached cmode to 0.
>    This reflects the actual status and is cleaner if we bail out with an
>    error in the following function calls.
> 
> 3. The cached cmode is used by mv88e6390x_serdes_get_lane(),
>    mv88e6390_serdes_power_lane() and mv88e6390_serdes_irq_enable().
>    Currently we set the cached mode to the new one at the very end of
>    the function only, means until then we use the old one what may be
>    wrong.
> 
> 4. When calling mv88e6390_serdes_irq_enable() we use the lane value
>    belonging to the old cmode. Get the lane belonging to the new cmode
>    before calling this function.
> 
> It's hard to provide a good "Fixes" tag because quite a few smaller
> changes have been done to the code in question recently.
> 
> Fixes: d235c48b40d3 ("net: dsa: mv88e6xxx: power serdes on/off for 10G interfaces on 6390X")
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>

Andrew et al., please review.

Thank you.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net] net: dsa: mv88e6xxx: fix few issues in mv88e6390x_port_set_cmode
  2019-03-23 18:41 [PATCH net] net: dsa: mv88e6xxx: fix few issues in mv88e6390x_port_set_cmode Heiner Kallweit
  2019-03-26 18:23 ` David Miller
@ 2019-03-27 20:45 ` David Miller
  2019-03-27 21:22 ` Florian Fainelli
  2019-03-28  4:54 ` David Miller
  3 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2019-03-27 20:45 UTC (permalink / raw)
  To: hkallweit1; +Cc: vivien.didelot, andrew, f.fainelli, netdev

From: Heiner Kallweit <hkallweit1@gmail.com>
Date: Sat, 23 Mar 2019 19:41:32 +0100

> This patches fixes few issues in mv88e6390x_port_set_cmode().
> 
> 1. When entering the function the old cmode may be 0, in this case
>    mv88e6390x_serdes_get_lane() returns -ENODEV. As result we bail
>    out and have no chance to set a new mode. Therefore deal properly
>    with -ENODEV.
> 
> 2. Once we have disabled power and irq, let's set the cached cmode to 0.
>    This reflects the actual status and is cleaner if we bail out with an
>    error in the following function calls.
> 
> 3. The cached cmode is used by mv88e6390x_serdes_get_lane(),
>    mv88e6390_serdes_power_lane() and mv88e6390_serdes_irq_enable().
>    Currently we set the cached mode to the new one at the very end of
>    the function only, means until then we use the old one what may be
>    wrong.
> 
> 4. When calling mv88e6390_serdes_irq_enable() we use the lane value
>    belonging to the old cmode. Get the lane belonging to the new cmode
>    before calling this function.
> 
> It's hard to provide a good "Fixes" tag because quite a few smaller
> changes have been done to the code in question recently.
> 
> Fixes: d235c48b40d3 ("net: dsa: mv88e6xxx: power serdes on/off for 10G interfaces on 6390X")
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>

Once again, Andrew, Florian, Vivien, et al., please review.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net] net: dsa: mv88e6xxx: fix few issues in mv88e6390x_port_set_cmode
  2019-03-23 18:41 [PATCH net] net: dsa: mv88e6xxx: fix few issues in mv88e6390x_port_set_cmode Heiner Kallweit
  2019-03-26 18:23 ` David Miller
  2019-03-27 20:45 ` David Miller
@ 2019-03-27 21:22 ` Florian Fainelli
  2019-03-27 21:38   ` Heiner Kallweit
  2019-03-28  4:54 ` David Miller
  3 siblings, 1 reply; 6+ messages in thread
From: Florian Fainelli @ 2019-03-27 21:22 UTC (permalink / raw)
  To: Heiner Kallweit, Vivien Didelot, Andrew Lunn, David Miller; +Cc: netdev

On 3/23/19 11:41 AM, Heiner Kallweit wrote:
> This patches fixes few issues in mv88e6390x_port_set_cmode().
> 
> 1. When entering the function the old cmode may be 0, in this case
>    mv88e6390x_serdes_get_lane() returns -ENODEV. As result we bail
>    out and have no chance to set a new mode. Therefore deal properly
>    with -ENODEV.
> 
> 2. Once we have disabled power and irq, let's set the cached cmode to 0.
>    This reflects the actual status and is cleaner if we bail out with an
>    error in the following function calls.
> 
> 3. The cached cmode is used by mv88e6390x_serdes_get_lane(),
>    mv88e6390_serdes_power_lane() and mv88e6390_serdes_irq_enable().
>    Currently we set the cached mode to the new one at the very end of
>    the function only, means until then we use the old one what may be
>    wrong.
> 
> 4. When calling mv88e6390_serdes_irq_enable() we use the lane value
>    belonging to the old cmode. Get the lane belonging to the new cmode
>    before calling this function.
> 
> It's hard to provide a good "Fixes" tag because quite a few smaller
> changes have been done to the code in question recently.
> 
> Fixes: d235c48b40d3 ("net: dsa: mv88e6xxx: power serdes on/off for 10G interfaces on 6390X")
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
>  drivers/net/dsa/mv88e6xxx/port.c | 24 ++++++++++++++++--------
>  1 file changed, 16 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/dsa/mv88e6xxx/port.c b/drivers/net/dsa/mv88e6xxx/port.c
> index dce84a2a6..c44b2822e 100644
> --- a/drivers/net/dsa/mv88e6xxx/port.c
> +++ b/drivers/net/dsa/mv88e6xxx/port.c
> @@ -427,18 +427,22 @@ int mv88e6390x_port_set_cmode(struct mv88e6xxx_chip *chip, int port,
>  		return 0;
>  
>  	lane = mv88e6390x_serdes_get_lane(chip, port);
> -	if (lane < 0)
> +	if (lane < 0 && lane != -ENODEV)
>  		return lane;

It does not look like you can return a negative error code from
mv88e6390x_serdes_get_lane() that is not -ENODEV?

Other than that:

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net] net: dsa: mv88e6xxx: fix few issues in mv88e6390x_port_set_cmode
  2019-03-27 21:22 ` Florian Fainelli
@ 2019-03-27 21:38   ` Heiner Kallweit
  0 siblings, 0 replies; 6+ messages in thread
From: Heiner Kallweit @ 2019-03-27 21:38 UTC (permalink / raw)
  To: Florian Fainelli, Vivien Didelot, Andrew Lunn, David Miller; +Cc: netdev

On 27.03.2019 22:22, Florian Fainelli wrote:
> On 3/23/19 11:41 AM, Heiner Kallweit wrote:
>> This patches fixes few issues in mv88e6390x_port_set_cmode().
>>
>> 1. When entering the function the old cmode may be 0, in this case
>>    mv88e6390x_serdes_get_lane() returns -ENODEV. As result we bail
>>    out and have no chance to set a new mode. Therefore deal properly
>>    with -ENODEV.
>>
>> 2. Once we have disabled power and irq, let's set the cached cmode to 0.
>>    This reflects the actual status and is cleaner if we bail out with an
>>    error in the following function calls.
>>
>> 3. The cached cmode is used by mv88e6390x_serdes_get_lane(),
>>    mv88e6390_serdes_power_lane() and mv88e6390_serdes_irq_enable().
>>    Currently we set the cached mode to the new one at the very end of
>>    the function only, means until then we use the old one what may be
>>    wrong.
>>
>> 4. When calling mv88e6390_serdes_irq_enable() we use the lane value
>>    belonging to the old cmode. Get the lane belonging to the new cmode
>>    before calling this function.
>>
>> It's hard to provide a good "Fixes" tag because quite a few smaller
>> changes have been done to the code in question recently.
>>
>> Fixes: d235c48b40d3 ("net: dsa: mv88e6xxx: power serdes on/off for 10G interfaces on 6390X")
>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>> ---
>>  drivers/net/dsa/mv88e6xxx/port.c | 24 ++++++++++++++++--------
>>  1 file changed, 16 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/net/dsa/mv88e6xxx/port.c b/drivers/net/dsa/mv88e6xxx/port.c
>> index dce84a2a6..c44b2822e 100644
>> --- a/drivers/net/dsa/mv88e6xxx/port.c
>> +++ b/drivers/net/dsa/mv88e6xxx/port.c
>> @@ -427,18 +427,22 @@ int mv88e6390x_port_set_cmode(struct mv88e6xxx_chip *chip, int port,
>>  		return 0;
>>  
>>  	lane = mv88e6390x_serdes_get_lane(chip, port);
>> -	if (lane < 0)
>> +	if (lane < 0 && lane != -ENODEV)
>>  		return lane;
> 
> It does not look like you can return a negative error code from
> mv88e6390x_serdes_get_lane() that is not -ENODEV?
> 
Thanks for reviewing, Florian. Right, at least for now
mv88e6390x_serdes_get_lane() doesn't return any other errno.
But that's not carved in stone, and if somebody comes and adds
a check that returns -EINVAL to this function, then this person
most likely won't update mv88e6390x_port_set_cmode().

> Other than that:
> 
> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net] net: dsa: mv88e6xxx: fix few issues in mv88e6390x_port_set_cmode
  2019-03-23 18:41 [PATCH net] net: dsa: mv88e6xxx: fix few issues in mv88e6390x_port_set_cmode Heiner Kallweit
                   ` (2 preceding siblings ...)
  2019-03-27 21:22 ` Florian Fainelli
@ 2019-03-28  4:54 ` David Miller
  3 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2019-03-28  4:54 UTC (permalink / raw)
  To: hkallweit1; +Cc: vivien.didelot, andrew, f.fainelli, netdev

From: Heiner Kallweit <hkallweit1@gmail.com>
Date: Sat, 23 Mar 2019 19:41:32 +0100

> This patches fixes few issues in mv88e6390x_port_set_cmode().
> 
> 1. When entering the function the old cmode may be 0, in this case
>    mv88e6390x_serdes_get_lane() returns -ENODEV. As result we bail
>    out and have no chance to set a new mode. Therefore deal properly
>    with -ENODEV.
> 
> 2. Once we have disabled power and irq, let's set the cached cmode to 0.
>    This reflects the actual status and is cleaner if we bail out with an
>    error in the following function calls.
> 
> 3. The cached cmode is used by mv88e6390x_serdes_get_lane(),
>    mv88e6390_serdes_power_lane() and mv88e6390_serdes_irq_enable().
>    Currently we set the cached mode to the new one at the very end of
>    the function only, means until then we use the old one what may be
>    wrong.
> 
> 4. When calling mv88e6390_serdes_irq_enable() we use the lane value
>    belonging to the old cmode. Get the lane belonging to the new cmode
>    before calling this function.
> 
> It's hard to provide a good "Fixes" tag because quite a few smaller
> changes have been done to the code in question recently.
> 
> Fixes: d235c48b40d3 ("net: dsa: mv88e6xxx: power serdes on/off for 10G interfaces on 6390X")
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-03-28  4:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-23 18:41 [PATCH net] net: dsa: mv88e6xxx: fix few issues in mv88e6390x_port_set_cmode Heiner Kallweit
2019-03-26 18:23 ` David Miller
2019-03-27 20:45 ` David Miller
2019-03-27 21:22 ` Florian Fainelli
2019-03-27 21:38   ` Heiner Kallweit
2019-03-28  4:54 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.