From patchwork Mon May 4 15:13:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yingjoe Chen X-Patchwork-Id: 6327361 Return-Path: X-Original-To: patchwork-linux-mediatek@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 14767BEEE1 for ; Mon, 4 May 2015 15:14:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 34026202E9 for ; Mon, 4 May 2015 15:14:45 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3EA7120376 for ; Mon, 4 May 2015 15:14:44 +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 1YpI4x-0005Nn-La; Mon, 04 May 2015 15:14:43 +0000 Received: from [210.61.82.184] (helo=mailgw02.mediatek.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YpI4k-0005Cd-MT; Mon, 04 May 2015 15:14:31 +0000 X-Listener-Flag: 11101 Received: from mtkhts07.mediatek.inc [(172.21.101.69)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 144573672; Mon, 04 May 2015 23:14:01 +0800 Received: from [172.21.77.4] (172.21.77.4) by mtkhts07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 14.3.181.6; Mon, 4 May 2015 23:13:59 +0800 Message-ID: <1430752439.24965.2.camel@mtksdaap41> Subject: Re: [PATCH 1/7] clocksource: mediatek: Don't run event_handler if it is NULL From: Yingjoe Chen To: Daniel Lezcano Date: Mon, 4 May 2015 23:13:59 +0800 In-Reply-To: <55473162.5010608@linaro.org> References: <1430466210-22963-1-git-send-email-yingjoe.chen@mediatek.com> <1430466210-22963-2-git-send-email-yingjoe.chen@mediatek.com> <55472A80.9020904@linaro.org> <55473162.5010608@linaro.org> X-Mailer: Evolution 3.2.3-0ubuntu6 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150504_081430_965757_4644C692 X-CRM114-Status: GOOD ( 17.41 ) X-Spam-Score: 1.3 (+) Cc: Mark Rutland , "devicetree@vger.kernel.org" , Lorenzo Pieralisi , Russell King , Pawel Moll , Arnd Bergmann , Ian Campbell , Catalin Marinas , "linux-kernel@vger.kernel.org" , Olof Johansson , Rob Herring , linux-mediatek@lists.infradead.org, "linux-arm-kernel@lists.infradead.org" , Sascha Hauer , Matthias Brugger , Thomas Gleixner , srv_heupstream , Marc Carino , Jason Cooper X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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, T_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 On Mon, 2015-05-04 at 10:44 +0200, Daniel Lezcano wrote: > On 05/04/2015 10:34 AM, Matthias Brugger wrote: > > 2015-05-04 10:14 GMT+02:00 Daniel Lezcano : > >> On 05/01/2015 09:43 AM, Yingjoe Chen wrote: > >>> > >>> Spurious timer interrupt is noticed in mtk timer and cause kernel > >>> crash. In mtk_timer_interrupt(), only run event_handler if it is > >>> not NULL. > >>> > >>> Signed-off-by: Yingjoe Chen > >>> --- > >>> drivers/clocksource/mtk_timer.c | 3 ++- > >>> 1 file changed, 2 insertions(+), 1 deletion(-) > >>> > >>> diff --git a/drivers/clocksource/mtk_timer.c > >>> b/drivers/clocksource/mtk_timer.c > >>> index 68ab423..85e0ab5 100644 > >>> --- a/drivers/clocksource/mtk_timer.c > >>> +++ b/drivers/clocksource/mtk_timer.c > >>> @@ -143,7 +143,8 @@ static irqreturn_t mtk_timer_interrupt(int irq, void > >>> *dev_id) > >>> > >>> /* Acknowledge timer0 irq */ > >>> writel(GPT_IRQ_ACK(GPT_CLK_EVT), evt->gpt_base + GPT_IRQ_ACK_REG); > >>> - evt->dev.event_handler(&evt->dev); > >>> + if (evt->dev.event_handler) > >>> + evt->dev.event_handler(&evt->dev); > >>> > >>> return IRQ_HANDLED; > >>> } > >>> > >> > >> This fix does not look good. > >> > >> Could you try by requesting the irq *after* clockevents_config_and_register > >> in the init sequence [1] ? > >> > > > > From my understanding [1] should already fix this. > > > > [1] https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/drivers/clocksource/mtk_timer.c?id=d4a19eb3b15a4ba98f627182f48d5bc0cffae670 > > Indeed it seems to fix it. But I think request_irq should be done after > clockevents_config_and_register in any case. > > Yingjoe, are the spurious interrupts occurring with the fix Matthias > mentions ? > Hi Daniel, Matthias, Thanks for your review. Unfortunately, I still saw the spurious interrupts with both fixes. After some experiments, it seems the HW will latch irq status even when IRQ is disabled. I can fix this issue by either ack irq before enable irq(like patch below), or not enable clock event before enable irq. I'll come up a fix base on this next time. evt->gpt_base + GPT_IRQ_EN_REG); Joe.C diff --git a/drivers/clocksource/mtk_timer.c b/drivers/clocksource/mtk_timer.c index 9a90c7b..c5f804a 100644 --- a/drivers/clocksource/mtk_timer.c +++ b/drivers/clocksource/mtk_timer.c @@ -184,6 +183,7 @@ static void mtk_timer_enable_irq(struct mtk_clock_event_device *evt, u8 timer) { u32 val; + writel(GPT_IRQ_ENABLE(timer), evt->gpt_base + GPT_IRQ_ACK_REG); val = readl(evt->gpt_base + GPT_IRQ_EN_REG); writel(val | GPT_IRQ_ENABLE(timer),