Skip to content

Commit f9a38ea

Browse files
author
Christoph Hellwig
committed
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: Christoph Hellwig <hch@lst.de> Reviewed-by: Juergen Gross <jgross@suse.com>
1 parent 358cd9a commit f9a38ea

3 files changed

Lines changed: 7 additions & 34 deletions

File tree

arch/x86/include/asm/xen/swiotlb-xen.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
#ifndef _ASM_X86_SWIOTLB_XEN_H
33
#define _ASM_X86_SWIOTLB_XEN_H
44

5-
#ifdef CONFIG_SWIOTLB_XEN
6-
extern int pci_xen_swiotlb_init_late(void);
7-
#else
8-
static inline int pci_xen_swiotlb_init_late(void) { return -ENXIO; }
9-
#endif
10-
115
int xen_swiotlb_fixup(void *buf, unsigned long nslabs);
126
int xen_create_contiguous_region(phys_addr_t pstart, unsigned int order,
137
unsigned int address_bits,

arch/x86/kernel/pci-dma.c

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,15 @@ static inline void __init pci_swiotlb_detect(void)
7272
#endif /* CONFIG_SWIOTLB */
7373

7474
#ifdef CONFIG_SWIOTLB_XEN
75+
static bool xen_swiotlb_enabled(void)
76+
{
77+
return xen_initial_domain() || x86_swiotlb_enable ||
78+
(IS_ENABLED(CONFIG_XEN_PCIDEV_FRONTEND) && xen_pv_pci_possible);
79+
}
80+
7581
static void __init pci_xen_swiotlb_init(void)
7682
{
77-
if (!xen_initial_domain() && !x86_swiotlb_enable)
83+
if (!xen_swiotlb_enabled())
7884
return;
7985
x86_swiotlb_enable = true;
8086
x86_swiotlb_flags |= SWIOTLB_ANY;
@@ -83,27 +89,6 @@ static void __init pci_xen_swiotlb_init(void)
8389
if (IS_ENABLED(CONFIG_PCI))
8490
pci_request_acs();
8591
}
86-
87-
int pci_xen_swiotlb_init_late(void)
88-
{
89-
if (dma_ops == &xen_swiotlb_dma_ops)
90-
return 0;
91-
92-
/* we can work with the default swiotlb */
93-
if (!io_tlb_default_mem.nslabs) {
94-
int rc = swiotlb_init_late(swiotlb_size_or_default(),
95-
GFP_KERNEL, xen_swiotlb_fixup);
96-
if (rc < 0)
97-
return rc;
98-
}
99-
100-
/* XXX: this switches the dma ops under live devices! */
101-
dma_ops = &xen_swiotlb_dma_ops;
102-
if (IS_ENABLED(CONFIG_PCI))
103-
pci_request_acs();
104-
return 0;
105-
}
106-
EXPORT_SYMBOL_GPL(pci_xen_swiotlb_init_late);
10792
#else
10893
static inline void __init pci_xen_swiotlb_init(void)
10994
{

drivers/pci/xen-pcifront.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <linux/bitops.h>
2323
#include <linux/time.h>
2424
#include <linux/ktime.h>
25-
#include <linux/swiotlb.h>
2625
#include <xen/platform_pci.h>
2726

2827
#include <asm/xen/swiotlb-xen.h>
@@ -669,11 +668,6 @@ static int pcifront_connect_and_init_dma(struct pcifront_device *pdev)
669668

670669
spin_unlock(&pcifront_dev_lock);
671670

672-
if (!err && !is_swiotlb_active(&pdev->xdev->dev)) {
673-
err = pci_xen_swiotlb_init_late();
674-
if (err)
675-
dev_err(&pdev->xdev->dev, "Could not setup SWIOTLB!\n");
676-
}
677671
return err;
678672
}
679673

0 commit comments

Comments
 (0)