All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] swiotlb: Correct kernel command line handler
@ 2014-04-01  1:51 Jungseok Lee
  2014-04-01 12:46 ` Konrad Rzeszutek Wilk
  0 siblings, 1 reply; 4+ messages in thread
From: Jungseok Lee @ 2014-04-01  1:51 UTC (permalink / raw)
  To: konrad.wilk, linux-kernel; +Cc: sungjinn.chung, linux-samsung-soc

This patch corrects kernel command line handler when io_tlb_nslabs
is set to 0.

A current implementation allocates default size memory (64MB) when
0 is given to io_tlb_nslabs ("swiotlb=0") by kernel command line.
In other words, memory is allocated unintentionally.

Signed-off-by: Jungseok Lee <jays.lee@samsung.com>
Signed-off-by: Sungjinn Chung <sungjinn.chung@samsung.com>
---
 lib/swiotlb.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index b604b83..9fe9f71 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -55,6 +55,8 @@
 
 int swiotlb_force;
 
+static int swiotlb_no_use;
+
 /*
  * Used to do a quick range check in swiotlb_tbl_unmap_single and
  * swiotlb_tbl_sync_single_*, to see if the memory was in fact allocated by this
@@ -102,6 +104,8 @@ setup_io_tlb_npages(char *str)
 		io_tlb_nslabs = simple_strtoul(str, &str, 0);
 		/* avoid tail segment of size < IO_TLB_SEGSIZE */
 		io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
+		if (!io_tlb_nslabs)
+			swiotlb_no_use = 1;
 	}
 	if (*str == ',')
 		++str;
@@ -212,7 +216,7 @@ swiotlb_init(int verbose)
 	unsigned char *vstart;
 	unsigned long bytes;
 
-	if (!io_tlb_nslabs) {
+	if (!swiotlb_no_use && !io_tlb_nslabs) {
 		io_tlb_nslabs = (default_size >> IO_TLB_SHIFT);
 		io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
 	}
@@ -244,7 +248,7 @@ swiotlb_late_init_with_default_size(size_t default_size)
 	unsigned int order;
 	int rc = 0;
 
-	if (!io_tlb_nslabs) {
+	if (!swiotlb_no_use && !io_tlb_nslabs) {
 		io_tlb_nslabs = (default_size >> IO_TLB_SHIFT);
 		io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
 	}
-- 
1.7.10.4



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

* Re: [PATCH] swiotlb: Correct kernel command line handler
  2014-04-01  1:51 [PATCH] swiotlb: Correct kernel command line handler Jungseok Lee
@ 2014-04-01 12:46 ` Konrad Rzeszutek Wilk
  2014-04-02  4:36   ` Jungseok Lee
  0 siblings, 1 reply; 4+ messages in thread
From: Konrad Rzeszutek Wilk @ 2014-04-01 12:46 UTC (permalink / raw)
  To: Jungseok Lee; +Cc: linux-kernel, sungjinn.chung, linux-samsung-soc

On Tue, Apr 01, 2014 at 10:51:58AM +0900, Jungseok Lee wrote:
> This patch corrects kernel command line handler when io_tlb_nslabs
> is set to 0.
> 
> A current implementation allocates default size memory (64MB) when
> 0 is given to io_tlb_nslabs ("swiotlb=0") by kernel command line.
> In other words, memory is allocated unintentionally.

What are the other IOMMUs that end up taking over the DMA ops?
Or do you end up with no DMA ops?

> 
> Signed-off-by: Jungseok Lee <jays.lee@samsung.com>
> Signed-off-by: Sungjinn Chung <sungjinn.chung@samsung.com>
> ---
>  lib/swiotlb.c |    8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/swiotlb.c b/lib/swiotlb.c
> index b604b83..9fe9f71 100644
> --- a/lib/swiotlb.c
> +++ b/lib/swiotlb.c
> @@ -55,6 +55,8 @@
>  
>  int swiotlb_force;
>  
> +static int swiotlb_no_use;
> +
>  /*
>   * Used to do a quick range check in swiotlb_tbl_unmap_single and
>   * swiotlb_tbl_sync_single_*, to see if the memory was in fact allocated by this
> @@ -102,6 +104,8 @@ setup_io_tlb_npages(char *str)
>  		io_tlb_nslabs = simple_strtoul(str, &str, 0);
>  		/* avoid tail segment of size < IO_TLB_SEGSIZE */
>  		io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
> +		if (!io_tlb_nslabs)
> +			swiotlb_no_use = 1;
>  	}
>  	if (*str == ',')
>  		++str;
> @@ -212,7 +216,7 @@ swiotlb_init(int verbose)
>  	unsigned char *vstart;
>  	unsigned long bytes;
>  
> -	if (!io_tlb_nslabs) {
> +	if (!swiotlb_no_use && !io_tlb_nslabs) {
>  		io_tlb_nslabs = (default_size >> IO_TLB_SHIFT);
>  		io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
>  	}
> @@ -244,7 +248,7 @@ swiotlb_late_init_with_default_size(size_t default_size)
>  	unsigned int order;
>  	int rc = 0;
>  
> -	if (!io_tlb_nslabs) {
> +	if (!swiotlb_no_use && !io_tlb_nslabs) {
>  		io_tlb_nslabs = (default_size >> IO_TLB_SHIFT);
>  		io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
>  	}
> -- 
> 1.7.10.4
> 
> 

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

* Re: [PATCH] swiotlb: Correct kernel command line handler
  2014-04-01 12:46 ` Konrad Rzeszutek Wilk
@ 2014-04-02  4:36   ` Jungseok Lee
  2014-06-20 20:20     ` Konrad Rzeszutek Wilk
  0 siblings, 1 reply; 4+ messages in thread
From: Jungseok Lee @ 2014-04-02  4:36 UTC (permalink / raw)
  To: 'Konrad Rzeszutek Wilk'
  Cc: linux-kernel, sungjinn.chung, 'linux-samsung-soc'

On Tuesday, April 01, 2014 9:46 PM, Konrad Rzeszutek Wilk wrote:
> On Tue, Apr 01, 2014 at 10:51:58AM +0900, Jungseok Lee wrote:
> > This patch corrects kernel command line handler when io_tlb_nslabs is
> > set to 0.
> >
> > A current implementation allocates default size memory (64MB) when
> > 0 is given to io_tlb_nslabs ("swiotlb=0") by kernel command line.
> > In other words, memory is allocated unintentionally.
> 
> What are the other IOMMUs that end up taking over the DMA ops?

I think that no other IOMMUs take over it on ARM64 system, except Xen.

> Or do you end up with no DMA ops?

I focus on ARM64 system which uses swiotlb as default DMA ops.

If some ARM64 platforms would like to use memory only from
__get_free_pages in swiotlb_alloc_coherent function, an
interface would be needed to configure reserved memory size.

Thus, I add it to kernel command line handler.

Best Regards
Jungseok Lee

