The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* Re: [PATCH iwl-next v4 3/3] igc: add support for forcing link speed without autonegotiation
       [not found] ` <20260430135057.1653330-1-horms@kernel.org>
@ 2026-05-06  6:25   ` Abdul Rahim, Faizal
  2026-05-07 10:32     ` Simon Horman
  0 siblings, 1 reply; 2+ messages in thread
From: Abdul Rahim, Faizal @ 2026-05-06  6:25 UTC (permalink / raw)
  To: Simon Horman, khai.wen.tan
  Cc: anthony.l.nguyen, andrew+netdev, davem, edumazet, kuba, pabeni,
	intel-wired-lan, netdev, linux-kernel, faizal.abdul.rahim,
	hong.aun.looi, khai.wen.tan



On 30/4/2026 9:50 pm, Simon Horman wrote:
> From: 'Simon Horman' <horms@kernel.org>
> 
> This is an AI-generated review of your patch. The human sending this
> email has considered the AI review valid, or at least plausible.
> Full review at: https://sashiko.dev
> ---
> igc: add support for forcing link speed without autonegotiation
> 
> This commit allows users to force 10/100 Mb/s link speed and duplex via
> ethtool when autonegotiation is disabled. Previously, the driver rejected
> these requests.
> 
>> diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c
>> index cfcbf2fdad6e..9997ebbdf778 100644
>> --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c
>> +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c
> [ ... ]
>> @@ -2000,6 +2013,41 @@ static int igc_ethtool_get_link_ksettings(struct net_device *netdev,
>>  	return 0;
>>  }
>>  
>> +/**
>> + * igc_handle_autoneg_disabled - Configure forced speed/duplex settings
>> + * @adapter: private driver structure
>> + * @speed: requested speed (must be SPEED_10 or SPEED_100)
>> + * @duplex: requested duplex
>> + *
>> + * Records forced speed/duplex when autoneg is disabled.
>> + * Caller must validate speed before calling this function.
>> + */
>> +static void igc_handle_autoneg_disabled(struct igc_adapter *adapter, u32 speed,
>> +					u8 duplex)
>> +{
>> +	struct igc_mac_info *mac = &adapter->hw.mac;
>> +
>> +	switch (speed) {
>> +	case SPEED_10:
>> +		mac->forced_speed_duplex = (duplex == DUPLEX_FULL) ?
>> +			IGC_FORCED_10F : IGC_FORCED_10H;
>> +		break;
>> +	case SPEED_100:
>> +		mac->forced_speed_duplex = (duplex == DUPLEX_FULL) ?
>> +			IGC_FORCED_100F : IGC_FORCED_100H;
>> +		break;
>> +	default:
>> +		WARN_ONCE(1, "Unsupported speed %u\n", speed);
>> +		return;
>> +	}
>> +
>> +	mac->autoneg_enabled = false;
>> +
>> +	/* Half-duplex cannot support flow control per IEEE 802.3 */
>> +	if (duplex != DUPLEX_FULL)
>> +		adapter->hw.fc.requested_mode = igc_fc_none;
> 
> Does this permanently overwrite the user's flow control preference?
> 
> If half-duplex is requested, requested_mode is set to igc_fc_none. Because
> requested_mode represents the persistent state for the user's flow control
> preference, the user might permanently lose their configuration. If they later
> switch back to full-duplex, requested_mode remains igc_fc_none, and flow
> control stays disabled.
> 
> Would it be better to dynamically override hw->fc.current_mode to
> igc_fc_none during link configuration instead of mutating requested_mode?
> 

Yes you're right, thanks, will update.

>> +}
> [ ... ]
>> @@ -2071,14 +2126,20 @@ igc_ethtool_set_link_ksettings(struct net_device *netdev,
>>  		}
>>  	}
>>  
>> +	if (cmd->base.autoneg == AUTONEG_DISABLE &&
>> +	    cmd->base.speed != SPEED_10 && cmd->base.speed != SPEED_100) {
>> +		netdev_info(dev, "Unsupported speed for forced link\n");
>> +		return -EINVAL;
>> +	}
>> +
> 
> Should we also validate cmd->base.duplex here to prevent a fallback to
> half-duplex?
> 
> If a user runs a command like "ethtool -s eth0 speed 100 autoneg off" while
> the link is down, ethtool queries and preserves the current duplex value,
> which is DUPLEX_UNKNOWN (0xff).
> 
> In igc_handle_autoneg_disabled(), the code checks if duplex == DUPLEX_FULL,
> which evaluates to false, and forces the interface to 100 Mbps half-duplex.
> 
> Could we explicitly check that cmd->base.duplex is either DUPLEX_HALF or
> DUPLEX_FULL and return -EINVAL otherwise?

Will update.

> 
>>  	while (test_and_set_bit(__IGC_RESETTING, &adapter->state))
>>  		usleep_range(1000, 2000);
> 
> This isn't a bug introduced by this patch, but does this ad-hoc
> synchronization loop reimplement locking without fairness or lockdep support?
> 
> According to the Networking Subsystem Guidelines, using bit operations as a
> substitute for real locks violates core kernel locking rules and introduces
> potential races.
> 
> Could this be replaced with a proper concurrency mechanism such as a mutex?
> 

Hi Simon, you've raised this issue in v2, and after discussion, you've
agreed that this change doesn't belong in this patch series.

Not sure if I missed anything?

>>  
>> -	if (cmd->base.autoneg == AUTONEG_ENABLE) {
>> +	if (cmd->base.autoneg == AUTONEG_ENABLE)
>>  		igc_handle_autoneg_enabled(adapter, cmd);
>> -	} else {
>> -		netdev_info(dev, "Force mode currently not supported\n");
>> -	}
>> +	else
>> +		igc_handle_autoneg_disabled(adapter, cmd->base.speed,
>> +					    cmd->base.duplex);
>>  
>>  	/* MDI-X => 2; MDI => 1; Auto => 3 */
>>  	if (cmd->base.eth_tp_mdix_ctrl) {
> 


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

* Re: [PATCH iwl-next v4 3/3] igc: add support for forcing link speed without autonegotiation
  2026-05-06  6:25   ` [PATCH iwl-next v4 3/3] igc: add support for forcing link speed without autonegotiation Abdul Rahim, Faizal
@ 2026-05-07 10:32     ` Simon Horman
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2026-05-07 10:32 UTC (permalink / raw)
  To: Abdul Rahim, Faizal
  Cc: khai.wen.tan, anthony.l.nguyen, andrew+netdev, davem, edumazet,
	kuba, pabeni, intel-wired-lan, netdev, linux-kernel,
	faizal.abdul.rahim, hong.aun.looi, khai.wen.tan

On Wed, May 06, 2026 at 02:25:23PM +0800, Abdul Rahim, Faizal wrote:
> 
> 
> On 30/4/2026 9:50 pm, Simon Horman wrote:
> > From: 'Simon Horman' <horms@kernel.org>
> > 
> > This is an AI-generated review of your patch. The human sending this
> > email has considered the AI review valid, or at least plausible.
> > Full review at: https://sashiko.dev
> > ---
> > igc: add support for forcing link speed without autonegotiation
> > 
> > This commit allows users to force 10/100 Mb/s link speed and duplex via
> > ethtool when autonegotiation is disabled. Previously, the driver rejected
> > these requests.
> > 
> >> diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c
> >> index cfcbf2fdad6e..9997ebbdf778 100644
> >> --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c
> >> +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c
> > [ ... ]
> >> @@ -2000,6 +2013,41 @@ static int igc_ethtool_get_link_ksettings(struct net_device *netdev,
> >>  	return 0;
> >>  }
> >>  
> >> +/**
> >> + * igc_handle_autoneg_disabled - Configure forced speed/duplex settings
> >> + * @adapter: private driver structure
> >> + * @speed: requested speed (must be SPEED_10 or SPEED_100)
> >> + * @duplex: requested duplex
> >> + *
> >> + * Records forced speed/duplex when autoneg is disabled.
> >> + * Caller must validate speed before calling this function.
> >> + */
> >> +static void igc_handle_autoneg_disabled(struct igc_adapter *adapter, u32 speed,
> >> +					u8 duplex)
> >> +{
> >> +	struct igc_mac_info *mac = &adapter->hw.mac;
> >> +
> >> +	switch (speed) {
> >> +	case SPEED_10:
> >> +		mac->forced_speed_duplex = (duplex == DUPLEX_FULL) ?
> >> +			IGC_FORCED_10F : IGC_FORCED_10H;
> >> +		break;
> >> +	case SPEED_100:
> >> +		mac->forced_speed_duplex = (duplex == DUPLEX_FULL) ?
> >> +			IGC_FORCED_100F : IGC_FORCED_100H;
> >> +		break;
> >> +	default:
> >> +		WARN_ONCE(1, "Unsupported speed %u\n", speed);
> >> +		return;
> >> +	}
> >> +
> >> +	mac->autoneg_enabled = false;
> >> +
> >> +	/* Half-duplex cannot support flow control per IEEE 802.3 */
> >> +	if (duplex != DUPLEX_FULL)
> >> +		adapter->hw.fc.requested_mode = igc_fc_none;
> > 
> > Does this permanently overwrite the user's flow control preference?
> > 
> > If half-duplex is requested, requested_mode is set to igc_fc_none. Because
> > requested_mode represents the persistent state for the user's flow control
> > preference, the user might permanently lose their configuration. If they later
> > switch back to full-duplex, requested_mode remains igc_fc_none, and flow
> > control stays disabled.
> > 
> > Would it be better to dynamically override hw->fc.current_mode to
> > igc_fc_none during link configuration instead of mutating requested_mode?
> > 
> 
> Yes you're right, thanks, will update.
> 
> >> +}
> > [ ... ]
> >> @@ -2071,14 +2126,20 @@ igc_ethtool_set_link_ksettings(struct net_device *netdev,
> >>  		}
> >>  	}
> >>  
> >> +	if (cmd->base.autoneg == AUTONEG_DISABLE &&
> >> +	    cmd->base.speed != SPEED_10 && cmd->base.speed != SPEED_100) {
> >> +		netdev_info(dev, "Unsupported speed for forced link\n");
> >> +		return -EINVAL;
> >> +	}
> >> +
> > 
> > Should we also validate cmd->base.duplex here to prevent a fallback to
> > half-duplex?
> > 
> > If a user runs a command like "ethtool -s eth0 speed 100 autoneg off" while
> > the link is down, ethtool queries and preserves the current duplex value,
> > which is DUPLEX_UNKNOWN (0xff).
> > 
> > In igc_handle_autoneg_disabled(), the code checks if duplex == DUPLEX_FULL,
> > which evaluates to false, and forces the interface to 100 Mbps half-duplex.
> > 
> > Could we explicitly check that cmd->base.duplex is either DUPLEX_HALF or
> > DUPLEX_FULL and return -EINVAL otherwise?
> 
> Will update.
> 
> > 
> >>  	while (test_and_set_bit(__IGC_RESETTING, &adapter->state))
> >>  		usleep_range(1000, 2000);
> > 
> > This isn't a bug introduced by this patch, but does this ad-hoc
> > synchronization loop reimplement locking without fairness or lockdep support?
> > 
> > According to the Networking Subsystem Guidelines, using bit operations as a
> > substitute for real locks violates core kernel locking rules and introduces
> > potential races.
> > 
> > Could this be replaced with a proper concurrency mechanism such as a mutex?
> > 
> 
> Hi Simon, you've raised this issue in v2, and after discussion, you've
> agreed that this change doesn't belong in this patch series.
> 
> Not sure if I missed anything?

Sorry, my bad. I missed that we'd already covered this one.

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

end of thread, other threads:[~2026-05-07 10:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20260428060009.311393-4-khai.wen.tan@linux.intel.com>
     [not found] ` <20260430135057.1653330-1-horms@kernel.org>
2026-05-06  6:25   ` [PATCH iwl-next v4 3/3] igc: add support for forcing link speed without autonegotiation Abdul Rahim, Faizal
2026-05-07 10:32     ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox