From patchwork Mon Apr 24 14:01:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 754276 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wBSk81yvHz9sN5 for ; Tue, 25 Apr 2017 00:03:44 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="o+n4J4fM"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="SWsqGet8"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=A6saWYmkVDoNNL0V+9+q0eNezUWvGKTVoCX5vhPs4O0=; b=o+n4J4fMZl9eXt kLawNs/AeDsfJfuKSmmMlVJqVv7yKC80PH74cxdGrT0wi9CgeUVaH4dp7dgyA2rkpN07kbjE5mSy3 nrNhZb/hOXC6XZP9ePUfhKtG8PeTd1IHY2K3wZNBOgrNHEu0h8fvQUwdbjwk/+PXfj47rNyqYnRzD ftgYwxcHdJS2bk0MGszoni1bzpfkVRLNdc0LgJ+vKx3Da2haQ2O5fXM5haX8GANhrbm4pwM+fLwIw JE1l+r2zMY6ysEGKjRddFQshg5GgBWWoFlyDvh0yTvlspQTSBQQCrLsyZlIwuhcRh8gRmmgWXerfh 9ASDH/0JsqfIONecD86w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d2eac-0008Ra-To; Mon, 24 Apr 2017 14:03:42 +0000 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d2eaP-0008E8-IB for linux-snps-arc@lists.infradead.org; Mon, 24 Apr 2017 14:03:32 +0000 Received: by mail-wm0-x232.google.com with SMTP id r190so68857804wme.1 for ; Mon, 24 Apr 2017 07:03:08 -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=aaVG34bbyRWFloZF5LrpJFCr+dv2UKhCJk9JaU9QvGY=; b=SWsqGet8w8VmX84t1d0551Nehw/Esyyku/tv0cdpmdB1d8cNJXJs48TD3SZxC67B0o FnE5+Oy/h1XeJ1/hM5RT09WR7Ep1n05Mk5ngvwNC01Q2ECA3sGGCfG44JgibkrBpQDZ7 zoV2gXojBO5ZLgFO7DkuDzwODbxByqiJhBL6c= 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=aaVG34bbyRWFloZF5LrpJFCr+dv2UKhCJk9JaU9QvGY=; b=B7I4+8+VcLGfz3UQoIc+34NYAVHt8ErPwd6M+zPydoJ3mpxiJhQYMow6TmHru0A170 s3GAO+4SaFNlg2+Shmsh2uta9KbOmZUQDLP7QwAp7e7h0qfflSeJaPCKYZgE3YbdW/ho b48iMr8543OloM+cquRWVplAXrtAC1YZpGwO0msPQJRz8R1IrshmzcaanWsCvCbPn8qa HyDT/CO5JyJ3wzq1nk0thY62XU3hs4WtycURUyEI300M40a8aN2LpDuOFhfTb+vGKerY mw65IRqtzeOiwEUZ0B9NrdjZ7FrgEA7n7mAmd5iBvpLQoapMYKZB5fY8dWM9TsiIOOrc adYg== X-Gm-Message-State: AN3rC/62mu5ffYGPruZSCvdbs151DnsxOiKJDbSA/Gir3OjiFbwA02Eb BVBYwEMl9QwkAwPx X-Received: by 10.28.130.210 with SMTP id e201mr9637304wmd.128.1493042586958; Mon, 24 Apr 2017 07:03:06 -0700 (PDT) Received: from localhost.localdomain (lft31-1-88-121-166-205.fbx.proxad.net. [88.121.166.205]) by smtp.gmail.com with ESMTPSA id s137sm408565wme.31.2017.04.24.07.03.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Apr 2017 07:03:06 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de Subject: [PATCH V9 1/3] irq: Allow to pass the IRQF_TIMER flag with percpu irq request Date: Mon, 24 Apr 2017 16:01:31 +0200 Message-Id: <1493042494-14057-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170424_070329_906894_DF2CD26C X-CRM114-Status: GOOD ( 20.37 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:232 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , linux-samsung-soc@vger.kernel.org, kernel@stlinux.com, kvm@vger.kernel.org, =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Marc Zyngier , Vineet Gupta , Patrice Chotard , Krzysztof Kozlowski , linux-kernel@vger.kernel.org, Javier Martinez Canillas , Kukjin Kim , linux-arm-kernel@lists.infradead.org, Paolo Bonzini , linux-snps-arc@lists.infradead.org, kvmarm@lists.cs.columbia.edu, Christoffer Dall Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.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: Krzysztof Kozlowski Cc: Javier Martinez Canillas Cc: Christoffer Dall Cc: Paolo Bonzini Cc: Radim Krčmář Acked-by: Krzysztof Kozlowski --- Changelog: 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 ++++++++++----- virt/kvm/arm/arch_timer.c | 5 +++-- 11 files changed, 55 insertions(+), 33 deletions(-) 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 7517f95..993e6af 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 7a8a411..d9d00b0 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c @@ -768,25 +768,29 @@ static int __init arch_timer_register(void) ppi = arch_timer_ppi[arch_timer_uses_ppi]; switch (arch_timer_uses_ppi) { case 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 PHYS_SECURE_PPI: case 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_ppi[PHYS_NONSECURE_PPI]) { ppi = arch_timer_ppi[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[PHYS_SECURE_PPI], arch_timer_evt); } break; case 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 4440aef..7405e14 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"); diff --git a/drivers/clocksource/timer-nps.c b/drivers/clocksource/timer-nps.c index da1f798..195f039 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 53144e7..8f44f23 100644 --- a/include/linux/interrupt.h +++ b/include/linux/interrupt.h @@ -152,8 +152,17 @@ struct irqaction { 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 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 ae1c90f..1ba7734 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -1951,9 +1951,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 * @@ -1966,8 +1967,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; @@ -1981,12 +1983,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; @@ -2007,7 +2012,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. diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index 35d7100..602e0a8 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c @@ -523,8 +523,9 @@ int kvm_timer_hyp_init(void) host_vtimer_irq_flags = IRQF_TRIGGER_LOW; } - err = request_percpu_irq(host_vtimer_irq, kvm_arch_timer_handler, - "kvm guest timer", kvm_get_running_vcpus()); + err = request_percpu_irq_flags(host_vtimer_irq, kvm_arch_timer_handler, + IRQF_TIMER, "kvm guest timer", + kvm_get_running_vcpus()); if (err) { kvm_err("kvm_arch_timer: can't request interrupt %d (%d)\n", host_vtimer_irq, err);