Skip to content

Commit bb81bf6

Browse files
Jiasen Linjonmason
authored andcommitted
NTB: Fix an error in get link status
The offset of PCIe Capability Header for AMD and HYGON NTB is 0x64, but the macro which named "AMD_LINK_STATUS_OFFSET" is defined as 0x68. It is offset of Device Capabilities Reg rather than Link Control Reg. This code trigger an error in get link statsus: cat /sys/kernel/debug/ntb_hw_amd/0000:43:00.1/info LNK STA - 0x8fa1 Link Status - Up Link Speed - PCI-E Gen 0 Link Width - x0 This patch use pcie_capability_read_dword to get link status. After fix this issue, we can get link status accurately: cat /sys/kernel/debug/ntb_hw_amd/0000:43:00.1/info LNK STA - 0x11030042 Link Status - Up Link Speed - PCI-E Gen 3 Link Width - x16 Fixes: a1b3695 ("NTB: Add support for AMD PCI-Express Non-Transparent Bridge") Signed-off-by: Jiasen Lin <[email protected]> Signed-off-by: Jon Mason <[email protected]>
1 parent bb6d3fb commit bb81bf6

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

drivers/ntb/hw/amd/ntb_hw_amd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -855,8 +855,8 @@ static int amd_poll_link(struct amd_ntb_dev *ndev)
855855

856856
ndev->cntl_sta = reg;
857857

858-
rc = pci_read_config_dword(ndev->ntb.pdev,
859-
AMD_LINK_STATUS_OFFSET, &stat);
858+
rc = pcie_capability_read_dword(ndev->ntb.pdev,
859+
PCI_EXP_LNKCTL, &stat);
860860
if (rc)
861861
return 0;
862862
ndev->lnk_sta = stat;

drivers/ntb/hw/amd/ntb_hw_amd.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
#include <linux/pci.h>
5454

5555
#define AMD_LINK_HB_TIMEOUT msecs_to_jiffies(1000)
56-
#define AMD_LINK_STATUS_OFFSET 0x68
5756
#define NTB_LIN_STA_ACTIVE_BIT 0x00000002
5857
#define NTB_LNK_STA_SPEED_MASK 0x000F0000
5958
#define NTB_LNK_STA_WIDTH_MASK 0x03F00000

0 commit comments

Comments
 (0)