iommu.txt 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. This document describes the generic device tree binding for IOMMUs and their
  2. master(s).
  3. IOMMU device node:
  4. ==================
  5. An IOMMU can provide the following services:
  6. * Remap address space to allow devices to access physical memory ranges that
  7. they otherwise wouldn't be capable of accessing.
  8. Example: 32-bit DMA to 64-bit physical addresses
  9. * Implement scatter-gather at page level granularity so that the device does
  10. not have to.
  11. * Provide system protection against "rogue" DMA by forcing all accesses to go
  12. through the IOMMU and faulting when encountering accesses to unmapped
  13. address regions.
  14. * Provide address space isolation between multiple contexts.
  15. Example: Virtualization
  16. Device nodes compatible with this binding represent hardware with some of the
  17. above capabilities.
  18. IOMMUs can be single-master or multiple-master. Single-master IOMMU devices
  19. typically have a fixed association to the master device, whereas multiple-
  20. master IOMMU devices can translate accesses from more than one master.
  21. The device tree node of the IOMMU device's parent bus must contain a valid
  22. "dma-ranges" property that describes how the physical address space of the
  23. IOMMU maps to memory. An empty "dma-ranges" property means that there is a
  24. 1:1 mapping from IOMMU to memory.
  25. Required properties:
  26. --------------------
  27. - #iommu-cells: The number of cells in an IOMMU specifier needed to encode an
  28. address.
  29. The meaning of the IOMMU specifier is defined by the device tree binding of
  30. the specific IOMMU. Below are a few examples of typical use-cases:
  31. - #iommu-cells = <0>: Single master IOMMU devices are not configurable and
  32. therefore no additional information needs to be encoded in the specifier.
  33. This may also apply to multiple master IOMMU devices that do not allow the
  34. association of masters to be configured. Note that an IOMMU can by design
  35. be multi-master yet only expose a single master in a given configuration.
  36. In such cases the number of cells will usually be 1 as in the next case.
  37. - #iommu-cells = <1>: Multiple master IOMMU devices may need to be configured
  38. in order to enable translation for a given master. In such cases the single
  39. address cell corresponds to the master device's ID. In some cases more than
  40. one cell can be required to represent a single master ID.
  41. - #iommu-cells = <4>: Some IOMMU devices allow the DMA window for masters to
  42. be configured. The first cell of the address in this may contain the master
  43. device's ID for example, while the second cell could contain the start of
  44. the DMA window for the given device. The length of the DMA window is given
  45. by the third and fourth cells.
  46. Note that these are merely examples and real-world use-cases may use different
  47. definitions to represent their individual needs. Always refer to the specific
  48. IOMMU binding for the exact meaning of the cells that make up the specifier.
  49. IOMMU master node:
  50. ==================
  51. Devices that access memory through an IOMMU are called masters. A device can
  52. have multiple master interfaces (to one or more IOMMU devices).
  53. Required properties:
  54. --------------------
  55. - iommus: A list of phandle and IOMMU specifier pairs that describe the IOMMU
  56. master interfaces of the device. One entry in the list describes one master
  57. interface of the device.
  58. When an "iommus" property is specified in a device tree node, the IOMMU will
  59. be used for address translation. If a "dma-ranges" property exists in the
  60. device's parent node it will be ignored. An exception to this rule is if the
  61. referenced IOMMU is disabled, in which case the "dma-ranges" property of the
  62. parent shall take effect. Note that merely disabling a device tree node does
  63. not guarantee that the IOMMU is really disabled since the hardware may not
  64. have a means to turn off translation. But it is invalid in such cases to
  65. disable the IOMMU's device tree node in the first place because it would
  66. prevent any driver from properly setting up the translations.
  67. Notes:
  68. ======
  69. One possible extension to the above is to use an "iommus" property along with
  70. a "dma-ranges" property in a bus device node (such as PCI host bridges). This
  71. can be useful to describe how children on the bus relate to the IOMMU if they
  72. are not explicitly listed in the device tree (e.g. PCI devices). However, the
  73. requirements of that use-case haven't been fully determined yet. Implementing
  74. this is therefore not recommended without further discussion and extension of
  75. this binding.
  76. Examples:
  77. =========
  78. Single-master IOMMU:
  79. --------------------
  80. iommu {
  81. #iommu-cells = <0>;
  82. };
  83. master {
  84. iommus = <&{/iommu}>;
  85. };
  86. Multiple-master IOMMU with fixed associations:
  87. ----------------------------------------------
  88. /* multiple-master IOMMU */
  89. iommu {
  90. /*
  91. * Masters are statically associated with this IOMMU and share
  92. * the same address translations because the IOMMU does not
  93. * have sufficient information to distinguish between masters.
  94. *
  95. * Consequently address translation is always on or off for
  96. * all masters at any given point in time.
  97. */
  98. #iommu-cells = <0>;
  99. };
  100. /* static association with IOMMU */
  101. master@1 {
  102. reg = <1>;
  103. iommus = <&{/iommu}>;
  104. };
  105. /* static association with IOMMU */
  106. master@2 {
  107. reg = <2>;
  108. iommus = <&{/iommu}>;
  109. };
  110. Multiple-master IOMMU:
  111. ----------------------
  112. iommu {
  113. /* the specifier represents the ID of the master */
  114. #iommu-cells = <1>;
  115. };
  116. master@1 {
  117. /* device has master ID 42 in the IOMMU */
  118. iommus = <&{/iommu} 42>;
  119. };
  120. master@2 {
  121. /* device has master IDs 23 and 24 in the IOMMU */
  122. iommus = <&{/iommu} 23>, <&{/iommu} 24>;
  123. };
  124. Multiple-master IOMMU with configurable DMA window:
  125. ---------------------------------------------------
  126. / {
  127. iommu {
  128. /*
  129. * One cell for the master ID and one cell for the
  130. * address of the DMA window. The length of the DMA
  131. * window is encoded in two cells.
  132. *
  133. * The DMA window is the range addressable by the
  134. * master (i.e. the I/O virtual address space).
  135. */
  136. #iommu-cells = <4>;
  137. };
  138. master {
  139. /* master ID 42, 4 GiB DMA window starting at 0 */
  140. iommus = <&{/iommu} 42 0 0x1 0x0>;
  141. };
  142. };