← Documents Documentation/i2c/fault-codes.rst GitHub 원문 ↗

Linux 6.18.37 · I2C

I2C/SMBUS Fault Codes

I2C/SMBus fault가 뜻하는 주소·중재·PEC·장치·프로토콜·시간 오류와 반환 관례를 설명합니다.

Source pathDocumentation/i2c/fault-codes.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

fault-codes.rst:1-135

fault는 복구 가능한 상태나 정의된 결과일 수 있으며, 드라이버는 상위 계층이 올바르게 재시도·복구하도록 13개 구체적 errno를 원인에 맞춰 반환해야 합니다.

문서 개요
항목
SourceDocumentation/i2c/fault-codes.rst
분량135 source lines
주요 fault codes13
정상 반환0 or positive

원문 분량과 핵심 기능을 요약합니다.

동작 흐름
fault 원인 식별구체적 errno 선택재시도 가능성 판단필요 시 reset·복구상위 계층에 결과 전달

호출 또는 판단의 핵심 순서입니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 =====================
2 I2C/SMBUS Fault Codes
3 =====================
4
5 This is a summary of the most important conventions for use of fault
6 codes in the I2C/SMBus stack.
7
8
9 A "Fault" is not always an "Error"
10 ----------------------------------
11 Not all fault reports imply errors; "page faults" should be a familiar
12 example. Software often retries idempotent operations after transient
13 faults. There may be fancier recovery schemes that are appropriate in
14 some cases, such as re-initializing (and maybe resetting). After such
15 recovery, triggered by a fault report, there is no error.
16
17 In a similar way, sometimes a "fault" code just reports one defined
18 result for an operation ... it doesn't indicate that anything is wrong
19 at all, just that the outcome wasn't on the "golden path".
20
21 In short, your I2C driver code may need to know these codes in order
22 to respond correctly. Other code may need to rely on YOUR code reporting
23 the right fault code, so that it can (in turn) behave correctly.
24
25
26 I2C and SMBus fault codes
27 -------------------------
28 These are returned as negative numbers from most calls, with zero or
29 some positive number indicating a non-fault return. The specific
30 numbers associated with these symbols differ between architectures,
31 though most Linux systems use <asm-generic/errno*.h> numbering.
32
33 Note that the descriptions here are not exhaustive. There are other
34 codes that may be returned, and other cases where these codes should
35 be returned. However, drivers should not return other codes for these
36 cases (unless the hardware doesn't provide unique fault reports).
37
38 Also, codes returned by adapter probe methods follow rules which are
39 specific to their host bus (such as PCI, or the platform bus).
40
41
42 EAFNOSUPPORT
43 Returned by I2C adapters not supporting 10 bit addresses when
44 they are requested to use such an address.
45
46 EAGAIN
47 Returned by I2C adapters when they lose arbitration in master
48 transmit mode: some other master was transmitting different
49 data at the same time.
50
51 Also returned when trying to invoke an I2C operation in an
52 atomic context, when some task is already using that I2C bus
53 to execute some other operation.
54
55 EBADMSG
56 Returned by SMBus logic when an invalid Packet Error Code byte
57 is received. This code is a CRC covering all bytes in the
58 transaction, and is sent before the terminating STOP. This
59 fault is only reported on read transactions; the SMBus slave
60 may have a way to report PEC mismatches on writes from the
61 host. Note that even if PECs are in use, you should not rely
62 on these as the only way to detect incorrect data transfers.
63
64 EBUSY
65 Returned by SMBus adapters when the bus was busy for longer
66 than allowed. This usually indicates some device (maybe the
67 SMBus adapter) needs some fault recovery (such as resetting),
68 or that the reset was attempted but failed.
69
70 EINVAL
71 This rather vague error means an invalid parameter has been
72 detected before any I/O operation was started. Use a more
73 specific fault code when you can.
74
75 EIO
76 This rather vague error means something went wrong when
77 performing an I/O operation. Use a more specific fault
78 code when you can.
79
80 ENODEV
81 Returned by driver probe() methods. This is a bit more
82 specific than ENXIO, implying the problem isn't with the
83 address, but with the device found there. Driver probes
84 may verify the device returns *correct* responses, and
85 return this as appropriate. (The driver core will warn
86 about probe faults other than ENXIO and ENODEV.)
87
88 ENOMEM
89 Returned by any component that can't allocate memory when
90 it needs to do so.
91
92 ENXIO
93 Returned by I2C adapters to indicate that the address phase
94 of a transfer didn't get an ACK. While it might just mean
95 an I2C device was temporarily not responding, usually it
96 means there's nothing listening at that address.
97
98 Returned by driver probe() methods to indicate that they
99 found no device to bind to. (ENODEV may also be used.)
100
101 EOPNOTSUPP
102 Returned by an adapter when asked to perform an operation
103 that it doesn't, or can't, support.
104
105 For example, this would be returned when an adapter that
106 doesn't support SMBus block transfers is asked to execute
107 one. In that case, the driver making that request should
108 have verified that functionality was supported before it
109 made that block transfer request.
110
111 Similarly, if an I2C adapter can't execute all legal I2C
112 messages, it should return this when asked to perform a
113 transaction it can't. (These limitations can't be seen in
114 the adapter's functionality mask, since the assumption is
115 that if an adapter supports I2C it supports all of I2C.)
116
117 EPROTO
118 Returned when slave does not conform to the relevant I2C
119 or SMBus (or chip-specific) protocol specifications. One
120 case is when the length of an SMBus block data response
121 (from the SMBus slave) is outside the range 1-32 bytes.
122
123 ESHUTDOWN
124 Returned when a transfer was requested using an adapter
125 which is already suspended.
126
127 ETIMEDOUT
128 This is returned by drivers when an operation took too much
129 time, and was aborted before it completed.
130
131 SMBus adapters may return it when an operation took more
132 time than allowed by the SMBus specification; for example,
133 when a slave stretches clocks too far. I2C has no such
134 timeouts, but it's normal for I2C adapters to impose some
135 arbitrary limits (much longer than SMBus!) too.
136

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

