Skip to content

Commit f0c260f

Browse files
basuamdjonmason
authored andcommitted
ntb_hw_amd: Update amd_ntb_get_link_status to support latest generation secondary topology
In the NTB secondary topology configuration of the latest generation, the device behaves like an endpoint. Hence, add endpoint support and update amd_ntb_get_link_status to accommodate endpoint devices. Co-developed-by: Sanath S <Sanath.S@amd.com> Signed-off-by: Sanath S <Sanath.S@amd.com> Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Jon Mason <jdmason@kudzu.us>
1 parent 8f5ae30 commit f0c260f

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

drivers/ntb/hw/amd/ntb_hw_amd.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,22 @@ static int amd_ntb_mw_set_trans(struct ntb_dev *ntb, int pidx, int idx,
197197

198198
static int amd_ntb_get_link_status(struct amd_ntb_dev *ndev)
199199
{
200-
struct pci_dev *pdev = NULL;
200+
struct pci_dev *pdev = ndev->ntb.pdev;
201201
struct pci_dev *pci_swds = NULL;
202202
struct pci_dev *pci_swus = NULL;
203203
u32 stat;
204204
int rc;
205205

206206
if (ndev->ntb.topo == NTB_TOPO_SEC) {
207+
if (ndev->dev_data->is_endpoint) {
208+
rc = pcie_capability_read_dword(pdev, PCI_EXP_LNKCTL, &stat);
209+
if (rc)
210+
return rc;
211+
212+
ndev->lnk_sta = stat;
213+
return 0;
214+
}
215+
207216
/* Locate the pointer to Downstream Switch for this device */
208217
pci_swds = pci_upstream_bridge(ndev->ntb.pdev);
209218
if (pci_swds) {
@@ -1311,6 +1320,11 @@ static const struct ntb_dev_data dev_data[] = {
13111320
.mw_count = 2,
13121321
.mw_idx = 2,
13131322
},
1323+
{ /* for device 0x17d7 */
1324+
.mw_count = 2,
1325+
.mw_idx = 2,
1326+
.is_endpoint = true,
1327+
},
13141328
};
13151329

13161330
static const struct pci_device_id amd_ntb_pci_tbl[] = {
@@ -1319,6 +1333,8 @@ static const struct pci_device_id amd_ntb_pci_tbl[] = {
13191333
{ PCI_VDEVICE(AMD, 0x14c0), (kernel_ulong_t)&dev_data[1] },
13201334
{ PCI_VDEVICE(AMD, 0x14c3), (kernel_ulong_t)&dev_data[1] },
13211335
{ PCI_VDEVICE(AMD, 0x155a), (kernel_ulong_t)&dev_data[1] },
1336+
{ PCI_VDEVICE(AMD, 0x17d4), (kernel_ulong_t)&dev_data[1] },
1337+
{ PCI_VDEVICE(AMD, 0x17d7), (kernel_ulong_t)&dev_data[2] },
13221338
{ PCI_VDEVICE(HYGON, 0x145b), (kernel_ulong_t)&dev_data[0] },
13231339
{ 0, }
13241340
};

drivers/ntb/hw/amd/ntb_hw_amd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ enum {
168168
struct ntb_dev_data {
169169
const unsigned char mw_count;
170170
const unsigned int mw_idx;
171+
const bool is_endpoint;
171172
};
172173

173174
struct amd_ntb_dev;

0 commit comments

Comments
 (0)