From patchwork Fri Jun 3 14:15:58 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 846932 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p53EJnj8008625 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 3 Jun 2011 14:20:10 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QSVDc-00013v-Hw; Fri, 03 Jun 2011 14:19:22 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QSVDY-0006av-I4; Fri, 03 Jun 2011 14:19:16 +0000 Received: from service87.mimecast.com ([94.185.240.25]) by canuck.infradead.org with smtp (Exim 4.76 #1 (Red Hat Linux)) id 1QSVAQ-0005ex-DB for linux-arm-kernel@lists.infradead.org; Fri, 03 Jun 2011 14:16:05 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Fri, 03 Jun 2011 15:16:00 +0100 Received: from localhost.localdomain ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 3 Jun 2011 15:15:53 +0100 From: Marc Zyngier To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 14/14] ARM: exynos4: switch MCT to the full local timer infrastructure Date: Fri, 3 Jun 2011 15:15:58 +0100 Message-Id: <1307110558-29710-15-git-send-email-marc.zyngier@arm.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1307110558-29710-1-git-send-email-marc.zyngier@arm.com> References: <1307110558-29710-1-git-send-email-marc.zyngier@arm.com> X-OriginalArrivalTime: 03 Jun 2011 14:15:53.0367 (UTC) FILETIME=[BF667270:01CC21F8] X-MC-Unique: 111060315160003201 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110603_101602_803129_3BA0BCC2 X-CRM114-Status: GOOD ( 12.76 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [94.185.240.25 listed in list.dnswl.org] Cc: Kukjin Kim X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Fri, 03 Jun 2011 14:20:10 +0000 (UTC) Despite MCT not using PPIs, there is now no reason for not using the local timer infrastructure. Cc: Kukjin Kim Signed-off-by: Marc Zyngier --- arch/arm/mach-exynos4/mct.c | 68 ++++++++++++++++++------------------------ 1 files changed, 29 insertions(+), 39 deletions(-) diff --git a/arch/arm/mach-exynos4/mct.c b/arch/arm/mach-exynos4/mct.c index 14ac10b..1a30278 100644 --- a/arch/arm/mach-exynos4/mct.c +++ b/arch/arm/mach-exynos4/mct.c @@ -22,6 +22,7 @@ #include #include +#include #include static unsigned long clk_cnt_per_tick; @@ -30,9 +31,10 @@ static unsigned long clk_rate; struct mct_clock_event_device { struct clock_event_device *evt; void __iomem *base; + bool booted; }; -struct mct_clock_event_device mct_tick[2]; +static struct mct_clock_event_device mct_tick[2]; static void exynos4_mct_write(unsigned int value, void *addr) { @@ -307,17 +309,20 @@ static inline void exynos4_tick_set_mode(enum clock_event_mode mode, exynos4_mct_tick_start(clk_cnt_per_tick, mevt); break; - case CLOCK_EVT_MODE_ONESHOT: case CLOCK_EVT_MODE_UNUSED: + disable_irq(evt->irq); + /* fall through */ + case CLOCK_EVT_MODE_ONESHOT: case CLOCK_EVT_MODE_SHUTDOWN: case CLOCK_EVT_MODE_RESUME: break; } } -static irqreturn_t exynos4_mct_tick_isr(int irq, void *dev_id) +int local_timer_ack(void) { - struct mct_clock_event_device *mevt = dev_id; + unsigned int cpu = smp_processor_id(); + struct mct_clock_event_device *mevt = &mct_tick[cpu]; struct clock_event_device *evt = mevt->evt; /* @@ -330,27 +335,14 @@ static irqreturn_t exynos4_mct_tick_isr(int irq, void *dev_id) /* Clear the MCT tick interrupt */ exynos4_mct_write(0x1, mevt->base + MCT_L_INT_CSTAT_OFFSET); - - evt->event_handler(evt); - - return IRQ_HANDLED; + + return 1; } -static struct irqaction mct_tick0_event_irq = { - .name = "mct_tick0_irq", - .flags = IRQF_TIMER | IRQF_NOBALANCING, - .handler = exynos4_mct_tick_isr, -}; - -static struct irqaction mct_tick1_event_irq = { - .name = "mct_tick1_irq", - .flags = IRQF_TIMER | IRQF_NOBALANCING, - .handler = exynos4_mct_tick_isr, -}; - -static void exynos4_mct_tick_init(struct clock_event_device *evt) +int __cpuinit local_timer_setup(struct clock_event_device *evt) { unsigned int cpu = smp_processor_id(); + int err = 0; mct_tick[cpu].evt = evt; @@ -378,27 +370,25 @@ static void exynos4_mct_tick_init(struct clock_event_device *evt) exynos4_mct_write(0x1, mct_tick[cpu].base + MCT_L_TCNTB_OFFSET); - if (cpu == 0) { - mct_tick0_event_irq.dev_id = &mct_tick[cpu]; - setup_irq(IRQ_MCT_L0, &mct_tick0_event_irq); - } else { - mct_tick1_event_irq.dev_id = &mct_tick[cpu]; - irq_set_affinity(IRQ_MCT1, cpumask_of(1)); - setup_irq(IRQ_MCT_L1, &mct_tick1_event_irq); - } -} + if (cpu == 0) + evt->irq = IRQ_MCT_L0; + else + evt->irq = IRQ_MCT_L1; -/* Setup the local clock events for a CPU */ -void __cpuinit local_timer_setup(struct clock_event_device *evt) -{ - exynos4_mct_tick_init(evt); -} + if (!mct_tick[cpu].booted) { + irq_set_affinity(evt->irq, cpumask_of(cpu)); + err = request_irq(evt->irq, percpu_timer_handler, + IRQF_TIMER | IRQF_NOBALANCING, + evt->name, evt); -int local_timer_ack(void) -{ - return 0; -} + if (err) + pr_err("MCT: request_irq failed for %s\n", evt->name); + mct_tick[cpu].booted = true; + } else + enable_irq(evt->irq); + return err; +} #endif /* CONFIG_LOCAL_TIMERS */ static void __init exynos4_timer_resources(void)