From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751583AbbHENXL (ORCPT ); Wed, 5 Aug 2015 09:23:11 -0400 Received: from mail-ig0-f181.google.com ([209.85.213.181]:33205 "EHLO mail-ig0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750829AbbHENXJ (ORCPT ); Wed, 5 Aug 2015 09:23:09 -0400 Message-ID: <55C20E3B.5040102@linaro.org> Date: Wed, 05 Aug 2015 08:23:07 -0500 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-Version: 1.0 To: check.kernel@gmail.com, Anton Vorontsov , Colin Cross , Kees Cook , Tony Luck , Andrew Morton , Petr Mladek , "Luis R. Rodriguez" , Peter Hurley , Joe Perches , Tejun Heo , Ethan du , Linghua Gu CC: linux-kernel@vger.kernel.org, yangdongdong Subject: Re: [PATCH] fs/pstore: provide panic data even in suspend References: <1438780270-12024-1-git-send-email-check.kernel@gmail.com> In-Reply-To: <1438780270-12024-1-git-send-email-check.kernel@gmail.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/05/2015 08:11 AM, check.kernel@gmail.com wrote: > From: yangdongdong > > This also enables panic and oops messages which > in suspend context to be logged into ramoops console > buffer where it can be read back at some later point. > > Signed-off-by: yangdongdong > Signed-off-by: gulinghua I have a small comment on the code below. -Alex > --- > fs/pstore/ram.c | 21 +++++++++++++++++++++ > include/linux/pstore_ram.h | 1 + > kernel/printk/printk.c | 6 ++++++ > 3 files changed, 28 insertions(+) > > diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c > index 6c26c4d..f84c5ab 100644 > --- a/fs/pstore/ram.c > +++ b/fs/pstore/ram.c > @@ -642,8 +642,28 @@ static void ramoops_register_dummy(void) > } > } > > +static int ramoops_console_notify(struct notifier_block *this, > + unsigned long event, void *ptr) > +{ > + pr_emerg("ramoops unlock console ...\n"); > + emergency_unlock_console(); > + > + return 0; > +} > + > +static struct notifier_block ramoop_nb = { > + .notifier_call = ramoops_console_notify, > + .priority = INT_MAX, > +}; > + > +static void ramoops_prepare(void) > +{ > + atomic_notifier_chain_register(&panic_notifier_list, &ramoop_nb); > +} > + > static int __init ramoops_init(void) > { > + ramoops_prepare(); > ramoops_register_dummy(); > return platform_driver_register(&ramoops_driver); > } > @@ -654,6 +674,7 @@ static void __exit ramoops_exit(void) > platform_driver_unregister(&ramoops_driver); > platform_device_unregister(dummy); > kfree(dummy_data); > + atomic_notifier_chain_unregister(&panic_notifier_list, &ramoop_nb); I would say either wrap this atomic_notificer_chain_unregister() call in a trivial function ramoops_unprepare(), or (preferably) get rid of ramoops_prepare(). > } > module_exit(ramoops_exit); > > diff --git a/include/linux/pstore_ram.h b/include/linux/pstore_ram.h > index 9c9d6c1..826a35b 100644 > --- a/include/linux/pstore_ram.h > +++ b/include/linux/pstore_ram.h > @@ -52,6 +52,7 @@ struct persistent_ram_zone { > size_t old_log_size; > }; > > +extern void emergency_unlock_console(void); > struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size, > u32 sig, struct persistent_ram_ecc_info *ecc_info, > unsigned int memtype); > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c > index cf8c242..ece645c 100644 > --- a/kernel/printk/printk.c > +++ b/kernel/printk/printk.c > @@ -2107,6 +2107,12 @@ void resume_console(void) > console_unlock(); > } > > +void emergency_unlock_console(void) > +{ > + resume_console(); > +} > +EXPORT_SYMBOL(emergency_unlock_console); > + > /** > * console_cpu_notify - print deferred console messages after CPU hotplug > * @self: notifier struct >