diff mbox series

[RFC,net-next,1/7] net: sunhme: Just restart autonegotiation if we can't bring the link up

Message ID 20230222210355.2741485-2-seanga2@gmail.com (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series net: sunhme: Probe/IRQ cleanups | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next, async
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 6 of 6 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 No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch warning WARNING: line length of 91 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Sean Anderson Feb. 22, 2023, 9:03 p.m. UTC
If we've tried regular autonegotiation and forcing the link mode, just
restart autonegotiation instead of reinitializing the whole NIC.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
---

 drivers/net/ethernet/sun/sunhme.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Comments

Simon Horman Feb. 25, 2023, 4:56 p.m. UTC | #1
On Wed, Feb 22, 2023 at 04:03:49PM -0500, Sean Anderson wrote:
> If we've tried regular autonegotiation and forcing the link mode, just
> restart autonegotiation instead of reinitializing the whole NIC.
> 
> Signed-off-by: Sean Anderson <seanga2@gmail.com>
> ---
> 
>  drivers/net/ethernet/sun/sunhme.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c
> index dd14114cbcfb..3eeda8f3fa80 100644
> --- a/drivers/net/ethernet/sun/sunhme.c
> +++ b/drivers/net/ethernet/sun/sunhme.c
> @@ -589,7 +589,10 @@ static int set_happy_link_modes(struct happy_meal *hp, void __iomem *tregs)
>  	return 1;
>  }
>  
> -static int happy_meal_init(struct happy_meal *hp);
> +static void
> +happy_meal_begin_auto_negotiation(struct happy_meal *hp,
> +				  void __iomem *tregs,
> +				  const struct ethtool_link_ksettings *ep);

I think it is preferable, though far more verbose, to move
happy_meal_begin_auto_negotiation() before happy_meal_timer and avoid the
need for a forward declaration. I did try this locally, and it did
compile.

>  static int is_lucent_phy(struct happy_meal *hp)
>  {
> @@ -743,12 +746,7 @@ static void happy_meal_timer(struct timer_list *t)
>  					netdev_notice(hp->dev,
>  						      "Link down, cable problem?\n");
>  
> -					ret = happy_meal_init(hp);
> -					if (ret) {
> -						/* ho hum... */
> -						netdev_err(hp->dev,
> -							   "Error, cannot re-init the Happy Meal.\n");
> -					}
> +					happy_meal_begin_auto_negotiation(hp, tregs, NULL);
>  					goto out;
>  				}
>  				if (!is_lucent_phy(hp)) {
> -- 
> 2.37.1
>
Sean Anderson Feb. 25, 2023, 6:59 p.m. UTC | #2
On 2/25/23 11:56, Simon Horman wrote:
> On Wed, Feb 22, 2023 at 04:03:49PM -0500, Sean Anderson wrote:
>> If we've tried regular autonegotiation and forcing the link mode, just
>> restart autonegotiation instead of reinitializing the whole NIC.
>>
>> Signed-off-by: Sean Anderson <seanga2@gmail.com>
>> ---
>>
>>   drivers/net/ethernet/sun/sunhme.c | 12 +++++-------
>>   1 file changed, 5 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c
>> index dd14114cbcfb..3eeda8f3fa80 100644
>> --- a/drivers/net/ethernet/sun/sunhme.c
>> +++ b/drivers/net/ethernet/sun/sunhme.c
>> @@ -589,7 +589,10 @@ static int set_happy_link_modes(struct happy_meal *hp, void __iomem *tregs)
>>   	return 1;
>>   }
>>   
>> -static int happy_meal_init(struct happy_meal *hp);
>> +static void
>> +happy_meal_begin_auto_negotiation(struct happy_meal *hp,
>> +				  void __iomem *tregs,
>> +				  const struct ethtool_link_ksettings *ep);
> 
> I think it is preferable, though far more verbose, to move
> happy_meal_begin_auto_negotiation() before happy_meal_timer and avoid the
> need for a forward declaration. I did try this locally, and it did
> compile.

Fine by me.

--Sean

>>   static int is_lucent_phy(struct happy_meal *hp)
>>   {
>> @@ -743,12 +746,7 @@ static void happy_meal_timer(struct timer_list *t)
>>   					netdev_notice(hp->dev,
>>   						      "Link down, cable problem?\n");
>>   
>> -					ret = happy_meal_init(hp);
>> -					if (ret) {
>> -						/* ho hum... */
>> -						netdev_err(hp->dev,
>> -							   "Error, cannot re-init the Happy Meal.\n");
>> -					}
>> +					happy_meal_begin_auto_negotiation(hp, tregs, NULL);
>>   					goto out;
>>   				}
>>   				if (!is_lucent_phy(hp)) {
>> -- 
>> 2.37.1
>>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c
index dd14114cbcfb..3eeda8f3fa80 100644
--- a/drivers/net/ethernet/sun/sunhme.c
+++ b/drivers/net/ethernet/sun/sunhme.c
@@ -589,7 +589,10 @@  static int set_happy_link_modes(struct happy_meal *hp, void __iomem *tregs)
 	return 1;
 }
 
-static int happy_meal_init(struct happy_meal *hp);
+static void
+happy_meal_begin_auto_negotiation(struct happy_meal *hp,
+				  void __iomem *tregs,
+				  const struct ethtool_link_ksettings *ep);
 
 static int is_lucent_phy(struct happy_meal *hp)
 {
@@ -743,12 +746,7 @@  static void happy_meal_timer(struct timer_list *t)
 					netdev_notice(hp->dev,
 						      "Link down, cable problem?\n");
 
-					ret = happy_meal_init(hp);
-					if (ret) {
-						/* ho hum... */
-						netdev_err(hp->dev,
-							   "Error, cannot re-init the Happy Meal.\n");
-					}
+					happy_meal_begin_auto_negotiation(hp, tregs, NULL);
 					goto out;
 				}
 				if (!is_lucent_phy(hp)) {