요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GPL-2.0
.. include:: <isonum.txt>
===========================================================
The PCI Express Advanced Error Reporting Driver Guide HOWTO
===========================================================
:Authors: - T. Long Nguyen <[email protected]>
- Yanmin Zhang <[email protected]>
:Copyright: |copy| 2006 Intel Corporation
Overview
===========
About this guide
----------------
This guide describes the basics of the PCI Express (PCIe) Advanced Error
Reporting (AER) driver and provides information on how to use it, as
well as how to enable the drivers of Endpoint devices to conform with
the PCIe AER driver.
What is the PCIe AER Driver?
----------------------------
PCIe error signaling can occur on the PCIe link itself
or on behalf of transactions initiated on the link. PCIe
defines two error reporting paradigms: the baseline capability and
the Advanced Error Reporting capability. The baseline capability is
required of all PCIe components providing a minimum defined
set of error reporting requirements. Advanced Error Reporting
capability is implemented with a PCIe Advanced Error Reporting
extended capability structure providing more robust error reporting.
The PCIe AER driver provides the infrastructure to support PCIe Advanced
Error Reporting capability. The PCIe AER driver provides three basic
functions:
- Gathers the comprehensive error information if errors occurred.
- Reports error to the users.
- Performs error recovery actions.
The AER driver only attaches to Root Ports and RCECs that support the PCIe
AER capability.
User Guide
==========
Include the PCIe AER Root Driver into the Linux Kernel
------------------------------------------------------
The PCIe AER driver is a Root Port service driver attached
via the PCIe Port Bus driver. If a user wants to use it, the driver
must be compiled. It is enabled with CONFIG_PCIEAER, which
depends on CONFIG_PCIEPORTBUS.
Load PCIe AER Root Driver
-------------------------
Some systems have AER support in firmware. Enabling Linux AER support at
the same time the firmware handles AER would result in unpredictable
behavior. Therefore, Linux does not handle AER events unless the firmware
grants AER control to the OS via the ACPI _OSC method. See the PCI Firmware
Specification for details regarding _OSC usage.
AER error output
----------------
When a PCIe AER error is captured, an error message will be output to
console. If it's a correctable error, it is output as a warning message.
Otherwise, it is printed as an error. So users could choose different
log level to filter out correctable error messages.
Below shows an example::
0000:50:00.0: PCIe Bus Error: severity=Uncorrectable (Fatal), type=Transaction Layer, (Requester ID)
0000:50:00.0: device [8086:0329] error status/mask=00100000/00000000
0000:50:00.0: [20] UnsupReq (First)
0000:50:00.0: TLP Header: 0x04000001 0x00200a03 0x05010000 0x00050100
In the example, 'Requester ID' means the ID of the device that sent
the error message to the Root Port. Please refer to PCIe specs for other
fields.
AER Ratelimits
--------------
Since error messages can be generated for each transaction, we may see
large volumes of errors reported. To prevent spammy devices from flooding
the console/stalling execution, messages are throttled by device and error
type (correctable vs. non-fatal uncorrectable). Fatal errors, including
DPC errors, are not ratelimited.
AER uses the default ratelimit of DEFAULT_RATELIMIT_BURST (10 events) over
DEFAULT_RATELIMIT_INTERVAL (5 seconds).
Ratelimits are exposed in the form of sysfs attributes and configurable.
See Documentation/ABI/testing/sysfs-bus-pci-devices-aer.
AER Statistics / Counters
-------------------------
When PCIe AER errors are captured, the counters / statistics are also exposed
in the form of sysfs attributes which are documented at
Documentation/ABI/testing/sysfs-bus-pci-devices-aer.
Developer Guide
===============
To enable error recovery, a software driver must provide callbacks.
To support AER better, developers need to understand how AER works.
PCIe errors are classified into two types: correctable errors
and uncorrectable errors. This classification is based on the impact
of those errors, which may result in degraded performance or function
failure.
Correctable errors pose no impacts on the functionality of the
interface. The PCIe protocol can recover without any software
intervention or any loss of data. These errors are detected and
corrected by hardware.
Unlike correctable errors, uncorrectable
errors impact functionality of the interface. Uncorrectable errors
can cause a particular transaction or a particular PCIe link
to be unreliable. Depending on those error conditions, uncorrectable
errors are further classified into non-fatal errors and fatal errors.
Non-fatal errors cause the particular transaction to be unreliable,
but the PCIe link itself is fully functional. Fatal errors, on
the other hand, cause the link to be unreliable.
When PCIe error reporting is enabled, a device will automatically send an
error message to the Root Port above it when it captures
an error. The Root Port, upon receiving an error reporting message,
internally processes and logs the error message in its AER
Capability structure. Error information being logged includes storing
the error reporting agent's Requester ID into the Error Source
Identification Registers and setting the error bits of the Root Error
Status Register accordingly. If AER error reporting is enabled in the Root
Error Command Register, the Root Port generates an interrupt when an
error is detected.
Note that the errors as described above are related to the PCIe
hierarchy and links. These errors do not include any device specific
errors because device specific errors will still get sent directly to
the device driver.
Provide callbacks
-----------------
PCI error-recovery callbacks
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The PCIe AER Root driver uses error callbacks to coordinate
with downstream device drivers associated with a hierarchy in question
when performing error recovery actions.
Data struct pci_driver has a pointer, err_handler, to point to
pci_error_handlers who consists of a couple of callback function
pointers. The AER driver follows the rules defined in
pci-error-recovery.rst except PCIe-specific parts (see
below). Please refer to pci-error-recovery.rst for detailed
definitions of the callbacks.
The sections below specify when to call the error callback functions.
Correctable errors
~~~~~~~~~~~~~~~~~~
Correctable errors pose no impacts on the functionality of
the interface. The PCIe protocol can recover without any
software intervention or any loss of data. These errors do not
require any recovery actions. The AER driver clears the device's
correctable error status register accordingly and logs these errors.
Uncorrectable (non-fatal and fatal) errors
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The AER driver performs a Secondary Bus Reset to recover from
uncorrectable errors. The reset is applied at the port above
the originating device: If the originating device is an Endpoint,
only the Endpoint is reset. If on the other hand the originating
device has subordinate devices, those are all affected by the
reset as well.
If the originating device is a Root Complex Integrated Endpoint,
there's no port above where a Secondary Bus Reset could be applied.
In this case, the AER driver instead applies a Function Level Reset.
If an error message indicates a non-fatal error, performing a reset
at upstream is not required. The AER driver calls error_detected(dev,
pci_channel_io_normal) to all drivers associated within a hierarchy in
question. For example::
Endpoint <==> Downstream Port B <==> Upstream Port A <==> Root Port
If Upstream Port A captures an AER error, the hierarchy consists of
Downstream Port B and Endpoint.
A driver may return PCI_ERS_RESULT_CAN_RECOVER,
PCI_ERS_RESULT_DISCONNECT, or PCI_ERS_RESULT_NEED_RESET, depending on
whether it can recover without a reset, considers the device unrecoverable
or needs a reset for recovery. If all affected drivers agree that they can
recover without a reset, it is skipped. Should one driver request a reset,
it overrides all other drivers.
If an error message indicates a fatal error, kernel will broadcast
error_detected(dev, pci_channel_io_frozen) to all drivers within
a hierarchy in question. Then, performing a reset at upstream is
necessary. If error_detected returns PCI_ERS_RESULT_CAN_RECOVER
to indicate that recovery without a reset is possible, the error
handling goes to mmio_enabled, but afterwards a reset is still
performed.
In other words, for non-fatal errors, drivers may opt in to a reset.
But for fatal errors, they cannot opt out of a reset, based on the
assumption that the link is unreliable.
Frequently Asked Questions
--------------------------
Q:
What happens if a PCIe device driver does not provide an
error recovery handler (pci_driver->err_handler is equal to NULL)?
A:
The devices attached with the driver won't be recovered.
The kernel will print out informational messages to identify
unrecoverable devices.
Software error injection
========================
Debugging PCIe AER error recovery code is quite difficult because it
is hard to trigger real hardware errors. Software based error
injection can be used to fake various kinds of PCIe errors.
First you should enable PCIe AER software error injection in kernel
configuration, that is, following item should be in your .config.
CONFIG_PCIEAER_INJECT=y or CONFIG_PCIEAER_INJECT=m
After reboot with new kernel or insert the module, a device file named
/dev/aer_inject should be created.
Then, you need a user space tool named aer-inject, which can be gotten
from:
https://github.com/intel/aer-inject.git
More information about aer-inject can be found in the document in
its source code.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
개요와 안내서의 범위
1-23이 문서는 GPL-2.0으로 배포되며 저자는 T. Long Nguyen과 Yanmin Zhang, 저작권자는 2006년 Intel Corporation입니다.
이 안내서는 PCI Express(PCIe) Advanced Error Reporting(AER) 드라이버의 기본 원리를 설명합니다. AER 드라이버를 사용하는 방법과 Endpoint 장치 드라이버가 PCIe AER 드라이버의 복구 절차에 맞도록 구현하는 방법도 다룹니다.
AER를 도입하고 Endpoint 드라이버를 연동할 때 필요한 내용을 구분합니다.
.. SPDX-License-Identifier: GPL-2.0
.. include:: <isonum.txt>
===========================================================
The PCI Express Advanced Error Reporting Driver Guide HOWTO
===========================================================
:Authors: - T. Long Nguyen <[email protected]>
- Yanmin Zhang <[email protected]>
:Copyright: |copy| 2006 Intel Corporation
Overview
===========
About this guide
----------------
This guide describes the basics of the PCI Express (PCIe) Advanced Error
Reporting (AER) driver and provides information on how to use it, as
well as how to enable the drivers of Endpoint devices to conform with
the PCIe AER driver.
PCIe AER 드라이버란 무엇인가
24-47PCIe 오류 신호는 PCIe link 자체에서 발생할 수도 있고 그 link에서 시작된 transaction을 대신해 전달될 수도 있습니다. PCIe는 baseline capability와 Advanced Error Reporting capability라는 두 가지 오류 보고 체계를 정의합니다.
Baseline capability는 모든 PCIe component에 필수이며 최소한의 오류 보고 요구 사항을 제공합니다. AER capability는 PCIe Advanced Error Reporting extended capability structure로 구현되어 더 상세하고 견고한 오류 정보를 제공합니다.
Linux PCIe AER 드라이버는 AER capability를 지원하는 기반 구조입니다. 오류가 발생하면 포괄적인 오류 정보를 수집하고 사용자에게 보고하며 오류 복구 작업을 수행합니다.
AER 드라이버는 PCIe AER capability를 지원하는 Root Port와 RCEC(Root Complex Event Collector)에만 연결됩니다.
모든 component가 제공하는 최소 기능과 선택적인 상세 기능을 비교합니다.
오류 포착부터 복구까지의 세 책임입니다.
What is the PCIe AER Driver?
----------------------------
PCIe error signaling can occur on the PCIe link itself
or on behalf of transactions initiated on the link. PCIe
defines two error reporting paradigms: the baseline capability and
the Advanced Error Reporting capability. The baseline capability is
required of all PCIe components providing a minimum defined
set of error reporting requirements. Advanced Error Reporting
capability is implemented with a PCIe Advanced Error Reporting
extended capability structure providing more robust error reporting.
The PCIe AER driver provides the infrastructure to support PCIe Advanced
Error Reporting capability. The PCIe AER driver provides three basic
functions:
- Gathers the comprehensive error information if errors occurred.
- Reports error to the users.
- Performs error recovery actions.
The AER driver only attaches to Root Ports and RCECs that support the PCIe
AER capability.
Kernel에 AER Root 드라이버 포함하기
48-59PCIe AER 드라이버는 PCIe Port Bus 드라이버를 통해 연결되는 Root Port service driver입니다. 사용하려면 kernel에 컴파일해야 합니다.
`CONFIG_PCIEAER`로 AER 드라이버를 활성화하며 이 항목은 `CONFIG_PCIEPORTBUS`에 의존합니다. 따라서 Port Bus 지원 없이 AER Root service만 독립적으로 활성화할 수 없습니다.
Root Port service가 PCIe Port Bus 위에 연결됩니다.
User Guide
==========
Include the PCIe AER Root Driver into the Linux Kernel
------------------------------------------------------
The PCIe AER driver is a Root Port service driver attached
via the PCIe Port Bus driver. If a user wants to use it, the driver
must be compiled. It is enabled with CONFIG_PCIEAER, which
depends on CONFIG_PCIEPORTBUS.
AER Root 드라이버 로드와 소유권
60-68일부 system에서는 firmware가 AER를 처리합니다. Firmware와 Linux가 동시에 같은 AER event를 처리하면 예측할 수 없는 동작이 생길 수 있습니다.
따라서 Linux는 firmware가 ACPI `_OSC` method를 통해 AER control을 OS에 부여한 경우에만 AER event를 처리합니다. `_OSC` 사용의 자세한 내용은 PCI Firmware Specification을 참조해야 합니다.
Firmware와 OS가 동시에 처리하지 않도록 ownership을 명시적으로 넘깁니다.
Load PCIe AER Root Driver
-------------------------
Some systems have AER support in firmware. Enabling Linux AER support at
the same time the firmware handles AER would result in unpredictable
behavior. Therefore, Linux does not handle AER events unless the firmware
grants AER control to the OS via the ACPI _OSC method. See the PCI Firmware
Specification for details regarding _OSC usage.
AER 오류 출력 읽기
69-87PCIe AER 오류가 포착되면 console에 메시지가 출력됩니다. Correctable error는 warning으로, 그 밖의 오류는 error로 출력하므로 사용자는 log level을 달리해 correctable error 메시지를 걸러낼 수 있습니다.
예제는 BDF `0000:50:00.0`에서 fatal uncorrectable Transaction Layer 오류가 발생했음을 보여 줍니다. `device [8086:0329]`는 vendor·device ID이며 `error status/mask`는 상태와 mask, `[20] UnsupReq (First)`는 첫 번째로 기록된 Unsupported Request bit입니다. 네 개의 32-bit 값은 TLP Header입니다.
0000:50:00.0: PCIe Bus Error: severity=Uncorrectable (Fatal), type=Transaction Layer, (Requester ID)
0000:50:00.0: device [8086:0329] error status/mask=00100000/00000000
0000:50:00.0: [20] UnsupReq (First)
0000:50:00.0: TLP Header: 0x04000001 0x00200a03 0x05010000 0x00050100
이 예제의 `Requester ID`는 Root Port에 오류 메시지를 보낸 장치의 ID입니다. 나머지 field의 정확한 해석은 PCIe specification을 참조해야 합니다.
예제 출력에서 원인과 보고 주체를 찾는 기준입니다.
AER error output
----------------
When a PCIe AER error is captured, an error message will be output to
console. If it's a correctable error, it is output as a warning message.
Otherwise, it is printed as an error. So users could choose different
log level to filter out correctable error messages.
Below shows an example::
0000:50:00.0: PCIe Bus Error: severity=Uncorrectable (Fatal), type=Transaction Layer, (Requester ID)
0000:50:00.0: device [8086:0329] error status/mask=00100000/00000000
0000:50:00.0: [20] UnsupReq (First)
0000:50:00.0: TLP Header: 0x04000001 0x00200a03 0x05010000 0x00050100
In the example, 'Requester ID' means the ID of the device that sent
the error message to the Root Port. Please refer to PCIe specs for other
fields.
Ratelimit와 통계 counter
88-109Transaction마다 오류 메시지가 생길 수 있으므로 결함 장치가 막대한 양의 오류를 보고할 수 있습니다. Console flood와 실행 정지를 막기 위해 메시지는 장치별, 오류 유형별로 제한됩니다. 이때 유형은 correctable과 non-fatal uncorrectable로 구분합니다.
Fatal error는 DPC error를 포함해 ratelimit을 적용하지 않습니다. 즉 복구에 즉각적인 주의가 필요한 치명적 오류는 출력 제한 때문에 감춰지지 않습니다.
AER의 기본 제한은 `DEFAULT_RATELIMIT_INTERVAL` 5초 동안 `DEFAULT_RATELIMIT_BURST` 10개 event입니다. Ratelimit은 sysfs attribute로 노출되어 변경할 수 있습니다.
AER 오류가 포착되면 counter와 통계도 sysfs attribute로 노출됩니다. Ratelimit과 통계 attribute의 ABI는 모두 `Documentation/ABI/testing/sysfs-bus-pci-devices-aer`에 문서화되어 있습니다.
Severity별 console 정책과 기본값입니다.
동일한 sysfs ABI에서 출력 정책과 누적 통계를 확인합니다.
AER Ratelimits
--------------
Since error messages can be generated for each transaction, we may see
large volumes of errors reported. To prevent spammy devices from flooding
the console/stalling execution, messages are throttled by device and error
type (correctable vs. non-fatal uncorrectable). Fatal errors, including
DPC errors, are not ratelimited.
AER uses the default ratelimit of DEFAULT_RATELIMIT_BURST (10 events) over
DEFAULT_RATELIMIT_INTERVAL (5 seconds).
Ratelimits are exposed in the form of sysfs attributes and configurable.
See Documentation/ABI/testing/sysfs-bus-pci-devices-aer.
AER Statistics / Counters
-------------------------
When PCIe AER errors are captured, the counters / statistics are also exposed
in the form of sysfs attributes which are documented at
Documentation/ABI/testing/sysfs-bus-pci-devices-aer.
오류 등급과 Root Port 보고 흐름
110-151오류 복구를 활성화하려면 software driver가 callback을 제공해야 합니다. 이를 올바르게 구현하려면 개발자는 AER가 오류를 분류하고 전달하는 방식을 이해해야 합니다.
PCIe 오류는 correctable과 uncorrectable로 분류됩니다. 이 분류는 성능 저하 또는 기능 실패처럼 오류가 interface에 미치는 영향을 기준으로 합니다.
Correctable error는 interface 기능에 영향을 주지 않습니다. PCIe protocol이 software 개입이나 data 손실 없이 복구하며 hardware가 직접 감지하고 교정합니다.
Uncorrectable error는 특정 transaction 또는 PCIe link를 신뢰할 수 없게 만듭니다. Non-fatal error에서는 해당 transaction만 신뢰할 수 없고 link 자체는 완전히 동작하지만, fatal error에서는 link를 신뢰할 수 없습니다.
복구 범위는 오류가 transaction과 link에 미치는 영향으로 결정됩니다.
PCIe error reporting이 활성화된 장치는 오류를 포착하면 위쪽 Root Port로 자동으로 오류 메시지를 보냅니다. Root Port는 메시지를 내부 처리한 뒤 AER Capability structure에 기록합니다.
기록에는 오류 보고 agent의 Requester ID를 Error Source Identification Registers에 저장하고 Root Error Status Register의 대응 bit를 설정하는 작업이 포함됩니다. Root Error Command Register에서 AER error reporting이 활성화되어 있으면 Root Port는 오류 감지 시 interrupt를 발생시킵니다.
Requester ID와 status가 Root Port의 AER capability에 남고 interrupt가 복구를 시작합니다.
여기서 설명하는 오류는 PCIe hierarchy와 link에 관련된 오류입니다. Device-specific error는 여기에 포함되지 않으며 계속 해당 device driver에 직접 전달됩니다.
AER가 다루는 protocol 오류와 장치 고유 오류의 수신자를 구분합니다.
Developer Guide
===============
To enable error recovery, a software driver must provide callbacks.
To support AER better, developers need to understand how AER works.
PCIe errors are classified into two types: correctable errors
and uncorrectable errors. This classification is based on the impact
of those errors, which may result in degraded performance or function
failure.
Correctable errors pose no impacts on the functionality of the
interface. The PCIe protocol can recover without any software
intervention or any loss of data. These errors are detected and
corrected by hardware.
Unlike correctable errors, uncorrectable
errors impact functionality of the interface. Uncorrectable errors
can cause a particular transaction or a particular PCIe link
to be unreliable. Depending on those error conditions, uncorrectable
errors are further classified into non-fatal errors and fatal errors.
Non-fatal errors cause the particular transaction to be unreliable,
but the PCIe link itself is fully functional. Fatal errors, on
the other hand, cause the link to be unreliable.
When PCIe error reporting is enabled, a device will automatically send an
error message to the Root Port above it when it captures
an error. The Root Port, upon receiving an error reporting message,
internally processes and logs the error message in its AER
Capability structure. Error information being logged includes storing
the error reporting agent's Requester ID into the Error Source
Identification Registers and setting the error bits of the Root Error
Status Register accordingly. If AER error reporting is enabled in the Root
Error Command Register, the Root Port generates an interrupt when an
error is detected.
Note that the errors as described above are related to the PCIe
hierarchy and links. These errors do not include any device specific
errors because device specific errors will still get sent directly to
the device driver.
PCI error-recovery callback 제공
152-169PCIe AER Root driver는 복구할 때 문제의 hierarchy에 속한 downstream device driver들과 error callback으로 조정합니다.
`struct pci_driver`의 `err_handler` pointer는 여러 callback function pointer로 구성된 `struct pci_error_handlers`를 가리킵니다.
AER 드라이버는 아래에 설명한 PCIe 전용 부분을 제외하고 `pci-error-recovery.rst`의 규칙을 따릅니다. 각 callback의 자세한 정의도 그 문서를 참조해야 하며, 이어지는 절은 오류 callback을 언제 호출하는지 규정합니다.
Root driver가 hierarchy의 각 장치 드라이버와 PCI error recovery contract로 협력합니다.
Provide callbacks
-----------------
PCI error-recovery callbacks
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The PCIe AER Root driver uses error callbacks to coordinate
with downstream device drivers associated with a hierarchy in question
when performing error recovery actions.
Data struct pci_driver has a pointer, err_handler, to point to
pci_error_handlers who consists of a couple of callback function
pointers. The AER driver follows the rules defined in
pci-error-recovery.rst except PCIe-specific parts (see
below). Please refer to pci-error-recovery.rst for detailed
definitions of the callbacks.
The sections below specify when to call the error callback functions.
Correctable error 처리
170-179Correctable error는 interface 기능에 영향을 주지 않으며 PCIe protocol이 software 개입이나 data 손실 없이 복구합니다. 따라서 별도의 복구 작업은 필요하지 않습니다.
AER 드라이버는 장치의 correctable error status register에서 해당 상태를 지우고 오류를 log에 남깁니다.
Hardware 복구가 끝난 뒤 상태를 정리하고 관측 기록만 남깁니다.
Correctable errors
~~~~~~~~~~~~~~~~~~
Correctable errors pose no impacts on the functionality of
the interface. The PCIe protocol can recover without any
software intervention or any loss of data. These errors do not
require any recovery actions. The AER driver clears the device's
correctable error status register accordingly and logs these errors.
Uncorrectable error의 reset 범위
180-193AER 드라이버는 uncorrectable error에서 복구하기 위해 오류 발생 장치 위쪽 port에 Secondary Bus Reset을 적용합니다.
오류 발생 장치가 Endpoint이면 Endpoint만 reset됩니다. 반대로 오류 발생 장치 아래에 subordinate device가 있으면 그 장치들도 모두 reset의 영향을 받습니다.
Root Complex Integrated Endpoint(RCIEP)는 위쪽에 Secondary Bus Reset을 적용할 port가 없습니다. 이 경우 AER 드라이버는 대신 Function Level Reset(FLR)을 적용합니다.
Reset은 오류 발생 장치 바로 위의 port를 기준으로 전파됩니다.
Uncorrectable (non-fatal and fatal) errors
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The AER driver performs a Secondary Bus Reset to recover from
uncorrectable errors. The reset is applied at the port above
the originating device: If the originating device is an Endpoint,
only the Endpoint is reset. If on the other hand the originating
device has subordinate devices, those are all affected by the
reset as well.
If the originating device is a Root Complex Integrated Endpoint,
there's no port above where a Secondary Bus Reset could be applied.
In this case, the AER driver instead applies a Function Level Reset.
Non-fatal과 fatal 복구 결정
194-222Non-fatal error는 upstream에서 reset할 필요가 없습니다. AER 드라이버는 문제의 hierarchy에 속한 모든 driver에 `error_detected(dev, pci_channel_io_normal)`을 호출합니다.
원문의 토폴로지에서 Endpoint는 Downstream Port B, Upstream Port A, Root Port 순으로 연결됩니다. Upstream Port A가 AER 오류를 포착했다면 복구 대상 hierarchy는 Downstream Port B와 Endpoint입니다.
원문의 좌우 연결 순서를 Root Port에서 Endpoint 방향으로 명확히 다시 그렸습니다.
Driver는 reset 없이 복구할 수 있으면 `PCI_ERS_RESULT_CAN_RECOVER`, 장치를 복구할 수 없다고 판단하면 `PCI_ERS_RESULT_DISCONNECT`, 복구에 reset이 필요하면 `PCI_ERS_RESULT_NEED_RESET`을 반환합니다.
영향받은 모든 driver가 reset 없이 복구할 수 있다고 합의하면 reset을 건너뜁니다. Driver 하나라도 reset을 요청하면 그 요청이 다른 모든 응답보다 우선합니다.
Hierarchy의 모든 driver 응답을 모아 reset 필요 여부를 결정합니다.
Fatal error이면 kernel은 hierarchy의 모든 driver에 `error_detected(dev, pci_channel_io_frozen)`을 broadcast하고 upstream reset을 반드시 수행합니다.
Fatal 경로에서 `error_detected()`가 `PCI_ERS_RESULT_CAN_RECOVER`를 반환하면 reset 없이 복구할 수 있다는 뜻이므로 먼저 `mmio_enabled` 단계로 가지만, 그 뒤에도 reset은 수행됩니다.
즉 non-fatal error에서는 driver가 reset을 요청해 opt in할 수 있습니다. Fatal error에서는 link를 신뢰할 수 없다고 가정하므로 어떤 driver도 reset을 거부해 opt out할 수 없습니다.
Callback channel state와 reset 강제 여부가 핵심 차이입니다.
If an error message indicates a non-fatal error, performing a reset
at upstream is not required. The AER driver calls error_detected(dev,
pci_channel_io_normal) to all drivers associated within a hierarchy in
question. For example::
Endpoint <==> Downstream Port B <==> Upstream Port A <==> Root Port
If Upstream Port A captures an AER error, the hierarchy consists of
Downstream Port B and Endpoint.
A driver may return PCI_ERS_RESULT_CAN_RECOVER,
PCI_ERS_RESULT_DISCONNECT, or PCI_ERS_RESULT_NEED_RESET, depending on
whether it can recover without a reset, considers the device unrecoverable
or needs a reset for recovery. If all affected drivers agree that they can
recover without a reset, it is skipped. Should one driver request a reset,
it overrides all other drivers.
If an error message indicates a fatal error, kernel will broadcast
error_detected(dev, pci_channel_io_frozen) to all drivers within
a hierarchy in question. Then, performing a reset at upstream is
necessary. If error_detected returns PCI_ERS_RESULT_CAN_RECOVER
to indicate that recovery without a reset is possible, the error
handling goes to mmio_enabled, but afterwards a reset is still
performed.
In other words, for non-fatal errors, drivers may opt in to a reset.
But for fatal errors, they cannot opt out of a reset, based on the
assumption that the link is unreliable.
오류 복구 handler가 없는 경우
223-235질문은 PCIe device driver가 error recovery handler를 제공하지 않아 `pci_driver->err_handler`가 `NULL`이면 어떻게 되는가입니다.
그 driver에 연결된 장치는 복구되지 않습니다. Kernel은 복구할 수 없는 장치를 식별할 수 있도록 informational message를 출력합니다.
AER가 장치 드라이버와 협력할 callback이 있는지에 따른 결과입니다.
Frequently Asked Questions
--------------------------
Q:
What happens if a PCIe device driver does not provide an
error recovery handler (pci_driver->err_handler is equal to NULL)?
A:
The devices attached with the driver won't be recovered.
The kernel will print out informational messages to identify
unrecoverable devices.
Software 오류 주입
236-257실제 hardware error를 의도적으로 발생시키기 어려워 PCIe AER error recovery code를 debugging하기는 까다롭습니다. Software 기반 error injection은 여러 종류의 PCIe error를 가짜로 만들어 복구 경로를 시험할 수 있게 합니다.
먼저 kernel configuration에서 PCIe AER software error injection을 활성화합니다. `.config`에 `CONFIG_PCIEAER_INJECT=y` 또는 `CONFIG_PCIEAER_INJECT=m`이 있어야 합니다.
CONFIG_PCIEAER_INJECT=y
# 또는
CONFIG_PCIEAER_INJECT=m
새 kernel로 reboot하거나 module을 삽입하면 `/dev/aer_inject` device file이 생성되어야 합니다.
그다음 `https://github.com/intel/aer-inject.git`에서 얻을 수 있는 user-space 도구 `aer-inject`가 필요합니다. 더 자세한 사용법은 `aer-inject` source code에 포함된 문서를 참조하십시오.
Kernel 지원부터 user-space 도구 실행 전까지의 준비 순서입니다.
Software error injection
========================
Debugging PCIe AER error recovery code is quite difficult because it
is hard to trigger real hardware errors. Software based error
injection can be used to fake various kinds of PCIe errors.
First you should enable PCIe AER software error injection in kernel
configuration, that is, following item should be in your .config.
CONFIG_PCIEAER_INJECT=y or CONFIG_PCIEAER_INJECT=m
After reboot with new kernel or insert the module, a device file named
/dev/aer_inject should be created.
Then, you need a user space tool named aer-inject, which can be gotten
from:
https://github.com/intel/aer-inject.git
More information about aer-inject can be found in the document in
its source code.
요약·해설
pcieaer-howto.rst:1-257PCIe AER 드라이버는 AER capability를 지원하는 Root Port와 RCEC에 연결되어 hierarchy·link 오류의 상세 정보를 수집하고 console과 sysfs로 보고하며 device driver callback을 조정해 복구합니다.
Correctable error는 hardware가 교정하므로 상태를 지우고 기록만 남깁니다. Non-fatal uncorrectable error는 driver 합의에 따라 reset을 선택하지만 fatal error는 link를 신뢰할 수 없으므로 upstream reset을 반드시 수행합니다.
Firmware가 AER를 소유할 수 있어 ACPI `_OSC`로 OS control을 받은 경우에만 Linux가 처리합니다. 반복 메시지는 severity별 ratelimit을 적용하고, 실제 hardware 오류 없이도 `aer-inject`로 recovery path를 시험할 수 있습니다.