summaryrefslogtreecommitdiff
path: root/arch/x86/kernel/pci-dma.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2022-03-29 18:27:33 +0300
committerChristoph Hellwig <hch@lst.de>2022-04-18 08:21:11 +0300
commitc6af2aa9ffc9763826607bc2664ef3ea4475ed18 (patch)
treea317bf9fea869ed4555759c155f0a95dc9a2cd95 /arch/x86/kernel/pci-dma.c
parenta3e230926708125205ffd06d3dc2175a8263ae7e (diff)
downloadlinux-c6af2aa9ffc9763826607bc2664ef3ea4475ed18.tar.xz
swiotlb: make the swiotlb_init interface more useful
Pass a boolean flag to indicate if swiotlb needs to be enabled based on the addressing needs, and replace the verbose argument with a set of flags, including one to force enable bounce buffering. Note that this patch removes the possibility to force xen-swiotlb use with the swiotlb=force parameter on the command line on x86 (arm and arm64 never supported that), but this interface will be restored shortly. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Tested-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Diffstat (limited to 'arch/x86/kernel/pci-dma.c')
-rw-r--r--arch/x86/kernel/pci-dma.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 04140e20ef1a..a705a199bf8a 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -39,6 +39,7 @@ int iommu_detected __read_mostly = 0;
#ifdef CONFIG_SWIOTLB
bool x86_swiotlb_enable;
+static unsigned int x86_swiotlb_flags;
static void __init pci_swiotlb_detect(void)
{
@@ -58,16 +59,16 @@ static void __init pci_swiotlb_detect(void)
* bounce buffers as the hypervisor can't access arbitrary VM memory
* that is not explicitly shared with it.
*/
- if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
- swiotlb_force = SWIOTLB_FORCE;
-
- if (swiotlb_force == SWIOTLB_FORCE)
+ if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT)) {
x86_swiotlb_enable = true;
+ x86_swiotlb_flags |= SWIOTLB_FORCE;
+ }
}
#else
static inline void __init pci_swiotlb_detect(void)
{
}
+#define x86_swiotlb_flags 0
#endif /* CONFIG_SWIOTLB */
#ifdef CONFIG_SWIOTLB_XEN
@@ -75,8 +76,7 @@ static bool xen_swiotlb;
static void __init pci_xen_swiotlb_init(void)
{
- if (!xen_initial_domain() && !x86_swiotlb_enable &&
- swiotlb_force != SWIOTLB_FORCE)
+ if (!xen_initial_domain() && !x86_swiotlb_enable)
return;
x86_swiotlb_enable = true;
xen_swiotlb = true;
@@ -120,8 +120,7 @@ void __init pci_iommu_alloc(void)
gart_iommu_hole_init();
amd_iommu_detect();
detect_intel_iommu();
- if (x86_swiotlb_enable)
- swiotlb_init(0);
+ swiotlb_init(x86_swiotlb_enable, x86_swiotlb_flags);
}
/*