← Documents Documentation/devicetree/bindings/iommu/iommu.txt GitHub 원문 ↗

Linux 6.18.37 · Devicetree Bindings

Generic IOMMU Bindings

IOMMU device, master interface, 주소 변환과 DMA stall의 공통 바인딩입니다.

Source pathDocumentation/devicetree/bindings/iommu/iommu.txt
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

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

1. 요약·해설

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

요약과 해설

iommu.txt:1-206

Cell 형식, dma-ranges 우선순위와 네 가지 master 구성을 설명합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 This document describes the generic device tree binding for IOMMUs and their
2 master(s).
3
4
5 IOMMU device node:
6 ==================
7
8 An IOMMU can provide the following services:
9
10 * Remap address space to allow devices to access physical memory ranges that
11 they otherwise wouldn't be capable of accessing.
12
13 Example: 32-bit DMA to 64-bit physical addresses
14
15 * Implement scatter-gather at page level granularity so that the device does
16 not have to.
17
18 * Provide system protection against "rogue" DMA by forcing all accesses to go
19 through the IOMMU and faulting when encountering accesses to unmapped
20 address regions.
21
22 * Provide address space isolation between multiple contexts.
23
24 Example: Virtualization
25
26 Device nodes compatible with this binding represent hardware with some of the
27 above capabilities.
28
29 IOMMUs can be single-master or multiple-master. Single-master IOMMU devices
30 typically have a fixed association to the master device, whereas multiple-
31 master IOMMU devices can translate accesses from more than one master.
32
33 The device tree node of the IOMMU device's parent bus must contain a valid
34 "dma-ranges" property that describes how the physical address space of the
35 IOMMU maps to memory. An empty "dma-ranges" property means that there is a
36 1:1 mapping from IOMMU to memory.
37
38 Required properties:
39 --------------------
40 - #iommu-cells: The number of cells in an IOMMU specifier needed to encode an
41 address.
42
43 The meaning of the IOMMU specifier is defined by the device tree binding of
44 the specific IOMMU. Below are a few examples of typical use-cases:
45
46 - #iommu-cells = <0>: Single master IOMMU devices are not configurable and
47 therefore no additional information needs to be encoded in the specifier.
48 This may also apply to multiple master IOMMU devices that do not allow the
49 association of masters to be configured. Note that an IOMMU can by design
50 be multi-master yet only expose a single master in a given configuration.
51 In such cases the number of cells will usually be 1 as in the next case.
52 - #iommu-cells = <1>: Multiple master IOMMU devices may need to be configured
53 in order to enable translation for a given master. In such cases the single
54 address cell corresponds to the master device's ID. In some cases more than
55 one cell can be required to represent a single master ID.
56 - #iommu-cells = <4>: Some IOMMU devices allow the DMA window for masters to
57 be configured. The first cell of the address in this may contain the master
58 device's ID for example, while the second cell could contain the start of
59 the DMA window for the given device. The length of the DMA window is given
60 by the third and fourth cells.
61
62 Note that these are merely examples and real-world use-cases may use different
63 definitions to represent their individual needs. Always refer to the specific
64 IOMMU binding for the exact meaning of the cells that make up the specifier.
65
66
67 IOMMU master node:
68 ==================
69
70 Devices that access memory through an IOMMU are called masters. A device can
71 have multiple master interfaces (to one or more IOMMU devices).
72
73 Required properties:
74 --------------------
75 - iommus: A list of phandle and IOMMU specifier pairs that describe the IOMMU
76 master interfaces of the device. One entry in the list describes one master
77 interface of the device.
78
79 When an "iommus" property is specified in a device tree node, the IOMMU will
80 be used for address translation. If a "dma-ranges" property exists in the
81 device's parent node it will be ignored. An exception to this rule is if the
82 referenced IOMMU is disabled, in which case the "dma-ranges" property of the
83 parent shall take effect. Note that merely disabling a device tree node does
84 not guarantee that the IOMMU is really disabled since the hardware may not
85 have a means to turn off translation. But it is invalid in such cases to
86 disable the IOMMU's device tree node in the first place because it would
87 prevent any driver from properly setting up the translations.
88
89 Optional properties:
90 --------------------
91 - pasid-num-bits: Some masters support multiple address spaces for DMA, by
92 tagging DMA transactions with an address space identifier. By default,
93 this is 0, which means that the device only has one address space.
94
95 - dma-can-stall: When present, the master can wait for a transaction to
96 complete for an indefinite amount of time. Upon translation fault some
97 IOMMUs, instead of aborting the translation immediately, may first
98 notify the driver and keep the transaction in flight. This allows the OS
99 to inspect the fault and, for example, make physical pages resident
100 before updating the mappings and completing the transaction. Such IOMMU
101 accepts a limited number of simultaneous stalled transactions before
102 having to either put back-pressure on the master, or abort new faulting
103 transactions.
104
105 Firmware has to opt-in stalling, because most buses and masters don't
106 support it. In particular it isn't compatible with PCI, where
107 transactions have to complete before a time limit. More generally it
108 won't work in systems and masters that haven't been designed for
109 stalling. For example the OS, in order to handle a stalled transaction,
110 may attempt to retrieve pages from secondary storage in a stalled
111 domain, leading to a deadlock.
112
113
114 Notes:
115 ======
116
117 One possible extension to the above is to use an "iommus" property along with
118 a "dma-ranges" property in a bus device node (such as PCI host bridges). This
119 can be useful to describe how children on the bus relate to the IOMMU if they
120 are not explicitly listed in the device tree (e.g. PCI devices). However, the
121 requirements of that use-case haven't been fully determined yet. Implementing
122 this is therefore not recommended without further discussion and extension of
123 this binding.
124
125
126 Examples:
127 =========
128
129 Single-master IOMMU:
130 --------------------
131
132 iommu {
133 #iommu-cells = <0>;
134 };
135
136 master {
137 iommus = <&{/iommu}>;
138 };
139
140 Multiple-master IOMMU with fixed associations:
141 ----------------------------------------------
142
143 /* multiple-master IOMMU */
144 iommu {
145 /*
146 * Masters are statically associated with this IOMMU and share
147 * the same address translations because the IOMMU does not
148 * have sufficient information to distinguish between masters.
149 *
150 * Consequently address translation is always on or off for
151 * all masters at any given point in time.
152 */
153 #iommu-cells = <0>;
154 };
155
156 /* static association with IOMMU */
157 master@1 {
158 reg = <1>;
159 iommus = <&{/iommu}>;
160 };
161
162 /* static association with IOMMU */
163 master@2 {
164 reg = <2>;
165 iommus = <&{/iommu}>;
166 };
167
168 Multiple-master IOMMU:
169 ----------------------
170
171 iommu {
172 /* the specifier represents the ID of the master */
173 #iommu-cells = <1>;
174 };
175
176 master@1 {
177 /* device has master ID 42 in the IOMMU */
178 iommus = <&{/iommu} 42>;
179 };
180
181 master@2 {
182 /* device has master IDs 23 and 24 in the IOMMU */
183 iommus = <&{/iommu} 23>, <&{/iommu} 24>;
184 };
185
186 Multiple-master IOMMU with configurable DMA window:
187 ---------------------------------------------------
188
189 / {
190 iommu {
191 /*
192 * One cell for the master ID and one cell for the
193 * address of the DMA window. The length of the DMA
194 * window is encoded in two cells.
195 *
196 * The DMA window is the range addressable by the
197 * master (i.e. the I/O virtual address space).
198 */
199 #iommu-cells = <4>;
200 };
201
202 master {
203 /* master ID 42, 4 GiB DMA window starting at 0 */
204 iommus = <&{/iommu} 42 0 0x1 0x0>;
205 };
206 };
207

