From patchwork Mon Aug 24 13:30:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 52633 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by patches.linaro.org (Postfix) with ESMTPS id EA88622E9E for ; Mon, 24 Aug 2015 13:31:07 +0000 (UTC) Received: by lbcli1 with SMTP id li1sf40499923lbc.2 for ; Mon, 24 Aug 2015 06:31:06 -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=cuvZBZRBUcJFq6ZAToNurQU4k0lx1MlHEI/Y0C17dp4=; b=kbz0hO7uVONTP3WNJ/r1y9yrqF+kaoo3bRjPjFAvkyAbYA+QKZztrbmPeBIr3dIJnX oFKXYSCus4R/u3LDcfg60JISfn/wY9fMBKpnVk4442UqXPVHje/vk4qQ8/0xDt3hjpDf s3loUH6MGs8bLE1h/H+1Ro0Wwl8KAeS+I+Fv8g41tiYtywedK9P+Bt+XS6adFuWhZMF3 TcjlVm5EuKB6xLJQXMr1hLWIhtBxc6sA9QFd9biLaRuQ9uGZf864bikV9TwKTcaFrLpW +jhqf05eLhU2RMNVsi5Iqwl6knIlOodTx870SOo1ZtmjcpLl2m+NzlIvzmywDfu6kqUH c8sw== X-Gm-Message-State: ALoCoQk1t1ch42j+UjfxECrr8o0CnnOuF4AoyKsFK5pgjKkYdIPiIY4+P1+HLKV9VXrn8s++ErvT X-Received: by 10.112.172.70 with SMTP id ba6mr6771733lbc.1.1440423066855; Mon, 24 Aug 2015 06:31:06 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.3.200 with SMTP id e8ls562824lae.4.gmail; Mon, 24 Aug 2015 06:31:06 -0700 (PDT) X-Received: by 10.112.87.69 with SMTP id v5mr20674637lbz.12.1440423066667; Mon, 24 Aug 2015 06:31:06 -0700 (PDT) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id ca10si13087919lad.158.2015.08.24.06.31.06 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Aug 2015 06:31:06 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by lalv9 with SMTP id v9so77319266lal.0 for ; Mon, 24 Aug 2015 06:31:06 -0700 (PDT) X-Received: by 10.112.219.70 with SMTP id pm6mr19599668lbc.41.1440423066559; Mon, 24 Aug 2015 06:31:06 -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.162.200 with SMTP id yc8csp2475160lbb; Mon, 24 Aug 2015 06:31:04 -0700 (PDT) X-Received: by 10.68.177.4 with SMTP id cm4mr45122495pbc.76.1440423064184; Mon, 24 Aug 2015 06:31:04 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x5si27397360pbt.100.2015.08.24.06.31.01; Mon, 24 Aug 2015 06:31:04 -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 S1754752AbbHXNbA (ORCPT + 28 others); Mon, 24 Aug 2015 09:31:00 -0400 Received: from mail-wi0-f176.google.com ([209.85.212.176]:33809 "EHLO mail-wi0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752904AbbHXNa6 (ORCPT ); Mon, 24 Aug 2015 09:30:58 -0400 Received: by widdq5 with SMTP id dq5so50416829wid.1 for ; Mon, 24 Aug 2015 06:30:57 -0700 (PDT) X-Received: by 10.194.63.20 with SMTP id c20mr42859105wjs.134.1440423057100; Mon, 24 Aug 2015 06:30:57 -0700 (PDT) Received: from localhost.localdomain (sju31-1-78-210-255-2.fbx.proxad.net. [78.210.255.2]) by smtp.gmail.com with ESMTPSA id cd16sm16230548wib.19.2015.08.24.06.30.54 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Aug 2015 06:30:55 -0700 (PDT) From: Daniel Lezcano To: yingjoe.chen@mediatek.com Cc: djkurtz@chromium.org, sboyd@codeaurora.org, tglx@linutronix.de, jamesjj.liao@mediatek.com, linux@arm.linux.org.uk, srv_heupstream@mediatek.com, arnd@arndb.de, catalin.marinas@arm.com, kernel@pengutronix.de, matthias.bgg@gmail.com, linux-kernel@vger.kernel.org (open list:CLOCKSOURCE, CLOC...), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Mediatek SoC...), linux-mediatek@lists.infradead.org (moderated list:ARM/Mediatek SoC...) Subject: [PATCH] clockevents/drivers/mtk: Fix spurious interrupt leading to crash Date: Mon, 24 Aug 2015 15:30:44 +0200 Message-Id: <1440423045-7883-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1440167950.20169.29.camel@mtksdaap41> References: <1440167950.20169.29.camel@mtksdaap41> 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: daniel.lezcano@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.53 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: , 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 --- drivers/clocksource/mtk_timer.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/clocksource/mtk_timer.c b/drivers/clocksource/mtk_timer.c index 4cd16fb..13543a8 100644 --- a/drivers/clocksource/mtk_timer.c +++ b/drivers/clocksource/mtk_timer.c @@ -156,14 +156,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) { @@ -183,6 +175,9 @@ static void mtk_timer_enable_irq(struct mtk_clock_event_device *evt, u8 timer) { u32 val; + /* 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); @@ -232,8 +227,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);