[PATCH kernel 4/9] dma/swiotlb: Stop forcing SWIOTLB for TDISP devices

Alexey Kardashevskiy
2026-02-25T05:41:14Z

SWIOTLB is enforced when encrypted guest memory is detected
in pci_swiotlb_detect() which is required for legacy devices.

Skip SWIOTLB for TDISP devices.

Signed-off-by: Alexey Kardashevskiy <aik@amd.com>
---
include/linux/swiotlb.h | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index 3dae0f592063..119c25d639a7 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -173,6 +173,15 @@ static inline bool is_swiotlb_force_bounce(struct device *dev)
{
struct io_tlb_mem *mem = dev->dma_io_tlb_mem;

+ /*
+ * CC_ATTR_GUEST_MEM_ENCRYPT enforces SWIOTLB_FORCE in
+ * swiotlb_init_remap() to allow legacy devices access arbitrary
+ * VM encrypted memory.
+ * Skip it for TDISP devices capable of DMA-ing the encrypted memory.
+ */
+ if (device_cc_accepted(dev))
+ return false;
+
return mem && mem->force_bounce;
}

--
2.52.0