aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeith Busch <keith.busch@intel.com>2018-07-19 17:16:55 -0400
committerBjorn Helgaas <bhelgaas@google.com>2018-07-19 17:16:55 -0400
commit1e4511604dfaf6d1642603ff89effb9e93682716 (patch)
tree818e07661f0c3800ea7c05c1ce30d66bb74559a2
parentce397d215ccd07b8ae3f71db689aedb85d56ab40 (diff)
PCI/AER: Expose internal API for obtaining AER information
Export some common AER functions and structures for other PCI core drivers to use. Since this is making the function externally visible inside the PCI core, prepend "aer_" to the function name. Signed-off-by: Keith Busch <keith.busch@intel.com> [bhelgaas: move AER declarations from linux/aer.h to drivers/pci/pci.h] Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Sinan Kaya <okaya@kernel.org> Reviewed-by: Oza Pawandeep <poza@codeaurora.org>
-rw-r--r--drivers/pci/pci.h28
-rw-r--r--drivers/pci/pcie/aer.c30
2 files changed, 33 insertions, 25 deletions
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index c358e7a07f3f..4f723442f602 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -300,6 +300,34 @@ static inline bool pci_dev_is_disconnected(const struct pci_dev *dev)
300 return test_bit(PCI_DEV_DISCONNECTED, &dev->priv_flags); 300 return test_bit(PCI_DEV_DISCONNECTED, &dev->priv_flags);
301} 301}
302 302
303#ifdef CONFIG_PCIEAER
304#include <linux/aer.h>
305
306#define AER_MAX_MULTI_ERR_DEVICES 5 /* Not likely to have more */
307
308struct aer_err_info {
309 struct pci_dev *dev[AER_MAX_MULTI_ERR_DEVICES];
310 int error_dev_num;
311
312 unsigned int id:16;
313
314 unsigned int severity:2; /* 0:NONFATAL | 1:FATAL | 2:COR */
315 unsigned int __pad1:5;
316 unsigned int multi_error_valid:1;
317
318 unsigned int first_error:5;
319 unsigned int __pad2:2;
320 unsigned int tlp_header_valid:1;
321
322 unsigned int status; /* COR/UNCOR Error Status */
323 unsigned int mask; /* COR/UNCOR Error Mask */
324 struct aer_header_log_regs tlp; /* TLP Header */
325};
326
327int aer_get_device_error_info(struct pci_dev *dev, struct aer_err_info *info);
328void aer_print_error(struct pci_dev *dev, struct aer_err_info *info);
329#endif /* CONFIG_PCIEAER */
330
303#ifdef CONFIG_PCI_ATS 331#ifdef CONFIG_PCI_ATS
304void pci_restore_ats_state(struct pci_dev *dev); 332void pci_restore_ats_state(struct pci_dev *dev);
305#else 333#else
diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index a2e88386af28..0a60275f0582 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -31,26 +31,6 @@
31#include "portdrv.h" 31#include "portdrv.h"
32 32
33#define AER_ERROR_SOURCES_MAX 100 33#define AER_ERROR_SOURCES_MAX 100
34#define AER_MAX_MULTI_ERR_DEVICES 5 /* Not likely to have more */
35
36struct aer_err_info {
37 struct pci_dev *dev[AER_MAX_MULTI_ERR_DEVICES];
38 int error_dev_num;
39
40 unsigned int id:16;
41
42 unsigned int severity:2; /* 0:NONFATAL | 1:FATAL | 2:COR */
43 unsigned int __pad1:5;
44 unsigned int multi_error_valid:1;
45
46 unsigned int first_error:5;
47 unsigned int __pad2:2;
48 unsigned int tlp_header_valid:1;
49
50 unsigned int status; /* COR/UNCOR Error Status */
51 unsigned int mask; /* COR/UNCOR Error Mask */
52 struct aer_header_log_regs tlp; /* TLP Header */
53};
54 34
55struct aer_err_source { 35struct aer_err_source {
56 unsigned int status; 36 unsigned int status;
@@ -547,7 +527,7 @@ static void __aer_print_error(struct pci_dev *dev,
547 } 527 }
548} 528}
549 529
550static void aer_print_error(struct pci_dev *dev, struct aer_err_info *info) 530void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
551{ 531{
552 int layer, agent; 532 int layer, agent;
553 int id = ((dev->bus->number << 8) | dev->devfn); 533 int id = ((dev->bus->number << 8) | dev->devfn);
@@ -876,7 +856,7 @@ EXPORT_SYMBOL_GPL(aer_recover_queue);
876#endif 856#endif
877 857
878/** 858/**
879 * get_device_error_info - read error status from dev and store it to info 859 * aer_get_device_error_info - read error status from dev and store it to info
880 * @dev: pointer to the device expected to have a error record 860 * @dev: pointer to the device expected to have a error record
881 * @info: pointer to structure to store the error record 861 * @info: pointer to structure to store the error record
882 * 862 *
@@ -884,7 +864,7 @@ EXPORT_SYMBOL_GPL(aer_recover_queue);
884 * 864 *
885 * Note that @info is reused among all error devices. Clear fields properly. 865 * Note that @info is reused among all error devices. Clear fields properly.
886 */ 866 */
887static int get_device_error_info(struct pci_dev *dev, struct aer_err_info *info) 867int aer_get_device_error_info(struct pci_dev *dev, struct aer_err_info *info)
888{ 868{
889 int pos, temp; 869 int pos, temp;
890 870
@@ -942,11 +922,11 @@ static inline void aer_process_err_devices(struct aer_err_info *e_info)
942 922
943 /* Report all before handle them, not to lost records by reset etc. */ 923 /* Report all before handle them, not to lost records by reset etc. */
944 for (i = 0; i < e_info->error_dev_num && e_info->dev[i]; i++) { 924 for (i = 0; i < e_info->error_dev_num && e_info->dev[i]; i++) {
945 if (get_device_error_info(e_info->dev[i], e_info)) 925 if (aer_get_device_error_info(e_info->dev[i], e_info))
946 aer_print_error(e_info->dev[i], e_info); 926 aer_print_error(e_info->dev[i], e_info);
947 } 927 }
948 for (i = 0; i < e_info->error_dev_num && e_info->dev[i]; i++) { 928 for (i = 0; i < e_info->error_dev_num && e_info->dev[i]; i++) {
949 if (get_device_error_info(e_info->dev[i], e_info)) 929 if (aer_get_device_error_info(e_info->dev[i], e_info))
950 handle_error_source(e_info->dev[i], e_info); 930 handle_error_source(e_info->dev[i], e_info);
951 } 931 }
952} 932}