platform/mellanox: mlxreg-hotplug: Improve mechanism of ASIC health discovery

Simplify the logic of ASIC health discovery.
ASIC device can indicate its health state as a good, booting or dormant.
During ASIC reset the device is dropped to dormant state and should get to
the stable good health state through the intermediate booting state.
The sequence for getting to the steady state health after reset is:
(dormant -> booting -> good)+.
Initial implementation assumes that ?good? within this sequence is always
repeated twice and device is getting steady state only after the second
?good?. This patch removes this dependency, since the second ?good? is
received because of the noise on line and can be ignored. Device reaches
steady state after the first ?good? is received.

Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart (VMware) <dvhart@infradead.org>
This commit is contained in:
Vadim Pasternak 2018-07-26 22:40:58 +00:00 committed by Darren Hart (VMware)
parent 0378123c58
commit 66342d1c9c
1 changed files with 26 additions and 8 deletions

View File

@ -50,9 +50,8 @@
#define MLXREG_HOTPLUG_MASK_OFF 2
#define MLXREG_HOTPLUG_AGGR_MASK_OFF 1
/* ASIC health parameters. */
#define MLXREG_HOTPLUG_HEALTH_MASK 0x02
#define MLXREG_HOTPLUG_RST_CNTR 3
/* ASIC good health mask. */
#define MLXREG_HOTPLUG_GOOD_HEALTH_MASK 0x02
#define MLXREG_HOTPLUG_ATTRS_MAX 24
#define MLXREG_HOTPLUG_NOT_ASSERT 3
@ -325,21 +324,40 @@ mlxreg_hotplug_health_work_helper(struct mlxreg_hotplug_priv_data *priv,
goto out;
regval &= data->mask;
item->cache = regval;
if (regval == MLXREG_HOTPLUG_HEALTH_MASK) {
if ((data->health_cntr++ == MLXREG_HOTPLUG_RST_CNTR) ||
!priv->after_probe) {
if (item->cache == regval)
goto ack_event;
/*
* ASIC health indication is provided through two bits. Bits
* value 0x2 indicates that ASIC reached the good health, value
* 0x0 indicates ASIC the bad health or dormant state and value
* 0x3 indicates the booting state. During ASIC reset it should
* pass the following states: dormant -> booting -> good.
*/
if (regval == MLXREG_HOTPLUG_GOOD_HEALTH_MASK) {
if (!data->attached) {
/*
* ASIC is in steady state. Connect associated
* device, if configured.
*/
mlxreg_hotplug_device_create(priv, data);
data->attached = true;
}
} else {
if (data->attached) {
/*
* ASIC health is failed after ASIC has been
* in steady state. Disconnect associated
* device, if it has been connected.
*/
mlxreg_hotplug_device_destroy(data);
data->attached = false;
data->health_cntr = 0;
}
}
item->cache = regval;
ack_event:
/* Acknowledge event. */
ret = regmap_write(priv->regmap, data->reg +
MLXREG_HOTPLUG_EVENT_OFF, 0);