summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2018-06-28 03:57:42 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-07-07 11:38:57 -0400
commite890591413819eeb604207ad3261ba617b2ec0bb (patch)
tree16d356d9ca2a3c2de4f07cee8ea1b681406578b7
parent7e6f7d24535b7c1edec3605d85c7684f7388d122 (diff)
siox: don't create a thread without starting it
When a siox master device is registered a kthread is created that is only started when triggered by userspace. So this thread might be in TASK_UNINTERRUPTIBLE state for long and trigger a warning [ 241.130465] INFO: task siox-0:626 blocked for more than 120 seconds. with the respective debug settings enabled. It might be right to put an unstarted thread to TASK_IDLE (in kernel/kthread.c:kthread()) instead, but independant of this discussion it is cleaner for siox_master_register() to start the thread immediately. The effect is that it enters its own waiting state and then stays in state TASK_IDLE which doesn't trigger the above warning. As siox_poll_thread() uses some variables of the device the initialisation of these is moved before thread creation. Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Acked-by: Gavin Schenk <g.schenk@eckelmann.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/siox/siox-core.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/siox/siox-core.c b/drivers/siox/siox-core.c
index 3115f930fa83..f8c08fb9891d 100644
--- a/drivers/siox/siox-core.c
+++ b/drivers/siox/siox-core.c
@@ -715,17 +715,17 @@ int siox_master_register(struct siox_master *smaster)
715 715
716 dev_set_name(&smaster->dev, "siox-%d", smaster->busno); 716 dev_set_name(&smaster->dev, "siox-%d", smaster->busno);
717 717
718 mutex_init(&smaster->lock);
719 INIT_LIST_HEAD(&smaster->devices);
720
718 smaster->last_poll = jiffies; 721 smaster->last_poll = jiffies;
719 smaster->poll_thread = kthread_create(siox_poll_thread, smaster, 722 smaster->poll_thread = kthread_run(siox_poll_thread, smaster,
720 "siox-%d", smaster->busno); 723 "siox-%d", smaster->busno);
721 if (IS_ERR(smaster->poll_thread)) { 724 if (IS_ERR(smaster->poll_thread)) {
722 smaster->active = 0; 725 smaster->active = 0;
723 return PTR_ERR(smaster->poll_thread); 726 return PTR_ERR(smaster->poll_thread);
724 } 727 }
725 728
726 mutex_init(&smaster->lock);
727 INIT_LIST_HEAD(&smaster->devices);
728
729 ret = device_add(&smaster->dev); 729 ret = device_add(&smaster->dev);
730 if (ret) 730 if (ret)
731 kthread_stop(smaster->poll_thread); 731 kthread_stop(smaster->poll_thread);