Skip to content

Commit c1e900d

Browse files
committed
Merge branch 'pci/ptm'
- Enable PTM only if device advertises support for a relevant role, to prevent invalid PTM Requests that cause ACS violations that are reported as AER Uncorrectable Non-Fatal errors (Mika Westerberg) * pci/ptm: PCI/PTM: Enable only if device advertises relevant role
2 parents 5c5b875 + 044b9f1 commit c1e900d

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

drivers/pci/pcie/ptm.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ void pci_ptm_init(struct pci_dev *dev)
8181
dev->ptm_granularity = 0;
8282
}
8383

84+
if (cap & PCI_PTM_CAP_RES)
85+
dev->ptm_responder = 1;
86+
if (cap & PCI_PTM_CAP_REQ)
87+
dev->ptm_requester = 1;
88+
8489
if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT ||
8590
pci_pcie_type(dev) == PCI_EXP_TYPE_UPSTREAM)
8691
pci_enable_ptm(dev, NULL);
@@ -144,6 +149,24 @@ static int __pci_enable_ptm(struct pci_dev *dev)
144149
return -EINVAL;
145150
}
146151

152+
switch (pci_pcie_type(dev)) {
153+
case PCI_EXP_TYPE_ROOT_PORT:
154+
if (!dev->ptm_root)
155+
return -EINVAL;
156+
break;
157+
case PCI_EXP_TYPE_UPSTREAM:
158+
if (!dev->ptm_responder)
159+
return -EINVAL;
160+
break;
161+
case PCI_EXP_TYPE_ENDPOINT:
162+
case PCI_EXP_TYPE_LEG_END:
163+
if (!dev->ptm_requester)
164+
return -EINVAL;
165+
break;
166+
default:
167+
return -EINVAL;
168+
}
169+
147170
pci_read_config_dword(dev, ptm + PCI_PTM_CTRL, &ctrl);
148171

149172
ctrl |= PCI_PTM_CTRL_ENABLE;

include/linux/pci.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,8 @@ struct pci_dev {
500500
#ifdef CONFIG_PCIE_PTM
501501
u16 ptm_cap; /* PTM Capability */
502502
unsigned int ptm_root:1;
503+
unsigned int ptm_responder:1;
504+
unsigned int ptm_requester:1;
503505
unsigned int ptm_enabled:1;
504506
u8 ptm_granularity;
505507
#endif

0 commit comments

Comments
 (0)