Skip to content

Commit 127cd68

Browse files
committed
Merge branch 'rework-sfp-a2-access-conditionals'
Russell King says: ==================== Rework SFP A2 access conditionals This series reworks the SFP A2 (diagnostics and control) access so we don't end up testing a variable number of conditions in several places. This also resolves a minor issue where we may have a module indicating that it is not SFF8472 compliant, doesn't implement A2, but fails to set the enhanced option byte to zero, leading to accesses to the A2 page that fail. The first patch adds a new flag "have_a2" which indicates whether we should be accessing the A2 page, and uses this for hwmon. The conditions are kept the same. The second patch extends the check for soft-state polling and control by using this "have_a2" flag (which effectively augments the check to include some level of SFF8472 compliance.) ==================== Link: https://lore.kernel.org/r/ZAoBnqGBnIZzLwpV@shell.armlinux.org.uk Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents c568a8d + 5daed42 commit 127cd68

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed

drivers/net/phy/sfp.c

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ struct sfp {
255255
unsigned int module_power_mW;
256256
unsigned int module_t_start_up;
257257
unsigned int module_t_wait;
258+
259+
bool have_a2;
258260
bool tx_fault_ignore;
259261

260262
const struct sfp_quirk *quirk;
@@ -1453,20 +1455,10 @@ static void sfp_hwmon_probe(struct work_struct *work)
14531455

14541456
static int sfp_hwmon_insert(struct sfp *sfp)
14551457
{
1456-
if (sfp->id.ext.sff8472_compliance == SFP_SFF8472_COMPLIANCE_NONE)
1457-
return 0;
1458-
1459-
if (!(sfp->id.ext.diagmon & SFP_DIAGMON_DDM))
1460-
return 0;
1461-
1462-
if (sfp->id.ext.diagmon & SFP_DIAGMON_ADDRMODE)
1463-
/* This driver in general does not support address
1464-
* change.
1465-
*/
1466-
return 0;
1467-
1468-
mod_delayed_work(system_wq, &sfp->hwmon_probe, 1);
1469-
sfp->hwmon_tries = R_PROBE_RETRY_SLOW;
1458+
if (sfp->have_a2 && sfp->id.ext.diagmon & SFP_DIAGMON_DDM) {
1459+
mod_delayed_work(system_wq, &sfp->hwmon_probe, 1);
1460+
sfp->hwmon_tries = R_PROBE_RETRY_SLOW;
1461+
}
14701462

14711463
return 0;
14721464
}
@@ -1916,6 +1908,18 @@ static int sfp_cotsworks_fixup_check(struct sfp *sfp, struct sfp_eeprom_id *id)
19161908
return 0;
19171909
}
19181910

1911+
static int sfp_module_parse_sff8472(struct sfp *sfp)
1912+
{
1913+
/* If the module requires address swap mode, warn about it */
1914+
if (sfp->id.ext.diagmon & SFP_DIAGMON_ADDRMODE)
1915+
dev_warn(sfp->dev,
1916+
"module address swap to access page 0xA2 is not supported.\n");
1917+
else
1918+
sfp->have_a2 = true;
1919+
1920+
return 0;
1921+
}
1922+
19191923
static int sfp_sm_mod_probe(struct sfp *sfp, bool report)
19201924
{
19211925
/* SFP module inserted - read I2C data */
@@ -2053,10 +2057,11 @@ static int sfp_sm_mod_probe(struct sfp *sfp, bool report)
20532057
return -EINVAL;
20542058
}
20552059

2056-
/* If the module requires address swap mode, warn about it */
2057-
if (sfp->id.ext.diagmon & SFP_DIAGMON_ADDRMODE)
2058-
dev_warn(sfp->dev,
2059-
"module address swap to access page 0xA2 is not supported.\n");
2060+
if (sfp->id.ext.sff8472_compliance != SFP_SFF8472_COMPLIANCE_NONE) {
2061+
ret = sfp_module_parse_sff8472(sfp);
2062+
if (ret < 0)
2063+
return ret;
2064+
}
20602065

20612066
/* Parse the module power requirement */
20622067
ret = sfp_module_parse_power(sfp);
@@ -2103,6 +2108,7 @@ static void sfp_sm_mod_remove(struct sfp *sfp)
21032108

21042109
memset(&sfp->id, 0, sizeof(sfp->id));
21052110
sfp->module_power_mW = 0;
2111+
sfp->have_a2 = false;
21062112

21072113
dev_info(sfp->dev, "module removed\n");
21082114
}
@@ -2278,7 +2284,11 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event)
22782284
sfp->sm_dev_state != SFP_DEV_UP)
22792285
break;
22802286

2281-
if (!(sfp->id.ext.diagmon & SFP_DIAGMON_ADDRMODE))
2287+
/* Only use the soft state bits if we have access to the A2h
2288+
* memory, which implies that we have some level of SFF-8472
2289+
* compliance.
2290+
*/
2291+
if (sfp->have_a2)
22822292
sfp_soft_start_poll(sfp);
22832293

22842294
sfp_module_tx_enable(sfp);

0 commit comments

Comments
 (0)