Re: [PATCH 0/6 v4] staging: brcm80211: remove kernel_thread()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Greg KH wrote:
On Mon, Oct 11, 2010 at 06:24:15PM -0700, Nohee Ko wrote:
I just found this change has fatal problem. Due to this change
there is no way to kill the process which is waiting for the
SIGTERM event with down_interruptible().

If you have no objection, I will revert it to kernel_thread and
send the patch. Please let me know.

How about fixing the problem and not going back to kernel_thread, as that is a depreciated interface and could go away any release now.


How does the attached patch look (RFC only)?

thx,

Jason.
>From 8c0d961a5e8afabdbff169319b43652b8b7d99bc Mon Sep 17 00:00:00 2001
Message-Id: <8c0d961a5e8afabdbff169319b43652b8b7d99bc.1286893835.git.jason@xxxxxxxxxxxxxx>
From: Jason Cooper <jason@xxxxxxxxxxxxxx>
Date: Tue, 12 Oct 2010 10:25:31 -0400
Subject: [PATCH 1/1] staging: brcm80211: remove semaphore, down_interruptible().

daemonize() should not have been removed, only extracted from DAEMONIZE()
macro, since allow_signal()'s in same macro aren't needed.

change down_interruptible() to schedule() and remove unneeded semaphore.

Signed-off-by: Jason Cooper <jason@xxxxxxxxxxxxxx>
---
 drivers/staging/brcm80211/brcmfmac/dhd_linux.c |   33 +++++++++++------------
 1 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c
index e8debe4..e4f13a4 100644
--- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c
+++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c
@@ -241,7 +241,6 @@ typedef struct dhd_info {
 	bool threads_only;
 	struct semaphore sdsem;
 	struct task_struct *watchdog_tsk;
-	struct semaphore watchdog_sem;
 	struct task_struct *dpc_tsk;
 	struct semaphore dpc_sem;
 
@@ -1286,6 +1285,8 @@ static int dhd_watchdog_thread(void *data)
 	/* This thread doesn't need any user-level access,
 	 * so get rid of all our resources
 	 */
+	daemonize("dhd_watchdog_thread");
+
 #ifdef DHD_SCHED
 	if (dhd_watchdog_prio > 0) {
 		struct sched_param param;
@@ -1296,21 +1297,20 @@ static int dhd_watchdog_thread(void *data)
 #endif				/* DHD_SCHED */
 
 	/* Run until signal received */
-	while (1) {
-		if (kthread_should_stop())
-			break;
-		if (down_interruptible(&dhd->watchdog_sem) == 0) {
-			if (dhd->pub.dongle_reset == FALSE) {
-				WAKE_LOCK(&dhd->pub, WAKE_LOCK_WATCHDOG);
-				/* Call the bus module watchdog */
-				dhd_bus_watchdog(&dhd->pub);
-				WAKE_UNLOCK(&dhd->pub, WAKE_LOCK_WATCHDOG);
-			}
-			/* Count the tick for reference */
-			dhd->pub.tickcnt++;
-		} else
-			break;
+	set_current_state(TASK_INTERRUPTIBLE);
+	while (!kthread_should_stop()) {
+		schedule();
+		set_current_state(TASK_INTERRUPTIBLE);
+		if (dhd->pub.dongle_reset == FALSE) {
+			WAKE_LOCK(&dhd->pub, WAKE_LOCK_WATCHDOG);
+			/* Call the bus module watchdog */
+			dhd_bus_watchdog(&dhd->pub);
+			WAKE_UNLOCK(&dhd->pub, WAKE_LOCK_WATCHDOG);
+		}
+		/* Count the tick for reference */
+		dhd->pub.tickcnt++;
 	}
+	set_current_state(TASK_RUNNING);
 
 	WAKE_LOCK_DESTROY(&dhd->pub, WAKE_LOCK_WATCHDOG);
 	return 0;
@@ -1321,7 +1321,7 @@ static void dhd_watchdog(unsigned long data)
 	dhd_info_t *dhd = (dhd_info_t *) data;
 
 	if (dhd->watchdog_tsk) {
-		up(&dhd->watchdog_sem);
+		wake_up_process(dhd->watchdog_tsk);
 
 		/* Reschedule the watchdog */
 		if (dhd->wd_timer_valid) {
@@ -1991,7 +1991,6 @@ dhd_pub_t *dhd_attach(osl_t *osh, struct dhd_bus *bus, uint bus_hdrlen)
 
 	if (dhd_dpc_prio >= 0) {
 		/* Initialize watchdog thread */
-		sema_init(&dhd->watchdog_sem, 0);
 		dhd->watchdog_tsk = kthread_run(dhd_watchdog_thread, dhd,
 						"dhd_watchdog");
 		if (IS_ERR(dhd->watchdog_tsk)) {
-- 
1.6.3.3

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel

[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux