All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] staging: unisys: kthread fixes (resubmission)
@ 2015-02-19 19:08 Benjamin Romer
  2015-02-19 19:08 ` [PATCH 1/5] unisys: replace kthread_create and wake_up_process with kthread_run Benjamin Romer
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Benjamin Romer @ 2015-02-19 19:08 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer

This set contains Devendra's patches for fixing s-Par's drivers so they use
the kthread API.

This patch set has been tested on s-Par and works correctly.

Devendra Naga (5):
  unisys: replace kthread_create and wake_up_process with kthread_run
  unisys: use simpler kthread_ API
  unisys: use kthread_should_stop in the thread
  unisys: use kthread_should_stop API in the lib thread
  unisys: remove the thread variable and API

 drivers/staging/unisys/include/uisthread.h |  1 -
 drivers/staging/unisys/uislib/uislib.c     |  4 ++--
 drivers/staging/unisys/uislib/uisthread.c  | 25 ++++++++-----------------
 drivers/staging/unisys/virthba/virthba.c   |  4 ++--
 4 files changed, 12 insertions(+), 22 deletions(-)

-- 
2.1.0

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/5] unisys: replace kthread_create and wake_up_process with kthread_run
  2015-02-19 19:08 [PATCH 0/5] staging: unisys: kthread fixes (resubmission) Benjamin Romer
@ 2015-02-19 19:08 ` Benjamin Romer
  2015-02-19 19:08 ` [PATCH 2/5] unisys: use simpler kthread_ API Benjamin Romer
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Benjamin Romer @ 2015-02-19 19:08 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer

From: Devendra Naga <devendra.aaru@gmail.com>

kthread_run calls kthread_create and if the thread is created
it then calls wake_up_process on the corresponding returned
task struct. So the code can be simplified by calling just
kthread_run.

Cc: Ken Cox <jkc@redhat.com>
Cc: Benjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/uislib/uisthread.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/uislib/uisthread.c b/drivers/staging/unisys/uislib/uisthread.c
index 25adf1a..c5c68cb 100644
--- a/drivers/staging/unisys/uislib/uisthread.c
+++ b/drivers/staging/unisys/uislib/uisthread.c
@@ -44,13 +44,12 @@ uisthread_start(struct uisthread_info *thrinfo,
 	thrinfo->should_stop = 0;
 	/* used to stop the thread */
 	init_completion(&thrinfo->has_stopped);
-	thrinfo->task = kthread_create(threadfn, thrcontext, name, NULL);
+	thrinfo->task = kthread_run(threadfn, thrcontext, name);
 	if (IS_ERR(thrinfo->task)) {
 		thrinfo->id = 0;
 		return 0;	/* failure */
 	}
 	thrinfo->id = thrinfo->task->pid;
-	wake_up_process(thrinfo->task);
 	LOGINF("started thread pid:%d\n", thrinfo->id);
 	return 1;
 }
-- 
2.1.0

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/5] unisys: use simpler kthread_ API
  2015-02-19 19:08 [PATCH 0/5] staging: unisys: kthread fixes (resubmission) Benjamin Romer
  2015-02-19 19:08 ` [PATCH 1/5] unisys: replace kthread_create and wake_up_process with kthread_run Benjamin Romer
@ 2015-02-19 19:08 ` Benjamin Romer
  2015-02-19 19:08 ` [PATCH 3/5] unisys: use kthread_should_stop in the thread Benjamin Romer
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Benjamin Romer @ 2015-02-19 19:08 UTC (permalink / raw)
  To: gregkh
  Cc: jkc, driverdev-devel, sparmaintainer, Devendra Naga, Benjamin Romer

From: Devendra Naga <devendra.aaru@gmail.com>

The code does the checks on should_stop variable in the kernel
threads. The uisthread_stop function sets the should_stop and calls
KILL (eventually kill_pid) to stop the thread.

The checking of should_stop variable can be replaced to a call to
kthread_should_stop function and the setting of the should_stop and
a call to KILL can be replaced with kthread_stop function.

