提交 66feadda 编写于 作者: J Jiasen Lin 提交者: Yang Yingliang

NTB: Fix an error in get link status

mainline inclusion
from mainline-v5.7-rc1
commit bb81bf62
category: bugfix
bugzilla: NA
CVE: NA
---------------------------

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: a1b36958 ("NTB: Add support for AMD PCI-Express Non-Transparent Bridge")
Signed-off-by: NJiasen Lin <linjiasen@hygon.cn>
Signed-off-by: NJon Mason <jdmason@kudzu.us>
Signed-off-by: NHanjun Guo <guohanjun@huawei.com>
Reviewed-by: NXie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 81806f38
...@@ -855,8 +855,8 @@ static int amd_poll_link(struct amd_ntb_dev *ndev) ...@@ -855,8 +855,8 @@ static int amd_poll_link(struct amd_ntb_dev *ndev)
ndev->cntl_sta = reg; ndev->cntl_sta = reg;
rc = pci_read_config_dword(ndev->ntb.pdev, rc = pcie_capability_read_dword(ndev->ntb.pdev,
AMD_LINK_STATUS_OFFSET, &stat); PCI_EXP_LNKCTL, &stat);
if (rc) if (rc)
return 0; return 0;
ndev->lnk_sta = stat; ndev->lnk_sta = stat;
......
...@@ -54,7 +54,6 @@ ...@@ -54,7 +54,6 @@
#define PCI_DEVICE_ID_AMD_NTB 0x145B #define PCI_DEVICE_ID_AMD_NTB 0x145B
#define AMD_LINK_HB_TIMEOUT msecs_to_jiffies(1000) #define AMD_LINK_HB_TIMEOUT msecs_to_jiffies(1000)
#define AMD_LINK_STATUS_OFFSET 0x68
#define NTB_LIN_STA_ACTIVE_BIT 0x00000002 #define NTB_LIN_STA_ACTIVE_BIT 0x00000002
#define NTB_LNK_STA_SPEED_MASK 0x000F0000 #define NTB_LNK_STA_SPEED_MASK 0x000F0000
#define NTB_LNK_STA_WIDTH_MASK 0x03F00000 #define NTB_LNK_STA_WIDTH_MASK 0x03F00000
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册