public inbox for iommu@lists.linux-foundation.org
 help / color / mirror / Atom feed
* [PATCH] swiotlb: Add swiotlb=off to disable SWIOTLB
@ 2021-03-18 19:18 Florian Fainelli
  2021-03-18 19:22 ` Florian Fainelli
  2021-03-19  4:00 ` [PATCH] swiotlb: Make SWIOTLB_NO_FORCE perform no allocation Florian Fainelli
  0 siblings, 2 replies; 18+ messages in thread
From: Florian Fainelli @ 2021-03-18 19:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Paul E. McKenney, Konrad Rzeszutek Wilk,
	Mauro Carvalho Chehab, Viresh Kumar, Jonathan Corbet,
	open list:DOCUMENTATION, Peter Zijlstra,
	open list:SWIOTLB SUBSYSTEM, opendmb, Thomas Gleixner,
	Randy Dunlap, Andrew Morton, Mike Kravetz, Robin Murphy,
	Christoph Hellwig

It may be useful to disable the SWIOTLB completely for testing or when a
platform is known not to have any DRAM addressing limitations what so
ever.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 Documentation/admin-guide/kernel-parameters.txt | 1 +
 include/linux/swiotlb.h                         | 1 +
 kernel/dma/swiotlb.c                            | 9 +++++++++
 3 files changed, 11 insertions(+)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 04545725f187..b0223e48921e 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -5278,6 +5278,7 @@
 			force -- force using of bounce buffers even if they
 			         wouldn't be automatically used by the kernel
 			noforce -- Never use bounce buffers (for debugging)
+			off -- Completely disable SWIOTLB
 
 	switches=	[HW,M68k]
 
diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index 5857a937c637..23f86243defe 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -15,6 +15,7 @@ enum swiotlb_force {
 	SWIOTLB_NORMAL,		/* Default - depending on HW DMA mask etc. */
 	SWIOTLB_FORCE,		/* swiotlb=force */
 	SWIOTLB_NO_FORCE,	/* swiotlb=noforce */
+	SWIOTLB_OFF,		/* swiotlb=off */
 };
 
 /*
diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
index c10e855a03bc..d7a4a789c7d3 100644
--- a/kernel/dma/swiotlb.c
+++ b/kernel/dma/swiotlb.c
@@ -126,6 +126,8 @@ setup_io_tlb_npages(char *str)
 	} else if (!strcmp(str, "noforce")) {
 		swiotlb_force = SWIOTLB_NO_FORCE;
 		io_tlb_nslabs = 1;
+	} else if (!strcmp(str, "off")) {
+		swiotlb_force = SWIOTLB_OFF;
 	}
 
 	return 0;
@@ -229,6 +231,9 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)
 	unsigned long i, bytes;
 	size_t alloc_size;
 
+	if (swiotlb_force == SWIOTLB_OFF)
+		return 0;
+
 	bytes = nslabs << IO_TLB_SHIFT;
 
 	io_tlb_nslabs = nslabs;
@@ -284,6 +289,9 @@ swiotlb_init(int verbose)
 	unsigned char *vstart;
 	unsigned long bytes;
 
+	if (swiotlb_force == SWIOTLB_OFF)
+		goto out;
+
 	if (!io_tlb_nslabs) {
 		io_tlb_nslabs = (default_size >> IO_TLB_SHIFT);
 		io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
@@ -302,6 +310,7 @@ swiotlb_init(int verbose)
 		io_tlb_start = 0;
 	}
 	pr_warn("Cannot allocate buffer");
+out:
 	no_iotlb_memory = true;
 }
 
-- 
2.25.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2021-04-09 20:33 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-18 19:18 [PATCH] swiotlb: Add swiotlb=off to disable SWIOTLB Florian Fainelli
2021-03-18 19:22 ` Florian Fainelli
2021-03-18 19:34   ` Robin Murphy
2021-03-18 19:43     ` Florian Fainelli
2021-03-18 19:53       ` Robin Murphy
2021-03-18 21:31         ` Florian Fainelli
2021-03-18 23:35           ` Robin Murphy
2021-03-19  0:48             ` Florian Fainelli
2021-03-19  2:34               ` Konrad Rzeszutek Wilk
2021-03-19  4:00 ` [PATCH] swiotlb: Make SWIOTLB_NO_FORCE perform no allocation Florian Fainelli
2021-03-19  5:01   ` Konrad Rzeszutek Wilk
2021-03-21  3:37   ` [PATCH v2] " Florian Fainelli
2021-03-22  7:46     ` Christoph Hellwig
2021-03-23  1:53     ` [PATCH v3] " Florian Fainelli
2021-03-24  8:42       ` Christoph Hellwig
2021-04-09  3:13         ` Florian Fainelli
2021-04-09 19:32           ` Konrad Rzeszutek Wilk
2021-04-09 20:33             ` Florian Fainelli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox