From patchwork Mon Aug 24 21:57:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 7066961 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 1751C9F402 for ; Mon, 24 Aug 2015 21:58:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3BC2F20749 for ; Mon, 24 Aug 2015 21:58:08 +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 38C4E2070C for ; Mon, 24 Aug 2015 21:58:07 +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 1ZTzkk-00074G-Vz; Mon, 24 Aug 2015 21:58:07 +0000 Received: from mail-wi0-f177.google.com ([209.85.212.177]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZTzkc-00072b-Nq for linux-mediatek@lists.infradead.org; Mon, 24 Aug 2015 21:57:59 +0000 Received: by wicja10 with SMTP id ja10so83980460wic.1 for ; Mon, 24 Aug 2015 14:57:36 -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=4gO3M4tozpq9g2VBlx+UDvp9gD1+XWTdfmk/hivf+yM=; b=K2R8QFRGljzj1Q20QjO578PvWBlzqv6zTNV1c7omWZVbji5BeVNV1GfnKPRfPir//t LUS3HM98+j83IpyGe6fzQVJxZEqjPKhbP4Voj+cl4sIv6aKzeGpfjFvHwmCNne0B3wOn A3lRorUm3NFUPqM+fSLp030Icjt1BlbpLE79Vne+hp7r14yuZDIE9+dE+EDZWqnmMlsv xSTi3VeZoII9bt0uqwOTM+1ypT9M3P4MifbUgUUd1wubNPNKZhRRBQY2UFwisHu2pAvl WNMkkisLczu5rYRujuD72kznA5rZlahH2Fi8RIuSbaTjsdhxebDB6oI+SbNlaxTz/zwc T8uw== X-Gm-Message-State: ALoCoQkC0GBcgHqY3V6vnibLjLD44XhxVVp70BeHrq2ukkd3bXkrWCqSND788Q6I1sXlirL1uDBa X-Received: by 10.194.71.65 with SMTP id s1mr45020583wju.96.1440453456571; Mon, 24 Aug 2015 14:57:36 -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 uo6sm24988278wjc.1.2015.08.24.14.57.34 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Aug 2015 14:57:35 -0700 (PDT) From: Daniel Lezcano To: yingjoe.chen@mediatek.com Subject: [PATCH V2] clockevents/drivers/mtk: Fix spurious interrupt leading to crash Date: Mon, 24 Aug 2015 23:57:30 +0200 Message-Id: <1440453450-21203-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1440426924.17418.11.camel@mtksdaap41> References: <1440426924.17418.11.camel@mtksdaap41> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150824_145758_926616_41401BAD X-CRM114-Status: GOOD ( 11.89 ) 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: jamesjj.liao@mediatek.com, linux@arm.linux.org.uk, arnd@arndb.de, srv_heupstream@mediatek.com, catalin.marinas@arm.com, sboyd@codeaurora.org, "open list:CLOCKSOURCE, CLOC..." , "moderated list:ARM/Mediatek SoC..." , kernel@pengutronix.de, matthias.bgg@gmail.com, tglx@linutronix.de, "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=-5.6 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 --- 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 4cd16fb..505f53d 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,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); @@ -232,8 +230,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);