Bug 197795

Summary: write_irq_affinity not throw error number
Product: Drivers Reporter: Wen Yang (wenyang)
Component: OtherAssignee: drivers_other
Status: RESOLVED CODE_FIX    
Severity: normal    
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: all Subsystem:
Regression: No Bisected commit-id:

Description Wen Yang 2017-11-07 07:35:27 UTC
step1:irq 769's smp_affinity is cpu0:
# cat /proc/irq/769/smp_affinity
00000000,00000000,00000000,00000000,00000000,00000000,00000001

step2: I set irq affinity,use this command:
# echo 2 > /proc/irq/769/smp_affinity      

step3: view the result, no change:
# cat /proc/irq/769/smp_affinity
00000000,00000000,00000000,00000000,00000000,00000000,00000001

I use this stap script to trace:
probe kernel.function("__irq_set_affinity").return
{
                printf(">>> return %d \n", $return);
                printf(">>> call stack:   \n");
                        print_backtrace();
}

redo step1-3, the result is:
>>> return -28 
>>> call stack:   
Returning from:  0xffffffff8111e5b0 : __irq_set_affinity+0x0/0x70 [kernel]
Returning to  :  0xffffffff81122709 : write_irq_affinity.isra.3+0x119/0x140 [kernel]
 0xffffffff8112274c : irq_affinity_list_proc_write+0x1c/0x20 [kernel]
 0xffffffff8124acdd : proc_reg_write+0x3d/0x80 [kernel]
 0xffffffff811dfdcd : vfs_write+0xbd/0x1e0 [kernel]
 0xffffffff811e086f : sys_write+0x7f/0xe0 [kernel]
 0xffffffff81648849 : system_call_fastpath+0x16/0x1b [kernel]


it's because the write_irq_affinity function, not thow err number:
static ssize_t write_irq_affinity(int type, struct file *file,
		const char __user *buffer, size_t count, loff_t *pos)
{
	unsigned int irq = (int)(long)PDE_DATA(file_inode(file));
	cpumask_var_t new_value;
	int err;

	if (!irq_can_set_affinity(irq) || no_irq_affinity)
		return -EIO;

......
	if (!cpumask_intersects(new_value, cpu_online_mask)) {
		/* Special case for empty set - allow the architecture
		   code to set default SMP affinity. */
		err = irq_select_affinity_usr(irq, new_value) ? -EINVAL : count;
	} else {
		irq_set_affinity(irq, new_value);
==============> it should throw error number
		err = count;
	}

free_cpumask:
	free_cpumask_var(new_value);
	return err;
}