Skip to content

Commit 233fa44

Browse files
jpirkodavem330
authored andcommitted
mlxsw: pci: Implement reset done check
Firmware now tells us that the reset is done by passing a magic value via register. Use it to shorten the wait in case this is supported. With old firmware, we still wait until the timeout is reached. Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent cea8768 commit 233fa44

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

drivers/net/ethernet/mellanox/mlxsw/pci.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,11 +1681,18 @@ static const struct mlxsw_bus mlxsw_pci_bus = {
16811681

16821682
static int mlxsw_pci_sw_reset(struct mlxsw_pci *mlxsw_pci)
16831683
{
1684+
unsigned long end;
1685+
16841686
mlxsw_pci_write32(mlxsw_pci, SW_RESET, MLXSW_PCI_SW_RESET_RST_BIT);
1685-
/* Current firware does not let us know when the reset is done.
1686-
* So we just wait here for constant time and hope for the best.
1687-
*/
1688-
msleep(MLXSW_PCI_SW_RESET_TIMEOUT_MSECS);
1687+
wmb(); /* reset needs to be written before we read control register */
1688+
end = jiffies + msecs_to_jiffies(MLXSW_PCI_SW_RESET_TIMEOUT_MSECS);
1689+
do {
1690+
u32 val = mlxsw_pci_read32(mlxsw_pci, FW_READY);
1691+
1692+
if ((val & MLXSW_PCI_FW_READY_MASK) == MLXSW_PCI_FW_READY_MAGIC)
1693+
break;
1694+
cond_resched();
1695+
} while (time_before(jiffies, end));
16891696
return 0;
16901697
}
16911698

drivers/net/ethernet/mellanox/mlxsw/pci.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@
6161
#define MLXSW_PCI_SW_RESET 0xF0010
6262
#define MLXSW_PCI_SW_RESET_RST_BIT BIT(0)
6363
#define MLXSW_PCI_SW_RESET_TIMEOUT_MSECS 5000
64+
#define MLXSW_PCI_FW_READY 0xA1844
65+
#define MLXSW_PCI_FW_READY_MASK 0xFF
66+
#define MLXSW_PCI_FW_READY_MAGIC 0x5E
6467

6568
#define MLXSW_PCI_DOORBELL_SDQ_OFFSET 0x000
6669
#define MLXSW_PCI_DOORBELL_RDQ_OFFSET 0x200

0 commit comments

Comments
 (0)