Skip to content

Commit 5765cee

Browse files
Russell King (Oracle)davem330
authored andcommitted
net: sfp: fix high power modules without diagnostic monitoring
Commit 7cfa9c9 ("net: sfp: avoid power switch on address-change modules") unintetionally changed the semantics for high power modules without the digital diagnostics monitoring. We repeatedly attempt to read the power status from the non-existing 0xa2 address in a futile hope this failure is temporary: [ 8.856051] sfp sfp-eth3: module NTT 0000000000000000 rev 0000 sn 0000000000000000 dc 160408 [ 8.865843] mvpp2 f4000000.ethernet eth3: switched to inband/1000base-x link mode [ 8.873469] sfp sfp-eth3: Failed to read EEPROM: -5 [ 8.983251] sfp sfp-eth3: Failed to read EEPROM: -5 [ 9.103250] sfp sfp-eth3: Failed to read EEPROM: -5 We previosuly assumed such modules were powered up in the correct mode, continuing without further configuration as long as the required power class was supported by the host. Restore this behaviour, while preserving the intent of subsequent patches to avoid the "Address Change Sequence not supported" warning if we are not going to be accessing the DDM address. Fixes: 7cfa9c9 ("net: sfp: avoid power switch on address-change modules") Reported-by: 照山周一郎 <[email protected]> Tested-by: 照山周一郎 <[email protected]> Signed-off-by: Russell King (Oracle) <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9ea674d commit 5765cee

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

drivers/net/phy/sfp.c

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,17 +1641,20 @@ static int sfp_sm_probe_for_phy(struct sfp *sfp)
16411641
static int sfp_module_parse_power(struct sfp *sfp)
16421642
{
16431643
u32 power_mW = 1000;
1644+
bool supports_a2;
16441645

16451646
if (sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_POWER_DECL))
16461647
power_mW = 1500;
16471648
if (sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_HIGH_POWER_LEVEL))
16481649
power_mW = 2000;
16491650

1651+
supports_a2 = sfp->id.ext.sff8472_compliance !=
1652+
SFP_SFF8472_COMPLIANCE_NONE ||
1653+
sfp->id.ext.diagmon & SFP_DIAGMON_DDM;
1654+
16501655
if (power_mW > sfp->max_power_mW) {
16511656
/* Module power specification exceeds the allowed maximum. */
1652-
if (sfp->id.ext.sff8472_compliance ==
1653-
SFP_SFF8472_COMPLIANCE_NONE &&
1654-
!(sfp->id.ext.diagmon & SFP_DIAGMON_DDM)) {
1657+
if (!supports_a2) {
16551658
/* The module appears not to implement bus address
16561659
* 0xa2, so assume that the module powers up in the
16571660
* indicated mode.
@@ -1668,11 +1671,25 @@ static int sfp_module_parse_power(struct sfp *sfp)
16681671
}
16691672
}
16701673

1674+
if (power_mW <= 1000) {
1675+
/* Modules below 1W do not require a power change sequence */
1676+
sfp->module_power_mW = power_mW;
1677+
return 0;
1678+
}
1679+
1680+
if (!supports_a2) {
1681+
/* The module power level is below the host maximum and the
1682+
* module appears not to implement bus address 0xa2, so assume
1683+
* that the module powers up in the indicated mode.
1684+
*/
1685+
return 0;
1686+
}
1687+
16711688
/* If the module requires a higher power mode, but also requires
16721689
* an address change sequence, warn the user that the module may
16731690
* not be functional.
16741691
*/
1675-
if (sfp->id.ext.diagmon & SFP_DIAGMON_ADDRMODE && power_mW > 1000) {
1692+
if (sfp->id.ext.diagmon & SFP_DIAGMON_ADDRMODE) {
16761693
dev_warn(sfp->dev,
16771694
"Address Change Sequence not supported but module requires %u.%uW, module may not be functional\n",
16781695
power_mW / 1000, (power_mW / 100) % 10);

0 commit comments

Comments
 (0)