NTB: return link up status correctly for PRI and SEC
authorArindam Nath <arindam.nath@amd.com>
Wed, 5 Feb 2020 15:54:29 +0000 (21:24 +0530)
committerJon Mason <jdmason@kudzu.us>
Fri, 13 Mar 2020 14:04:20 +0000 (10:04 -0400)
commit5f0856bebc6e02a57b36cd2146f056c71862f0b6
treec12a06b2997e2430aa440468e5be7059f50b4be2
parentae5f4bdccf030d524f995dfc364ea6a96c22882c
NTB: return link up status correctly for PRI and SEC

Since NTB connects two physically separate systems,
there can be scenarios where one system goes down
while the other one remains active. In case of NTB
primary, if the NTB secondary goes down, a Link-Down
event is received. For the NTB secondary, if the
NTB primary goes down, the PCIe hotplug mechanism
ensures that the driver on the secondary side is also
unloaded.

But there are other scenarios to consider as well,
when suppose the physical link remains active, but
the driver on primary or secondary side is loaded
or un-loaded.

When the driver is loaded, on either side, it sets
SIDE_READY bit(bit-1) of SIDE_INFO register. Similarly,
when the driver is un-loaded, it resets the same bit.

We consider the NTB link to be up and operational
only when the driver on both sides of link are loaded
and ready. But we also need to take account of
Link Up and Down events which signify the physical
link status. So amd_link_is_up() is modified to take
care of the above scenarios.

Signed-off-by: Arindam Nath <arindam.nath@amd.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>
drivers/ntb/hw/amd/ntb_hw_amd.c
drivers/ntb/hw/amd/ntb_hw_amd.h