--- zzzz-none-000/linux-2.6.39.4/kernel/irq/proc.c 2011-08-03 19:43:28.000000000 +0000 +++ puma6-atom-6490-729/linux-2.6.39.4/kernel/irq/proc.c 2021-11-10 13:38:18.000000000 +0000 @@ -12,7 +12,11 @@ #include #include #include - +#ifdef CONFIG_INTEL_IRQ_THREAD_CHANGE_PRIORITY +#include +#include +#include +#endif #include "internals.h" static struct proc_dir_entry *root_irq_dir; @@ -118,6 +122,10 @@ .write = irq_affinity_proc_write, }; + + + + static const struct file_operations irq_affinity_hint_proc_fops = { .open = irq_affinity_hint_proc_open, .read = seq_read, @@ -265,6 +273,112 @@ #define MAX_NAMELEN 10 + +#ifdef CONFIG_INTEL_IRQ_THREAD_CHANGE_PRIORITY + +#define POLICY_POS 0 +#define PRIORITY_POS 1 +static int irq_schedule_param_proc_show(struct seq_file *m, void *v) +{ + + struct irq_desc *desc = irq_to_desc((long) m->private); + /* SCHED_ISO: reserved but not implemented yet */ + seq_printf(m,"\n The schedule param command usage: \n" + "\t \t\n" + "\t \t\n" + "\t \t\n" + "\t \t\n" + "\t \t\n"); + + seq_printf(m, "schedule param:\n\tschedule_policy %d\n" "\tschedule_priority %d\n", + desc->policy, desc->sched_priority); + return 0; +} +static ssize_t irq_schedule_param_proc_write(struct file *file, + const char __user *buffer, size_t count, loff_t *pos) +{ + unsigned int irq = (int)(long)PDE(file->f_path.dentry->d_inode)->data; + struct irq_desc *desc = irq_to_desc(irq); + unsigned long flags; + int tmp,err,i; + char proc_buffer[10], *value, *pbuf; + + if (count < PRIORITY_POS +1) + { + printk("irq_schedule_param_proc_write:wrong argc\n"); + return -EINVAL; + + } + /* Copy from user space. */ + if (copy_from_user (&proc_buffer, buffer, count)) + { + printk("irq_schedule_param_proc_write:copy_from_user failure\n"); + return -EFAULT; + } + pbuf = &proc_buffer[0]; + proc_buffer[count]='\0'; + raw_spin_lock_irqsave(&desc->lock, flags); + for (i = 0; i < (PRIORITY_POS + 1); i++) { + value = strsep(&pbuf, " "); + if (value != NULL) { + if(kstrtoint(strstrip(value),0,&tmp)) + { + printk("irq_schedule_param_proc_write:kstrtoint failure proc_buffer=%s value=%s\n",proc_buffer,value); + err = -EINVAL; + goto out; + } + switch(i){ + case POLICY_POS: + if (tmp != SCHED_FIFO && tmp != SCHED_RR && + tmp != SCHED_NORMAL && tmp != SCHED_BATCH && + tmp != SCHED_IDLE) + { + printk("irq_schedule_param_proc_write:policy failure\n"); + err = -EINVAL; + goto out; + } + desc->policy = tmp; + break; + case PRIORITY_POS: + if(tmp<0 || tmp > MAX_USER_RT_PRIO-1) + { + printk("irq_schedule_param_proc_write:priority failure\n"); + err = -EINVAL; + goto out; + } + desc->sched_priority = tmp; + break; + } + } + else + { + + err = -EINVAL; + goto out; + } + + } + err = count; +out: + raw_spin_unlock_irqrestore(&desc->lock, flags); + + return err; +} +static int irq_schedule_param_proc_open(struct inode *inode, struct file *file) +{ + return single_open(file, irq_schedule_param_proc_show, PDE(inode)->data); +} + +static const struct file_operations irq_schedule_param_proc_fops = { + .open = irq_schedule_param_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, + .write = irq_schedule_param_proc_write, +}; + +#endif + void register_irq_proc(unsigned int irq, struct irq_desc *desc) { char name [MAX_NAMELEN]; @@ -295,6 +409,10 @@ proc_create_data("spurious", 0444, desc->dir, &irq_spurious_proc_fops, (void *)(long)irq); +#ifdef CONFIG_INTEL_IRQ_THREAD_CHANGE_PRIORITY + proc_create_data("schedule_param", 0600, desc->dir, + &irq_schedule_param_proc_fops, (void *)(long)irq); +#endif } void unregister_irq_proc(unsigned int irq, struct irq_desc *desc) @@ -309,6 +427,9 @@ remove_proc_entry("node", desc->dir); #endif remove_proc_entry("spurious", desc->dir); +#ifdef CONFIG_INTEL_IRQ_THREAD_CHANGE_PRIORITY + remove_proc_entry("schedule_param", desc->dir); +#endif memset(name, 0, MAX_NAMELEN); sprintf(name, "%u", irq);