|
18 | 18 | static struct kmem_cache *dma_region_table_cache;
|
19 | 19 | static struct kmem_cache *dma_page_table_cache;
|
20 | 20 | static int s390_iommu_strict;
|
| 21 | +static u64 s390_iommu_aperture; |
| 22 | +static u32 s390_iommu_aperture_factor = 1; |
21 | 23 |
|
22 | 24 | static int zpci_refresh_global(struct zpci_dev *zdev)
|
23 | 25 | {
|
@@ -565,15 +567,19 @@ int zpci_dma_init_device(struct zpci_dev *zdev)
|
565 | 567 |
|
566 | 568 | /*
|
567 | 569 | * Restrict the iommu bitmap size to the minimum of the following:
|
568 |
| - * - main memory size |
| 570 | + * - s390_iommu_aperture which defaults to high_memory |
569 | 571 | * - 3-level pagetable address limit minus start_dma offset
|
570 | 572 | * - DMA address range allowed by the hardware (clp query pci fn)
|
571 | 573 | *
|
572 | 574 | * Also set zdev->end_dma to the actual end address of the usable
|
573 | 575 | * range, instead of the theoretical maximum as reported by hardware.
|
| 576 | + * |
| 577 | + * This limits the number of concurrently usable DMA mappings since |
| 578 | + * for each DMA mapped memory address we need a DMA address including |
| 579 | + * extra DMA addresses for multiple mappings of the same memory address. |
574 | 580 | */
|
575 | 581 | zdev->start_dma = PAGE_ALIGN(zdev->start_dma);
|
576 |
| - zdev->iommu_size = min3((u64) high_memory, |
| 582 | + zdev->iommu_size = min3(s390_iommu_aperture, |
577 | 583 | ZPCI_TABLE_SIZE_RT - zdev->start_dma,
|
578 | 584 | zdev->end_dma - zdev->start_dma + 1);
|
579 | 585 | zdev->end_dma = zdev->start_dma + zdev->iommu_size - 1;
|
@@ -660,6 +666,12 @@ static int __init dma_alloc_cpu_table_caches(void)
|
660 | 666 |
|
661 | 667 | int __init zpci_dma_init(void)
|
662 | 668 | {
|
| 669 | + s390_iommu_aperture = (u64)high_memory; |
| 670 | + if (!s390_iommu_aperture_factor) |
| 671 | + s390_iommu_aperture = ULONG_MAX; |
| 672 | + else |
| 673 | + s390_iommu_aperture *= s390_iommu_aperture_factor; |
| 674 | + |
663 | 675 | return dma_alloc_cpu_table_caches();
|
664 | 676 | }
|
665 | 677 |
|
@@ -692,3 +704,12 @@ static int __init s390_iommu_setup(char *str)
|
692 | 704 | }
|
693 | 705 |
|
694 | 706 | __setup("s390_iommu=", s390_iommu_setup);
|
| 707 | + |
| 708 | +static int __init s390_iommu_aperture_setup(char *str) |
| 709 | +{ |
| 710 | + if (kstrtou32(str, 10, &s390_iommu_aperture_factor)) |
| 711 | + s390_iommu_aperture_factor = 1; |
| 712 | + return 1; |
| 713 | +} |
| 714 | + |
| 715 | +__setup("s390_iommu_aperture=", s390_iommu_aperture_setup); |
0 commit comments