diff options
author | Mike Galbraith <efault@gmx.de> | 2009-07-31 01:14:04 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-08-07 19:12:02 -0400 |
commit | 2c63abf9e8a51dec886da482dfd8ae752581a61c (patch) | |
tree | 05bb3f69ae9cfe205e5f30353237e8089736c3b9 | |
parent | 4d2da07bc876fc5bc455e0721df388a3db7e4ba5 (diff) |
Staging: rt2870: Revert d44ca7 Removal of kernel_thread() API
Staging: rt2870: Revert d44ca7 Removal of kernel_thread() API
The sanity check this patch introduced triggers on shutdown, apparently due to
threads having already exited by the time BUG_ON() is reached.
Signed-off-by: Mike Galbraith <efault@gmx.de>
Cc: Peter Teoh <htmldeveloper@gmail.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/staging/rt2860/rt_linux.h | 13 | ||||
-rw-r--r-- | drivers/staging/rt2870/2870_main_dev.c | 67 | ||||
-rw-r--r-- | drivers/staging/rt2870/common/2870_rtmp_init.c | 33 | ||||
-rw-r--r-- | drivers/staging/rt2870/common/rtusb_io.c | 3 | ||||
-rw-r--r-- | drivers/staging/rt2870/rt2870.h | 6 |
5 files changed, 68 insertions, 54 deletions
diff --git a/drivers/staging/rt2860/rt_linux.h b/drivers/staging/rt2860/rt_linux.h index 85175c182432..25b53ac3f820 100644 --- a/drivers/staging/rt2860/rt_linux.h +++ b/drivers/staging/rt2860/rt_linux.h | |||
@@ -43,9 +43,6 @@ | |||
43 | #include "rtmp_type.h" | 43 | #include "rtmp_type.h" |
44 | #include <linux/module.h> | 44 | #include <linux/module.h> |
45 | #include <linux/kernel.h> | 45 | #include <linux/kernel.h> |
46 | #if !defined(RT2860) && !defined(RT30xx) | ||
47 | #include <linux/kthread.h> | ||
48 | #endif | ||
49 | 46 | ||
50 | #include <linux/spinlock.h> | 47 | #include <linux/spinlock.h> |
51 | #include <linux/init.h> | 48 | #include <linux/init.h> |
@@ -166,9 +163,7 @@ typedef int (*HARD_START_XMIT_FUNC)(struct sk_buff *skb, struct net_device *net_ | |||
166 | 163 | ||
167 | #ifndef RT30xx | 164 | #ifndef RT30xx |
168 | typedef struct pid * THREAD_PID; | 165 | typedef struct pid * THREAD_PID; |
169 | #ifdef RT2860 | ||
170 | #define THREAD_PID_INIT_VALUE NULL | 166 | #define THREAD_PID_INIT_VALUE NULL |
171 | #endif | ||
172 | #define GET_PID(_v) find_get_pid(_v) | 167 | #define GET_PID(_v) find_get_pid(_v) |
173 | #define GET_PID_NUMBER(_v) pid_nr(_v) | 168 | #define GET_PID_NUMBER(_v) pid_nr(_v) |
174 | #define CHECK_PID_LEGALITY(_pid) if (pid_nr(_pid) >= 0) | 169 | #define CHECK_PID_LEGALITY(_pid) if (pid_nr(_pid) >= 0) |
@@ -188,12 +183,12 @@ struct os_cookie { | |||
188 | dma_addr_t pAd_pa; | 183 | dma_addr_t pAd_pa; |
189 | #endif | 184 | #endif |
190 | #ifdef RT2870 | 185 | #ifdef RT2870 |
191 | struct usb_device *pUsb_Dev; | 186 | struct usb_device *pUsb_Dev; |
192 | 187 | ||
193 | #ifndef RT30xx | 188 | #ifndef RT30xx |
194 | struct task_struct *MLMEThr_task; | 189 | THREAD_PID MLMEThr_pid; |
195 | struct task_struct *RTUSBCmdThr_task; | 190 | THREAD_PID RTUSBCmdThr_pid; |
196 | struct task_struct *TimerQThr_task; | 191 | THREAD_PID TimerQThr_pid; |
197 | #endif | 192 | #endif |
198 | #ifdef RT30xx | 193 | #ifdef RT30xx |
199 | struct pid *MLMEThr_pid; | 194 | struct pid *MLMEThr_pid; |
diff --git a/drivers/staging/rt2870/2870_main_dev.c b/drivers/staging/rt2870/2870_main_dev.c index dd01c64fbf61..a4e8696ca39c 100644 --- a/drivers/staging/rt2870/2870_main_dev.c +++ b/drivers/staging/rt2870/2870_main_dev.c | |||
@@ -235,7 +235,7 @@ INT MlmeThread( | |||
235 | DBGPRINT(RT_DEBUG_TRACE,( "<---%s\n",__func__)); | 235 | DBGPRINT(RT_DEBUG_TRACE,( "<---%s\n",__func__)); |
236 | 236 | ||
237 | #ifndef RT30xx | 237 | #ifndef RT30xx |
238 | pObj->MLMEThr_task = NULL; | 238 | pObj->MLMEThr_pid = THREAD_PID_INIT_VALUE; |
239 | #endif | 239 | #endif |
240 | #ifdef RT30xx | 240 | #ifdef RT30xx |
241 | pObj->MLMEThr_pid = NULL; | 241 | pObj->MLMEThr_pid = NULL; |
@@ -348,7 +348,7 @@ INT RTUSBCmdThread( | |||
348 | DBGPRINT(RT_DEBUG_TRACE,( "<---RTUSBCmdThread\n")); | 348 | DBGPRINT(RT_DEBUG_TRACE,( "<---RTUSBCmdThread\n")); |
349 | 349 | ||
350 | #ifndef RT30xx | 350 | #ifndef RT30xx |
351 | pObj->RTUSBCmdThr_task = NULL; | 351 | pObj->RTUSBCmdThr_pid = THREAD_PID_INIT_VALUE; |
352 | #endif | 352 | #endif |
353 | #ifdef RT30xx | 353 | #ifdef RT30xx |
354 | pObj->RTUSBCmdThr_pid = NULL; | 354 | pObj->RTUSBCmdThr_pid = NULL; |
@@ -447,7 +447,7 @@ INT TimerQThread( | |||
447 | DBGPRINT(RT_DEBUG_TRACE,( "<---%s\n",__func__)); | 447 | DBGPRINT(RT_DEBUG_TRACE,( "<---%s\n",__func__)); |
448 | 448 | ||
449 | #ifndef RT30xx | 449 | #ifndef RT30xx |
450 | pObj->TimerQThr_task = NULL; | 450 | pObj->TimerQThr_pid = THREAD_PID_INIT_VALUE; |
451 | #endif | 451 | #endif |
452 | #ifdef RT30xx | 452 | #ifdef RT30xx |
453 | pObj->TimerQThr_pid = NULL; | 453 | pObj->TimerQThr_pid = NULL; |
@@ -883,46 +883,69 @@ VOID RT28xxThreadTerminate( | |||
883 | 883 | ||
884 | // Terminate Threads | 884 | // Terminate Threads |
885 | #ifndef RT30xx | 885 | #ifndef RT30xx |
886 | BUG_ON(pObj->TimerQThr_task == NULL); | 886 | CHECK_PID_LEGALITY(pObj->TimerQThr_pid) |
887 | CHECK_PID_LEGALITY(task_pid(pObj->TimerQThr_task)) | ||
888 | { | 887 | { |
889 | POS_COOKIE pObj = (POS_COOKIE)pAd->OS_Cookie; | 888 | POS_COOKIE pObj = (POS_COOKIE)pAd->OS_Cookie; |
890 | 889 | ||
891 | printk(KERN_DEBUG "Terminate the TimerQThr pid=%d!\n", | 890 | printk("Terminate the TimerQThr_pid=%d!\n", GET_PID_NUMBER(pObj->TimerQThr_pid)); |
892 | pid_nr(task_pid(pObj->TimerQThr_task))); | ||
893 | mb(); | 891 | mb(); |
894 | pAd->TimerFunc_kill = 1; | 892 | pAd->TimerFunc_kill = 1; |
895 | mb(); | 893 | mb(); |
896 | kthread_stop(pObj->TimerQThr_task); | 894 | ret = KILL_THREAD_PID(pObj->TimerQThr_pid, SIGTERM, 1); |
897 | pObj->TimerQThr_task = NULL; | 895 | if (ret) |
896 | { | ||
897 | printk(KERN_WARNING "%s: unable to stop TimerQThread, pid=%d, ret=%d!\n", | ||
898 | pAd->net_dev->name, GET_PID_NUMBER(pObj->TimerQThr_pid), ret); | ||
899 | } | ||
900 | else | ||
901 | { | ||
902 | wait_for_completion(&pAd->TimerQComplete); | ||
903 | pObj->TimerQThr_pid = THREAD_PID_INIT_VALUE; | ||
904 | } | ||
898 | } | 905 | } |
899 | 906 | ||
900 | BUG_ON(pObj->MLMEThr_task == NULL); | 907 | CHECK_PID_LEGALITY(pObj->MLMEThr_pid) |
901 | CHECK_PID_LEGALITY(task_pid(pObj->MLMEThr_task)) | ||
902 | { | 908 | { |
903 | printk(KERN_DEBUG "Terminate the MLMEThr pid=%d!\n", | 909 | printk("Terminate the MLMEThr_pid=%d!\n", GET_PID_NUMBER(pObj->MLMEThr_pid)); |
904 | pid_nr(task_pid(pObj->MLMEThr_task))); | ||
905 | mb(); | 910 | mb(); |
906 | pAd->mlme_kill = 1; | 911 | pAd->mlme_kill = 1; |
907 | //RT28XX_MLME_HANDLER(pAd); | 912 | //RT28XX_MLME_HANDLER(pAd); |
908 | mb(); | 913 | mb(); |
909 | kthread_stop(pObj->MLMEThr_task); | 914 | ret = KILL_THREAD_PID(pObj->MLMEThr_pid, SIGTERM, 1); |
910 | pObj->MLMEThr_task = NULL; | 915 | if (ret) |
916 | { | ||
917 | printk (KERN_WARNING "%s: unable to Mlme thread, pid=%d, ret=%d!\n", | ||
918 | pAd->net_dev->name, GET_PID_NUMBER(pObj->MLMEThr_pid), ret); | ||
919 | } | ||
920 | else | ||
921 | { | ||
922 | //wait_for_completion (&pAd->notify); | ||
923 | wait_for_completion (&pAd->mlmeComplete); | ||
924 | pObj->MLMEThr_pid = THREAD_PID_INIT_VALUE; | ||
925 | } | ||
911 | } | 926 | } |
912 | 927 | ||
913 | BUG_ON(pObj->RTUSBCmdThr_task == NULL); | 928 | CHECK_PID_LEGALITY(pObj->RTUSBCmdThr_pid) |
914 | CHECK_PID_LEGALITY(task_pid(pObj->RTUSBCmdThr_task)) | ||
915 | { | 929 | { |
916 | printk(KERN_DEBUG "Terminate the RTUSBCmdThr pid=%d!\n", | 930 | printk("Terminate the RTUSBCmdThr_pid=%d!\n", GET_PID_NUMBER(pObj->RTUSBCmdThr_pid)); |
917 | pid_nr(task_pid(pObj->RTUSBCmdThr_task))); | ||
918 | mb(); | 931 | mb(); |
919 | NdisAcquireSpinLock(&pAd->CmdQLock); | 932 | NdisAcquireSpinLock(&pAd->CmdQLock); |
920 | pAd->CmdQ.CmdQState = RT2870_THREAD_STOPED; | 933 | pAd->CmdQ.CmdQState = RT2870_THREAD_STOPED; |
921 | NdisReleaseSpinLock(&pAd->CmdQLock); | 934 | NdisReleaseSpinLock(&pAd->CmdQLock); |
922 | mb(); | 935 | mb(); |
923 | //RTUSBCMDUp(pAd); | 936 | //RTUSBCMDUp(pAd); |
924 | kthread_stop(pObj->RTUSBCmdThr_task); | 937 | ret = KILL_THREAD_PID(pObj->RTUSBCmdThr_pid, SIGTERM, 1); |
925 | pObj->RTUSBCmdThr_task = NULL; | 938 | if (ret) |
939 | { | ||
940 | printk(KERN_WARNING "%s: unable to RTUSBCmd thread, pid=%d, ret=%d!\n", | ||
941 | pAd->net_dev->name, GET_PID_NUMBER(pObj->RTUSBCmdThr_pid), ret); | ||
942 | } | ||
943 | else | ||
944 | { | ||
945 | //wait_for_completion (&pAd->notify); | ||
946 | wait_for_completion (&pAd->CmdQComplete); | ||
947 | pObj->RTUSBCmdThr_pid = THREAD_PID_INIT_VALUE; | ||
948 | } | ||
926 | } | 949 | } |
927 | #endif | 950 | #endif |
928 | #ifdef RT30xx | 951 | #ifdef RT30xx |
@@ -1045,7 +1068,7 @@ BOOLEAN RT28XXChipsetCheck( | |||
1045 | dev_p->descriptor.idProduct == rtusb_usb_id[i].idProduct) | 1068 | dev_p->descriptor.idProduct == rtusb_usb_id[i].idProduct) |
1046 | { | 1069 | { |
1047 | #ifndef RT30xx | 1070 | #ifndef RT30xx |
1048 | printk(KERN_DEBUG "rt2870: idVendor = 0x%x, idProduct = 0x%x\n", | 1071 | printk("rt2870: idVendor = 0x%x, idProduct = 0x%x\n", |
1049 | #endif | 1072 | #endif |
1050 | #ifdef RT30xx | 1073 | #ifdef RT30xx |
1051 | printk("rt2870: idVendor = 0x%x, idProduct = 0x%x\n", | 1074 | printk("rt2870: idVendor = 0x%x, idProduct = 0x%x\n", |
diff --git a/drivers/staging/rt2870/common/2870_rtmp_init.c b/drivers/staging/rt2870/common/2870_rtmp_init.c index 0f4c8af97e47..80909e9ab5ae 100644 --- a/drivers/staging/rt2870/common/2870_rtmp_init.c +++ b/drivers/staging/rt2870/common/2870_rtmp_init.c | |||
@@ -700,8 +700,8 @@ NDIS_STATUS AdapterBlockAllocateMemory( | |||
700 | usb_dev = pObj->pUsb_Dev; | 700 | usb_dev = pObj->pUsb_Dev; |
701 | 701 | ||
702 | #ifndef RT30xx | 702 | #ifndef RT30xx |
703 | pObj->MLMEThr_task = NULL; | 703 | pObj->MLMEThr_pid = THREAD_PID_INIT_VALUE; |
704 | pObj->RTUSBCmdThr_task = NULL; | 704 | pObj->RTUSBCmdThr_pid = THREAD_PID_INIT_VALUE; |
705 | #endif | 705 | #endif |
706 | #ifdef RT30xx | 706 | #ifdef RT30xx |
707 | pObj->MLMEThr_pid = NULL; | 707 | pObj->MLMEThr_pid = NULL; |
@@ -743,7 +743,7 @@ NDIS_STATUS CreateThreads( | |||
743 | PRTMP_ADAPTER pAd = net_dev->ml_priv; | 743 | PRTMP_ADAPTER pAd = net_dev->ml_priv; |
744 | POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie; | 744 | POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie; |
745 | #ifndef RT30xx | 745 | #ifndef RT30xx |
746 | struct task_struct *tsk; | 746 | pid_t pid_number = -1; |
747 | #endif | 747 | #endif |
748 | #ifdef RT30xx | 748 | #ifdef RT30xx |
749 | pid_t pid_number; | 749 | pid_t pid_number; |
@@ -762,10 +762,10 @@ NDIS_STATUS CreateThreads( | |||
762 | 762 | ||
763 | // Creat MLME Thread | 763 | // Creat MLME Thread |
764 | #ifndef RT30xx | 764 | #ifndef RT30xx |
765 | pObj->MLMEThr_task = NULL; | 765 | pObj->MLMEThr_pid= THREAD_PID_INIT_VALUE; |
766 | tsk = kthread_run(MlmeThread, pAd, "%s", pAd->net_dev->name); | 766 | pid_number = kernel_thread(MlmeThread, pAd, CLONE_VM); |
767 | 767 | if (pid_number < 0) | |
768 | if (IS_ERR(tsk)) { | 768 | { |
769 | #endif | 769 | #endif |
770 | #ifdef RT30xx | 770 | #ifdef RT30xx |
771 | pObj->MLMEThr_pid = NULL; | 771 | pObj->MLMEThr_pid = NULL; |
@@ -778,7 +778,7 @@ NDIS_STATUS CreateThreads( | |||
778 | } | 778 | } |
779 | 779 | ||
780 | #ifndef RT30xx | 780 | #ifndef RT30xx |
781 | pObj->MLMEThr_task = tsk; | 781 | pObj->MLMEThr_pid = GET_PID(pid_number); |
782 | #endif | 782 | #endif |
783 | #ifdef RT30xx | 783 | #ifdef RT30xx |
784 | pObj->MLMEThr_pid = find_get_pid(pid_number); | 784 | pObj->MLMEThr_pid = find_get_pid(pid_number); |
@@ -788,10 +788,9 @@ NDIS_STATUS CreateThreads( | |||
788 | 788 | ||
789 | // Creat Command Thread | 789 | // Creat Command Thread |
790 | #ifndef RT30xx | 790 | #ifndef RT30xx |
791 | pObj->RTUSBCmdThr_task = NULL; | 791 | pObj->RTUSBCmdThr_pid= THREAD_PID_INIT_VALUE; |
792 | tsk = kthread_run(RTUSBCmdThread, pAd, "%s", pAd->net_dev->name); | 792 | pid_number = kernel_thread(RTUSBCmdThread, pAd, CLONE_VM); |
793 | 793 | if (pid_number < 0) | |
794 | if (IS_ERR(tsk) < 0) | ||
795 | #endif | 794 | #endif |
796 | #ifdef RT30xx | 795 | #ifdef RT30xx |
797 | pObj->RTUSBCmdThr_pid = NULL; | 796 | pObj->RTUSBCmdThr_pid = NULL; |
@@ -804,7 +803,7 @@ NDIS_STATUS CreateThreads( | |||
804 | } | 803 | } |
805 | 804 | ||
806 | #ifndef RT30xx | 805 | #ifndef RT30xx |
807 | pObj->RTUSBCmdThr_task = tsk; | 806 | pObj->RTUSBCmdThr_pid = GET_PID(pid_number); |
808 | #endif | 807 | #endif |
809 | #ifdef RT30xx | 808 | #ifdef RT30xx |
810 | pObj->RTUSBCmdThr_pid = find_get_pid(pid_number); | 809 | pObj->RTUSBCmdThr_pid = find_get_pid(pid_number); |
@@ -812,9 +811,9 @@ NDIS_STATUS CreateThreads( | |||
812 | wait_for_completion(&(pAd->CmdQComplete)); | 811 | wait_for_completion(&(pAd->CmdQComplete)); |
813 | 812 | ||
814 | #ifndef RT30xx | 813 | #ifndef RT30xx |
815 | pObj->TimerQThr_task = NULL; | 814 | pObj->TimerQThr_pid= THREAD_PID_INIT_VALUE; |
816 | tsk = kthread_run(TimerQThread, pAd, "%s", pAd->net_dev->name); | 815 | pid_number = kernel_thread(TimerQThread, pAd, CLONE_VM); |
817 | if (IS_ERR(tsk) < 0) | 816 | if (pid_number < 0) |
818 | #endif | 817 | #endif |
819 | #ifdef RT30xx | 818 | #ifdef RT30xx |
820 | pObj->TimerQThr_pid = NULL; | 819 | pObj->TimerQThr_pid = NULL; |
@@ -826,7 +825,7 @@ NDIS_STATUS CreateThreads( | |||
826 | return NDIS_STATUS_FAILURE; | 825 | return NDIS_STATUS_FAILURE; |
827 | } | 826 | } |
828 | #ifndef RT30xx | 827 | #ifndef RT30xx |
829 | pObj->TimerQThr_task = tsk; | 828 | pObj->TimerQThr_pid = GET_PID(pid_number); |
830 | #endif | 829 | #endif |
831 | #ifdef RT30xx | 830 | #ifdef RT30xx |
832 | pObj->TimerQThr_pid = find_get_pid(pid_number); | 831 | pObj->TimerQThr_pid = find_get_pid(pid_number); |
diff --git a/drivers/staging/rt2870/common/rtusb_io.c b/drivers/staging/rt2870/common/rtusb_io.c index fd1b0c18f2a0..704b5c2d5091 100644 --- a/drivers/staging/rt2870/common/rtusb_io.c +++ b/drivers/staging/rt2870/common/rtusb_io.c | |||
@@ -984,8 +984,7 @@ NDIS_STATUS RTUSBEnqueueCmdFromNdis( | |||
984 | POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie; | 984 | POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie; |
985 | 985 | ||
986 | #ifndef RT30xx | 986 | #ifndef RT30xx |
987 | BUG_ON(pObj->RTUSBCmdThr_task == NULL); | 987 | CHECK_PID_LEGALITY(pObj->RTUSBCmdThr_pid) |
988 | CHECK_PID_LEGALITY(task_pid(pObj->RTUSBCmdThr_task)) | ||
989 | #endif | 988 | #endif |
990 | #ifdef RT30xx | 989 | #ifdef RT30xx |
991 | if (pObj->RTUSBCmdThr_pid < 0) | 990 | if (pObj->RTUSBCmdThr_pid < 0) |
diff --git a/drivers/staging/rt2870/rt2870.h b/drivers/staging/rt2870/rt2870.h index 10e1640d61e5..2b8872b2fd9d 100644 --- a/drivers/staging/rt2870/rt2870.h +++ b/drivers/staging/rt2870/rt2870.h | |||
@@ -590,16 +590,14 @@ VOID RTUSBBulkRxComplete(purbb_t pUrb, struct pt_regs *pt_regs); | |||
590 | #define RTUSBMlmeUp(pAd) \ | 590 | #define RTUSBMlmeUp(pAd) \ |
591 | { \ | 591 | { \ |
592 | POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie; \ | 592 | POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie; \ |
593 | BUG_ON(pObj->MLMEThr_task == NULL); \ | 593 | CHECK_PID_LEGALITY(pObj->MLMEThr_pid) \ |
594 | CHECK_PID_LEGALITY(task_pid(pObj->MLMEThr_task)) \ | ||
595 | up(&(pAd->mlme_semaphore)); \ | 594 | up(&(pAd->mlme_semaphore)); \ |
596 | } | 595 | } |
597 | 596 | ||
598 | #define RTUSBCMDUp(pAd) \ | 597 | #define RTUSBCMDUp(pAd) \ |
599 | { \ | 598 | { \ |
600 | POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie; \ | 599 | POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie; \ |
601 | BUG_ON(pObj->RTUSBCmdThr_task == NULL); \ | 600 | CHECK_PID_LEGALITY(pObj->RTUSBCmdThr_pid) \ |
602 | CHECK_PID_LEGALITY(task_pid(pObj->RTUSBCmdThr_task)) \ | ||
603 | up(&(pAd->RTUSBCmd_semaphore)); \ | 601 | up(&(pAd->RTUSBCmd_semaphore)); \ |
604 | } | 602 | } |
605 | #endif | 603 | #endif |