fault가 항상 error는 아님

1-24

이 문서는 I2C/SMBus 스택에서 fault code를 사용하는 가장 중요한 관례를 요약합니다.

모든 fault 보고가 error를 뜻하지는 않습니다. page fault가 익숙한 예입니다. 소프트웨어는 일시적인 fault 뒤에 멱등 연산을 재시도하곤 합니다. 경우에 따라 재초기화나 reset 같은 더 정교한 복구가 적절하며, fault 보고로 복구한 뒤에는 error가 남지 않습니다.

마찬가지로 fault code가 연산의 정의된 결과 하나를 보고할 뿐인 때도 있습니다. 잘못된 것이 아니라 결과가 정상 경로와 달랐다는 뜻입니다.

따라서 I2C 드라이버 코드는 올바르게 대응하려면 이 코드를 알아야 합니다. 다른 코드도 올바르게 동작하려고 드라이버가 정확한 fault code를 보고하는 것에 의존할 수 있습니다.

I2C fault 해석
상황의미·대응
일시적 fault멱등 연산 재시도 가능
복구 가능한 fault재초기화 또는 reset
정의된 비정상 경로 결과오류가 아닐 수 있음
복구 성공최종 error 없음
정확한 코드 보고상위 계층의 올바른 대응에 필수

fault와 최종 error를 구분하는 기준입니다.

fault 처리
fault code 수신정의된 결과인지 오류인지 분류일시적이면 안전한 연산 재시도필요하면 재초기화·reset복구 실패만 최종 error로 전달

코드 의미를 분류한 뒤 재시도·복구·실패를 결정합니다.

=====================
I2C/SMBUS Fault Codes
=====================

This is a summary of the most important conventions for use of fault
codes in the I2C/SMBus stack.


A "Fault" is not always an "Error"
----------------------------------
Not all fault reports imply errors; "page faults" should be a familiar
example.  Software often retries idempotent operations after transient
faults.  There may be fancier recovery schemes that are appropriate in
some cases, such as re-initializing (and maybe resetting).  After such
recovery, triggered by a fault report, there is no error.

In a similar way, sometimes a "fault" code just reports one defined
result for an operation ... it doesn't indicate that anything is wrong
at all, just that the outcome wasn't on the "golden path".

In short, your I2C driver code may need to know these codes in order
to respond correctly.  Other code may need to rely on YOUR code reporting
the right fault code, so that it can (in turn) behave correctly.

I2C·SMBus 반환값 관례

25-40

대부분의 호출은 fault를 음수로 반환하며 0 또는 양수는 fault가 아님을 나타냅니다. 기호에 대응하는 실제 숫자는 아키텍처마다 다르지만 대부분의 Linux 시스템은 `<asm-generic/errno*.h>` 번호를 사용합니다.

여기 설명은 완전한 목록이 아닙니다. 다른 코드가 반환될 수도 있고 같은 코드가 필요한 다른 사례도 있습니다. 그러나 하드웨어가 fault를 구별해 보고하지 못하는 경우를 제외하면, 아래 사례에 드라이버가 다른 코드를 반환해서는 안 됩니다.

어댑터 `probe` 메서드가 반환하는 코드는 PCI나 platform bus 같은 호스트 버스별 규칙도 따릅니다.

fault 반환 관례
항목관례
fault대부분 음수
정상0 또는 양수
번호아키텍처별 차이, 보통 `<asm-generic/errno*.h>`
목록 범위비완전 목록
하드웨어 제한고유 fault 구분 불가 시 예외 가능
adapter probePCI·platform bus별 규칙 추가 적용

부호, 번호 체계, probe 예외를 정리합니다.

반환 코드 선택
하드웨어 fault 원인 확인가장 구체적인 errno 선택정상 결과는 0 또는 양수호스트 버스 probe 규칙 적용상위 호출자에 음수 fault 반환

구체적인 하드웨어 보고가 있으면 대응하는 errno를 사용합니다.


I2C and SMBus fault codes
-------------------------
These are returned as negative numbers from most calls, with zero or
some positive number indicating a non-fault return.  The specific
numbers associated with these symbols differ between architectures,
though most Linux systems use <asm-generic/errno*.h> numbering.

