genirq: Allow to pass the IRQF_TIMER flag with percpu irq request

The irq timings infrastructure tracks when interrupts occur in order to
statistically predict te next interrupt event.

There is no point to track timer interrupts and try to predict them because
the next expiration time is already known. This can be avoided via the
IRQF_TIMER flag which is passed by timer drivers in request_irq(). It marks
the interrupt as timer based which alloes to ignore these interrupts in the
timings code.

Per CPU interrupts which are requested via request_percpu_+irq() have no
flag argument, so marking per cpu timer interrupts is not possible and they
get tracked pointlessly.

Add __request_percpu_irq() as a variant of request_percpu_irq() with a
flags argument and make request_percpu_irq() an inline wrapper passing
flags = 0.

The flag parameter is restricted to IRQF_TIMER as all other IRQF_ flags
make no sense for per cpu interrupts.

The next step is to convert all existing users of request_percpu_irq() and
then remove the wrapper and the underscores.

[ tglx: Massaged changelog ]

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: peterz@infradead.org
Cc: nicolas.pitre@linaro.org
Cc: vincent.guittot@linaro.org
Cc: rafael@kernel.org
Link: http://lkml.kernel.org/r/1499344144-3964-1-git-send-email-daniel.lezcano@linaro.org

authored by

Daniel Lezcano and committed by
Thomas Gleixner
c80081b9 2343877f

+20 -6
+10 -1
include/linux/interrupt.h
··· 152 unsigned long flags, const char *name, void *dev_id); 153 154 extern int __must_check 155 request_percpu_irq(unsigned int irq, irq_handler_t handler, 156 - const char *devname, void __percpu *percpu_dev_id); 157 158 extern const void *free_irq(unsigned int, void *); 159 extern void free_percpu_irq(unsigned int, void __percpu *);
··· 152 unsigned long flags, const char *name, void *dev_id); 153 154 extern int __must_check 155 + __request_percpu_irq(unsigned int irq, irq_handler_t handler, 156 + unsigned long flags, const char *devname, 157 + void __percpu *percpu_dev_id); 158 + 159 + static inline int __must_check 160 request_percpu_irq(unsigned int irq, irq_handler_t handler, 161 + const char *devname, void __percpu *percpu_dev_id) 162 + { 163 + return __request_percpu_irq(irq, handler, 0, 164 + devname, percpu_dev_id); 165 + } 166 167 extern const void *free_irq(unsigned int, void *); 168 extern void free_percpu_irq(unsigned int, void __percpu *);
+10 -5
kernel/irq/manage.c
··· 1950 } 1951 1952 /** 1953 - * request_percpu_irq - allocate a percpu interrupt line 1954 * @irq: Interrupt line to allocate 1955 * @handler: Function to be called when the IRQ occurs. 1956 * @devname: An ascii name for the claiming device 1957 * @dev_id: A percpu cookie passed back to the handler function 1958 * ··· 1966 * the handler gets called with the interrupted CPU's instance of 1967 * that variable. 1968 */ 1969 - int request_percpu_irq(unsigned int irq, irq_handler_t handler, 1970 - const char *devname, void __percpu *dev_id) 1971 { 1972 struct irqaction *action; 1973 struct irq_desc *desc; ··· 1982 !irq_settings_is_per_cpu_devid(desc)) 1983 return -EINVAL; 1984 1985 action = kzalloc(sizeof(struct irqaction), GFP_KERNEL); 1986 if (!action) 1987 return -ENOMEM; 1988 1989 action->handler = handler; 1990 - action->flags = IRQF_PERCPU | IRQF_NO_SUSPEND; 1991 action->name = devname; 1992 action->percpu_dev_id = dev_id; 1993 ··· 2009 2010 return retval; 2011 } 2012 - EXPORT_SYMBOL_GPL(request_percpu_irq); 2013 2014 /** 2015 * irq_get_irqchip_state - returns the irqchip state of a interrupt.
··· 1950 } 1951 1952 /** 1953 + * __request_percpu_irq - allocate a percpu interrupt line 1954 * @irq: Interrupt line to allocate 1955 * @handler: Function to be called when the IRQ occurs. 1956 + * @flags: Interrupt type flags (IRQF_TIMER only) 1957 * @devname: An ascii name for the claiming device 1958 * @dev_id: A percpu cookie passed back to the handler function 1959 * ··· 1965 * the handler gets called with the interrupted CPU's instance of 1966 * that variable. 1967 */ 1968 + int __request_percpu_irq(unsigned int irq, irq_handler_t handler, 1969 + unsigned long flags, const char *devname, 1970 + void __percpu *dev_id) 1971 { 1972 struct irqaction *action; 1973 struct irq_desc *desc; ··· 1980 !irq_settings_is_per_cpu_devid(desc)) 1981 return -EINVAL; 1982 1983 + if (flags && flags != IRQF_TIMER) 1984 + return -EINVAL; 1985 + 1986 action = kzalloc(sizeof(struct irqaction), GFP_KERNEL); 1987 if (!action) 1988 return -ENOMEM; 1989 1990 action->handler = handler; 1991 + action->flags = flags | IRQF_PERCPU | IRQF_NO_SUSPEND; 1992 action->name = devname; 1993 action->percpu_dev_id = dev_id; 1994 ··· 2004 2005 return retval; 2006 } 2007 + EXPORT_SYMBOL_GPL(__request_percpu_irq); 2008 2009 /** 2010 * irq_get_irqchip_state - returns the irqchip state of a interrupt.