From patchwork Thu Jul 6 12:29:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 107141 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2044502qge; Thu, 6 Jul 2017 05:30:41 -0700 (PDT) X-Received: by 10.84.132.40 with SMTP id 37mr13175148ple.178.1499344241837; Thu, 06 Jul 2017 05:30:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499344241; cv=none; d=google.com; s=arc-20160816; b=qqI3OhhfEn7t4c4PtjD6mZH0NRSuHbJS85iJUIrOfT0AOM8lTW9af3l21NRM/FvJVl ZwG1I7AAdvDxLIMA2a/BgiTNImmknsS9mlUITEwyn4kqyfESqocvu11DpKUnHiNlV75k qnlT6HRr8ay4pD6pncs8DNkSN49xSjSSc9H4BS3q8WPOt01RztVnyl5i3rAfzoDWM3OH WGwRbnhu8d8Qsx+BQX2TDdJlzPyF2eGkRPQwVjp4pmxpKmOZe8+opNTau0hSt3bjGKn9 aAgao3YbEMlA4LQ371LFodQMxTYay4RdKcrF6dlhU4AmUB9TlEt2MNF4GCu0T3lWWOFX dLYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=JrscfCG0bVx5+1X6IB5wPBMboJMvmCqG3SKweSWEGyg=; b=yi3fiSWw6iVZPJH8TtiJu5zQroHQFLPsPpwQS46XicfwmFktU87apejXDEyrXNQ0r+ Dx+tuhkt4rGmnvJqBtcoMNDEXxSsUhQzKZXUpGeAW4Bgx0DJBuf3SqbwoeicbcQ/l59w iMlWtXZAu1zS+EPP0nfU5xio3ss+EFtumMjgVOqIIIvWlP6IOcFfp94+9QNrB63tClTB QS0x9rGcygK6J5klLmR/nZOXehu6I+TTmCj3aEZSM27BmzWC1puVQeXFcZdCturfchgY Tb0SNsCHfEQH4S3eBfF/ZpgSU4X3El+4quy3YtRmVp/utuavqkfQ0EQJQyu9ha3xl3j9 fwYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=XutbRuus; 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 g1si46440plb.21.2017.07.06.05.30.41; Thu, 06 Jul 2017 05:30:41 -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 header.b=XutbRuus; 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 S1752571AbdGFMae (ORCPT + 25 others); Thu, 6 Jul 2017 08:30:34 -0400 Received: from mail-wr0-f177.google.com ([209.85.128.177]:33858 "EHLO mail-wr0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751900AbdGFMac (ORCPT ); Thu, 6 Jul 2017 08:30:32 -0400 Received: by mail-wr0-f177.google.com with SMTP id 77so961263wrb.1 for ; Thu, 06 Jul 2017 05:30:32 -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:in-reply-to:references; bh=JrscfCG0bVx5+1X6IB5wPBMboJMvmCqG3SKweSWEGyg=; b=XutbRuus8RlyrijKejPAXxTmefyhp9A4jHku5ZzGCPmQZhCWPrOHu8CDpDZptL1gXW 6VsE28/U6wBuSaXT/LSiIQAxivxH3O3tpltTH4Fu4wmoaWSzMbBGXNAS0y3jJRyfFdaG ZH9SqkLn33qpBeZ/qqvNobrR306kfgp/zkqFE= 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:in-reply-to :references; bh=JrscfCG0bVx5+1X6IB5wPBMboJMvmCqG3SKweSWEGyg=; b=K54D9ESe+OBF/Nv8v5mKdwwQWsff1mfcDPi3Pu6V975CLtP41bOmRK5mKtacaC0Rav HvzRi51077TBJBh/JPcYwwvkvzfdhIIwLlSiCU7YpxTpBeX/5H0EYaXTlRnAo/zm4KeL KwbjDd6B0p08HR/3lS5o5Gsk0XA/EUJSozqdDUZfmcfd2llnmAyG/4BRk3uIJJ2RNJ1S 7/TcV2HgSNrLTMIhilBA7teXxER9Q1J3jPB1A/AmW3F1TjCe7WprVyRcAqJWnxvSkLB3 PyasV8h+e4aRqswnPJO2p4NaAfkVZ98kUWIaEXLqHf4NoTjZ1C6SEVpVL2BTBfnAaAVp qOGQ== X-Gm-Message-State: AIVw113LF+lCYzD8IiAScv9UUkvUdzWFNDXLa/iGvKVkfWMiRasBDN6c SAqGlUHGMu+L5GM0 X-Received: by 10.28.21.72 with SMTP id 69mr10173103wmv.75.1499344231145; Thu, 06 Jul 2017 05:30:31 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:6ca1:bc24:9912:9113]) by smtp.gmail.com with ESMTPSA id 55sm46487wrt.36.2017.07.06.05.30.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Jul 2017 05:30:30 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, vincent.guittot@linaro.org, peterz@infradead.org, rafael@kernel.org, nicolas.pitre@linaro.org Subject: [PATCH V11] irq: Allow to pass the IRQF_TIMER flag with percpu irq request Date: Thu, 6 Jul 2017 14:29:04 +0200 Message-Id: <1499344144-3964-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The irq timings infrastructure tracks when the interrupts occur in order to statistically compute when is supposed to happen an interrupt. In all the interruptions, it does not make sense to store the timer interrupt occurences and try to predict the next interrupt as we 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() where we can specify the flags. The request_percpu_irq() function is changed to be a wrapper to __request_percpu_irq() passing a zero flag parameter. 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() function. Signed-off-by: Daniel Lezcano Cc: Mark Rutland --- Changelog: V11: - Drop the changes in the timer drivers and rename the function request_percpu_irq_flags to __request_percpu_irq. 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) Signed-off-by: Daniel Lezcano --- include/linux/interrupt.h | 11 ++++++++++- kernel/irq/manage.c | 15 ++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) -- 2.7.4 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h index 37f8e35..5ac6e23 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(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(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 5c11c17..f80baf7 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -1935,9 +1935,10 @@ int setup_percpu_irq(unsigned int irq, struct irqaction *act) } /** - * request_percpu_irq - allocate a percpu interrupt line + * __request_percpu_irq - 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 * @@ -1950,8 +1951,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(unsigned int irq, irq_handler_t handler, + unsigned long flags, const char *devname, + void __percpu *dev_id) { struct irqaction *action; struct irq_desc *desc; @@ -1965,12 +1967,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; @@ -1991,7 +1996,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); /** * irq_get_irqchip_state - returns the irqchip state of a interrupt.