diff options
author | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2010-08-26 13:57:59 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2010-08-26 18:13:29 -0400 |
commit | efa631c26d3bb1162b8f95008801db602217f52b (patch) | |
tree | bc2b88fa3a08be9c96b663f37ed425a7b3be15f5 /arch/x86/kernel/pci-swiotlb.c | |
parent | 5bef80a4b826b9cee1c6aec7ecc371ec395260cc (diff) |
x86, swiotlb: Simplify SWIOTLB pci_swiotlb_detect routine.
In 'pci_swiotlb_detect' we used to do two different things:
a). If user provided 'iommu=soft' or 'swiotlb=force' we
would set swiotlb=1 and return 1 (and forcing pci-dma.c
to call pci_swiotlb_init() immediately).
b). If 4GB or more would be detected and if user did not specify
iommu=off, we would set 'swiotlb=1' and return whatever 'a)'
figured out.
We simplify this by splitting a) and b) in two different routines.
CC: Fujita Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
LKML-Reference: <1282845485-8991-5-git-send-email-konrad.wilk@oracle.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'arch/x86/kernel/pci-swiotlb.c')
-rw-r--r-- | arch/x86/kernel/pci-swiotlb.c | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c index a5bc528d4328..c7a72faeb146 100644 --- a/arch/x86/kernel/pci-swiotlb.c +++ b/arch/x86/kernel/pci-swiotlb.c | |||
@@ -41,24 +41,33 @@ static struct dma_map_ops swiotlb_dma_ops = { | |||
41 | }; | 41 | }; |
42 | 42 | ||
43 | /* | 43 | /* |
44 | * pci_swiotlb_detect - set swiotlb to 1 if necessary | 44 | * pci_swiotlb_detect_override - set swiotlb to 1 if necessary |
45 | * | 45 | * |
46 | * This returns non-zero if we are forced to use swiotlb (by the boot | 46 | * This returns non-zero if we are forced to use swiotlb (by the boot |
47 | * option). | 47 | * option). |
48 | */ | 48 | */ |
49 | int __init pci_swiotlb_detect(void) | 49 | int __init pci_swiotlb_detect_override(void) |
50 | { | 50 | { |
51 | int use_swiotlb = swiotlb | swiotlb_force; | 51 | int use_swiotlb = swiotlb | swiotlb_force; |
52 | 52 | ||
53 | if (swiotlb_force) | ||
54 | swiotlb = 1; | ||
55 | |||
56 | return use_swiotlb; | ||
57 | } | ||
58 | |||
59 | /* | ||
60 | * if 4GB or more detected (and iommu=off not set) return 1 | ||
61 | * and set swiotlb to 1. | ||
62 | */ | ||
63 | int __init pci_swiotlb_detect_4gb(void) | ||
64 | { | ||
53 | /* don't initialize swiotlb if iommu=off (no_iommu=1) */ | 65 | /* don't initialize swiotlb if iommu=off (no_iommu=1) */ |
54 | #ifdef CONFIG_X86_64 | 66 | #ifdef CONFIG_X86_64 |
55 | if (!no_iommu && max_pfn > MAX_DMA32_PFN) | 67 | if (!no_iommu && max_pfn > MAX_DMA32_PFN) |
56 | swiotlb = 1; | 68 | swiotlb = 1; |
57 | #endif | 69 | #endif |
58 | if (swiotlb_force) | 70 | return swiotlb; |
59 | swiotlb = 1; | ||
60 | |||
61 | return use_swiotlb; | ||
62 | } | 71 | } |
63 | 72 | ||
64 | void __init pci_swiotlb_init(void) | 73 | void __init pci_swiotlb_init(void) |
@@ -68,3 +77,15 @@ void __init pci_swiotlb_init(void) | |||
68 | dma_ops = &swiotlb_dma_ops; | 77 | dma_ops = &swiotlb_dma_ops; |
69 | } | 78 | } |
70 | } | 79 | } |
80 | |||
81 | void __init pci_swiotlb_late_init(void) | ||
82 | { | ||
83 | /* An IOMMU turned us off. */ | ||
84 | if (!swiotlb) | ||
85 | swiotlb_free(); | ||
86 | else { | ||
87 | printk(KERN_INFO "PCI-DMA: " | ||
88 | "Using software bounce buffering for IO (SWIOTLB)\n"); | ||
89 | swiotlb_print_info(); | ||
90 | } | ||
91 | } | ||