aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorChristoph Lameter <christoph@lameter.com>2005-06-25 02:13:50 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-25 20:10:13 -0400
commit3e1d1d28d99dabe63c64f7f40f1ca1d646de1f73 (patch)
treed1e7c1e2e8902072042aefc3a7976b271cf76021 /drivers
parentb3e112bcc19abd8e9657dca34a87316786e096f3 (diff)
[PATCH] Cleanup patch for process freezing
1. Establish a simple API for process freezing defined in linux/include/sched.h: frozen(process) Check for frozen process freezing(process) Check if a process is being frozen freeze(process) Tell a process to freeze (go to refrigerator) thaw_process(process) Restart process frozen_process(process) Process is frozen now 2. Remove all references to PF_FREEZE and PF_FROZEN from all kernel sources except sched.h 3. Fix numerous locations where try_to_freeze is manually done by a driver 4. Remove the argument that is no longer necessary from two function calls. 5. Some whitespace cleanup 6. Clear potential race in refrigerator (provides an open window of PF_FREEZE cleared before setting PF_FROZEN, recalc_sigpending does not check PF_FROZEN). This patch does not address the problem of freeze_processes() violating the rule that a task may only modify its own flags by setting PF_FREEZE. This is not clean in an SMP environment. freeze(process) is therefore not SMP safe! Signed-off-by: Christoph Lameter <christoph@lameter.com> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/block/pktcdvd.c3
-rw-r--r--drivers/ieee1394/ieee1394_core.c4
-rw-r--r--drivers/ieee1394/nodemgr.c2
-rw-r--r--drivers/input/gameport/gameport.c2
-rw-r--r--drivers/input/serio/serio.c2
-rw-r--r--drivers/macintosh/therm_adt746x.c4
-rw-r--r--drivers/md/md.c3
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c3
-rw-r--r--drivers/media/video/msp3400.c3
-rw-r--r--drivers/media/video/video-buf-dvb.c3
-rw-r--r--drivers/net/8139too.c2
-rw-r--r--drivers/net/irda/sir_kthread.c3
-rw-r--r--drivers/net/irda/stir4200.c4
-rw-r--r--drivers/net/wireless/airo.c2
-rw-r--r--drivers/pcmcia/cs.c2
-rw-r--r--drivers/pnp/pnpbios/core.c2
-rw-r--r--drivers/usb/core/hub.c2
-rw-r--r--drivers/usb/gadget/file_storage.c3
-rw-r--r--drivers/usb/storage/usb.c4
-rw-r--r--drivers/w1/w1.c4
20 files changed, 22 insertions, 35 deletions
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 7f3d78de265c..7b838342f0a3 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -1251,8 +1251,7 @@ static int kcdrwd(void *foobar)
1251 VPRINTK("kcdrwd: wake up\n"); 1251 VPRINTK("kcdrwd: wake up\n");
1252 1252
1253 /* make swsusp happy with our thread */ 1253 /* make swsusp happy with our thread */
1254 if (current->flags & PF_FREEZE) 1254 try_to_freeze();
1255 refrigerator(PF_FREEZE);
1256 1255
1257 list_for_each_entry(pkt, &pd->cdrw.pkt_active_list, list) { 1256 list_for_each_entry(pkt, &pd->cdrw.pkt_active_list, list) {
1258 if (!pkt->sleep_time) 1257 if (!pkt->sleep_time)
diff --git a/drivers/ieee1394/ieee1394_core.c b/drivers/ieee1394/ieee1394_core.c
index 2d9a9b74e687..629070b83a33 100644
--- a/drivers/ieee1394/ieee1394_core.c
+++ b/drivers/ieee1394/ieee1394_core.c
@@ -1041,10 +1041,8 @@ static int hpsbpkt_thread(void *__hi)
1041 1041
1042 while (1) { 1042 while (1) {
1043 if (down_interruptible(&khpsbpkt_sig)) { 1043 if (down_interruptible(&khpsbpkt_sig)) {
1044 if (current->flags & PF_FREEZE) { 1044 if (try_to_freeze())
1045 refrigerator(0);
1046 continue; 1045 continue;
1047 }
1048 printk("khpsbpkt: received unexpected signal?!\n" ); 1046 printk("khpsbpkt: received unexpected signal?!\n" );
1049 break; 1047 break;
1050 } 1048 }
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
index 32abb6dda888..9a46c3b44bf8 100644
--- a/drivers/ieee1394/nodemgr.c
+++ b/drivers/ieee1394/nodemgr.c
@@ -1510,7 +1510,7 @@ static int nodemgr_host_thread(void *__hi)
1510 1510
1511 if (down_interruptible(&hi->reset_sem) || 1511 if (down_interruptible(&hi->reset_sem) ||
1512 down_interruptible(&nodemgr_serialize)) { 1512 down_interruptible(&nodemgr_serialize)) {
1513 if (try_to_freeze(PF_FREEZE)) 1513 if (try_to_freeze())
1514 continue; 1514 continue;
1515 printk("NodeMgr: received unexpected signal?!\n" ); 1515 printk("NodeMgr: received unexpected signal?!\n" );
1516 break; 1516 break;
diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
index e152d0fa0cdd..c77a82e46055 100644
--- a/drivers/input/gameport/gameport.c
+++ b/drivers/input/gameport/gameport.c
@@ -439,7 +439,7 @@ static int gameport_thread(void *nothing)
439 do { 439 do {
440 gameport_handle_events(); 440 gameport_handle_events();
441 wait_event_interruptible(gameport_wait, !list_empty(&gameport_event_list)); 441 wait_event_interruptible(gameport_wait, !list_empty(&gameport_event_list));
442 try_to_freeze(PF_FREEZE); 442 try_to_freeze();
443 } while (!signal_pending(current)); 443 } while (!signal_pending(current));
444 444
445 printk(KERN_DEBUG "gameport: kgameportd exiting\n"); 445 printk(KERN_DEBUG "gameport: kgameportd exiting\n");
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index feab4970406e..341824c48529 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -344,7 +344,7 @@ static int serio_thread(void *nothing)
344 do { 344 do {
345 serio_handle_events(); 345 serio_handle_events();
346 wait_event_interruptible(serio_wait, !list_empty(&serio_event_list)); 346 wait_event_interruptible(serio_wait, !list_empty(&serio_event_list));
347 try_to_freeze(PF_FREEZE); 347 try_to_freeze();
348 } while (!signal_pending(current)); 348 } while (!signal_pending(current));
349 349
350 printk(KERN_DEBUG "serio: kseriod exiting\n"); 350 printk(KERN_DEBUG "serio: kseriod exiting\n");
diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c
index 5ba190ce14a0..c9ca1118e449 100644
--- a/drivers/macintosh/therm_adt746x.c
+++ b/drivers/macintosh/therm_adt746x.c
@@ -328,9 +328,7 @@ static int monitor_task(void *arg)
328 struct thermostat* th = arg; 328 struct thermostat* th = arg;
329 329
330 while(!kthread_should_stop()) { 330 while(!kthread_should_stop()) {
331 if (current->flags & PF_FREEZE) 331 try_to_freeze();
332 refrigerator(PF_FREEZE);
333
334 msleep_interruptible(2000); 332 msleep_interruptible(2000);
335 333
336#ifndef DEBUG 334#ifndef DEBUG
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 0c6b5b6baff6..3802f7a17f16 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2976,8 +2976,7 @@ static int md_thread(void * arg)
2976 wait_event_interruptible_timeout(thread->wqueue, 2976 wait_event_interruptible_timeout(thread->wqueue,
2977 test_bit(THREAD_WAKEUP, &thread->flags), 2977 test_bit(THREAD_WAKEUP, &thread->flags),
2978 thread->timeout); 2978 thread->timeout);
2979 if (current->flags & PF_FREEZE) 2979 try_to_freeze();
2980 refrigerator(PF_FREEZE);
2981 2980
2982 clear_bit(THREAD_WAKEUP, &thread->flags); 2981 clear_bit(THREAD_WAKEUP, &thread->flags);
2983 2982
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index d6b7a9de471e..f11daae91cd4 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -391,8 +391,7 @@ static int dvb_frontend_thread(void *data)
391 break; 391 break;
392 } 392 }
393 393
394 if (current->flags & PF_FREEZE) 394 try_to_freeze();
395 refrigerator(PF_FREEZE);
396 395
397 if (down_interruptible(&fepriv->sem)) 396 if (down_interruptible(&fepriv->sem))
398 break; 397 break;
diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c
index 1b7d38e96f14..b4ee9dfe6d42 100644
--- a/drivers/media/video/msp3400.c
+++ b/drivers/media/video/msp3400.c
@@ -750,8 +750,7 @@ static int msp34xx_sleep(struct msp3400c *msp, int timeout)
750#endif 750#endif
751 } 751 }
752 } 752 }
753 if (current->flags & PF_FREEZE) 753 try_to_freeze();
754 refrigerator(PF_FREEZE);
755 remove_wait_queue(&msp->wq, &wait); 754 remove_wait_queue(&msp->wq, &wait);
756 return msp->restart; 755 return msp->restart;
757} 756}
diff --git a/drivers/media/video/video-buf-dvb.c b/drivers/media/video/video-buf-dvb.c
index 5f870075b55e..15f5bb486963 100644
--- a/drivers/media/video/video-buf-dvb.c
+++ b/drivers/media/video/video-buf-dvb.c
@@ -62,8 +62,7 @@ static int videobuf_dvb_thread(void *data)
62 break; 62 break;
63 if (kthread_should_stop()) 63 if (kthread_should_stop())
64 break; 64 break;
65 if (current->flags & PF_FREEZE) 65 try_to_freeze();
66 refrigerator(PF_FREEZE);
67 66
68 /* feed buffer data to demux */ 67 /* feed buffer data to demux */
69 if (buf->state == STATE_DONE) 68 if (buf->state == STATE_DONE)
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index 047202c4d9a8..5a4a08a7c951 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -1606,7 +1606,7 @@ static int rtl8139_thread (void *data)
1606 do { 1606 do {
1607 timeout = interruptible_sleep_on_timeout (&tp->thr_wait, timeout); 1607 timeout = interruptible_sleep_on_timeout (&tp->thr_wait, timeout);
1608 /* make swsusp happy with our thread */ 1608 /* make swsusp happy with our thread */
1609 try_to_freeze(PF_FREEZE); 1609 try_to_freeze();
1610 } while (!signal_pending (current) && (timeout > 0)); 1610 } while (!signal_pending (current) && (timeout > 0));
1611 1611
1612 if (signal_pending (current)) { 1612 if (signal_pending (current)) {
diff --git a/drivers/net/irda/sir_kthread.c b/drivers/net/irda/sir_kthread.c
index 18cea1099530..c65054364bca 100644
--- a/drivers/net/irda/sir_kthread.c
+++ b/drivers/net/irda/sir_kthread.c
@@ -135,8 +135,7 @@ static int irda_thread(void *startup)
135 remove_wait_queue(&irda_rq_queue.kick, &wait); 135 remove_wait_queue(&irda_rq_queue.kick, &wait);
136 136
137 /* make swsusp happy with our thread */ 137 /* make swsusp happy with our thread */
138 if (current->flags & PF_FREEZE) 138 try_to_freeze();
139 refrigerator(PF_FREEZE);
140 139
141 run_irda_queue(); 140 run_irda_queue();
142 } 141 }
diff --git a/drivers/net/irda/stir4200.c b/drivers/net/irda/stir4200.c
index 66f488c13717..15f207323d97 100644
--- a/drivers/net/irda/stir4200.c
+++ b/drivers/net/irda/stir4200.c
@@ -763,7 +763,7 @@ static int stir_transmit_thread(void *arg)
763 { 763 {
764#ifdef CONFIG_PM 764#ifdef CONFIG_PM
765 /* if suspending, then power off and wait */ 765 /* if suspending, then power off and wait */
766 if (unlikely(current->flags & PF_FREEZE)) { 766 if (unlikely(freezing(current))) {
767 if (stir->receiving) 767 if (stir->receiving)
768 receive_stop(stir); 768 receive_stop(stir);
769 else 769 else
@@ -771,7 +771,7 @@ static int stir_transmit_thread(void *arg)
771 771
772 write_reg(stir, REG_CTRL1, CTRL1_TXPWD|CTRL1_RXPWD); 772 write_reg(stir, REG_CTRL1, CTRL1_TXPWD|CTRL1_RXPWD);
773 773
774 refrigerator(PF_FREEZE); 774 refrigerator();
775 775
776 if (change_speed(stir, stir->speed)) 776 if (change_speed(stir, stir->speed))
777 break; 777 break;
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index fb10a2db63ad..d72e0385e4f2 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -2918,7 +2918,7 @@ static int airo_thread(void *data) {
2918 flush_signals(current); 2918 flush_signals(current);
2919 2919
2920 /* make swsusp happy with our thread */ 2920 /* make swsusp happy with our thread */
2921 try_to_freeze(PF_FREEZE); 2921 try_to_freeze();
2922 2922
2923 if (test_bit(JOB_DIE, &ai->flags)) 2923 if (test_bit(JOB_DIE, &ai->flags))
2924 break; 2924 break;
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index d136b3c8fac9..48e4f04530d8 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -718,7 +718,7 @@ static int pccardd(void *__skt)
718 } 718 }
719 719
720 schedule(); 720 schedule();
721 try_to_freeze(PF_FREEZE); 721 try_to_freeze();
722 722
723 if (!skt->thread) 723 if (!skt->thread)
724 break; 724 break;
diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c
index e939c93a931c..778a324028f4 100644
--- a/drivers/pnp/pnpbios/core.c
+++ b/drivers/pnp/pnpbios/core.c
@@ -182,7 +182,7 @@ static int pnp_dock_thread(void * unused)
182 msleep_interruptible(2000); 182 msleep_interruptible(2000);
183 183
184 if(signal_pending(current)) { 184 if(signal_pending(current)) {
185 if (try_to_freeze(PF_FREEZE)) 185 if (try_to_freeze())
186 continue; 186 continue;
187 break; 187 break;
188 } 188 }
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index d2d648ee8640..a8d879a85d04 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2808,7 +2808,7 @@ static int hub_thread(void *__unused)
2808 do { 2808 do {
2809 hub_events(); 2809 hub_events();
2810 wait_event_interruptible(khubd_wait, !list_empty(&hub_event_list)); 2810 wait_event_interruptible(khubd_wait, !list_empty(&hub_event_list));
2811 try_to_freeze(PF_FREEZE); 2811 try_to_freeze();
2812 } while (!signal_pending(current)); 2812 } while (!signal_pending(current));
2813 2813
2814 pr_debug ("%s: khubd exiting\n", usbcore_name); 2814 pr_debug ("%s: khubd exiting\n", usbcore_name);
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index 037a7f163822..a9be85103d23 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -1554,8 +1554,7 @@ static int sleep_thread(struct fsg_dev *fsg)
1554 rc = wait_event_interruptible(fsg->thread_wqh, 1554 rc = wait_event_interruptible(fsg->thread_wqh,
1555 fsg->thread_wakeup_needed); 1555 fsg->thread_wakeup_needed);
1556 fsg->thread_wakeup_needed = 0; 1556 fsg->thread_wakeup_needed = 0;
1557 if (current->flags & PF_FREEZE) 1557 try_to_freeze();
1558 refrigerator(PF_FREEZE);
1559 return (rc ? -EINTR : 0); 1558 return (rc ? -EINTR : 0);
1560} 1559}
1561 1560
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 35c1ca6b5a8e..77e7fc258aa2 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -847,10 +847,8 @@ retry:
847 wait_event_interruptible_timeout(us->delay_wait, 847 wait_event_interruptible_timeout(us->delay_wait,
848 test_bit(US_FLIDX_DISCONNECTING, &us->flags), 848 test_bit(US_FLIDX_DISCONNECTING, &us->flags),
849 delay_use * HZ); 849 delay_use * HZ);
850 if (current->flags & PF_FREEZE) { 850 if (try_to_freeze())
851 refrigerator(PF_FREEZE);
852 goto retry; 851 goto retry;
853 }
854 } 852 }
855 853
856 /* If the device is still connected, perform the scanning */ 854 /* If the device is still connected, perform the scanning */
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index b460927ec32a..312cf3220f12 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -646,7 +646,7 @@ static int w1_control(void *data)
646 while (!control_needs_exit || have_to_wait) { 646 while (!control_needs_exit || have_to_wait) {
647 have_to_wait = 0; 647 have_to_wait = 0;
648 648
649 try_to_freeze(PF_FREEZE); 649 try_to_freeze();
650 msleep_interruptible(w1_timeout * 1000); 650 msleep_interruptible(w1_timeout * 1000);
651 651
652 if (signal_pending(current)) 652 if (signal_pending(current))
@@ -725,7 +725,7 @@ int w1_process(void *data)
725 allow_signal(SIGTERM); 725 allow_signal(SIGTERM);
726 726
727 while (!test_bit(W1_MASTER_NEED_EXIT, &dev->flags)) { 727 while (!test_bit(W1_MASTER_NEED_EXIT, &dev->flags)) {
728 try_to_freeze(PF_FREEZE); 728 try_to_freeze();
729 msleep_interruptible(w1_timeout * 1000); 729 msleep_interruptible(w1_timeout * 1000);
730 730
731 if (signal_pending(current)) 731 if (signal_pending(current))