# PCI IOMMU Mapping Properties

_Peios Kernel / Hardware and drivers / Device-tree binding reference / Shared binding definitions / pci_

> Device-tree binding reference for PCI IOMMU Mapping Properties.

<!-- SPDX-License-Identifier: BSD-2-Clause -->


<a id="dt-root"></a>

**Schema identifier (<code>&#36;id</code>):** <span id="dt-09f478f44eb202ea573e"><code>&#34;http&#58;&#47;&#47;devicetree&#46;org&#47;schemas&#47;pci&#47;pci&#45;iommu&#46;yaml&#35;&#34;</code></span>

**Schema dialect (<code>&#36;schema</code>):** <span id="dt-dcb375baab6014763a68"><code>&#34;http&#58;&#47;&#47;devicetree&#46;org&#47;meta&#45;schemas&#47;core&#46;yaml&#35;&#34;</code></span>

<a id="dt-e46b5a5dd81dbd751c9f"></a>

<div id="dt-6d1c5ef59f0239d38c02">
<p style="white-space: pre-wrap">This document describes the generic device tree binding for describing the
relationship between PCI(e) devices and IOMMU(s).</p>
<p style="white-space: pre-wrap">Each PCI(e) device under a root complex is uniquely identified by its Requester
ID (AKA RID). A Requester ID is a triplet of a Bus number, Device number, and
Function number.</p>
<p style="white-space: pre-wrap">For the purpose of this document, when treated as a numeric value, a RID is
formatted such that:</p>
<p style="white-space: pre-wrap">* Bits [15:8] are the Bus number.
* Bits [7:3] are the Device number.
* Bits [2:0] are the Function number.
* Any other bits required for padding must be zero.</p>
<p style="white-space: pre-wrap">IOMMUs may distinguish PCI devices through sideband data derived from the
Requester ID. While a given PCI device can only master through one IOMMU, a
root complex may split masters across a set of IOMMUs (e.g. with one IOMMU per
bus).</p>
<p style="white-space: pre-wrap">The generic 'iommus' property is insufficient to describe this relationship,
and a mechanism is required to map from a PCI device to its IOMMU and sideband
data.</p>
</div>

**Maintainers (<code>maintainers</code>):** <a id="dt-fbc39820abb8bb999095"></a> <span id="dt-fb78ddfc22abfc6fe56d"><code>&#34;Rob Herring &#60;robh&#64;kernel&#46;org&#62;&#34;</code></span>

<a id="dt-865ef19e891fb9fe7b15"></a>

## Automatic schema selection (<code>select</code>)

<code>true</code>

This selection rule always matches.

<a id="dt-e1f655ed0ff4d595dadc"></a>

## Properties and child nodes (<code>properties</code>)

<a id="dt-476cf51129594c4bb1fd"></a>

### <code>iommu&#45;map</code> — not listed as required here

<div id="dt-8e0b4813cab58856655c">
<p style="white-space: pre-wrap">Maps a Requester ID to an IOMMU and associated IOMMU specifier data.</p>
<p style="white-space: pre-wrap">The property is an arbitrary number of tuples of
(rid-base, iommu, iommu-specifier, rid-length).</p>
<p style="white-space: pre-wrap">The length of the iommu-specifier is determined by the #iommu-cells
property of the associated IOMMU node.</p>
<p style="white-space: pre-wrap">Any RID r in the interval [rid-base, rid-base + length) is associated
with the listed IOMMU, with the IOMMU specifier (r - rid-base + iommu-base).</p>
</div>

**Shared schema rule (<code>&#36;ref</code>):** <span id="dt-467f9994d944559515a3">[<code>&#47;schemas&#47;types&#46;yaml&#35;&#47;definitions&#47;uint32&#45;matrix</code>](</kernel/hardware/devicetree-bindings/dt-shared/types.md#dt-d948f2945b497d9aa3c7>)</span>

<a id="dt-00761d1c23dbb6f3acd2"></a>

### <code>iommu&#45;map&#45;mask</code> — not listed as required here

<div id="dt-d6b446884f238fed6f5a">
<p style="white-space: pre-wrap">A mask to be applied to each Requester ID prior to being mapped to an IOMMU specifier per the iommu-map property.</p>
</div>

**Shared schema rule (<code>&#36;ref</code>):** <span id="dt-010356b7462fa5b50a20">[<code>&#47;schemas&#47;types&#46;yaml&#35;&#47;definitions&#47;uint32</code>](</kernel/hardware/devicetree-bindings/dt-shared/types.md#dt-d57795d6573ee5d67d37>)</span>

**Maximum value (<code>maximum</code>):** <span id="dt-4d97fe954bbc2502650c"><code>65535</code></span>

<a id="dt-738c4b4f9e483441138b"></a>

## Properties not matched by properties or patternProperties in this schema (<code>additionalProperties</code>)

<code>true</code>

Allowed by this rule.

<a id="dt-1a130cabaa8a47b058bf"></a>

## Examples (<code>examples</code>)

<pre id="dt-0bd6510295af0c95ff2d"><code class="language-dts">/ {
    #address-cells = &lt;1&gt;;
    #size-cells = &lt;1&gt;;

    iommu: iommu@a {
        reg = &lt;0xa 0x1&gt;;
        compatible = "foo,some-iommu";
        #iommu-cells = &lt;1&gt;;
    };

    pci: pci@f {
        reg = &lt;0xf 0x1&gt;;
        compatible = "foo,pcie-root-complex";
        device_type = "pci";

        /*
        * The sideband data provided to the IOMMU is the RID,
        * identity-mapped.
        */
        iommu-map = &lt;0x0 &amp;iommu 0x0 0x10000&gt;;
    };
};
</code></pre>

<pre id="dt-bae0d43ea48e35208b4a"><code class="language-dts">/ {
    #address-cells = &lt;1&gt;;
    #size-cells = &lt;1&gt;;

    iommu: iommu@a {
        reg = &lt;0xa 0x1&gt;;
        compatible = "foo,some-iommu";
        #iommu-cells = &lt;1&gt;;
    };

    pci: pci@f {
        reg = &lt;0xf 0x1&gt;;
        compatible = "foo,pcie-root-complex";
        device_type = "pci";

        /*
        * The sideband data provided to the IOMMU is the RID with the
        * function bits masked out.
        */
        iommu-map = &lt;0x0 &amp;iommu 0x0 0x10000&gt;;
        iommu-map-mask = &lt;0xfff8&gt;;
    };
};
</code></pre>

<pre id="dt-d0212a4cd671f89a0b40"><code class="language-dts">/ {
  #address-cells = &lt;1&gt;;
  #size-cells = &lt;1&gt;;

  iommu: iommu@a {
      reg = &lt;0xa 0x1&gt;;
      compatible = "foo,some-iommu";
      #iommu-cells = &lt;1&gt;;
  };

  pci: pci@f {
      reg = &lt;0xf 0x1&gt;;
      compatible = "foo,pcie-root-complex";
      device_type = "pci";

      /*
      * The sideband data provided to the IOMMU is the RID,
      * but the high bits of the bus number are flipped.
      */
      iommu-map = &lt;0x0000 &amp;iommu 0x8000 0x8000&gt;,
                  &lt;0x8000 &amp;iommu 0x0000 0x8000&gt;;
  };
};
</code></pre>

<pre id="dt-cf8a683b5a963eb1c566"><code class="language-dts">/ {
  #address-cells = &lt;1&gt;;
  #size-cells = &lt;1&gt;;

  iommu_a: iommu@a {
      reg = &lt;0xa 0x1&gt;;
      compatible = "foo,some-iommu";
      #iommu-cells = &lt;1&gt;;
  };

  iommu_b: iommu@b {
      reg = &lt;0xb 0x1&gt;;
      compatible = "foo,some-iommu";
      #iommu-cells = &lt;1&gt;;
  };

  iommu_c: iommu@c {
      reg = &lt;0xc 0x1&gt;;
      compatible = "foo,some-iommu";
      #iommu-cells = &lt;1&gt;;
  };

  pci: pci@f {
      reg = &lt;0xf 0x1&gt;;
      compatible = "foo,pcie-root-complex";
      device_type = "pci";

      /*
      * Devices with bus number 0-127 are mastered via IOMMU
      * a, with sideband data being RID[14:0].
      * Devices with bus number 128-255 are mastered via
      * IOMMU b, with sideband data being RID[14:0].
      * No devices master via IOMMU c.
      */
      iommu-map = &lt;0x0000 &amp;iommu_a 0x0000 0x8000&gt;,
                  &lt;0x8000 &amp;iommu_b 0x0000 0x8000&gt;;
    };
};
</code></pre>

<pre id="dt-89dd782fdab7d446b5b9"><code class="language-dts">/ {
  #address-cells = &lt;1&gt;;
  #size-cells = &lt;1&gt;;

  iommu: iommu@a {
      reg = &lt;0xa 0x1&gt;;
      compatible = "foo,some-iommu";
      #iommu-cells = &lt;2&gt;;
  };

  pci: pci@f {
      reg = &lt;0xf 0x1&gt;;
      compatible = "foo,pcie-root-complex";
      device_type = "pci";

      /*
      * The IOMMU uses 2-cell specifiers (#iommu-cells = &lt;2&gt;).
      * Each iommu-map entry has 5 cells:
      * (rid-base, iommu, iommu-specifier[0], iommu-specifier[1], length)
      * Multiple entries are supported.
      */
      iommu-map = &lt;0x0000 &amp;iommu 0x0 0x0 0x8000&gt;,
                  &lt;0x8000 &amp;iommu 0x0 0x1 0x8000&gt;;
  };
};
</code></pre>

## Source notes

<details>
<summary>Annotations retained from the schema source</summary>

<p id="dt-comment-0"><strong>Line 1:</strong> <span> SPDX-License-Identifier: BSD-2-Clause</span></p>

<p id="dt-comment-1"><strong>Line 2:</strong> <span> Copyright 2016,2022 Arm Ltd.</span></p>

</details>
