Commit 2c63abf9 authored by Mike Galbraith's avatar Mike Galbraith Committed by Greg Kroah-Hartman

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: default avatarMike Galbraith <efault@gmx.de>
Cc: Peter Teoh <htmldeveloper@gmail.com>
Cc: stable <stable@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 4d2da07b
...@@ -43,9 +43,6 @@ ...@@ -43,9 +43,6 @@
#include "rtmp_type.h" #include "rtmp_type.h"
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#if !defined(RT2860) && !defined(RT30xx)
#include <linux/kthread.h>
#endif
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -166,9 +163,7 @@ typedef int (*HARD_START_XMIT_FUNC)(struct sk_buff *skb, struct net_device *net_ ...@@ -166,9 +163,7 @@ typedef int (*HARD_START_XMIT_FUNC)(struct sk_buff *skb, struct net_device *net_
#ifndef RT30xx #ifndef RT30xx
typedef struct pid * THREAD_PID; typedef struct pid * THREAD_PID;
#ifdef RT2860
#define THREAD_PID_INIT_VALUE NULL #define THREAD_PID_INIT_VALUE NULL
#endif
#define GET_PID(_v) find_get_pid(_v) #define GET_PID(_v) find_get_pid(_v)
#define GET_PID_NUMBER(_v) pid_nr(_v) #define GET_PID_NUMBER(_v) pid_nr(_v)
#define CHECK_PID_LEGALITY(_pid) if (pid_nr(_pid) >= 0) #define CHECK_PID_LEGALITY(_pid) if (pid_nr(_pid) >= 0)
...@@ -188,12 +183,12 @@ struct os_cookie { ...@@ -188,12 +183,12 @@ struct os_cookie {
dma_addr_t pAd_pa; dma_addr_t pAd_pa;
#endif #endif
#ifdef RT2870 #ifdef RT2870
struct usb_device *pUsb_Dev; struct usb_device *pUsb_Dev;
#ifndef RT30xx #ifndef RT30xx
struct task_struct *MLMEThr_task; THREAD_PID MLMEThr_pid;
struct task_struct *RTUSBCmdThr_task; THREAD_PID RTUSBCmdThr_pid;
struct task_struct *TimerQThr_task; THREAD_PID TimerQThr_pid;
#endif #endif
#ifdef RT30xx #ifdef RT30xx
struct pid *MLMEThr_pid; struct pid *MLMEThr_pid;
......
...@@ -235,7 +235,7 @@ INT MlmeThread( ...@@ -235,7 +235,7 @@ INT MlmeThread(
DBGPRINT(RT_DEBUG_TRACE,( "<---%s\n",__func__)); DBGPRINT(RT_DEBUG_TRACE,( "<---%s\n",__func__));
#ifndef RT30xx #ifndef RT30xx
pObj->MLMEThr_task = NULL; pObj->MLMEThr_pid = THREAD_PID_INIT_VALUE;
#endif #endif
#ifdef RT30xx #ifdef RT30xx
pObj->MLMEThr_pid = NULL; pObj->MLMEThr_pid = NULL;
...@@ -348,7 +348,7 @@ INT RTUSBCmdThread( ...@@ -348,7 +348,7 @@ INT RTUSBCmdThread(
DBGPRINT(RT_DEBUG_TRACE,( "<---RTUSBCmdThread\n")); DBGPRINT(RT_DEBUG_TRACE,( "<---RTUSBCmdThread\n"));
#ifndef RT30xx #ifndef RT30xx
pObj->RTUSBCmdThr_task = NULL; pObj->RTUSBCmdThr_pid = THREAD_PID_INIT_VALUE;
#endif #endif
#ifdef RT30xx #ifdef RT30xx
pObj->RTUSBCmdThr_pid = NULL; pObj->RTUSBCmdThr_pid = NULL;
...@@ -447,7 +447,7 @@ INT TimerQThread( ...@@ -447,7 +447,7 @@ INT TimerQThread(
DBGPRINT(RT_DEBUG_TRACE,( "<---%s\n",__func__)); DBGPRINT(RT_DEBUG_TRACE,( "<---%s\n",__func__));
#ifndef RT30xx #ifndef RT30xx
pObj->TimerQThr_task = NULL; pObj->TimerQThr_pid = THREAD_PID_INIT_VALUE;
#endif #endif
#ifdef RT30xx #ifdef RT30xx
pObj->TimerQThr_pid = NULL; pObj->TimerQThr_pid = NULL;
...@@ -883,46 +883,69 @@ VOID RT28xxThreadTerminate( ...@@ -883,46 +883,69 @@ VOID RT28xxThreadTerminate(
// Terminate Threads // Terminate Threads
#ifndef RT30xx #ifndef RT30xx
BUG_ON(pObj->TimerQThr_task == NULL); CHECK_PID_LEGALITY(pObj->TimerQThr_pid)
CHECK_PID_LEGALITY(task_pid(pObj->TimerQThr_task))
{ {
POS_COOKIE pObj = (POS_COOKIE)pAd->OS_Cookie; POS_COOKIE pObj = (POS_COOKIE)pAd->OS_Cookie;
printk(KERN_DEBUG "Terminate the TimerQThr pid=%d!\n", printk("Terminate the TimerQThr_pid=%d!\n", GET_PID_NUMBER(pObj->TimerQThr_pid));
pid_nr(task_pid(pObj->TimerQThr_task)));
mb(); mb();
pAd->TimerFunc_kill = 1; pAd->TimerFunc_kill = 1;
mb(); mb();
kthread_stop(pObj->TimerQThr_task); ret = KILL_THREAD_PID(pObj->TimerQThr_pid, SIGTERM, 1);
pObj->TimerQThr_task = NULL; if (ret)
{
printk(KERN_WARNING "%s: unable to stop TimerQThread, pid=%d, ret=%d!\n",
pAd->net_dev->name, GET_PID_NUMBER(pObj->TimerQThr_pid), ret);
}
else
{
wait_for_completion(&pAd->TimerQComplete);
pObj->TimerQThr_pid = THREAD_PID_INIT_VALUE;
}
} }
BUG_ON(pObj->MLMEThr_task == NULL); CHECK_PID_LEGALITY(pObj->MLMEThr_pid)
CHECK_PID_LEGALITY(task_pid(pObj->MLMEThr_task))
{ {
printk(KERN_DEBUG "Terminate the MLMEThr pid=%d!\n", printk("Terminate the MLMEThr_pid=%d!\n", GET_PID_NUMBER(pObj->MLMEThr_pid));
pid_nr(task_pid(pObj->MLMEThr_task)));
mb(); mb();
pAd->mlme_kill = 1; pAd->mlme_kill = 1;
//RT28XX_MLME_HANDLER(pAd); //RT28XX_MLME_HANDLER(pAd);
mb(); mb();
kthread_stop(pObj->MLMEThr_task); ret = KILL_THREAD_PID(pObj->MLMEThr_pid, SIGTERM, 1);
pObj->MLMEThr_task = NULL; if (ret)
{
printk (KERN_WARNING "%s: unable to Mlme thread, pid=%d, ret=%d!\n",
pAd->net_dev->name, GET_PID_NUMBER(pObj->MLMEThr_pid), ret);
}
else
{
//wait_for_completion (&pAd->notify);
wait_for_completion (&pAd->mlmeComplete);
pObj->MLMEThr_pid = THREAD_PID_INIT_VALUE;
}
} }
BUG_ON(pObj->RTUSBCmdThr_task == NULL); CHECK_PID_LEGALITY(pObj->RTUSBCmdThr_pid)
CHECK_PID_LEGALITY(task_pid(pObj->RTUSBCmdThr_task))
{ {
printk(KERN_DEBUG "Terminate the RTUSBCmdThr pid=%d!\n", printk("Terminate the RTUSBCmdThr_pid=%d!\n", GET_PID_NUMBER(pObj->RTUSBCmdThr_pid));
pid_nr(task_pid(pObj->RTUSBCmdThr_task)));
mb(); mb();
NdisAcquireSpinLock(&pAd->CmdQLock); NdisAcquireSpinLock(&pAd->CmdQLock);
pAd->CmdQ.CmdQState = RT2870_THREAD_STOPED; pAd->CmdQ.CmdQState = RT2870_THREAD_STOPED;
NdisReleaseSpinLock(&pAd->CmdQLock); NdisReleaseSpinLock(&pAd->CmdQLock);
mb(); mb();
//RTUSBCMDUp(pAd); //RTUSBCMDUp(pAd);
kthread_stop(pObj->RTUSBCmdThr_task); ret = KILL_THREAD_PID(pObj->RTUSBCmdThr_pid, SIGTERM, 1);
pObj->RTUSBCmdThr_task = NULL; if (ret)
{
printk(KERN_WARNING "%s: unable to RTUSBCmd thread, pid=%d, ret=%d!\n",
pAd->net_dev->name, GET_PID_NUMBER(pObj->RTUSBCmdThr_pid), ret);
}
else
{
//wait_for_completion (&pAd->notify);
wait_for_completion (&pAd->CmdQComplete);
pObj->RTUSBCmdThr_pid = THREAD_PID_INIT_VALUE;
}
} }
#endif #endif
#ifdef RT30xx #ifdef RT30xx
...@@ -1045,7 +1068,7 @@ BOOLEAN RT28XXChipsetCheck( ...@@ -1045,7 +1068,7 @@ BOOLEAN RT28XXChipsetCheck(
dev_p->descriptor.idProduct == rtusb_usb_id[i].idProduct) dev_p->descriptor.idProduct == rtusb_usb_id[i].idProduct)
{ {
#ifndef RT30xx #ifndef RT30xx
printk(KERN_DEBUG "rt2870: idVendor = 0x%x, idProduct = 0x%x\n", printk("rt2870: idVendor = 0x%x, idProduct = 0x%x\n",
#endif #endif
#ifdef RT30xx #ifdef RT30xx
printk("rt2870: idVendor = 0x%x, idProduct = 0x%x\n", printk("rt2870: idVendor = 0x%x, idProduct = 0x%x\n",
......
...@@ -700,8 +700,8 @@ NDIS_STATUS AdapterBlockAllocateMemory( ...@@ -700,8 +700,8 @@ NDIS_STATUS AdapterBlockAllocateMemory(
usb_dev = pObj->pUsb_Dev; usb_dev = pObj->pUsb_Dev;
#ifndef RT30xx #ifndef RT30xx
pObj->MLMEThr_task = NULL; pObj->MLMEThr_pid = THREAD_PID_INIT_VALUE;
pObj->RTUSBCmdThr_task = NULL; pObj->RTUSBCmdThr_pid = THREAD_PID_INIT_VALUE;
#endif #endif
#ifdef RT30xx #ifdef RT30xx
pObj->MLMEThr_pid = NULL; pObj->MLMEThr_pid = NULL;
...@@ -743,7 +743,7 @@ NDIS_STATUS CreateThreads( ...@@ -743,7 +743,7 @@ NDIS_STATUS CreateThreads(
PRTMP_ADAPTER pAd = net_dev->ml_priv; PRTMP_ADAPTER pAd = net_dev->ml_priv;
POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie; POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie;
#ifndef RT30xx #ifndef RT30xx
struct task_struct *tsk; pid_t pid_number = -1;
#endif #endif
#ifdef RT30xx #ifdef RT30xx
pid_t pid_number; pid_t pid_number;
...@@ -762,10 +762,10 @@ NDIS_STATUS CreateThreads( ...@@ -762,10 +762,10 @@ NDIS_STATUS CreateThreads(
// Creat MLME Thread // Creat MLME Thread
#ifndef RT30xx #ifndef RT30xx
pObj->MLMEThr_task = NULL; pObj->MLMEThr_pid= THREAD_PID_INIT_VALUE;
tsk = kthread_run(MlmeThread, pAd, "%s", pAd->net_dev->name); pid_number = kernel_thread(MlmeThread, pAd, CLONE_VM);
if (pid_number < 0)
if (IS_ERR(tsk)) { {
#endif #endif
#ifdef RT30xx #ifdef RT30xx
pObj->MLMEThr_pid = NULL; pObj->MLMEThr_pid = NULL;
...@@ -778,7 +778,7 @@ NDIS_STATUS CreateThreads( ...@@ -778,7 +778,7 @@ NDIS_STATUS CreateThreads(
} }
#ifndef RT30xx #ifndef RT30xx
pObj->MLMEThr_task = tsk; pObj->MLMEThr_pid = GET_PID(pid_number);
#endif #endif
#ifdef RT30xx #ifdef RT30xx
pObj->MLMEThr_pid = find_get_pid(pid_number); pObj->MLMEThr_pid = find_get_pid(pid_number);
...@@ -788,10 +788,9 @@ NDIS_STATUS CreateThreads( ...@@ -788,10 +788,9 @@ NDIS_STATUS CreateThreads(
// Creat Command Thread // Creat Command Thread
#ifndef RT30xx #ifndef RT30xx
pObj->RTUSBCmdThr_task = NULL; pObj->RTUSBCmdThr_pid= THREAD_PID_INIT_VALUE;
tsk = kthread_run(RTUSBCmdThread, pAd, "%s", pAd->net_dev->name); pid_number = kernel_thread(RTUSBCmdThread, pAd, CLONE_VM);
if (pid_number < 0)
if (IS_ERR(tsk) < 0)
#endif #endif
#ifdef RT30xx #ifdef RT30xx
pObj->RTUSBCmdThr_pid = NULL; pObj->RTUSBCmdThr_pid = NULL;
...@@ -804,7 +803,7 @@ NDIS_STATUS CreateThreads( ...@@ -804,7 +803,7 @@ NDIS_STATUS CreateThreads(
} }
#ifndef RT30xx #ifndef RT30xx
pObj->RTUSBCmdThr_task = tsk; pObj->RTUSBCmdThr_pid = GET_PID(pid_number);
#endif #endif
#ifdef RT30xx #ifdef RT30xx
pObj->RTUSBCmdThr_pid = find_get_pid(pid_number); pObj->RTUSBCmdThr_pid = find_get_pid(pid_number);
...@@ -812,9 +811,9 @@ NDIS_STATUS CreateThreads( ...@@ -812,9 +811,9 @@ NDIS_STATUS CreateThreads(
wait_for_completion(&(pAd->CmdQComplete)); wait_for_completion(&(pAd->CmdQComplete));
#ifndef RT30xx #ifndef RT30xx
pObj->TimerQThr_task = NULL; pObj->TimerQThr_pid= THREAD_PID_INIT_VALUE;
tsk = kthread_run(TimerQThread, pAd, "%s", pAd->net_dev->name); pid_number = kernel_thread(TimerQThread, pAd, CLONE_VM);
if (IS_ERR(tsk) < 0) if (pid_number < 0)
#endif #endif
#ifdef RT30xx #ifdef RT30xx
pObj->TimerQThr_pid = NULL; pObj->TimerQThr_pid = NULL;
...@@ -826,7 +825,7 @@ NDIS_STATUS CreateThreads( ...@@ -826,7 +825,7 @@ NDIS_STATUS CreateThreads(
return NDIS_STATUS_FAILURE; return NDIS_STATUS_FAILURE;
} }
#ifndef RT30xx #ifndef RT30xx
pObj->TimerQThr_task = tsk; pObj->TimerQThr_pid = GET_PID(pid_number);
#endif #endif
#ifdef RT30xx #ifdef RT30xx
pObj->TimerQThr_pid = find_get_pid(pid_number); pObj->TimerQThr_pid = find_get_pid(pid_number);
......
...@@ -984,8 +984,7 @@ NDIS_STATUS RTUSBEnqueueCmdFromNdis( ...@@ -984,8 +984,7 @@ NDIS_STATUS RTUSBEnqueueCmdFromNdis(
POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie; POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie;
#ifndef RT30xx #ifndef RT30xx
BUG_ON(pObj->RTUSBCmdThr_task == NULL); CHECK_PID_LEGALITY(pObj->RTUSBCmdThr_pid)
CHECK_PID_LEGALITY(task_pid(pObj->RTUSBCmdThr_task))
#endif #endif
#ifdef RT30xx #ifdef RT30xx
if (pObj->RTUSBCmdThr_pid < 0) if (pObj->RTUSBCmdThr_pid < 0)
......
...@@ -590,16 +590,14 @@ VOID RTUSBBulkRxComplete(purbb_t pUrb, struct pt_regs *pt_regs); ...@@ -590,16 +590,14 @@ VOID RTUSBBulkRxComplete(purbb_t pUrb, struct pt_regs *pt_regs);
#define RTUSBMlmeUp(pAd) \ #define RTUSBMlmeUp(pAd) \
{ \ { \
POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie; \ POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie; \
BUG_ON(pObj->MLMEThr_task == NULL); \ CHECK_PID_LEGALITY(pObj->MLMEThr_pid) \
CHECK_PID_LEGALITY(task_pid(pObj->MLMEThr_task)) \
up(&(pAd->mlme_semaphore)); \ up(&(pAd->mlme_semaphore)); \
} }
#define RTUSBCMDUp(pAd) \ #define RTUSBCMDUp(pAd) \
{ \ { \
POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie; \ POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie; \
BUG_ON(pObj->RTUSBCmdThr_task == NULL); \ CHECK_PID_LEGALITY(pObj->RTUSBCmdThr_pid) \
CHECK_PID_LEGALITY(task_pid(pObj->RTUSBCmdThr_task)) \
up(&(pAd->RTUSBCmd_semaphore)); \ up(&(pAd->RTUSBCmd_semaphore)); \
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment