aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2008-01-11 08:28:04 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-01-11 14:47:43 -0500
commit8dab63761219d7bc6a7d7d3b5f0fca76af5533a5 (patch)
tree3354b2867c05507acb5618f961cdf982f98e2b41 /drivers
parentba21611c9c0031ca8388cae5e43b38c29c8b595d (diff)
ps3fb: fix deadlock on kexec()
Since the introduction of the acquire_console_sem calls in 0333d83509c7d8496c8965b5ba9bc0c98e83c259, kexecing can cause the kernel to deadlock: ps3fb_shutdown() -> unregister_framebuffer() -> fb_notifier_call_chain(FB_EVENT_FB_UNBIND) -> fbcon_fb_unbind() -> unbind_con_driver() -> bind_con_driver() [ acquires console_sem ] -> fbcon_deinit() -> fbops->fb_release(newinfo, 0) -> ps3fb_release() -> ps3fb_sync() [ acquires console_sem ] This change avoids the deadlock by moving the acquire_console_sem() out of ps3fb_sync(), and puts it into the two other callsites, leaving ps3fb_release() to call ps3fb_sync() without the console semaphore. [Geert] - Corrected call sequence above - ps3fb_release() may be called with and without console_sem held. This is an inconsistency that should be fixed at the fb level, but for now, try to acquire console_sem in ps3fb_release(). I think it's safer to let ps3fb_release() try to acquire console_sem and not refresh the screen if it fails, than to call ps3fb_sync() without holding console_sem, as ps3fb_par may be modified at the same time, causing crashes or lockups. Besides, ps3fb_release() only calls ps3fb_sync() to refresh the screen when display flipping is disabled, which is an uncommon case (except during shutdown/kexec). Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/video/ps3fb.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/video/ps3fb.c b/drivers/video/ps3fb.c
index ae07e02943d8..044a423a72cb 100644
--- a/drivers/video/ps3fb.c
+++ b/drivers/video/ps3fb.c
@@ -443,8 +443,6 @@ static int ps3fb_sync(struct fb_info *info, u32 frame)
443 u32 ddr_line_length, xdr_line_length; 443 u32 ddr_line_length, xdr_line_length;
444 u64 ddr_base, xdr_base; 444 u64 ddr_base, xdr_base;
445 445
446 acquire_console_sem();
447
448 if (frame > par->num_frames - 1) { 446 if (frame > par->num_frames - 1) {
449 dev_dbg(info->device, "%s: invalid frame number (%u)\n", 447 dev_dbg(info->device, "%s: invalid frame number (%u)\n",
450 __func__, frame); 448 __func__, frame);
@@ -464,7 +462,6 @@ static int ps3fb_sync(struct fb_info *info, u32 frame)
464 xdr_line_length); 462 xdr_line_length);
465 463
466out: 464out:
467 release_console_sem();
468 return error; 465 return error;
469} 466}
470 467
@@ -479,7 +476,10 @@ static int ps3fb_release(struct fb_info *info, int user)
479 if (atomic_dec_and_test(&ps3fb.f_count)) { 476 if (atomic_dec_and_test(&ps3fb.f_count)) {
480 if (atomic_read(&ps3fb.ext_flip)) { 477 if (atomic_read(&ps3fb.ext_flip)) {
481 atomic_set(&ps3fb.ext_flip, 0); 478 atomic_set(&ps3fb.ext_flip, 0);
482 ps3fb_sync(info, 0); /* single buffer */ 479 if (!try_acquire_console_sem()) {
480 ps3fb_sync(info, 0); /* single buffer */
481 release_console_sem();
482 }
483 } 483 }
484 } 484 }
485 return 0; 485 return 0;
@@ -865,7 +865,9 @@ static int ps3fb_ioctl(struct fb_info *info, unsigned int cmd,
865 break; 865 break;
866 866
867 dev_dbg(info->device, "PS3FB_IOCTL_FSEL:%d\n", val); 867 dev_dbg(info->device, "PS3FB_IOCTL_FSEL:%d\n", val);
868 acquire_console_sem();
868 retval = ps3fb_sync(info, val); 869 retval = ps3fb_sync(info, val);
870 release_console_sem();
869 break; 871 break;
870 872
871 default: 873 default:
@@ -885,7 +887,9 @@ static int ps3fbd(void *arg)
885 set_current_state(TASK_INTERRUPTIBLE); 887 set_current_state(TASK_INTERRUPTIBLE);
886 if (ps3fb.is_kicked) { 888 if (ps3fb.is_kicked) {
887 ps3fb.is_kicked = 0; 889 ps3fb.is_kicked = 0;
890 acquire_console_sem();
888 ps3fb_sync(info, 0); /* single buffer */ 891 ps3fb_sync(info, 0); /* single buffer */
892 release_console_sem();
889 } 893 }
890 schedule(); 894 schedule();
891 } 895 }