diff options
Diffstat (limited to 'arch/s390/pci')
-rw-r--r-- | arch/s390/pci/pci.c | 4 | ||||
-rw-r--r-- | arch/s390/pci/pci_clp.c | 4 | ||||
-rw-r--r-- | arch/s390/pci/pci_debug.c | 4 | ||||
-rw-r--r-- | arch/s390/pci/pci_dma.c | 50 | ||||
-rw-r--r-- | arch/s390/pci/pci_event.c | 4 | ||||
-rw-r--r-- | arch/s390/pci/pci_sysfs.c | 4 |
6 files changed, 46 insertions, 24 deletions
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c index 30de42730b2f..2fa7b14b9c08 100644 --- a/arch/s390/pci/pci.c +++ b/arch/s390/pci/pci.c | |||
@@ -15,8 +15,8 @@ | |||
15 | * Thomas Klein | 15 | * Thomas Klein |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #define COMPONENT "zPCI" | 18 | #define KMSG_COMPONENT "zpci" |
19 | #define pr_fmt(fmt) COMPONENT ": " fmt | 19 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt |
20 | 20 | ||
21 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
diff --git a/arch/s390/pci/pci_clp.c b/arch/s390/pci/pci_clp.c index 96545d7659fd..6e22a247de9b 100644 --- a/arch/s390/pci/pci_clp.c +++ b/arch/s390/pci/pci_clp.c | |||
@@ -5,8 +5,8 @@ | |||
5 | * Jan Glauber <jang@linux.vnet.ibm.com> | 5 | * Jan Glauber <jang@linux.vnet.ibm.com> |
6 | */ | 6 | */ |
7 | 7 | ||
8 | #define COMPONENT "zPCI" | 8 | #define KMSG_COMPONENT "zpci" |
9 | #define pr_fmt(fmt) COMPONENT ": " fmt | 9 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt |
10 | 10 | ||
11 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
12 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
diff --git a/arch/s390/pci/pci_debug.c b/arch/s390/pci/pci_debug.c index c5c66840ac00..eec598c5939f 100644 --- a/arch/s390/pci/pci_debug.c +++ b/arch/s390/pci/pci_debug.c | |||
@@ -5,8 +5,8 @@ | |||
5 | * Jan Glauber <jang@linux.vnet.ibm.com> | 5 | * Jan Glauber <jang@linux.vnet.ibm.com> |
6 | */ | 6 | */ |
7 | 7 | ||
8 | #define COMPONENT "zPCI" | 8 | #define KMSG_COMPONENT "zpci" |
9 | #define pr_fmt(fmt) COMPONENT ": " fmt | 9 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt |
10 | 10 | ||
11 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
12 | #include <linux/seq_file.h> | 12 | #include <linux/seq_file.h> |
diff --git a/arch/s390/pci/pci_dma.c b/arch/s390/pci/pci_dma.c index f91c03119804..4cbb29a4d615 100644 --- a/arch/s390/pci/pci_dma.c +++ b/arch/s390/pci/pci_dma.c | |||
@@ -16,6 +16,13 @@ | |||
16 | 16 | ||
17 | static struct kmem_cache *dma_region_table_cache; | 17 | static struct kmem_cache *dma_region_table_cache; |
18 | static struct kmem_cache *dma_page_table_cache; | 18 | static struct kmem_cache *dma_page_table_cache; |
19 | static int s390_iommu_strict; | ||
20 | |||
21 | static int zpci_refresh_global(struct zpci_dev *zdev) | ||
22 | { | ||
23 | return zpci_refresh_trans((u64) zdev->fh << 32, zdev->start_dma, | ||
24 | zdev->iommu_pages * PAGE_SIZE); | ||
25 | } | ||
19 | 26 | ||
20 | static unsigned long *dma_alloc_cpu_table(void) | 27 | static unsigned long *dma_alloc_cpu_table(void) |
21 | { | 28 | { |
@@ -155,18 +162,15 @@ static int dma_update_trans(struct zpci_dev *zdev, unsigned long pa, | |||
155 | } | 162 | } |
156 | 163 | ||
157 | /* | 164 | /* |
158 | * rpcit is not required to establish new translations when previously | 165 | * With zdev->tlb_refresh == 0, rpcit is not required to establish new |
159 | * invalid translation-table entries are validated, however it is | 166 | * translations when previously invalid translation-table entries are |
160 | * required when altering previously valid entries. | 167 | * validated. With lazy unmap, it also is skipped for previously valid |
168 | * entries, but a global rpcit is then required before any address can | ||
169 | * be re-used, i.e. after each iommu bitmap wrap-around. | ||
161 | */ | 170 | */ |
162 | if (!zdev->tlb_refresh && | 171 | if (!zdev->tlb_refresh && |
163 | ((flags & ZPCI_PTE_VALID_MASK) == ZPCI_PTE_VALID)) | 172 | (!s390_iommu_strict || |
164 | /* | 173 | ((flags & ZPCI_PTE_VALID_MASK) == ZPCI_PTE_VALID))) |
165 | * TODO: also need to check that the old entry is indeed INVALID | ||
166 | * and not only for one page but for the whole range... | ||
167 | * -> now we WARN_ON in that case but with lazy unmap that | ||
168 | * needs to be redone! | ||
169 | */ | ||
170 | goto no_refresh; | 174 | goto no_refresh; |
171 | 175 | ||
172 | rc = zpci_refresh_trans((u64) zdev->fh << 32, start_dma_addr, | 176 | rc = zpci_refresh_trans((u64) zdev->fh << 32, start_dma_addr, |
@@ -220,16 +224,21 @@ static unsigned long __dma_alloc_iommu(struct zpci_dev *zdev, | |||
220 | static unsigned long dma_alloc_iommu(struct zpci_dev *zdev, int size) | 224 | static unsigned long dma_alloc_iommu(struct zpci_dev *zdev, int size) |
221 | { | 225 | { |
222 | unsigned long offset, flags; | 226 | unsigned long offset, flags; |
227 | int wrap = 0; | ||
223 | 228 | ||
224 | spin_lock_irqsave(&zdev->iommu_bitmap_lock, flags); | 229 | spin_lock_irqsave(&zdev->iommu_bitmap_lock, flags); |
225 | offset = __dma_alloc_iommu(zdev, zdev->next_bit, size); | 230 | offset = __dma_alloc_iommu(zdev, zdev->next_bit, size); |
226 | if (offset == -1) | 231 | if (offset == -1) { |
232 | /* wrap-around */ | ||
227 | offset = __dma_alloc_iommu(zdev, 0, size); | 233 | offset = __dma_alloc_iommu(zdev, 0, size); |
234 | wrap = 1; | ||
235 | } | ||
228 | 236 | ||
229 | if (offset != -1) { | 237 | if (offset != -1) { |
230 | zdev->next_bit = offset + size; | 238 | zdev->next_bit = offset + size; |
231 | if (zdev->next_bit >= zdev->iommu_pages) | 239 | if (!zdev->tlb_refresh && !s390_iommu_strict && wrap) |
232 | zdev->next_bit = 0; | 240 | /* global flush after wrap-around with lazy unmap */ |
241 | zpci_refresh_global(zdev); | ||
233 | } | 242 | } |
234 | spin_unlock_irqrestore(&zdev->iommu_bitmap_lock, flags); | 243 | spin_unlock_irqrestore(&zdev->iommu_bitmap_lock, flags); |
235 | return offset; | 244 | return offset; |
@@ -243,7 +252,11 @@ static void dma_free_iommu(struct zpci_dev *zdev, unsigned long offset, int size | |||
243 | if (!zdev->iommu_bitmap) | 252 | if (!zdev->iommu_bitmap) |
244 | goto out; | 253 | goto out; |
245 | bitmap_clear(zdev->iommu_bitmap, offset, size); | 254 | bitmap_clear(zdev->iommu_bitmap, offset, size); |
246 | if (offset >= zdev->next_bit) | 255 | /* |
256 | * Lazy flush for unmap: need to move next_bit to avoid address re-use | ||
257 | * until wrap-around. | ||
258 | */ | ||
259 | if (!s390_iommu_strict && offset >= zdev->next_bit) | ||
247 | zdev->next_bit = offset + size; | 260 | zdev->next_bit = offset + size; |
248 | out: | 261 | out: |
249 | spin_unlock_irqrestore(&zdev->iommu_bitmap_lock, flags); | 262 | spin_unlock_irqrestore(&zdev->iommu_bitmap_lock, flags); |
@@ -504,3 +517,12 @@ struct dma_map_ops s390_dma_ops = { | |||
504 | /* dma_supported is unconditionally true without a callback */ | 517 | /* dma_supported is unconditionally true without a callback */ |
505 | }; | 518 | }; |
506 | EXPORT_SYMBOL_GPL(s390_dma_ops); | 519 | EXPORT_SYMBOL_GPL(s390_dma_ops); |
520 | |||
521 | static int __init s390_iommu_setup(char *str) | ||
522 | { | ||
523 | if (!strncmp(str, "strict", 6)) | ||
524 | s390_iommu_strict = 1; | ||
525 | return 0; | ||
526 | } | ||
527 | |||
528 | __setup("s390_iommu=", s390_iommu_setup); | ||
diff --git a/arch/s390/pci/pci_event.c b/arch/s390/pci/pci_event.c index 6d7f5a3016ca..460fdb21cf61 100644 --- a/arch/s390/pci/pci_event.c +++ b/arch/s390/pci/pci_event.c | |||
@@ -5,8 +5,8 @@ | |||
5 | * Jan Glauber <jang@linux.vnet.ibm.com> | 5 | * Jan Glauber <jang@linux.vnet.ibm.com> |
6 | */ | 6 | */ |
7 | 7 | ||
8 | #define COMPONENT "zPCI" | 8 | #define KMSG_COMPONENT "zpci" |
9 | #define pr_fmt(fmt) COMPONENT ": " fmt | 9 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt |
10 | 10 | ||
11 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
12 | #include <linux/pci.h> | 12 | #include <linux/pci.h> |
diff --git a/arch/s390/pci/pci_sysfs.c b/arch/s390/pci/pci_sysfs.c index 9190214b8702..fa3ce891e597 100644 --- a/arch/s390/pci/pci_sysfs.c +++ b/arch/s390/pci/pci_sysfs.c | |||
@@ -5,8 +5,8 @@ | |||
5 | * Jan Glauber <jang@linux.vnet.ibm.com> | 5 | * Jan Glauber <jang@linux.vnet.ibm.com> |
6 | */ | 6 | */ |
7 | 7 | ||
8 | #define COMPONENT "zPCI" | 8 | #define KMSG_COMPONENT "zpci" |
9 | #define pr_fmt(fmt) COMPONENT ": " fmt | 9 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt |
10 | 10 | ||
11 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
12 | #include <linux/stat.h> | 12 | #include <linux/stat.h> |