From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756288AbdJLUxQ (ORCPT ); Thu, 12 Oct 2017 16:53:16 -0400 Received: from mailgw1.fjfi.cvut.cz ([147.32.9.3]:50642 "EHLO mailgw1.fjfi.cvut.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751710AbdJLUxP (ORCPT ); Thu, 12 Oct 2017 16:53:15 -0400 X-CTU-FNSPE-Virus-Scanned: amavisd-new at fjfi.cvut.cz DKIM-Filter: OpenDKIM Filter v2.11.0 mailgw1.fjfi.cvut.cz A7A6FA04CB Date: Thu, 12 Oct 2017 22:53:09 +0200 (CEST) From: David Kozub To: Thomas Gleixner , Daniel Lezcano cc: linux-kernel@vger.kernel.org Subject: Re: PROBLEM: Kernel BUG in mfgpt_tick (cs5535-clockevt.c) on ALIX 2c3 - null call In-Reply-To: Message-ID: References: <8de07c60-8d37-802a-837c-a6cf356d1535@linaro.org> <29c0b5e6-3285-a307-4045-6b2b9f9747d6@linaro.org> User-Agent: Alpine 2.21 (LRH 202 2017-01-01) MIME-Version: 1.0 Content-Type: multipart/mixed; BOUNDARY="546533125-1994574312-1507840142=:2000" Content-ID: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --546533125-1994574312-1507840142=:2000 Content-Type: text/plain; CHARSET=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8BIT Content-ID: On Thu, 12 Oct 2017, Thomas Gleixner wrote: > On Thu, 12 Oct 2017, Daniel Lezcano wrote: > >> On 11/10/2017 22:48, David Kozub wrote: >> >> [ ... ] >> >>>> >>>> +       disable_timer(timer); >>>> +       cs5535_mfgpt_write(timer, MFGPT_REG_COUNTER, 0); >>>> + >>>>        /* Set up the IRQ on the MFGPT side */ >>>>        if (cs5535_mfgpt_setup_irq(timer, MFGPT_CMP2, &timer_irq)) { >>>>                printk(KERN_ERR DRV_NAME ": Could not set up IRQ %d\n", >>> >>> I tried that and the handler is still called. So I did some more random >>> experiments and I found out that if I call disable_timer(timer) twice, >>> then the issue is resolved (the handler is not called before the >>> registration is finished.) And I don't have to set MFGPT_REG_COUNTER to 0. >> >> Aha! we are close to a fix. >> >>> I have no idea why do I have to call disable_timer twice. >> >> For testing purpose, can you try by adding mmiowb() and/or wmb() after >> disable_timer()? I tried one, the other, both. Still, the unexpected handler call happens. I (again) added a msleep(1000) after the disable (and the barriers). If the trouble was a missing barrier, the sleep would most likely also make the isaue go away (even if in a hacky way). > The real question is why > > /* Set the clock scale and enable the event mode for CMP2 */ > val = MFGPT_SCALE | (3 << 8); > > cs5535_mfgpt_write(cs5535_event_clock, MFGPT_REG_SETUP, val); > > is in the setup code at all. > > The obvious place for this is in mfgpt_set_periodic() which gets called > when the clock event and the handler is set up in the core code. Up to that > point the interrupt handler is protected against shared interrupts via the > is_shutdown() check. It is, but only after clockevents_config_and_register. But mfgpt_tick is called before that (just after setup_irq). Best regards, David --546533125-1994574312-1507840142=:2000--