pci-iommu.txt 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. This document describes the generic device tree binding for describing the
  2. relationship between PCI(e) devices and IOMMU(s).
  3. Each PCI(e) device under a root complex is uniquely identified by its Requester
  4. ID (AKA RID). A Requester ID is a triplet of a Bus number, Device number, and
  5. Function number.
  6. For the purpose of this document, when treated as a numeric value, a RID is
  7. formatted such that:
  8. * Bits [15:8] are the Bus number.
  9. * Bits [7:3] are the Device number.
  10. * Bits [2:0] are the Function number.
  11. * Any other bits required for padding must be zero.
  12. IOMMUs may distinguish PCI devices through sideband data derived from the
  13. Requester ID. While a given PCI device can only master through one IOMMU, a
  14. root complex may split masters across a set of IOMMUs (e.g. with one IOMMU per
  15. bus).
  16. The generic 'iommus' property is insufficient to describe this relationship,
  17. and a mechanism is required to map from a PCI device to its IOMMU and sideband
  18. data.
  19. For generic IOMMU bindings, see
  20. Documentation/devicetree/bindings/iommu/iommu.txt.
  21. PCI root complex
  22. ================
  23. Optional properties
  24. -------------------
  25. - iommu-map: Maps a Requester ID to an IOMMU and associated iommu-specifier
  26. data.
  27. The property is an arbitrary number of tuples of
  28. (rid-base,iommu,iommu-base,length).
  29. Any RID r in the interval [rid-base, rid-base + length) is associated with
  30. the listed IOMMU, with the iommu-specifier (r - rid-base + iommu-base).
  31. - iommu-map-mask: A mask to be applied to each Requester ID prior to being
  32. mapped to an iommu-specifier per the iommu-map property.
  33. Example (1)
  34. ===========
  35. / {
  36. #address-cells = <1>;
  37. #size-cells = <1>;
  38. iommu: iommu@a {
  39. reg = <0xa 0x1>;
  40. compatible = "vendor,some-iommu";
  41. #iommu-cells = <1>;
  42. };
  43. pci: pci@f {
  44. reg = <0xf 0x1>;
  45. compatible = "vendor,pcie-root-complex";
  46. device_type = "pci";
  47. /*
  48. * The sideband data provided to the IOMMU is the RID,
  49. * identity-mapped.
  50. */
  51. iommu-map = <0x0 &iommu 0x0 0x10000>;
  52. };
  53. };
  54. Example (2)
  55. ===========
  56. / {
  57. #address-cells = <1>;
  58. #size-cells = <1>;
  59. iommu: iommu@a {
  60. reg = <0xa 0x1>;
  61. compatible = "vendor,some-iommu";
  62. #iommu-cells = <1>;
  63. };
  64. pci: pci@f {
  65. reg = <0xf 0x1>;
  66. compatible = "vendor,pcie-root-complex";
  67. device_type = "pci";
  68. /*
  69. * The sideband data provided to the IOMMU is the RID with the
  70. * function bits masked out.
  71. */
  72. iommu-map = <0x0 &iommu 0x0 0x10000>;
  73. iommu-map-mask = <0xfff8>;
  74. };
  75. };
  76. Example (3)
  77. ===========
  78. / {
  79. #address-cells = <1>;
  80. #size-cells = <1>;
  81. iommu: iommu@a {
  82. reg = <0xa 0x1>;
  83. compatible = "vendor,some-iommu";
  84. #iommu-cells = <1>;
  85. };
  86. pci: pci@f {
  87. reg = <0xf 0x1>;
  88. compatible = "vendor,pcie-root-complex";
  89. device_type = "pci";
  90. /*
  91. * The sideband data provided to the IOMMU is the RID,
  92. * but the high bits of the bus number are flipped.
  93. */
  94. iommu-map = <0x0000 &iommu 0x8000 0x8000>,
  95. <0x8000 &iommu 0x0000 0x8000>;
  96. };
  97. };
  98. Example (4)
  99. ===========
  100. / {
  101. #address-cells = <1>;
  102. #size-cells = <1>;
  103. iommu_a: iommu@a {
  104. reg = <0xa 0x1>;
  105. compatible = "vendor,some-iommu";
  106. #iommu-cells = <1>;
  107. };
  108. iommu_b: iommu@b {
  109. reg = <0xb 0x1>;
  110. compatible = "vendor,some-iommu";
  111. #iommu-cells = <1>;
  112. };
  113. iommu_c: iommu@c {
  114. reg = <0xc 0x1>;
  115. compatible = "vendor,some-iommu";
  116. #iommu-cells = <1>;
  117. };
  118. pci: pci@f {
  119. reg = <0xf 0x1>;
  120. compatible = "vendor,pcie-root-complex";
  121. device_type = "pci";
  122. /*
  123. * Devices with bus number 0-127 are mastered via IOMMU
  124. * a, with sideband data being RID[14:0].
  125. * Devices with bus number 128-255 are mastered via
  126. * IOMMU b, with sideband data being RID[14:0].
  127. * No devices master via IOMMU c.
  128. */
  129. iommu-map = <0x0000 &iommu_a 0x0000 0x8000>,
  130. <0x8000 &iommu_b 0x0000 0x8000>;
  131. };
  132. };