[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20121222022113.GD3468@phenom.dumpdata.com>
Date: Fri, 21 Dec 2012 21:21:13 -0500
From: Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>
To: Yinghai Lu <yinghai@...nel.org>
Cc: Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...e.hu>,
"H. Peter Anvin" <hpa@...or.com>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org, Yinghai Lu <yinghai@...ne.org>
Subject: Re: [PATCH v6 23/27] x86: Don't panic if can not alloc buffer for
swiotlb
On Thu, Dec 13, 2012 at 02:02:17PM -0800, Yinghai Lu wrote:
> Normal boot path on system with iommu support:
> swiotlb buffer will be allocated early at first and then try to initialize
> iommu, if iommu for intel or amd could setup properly, swiotlb buffer
> will be freed.
>
> The early allocating is with bootmem, and could panic when we try to use
> kdump with buffer above 4G only.
>
> Replace the panic with WARN, and the kernel can go on without swiotlb,
> and could iommu later.
What if SWIOTLB is the only option? Meaning there are no other IOMMUs?
>
> Signed-off-by: Yinghai Lu <yinghai@...ne.org>
> ---
> arch/x86/kernel/pci-swiotlb.c | 5 ++++-
> include/linux/swiotlb.h | 2 +-
> lib/swiotlb.c | 17 +++++++++++------
> 3 files changed, 16 insertions(+), 8 deletions(-)
>
> diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
> index 6c483ba..6f93eb7 100644
> --- a/arch/x86/kernel/pci-swiotlb.c
> +++ b/arch/x86/kernel/pci-swiotlb.c
> @@ -91,7 +91,10 @@ IOMMU_INIT(pci_swiotlb_detect_4gb,
> void __init pci_swiotlb_init(void)
> {
> if (swiotlb) {
> - swiotlb_init(0);
> + if (swiotlb_init(0)) {
> + swiotlb = 0;
> + return;
> + }
> dma_ops = &swiotlb_dma_ops;
> }
> }
> diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
> index 8d08b3e..f7535d1 100644
> --- a/include/linux/swiotlb.h
> +++ b/include/linux/swiotlb.h
> @@ -22,7 +22,7 @@ extern int swiotlb_force;
> */
> #define IO_TLB_SHIFT 11
>
> -extern void swiotlb_init(int verbose);
> +int swiotlb_init(int verbose);
> extern void swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose);
> extern unsigned long swiotlb_nr_tbl(void);
> extern int swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs);
> diff --git a/lib/swiotlb.c b/lib/swiotlb.c
> index f114bf6..6b99ea7 100644
> --- a/lib/swiotlb.c
> +++ b/lib/swiotlb.c
> @@ -170,7 +170,7 @@ void __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)
> * Statically reserve bounce buffer space and initialize bounce buffer data
> * structures for the software IO TLB used to implement the DMA API.
> */
> -static void __init
> +static int __init
> swiotlb_init_with_default_size(size_t default_size, int verbose)
> {
> unsigned long bytes;
> @@ -185,17 +185,22 @@ swiotlb_init_with_default_size(size_t default_size, int verbose)
> /*
> * Get IO TLB memory from the low pages
> */
> - io_tlb_start = alloc_bootmem_low_pages(PAGE_ALIGN(bytes));
> - if (!io_tlb_start)
> - panic("Cannot allocate SWIOTLB buffer");
> + io_tlb_start = alloc_bootmem_low_pages_nopanic(PAGE_ALIGN(bytes));
> + if (!io_tlb_start) {
> + WARN(1, "Cannot allocate SWIOTLB buffer");
> + return -1;
> + }
>
> swiotlb_init_with_tbl(io_tlb_start, io_tlb_nslabs, verbose);
> +
> + return 0;
> }
>
> -void __init
> +int __init
> swiotlb_init(int verbose)
> {
> - swiotlb_init_with_default_size(64 * (1<<20), verbose); /* default to 64MB */
> + /* default to 64MB */
> + return swiotlb_init_with_default_size(64 * (1<<20), verbose);
> }
>
> /*
> --
> 1.7.10.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists