All of lore.kernel.org
 help / color / mirror / Atom feed
From: alexandre.belloni@free-electrons.com (Alexandre Belloni)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/3] clocksource: atmel-pit: Remove irq handler when clock event is unused
Date: Sun, 19 Jul 2015 00:18:37 +0200	[thread overview]
Message-ID: <20150718221837.GK3487@piout.net> (raw)
In-Reply-To: <alpine.DEB.2.11.1507181013050.18576@nanos>

On 18/07/2015 at 10:20:53 +0200, Thomas Gleixner wrote :
> 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());
> 

Yeah, I was skeptical when I read that...

> 
> > +	/* 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.
> 

... for both comments, this is just code I'm moving from one place to
another. I'll have a look a clean that up in a preliminary patch.
Thanks!


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

WARNING: multiple messages have this Message-ID (diff)
From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>,
	Nicolas Ferre <nicolas.ferre@atmel.com>,
	Boris Brezillon <boris.brezillon@free-electrons.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	David Dueck <davidcdueck@googlemail.com>
Subject: Re: [PATCH 3/3] clocksource: atmel-pit: Remove irq handler when clock event is unused
Date: Sun, 19 Jul 2015 00:18:37 +0200	[thread overview]
Message-ID: <20150718221837.GK3487@piout.net> (raw)
In-Reply-To: <alpine.DEB.2.11.1507181013050.18576@nanos>

On 18/07/2015 at 10:20:53 +0200, Thomas Gleixner wrote :
> 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());
> 

Yeah, I was skeptical when I read that...

> 
> > +	/* 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.
> 

... for both comments, this is just code I'm moving from one place to
another. I'll have a look a clean that up in a preliminary patch.
Thanks!


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

  reply	other threads:[~2015-07-18 22:18 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-17 19:33 [PATCH 0/3] clocksource: at91: Remove irq handler when clock event is unused Alexandre Belloni
2015-07-17 19:33 ` Alexandre Belloni
2015-07-17 19:33 ` [PATCH 1/3] clocksource: atmel-st: " Alexandre Belloni
2015-07-17 19:33   ` Alexandre Belloni
2015-07-18  8:12   ` Thomas Gleixner
2015-07-18  8:12     ` Thomas Gleixner
2015-07-18 22:23     ` Alexandre Belloni
2015-07-18 22:23       ` Alexandre Belloni
2015-07-20  9:04       ` Thomas Gleixner
2015-07-20  9:04         ` Thomas Gleixner
2015-07-20 19:37         ` Alexandre Belloni
2015-07-20 19:37           ` Alexandre Belloni
2015-07-20 20:46           ` Thomas Gleixner
2015-07-20 20:46             ` Thomas Gleixner
2015-08-02  9:10             ` Thomas Gleixner
2015-08-02  9:10               ` Thomas Gleixner
2015-08-02  9:40               ` Peter Zijlstra
2015-08-02  9:40                 ` Peter Zijlstra
2015-08-03 13:30                 ` Boris Brezillon
2015-08-03 13:30                   ` Boris Brezillon
2015-08-03 14:36                   ` Thomas Gleixner
2015-08-03 14:36                     ` Thomas Gleixner
2015-08-03 20:07                     ` Boris Brezillon
2015-08-03 20:07                       ` Boris Brezillon
2015-07-17 19:33 ` [PATCH 2/3] clocksource: atmel-pit: drop at91sam926x_pit_common_init Alexandre Belloni
2015-07-17 19:33   ` Alexandre Belloni
2015-07-17 19:33 ` [PATCH 3/3] clocksource: atmel-pit: Remove irq handler when clock event is unused Alexandre Belloni
2015-07-17 19:33   ` Alexandre Belloni
2015-07-18  8:20   ` Thomas Gleixner
2015-07-18  8:20     ` Thomas Gleixner
2015-07-18 22:18     ` Alexandre Belloni [this message]
2015-07-18 22:18       ` Alexandre Belloni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150718221837.GK3487@piout.net \
    --to=alexandre.belloni@free-electrons.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.