3. 한국어 전문 번역

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

IOMMU device node

1-66

이 문서는 IOMMU와 그 master를 위한 일반 Device Tree 바인딩을 설명합니다. IOMMU는 장치가 원래 접근할 수 없는 물리 메모리 범위를 사용하도록 주소 공간을 재매핑할 수 있습니다. 예를 들어 32-bit DMA를 64-bit 물리 주소에 연결할 수 있습니다.

또한 장치가 직접 구현하지 않아도 되도록 page 단위 scatter-gather를 제공하고, 모든 접근을 IOMMU를 거치게 한 뒤 매핑되지 않은 주소 접근에서 fault를 발생시켜 rogue DMA로부터 시스템을 보호합니다. 여러 context 사이의 주소 공간 격리도 제공하며 virtualization이 대표 사례입니다.

이 바인딩과 호환되는 node는 위 기능 중 일부를 가진 하드웨어를 나타냅니다. IOMMU는 single-master 또는 multiple-master일 수 있습니다. Single-master 장치는 보통 master와 고정 연결되고, multiple-master 장치는 둘 이상의 master 접근을 변환할 수 있습니다.

IOMMU 장치의 부모 bus node에는 IOMMU의 물리 주소 공간이 메모리에 어떻게 매핑되는지 설명하는 유효한 `dma-ranges`가 있어야 합니다. 빈 `dma-ranges`는 IOMMU와 메모리 사이의 1:1 매핑을 뜻합니다.

