Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161090AbbEUWFu (ORCPT ); Thu, 21 May 2015 18:05:50 -0400 Received: from mailapp01.imgtec.com ([195.59.15.196]:55914 "EHLO mailapp01.imgtec.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932339AbbEUWFr (ORCPT ); Thu, 21 May 2015 18:05:47 -0400 Message-ID: <555E55F4.2060500@imgtec.com> Date: Thu, 21 May 2015 19:02:28 -0300 From: Ezequiel Garcia User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Thomas Gleixner CC: , , "Daniel Lezcano" , , "Andrew Bresticker" , James Hartley , James Hogan , , Subject: Re: [PATCH 6/7] clocksource: Add Pistachio clocksource-only driver References: <1432244260-14908-1-git-send-email-ezequiel.garcia@imgtec.com> <1432244506-15388-1-git-send-email-ezequiel.garcia@imgtec.com> In-Reply-To: Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.100.200.44] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1144 Lines: 41 On 05/21/2015 07:00 PM, Thomas Gleixner wrote: > On Thu, 21 May 2015, Ezequiel Garcia wrote: >> +static cycle_t clocksource_read_cycles(struct clocksource *cs) >> +{ >> + u32 counter, overflw; >> + unsigned long flags; >> + >> + raw_spin_lock_irqsave(&lock, flags); > > Hmm. Is that lock really necessary to read that counter? The > clocksource is global. And if its actually used for timekeeping, the > lock can get heavy contended. > Yup, it is really (and sadly) necessary. The kernel hangs up completely without it when the counter is accesed by more than one CPU. Apparently, those two timer registers overflow and counter must be read atomically. >> + overflw = gpt_readl(TIMER_CURRENT_OVERFLOW_VALUE, 0); >> + counter = gpt_readl(TIMER_CURRENT_VALUE, 0); >> + raw_spin_unlock_irqrestore(&lock, flags); >> + >> + return ~(cycle_t)counter; >> +} > > Thanks, > > tglx > -- Ezequiel -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/