forked from sophgo/linux_5.10
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PCI/ERR: Cache RCEC EA Capability offset in pci_init_capabilities()
Extend support for Root Complex Event Collectors by decoding and caching the RCEC Endpoint Association Extended Capabilities when enumerating. Use that cached information for later error source reporting. See PCIe r5.0, sec 7.9.10. Co-developed-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com> Link: https://lore.kernel.org/r/20201121001036.8560-4-sean.v.kelley@intel.com Tested-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> # non-native/no RCEC Signed-off-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com> Signed-off-by: Sean V Kelley <sean.v.kelley@intel.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
- Loading branch information
1 parent
c9d659b
commit 9065563
Showing
5 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* | ||
* Root Complex Event Collector Support | ||
* | ||
* Authors: | ||
* Sean V Kelley <sean.v.kelley@intel.com> | ||
* Qiuxu Zhuo <qiuxu.zhuo@intel.com> | ||
* | ||
* Copyright (C) 2020 Intel Corp. | ||
*/ | ||
|
||
#include <linux/kernel.h> | ||
#include <linux/pci.h> | ||
#include <linux/pci_regs.h> | ||
|
||
#include "../pci.h" | ||
|
||
void pci_rcec_init(struct pci_dev *dev) | ||
{ | ||
struct rcec_ea *rcec_ea; | ||
u32 rcec, hdr, busn; | ||
u8 ver; | ||
|
||
/* Only for Root Complex Event Collectors */ | ||
if (pci_pcie_type(dev) != PCI_EXP_TYPE_RC_EC) | ||
return; | ||
|
||
rcec = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_RCEC); | ||
if (!rcec) | ||
return; | ||
|
||
rcec_ea = kzalloc(sizeof(*rcec_ea), GFP_KERNEL); | ||
if (!rcec_ea) | ||
return; | ||
|
||
pci_read_config_dword(dev, rcec + PCI_RCEC_RCIEP_BITMAP, | ||
&rcec_ea->bitmap); | ||
|
||
/* Check whether RCEC BUSN register is present */ | ||
pci_read_config_dword(dev, rcec, &hdr); | ||
ver = PCI_EXT_CAP_VER(hdr); | ||
if (ver >= PCI_RCEC_BUSN_REG_VER) { | ||
pci_read_config_dword(dev, rcec + PCI_RCEC_BUSN, &busn); | ||
rcec_ea->nextbusn = PCI_RCEC_BUSN_NEXT(busn); | ||
rcec_ea->lastbusn = PCI_RCEC_BUSN_LAST(busn); | ||
} else { | ||
/* Avoid later ver check by setting nextbusn */ | ||
rcec_ea->nextbusn = 0xff; | ||
rcec_ea->lastbusn = 0x00; | ||
} | ||
|
||
dev->rcec_ea = rcec_ea; | ||
} | ||
|
||
void pci_rcec_exit(struct pci_dev *dev) | ||
{ | ||
kfree(dev->rcec_ea); | ||
dev->rcec_ea = NULL; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters