#include #include #include #include #include #include #include #include #include "irq.h" #include "str.h" #include "die.h" int device_irq_number(const char *ifname) { int irq = 0; char buff[128], sysname[128]; FILE *fp; if (!strncmp("lo", ifname, strlen("lo"))) return 0; slprintf(sysname, sizeof(sysname), "/sys/class/net/%s/device/irq", ifname); fp = fopen(sysname, "r"); if (!fp) return -ENOENT; memset(buff, 0, sizeof(buff)); if (fgets(buff, sizeof(buff), fp) != NULL) { buff[sizeof(buff) - 1] = 0; irq = atoi(buff); } fclose(fp); return irq; } static char nic_irq_affinity_list[128]; static bool nic_irq_stored = false; static int nic_irq = -1; static void device_save_irq_affinity_list(void) { int ret, fd; char file[128]; bug_on(nic_irq_stored); slprintf(file, sizeof(file), "/proc/irq/%d/smp_affinity_list", nic_irq); fd = open(file, O_RDONLY); if (fd < 0) return; memset(nic_irq_affinity_list, 0, sizeof(nic_irq_affinity_list)); ret = read(fd, nic_irq_affinity_list, sizeof(nic_irq_affinity_list)); if (ret < 0) panic("Cannot store NIC IRQ affinity!\n"); close(fd); nic_irq_stored = true; } void device_restore_irq_affinity_list(void) { int ret, fd; char file[128]; if (!nic_irq_stored) return; bug_on(nic_irq == -1); slprintf(file, sizeof(file), "/proc/irq/%d/smp_affinity_list", nic_irq); fd = open(file, O_WRONLY); if (fd < 0) return; ret = write(fd, nic_irq_affinity_list, sizeof(nic_irq_affinity_list)); if (ret < 0) panic("Cannot restore NIC IRQ affinity!\n"); close(fd); } int device_set_irq_affinity_list(int irq, unsigned long from, unsigned long to) { int ret, fd; char file[128], list[64]; if (unlikely(irq == 0)) return 0; if (!nic_irq_stored) { nic_irq = irq; device_save_irq_affinity_list(); } slprintf(file, sizeof(file), "/proc/irq/%d/smp_affinity_list", irq); slprintf(list, sizeof(list), "%lu-%lu\n", from, to); fd = open(file, O_WRONLY); if (fd < 0) return -ENOENT; ret = write(fd, list, strlen(list)); close(fd); return ret; } int device_set_irq_affinity(int irq, unsigned long cpu) { return device_set_irq_affinity_list(irq, cpu, cpu); } t.git/log/'>
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2016-08-09 21:54:53 +0200
committerIngo Molnar <mingo@kernel.org>2016-08-10 14:37:06 +0200
commit22cc1ca3c5469cf17e149be232817b9223afa5e4 (patch)
tree2c3c1c8fe8ca08f4a7e9ee6e3763be02980343ab
parentfdbdfefbabefcdf3f57560163b43fdc4cf95eb2f (diff)
x86/hpet: Fix /dev/rtc breakage caused by RTC cleanup
Ville Syrjälä reports "The first time I run hwclock after rebooting I get this: open("/dev/rtc", O_RDONLY) = 3 ioctl(3, PHN_SET_REGS or RTC_UIE_ON, 0) = 0 select(4, [3], NULL, NULL, {10, 0}) = 0 (Timeout) ioctl(3, PHN_NOT_OH or RTC_UIE_OFF, 0) = 0 close(3) = 0 On all subsequent runs I get this: open("/dev/rtc", O_RDONLY) = 3 ioctl(3, PHN_SET_REGS or RTC_UIE_ON, 0) = -1 EINVAL (Invalid argument) ioctl(3, RTC_RD_TIME, 0x7ffd76b3ae70) = -1 EINVAL (Invalid argument) close(3) = 0" This was caused by a stupid typo in a patch that should have been a simple rename to move around contents of a header file, but accidentally wrote zeroes into the rtc rather than reading from it: 463a86304cae ("char/genrtc: x86: remove remnants of asm/rtc.h") Reported-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Tested-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Signed-off-by: Arnd Bergmann <arnd@arndb.de> Cc: Alessandro Zummo <a.zummo@towertech.it> Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com> Cc: Borislav Petkov <bp@suse.de> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: rtc-linux@googlegroups.com Fixes: 463a86304cae ("char/genrtc: x86: remove remnants of asm/rtc.h") Link: http://lkml.kernel.org/r/20160809195528.1604312-1-arnd@arndb.de Signed-off-by: Ingo Molnar <mingo@kernel.org>