All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] swiotlb: Add swiotlb=noforce debug option
@ 2016-12-16 13:28 Geert Uytterhoeven
  2016-12-16 13:28 ` [PATCH v2 1/3] x86, swiotlb: Simplify pci_swiotlb_detect_override() Geert Uytterhoeven
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Geert Uytterhoeven @ 2016-12-16 13:28 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk
  Cc: Jonathan Corbet, Catalin Marinas, Will Deacon, Thomas Gleixner,
	Ingo Molnar, H. Peter Anvin, Boris Ostrovsky, David Vrabel,
	Juergen Gross, Steven Rostedt, linux-kernel, linux-renesas-soc,
	Geert Uytterhoeven

	Hi Konrad,

This patch series adds a kernel command line option to aid debugging
when developing support for DMA to memory outside the 32-bit address
space.  If specified, trying to map memory that cannot be used with DMA
will fail, and a warning will be printed.  This has been used
succesfully to find drivers and DMA engines that do not support 64-bit
memory.

Changes compared to v1:
  - Dropp patch "swiotlb: Rate-limit printing when running out of
    SW-IOMMU space", which has been picked up,
  - Add cleanup patch 1/3,
  - Add patch 2/3, to convert the flag swiotlb_force from an int to an
    enum,
  - Change the kernel parameter "swiotlb=nobounce" to "swiotlb=noforce"
    (requested by Konrad Wilk),
  - Extend swiotlb_force enum instead of adding an swiotlb_nobounce
    variable (requested by Konrad Wilk).

This has been tested on ra7796/salvator-x, and compile-tested on x86.

Thanks!

Geert Uytterhoeven (3):
  x86, swiotlb: Simplify pci_swiotlb_detect_override()
  swiotlb: Convert swiotlb_force from int to enum
  swiotlb: Add swiotlb=noforce debug option

 Documentation/admin-guide/kernel-parameters.txt |  3 ++-
 arch/arm64/mm/dma-mapping.c                     |  3 ++-
 arch/arm64/mm/init.c                            |  3 ++-
 arch/x86/kernel/pci-swiotlb.c                   |  6 ++----
 arch/x86/xen/pci-swiotlb-xen.c                  |  2 +-
 drivers/xen/swiotlb-xen.c                       |  4 ++--
 include/linux/swiotlb.h                         |  8 +++++++-
 include/trace/events/swiotlb.h                  | 17 +++++++++-------
 lib/swiotlb.c                                   | 26 +++++++++++++++++++------
 9 files changed, 48 insertions(+), 24 deletions(-)

-- 
1.9.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

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

* [PATCH v2 1/3] x86, swiotlb: Simplify pci_swiotlb_detect_override()
  2016-12-16 13:28 [PATCH v2 0/3] swiotlb: Add swiotlb=noforce debug option Geert Uytterhoeven
@ 2016-12-16 13:28 ` Geert Uytterhoeven
  2016-12-16 13:28 ` [PATCH v2 2/3] swiotlb: Convert swiotlb_force from int to enum Geert Uytterhoeven
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 11+ messages in thread
From: Geert Uytterhoeven @ 2016-12-16 13:28 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk
  Cc: Jonathan Corbet, Catalin Marinas, Will Deacon, Thomas Gleixner,
	Ingo Molnar, H. Peter Anvin, Boris Ostrovsky, David Vrabel,
	Juergen Gross, Steven Rostedt, linux-kernel, linux-renesas-soc,
	Geert Uytterhoeven

At the end of the function, the local variable use_swiotlb has always
the same value as the global variable swiotlb. Hence drop the local
variable completely.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.
---
 arch/x86/kernel/pci-swiotlb.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
index b47edb8f52566e22..36049af2715ebd13 100644
--- a/arch/x86/kernel/pci-swiotlb.c
+++ b/arch/x86/kernel/pci-swiotlb.c
@@ -68,12 +68,10 @@ void x86_swiotlb_free_coherent(struct device *dev, size_t size,
  */
 int __init pci_swiotlb_detect_override(void)
 {
-	int use_swiotlb = swiotlb | swiotlb_force;
-
 	if (swiotlb_force)
 		swiotlb = 1;
 
-	return use_swiotlb;
+	return swiotlb;
 }
 IOMMU_INIT_FINISH(pci_swiotlb_detect_override,
 		  pci_xen_swiotlb_detect,
-- 
1.9.1

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

* [PATCH v2 2/3] swiotlb: Convert swiotlb_force from int to enum
  2016-12-16 13:28 [PATCH v2 0/3] swiotlb: Add swiotlb=noforce debug option Geert Uytterhoeven
  2016-12-16 13:28 ` [PATCH v2 1/3] x86, swiotlb: Simplify pci_swiotlb_detect_override() Geert Uytterhoeven
@ 2016-12-16 13:28 ` Geert Uytterhoeven
  2017-01-04 17:57   ` Catalin Marinas
  2016-12-16 13:28 ` [PATCH v2 3/3] swiotlb: Add swiotlb=noforce debug option Geert Uytterhoeven
  2016-12-19 13:31 ` [PATCH v2 0/3] " Konrad Rzeszutek Wilk
  3 siblings, 1 reply; 11+ messages in thread
From: Geert Uytterhoeven @ 2016-12-16 13:28 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk
  Cc: Jonathan Corbet, Catalin Marinas, Will Deacon, Thomas Gleixner,
	Ingo Molnar, H. Peter Anvin, Boris Ostrovsky, David Vrabel,
	Juergen Gross, Steven Rostedt, linux-kernel, linux-renesas-soc,
	Geert Uytterhoeven

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>
---
v2:
  - New.
---
 arch/arm64/mm/dma-mapping.c    |  3 ++-
 arch/arm64/mm/init.c           |  3 ++-
 arch/x86/kernel/pci-swiotlb.c  |  2 +-
 arch/x86/xen/pci-swiotlb-xen.c |  2 +-
 drivers/xen/swiotlb-xen.c      |  4 ++--
 include/linux/swiotlb.h        |  7 ++++++-
 include/trace/events/swiotlb.h | 16 +++++++++-------
 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 290a84f3351f706b..e04082700bb16c35 100644
