summaryrefslogtreecommitdiffstats
path: root/lib/swiotlb.c
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert+renesas@glider.be>2016-12-16 08:28:42 -0500
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2016-12-19 09:05:20 -0500
commitfff5d99225107f5f13fe4a9805adc2a1c4b5fb00 (patch)
tree0b9748236ea4580bc44f9a24ec27c215cb46ed9b /lib/swiotlb.c
parentae7871be189cb41184f1e05742b4a99e2c59774d (diff)
swiotlb: Add swiotlb=noforce debug option
On architectures like arm64, swiotlb is tied intimately to the core architecture DMA support. In addition, ZONE_DMA cannot be disabled. To aid debugging and catch devices not supporting DMA to memory outside the 32-bit address space, add a kernel command line option "swiotlb=noforce", which disables the use of bounce buffers. If specified, trying to map memory that cannot be used with DMA will fail, and a rate-limited warning will be printed. Note that io_tlb_nslabs is set to 1, which is the minimal supported value. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'lib/swiotlb.c')
-rw-r--r--lib/swiotlb.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index a32dce6d5101..9def738af4f4 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -106,8 +106,12 @@ setup_io_tlb_npages(char *str)
106 } 106 }
107 if (*str == ',') 107 if (*str == ',')
108 ++str; 108 ++str;
109 if (!strcmp(str, "force")) 109 if (!strcmp(str, "force")) {
110 swiotlb_force = SWIOTLB_FORCE; 110 swiotlb_force = SWIOTLB_FORCE;
111 } else if (!strcmp(str, "noforce")) {
112 swiotlb_force = SWIOTLB_NO_FORCE;
113 io_tlb_nslabs = 1;
114 }
111 115
112 return 0; 116 return 0;
113} 117}
@@ -543,8 +547,15 @@ static phys_addr_t
543map_single(struct device *hwdev, phys_addr_t phys, size_t size, 547map_single(struct device *hwdev, phys_addr_t phys, size_t size,
544 enum dma_data_direction dir, unsigned long attrs) 548 enum dma_data_direction dir, unsigned long attrs)
545{ 549{
546 dma_addr_t start_dma_addr = phys_to_dma(hwdev, io_tlb_start); 550 dma_addr_t start_dma_addr;
551
552 if (swiotlb_force == SWIOTLB_NO_FORCE) {
553 dev_warn_ratelimited(hwdev, "Cannot do DMA to address %pa\n",
554 &phys);
555 return SWIOTLB_MAP_ERROR;
556 }
547 557
558 start_dma_addr = phys_to_dma(hwdev, io_tlb_start);
548 return swiotlb_tbl_map_single(hwdev, start_dma_addr, phys, size, 559 return swiotlb_tbl_map_single(hwdev, start_dma_addr, phys, size,
549 dir, attrs); 560 dir, attrs);
550} 561}
@@ -721,6 +732,9 @@ static void
721swiotlb_full(struct device *dev, size_t size, enum dma_data_direction dir, 732swiotlb_full(struct device *dev, size_t size, enum dma_data_direction dir,
722 int do_panic) 733 int do_panic)
723{ 734{
735 if (swiotlb_force == SWIOTLB_NO_FORCE)
736 return;
737
724 /* 738 /*
725 * Ran out of IOMMU space for this operation. This is very bad. 739 * Ran out of IOMMU space for this operation. This is very bad.
726 * Unfortunately the drivers cannot handle this operation properly. 740 * Unfortunately the drivers cannot handle this operation properly.