From patchwork Tue May 16 19:44:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 99890 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp2184090qge; Tue, 16 May 2017 12:45:33 -0700 (PDT) X-Received: by 10.99.126.20 with SMTP id z20mr13519098pgc.158.1494963933029; Tue, 16 May 2017 12:45:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494963933; cv=none; d=google.com; s=arc-20160816; b=FXcD7XenoNs3gvlXiUOK4ouRESRjSLKxEyIXUhnsQVaafwCX4Qveo+4lJZUCj7b6LN VKduAkDXBgl957AKh1BlKr9p/ewh+xsigTcsJiULfmsG3Lwp9BxXugFYiJMCu+GAwje0 hqAJdSNqI46F7zZmUMLvSB/b9o052AsL/CwcUa66g4vf0SjzxKhoMs4JTpPQlV9hkwRq Cv63wqN/A/y3kEI8dmw5PIJqyObTDhWedhKzw/BBPVG4CqyKkq9tjIGPNqybIzvzA2iS 6vkXQ9TzpQLyi/0PgMeuJ/VAMo6rAc0uLTqHbj6ljesqa++BFtgIwNxK5YaRlI9tgw1o 3r9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=n1vdezCWxlygBce4NSYAOXCgrQlgaOzWsUBj8NHBheM=; b=LIVKzGbvCMWfy6w2J4vprPmN90ha9By/8+PZmso0FvhvhxmTqr1Xw/Sv00gj/dRV8o idwxdnKioyjVVvq/LQF84jgUzbb1fBYMrPkuIzd0QTkTNlm0Q4dnPb3zPbLlTz8fb5Me pb+28IfjW5AAZyy3sD1EnSFjitK/WoxhGtbs/ZAZa3hktu2IbfVqi8Uu+zFyIdWqZQcG gcj4OQlfqD4WCDu5M+ZkeVhxWb/l3WDGNZtaAuZrLqdwBBwhVYgXgq+9nPMQfPr9NCSk yNPqt1Q2CXRl33WksA3iDnldcc/Lcz3YU9vpUanhdbOYXwdTFXPvLbHHkX34K03zFJ2f e5qA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i20si196837pfi.111.2017.05.16.12.45.32; Tue, 16 May 2017 12:45:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752744AbdEPTp3 (ORCPT + 25 others); Tue, 16 May 2017 15:45:29 -0400 Received: from mail-wm0-f47.google.com ([74.125.82.47]:38799 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750950AbdEPTpU (ORCPT ); Tue, 16 May 2017 15:45:20 -0400 Received: by mail-wm0-f47.google.com with SMTP id v15so103432028wmv.1 for ; Tue, 16 May 2017 12:45:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=n1vdezCWxlygBce4NSYAOXCgrQlgaOzWsUBj8NHBheM=; b=jeQWB+RJSDr1/ij+yX/TJh+oMQj6Txe253CxqODAeUe2e51p65kgIj+X3FjPWYW7a2 aHzqEFX8NPo0B9Ig7wEeGyDbx8Qi1w5koOyf2MXn7N9jgKEUo0v3cZ1MBBN3IzQssLNC tux1VR6MUbzI/MxAyZzYowvXze2/SY2MhaUco= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=n1vdezCWxlygBce4NSYAOXCgrQlgaOzWsUBj8NHBheM=; b=kWzHeS0IEZcv5S+Hi6WAwL90SVw2dQcYU3DDl0mCH9vH2aC/U5AvMkiTWkUNp9dhBy 5SqhW4qDSgKfPEPXsEnk3cSdkWqMMNVZ/TyGsKSWmw6HKgG27ueA9oZl9+QxJJb9W9+W VnIsTUIzHoIYuvx9+bNAplLXoEvp7WavSBY7o8yTd4mRy64oXoSr8WJHKs//Ew7c7Jtm 2RproUxsjnSxaG3pCX5ZxFV8Y2KvL2Px6n/i9PCTC/PZ+IknX75qpgefW++pszi4CiFU hIzvAXC/zla6QAWwMUCM7ZeBd1ZLOoY+Ek9qGjs23QQPVFR/Fbv5HhcgwtMrsx9zdimI tL5A== X-Gm-Message-State: AODbwcBxgci9rKJTWM2xbjqLdk+oDi/CMNKU1xlk0b48tV/aXEaf32YV DPLbzUuY6+9O939w X-Received: by 10.28.32.19 with SMTP id g19mr171858wmg.123.1494963918956; Tue, 16 May 2017 12:45:18 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:78a3:5e81:ca22:9f9b]) by smtp.gmail.com with ESMTPSA id x64sm3219599wrb.10.2017.05.16.12.45.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 May 2017 12:45:18 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de Cc: Mark Rutland , Vineet Gupta , Marc Zyngier , Patrice Chotard , Kukjin Kim , Javier Martinez Canillas , Christoffer Dall , Paolo Bonzini , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= , Krzysztof Kozlowski , Russell King , Carlo Caione , Richard Cochran , Christoph Hellwig , Jens Axboe , Hannes Reinecke , linux-arm-kernel@lists.infradead.org (moderated list:ARM PORT), linux-kernel@vger.kernel.org (open list), linux-snps-arc@lists.infradead.org (open list:SYNOPSYS ARC ARCH...), kernel@stlinux.com (open list:ARM/STI ARCHITECTURE), linux-samsung-soc@vger.kernel.org (moderated list:ARM/SAMSUNG EXYNO...) Subject: [PATCH V10 1/3] irq: Allow to pass the IRQF_TIMER flag with percpu irq request Date: Tue, 16 May 2017 21:44:32 +0200 Message-Id: <1494963880-16160-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the next changes, we track when the interrupts occur in order to statistically compute when is supposed to happen the next interrupt. In all the interruptions, it does not make sense to store the timer interrupt occurences and try to predict the next interrupt as when know the expiration time. The request_irq() has a irq flags parameter and the timer drivers use it to pass the IRQF_TIMER flag, letting us know the interrupt is coming from a timer. Based on this flag, we can discard these interrupts when tracking them. But, the API request_percpu_irq does not allow to pass a flag, hence specifying if the interrupt type is a timer. Add a function request_percpu_irq_flags() where we can specify the flags. The request_percpu_irq() function is changed to be a wrapper to request_percpu_irq_flags() passing a zero flag parameter. Change the timers using request_percpu_irq() to use request_percpu_irq_flags() instead with the IRQF_TIMER flag set. For now, in order to prevent a misusage of this parameter, only the IRQF_TIMER flag (or zero) is a valid parameter to be passed to the request_percpu_irq_flags() function. Signed-off-by: Daniel Lezcano Cc: Mark Rutland Cc: Vineet Gupta Cc: Marc Zyngier Cc: Patrice Chotard Cc: Kukjin Kim Cc: Javier Martinez Canillas Cc: Christoffer Dall Cc: Paolo Bonzini Cc: Radim Krčmář Acked-by: Krzysztof Kozlowski --- Changelog: V10: - Drop the change for arch arm virtual timer https://lkml.org/lkml/2017/4/25/184 V9: - Clarified the patch description - Fixed EXPORT_SYMBOL_GPL(request_percpu_irq_flags) --- arch/arm/kernel/smp_twd.c | 3 ++- drivers/clocksource/arc_timer.c | 4 ++-- drivers/clocksource/arm_arch_timer.c | 20 ++++++++++++-------- drivers/clocksource/arm_global_timer.c | 4 ++-- drivers/clocksource/exynos_mct.c | 7 ++++--- drivers/clocksource/qcom-timer.c | 4 ++-- drivers/clocksource/time-armada-370-xp.c | 9 +++++---- drivers/clocksource/timer-nps.c | 6 +++--- include/linux/interrupt.h | 11 ++++++++++- kernel/irq/manage.c | 15 ++++++++++----- 10 files changed, 52 insertions(+), 31 deletions(-) -- 2.7.4 diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c index 895ae51..ce9fdcf 100644 --- a/arch/arm/kernel/smp_twd.c +++ b/arch/arm/kernel/smp_twd.c @@ -332,7 +332,8 @@ static int __init twd_local_timer_common_register(struct device_node *np) goto out_free; } - err = request_percpu_irq(twd_ppi, twd_handler, "twd", twd_evt); + err = request_percpu_irq_flags(twd_ppi, twd_handler, IRQF_TIMER, "twd", + twd_evt); if (err) { pr_err("twd: can't register interrupt %d (%d)\n", twd_ppi, err); goto out_free; diff --git a/drivers/clocksource/arc_timer.c b/drivers/clocksource/arc_timer.c index 2164973..66f2632 100644 --- a/drivers/clocksource/arc_timer.c +++ b/drivers/clocksource/arc_timer.c @@ -301,8 +301,8 @@ static int __init arc_clockevent_setup(struct device_node *node) } /* Needs apriori irq_set_percpu_devid() done in intc map function */ - ret = request_percpu_irq(arc_timer_irq, timer_irq_handler, - "Timer0 (per-cpu-tick)", evt); + ret = request_percpu_irq_flags(arc_timer_irq, timer_irq_handler, IRQF_TIMER, + "Timer0 (per-cpu-tick)", evt); if (ret) { pr_err("clockevent: unable to request irq\n"); return ret; diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index 4bed671..22646b5 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c @@ -980,25 +980,29 @@ static int __init arch_timer_register(void) ppi = arch_timer_ppi[arch_timer_uses_ppi]; switch (arch_timer_uses_ppi) { case ARCH_TIMER_VIRT_PPI: - err = request_percpu_irq(ppi, arch_timer_handler_virt, - "arch_timer", arch_timer_evt); + err = request_percpu_irq_flags(ppi, arch_timer_handler_virt, + IRQF_TIMER, "arch_timer", + arch_timer_evt); break; case ARCH_TIMER_PHYS_SECURE_PPI: case ARCH_TIMER_PHYS_NONSECURE_PPI: - err = request_percpu_irq(ppi, arch_timer_handler_phys, - "arch_timer", arch_timer_evt); + err = request_percpu_irq_flags(ppi, arch_timer_handler_phys, + IRQF_TIMER, "arch_timer", + arch_timer_evt); if (!err && arch_timer_has_nonsecure_ppi()) { ppi = arch_timer_ppi[ARCH_TIMER_PHYS_NONSECURE_PPI]; - err = request_percpu_irq(ppi, arch_timer_handler_phys, - "arch_timer", arch_timer_evt); + err = request_percpu_irq_flags(ppi, arch_timer_handler_phys, + IRQF_TIMER, "arch_timer", + arch_timer_evt); if (err) free_percpu_irq(arch_timer_ppi[ARCH_TIMER_PHYS_SECURE_PPI], arch_timer_evt); } break; case ARCH_TIMER_HYP_PPI: - err = request_percpu_irq(ppi, arch_timer_handler_phys, - "arch_timer", arch_timer_evt); + err = request_percpu_irq_flags(ppi, arch_timer_handler_phys, + IRQF_TIMER, "arch_timer", + arch_timer_evt); break; default: BUG(); diff --git a/drivers/clocksource/arm_global_timer.c b/drivers/clocksource/arm_global_timer.c index 123ed20..5a72ec1 100644 --- a/drivers/clocksource/arm_global_timer.c +++ b/drivers/clocksource/arm_global_timer.c @@ -302,8 +302,8 @@ static int __init global_timer_of_register(struct device_node *np) goto out_clk; } - err = request_percpu_irq(gt_ppi, gt_clockevent_interrupt, - "gt", gt_evt); + err = request_percpu_irq_flags(gt_ppi, gt_clockevent_interrupt, + IRQF_TIMER, "gt", gt_evt); if (err) { pr_warn("global-timer: can't register interrupt %d (%d)\n", gt_ppi, err); diff --git a/drivers/clocksource/exynos_mct.c b/drivers/clocksource/exynos_mct.c index 670ff0f..a48ca0f 100644 --- a/drivers/clocksource/exynos_mct.c +++ b/drivers/clocksource/exynos_mct.c @@ -524,9 +524,10 @@ static int __init exynos4_timer_resources(struct device_node *np, void __iomem * if (mct_int_type == MCT_INT_PPI) { - err = request_percpu_irq(mct_irqs[MCT_L0_IRQ], - exynos4_mct_tick_isr, "MCT", - &percpu_mct_tick); + err = request_percpu_irq_flags(mct_irqs[MCT_L0_IRQ], + exynos4_mct_tick_isr, + IRQF_TIMER, "MCT", + &percpu_mct_tick); WARN(err, "MCT: can't request IRQ %d (%d)\n", mct_irqs[MCT_L0_IRQ], err); } else { diff --git a/drivers/clocksource/qcom-timer.c b/drivers/clocksource/qcom-timer.c index ee358cd..8e876fc 100644 --- a/drivers/clocksource/qcom-timer.c +++ b/drivers/clocksource/qcom-timer.c @@ -174,8 +174,8 @@ static int __init msm_timer_init(u32 dgt_hz, int sched_bits, int irq, } if (percpu) - res = request_percpu_irq(irq, msm_timer_interrupt, - "gp_timer", msm_evt); + res = request_percpu_irq_flags(irq, msm_timer_interrupt, + IRQF_TIMER, "gp_timer", msm_evt); if (res) { pr_err("request_percpu_irq failed\n"); diff --git a/drivers/clocksource/time-armada-370-xp.c b/drivers/clocksource/time-armada-370-xp.c index aea4380..fea81ad 100644 --- a/drivers/clocksource/time-armada-370-xp.c +++ b/drivers/clocksource/time-armada-370-xp.c @@ -309,10 +309,11 @@ static int __init armada_370_xp_timer_common_init(struct device_node *np) /* * Setup clockevent timer (interrupt-driven). */ - res = request_percpu_irq(armada_370_xp_clkevt_irq, - armada_370_xp_timer_interrupt, - "armada_370_xp_per_cpu_tick", - armada_370_xp_evt); + res = request_percpu_irq_flags(armada_370_xp_clkevt_irq, + armada_370_xp_timer_interrupt, + IRQF_TIMER, + "armada_370_xp_per_cpu_tick", + armada_370_xp_evt); /* Immediately configure the timer on the boot CPU */ if (res) { pr_err("Failed to request percpu irq\n"); diff --git a/drivers/clocksource/timer-nps.c b/drivers/clocksource/timer-nps.c index e74ea17..a83b6a4 100644 --- a/drivers/clocksource/timer-nps.c +++ b/drivers/clocksource/timer-nps.c @@ -256,9 +256,9 @@ static int __init nps_setup_clockevent(struct device_node *node) return ret; /* Needs apriori irq_set_percpu_devid() done in intc map function */ - ret = request_percpu_irq(nps_timer0_irq, timer_irq_handler, - "Timer0 (per-cpu-tick)", - &nps_clockevent_device); + ret = request_percpu_irq_flags(nps_timer0_irq, timer_irq_handler, + IRQF_TIMER, "Timer0 (per-cpu-tick)", + &nps_clockevent_device); if (ret) { pr_err("Couldn't request irq\n"); clk_disable_unprepare(clk); diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h index a6fba48..89defd5 100644 --- a/include/linux/interrupt.h +++ b/include/linux/interrupt.h @@ -152,8 +152,17 @@ request_any_context_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, const char *name, void *dev_id); extern int __must_check +request_percpu_irq_flags(unsigned int irq, irq_handler_t handler, + unsigned long flags, const char *devname, + void __percpu *percpu_dev_id); + +static inline int __must_check request_percpu_irq(unsigned int irq, irq_handler_t handler, - const char *devname, void __percpu *percpu_dev_id); + const char *devname, void __percpu *percpu_dev_id) +{ + return request_percpu_irq_flags(irq, handler, 0, + devname, percpu_dev_id); +} extern const void *free_irq(unsigned int, void *); extern void free_percpu_irq(unsigned int, void __percpu *); diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 070be98..057fde8 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -1958,9 +1958,10 @@ int setup_percpu_irq(unsigned int irq, struct irqaction *act) } /** - * request_percpu_irq - allocate a percpu interrupt line + * request_percpu_irq_flags - allocate a percpu interrupt line * @irq: Interrupt line to allocate * @handler: Function to be called when the IRQ occurs. + * @flags: Interrupt type flags (IRQF_TIMER only) * @devname: An ascii name for the claiming device * @dev_id: A percpu cookie passed back to the handler function * @@ -1973,8 +1974,9 @@ int setup_percpu_irq(unsigned int irq, struct irqaction *act) * the handler gets called with the interrupted CPU's instance of * that variable. */ -int request_percpu_irq(unsigned int irq, irq_handler_t handler, - const char *devname, void __percpu *dev_id) +int request_percpu_irq_flags(unsigned int irq, irq_handler_t handler, + unsigned long flags, const char *devname, + void __percpu *dev_id) { struct irqaction *action; struct irq_desc *desc; @@ -1988,12 +1990,15 @@ int request_percpu_irq(unsigned int irq, irq_handler_t handler, !irq_settings_is_per_cpu_devid(desc)) return -EINVAL; + if (flags && flags != IRQF_TIMER) + return -EINVAL; + action = kzalloc(sizeof(struct irqaction), GFP_KERNEL); if (!action) return -ENOMEM; action->handler = handler; - action->flags = IRQF_PERCPU | IRQF_NO_SUSPEND; + action->flags = flags | IRQF_PERCPU | IRQF_NO_SUSPEND; action->name = devname; action->percpu_dev_id = dev_id; @@ -2014,7 +2019,7 @@ int request_percpu_irq(unsigned int irq, irq_handler_t handler, return retval; } -EXPORT_SYMBOL_GPL(request_percpu_irq); +EXPORT_SYMBOL_GPL(request_percpu_irq_flags); /** * irq_get_irqchip_state - returns the irqchip state of a interrupt.