Note that the descriptions here are not exhaustive.  There are other
codes that may be returned, and other cases where these codes should
be returned.  However, drivers should not return other codes for these
cases (unless the hardware doesn't provide unique fault reports).

Also, codes returned by adapter probe methods follow rules which are
specific to their host bus (such as PCI, or the platform bus).

주소·중재·PEC·버스 점유 fault

41-69

`EAFNOSUPPORT`는 10비트 주소를 지원하지 않는 I2C 어댑터에 10비트 주소 사용을 요청했을 때 반환합니다.

`EAGAIN`은 마스터 송신 중 중재를 잃었을 때 반환합니다. 다른 마스터가 동시에 다른 데이터를 전송한 경우입니다. atomic context에서 I2C 연산을 호출하려는데 다른 task가 이미 그 버스를 사용하는 경우에도 반환합니다.

`EBADMSG`는 SMBus 로직이 잘못된 Packet Error Code 바이트를 받았을 때 반환합니다. PEC는 트랜잭션의 모든 바이트를 덮는 CRC이며 마지막 STOP 전에 전송됩니다. 이 fault는 읽기에서만 보고되고, 쓰기의 PEC 불일치는 슬레이브가 별도 방식으로 호스트에 알릴 수 있습니다. PEC를 사용해도 잘못된 데이터 전송을 감지하는 유일한 수단으로 의존해서는 안 됩니다.

`EBUSY`는 버스가 허용 시간보다 오래 busy였을 때 SMBus 어댑터가 반환합니다. 보통 어떤 장치나 어댑터에 reset 같은 fault 복구가 필요하거나, reset을 시도했지만 실패했음을 나타냅니다.

초기 I2C fault codes
코드대표 원인대응
`EAFNOSUPPORT`10비트 주소 미지원7비트 사용 또는 기능 확인
`EAGAIN`중재 손실멱등 전송 재시도
`EAGAIN`atomic context에서 버스 사용 중나중에 재시도
`EBADMSG`읽기 PEC CRC 불일치데이터 폐기·재시도, 다른 검증 병행
`EBUSY`버스가 너무 오래 busy장치·어댑터 reset과 복구 확인

주소 모드, 중재, PEC, 버스 점유 원인을 대응시킵니다.

중재·PEC·busy 복구
fault code와 전송 단계 확인`EAGAIN`이면 중재·context 원인 제거 후 재시도`EBADMSG`이면 PEC 데이터 폐기`EBUSY`이면 버스·장치 reset 검토복구 결과를 상위 계층에 전달

일시적 재시도와 하드웨어 복구를 원인별로 나눕니다.


EAFNOSUPPORT
        Returned by I2C adapters not supporting 10 bit addresses when
        they are requested to use such an address.

EAGAIN
        Returned by I2C adapters when they lose arbitration in master
        transmit mode:  some other master was transmitting different
        data at the same time.

        Also returned when trying to invoke an I2C operation in an
        atomic context, when some task is already using that I2C bus
        to execute some other operation.

EBADMSG
        Returned by SMBus logic when an invalid Packet Error Code byte
        is received.  This code is a CRC covering all bytes in the
        transaction, and is sent before the terminating STOP.  This
        fault is only reported on read transactions; the SMBus slave
        may have a way to report PEC mismatches on writes from the
        host.  Note that even if PECs are in use, you should not rely
        on these as the only way to detect incorrect data transfers.

EBUSY
        Returned by SMBus adapters when the bus was busy for longer
        than allowed.  This usually indicates some device (maybe the
        SMBus adapter) needs some fault recovery (such as resetting),
        or that the reset was attempted but failed.

일반 I/O·장치·주소 fault

70-100

`EINVAL`은 I/O를 시작하기 전에 잘못된 매개변수를 감지했다는 다소 모호한 오류입니다. 가능하면 더 구체적인 fault code를 사용하십시오.

`EIO`는 I/O 연산 수행 중 무언가 잘못되었다는 다소 모호한 오류입니다. 가능하면 더 구체적인 fault code를 사용하십시오.

`ENODEV`는 드라이버 `probe()`가 반환합니다. 주소 문제가 아니라 그 주소에서 찾은 장치가 문제라는 점에서 `ENXIO`보다 구체적입니다. probe는 장치가 올바른 응답을 반환하는지 검증한 뒤 적절히 이 코드를 반환할 수 있습니다. 드라이버 core는 `ENXIO`와 `ENODEV` 이외의 probe fault를 경고합니다.

`ENOMEM`은 필요한 메모리를 할당할 수 없는 구성 요소가 반환합니다.

`ENXIO`는 전송 주소 단계가 ACK를 받지 못했음을 I2C 어댑터가 나타낼 때 반환합니다. 장치가 일시적으로 응답하지 않는 경우도 있지만 보통 해당 주소에 수신 장치가 없다는 뜻입니다.

드라이버 `probe()`가 결합할 장치를 찾지 못했음을 나타낼 때도 `ENXIO`를 반환합니다. 이때 `ENODEV`도 사용할 수 있습니다.

일반·장치 fault codes
코드의미
`EINVAL`I/O 시작 전 잘못된 매개변수
`EIO`I/O 수행 중 일반 오류
`ENODEV`주소에는 응답이 있지만 올바른 장치가 아님
`ENOMEM`필요한 메모리 할당 실패
`ENXIO`주소 단계 ACK 없음
`ENXIO` 또는 `ENODEV``probe()`가 결합할 장치를 찾지 못함

모호한 오류와 probe·주소 오류를 구분합니다.

probe fault 선택
주소 단계 ACK 확인ACK가 없으면 `ENXIO`응답이 있으면 장치 식별 검증잘못된 장치면 `ENODEV`더 구체적 원인이 없을 때만 `EINVAL`·`EIO`

주소 응답 여부와 장치 정합성을 구분합니다.

EINVAL
        This rather vague error means an invalid parameter has been
        detected before any I/O operation was started.  Use a more
        specific fault code when you can.

EIO
        This rather vague error means something went wrong when
        performing an I/O operation.  Use a more specific fault
        code when you can.

ENODEV
        Returned by driver probe() methods.  This is a bit more
        specific than ENXIO, implying the problem isn't with the
        address, but with the device found there.  Driver probes
        may verify the device returns *correct* responses, and
        return this as appropriate.  (The driver core will warn
        about probe faults other than ENXIO and ENODEV.)

ENOMEM
        Returned by any component that can't allocate memory when
        it needs to do so.

ENXIO
        Returned by I2C adapters to indicate that the address phase
        of a transfer didn't get an ACK.  While it might just mean
        an I2C device was temporarily not responding, usually it
        means there's nothing listening at that address.

        Returned by driver probe() methods to indicate that they
        found no device to bind to.  (ENODEV may also be used.)

미지원·프로토콜·중지·시간 초과

101-135

`EOPNOTSUPP`는 어댑터가 지원하지 않거나 수행할 수 없는 연산을 요청받았을 때 반환합니다. 예를 들어 SMBus block transfer를 지원하지 않는 어댑터에 이를 요청하면 반환합니다. 요청 드라이버는 block transfer 전에 기능 지원을 확인했어야 합니다.

마찬가지로 I2C 어댑터가 합법적인 모든 I2C 메시지를 실행할 수 없다면 수행 불가능한 트랜잭션 요청에 이 코드를 반환해야 합니다. 어댑터가 I2C를 지원하면 전체 I2C를 지원한다고 가정하므로 이런 제한은 functionality mask에 나타낼 수 없습니다.

`EPROTO`는 슬레이브가 관련 I2C, SMBus 또는 칩 고유 프로토콜 규격을 따르지 않을 때 반환합니다. 예를 들어 SMBus 슬레이브의 block data 응답 길이가 1~32바이트 범위를 벗어난 경우입니다.

`ESHUTDOWN`은 이미 suspend된 어댑터로 전송을 요청했을 때 반환합니다.

`ETIMEDOUT`은 연산이 너무 오래 걸려 완료 전에 중단했을 때 드라이버가 반환합니다. SMBus 어댑터는 슬레이브가 클록을 지나치게 늘이는 등 SMBus 규격의 허용 시간을 넘으면 반환할 수 있습니다. I2C에는 그런 timeout이 없지만 I2C 어댑터가 SMBus보다 훨씬 긴 임의 제한을 두는 것은 일반적입니다.

연산·프로토콜 fault codes
코드대표 원인핵심 조건
`EOPNOTSUPP`지원하지 않는 연산block transfer 또는 일부 합법 I2C 메시지
`EPROTO`슬레이브 프로토콜 위반SMBus block 길이가 1~32 밖
`ESHUTDOWN`suspend된 어댑터전송 요청 시점
`ETIMEDOUT`연산 시간 초과SMBus 제한 또는 어댑터 자체 제한

지원 능력, 응답 형식, 전원 상태, 시간 제한을 구분합니다.

최종 fault 분류
어댑터 기능 지원 여부 확인슬레이브 응답 형식 검증어댑터 suspend 상태 확인허용 전송 시간 확인가장 구체적인 fault code 반환

기능, 프로토콜, 전원 상태, 시간을 차례로 확인합니다.

EOPNOTSUPP
        Returned by an adapter when asked to perform an operation
        that it doesn't, or can't, support.

        For example, this would be returned when an adapter that
        doesn't support SMBus block transfers is asked to execute
        one.  In that case, the driver making that request should
        have verified that functionality was supported before it
        made that block transfer request.

        Similarly, if an I2C adapter can't execute all legal I2C
        messages, it should return this when asked to perform a
        transaction it can't.  (These limitations can't be seen in
        the adapter's functionality mask, since the assumption is
        that if an adapter supports I2C it supports all of I2C.)

EPROTO
        Returned when slave does not conform to the relevant I2C
        or SMBus (or chip-specific) protocol specifications.  One
        case is when the length of an SMBus block data response
        (from the SMBus slave) is outside the range 1-32 bytes.

ESHUTDOWN
        Returned when a transfer was requested using an adapter
        which is already suspended.

ETIMEDOUT
        This is returned by drivers when an operation took too much
        time, and was aborted before it completed.

        SMBus adapters may return it when an operation took more
        time than allowed by the SMBus specification; for example,
        when a slave stretches clocks too far.  I2C has no such
        timeouts, but it's normal for I2C adapters to impose some
        arbitrary limits (much longer than SMBus!) too.