Commit f9a38ea5 authored by Christoph Hellwig's avatar Christoph Hellwig

x86: always initialize xen-swiotlb when xen-pcifront is enabling

Remove the dangerous late initialization of xen-swiotlb in
pci_xen_swiotlb_init_late and instead just always initialize
xen-swiotlb in the boot code if CONFIG_XEN_PCIDEV_FRONTEND is
enabled and Xen PV PCI is possible.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
parent 358cd9af
...@@ -2,12 +2,6 @@ ...@@ -2,12 +2,6 @@
#ifndef _ASM_X86_SWIOTLB_XEN_H #ifndef _ASM_X86_SWIOTLB_XEN_H
#define _ASM_X86_SWIOTLB_XEN_H #define _ASM_X86_SWIOTLB_XEN_H
#ifdef CONFIG_SWIOTLB_XEN
extern int pci_xen_swiotlb_init_late(void);
#else
static inline int pci_xen_swiotlb_init_late(void) { return -ENXIO; }
#endif
int xen_swiotlb_fixup(void *buf, unsigned long nslabs); int xen_swiotlb_fixup(void *buf, unsigned long nslabs);
int xen_create_contiguous_region(phys_addr_t pstart, unsigned int order, int xen_create_contiguous_region(phys_addr_t pstart, unsigned int order,
unsigned int address_bits, unsigned int address_bits,
......
...@@ -72,9 +72,15 @@ static inline void __init pci_swiotlb_detect(void) ...@@ -72,9 +72,15 @@ static inline void __init pci_swiotlb_detect(void)
#endif /* CONFIG_SWIOTLB */ #endif /* CONFIG_SWIOTLB */
#ifdef CONFIG_SWIOTLB_XEN #ifdef CONFIG_SWIOTLB_XEN
static bool xen_swiotlb_enabled(void)
{
return xen_initial_domain() || x86_swiotlb_enable ||
(IS_ENABLED(CONFIG_XEN_PCIDEV_FRONTEND) && xen_pv_pci_possible);
}
static void __init pci_xen_swiotlb_init(void) static void __init pci_xen_swiotlb_init(void)
{ {
if (!xen_initial_domain() && !x86_swiotlb_enable) if (!xen_swiotlb_enabled())
return; return;
x86_swiotlb_enable = true; x86_swiotlb_enable = true;
x86_swiotlb_flags |= SWIOTLB_ANY; x86_swiotlb_flags |= SWIOTLB_ANY;
...@@ -83,27 +89,6 @@ static void __init pci_xen_swiotlb_init(void) ...@@ -83,27 +89,6 @@ static void __init pci_xen_swiotlb_init(void)
if (IS_ENABLED(CONFIG_PCI)) if (IS_ENABLED(CONFIG_PCI))
pci_request_acs(); pci_request_acs();
} }
int pci_xen_swiotlb_init_late(void)
{
if (dma_ops == &xen_swiotlb_dma_ops)
return 0;
/* we can work with the default swiotlb */
if (!io_tlb_default_mem.nslabs) {
int rc = swiotlb_init_late(swiotlb_size_or_default(),
GFP_KERNEL, xen_swiotlb_fixup);
if (rc < 0)
return rc;
}
/* XXX: this switches the dma ops under live devices! */
dma_ops = &xen_swiotlb_dma_ops;
if (IS_ENABLED(CONFIG_PCI))
pci_request_acs();
return 0;
}
EXPORT_SYMBOL_GPL(pci_xen_swiotlb_init_late);
#else #else
static inline void __init pci_xen_swiotlb_init(void) static inline void __init pci_xen_swiotlb_init(void)
{ {
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/time.h> #include <linux/time.h>
#include <linux/ktime.h> #include <linux/ktime.h>
#include <linux/swiotlb.h>
#include <xen/platform_pci.h> #include <xen/platform_pci.h>
#include <asm/xen/swiotlb-xen.h> #include <asm/xen/swiotlb-xen.h>
...@@ -669,11 +668,6 @@ static int pcifront_connect_and_init_dma(struct pcifront_device *pdev) ...@@ -669,11 +668,6 @@ static int pcifront_connect_and_init_dma(struct pcifront_device *pdev)
spin_unlock(&pcifront_dev_lock); spin_unlock(&pcifront_dev_lock);
if (!err && !is_swiotlb_active(&pdev->xdev->dev)) {
err = pci_xen_swiotlb_init_late();
if (err)
dev_err(&pdev->xdev->dev, "Could not setup SWIOTLB!\n");
}
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment