From patchwork Thu Sep 3 21:06:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 53061 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by patches.linaro.org (Postfix) with ESMTPS id 6624822E23 for ; Thu, 3 Sep 2015 21:09:15 +0000 (UTC) Received: by wisv5 with SMTP id v5sf706787wis.0 for ; Thu, 03 Sep 2015 14:09:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=L1HZqwcVRK5U8XZcjC5c7iDvUT7juEJL3FB4VtU54Rg=; b=Uzypf6X8VwL89BvgeD73tMI+I4KI9J4vAm9DOrh9bGFlSr/VV/+8riTeNt/Cwn2JiM Kw08b0LD9Ylhk24A18F75E37kueqg6N7AlM2jBdI0lZaJQvYEpNG2kDY8Ds5itaeZ4lH MArEmnlckgK0ySxo+HpXToIEi/ulYYq9IWQJCALkHXiaXve3uWcwVjk27KkHtAkbgH5d 1ptnG53KKHvrsmKqnH2pLUPlfnp1DQbFp7Lhe65JJ7aZLJ2F+CrQF4vSwOZ1bQdax0W+ issY+SwM6ZFHSnqaLGvG2pSWHZtp5hqk9CWvuKyvoghfYTbhMKV7npK8RVV4N+/Uo4k4 x0ag== X-Gm-Message-State: ALoCoQmQZvkPQ16VArVGiUZRwn+wA+BkzyzDFOZOlf/Nx/rB6j/yHtDgdLbH+xOMCBDVNRI+h2dj X-Received: by 10.112.16.200 with SMTP id i8mr11318570lbd.20.1441314554694; Thu, 03 Sep 2015 14:09:14 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.196 with SMTP id d4ls305592laa.91.gmail; Thu, 03 Sep 2015 14:09:14 -0700 (PDT) X-Received: by 10.152.37.2 with SMTP id u2mr24089324laj.70.1441314554500; Thu, 03 Sep 2015 14:09:14 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id kx10si78868lac.157.2015.09.03.14.09.14 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Sep 2015 14:09:14 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by lamp12 with SMTP id p12so1326778lam.0 for ; Thu, 03 Sep 2015 14:09:14 -0700 (PDT) X-Received: by 10.112.166.106 with SMTP id zf10mr24057173lbb.36.1441314554323; Thu, 03 Sep 2015 14:09:14 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.164.42 with SMTP id yn10csp1523520lbb; Thu, 3 Sep 2015 14:09:12 -0700 (PDT) X-Received: by 10.60.140.132 with SMTP id rg4mr16610658oeb.70.1441314552791; Thu, 03 Sep 2015 14:09:12 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id as7si192421pac.16.2015.09.03.14.09.11; Thu, 03 Sep 2015 14:09:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757505AbbICVJK (ORCPT + 28 others); Thu, 3 Sep 2015 17:09:10 -0400 Received: from mail-la0-f53.google.com ([209.85.215.53]:35319 "EHLO mail-la0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757459AbbICVJB (ORCPT ); Thu, 3 Sep 2015 17:09:01 -0400 Received: by lagj9 with SMTP id j9so1345706lag.2 for ; Thu, 03 Sep 2015 14:09:00 -0700 (PDT) X-Received: by 10.112.64.228 with SMTP id r4mr23945644lbs.103.1441314539850; Thu, 03 Sep 2015 14:08:59 -0700 (PDT) Received: from localhost (c-b03670d5.07-21-73746f28.cust.bredbandsbolaget.se. [213.112.54.176]) by smtp.gmail.com with ESMTPSA id z5sm19323lbj.34.2015.09.03.14.08.58 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Sep 2015 14:08:58 -0700 (PDT) From: Anders Roxell To: kgene@kernel.org, k.kozlowski@samsung.com, wsa@the-dreams.de Cc: ch.naveen@samsung.com, linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, khilman@linaro.org, linux-rt-users@vger.kernel.org, Anders Roxell Subject: [PATCHv2] drivers: i2c: exynos5: irq spinlock rt-safe Date: Thu, 3 Sep 2015 23:06:03 +0200 Message-Id: <1441314363-9836-1-git-send-email-anders.roxell@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1440489125-20082-1-git-send-email-anders.roxell@linaro.org> References: <1440489125-20082-1-git-send-email-anders.roxell@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: anders.roxell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The current spin_lock_irqsave() protects the enabling of the device interrupt. In order to prevent recursion in the case of sleeping spinlocks (e.g. with RT patch, stacktrace below), convert the spin lock to a raw spin lock. No change for !RT kernels. [ 10.992238] kernel BUG at ../kernel/locking/rtmutex.c:998! [ 10.992243] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP ARM [ 10.992250] Modules linked in: [ 10.992258] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.1.5-rt5 [ 10.992263] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree) [ 10.992268] task: ed880000 ti: ed888000 task.ti: ed888000 [ 10.992281] PC is at rt_spin_lock_slowlock+0xa4/0x2ec [ 10.992288] LR is at rt_spin_lock_slowlock+0x54/0x2ec [ 10.992296] pc : [] lr : [] psr: 60000193 [ 10.992296] sp : ed889a28 ip : ed880001 fp : 00000089 [ 10.992300] r10: ed889a28 r9 : c0f55654 r8 : 00000060 [ 10.992305] r7 : ed880000 r6 : 00000000 r5 : 00000001 r4 : ed9f7288 [ 10.992310] r3 : ed880000 r2 : 00000000 r1 : ed880000 r0 : 00000000 [ 10.992316] Flags: nZCv IRQs off FIQs on Mode SVC_32 ISA ARM Segment kernel ... ... [ 10.992662] [] (rt_spin_lock_slowlock) from [] (exynos5_i2c_irq+0x20/0x2b0) [ 10.992678] [] (exynos5_i2c_irq) from [] (handle_irq_event_percpu+0x68/0x158) [ 10.992690] [] (handle_irq_event_percpu) from [] (handle_irq_event+0x68/0xa8) [ 10.992702] [] (handle_irq_event) from [] (handle_fasteoi_irq+0x11c/0x1d4) [ 10.992713] [] (handle_fasteoi_irq) from [] (generic_handle_irq+0x20/0x30) [ 10.992724] [] (generic_handle_irq) from [] (__handle_domain_irq+0x6c/0xe4) [ 10.992734] [] (__handle_domain_irq) from [] (gic_handle_irq+0x2c/0x68) [ 10.992744] [] (gic_handle_irq) from [] (__irq_svc+0x40/0x88) [ 10.992749] Exception stack(0xed889b28 to 0xed889b70) ... ... Signed-off-by: Anders Roxell --- drivers/i2c/busses/i2c-exynos5.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/busses/i2c-exynos5.c b/drivers/i2c/busses/i2c-exynos5.c index b29c750..b12e77e 100644 --- a/drivers/i2c/busses/i2c-exynos5.c +++ b/drivers/i2c/busses/i2c-exynos5.c @@ -170,7 +170,7 @@ struct exynos5_i2c { struct device *dev; int state; - spinlock_t lock; /* IRQ synchronization */ + raw_spinlock_t lock; /* IRQ synchronization */ /* * Since the TRANS_DONE bit is cleared on read, and we may read it @@ -433,7 +433,7 @@ static irqreturn_t exynos5_i2c_irq(int irqno, void *dev_id) i2c->state = -EINVAL; - spin_lock(&i2c->lock); + raw_spin_lock(&i2c->lock); int_status = readl(i2c->regs + HSI2C_INT_STATUS); writel(int_status, i2c->regs + HSI2C_INT_STATUS); @@ -521,7 +521,7 @@ static irqreturn_t exynos5_i2c_irq(int irqno, void *dev_id) complete(&i2c->msg_complete); } - spin_unlock(&i2c->lock); + raw_spin_unlock(&i2c->lock); return IRQ_HANDLED; } @@ -610,7 +610,7 @@ static void exynos5_i2c_message_start(struct exynos5_i2c *i2c, int stop) * Enable interrupts before starting the transfer so that we don't * miss any INT_I2C interrupts. */ - spin_lock_irqsave(&i2c->lock, flags); + raw_spin_lock_irqsave(&i2c->lock, flags); writel(int_en, i2c->regs + HSI2C_INT_ENABLE); if (stop == 1) @@ -618,7 +618,7 @@ static void exynos5_i2c_message_start(struct exynos5_i2c *i2c, int stop) i2c_auto_conf |= i2c->msg->len; i2c_auto_conf |= HSI2C_MASTER_RUN; writel(i2c_auto_conf, i2c->regs + HSI2C_AUTO_CONF); - spin_unlock_irqrestore(&i2c->lock, flags); + raw_spin_unlock_irqrestore(&i2c->lock, flags); } static int exynos5_i2c_xfer_msg(struct exynos5_i2c *i2c, @@ -763,7 +763,7 @@ static int exynos5_i2c_probe(struct platform_device *pdev) /* Clear pending interrupts from u-boot or misc causes */ exynos5_i2c_clr_pend_irq(i2c); - spin_lock_init(&i2c->lock); + raw_spin_lock_init(&i2c->lock); init_completion(&i2c->msg_complete); i2c->irq = ret = platform_get_irq(pdev, 0);