NTB: Fix access to link status and control register
authorArindam Nath <arindam.nath@amd.com>
Wed, 5 Feb 2020 15:54:18 +0000 (21:24 +0530)
committerJon Mason <jdmason@kudzu.us>
Fri, 13 Mar 2020 14:04:19 +0000 (10:04 -0400)
commitcb004c28dd2fabbb57bc03fb002f780054c28780
treedfdb413825fd4ced57703b9e88f40897365e7dff
parent8ad1a2f351c1ade21ad7a2f0bc34fc887878f965
NTB: Fix access to link status and control register

The design of AMD NTB implementation is such that
NTB primary acts as an endpoint device and NTB
secondary is an endpoint device behind a combination
of Switch Upstream and Switch Downstream. Considering
that, the link status and control register needs to
be accessed differently based on the NTB topology.

So in the case of NTB secondary, we first get the
pointer to the Switch Downstream device for the NTB
device. Then we get the pointer to the Switch Upstream
device. Once we have that, we read the Link Status
and Control register to get the correct status of
link at the secondary.

In the case of NTB primary, simply reading the Link
Status and Control register of the NTB device itself
will suffice.

Suggested-by: Jiasen Lin <linjiasen@hygon.cn>
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