···431431432432 void pm_runtime_irq_safe(struct device *dev);433433 - set the power.irq_safe flag for the device, causing the runtime-PM434434- suspend and resume callbacks (but not the idle callback) to be invoked435435- with interrupts disabled434434+ callbacks to be invoked with interrupts off436435437436 void pm_runtime_mark_last_busy(struct device *dev);438437 - set the power.last_busy field to the current time
+8-9
MAINTAINERS
···12781278ATLX ETHERNET DRIVERS12791279M: Jay Cliburn <jcliburn@gmail.com>12801280M: Chris Snook <chris.snook@gmail.com>12811281-M: Jie Yang <jie.yang@atheros.com>12821281L: netdev@vger.kernel.org12831282W: http://sourceforge.net/projects/atl112841283W: http://atl1.sourceforge.net···1573157415741575BROCADE BNA 10 GIGABIT ETHERNET DRIVER15751576M: Rasesh Mody <rmody@brocade.com>15761576-M: Debashis Dutt <ddutt@brocade.com>15771577L: netdev@vger.kernel.org15781578S: Supported15791579F: drivers/net/bna/···1756175817571759CISCO VIC ETHERNET NIC DRIVER17581760M: Christian Benvenuti <benve@cisco.com>17591759-M: Vasanthy Kolluri <vkolluri@cisco.com>17601761M: Roopa Prabhu <roprabhu@cisco.com>17611762M: David Wang <dwang2@cisco.com>17621763S: Supported···18801883F: drivers/connector/1881188418821885CONTROL GROUPS (CGROUPS)18831883-M: Paul Menage <menage@google.com>18861886+M: Paul Menage <paul@paulmenage.org>18841887M: Li Zefan <lizf@cn.fujitsu.com>18851888L: containers@lists.linux-foundation.org18861889S: Maintained···19291932F: tools/power/cpupower1930193319311934CPUSETS19321932-M: Paul Menage <menage@google.com>19351935+M: Paul Menage <paul@paulmenage.org>19331936W: http://www.bullopensource.org/cpuset/19341937W: http://oss.sgi.com/projects/cpusets/19351938S: Supported···26462649F: drivers/net/wan/sdla.c2647265026482651FRAMEBUFFER LAYER26492649-M: Paul Mundt <lethal@linux-sh.org>26522652+M: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>26502653L: linux-fbdev@vger.kernel.org26512654W: http://linux-fbdev.sourceforge.net/26522655Q: http://patchwork.kernel.org/project/linux-fbdev/list/26532653-T: git git://git.kernel.org/pub/scm/linux/kernel/git/lethal/fbdev-2.6.git26562656+T: git git://github.com/schandinat/linux-2.6.git fbdev-next26542657S: Maintained26552658F: Documentation/fb/26562659F: Documentation/devicetree/bindings/fb/···44014404L: coreteam@netfilter.org44024405W: http://www.netfilter.org/44034406W: http://www.iptables.org/44044404-T: git git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-2.6.git44074407+T: git git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf-2.6.git44084408+T: git git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf-next-2.6.git44054409S: Supported44064410F: include/linux/netfilter*44074411F: include/linux/netfilter/···5530553255315533SAMSUNG AUDIO (ASoC) DRIVERS55325534M: Jassi Brar <jassisinghbrar@gmail.com>55355535+M: Sangbeom Kim <sbkim73@samsung.com>55335536L: alsa-devel@alsa-project.org (moderated for non-subscribers)55345537S: Supported55355538F: sound/soc/samsung···70867087F: drivers/mmc/host/vub300.c7087708870887089W1 DALLAS'S 1-WIRE BUS70897089-M: Evgeniy Polyakov <johnpol@2ka.mipt.ru>70907090+M: Evgeniy Polyakov <zbr@ioremap.net>70907091S: Maintained70917092F: Documentation/w1/70927093F: drivers/w1/
···2727#define UAC_NOFIX 22828#define UAC_SIGBUS 429293030-3131-#ifdef __KERNEL__3232-3333-/* This is the shift that is applied to the UAC bits as stored in the3434- per-thread flags. See thread_info.h. */3535-#define UAC_SHIFT 63636-3737-#endif3838-3930#endif /* __ASM_ALPHA_SYSINFO_H */
+4-4
arch/alpha/include/asm/thread_info.h
···7474#define TIF_NEED_RESCHED 3 /* rescheduling necessary */7575#define TIF_POLLING_NRFLAG 8 /* poll_idle is polling NEED_RESCHED */7676#define TIF_DIE_IF_KERNEL 9 /* dik recursion lock */7777-#define TIF_UAC_NOPRINT 10 /* see sysinfo.h */7878-#define TIF_UAC_NOFIX 117979-#define TIF_UAC_SIGBUS 127777+#define TIF_UAC_NOPRINT 10 /* ! Preserve sequence of following */7878+#define TIF_UAC_NOFIX 11 /* ! flags as they match */7979+#define TIF_UAC_SIGBUS 12 /* ! userspace part of 'osf_sysinfo' */8080#define TIF_MEMDIE 13 /* is terminating due to OOM killer */8181#define TIF_RESTORE_SIGMASK 14 /* restore signal mask in do_signal */8282#define TIF_FREEZE 16 /* is freezing for suspend */···9797#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK \9898 | _TIF_SYSCALL_TRACE)9999100100-#define ALPHA_UAC_SHIFT 10100100+#define ALPHA_UAC_SHIFT TIF_UAC_NOPRINT101101#define ALPHA_UAC_MASK (1 << TIF_UAC_NOPRINT | 1 << TIF_UAC_NOFIX | \102102 1 << TIF_UAC_SIGBUS)103103
+7-5
arch/alpha/kernel/osf_sys.c
···4242#include <asm/uaccess.h>4343#include <asm/system.h>4444#include <asm/sysinfo.h>4545+#include <asm/thread_info.h>4546#include <asm/hwrpb.h>4647#include <asm/processor.h>4748···634633 case GSI_UACPROC:635634 if (nbytes < sizeof(unsigned int))636635 return -EINVAL;637637- w = (current_thread_info()->flags >> UAC_SHIFT) & UAC_BITMASK;638638- if (put_user(w, (unsigned int __user *)buffer))639639- return -EFAULT;636636+ w = (current_thread_info()->flags >> ALPHA_UAC_SHIFT) &637637+ UAC_BITMASK;638638+ if (put_user(w, (unsigned int __user *)buffer))639639+ return -EFAULT;640640 return 1;641641642642 case GSI_PROC_TYPE:···758756 case SSIN_UACPROC:759757 again:760758 old = current_thread_info()->flags;761761- new = old & ~(UAC_BITMASK << UAC_SHIFT);762762- new = new | (w & UAC_BITMASK) << UAC_SHIFT;759759+ new = old & ~(UAC_BITMASK << ALPHA_UAC_SHIFT);760760+ new = new | (w & UAC_BITMASK) << ALPHA_UAC_SHIFT;763761 if (cmpxchg(¤t_thread_info()->flags,764762 old, new) != old)765763 goto again;
···11+#ifndef _ASM_SERIAL_H22+#define _ASM_SERIAL_H33+44+/*55+ * This assumes you have a 1.8432 MHz clock for your UART.66+ */77+#define BASE_BAUD (1843200 / 16)88+99+#endif /* _ASM_SERIAL_H */
···665665 lgfr %r4,%r4 # long666666 jg sys_poll # branch to system call667667668668-ENTRY(compat_sys_nfsservctl_wrapper)669669- lgfr %r2,%r2 # int670670- llgtr %r3,%r3 # struct compat_nfsctl_arg*671671- llgtr %r4,%r4 # union compat_nfsctl_res*672672- jg compat_sys_nfsservctl # branch to system call673673-674668ENTRY(sys32_setresgid16_wrapper)675669 llgfr %r2,%r2 # __kernel_old_gid_emu31_t676670 llgfr %r3,%r3 # __kernel_old_gid_emu31_t
+8-6
arch/s390/kernel/early.c
···396396static __init void rescue_initrd(void)397397{398398#ifdef CONFIG_BLK_DEV_INITRD399399+ unsigned long min_initrd_addr = (unsigned long) _end + (4UL << 20);399400 /*400400- * Move the initrd right behind the bss section in case it starts401401- * within the bss section. So we don't overwrite it when the bss402402- * section gets cleared.401401+ * Just like in case of IPL from VM reader we make sure there is a402402+ * gap of 4MB between end of kernel and start of initrd.403403+ * That way we can also be sure that saving an NSS will succeed,404404+ * which however only requires different segments.403405 */404406 if (!INITRD_START || !INITRD_SIZE)405407 return;406406- if (INITRD_START >= (unsigned long) __bss_stop)408408+ if (INITRD_START >= min_initrd_addr)407409 return;408408- memmove(__bss_stop, (void *) INITRD_START, INITRD_SIZE);409409- INITRD_START = (unsigned long) __bss_stop;410410+ memmove((void *) min_initrd_addr, (void *) INITRD_START, INITRD_SIZE);411411+ INITRD_START = min_initrd_addr;410412#endif411413}412414
+4-3
arch/s390/kernel/ipl.c
···12201220 /* sysfs: create fcp kset for mixing attr group and bin attrs */12211221 reipl_fcp_kset = kset_create_and_add(IPL_FCP_STR, NULL,12221222 &reipl_kset->kobj);12231223- if (!reipl_kset) {12231223+ if (!reipl_fcp_kset) {12241224 free_page((unsigned long) reipl_block_fcp);12251225 return -ENOMEM;12261226 }···1618161816191619static void stop_run(struct shutdown_trigger *trigger)16201620{16211621- if (strcmp(trigger->name, ON_PANIC_STR) == 0)16211621+ if (strcmp(trigger->name, ON_PANIC_STR) == 0 ||16221622+ strcmp(trigger->name, ON_RESTART_STR) == 0)16221623 disabled_wait((unsigned long) __builtin_return_address(0));16231624 while (sigp(smp_processor_id(), sigp_stop) == sigp_busy)16241625 cpu_relax();···17181717/* on restart */1719171817201719static struct shutdown_trigger on_restart_trigger = {ON_RESTART_STR,17211721- &reipl_action};17201720+ &stop_action};1722172117231722static ssize_t on_restart_show(struct kobject *kobj,17241723 struct kobj_attribute *attr, char *page)
+1-1
arch/s390/kernel/syscalls.S
···177177NI_SYSCALL /* for vm86 */178178NI_SYSCALL /* old sys_query_module */179179SYSCALL(sys_poll,sys_poll,sys32_poll_wrapper)180180-SYSCALL(sys_nfsservctl,sys_nfsservctl,compat_sys_nfsservctl_wrapper)180180+NI_SYSCALL /* old nfsservctl */181181SYSCALL(sys_setresgid16,sys_ni_syscall,sys32_setresgid16_wrapper) /* 170 old setresgid16 syscall */182182SYSCALL(sys_getresgid16,sys_ni_syscall,sys32_getresgid16_wrapper) /* old getresgid16 syscall */183183SYSCALL(sys_prctl,sys_prctl,sys32_prctl_wrapper)
···316316 break;317317 }318318 break;319319+320320+ case 9: /* mov.w @(disp,PC),Rn */321321+ srcu = (unsigned char __user *)regs->pc;322322+ srcu += 4;323323+ srcu += (instruction & 0x00FF) << 1;324324+ dst = (unsigned char *)rn;325325+ *(unsigned long *)dst = 0;326326+327327+#if !defined(__LITTLE_ENDIAN__)328328+ dst += 2;329329+#endif330330+331331+ if (ma->from(dst, srcu, 2))332332+ goto fetch_fault;333333+ sign_extend(2, dst);334334+ ret = 0;335335+ break;336336+337337+ case 0xd: /* mov.l @(disp,PC),Rn */338338+ srcu = (unsigned char __user *)(regs->pc & ~0x3);339339+ srcu += 4;340340+ srcu += (instruction & 0x00FF) << 2;341341+ dst = (unsigned char *)rn;342342+ *(unsigned long *)dst = 0;343343+344344+ if (ma->from(dst, srcu, 4))345345+ goto fetch_fault;346346+ ret = 0;347347+ break;319348 }320349 return ret;321350···495466 case 0x0500: /* mov.w @(disp,Rm),R0 */496467 goto simple;497468 case 0x0B00: /* bf lab - no delayslot*/469469+ ret = 0;498470 break;499471 case 0x0F00: /* bf/s lab */500472 ret = handle_delayslot(regs, instruction, ma);···509479 }510480 break;511481 case 0x0900: /* bt lab - no delayslot */482482+ ret = 0;512483 break;513484 case 0x0D00: /* bt/s lab */514485 ret = handle_delayslot(regs, instruction, ma);···525494 }526495 break;527496497497+ case 0x9000: /* mov.w @(disp,Rm),Rn */498498+ goto simple;499499+528500 case 0xA000: /* bra label */529501 ret = handle_delayslot(regs, instruction, ma);530502 if (ret==0)···541507 regs->pc += SH_PC_12BIT_OFFSET(instruction);542508 }543509 break;510510+511511+ case 0xD000: /* mov.l @(disp,Rm),Rn */512512+ goto simple;544513 }545514 return ret;546515
+1-1
arch/sparc/kernel/irq.h
···8888#define set_irq_udt(cpu) BTFIXUP_CALL(set_irq_udt)(cpu)89899090/* All SUN4D IPIs are sent on this IRQ, may be shared with hard IRQs */9191-#define SUN4D_IPI_IRQ 149191+#define SUN4D_IPI_IRQ 1392929393extern void sun4d_ipi_interrupt(void);9494
···689689 irq_attr.trigger = 1;690690 irq_attr.polarity = 1;691691 io_apic_set_pci_routing(NULL, pentry->irq, &irq_attr);692692- }692692+ } else693693+ pentry->irq = 0; /* No irq */694694+693695 switch (pentry->type) {694696 case SFI_DEV_TYPE_IPC:695697 /* ID as IRQ is a hack that will go away */
···521521 if (!firmware_p)522522 return -EINVAL;523523524524- if (WARN_ON(usermodehelper_is_disabled())) {525525- dev_err(device, "firmware: %s will not be loaded\n", name);526526- return -EBUSY;527527- }528528-529524 *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL);530525 if (!firmware) {531526 dev_err(device, "%s: kmalloc(struct firmware) failed\n",···532537 if (fw_get_builtin_firmware(firmware, name)) {533538 dev_dbg(device, "firmware: using built-in firmware %s\n", name);534539 return 0;540540+ }541541+542542+ if (WARN_ON(usermodehelper_is_disabled())) {543543+ dev_err(device, "firmware: %s will not be loaded\n", name);544544+ retval = -EBUSY;545545+ goto out;535546 }536547537548 if (uevent)
+1-1
drivers/base/platform.c
···33333434/**3535 * arch_setup_pdev_archdata - Allow manipulation of archdata before its used3636- * @dev: platform device3636+ * @pdev: platform device3737 *3838 * This is called before platform_device_add() such that any pdev_archdata may3939 * be setup before the platform_notifier is called. So if a user needs to
+22-18
drivers/base/power/clock_ops.c
···19192020struct pm_clk_data {2121 struct list_head clock_list;2222- struct mutex lock;2222+ spinlock_t lock;2323};24242525enum pce_status {···7373 }7474 }75757676- mutex_lock(&pcd->lock);7676+ spin_lock_irq(&pcd->lock);7777 list_add_tail(&ce->node, &pcd->clock_list);7878- mutex_unlock(&pcd->lock);7878+ spin_unlock_irq(&pcd->lock);7979 return 0;8080}8181···8383 * __pm_clk_remove - Destroy PM clock entry.8484 * @ce: PM clock entry to destroy.8585 *8686- * This routine must be called under the mutex protecting the PM list of clocks8787- * corresponding the the @ce's device.8686+ * This routine must be called under the spinlock protecting the PM list of8787+ * clocks corresponding the the @ce's device.8888 */8989static void __pm_clk_remove(struct pm_clock_entry *ce)9090{···123123 if (!pcd)124124 return;125125126126- mutex_lock(&pcd->lock);126126+ spin_lock_irq(&pcd->lock);127127128128 list_for_each_entry(ce, &pcd->clock_list, node) {129129 if (!con_id && !ce->con_id) {···137137 }138138 }139139140140- mutex_unlock(&pcd->lock);140140+ spin_unlock_irq(&pcd->lock);141141}142142143143/**···158158 }159159160160 INIT_LIST_HEAD(&pcd->clock_list);161161- mutex_init(&pcd->lock);161161+ spin_lock_init(&pcd->lock);162162 dev->power.subsys_data = pcd;163163 return 0;164164}···181181182182 dev->power.subsys_data = NULL;183183184184- mutex_lock(&pcd->lock);184184+ spin_lock_irq(&pcd->lock);185185186186 list_for_each_entry_safe_reverse(ce, c, &pcd->clock_list, node)187187 __pm_clk_remove(ce);188188189189- mutex_unlock(&pcd->lock);189189+ spin_unlock_irq(&pcd->lock);190190191191 kfree(pcd);192192}···220220{221221 struct pm_clk_data *pcd = __to_pcd(dev);222222 struct pm_clock_entry *ce;223223+ unsigned long flags;223224224225 dev_dbg(dev, "%s()\n", __func__);225226226227 if (!pcd)227228 return 0;228229229229- mutex_lock(&pcd->lock);230230+ spin_lock_irqsave(&pcd->lock, flags);230231231232 list_for_each_entry_reverse(ce, &pcd->clock_list, node) {232233 if (ce->status == PCE_STATUS_NONE)···239238 }240239 }241240242242- mutex_unlock(&pcd->lock);241241+ spin_unlock_irqrestore(&pcd->lock, flags);243242244243 return 0;245244}···252251{253252 struct pm_clk_data *pcd = __to_pcd(dev);254253 struct pm_clock_entry *ce;254254+ unsigned long flags;255255256256 dev_dbg(dev, "%s()\n", __func__);257257258258 if (!pcd)259259 return 0;260260261261- mutex_lock(&pcd->lock);261261+ spin_lock_irqsave(&pcd->lock, flags);262262263263 list_for_each_entry(ce, &pcd->clock_list, node) {264264 if (ce->status == PCE_STATUS_NONE)···271269 }272270 }273271274274- mutex_unlock(&pcd->lock);272272+ spin_unlock_irqrestore(&pcd->lock, flags);275273276274 return 0;277275}···346344{347345 struct pm_clk_data *pcd = __to_pcd(dev);348346 struct pm_clock_entry *ce;347347+ unsigned long flags;349348350349 dev_dbg(dev, "%s()\n", __func__);351350···354351 if (!pcd || !dev->driver)355352 return 0;356353357357- mutex_lock(&pcd->lock);354354+ spin_lock_irqsave(&pcd->lock, flags);358355359356 list_for_each_entry_reverse(ce, &pcd->clock_list, node)360357 clk_disable(ce->clk);361358362362- mutex_unlock(&pcd->lock);359359+ spin_unlock_irqrestore(&pcd->lock, flags);363360364361 return 0;365362}···372369{373370 struct pm_clk_data *pcd = __to_pcd(dev);374371 struct pm_clock_entry *ce;372372+ unsigned long flags;375373376374 dev_dbg(dev, "%s()\n", __func__);377375···380376 if (!pcd || !dev->driver)381377 return 0;382378383383- mutex_lock(&pcd->lock);379379+ spin_lock_irqsave(&pcd->lock, flags);384380385381 list_for_each_entry(ce, &pcd->clock_list, node)386382 clk_enable(ce->clk);387383388388- mutex_unlock(&pcd->lock);384384+ spin_unlock_irqrestore(&pcd->lock, flags);389385390386 return 0;391387}
+2-3
drivers/char/msm_smd_pkt.c
···379379 for (i = 0; i < NUM_SMD_PKT_PORTS; ++i) {380380 smd_pkt_devp[i] = kzalloc(sizeof(struct smd_pkt_dev),381381 GFP_KERNEL);382382- if (IS_ERR(smd_pkt_devp[i])) {383383- r = PTR_ERR(smd_pkt_devp[i]);384384- pr_err("kmalloc() failed %d\n", r);382382+ if (!smd_pkt_devp[i]) {383383+ pr_err("kmalloc() failed\n");385384 goto clean_cdevs;386385 }387386
+32-2
drivers/clocksource/sh_cmt.c
···2626#include <linux/clk.h>2727#include <linux/irq.h>2828#include <linux/err.h>2929+#include <linux/delay.h>2930#include <linux/clocksource.h>3031#include <linux/clockchips.h>3132#include <linux/sh_timer.h>···151150152151static int sh_cmt_enable(struct sh_cmt_priv *p, unsigned long *rate)153152{154154- int ret;153153+ int k, ret;155154156155 /* enable clock */157156 ret = clk_enable(p->clk);158157 if (ret) {159158 dev_err(&p->pdev->dev, "cannot enable clock\n");160160- return ret;159159+ goto err0;161160 }162161163162 /* make sure channel is disabled */···175174 sh_cmt_write(p, CMCOR, 0xffffffff);176175 sh_cmt_write(p, CMCNT, 0);177176177177+ /*178178+ * According to the sh73a0 user's manual, as CMCNT can be operated179179+ * only by the RCLK (Pseudo 32 KHz), there's one restriction on180180+ * modifying CMCNT register; two RCLK cycles are necessary before181181+ * this register is either read or any modification of the value182182+ * it holds is reflected in the LSI's actual operation.183183+ *184184+ * While at it, we're supposed to clear out the CMCNT as of this185185+ * moment, so make sure it's processed properly here. This will186186+ * take RCLKx2 at maximum.187187+ */188188+ for (k = 0; k < 100; k++) {189189+ if (!sh_cmt_read(p, CMCNT))190190+ break;191191+ udelay(1);192192+ }193193+194194+ if (sh_cmt_read(p, CMCNT)) {195195+ dev_err(&p->pdev->dev, "cannot clear CMCNT\n");196196+ ret = -ETIMEDOUT;197197+ goto err1;198198+ }199199+178200 /* enable channel */179201 sh_cmt_start_stop_ch(p, 1);180202 return 0;203203+ err1:204204+ /* stop clock */205205+ clk_disable(p->clk);206206+207207+ err0:208208+ return ret;181209}182210183211static void sh_cmt_disable(struct sh_cmt_priv *p)
···420420421421static efi_status_t gsmi_set_variable(efi_char16_t *name,422422 efi_guid_t *vendor,423423- unsigned long attr,423423+ u32 attr,424424 unsigned long data_size,425425 void *data)426426{
+1-3
drivers/gpu/drm/i915/intel_display.c
···878878 int pp_reg, lvds_reg;879879 u32 val;880880 enum pipe panel_pipe = PIPE_A;881881- bool locked = locked;881881+ bool locked = true;882882883883 if (HAS_PCH_SPLIT(dev_priv->dev)) {884884 pp_reg = PCH_PP_CONTROL;···72377237 encoder->base.possible_clones =72387238 intel_encoder_clones(dev, encoder->clone_mask);72397239 }72407240-72417241- intel_panel_setup_backlight(dev);7242724072437241 /* disable all the possible outputs/crtcs before entering KMS mode */72447242 drm_helper_disable_unused_functions(dev);
+14-28
drivers/hwmon/i5k_amb.c
···114114 void __iomem *amb_mmio;115115 struct i5k_device_attribute *attrs;116116 unsigned int num_attrs;117117- unsigned long chipset_id;118117};119118120119static ssize_t show_name(struct device *dev, struct device_attribute *devattr,···443444 goto out;444445 }445446446446- data->chipset_id = devid;447447-448447 res = 0;449448out:450449 pci_dev_put(pcidev);···475478 return res;476479}477480478478-static unsigned long i5k_channel_pci_id(struct i5k_amb_data *data,479479- unsigned long channel)480480-{481481- switch (data->chipset_id) {482482- case PCI_DEVICE_ID_INTEL_5000_ERR:483483- return PCI_DEVICE_ID_INTEL_5000_FBD0 + channel;484484- case PCI_DEVICE_ID_INTEL_5400_ERR:485485- return PCI_DEVICE_ID_INTEL_5400_FBD0 + channel;486486- default:487487- BUG();488488- }489489-}490490-491491-static unsigned long chipset_ids[] = {492492- PCI_DEVICE_ID_INTEL_5000_ERR,493493- PCI_DEVICE_ID_INTEL_5400_ERR,494494- 0481481+static struct {482482+ unsigned long err;483483+ unsigned long fbd0;484484+} chipset_ids[] __devinitdata = {485485+ { PCI_DEVICE_ID_INTEL_5000_ERR, PCI_DEVICE_ID_INTEL_5000_FBD0 },486486+ { PCI_DEVICE_ID_INTEL_5400_ERR, PCI_DEVICE_ID_INTEL_5400_FBD0 },487487+ { 0, 0 }495488};496489497490#ifdef MODULE···497510{498511 struct i5k_amb_data *data;499512 struct resource *reso;500500- int i;501501- int res = -ENODEV;513513+ int i, res;502514503515 data = kzalloc(sizeof(*data), GFP_KERNEL);504516 if (!data)···506520 /* Figure out where the AMB registers live */507521 i = 0;508522 do {509509- res = i5k_find_amb_registers(data, chipset_ids[i]);523523+ res = i5k_find_amb_registers(data, chipset_ids[i].err);524524+ if (res == 0)525525+ break;510526 i++;511511- } while (res && chipset_ids[i]);527527+ } while (chipset_ids[i].err);512528513529 if (res)514530 goto err;515531516532 /* Copy the DIMM presence map for the first two channels */517517- res = i5k_channel_probe(&data->amb_present[0],518518- i5k_channel_pci_id(data, 0));533533+ res = i5k_channel_probe(&data->amb_present[0], chipset_ids[i].fbd0);519534 if (res)520535 goto err;521536522537 /* Copy the DIMM presence map for the optional second two channels */523523- i5k_channel_probe(&data->amb_present[2],524524- i5k_channel_pci_id(data, 1));538538+ i5k_channel_probe(&data->amb_present[2], chipset_ids[i].fbd0 + 1);525539526540 /* Set up resource regions */527541 reso = request_mem_region(data->amb_base, data->amb_len, DRVNAME);
···88 * published by the Free Software Foundation.99 */10101111+#include <linux/module.h>1112#include <linux/kernel.h>1213#include <linux/init.h>1314#include <linux/platform_device.h>
···1010 * published by the Free Software Foundation.1111 */12121313+#include <linux/module.h>1314#include <linux/kernel.h>1415#include <linux/init.h>1516#include <linux/platform_device.h>
+1
drivers/misc/Kconfig
···146146147147config INTEL_MID_PTI148148 tristate "Parallel Trace Interface for MIPI P1149.7 cJTAG standard"149149+ depends on PCI149150 default n150151 help151152 The PTI (Parallel Trace Interface) driver directs
···338338 /* Unknow packet? */339339 default:340340 type = *ptr;341341+ if (st_gdata->list[type] == NULL) {342342+ pr_err("chip/interface misbehavior dropping"343343+ " frame starting with 0x%02x", type);344344+ goto done;345345+346346+ }341347 st_gdata->rx_skb = alloc_skb(342348 st_gdata->list[type]->max_frame_size,343349 GFP_ATOMIC);···360354 ptr++;361355 count--;362356 }357357+done:363358 spin_unlock_irqrestore(&st_gdata->lock, flags);364359 pr_debug("done %s", __func__);365360 return;···724717 */725718 spin_lock_irqsave(&st_gdata->lock, flags);726719 for (i = ST_BT; i < ST_MAX_CHANNELS; i++) {727727- if (st_gdata->list[i] != NULL)720720+ if (st_gdata->is_registered[i] == true)728721 pr_err("%d not un-registered", i);729722 st_gdata->list[i] = NULL;723723+ st_gdata->is_registered[i] = false;730724 }731725 st_gdata->protos_registered = 0;732726 spin_unlock_irqrestore(&st_gdata->lock, flags);
+33
drivers/misc/ti-st/st_kim.c
···6868 if (unlikely(skb->data[5] != 0)) {6969 pr_err("no proper response during fw download");7070 pr_err("data6 %x", skb->data[5]);7171+ kfree_skb(skb);7172 return; /* keep waiting for the proper response */7273 }7374 /* becos of all the script being downloaded */···211210 pr_err(" waiting for ver info- timed out ");212211 return -ETIMEDOUT;213212 }213213+ INIT_COMPLETION(kim_gdata->kim_rcvd);214214215215 version =216216 MAKEWORD(kim_gdata->resp_buffer[13],···300298301299 switch (((struct bts_action *)ptr)->type) {302300 case ACTION_SEND_COMMAND: /* action send */301301+ pr_debug("S");303302 action_ptr = &(((struct bts_action *)ptr)->data[0]);304303 if (unlikely305304 (((struct hci_command *)action_ptr)->opcode ==···338335 release_firmware(kim_gdata->fw_entry);339336 return -ETIMEDOUT;340337 }338338+ /* reinit completion before sending for the339339+ * relevant wait340340+ */341341+ INIT_COMPLETION(kim_gdata->kim_rcvd);341342342343 /*343344 * Free space found in uart buffer, call st_int_write···368361 }369362 break;370363 case ACTION_WAIT_EVENT: /* wait */364364+ pr_debug("W");371365 if (!wait_for_completion_timeout372366 (&kim_gdata->kim_rcvd,373367 msecs_to_jiffies(CMD_RESP_TIME))) {···442434{443435 long err = 0;444436 long retry = POR_RETRY_COUNT;437437+ struct ti_st_plat_data *pdata;445438 struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data;446439447440 pr_info(" %s", __func__);441441+ pdata = kim_gdata->kim_pdev->dev.platform_data;448442449443 do {444444+ /* platform specific enabling code here */445445+ if (pdata->chip_enable)446446+ pdata->chip_enable(kim_gdata);447447+450448 /* Configure BT nShutdown to HIGH state */451449 gpio_set_value(kim_gdata->nshutdown, GPIO_LOW);452450 mdelay(5); /* FIXME: a proper toggle */···474460 pr_info("ldisc_install = 0");475461 sysfs_notify(&kim_gdata->kim_pdev->dev.kobj,476462 NULL, "install");463463+ /* the following wait is never going to be completed,464464+ * since the ldisc was never installed, hence serving465465+ * as a mdelay of LDISC_TIME msecs */466466+ err = wait_for_completion_timeout467467+ (&kim_gdata->ldisc_installed,468468+ msecs_to_jiffies(LDISC_TIME));477469 err = -ETIMEDOUT;478470 continue;479471 } else {···492472 pr_info("ldisc_install = 0");493473 sysfs_notify(&kim_gdata->kim_pdev->dev.kobj,494474 NULL, "install");475475+ /* this wait might be completed, though in the476476+ * tty_close() since the ldisc is already477477+ * installed */478478+ err = wait_for_completion_timeout479479+ (&kim_gdata->ldisc_installed,480480+ msecs_to_jiffies(LDISC_TIME));481481+ err = -EINVAL;495482 continue;496483 } else { /* on success don't retry */497484 break;···516489{517490 long err = 0;518491 struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data;492492+ struct ti_st_plat_data *pdata =493493+ kim_gdata->kim_pdev->dev.platform_data;519494520495 INIT_COMPLETION(kim_gdata->ldisc_installed);521496···544515 gpio_set_value(kim_gdata->nshutdown, GPIO_HIGH);545516 mdelay(1);546517 gpio_set_value(kim_gdata->nshutdown, GPIO_LOW);518518+519519+ /* platform specific disable */520520+ if (pdata->chip_disable)521521+ pdata->chip_disable(kim_gdata);547522 return err;548523}549524
+19
drivers/misc/ti-st/st_ll.c
···2222#define pr_fmt(fmt) "(stll) :" fmt2323#include <linux/skbuff.h>2424#include <linux/module.h>2525+#include <linux/platform_device.h>2526#include <linux/ti_wilink_st.h>26272728/**********************************************************************/···38373938static void ll_device_want_to_sleep(struct st_data_s *st_data)4039{4040+ struct kim_data_s *kim_data;4141+ struct ti_st_plat_data *pdata;4242+4143 pr_debug("%s", __func__);4244 /* sanity check */4345 if (st_data->ll_state != ST_LL_AWAKE)···5046 send_ll_cmd(st_data, LL_SLEEP_ACK);5147 /* update state */5248 st_data->ll_state = ST_LL_ASLEEP;4949+5050+ /* communicate to platform about chip asleep */5151+ kim_data = st_data->kim_data;5252+ pdata = kim_data->kim_pdev->dev.platform_data;5353+ if (pdata->chip_asleep)5454+ pdata->chip_asleep(NULL);5355}54565557static void ll_device_want_to_wakeup(struct st_data_s *st_data)5658{5959+ struct kim_data_s *kim_data;6060+ struct ti_st_plat_data *pdata;6161+5762 /* diff actions in diff states */5863 switch (st_data->ll_state) {5964 case ST_LL_ASLEEP:···8370 }8471 /* update state */8572 st_data->ll_state = ST_LL_AWAKE;7373+7474+ /* communicate to platform about chip wakeup */7575+ kim_data = st_data->kim_data;7676+ pdata = kim_data->kim_pdev->dev.platform_data;7777+ if (pdata->chip_asleep)7878+ pdata->chip_awake(NULL);8679}87808881/**********************************************************************/
+6
drivers/net/e1000/e1000_hw.c
···40264026 checksum += eeprom_data;40274027 }4028402840294029+#ifdef CONFIG_PARISC40304030+ /* This is a signature and not a checksum on HP c8000 */40314031+ if ((hw->subsystem_vendor_id == 0x103C) && (eeprom_data == 0x16d6))40324032+ return E1000_SUCCESS;40334033+40344034+#endif40294035 if (checksum == (u16) EEPROM_SUM)40304036 return E1000_SUCCESS;40314037 else {
+8-15
drivers/net/rionet.c
···8080 */8181static struct rio_dev **rionet_active;82828383-#define is_rionet_capable(pef, src_ops, dst_ops) \8484- ((pef & RIO_PEF_INB_MBOX) && \8585- (pef & RIO_PEF_INB_DOORBELL) && \8383+#define is_rionet_capable(src_ops, dst_ops) \8484+ ((src_ops & RIO_SRC_OPS_DATA_MSG) && \8585+ (dst_ops & RIO_DST_OPS_DATA_MSG) && \8686 (src_ops & RIO_SRC_OPS_DOORBELL) && \8787 (dst_ops & RIO_DST_OPS_DOORBELL))8888#define dev_rionet_capable(dev) \8989- is_rionet_capable(dev->pef, dev->src_ops, dev->dst_ops)8989+ is_rionet_capable(dev->src_ops, dev->dst_ops)90909191#define RIONET_MAC_MATCH(x) (*(u32 *)x == 0x00010001)9292#define RIONET_GET_DESTID(x) (*(u16 *)(x + 4))···282282{283283 int i, rc = 0;284284 struct rionet_peer *peer, *tmp;285285- u32 pwdcsr;286285 struct rionet_private *rnet = netdev_priv(ndev);287286288287 if (netif_msg_ifup(rnet))···331332 continue;332333 }333334334334- /*335335- * If device has initialized inbound doorbells,336336- * send a join message337337- */338338- rio_read_config_32(peer->rdev, RIO_WRITE_PORT_CSR, &pwdcsr);339339- if (pwdcsr & RIO_DOORBELL_AVAIL)340340- rio_send_doorbell(peer->rdev, RIONET_DOORBELL_JOIN);335335+ /* Send a join message */336336+ rio_send_doorbell(peer->rdev, RIONET_DOORBELL_JOIN);341337 }342338343339 out:···486492static int rionet_probe(struct rio_dev *rdev, const struct rio_device_id *id)487493{488494 int rc = -ENODEV;489489- u32 lpef, lsrc_ops, ldst_ops;495495+ u32 lsrc_ops, ldst_ops;490496 struct rionet_peer *peer;491497 struct net_device *ndev = NULL;492498···509515 * on later probes510516 */511517 if (!rionet_check) {512512- rio_local_read_config_32(rdev->net->hport, RIO_PEF_CAR, &lpef);513518 rio_local_read_config_32(rdev->net->hport, RIO_SRC_OPS_CAR,514519 &lsrc_ops);515520 rio_local_read_config_32(rdev->net->hport, RIO_DST_OPS_CAR,516521 &ldst_ops);517517- if (!is_rionet_capable(lpef, lsrc_ops, ldst_ops)) {522522+ if (!is_rionet_capable(lsrc_ops, ldst_ops)) {518523 printk(KERN_ERR519524 "%s: local device is not network capable\n",520525 DRV_NAME);
···249249static int dasd_ioctl_read_profile(struct dasd_block *block, void __user *argp)250250{251251 struct dasd_profile_info_t *data;252252+ int rc = 0;252253253254 data = kmalloc(sizeof(*data), GFP_KERNEL);254255 if (!data)···280279 spin_unlock_bh(&block->profile.lock);281280 } else {282281 spin_unlock_bh(&block->profile.lock);283283- return -EIO;282282+ rc = -EIO;283283+ goto out;284284 }285285 if (copy_to_user(argp, data, sizeof(*data)))286286- return -EFAULT;287287- return 0;286286+ rc = -EFAULT;287287+out:288288+ kfree(data);289289+ return rc;288290}289291#else290292static int dasd_ioctl_reset_profile(struct dasd_block *block)
+4-2
drivers/s390/char/sclp_cmd.c
···383383 switch (sccb->header.response_code) {384384 case 0x0020:385385 set_bit(id, sclp_storage_ids);386386- for (i = 0; i < sccb->assigned; i++)387387- sclp_unassign_storage(sccb->entries[i] >> 16);386386+ for (i = 0; i < sccb->assigned; i++) {387387+ if (sccb->entries[i])388388+ sclp_unassign_storage(sccb->entries[i] >> 16);389389+ }388390 break;389391 default:390392 rc = -EIO;
+3
drivers/sh/intc/chip.c
···186186 !defined(CONFIG_CPU_SUBTYPE_SH7709)187187 [IRQ_TYPE_LEVEL_HIGH] = VALID(3),188188#endif189189+#if defined(CONFIG_ARCH_SH7372)190190+ [IRQ_TYPE_EDGE_BOTH] = VALID(4),191191+#endif189192};190193191194static int intc_set_type(struct irq_data *data, unsigned int type)
···15981598 * from the decoded fabric module specific TransportID15991599 * at *i_str.16001600 */16011601- spin_lock_bh(&tmp_tpg->acl_node_lock);16011601+ spin_lock_irq(&tmp_tpg->acl_node_lock);16021602 dest_node_acl = __core_tpg_get_initiator_node_acl(16031603 tmp_tpg, i_str);16041604 if (dest_node_acl) {16051605 atomic_inc(&dest_node_acl->acl_pr_ref_count);16061606 smp_mb__after_atomic_inc();16071607 }16081608- spin_unlock_bh(&tmp_tpg->acl_node_lock);16081608+ spin_unlock_irq(&tmp_tpg->acl_node_lock);1609160916101610 if (!dest_node_acl) {16111611 core_scsi3_tpg_undepend_item(tmp_tpg);···34963496 /*34973497 * Locate the destination struct se_node_acl from the received Transport ID34983498 */34993499- spin_lock_bh(&dest_se_tpg->acl_node_lock);34993499+ spin_lock_irq(&dest_se_tpg->acl_node_lock);35003500 dest_node_acl = __core_tpg_get_initiator_node_acl(dest_se_tpg,35013501 initiator_str);35023502 if (dest_node_acl) {35033503 atomic_inc(&dest_node_acl->acl_pr_ref_count);35043504 smp_mb__after_atomic_inc();35053505 }35063506- spin_unlock_bh(&dest_se_tpg->acl_node_lock);35063506+ spin_unlock_irq(&dest_se_tpg->acl_node_lock);3507350735083508 if (!dest_node_acl) {35093509 pr_err("Unable to locate %s dest_node_acl for"
···137137{138138 struct se_node_acl *acl;139139140140- spin_lock_bh(&tpg->acl_node_lock);140140+ spin_lock_irq(&tpg->acl_node_lock);141141 list_for_each_entry(acl, &tpg->acl_node_list, acl_list) {142142 if (!strcmp(acl->initiatorname, initiatorname) &&143143 !acl->dynamic_node_acl) {144144- spin_unlock_bh(&tpg->acl_node_lock);144144+ spin_unlock_irq(&tpg->acl_node_lock);145145 return acl;146146 }147147 }148148- spin_unlock_bh(&tpg->acl_node_lock);148148+ spin_unlock_irq(&tpg->acl_node_lock);149149150150 return NULL;151151}···298298 tpg->se_tpg_tfo->tpg_release_fabric_acl(tpg, acl);299299 return NULL;300300 }301301+ /*302302+ * Here we only create demo-mode MappedLUNs from the active303303+ * TPG LUNs if the fabric is not explictly asking for304304+ * tpg_check_demo_mode_login_only() == 1.305305+ */306306+ if ((tpg->se_tpg_tfo->tpg_check_demo_mode_login_only != NULL) &&307307+ (tpg->se_tpg_tfo->tpg_check_demo_mode_login_only(tpg) == 1))308308+ do { ; } while (0);309309+ else310310+ core_tpg_add_node_to_devs(acl, tpg);301311302302- core_tpg_add_node_to_devs(acl, tpg);303303-304304- spin_lock_bh(&tpg->acl_node_lock);312312+ spin_lock_irq(&tpg->acl_node_lock);305313 list_add_tail(&acl->acl_list, &tpg->acl_node_list);306314 tpg->num_node_acls++;307307- spin_unlock_bh(&tpg->acl_node_lock);315315+ spin_unlock_irq(&tpg->acl_node_lock);308316309317 pr_debug("%s_TPG[%u] - Added DYNAMIC ACL with TCQ Depth: %d for %s"310318 " Initiator Node: %s\n", tpg->se_tpg_tfo->get_fabric_name(),···362354{363355 struct se_node_acl *acl = NULL;364356365365- spin_lock_bh(&tpg->acl_node_lock);357357+ spin_lock_irq(&tpg->acl_node_lock);366358 acl = __core_tpg_get_initiator_node_acl(tpg, initiatorname);367359 if (acl) {368360 if (acl->dynamic_node_acl) {···370362 pr_debug("%s_TPG[%u] - Replacing dynamic ACL"371363 " for %s\n", tpg->se_tpg_tfo->get_fabric_name(),372364 tpg->se_tpg_tfo->tpg_get_tag(tpg), initiatorname);373373- spin_unlock_bh(&tpg->acl_node_lock);365365+ spin_unlock_irq(&tpg->acl_node_lock);374366 /*375367 * Release the locally allocated struct se_node_acl376368 * because * core_tpg_add_initiator_node_acl() returned···386378 " Node %s already exists for TPG %u, ignoring"387379 " request.\n", tpg->se_tpg_tfo->get_fabric_name(),388380 initiatorname, tpg->se_tpg_tfo->tpg_get_tag(tpg));389389- spin_unlock_bh(&tpg->acl_node_lock);381381+ spin_unlock_irq(&tpg->acl_node_lock);390382 return ERR_PTR(-EEXIST);391383 }392392- spin_unlock_bh(&tpg->acl_node_lock);384384+ spin_unlock_irq(&tpg->acl_node_lock);393385394386 if (!se_nacl) {395387 pr_err("struct se_node_acl pointer is NULL\n");···426418 return ERR_PTR(-EINVAL);427419 }428420429429- spin_lock_bh(&tpg->acl_node_lock);421421+ spin_lock_irq(&tpg->acl_node_lock);430422 list_add_tail(&acl->acl_list, &tpg->acl_node_list);431423 tpg->num_node_acls++;432432- spin_unlock_bh(&tpg->acl_node_lock);424424+ spin_unlock_irq(&tpg->acl_node_lock);433425434426done:435427 pr_debug("%s_TPG[%hu] - Added ACL with TCQ Depth: %d for %s"···453445 struct se_session *sess, *sess_tmp;454446 int dynamic_acl = 0;455447456456- spin_lock_bh(&tpg->acl_node_lock);448448+ spin_lock_irq(&tpg->acl_node_lock);457449 if (acl->dynamic_node_acl) {458450 acl->dynamic_node_acl = 0;459451 dynamic_acl = 1;460452 }461453 list_del(&acl->acl_list);462454 tpg->num_node_acls--;463463- spin_unlock_bh(&tpg->acl_node_lock);455455+ spin_unlock_irq(&tpg->acl_node_lock);464456465457 spin_lock_bh(&tpg->session_lock);466458 list_for_each_entry_safe(sess, sess_tmp,···511503 struct se_node_acl *acl;512504 int dynamic_acl = 0;513505514514- spin_lock_bh(&tpg->acl_node_lock);506506+ spin_lock_irq(&tpg->acl_node_lock);515507 acl = __core_tpg_get_initiator_node_acl(tpg, initiatorname);516508 if (!acl) {517509 pr_err("Access Control List entry for %s Initiator"518510 " Node %s does not exists for TPG %hu, ignoring"519511 " request.\n", tpg->se_tpg_tfo->get_fabric_name(),520512 initiatorname, tpg->se_tpg_tfo->tpg_get_tag(tpg));521521- spin_unlock_bh(&tpg->acl_node_lock);513513+ spin_unlock_irq(&tpg->acl_node_lock);522514 return -ENODEV;523515 }524516 if (acl->dynamic_node_acl) {525517 acl->dynamic_node_acl = 0;526518 dynamic_acl = 1;527519 }528528- spin_unlock_bh(&tpg->acl_node_lock);520520+ spin_unlock_irq(&tpg->acl_node_lock);529521530522 spin_lock_bh(&tpg->session_lock);531523 list_for_each_entry(sess, &tpg->tpg_sess_list, sess_list) {···541533 tpg->se_tpg_tfo->get_fabric_name(), initiatorname);542534 spin_unlock_bh(&tpg->session_lock);543535544544- spin_lock_bh(&tpg->acl_node_lock);536536+ spin_lock_irq(&tpg->acl_node_lock);545537 if (dynamic_acl)546538 acl->dynamic_node_acl = 1;547547- spin_unlock_bh(&tpg->acl_node_lock);539539+ spin_unlock_irq(&tpg->acl_node_lock);548540 return -EEXIST;549541 }550542 /*···579571 if (init_sess)580572 tpg->se_tpg_tfo->close_session(init_sess);581573582582- spin_lock_bh(&tpg->acl_node_lock);574574+ spin_lock_irq(&tpg->acl_node_lock);583575 if (dynamic_acl)584576 acl->dynamic_node_acl = 1;585585- spin_unlock_bh(&tpg->acl_node_lock);577577+ spin_unlock_irq(&tpg->acl_node_lock);586578 return -EINVAL;587579 }588580 spin_unlock_bh(&tpg->session_lock);···598590 initiatorname, tpg->se_tpg_tfo->get_fabric_name(),599591 tpg->se_tpg_tfo->tpg_get_tag(tpg));600592601601- spin_lock_bh(&tpg->acl_node_lock);593593+ spin_lock_irq(&tpg->acl_node_lock);602594 if (dynamic_acl)603595 acl->dynamic_node_acl = 1;604604- spin_unlock_bh(&tpg->acl_node_lock);596596+ spin_unlock_irq(&tpg->acl_node_lock);605597606598 return 0;607599}···725717 * not been released because of TFO->tpg_check_demo_mode_cache() == 1726718 * in transport_deregister_session().727719 */728728- spin_lock_bh(&se_tpg->acl_node_lock);720720+ spin_lock_irq(&se_tpg->acl_node_lock);729721 list_for_each_entry_safe(nacl, nacl_tmp, &se_tpg->acl_node_list,730722 acl_list) {731723 list_del(&nacl->acl_list);732724 se_tpg->num_node_acls--;733733- spin_unlock_bh(&se_tpg->acl_node_lock);725725+ spin_unlock_irq(&se_tpg->acl_node_lock);734726735727 core_tpg_wait_for_nacl_pr_ref(nacl);736728 core_free_device_list_for_node(nacl, se_tpg);737729 se_tpg->se_tpg_tfo->tpg_release_fabric_acl(se_tpg, nacl);738730739739- spin_lock_bh(&se_tpg->acl_node_lock);731731+ spin_lock_irq(&se_tpg->acl_node_lock);740732 }741741- spin_unlock_bh(&se_tpg->acl_node_lock);733733+ spin_unlock_irq(&se_tpg->acl_node_lock);742734743735 if (se_tpg->se_tpg_type == TRANSPORT_TPG_TYPE_NORMAL)744736 core_tpg_release_virtual_lun0(se_tpg);
+123-85
drivers/target/target_core_transport.c
···389389{390390 struct se_portal_group *se_tpg = se_sess->se_tpg;391391 struct se_node_acl *se_nacl;392392+ unsigned long flags;392393393394 if (!se_tpg) {394395 transport_free_session(se_sess);395396 return;396397 }397398398398- spin_lock_bh(&se_tpg->session_lock);399399+ spin_lock_irqsave(&se_tpg->session_lock, flags);399400 list_del(&se_sess->sess_list);400401 se_sess->se_tpg = NULL;401402 se_sess->fabric_sess_ptr = NULL;402402- spin_unlock_bh(&se_tpg->session_lock);403403+ spin_unlock_irqrestore(&se_tpg->session_lock, flags);403404404405 /*405406 * Determine if we need to do extra work for this initiator node's···408407 */409408 se_nacl = se_sess->se_node_acl;410409 if (se_nacl) {411411- spin_lock_bh(&se_tpg->acl_node_lock);410410+ spin_lock_irqsave(&se_tpg->acl_node_lock, flags);412411 if (se_nacl->dynamic_node_acl) {413412 if (!se_tpg->se_tpg_tfo->tpg_check_demo_mode_cache(414413 se_tpg)) {415414 list_del(&se_nacl->acl_list);416415 se_tpg->num_node_acls--;417417- spin_unlock_bh(&se_tpg->acl_node_lock);416416+ spin_unlock_irqrestore(&se_tpg->acl_node_lock, flags);418417419418 core_tpg_wait_for_nacl_pr_ref(se_nacl);420419 core_free_device_list_for_node(se_nacl, se_tpg);421420 se_tpg->se_tpg_tfo->tpg_release_fabric_acl(se_tpg,422421 se_nacl);423423- spin_lock_bh(&se_tpg->acl_node_lock);422422+ spin_lock_irqsave(&se_tpg->acl_node_lock, flags);424423 }425424 }426426- spin_unlock_bh(&se_tpg->acl_node_lock);425425+ spin_unlock_irqrestore(&se_tpg->acl_node_lock, flags);427426 }428427429428 transport_free_session(se_sess);···20542053 cmd->scsi_sense_reason = TCM_UNSUPPORTED_SCSI_OPCODE;20552054 break;20562055 }20572057-20582058- if (!sc)20562056+ /*20572057+ * If a fabric does not define a cmd->se_tfo->new_cmd_map caller,20582058+ * make the call to transport_send_check_condition_and_sense()20592059+ * directly. Otherwise expect the fabric to make the call to20602060+ * transport_send_check_condition_and_sense() after handling20612061+ * possible unsoliticied write data payloads.20622062+ */20632063+ if (!sc && !cmd->se_tfo->new_cmd_map)20592064 transport_new_cmd_failure(cmd);20602065 else {20612066 ret = transport_send_check_condition_and_sense(cmd,···28542847 " transport_dev_end_lba(): %llu\n",28552848 cmd->t_task_lba, sectors,28562849 transport_dev_end_lba(dev));28572857- pr_err(" We should return CHECK_CONDITION"28582858- " but we don't yet\n");28592859- return 0;28502850+ return -EINVAL;28602851 }2861285228622862- return sectors;28532853+ return 0;28542854+}28552855+28562856+static int target_check_write_same_discard(unsigned char *flags, struct se_device *dev)28572857+{28582858+ /*28592859+ * Determine if the received WRITE_SAME is used to for direct28602860+ * passthrough into Linux/SCSI with struct request via TCM/pSCSI28612861+ * or we are signaling the use of internal WRITE_SAME + UNMAP=128622862+ * emulation for -> Linux/BLOCK disbard with TCM/IBLOCK code.28632863+ */28642864+ int passthrough = (dev->transport->transport_type ==28652865+ TRANSPORT_PLUGIN_PHBA_PDEV);28662866+28672867+ if (!passthrough) {28682868+ if ((flags[0] & 0x04) || (flags[0] & 0x02)) {28692869+ pr_err("WRITE_SAME PBDATA and LBDATA"28702870+ " bits not supported for Block Discard"28712871+ " Emulation\n");28722872+ return -ENOSYS;28732873+ }28742874+ /*28752875+ * Currently for the emulated case we only accept28762876+ * tpws with the UNMAP=1 bit set.28772877+ */28782878+ if (!(flags[0] & 0x08)) {28792879+ pr_err("WRITE_SAME w/o UNMAP bit not"28802880+ " supported for Block Discard Emulation\n");28812881+ return -ENOSYS;28822882+ }28832883+ }28842884+28852885+ return 0;28632886}2864288728652888/* transport_generic_cmd_sequencer():···31023065 goto out_unsupported_cdb;3103306631043067 if (sectors)31053105- size = transport_get_size(sectors, cdb, cmd);30683068+ size = transport_get_size(1, cdb, cmd);31063069 else {31073070 pr_err("WSNZ=1, WRITE_SAME w/sectors=0 not"31083071 " supported\n");···31123075 cmd->t_task_lba = get_unaligned_be64(&cdb[12]);31133076 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;3114307731153115- /*31163116- * Skip the remaining assignments for TCM/PSCSI passthrough31173117- */31183118- if (passthrough)31193119- break;30783078+ if (target_check_write_same_discard(&cdb[10], dev) < 0)30793079+ goto out_invalid_cdb_field;3120308031213121- if ((cdb[10] & 0x04) || (cdb[10] & 0x02)) {31223122- pr_err("WRITE_SAME PBDATA and LBDATA"31233123- " bits not supported for Block Discard"31243124- " Emulation\n");31253125- goto out_invalid_cdb_field;31263126- }31273127- /*31283128- * Currently for the emulated case we only accept31293129- * tpws with the UNMAP=1 bit set.31303130- */31313131- if (!(cdb[10] & 0x08)) {31323132- pr_err("WRITE_SAME w/o UNMAP bit not"31333133- " supported for Block Discard Emulation\n");31343134- goto out_invalid_cdb_field;31353135- }31363081 break;31373082 default:31383083 pr_err("VARIABLE_LENGTH_CMD service action"···33493330 cmd->se_cmd_flags |= SCF_EMULATE_CDB_ASYNC;33503331 /*33513332 * Check to ensure that LBA + Range does not exceed past end of33523352- * device.33333333+ * device for IBLOCK and FILEIO ->do_sync_cache() backend calls33533334 */33543354- if (!transport_cmd_get_valid_sectors(cmd))33553355- goto out_invalid_cdb_field;33353335+ if ((cmd->t_task_lba != 0) || (sectors != 0)) {33363336+ if (transport_cmd_get_valid_sectors(cmd) < 0)33373337+ goto out_invalid_cdb_field;33383338+ }33563339 break;33573340 case UNMAP:33583341 size = get_unaligned_be16(&cdb[7]);···33663345 goto out_unsupported_cdb;3367334633683347 if (sectors)33693369- size = transport_get_size(sectors, cdb, cmd);33483348+ size = transport_get_size(1, cdb, cmd);33703349 else {33713350 pr_err("WSNZ=1, WRITE_SAME w/sectors=0 not supported\n");33723351 goto out_invalid_cdb_field;33733352 }3374335333753354 cmd->t_task_lba = get_unaligned_be64(&cdb[2]);33763376- passthrough = (dev->transport->transport_type ==33773377- TRANSPORT_PLUGIN_PHBA_PDEV);33783378- /*33793379- * Determine if the received WRITE_SAME_16 is used to for direct33803380- * passthrough into Linux/SCSI with struct request via TCM/pSCSI33813381- * or we are signaling the use of internal WRITE_SAME + UNMAP=133823382- * emulation for -> Linux/BLOCK disbard with TCM/IBLOCK and33833383- * TCM/FILEIO subsystem plugin backstores.33843384- */33853385- if (!passthrough) {33863386- if ((cdb[1] & 0x04) || (cdb[1] & 0x02)) {33873387- pr_err("WRITE_SAME PBDATA and LBDATA"33883388- " bits not supported for Block Discard"33893389- " Emulation\n");33903390- goto out_invalid_cdb_field;33913391- }33923392- /*33933393- * Currently for the emulated case we only accept33943394- * tpws with the UNMAP=1 bit set.33953395- */33963396- if (!(cdb[1] & 0x08)) {33973397- pr_err("WRITE_SAME w/o UNMAP bit not "33983398- " supported for Block Discard Emulation\n");33993399- goto out_invalid_cdb_field;34003400- }34013401- }34023355 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;33563356+33573357+ if (target_check_write_same_discard(&cdb[1], dev) < 0)33583358+ goto out_invalid_cdb_field;33593359+ break;33603360+ case WRITE_SAME:33613361+ sectors = transport_get_sectors_10(cdb, cmd, §or_ret);33623362+ if (sector_ret)33633363+ goto out_unsupported_cdb;33643364+33653365+ if (sectors)33663366+ size = transport_get_size(1, cdb, cmd);33673367+ else {33683368+ pr_err("WSNZ=1, WRITE_SAME w/sectors=0 not supported\n");33693369+ goto out_invalid_cdb_field;33703370+ }33713371+33723372+ cmd->t_task_lba = get_unaligned_be32(&cdb[2]);33733373+ cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;33743374+ /*33753375+ * Follow sbcr26 with WRITE_SAME (10) and check for the existence33763376+ * of byte 1 bit 3 UNMAP instead of original reserved field33773377+ */33783378+ if (target_check_write_same_discard(&cdb[1], dev) < 0)33793379+ goto out_invalid_cdb_field;34033380 break;34043381 case ALLOW_MEDIUM_REMOVAL:34053382 case GPCMD_CLOSE_TRACK:···38923873static int transport_new_cmd_obj(struct se_cmd *cmd)38933874{38943875 struct se_device *dev = cmd->se_dev;38953895- u32 task_cdbs;38963896- u32 rc;38973897- int set_counts = 1;38763876+ int set_counts = 1, rc, task_cdbs;3898387738993878 /*39003879 * Setup any BIDI READ tasks and memory from···39103893 cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;39113894 cmd->scsi_sense_reason =39123895 TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;39133913- return PYX_TRANSPORT_LU_COMM_FAILURE;38963896+ return -EINVAL;39143897 }39153898 atomic_inc(&cmd->t_fe_count);39163899 atomic_inc(&cmd->t_se_count);···39293912 cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;39303913 cmd->scsi_sense_reason =39313914 TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;39323932- return PYX_TRANSPORT_LU_COMM_FAILURE;39153915+ return -EINVAL;39333916 }3934391739353918 if (set_counts) {···40454028 if (!task->task_sg)40464029 continue;4047403040484048- BUG_ON(!task->task_padded_sg);40494049-40504031 if (!sg_first) {40514032 sg_first = task->task_sg;40524033 chained_nents = task->task_sg_nents;···40524037 sg_chain(sg_prev, sg_prev_nents, task->task_sg);40534038 chained_nents += task->task_sg_nents;40544039 }40404040+ /*40414041+ * For the padded tasks, use the extra SGL vector allocated40424042+ * in transport_allocate_data_tasks() for the sg_prev_nents40434043+ * offset into sg_chain() above.. The last task of a40444044+ * multi-task list, or a single task will not have40454045+ * task->task_sg_padded set..40464046+ */40474047+ if (task->task_padded_sg)40484048+ sg_prev_nents = (task->task_sg_nents + 1);40494049+ else40504050+ sg_prev_nents = task->task_sg_nents;4055405140564052 sg_prev = task->task_sg;40574057- sg_prev_nents = task->task_sg_nents;40584053 }40594054 /*40604055 * Setup the starting pointer and total t_tasks_sg_linked_no including···4116409141174092 cmd_sg = sgl;41184093 for (i = 0; i < task_count; i++) {41194119- unsigned int task_size;40944094+ unsigned int task_size, task_sg_nents_padded;41204095 int count;4121409641224097 task = transport_generic_get_task(cmd, data_direction);···4135411041364111 /* Update new cdb with updated lba/sectors */41374112 cmd->transport_split_cdb(task->task_lba, task->task_sectors, cdb);41384138-41134113+ /*41144114+ * This now assumes that passed sg_ents are in PAGE_SIZE chunks41154115+ * in order to calculate the number per task SGL entries41164116+ */41174117+ task->task_sg_nents = DIV_ROUND_UP(task->task_size, PAGE_SIZE);41394118 /*41404119 * Check if the fabric module driver is requesting that all41414120 * struct se_task->task_sg[] be chained together.. If so,41424121 * then allocate an extra padding SG entry for linking and41434143- * marking the end of the chained SGL.41444144- * Possibly over-allocate task sgl size by using cmd sgl size.41454145- * It's so much easier and only a waste when task_count > 1.41464146- * That is extremely rare.41224122+ * marking the end of the chained SGL for every task except41234123+ * the last one for (task_count > 1) operation, or skipping41244124+ * the extra padding for the (task_count == 1) case.41474125 */41484148- task->task_sg_nents = sgl_nents;41494149- if (cmd->se_tfo->task_sg_chaining) {41504150- task->task_sg_nents++;41264126+ if (cmd->se_tfo->task_sg_chaining && (i < (task_count - 1))) {41274127+ task_sg_nents_padded = (task->task_sg_nents + 1);41514128 task->task_padded_sg = 1;41524152- }41294129+ } else41304130+ task_sg_nents_padded = task->task_sg_nents;4153413141544132 task->task_sg = kmalloc(sizeof(struct scatterlist) *41554155- task->task_sg_nents, GFP_KERNEL);41334133+ task_sg_nents_padded, GFP_KERNEL);41564134 if (!task->task_sg) {41574135 cmd->se_dev->transport->free_task(task);41584136 return -ENOMEM;41594137 }4160413841614161- sg_init_table(task->task_sg, task->task_sg_nents);41394139+ sg_init_table(task->task_sg, task_sg_nents_padded);4162414041634141 task_size = task->task_size;41644142···42584230 struct scatterlist *sgl,42594231 unsigned int sgl_nents)42604232{42614261- if (cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB)42334233+ if (cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB) {42344234+ if (transport_cmd_get_valid_sectors(cmd) < 0)42354235+ return -EINVAL;42364236+42624237 return transport_allocate_data_tasks(cmd, lba, data_direction,42634238 sgl, sgl_nents);42644264- else42394239+ } else42654240 return transport_allocate_control_task(cmd);4266424142674242}···47574726 */47584727 switch (reason) {47594728 case TCM_NON_EXISTENT_LUN:47294729+ /* CURRENT ERROR */47304730+ buffer[offset] = 0x70;47314731+ /* ILLEGAL REQUEST */47324732+ buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST;47334733+ /* LOGICAL UNIT NOT SUPPORTED */47344734+ buffer[offset+SPC_ASC_KEY_OFFSET] = 0x25;47354735+ break;47604736 case TCM_UNSUPPORTED_SCSI_OPCODE:47614737 case TCM_SECTOR_COUNT_TOO_MANY:47624738 /* CURRENT ERROR */
···446446int pty_limit = NR_UNIX98_PTY_DEFAULT;447447static int pty_limit_min;448448static int pty_limit_max = NR_UNIX98_PTY_MAX;449449+static int tty_count;449450static int pty_count;451451+452452+static inline void pty_inc_count(void)453453+{454454+ pty_count = (++tty_count) / 2;455455+}456456+457457+static inline void pty_dec_count(void)458458+{459459+ pty_count = (--tty_count) / 2;460460+}450461451462static struct cdev ptmx_cdev;452463···553542554543static void pty_unix98_shutdown(struct tty_struct *tty)555544{545545+ tty_driver_remove_tty(tty->driver, tty);556546 /* We have our own method as we don't use the tty index */557547 kfree(tty->termios);558548}···600588 */601589 tty_driver_kref_get(driver);602590 tty->count++;603603- pty_count++;591591+ pty_inc_count(); /* tty */592592+ pty_inc_count(); /* tty->link */604593 return 0;605594err_free_mem:606595 deinitialize_tty_struct(o_tty);···615602616603static void pty_unix98_remove(struct tty_driver *driver, struct tty_struct *tty)617604{618618- pty_count--;605605+ pty_dec_count();619606}620607621608static const struct tty_operations ptm_unix98_ops = {
+5-3
drivers/tty/serial/8250.c
···18191819 unsigned int iir, ier = 0, lsr;18201820 unsigned long flags;1821182118221822+ spin_lock_irqsave(&up->port.lock, flags);18231823+18221824 /*18231825 * Must disable interrupts or else we risk racing with the interrupt18241826 * based handler.···18381836 * the "Diva" UART used on the management processor on many HP18391837 * ia64 and parisc boxes.18401838 */18411841- spin_lock_irqsave(&up->port.lock, flags);18421839 lsr = serial_in(up, UART_LSR);18431840 up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS;18441844- spin_unlock_irqrestore(&up->port.lock, flags);18451841 if ((iir & UART_IIR_NO_INT) && (up->ier & UART_IER_THRI) &&18461842 (!uart_circ_empty(&up->port.state->xmit) || up->port.x_char) &&18471843 (lsr & UART_LSR_THRE)) {···18481848 }1849184918501850 if (!(iir & UART_IIR_NO_INT))18511851- serial8250_handle_port(up);18511851+ transmit_chars(up);1852185218531853 if (is_real_interrupt(up->port.irq))18541854 serial_out(up, UART_IER, ier);18551855+18561856+ spin_unlock_irqrestore(&up->port.lock, flags);1855185718561858 /* Standard timer interval plus 0.2s to keep the port running */18571859 mod_timer(&up->timer,
···200200 clear_bit(TTY_IO_ERROR, &tty->flags);201201 }202202203203+ /*204204+ * This is to allow setserial on this port. People may want to set205205+ * port/irq/type and then reconfigure the port properly if it failed206206+ * now.207207+ */203208 if (retval && capable(CAP_SYS_ADMIN))204209 retval = 0;205210
···17751775 struct usb_interface *iface = usb_ifnum_to_if(udev,17761776 cur_alt->desc.bInterfaceNumber);1777177717781778+ if (!iface)17791779+ return -EINVAL;17781780 if (iface->resetting_device) {17791781 /*17801782 * The USB core just reset the device, so the xHCI host
···463463 && (temp & PORT_POWER))464464 status |= USB_PORT_STAT_SUSPEND;465465 }466466- if ((temp & PORT_PLS_MASK) == XDEV_RESUME) {466466+ if ((temp & PORT_PLS_MASK) == XDEV_RESUME &&467467+ !DEV_SUPERSPEED(temp)) {467468 if ((temp & PORT_RESET) || !(temp & PORT_PE))468469 goto error;469469- if (!DEV_SUPERSPEED(temp) && time_after_eq(jiffies,470470- bus_state->resume_done[wIndex])) {470470+ if (time_after_eq(jiffies,471471+ bus_state->resume_done[wIndex])) {471472 xhci_dbg(xhci, "Resume USB2 port %d\n",472473 wIndex + 1);473474 bus_state->resume_done[wIndex] = 0;···488487 xhci_ring_device(xhci, slot_id);489488 bus_state->port_c_suspend |= 1 << wIndex;490489 bus_state->suspended_ports &= ~(1 << wIndex);490490+ } else {491491+ /*492492+ * The resume has been signaling for less than493493+ * 20ms. Report the port status as SUSPEND,494494+ * let the usbcore check port status again495495+ * and clear resume signaling later.496496+ */497497+ status |= USB_PORT_STAT_SUSPEND;491498 }492499 }493500 if ((temp & PORT_PLS_MASK) == XDEV_U0···673664 xhci_dbg(xhci, "PORTSC %04x\n", temp);674665 if (temp & PORT_RESET)675666 goto error;676676- if (temp & XDEV_U3) {667667+ if ((temp & PORT_PLS_MASK) == XDEV_U3) {677668 if ((temp & PORT_PE) == 0)678669 goto error;679670
+63-27
drivers/usb/host/xhci-ring.c
···514514 (unsigned long long) addr);515515}516516517517+/* flip_cycle means flip the cycle bit of all but the first and last TRB.518518+ * (The last TRB actually points to the ring enqueue pointer, which is not part519519+ * of this TD.) This is used to remove partially enqueued isoc TDs from a ring.520520+ */517521static void td_to_noop(struct xhci_hcd *xhci, struct xhci_ring *ep_ring,518518- struct xhci_td *cur_td)522522+ struct xhci_td *cur_td, bool flip_cycle)519523{520524 struct xhci_segment *cur_seg;521525 union xhci_trb *cur_trb;···532528 * leave the pointers intact.533529 */534530 cur_trb->generic.field[3] &= cpu_to_le32(~TRB_CHAIN);531531+ /* Flip the cycle bit (link TRBs can't be the first532532+ * or last TRB).533533+ */534534+ if (flip_cycle)535535+ cur_trb->generic.field[3] ^=536536+ cpu_to_le32(TRB_CYCLE);535537 xhci_dbg(xhci, "Cancel (unchain) link TRB\n");536538 xhci_dbg(xhci, "Address = %p (0x%llx dma); "537539 "in seg %p (0x%llx dma)\n",···551541 cur_trb->generic.field[2] = 0;552542 /* Preserve only the cycle bit of this TRB */553543 cur_trb->generic.field[3] &= cpu_to_le32(TRB_CYCLE);544544+ /* Flip the cycle bit except on the first or last TRB */545545+ if (flip_cycle && cur_trb != cur_td->first_trb &&546546+ cur_trb != cur_td->last_trb)547547+ cur_trb->generic.field[3] ^=548548+ cpu_to_le32(TRB_CYCLE);554549 cur_trb->generic.field[3] |= cpu_to_le32(555550 TRB_TYPE(TRB_TR_NOOP));556551 xhci_dbg(xhci, "Cancel TRB %p (0x%llx dma) "···734719 cur_td->urb->stream_id,735720 cur_td, &deq_state);736721 else737737- td_to_noop(xhci, ep_ring, cur_td);722722+ td_to_noop(xhci, ep_ring, cur_td, false);738723remove_finished_td:739724 /*740725 * The event handler won't see a completion for this TD anymore,741726 * so remove it from the endpoint ring's TD list. Keep it in742727 * the cancelled TD list for URB completion later.743728 */744744- list_del(&cur_td->td_list);729729+ list_del_init(&cur_td->td_list);745730 }746731 last_unlinked_td = cur_td;747732 xhci_stop_watchdog_timer_in_irq(xhci, ep);···769754 do {770755 cur_td = list_entry(ep->cancelled_td_list.next,771756 struct xhci_td, cancelled_td_list);772772- list_del(&cur_td->cancelled_td_list);757757+ list_del_init(&cur_td->cancelled_td_list);773758774759 /* Clean up the cancelled URB */775760 /* Doesn't matter what we pass for status, since the core will···877862 cur_td = list_first_entry(&ring->td_list,878863 struct xhci_td,879864 td_list);880880- list_del(&cur_td->td_list);865865+ list_del_init(&cur_td->td_list);881866 if (!list_empty(&cur_td->cancelled_td_list))882882- list_del(&cur_td->cancelled_td_list);867867+ list_del_init(&cur_td->cancelled_td_list);883868 xhci_giveback_urb_in_irq(xhci, cur_td,884869 -ESHUTDOWN, "killed");885870 }···888873 &temp_ep->cancelled_td_list,889874 struct xhci_td,890875 cancelled_td_list);891891- list_del(&cur_td->cancelled_td_list);876876+ list_del_init(&cur_td->cancelled_td_list);892877 xhci_giveback_urb_in_irq(xhci, cur_td,893878 -ESHUTDOWN, "killed");894879 }···15801565 else15811566 *status = 0;15821567 }15831583- list_del(&td->td_list);15681568+ list_del_init(&td->td_list);15841569 /* Was this TD slated to be cancelled but completed anyway? */15851570 if (!list_empty(&td->cancelled_td_list))15861586- list_del(&td->cancelled_td_list);15711571+ list_del_init(&td->cancelled_td_list);1587157215881573 urb_priv->td_cnt++;15891574 /* Giveback the urb when all the tds are completed */···2515250025162501 if (td_index == 0) {25172502 ret = usb_hcd_link_urb_to_ep(bus_to_hcd(urb->dev->bus), urb);25182518- if (unlikely(ret)) {25192519- xhci_urb_free_priv(xhci, urb_priv);25202520- urb->hcpriv = NULL;25032503+ if (unlikely(ret))25212504 return ret;25222522- }25232505 }2524250625252507 td->urb = urb;···26832671 unsigned int total_packet_count, struct urb *urb)26842672{26852673 int packets_transferred;26742674+26752675+ /* One TRB with a zero-length data packet. */26762676+ if (running_total == 0 && trb_buff_len == 0)26772677+ return 0;2686267826872679 /* All the TRB queueing functions don't count the current TRB in26882680 * running_total.···31293113 struct urb *urb, int i)31303114{31313115 int num_trbs = 0;31323132- u64 addr, td_len, running_total;31163116+ u64 addr, td_len;3133311731343118 addr = (u64) (urb->transfer_dma + urb->iso_frame_desc[i].offset);31353119 td_len = urb->iso_frame_desc[i].length;3136312031373137- running_total = TRB_MAX_BUFF_SIZE - (addr & (TRB_MAX_BUFF_SIZE - 1));31383138- running_total &= TRB_MAX_BUFF_SIZE - 1;31393139- if (running_total != 0)31213121+ num_trbs = DIV_ROUND_UP(td_len + (addr & (TRB_MAX_BUFF_SIZE - 1)),31223122+ TRB_MAX_BUFF_SIZE);31233123+ if (num_trbs == 0)31403124 num_trbs++;31413141-31423142- while (running_total < td_len) {31433143- num_trbs++;31443144- running_total += TRB_MAX_BUFF_SIZE;31453145- }3146312531473126 return num_trbs;31483127}···32373226 start_trb = &ep_ring->enqueue->generic;32383227 start_cycle = ep_ring->cycle_state;3239322832293229+ urb_priv = urb->hcpriv;32403230 /* Queue the first TRB, even if it's zero-length */32413231 for (i = 0; i < num_tds; i++) {32423232 unsigned int total_packet_count;···32493237 addr = start_addr + urb->iso_frame_desc[i].offset;32503238 td_len = urb->iso_frame_desc[i].length;32513239 td_remain_len = td_len;32523252- /* FIXME: Ignoring zero-length packets, can those happen? */32533240 total_packet_count = roundup(td_len,32543241 le16_to_cpu(urb->ep->desc.wMaxPacketSize));32423242+ /* A zero-length transfer still involves at least one packet. */32433243+ if (total_packet_count == 0)32443244+ total_packet_count++;32553245 burst_count = xhci_get_burst_count(xhci, urb->dev, urb,32563246 total_packet_count);32573247 residue = xhci_get_last_burst_packet_count(xhci,···3263324932643250 ret = prepare_transfer(xhci, xhci->devs[slot_id], ep_index,32653251 urb->stream_id, trbs_per_td, urb, i, mem_flags);32663266- if (ret < 0)32673267- return ret;32523252+ if (ret < 0) {32533253+ if (i == 0)32543254+ return ret;32553255+ goto cleanup;32563256+ }3268325732693269- urb_priv = urb->hcpriv;32703258 td = urb_priv->td[i];32713271-32723259 for (j = 0; j < trbs_per_td; j++) {32733260 u32 remainder = 0;32743261 field = TRB_TBC(burst_count) | TRB_TLBPC(residue);···33593344 giveback_first_trb(xhci, slot_id, ep_index, urb->stream_id,33603345 start_cycle, start_trb);33613346 return 0;33473347+cleanup:33483348+ /* Clean up a partially enqueued isoc transfer. */33493349+33503350+ for (i--; i >= 0; i--)33513351+ list_del_init(&urb_priv->td[i]->td_list);33523352+33533353+ /* Use the first TD as a temporary variable to turn the TDs we've queued33543354+ * into No-ops with a software-owned cycle bit. That way the hardware33553355+ * won't accidentally start executing bogus TDs when we partially33563356+ * overwrite them. td->first_trb and td->start_seg are already set.33573357+ */33583358+ urb_priv->td[0]->last_trb = ep_ring->enqueue;33593359+ /* Every TRB except the first & last will have its cycle bit flipped. */33603360+ td_to_noop(xhci, ep_ring, urb_priv->td[0], true);33613361+33623362+ /* Reset the ring enqueue back to the first TRB and its cycle bit. */33633363+ ep_ring->enqueue = urb_priv->td[0]->first_trb;33643364+ ep_ring->enq_seg = urb_priv->td[0]->start_seg;33653365+ ep_ring->cycle_state = start_cycle;33663366+ usb_hcd_unlink_urb_from_ep(bus_to_hcd(urb->dev->bus), urb);33673367+ return ret;33623368}3363336933643370/*
+24-4
drivers/usb/host/xhci.c
···10851085 if (urb->dev->speed == USB_SPEED_FULL) {10861086 ret = xhci_check_maxpacket(xhci, slot_id,10871087 ep_index, urb);10881088- if (ret < 0)10881088+ if (ret < 0) {10891089+ xhci_urb_free_priv(xhci, urb_priv);10901090+ urb->hcpriv = NULL;10891091 return ret;10921092+ }10901093 }1091109410921095 /* We have a spinlock and interrupts disabled, so we must pass···11001097 goto dying;11011098 ret = xhci_queue_ctrl_tx(xhci, GFP_ATOMIC, urb,11021099 slot_id, ep_index);11001100+ if (ret)11011101+ goto free_priv;11031102 spin_unlock_irqrestore(&xhci->lock, flags);11041103 } else if (usb_endpoint_xfer_bulk(&urb->ep->desc)) {11051104 spin_lock_irqsave(&xhci->lock, flags);···11221117 ret = xhci_queue_bulk_tx(xhci, GFP_ATOMIC, urb,11231118 slot_id, ep_index);11241119 }11201120+ if (ret)11211121+ goto free_priv;11251122 spin_unlock_irqrestore(&xhci->lock, flags);11261123 } else if (usb_endpoint_xfer_int(&urb->ep->desc)) {11271124 spin_lock_irqsave(&xhci->lock, flags);···11311124 goto dying;11321125 ret = xhci_queue_intr_tx(xhci, GFP_ATOMIC, urb,11331126 slot_id, ep_index);11271127+ if (ret)11281128+ goto free_priv;11341129 spin_unlock_irqrestore(&xhci->lock, flags);11351130 } else {11361131 spin_lock_irqsave(&xhci->lock, flags);···11401131 goto dying;11411132 ret = xhci_queue_isoc_tx_prepare(xhci, GFP_ATOMIC, urb,11421133 slot_id, ep_index);11341134+ if (ret)11351135+ goto free_priv;11431136 spin_unlock_irqrestore(&xhci->lock, flags);11441137 }11451138exit:11461139 return ret;11471140dying:11481148- xhci_urb_free_priv(xhci, urb_priv);11491149- urb->hcpriv = NULL;11501141 xhci_dbg(xhci, "Ep 0x%x: URB %p submitted for "11511142 "non-responsive xHCI host.\n",11521143 urb->ep->desc.bEndpointAddress, urb);11441144+ ret = -ESHUTDOWN;11451145+free_priv:11461146+ xhci_urb_free_priv(xhci, urb_priv);11471147+ urb->hcpriv = NULL;11531148 spin_unlock_irqrestore(&xhci->lock, flags);11541154- return -ESHUTDOWN;11491149+ return ret;11551150}1156115111571152/* Get the right ring for the given URB.···12521239 if (temp == 0xffffffff || (xhci->xhc_state & XHCI_STATE_HALTED)) {12531240 xhci_dbg(xhci, "HW died, freeing TD.\n");12541241 urb_priv = urb->hcpriv;12421242+ for (i = urb_priv->td_cnt; i < urb_priv->length; i++) {12431243+ td = urb_priv->td[i];12441244+ if (!list_empty(&td->td_list))12451245+ list_del_init(&td->td_list);12461246+ if (!list_empty(&td->cancelled_td_list))12471247+ list_del_init(&td->cancelled_td_list);12481248+ }1255124912561250 usb_hcd_unlink_urb_from_ep(hcd, urb);12571251 spin_unlock_irqrestore(&xhci->lock, flags);
···1111 * BRIGHT, on the Cirrus EP9307, EP9312, and EP9315 processors.1212 */13131414-1414+#include <linux/module.h>1515#include <linux/platform_device.h>1616#include <linux/io.h>1717#include <linux/fb.h>
+9
drivers/video/backlight/pwm_bl.c
···2828 unsigned int lth_brightness;2929 int (*notify)(struct device *,3030 int brightness);3131+ void (*notify_after)(struct device *,3232+ int brightness);3133 int (*check_fb)(struct device *, struct fb_info *);3234};3335···5755 pwm_config(pb->pwm, brightness, pb->period);5856 pwm_enable(pb->pwm);5957 }5858+5959+ if (pb->notify_after)6060+ pb->notify_after(pb->dev, brightness);6161+6062 return 0;6163}6264···111105112106 pb->period = data->pwm_period_ns;113107 pb->notify = data->notify;108108+ pb->notify_after = data->notify_after;114109 pb->check_fb = data->check_fb;115110 pb->lth_brightness = data->lth_brightness *116111 (data->pwm_period_ns / data->max_brightness);···179172 pb->notify(pb->dev, 0);180173 pwm_config(pb->pwm, 0, pb->period);181174 pwm_disable(pb->pwm);175175+ if (pb->notify_after)176176+ pb->notify_after(pb->dev, 0);182177 return 0;183178}184179
+2-2
drivers/w1/masters/ds2490.c
···11/*22 * dscore.c33 *44- * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>44+ * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>55 *66 *77 * This program is free software; you can redistribute it and/or modify···10241024module_exit(ds_fini);1025102510261026MODULE_LICENSE("GPL");10271027-MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>");10271027+MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>");10281028MODULE_DESCRIPTION("DS2490 USB <-> W1 bus master driver (DS9490*)");
+2-2
drivers/w1/masters/matrox_w1.c
···11/*22 * matrox_w1.c33 *44- * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>44+ * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>55 *66 *77 * This program is free software; you can redistribute it and/or modify···3939#include "../w1_log.h"40404141MODULE_LICENSE("GPL");4242-MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>");4242+MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>");4343MODULE_DESCRIPTION("Driver for transport(Dallas 1-wire prtocol) over VGA DDC(matrox gpio).");44444545static struct pci_device_id matrox_w1_tbl[] = {
+1-1
drivers/w1/slaves/w1_ds2408.c
···373373static void w1_f29_remove_slave(struct w1_slave *sl)374374{375375 int i;376376- for (i = NB_SYSFS_BIN_FILES; i <= 0; --i)376376+ for (i = NB_SYSFS_BIN_FILES - 1; i >= 0; --i)377377 sysfs_remove_bin_file(&sl->dev.kobj,378378 &(w1_f29_sysfs_bin_files[i]));379379}
+2-2
drivers/w1/slaves/w1_smem.c
···11/*22 * w1_smem.c33 *44- * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>44+ * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>55 *66 *77 * This program is free software; you can redistribute it and/or modify···3232#include "../w1_family.h"33333434MODULE_LICENSE("GPL");3535-MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>");3535+MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>");3636MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol, 64bit memory family.");37373838static struct w1_family w1_smem_family_01 = {
+2-2
drivers/w1/slaves/w1_therm.c
···11/*22 * w1_therm.c33 *44- * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>44+ * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>55 *66 *77 * This program is free software; you can redistribute it and/or modify···3434#include "../w1_family.h"35353636MODULE_LICENSE("GPL");3737-MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>");3737+MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>");3838MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol, temperature family.");39394040/* Allow the strong pullup to be disabled, but default to enabled.
+2-2
drivers/w1/w1.c
···11/*22 * w1.c33 *44- * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>44+ * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>55 *66 *77 * This program is free software; you can redistribute it and/or modify···4242#include "w1_netlink.h"43434444MODULE_LICENSE("GPL");4545-MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>");4545+MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>");4646MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol.");47474848static int w1_timeout = 10;
+1-1
drivers/w1/w1.h
···11/*22 * w1.h33 *44- * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>44+ * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>55 *66 *77 * This program is free software; you can redistribute it and/or modify
+1-1
drivers/w1/w1_family.c
···11/*22 * w1_family.c33 *44- * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>44+ * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>55 *66 *77 * This program is free software; you can redistribute it and/or modify
+1-1
drivers/w1/w1_family.h
···11/*22 * w1_family.h33 *44- * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>44+ * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>55 *66 *77 * This program is free software; you can redistribute it and/or modify
+1-1
drivers/w1/w1_int.c
···11/*22 * w1_int.c33 *44- * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>44+ * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>55 *66 *77 * This program is free software; you can redistribute it and/or modify
+1-1
drivers/w1/w1_int.h
···11/*22 * w1_int.h33 *44- * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>44+ * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>55 *66 *77 * This program is free software; you can redistribute it and/or modify
+1-1
drivers/w1/w1_io.c
···11/*22 * w1_io.c33 *44- * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>44+ * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>55 *66 *77 * This program is free software; you can redistribute it and/or modify
+1-1
drivers/w1/w1_log.h
···11/*22 * w1_log.h33 *44- * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>44+ * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>55 *66 *77 * This program is free software; you can redistribute it and/or modify
+1-1
drivers/w1/w1_netlink.c
···11/*22 * w1_netlink.c33 *44- * Copyright (c) 2003 Evgeniy Polyakov <johnpol@2ka.mipt.ru>44+ * Copyright (c) 2003 Evgeniy Polyakov <zbr@ioremap.net>55 *66 *77 * This program is free software; you can redistribute it and/or modify
+1-1
drivers/w1/w1_netlink.h
···11/*22 * w1_netlink.h33 *44- * Copyright (c) 2003 Evgeniy Polyakov <johnpol@2ka.mipt.ru>44+ * Copyright (c) 2003 Evgeniy Polyakov <zbr@ioremap.net>55 *66 *77 * This program is free software; you can redistribute it and/or modify
···848848}849849EXPORT_SYMBOL(new_inode);850850851851-/**852852- * unlock_new_inode - clear the I_NEW state and wake up any waiters853853- * @inode: new inode to unlock854854- *855855- * Called when the inode is fully initialised to clear the new state of the856856- * inode and wake up anyone waiting for the inode to finish initialisation.857857- */858858-void unlock_new_inode(struct inode *inode)859859-{860851#ifdef CONFIG_DEBUG_LOCK_ALLOC852852+void lockdep_annotate_inode_mutex_key(struct inode *inode)853853+{861854 if (S_ISDIR(inode->i_mode)) {862855 struct file_system_type *type = inode->i_sb->s_type;863856···866873 &type->i_mutex_dir_key);867874 }868875 }876876+}877877+EXPORT_SYMBOL(lockdep_annotate_inode_mutex_key);869878#endif879879+880880+/**881881+ * unlock_new_inode - clear the I_NEW state and wake up any waiters882882+ * @inode: new inode to unlock883883+ *884884+ * Called when the inode is fully initialised to clear the new state of the885885+ * inode and wake up anyone waiting for the inode to finish initialisation.886886+ */887887+void unlock_new_inode(struct inode *inode)888888+{889889+ lockdep_annotate_inode_mutex_key(inode);870890 spin_lock(&inode->i_lock);871891 WARN_ON(!(inode->i_state & I_NEW));872892 inode->i_state &= ~I_NEW;
···438438 struct compat_timespec __user *tsp,439439 const compat_sigset_t __user *sigmask,440440 compat_size_t sigsetsize);441441-asmlinkage long compat_sys_nfsservctl(int cmd, void *notused, void *notused2);442441asmlinkage long compat_sys_signalfd4(int ufd,443442 const compat_sigset_t __user *sigmask,444443 compat_size_t sigsetsize, int flags);
+1-1
include/linux/connector.h
···11/*22 * connector.h33 * 44- * 2004-2005 Copyright (c) Evgeniy Polyakov <johnpol@2ka.mipt.ru>44+ * 2004-2005 Copyright (c) Evgeniy Polyakov <zbr@ioremap.net>55 * All rights reserved.66 * 77 * This program is free software; you can redistribute it and/or modify
···2222 * These occupy the top three bytes.2323 */2424enum {2525+ UNAME26 = 0x0020000,2526 ADDR_NO_RANDOMIZE = 0x0040000, /* disable randomization of VA space */2627 FDPIC_FUNCPTRS = 0x0080000, /* userspace function ptrs point to descriptors2728 * (signal handling)
+1
include/linux/pwm_backlight.h
···1414 unsigned int pwm_period_ns;1515 int (*init)(struct device *dev);1616 int (*notify)(struct device *dev, int brightness);1717+ void (*notify_after)(struct device *dev, int brightness);1718 void (*exit)(struct device *dev);1819 int (*check_fb)(struct device *dev, struct fb_info *info);1920};
···702702asmlinkage long sys_sysinfo(struct sysinfo __user *info);703703asmlinkage long sys_sysfs(int option,704704 unsigned long arg1, unsigned long arg2);705705-asmlinkage long sys_nfsservctl(int cmd,706706- struct nfsctl_arg __user *arg,707707- void __user *res);708705asmlinkage long sys_syslog(int type, char __user *buf, int len);709706asmlinkage long sys_uselib(const char __user *library);710707asmlinkage long sys_ni_syscall(void);
+26-1
include/linux/ti_wilink_st.h
···410410 u16 plen;411411} __attribute__ ((packed));412412413413-/* platform data */413413+/**414414+ * struct ti_st_plat_data - platform data shared between ST driver and415415+ * platform specific board file which adds the ST device.416416+ * @nshutdown_gpio: Host's GPIO line to which chip's BT_EN is connected.417417+ * @dev_name: The UART/TTY name to which chip is interfaced. (eg: /dev/ttyS1)418418+ * @flow_cntrl: Should always be 1, since UART's CTS/RTS is used for PM419419+ * purposes.420420+ * @baud_rate: The baud rate supported by the Host UART controller, this will421421+ * be shared across with the chip via a HCI VS command from User-Space Init422422+ * Mgr application.423423+ * @suspend:424424+ * @resume: legacy PM routines hooked to platform specific board file, so as425425+ * to take chip-host interface specific action.426426+ * @chip_enable:427427+ * @chip_disable: Platform/Interface specific mux mode setting, GPIO428428+ * configuring, Host side PM disabling etc.. can be done here.429429+ * @chip_asleep:430430+ * @chip_awake: Chip specific deep sleep states is communicated to Host431431+ * specific board-xx.c to take actions such as cut UART clocks when chip432432+ * asleep or run host faster when chip awake etc..433433+ *434434+ */414435struct ti_st_plat_data {415436 long nshutdown_gpio;416437 unsigned char dev_name[UART_DEV_NAME_LEN]; /* uart name */···439418 unsigned long baud_rate;440419 int (*suspend)(struct platform_device *, pm_message_t);441420 int (*resume)(struct platform_device *);421421+ int (*chip_enable) (struct kim_data_s *);422422+ int (*chip_disable) (struct kim_data_s *);423423+ int (*chip_asleep) (struct kim_data_s *);424424+ int (*chip_awake) (struct kim_data_s *);442425};443426444427#endif /* TI_WILINK_ST_H */
···4747 *4848 * This routine is called synchronously when a particular tty device4949 * is closed for the last time freeing up the resources.5050+ * Note that tty_shutdown() is not called if ops->shutdown is defined.5151+ * This means one is responsible to take care of calling ops->remove (e.g.5252+ * via tty_driver_remove_tty) and releasing tty->termios.5053 *5154 *5255 * void (*cleanup)(struct tty_struct * tty);
-11
include/linux/writeback.h
···1212 *1313 * (thresh - thresh/DIRTY_FULL_SCOPE, thresh)1414 *1515- * The 1/16 region above the global dirty limit will be put to maximum pauses:1616- *1717- * (limit, limit + limit/DIRTY_MAXPAUSE_AREA)1818- *1919- * The 1/16 region above the max-pause region, dirty exceeded bdi's will be put2020- * to loops:2121- *2222- * (limit + limit/DIRTY_MAXPAUSE_AREA, limit + limit/DIRTY_PASSGOOD_AREA)2323- *2415 * Further beyond, all dirtier tasks will enter a loop waiting (possibly long2516 * time) for the dirty pages to drop, unless written enough pages.2617 *···2231 */2332#define DIRTY_SCOPE 82433#define DIRTY_FULL_SCOPE (DIRTY_SCOPE / 2)2525-#define DIRTY_MAXPAUSE_AREA 162626-#define DIRTY_PASSGOOD_AREA 827342835/*2936 * 4MB minimal write chunk size
+1
include/net/transp_v6.h
···3939 struct sk_buff *skb);40404141extern int datagram_send_ctl(struct net *net,4242+ struct sock *sk,4243 struct msghdr *msg,4344 struct flowi6 *fl6,4445 struct ipv6_txoptions *opt,
+6
include/target/target_core_fabric_ops.h
···2727 int (*tpg_check_demo_mode_cache)(struct se_portal_group *);2828 int (*tpg_check_demo_mode_write_protect)(struct se_portal_group *);2929 int (*tpg_check_prod_mode_write_protect)(struct se_portal_group *);3030+ /*3131+ * Optionally used by fabrics to allow demo-mode login, but not3232+ * expose any TPG LUNs, and return 'not connected' in standard3333+ * inquiry response3434+ */3535+ int (*tpg_check_demo_mode_login_only)(struct se_portal_group *);3036 struct se_node_acl *(*tpg_alloc_fabric_acl)(3137 struct se_portal_group *);3238 void (*tpg_release_fabric_acl)(struct se_portal_group *,
+1-1
kernel/printk.c
···16041604 struct console *con;1605160516061606 for_each_console(con) {16071607- if (con->flags & CON_BOOT) {16071607+ if (!keep_bootcon && con->flags & CON_BOOT) {16081608 printk(KERN_INFO "turn off boot console %s%d\n",16091609 con->name, con->index);16101610 unregister_console(con);
+38
kernel/sys.c
···3737#include <linux/fs_struct.h>3838#include <linux/gfp.h>3939#include <linux/syscore_ops.h>4040+#include <linux/version.h>4141+#include <linux/ctype.h>40424143#include <linux/compat.h>4244#include <linux/syscalls.h>···4644#include <linux/user_namespace.h>47454846#include <linux/kmsg_dump.h>4747+/* Move somewhere else to avoid recompiling? */4848+#include <generated/utsrelease.h>49495050#include <asm/uaccess.h>5151#include <asm/io.h>···11651161#define override_architecture(name) 011661162#endif1167116311641164+/*11651165+ * Work around broken programs that cannot handle "Linux 3.0".11661166+ * Instead we map 3.x to 2.6.40+x, so e.g. 3.0 would be 2.6.4011671167+ */11681168+static int override_release(char __user *release, int len)11691169+{11701170+ int ret = 0;11711171+ char buf[len];11721172+11731173+ if (current->personality & UNAME26) {11741174+ char *rest = UTS_RELEASE;11751175+ int ndots = 0;11761176+ unsigned v;11771177+11781178+ while (*rest) {11791179+ if (*rest == '.' && ++ndots >= 3)11801180+ break;11811181+ if (!isdigit(*rest) && *rest != '.')11821182+ break;11831183+ rest++;11841184+ }11851185+ v = ((LINUX_VERSION_CODE >> 8) & 0xff) + 40;11861186+ snprintf(buf, len, "2.6.%u%s", v, rest);11871187+ ret = copy_to_user(release, buf, len);11881188+ }11891189+ return ret;11901190+}11911191+11681192SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name)11691193{11701194 int errno = 0;···12021170 errno = -EFAULT;12031171 up_read(&uts_sem);1204117211731173+ if (!errno && override_release(name->release, sizeof(name->release)))11741174+ errno = -EFAULT;12051175 if (!errno && override_architecture(name))12061176 errno = -EFAULT;12071177 return errno;···12251191 error = -EFAULT;12261192 up_read(&uts_sem);1227119311941194+ if (!error && override_release(name->release, sizeof(name->release)))11951195+ error = -EFAULT;12281196 if (!error && override_architecture(name))12291197 error = -EFAULT;12301198 return error;···12601224 up_read(&uts_sem);1261122512621226 if (!error && override_architecture(name))12271227+ error = -EFAULT;12281228+ if (!error && override_release(name->release, sizeof(name->release)))12631229 error = -EFAULT;12641230 return error ? -EFAULT : 0;12651231}
···18411841 */18421842static bool mem_cgroup_oom_lock(struct mem_cgroup *mem)18431843{18441844- int lock_count = -1;18451844 struct mem_cgroup *iter, *failed = NULL;18461845 bool cond = true;1847184618481847 for_each_mem_cgroup_tree_cond(iter, mem, cond) {18491849- bool locked = iter->oom_lock;18501850-18511851- iter->oom_lock = true;18521852- if (lock_count == -1)18531853- lock_count = iter->oom_lock;18541854- else if (lock_count != locked) {18481848+ if (iter->oom_lock) {18551849 /*18561850 * this subtree of our hierarchy is already locked18571851 * so we cannot give a lock.18581852 */18591859- lock_count = 0;18601853 failed = iter;18611854 cond = false;18621862- }18551855+ } else18561856+ iter->oom_lock = true;18631857 }1864185818651859 if (!failed)18661866- goto done;18601860+ return true;1867186118681862 /*18691863 * OK, we failed to lock the whole subtree so we have to clean up···18711877 }18721878 iter->oom_lock = false;18731879 }18741874-done:18751875- return lock_count;18801880+ return false;18761881}1877188218781883/*···2162216921632170 /* Notify other cpus that system-wide "drain" is running */21642171 get_online_cpus();21652165- /*21662166- * Get a hint for avoiding draining charges on the current cpu,21672167- * which must be exhausted by our charging. It is not required that21682168- * this be a precise check, so we use raw_smp_processor_id() instead of21692169- * getcpu()/putcpu().21702170- */21712171- curcpu = raw_smp_processor_id();21722172+ curcpu = get_cpu();21722173 for_each_online_cpu(cpu) {21732174 struct memcg_stock_pcp *stock = &per_cpu(memcg_stock, cpu);21742175 struct mem_cgroup *mem;···21792192 schedule_work_on(cpu, &stock->work);21802193 }21812194 }21952195+ put_cpu();2182219621832197 if (!sync)21842198 goto out;
+2-13
mm/page-writeback.c
···754754 * 200ms is typically more than enough to curb heavy dirtiers;755755 * (b) the pause time limit makes the dirtiers more responsive.756756 */757757- if (nr_dirty < dirty_thresh +758758- dirty_thresh / DIRTY_MAXPAUSE_AREA &&757757+ if (nr_dirty < dirty_thresh &&758758+ bdi_dirty < (task_bdi_thresh + bdi_thresh) / 2 &&759759 time_after(jiffies, start_time + MAX_PAUSE))760760- break;761761- /*762762- * pass-good area. When some bdi gets blocked (eg. NFS server763763- * not responding), or write bandwidth dropped dramatically due764764- * to concurrent reads, or dirty threshold suddenly dropped and765765- * the dirty pages cannot be brought down anytime soon (eg. on766766- * slow USB stick), at least let go of the good bdi's.767767- */768768- if (nr_dirty < dirty_thresh +769769- dirty_thresh / DIRTY_PASSGOOD_AREA &&770770- bdi_dirty < bdi_thresh)771760 break;772761773762 /*
+11-8
mm/vmscan.c
···22832283 .mem_cgroup = mem,22842284 .memcg_record = rec,22852285 };22862286- unsigned long start, end;22862286+ ktime_t start, end;2287228722882288 sc.gfp_mask = (gfp_mask & GFP_RECLAIM_MASK) |22892289 (GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK);···22922292 sc.may_writepage,22932293 sc.gfp_mask);2294229422952295- start = sched_clock();22952295+ start = ktime_get();22962296 /*22972297 * NOTE: Although we can get the priority field, using it22982298 * here is not a good idea, since it limits the pages we can scan.···23012301 * the priority and make it zero.23022302 */23032303 shrink_zone(0, zone, &sc);23042304- end = sched_clock();23042304+ end = ktime_get();2305230523062306 if (rec)23072307- rec->elapsed += end - start;23072307+ rec->elapsed += ktime_to_ns(ktime_sub(end, start));23082308 *scanned = sc.nr_scanned;2309230923102310 trace_mm_vmscan_memcg_softlimit_reclaim_end(sc.nr_reclaimed);···23192319{23202320 struct zonelist *zonelist;23212321 unsigned long nr_reclaimed;23222322- unsigned long start, end;23222322+ ktime_t start, end;23232323 int nid;23242324 struct scan_control sc = {23252325 .may_writepage = !laptop_mode,···23372337 .gfp_mask = sc.gfp_mask,23382338 };2339233923402340- start = sched_clock();23402340+ start = ktime_get();23412341 /*23422342 * Unlike direct reclaim via alloc_pages(), memcg's reclaim doesn't23432343 * take care of from where we get pages. So the node where we start the···23522352 sc.gfp_mask);2353235323542354 nr_reclaimed = do_try_to_free_pages(zonelist, &sc, &shrink);23552355- end = sched_clock();23552355+ end = ktime_get();23562356 if (rec)23572357- rec->elapsed += end - start;23572357+ rec->elapsed += ktime_to_ns(ktime_sub(end, start));2358235823592359 trace_mm_vmscan_memcg_reclaim_end(nr_reclaimed);23602360···25292529 high_wmark_pages(zone), 0, 0)) {25302530 end_zone = i;25312531 break;25322532+ } else {25332533+ /* If balanced, clear the congested flag */25342534+ zone_clear_flag(zone, ZONE_CONGESTED);25322535 }25332536 }25342537 if (i < 0)
+1-1
net/bridge/netfilter/Kconfig
···4455menuconfig BRIDGE_NF_EBTABLES66 tristate "Ethernet Bridge tables (ebtables) support"77- depends on BRIDGE && BRIDGE_NETFILTER77+ depends on BRIDGE && NETFILTER88 select NETFILTER_XTABLES99 help1010 ebtables is a general, extensible frame/packet identification
+6-1
net/ipv4/af_inet.c
···466466 goto out;467467468468 if (addr->sin_family != AF_INET) {469469+ /* Compatibility games : accept AF_UNSPEC (mapped to AF_INET)470470+ * only if s_addr is INADDR_ANY.471471+ */469472 err = -EAFNOSUPPORT;470470- goto out;473473+ if (addr->sin_family != AF_UNSPEC ||474474+ addr->sin_addr.s_addr != htonl(INADDR_ANY))475475+ goto out;471476 }472477473478 chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
+5-7
net/ipv4/netfilter/ip_queue.c
···218218 return skb;219219220220nlmsg_failure:221221+ kfree_skb(skb);221222 *errp = -EINVAL;222223 printk(KERN_ERR "ip_queue: error creating packet message\n");223224 return NULL;···314313{315314 struct nf_queue_entry *entry;316315317317- if (vmsg->value > NF_MAX_VERDICT)316316+ if (vmsg->value > NF_MAX_VERDICT || vmsg->value == NF_STOLEN)318317 return -EINVAL;319318320319 entry = ipq_find_dequeue_entry(vmsg->id);···359358 break;360359361360 case IPQM_VERDICT:362362- if (pmsg->msg.verdict.value > NF_MAX_VERDICT)363363- status = -EINVAL;364364- else365365- status = ipq_set_verdict(&pmsg->msg.verdict,366366- len - sizeof(*pmsg));367367- break;361361+ status = ipq_set_verdict(&pmsg->msg.verdict,362362+ len - sizeof(*pmsg));363363+ break;368364 default:369365 status = -EINVAL;370366 }
+3-2
net/ipv6/datagram.c
···599599 return 0;600600}601601602602-int datagram_send_ctl(struct net *net,602602+int datagram_send_ctl(struct net *net, struct sock *sk,603603 struct msghdr *msg, struct flowi6 *fl6,604604 struct ipv6_txoptions *opt,605605 int *hlimit, int *tclass, int *dontfrag)···658658659659 if (addr_type != IPV6_ADDR_ANY) {660660 int strict = __ipv6_addr_src_scope(addr_type) <= IPV6_ADDR_SCOPE_LINKLOCAL;661661- if (!ipv6_chk_addr(net, &src_info->ipi6_addr,661661+ if (!inet_sk(sk)->transparent &&662662+ !ipv6_chk_addr(net, &src_info->ipi6_addr,662663 strict ? dev : NULL, 0))663664 err = -EINVAL;664665 else
+4-4
net/ipv6/ip6_flowlabel.c
···322322}323323324324static struct ip6_flowlabel *325325-fl_create(struct net *net, struct in6_flowlabel_req *freq, char __user *optval,326326- int optlen, int *err_p)325325+fl_create(struct net *net, struct sock *sk, struct in6_flowlabel_req *freq,326326+ char __user *optval, int optlen, int *err_p)327327{328328 struct ip6_flowlabel *fl = NULL;329329 int olen;···360360 msg.msg_control = (void*)(fl->opt+1);361361 memset(&flowi6, 0, sizeof(flowi6));362362363363- err = datagram_send_ctl(net, &msg, &flowi6, fl->opt, &junk,363363+ err = datagram_send_ctl(net, sk, &msg, &flowi6, fl->opt, &junk,364364 &junk, &junk);365365 if (err)366366 goto done;···528528 if (freq.flr_label & ~IPV6_FLOWLABEL_MASK)529529 return -EINVAL;530530531531- fl = fl_create(net, &freq, optval, optlen, &err);531531+ fl = fl_create(net, sk, &freq, optval, optlen, &err);532532 if (fl == NULL)533533 return err;534534 sfl1 = kmalloc(sizeof(*sfl1), GFP_KERNEL);
···364364 break;365365366366 case PPTP_WAN_ERROR_NOTIFY:367367+ case PPTP_SET_LINK_INFO:367368 case PPTP_ECHO_REQUEST:368369 case PPTP_ECHO_REPLY:369370 /* I don't have to explain these ;) */
···879879 * assume that device_node pointers are a valid comparison.880880 */881881 np = of_parse_phandle(ssi_np, "fsl,playback-dma", 0);882882+ of_node_put(np);882883 if (np == dma_channel_np)883884 return ssi_np;884885885886 np = of_parse_phandle(ssi_np, "fsl,capture-dma", 0);887887+ of_node_put(np);886888 if (np == dma_channel_np)887889 return ssi_np;888890 }
+9-9
sound/soc/fsl/mpc8610_hpcd.c
···345345 }346346347347 machine_data = kzalloc(sizeof(struct mpc8610_hpcd_data), GFP_KERNEL);348348- if (!machine_data)349349- return -ENOMEM;348348+ if (!machine_data) {349349+ ret = -ENOMEM;350350+ goto error_alloc;351351+ }350352351353 machine_data->dai[0].cpu_dai_name = dev_name(&ssi_pdev->dev);352354 machine_data->dai[0].ops = &mpc8610_hpcd_ops;···496494 ret = platform_device_add(sound_device);497495 if (ret) {498496 dev_err(&pdev->dev, "platform device add failed\n");499499- goto error;497497+ goto error_sound;500498 }501499 dev_set_drvdata(&pdev->dev, sound_device);502500···504502505503 return 0;506504505505+error_sound:506506+ platform_device_unregister(sound_device);507507error:508508- of_node_put(codec_np);509509-510510- if (sound_device)511511- platform_device_unregister(sound_device);512512-513508 kfree(machine_data);514514-509509+error_alloc:510510+ of_node_put(codec_np);515511 return ret;516512}517513
+3-1
sound/soc/fsl/p1022_ds.c
···297297 * dai->platform name should already point to an allocated buffer.298298 */299299 ret = of_address_to_resource(dma_channel_np, 0, &res);300300- if (ret)300300+ if (ret) {301301+ of_node_put(dma_channel_np);301302 return ret;303303+ }302304 snprintf((char *)dai->platform_name, DAI_NAME_SIZE, "%llx.%s",303305 (unsigned long long) res.start, dma_channel_np->name);304306
···514514 }515515516516 /* Set codec bias level */517517- ams_delta_set_bias_level(card, SND_SOC_BIAS_STANDBY);517517+ ams_delta_set_bias_level(card, dapm, SND_SOC_BIAS_STANDBY);518518519519 /* Add hook switch - can be used to control the codec from userspace520520 * even if line discipline fails */···649649 ams_delta_hook_switch_gpios);650650651651 /* Keep modem power on */652652- ams_delta_set_bias_level(&ams_delta_audio_card, SND_SOC_BIAS_STANDBY);652652+ ams_delta_set_bias_level(&ams_delta_audio_card,653653+ &ams_delta_audio_card.rtd[0].codec->dapm,654654+ SND_SOC_BIAS_STANDBY);653655654656 platform_device_unregister(cx20442_platform_device);655657 platform_device_unregister(ams_delta_audio_platform_device);
+1
sound/soc/samsung/Kconfig
···185185 select SND_SAMSUNG_I2S186186 select SND_SOC_WM8996187187 select SND_SOC_WM9081188188+ select SND_SOC_WM1250_EV1188189189190config SND_SOC_SPEYSIDE_WM8962190191 tristate "Audio support for Wolfson Speyside with WM8962"
···290290 codec_dai->active--;291291 codec->active--;292292293293+ if (!cpu_dai->active && !codec_dai->active)294294+ rtd->rate = 0;295295+293296 /* Muting the DAC suppresses artifacts caused during digital294297 * shutdown, for example from stopping clocks.295298 */
+2-2
sound/soc/tegra/tegra_wm8903.c
···319319 snd_soc_dapm_force_enable_pin(dapm, "Mic Bias");320320321321 /* FIXME: Calculate automatically based on DAPM routes? */322322- if (!machine_is_harmony() && !machine_is_ventana())322322+ if (!machine_is_harmony())323323 snd_soc_dapm_nc_pin(dapm, "IN1L");324324 if (!machine_is_seaboard() && !machine_is_aebl())325325 snd_soc_dapm_nc_pin(dapm, "IN1R");···395395 platform_set_drvdata(pdev, card);396396 snd_soc_card_set_drvdata(card, machine);397397398398- if (machine_is_harmony() || machine_is_ventana()) {398398+ if (machine_is_harmony()) {399399 card->dapm_routes = harmony_audio_map;400400 card->num_dapm_routes = ARRAY_SIZE(harmony_audio_map);401401 } else if (machine_is_seaboard()) {
+4-3
tools/power/cpupower/Makefile
···24242525# Set the following to `true' to make a unstripped, unoptimized2626# binary. Leave this set to `false' for production use.2727-DEBUG ?= false2727+DEBUG ?= true28282929# make the build silent. Set this to something else to make it noisy again.3030V ?= false···35353636# Set the following to 'true' to build/install the3737# cpufreq-bench benchmarking tool3838-CPUFRQ_BENCH ?= true3838+CPUFREQ_BENCH ?= true39394040# Prefix to the directories we're installing to4141DESTDIR ?=···137137ifeq ($(strip $(NLS)),true)138138 INSTALL_NLS += install-gmo139139 COMPILE_NLS += create-gmo140140+ CFLAGS += -DNLS140141endif141142142142-ifeq ($(strip $(CPUFRQ_BENCH)),true)143143+ifeq ($(strip $(CPUFREQ_BENCH)),true)143144 INSTALL_BENCH += install-bench144145 COMPILE_BENCH += compile-bench145146endif
···11-.TH "cpufreq-info" "1" "0.1" "Mattia Dongili" ""11+.TH "cpupower-frequency-info" "1" "0.1" "Mattia Dongili" ""22.SH "NAME"33.LP 44-cpufreq\-info \- Utility to retrieve cpufreq kernel information44+cpupower frequency\-info \- Utility to retrieve cpufreq kernel information55.SH "SYNTAX"66.LP 77-cpufreq\-info [\fIoptions\fP]77+cpupower [ \-c cpulist ] frequency\-info [\fIoptions\fP]88.SH "DESCRIPTION"99.LP 1010A small tool which prints out cpufreq information helpful to developers and interested users.
+4-4
tools/power/cpupower/man/cpupower-frequency-set.1
···11-.TH "cpufreq-set" "1" "0.1" "Mattia Dongili" ""11+.TH "cpupower-freqency-set" "1" "0.1" "Mattia Dongili" ""22.SH "NAME"33.LP 44-cpufreq\-set \- A small tool which allows to modify cpufreq settings.44+cpupower frequency\-set \- A small tool which allows to modify cpufreq settings.55.SH "SYNTAX"66.LP 77-cpufreq\-set [\fIoptions\fP]77+cpupower [ \-c cpu ] frequency\-set [\fIoptions\fP]88.SH "DESCRIPTION"99.LP 1010-cpufreq\-set allows you to modify cpufreq settings without having to type e.g. "/sys/devices/system/cpu/cpu0/cpufreq/scaling_set_speed" all the time.1010+cpupower frequency\-set allows you to modify cpufreq settings without having to type e.g. "/sys/devices/system/cpu/cpu0/cpufreq/scaling_set_speed" all the time.1111.SH "OPTIONS"1212.LP 1313.TP
+7-7
tools/power/cpupower/man/cpupower.1
···33cpupower \- Shows and sets processor power related values44.SH SYNOPSIS55.ft B66-.B cpupower [ \-c cpulist ] subcommand [ARGS]66+.B cpupower [ \-c cpulist ] <command> [ARGS]7788.B cpupower \-v|\-\-version99···1313\fBcpupower \fP is a collection of tools to examine and tune power saving1414related features of your processor.15151616-The manpages of the subcommands (cpupower\-<subcommand>(1)) provide detailed1616+The manpages of the commands (cpupower\-<command>(1)) provide detailed1717descriptions of supported features. Run \fBcpupower help\fP to get an overview1818-of supported subcommands.1818+of supported commands.19192020.SH Options2121.PP2222\-\-help, \-h2323.RS 42424-Shows supported subcommands and general usage.2424+Shows supported commands and general usage.2525.RE2626.PP2727\-\-cpu cpulist, \-c cpulist2828.RS 42929Only show or set values for specific cores.3030-This option is not supported by all subcommands, details can be found in the3131-manpages of the subcommands.3030+This option is not supported by all commands, details can be found in the3131+manpages of the commands.32323333-Some subcommands access all cores (typically the *\-set commands), some only3333+Some commands access all cores (typically the *\-set commands), some only3434the first core (typically the *\-info commands) by default.35353636The syntax for <cpulist> is based on how the kernel exports CPU bitmasks via
···510510 return 0;511511}512512513513-void freq_info_help(void)514514-{515515- printf(_("Usage: cpupower freqinfo [options]\n"));516516- printf(_("Options:\n"));517517- printf(_(" -e, --debug Prints out debug information [default]\n"));518518- printf(_(" -f, --freq Get frequency the CPU currently runs at, according\n"519519- " to the cpufreq core *\n"));520520- printf(_(" -w, --hwfreq Get frequency the CPU currently runs at, by reading\n"521521- " it from hardware (only available to root) *\n"));522522- printf(_(" -l, --hwlimits Determine the minimum and maximum CPU frequency allowed *\n"));523523- printf(_(" -d, --driver Determines the used cpufreq kernel driver *\n"));524524- printf(_(" -p, --policy Gets the currently used cpufreq policy *\n"));525525- printf(_(" -g, --governors Determines available cpufreq governors *\n"));526526- printf(_(" -r, --related-cpus Determines which CPUs run at the same hardware frequency *\n"));527527- printf(_(" -a, --affected-cpus Determines which CPUs need to have their frequency\n"528528- " coordinated by software *\n"));529529- printf(_(" -s, --stats Shows cpufreq statistics if available\n"));530530- printf(_(" -y, --latency Determines the maximum latency on CPU frequency changes *\n"));531531- printf(_(" -b, --boost Checks for turbo or boost modes *\n"));532532- printf(_(" -o, --proc Prints out information like provided by the /proc/cpufreq\n"533533- " interface in 2.4. and early 2.6. kernels\n"));534534- printf(_(" -m, --human human-readable output for the -f, -w, -s and -y parameters\n"));535535- printf(_(" -h, --help Prints out this screen\n"));536536-537537- printf("\n");538538- printf(_("If no argument is given, full output about\n"539539- "cpufreq is printed which is useful e.g. for reporting bugs.\n\n"));540540- printf(_("By default info of CPU 0 is shown which can be overridden\n"541541- "with the cpupower --cpu main command option.\n"));542542-}543543-544513static struct option info_opts[] = {545514 { .name = "debug", .has_arg = no_argument, .flag = NULL, .val = 'e'},546515 { .name = "boost", .has_arg = no_argument, .flag = NULL, .val = 'b'},···525556 { .name = "latency", .has_arg = no_argument, .flag = NULL, .val = 'y'},526557 { .name = "proc", .has_arg = no_argument, .flag = NULL, .val = 'o'},527558 { .name = "human", .has_arg = no_argument, .flag = NULL, .val = 'm'},528528- { .name = "help", .has_arg = no_argument, .flag = NULL, .val = 'h'},529559 { },530560};531561···538570 int output_param = 0;539571540572 do {541541- ret = getopt_long(argc, argv, "hoefwldpgrasmyb", info_opts, NULL);573573+ ret = getopt_long(argc, argv, "oefwldpgrasmyb", info_opts, NULL);542574 switch (ret) {543575 case '?':544576 output_param = '?';545545- cont = 0;546546- break;547547- case 'h':548548- output_param = 'h';549577 cont = 0;550578 break;551579 case -1:···606642 return -EINVAL;607643 case '?':608644 printf(_("invalid or unknown argument\n"));609609- freq_info_help();610645 return -EINVAL;611611- case 'h':612612- freq_info_help();613613- return EXIT_SUCCESS;614646 case 'o':615647 proc_cpufreq_output();616648 return EXIT_SUCCESS;
+1-28
tools/power/cpupower/utils/cpufreq-set.c
···20202121#define NORM_FREQ_LEN 3222222323-void freq_set_help(void)2424-{2525- printf(_("Usage: cpupower frequency-set [options]\n"));2626- printf(_("Options:\n"));2727- printf(_(" -d FREQ, --min FREQ new minimum CPU frequency the governor may select\n"));2828- printf(_(" -u FREQ, --max FREQ new maximum CPU frequency the governor may select\n"));2929- printf(_(" -g GOV, --governor GOV new cpufreq governor\n"));3030- printf(_(" -f FREQ, --freq FREQ specific frequency to be set. Requires userspace\n"3131- " governor to be available and loaded\n"));3232- printf(_(" -r, --related Switches all hardware-related CPUs\n"));3333- printf(_(" -h, --help Prints out this screen\n"));3434- printf("\n");3535- printf(_("Notes:\n"3636- "1. Omitting the -c or --cpu argument is equivalent to setting it to \"all\"\n"));3737- printf(_("2. The -f FREQ, --freq FREQ parameter cannot be combined with any other parameter\n"3838- " except the -c CPU, --cpu CPU parameter\n"3939- "3. FREQuencies can be passed in Hz, kHz (default), MHz, GHz, or THz\n"4040- " by postfixing the value with the wanted unit name, without any space\n"4141- " (FREQuency in kHz =^ Hz * 0.001 =^ MHz * 1000 =^ GHz * 1000000).\n"));4242-4343-}4444-4523static struct option set_opts[] = {4624 { .name = "min", .has_arg = required_argument, .flag = NULL, .val = 'd'},4725 { .name = "max", .has_arg = required_argument, .flag = NULL, .val = 'u'},4826 { .name = "governor", .has_arg = required_argument, .flag = NULL, .val = 'g'},4927 { .name = "freq", .has_arg = required_argument, .flag = NULL, .val = 'f'},5050- { .name = "help", .has_arg = no_argument, .flag = NULL, .val = 'h'},5128 { .name = "related", .has_arg = no_argument, .flag = NULL, .val='r'},5229 { },5330};···5780static void print_unknown_arg(void)5881{5982 printf(_("invalid or unknown argument\n"));6060- freq_set_help();6183}62846385static unsigned long string_to_frequency(const char *str)···207231208232 /* parameter parsing */209233 do {210210- ret = getopt_long(argc, argv, "d:u:g:f:hr", set_opts, NULL);234234+ ret = getopt_long(argc, argv, "d:u:g:f:r", set_opts, NULL);211235 switch (ret) {212236 case '?':213237 print_unknown_arg();214238 return -EINVAL;215215- case 'h':216216- freq_set_help();217217- return 0;218239 case -1:219240 cont = 0;220241 break;
+1-23
tools/power/cpupower/utils/cpuidle-info.c
···139139 }140140}141141142142-/* --freq / -f */143143-144144-void idle_info_help(void)145145-{146146- printf(_ ("Usage: cpupower idleinfo [options]\n"));147147- printf(_ ("Options:\n"));148148- printf(_ (" -s, --silent Only show general C-state information\n"));149149- printf(_ (" -o, --proc Prints out information like provided by the /proc/acpi/processor/*/power\n"150150- " interface in older kernels\n"));151151- printf(_ (" -h, --help Prints out this screen\n"));152152-153153- printf("\n");154154-}155155-156142static struct option info_opts[] = {157143 { .name = "silent", .has_arg = no_argument, .flag = NULL, .val = 's'},158144 { .name = "proc", .has_arg = no_argument, .flag = NULL, .val = 'o'},159159- { .name = "help", .has_arg = no_argument, .flag = NULL, .val = 'h'},160145 { },161146};162147163148static inline void cpuidle_exit(int fail)164149{165165- idle_info_help();166150 exit(EXIT_FAILURE);167151}168152···158174 unsigned int cpu = 0;159175160176 do {161161- ret = getopt_long(argc, argv, "hos", info_opts, NULL);177177+ ret = getopt_long(argc, argv, "os", info_opts, NULL);162178 if (ret == -1)163179 break;164180 switch (ret) {165181 case '?':166182 output_param = '?';167167- cont = 0;168168- break;169169- case 'h':170170- output_param = 'h';171183 cont = 0;172184 break;173185 case 's':···191211 case '?':192212 printf(_("invalid or unknown argument\n"));193213 cpuidle_exit(EXIT_FAILURE);194194- case 'h':195195- cpuidle_exit(EXIT_SUCCESS);196214 }197215198216 /* Default is: show output of CPU 0 only */
+1-19
tools/power/cpupower/utils/cpupower-info.c
···1616#include "helpers/helpers.h"1717#include "helpers/sysfs.h"18181919-void info_help(void)2020-{2121- printf(_("Usage: cpupower info [ -b ] [ -m ] [ -s ]\n"));2222- printf(_("Options:\n"));2323- printf(_(" -b, --perf-bias Gets CPU's power vs performance policy on some\n"2424- " Intel models [0-15], see manpage for details\n"));2525- printf(_(" -m, --sched-mc Gets the kernel's multi core scheduler policy.\n"));2626- printf(_(" -s, --sched-smt Gets the kernel's thread sibling scheduler policy.\n"));2727- printf(_(" -h, --help Prints out this screen\n"));2828- printf(_("\nPassing no option will show all info, by default only on core 0\n"));2929- printf("\n");3030-}3131-3219static struct option set_opts[] = {3320 { .name = "perf-bias", .has_arg = optional_argument, .flag = NULL, .val = 'b'},3421 { .name = "sched-mc", .has_arg = optional_argument, .flag = NULL, .val = 'm'},3522 { .name = "sched-smt", .has_arg = optional_argument, .flag = NULL, .val = 's'},3636- { .name = "help", .has_arg = no_argument, .flag = NULL, .val = 'h'},3723 { },3824};39254026static void print_wrong_arg_exit(void)4127{4228 printf(_("invalid or unknown argument\n"));4343- info_help();4429 exit(EXIT_FAILURE);4530}4631···4964 textdomain(PACKAGE);50655166 /* parameter parsing */5252- while ((ret = getopt_long(argc, argv, "msbh", set_opts, NULL)) != -1) {6767+ while ((ret = getopt_long(argc, argv, "msb", set_opts, NULL)) != -1) {5368 switch (ret) {5454- case 'h':5555- info_help();5656- return 0;5769 case 'b':5870 if (params.perf_bias)5971 print_wrong_arg_exit();
+3-22
tools/power/cpupower/utils/cpupower-set.c
···1717#include "helpers/sysfs.h"1818#include "helpers/bitmask.h"19192020-void set_help(void)2121-{2222- printf(_("Usage: cpupower set [ -b val ] [ -m val ] [ -s val ]\n"));2323- printf(_("Options:\n"));2424- printf(_(" -b, --perf-bias [VAL] Sets CPU's power vs performance policy on some\n"2525- " Intel models [0-15], see manpage for details\n"));2626- printf(_(" -m, --sched-mc [VAL] Sets the kernel's multi core scheduler policy.\n"));2727- printf(_(" -s, --sched-smt [VAL] Sets the kernel's thread sibling scheduler policy.\n"));2828- printf(_(" -h, --help Prints out this screen\n"));2929- printf("\n");3030-}3131-3220static struct option set_opts[] = {3321 { .name = "perf-bias", .has_arg = optional_argument, .flag = NULL, .val = 'b'},3422 { .name = "sched-mc", .has_arg = optional_argument, .flag = NULL, .val = 'm'},3523 { .name = "sched-smt", .has_arg = optional_argument, .flag = NULL, .val = 's'},3636- { .name = "help", .has_arg = no_argument, .flag = NULL, .val = 'h'},3724 { },3825};39264027static void print_wrong_arg_exit(void)4128{4229 printf(_("invalid or unknown argument\n"));4343- set_help();4430 exit(EXIT_FAILURE);4531}4632···52665367 params.params = 0;5468 /* parameter parsing */5555- while ((ret = getopt_long(argc, argv, "m:s:b:h",6969+ while ((ret = getopt_long(argc, argv, "m:s:b:",5670 set_opts, NULL)) != -1) {5771 switch (ret) {5858- case 'h':5959- set_help();6060- return 0;6172 case 'b':6273 if (params.perf_bias)6374 print_wrong_arg_exit();···93110 }94111 };951129696- if (!params.params) {9797- set_help();9898- return -EINVAL;9999- }113113+ if (!params.params)114114+ print_wrong_arg_exit();100115101116 if (params.sched_mc) {102117 ret = sysfs_set_sched("mc", sched_mc);
+51-40
tools/power/cpupower/utils/cpupower.c
···1111#include <stdlib.h>1212#include <string.h>1313#include <unistd.h>1414+#include <errno.h>14151516#include "builtin.h"1617#include "helpers/helpers.h"···2019struct cmd_struct {2120 const char *cmd;2221 int (*main)(int, const char **);2323- void (*usage)(void);2422 int needs_root;2523};26242725#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))28262929-int cmd_help(int argc, const char **argv);2727+static int cmd_help(int argc, const char **argv);30283129/* Global cpu_info object available for all binaries3230 * Info only retrieved from CPU 0···4444static void print_help(void);45454646static struct cmd_struct commands[] = {4747- { "frequency-info", cmd_freq_info, freq_info_help, 0 },4848- { "frequency-set", cmd_freq_set, freq_set_help, 1 },4949- { "idle-info", cmd_idle_info, idle_info_help, 0 },5050- { "set", cmd_set, set_help, 1 },5151- { "info", cmd_info, info_help, 0 },5252- { "monitor", cmd_monitor, monitor_help, 0 },5353- { "help", cmd_help, print_help, 0 },5454- /* { "bench", cmd_bench, NULL, 1 }, */4747+ { "frequency-info", cmd_freq_info, 0 },4848+ { "frequency-set", cmd_freq_set, 1 },4949+ { "idle-info", cmd_idle_info, 0 },5050+ { "set", cmd_set, 1 },5151+ { "info", cmd_info, 0 },5252+ { "monitor", cmd_monitor, 0 },5353+ { "help", cmd_help, 0 },5454+ /* { "bench", cmd_bench, 1 }, */5555};5656-5757-int cmd_help(int argc, const char **argv)5858-{5959- unsigned int i;6060-6161- if (argc > 1) {6262- for (i = 0; i < ARRAY_SIZE(commands); i++) {6363- struct cmd_struct *p = commands + i;6464- if (strcmp(p->cmd, argv[1]))6565- continue;6666- if (p->usage) {6767- p->usage();6868- return EXIT_SUCCESS;6969- }7070- }7171- }7272- print_help();7373- if (argc == 1)7474- return EXIT_SUCCESS; /* cpupower help */7575- return EXIT_FAILURE;7676-}77567857static void print_help(void)7958{8059 unsigned int i;81608261#ifdef DEBUG8383- printf(_("cpupower [ -d ][ -c cpulist ] subcommand [ARGS]\n"));8484- printf(_(" -d, --debug May increase output (stderr) on some subcommands\n"));6262+ printf(_("Usage:\tcpupower [-d|--debug] [-c|--cpu cpulist ] <command> [<args>]\n"));8563#else8686- printf(_("cpupower [ -c cpulist ] subcommand [ARGS]\n"));6464+ printf(_("Usage:\tcpupower [-c|--cpu cpulist ] <command> [<args>]\n"));8765#endif8888- printf(_("cpupower --version\n"));8989- printf(_("Supported subcommands are:\n"));6666+ printf(_("Supported commands are:\n"));9067 for (i = 0; i < ARRAY_SIZE(commands); i++)9168 printf("\t%s\n", commands[i].cmd);9292- printf(_("\nSome subcommands can make use of the -c cpulist option.\n"));9393- printf(_("Look at the general cpupower manpage how to use it\n"));9494- printf(_("and read up the subcommand's manpage whether it is supported.\n"));9595- printf(_("\nUse cpupower help subcommand for getting help for above subcommands.\n"));6969+ printf(_("\nNot all commands can make use of the -c cpulist option.\n"));7070+ printf(_("\nUse 'cpupower help <command>' for getting help for above commands.\n"));7171+}7272+7373+static int print_man_page(const char *subpage)7474+{7575+ int len;7676+ char *page;7777+7878+ len = 10; /* enough for "cpupower-" */7979+ if (subpage != NULL)8080+ len += strlen(subpage);8181+8282+ page = malloc(len);8383+ if (!page)8484+ return -ENOMEM;8585+8686+ sprintf(page, "cpupower");8787+ if ((subpage != NULL) && strcmp(subpage, "help")) {8888+ strcat(page, "-");8989+ strcat(page, subpage);9090+ }9191+9292+ execlp("man", "man", page, NULL);9393+9494+ /* should not be reached */9595+ return -EINVAL;9696+}9797+9898+static int cmd_help(int argc, const char **argv)9999+{100100+ if (argc > 1) {101101+ print_man_page(argv[1]); /* exits within execlp() */102102+ return EXIT_FAILURE;103103+ }104104+105105+ print_help();106106+ return EXIT_SUCCESS;96107}9710898109static void print_version(void)
+12
tools/power/cpupower/utils/helpers/helpers.h
···1616#include "helpers/bitmask.h"17171818/* Internationalization ****************************/1919+#ifdef NLS2020+1921#define _(String) gettext(String)2022#ifndef gettext_noop2123#define gettext_noop(String) String2224#endif2325#define N_(String) gettext_noop(String)2626+2727+#else /* !NLS */2828+2929+#define _(String) String3030+#define N_(String) String3131+3232+#endif2433/* Internationalization ****************************/25342635extern int run_as_root;···10596 int pkg;10697 int core;10798 int cpu;9999+100100+ /* flags */101101+ unsigned int is_online:1;108102 } *core_info;109103};110104
+50
tools/power/cpupower/utils/helpers/sysfs.c
···5656 return (unsigned int) numwrite;5757}58585959+/*6060+ * Detect whether a CPU is online6161+ *6262+ * Returns:6363+ * 1 -> if CPU is online6464+ * 0 -> if CPU is offline6565+ * negative errno values in error case6666+ */6767+int sysfs_is_cpu_online(unsigned int cpu)6868+{6969+ char path[SYSFS_PATH_MAX];7070+ int fd;7171+ ssize_t numread;7272+ unsigned long long value;7373+ char linebuf[MAX_LINE_LEN];7474+ char *endp;7575+ struct stat statbuf;7676+7777+ snprintf(path, sizeof(path), PATH_TO_CPU "cpu%u", cpu);7878+7979+ if (stat(path, &statbuf) != 0)8080+ return 0;8181+8282+ /*8383+ * kernel without CONFIG_HOTPLUG_CPU8484+ * -> cpuX directory exists, but not cpuX/online file8585+ */8686+ snprintf(path, sizeof(path), PATH_TO_CPU "cpu%u/online", cpu);8787+ if (stat(path, &statbuf) != 0)8888+ return 1;8989+9090+ fd = open(path, O_RDONLY);9191+ if (fd == -1)9292+ return -errno;9393+9494+ numread = read(fd, linebuf, MAX_LINE_LEN - 1);9595+ if (numread < 1) {9696+ close(fd);9797+ return -EIO;9898+ }9999+ linebuf[numread] = '\0';100100+ close(fd);101101+102102+ value = strtoull(linebuf, &endp, 0);103103+ if (value > 1 || value < 0)104104+ return -EINVAL;105105+106106+ return value;107107+}108108+59109/* CPUidle idlestate specific /sys/devices/system/cpu/cpuX/cpuidle/ access */6011061111/*
+2
tools/power/cpupower/utils/helpers/sysfs.h
···7788extern unsigned int sysfs_read_file(const char *path, char *buf, size_t buflen);991010+extern int sysfs_is_cpu_online(unsigned int cpu);1111+1012extern unsigned long sysfs_get_idlestate_latency(unsigned int cpu,1113 unsigned int idlestate);1214extern unsigned long sysfs_get_idlestate_usage(unsigned int cpu,
+4-1
tools/power/cpupower/utils/helpers/topology.c
···4141 unsigned int pkg;4242 unsigned int thread;4343 unsigned int cpu;4444+ /* flags */4545+ unsigned int is_online:1;4446};45474648static int __compare(const void *t1, const void *t2)···8078 return -ENOMEM;8179 cpu_top->pkgs = cpu_top->cores = 0;8280 for (cpu = 0; cpu < cpus; cpu++) {8181+ cpu_top->core_info[cpu].cpu = cpu;8282+ cpu_top->core_info[cpu].is_online = sysfs_is_cpu_online(cpu);8383 cpu_top->core_info[cpu].pkg =8484 sysfs_topology_read_file(cpu, "physical_package_id");8585 if ((int)cpu_top->core_info[cpu].pkg != -1 &&···8985 cpu_top->pkgs = cpu_top->core_info[cpu].pkg;9086 cpu_top->core_info[cpu].core =9187 sysfs_topology_read_file(cpu, "core_id");9292- cpu_top->core_info[cpu].cpu = cpu;9388 }9489 cpu_top->pkgs++;9590
···134134 /* Assume idle state count is the same for all CPUs */135135 cpuidle_sysfs_monitor.hw_states_num = sysfs_get_idlestate_count(0);136136137137- if (cpuidle_sysfs_monitor.hw_states_num == 0)137137+ if (cpuidle_sysfs_monitor.hw_states_num <= 0)138138 return NULL;139139140140 for (num = 0; num < cpuidle_sysfs_monitor.hw_states_num; num++) {
···4343/* ToDo: Document this in the manpage */4444static char range_abbr[RANGE_MAX] = { 'T', 'C', 'P', 'M', };45454646+static void print_wrong_arg_exit(void)4747+{4848+ printf(_("invalid or unknown argument\n"));4949+ exit(EXIT_FAILURE);5050+}5151+4652long long timespec_diff_us(struct timespec start, struct timespec end)4753{4854 struct timespec temp;···6054 temp.tv_nsec = end.tv_nsec - start.tv_nsec;6155 }6256 return (temp.tv_sec * 1000000) + (temp.tv_nsec / 1000);6363-}6464-6565-void monitor_help(void)6666-{6767- printf(_("cpupower monitor: [-m <mon1>,[<mon2>],.. ] command\n"));6868- printf(_("cpupower monitor: [-m <mon1>,[<mon2>],.. ] [ -i interval_sec ]\n"));6969- printf(_("cpupower monitor: -l\n"));7070- printf(_("\t command: pass an arbitrary command to measure specific workload\n"));7171- printf(_("\t -i: time intervall to measure for in seconds (default 1)\n"));7272- printf(_("\t -l: list available CPU sleep monitors (for use with -m)\n"));7373- printf(_("\t -m: show specific CPU sleep monitors only (in same order)\n"));7474- printf(_("\t -h: print this help\n"));7575- printf("\n");7676- printf(_("only one of: -l, -m are allowed\nIf none of them is passed,"));7777- printf(_(" all supported monitors are shown\n"));7857}79588059void print_n_spaces(int n)···140149 unsigned long long result;141150 cstate_t s;142151152152+ /* Be careful CPUs may got resorted for pkg value do not just use cpu */153153+ if (!bitmask_isbitset(cpus_chosen, cpu_top.core_info[cpu].cpu))154154+ return;155155+143156 if (topology_depth > 2)144157 printf("%4d|", cpu_top.core_info[cpu].pkg);145158 if (topology_depth > 1)···185190 }186191 }187192 }188188- /* cpu offline */189189- if (cpu_top.core_info[cpu].pkg == -1 ||190190- cpu_top.core_info[cpu].core == -1) {193193+ /*194194+ * The monitor could still provide useful data, for example195195+ * AMD HW counters partly sit in PCI config space.196196+ * It's up to the monitor plug-in to check .is_online, this one197197+ * is just for additional info.198198+ */199199+ if (!cpu_top.core_info[cpu].is_online) {191200 printf(_(" *is offline\n"));192201 return;193202 } else···237238 if (hits == 0) {238239 printf(_("No matching monitor found in %s, "239240 "try -l option\n"), param);240240- monitor_help();241241 exit(EXIT_FAILURE);242242 }243243 /* Override detected/registerd monitors array with requested one */···333335 int opt;334336 progname = basename(argv[0]);335337336336- while ((opt = getopt(argc, argv, "+hli:m:")) != -1) {338338+ while ((opt = getopt(argc, argv, "+li:m:")) != -1) {337339 switch (opt) {338338- case 'h':339339- monitor_help();340340- exit(EXIT_SUCCESS);341340 case 'l':342342- if (mode) {343343- monitor_help();344344- exit(EXIT_FAILURE);345345- }341341+ if (mode)342342+ print_wrong_arg_exit();346343 mode = list;347344 break;348345 case 'i':349346 /* only allow -i with -m or no option */350350- if (mode && mode != show) {351351- monitor_help();352352- exit(EXIT_FAILURE);353353- }347347+ if (mode && mode != show)348348+ print_wrong_arg_exit();354349 interval = atoi(optarg);355350 break;356351 case 'm':357357- if (mode) {358358- monitor_help();359359- exit(EXIT_FAILURE);360360- }352352+ if (mode)353353+ print_wrong_arg_exit();361354 mode = show;362355 show_monitors_param = optarg;363356 break;364357 default:365365- monitor_help();366366- exit(EXIT_FAILURE);358358+ print_wrong_arg_exit();367359 }368360 }369361 if (!mode)···372384 printf(_("Cannot read number of available processors\n"));373385 return EXIT_FAILURE;374386 }387387+388388+ /* Default is: monitor all CPUs */389389+ if (bitmask_isallclear(cpus_chosen))390390+ bitmask_setall(cpus_chosen);375391376392 dprint("System has up to %d CPU cores\n", cpu_count);377393
···22222323#define MSR_TSC 0x1024242525+#define MSR_AMD_HWCR 0xc00100152626+2527enum mperf_id { C0 = 0, Cx, AVG_FREQ, MPERF_CSTATE_COUNT };26282729static int mperf_get_count_percent(unsigned int self_id, double *percent,2830 unsigned int cpu);2931static int mperf_get_count_freq(unsigned int id, unsigned long long *count,3032 unsigned int cpu);3333+static struct timespec time_start, time_end;31343235static cstate_t mperf_cstates[MPERF_CSTATE_COUNT] = {3336 {···5754 },5855};59565757+enum MAX_FREQ_MODE { MAX_FREQ_SYSFS, MAX_FREQ_TSC_REF };5858+static int max_freq_mode;5959+/*6060+ * The max frequency mperf is ticking at (in C0), either retrieved via:6161+ * 1) calculated after measurements if we know TSC ticks at mperf/P0 frequency6262+ * 2) cpufreq /sys/devices/.../cpu0/cpufreq/cpuinfo_max_freq at init time6363+ * 1. Is preferred as it also works without cpufreq subsystem (e.g. on Xen)6464+ */6565+static unsigned long max_frequency;6666+6067static unsigned long long tsc_at_measure_start;6168static unsigned long long tsc_at_measure_end;6262-static unsigned long max_frequency;6369static unsigned long long *mperf_previous_count;6470static unsigned long long *aperf_previous_count;6571static unsigned long long *mperf_current_count;6672static unsigned long long *aperf_current_count;7373+6774/* valid flag for all CPUs. If a MSR read failed it will be zero */6875static int *is_valid;69767077static int mperf_get_tsc(unsigned long long *tsc)7178{7272- return read_msr(0, MSR_TSC, tsc);7979+ int ret;8080+ ret = read_msr(0, MSR_TSC, tsc);8181+ if (ret)8282+ dprint("Reading TSC MSR failed, returning %llu\n", *tsc);8383+ return ret;7384}74857586static int mperf_init_stats(unsigned int cpu)···11497 return 0;11598}11699117117-/*118118- * get_average_perf()119119- *120120- * Returns the average performance (also considers boosted frequencies)121121- *122122- * Input:123123- * aperf_diff: Difference of the aperf register over a time period124124- * mperf_diff: Difference of the mperf register over the same time period125125- * max_freq: Maximum frequency (P0)126126- *127127- * Returns:128128- * Average performance over the time period129129- */130130-static unsigned long get_average_perf(unsigned long long aperf_diff,131131- unsigned long long mperf_diff)132132-{133133- unsigned int perf_percent = 0;134134- if (((unsigned long)(-1) / 100) < aperf_diff) {135135- int shift_count = 7;136136- aperf_diff >>= shift_count;137137- mperf_diff >>= shift_count;138138- }139139- perf_percent = (aperf_diff * 100) / mperf_diff;140140- return (max_frequency * perf_percent) / 100;141141-}142142-143100static int mperf_get_count_percent(unsigned int id, double *percent,144101 unsigned int cpu)145102{146103 unsigned long long aperf_diff, mperf_diff, tsc_diff;104104+ unsigned long long timediff;147105148106 if (!is_valid[cpu])149107 return -1;···128136129137 mperf_diff = mperf_current_count[cpu] - mperf_previous_count[cpu];130138 aperf_diff = aperf_current_count[cpu] - aperf_previous_count[cpu];131131- tsc_diff = tsc_at_measure_end - tsc_at_measure_start;132139133133- *percent = 100.0 * mperf_diff / tsc_diff;134134- dprint("%s: mperf_diff: %llu, tsc_diff: %llu\n",135135- mperf_cstates[id].name, mperf_diff, tsc_diff);140140+ if (max_freq_mode == MAX_FREQ_TSC_REF) {141141+ tsc_diff = tsc_at_measure_end - tsc_at_measure_start;142142+ *percent = 100.0 * mperf_diff / tsc_diff;143143+ dprint("%s: TSC Ref - mperf_diff: %llu, tsc_diff: %llu\n",144144+ mperf_cstates[id].name, mperf_diff, tsc_diff);145145+ } else if (max_freq_mode == MAX_FREQ_SYSFS) {146146+ timediff = timespec_diff_us(time_start, time_end);147147+ *percent = 100.0 * mperf_diff / timediff;148148+ dprint("%s: MAXFREQ - mperf_diff: %llu, time_diff: %llu\n",149149+ mperf_cstates[id].name, mperf_diff, timediff);150150+ } else151151+ return -1;136152137153 if (id == Cx)138154 *percent = 100.0 - *percent;···154154static int mperf_get_count_freq(unsigned int id, unsigned long long *count,155155 unsigned int cpu)156156{157157- unsigned long long aperf_diff, mperf_diff;157157+ unsigned long long aperf_diff, mperf_diff, time_diff, tsc_diff;158158159159 if (id != AVG_FREQ)160160 return 1;···165165 mperf_diff = mperf_current_count[cpu] - mperf_previous_count[cpu];166166 aperf_diff = aperf_current_count[cpu] - aperf_previous_count[cpu];167167168168- /* Return MHz for now, might want to return KHz if column width is more169169- generic */170170- *count = get_average_perf(aperf_diff, mperf_diff) / 1000;171171- dprint("%s: %llu\n", mperf_cstates[id].name, *count);168168+ if (max_freq_mode == MAX_FREQ_TSC_REF) {169169+ /* Calculate max_freq from TSC count */170170+ tsc_diff = tsc_at_measure_end - tsc_at_measure_start;171171+ time_diff = timespec_diff_us(time_start, time_end);172172+ max_frequency = tsc_diff / time_diff;173173+ }172174175175+ *count = max_frequency * ((double)aperf_diff / mperf_diff);176176+ dprint("%s: Average freq based on %s maximum frequency:\n",177177+ mperf_cstates[id].name,178178+ (max_freq_mode == MAX_FREQ_TSC_REF) ? "TSC calculated" : "sysfs read");179179+ dprint("%max_frequency: %lu", max_frequency);180180+ dprint("aperf_diff: %llu\n", aperf_diff);181181+ dprint("mperf_diff: %llu\n", mperf_diff);182182+ dprint("avg freq: %llu\n", *count);173183 return 0;174184}175185···188178 int cpu;189179 unsigned long long dbg;190180181181+ clock_gettime(CLOCK_REALTIME, &time_start);191182 mperf_get_tsc(&tsc_at_measure_start);192183193184 for (cpu = 0; cpu < cpu_count; cpu++)···204193 unsigned long long dbg;205194 int cpu;206195207207- mperf_get_tsc(&tsc_at_measure_end);208208-209196 for (cpu = 0; cpu < cpu_count; cpu++)210197 mperf_measure_stats(cpu);198198+199199+ mperf_get_tsc(&tsc_at_measure_end);200200+ clock_gettime(CLOCK_REALTIME, &time_end);211201212202 mperf_get_tsc(&dbg);213203 dprint("TSC diff: %llu\n", dbg - tsc_at_measure_end);···216204 return 0;217205}218206219219-struct cpuidle_monitor mperf_monitor;220220-221221-struct cpuidle_monitor *mperf_register(void)207207+/*208208+ * Mperf register is defined to tick at P0 (maximum) frequency209209+ *210210+ * Instead of reading out P0 which can be tricky to read out from HW,211211+ * we use TSC counter if it reliably ticks at P0/mperf frequency.212212+ *213213+ * Still try to fall back to:214214+ * /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq215215+ * on older Intel HW without invariant TSC feature.216216+ * Or on AMD machines where TSC does not tick at P0 (do not exist yet, but217217+ * it's still double checked (MSR_AMD_HWCR)).218218+ *219219+ * On these machines the user would still get useful mperf220220+ * stats when acpi-cpufreq driver is loaded.221221+ */222222+static int init_maxfreq_mode(void)222223{224224+ int ret;225225+ unsigned long long hwcr;223226 unsigned long min;224227225225- if (!(cpupower_cpu_info.caps & CPUPOWER_CAP_APERF))226226- return NULL;228228+ if (!cpupower_cpu_info.caps & CPUPOWER_CAP_INV_TSC)229229+ goto use_sysfs;227230228228- /* Assume min/max all the same on all cores */231231+ if (cpupower_cpu_info.vendor == X86_VENDOR_AMD) {232232+ /* MSR_AMD_HWCR tells us whether TSC runs at P0/mperf233233+ * freq.234234+ * A test whether hwcr is accessable/available would be:235235+ * (cpupower_cpu_info.family > 0x10 ||236236+ * cpupower_cpu_info.family == 0x10 &&237237+ * cpupower_cpu_info.model >= 0x2))238238+ * This should be the case for all aperf/mperf239239+ * capable AMD machines and is therefore safe to test here.240240+ * Compare with Linus kernel git commit: acf01734b1747b1ec4241241+ */242242+ ret = read_msr(0, MSR_AMD_HWCR, &hwcr);243243+ /*244244+ * If the MSR read failed, assume a Xen system that did245245+ * not explicitly provide access to it and assume TSC works246246+ */247247+ if (ret != 0) {248248+ dprint("TSC read 0x%x failed - assume TSC working\n",249249+ MSR_AMD_HWCR);250250+ return 0;251251+ } else if (1 & (hwcr >> 24)) {252252+ max_freq_mode = MAX_FREQ_TSC_REF;253253+ return 0;254254+ } else { /* Use sysfs max frequency if available */ }255255+ } else if (cpupower_cpu_info.vendor == X86_VENDOR_INTEL) {256256+ /*257257+ * On Intel we assume mperf (in C0) is ticking at same258258+ * rate than TSC259259+ */260260+ max_freq_mode = MAX_FREQ_TSC_REF;261261+ return 0;262262+ }263263+use_sysfs:229264 if (cpufreq_get_hardware_limits(0, &min, &max_frequency)) {230265 dprint("Cannot retrieve max freq from cpufreq kernel "231266 "subsystem\n");232232- return NULL;267267+ return -1;233268 }269269+ max_freq_mode = MAX_FREQ_SYSFS;270270+ return 0;271271+}272272+273273+/*274274+ * This monitor provides:275275+ *276276+ * 1) Average frequency a CPU resided in277277+ * This always works if the CPU has aperf/mperf capabilities278278+ *279279+ * 2) C0 and Cx (any sleep state) time a CPU resided in280280+ * Works if mperf timer stops ticking in sleep states which281281+ * seem to be the case on all current HW.282282+ * Both is directly retrieved from HW registers and is independent283283+ * from kernel statistics.284284+ */285285+struct cpuidle_monitor mperf_monitor;286286+struct cpuidle_monitor *mperf_register(void)287287+{288288+ if (!(cpupower_cpu_info.caps & CPUPOWER_CAP_APERF))289289+ return NULL;290290+291291+ if (init_maxfreq_mode())292292+ return NULL;234293235294 /* Free this at program termination */236295 is_valid = calloc(cpu_count, sizeof(int));