public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: Manjeet Pawar <manjeet.p@samsung.com>,
	corbet@lwn.net, catalin.marinas@arm.com, will.deacon@arm.com,
	konrad.wilk@oracle.com, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, r.thapliyal@samsung.com,
	akhilesh.k@samsung.com, ajeet.y@samsung.com
Cc: pankaj.m@samsung.com
Subject: Re: [PATCH] arm64:swiotlb:Enable only when Input size through command line
Date: Thu, 23 Jun 2016 13:31:25 +0100	[thread overview]
Message-ID: <576BD69D.2090107@arm.com> (raw)
In-Reply-To: <1466684020-5224-1-git-send-email-manjeet.p@samsung.com>

On 23/06/16 13:13, Manjeet Pawar wrote:
> From: Rohit Thapliyal <r.thapliyal@samsung.com>
>
> swiotlb default size of 64M is too big as
> default value therefore it is made configurable
> through command line through swiotlb_size parameter.
> swiotlb allocation shall be done only when the
> swiotlb size is given through command line.
> Otherwise no swiotlb is allocated.

So all platforms with most memory physically above 4GB (which is quite a 
lot of them) are suddenly broken unless they go and muck about with 
their bootloader?

If anyone's got to muck about with their bootloader, why can't it be the 
memory-constrained platforms just passing "swiotlb=1" instead?

Robin.

> Signed-off-by: Rohit Thapliyal <r.thapliyal@samsung.com>
> Signed-off-by: Manjeet Pawar <manjeet.p@samsung.com>
> Reviewed-by: Akhilesh Kumar <akhilesh.k@samsung.com>
> Reviewed-by: Ajeet Kumar Yadav <ajeet.y@samsung.com>
> ---
>   Documentation/kernel-parameters.txt |    3 +++
>   arch/arm64/mm/init.c                |    3 ++-
>   include/linux/swiotlb.h             |    1 +
>   lib/swiotlb.c                       |   33 +++++++++++++++++++++++++++++----
>   4 files changed, 35 insertions(+), 5 deletions(-)
>
> diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
> index 82b42c9..12b680f 100644
> --- a/Documentation/kernel-parameters.txt
> +++ b/Documentation/kernel-parameters.txt
> @@ -3875,6 +3875,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
>   			force -- force using of bounce buffers even if they
>   			         wouldn't be automatically used by the kernel
>
> +	swiotlb_sz= [KNL] enter swiotlb size.
> +			Sets the swiotlb size for eg. swiotlb_sz=64M
> +
>   	switches=	[HW,M68k]
>
>   	sysfs.deprecated=0|1 [KNL]
> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
> index d45f862..89c6b39 100644
> --- a/arch/arm64/mm/init.c
> +++ b/arch/arm64/mm/init.c
> @@ -403,7 +403,8 @@ static void __init free_unused_memmap(void)
>    */
>   void __init mem_init(void)
>   {
> -	swiotlb_init(1);
> +	if (swiotlb_enabled)
> +		swiotlb_init(1);
>
>   	set_max_mapnr(pfn_to_page(max_pfn) - mem_map);
>
> diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
> index 017fced..c7eb146 100644
> --- a/include/linux/swiotlb.h
> +++ b/include/linux/swiotlb.h
> @@ -11,6 +11,7 @@ struct page;
>   struct scatterlist;
>
>   extern int swiotlb_force;
> +extern int swiotlb_enabled;
>
>   /*
>    * Maximum allowable number of contiguous slabs to map,
> diff --git a/lib/swiotlb.c b/lib/swiotlb.c
> index 76f29ec..e89296a 100644
> --- a/lib/swiotlb.c
> +++ b/lib/swiotlb.c
> @@ -54,6 +54,7 @@
>   #define IO_TLB_MIN_SLABS ((1<<20) >> IO_TLB_SHIFT)
>
>   int swiotlb_force;
> +int swiotlb_enabled;
>
>   /*
>    * Used to do a quick range check in swiotlb_tbl_unmap_single and
> @@ -96,6 +97,9 @@ static DEFINE_SPINLOCK(io_tlb_lock);
>
>   static int late_alloc;
>
> +unsigned long swiotlb_sz;
> +unsigned int swiotlb_sz_shift;
> +
>   static int __init
>   setup_io_tlb_npages(char *str)
>   {
> @@ -112,6 +116,24 @@ setup_io_tlb_npages(char *str)
>   	return 0;
>   }
>   early_param("swiotlb", setup_io_tlb_npages);
> +
> +static int __init
> +setup_io_tlb_size(char *str)
> +{
> +	int len = strlen(str);
> +
> +	if (str[len-1] == 'M')
> +		swiotlb_sz_shift = 20;
> +	else if (str[len-1] == 'K')
> +		swiotlb_sz_shift = 10;
> +	str[len-1] = '\0';
> +	if (isdigit(*str))
> +		swiotlb_sz = kstrtoul(str, &str, 0);
> +
> +	swiotlb_enabled = 1;
> +	return 0;
> +}
> +early_param("swiotlb_sz", setup_io_tlb_size);
>   /* make io_tlb_overflow tunable too? */
>
>   unsigned long swiotlb_nr_tbl(void)
> @@ -120,8 +142,9 @@ unsigned long swiotlb_nr_tbl(void)
>   }
>   EXPORT_SYMBOL_GPL(swiotlb_nr_tbl);
>
> -/* default to 64MB */
> -#define IO_TLB_DEFAULT_SIZE (64UL<<20)
> +/* Pass from command line as swiotlb_sz=64M (for eg.)*/
> +#define IO_TLB_DEFAULT_SIZE (swiotlb_sz<<swiotlb_sz_shift)
> +
>   unsigned long swiotlb_size_or_default(void)
>   {
>   	unsigned long size;
> @@ -153,10 +176,12 @@ void swiotlb_print_info(void)
>   	vstart = phys_to_virt(io_tlb_start);
>   	vend = phys_to_virt(io_tlb_end);
>
> -	printk(KERN_INFO "software IO TLB [mem %#010llx-%#010llx] (%luMB) mapped at [%p-%p]\n",
> +	pr_info("software IO TLB [mem %#010llx-%#010llx] (%lu%cB) mapped at [%p-%p]\n",
>   	       (unsigned long long)io_tlb_start,
>   	       (unsigned long long)io_tlb_end,
> -	       bytes >> 20, vstart, vend - 1);
> +		bytes >> swiotlb_sz_shift,
> +		swiotlb_sz_shift == 20 ? 'M' : 'K',
> +		vstart, vend - 1);
>   }
>
>   int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)
>

  reply	other threads:[~2016-06-23 12:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-23 12:13 [PATCH] arm64:swiotlb:Enable only when Input size through command line Manjeet Pawar
2016-06-23 12:31 ` Robin Murphy [this message]
2016-06-23 14:30 ` Catalin Marinas
2016-06-23 16:06   ` Konrad Rzeszutek Wilk
2016-06-24  2:57     ` Jisheng Zhang
2016-06-24 10:46       ` Konrad Rzeszutek Wilk
2016-06-24 10:53         ` Robin Murphy
2016-06-23 14:38 ` kbuild test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=576BD69D.2090107@arm.com \
    --to=robin.murphy@arm.com \
    --cc=ajeet.y@samsung.com \
    --cc=akhilesh.k@samsung.com \
    --cc=catalin.marinas@arm.com \
    --cc=corbet@lwn.net \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manjeet.p@samsung.com \
    --cc=pankaj.m@samsung.com \
    --cc=r.thapliyal@samsung.com \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox