What IOMMU controller does?
Some PCI devices can only handle 32 bit address through DMA access (it's a legacy matter). So some PCI devices can only use the first 4GB of memory. Even on modern 64 bits systems.
When the addressable range of a device (through DMA) is limited and no IOMMU exists, the device might not be able to reach all of physical memory. In this case a region of system memory that the device can address is reserved (within the first 4GB of memory), and the device is programmed to DMA to this reserved area. The processor then copies the result to the target memory that was beyond the “reach” of the device. That takes a lot of processor resources. This method is known as bounce buffering (also known as SWIOTLB or software IOMMU).
Hardware IOMMUs are physical devices that translate (remaps) device DMA addresses (32 bit) to 64 bit physical addresses so devices could access all of physical memory without processor help.
Some IOMMU provide address translation, some other isolation (checking if an address is allowed) and most modern IOMMU both characteristics.
Fixes for boot and USB problems related to IOMMU in Linux
Different ways to fix USB and boot issues in Linux on AMD Ryzen processors:
If you don't use Virtual Machines its OK, but solution 3 is the one that don't penalize virtualization features.
To apply solution number 3 follow these instructions:
Edit /etc/default/grub
and add amd_iommu=force_enable iommu=pt
at the end of the line GRUB_CMDLINE_LINUX_DEFAULT
my line looks like:
after saving changes you will have to do a update-grub:
Reboot
Enter BIOS and enable:
After rebooting your Ubuntu will boot OK, your rear USBs will work
and your virtual machines will be able to benefit from a working IOMMU with passthru option. Passthru enables virtual machines to directly use hardware component from host (a second GPU, NVME drive, Ethernet, WiFi, USB ...)
Tested on Ubuntu 20.04 Kernel 5.13.0-28 with BIOS 2.20.1275
Related documentation
Official kernel supported options:
Here you have many excellent documents for understanding what IOMMU does and its different modes:
https://lenovopress.com/lp1467.pdf
https://www.amd.com/system/files/TechDocs/48882_IOMMU.pdf
Some PCI devices can only handle 32 bit address through DMA access (it's a legacy matter). So some PCI devices can only use the first 4GB of memory. Even on modern 64 bits systems.
When the addressable range of a device (through DMA) is limited and no IOMMU exists, the device might not be able to reach all of physical memory. In this case a region of system memory that the device can address is reserved (within the first 4GB of memory), and the device is programmed to DMA to this reserved area. The processor then copies the result to the target memory that was beyond the “reach” of the device. That takes a lot of processor resources. This method is known as bounce buffering (also known as SWIOTLB or software IOMMU).
Hardware IOMMUs are physical devices that translate (remaps) device DMA addresses (32 bit) to 64 bit physical addresses so devices could access all of physical memory without processor help.
Some IOMMU provide address translation, some other isolation (checking if an address is allowed) and most modern IOMMU both characteristics.
Fixes for boot and USB problems related to IOMMU in Linux
Different ways to fix USB and boot issues in Linux on AMD Ryzen processors:
- Disable IOMMU in BIOS
- Linux emulates the IOMMU (software IOMMU) if there is more than 4GB of RAM.
- Pros: Easy. No Linux setup needed.
- Cons: Lose of performance when Virtual Machines used.
- Kernel parameter: iommu=soft OR amd_iommu=off
- Is equivalent to the previous option. We are telling the kernel not to use the IOMMU hardware but instead emulate it through software. Is the default mode for Intel processors.
- Pros: You don't need to disable IOMMU in bios. Is one suitable option if you have dual boot and the other O.S. needs the IOMMU enabled.
- Cons: Lose of features when Virtual Machines used
- Kernel parameter: amd_iommu=force_enable iommu=pt
- amd_iommu=on is not supported but amd_iommu=force_enable is. Look like just putting iommu=pt alone works.
Requires further testing!Tested! - Pros: Works. At least for me. Not a software emulation. 100% hardware accelerated. Passthrough enabled
- Cons: iommu=pt is incompatible with Secure Memory Encryption (RAM encryption present on Ryzen Pro processors)
- amd_iommu=on is not supported but amd_iommu=force_enable is. Look like just putting iommu=pt alone works.
- Kernel parameter: amd_iommu=force_enable
- Same as fix #3 but without passthrough
- Kernel parameter: pci=noats
- Not tested. Almost no information. Comments about that solution are welcome.
If you don't use Virtual Machines its OK, but solution 3 is the one that don't penalize virtualization features.
To apply solution number 3 follow these instructions:
Edit /etc/default/grub
and add amd_iommu=force_enable iommu=pt
at the end of the line GRUB_CMDLINE_LINUX_DEFAULT
my line looks like:
Code:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash amd_iommu=force_enable iommu=pt"
Code:
$ sudo update-grub
Enter BIOS and enable:
- IOMMU
- SVM mode (virtualization support) Advanced->CPU configuration->SVM mode
After rebooting your Ubuntu will boot OK, your rear USBs will work
and your virtual machines will be able to benefit from a working IOMMU with passthru option. Passthru enables virtual machines to directly use hardware component from host (a second GPU, NVME drive, Ethernet, WiFi, USB ...)
Tested on Ubuntu 20.04 Kernel 5.13.0-28 with BIOS 2.20.1275
Related documentation
Official kernel supported options:
Here you have many excellent documents for understanding what IOMMU does and its different modes:
https://lenovopress.com/lp1467.pdf
https://www.amd.com/system/files/TechDocs/48882_IOMMU.pdf
Last edited: