From patchwork Mon Oct 19 20:59:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 7439821 Return-Path: X-Original-To: patchwork-linux-mediatek@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6C0379F52D for ; Mon, 19 Oct 2015 21:00:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 758BB206EF for ; Mon, 19 Oct 2015 21:00:22 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 7A3A0206E8 for ; Mon, 19 Oct 2015 21:00:20 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZoHXY-0007WQ-5e; Mon, 19 Oct 2015 21:00:20 +0000 Received: from mail-wi0-f169.google.com ([209.85.212.169]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZoHXW-0006Hx-1Z for linux-mediatek@lists.infradead.org; Mon, 19 Oct 2015 21:00:19 +0000 Received: by wicfx6 with SMTP id fx6so17490756wic.1 for ; Mon, 19 Oct 2015 13:59:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zcbbMJ6wkf2wRrWbdc9qeEBXhJZp1a5c8DHpi1k2H48=; b=Y+onWARQI1tsrcTTF/Ea53d86bc8bAZxohUFpF6sV79Uf6RaUofLg9LPUEAa1kJmh8 vKViIH9xggeNVgg7YBY/wzUkWUiz1V0npaEN1zYrEeeo6cjsxg227In16oll1YGnuPAu e8TYof0fsdSMCxk8uPJHh6PzqyGgTVUeqIHkl2i6DSi6Gv2JkQPYyJxllq/YqRB3U0tH lK+QAtMzORjA5Fg0IhieItsA5tXFW/DH3eHi15p9FnfL09F6Vc3ouYBuVJtMI1My3JLS jk/ChqGhAkQS7/p/R9kgs1WsyEG8W6mMd+C/z3NUJnRkQQWWrnDF9HWzXQtAJLqtzS+c y/pw== X-Gm-Message-State: ALoCoQlq6hzUzCkOP7sPsFNRtDDp4wRhp5uF3lzY7iiKrqIBAC/jslLxRjT7SQCQR53x+SEBVyli X-Received: by 10.180.93.133 with SMTP id cu5mr21647960wib.49.1445288395985; Mon, 19 Oct 2015 13:59:55 -0700 (PDT) Received: from mai.telefonica.net (185.Red-213-96-199.staticIP.rima-tde.net. [213.96.199.185]) by smtp.gmail.com with ESMTPSA id xt1sm42296501wjb.32.2015.10.19.13.59.54 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Oct 2015 13:59:55 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de Subject: [PATCH 1/9] clockevents/drivers/mtk: Fix spurious interrupt leading to crash Date: Mon, 19 Oct 2015 22:59:20 +0200 Message-Id: <1445288368-6440-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <56255943.6060807@linaro.org> References: <56255943.6060807@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151019_140018_273473_CE17A9A5 X-CRM114-Status: GOOD ( 12.69 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, "moderated list:ARM/Mediatek SoC..." , Matthias Brugger , Yingjoe Chen , mingo@kernel.org, "moderated list:ARM/Mediatek SoC..." MIME-Version: 1.0 Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP After analysis done by Yingjoe Chen, the timer appears to have a pending interrupt when it is enabled. Fix this by acknowledging the pending interrupt when enabling the timer interrupt. Signed-off-by: Daniel Lezcano Tested-by: Yingjoe Chen Acked-by: Matthias Brugger --- drivers/clocksource/mtk_timer.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/clocksource/mtk_timer.c b/drivers/clocksource/mtk_timer.c index 50f0641..c8badc4 100644 --- a/drivers/clocksource/mtk_timer.c +++ b/drivers/clocksource/mtk_timer.c @@ -141,14 +141,6 @@ static irqreturn_t mtk_timer_interrupt(int irq, void *dev_id) return IRQ_HANDLED; } -static void mtk_timer_global_reset(struct mtk_clock_event_device *evt) -{ - /* Disable all interrupts */ - writel(0x0, evt->gpt_base + GPT_IRQ_EN_REG); - /* Acknowledge all interrupts */ - writel(0x3f, evt->gpt_base + GPT_IRQ_ACK_REG); -} - static void mtk_timer_setup(struct mtk_clock_event_device *evt, u8 timer, u8 option) { @@ -168,6 +160,12 @@ static void mtk_timer_enable_irq(struct mtk_clock_event_device *evt, u8 timer) { u32 val; + /* Disable all interrupts */ + writel(0x0, evt->gpt_base + GPT_IRQ_EN_REG); + + /* Acknowledge all spurious pending interrupts */ + writel(0x3f, evt->gpt_base + GPT_IRQ_ACK_REG); + val = readl(evt->gpt_base + GPT_IRQ_EN_REG); writel(val | GPT_IRQ_ENABLE(timer), evt->gpt_base + GPT_IRQ_EN_REG); @@ -220,8 +218,6 @@ static void __init mtk_timer_init(struct device_node *node) } rate = clk_get_rate(clk); - mtk_timer_global_reset(evt); - if (request_irq(evt->dev.irq, mtk_timer_interrupt, IRQF_TIMER | IRQF_IRQPOLL, "mtk_timer", evt)) { pr_warn("failed to setup irq %d\n", evt->dev.irq);