726-v5.5-net-sfp-avoid-power-switch-on-address-change-modules.patch 2.5 KB

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