Cc: Ken Cox <jkc@redhat.com>
Cc: Benjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/uislib/uisthread.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/unisys/uislib/uisthread.c b/drivers/staging/unisys/uislib/uisthread.c
index c5c68cb..20a2a1b 100644
--- a/drivers/staging/unisys/uislib/uisthread.c
+++ b/drivers/staging/unisys/uislib/uisthread.c
@@ -41,7 +41,6 @@ int
 uisthread_start(struct uisthread_info *thrinfo,
 		int (*threadfn)(void *), void *thrcontext, char *name)
 {
-	thrinfo->should_stop = 0;
 	/* used to stop the thread */
 	init_completion(&thrinfo->has_stopped);
 	thrinfo->task = kthread_run(threadfn, thrcontext, name);
@@ -58,24 +57,19 @@ EXPORT_SYMBOL_GPL(uisthread_start);
 void
 uisthread_stop(struct uisthread_info *thrinfo)
 {
-	int ret;
 	int stopped = 0;
 
 	if (thrinfo->id == 0)
 		return;		/* thread not running */
 
 	LOGINF("uisthread_stop stopping id:%d\n", thrinfo->id);
-	thrinfo->should_stop = 1;
-	ret = KILL(thrinfo->id, SIGHUP, 1);
-	if (ret) {
-		LOGERR("unable to signal thread %d\n", ret);
-	} else {
-		/* give up if the thread has NOT died in 1 minute */
-		if (wait_for_completion_timeout(&thrinfo->has_stopped, 60 * HZ))
-			stopped = 1;
-		else
-			LOGERR("timed out trying to signal thread\n");
-	}
+	kthread_stop(thrinfo->task);
+	/* give up if the thread has NOT died in 1 minute */
+	if (wait_for_completion_timeout(&thrinfo->has_stopped, 60 * HZ))
+		stopped = 1;
+	else
+		LOGERR("timed out trying to signal thread\n");
+
 	if (stopped) {
 		LOGINF("uisthread_stop stopped id:%d\n", thrinfo->id);
 		thrinfo->id = 0;
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/5] unisys: use kthread_should_stop in the thread
  2015-02-19 19:08 [PATCH 0/5] staging: unisys: kthread fixes (resubmission) Benjamin Romer
  2015-02-19 19:08 ` [PATCH 1/5] unisys: replace kthread_create and wake_up_process with kthread_run Benjamin Romer
  2015-02-19 19:08 ` [PATCH 2/5] unisys: use simpler kthread_ API Benjamin Romer
@ 2015-02-19 19:08 ` Benjamin Romer
  2015-02-19 19:08 ` [PATCH 4/5] unisys: use kthread_should_stop API in the lib thread Benjamin Romer
  2015-02-19 19:08 ` [PATCH 5/5] unisys: remove the thread variable and API Benjamin Romer
  4 siblings, 0 replies; 6+ messages in thread
From: Benjamin Romer @ 2015-02-19 19:08 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer

From: Devendra Naga <devendra.aaru@gmail.com>

convert the users of should_stop variable into kthread_should_stop() API.

Cc: Ken Cox <jkc@redhat.com>
Cc: Benjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/virthba/virthba.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c
index e6ecea5..573cbcb 100644
--- a/drivers/staging/unisys/virthba/virthba.c
+++ b/drivers/staging/unisys/virthba/virthba.c
@@ -1348,6 +1348,8 @@ process_incoming_rsps(void *v)
 	}
 	mask = ULTRA_CHANNEL_ENABLE_INTS;
 	while (1) {
+		if (kthread_should_stop())
+			break;
 		wait_event_interruptible_timeout(virthbainfo->rsp_queue,
 			 (atomic_read(&virthbainfo->interrupt_rcvd) == 1),
 				      usecs_to_jiffies(rsltq_wait_usecs));
@@ -1355,8 +1357,6 @@ process_incoming_rsps(void *v)
 		/* drain queue */
 		drain_queue(virthbainfo, dc, cmdrsp);
 		rc1 = uisqueue_interlocked_or(virthbainfo->flags_addr, mask);
-		if (dc->threadinfo.should_stop)
-			break;
 	}
 
 	kfree(cmdrsp);
-- 
2.1.0

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/5] unisys: use kthread_should_stop API in the lib thread
  2015-02-19 19:08 [PATCH 0/5] staging: unisys: kthread fixes (resubmission) Benjamin Romer
                   ` (2 preceding siblings ...)
  2015-02-19 19:08 ` [PATCH 3/5] unisys: use kthread_should_stop in the thread Benjamin Romer
@ 2015-02-19 19:08 ` Benjamin Romer
  2015-02-19 19:08 ` [PATCH 5/5] unisys: remove the thread variable and API Benjamin Romer
  4 siblings, 0 replies; 6+ messages in thread
From: Benjamin Romer @ 2015-02-19 19:08 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer

From: Devendra Naga <devendra.aaru@gmail.com>

convert the users of should_stop into using kthread_should_stop API.

Cc: Ken Cox <jkc@redhat.com>
Cc: Benjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/uislib/uislib.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c
index a9eedde..22aa808 100644
--- a/drivers/staging/unisys/uislib/uislib.c
+++ b/drivers/staging/unisys/uislib/uislib.c
@@ -1294,7 +1294,7 @@ static int process_incoming(void *v)
 					}
 				}
 			}
-			if (incoming_ti.should_stop)
+			if (kthread_should_stop())
 				break;
 		}
 		if (new_tail != NULL) {
@@ -1311,7 +1311,7 @@ static int process_incoming(void *v)
 		* - there is no input waiting on any of the channels
 		* - we have received a signal to stop this thread
 		*/
-		if (incoming_ti.should_stop)
+		if (kthread_should_stop())
 			break;
 		if (en_smart_wakeup == 0xFF) {
 			LOGINF("en_smart_wakeup set to 0xff, to force exiting process_incoming");
-- 
2.1.0

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 5/5] unisys: remove the thread variable and API
  2015-02-19 19:08 [PATCH 0/5] staging: unisys: kthread fixes (resubmission) Benjamin Romer
                   ` (3 preceding siblings ...)
  2015-02-19 19:08 ` [PATCH 4/5] unisys: use kthread_should_stop API in the lib thread Benjamin Romer
@ 2015-02-19 19:08 ` Benjamin Romer
  4 siblings, 0 replies; 6+ messages in thread
From: Benjamin Romer @ 2015-02-19 19:08 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer

From: Devendra Naga <devendra.aaru@gmail.com>

remove the should_stop variable and KILL API as they are
no longer required

Cc: Ken Cox <jkc@redhat.com>
Cc: Benjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/include/uisthread.h | 1 -
 drivers/staging/unisys/uislib/uisthread.c  | 2 --
 2 files changed, 3 deletions(-)

diff --git a/drivers/staging/unisys/include/uisthread.h b/drivers/staging/unisys/include/uisthread.h
index aa86ade..52c3eb4 100644
--- a/drivers/staging/unisys/include/uisthread.h
+++ b/drivers/staging/unisys/include/uisthread.h
@@ -27,7 +27,6 @@
 struct uisthread_info {
 	struct task_struct *task;
 	int id;
-	int should_stop;
 	struct completion has_stopped;
 };
 
diff --git a/drivers/staging/unisys/uislib/uisthread.c b/drivers/staging/unisys/uislib/uisthread.c
index 20a2a1b..d54005d 100644
--- a/drivers/staging/unisys/uislib/uisthread.c
+++ b/drivers/staging/unisys/uislib/uisthread.c
@@ -24,8 +24,6 @@
 #include "uisutils.h"
 #include "uisthread.h"
 
-#define KILL(a, b, c) kill_pid(find_vpid(a), b, c)
-
 /* this is shorter than using __FILE__ (full path name) in
  * debug/info/error messages
  */
-- 
2.1.0

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-02-19 19:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-19 19:08 [PATCH 0/5] staging: unisys: kthread fixes (resubmission) Benjamin Romer
2015-02-19 19:08 ` [PATCH 1/5] unisys: replace kthread_create and wake_up_process with kthread_run Benjamin Romer
2015-02-19 19:08 ` [PATCH 2/5] unisys: use simpler kthread_ API Benjamin Romer
2015-02-19 19:08 ` [PATCH 3/5] unisys: use kthread_should_stop in the thread Benjamin Romer
2015-02-19 19:08 ` [PATCH 4/5] unisys: use kthread_should_stop API in the lib thread Benjamin Romer
2015-02-19 19:08 ` [PATCH 5/5] unisys: remove the thread variable and API Benjamin Romer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.