b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | From dca678b8838945572cf50584cb33a7199c1fd397 Mon Sep 17 00:00:00 2001 |
| 2 | From: Russell King <rmk+kernel@armlinux.org.uk> |
| 3 | Date: Thu, 17 Oct 2019 00:24:18 +0100 |
| 4 | Subject: [PATCH 624/660] net: sfp: avoid power switch on address-change |
| 5 | modules |
| 6 | |
| 7 | If the module indicates that it requires an address change sequence to |
| 8 | switch between address 0x50 and 0x51, which we don't support, we can't |
| 9 | write to the register that controls the power mode to switch to high |
| 10 | power mode. Warn the user that the module may not be functional in |
| 11 | this case, and don't try to change the power mode. |
| 12 | |
| 13 | Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> |
| 14 | --- |
| 15 | drivers/net/phy/sfp.c | 31 ++++++++++++++++++++----------- |
| 16 | 1 file changed, 20 insertions(+), 11 deletions(-) |
| 17 | |
| 18 | --- a/drivers/net/phy/sfp.c |
| 19 | +++ b/drivers/net/phy/sfp.c |
| 20 | @@ -1385,25 +1385,34 @@ static int sfp_module_parse_power(struct |
| 21 | if (sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_HIGH_POWER_LEVEL)) |
| 22 | power_mW = 2000; |
| 23 | |
| 24 | - if (sfp->id.ext.sff8472_compliance == SFP_SFF8472_COMPLIANCE_NONE && |
| 25 | - (sfp->id.ext.diagmon & (SFP_DIAGMON_DDM | SFP_DIAGMON_ADDRMODE)) != |
| 26 | - SFP_DIAGMON_DDM) { |
| 27 | - /* The module appears not to implement bus address 0xa2, |
| 28 | - * or requires an address change sequence, so assume that |
| 29 | - * the module powers up in the indicated power mode. |
| 30 | - */ |
| 31 | - if (power_mW > sfp->max_power_mW) { |
| 32 | + if (power_mW > sfp->max_power_mW) { |
| 33 | + /* Module power specification exceeds the allowed maximum. */ |
| 34 | + if (sfp->id.ext.sff8472_compliance == |
| 35 | + SFP_SFF8472_COMPLIANCE_NONE && |
| 36 | + !(sfp->id.ext.diagmon & SFP_DIAGMON_DDM)) { |
| 37 | + /* The module appears not to implement bus address |
| 38 | + * 0xa2, so assume that the module powers up in the |
| 39 | + * indicated mode. |
| 40 | + */ |
| 41 | dev_err(sfp->dev, |
| 42 | "Host does not support %u.%uW modules\n", |
| 43 | power_mW / 1000, (power_mW / 100) % 10); |
| 44 | return -EINVAL; |
| 45 | + } else { |
| 46 | + dev_warn(sfp->dev, |
| 47 | + "Host does not support %u.%uW modules, module left in power mode 1\n", |
| 48 | + power_mW / 1000, (power_mW / 100) % 10); |
| 49 | + return 0; |
| 50 | } |
| 51 | - return 0; |
| 52 | } |
| 53 | |
| 54 | - if (power_mW > sfp->max_power_mW) { |
| 55 | + /* If the module requires a higher power mode, but also requires |
| 56 | + * an address change sequence, warn the user that the module may |
| 57 | + * not be functional. |
| 58 | + */ |
| 59 | + if (sfp->id.ext.diagmon & SFP_DIAGMON_ADDRMODE && power_mW > 1000) { |
| 60 | dev_warn(sfp->dev, |
| 61 | - "Host does not support %u.%uW modules, module left in power mode 1\n", |
| 62 | + "Address Change Sequence not supported but module requies %u.%uW, module may not be functional\n", |
| 63 | power_mW / 1000, (power_mW / 100) % 10); |
| 64 | return 0; |
| 65 | } |