From patchwork Thu May 1 08:15:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 4097981 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id ED2179F1E1 for ; Thu, 1 May 2014 08:15:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1FCB32034B for ; Thu, 1 May 2014 08:15:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 28F052025B for ; Thu, 1 May 2014 08:15:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752473AbaEAIP0 (ORCPT ); Thu, 1 May 2014 04:15:26 -0400 Received: from mail-lb0-f174.google.com ([209.85.217.174]:43447 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751807AbaEAIPY (ORCPT ); Thu, 1 May 2014 04:15:24 -0400 Received: by mail-lb0-f174.google.com with SMTP id n15so4993lbi.19 for ; Thu, 01 May 2014 01:15:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=8msVfPMw7zWXkPP67H1BWwDBmPXD6u8/LXEbs53kKvM=; b=IUCr6exAVMbQ3IwOo9/ImcSLXtydDkBTr5NT9S/qyYdCYbtdwgDpmjZ+9Hsm/aslHe 8+nhItlsH+K9pH+O43vYGZEl417qRSyj3sIZvJjJsgaiteKXvAZqSUkuDymhUCCp1DEv tRB8BAMQBSIDFemQz4/rBQz3FL6xYHPowoOPiNV3hcISHoTksMOsmufjzfGUHpyiJrH0 a9G6Xc88BxOqPfbG8bQNKDvwSAAWqKGVDyF5qwKcOpmWczhxamYvs527ob2xC1ilaVme OOeR7nNL8kJz4R5XwbIbiEs4lb4640pvDHK85ClJWxihwyT1OWOJCwwlV5Gg/7BKvSxa GBwQ== X-Received: by 10.152.4.129 with SMTP id k1mr6609823lak.28.1398932122039; Thu, 01 May 2014 01:15:22 -0700 (PDT) Received: from neopili.qtec.com (0x4dd4aed9.adsl.cybercity.dk. [77.212.174.217]) by mx.google.com with ESMTPSA id mw10sm29102009lbb.24.2014.05.01.01.15.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 May 2014 01:15:21 -0700 (PDT) From: Ricardo Ribalda Delgado To: linux-spi@vger.kernel.org, broonie@kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Delgado Subject: [PATCH] spi: Fix hung task timeout when initialization fails Date: Thu, 1 May 2014 10:15:15 +0200 Message-Id: <1398932115-11646-1-git-send-email-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 1.9.2 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If kthread_run on spi_init_queue() fails, spi_destroy_queue can lead to hang timeout. Before 786235eeba0e1e85e5cbbb9f97d1087ad03dfa21 kthread: make kthread_create() killable" it was very unlikely that kthread_run would fail, but after that patch a kill to modprobe can lead to this kind of error. Udev kills modprobe after 30 seconds. When this happens, spi_destroy_queue() leads to a hung process that outputs a error message and avoids the computer to be halted/rebooted. This bug is particulary critical on machines that relay on the spi subsystem to hold a file system (MTD over SPI). [ 95.900328] spi_master spi32765: failed to create message pump task [ 95.900358] spi_master spi32765: problem initializing queue [ 95.912333] qtec_pcie b0030000.pcie_bridge: Axi-pcie bridge supervisor [ 240.463698] INFO: task udevd:129 blocked for more than 120 seconds. [ 240.463733] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. [ 240.463807] Call Trace: [ 240.463968] [] wait_for_completion+0x1d/0x20 [ 240.464036] [] spi_destroy_queue+0x27/0x60 [ 240.464050] [] spi_register_master+0x5d6/0x900 Signed-off-by: Ricardo Ribalda Delgado --- v2: Comment by Mark Brown: -Improve commit message drivers/spi/spi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 4eb9bf0..8331556 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1114,8 +1114,10 @@ static int spi_destroy_queue(struct spi_master *master) return ret; } - flush_kthread_worker(&master->kworker); - kthread_stop(master->kworker_task); + if (!IS_ERR(master->kworker_task)) { + flush_kthread_worker(&master->kworker); + kthread_stop(master->kworker_task); + } return 0; }