From patchwork Fri Sep 10 08:35:23 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 168372 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o8A8ZYej000630 for ; Fri, 10 Sep 2010 08:35:34 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755839Ab0IJIfd (ORCPT ); Fri, 10 Sep 2010 04:35:33 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:44659 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755825Ab0IJIfb (ORCPT ); Fri, 10 Sep 2010 04:35:31 -0400 Received: by fxm16 with SMTP id 16so1545094fxm.19 for ; Fri, 10 Sep 2010 01:35:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:cc :in-reply-to:references:content-type:date:message-id:mime-version :x-mailer; bh=/hIog6U+90Nd/r0k4pluMkNWEfgnysoxJEVqO3LMhOI=; b=Q/Tv1bK2PcVMjrjtRhV/EZzBAhmqifpY3XnfoNCrp2eKe12bnQcmkRjTjs+IDtT42o yE5BtcEMy7eXg2bJICtBXGQAt15tJVsDBvYcz9uwngKHID3QLlfwDD5aH7pS/ZEIUyua 2j5wSF8gud5k89K8AXJPDLnKYAAy50r1RIVyg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:x-mailer; b=nlNUjR8rOVRqb+SEEQK7KQ6MBiS19izMaB8zP5nWlmYBcDuFKRaXYCwGuROaVoPZ5m qPtRo/hXNA2f3sdvBLC+RBB9shZLIL+3Rr8wEn8B7i76ZwJJXQ+oA8EAXGiHA0/3ZWBr bTyVbBqlVrifSTlXiTR/X7SWaJo4kdICwyAsY= Received: by 10.223.104.13 with SMTP id m13mr181404fao.25.1284107729667; Fri, 10 Sep 2010 01:35:29 -0700 (PDT) Received: from [10.0.0.2] (87.68.43.69.cable.012.net.il [87.68.43.69]) by mx.google.com with ESMTPS id f28sm1211842faa.0.2010.09.10.01.35.26 (version=SSLv3 cipher=RC4-MD5); Fri, 10 Sep 2010 01:35:27 -0700 (PDT) Subject: Re: [PATCH 0/8 V5] Many fixes for in-kernel decoding and for the ENE driver From: Maxim Levitsky To: Jarod Wilson Cc: Jarod Wilson , Mauro Carvalho Chehab , lirc-list@lists.sourceforge.net, David =?ISO-8859-1?Q?H=E4rdeman?= , linux-input@vger.kernel.org, linux-media@vger.kernel.org In-Reply-To: <20100910020129.GA26845@redhat.com> References: <1283808373-27876-1-git-send-email-maximlevitsky@gmail.com> <4C8805FA.3060102@infradead.org> <20100908224227.GL22323@redhat.com> <20100910020129.GA26845@redhat.com> Date: Fri, 10 Sep 2010 11:35:23 +0300 Message-ID: <1284107723.3498.21.camel@maxim-laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 10 Sep 2010 08:35:35 +0000 (UTC) commit 8f1c423046c22dad6aaeca04bfcb0ab301843c36 Author: Maxim Levitsky Date: Sat Jul 31 13:43:03 2010 +0300 printk: Allow to fix the physical address of printk buffer Allows to put printk buffer at fixed location of ram (default 128M). If debugfs is enabled, log of last boot is copied into system ram, and can be accessed via debugfs, for example cat /sys/kernel/debug/printk/crash_dmesg Signed-off-by: Maxim Levitsky diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h index ef292c7..a6eaf40 100644 --- a/arch/x86/include/asm/setup.h +++ b/arch/x86/include/asm/setup.h @@ -46,6 +46,7 @@ extern unsigned long saved_video_mode; extern void reserve_standard_io_resources(void); extern void i386_reserve_resources(void); extern void setup_default_timer_irq(void); +extern void early_reserve_printk_buffer(void); #ifdef CONFIG_X86_MRST extern void x86_mrst_early_setup(void); diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index c3a4fbb..6fbf2a0 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -843,6 +843,7 @@ void __init setup_arch(char **cmdline_p) /* after early param, so could get panic from serial */ reserve_early_setup_data(); + early_reserve_printk_buffer(); if (acpi_mps_check()) { #ifdef CONFIG_X86_LOCAL_APIC diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c index 3ba6e06..8854a91 100644 --- a/arch/x86/mm/ioremap.c +++ b/arch/x86/mm/ioremap.c @@ -106,7 +106,6 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr, if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn))) return NULL; - WARN_ON_ONCE(is_ram); } /* diff --git a/kernel/printk.c b/kernel/printk.c index 8fe465a..a6fff63 100644 --- a/kernel/printk.c +++ b/kernel/printk.c @@ -41,6 +41,7 @@ #include #include +#include /* * for_each_console() allows you to iterate on each console @@ -167,6 +168,7 @@ void log_buf_kexec_setup(void) } #endif +#ifndef CONFIG_HWMEM_PRINTK static int __init log_buf_len_setup(char *str) { unsigned size = memparse(str, &str); @@ -207,6 +209,93 @@ out: } __setup("log_buf_len=", log_buf_len_setup); +#endif + +#ifdef CONFIG_HWMEM_PRINTK + +char *old_log_buf; +struct debugfs_blob_wrapper crash_dmesg_wrapper; +static unsigned int printk_phys_address = CONFIG_HWMEM_PRINTK_DEFAULT_ADDRESS; + + +static int __init printk_address_setup(char *p) +{ + char *tmp; + + if (!strncmp(p, "off", 3)) + printk_phys_address = 0; + else + printk_phys_address = memparse(p, &tmp); + return 0; +} +early_param("printk_address", printk_address_setup); + + +void early_reserve_printk_buffer(void) +{ + if (printk_phys_address) + reserve_early(printk_phys_address, + printk_phys_address + __LOG_BUF_LEN, "printk buffer"); +} + +static int printk_move_to_fixed_address(void) +{ + + char *mem_address; + unsigned long flags; + struct dentry *dbgfs_dir; + + if (!printk_phys_address) + return 0; + + mem_address = ioremap(printk_phys_address, __LOG_BUF_LEN); + + if (!mem_address) { + printk(KERN_ALERT "Can't map hardware kernel log memory." + "printk buffer disabled\n"); + return 0; + } + + printk(KERN_INFO "Logging kernel messages into HW memory at 0x%08x\n", + printk_phys_address); + + /* allocate saved log buffer, and save the log memory that we + will otherwise overwrite */ + old_log_buf = kmalloc(__LOG_BUF_LEN, GFP_KERNEL); + if (old_log_buf) + memcpy(old_log_buf, mem_address, __LOG_BUF_LEN); + + + /* copy current log to the new memory */ + memcpy(mem_address, log_buf, __LOG_BUF_LEN); + + /* save the log memory, and publish it */ + if (old_log_buf) { + + crash_dmesg_wrapper.data = old_log_buf; + crash_dmesg_wrapper.size = __LOG_BUF_LEN; + + dbgfs_dir = debugfs_create_dir("printk", NULL); + + if (dbgfs_dir > 0) + debugfs_create_blob("crash_dmesg", S_IRUSR, dbgfs_dir, + &crash_dmesg_wrapper); + } + + + + /* switch to the full log memory now */ + spin_lock_irqsave(&logbuf_lock, flags); + log_buf = mem_address; + spin_unlock_irqrestore(&logbuf_lock, flags); + + return 1; +} +postcore_initcall(printk_move_to_fixed_address); + +#else +void early_reserve_printk_buffer(void) {} +#endif #ifdef CONFIG_BOOT_PRINTK_DELAY diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 1b4afd2..1f12584 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -788,6 +788,35 @@ config BOOT_PRINTK_DELAY BOOT_PRINTK_DELAY also may cause DETECT_SOFTLOCKUP to detect what it believes to be lockup conditions. +config HWMEM_PRINTK + bool "Log printk message buffer into fixed physical address (DANGEROUS)" + depends on DEBUG_KERNEL && PRINTK + help + This option allows to place kernel log buffer into pre-defined + area, somewhere in memory space. + + This creates some sort of black box recorder and can be very useful + to debug several problems, especially 'panics' that happen while you + use the X window system. + + + If you also select debugfs support, you can easily look at + kernel log of failed boot at: + /sys/kernel/debug/printk/crash_dmesg + + (Assuming you mounted debugfs on /sys/kernel/debug) + + Misuse of this option can be DANGEROUS, as it makes kernel write at + arbitary (selected by you) hardware memory range. + + It is only intended for debbuging, so say 'no' if not sure + +config HWMEM_PRINTK_DEFAULT_ADDRESS + hex + depends on HWMEM_PRINTK + prompt "Default address at which store the printk buffer (default 60M)" + default "0x3C00000" + config RCU_TORTURE_TEST tristate "torture tests for RCU" depends on DEBUG_KERNEL