From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752352AbbGRIVL (ORCPT ); Sat, 18 Jul 2015 04:21:11 -0400 Received: from www.linutronix.de ([62.245.132.108]:50403 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751253AbbGRIVI (ORCPT ); Sat, 18 Jul 2015 04:21:08 -0400 Date: Sat, 18 Jul 2015 10:20:53 +0200 (CEST) From: Thomas Gleixner To: Alexandre Belloni cc: Daniel Lezcano , Nicolas Ferre , Boris Brezillon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, David Dueck Subject: Re: [PATCH 3/3] clocksource: atmel-pit: Remove irq handler when clock event is unused In-Reply-To: <1437161608-26782-4-git-send-email-alexandre.belloni@free-electrons.com> Message-ID: References: <1437161608-26782-1-git-send-email-alexandre.belloni@free-electrons.com> <1437161608-26782-4-git-send-email-alexandre.belloni@free-electrons.com> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 17 Jul 2015, Alexandre Belloni wrote: > /* > + * IRQ handler for the timer. > + */ > +static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id) > +{ > + struct pit_data *data = dev_id; > + > + /* > + * irqs should be disabled here, but as the irq is shared they are only > + * guaranteed to be off if the timer irq is registered first. That's wrong. We run all handlers with interrupts disabled for about 5 years now. > + */ > + WARN_ON_ONCE(!irqs_disabled()); > + /* The PIT interrupt may be disabled, and is shared */ > + if (clockevent_state_periodic(&data->clkevt) && > + (pit_read(data->base, AT91_PIT_SR) & AT91_PIT_PITS)) { > + unsigned nr_ticks; > + > + /* Get number of ticks performed before irq, and ack it */ > + nr_ticks = PIT_PICNT(pit_read(data->base, AT91_PIT_PIVR)); > + do { > + data->cnt += data->cycle; > + data->clkevt.event_handler(&data->clkevt); > + nr_ticks--; > + } while (nr_ticks); I don't think you need this loop. You have a proper clocksource registered so the timekeeping code will handle the lost ticks nicely. Thanks, tglx