2 * drivers/pci/pcie/aer/aerdrv_core.c
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
8 * This file implements the core part of PCI-Express AER. When an pci-express
9 * error is delivered, an error message will be collected and printed to
10 * console, then, an error recovery procedure will be executed by following
11 * the pci error recovery rules.
13 * Copyright (C) 2006 Intel Corp.
14 * Tom Long Nguyen (tom.l.nguyen@intel.com)
15 * Zhang Yanmin (yanmin.zhang@intel.com)
19 #include <linux/module.h>
20 #include <linux/pci.h>
21 #include <linux/kernel.h>
22 #include <linux/errno.h>
24 #include <linux/suspend.h>
25 #include <linux/delay.h>
29 static int nosourceid
;
30 module_param(forceload
, bool, 0);
31 module_param(nosourceid
, bool, 0);
33 int pci_enable_pcie_error_reporting(struct pci_dev
*dev
)
38 pos
= pci_find_ext_capability(dev
, PCI_EXT_CAP_ID_ERR
);
42 pos
= pci_find_capability(dev
, PCI_CAP_ID_EXP
);
46 pci_read_config_word(dev
, pos
+PCI_EXP_DEVCTL
, ®16
);
49 PCI_EXP_DEVCTL_NFERE
|
52 pci_write_config_word(dev
, pos
+PCI_EXP_DEVCTL
, reg16
);
56 EXPORT_SYMBOL_GPL(pci_enable_pcie_error_reporting
);
58 int pci_disable_pcie_error_reporting(struct pci_dev
*dev
)
63 pos
= pci_find_capability(dev
, PCI_CAP_ID_EXP
);
67 pci_read_config_word(dev
, pos
+PCI_EXP_DEVCTL
, ®16
);
68 reg16
= reg16
& ~(PCI_EXP_DEVCTL_CERE
|
69 PCI_EXP_DEVCTL_NFERE
|
72 pci_write_config_word(dev
, pos
+PCI_EXP_DEVCTL
, reg16
);
76 EXPORT_SYMBOL_GPL(pci_disable_pcie_error_reporting
);
78 int pci_cleanup_aer_uncorrect_error_status(struct pci_dev
*dev
)
83 pos
= pci_find_ext_capability(dev
, PCI_EXT_CAP_ID_ERR
);
87 pci_read_config_dword(dev
, pos
+ PCI_ERR_UNCOR_STATUS
, &status
);
89 pci_write_config_dword(dev
, pos
+ PCI_ERR_UNCOR_STATUS
, status
);
93 EXPORT_SYMBOL_GPL(pci_cleanup_aer_uncorrect_error_status
);
96 int pci_cleanup_aer_correct_error_status(struct pci_dev
*dev
)
101 pos
= pci_find_ext_capability(dev
, PCI_EXT_CAP_ID_ERR
);
105 pci_read_config_dword(dev
, pos
+ PCI_ERR_COR_STATUS
, &status
);
106 pci_write_config_dword(dev
, pos
+ PCI_ERR_COR_STATUS
, status
);
112 static int set_device_error_reporting(struct pci_dev
*dev
, void *data
)
114 bool enable
= *((bool *)data
);
116 if (dev
->pcie_type
== PCIE_RC_PORT
||
117 dev
->pcie_type
== PCIE_SW_UPSTREAM_PORT
||
118 dev
->pcie_type
== PCIE_SW_DOWNSTREAM_PORT
) {
120 pci_enable_pcie_error_reporting(dev
);
122 pci_disable_pcie_error_reporting(dev
);
126 pcie_set_ecrc_checking(dev
);
132 * set_downstream_devices_error_reporting - enable/disable the error reporting bits on the root port and its downstream ports.
133 * @dev: pointer to root port's pci_dev data structure
134 * @enable: true = enable error reporting, false = disable error reporting.
136 static void set_downstream_devices_error_reporting(struct pci_dev
*dev
,
139 set_device_error_reporting(dev
, &enable
);
141 if (!dev
->subordinate
)
143 pci_walk_bus(dev
->subordinate
, set_device_error_reporting
, &enable
);
146 static inline int compare_device_id(struct pci_dev
*dev
,
147 struct aer_err_info
*e_info
)
149 if (e_info
->id
== ((dev
->bus
->number
<< 8) | dev
->devfn
)) {
159 static int add_error_device(struct aer_err_info
*e_info
, struct pci_dev
*dev
)
161 if (e_info
->error_dev_num
< AER_MAX_MULTI_ERR_DEVICES
) {
162 e_info
->dev
[e_info
->error_dev_num
] = dev
;
163 e_info
->error_dev_num
++;
171 #define PCI_BUS(x) (((x) >> 8) & 0xff)
173 static int find_device_iter(struct pci_dev
*dev
, void *data
)
180 struct aer_err_info
*e_info
= (struct aer_err_info
*)data
;
183 * When bus id is equal to 0, it might be a bad id
184 * reported by root port.
186 if (!nosourceid
&& (PCI_BUS(e_info
->id
) != 0)) {
187 result
= compare_device_id(dev
, e_info
);
189 add_error_device(e_info
, dev
);
192 * If there is no multiple error, we stop
193 * or continue based on the id comparing.
195 if (!e_info
->multi_error_valid
)
199 * If there are multiple errors and id does match,
200 * We need continue to search other devices under
201 * the root port. Return 0 means that.
210 * 2) bus id is equal to 0. Some ports might lose the bus
211 * id of error source id;
212 * 3) There are multiple errors and prior id comparing fails;
213 * We check AER status registers to find the initial reporter.
215 if (atomic_read(&dev
->enable_cnt
) == 0)
217 pos
= pci_find_capability(dev
, PCI_CAP_ID_EXP
);
220 /* Check if AER is enabled */
221 pci_read_config_word(dev
, pos
+PCI_EXP_DEVCTL
, ®16
);
223 PCI_EXP_DEVCTL_CERE
|
224 PCI_EXP_DEVCTL_NFERE
|
225 PCI_EXP_DEVCTL_FERE
|
226 PCI_EXP_DEVCTL_URRE
)))
228 pos
= pci_find_ext_capability(dev
, PCI_EXT_CAP_ID_ERR
);
234 if (e_info
->severity
== AER_CORRECTABLE
) {
235 pci_read_config_dword(dev
, pos
+ PCI_ERR_COR_STATUS
, &status
);
236 pci_read_config_dword(dev
, pos
+ PCI_ERR_COR_MASK
, &mask
);
237 if (status
& ~mask
) {
238 add_error_device(e_info
, dev
);
242 pci_read_config_dword(dev
, pos
+ PCI_ERR_UNCOR_STATUS
, &status
);
243 pci_read_config_dword(dev
, pos
+ PCI_ERR_UNCOR_MASK
, &mask
);
244 if (status
& ~mask
) {
245 add_error_device(e_info
, dev
);
253 if (e_info
->multi_error_valid
)
260 * find_source_device - search through device hierarchy for source device
261 * @parent: pointer to Root Port pci_dev data structure
262 * @err_info: including detailed error information such like id
264 * Invoked when error is detected at the Root Port.
266 static void find_source_device(struct pci_dev
*parent
,
267 struct aer_err_info
*e_info
)
269 struct pci_dev
*dev
= parent
;
272 /* Is Root Port an agent that sends error message? */
273 result
= find_device_iter(dev
, e_info
);
277 pci_walk_bus(parent
->subordinate
, find_device_iter
, e_info
);
280 static int report_error_detected(struct pci_dev
*dev
, void *data
)
282 pci_ers_result_t vote
;
283 struct pci_error_handlers
*err_handler
;
284 struct aer_broadcast_data
*result_data
;
285 result_data
= (struct aer_broadcast_data
*) data
;
287 dev
->error_state
= result_data
->state
;
290 !dev
->driver
->err_handler
||
291 !dev
->driver
->err_handler
->error_detected
) {
292 if (result_data
->state
== pci_channel_io_frozen
&&
293 !(dev
->hdr_type
& PCI_HEADER_TYPE_BRIDGE
)) {
295 * In case of fatal recovery, if one of down-
296 * stream device has no driver. We might be
297 * unable to recover because a later insmod
298 * of a driver for this device is unaware of
301 dev_printk(KERN_DEBUG
, &dev
->dev
, "device has %s\n",
303 "no AER-aware driver" : "no driver");
308 err_handler
= dev
->driver
->err_handler
;
309 vote
= err_handler
->error_detected(dev
, result_data
->state
);
310 result_data
->result
= merge_result(result_data
->result
, vote
);
314 static int report_mmio_enabled(struct pci_dev
*dev
, void *data
)
316 pci_ers_result_t vote
;
317 struct pci_error_handlers
*err_handler
;
318 struct aer_broadcast_data
*result_data
;
319 result_data
= (struct aer_broadcast_data
*) data
;
322 !dev
->driver
->err_handler
||
323 !dev
->driver
->err_handler
->mmio_enabled
)
326 err_handler
= dev
->driver
->err_handler
;
327 vote
= err_handler
->mmio_enabled(dev
);
328 result_data
->result
= merge_result(result_data
->result
, vote
);
332 static int report_slot_reset(struct pci_dev
*dev
, void *data
)
334 pci_ers_result_t vote
;
335 struct pci_error_handlers
*err_handler
;
336 struct aer_broadcast_data
*result_data
;
337 result_data
= (struct aer_broadcast_data
*) data
;
340 !dev
->driver
->err_handler
||
341 !dev
->driver
->err_handler
->slot_reset
)
344 err_handler
= dev
->driver
->err_handler
;
345 vote
= err_handler
->slot_reset(dev
);
346 result_data
->result
= merge_result(result_data
->result
, vote
);
350 static int report_resume(struct pci_dev
*dev
, void *data
)
352 struct pci_error_handlers
*err_handler
;
354 dev
->error_state
= pci_channel_io_normal
;
357 !dev
->driver
->err_handler
||
358 !dev
->driver
->err_handler
->resume
)
361 err_handler
= dev
->driver
->err_handler
;
362 err_handler
->resume(dev
);
367 * broadcast_error_message - handle message broadcast to downstream drivers
368 * @dev: pointer to from where in a hierarchy message is broadcasted down
369 * @state: error state
370 * @error_mesg: message to print
371 * @cb: callback to be broadcasted
373 * Invoked during error recovery process. Once being invoked, the content
374 * of error severity will be broadcasted to all downstream drivers in a
375 * hierarchy in question.
377 static pci_ers_result_t
broadcast_error_message(struct pci_dev
*dev
,
378 enum pci_channel_state state
,
380 int (*cb
)(struct pci_dev
*, void *))
382 struct aer_broadcast_data result_data
;
384 dev_printk(KERN_DEBUG
, &dev
->dev
, "broadcast %s message\n", error_mesg
);
385 result_data
.state
= state
;
386 if (cb
== report_error_detected
)
387 result_data
.result
= PCI_ERS_RESULT_CAN_RECOVER
;
389 result_data
.result
= PCI_ERS_RESULT_RECOVERED
;
391 if (dev
->hdr_type
& PCI_HEADER_TYPE_BRIDGE
) {
393 * If the error is reported by a bridge, we think this error
394 * is related to the downstream link of the bridge, so we
395 * do error recovery on all subordinates of the bridge instead
396 * of the bridge and clear the error status of the bridge.
398 if (cb
== report_error_detected
)
399 dev
->error_state
= state
;
400 pci_walk_bus(dev
->subordinate
, cb
, &result_data
);
401 if (cb
== report_resume
) {
402 pci_cleanup_aer_uncorrect_error_status(dev
);
403 dev
->error_state
= pci_channel_io_normal
;
407 * If the error is reported by an end point, we think this
408 * error is related to the upstream link of the end point.
410 pci_walk_bus(dev
->bus
, cb
, &result_data
);
413 return result_data
.result
;
416 struct find_aer_service_data
{
417 struct pcie_port_service_driver
*aer_driver
;
421 static int find_aer_service_iter(struct device
*device
, void *data
)
423 struct device_driver
*driver
;
424 struct pcie_port_service_driver
*service_driver
;
425 struct find_aer_service_data
*result
;
427 result
= (struct find_aer_service_data
*) data
;
429 if (device
->bus
== &pcie_port_bus_type
) {
430 struct pcie_port_data
*port_data
;
432 port_data
= pci_get_drvdata(to_pcie_device(device
)->port
);
433 if (port_data
->port_type
== PCIE_SW_DOWNSTREAM_PORT
)
434 result
->is_downstream
= 1;
436 driver
= device
->driver
;
438 service_driver
= to_service_driver(driver
);
439 if (service_driver
->service
== PCIE_PORT_SERVICE_AER
) {
440 result
->aer_driver
= service_driver
;
449 static void find_aer_service(struct pci_dev
*dev
,
450 struct find_aer_service_data
*data
)
453 retval
= device_for_each_child(&dev
->dev
, data
, find_aer_service_iter
);
456 static pci_ers_result_t
reset_link(struct pcie_device
*aerdev
,
459 struct pci_dev
*udev
;
460 pci_ers_result_t status
;
461 struct find_aer_service_data data
;
463 if (dev
->hdr_type
& PCI_HEADER_TYPE_BRIDGE
)
466 udev
= dev
->bus
->self
;
468 data
.is_downstream
= 0;
469 data
.aer_driver
= NULL
;
470 find_aer_service(udev
, &data
);
473 * Use the aer driver of the error agent firstly.
474 * If it hasn't the aer driver, use the root port's
476 if (!data
.aer_driver
|| !data
.aer_driver
->reset_link
) {
477 if (data
.is_downstream
&&
478 aerdev
->device
.driver
&&
479 to_service_driver(aerdev
->device
.driver
)->reset_link
) {
481 to_service_driver(aerdev
->device
.driver
);
483 dev_printk(KERN_DEBUG
, &dev
->dev
, "no link-reset "
485 return PCI_ERS_RESULT_DISCONNECT
;
489 status
= data
.aer_driver
->reset_link(udev
);
490 if (status
!= PCI_ERS_RESULT_RECOVERED
) {
491 dev_printk(KERN_DEBUG
, &dev
->dev
, "link reset at upstream "
492 "device %s failed\n", pci_name(udev
));
493 return PCI_ERS_RESULT_DISCONNECT
;
500 * do_recovery - handle nonfatal/fatal error recovery process
501 * @aerdev: pointer to a pcie_device data structure of root port
502 * @dev: pointer to a pci_dev data structure of agent detecting an error
503 * @severity: error severity type
505 * Invoked when an error is nonfatal/fatal. Once being invoked, broadcast
506 * error detected message to all downstream drivers within a hierarchy in
507 * question and return the returned code.
509 static pci_ers_result_t
do_recovery(struct pcie_device
*aerdev
,
513 pci_ers_result_t status
, result
= PCI_ERS_RESULT_RECOVERED
;
514 enum pci_channel_state state
;
516 if (severity
== AER_FATAL
)
517 state
= pci_channel_io_frozen
;
519 state
= pci_channel_io_normal
;
521 status
= broadcast_error_message(dev
,
524 report_error_detected
);
526 if (severity
== AER_FATAL
) {
527 result
= reset_link(aerdev
, dev
);
528 if (result
!= PCI_ERS_RESULT_RECOVERED
) {
529 /* TODO: Should panic here? */
534 if (status
== PCI_ERS_RESULT_CAN_RECOVER
)
535 status
= broadcast_error_message(dev
,
538 report_mmio_enabled
);
540 if (status
== PCI_ERS_RESULT_NEED_RESET
) {
542 * TODO: Should call platform-specific
543 * functions to reset slot before calling
544 * drivers' slot_reset callbacks?
546 status
= broadcast_error_message(dev
,
552 if (status
== PCI_ERS_RESULT_RECOVERED
)
553 broadcast_error_message(dev
,
562 * handle_error_source - handle logging error into an event log
563 * @aerdev: pointer to pcie_device data structure of the root port
564 * @dev: pointer to pci_dev data structure of error source device
565 * @info: comprehensive error information
567 * Invoked when an error being detected by Root Port.
569 static void handle_error_source(struct pcie_device
*aerdev
,
571 struct aer_err_info
*info
)
573 pci_ers_result_t status
= 0;
576 if (info
->severity
== AER_CORRECTABLE
) {
578 * Correctable error does not need software intevention.
579 * No need to go through error recovery process.
581 pos
= pci_find_ext_capability(dev
, PCI_EXT_CAP_ID_ERR
);
583 pci_write_config_dword(dev
, pos
+ PCI_ERR_COR_STATUS
,
586 status
= do_recovery(aerdev
, dev
, info
->severity
);
587 if (status
== PCI_ERS_RESULT_RECOVERED
) {
588 dev_printk(KERN_DEBUG
, &dev
->dev
, "AER driver "
589 "successfully recovered\n");
591 /* TODO: Should kernel panic here? */
592 dev_printk(KERN_DEBUG
, &dev
->dev
, "AER driver didn't "
599 * aer_enable_rootport - enable Root Port's interrupts when receiving messages
600 * @rpc: pointer to a Root Port data structure
602 * Invoked when PCIE bus loads AER service driver.
604 void aer_enable_rootport(struct aer_rpc
*rpc
)
606 struct pci_dev
*pdev
= rpc
->rpd
->port
;
611 pos
= pci_find_capability(pdev
, PCI_CAP_ID_EXP
);
612 /* Clear PCIE Capability's Device Status */
613 pci_read_config_word(pdev
, pos
+PCI_EXP_DEVSTA
, ®16
);
614 pci_write_config_word(pdev
, pos
+PCI_EXP_DEVSTA
, reg16
);
616 /* Disable system error generation in response to error messages */
617 pci_read_config_word(pdev
, pos
+ PCI_EXP_RTCTL
, ®16
);
618 reg16
&= ~(SYSTEM_ERROR_INTR_ON_MESG_MASK
);
619 pci_write_config_word(pdev
, pos
+ PCI_EXP_RTCTL
, reg16
);
621 aer_pos
= pci_find_ext_capability(pdev
, PCI_EXT_CAP_ID_ERR
);
622 /* Clear error status */
623 pci_read_config_dword(pdev
, aer_pos
+ PCI_ERR_ROOT_STATUS
, ®32
);
624 pci_write_config_dword(pdev
, aer_pos
+ PCI_ERR_ROOT_STATUS
, reg32
);
625 pci_read_config_dword(pdev
, aer_pos
+ PCI_ERR_COR_STATUS
, ®32
);
626 pci_write_config_dword(pdev
, aer_pos
+ PCI_ERR_COR_STATUS
, reg32
);
627 pci_read_config_dword(pdev
, aer_pos
+ PCI_ERR_UNCOR_STATUS
, ®32
);
628 pci_write_config_dword(pdev
, aer_pos
+ PCI_ERR_UNCOR_STATUS
, reg32
);
631 * Enable error reporting for the root port device and downstream port
634 set_downstream_devices_error_reporting(pdev
, true);
636 /* Enable Root Port's interrupt in response to error messages */
637 pci_write_config_dword(pdev
,
638 aer_pos
+ PCI_ERR_ROOT_COMMAND
,
639 ROOT_PORT_INTR_ON_MESG_MASK
);
643 * disable_root_aer - disable Root Port's interrupts when receiving messages
644 * @rpc: pointer to a Root Port data structure
646 * Invoked when PCIE bus unloads AER service driver.
648 static void disable_root_aer(struct aer_rpc
*rpc
)
650 struct pci_dev
*pdev
= rpc
->rpd
->port
;
655 * Disable error reporting for the root port device and downstream port
658 set_downstream_devices_error_reporting(pdev
, false);
660 pos
= pci_find_ext_capability(pdev
, PCI_EXT_CAP_ID_ERR
);
661 /* Disable Root's interrupt in response to error messages */
662 pci_write_config_dword(pdev
, pos
+ PCI_ERR_ROOT_COMMAND
, 0);
664 /* Clear Root's error status reg */
665 pci_read_config_dword(pdev
, pos
+ PCI_ERR_ROOT_STATUS
, ®32
);
666 pci_write_config_dword(pdev
, pos
+ PCI_ERR_ROOT_STATUS
, reg32
);
670 * get_e_source - retrieve an error source
671 * @rpc: pointer to the root port which holds an error
673 * Invoked by DPC handler to consume an error.
675 static struct aer_err_source
*get_e_source(struct aer_rpc
*rpc
)
677 struct aer_err_source
*e_source
;
680 /* Lock access to Root error producer/consumer index */
681 spin_lock_irqsave(&rpc
->e_lock
, flags
);
682 if (rpc
->prod_idx
== rpc
->cons_idx
) {
683 spin_unlock_irqrestore(&rpc
->e_lock
, flags
);
686 e_source
= &rpc
->e_sources
[rpc
->cons_idx
];
688 if (rpc
->cons_idx
== AER_ERROR_SOURCES_MAX
)
690 spin_unlock_irqrestore(&rpc
->e_lock
, flags
);
696 * get_device_error_info - read error status from dev and store it to info
697 * @dev: pointer to the device expected to have a error record
698 * @info: pointer to structure to store the error record
700 * Return 1 on success, 0 on error.
702 static int get_device_error_info(struct pci_dev
*dev
, struct aer_err_info
*info
)
707 info
->tlp_header_valid
= 0;
709 pos
= pci_find_ext_capability(dev
, PCI_EXT_CAP_ID_ERR
);
711 /* The device might not support AER */
715 if (info
->severity
== AER_CORRECTABLE
) {
716 pci_read_config_dword(dev
, pos
+ PCI_ERR_COR_STATUS
,
718 pci_read_config_dword(dev
, pos
+ PCI_ERR_COR_MASK
,
720 if (!(info
->status
& ~info
->mask
))
722 } else if (dev
->hdr_type
& PCI_HEADER_TYPE_BRIDGE
||
723 info
->severity
== AER_NONFATAL
) {
725 /* Link is still healthy for IO reads */
726 pci_read_config_dword(dev
, pos
+ PCI_ERR_UNCOR_STATUS
,
728 pci_read_config_dword(dev
, pos
+ PCI_ERR_UNCOR_MASK
,
730 if (!(info
->status
& ~info
->mask
))
733 /* Get First Error Pointer */
734 pci_read_config_dword(dev
, pos
+ PCI_ERR_CAP
, &temp
);
735 info
->first_error
= PCI_ERR_CAP_FEP(temp
);
737 if (info
->status
& AER_LOG_TLP_MASKS
) {
738 info
->tlp_header_valid
= 1;
739 pci_read_config_dword(dev
,
740 pos
+ PCI_ERR_HEADER_LOG
, &info
->tlp
.dw0
);
741 pci_read_config_dword(dev
,
742 pos
+ PCI_ERR_HEADER_LOG
+ 4, &info
->tlp
.dw1
);
743 pci_read_config_dword(dev
,
744 pos
+ PCI_ERR_HEADER_LOG
+ 8, &info
->tlp
.dw2
);
745 pci_read_config_dword(dev
,
746 pos
+ PCI_ERR_HEADER_LOG
+ 12, &info
->tlp
.dw3
);
753 static inline void aer_process_err_devices(struct pcie_device
*p_device
,
754 struct aer_err_info
*e_info
)
758 if (!e_info
->dev
[0]) {
759 dev_printk(KERN_DEBUG
, &p_device
->port
->dev
,
760 "can't find device of ID%04x\n",
764 /* Report all before handle them, not to lost records by reset etc. */
765 for (i
= 0; i
< e_info
->error_dev_num
&& e_info
->dev
[i
]; i
++) {
766 if (get_device_error_info(e_info
->dev
[i
], e_info
))
767 aer_print_error(e_info
->dev
[i
], e_info
);
769 for (i
= 0; i
< e_info
->error_dev_num
&& e_info
->dev
[i
]; i
++) {
770 if (get_device_error_info(e_info
->dev
[i
], e_info
))
771 handle_error_source(p_device
, e_info
->dev
[i
], e_info
);
776 * aer_isr_one_error - consume an error detected by root port
777 * @p_device: pointer to error root port service device
778 * @e_src: pointer to an error source
780 static void aer_isr_one_error(struct pcie_device
*p_device
,
781 struct aer_err_source
*e_src
)
783 struct aer_err_info
*e_info
;
786 /* struct aer_err_info might be big, so we allocate it with slab */
787 e_info
= kmalloc(sizeof(struct aer_err_info
), GFP_KERNEL
);
788 if (e_info
== NULL
) {
789 dev_printk(KERN_DEBUG
, &p_device
->port
->dev
,
790 "Can't allocate mem when processing AER errors\n");
795 * There is a possibility that both correctable error and
796 * uncorrectable error being logged. Report correctable error first.
798 for (i
= 1; i
& ROOT_ERR_STATUS_MASKS
; i
<<= 2) {
801 if (!(e_src
->status
& i
))
804 memset(e_info
, 0, sizeof(struct aer_err_info
));
806 /* Init comprehensive error information */
807 if (i
& PCI_ERR_ROOT_COR_RCV
) {
808 e_info
->id
= ERR_COR_ID(e_src
->id
);
809 e_info
->severity
= AER_CORRECTABLE
;
811 e_info
->id
= ERR_UNCOR_ID(e_src
->id
);
812 e_info
->severity
= ((e_src
->status
>> 6) & 1);
815 (PCI_ERR_ROOT_MULTI_COR_RCV
|
816 PCI_ERR_ROOT_MULTI_UNCOR_RCV
))
817 e_info
->multi_error_valid
= 1;
819 aer_print_port_info(p_device
->port
, e_info
);
821 find_source_device(p_device
->port
, e_info
);
822 aer_process_err_devices(p_device
, e_info
);
829 * aer_isr - consume errors detected by root port
830 * @work: definition of this work item
832 * Invoked, as DPC, when root port records new detected error
834 void aer_isr(struct work_struct
*work
)
836 struct aer_rpc
*rpc
= container_of(work
, struct aer_rpc
, dpc_handler
);
837 struct pcie_device
*p_device
= rpc
->rpd
;
838 struct aer_err_source
*e_src
;
840 mutex_lock(&rpc
->rpc_mutex
);
841 e_src
= get_e_source(rpc
);
843 aer_isr_one_error(p_device
, e_src
);
844 e_src
= get_e_source(rpc
);
846 mutex_unlock(&rpc
->rpc_mutex
);
848 wake_up(&rpc
->wait_release
);
852 * aer_delete_rootport - disable root port aer and delete service data
853 * @rpc: pointer to a root port device being deleted
855 * Invoked when AER service unloaded on a specific Root Port
857 void aer_delete_rootport(struct aer_rpc
*rpc
)
859 /* Disable root port AER itself */
860 disable_root_aer(rpc
);
866 * aer_init - provide AER initialization
867 * @dev: pointer to AER pcie device
869 * Invoked when AER service driver is loaded.
871 int aer_init(struct pcie_device
*dev
)
873 if (aer_osc_setup(dev
) && !forceload
)