aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms/pseries/nvram.c
diff options
context:
space:
mode:
authorAnton Blanchard <anton@samba.org>2011-11-30 10:46:45 -0500
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2011-12-07 22:22:54 -0500
commit120a52c388fb29105fdfd3f27efc776e99f7b50e (patch)
tree428fa9916b85660cbd84d4722724c245c1bda0c3 /arch/powerpc/platforms/pseries/nvram.c
parent7cf82b1b65833f207f55bb6dea32488f558b200b (diff)
powerpc/nvram: Add spinlock to oops_to_nvram to prevent oops in compression code.
When issuing a system reset we almost always oops in the oops_to_nvram code because multiple CPUs are using the deflate work area. Add a spinlock to protect it. To play it safe I'm using trylock to avoid locking up if the NVRAM code oopses. This means we might miss multiple CPUs oopsing at exactly the same time but I think it's best to play it safe for now. Once we are happy with the reliability we can change it to a full spinlock. Signed-off-by: Anton Blanchard <anton@samba.org> Acked-by: Jim Keniston <jkenisto@us.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/platforms/pseries/nvram.c')
-rw-r--r--arch/powerpc/platforms/pseries/nvram.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/arch/powerpc/platforms/pseries/nvram.c b/arch/powerpc/platforms/pseries/nvram.c
index a76b22844d18..330a57b7c17c 100644
--- a/arch/powerpc/platforms/pseries/nvram.c
+++ b/arch/powerpc/platforms/pseries/nvram.c
@@ -625,6 +625,8 @@ static void oops_to_nvram(struct kmsg_dumper *dumper,
625{ 625{
626 static unsigned int oops_count = 0; 626 static unsigned int oops_count = 0;
627 static bool panicking = false; 627 static bool panicking = false;
628 static DEFINE_SPINLOCK(lock);
629 unsigned long flags;
628 size_t text_len; 630 size_t text_len;
629 unsigned int err_type = ERR_TYPE_KERNEL_PANIC_GZ; 631 unsigned int err_type = ERR_TYPE_KERNEL_PANIC_GZ;
630 int rc = -1; 632 int rc = -1;
@@ -655,6 +657,9 @@ static void oops_to_nvram(struct kmsg_dumper *dumper,
655 if (clobbering_unread_rtas_event()) 657 if (clobbering_unread_rtas_event())
656 return; 658 return;
657 659
660 if (!spin_trylock_irqsave(&lock, flags))
661 return;
662
658 if (big_oops_buf) { 663 if (big_oops_buf) {
659 text_len = capture_last_msgs(old_msgs, old_len, 664 text_len = capture_last_msgs(old_msgs, old_len,
660 new_msgs, new_len, big_oops_buf, big_oops_buf_sz); 665 new_msgs, new_len, big_oops_buf, big_oops_buf_sz);
@@ -670,4 +675,6 @@ static void oops_to_nvram(struct kmsg_dumper *dumper,
670 675
671 (void) nvram_write_os_partition(&oops_log_partition, oops_buf, 676 (void) nvram_write_os_partition(&oops_log_partition, oops_buf,
672 (int) (sizeof(*oops_len) + *oops_len), err_type, ++oops_count); 677 (int) (sizeof(*oops_len) + *oops_len), err_type, ++oops_count);
678
679 spin_unlock_irqrestore(&lock, flags);
673} 680}