--- a/arch/arm64/mm/dma-mapping.c
+++ b/arch/arm64/mm/dma-mapping.c
@@ -524,7 +524,8 @@ struct dma_map_ops dummy_dma_ops = {
 
 static int __init arm64_dma_init(void)
 {
-	if (swiotlb_force || max_pfn > (arm64_dma_phys_limit >> PAGE_SHIFT))
+	if (swiotlb_force == SWIOTLB_FORCE ||
+	    max_pfn > (arm64_dma_phys_limit >> PAGE_SHIFT))
 		swiotlb = 1;
 
 	return atomic_pool_init();
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 212c4d1e2f26df7f..716d1226ba6925ba 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -401,7 +401,8 @@ static void __init free_unused_memmap(void)
  */
 void __init mem_init(void)
 {
-	if (swiotlb_force || max_pfn > (arm64_dma_phys_limit >> PAGE_SHIFT))
+	if (swiotlb_force == SWIOTLB_FORCE ||
+	    max_pfn > (arm64_dma_phys_limit >> PAGE_SHIFT))
 		swiotlb_init(1);
 
 	set_max_mapnr(pfn_to_page(max_pfn) - mem_map);
diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
index 36049af2715ebd13..410efb2c7b80028b 100644
--- a/arch/x86/kernel/pci-swiotlb.c
+++ b/arch/x86/kernel/pci-swiotlb.c
@@ -68,7 +68,7 @@ void x86_swiotlb_free_coherent(struct device *dev, size_t size,
  */
 int __init pci_swiotlb_detect_override(void)
 {
-	if (swiotlb_force)
+	if (swiotlb_force == SWIOTLB_FORCE)
 		swiotlb = 1;
 
 	return swiotlb;
diff --git a/arch/x86/xen/pci-swiotlb-xen.c b/arch/x86/xen/pci-swiotlb-xen.c
index a9fafb5c873897ee..a0b36a9d5df149e6 100644
--- a/arch/x86/xen/pci-swiotlb-xen.c
+++ b/arch/x86/xen/pci-swiotlb-xen.c
@@ -48,7 +48,7 @@ int __init pci_xen_swiotlb_detect(void)
 	 * activate this IOMMU. If running as PV privileged, activate it
 	 * irregardless.
 	 */
-	if ((xen_initial_domain() || swiotlb || swiotlb_force))
+	if (xen_initial_domain() || swiotlb || swiotlb_force == SWIOTLB_FORCE)
 		xen_swiotlb = 1;
 
 	/* 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 478fb91e3df2b8a9..aba12009422e343d 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,
 	if (dma_capable(dev, dev_addr, size) &&
 	    !range_straddles_page_boundary(phys, size) &&
 		!xen_arch_need_swiotlb(dev, phys, dev_addr) &&
-		!swiotlb_force) {
+		(swiotlb_force != SWIOTLB_FORCE)) {
 		/* we are not interested in the dma_addr returned by
 		 * xen_dma_map_page, only in the potential cache flushes executed
 		 * by the function. */
@@ -552,7 +552,7 @@ void xen_swiotlb_unmap_page(struct device *hwdev, dma_addr_t dev_addr,
 		phys_addr_t paddr = sg_phys(sg);
 		dma_addr_t dev_addr = xen_phys_to_bus(paddr);
 
-		if (swiotlb_force ||
+		if (swiotlb_force == SWIOTLB_FORCE ||
 		    xen_arch_need_swiotlb(hwdev, paddr, dev_addr) ||
 		    !dma_capable(hwdev, dev_addr, sg->length) ||
 		    range_straddles_page_boundary(paddr, sg->length)) {
diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index 183f37c8a5e164ad..71d104e4c8490763 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -9,7 +9,12 @@
 struct page;
 struct scatterlist;
 
-extern int swiotlb_force;
+enum swiotlb_force {
+	SWIOTLB_NORMAL,		/* Default - depending on HW DMA mask etc. */
+	SWIOTLB_FORCE,		/* swiotlb=force */
+};
+
+extern enum swiotlb_force swiotlb_force;
 
 /*
  * Maximum allowable number of contiguous slabs to map,
diff --git a/include/trace/events/swiotlb.h b/include/trace/events/swiotlb.h
index 7ea4c5e7c4487a96..5e2e30a7efce0ebd 100644
--- a/include/trace/events/swiotlb.h
+++ b/include/trace/events/swiotlb.h
@@ -11,16 +11,16 @@
 	TP_PROTO(struct device *dev,
 		 dma_addr_t dev_addr,
 		 size_t size,
-		 int swiotlb_force),
+		 enum swiotlb_force swiotlb_force),
 
 	TP_ARGS(dev, dev_addr, size, swiotlb_force),
 
 	TP_STRUCT__entry(
-		__string(	dev_name,	dev_name(dev)	)
-		__field(	u64,	dma_mask		)
-		__field(	dma_addr_t,	dev_addr	)
-		__field(	size_t,	size			)
-		__field(	int,	swiotlb_force		)
+		__string(	dev_name,	dev_name(dev)		)
+		__field(	u64,	dma_mask			)
+		__field(	dma_addr_t,	dev_addr		)
+		__field(	size_t,	size				)
+		__field(	enum swiotlb_force,	swiotlb_force	)
 	),
 
 	TP_fast_assign(
@@ -37,7 +37,9 @@
 		__entry->dma_mask,
 		(unsigned long long)__entry->dev_addr,
 		__entry->size,
-		__entry->swiotlb_force ? "swiotlb_force" : "" )
+		__print_symbolic(__entry->swiotlb_force,
+			{ SWIOTLB_NORMAL,	"NORMAL" },
+			{ SWIOTLB_FORCE,	"FORCE" }))
 );
 
 #endif /*  _TRACE_SWIOTLB_H */
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index cb1b54ee8527241d..a32dce6d5101f408 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -53,7 +53,7 @@
  */
 #define IO_TLB_MIN_SLABS ((1<<20) >> IO_TLB_SHIFT)
 
-int swiotlb_force;
+enum swiotlb_force swiotlb_force;
 
 /*
  * Used to do a quick range check in swiotlb_tbl_unmap_single and
@@ -107,7 +107,7 @@
 	if (*str == ',')
 		++str;
 	if (!strcmp(str, "force"))
-		swiotlb_force = 1;
+		swiotlb_force = SWIOTLB_FORCE;
 
 	return 0;
 }
@@ -763,7 +763,7 @@ dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
 	 * we can safely return the device addr and not worry about bounce
 	 * buffering it.
 	 */
-	if (dma_capable(dev, dev_addr, size) && !swiotlb_force)
+	if (dma_capable(dev, dev_addr, size) && swiotlb_force != SWIOTLB_FORCE)
 		return dev_addr;
 
 	trace_swiotlb_bounced(dev, dev_addr, size, swiotlb_force);
@@ -904,7 +904,7 @@ void swiotlb_unmap_page(struct device *hwdev, dma_addr_t dev_addr,
 		phys_addr_t paddr = sg_phys(sg);
 		dma_addr_t dev_addr = phys_to_dma(hwdev, paddr);
 
-		if (swiotlb_force ||
+		if (swiotlb_force == SWIOTLB_FORCE ||
 		    !dma_capable(hwdev, dev_addr, sg->length)) {
 			phys_addr_t map = map_single(hwdev, sg_phys(sg),
 						     sg->length, dir, attrs);
-- 
1.9.1

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

* [PATCH v2 3/3] swiotlb: Add swiotlb=noforce debug option
  2016-12-16 13:28 [PATCH v2 0/3] swiotlb: Add swiotlb=noforce debug option Geert Uytterhoeven
  2016-12-16 13:28 ` [PATCH v2 1/3] x86, swiotlb: Simplify pci_swiotlb_detect_override() Geert Uytterhoeven
  2016-12-16 13:28 ` [PATCH v2 2/3] swiotlb: Convert swiotlb_force from int to enum Geert Uytterhoeven
@ 2016-12-16 13:28 ` Geert Uytterhoeven
  2016-12-19 13:38   ` Konrad Rzeszutek Wilk
  2017-01-04 18:00   ` Catalin Marinas
  2016-12-19 13:31 ` [PATCH v2 0/3] " Konrad Rzeszutek Wilk
  3 siblings, 2 replies; 11+ messages in thread
From: Geert Uytterhoeven @ 2016-12-16 13:28 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk
  Cc: Jonathan Corbet, Catalin Marinas, Will Deacon, Thomas Gleixner,
	Ingo Molnar, H. Peter Anvin, Boris Ostrovsky, David Vrabel,
	Juergen Gross, Steven Rostedt, linux-kernel, linux-renesas-soc,
	Geert Uytterhoeven

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>
---
v2:
  - Change kernel parameter value from "nobounce" to "noforce",
  - Extend swiotlb_force enum instead of adding swiotlb_nobounce
    variable (both requested by Konrad Wilk).
---
 Documentation/admin-guide/kernel-parameters.txt |  3 ++-
 include/linux/swiotlb.h                         |  1 +
 include/trace/events/swiotlb.h                  |  3 ++-
 lib/swiotlb.c                                   | 18 ++++++++++++++++--
 4 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 21e2d88637050b7a..24fb691b2da5f78d 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -3811,10 +3811,11 @@
 			it if 0 is given (See Documentation/cgroup-v1/memory.txt)
 
 	swiotlb=	[ARM,IA-64,PPC,MIPS,X86]
-			Format: { <int> | force }
+			Format: { <int> | force | noforce }
 			<int> -- Number of I/O TLB slabs
 			force -- force using of bounce buffers even if they
 			         wouldn't be automatically used by the kernel
+			noforce -- Never use bounce buffers (for debugging)
 
 	switches=	[HW,M68k]
 
diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index 71d104e4c8490763..d9c84a9cde3dd7d7 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -12,6 +12,7 @@
 enum swiotlb_force {
 	SWIOTLB_NORMAL,		/* Default - depending on HW DMA mask etc. */
 	SWIOTLB_FORCE,		/* swiotlb=force */
+	SWIOTLB_NO_FORCE,	/* swiotlb=noforce */
 };
 
 extern enum swiotlb_force swiotlb_force;
diff --git a/include/trace/events/swiotlb.h b/include/trace/events/swiotlb.h
index 5e2e30a7efce0ebd..288c0c54a2b4ace6 100644
--- a/include/trace/events/swiotlb.h
+++ b/include/trace/events/swiotlb.h
@@ -39,7 +39,8 @@
 		__entry->size,
 		__print_symbolic(__entry->swiotlb_force,
 			{ SWIOTLB_NORMAL,	"NORMAL" },
-			{ SWIOTLB_FORCE,	"FORCE" }))
+			{ SWIOTLB_FORCE,	"FORCE" },
+			{ SWIOTLB_NO_FORCE,	"NO_FORCE" }))
 );
 
 #endif /*  _TRACE_SWIOTLB_H */
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index a32dce6d5101f408..9def738af4f4e568 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -106,8 +106,12 @@
 	}
 	if (*str == ',')
 		++str;
-	if (!strcmp(str, "force"))
+	if (!strcmp(str, "force")) {
 		swiotlb_force = SWIOTLB_FORCE;
+	} else if (!strcmp(str, "noforce")) {
+		swiotlb_force = SWIOTLB_NO_FORCE;
+		io_tlb_nslabs = 1;
+	}
 
 	return 0;
 }
@@ -543,8 +547,15 @@ phys_addr_t swiotlb_tbl_map_single(struct device *hwdev,
 map_single(struct device *hwdev, phys_addr_t phys, size_t size,
 	   enum dma_data_direction dir, unsigned long attrs)
 {
-	dma_addr_t start_dma_addr = phys_to_dma(hwdev, io_tlb_start);
+	dma_addr_t start_dma_addr;
+
+	if (swiotlb_force == SWIOTLB_NO_FORCE) {
+		dev_warn_ratelimited(hwdev, "Cannot do DMA to address %pa\n",
+				     &phys);
+		return SWIOTLB_MAP_ERROR;
+	}
 
+	start_dma_addr = phys_to_dma(hwdev, io_tlb_start);
 	return swiotlb_tbl_map_single(hwdev, start_dma_addr, phys, size,
 				      dir, attrs);
 }
@@ -721,6 +732,9 @@ void swiotlb_tbl_sync_single(struct device *hwdev, phys_addr_t tlb_addr,
 swiotlb_full(struct device *dev, size_t size, enum dma_data_direction dir,
 	     int do_panic)
 {
+	if (swiotlb_force == SWIOTLB_NO_FORCE)
+		return;
+
 	/*
 	 * Ran out of IOMMU space for this operation. This is very bad.
 	 * Unfortunately the drivers cannot handle this operation properly.
-- 
1.9.1

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

* Re: [PATCH v2 0/3] swiotlb: Add swiotlb=noforce debug option
  2016-12-16 13:28 [PATCH v2 0/3] swiotlb: Add swiotlb=noforce debug option Geert Uytterhoeven
                   ` (2 preceding siblings ...)
  2016-12-16 13:28 ` [PATCH v2 3/3] swiotlb: Add swiotlb=noforce debug option Geert Uytterhoeven
@ 2016-12-19 13:31 ` Konrad Rzeszutek Wilk
  3 siblings, 0 replies; 11+ messages in thread
From: Konrad Rzeszutek Wilk @ 2016-12-19 13:31 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Konrad Rzeszutek Wilk, Jonathan Corbet, Catalin Marinas,
	Will Deacon, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
	Boris Ostrovsky, David Vrabel, Juergen Gross, Steven Rostedt,
	linux-kernel, linux-renesas-soc

On Fri, Dec 16, 2016 at 02:28:39PM +0100, Geert Uytterhoeven wrote:
> 	Hi Konrad,

Heya!
> 
> This patch series adds a kernel command line option to aid debugging
> when developing support for DMA to memory outside the 32-bit address
> space.  If specified, trying to map memory that cannot be used with DMA
> will fail, and a warning will be printed.  This has been used
> succesfully to find drivers and DMA engines that do not support 64-bit
> memory.
> 
> Changes compared to v1:
>   - Dropp patch "swiotlb: Rate-limit printing when running out of
>     SW-IOMMU space", which has been picked up,
>   - Add cleanup patch 1/3,
>   - Add patch 2/3, to convert the flag swiotlb_force from an int to an
>     enum,
>   - Change the kernel parameter "swiotlb=nobounce" to "swiotlb=noforce"
>     (requested by Konrad Wilk),
>   - Extend swiotlb_force enum instead of adding an swiotlb_nobounce
>     variable (requested by Konrad Wilk).
> 
> This has been tested on ra7796/salvator-x, and compile-tested on x86.

Let me run it on various combinations of x86 and if all is good
will ask Linus to pick it up for rc1.

Thanks!
> 
> Thanks!
> 
> Geert Uytterhoeven (3):
>   x86, swiotlb: Simplify pci_swiotlb_detect_override()
>   swiotlb: Convert swiotlb_force from int to enum
>   swiotlb: Add swiotlb=noforce debug option
> 
>  Documentation/admin-guide/kernel-parameters.txt |  3 ++-
>  arch/arm64/mm/dma-mapping.c                     |  3 ++-
>  arch/arm64/mm/init.c                            |  3 ++-
>  arch/x86/kernel/pci-swiotlb.c                   |  6 ++----
>  arch/x86/xen/pci-swiotlb-xen.c                  |  2 +-
>  drivers/xen/swiotlb-xen.c                       |  4 ++--
>  include/linux/swiotlb.h                         |  8 +++++++-
>  include/trace/events/swiotlb.h                  | 17 +++++++++-------
>  lib/swiotlb.c                                   | 26 +++++++++++++++++++------
>  9 files changed, 48 insertions(+), 24 deletions(-)
> 
> -- 
> 1.9.1
> 
> Gr{oetje,eeting}s,
> 
> 						Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> 							    -- Linus Torvalds

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

* Re: [PATCH v2 3/3] swiotlb: Add swiotlb=noforce debug option
  2016-12-16 13:28 ` [PATCH v2 3/3] swiotlb: Add swiotlb=noforce debug option Geert Uytterhoeven
@ 2016-12-19 13:38   ` Konrad Rzeszutek Wilk
  2016-12-19 13:57     ` Geert Uytterhoeven
  2017-01-04 18:00   ` Catalin Marinas
  1 sibling, 1 reply; 11+ messages in thread
From: Konrad Rzeszutek Wilk @ 2016-12-19 13:38 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Konrad Rzeszutek Wilk, Jonathan Corbet, Catalin Marinas,
	Will Deacon, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
	Boris Ostrovsky, David Vrabel, Juergen Gross, Steven Rostedt,
	linux-kernel, linux-renesas-soc

On Fri, Dec 16, 2016 at 02:28:42PM +0100, Geert Uytterhoeven wrote:
> 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>

What is this based on? I can't apply it on my latest that I had
sent to Linus?

Could you rebase this one please on:

git://git.kernel.org/pub/scm/linux/kernel/git/konrad/swiotlb.git stable/for-linus-4.9

Thanks?

Or if alternatively that does not - then please rebase it on
b5cab0da75c292ffa0fbd68dd2c820066b2842de

Thanks!

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

* Re: [PATCH v2 3/3] swiotlb: Add swiotlb=noforce debug option
  2016-12-19 13:38   ` Konrad Rzeszutek Wilk
@ 2016-12-19 13:57     ` Geert Uytterhoeven
  2016-12-19 14:31       ` Konrad Rzeszutek Wilk
  0 siblings, 1 reply; 11+ messages in thread
From: Geert Uytterhoeven @ 2016-12-19 13:57 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk
  Cc: Geert Uytterhoeven, Konrad Rzeszutek Wilk, Jonathan Corbet,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, Boris Ostrovsky, David Vrabel, Juergen Gross,
	Steven Rostedt, linux-kernel, Linux-Renesas

Hi Konrad,

On Mon, Dec 19, 2016 at 2:38 PM, Konrad Rzeszutek Wilk
<konrad@darnok.org> wrote:
> On Fri, Dec 16, 2016 at 02:28:42PM +0100, Geert Uytterhoeven wrote:
>> 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>
>
> What is this based on? I can't apply it on my latest that I had
> sent to Linus?

I rebased it on last Friday's linux-next, due to the recent move of
kernel-parameters.txt.
All the rest should be identical to your linux-next branch.

> Could you rebase this one please on:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/konrad/swiotlb.git stable/for-linus-4.9

That one indeed doesn't have the move of kernel-parameters.txt.

> Or if alternatively that does not - then please rebase it on
> b5cab0da75c292ffa0fbd68dd2c820066b2842de

However, my series already applies cleanly with git am on top of
that commit?

Please let me know what to do. Thanks!

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v2 3/3] swiotlb: Add swiotlb=noforce debug option
  2016-12-19 13:57     ` Geert Uytterhoeven
@ 2016-12-19 14:31       ` Konrad Rzeszutek Wilk
  0 siblings, 0 replies; 11+ messages in thread
From: Konrad Rzeszutek Wilk @ 2016-12-19 14:31 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Konrad Rzeszutek Wilk, Geert Uytterhoeven, Jonathan Corbet,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, Boris Ostrovsky, David Vrabel, Juergen Gross,
	Steven Rostedt, linux-kernel, Linux-Renesas

On Mon, Dec 19, 2016 at 02:57:00PM +0100, Geert Uytterhoeven wrote:
> Hi Konrad,
> 
> On Mon, Dec 19, 2016 at 2:38 PM, Konrad Rzeszutek Wilk
> <konrad@darnok.org> wrote:
> > On Fri, Dec 16, 2016 at 02:28:42PM +0100, Geert Uytterhoeven wrote:
> >> 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>
> >
> > What is this based on? I can't apply it on my latest that I had
> > sent to Linus?
> 
> I rebased it on last Friday's linux-next, due to the recent move of
> kernel-parameters.txt.
> All the rest should be identical to your linux-next branch.
> 
> > Could you rebase this one please on:
> >
> > git://git.kernel.org/pub/scm/linux/kernel/git/konrad/swiotlb.git stable/for-linus-4.9
> 
> That one indeed doesn't have the move of kernel-parameters.txt.
> 
> > Or if alternatively that does not - then please rebase it on
> > b5cab0da75c292ffa0fbd68dd2c820066b2842de
> 
> However, my series already applies cleanly with git am on top of
> that commit?

Ah that does indeed work.

Which means I can't push it to Linus until rc2 at least.

Linus is sad when he sees git pulls that hadn't "soaked"
for two weeks in linux-next - and especially patches on top of
merges during the merge window.

> 
> Please let me know what to do. Thanks!

Building and testing them now.

Wish there was some travis script to do this.

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

* Re: [PATCH v2 2/3] swiotlb: Convert swiotlb_force from int to enum
  2016-12-16 13:28 ` [PATCH v2 2/3] swiotlb: Convert swiotlb_force from int to enum Geert Uytterhoeven
@ 2017-01-04 17:57   ` Catalin Marinas
  2017-01-04 18:25     ` Konrad Rzeszutek Wilk
  0 siblings, 1 reply; 11+ messages in thread
From: Catalin Marinas @ 2017-01-04 17:57 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Konrad Rzeszutek Wilk, Jonathan Corbet, Will Deacon,
	Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Boris Ostrovsky,
	David Vrabel, Juergen Gross, Steven Rostedt, linux-kernel,
	linux-renesas-soc

On Fri, Dec 16, 2016 at 02:28:41PM +0100, Geert Uytterhoeven wrote:
> 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>
> ---
> v2:
>   - New.
> ---
>  arch/arm64/mm/dma-mapping.c    |  3 ++-
>  arch/arm64/mm/init.c           |  3 ++-
>  arch/x86/kernel/pci-swiotlb.c  |  2 +-
>  arch/x86/xen/pci-swiotlb-xen.c |  2 +-
>  drivers/xen/swiotlb-xen.c      |  4 ++--
>  include/linux/swiotlb.h        |  7 ++++++-
>  include/trace/events/swiotlb.h | 16 +++++++++-------
>  lib/swiotlb.c                  |  8 ++++----
>  8 files changed, 27 insertions(+), 18 deletions(-)

If this hasn't been queued somewhere yet, for arm64:

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

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

* Re: [PATCH v2 3/3] swiotlb: Add swiotlb=noforce debug option
  2016-12-16 13:28 ` [PATCH v2 3/3] swiotlb: Add swiotlb=noforce debug option Geert Uytterhoeven
  2016-12-19 13:38   ` Konrad Rzeszutek Wilk
@ 2017-01-04 18:00   ` Catalin Marinas
  1 sibling, 0 replies; 11+ messages in thread
From: Catalin Marinas @ 2017-01-04 18:00 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Konrad Rzeszutek Wilk, Jonathan Corbet, Will Deacon,
	Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Boris Ostrovsky,
	David Vrabel, Juergen Gross, Steven Rostedt, linux-kernel,
	linux-renesas-soc

On Fri, Dec 16, 2016 at 02:28:42PM +0100, Geert Uytterhoeven wrote:
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index 21e2d88637050b7a..24fb691b2da5f78d 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -3811,10 +3811,11 @@
>  			it if 0 is given (See Documentation/cgroup-v1/memory.txt)
>  
>  	swiotlb=	[ARM,IA-64,PPC,MIPS,X86]
> -			Format: { <int> | force }
> +			Format: { <int> | force | noforce }
>  			<int> -- Number of I/O TLB slabs
>  			force -- force using of bounce buffers even if they
>  			         wouldn't be automatically used by the kernel
> +			noforce -- Never use bounce buffers (for debugging)

Nitpick (bikeshedding, feel free to ignore): "noforce" looks to me like
the current default behaviour if swiotlb= argument is passed. I would
have preferred "never" or "disable" instead, it has a clearer intent.

-- 
Catalin

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

* Re: [PATCH v2 2/3] swiotlb: Convert swiotlb_force from int to enum
  2017-01-04 17:57   ` Catalin Marinas
@ 2017-01-04 18:25     ` Konrad Rzeszutek Wilk
  0 siblings, 0 replies; 11+ messages in thread
From: Konrad Rzeszutek Wilk @ 2017-01-04 18:25 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: Geert Uytterhoeven, Jonathan Corbet, Will Deacon,
	Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Boris Ostrovsky,
	David Vrabel, Juergen Gross, Steven Rostedt, linux-kernel,
	linux-renesas-soc

On Wed, Jan 04, 2017 at 05:57:17PM +0000, Catalin Marinas wrote:
> On Fri, Dec 16, 2016 at 02:28:41PM +0100, Geert Uytterhoeven wrote:
> > 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>
> > ---
> > v2:
> >   - New.
> > ---
> >  arch/arm64/mm/dma-mapping.c    |  3 ++-
> >  arch/arm64/mm/init.c           |  3 ++-
> >  arch/x86/kernel/pci-swiotlb.c  |  2 +-
> >  arch/x86/xen/pci-swiotlb-xen.c |  2 +-
> >  drivers/xen/swiotlb-xen.c      |  4 ++--
> >  include/linux/swiotlb.h        |  7 ++++++-
> >  include/trace/events/swiotlb.h | 16 +++++++++-------
> >  lib/swiotlb.c                  |  8 ++++----
> >  8 files changed, 27 insertions(+), 18 deletions(-)
> 
> If this hasn't been queued somewhere yet, for arm64:

It is on swiotlb git tree.
> 
> Acked-by: Catalin Marinas <catalin.marinas@arm.com>

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

end of thread, other threads:[~2017-01-04 18:27 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-16 13:28 [PATCH v2 0/3] swiotlb: Add swiotlb=noforce debug option Geert Uytterhoeven
2016-12-16 13:28 ` [PATCH v2 1/3] x86, swiotlb: Simplify pci_swiotlb_detect_override() Geert Uytterhoeven
2016-12-16 13:28 ` [PATCH v2 2/3] swiotlb: Convert swiotlb_force from int to enum Geert Uytterhoeven
2017-01-04 17:57   ` Catalin Marinas
2017-01-04 18:25     ` Konrad Rzeszutek Wilk
2016-12-16 13:28 ` [PATCH v2 3/3] swiotlb: Add swiotlb=noforce debug option Geert Uytterhoeven
2016-12-19 13:38   ` Konrad Rzeszutek Wilk
2016-12-19 13:57     ` Geert Uytterhoeven
2016-12-19 14:31       ` Konrad Rzeszutek Wilk
2017-01-04 18:00   ` Catalin Marinas
2016-12-19 13:31 ` [PATCH v2 0/3] " Konrad Rzeszutek Wilk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.