]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
iommu/amd: Enable swiotlb in all cases
authorMario Limonciello <mario.limonciello@amd.com>
Mon, 4 Apr 2022 20:47:22 +0000 (15:47 -0500)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 10 Aug 2022 07:24:58 +0000 (09:24 +0200)
commita0468da388126aece4c989eee5a6cd83945cf731
tree8fb0a5c8d9ec3b53dc379fefbdaa14c2d8fa005d
parentdca9073e5836b1be768d2c74e851af2bde47298e
iommu/amd: Enable swiotlb in all cases

BugLink: https://bugs.launchpad.net/bugs/1981864
[ Upstream commit 121660bba631104154b7c15e88f208c48c8c3297 ]

Previously the AMD IOMMU would only enable SWIOTLB in certain
circumstances:
 * IOMMU in passthrough mode
 * SME enabled

This logic however doesn't work when an untrusted device is plugged in
that doesn't do page aligned DMA transactions.  The expectation is
that a bounce buffer is used for those transactions.

This fails like this:

swiotlb buffer is full (sz: 4096 bytes), total 0 (slots), used 0 (slots)

That happens because the bounce buffers have been allocated, followed by
freed during startup but the bounce buffering code expects that all IOMMUs
have left it enabled.

Remove the criteria to set up bounce buffers on AMD systems to ensure
they're always available for supporting untrusted devices.

Fixes: 82612d66d51d ("iommu: Allow the dma-iommu api to use bounce buffers")
Suggested-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20220404204723.9767-2-mario.limonciello@amd.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/iommu/amd/iommu.c