<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>i.MX ProcessorsのトピックPCI device assignment on iMX8 QM board</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/PCI-device-assignment-on-iMX8-QM-board/m-p/1730779#M213294</link>
    <description>&lt;P&gt;&lt;BR /&gt;We are doing some testing on iMX8 QM board.&lt;BR /&gt;We are trying to assign a network PCI card to a KVM guest.&lt;BR /&gt;Unfortunately, the device tree for the board does not specify an IOMMU for the PCI bus 1 (where this network card resides).&lt;BR /&gt;so we tried adding iommu and iommu-maps properties to the device tree:&lt;/P&gt;&lt;P&gt;diff --git a/arch/arm64/boot/dts/freescale/imx8qm-ss-hsio.dtsi b/arch/arm64/boot/dts/freescale/imx8qm-ss-hsio.dtsi&lt;BR /&gt;index 09fde1445c45..d1c1d8a89509 100644&lt;BR /&gt;--- a/arch/arm64/boot/dts/freescale/imx8qm-ss-hsio.dtsi&lt;BR /&gt;+++ b/arch/arm64/boot/dts/freescale/imx8qm-ss-hsio.dtsi&lt;BR /&gt;@@ -133,6 +133,23 @@ pciea: pcie@0x5f000000 {&lt;BR /&gt;hsio-cfg = &amp;lt;PCIEAX1PCIEBX1SATA&amp;gt;;&lt;BR /&gt;local-addr = &amp;lt;0x40000000&amp;gt;;&lt;BR /&gt;status = "disabled";&lt;BR /&gt;+ iommus = &amp;lt;&amp;amp;smmu 0x15 0x7f80&amp;gt;;&lt;BR /&gt;+ iommu-map = &amp;lt;0x0 &amp;amp;smmu 0x15 0x1000&amp;gt;;&lt;/P&gt;&lt;P&gt;which then puts all PCI devices in bus 1 under a single IOMMU group:&lt;/P&gt;&lt;P&gt;./3&lt;BR /&gt;./3/devices&lt;BR /&gt;./3/devices/0001:00:00.0&lt;BR /&gt;./3/devices/0001:02:02.0&lt;BR /&gt;./3/devices/0001:05:00.0&lt;BR /&gt;./3/devices/0001:02:01.0&lt;BR /&gt;./3/devices/0001:03:00.0&lt;BR /&gt;./3/devices/5f000000.pcie&lt;BR /&gt;./3/devices/0001:05:00.1&lt;BR /&gt;./3/devices/0001:02:03.0&lt;BR /&gt;./3/devices/0001:01:00.0&lt;BR /&gt;./3/type&lt;BR /&gt;./3/reserved_regions (edited)&lt;/P&gt;&lt;P&gt;However, this check on drivers/vfio/vfio_iommu_type1.c:&lt;/P&gt;&lt;P&gt;/* Determine bus_type in order to allocate a domain */&lt;BR /&gt;ret = iommu_group_for_each_dev(iommu_group, &amp;amp;bus, vfio_bus_type);&lt;BR /&gt;if (ret) {&lt;BR /&gt;goto out_free;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static int vfio_bus_type(struct device *dev, void *data)&lt;BR /&gt;{&lt;BR /&gt;struct bus_type **bus = data;&lt;/P&gt;&lt;P&gt;if (*bus &amp;amp;&amp;amp; *bus != dev-&amp;gt;bus)&lt;BR /&gt;return -EINVAL;&lt;/P&gt;&lt;P&gt;*bus = dev-&amp;gt;bus;&lt;/P&gt;&lt;P&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Fails since for ./3/devices/5f000000.pcie:&lt;/P&gt;&lt;P&gt;qemu-kvm-1218 [000] ..... 73.450622: vfio_bus_type: devname: 0001:00:00.0&lt;/P&gt;&lt;P&gt;And:&lt;/P&gt;&lt;P&gt;For 5f000000.pcie:&lt;/P&gt;&lt;P&gt;subsystem -&amp;gt; ../../../../bus/platform&lt;/P&gt;&lt;P&gt;whereas for the other devices in the IOMMU group&lt;/P&gt;&lt;P&gt;subsystem -&amp;gt; ../../../../../../../bus/pci&lt;/P&gt;&lt;P&gt;By skipping this check:&lt;/P&gt;&lt;P&gt;diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c&lt;BR /&gt;index 852e6c5643e5..4ce00dc42e7f 100644&lt;BR /&gt;--- a/drivers/vfio/vfio_iommu_type1.c&lt;BR /&gt;+++ b/drivers/vfio/vfio_iommu_type1.c&lt;BR /&gt;@@ -1699,8 +1699,12 @@ static int vfio_bus_type(struct device *dev, void *data)&lt;BR /&gt;{&lt;BR /&gt;struct bus_type **bus = data;&lt;/P&gt;&lt;P&gt;- if (*bus &amp;amp;&amp;amp; *bus != dev-&amp;gt;bus)&lt;BR /&gt;- return -EINVAL;&lt;BR /&gt;+ if (*bus &amp;amp;&amp;amp; *bus != dev-&amp;gt;bus) {&lt;BR /&gt;+ if (strncmp(dev_name(dev), "0001:00:00.0", 12) != 0) {&lt;BR /&gt;+ trace_printk("devname: %s\n", dev_name(dev));&lt;BR /&gt;+ return -EINVAL;&lt;BR /&gt;+ }&lt;BR /&gt;+ }&lt;/P&gt;&lt;P&gt;*bus = dev-&amp;gt;bus;&lt;/P&gt;&lt;P&gt;We are able to assign the PCI device to the guest, but:&lt;/P&gt;&lt;P&gt;[ 84.621002] igb 0000:00:03.0 enp0s3: igb: enp0s3 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX/TX&lt;BR /&gt;[ 88.071936] igb 0000:00:03.0: Detected Tx Unit Hang&lt;BR /&gt;[ 88.071936] Tx Queue &amp;lt;0&amp;gt;&lt;BR /&gt;[ 88.071936] TDH &amp;lt;1&amp;gt;&lt;BR /&gt;[ 88.071936] TDT &amp;lt;1&amp;gt;&lt;BR /&gt;[ 88.071936] next_to_use &amp;lt;1&amp;gt;&lt;BR /&gt;[ 88.071936] next_to_clean &amp;lt;0&amp;gt;&lt;BR /&gt;[ 88.071936] buffer_info[next_to_clean]&lt;BR /&gt;[ 88.071936] time_stamp &amp;lt;ffffac2a&amp;gt;&lt;BR /&gt;[ 88.071936] next_to_watch &amp;lt;00000000c2df116c&amp;gt;&lt;BR /&gt;[ 88.071936] jiffies &amp;lt;ffffad38&amp;gt;&lt;BR /&gt;[ 88.071936] desc.status &amp;lt;168000&amp;gt;&lt;BR /&gt;[ 90.070738] igb 0000:00:03.0: Detected Tx Unit Hang&lt;BR /&gt;[ 90.070738] Tx Queue &amp;lt;0&amp;gt;&lt;BR /&gt;[ 90.070738] TDH &amp;lt;1&amp;gt;&lt;BR /&gt;[ 90.070738] TDT &amp;lt;1&amp;gt;&lt;BR /&gt;[ 90.070738] next_to_use &amp;lt;1&amp;gt;&lt;BR /&gt;[ 90.070738] next_to_clean &amp;lt;0&amp;gt;&lt;BR /&gt;[ 90.070738] buffer_info[next_to_clean]&lt;BR /&gt;[ 90.070738] time_stamp &amp;lt;ffffac2a&amp;gt;&lt;BR /&gt;[ 90.070738] next_to_watch &amp;lt;00000000c2df116c&amp;gt;&lt;BR /&gt;[ 90.070738] jiffies &amp;lt;ffffae00&amp;gt;&lt;BR /&gt;[ 90.070738] desc.status &amp;lt;168000&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Any ideas on how to fix this?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;We are using origin/toradex_5.15-2.1.x-imx branch of git://git.toradex.com/linux-toradex.git&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 27 Sep 2023 21:12:30 GMT</pubDate>
    <dc:creator>mtosatti</dc:creator>
    <dc:date>2023-09-27T21:12:30Z</dc:date>
    <item>
      <title>PCI device assignment on iMX8 QM board</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/PCI-device-assignment-on-iMX8-QM-board/m-p/1730779#M213294</link>
      <description>&lt;P&gt;&lt;BR /&gt;We are doing some testing on iMX8 QM board.&lt;BR /&gt;We are trying to assign a network PCI card to a KVM guest.&lt;BR /&gt;Unfortunately, the device tree for the board does not specify an IOMMU for the PCI bus 1 (where this network card resides).&lt;BR /&gt;so we tried adding iommu and iommu-maps properties to the device tree:&lt;/P&gt;&lt;P&gt;diff --git a/arch/arm64/boot/dts/freescale/imx8qm-ss-hsio.dtsi b/arch/arm64/boot/dts/freescale/imx8qm-ss-hsio.dtsi&lt;BR /&gt;index 09fde1445c45..d1c1d8a89509 100644&lt;BR /&gt;--- a/arch/arm64/boot/dts/freescale/imx8qm-ss-hsio.dtsi&lt;BR /&gt;+++ b/arch/arm64/boot/dts/freescale/imx8qm-ss-hsio.dtsi&lt;BR /&gt;@@ -133,6 +133,23 @@ pciea: pcie@0x5f000000 {&lt;BR /&gt;hsio-cfg = &amp;lt;PCIEAX1PCIEBX1SATA&amp;gt;;&lt;BR /&gt;local-addr = &amp;lt;0x40000000&amp;gt;;&lt;BR /&gt;status = "disabled";&lt;BR /&gt;+ iommus = &amp;lt;&amp;amp;smmu 0x15 0x7f80&amp;gt;;&lt;BR /&gt;+ iommu-map = &amp;lt;0x0 &amp;amp;smmu 0x15 0x1000&amp;gt;;&lt;/P&gt;&lt;P&gt;which then puts all PCI devices in bus 1 under a single IOMMU group:&lt;/P&gt;&lt;P&gt;./3&lt;BR /&gt;./3/devices&lt;BR /&gt;./3/devices/0001:00:00.0&lt;BR /&gt;./3/devices/0001:02:02.0&lt;BR /&gt;./3/devices/0001:05:00.0&lt;BR /&gt;./3/devices/0001:02:01.0&lt;BR /&gt;./3/devices/0001:03:00.0&lt;BR /&gt;./3/devices/5f000000.pcie&lt;BR /&gt;./3/devices/0001:05:00.1&lt;BR /&gt;./3/devices/0001:02:03.0&lt;BR /&gt;./3/devices/0001:01:00.0&lt;BR /&gt;./3/type&lt;BR /&gt;./3/reserved_regions (edited)&lt;/P&gt;&lt;P&gt;However, this check on drivers/vfio/vfio_iommu_type1.c:&lt;/P&gt;&lt;P&gt;/* Determine bus_type in order to allocate a domain */&lt;BR /&gt;ret = iommu_group_for_each_dev(iommu_group, &amp;amp;bus, vfio_bus_type);&lt;BR /&gt;if (ret) {&lt;BR /&gt;goto out_free;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static int vfio_bus_type(struct device *dev, void *data)&lt;BR /&gt;{&lt;BR /&gt;struct bus_type **bus = data;&lt;/P&gt;&lt;P&gt;if (*bus &amp;amp;&amp;amp; *bus != dev-&amp;gt;bus)&lt;BR /&gt;return -EINVAL;&lt;/P&gt;&lt;P&gt;*bus = dev-&amp;gt;bus;&lt;/P&gt;&lt;P&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Fails since for ./3/devices/5f000000.pcie:&lt;/P&gt;&lt;P&gt;qemu-kvm-1218 [000] ..... 73.450622: vfio_bus_type: devname: 0001:00:00.0&lt;/P&gt;&lt;P&gt;And:&lt;/P&gt;&lt;P&gt;For 5f000000.pcie:&lt;/P&gt;&lt;P&gt;subsystem -&amp;gt; ../../../../bus/platform&lt;/P&gt;&lt;P&gt;whereas for the other devices in the IOMMU group&lt;/P&gt;&lt;P&gt;subsystem -&amp;gt; ../../../../../../../bus/pci&lt;/P&gt;&lt;P&gt;By skipping this check:&lt;/P&gt;&lt;P&gt;diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c&lt;BR /&gt;index 852e6c5643e5..4ce00dc42e7f 100644&lt;BR /&gt;--- a/drivers/vfio/vfio_iommu_type1.c&lt;BR /&gt;+++ b/drivers/vfio/vfio_iommu_type1.c&lt;BR /&gt;@@ -1699,8 +1699,12 @@ static int vfio_bus_type(struct device *dev, void *data)&lt;BR /&gt;{&lt;BR /&gt;struct bus_type **bus = data;&lt;/P&gt;&lt;P&gt;- if (*bus &amp;amp;&amp;amp; *bus != dev-&amp;gt;bus)&lt;BR /&gt;- return -EINVAL;&lt;BR /&gt;+ if (*bus &amp;amp;&amp;amp; *bus != dev-&amp;gt;bus) {&lt;BR /&gt;+ if (strncmp(dev_name(dev), "0001:00:00.0", 12) != 0) {&lt;BR /&gt;+ trace_printk("devname: %s\n", dev_name(dev));&lt;BR /&gt;+ return -EINVAL;&lt;BR /&gt;+ }&lt;BR /&gt;+ }&lt;/P&gt;&lt;P&gt;*bus = dev-&amp;gt;bus;&lt;/P&gt;&lt;P&gt;We are able to assign the PCI device to the guest, but:&lt;/P&gt;&lt;P&gt;[ 84.621002] igb 0000:00:03.0 enp0s3: igb: enp0s3 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX/TX&lt;BR /&gt;[ 88.071936] igb 0000:00:03.0: Detected Tx Unit Hang&lt;BR /&gt;[ 88.071936] Tx Queue &amp;lt;0&amp;gt;&lt;BR /&gt;[ 88.071936] TDH &amp;lt;1&amp;gt;&lt;BR /&gt;[ 88.071936] TDT &amp;lt;1&amp;gt;&lt;BR /&gt;[ 88.071936] next_to_use &amp;lt;1&amp;gt;&lt;BR /&gt;[ 88.071936] next_to_clean &amp;lt;0&amp;gt;&lt;BR /&gt;[ 88.071936] buffer_info[next_to_clean]&lt;BR /&gt;[ 88.071936] time_stamp &amp;lt;ffffac2a&amp;gt;&lt;BR /&gt;[ 88.071936] next_to_watch &amp;lt;00000000c2df116c&amp;gt;&lt;BR /&gt;[ 88.071936] jiffies &amp;lt;ffffad38&amp;gt;&lt;BR /&gt;[ 88.071936] desc.status &amp;lt;168000&amp;gt;&lt;BR /&gt;[ 90.070738] igb 0000:00:03.0: Detected Tx Unit Hang&lt;BR /&gt;[ 90.070738] Tx Queue &amp;lt;0&amp;gt;&lt;BR /&gt;[ 90.070738] TDH &amp;lt;1&amp;gt;&lt;BR /&gt;[ 90.070738] TDT &amp;lt;1&amp;gt;&lt;BR /&gt;[ 90.070738] next_to_use &amp;lt;1&amp;gt;&lt;BR /&gt;[ 90.070738] next_to_clean &amp;lt;0&amp;gt;&lt;BR /&gt;[ 90.070738] buffer_info[next_to_clean]&lt;BR /&gt;[ 90.070738] time_stamp &amp;lt;ffffac2a&amp;gt;&lt;BR /&gt;[ 90.070738] next_to_watch &amp;lt;00000000c2df116c&amp;gt;&lt;BR /&gt;[ 90.070738] jiffies &amp;lt;ffffae00&amp;gt;&lt;BR /&gt;[ 90.070738] desc.status &amp;lt;168000&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Any ideas on how to fix this?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;We are using origin/toradex_5.15-2.1.x-imx branch of git://git.toradex.com/linux-toradex.git&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2023 21:12:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/PCI-device-assignment-on-iMX8-QM-board/m-p/1730779#M213294</guid>
      <dc:creator>mtosatti</dc:creator>
      <dc:date>2023-09-27T21:12:30Z</dc:date>
    </item>
  </channel>
</rss>

