Merge f20e2fdaae ("Merge tag 'timers-clocksource-2026-06-13' of gitolite.kernel.org:pub/scm/linux/kernel/git/tip/tip") into android-mainline
Steps on the way to v7.2-rc1 Change-Id: I9c90ece98c5f7d66f2f2e799484e220224e327bb Signed-off-by: Carlos Llamas <cmllamas@google.com>
This commit is contained in:
commit
c3601310a9
109 files changed
+4538
-1223
No files matched your search
+6
-2
@@ -49,9 +49,11 @@ int irq_set_chip(unsigned int irq, const struct irq_chip *chip)
|
||||
scoped_irqdesc->irq_data.chip = (struct irq_chip *)(chip ?: &no_irq_chip);
|
||||
ret = 0;
|
||||
}
|
||||
/* For !CONFIG_SPARSE_IRQ make the irq show up in allocated_irqs. */
|
||||
if (!ret)
|
||||
if (!ret) {
|
||||
/* For !CONFIG_SPARSE_IRQ make the irq show up in allocated_irqs. */
|
||||
irq_mark_irq(irq);
|
||||
irq_proc_update_chip(chip);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(irq_set_chip);
|
||||
@@ -1027,6 +1029,7 @@ __irq_do_set_handler(struct irq_desc *desc, irq_flow_handler_t handle,
|
||||
WARN_ON(irq_chip_pm_get(irq_desc_get_irq_data(desc)));
|
||||
irq_activate_and_startup(desc, IRQ_RESEND);
|
||||
}
|
||||
irq_proc_update_valid(desc);
|
||||
}
|
||||
|
||||
void __irq_set_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
|
||||
@@ -1087,6 +1090,7 @@ void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set)
|
||||
trigger = tmp;
|
||||
|
||||
irqd_set(&desc->irq_data, trigger);
|
||||
irq_proc_update_valid(desc);
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(irq_modify_status);
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#ifndef _KERNEL_IRQ_DEBUGFS_H
|
||||
#define _KERNEL_IRQ_DEBUGFS_H
|
||||
|
||||
#ifdef CONFIG_GENERIC_IRQ_DEBUGFS
|
||||
#include <linux/debugfs.h>
|
||||
|
||||
struct irq_bit_descr {
|
||||
unsigned int mask;
|
||||
char *name;
|
||||
};
|
||||
|
||||
#define BIT_MASK_DESCR(m) { .mask = m, .name = #m }
|
||||
|
||||
void irq_debug_show_bits(struct seq_file *m, int ind, unsigned int state,
|
||||
const struct irq_bit_descr *sd, int size);
|
||||
|
||||
void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *desc);
|
||||
static inline void irq_remove_debugfs_entry(struct irq_desc *desc)
|
||||
{
|
||||
debugfs_remove(desc->debugfs_file);
|
||||
kfree(desc->dev_name);
|
||||
}
|
||||
void irq_debugfs_copy_devname(int irq, struct device *dev);
|
||||
# ifdef CONFIG_IRQ_DOMAIN
|
||||
void irq_domain_debugfs_init(struct dentry *root);
|
||||
# else
|
||||
static inline void irq_domain_debugfs_init(struct dentry *root)
|
||||
{
|
||||
}
|
||||
# endif
|
||||
#else /* CONFIG_GENERIC_IRQ_DEBUGFS */
|
||||
static inline void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *d)
|
||||
{
|
||||
}
|
||||
static inline void irq_remove_debugfs_entry(struct irq_desc *d)
|
||||
{
|
||||
}
|
||||
static inline void irq_debugfs_copy_devname(int irq, struct device *dev)
|
||||
{
|
||||
}
|
||||
#endif /* CONFIG_GENERIC_IRQ_DEBUGFS */
|
||||
|
||||
#endif
|
||||
+24
-40
@@ -9,8 +9,12 @@
|
||||
#include <linux/irqdesc.h>
|
||||
#include <linux/kernel_stat.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
#include <linux/rcuref.h>
|
||||
#include <linux/sched/clock.h>
|
||||
|
||||
#include "debugfs.h"
|
||||
#include "proc.h"
|
||||
|
||||
#ifdef CONFIG_SPARSE_IRQ
|
||||
# define MAX_SPARSE_IRQS INT_MAX
|
||||
#else
|
||||
@@ -21,6 +25,7 @@
|
||||
|
||||
extern bool noirqdebug;
|
||||
extern int irq_poll_cpu;
|
||||
extern unsigned int total_nr_irqs;
|
||||
|
||||
extern struct irqaction chained_action;
|
||||
|
||||
@@ -100,9 +105,23 @@ extern void unmask_irq(struct irq_desc *desc);
|
||||
extern void unmask_threaded_irq(struct irq_desc *desc);
|
||||
|
||||
#ifdef CONFIG_SPARSE_IRQ
|
||||
static inline void irq_mark_irq(unsigned int irq) { }
|
||||
static __always_inline void irq_mark_irq(unsigned int irq) { }
|
||||
void irq_desc_free_rcu(struct irq_desc *desc);
|
||||
|
||||
static __always_inline bool irq_desc_get_ref(struct irq_desc *desc)
|
||||
{
|
||||
return rcuref_get(&desc->refcnt);
|
||||
}
|
||||
|
||||
static __always_inline void irq_desc_put_ref(struct irq_desc *desc)
|
||||
{
|
||||
if (rcuref_put(&desc->refcnt))
|
||||
irq_desc_free_rcu(desc);
|
||||
}
|
||||
#else
|
||||
extern void irq_mark_irq(unsigned int irq);
|
||||
static __always_inline bool irq_desc_get_ref(struct irq_desc *desc) { return true; }
|
||||
static __always_inline void irq_desc_put_ref(struct irq_desc *desc) { }
|
||||
#endif
|
||||
|
||||
irqreturn_t __handle_irq_event_percpu(struct irq_desc *desc);
|
||||
@@ -122,6 +141,7 @@ extern void register_irq_proc(unsigned int irq, struct irq_desc *desc);
|
||||
extern void unregister_irq_proc(unsigned int irq, struct irq_desc *desc);
|
||||
extern void register_handler_proc(unsigned int irq, struct irqaction *action);
|
||||
extern void unregister_handler_proc(unsigned int irq, struct irqaction *action);
|
||||
void irq_proc_update_valid(struct irq_desc *desc);
|
||||
#else
|
||||
static inline void register_irq_proc(unsigned int irq, struct irq_desc *desc) { }
|
||||
static inline void unregister_irq_proc(unsigned int irq, struct irq_desc *desc) { }
|
||||
@@ -129,8 +149,11 @@ static inline void register_handler_proc(unsigned int irq,
|
||||
struct irqaction *action) { }
|
||||
static inline void unregister_handler_proc(unsigned int irq,
|
||||
struct irqaction *action) { }
|
||||
static inline void irq_proc_update_valid(struct irq_desc *desc) { }
|
||||
#endif
|
||||
|
||||
struct irq_desc *irq_find_desc_at_or_after(unsigned int offset);
|
||||
|
||||
extern bool irq_can_set_affinity_usr(unsigned int irq);
|
||||
|
||||
extern int irq_do_set_affinity(struct irq_data *data,
|
||||
@@ -372,42 +395,3 @@ static inline struct irq_data *irqd_get_parent_data(struct irq_data *irqd)
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef CONFIG_GENERIC_IRQ_DEBUGFS
|
||||
#include <linux/debugfs.h>
|
||||
|
||||
struct irq_bit_descr {
|
||||
unsigned int mask;
|
||||
char *name;
|
||||
};
|
||||
|
||||
#define BIT_MASK_DESCR(m) { .mask = m, .name = #m }
|
||||
|
||||
void irq_debug_show_bits(struct seq_file *m, int ind, unsigned int state,
|
||||
const struct irq_bit_descr *sd, int size);
|
||||
|
||||
void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *desc);
|
||||
static inline void irq_remove_debugfs_entry(struct irq_desc *desc)
|
||||
{
|
||||
debugfs_remove(desc->debugfs_file);
|
||||
kfree(desc->dev_name);
|
||||
}
|
||||
void irq_debugfs_copy_devname(int irq, struct device *dev);
|
||||
# ifdef CONFIG_IRQ_DOMAIN
|
||||
void irq_domain_debugfs_init(struct dentry *root);
|
||||
# else
|
||||
static inline void irq_domain_debugfs_init(struct dentry *root)
|
||||
{
|
||||
}
|
||||
# endif
|
||||
#else /* CONFIG_GENERIC_IRQ_DEBUGFS */
|
||||
static inline void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *d)
|
||||
{
|
||||
}
|
||||
static inline void irq_remove_debugfs_entry(struct irq_desc *d)
|
||||
{
|
||||
}
|
||||
static inline void irq_debugfs_copy_devname(int irq, struct device *dev)
|
||||
{
|
||||
}
|
||||
#endif /* CONFIG_GENERIC_IRQ_DEBUGFS */
|
||||
+39
-31
@@ -137,17 +137,18 @@ static void desc_set_defaults(unsigned int irq, struct irq_desc *desc, int node,
|
||||
desc->tot_count = 0;
|
||||
desc->name = NULL;
|
||||
desc->owner = owner;
|
||||
rcuref_init(&desc->refcnt, 1);
|
||||
desc_smp_init(desc, node, affinity);
|
||||
}
|
||||
|
||||
static unsigned int nr_irqs = NR_IRQS;
|
||||
unsigned int total_nr_irqs __read_mostly = NR_IRQS;
|
||||
|
||||
/**
|
||||
* irq_get_nr_irqs() - Number of interrupts supported by the system.
|
||||
*/
|
||||
unsigned int irq_get_nr_irqs(void)
|
||||
{
|
||||
return nr_irqs;
|
||||
return total_nr_irqs;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(irq_get_nr_irqs);
|
||||
|
||||
@@ -157,13 +158,12 @@ EXPORT_SYMBOL_GPL(irq_get_nr_irqs);
|
||||
*
|
||||
* Return: @nr.
|
||||
*/
|
||||
unsigned int irq_set_nr_irqs(unsigned int nr)
|
||||
unsigned int __init irq_set_nr_irqs(unsigned int nr)
|
||||
{
|
||||
nr_irqs = nr;
|
||||
|
||||
total_nr_irqs = nr;
|
||||
irq_proc_calc_prec();
|
||||
return nr;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(irq_set_nr_irqs);
|
||||
|
||||
static DEFINE_MUTEX(sparse_irq_lock);
|
||||
static struct maple_tree sparse_irqs = MTREE_INIT_EXT(sparse_irqs,
|
||||
@@ -181,15 +181,12 @@ static int irq_find_free_area(unsigned int from, unsigned int cnt)
|
||||
return mas.index;
|
||||
}
|
||||
|
||||
static unsigned int irq_find_at_or_after(unsigned int offset)
|
||||
struct irq_desc *irq_find_desc_at_or_after(unsigned int offset)
|
||||
{
|
||||
unsigned long index = offset;
|
||||
struct irq_desc *desc;
|
||||
|
||||
guard(rcu)();
|
||||
desc = mt_find(&sparse_irqs, &index, nr_irqs);
|
||||
|
||||
return desc ? irq_desc_get_irq(desc) : nr_irqs;
|
||||
lockdep_assert_in_rcu_read_lock();
|
||||
return mt_find(&sparse_irqs, &index, total_nr_irqs);
|
||||
}
|
||||
|
||||
static void irq_insert_desc(unsigned int irq, struct irq_desc *desc)
|
||||
@@ -464,6 +461,17 @@ static void delayed_free_desc(struct rcu_head *rhp)
|
||||
kobject_put(&desc->kobj);
|
||||
}
|
||||
|
||||
void irq_desc_free_rcu(struct irq_desc *desc)
|
||||
{
|
||||
/*
|
||||
* We free the descriptor, masks and stat fields via RCU. That
|
||||
* allows demultiplex interrupts to do rcu based management of
|
||||
* the child interrupts.
|
||||
* This also allows us to use rcu in kstat_irqs_usr().
|
||||
*/
|
||||
call_rcu(&desc->rcu, delayed_free_desc);
|
||||
}
|
||||
|
||||
static void free_desc(unsigned int irq)
|
||||
{
|
||||
struct irq_desc *desc = irq_to_desc(irq);
|
||||
@@ -482,14 +490,7 @@ static void free_desc(unsigned int irq)
|
||||
*/
|
||||
irq_sysfs_del(desc);
|
||||
delete_irq_desc(irq);
|
||||
|
||||
/*
|
||||
* We free the descriptor, masks and stat fields via RCU. That
|
||||
* allows demultiplex interrupts to do rcu based management of
|
||||
* the child interrupts.
|
||||
* This also allows us to use rcu in kstat_irqs_usr().
|
||||
*/
|
||||
call_rcu(&desc->rcu, delayed_free_desc);
|
||||
irq_desc_put_ref(desc);
|
||||
}
|
||||
|
||||
static int alloc_descs(unsigned int start, unsigned int cnt, int node,
|
||||
@@ -541,7 +542,8 @@ static bool irq_expand_nr_irqs(unsigned int nr)
|
||||
{
|
||||
if (nr > MAX_SPARSE_IRQS)
|
||||
return false;
|
||||
nr_irqs = nr;
|
||||
total_nr_irqs = nr;
|
||||
irq_proc_calc_prec();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -555,21 +557,22 @@ int __init early_irq_init(void)
|
||||
/* Let arch update nr_irqs and return the nr of preallocated irqs */
|
||||
initcnt = arch_probe_nr_irqs();
|
||||
printk(KERN_INFO "NR_IRQS: %d, nr_irqs: %d, preallocated irqs: %d\n",
|
||||
NR_IRQS, nr_irqs, initcnt);
|
||||
NR_IRQS, total_nr_irqs, initcnt);
|
||||
|
||||
if (WARN_ON(nr_irqs > MAX_SPARSE_IRQS))
|
||||
nr_irqs = MAX_SPARSE_IRQS;
|
||||
if (WARN_ON(total_nr_irqs > MAX_SPARSE_IRQS))
|
||||
total_nr_irqs = MAX_SPARSE_IRQS;
|
||||
|
||||
if (WARN_ON(initcnt > MAX_SPARSE_IRQS))
|
||||
initcnt = MAX_SPARSE_IRQS;
|
||||
|
||||
if (initcnt > nr_irqs)
|
||||
nr_irqs = initcnt;
|
||||
if (initcnt > total_nr_irqs)
|
||||
total_nr_irqs = initcnt;
|
||||
|
||||
for (i = 0; i < initcnt; i++) {
|
||||
desc = alloc_desc(i, node, 0, NULL, NULL);
|
||||
irq_insert_desc(i, desc);
|
||||
}
|
||||
irq_proc_calc_prec();
|
||||
return arch_early_irq_init();
|
||||
}
|
||||
|
||||
@@ -590,7 +593,7 @@ int __init early_irq_init(void)
|
||||
|
||||
init_irq_default_affinity();
|
||||
|
||||
printk(KERN_INFO "NR_IRQS: %d\n", NR_IRQS);
|
||||
pr_info("NR_IRQS: %d\n", NR_IRQS);
|
||||
|
||||
count = ARRAY_SIZE(irq_desc);
|
||||
|
||||
@@ -600,6 +603,7 @@ int __init early_irq_init(void)
|
||||
goto __free_desc_res;
|
||||
}
|
||||
|
||||
irq_proc_calc_prec();
|
||||
return arch_early_irq_init();
|
||||
|
||||
__free_desc_res:
|
||||
@@ -860,7 +864,7 @@ void irq_free_descs(unsigned int from, unsigned int cnt)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (from >= nr_irqs || (from + cnt) > nr_irqs)
|
||||
if (from >= total_nr_irqs || (from + cnt) > total_nr_irqs)
|
||||
return;
|
||||
|
||||
guard(mutex)(&sparse_irq_lock);
|
||||
@@ -909,7 +913,7 @@ int __ref __irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int no
|
||||
if (irq >=0 && start != irq)
|
||||
return -EEXIST;
|
||||
|
||||
if (start + cnt > nr_irqs) {
|
||||
if (start + cnt > total_nr_irqs) {
|
||||
if (!irq_expand_nr_irqs(start + cnt))
|
||||
return -ENOMEM;
|
||||
}
|
||||
@@ -921,11 +925,15 @@ EXPORT_SYMBOL_GPL(__irq_alloc_descs);
|
||||
* irq_get_next_irq - get next allocated irq number
|
||||
* @offset: where to start the search
|
||||
*
|
||||
* Returns next irq number after offset or nr_irqs if none is found.
|
||||
* Returns next irq number after offset or total_nr_irqs if none is found.
|
||||
*/
|
||||
unsigned int irq_get_next_irq(unsigned int offset)
|
||||
{
|
||||
return irq_find_at_or_after(offset);
|
||||
struct irq_desc *desc;
|
||||
|
||||
guard(rcu)();
|
||||
desc = irq_find_desc_at_or_after(offset);
|
||||
return desc ? irq_desc_get_irq(desc) : total_nr_irqs;
|
||||
}
|
||||
|
||||
struct irq_desc *__irq_get_desc_lock(unsigned int irq, unsigned long *flags, bool bus,
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include <linux/smp.h>
|
||||
#include <linux/fs.h>
|
||||
|
||||
#include "proc.h"
|
||||
|
||||
static LIST_HEAD(irq_domain_list);
|
||||
static DEFINE_MUTEX(irq_domain_mutex);
|
||||
|
||||
@@ -1532,6 +1534,7 @@ int irq_domain_set_hwirq_and_chip(struct irq_domain *domain, unsigned int virq,
|
||||
irq_data->chip = (struct irq_chip *)(chip ? chip : &no_irq_chip);
|
||||
irq_data->chip_data = chip_data;
|
||||
|
||||
irq_proc_update_chip(chip);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(irq_domain_set_hwirq_and_chip);
|
||||
@@ -2081,7 +2084,7 @@ static void irq_domain_free_one_irq(struct irq_domain *domain, unsigned int virq
|
||||
#endif /* CONFIG_IRQ_DOMAIN_HIERARCHY */
|
||||
|
||||
#ifdef CONFIG_GENERIC_IRQ_DEBUGFS
|
||||
#include "internals.h"
|
||||
#include "debugfs.h"
|
||||
|
||||
static struct dentry *domain_dir;
|
||||
|
||||
|
||||
+28
-17
@@ -1802,6 +1802,7 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)
|
||||
__enable_irq(desc);
|
||||
}
|
||||
|
||||
irq_proc_update_valid(desc);
|
||||
raw_spin_unlock_irqrestore(&desc->lock, flags);
|
||||
chip_bus_sync_unlock(desc);
|
||||
mutex_unlock(&desc->request_mutex);
|
||||
@@ -1906,6 +1907,7 @@ static struct irqaction *__free_irq(struct irq_desc *desc, void *dev_id)
|
||||
desc->affinity_hint = NULL;
|
||||
#endif
|
||||
|
||||
irq_proc_update_valid(desc);
|
||||
raw_spin_unlock_irqrestore(&desc->lock, flags);
|
||||
/*
|
||||
* Drop bus_lock here so the changes which were done in the chip
|
||||
@@ -2026,24 +2028,32 @@ const void *free_irq(unsigned int irq, void *dev_id)
|
||||
}
|
||||
EXPORT_SYMBOL(free_irq);
|
||||
|
||||
/* This function must be called with desc->lock held */
|
||||
static const void *__cleanup_nmi(unsigned int irq, struct irq_desc *desc)
|
||||
{
|
||||
struct irqaction *action = NULL;
|
||||
const char *devname = NULL;
|
||||
|
||||
desc->istate &= ~IRQS_NMI;
|
||||
scoped_guard(raw_spinlock_irqsave, &desc->lock) {
|
||||
irq_nmi_teardown(desc);
|
||||
|
||||
if (!WARN_ON(desc->action == NULL)) {
|
||||
irq_pm_remove_action(desc, desc->action);
|
||||
devname = desc->action->name;
|
||||
unregister_handler_proc(irq, desc->action);
|
||||
desc->istate &= ~IRQS_NMI;
|
||||
|
||||
kfree(desc->action);
|
||||
if (!WARN_ON(desc->action == NULL)) {
|
||||
action = desc->action;
|
||||
irq_pm_remove_action(desc, action);
|
||||
devname = action->name;
|
||||
}
|
||||
desc->action = NULL;
|
||||
|
||||
irq_settings_clr_disable_unlazy(desc);
|
||||
irq_shutdown_and_deactivate(desc);
|
||||
}
|
||||
|
||||
irq_settings_clr_disable_unlazy(desc);
|
||||
irq_shutdown_and_deactivate(desc);
|
||||
irq_proc_update_valid(desc);
|
||||
|
||||
if (action)
|
||||
unregister_handler_proc(irq, action);
|
||||
kfree(action);
|
||||
|
||||
irq_release_resources(desc);
|
||||
|
||||
@@ -2067,8 +2077,6 @@ const void *free_nmi(unsigned int irq, void *dev_id)
|
||||
if (WARN_ON(desc->depth == 0))
|
||||
disable_nmi_nosync(irq);
|
||||
|
||||
guard(raw_spinlock_irqsave)(&desc->lock);
|
||||
irq_nmi_teardown(desc);
|
||||
return __cleanup_nmi(irq, desc);
|
||||
}
|
||||
|
||||
@@ -2318,13 +2326,14 @@ int request_nmi(unsigned int irq, irq_handler_t handler,
|
||||
/* Setup NMI state */
|
||||
desc->istate |= IRQS_NMI;
|
||||
retval = irq_nmi_setup(desc);
|
||||
if (retval) {
|
||||
__cleanup_nmi(irq, desc);
|
||||
return -EINVAL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (retval) {
|
||||
__cleanup_nmi(irq, desc);
|
||||
return -EINVAL;
|
||||
}
|
||||
return 0;
|
||||
|
||||
err_irq_setup:
|
||||
irq_chip_pm_put(&desc->irq_data);
|
||||
err_out:
|
||||
@@ -2428,8 +2437,10 @@ static struct irqaction *__free_percpu_irq(unsigned int irq, void __percpu *dev_
|
||||
*action_ptr = action->next;
|
||||
|
||||
/* Demote from NMI if we killed the last action */
|
||||
if (!desc->action)
|
||||
if (!desc->action) {
|
||||
desc->istate &= ~IRQS_NMI;
|
||||
irq_proc_update_valid(desc);
|
||||
}
|
||||
}
|
||||
|
||||
unregister_handler_proc(irq, action);
|
||||
|
||||
+194
-42
@@ -10,6 +10,7 @@
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/seq_file.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/kernel_stat.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/string.h>
|
||||
@@ -326,7 +327,7 @@ void register_handler_proc(unsigned int irq, struct irqaction *action)
|
||||
|
||||
#undef MAX_NAMELEN
|
||||
|
||||
#define MAX_NAMELEN 10
|
||||
#define MAX_NAMELEN 11
|
||||
|
||||
void register_irq_proc(unsigned int irq, struct irq_desc *desc)
|
||||
{
|
||||
@@ -348,7 +349,7 @@ void register_irq_proc(unsigned int irq, struct irq_desc *desc)
|
||||
return;
|
||||
|
||||
/* create /proc/irq/1234 */
|
||||
sprintf(name, "%u", irq);
|
||||
snprintf(name, MAX_NAMELEN, "%u", irq);
|
||||
desc->dir = proc_mkdir(name, root_irq_dir);
|
||||
if (!desc->dir)
|
||||
return;
|
||||
@@ -401,7 +402,7 @@ void unregister_irq_proc(unsigned int irq, struct irq_desc *desc)
|
||||
#endif
|
||||
remove_proc_entry("spurious", desc->dir);
|
||||
|
||||
sprintf(name, "%u", irq);
|
||||
snprintf(name, MAX_NAMELEN, "%u", irq);
|
||||
remove_proc_entry(name, root_irq_dir);
|
||||
}
|
||||
|
||||
@@ -439,77 +440,159 @@ void init_irq_proc(void)
|
||||
register_irq_proc(irq, desc);
|
||||
}
|
||||
|
||||
void irq_proc_update_valid(struct irq_desc *desc)
|
||||
{
|
||||
u32 set = _IRQ_PROC_VALID;
|
||||
|
||||
if (irq_settings_is_hidden(desc) || irq_desc_is_chained(desc) || !desc->action)
|
||||
set = 0;
|
||||
|
||||
irq_settings_update_proc_valid(desc, set);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_GENERIC_IRQ_SHOW
|
||||
|
||||
#define ARCH_PROC_IRQDESC ((void *)0x00001111)
|
||||
|
||||
int __weak arch_show_interrupts(struct seq_file *p, int prec)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static DEFINE_RAW_SPINLOCK(irq_proc_constraints_lock);
|
||||
|
||||
static struct irq_proc_constraints {
|
||||
bool print_header;
|
||||
unsigned int num_prec;
|
||||
unsigned int chip_width;
|
||||
} irq_proc_constraints __read_mostly = {
|
||||
.num_prec = 4,
|
||||
.chip_width = 8,
|
||||
};
|
||||
|
||||
#ifndef ACTUAL_NR_IRQS
|
||||
# define ACTUAL_NR_IRQS irq_get_nr_irqs()
|
||||
# define ACTUAL_NR_IRQS total_nr_irqs
|
||||
#endif
|
||||
|
||||
int show_interrupts(struct seq_file *p, void *v)
|
||||
void irq_proc_calc_prec(void)
|
||||
{
|
||||
const unsigned int nr_irqs = irq_get_nr_irqs();
|
||||
static int prec;
|
||||
unsigned int prec, n;
|
||||
|
||||
int i = *(loff_t *) v, j;
|
||||
for (prec = 4, n = 10000; prec < 10 && n <= total_nr_irqs; ++prec)
|
||||
n *= 10;
|
||||
|
||||
guard(raw_spinlock_irqsave)(&irq_proc_constraints_lock);
|
||||
if (prec > irq_proc_constraints.num_prec)
|
||||
WRITE_ONCE(irq_proc_constraints.num_prec, prec);
|
||||
}
|
||||
|
||||
void irq_proc_update_chip(const struct irq_chip *chip)
|
||||
{
|
||||
unsigned int len = chip && chip->name ? strlen(chip->name) : 0;
|
||||
|
||||
if (!len || len <= READ_ONCE(irq_proc_constraints.chip_width))
|
||||
return;
|
||||
|
||||
/* Can be invoked from interrupt disabled contexts */
|
||||
guard(raw_spinlock_irqsave)(&irq_proc_constraints_lock);
|
||||
if (len > irq_proc_constraints.chip_width)
|
||||
WRITE_ONCE(irq_proc_constraints.chip_width, len);
|
||||
}
|
||||
|
||||
/* Same as seq_put_decimal_ull_width(p, " ", cnt, 10) */
|
||||
#define ZSTR1 " 0"
|
||||
#define ZSTR1_LEN (sizeof(ZSTR1) - 1)
|
||||
#define ZSTR16 ZSTR1 ZSTR1 ZSTR1 ZSTR1 ZSTR1 ZSTR1 ZSTR1 ZSTR1 \
|
||||
ZSTR1 ZSTR1 ZSTR1 ZSTR1 ZSTR1 ZSTR1 ZSTR1 ZSTR1
|
||||
#define ZSTR256 ZSTR16 ZSTR16 ZSTR16 ZSTR16 ZSTR16 ZSTR16 ZSTR16 ZSTR16 \
|
||||
ZSTR16 ZSTR16 ZSTR16 ZSTR16 ZSTR16 ZSTR16 ZSTR16 ZSTR16
|
||||
|
||||
static inline void irq_proc_emit_zero_counts(struct seq_file *p, unsigned int zeros)
|
||||
{
|
||||
if (!zeros)
|
||||
return;
|
||||
|
||||
for (unsigned int n = min(zeros, 256); n; zeros -= n, n = min(zeros, 256))
|
||||
seq_write(p, ZSTR256, n * ZSTR1_LEN);
|
||||
}
|
||||
|
||||
static inline unsigned int irq_proc_emit_count(struct seq_file *p, unsigned int cnt,
|
||||
unsigned int zeros)
|
||||
{
|
||||
if (!cnt)
|
||||
return zeros + 1;
|
||||
|
||||
irq_proc_emit_zero_counts(p, zeros);
|
||||
seq_put_decimal_ull_width(p, " ", cnt, 10);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void irq_proc_emit_counts(struct seq_file *p, unsigned int __percpu *cnts)
|
||||
{
|
||||
unsigned int cpu, zeros = 0;
|
||||
|
||||
for_each_online_cpu(cpu)
|
||||
zeros = irq_proc_emit_count(p, per_cpu(*cnts, cpu), zeros);
|
||||
irq_proc_emit_zero_counts(p, zeros);
|
||||
}
|
||||
|
||||
static int irq_seq_show(struct seq_file *p, void *v)
|
||||
{
|
||||
struct irq_proc_constraints *constr = p->private;
|
||||
struct irq_desc *desc = v;
|
||||
struct irqaction *action;
|
||||
struct irq_desc *desc;
|
||||
|
||||
if (i > ACTUAL_NR_IRQS)
|
||||
return 0;
|
||||
/* Print header for the first interrupt? */
|
||||
if (constr->print_header) {
|
||||
unsigned int cpu;
|
||||
|
||||
if (i == ACTUAL_NR_IRQS)
|
||||
return arch_show_interrupts(p, prec);
|
||||
|
||||
/* print header and calculate the width of the first column */
|
||||
if (i == 0) {
|
||||
for (prec = 3, j = 1000; prec < 10 && j <= nr_irqs; ++prec)
|
||||
j *= 10;
|
||||
|
||||
seq_printf(p, "%*s", prec + 8, "");
|
||||
for_each_online_cpu(j)
|
||||
seq_printf(p, "CPU%-8d", j);
|
||||
seq_printf(p, "%*s", constr->num_prec + 8, "");
|
||||
for_each_online_cpu(cpu)
|
||||
seq_printf(p, "CPU%-8d", cpu);
|
||||
seq_putc(p, '\n');
|
||||
constr->print_header = false;
|
||||
}
|
||||
|
||||
guard(rcu)();
|
||||
desc = irq_to_desc(i);
|
||||
if (!desc || irq_settings_is_hidden(desc))
|
||||
return 0;
|
||||
if (desc == ARCH_PROC_IRQDESC)
|
||||
return arch_show_interrupts(p, constr->num_prec);
|
||||
|
||||
if (!desc->action || irq_desc_is_chained(desc) || !desc->kstat_irqs)
|
||||
return 0;
|
||||
seq_put_decimal_ull_width(p, "", irq_desc_get_irq(desc), constr->num_prec);
|
||||
seq_putc(p, ':');
|
||||
|
||||
seq_printf(p, "%*d:", prec, i);
|
||||
for_each_online_cpu(j) {
|
||||
unsigned int cnt = desc->kstat_irqs ? per_cpu(desc->kstat_irqs->cnt, j) : 0;
|
||||
/*
|
||||
* Always output per CPU interrupts. Output device interrupts only when
|
||||
* desc::tot_count is not zero.
|
||||
*/
|
||||
if (irq_settings_is_per_cpu(desc) || irq_settings_is_per_cpu_devid(desc) ||
|
||||
data_race(desc->tot_count))
|
||||
irq_proc_emit_counts(p, &desc->kstat_irqs->cnt);
|
||||
else
|
||||
irq_proc_emit_zero_counts(p, num_online_cpus());
|
||||
|
||||
seq_put_decimal_ull_width(p, " ", cnt, 10);
|
||||
}
|
||||
seq_putc(p, ' ');
|
||||
/* Enforce a visual gap */
|
||||
seq_write(p, " ", 2);
|
||||
|
||||
guard(raw_spinlock_irq)(&desc->lock);
|
||||
if (desc->irq_data.chip) {
|
||||
if (desc->irq_data.chip->irq_print_chip)
|
||||
desc->irq_data.chip->irq_print_chip(&desc->irq_data, p);
|
||||
else if (desc->irq_data.chip->name)
|
||||
seq_printf(p, "%8s", desc->irq_data.chip->name);
|
||||
seq_printf(p, "%-*s", constr->chip_width, desc->irq_data.chip->name);
|
||||
else
|
||||
seq_printf(p, "%8s", "-");
|
||||
seq_printf(p, "%-*s", constr->chip_width, "-");
|
||||
} else {
|
||||
seq_printf(p, "%8s", "None");
|
||||
seq_printf(p, "%-*s", constr->chip_width, "None");
|
||||
}
|
||||
|
||||
seq_putc(p, ' ');
|
||||
if (desc->irq_data.domain)
|
||||
seq_printf(p, " %*lu", prec, desc->irq_data.hwirq);
|
||||
seq_put_decimal_ull_width(p, "", desc->irq_data.hwirq, constr->num_prec);
|
||||
else
|
||||
seq_printf(p, " %*s", prec, "");
|
||||
#ifdef CONFIG_GENERIC_IRQ_SHOW_LEVEL
|
||||
seq_printf(p, " %-8s", irqd_is_level_type(&desc->irq_data) ? "Level" : "Edge");
|
||||
#endif
|
||||
seq_printf(p, " %*s", constr->num_prec, "");
|
||||
|
||||
if (IS_ENABLED(CONFIG_GENERIC_IRQ_SHOW_LEVEL))
|
||||
seq_printf(p, " %-8s", irqd_is_level_type(&desc->irq_data) ? "Level" : "Edge");
|
||||
|
||||
if (desc->name)
|
||||
seq_printf(p, "-%-8s", desc->name);
|
||||
|
||||
@@ -523,4 +606,73 @@ int show_interrupts(struct seq_file *p, void *v)
|
||||
seq_putc(p, '\n');
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void *irq_seq_next_desc(loff_t *pos)
|
||||
{
|
||||
if (*pos > total_nr_irqs)
|
||||
return NULL;
|
||||
|
||||
guard(rcu)();
|
||||
for (;;) {
|
||||
struct irq_desc *desc = irq_find_desc_at_or_after((unsigned int) *pos);
|
||||
|
||||
if (desc) {
|
||||
*pos = irq_desc_get_irq(desc);
|
||||
/*
|
||||
* If valid for output then try to acquire a reference
|
||||
* count on the descriptor so that it can't be freed
|
||||
* after dropping RCU read lock on return.
|
||||
*/
|
||||
if (irq_settings_proc_valid(desc) && irq_desc_get_ref(desc))
|
||||
return desc;
|
||||
(*pos)++;
|
||||
} else {
|
||||
*pos = total_nr_irqs;
|
||||
return ARCH_PROC_IRQDESC;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void *irq_seq_start(struct seq_file *f, loff_t *pos)
|
||||
{
|
||||
if (!*pos) {
|
||||
struct irq_proc_constraints *constr = f->private;
|
||||
|
||||
constr->num_prec = READ_ONCE(irq_proc_constraints.num_prec);
|
||||
constr->chip_width = READ_ONCE(irq_proc_constraints.chip_width);
|
||||
constr->print_header = true;
|
||||
}
|
||||
return irq_seq_next_desc(pos);
|
||||
}
|
||||
|
||||
static void *irq_seq_next(struct seq_file *f, void *v, loff_t *pos)
|
||||
{
|
||||
if (v && v != ARCH_PROC_IRQDESC)
|
||||
irq_desc_put_ref(v);
|
||||
|
||||
(*pos)++;
|
||||
return irq_seq_next_desc(pos);
|
||||
}
|
||||
|
||||
static void irq_seq_stop(struct seq_file *f, void *v)
|
||||
{
|
||||
if (v && v != ARCH_PROC_IRQDESC)
|
||||
irq_desc_put_ref(v);
|
||||
}
|
||||
|
||||
static const struct seq_operations irq_seq_ops = {
|
||||
.start = irq_seq_start,
|
||||
.next = irq_seq_next,
|
||||
.stop = irq_seq_stop,
|
||||
.show = irq_seq_show,
|
||||
};
|
||||
|
||||
static int __init irq_proc_init(void)
|
||||
{
|
||||
proc_create_seq_private("interrupts", 0, NULL, &irq_seq_ops,
|
||||
sizeof(irq_proc_constraints), NULL);
|
||||
return 0;
|
||||
}
|
||||
fs_initcall(irq_proc_init);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,13 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#ifndef _KERNEL_IRQ_PROC_H
|
||||
#define _KERNEL_IRQ_PROC_H
|
||||
|
||||
#if defined(CONFIG_PROC_FS) && defined(CONFIG_GENERIC_IRQ_SHOW)
|
||||
void irq_proc_calc_prec(void);
|
||||
void irq_proc_update_chip(const struct irq_chip *chip);
|
||||
#else
|
||||
static inline void irq_proc_calc_prec(void) { }
|
||||
static inline void irq_proc_update_chip(const struct irq_chip *chip) { }
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -18,6 +18,7 @@ enum {
|
||||
_IRQ_DISABLE_UNLAZY = IRQ_DISABLE_UNLAZY,
|
||||
_IRQ_HIDDEN = IRQ_HIDDEN,
|
||||
_IRQ_NO_DEBUG = IRQ_NO_DEBUG,
|
||||
_IRQ_PROC_VALID = IRQ_RESERVED,
|
||||
_IRQF_MODIFY_MASK = IRQF_MODIFY_MASK,
|
||||
};
|
||||
|
||||
@@ -34,6 +35,7 @@ enum {
|
||||
#define IRQ_DISABLE_UNLAZY GOT_YOU_MORON
|
||||
#define IRQ_HIDDEN GOT_YOU_MORON
|
||||
#define IRQ_NO_DEBUG GOT_YOU_MORON
|
||||
#define IRQ_RESERVED GOT_YOU_MORON
|
||||
#undef IRQF_MODIFY_MASK
|
||||
#define IRQF_MODIFY_MASK GOT_YOU_MORON
|
||||
|
||||
@@ -180,3 +182,14 @@ static inline bool irq_settings_no_debug(struct irq_desc *desc)
|
||||
{
|
||||
return desc->status_use_accessors & _IRQ_NO_DEBUG;
|
||||
}
|
||||
|
||||
static inline bool irq_settings_proc_valid(struct irq_desc *desc)
|
||||
{
|
||||
return desc->status_use_accessors & _IRQ_PROC_VALID;
|
||||
}
|
||||
|
||||
static inline void irq_settings_update_proc_valid(struct irq_desc *desc, u32 set)
|
||||
{
|
||||
desc->status_use_accessors &= ~_IRQ_PROC_VALID;
|
||||
desc->status_use_accessors |= (set & _IRQ_PROC_VALID);
|
||||
}
|
||||
@@ -1338,6 +1338,26 @@ int __clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(__clocksource_register_scale);
|
||||
|
||||
static void __devm_clocksource_unregister(void *data)
|
||||
{
|
||||
struct clocksource *cs = data;
|
||||
|
||||
clocksource_unregister(cs);
|
||||
}
|
||||
|
||||
int __devm_clocksource_register_scale(struct device *dev, struct clocksource *cs,
|
||||
u32 scale, u32 freq)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = __clocksource_register_scale(cs, scale, freq);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return devm_add_action_or_reset(dev, __devm_clocksource_unregister, cs);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(__devm_clocksource_register_scale);
|
||||
|
||||
/*
|
||||
* Unbind clocksource @cs. Called with clocksource_mutex held
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user