diff options
author | Geert Uytterhoeven <geert+renesas@glider.be> | 2016-12-16 08:28:41 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-01-26 02:24:44 -0500 |
commit | 1fd1e6cd63143cf5d198a536d875dfc88ce179bc (patch) | |
tree | 7a90a6aa9b9593f183827fe2cd67206b1395acdd | |
parent | 776c2b2d165dc64397f3f9b39839920a08578e8f (diff) |
swiotlb: Convert swiotlb_force from int to enum
commit ae7871be189cb41184f1e05742b4a99e2c59774d upstream.
Convert the flag swiotlb_force from an int to an enum, to prepare for
the advent of more possible values.
Suggested-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | arch/arm64/mm/dma-mapping.c | 3 | ||||
-rw-r--r-- | arch/arm64/mm/init.c | 3 | ||||
-rw-r--r-- | arch/x86/kernel/pci-swiotlb.c | 2 | ||||
-rw-r--r-- | arch/x86/xen/pci-swiotlb-xen.c | 2 | ||||
-rw-r--r-- | drivers/xen/swiotlb-xen.c | 4 | ||||
-rw-r--r-- | include/linux/swiotlb.h | 7 | ||||
-rw-r--r-- | include/trace/events/swiotlb.h | 16 | ||||
-rw-r--r-- | lib/swiotlb.c | 8 |
8 files changed, 27 insertions, 18 deletions
diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c index 3f74d0d98de6..02265a589ef5 100644 --- a/arch/arm64/mm/dma-mapping.c +++ b/arch/arm64/mm/dma-mapping.c | |||
@@ -524,7 +524,8 @@ EXPORT_SYMBOL(dummy_dma_ops); | |||
524 | 524 | ||
525 | static int __init arm64_dma_init(void) | 525 | static int __init arm64_dma_init(void) |
526 | { | 526 | { |
527 | if (swiotlb_force || max_pfn > (arm64_dma_phys_limit >> PAGE_SHIFT)) | 527 | if (swiotlb_force == SWIOTLB_FORCE || |
528 | max_pfn > (arm64_dma_phys_limit >> PAGE_SHIFT)) | ||
528 | swiotlb = 1; | 529 | swiotlb = 1; |
529 | 530 | ||
530 | return atomic_pool_init(); | 531 | return atomic_pool_init(); |
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 59bd3d47647b..380ebe705093 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c | |||
@@ -401,7 +401,8 @@ static void __init free_unused_memmap(void) | |||
401 | */ | 401 | */ |
402 | void __init mem_init(void) | 402 | void __init mem_init(void) |
403 | { | 403 | { |
404 | if (swiotlb_force || max_pfn > (arm64_dma_phys_limit >> PAGE_SHIFT)) | 404 | if (swiotlb_force == SWIOTLB_FORCE || |
405 | max_pfn > (arm64_dma_phys_limit >> PAGE_SHIFT)) | ||
405 | swiotlb_init(1); | 406 | swiotlb_init(1); |
406 | else | 407 | else |
407 | swiotlb_force = SWIOTLB_NO_FORCE; | 408 | swiotlb_force = SWIOTLB_NO_FORCE; |
diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c index b47edb8f5256..8da13d4e77cc 100644 --- a/arch/x86/kernel/pci-swiotlb.c +++ b/arch/x86/kernel/pci-swiotlb.c | |||
@@ -70,7 +70,7 @@ int __init pci_swiotlb_detect_override(void) | |||
70 | { | 70 | { |
71 | int use_swiotlb = swiotlb | swiotlb_force; | 71 | int use_swiotlb = swiotlb | swiotlb_force; |
72 | 72 | ||
73 | if (swiotlb_force) | 73 | if (swiotlb_force == SWIOTLB_FORCE) |
74 | swiotlb = 1; | 74 | swiotlb = 1; |
75 | 75 | ||
76 | return use_swiotlb; | 76 | return use_swiotlb; |
diff --git a/arch/x86/xen/pci-swiotlb-xen.c b/arch/x86/xen/pci-swiotlb-xen.c index 0e98e5d241d0..5f8b4b0302b6 100644 --- a/arch/x86/xen/pci-swiotlb-xen.c +++ b/arch/x86/xen/pci-swiotlb-xen.c | |||
@@ -49,7 +49,7 @@ int __init pci_xen_swiotlb_detect(void) | |||
49 | * activate this IOMMU. If running as PV privileged, activate it | 49 | * activate this IOMMU. If running as PV privileged, activate it |
50 | * irregardless. | 50 | * irregardless. |
51 | */ | 51 | */ |
52 | if ((xen_initial_domain() || swiotlb || swiotlb_force)) | 52 | if (xen_initial_domain() || swiotlb || swiotlb_force == SWIOTLB_FORCE) |
53 | xen_swiotlb = 1; | 53 | xen_swiotlb = 1; |
54 | 54 | ||
55 | /* If we are running under Xen, we MUST disable the native SWIOTLB. | 55 | /* If we are running under Xen, we MUST disable the native SWIOTLB. |
diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c index 87e6035c9e81..8e7a3d646531 100644 --- a/drivers/xen/swiotlb-xen.c +++ b/drivers/xen/swiotlb-xen.c | |||
@@ -392,7 +392,7 @@ dma_addr_t xen_swiotlb_map_page(struct device *dev, struct page *page, | |||
392 | if (dma_capable(dev, dev_addr, size) && | 392 | if (dma_capable(dev, dev_addr, size) && |
393 | !range_straddles_page_boundary(phys, size) && | 393 | !range_straddles_page_boundary(phys, size) && |
394 | !xen_arch_need_swiotlb(dev, phys, dev_addr) && | 394 | !xen_arch_need_swiotlb(dev, phys, dev_addr) && |
395 | !swiotlb_force) { | 395 | (swiotlb_force != SWIOTLB_FORCE)) { |
396 | /* we are not interested in the dma_addr returned by | 396 | /* we are not interested in the dma_addr returned by |
397 | * xen_dma_map_page, only in the potential cache flushes executed | 397 | * xen_dma_map_page, only in the potential cache flushes executed |
398 | * by the function. */ | 398 | * by the function. */ |
@@ -549,7 +549,7 @@ xen_swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl, | |||
549 | phys_addr_t paddr = sg_phys(sg); | 549 | phys_addr_t paddr = sg_phys(sg); |
550 | dma_addr_t dev_addr = xen_phys_to_bus(paddr); | 550 | dma_addr_t dev_addr = xen_phys_to_bus(paddr); |
551 | 551 | ||
552 | if (swiotlb_force || | 552 | if (swiotlb_force == SWIOTLB_FORCE || |
553 | xen_arch_need_swiotlb(hwdev, paddr, dev_addr) || | 553 | xen_arch_need_swiotlb(hwdev, paddr, dev_addr) || |
554 | !dma_capable(hwdev, dev_addr, sg->length) || | 554 | !dma_capable(hwdev, dev_addr, sg->length) || |
555 | range_straddles_page_boundary(paddr, sg->length)) { | 555 | range_straddles_page_boundary(paddr, sg->length)) { |
diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h index 5f81f8a187f2..746ecebbd4ca 100644 --- a/include/linux/swiotlb.h +++ b/include/linux/swiotlb.h | |||
@@ -9,7 +9,12 @@ struct device; | |||
9 | struct page; | 9 | struct page; |
10 | struct scatterlist; | 10 | struct scatterlist; |
11 | 11 | ||
12 | extern int swiotlb_force; | 12 | enum swiotlb_force { |
13 | SWIOTLB_NORMAL, /* Default - depending on HW DMA mask etc. */ | ||
14 | SWIOTLB_FORCE, /* swiotlb=force */ | ||
15 | }; | ||
16 | |||
17 | extern enum swiotlb_force swiotlb_force; | ||
13 | 18 | ||
14 | /* | 19 | /* |
15 | * Maximum allowable number of contiguous slabs to map, | 20 | * Maximum allowable number of contiguous slabs to map, |
diff --git a/include/trace/events/swiotlb.h b/include/trace/events/swiotlb.h index 7ea4c5e7c448..5e2e30a7efce 100644 --- a/include/trace/events/swiotlb.h +++ b/include/trace/events/swiotlb.h | |||
@@ -11,16 +11,16 @@ TRACE_EVENT(swiotlb_bounced, | |||
11 | TP_PROTO(struct device *dev, | 11 | TP_PROTO(struct device *dev, |
12 | dma_addr_t dev_addr, | 12 | dma_addr_t dev_addr, |
13 | size_t size, | 13 | size_t size, |
14 | int swiotlb_force), | 14 | enum swiotlb_force swiotlb_force), |
15 | 15 | ||
16 | TP_ARGS(dev, dev_addr, size, swiotlb_force), | 16 | TP_ARGS(dev, dev_addr, size, swiotlb_force), |
17 | 17 | ||
18 | TP_STRUCT__entry( | 18 | TP_STRUCT__entry( |
19 | __string( dev_name, dev_name(dev) ) | 19 | __string( dev_name, dev_name(dev) ) |
20 | __field( u64, dma_mask ) | 20 | __field( u64, dma_mask ) |
21 | __field( dma_addr_t, dev_addr ) | 21 | __field( dma_addr_t, dev_addr ) |
22 | __field( size_t, size ) | 22 | __field( size_t, size ) |
23 | __field( int, swiotlb_force ) | 23 | __field( enum swiotlb_force, swiotlb_force ) |
24 | ), | 24 | ), |
25 | 25 | ||
26 | TP_fast_assign( | 26 | TP_fast_assign( |
@@ -37,7 +37,9 @@ TRACE_EVENT(swiotlb_bounced, | |||
37 | __entry->dma_mask, | 37 | __entry->dma_mask, |
38 | (unsigned long long)__entry->dev_addr, | 38 | (unsigned long long)__entry->dev_addr, |
39 | __entry->size, | 39 | __entry->size, |
40 | __entry->swiotlb_force ? "swiotlb_force" : "" ) | 40 | __print_symbolic(__entry->swiotlb_force, |
41 | { SWIOTLB_NORMAL, "NORMAL" }, | ||
42 | { SWIOTLB_FORCE, "FORCE" })) | ||
41 | ); | 43 | ); |
42 | 44 | ||
43 | #endif /* _TRACE_SWIOTLB_H */ | 45 | #endif /* _TRACE_SWIOTLB_H */ |
diff --git a/lib/swiotlb.c b/lib/swiotlb.c index 22e13a0e19d7..68e8f49c7e06 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c | |||
@@ -53,7 +53,7 @@ | |||
53 | */ | 53 | */ |
54 | #define IO_TLB_MIN_SLABS ((1<<20) >> IO_TLB_SHIFT) | 54 | #define IO_TLB_MIN_SLABS ((1<<20) >> IO_TLB_SHIFT) |
55 | 55 | ||
56 | int swiotlb_force; | 56 | enum swiotlb_force swiotlb_force; |
57 | 57 | ||
58 | /* | 58 | /* |
59 | * Used to do a quick range check in swiotlb_tbl_unmap_single and | 59 | * Used to do a quick range check in swiotlb_tbl_unmap_single and |
@@ -107,7 +107,7 @@ setup_io_tlb_npages(char *str) | |||
107 | if (*str == ',') | 107 | if (*str == ',') |
108 | ++str; | 108 | ++str; |
109 | if (!strcmp(str, "force")) | 109 | if (!strcmp(str, "force")) |
110 | swiotlb_force = 1; | 110 | swiotlb_force = SWIOTLB_FORCE; |
111 | 111 | ||
112 | return 0; | 112 | return 0; |
113 | } | 113 | } |
@@ -749,7 +749,7 @@ dma_addr_t swiotlb_map_page(struct device *dev, struct page *page, | |||
749 | * we can safely return the device addr and not worry about bounce | 749 | * we can safely return the device addr and not worry about bounce |
750 | * buffering it. | 750 | * buffering it. |
751 | */ | 751 | */ |
752 | if (dma_capable(dev, dev_addr, size) && !swiotlb_force) | 752 | if (dma_capable(dev, dev_addr, size) && swiotlb_force != SWIOTLB_FORCE) |
753 | return dev_addr; | 753 | return dev_addr; |
754 | 754 | ||
755 | trace_swiotlb_bounced(dev, dev_addr, size, swiotlb_force); | 755 | trace_swiotlb_bounced(dev, dev_addr, size, swiotlb_force); |
@@ -888,7 +888,7 @@ swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl, int nelems, | |||
888 | phys_addr_t paddr = sg_phys(sg); | 888 | phys_addr_t paddr = sg_phys(sg); |
889 | dma_addr_t dev_addr = phys_to_dma(hwdev, paddr); | 889 | dma_addr_t dev_addr = phys_to_dma(hwdev, paddr); |
890 | 890 | ||
891 | if (swiotlb_force || | 891 | if (swiotlb_force == SWIOTLB_FORCE || |
892 | !dma_capable(hwdev, dev_addr, sg->length)) { | 892 | !dma_capable(hwdev, dev_addr, sg->length)) { |
893 | phys_addr_t map = map_single(hwdev, sg_phys(sg), | 893 | phys_addr_t map = map_single(hwdev, sg_phys(sg), |
894 | sg->length, dir); | 894 | sg->length, dir); |