From patchwork Wed Mar 13 18:17:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 2264551 Return-Path: X-Original-To: patchwork-spi-devel-general@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by patchwork2.kernel.org (Postfix) with ESMTP id 146ECDF215 for ; Wed, 13 Mar 2013 18:25:40 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-4.v29.ch3.sourceforge.com) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1UFqMt-00038x-D4; Wed, 13 Mar 2013 18:25:39 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1UFqMr-00038o-8K for spi-devel-general@lists.sourceforge.net; Wed, 13 Mar 2013 18:25:37 +0000 Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of google.com designates 209.85.212.73 as permitted sender) client-ip=209.85.212.73; envelope-from=dianders@google.com; helo=mail-vb0-f73.google.com; Received: from mail-vb0-f73.google.com ([209.85.212.73]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1UFqMq-0004f6-DI for spi-devel-general@lists.sourceforge.net; Wed, 13 Mar 2013 18:25:37 +0000 Received: by mail-vb0-f73.google.com with SMTP id fj18so124144vbb.2 for ; Wed, 13 Mar 2013 11:25:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=NbdYwsa50MMZRbT0OiCchWpV72V8w7/3PIlaZoIgvLo=; b=IGcKAxS6sGIpb6CSibu3FVzjx7+5on8sCTA07lBvMkejjYoZcq3WW0L1l8lyMnFo7i 5eJ+9dIEiJP1JHA5je8FBDDn9XdBFi0wpAVxPxFXVeAzscrI7T8xNfbxvIMcchWUGL0Y af14mDGXXsPvte40lKTPM1lRJcykMM2OE33N3JXyOxTnSBC5AZpcu8+4BO9XQYvWbmq2 7D3OFFzsp6umzK/LYcHVUKlVFFYms2cGuWmrF6vH+pBEEGUxJnE+um6Sn/xcXNQCj/55 cBvpfuv5UjJjaW7rZQUkRlB0FSSj6Jy4oLbrRgDkBMNmqxtzm2twG6XOC5xcwCZaxz00 286w== X-Received: by 10.236.159.100 with SMTP id r64mr12741042yhk.20.1363198677615; Wed, 13 Mar 2013 11:17:57 -0700 (PDT) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id f47si1668999yhg.4.2013.03.13.11.17.57 (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Wed, 13 Mar 2013 11:17:57 -0700 (PDT) Received: from tictac.mtv.corp.google.com (tictac.mtv.corp.google.com [172.22.73.80]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 708E931C166; Wed, 13 Mar 2013 11:17:57 -0700 (PDT) Received: by tictac.mtv.corp.google.com (Postfix, from userid 121310) id 1109A804C1; Wed, 13 Mar 2013 11:17:56 -0700 (PDT) From: Doug Anderson To: Grant Likely Subject: [REPOST PATCH] spi: Unlock a spinlock before calling into the controller driver. Date: Wed, 13 Mar 2013 11:17:40 -0700 Message-Id: <1363198660-21656-1-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 1.8.1.3 In-Reply-To: <1340409205-23606-1-git-send-email-bfreed@chromium.org> References: <1340409205-23606-1-git-send-email-bfreed@chromium.org> X-Gm-Message-State: ALoCoQlVCT29IqgwiEDVd2ncIXifOVpKRFGKIDNScGUQusKq3lvGU1pTbmWSo2Mjx7/egEJ3KQ8W1GS9Vf9zoBtgMJoOA7xg13aW8VcALjYWUr5j9ZayVIDADsbhDG5/CJDszDLEkWnpa4elxJ/ePwqD7FoYDOejebLfhJBlycOv3m72U2uL733XfTfjWmvaYlEfqLkL4PcFHlRiZAqglE5VRXgkMerjvA== X-Spam-Score: -3.9 (---) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record -2.4 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain X-Headers-End: 1UFqMq-0004f6-DI Cc: Greg Kroah-Hartman , Linus Walleij , Mark Brown , Doug Anderson , Bryan Freed , Olof Johansson , spi-devel-general@lists.sourceforge.net, linux-kernel@vger.kernel.org X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: spi-devel-general-bounces@lists.sourceforge.net From: Bryan Freed spi_pump_messages() calls into a controller driver with unprepare_transfer_hardware() which is documented as "This may sleep". As in the prepare_transfer_hardware() call below, we should release the queue_lock spinlock before making the call. Rework the logic a bit to hold queue_lock to protect the 'busy' flag, then release it to call unprepare_transfer_hardware(). Signed-off-by: Bryan Freed Reviewed-by: Doug Anderson Signed-off-by: Doug Anderson Acked-by: Linus Walleij --- During a rebase we noticed that this old patch never actually landed anywhere. I haven't gone through an reproduced the original bug on ToT but I believe that this patch is still required. Perhaps it could land somewhere? ;) Thanks! drivers/spi/spi.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index f996c60..5b96250 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -543,17 +543,16 @@ static void spi_pump_messages(struct kthread_work *work) /* Lock queue and check for queue work */ spin_lock_irqsave(&master->queue_lock, flags); if (list_empty(&master->queue) || !master->running) { - if (master->busy && master->unprepare_transfer_hardware) { - ret = master->unprepare_transfer_hardware(master); - if (ret) { - spin_unlock_irqrestore(&master->queue_lock, flags); - dev_err(&master->dev, - "failed to unprepare transfer hardware\n"); - return; - } + if (!master->busy) { + spin_unlock_irqrestore(&master->queue_lock, flags); + return; } master->busy = false; spin_unlock_irqrestore(&master->queue_lock, flags); + if (master->unprepare_transfer_hardware && + master->unprepare_transfer_hardware(master)) + dev_err(&master->dev, + "failed to unprepare transfer hardware\n"); return; }