> >
> > Signed-off-by: Jungseok Lee <jays.lee@samsung.com>
> > Signed-off-by: Sungjinn Chung <sungjinn.chung@samsung.com>
> > ---
> >  lib/swiotlb.c |    8 ++++++--
> >  1 file changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/lib/swiotlb.c b/lib/swiotlb.c index b604b83..9fe9f71
> > 100644
> > --- a/lib/swiotlb.c
> > +++ b/lib/swiotlb.c
> > @@ -55,6 +55,8 @@
> >
> >  int swiotlb_force;
> >
> > +static int swiotlb_no_use;
> > +
> >  /*
> >   * Used to do a quick range check in swiotlb_tbl_unmap_single and
> >   * swiotlb_tbl_sync_single_*, to see if the memory was in fact
> > allocated by this @@ -102,6 +104,8 @@ setup_io_tlb_npages(char *str)
> >  		io_tlb_nslabs = simple_strtoul(str, &str, 0);
> >  		/* avoid tail segment of size < IO_TLB_SEGSIZE */
> >  		io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
> > +		if (!io_tlb_nslabs)
> > +			swiotlb_no_use = 1;
> >  	}
> >  	if (*str == ',')
> >  		++str;
> > @@ -212,7 +216,7 @@ swiotlb_init(int verbose)
> >  	unsigned char *vstart;
> >  	unsigned long bytes;
> >
> > -	if (!io_tlb_nslabs) {
> > +	if (!swiotlb_no_use && !io_tlb_nslabs) {
> >  		io_tlb_nslabs = (default_size >> IO_TLB_SHIFT);
> >  		io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
> >  	}
> > @@ -244,7 +248,7 @@ swiotlb_late_init_with_default_size(size_t default_size)
> >  	unsigned int order;
> >  	int rc = 0;
> >
> > -	if (!io_tlb_nslabs) {
> > +	if (!swiotlb_no_use && !io_tlb_nslabs) {
> >  		io_tlb_nslabs = (default_size >> IO_TLB_SHIFT);
> >  		io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
> >  	}
> > --
> > 1.7.10.4
> >
> >
> --
> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message
> to majordomo@vger.kernel.org More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

* Re: [PATCH] swiotlb: Correct kernel command line handler
  2014-04-02  4:36   ` Jungseok Lee
@ 2014-06-20 20:20     ` Konrad Rzeszutek Wilk
  0 siblings, 0 replies; 4+ messages in thread
From: Konrad Rzeszutek Wilk @ 2014-06-20 20:20 UTC (permalink / raw)
  To: Jungseok Lee; +Cc: linux-kernel, sungjinn.chung, 'linux-samsung-soc'

On Wed, Apr 02, 2014 at 01:36:29PM +0900, Jungseok Lee wrote:
> On Tuesday, April 01, 2014 9:46 PM, Konrad Rzeszutek Wilk wrote:
> > On Tue, Apr 01, 2014 at 10:51:58AM +0900, Jungseok Lee wrote:
> > > This patch corrects kernel command line handler when io_tlb_nslabs is
> > > set to 0.
> > >
> > > A current implementation allocates default size memory (64MB) when
> > > 0 is given to io_tlb_nslabs ("swiotlb=0") by kernel command line.
> > > In other words, memory is allocated unintentionally.
> > 
> > What are the other IOMMUs that end up taking over the DMA ops?
> 
> I think that no other IOMMUs take over it on ARM64 system, except Xen.
> 
> > Or do you end up with no DMA ops?
> 
> I focus on ARM64 system which uses swiotlb as default DMA ops.
> 
> If some ARM64 platforms would like to use memory only from
> __get_free_pages in swiotlb_alloc_coherent function, an
> interface would be needed to configure reserved memory size.
> 
> Thus, I add it to kernel command line handler.

OK. I somehow have lost track of this patch. Is this patch
still valid?

> 
> Best Regards
> Jungseok Lee
> 
> > >
> > > Signed-off-by: Jungseok Lee <jays.lee@samsung.com>
> > > Signed-off-by: Sungjinn Chung <sungjinn.chung@samsung.com>
> > > ---
> > >  lib/swiotlb.c |    8 ++++++--
> > >  1 file changed, 6 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/lib/swiotlb.c b/lib/swiotlb.c index b604b83..9fe9f71
> > > 100644
> > > --- a/lib/swiotlb.c
> > > +++ b/lib/swiotlb.c
> > > @@ -55,6 +55,8 @@
> > >
> > >  int swiotlb_force;
> > >
> > > +static int swiotlb_no_use;
> > > +
> > >  /*
> > >   * Used to do a quick range check in swiotlb_tbl_unmap_single and
> > >   * swiotlb_tbl_sync_single_*, to see if the memory was in fact
> > > allocated by this @@ -102,6 +104,8 @@ setup_io_tlb_npages(char *str)
> > >  		io_tlb_nslabs = simple_strtoul(str, &str, 0);
> > >  		/* avoid tail segment of size < IO_TLB_SEGSIZE */
> > >  		io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
> > > +		if (!io_tlb_nslabs)
> > > +			swiotlb_no_use = 1;
> > >  	}
> > >  	if (*str == ',')
> > >  		++str;
> > > @@ -212,7 +216,7 @@ swiotlb_init(int verbose)
> > >  	unsigned char *vstart;
> > >  	unsigned long bytes;
> > >
> > > -	if (!io_tlb_nslabs) {
> > > +	if (!swiotlb_no_use && !io_tlb_nslabs) {
> > >  		io_tlb_nslabs = (default_size >> IO_TLB_SHIFT);
> > >  		io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
> > >  	}
> > > @@ -244,7 +248,7 @@ swiotlb_late_init_with_default_size(size_t default_size)
> > >  	unsigned int order;
> > >  	int rc = 0;
> > >
> > > -	if (!io_tlb_nslabs) {
> > > +	if (!swiotlb_no_use && !io_tlb_nslabs) {
> > >  		io_tlb_nslabs = (default_size >> IO_TLB_SHIFT);
> > >  		io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
> > >  	}
> > > --
> > > 1.7.10.4
> > >
> > >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message
> > to majordomo@vger.kernel.org More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

end of thread, other threads:[~2014-06-20 20:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-01  1:51 [PATCH] swiotlb: Correct kernel command line handler Jungseok Lee
2014-04-01 12:46 ` Konrad Rzeszutek Wilk
2014-04-02  4:36   ` Jungseok Lee
2014-06-20 20:20     ` 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.