IOMMU 제공 기능
기능효과
Address remapping장치 주소 범위를 물리 메모리에 연결
Page scatter-gather장치 대신 비연속 page 처리
DMA protection미매핑 접근에서 fault
Context isolationVirtualization용 주소 공간 분리

주소 변환 계층이 장치 DMA에 더하는 대표 기능입니다.

필수 `#iommu-cells`는 주소를 인코딩하기 위해 IOMMU specifier에 필요한 cell 수입니다. 정확한 의미는 특정 IOMMU 바인딩이 정의합니다. `<0>`은 구성할 추가 정보가 없는 single-master 또는 master 연결을 구성할 수 없는 multiple-master 장치에 쓸 수 있습니다. 하드웨어가 multi-master여도 현재 구성에서 master 하나만 노출한다면 보통 다음 사례처럼 cell 수 1을 사용합니다.

`#iommu-cells = <1>`은 주어진 master의 변환을 활성화하기 위해 구성해야 하는 multiple-master 장치에 흔히 쓰며 단일 cell은 master ID입니다. 단일 master ID를 표현하는 데 cell이 둘 이상 필요할 수도 있습니다.

`#iommu-cells = <4>`는 master의 DMA window를 구성할 수 있는 사례입니다. 첫 cell은 master ID, 둘째 cell은 해당 장치 DMA window의 시작 주소가 될 수 있고 셋째와 넷째 cell이 window 길이를 나타냅니다. 이는 예시일 뿐이므로 실제 cell 의미는 언제나 개별 IOMMU 바인딩을 확인해야 합니다.

일반적인 IOMMU specifier
#iommu-cells대표 의미
0추가 정보 없는 고정 master 연결
1Master ID
4Master ID + DMA window 시작 + 2-cell 길이

문서가 제시하는 cell 수별 대표 인코딩입니다.

IOMMU master node

67-113

IOMMU를 통해 메모리에 접근하는 장치를 master라고 합니다. 장치 하나가 하나 이상의 IOMMU에 연결된 여러 master interface를 가질 수 있습니다. 필수 `iommus`는 phandle과 IOMMU specifier 쌍의 목록이며 항목 하나가 장치의 master interface 하나를 설명합니다.

Device Tree node에 `iommus`가 있으면 주소 변환에 IOMMU를 사용하고 부모 node의 `dma-ranges`는 무시합니다. 예외는 참조한 IOMMU가 disabled인 경우이며 이때 부모의 `dma-ranges`가 적용됩니다. 단, node를 disabled로 표시해도 하드웨어에 변환을 끄는 수단이 없다면 실제 IOMMU가 꺼진다는 보장은 없습니다. 이런 하드웨어에서 IOMMU node를 disabled로 두면 driver가 변환을 올바르게 설정할 수 없으므로 그 구성 자체가 유효하지 않습니다.

선택 `pasid-num-bits`는 master가 DMA transaction에 address-space identifier를 붙여 여러 주소 공간을 지원할 때 그 PASID bit 수입니다. 기본값 0은 장치에 주소 공간이 하나뿐임을 뜻합니다.

`dma-can-stall`이 있으면 master는 transaction 완료를 무기한 기다릴 수 있습니다. 일부 IOMMU는 translation fault에서 즉시 abort하지 않고 driver에 알린 뒤 transaction을 진행 중 상태로 유지합니다. OS는 fault를 조사하고 물리 page를 resident 상태로 만든 다음 mapping을 갱신하여 transaction을 완료할 수 있습니다.

