Re: [PATCH] earlyprintk=efi,keep fix

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 30 Apr, at 10:13:03AM, Dave Young wrote:
> 
> earlyprintk=efi,keep will cause kernel hangs while freeing initmem like below:
> [    2.826089] VFS: Mounted root (ext4 filesystem) readonly on device 254:2.
> [    2.846592] devtmpfs: mounted
> [    2.856974] Freeing unused kernel memory: 880K (ffffffff817d4000 - ffffffff818b0000)
> 
> It is caused by efi earlyprintk use __init function which will be freed later.
> Such as early_efi_write is marked as __init, also it will use early_ioremap
> which is init function as well.
> 
> To fix this issue, I added one early initcall efi_ioremap_fb which will map the whole
> efi fb for later use. OTOH, adding a wrapper function efi_ioremap which will call
> early_ioremap before ioremap is available.
> 
> With this patch applied efi boot ok with earlyprintk=efi,keep console=efi
> 
> Signed-off-by: Dave Young <dyoung@xxxxxxxxxx>
> ---
>  arch/x86/platform/efi/early_printk.c |   54 +++++++++++++++++++++++++++--------
>  1 file changed, 42 insertions(+), 12 deletions(-)
 
Thanks Dave, good catch. I've got a few comments below.

> +static __init int efi_ioremap_fb(void)
> +{
> +	unsigned long base, size;
> +
> +	base = boot_params.screen_info.lfb_base;
> +	size = boot_params.screen_info.lfb_size;
> +	efi_fb = ioremap(base, size);
> +
> +	return efi_fb ? 0 : -ENOMEM;
> +}
> +early_initcall(efi_ioremap_fb);

So, here you're actually ioremap'ing the framebuffer irrespective of
whether anyone passed earlyprintk=efi,keep on the command line.
Furthermore, you'll perform the ioremap() even if some error was
encountered in early_efi_setup().

You need a way to figure out whether the ioremap() is actually needed.

Please document this function to explain why we need to ioremap() the
framebuffer from an early_initcall().

Oh and as a side note, please prefix functions in this file with
early_efi_*. Yeah, I realise that I suggested efi_ioremap() as a name -
my bad.

> +static __init_refok void *efi_ioremap(unsigned long start, unsigned long len)
> +{
> +	unsigned long base;
> +
> +	base = boot_params.screen_info.lfb_base;
> +	if (efi_fb)
> +		return (efi_fb + start - base);
> +	else
> +		return early_ioremap(start, len);
> +}

Adding .lfb_base in the caller and then subtracting here seems
needlessly complicated. Instead I'd suggest making early_efi_map() take
an offset and a length, and document when each framebuffer is used.

-- 
Matt Fleming, Intel Open Source Technology Center
--
To unsubscribe from this list: send the line "unsubscribe linux-efi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux