From patchwork Mon Feb 15 18:34:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 104987 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1228117lbl; Mon, 15 Feb 2016 10:34:57 -0800 (PST) X-Received: by 10.66.124.131 with SMTP id mi3mr25103851pab.7.1455561297028; Mon, 15 Feb 2016 10:34:57 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id kn6si44877549pab.36.2016.02.15.10.34.56; Mon, 15 Feb 2016 10:34:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752340AbcBOSe4 (ORCPT + 1 other); Mon, 15 Feb 2016 13:34:56 -0500 Received: from mezzanine.sirena.org.uk ([106.187.55.193]:52693 "EHLO mezzanine.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752234AbcBOSe4 (ORCPT ); Mon, 15 Feb 2016 13:34:56 -0500 Received: from debutante.sirena.org.uk ([2a01:348:6:8808:fab::3] helo=debutante) by mezzanine.sirena.org.uk with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1aVNz0-0008FN-MV; Mon, 15 Feb 2016 18:34:51 +0000 Received: from broonie by debutante with local (Exim 4.86) (envelope-from ) id 1aVNyx-0004qH-DL; Mon, 15 Feb 2016 18:34:47 +0000 From: Mark Brown To: Arnd Bergmann Cc: linux-spi@vger.kernel.org, Mark Brown Date: Mon, 15 Feb 2016 18:34:41 +0000 Message-Id: <1455561281-18573-1-git-send-email-broonie@kernel.org> X-Mailer: git-send-email 2.7.0 X-SA-Exim-Connect-IP: 2a01:348:6:8808:fab::3 X-SA-Exim-Mail-From: broonie@sirena.org.uk X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on mezzanine.sirena.org.uk X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 Subject: [PATCH] spi: Add cond_resched() in main message processing loop X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on mezzanine.sirena.org.uk) Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org When a controller has only PIO support it is very likely that we will run into use cases where we spend a very large amount of time consuming CPU. Code that does this should call cond_resched() every once in a while to give other tasks more of a chance to run so do that in the main SPI loop, the overhead is negligable if it's not needed. Suggested-by: Arnd Bergmann Signed-off-by: Mark Brown --- drivers/spi/spi.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.7.0 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 0ad55946e388..4252a112985c 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1207,6 +1207,9 @@ static void __spi_pump_messages(struct spi_master *master, bool in_kthread) return; } mutex_unlock(&master->bus_lock_mutex); + + /* Prod the scheduler in case transfer_one() was busy waiting */ + cond_resched(); } /**