IOMMU가 동시에 유지할 수 있는 stalled transaction 수에는 한계가 있으므로 한도를 넘으면 master에 back-pressure를 주거나 새 fault transaction을 abort해야 합니다. 대부분의 bus와 master는 stall을 지원하지 않기 때문에 firmware가 명시적으로 opt-in해야 합니다. 시간 제한 안에 transaction을 완료해야 하는 PCI와 호환되지 않으며, stall을 고려하지 않은 시스템에서는 사용할 수 없습니다. 예를 들어 OS가 stalled domain의 secondary storage에서 page를 읽으려 하면 deadlock이 생길 수 있습니다.

Stalled translation fault 처리
DMA transactionTranslation fault
IOMMUTransaction in flight 유지
Driver / OSPage resident + mapping 갱신
Resume transaction또는 한도 초과 시 abort

지원되는 master에서는 fault를 보류한 채 OS가 page와 mapping을 복구할 수 있습니다.

Bus-level 확장에 관한 주의

114-125

가능한 확장으로 PCI host bridge 같은 bus 장치 node에서 `iommus`와 `dma-ranges`를 함께 사용하여 Device Tree에 명시적으로 나열되지 않은 PCI 장치 등의 자식과 IOMMU의 관계를 설명할 수 있습니다. 그러나 이 사용 사례의 요구사항은 아직 완전히 결정되지 않았으므로 바인딩을 더 논의하고 확장하기 전에는 구현하지 않는 것이 좋습니다.

IOMMU master 구성 예제

126-206

Single-master 예제는 `#iommu-cells = <0>`인 IOMMU를 master가 specifier 없이 참조합니다.

iommu {
        #iommu-cells = <0>;
};

master {
        iommus = <&{/iommu}>;
};

고정 연결 multiple-master 예제에서도 `#iommu-cells = <0>`을 사용합니다. IOMMU가 master를 구별할 정보가 부족해 모든 master가 같은 주소 변환을 공유하며 변환은 어느 시점에나 전체 master에 대해 함께 켜지거나 꺼집니다. `master@1`과 `master@2`는 같은 IOMMU에 정적으로 연결됩니다.

/* multiple-master IOMMU */
iommu {
        /*
         * Masters are statically associated with this IOMMU and share
         * the same address translations because the IOMMU does not
         * have sufficient information to distinguish between masters.
         *
         * Consequently address translation is always on or off for
         * all masters at any given point in time.
         */
        #iommu-cells = <0>;
};

/* static association with IOMMU */
master@1 {
        reg = <1>;
        iommus = <&{/iommu}>;
};

/* static association with IOMMU */
master@2 {
        reg = <2>;
        iommus = <&{/iommu}>;
};

구성 가능한 multiple-master 예제는 `#iommu-cells = <1>`로 master ID를 specifier에 넣습니다. 첫 장치는 ID 42 하나를 사용하고 둘째 장치는 ID 23과 24인 두 master interface를 가집니다.

iommu {
        /* the specifier represents the ID of the master */
        #iommu-cells = <1>;
};

master@1 {
        /* device has master ID 42 in the IOMMU */
        iommus = <&{/iommu} 42>;
};

master@2 {
        /* device has master IDs 23 and 24 in the IOMMU */
        iommus = <&{/iommu} 23>, <&{/iommu} 24>;
};

DMA window 구성 예제는 master ID 한 cell, window 주소 한 cell, 길이 두 cell로 총 네 cell을 사용합니다. Master 42에 주소 0에서 시작하는 4 GiB DMA window, 즉 I/O virtual address 공간을 지정합니다.

/ {
        iommu {
                /*
                 * One cell for the master ID and one cell for the
                 * address of the DMA window. The length of the DMA
                 * window is encoded in two cells.
                 *
                 * The DMA window is the range addressable by the
                 * master (i.e. the I/O virtual address space).
                 */
                #iommu-cells = <4>;
        };

        master {
                /* master ID 42, 4 GiB DMA window starting at 0 */
                iommus = <&{/iommu}  42  0  0x1 0x0>;
        };
};