From patchwork Thu Nov 10 15:34:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Whitten X-Patchwork-Id: 9421307 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 985D4601C0 for ; Thu, 10 Nov 2016 15:37:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8AFC6294D1 for ; Thu, 10 Nov 2016 15:37:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7CA4E29505; Thu, 10 Nov 2016 15:37:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E30C1294D1 for ; Thu, 10 Nov 2016 15:37:26 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c4rOK-0008Qv-4h; Thu, 10 Nov 2016 15:35:52 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c4rOE-0007r4-CS for linux-arm-kernel@lists.infradead.org; Thu, 10 Nov 2016 15:35:47 +0000 Received: by mail-wm0-x241.google.com with SMTP id g23so3898748wme.1 for ; Thu, 10 Nov 2016 07:35:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=q5CkIpPvkV9zq7S2pORgTmuzLsPQU3tJ1AJXeiuPoL4=; b=PKzZNw0NQbKKr6U/3Es2WvgpVjyz/Hvub4Xq/ZuEJAsA+ZSyf3se1YcIyOkEwFaeU1 5a0w/DnvLW69O3P277gnBTNTHmUdkk8LaZXzzIAuhNuZLIL7htqbFk6opEopInENEj/B IONBqj05Qs0swSwaIk/WkQTueZvFLGTbM73takTd8CC1UOAF38bjTKfFx48uVgUo5BDZ YadIhBclJScPf7DPRd0dvdfqj1YwWCNZ9t67faaIGd62sE0AGAC2sipn21gZfpEp02uB GWGdzyuJqnEPrYg2NcAUw6Z+ZDb5/oiZOn5LE7RcrkuSnDdBo6ZFeSWXQFZLdiUmu01E aM1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=q5CkIpPvkV9zq7S2pORgTmuzLsPQU3tJ1AJXeiuPoL4=; b=R5G8NuSyC36JtvFZ5yPjCvRQukTNKyjxcBwV/tYo0u+k+qdwuvKo1k69BPVZ6BY1Ah hEOdSKMMHWV/2IdZ5w0JH+lt+aEhZsz+I/toRohVs1cT09fEKB23Y1Xt0YvLIkkgqtAm iBOzW7EHFt6SWjYrgQaaZyCtX/So5xrlbe9LnfuxLjbUzYiDPt59XaMDwpZsEvZFsJoG 5ikTgzlg0WAtEM4S+ScB4p46DeB0xEeZ0MNPAWL7SUJSQAQ+0LVQuxAPBdNkO82Yzfru xRPCY6PPj2tHQRJI1AI8pjOM/zw6K6FHVvLReSTDrAk4A0NE7r2Azd8oSdMu8Q598iIq eTMw== X-Gm-Message-State: ABUngvekuCydmzkSc0sAjbe6wHG5xe7IqTS7AeQNirpB7IWU0LIuFK6noRhKDa2TcwCPgg== X-Received: by 10.28.127.9 with SMTP id a9mr28942446wmd.95.1478792124076; Thu, 10 Nov 2016 07:35:24 -0800 (PST) Received: from Sarah.lan (cpc96350-rdng26-2-0-cust877.15-3.cable.virginm.net. [86.18.47.110]) by smtp.gmail.com with ESMTPSA id l67sm23207536wmf.0.2016.11.10.07.35.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Nov 2016 07:35:23 -0800 (PST) From: ben.whitten@gmail.com To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] spi: atmel: Fix scheduling while atomic Date: Thu, 10 Nov 2016 15:34:50 +0000 Message-Id: <1478792090-6376-1-git-send-email-ben.whitten@gmail.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161110_073546_701279_9F5E5E54 X-CRM114-Status: GOOD ( 11.85 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Steve deRosier , nicolas.ferre@atmel.com, Ben Whitten MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ben Whitten A call to clk_get_rate appears to be called in the context of an interrupt, cache the bus clock for the frequency calculations in transmission. This fixes a 'BUG: scheduling while atomic' and 'WARNING: CPU: 0 PID: 777 at kernel/sched/core.c:2960 atmel_spi_unlock' Signed-off-by: Ben Whitten Signed-off-by: Steve deRosier --- drivers/spi/spi-atmel.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 8feac59..c281d1a 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c @@ -295,6 +295,7 @@ struct atmel_spi { int irq; struct clk *clk; struct platform_device *pdev; + unsigned long spi_clk; struct spi_transfer *current_transfer; int current_remaining_bytes; @@ -864,7 +865,7 @@ static int atmel_spi_set_xfer_speed(struct atmel_spi *as, unsigned long bus_hz; /* v1 chips start out at half the peripheral bus speed. */ - bus_hz = clk_get_rate(as->clk); + bus_hz = as->spi_clk; if (!atmel_spi_is_v2(as)) bus_hz /= 2; @@ -1606,6 +1607,9 @@ static int atmel_spi_probe(struct platform_device *pdev) ret = clk_prepare_enable(clk); if (ret) goto out_free_irq; + + as->spi_clk = clk_get_rate(clk); + spi_writel(as, CR, SPI_BIT(SWRST)); spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */ if (as->caps.has_wdrbt) {