From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752669AbbGRWXM (ORCPT ); Sat, 18 Jul 2015 18:23:12 -0400 Received: from down.free-electrons.com ([37.187.137.238]:55007 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752574AbbGRWXL (ORCPT ); Sat, 18 Jul 2015 18:23:11 -0400 Date: Sun, 19 Jul 2015 00:23:08 +0200 From: Alexandre Belloni To: Thomas Gleixner Cc: Daniel Lezcano , Nicolas Ferre , Boris Brezillon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, David Dueck Subject: Re: [PATCH 1/3] clocksource: atmel-st: Remove irq handler when clock event is unused Message-ID: <20150718222308.GA30489@piout.net> References: <1437161608-26782-1-git-send-email-alexandre.belloni@free-electrons.com> <1437161608-26782-2-git-send-email-alexandre.belloni@free-electrons.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 18/07/2015 at 10:12:03 +0200, Thomas Gleixner wrote : > On Fri, 17 Jul 2015, Alexandre Belloni wrote: > > +static int atmel_st_request_irq(struct clock_event_device *dev) > > +{ > > + int ret; > > + > > + if (clockevent_state_periodic(dev) || clockevent_state_oneshot(dev)) > > + return 0; > > + > > + ret = request_irq(irq, at91rm9200_timer_interrupt, > > + IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL, > > + "at91_tick", regmap_st); > > + if (ret) { > > + pr_alert("Unable to setup IRQ\n"); > > + return ret; > > + } > > + > > return 0; > > } > > > > static int clkevt32k_set_oneshot(struct clock_event_device *dev) > > { > > + int ret; > > + > > clkdev32k_disable_and_flush_irq(); > > > > /* > > * ALM for oneshot irqs, set by next_event() > > * before 32 seconds have passed. > > */ > > + ret = atmel_st_request_irq(dev); > > You cannot call request_irq() from interrupt disabled context. It > works during early boot because might_sleep() is not active then, but > if that happens during normal runtime it wont work. > Indeed, clockevents_switch_state() has to be called with interrupts disabled. So I'm not sure anymore how we should go about this change (obviously, the same applies to the pit change). Do you have an idea? -- Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com From mboxrd@z Thu Jan 1 00:00:00 1970 From: alexandre.belloni@free-electrons.com (Alexandre Belloni) Date: Sun, 19 Jul 2015 00:23:08 +0200 Subject: [PATCH 1/3] clocksource: atmel-st: Remove irq handler when clock event is unused In-Reply-To: References: <1437161608-26782-1-git-send-email-alexandre.belloni@free-electrons.com> <1437161608-26782-2-git-send-email-alexandre.belloni@free-electrons.com> Message-ID: <20150718222308.GA30489@piout.net> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On 18/07/2015 at 10:12:03 +0200, Thomas Gleixner wrote : > On Fri, 17 Jul 2015, Alexandre Belloni wrote: > > +static int atmel_st_request_irq(struct clock_event_device *dev) > > +{ > > + int ret; > > + > > + if (clockevent_state_periodic(dev) || clockevent_state_oneshot(dev)) > > + return 0; > > + > > + ret = request_irq(irq, at91rm9200_timer_interrupt, > > + IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL, > > + "at91_tick", regmap_st); > > + if (ret) { > > + pr_alert("Unable to setup IRQ\n"); > > + return ret; > > + } > > + > > return 0; > > } > > > > static int clkevt32k_set_oneshot(struct clock_event_device *dev) > > { > > + int ret; > > + > > clkdev32k_disable_and_flush_irq(); > > > > /* > > * ALM for oneshot irqs, set by next_event() > > * before 32 seconds have passed. > > */ > > + ret = atmel_st_request_irq(dev); > > You cannot call request_irq() from interrupt disabled context. It > works during early boot because might_sleep() is not active then, but > if that happens during normal runtime it wont work. > Indeed, clockevents_switch_state() has to be called with interrupts disabled. So I'm not sure anymore how we should go about this change (obviously, the same applies to the pit change). Do you have an idea? -- Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com