From patchwork Mon Nov 14 15:13:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Whitten X-Patchwork-Id: 9427679 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 757A460471 for ; Mon, 14 Nov 2016 15:16:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67136289B1 for ; Mon, 14 Nov 2016 15:16:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B621289C2; Mon, 14 Nov 2016 15:16:17 +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 1724E289B1 for ; Mon, 14 Nov 2016 15:16:16 +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 1c6IyB-000583-8z; Mon, 14 Nov 2016 15:14:51 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c6Ixw-00051e-H2 for linux-arm-kernel@lists.infradead.org; Mon, 14 Nov 2016 15:14:38 +0000 Received: by mail-wm0-x242.google.com with SMTP id a20so16220964wme.2 for ; Mon, 14 Nov 2016 07:14:15 -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=xif/0us8riRnAOE9sKiaABJrWn4F5akAahKnTgvGnlc=; b=ZKxYB4CqRx3Hi3cGk+/x/S/TYD21h9mi47inL7kTk8YptzhXovijbSqwzD60XCnJxQ LlFxhvOZdW/ltJHulI99FdTIMmkIMf/0SxtM4nHDGdplhGSZDqwnugdSqLC2zkUno7qy zGuMkcCU7soU9dySJ8cgzK9UcM9Bhlzu9A7qTWqoUwSs4qFDMd+E2JAPuKsF1BdVhHX9 gQwm3/nh69YyhugYYwRDTvEmz1KnPh/ita+bh1zfL/MmCyCeNNnEDiU8Z5mAqt7S7OhN EBybwwDTAez5u1kOFgvEXs3nDT4vo7dg+6x8qdUGriBFeAGmZf1nkOi4YRWb0x6IMuPI zhig== 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=xif/0us8riRnAOE9sKiaABJrWn4F5akAahKnTgvGnlc=; b=h0FA9gEe3AZRoeaslT5FXo8j84g/TYS+dqgY0NPs1R8AWzA8tD/V4rI0FSO+xQHaxZ POflPvz+zG1oxp+5oJpAglZj3iJxbrdiACuv5jx5Ade5eVz7sFV/kLwVT8AYHOLWU+9i sxXeS8nQhjdZMhGEYVOWWkYdOobnWGABWuaSQc0phuq4Nbre83yUnKODO8my3nEK/OVQ l6jKSyJbiWVSy7ixw6oKSG5nTWag/N2n7t5ZVLypW71oFlcqWpMw6mrqCZ80qiBQKgAE laY5NbcM5+gClS8Q/tD/KXoUt46ut7j849ITM21iKz1LFFkJZhiEommncewoipg3knc4 O0/Q== X-Gm-Message-State: ABUngvdRG1w2mLmXDVCabwiZFsKFn2Nq8c1qeQ7ic7eKXcnqFKH4sAP/pi2s80x7AtAxrw== X-Received: by 10.194.91.148 with SMTP id ce20mr24406306wjb.59.1479136454203; Mon, 14 Nov 2016 07:14:14 -0800 (PST) Received: from Sarah.corp.lairdtech.com ([109.174.151.67]) by smtp.gmail.com with ESMTPSA id hy10sm29253072wjb.10.2016.11.14.07.14.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 14 Nov 2016 07:14:13 -0800 (PST) From: Ben Whitten X-Google-Original-From: Ben Whitten To: linux-arm-kernel@lists.infradead.org Subject: [PATCH RESEND] spi: atmel: Fix scheduling while atomic Date: Mon, 14 Nov 2016 15:13:20 +0000 Message-Id: <1479136400-10285-1-git-send-email-ben.whitten@lairdtech.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-20161114_071436_844034_BE69EA0B X-CRM114-Status: GOOD ( 11.33 ) 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: alexandre.belloni@free-electrons.com, broonie@kernel.org, nicolas.ferre@atmel.com, Ben Whitten , Steve deRosier 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 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 Acked-by: Nicolas Ferre Acked-by: Alexandre Belloni --- Resending due to missing off the subsystem maintainer in initial submission, pointed out by Alexandre Belloni, thanks. --- 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) {