···173173 sector_t (*bmap)(struct address_space *, sector_t);174174 int (*invalidatepage) (struct page *, unsigned long);175175 int (*releasepage) (struct page *, int);176176+ void (*freepage)(struct page *);176177 int (*direct_IO)(int, struct kiocb *, const struct iovec *iov,177178 loff_t offset, unsigned long nr_segs);178179 int (*launder_page) (struct page *);179180180181locking rules:181181- All except set_page_dirty may block182182+ All except set_page_dirty and freepage may block182183183184 BKL PageLocked(page) i_mutex184185writepage: no yes, unlocks (see below)···194193bmap: no195194invalidatepage: no yes196195releasepage: no yes196196+freepage: no yes197197direct_IO: no198198launder_page: no yes199199···289287buffers from the page in preparation for freeing it. It returns zero to290288indicate that the buffers are (or may be) freeable. If ->releasepage is zero,291289the kernel assumes that the fs has no private interest in the buffers.290290+291291+ ->freepage() is called when the kernel is done dropping the page292292+from the page cache.292293293294 ->launder_page() may be called prior to releasing a page if294295it is still found to be dirty. It returns zero if the page was successfully
+7
Documentation/filesystems/vfs.txt
···534534 sector_t (*bmap)(struct address_space *, sector_t);535535 int (*invalidatepage) (struct page *, unsigned long);536536 int (*releasepage) (struct page *, int);537537+ void (*freepage)(struct page *);537538 ssize_t (*direct_IO)(int, struct kiocb *, const struct iovec *iov,538539 loff_t offset, unsigned long nr_segs);539540 struct page* (*get_xip_page)(struct address_space *, sector_t,···678677 that all pages are invalidated, then its releasepage will679678 need to ensure this. Possibly it can clear the PageUptodate680679 bit if it cannot free private data yet.680680+681681+ freepage: freepage is called once the page is no longer visible in682682+ the page cache in order to allow the cleanup of any private683683+ data. Since it may be called by the memory reclaimer, it684684+ should not assume that the original address_space mapping still685685+ exists, and it should not block.681686682687 direct_IO: called by the generic read/write routines to perform683688 direct_IO - that is IO requests which bypass the page cache
-5
Documentation/kernel-parameters.txt
···21672167 reset_devices [KNL] Force drivers to reset the underlying device21682168 during initialization.2169216921702170- resource_alloc_from_bottom21712171- Allocate new resources from the beginning of available21722172- space, not the end. If you need to use this, please21732173- report a bug.21742174-21752170 resume= [SWSUSP]21762171 Specify the partition device for software suspend21772172
+2-2
Documentation/power/runtime_pm.txt
···379379 zero)380380381381 bool pm_runtime_suspended(struct device *dev);382382- - return true if the device's runtime PM status is 'suspended', or false383383- otherwise382382+ - return true if the device's runtime PM status is 'suspended' and its383383+ 'power.disable_depth' field is equal to zero, or false otherwise384384385385 void pm_runtime_allow(struct device *dev);386386 - set the power.runtime_auto flag for the device and decrease its usage
+12-4
MAINTAINERS
···559559S: Maintained560560561561ARM/BCMRING ARM ARCHITECTURE562562-M: Leo Chen <leochen@broadcom.com>562562+M: Jiandong Zheng <jdzheng@broadcom.com>563563M: Scott Branden <sbranden@broadcom.com>564564L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)565565S: Maintained566566F: arch/arm/mach-bcmring567567568568ARM/BCMRING MTD NAND DRIVER569569-M: Leo Chen <leochen@broadcom.com>569569+M: Jiandong Zheng <jdzheng@broadcom.com>570570M: Scott Branden <sbranden@broadcom.com>571571L: linux-mtd@lists.infradead.org572572S: Maintained···815815F: drivers/mmc/host/msm_sdcc.h816816F: drivers/serial/msm_serial.h817817F: drivers/serial/msm_serial.c818818-T: git git://codeaurora.org/quic/kernel/dwalker/linux-msm.git818818+T: git git://codeaurora.org/quic/kernel/davidb/linux-msm.git819819S: Maintained820820821821ARM/TOSA MACHINE SUPPORT···5932593259335933TULIP NETWORK DRIVERS59345934M: Grant Grundler <grundler@parisc-linux.org>59355935-M: Kyle McMartin <kyle@mcmartin.ca>59365935L: netdev@vger.kernel.org59375936S: Maintained59385937F: drivers/net/tulip/···65826583F: include/linux/mfd/wm8400*65836584F: include/sound/wm????.h65846585F: sound/soc/codecs/wm*65866586+65876587+WORKQUEUE65886588+M: Tejun Heo <tj@kernel.org>65896589+L: linux-kernel@vger.kernel.org65906590+T: git git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.git65916591+S: Maintained65926592+F: include/linux/workqueue.h65936593+F: kernel/workqueue.c65946594+F: Documentation/workqueue.txt6585659565866596X.25 NETWORK LAYER65876597M: Andrew Hendry <andrew.hendry@gmail.com>
···1311131113121312config THUMB2_KERNEL13131313 bool "Compile the kernel in Thumb-2 mode"13141314- depends on CPU_V7 && EXPERIMENTAL13141314+ depends on CPU_V7 && !CPU_V6 && EXPERIMENTAL13151315 select AEABI13161316 select ARM_ASM_UNIFIED13171317 help···1759175917601760config FPE_NWFPE17611761 bool "NWFPE math emulation"17621762- depends on !AEABI || OABI_COMPAT17621762+ depends on (!AEABI || OABI_COMPAT) && !THUMB2_KERNEL17631763 ---help---17641764 Say Y to include the NWFPE floating point emulator in the kernel.17651765 This is necessary to run most binaries. Linux does not currently
···28282929config S3C2412_PM3030 bool3131+ select S3C2412_PM_SLEEP3132 help3233 Internal config node to apply S3C2412 power management3434+3535+config S3C2412_PM_SLEEP3636+ bool3737+ help3838+ Internal config node to apply sleep for S3C2412 power management.3939+ Can be selected by another SoCs with similar sleep procedure.33403441# Note, the S3C2412 IOtiming support is in plat-s3c24xx3542
···11/*22+ * Copyright (C) 2010 Magnus Damm23 * Copyright (C) 2008 Renesas Solutions Corp.34 *45 * This program is free software; you can redistribute it and/or modify···1514 * along with this program; if not, write to the Free Software1615 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA1716 */1818-#include <mach/hardware.h>1917#include <mach/irqs.h>1818+1919+#define INTCA_BASE 0xe69800002020+#define INTFLGA_OFFS 0x00000018 /* accept pending interrupt */2121+#define INTEVTA_OFFS 0x00000020 /* vector number of accepted interrupt */2222+#define INTLVLA_OFFS 0x00000030 /* priority level of accepted interrupt */2323+#define INTLVLB_OFFS 0x00000034 /* previous priority level */20242125 .macro disable_fiq2226 .endm23272428 .macro get_irqnr_preamble, base, tmp2525- ldr \base, =INTFLGA2929+ ldr \base, =INTCA_BASE2630 .endm27312832 .macro arch_ret_to_user, tmp1, tmp22933 .endm30343135 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp3232- ldr \irqnr, [\base]3636+ /* The single INTFLGA read access below results in the following:3737+ *3838+ * 1. INTLVLB is updated with old priority value from INTLVLA3939+ * 2. Highest priority interrupt is accepted4040+ * 3. INTLVLA is updated to contain priority of accepted interrupt4141+ * 4. Accepted interrupt vector is stored in INTFLGA and INTEVTA4242+ */4343+ ldr \irqnr, [\base, #INTFLGA_OFFS]4444+4545+ /* Restore INTLVLA with the value saved in INTLVLB.4646+ * This is required to support interrupt priorities properly.4747+ */4848+ ldrb \tmp, [\base, #INTLVLB_OFFS]4949+ strb \tmp, [\base, #INTLVLA_OFFS]5050+5151+ /* Handle invalid vector number case */3352 cmp \irqnr, #03453 beq 1000f3535- /* intevt to irq number */5454+5555+ /* Convert vector to irq number, same as the evt2irq() macro */3656 lsr \irqnr, \irqnr, #0x53757 subs \irqnr, \irqnr, #163858
···173173 UNWIND(.fnstart )174174 dcache_line_size r2, r3175175 sub r3, r2, #1176176- bic r0, r0, r3176176+ bic r12, r0, r31771771:178178- USER( mcr p15, 0, r0, c7, c11, 1 ) @ clean D line to the point of unification179179- dsb180180- USER( mcr p15, 0, r0, c7, c5, 1 ) @ invalidate I line181181- add r0, r0, r2182182-2:183183- cmp r0, r1178178+ USER( mcr p15, 0, r12, c7, c11, 1 ) @ clean D line to the point of unification179179+ add r12, r12, r2180180+ cmp r12, r1184181 blo 1b182182+ dsb183183+ icache_line_size r2, r3184184+ sub r3, r2, #1185185+ bic r12, r0, r3186186+2:187187+ USER( mcr p15, 0, r12, c7, c5, 1 ) @ invalidate I line188188+ add r12, r12, r2189189+ cmp r12, r1190190+ blo 2b191191+3:185192 mov r0, #0186193 ALT_SMP(mcr p15, 0, r0, c7, c1, 6) @ invalidate BTB Inner Shareable187194 ALT_UP(mcr p15, 0, r0, c7, c5, 6) @ invalidate BTB···201194 * isn't mapped, just try the next page.202195 */2031969001:204204- mov r0, r0, lsr #12205205- mov r0, r0, lsl #12206206- add r0, r0, #4096207207- b 2b197197+ mov r12, r12, lsr #12198198+ mov r12, r12, lsl #12199199+ add r12, r12, #4096200200+ b 3b208201 UNWIND(.fnend )209202ENDPROC(v7_coherent_kern_range)210203ENDPROC(v7_coherent_user_range)
+16-6
arch/arm/mm/proc-macros.S
···6161 .endm62626363/*6464- * cache_line_size - get the cache line size from the CSIDR register6565- * (available on ARMv7+). It assumes that the CSSR register was configured6666- * to access the L1 data cache CSIDR.6464+ * dcache_line_size - get the minimum D-cache line size from the CTR register6565+ * on ARMv7.6766 */6867 .macro dcache_line_size, reg, tmp6969- mrc p15, 1, \tmp, c0, c0, 0 @ read CSIDR7070- and \tmp, \tmp, #7 @ cache line size encoding7171- mov \reg, #16 @ size offset6868+ mrc p15, 0, \tmp, c0, c0, 1 @ read ctr6969+ lsr \tmp, \tmp, #167070+ and \tmp, \tmp, #0xf @ cache line size encoding7171+ mov \reg, #4 @ bytes per word7272 mov \reg, \reg, lsl \tmp @ actual cache line size7373 .endm74747575+/*7676+ * icache_line_size - get the minimum I-cache line size from the CTR register7777+ * on ARMv7.7878+ */7979+ .macro icache_line_size, reg, tmp8080+ mrc p15, 0, \tmp, c0, c0, 1 @ read ctr8181+ and \tmp, \tmp, #0xf @ cache line size encoding8282+ mov \reg, #4 @ bytes per word8383+ mov \reg, \reg, lsl \tmp @ actual cache line size8484+ .endm75857686/*7787 * Sanity check the PTE configuration for the code below - which makes
···1919 select GENERIC_ATOMIC64 if !64BIT2020 select HAVE_DMA_ATTRS2121 select HAVE_DMA_API_DEBUG2222+ select HAVE_GENERIC_HARDIRQS2323+ select GENERIC_IRQ_PROBE22242325menu "Machine selection"2426···1666166416671665endchoice1668166616671667+config FORCE_MAX_ZONEORDER16681668+ int "Maximum zone order"16691669+ range 13 64 if SYS_SUPPORTS_HUGETLBFS && PAGE_SIZE_32KB16701670+ default "13" if SYS_SUPPORTS_HUGETLBFS && PAGE_SIZE_32KB16711671+ range 12 64 if SYS_SUPPORTS_HUGETLBFS && PAGE_SIZE_16KB16721672+ default "12" if SYS_SUPPORTS_HUGETLBFS && PAGE_SIZE_16KB16731673+ range 11 6416741674+ default "11"16751675+ help16761676+ The kernel memory allocator divides physically contiguous memory16771677+ blocks into "zones", where each zone is a power of two number of16781678+ pages. This option selects the largest power of two that the kernel16791679+ keeps in the memory allocator. If you need to allocate very large16801680+ blocks of physically contiguous memory, then you may need to16811681+ increase this value.16821682+16831683+ This config option is actually maximum order plus one. For example,16841684+ a value of 11 means that the largest free memory block is 2^10 pages.16851685+16861686+ The page size is not necessarily 4KB. Keep this in mind16871687+ when choosing a value for this option.16881688+16691689config BOARD_SCACHE16701690 bool16711691···19431919 select CPU_R4400_WORKAROUNDS1944192019451921config CPU_R4400_WORKAROUNDS19461946- bool19471947-19481948-#19491949-# Use the generic interrupt handling code in kernel/irq/:19501950-#19511951-config GENERIC_HARDIRQS19521952- bool19531953- default y19541954-19551955-config GENERIC_IRQ_PROBE19561956- bool19571957- default y19581958-19591959-config IRQ_PER_CPU19601922 bool1961192319621924#
+2
arch/mips/alchemy/common/platform.c
···2727static void alchemy_8250_pm(struct uart_port *port, unsigned int state,2828 unsigned int old_state)2929{3030+#ifdef CONFIG_SERIAL_82503031 switch (state) {3132 case 0:3233 if ((__raw_readl(port->membase + UART_MOD_CNTRL) & 3) != 3) {···5049 serial8250_do_pm(port, state, old_state);5150 break;5251 }5252+#endif5353}54545555#define PORT(_base, _irq) \
···3030{3131 struct clk *cpu_clk;32323333+ /* Initialize ar7 clocks so the CPU clock frequency is correct */3434+ ar7_init_clocks();3535+3336 cpu_clk = clk_get(NULL, "cpu");3437 if (IS_ERR(cpu_clk)) {3538 printk(KERN_ERR "unable to get cpu clock\n");
···55 *66 * Copyright (c) 2009 Qi Hardware inc.,77 * Author: Xiangfu Liu <xiangfu@qi-hardware.com>88- * Copyright 2010, Lars-Petrer Clausen <lars@metafoo.de>88+ * Copyright 2010, Lars-Peter Clausen <lars@metafoo.de>99 *1010 * This program is free software; you can redistribute it and/or modify1111 * it under the terms of the GNU General Public License version 2 or later···235235 QI_LB60_GPIO_KEYIN(3),236236 QI_LB60_GPIO_KEYIN(4),237237 QI_LB60_GPIO_KEYIN(5),238238- QI_LB60_GPIO_KEYIN(7),238238+ QI_LB60_GPIO_KEYIN(6),239239 QI_LB60_GPIO_KEYIN8,240240};241241
···251251252252SYSCALL_DEFINE1(32_personality, unsigned long, personality)253253{254254+ unsigned int p = personality & 0xffffffff;254255 int ret;255255- personality &= 0xffffffff;256256+256257 if (personality(current->personality) == PER_LINUX32 &&257257- personality == PER_LINUX)258258- personality = PER_LINUX32;259259- ret = sys_personality(personality);260260- if (ret == PER_LINUX32)261261- ret = PER_LINUX;258258+ personality(p) == PER_LINUX)259259+ p = (p & ~PER_MASK) | PER_LINUX32;260260+ ret = sys_personality(p);261261+ if (ret != -1 && personality(ret) == PER_LINUX32)262262+ ret = (ret & ~PER_MASK) | PER_LINUX;262263 return ret;263264}264265
-1
arch/mips/kernel/process.c
···142142 childregs->regs[7] = 0; /* Clear error flag */143143144144 childregs->regs[2] = 0; /* Child gets zero as return value */145145- regs->regs[2] = p->pid;146145147146 if (childregs->cp0_status & ST0_CU0) {148147 childregs->regs[28] = (unsigned long) ti;
+1-1
arch/mips/kernel/prom.c
···100100 return;101101102102 base = virt_to_phys((void *)initial_boot_params);103103- size = initial_boot_params->totalsize;103103+ size = be32_to_cpu(initial_boot_params->totalsize);104104105105 /* Before we do anything, lets reserve the dt blob */106106 reserve_mem_mach(base, size);
+1-1
arch/mips/kernel/smp-mt.c
···153153{154154 extern int gic_present;155155156156- /* This is Malta specific: IPI,performance and timer inetrrupts */156156+ /* This is Malta specific: IPI,performance and timer interrupts */157157 if (gic_present)158158 change_c0_status(ST0_IM, STATUSF_IP3 | STATUSF_IP4 |159159 STATUSF_IP6 | STATUSF_IP7);
+35-9
arch/mips/kernel/traps.c
···8383extern asmlinkage void handle_reserved(void);84848585extern int fpu_emulator_cop1Handler(struct pt_regs *xcp,8686- struct mips_fpu_struct *ctx, int has_fpu);8686+ struct mips_fpu_struct *ctx, int has_fpu,8787+ void *__user *fault_addr);87888889void (*board_be_init)(void);8990int (*board_be_handler)(struct pt_regs *regs, int is_fixup);···662661 force_sig_info(SIGFPE, &info, current);663662}664663664664+static int process_fpemu_return(int sig, void __user *fault_addr)665665+{666666+ if (sig == SIGSEGV || sig == SIGBUS) {667667+ struct siginfo si = {0};668668+ si.si_addr = fault_addr;669669+ si.si_signo = sig;670670+ if (sig == SIGSEGV) {671671+ if (find_vma(current->mm, (unsigned long)fault_addr))672672+ si.si_code = SEGV_ACCERR;673673+ else674674+ si.si_code = SEGV_MAPERR;675675+ } else {676676+ si.si_code = BUS_ADRERR;677677+ }678678+ force_sig_info(sig, &si, current);679679+ return 1;680680+ } else if (sig) {681681+ force_sig(sig, current);682682+ return 1;683683+ } else {684684+ return 0;685685+ }686686+}687687+665688/*666689 * XXX Delayed fp exceptions when doing a lazy ctx switch XXX667690 */668691asmlinkage void do_fpe(struct pt_regs *regs, unsigned long fcr31)669692{670670- siginfo_t info;693693+ siginfo_t info = {0};671694672695 if (notify_die(DIE_FP, "FP exception", regs, 0, regs_to_trapnr(regs), SIGFPE)673696 == NOTIFY_STOP)···700675701676 if (fcr31 & FPU_CSR_UNI_X) {702677 int sig;678678+ void __user *fault_addr = NULL;703679704680 /*705681 * Unimplemented operation exception. If we've got the full···716690 lose_fpu(1);717691718692 /* Run the emulator */719719- sig = fpu_emulator_cop1Handler(regs, ¤t->thread.fpu, 1);693693+ sig = fpu_emulator_cop1Handler(regs, ¤t->thread.fpu, 1,694694+ &fault_addr);720695721696 /*722697 * We can't allow the emulated instruction to leave any of···729702 own_fpu(1); /* Using the FPU again. */730703731704 /* If something went wrong, signal */732732- if (sig)733733- force_sig(sig, current);705705+ process_fpemu_return(sig, fault_addr);734706735707 return;736708 } else if (fcr31 & FPU_CSR_INV_X)···10229961023997 if (!raw_cpu_has_fpu) {1024998 int sig;999999+ void __user *fault_addr = NULL;10251000 sig = fpu_emulator_cop1Handler(regs,10261026- ¤t->thread.fpu, 0);10271027- if (sig)10281028- force_sig(sig, current);10291029- else10011001+ ¤t->thread.fpu,10021002+ 0, &fault_addr);10031003+ if (!process_fpemu_return(sig, fault_addr))10301004 mt_ase_fp_affinity();10311005 }10321006
+6-8
arch/mips/kernel/vpe.c
···1092109210931093 /* this of-course trashes what was there before... */10941094 v->pbuffer = vmalloc(P_SIZE);10951095+ if (!v->pbuffer) {10961096+ pr_warning("VPE loader: unable to allocate memory\n");10971097+ return -ENOMEM;10981098+ }10951099 v->plen = P_SIZE;10961100 v->load_addr = NULL;10971101 v->len = 0;···11531149 if (ret < 0)11541150 v->shared_ptr = NULL;1155115111561156- // cleanup any temp buffers11571157- if (v->pbuffer)11581158- vfree(v->pbuffer);11521152+ vfree(v->pbuffer);11591153 v->plen = 0;11541154+11601155 return ret;11611156}11621157···11711168 v = get_vpe(tclimit);11721169 if (v == NULL)11731170 return -ENODEV;11741174-11751175- if (v->pbuffer == NULL) {11761176- printk(KERN_ERR "VPE loader: no buffer for program\n");11771177- return -ENOMEM;11781178- }1179117111801172 if ((count + v->len) > v->plen) {11811173 printk(KERN_WARNING
···8282enum swarm_rtc_type {8383 RTC_NONE,8484 RTC_XICOR,8585- RTC_M4LT818585+ RTC_M41T81,8686};87878888enum swarm_rtc_type swarm_rtc_type;···9696 sec = xicor_get_time();9797 break;98989999- case RTC_M4LT81:9999+ case RTC_M41T81:100100 sec = m41t81_get_time();101101 break;102102···115115 case RTC_XICOR:116116 return xicor_set_time(sec);117117118118- case RTC_M4LT81:118118+ case RTC_M41T81:119119 return m41t81_set_time(sec);120120121121 case RTC_NONE:···141141 if (xicor_probe())142142 swarm_rtc_type = RTC_XICOR;143143 if (m41t81_probe())144144- swarm_rtc_type = RTC_M4LT81;144144+ swarm_rtc_type = RTC_M41T81;145145146146#ifdef CONFIG_VT147147 screen_info = (struct screen_info) {
+3-7
arch/mn10300/kernel/time.c
···4040 unsigned long long ll;4141 unsigned l[2];4242 } tsc64, result;4343- unsigned long tsc, tmp;4343+ unsigned long tmp;4444 unsigned product[3]; /* 96-bit intermediate value */45454646 /* cnt32_to_63() is not safe with preemption */4747 preempt_disable();48484949- /* read the TSC value5050- */5151- tsc = get_cycles();5252-5353- /* expand to 64-bits.4949+ /* expand the tsc to 64-bits.5450 * - sched_clock() must be called once a minute or better or the5551 * following will go horribly wrong - see cnt32_to_63()5652 */5757- tsc64.ll = cnt32_to_63(tsc) & 0x7fffffffffffffffULL;5353+ tsc64.ll = cnt32_to_63(get_cycles()) & 0x7fffffffffffffffULL;58545955 preempt_enable();6056
+2-1
arch/sh/Kconfig
···2222 select HAVE_SPARSE_IRQ2323 select RTC_LIB2424 select GENERIC_ATOMIC642525- select GENERIC_HARDIRQS_NO_DEPRECATED2525+ # Support the deprecated APIs until MFD and GPIOLIB catch up.2626+ select GENERIC_HARDIRQS_NO_DEPRECATED if !MFD_SUPPORT && !GPIOLIB2627 help2728 The SuperH is a RISC processor targeted for use in embedded systems2829 and consumer electronics; it was also used in the Sega Dreamcast
···3939 int (*v2_dev_open)(char *devpath);4040 void (*v2_dev_close)(int d);4141 int (*v2_dev_read)(int d, char *buf, int nbytes);4242- int (*v2_dev_write)(int d, char *buf, int nbytes);4242+ int (*v2_dev_write)(int d, const char *buf, int nbytes);4343 int (*v2_dev_seek)(int d, int hi, int lo);44444545 /* Never issued (multistage load support) */
+2-33
arch/sparc/include/asm/oplib_32.h
···6060extern char *prom_mapio(char *virt_hint, int io_space, unsigned int phys_addr, unsigned int num_bytes);6161extern void prom_unmapio(char *virt_addr, unsigned int num_bytes);62626363-/* Device operations. */6464-6565-/* Open the device described by the passed string. Note, that the format6666- * of the string is different on V0 vs. V2->higher proms. The caller must6767- * know what he/she is doing! Returns the device descriptor, an int.6868- */6969-extern int prom_devopen(char *device_string);7070-7171-/* Close a previously opened device described by the passed integer7272- * descriptor.7373- */7474-extern int prom_devclose(int device_handle);7575-7676-/* Do a seek operation on the device described by the passed integer7777- * descriptor.7878- */7979-extern void prom_seek(int device_handle, unsigned int seek_hival,8080- unsigned int seek_lowval);8181-8263/* Miscellaneous routines, don't really fit in any category per se. */83648465/* Reboot the machine with the command line passed. */···102121/* Get the prom firmware revision. */103122extern int prom_getprev(void);104123105105-/* Character operations to/from the console.... */106106-107107-/* Non-blocking get character from console. */108108-extern int prom_nbgetchar(void);109109-110110-/* Non-blocking put character to console. */111111-extern int prom_nbputchar(char character);112112-113113-/* Blocking get character from console. */114114-extern char prom_getchar(void);115115-116116-/* Blocking put character to console. */117117-extern void prom_putchar(char character);124124+/* Write a buffer of characters to the console. */125125+extern void prom_console_write_buf(const char *buf, int len);118126119127/* Prom's internal routines, don't use in kernel/boot code. */120128extern void prom_printf(const char *fmt, ...);···208238extern int prom_setprop(phandle node, const char *prop_name, char *prop_value,209239 int value_size);210240211211-extern phandle prom_pathtoinode(char *path);212241extern phandle prom_inst2pkg(int);213242214243/* Dorking with Bus ranges... */
+2-44
arch/sparc/include/asm/oplib_64.h
···6767/* Boot argument acquisition, returns the boot command line string. */6868extern char *prom_getbootargs(void);69697070-/* Device utilities. */7171-7272-/* Device operations. */7373-7474-/* Open the device described by the passed string. Note, that the format7575- * of the string is different on V0 vs. V2->higher proms. The caller must7676- * know what he/she is doing! Returns the device descriptor, an int.7777- */7878-extern int prom_devopen(const char *device_string);7979-8080-/* Close a previously opened device described by the passed integer8181- * descriptor.8282- */8383-extern int prom_devclose(int device_handle);8484-8585-/* Do a seek operation on the device described by the passed integer8686- * descriptor.8787- */8888-extern void prom_seek(int device_handle, unsigned int seek_hival,8989- unsigned int seek_lowval);9090-9170/* Miscellaneous routines, don't really fit in any category per se. */92719372/* Reboot the machine with the command line passed. */···88109/* Halt and power-off the machine. */89110extern void prom_halt_power_off(void) __attribute__ ((noreturn));901119191-/* Set the PROM 'sync' callback function to the passed function pointer.9292- * When the user gives the 'sync' command at the prom prompt while the9393- * kernel is still active, the prom will call this routine.9494- *9595- */9696-typedef int (*callback_func_t)(long *cmd);9797-extern void prom_setcallback(callback_func_t func_ptr);9898-99112/* Acquire the IDPROM of the root node in the prom device tree. This100113 * gets passed a buffer where you would like it stuffed. The return value101114 * is the format type of this idprom or 0xff on error.102115 */103116extern unsigned char prom_get_idprom(char *idp_buffer, int idpbuf_size);104117105105-/* Character operations to/from the console.... */106106-107107-/* Non-blocking get character from console. */108108-extern int prom_nbgetchar(void);109109-110110-/* Non-blocking put character to console. */111111-extern int prom_nbputchar(char character);112112-113113-/* Blocking get character from console. */114114-extern char prom_getchar(void);115115-116116-/* Blocking put character to console. */117117-extern void prom_putchar(char character);118118+/* Write a buffer of characters to the console. */119119+extern void prom_console_write_buf(const char *buf, int len);118120119121/* Prom's internal routines, don't use in kernel/boot code. */120122extern void prom_printf(const char *fmt, ...);···239279extern int prom_setprop(phandle node, const char *prop_name, char *prop_value,240280 int value_size);241281242242-extern phandle prom_pathtoinode(const char *path);243282extern phandle prom_inst2pkg(int);244244-extern int prom_service_exists(const char *service_name);245283extern void prom_sun4v_guest_soft_state(void);246284247285extern int prom_ihandle2path(int handle, char *buffer, int bufsize);
···16161717extern void restore_current(void);18181919-/* Non blocking get character from console input device, returns -12020- * if no input was taken. This can be used for polling.2121- */2222-int2323-prom_nbgetchar(void)2424-{2525- static char inc;2626- int i = -1;2727- unsigned long flags;2828-2929- spin_lock_irqsave(&prom_lock, flags);3030- switch(prom_vers) {3131- case PROM_V0:3232- i = (*(romvec->pv_nbgetchar))();3333- break;3434- case PROM_V2:3535- case PROM_V3:3636- if( (*(romvec->pv_v2devops).v2_dev_read)(*romvec->pv_v2bootargs.fd_stdin , &inc, 0x1) == 1) {3737- i = inc;3838- } else {3939- i = -1;4040- }4141- break;4242- default:4343- i = -1;4444- break;4545- };4646- restore_current();4747- spin_unlock_irqrestore(&prom_lock, flags);4848- return i; /* Ugh, we could spin forever on unsupported proms ;( */4949-}5050-5119/* Non blocking put character to console device, returns -1 if5220 * unsuccessful.5321 */5454-int5555-prom_nbputchar(char c)2222+static int prom_nbputchar(const char *buf)5623{5757- static char outc;5824 unsigned long flags;5925 int i = -1;60266127 spin_lock_irqsave(&prom_lock, flags);6228 switch(prom_vers) {6329 case PROM_V0:6464- i = (*(romvec->pv_nbputchar))(c);3030+ i = (*(romvec->pv_nbputchar))(*buf);6531 break;6632 case PROM_V2:6733 case PROM_V3:6868- outc = c;6969- if( (*(romvec->pv_v2devops).v2_dev_write)(*romvec->pv_v2bootargs.fd_stdout, &outc, 0x1) == 1)3434+ if ((*(romvec->pv_v2devops).v2_dev_write)(*romvec->pv_v2bootargs.fd_stdout,3535+ buf, 0x1) == 1)7036 i = 0;7171- else7272- i = -1;7337 break;7438 default:7575- i = -1;7639 break;7740 };7841 restore_current();···4380 return i; /* Ugh, we could spin forever on unsupported proms ;( */4481}45824646-/* Blocking version of get character routine above. */4747-char4848-prom_getchar(void)8383+void prom_console_write_buf(const char *buf, int len)4984{5050- int character;5151- while((character = prom_nbgetchar()) == -1) ;5252- return (char) character;8585+ while (len) {8686+ int n = prom_nbputchar(buf);8787+ if (n)8888+ continue;8989+ len--;9090+ buf++;9191+ }5392}54935555-/* Blocking version of put character routine above. */5656-void5757-prom_putchar(char c)5858-{5959- while(prom_nbputchar(c) == -1) ;6060-}
+15-66
arch/sparc/prom/console_64.c
···15151616extern int prom_stdin, prom_stdout;17171818-/* Non blocking get character from console input device, returns -11919- * if no input was taken. This can be used for polling.2020- */2121-inline int2222-prom_nbgetchar(void)1818+static int __prom_console_write_buf(const char *buf, int len)2319{2420 unsigned long args[7];2525- char inc;2626-2727- args[0] = (unsigned long) "read";2828- args[1] = 3;2929- args[2] = 1;3030- args[3] = (unsigned int) prom_stdin;3131- args[4] = (unsigned long) &inc;3232- args[5] = 1;3333- args[6] = (unsigned long) -1;3434-3535- p1275_cmd_direct(args);3636-3737- if (args[6] == 1)3838- return inc;3939- return -1;4040-}4141-4242-/* Non blocking put character to console device, returns -1 if4343- * unsuccessful.4444- */4545-inline int4646-prom_nbputchar(char c)4747-{4848- unsigned long args[7];4949- char outc;5050-5151- outc = c;2121+ int ret;52225323 args[0] = (unsigned long) "write";5424 args[1] = 3;5525 args[2] = 1;5626 args[3] = (unsigned int) prom_stdout;5757- args[4] = (unsigned long) &outc;5858- args[5] = 1;2727+ args[4] = (unsigned long) buf;2828+ args[5] = (unsigned int) len;5929 args[6] = (unsigned long) -1;60306131 p1275_cmd_direct(args);62326363- if (args[6] == 1)6464- return 0;6565- else3333+ ret = (int) args[6];3434+ if (ret < 0)6635 return -1;3636+ return ret;6737}68386969-/* Blocking version of get character routine above. */7070-char7171-prom_getchar(void)3939+void prom_console_write_buf(const char *buf, int len)7240{7373- int character;7474- while((character = prom_nbgetchar()) == -1) ;7575- return (char) character;7676-}7777-7878-/* Blocking version of put character routine above. */7979-void8080-prom_putchar(char c)8181-{8282- prom_nbputchar(c);8383-}8484-8585-void8686-prom_puts(const char *s, int len)8787-{8888- unsigned long args[7];8989-9090- args[0] = (unsigned long) "write";9191- args[1] = 3;9292- args[2] = 1;9393- args[3] = (unsigned int) prom_stdout;9494- args[4] = (unsigned long) s;9595- args[5] = len;9696- args[6] = (unsigned long) -1;9797-9898- p1275_cmd_direct(args);4141+ while (len) {4242+ int n = __prom_console_write_buf(buf, len);4343+ if (n < 0)4444+ continue;4545+ len -= n;4646+ buf += len;4747+ }9948}
-87
arch/sparc/prom/devops_32.c
···11-/*22- * devops.c: Device operations using the PROM.33- *44- * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)55- */66-#include <linux/types.h>77-#include <linux/kernel.h>88-#include <linux/sched.h>99-1010-#include <asm/openprom.h>1111-#include <asm/oplib.h>1212-1313-extern void restore_current(void);1414-1515-/* Open the device described by the string 'dstr'. Returns the handle1616- * to that device used for subsequent operations on that device.1717- * Returns -1 on failure.1818- */1919-int2020-prom_devopen(char *dstr)2121-{2222- int handle;2323- unsigned long flags;2424- spin_lock_irqsave(&prom_lock, flags);2525- switch(prom_vers) {2626- case PROM_V0:2727- handle = (*(romvec->pv_v0devops.v0_devopen))(dstr);2828- if(handle == 0) handle = -1;2929- break;3030- case PROM_V2:3131- case PROM_V3:3232- handle = (*(romvec->pv_v2devops.v2_dev_open))(dstr);3333- break;3434- default:3535- handle = -1;3636- break;3737- };3838- restore_current();3939- spin_unlock_irqrestore(&prom_lock, flags);4040-4141- return handle;4242-}4343-4444-/* Close the device described by device handle 'dhandle'. */4545-int4646-prom_devclose(int dhandle)4747-{4848- unsigned long flags;4949- spin_lock_irqsave(&prom_lock, flags);5050- switch(prom_vers) {5151- case PROM_V0:5252- (*(romvec->pv_v0devops.v0_devclose))(dhandle);5353- break;5454- case PROM_V2:5555- case PROM_V3:5656- (*(romvec->pv_v2devops.v2_dev_close))(dhandle);5757- break;5858- default:5959- break;6060- };6161- restore_current();6262- spin_unlock_irqrestore(&prom_lock, flags);6363- return 0;6464-}6565-6666-/* Seek to specified location described by 'seekhi' and 'seeklo'6767- * for device 'dhandle'.6868- */6969-void7070-prom_seek(int dhandle, unsigned int seekhi, unsigned int seeklo)7171-{7272- unsigned long flags;7373- spin_lock_irqsave(&prom_lock, flags);7474- switch(prom_vers) {7575- case PROM_V0:7676- (*(romvec->pv_v0devops.v0_seekdev))(dhandle, seekhi, seeklo);7777- break;7878- case PROM_V2:7979- case PROM_V3:8080- (*(romvec->pv_v2devops.v2_dev_seek))(dhandle, seekhi, seeklo);8181- break;8282- default:8383- break;8484- };8585- restore_current();8686- spin_unlock_irqrestore(&prom_lock, flags);8787-}
-67
arch/sparc/prom/devops_64.c
···11-/*22- * devops.c: Device operations using the PROM.33- *44- * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)55- * Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)66- */77-#include <linux/types.h>88-#include <linux/kernel.h>99-#include <linux/sched.h>1010-1111-#include <asm/openprom.h>1212-#include <asm/oplib.h>1313-1414-/* Open the device described by the string 'dstr'. Returns the handle1515- * to that device used for subsequent operations on that device.1616- * Returns 0 on failure.1717- */1818-int1919-prom_devopen(const char *dstr)2020-{2121- unsigned long args[5];2222-2323- args[0] = (unsigned long) "open";2424- args[1] = 1;2525- args[2] = 1;2626- args[3] = (unsigned long) dstr;2727- args[4] = (unsigned long) -1;2828-2929- p1275_cmd_direct(args);3030-3131- return (int) args[4];3232-}3333-3434-/* Close the device described by device handle 'dhandle'. */3535-int3636-prom_devclose(int dhandle)3737-{3838- unsigned long args[4];3939-4040- args[0] = (unsigned long) "close";4141- args[1] = 1;4242- args[2] = 0;4343- args[3] = (unsigned int) dhandle;4444-4545- p1275_cmd_direct(args);4646-4747- return 0;4848-}4949-5050-/* Seek to specified location described by 'seekhi' and 'seeklo'5151- * for device 'dhandle'.5252- */5353-void5454-prom_seek(int dhandle, unsigned int seekhi, unsigned int seeklo)5555-{5656- unsigned long args[7];5757-5858- args[0] = (unsigned long) "seek";5959- args[1] = 3;6060- args[2] = 1;6161- args[3] = (unsigned int) dhandle;6262- args[4] = seekhi;6363- args[5] = seeklo;6464- args[6] = (unsigned long) -1;6565-6666- p1275_cmd_direct(args);6767-}
+1-15
arch/sparc/prom/misc_64.c
···1818#include <asm/system.h>1919#include <asm/ldc.h>20202121-int prom_service_exists(const char *service_name)2121+static int prom_service_exists(const char *service_name)2222{2323 unsigned long args[5];2424···148148149149 /* if nothing else helps, we just halt */150150 prom_halt();151151-}152152-153153-/* Set prom sync handler to call function 'funcp'. */154154-void prom_setcallback(callback_func_t funcp)155155-{156156- unsigned long args[5];157157- if (!funcp)158158- return;159159- args[0] = (unsigned long) "set-callback";160160- args[1] = 1;161161- args[2] = 1;162162- args[3] = (unsigned long) funcp;163163- args[4] = (unsigned long) -1;164164- p1275_cmd_direct(args);165151}166152167153/* Get the idprom and stuff it into buffer 'idbuf'. Returns the
+29-6
arch/sparc/prom/printf.c
···15151616#include <linux/kernel.h>1717#include <linux/compiler.h>1818+#include <linux/spinlock.h>18191920#include <asm/openprom.h>2021#include <asm/oplib.h>21222323+#define CONSOLE_WRITE_BUF_SIZE 10242424+2225static char ppbuf[1024];2626+static char console_write_buf[CONSOLE_WRITE_BUF_SIZE];2727+static DEFINE_RAW_SPINLOCK(console_write_lock);23282429void notrace prom_write(const char *buf, unsigned int n)2530{2626- char ch;3131+ unsigned int dest_len;3232+ unsigned long flags;3333+ char *dest;27342828- while (n != 0) {2929- --n;3030- if ((ch = *buf++) == '\n')3131- prom_putchar('\r');3232- prom_putchar(ch);3535+ dest = console_write_buf;3636+ raw_spin_lock_irqsave(&console_write_lock, flags);3737+3838+ dest_len = 0;3939+ while (n-- != 0) {4040+ char ch = *buf++;4141+ if (ch == '\n') {4242+ *dest++ = '\r';4343+ dest_len++;4444+ }4545+ *dest++ = ch;4646+ dest_len++;4747+ if (dest_len >= CONSOLE_WRITE_BUF_SIZE - 1) {4848+ prom_console_write_buf(console_write_buf, dest_len);4949+ dest = console_write_buf;5050+ dest_len = 0;5151+ }3352 }5353+ if (dest_len)5454+ prom_console_write_buf(console_write_buf, dest_len);5555+5656+ raw_spin_unlock_irqrestore(&console_write_lock, flags);3457}35583659void notrace prom_printf(const char *fmt, ...)
-16
arch/sparc/prom/tree_32.c
···342342 if (node == -1) return 0;343343 return node;344344}345345-346346-/* Return 'node' assigned to a particular prom 'path'347347- * FIXME: Should work for v0 as well348348- */349349-phandle prom_pathtoinode(char *path)350350-{351351- phandle node;352352- int inst;353353-354354- inst = prom_devopen (path);355355- if (inst == -1) return 0;356356- node = prom_inst2pkg (inst);357357- prom_devclose (inst);358358- if (node == -1) return 0;359359- return node;360360-}
-18
arch/sparc/prom/tree_64.c
···374374 return node;375375}376376377377-/* Return 'node' assigned to a particular prom 'path'378378- * FIXME: Should work for v0 as well379379- */380380-phandle prom_pathtoinode(const char *path)381381-{382382- phandle node;383383- int inst;384384-385385- inst = prom_devopen (path);386386- if (inst == 0)387387- return 0;388388- node = prom_inst2pkg(inst);389389- prom_devclose(inst);390390- if (node == -1)391391- return 0;392392- return node;393393-}394394-395377int prom_ihandle2path(int handle, char *buffer, int bufsize)396378{397379 unsigned long args[7];
···290290 return ret;291291}292292293293+/* The assembly shim for this function arranges to ignore the return value. */293294long compat_sys_rt_sigreturn(struct pt_regs *regs)294295{295296 struct compat_rt_sigframe __user *frame =296297 (struct compat_rt_sigframe __user *) compat_ptr(regs->sp);297298 sigset_t set;298298- long r0;299299300300 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))301301 goto badframe;···308308 recalc_sigpending();309309 spin_unlock_irq(¤t->sighand->siglock);310310311311- if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &r0))311311+ if (restore_sigcontext(regs, &frame->uc.uc_mcontext))312312 goto badframe;313313314314 if (compat_sys_sigaltstack(&frame->uc.uc_stack, NULL, regs) != 0)315315 goto badframe;316316317317- return r0;317317+ return 0;318318319319badframe:320320 force_sig(SIGSEGV, current);
+21-3
arch/tile/kernel/intvec_32.S
···13421342 lw r20, r201343134313441344 /* Jump to syscall handler. */13451345- jalr r20; .Lhandle_syscall_link:13461346- FEEDBACK_REENTER(handle_syscall)13451345+ jalr r2013461346+.Lhandle_syscall_link: /* value of "lr" after "jalr r20" above */1347134713481348 /*13491349 * Write our r0 onto the stack so it gets restored instead···13511351 */13521352 PTREGS_PTR(r29, PTREGS_OFFSET_REG(0))13531353 sw r29, r013541354+13551355+.Lsyscall_sigreturn_skip:13561356+ FEEDBACK_REENTER(handle_syscall)1354135713551358 /* Do syscall trace again, if requested. */13561359 lw r30, r31···15391536 }; \15401537 STD_ENDPROC(_##x)1541153815391539+/*15401540+ * Special-case sigreturn to not write r0 to the stack on return.15411541+ * This is technically more efficient, but it also avoids difficulties15421542+ * in the 64-bit OS when handling 32-bit compat code, since we must not15431543+ * sign-extend r0 for the sigreturn return-value case.15441544+ */15451545+#define PTREGS_SYSCALL_SIGRETURN(x, reg) \15461546+ STD_ENTRY(_##x); \15471547+ addli lr, lr, .Lsyscall_sigreturn_skip - .Lhandle_syscall_link; \15481548+ { \15491549+ PTREGS_PTR(reg, PTREGS_OFFSET_BASE); \15501550+ j x \15511551+ }; \15521552+ STD_ENDPROC(_##x)15531553+15421554PTREGS_SYSCALL(sys_execve, r3)15431555PTREGS_SYSCALL(sys_sigaltstack, r2)15441544-PTREGS_SYSCALL(sys_rt_sigreturn, r0)15561556+PTREGS_SYSCALL_SIGRETURN(sys_rt_sigreturn, r0)15451557PTREGS_SYSCALL(sys_cmpxchg_badaddr, r1)1546155815471559/* Save additional callee-saves to pt_regs, put address in r4 and jump. */
+8
arch/tile/kernel/process.c
···212212 childregs->sp = sp; /* override with new user stack pointer */213213214214 /*215215+ * If CLONE_SETTLS is set, set "tp" in the new task to "r4",216216+ * which is passed in as arg #5 to sys_clone().217217+ */218218+ if (clone_flags & CLONE_SETTLS)219219+ childregs->tp = regs->regs[4];220220+221221+ /*215222 * Copy the callee-saved registers from the passed pt_regs struct216223 * into the context-switch callee-saved registers area.217224 * This way when we start the interrupt-return sequence, the···546539 return __switch_to(prev, next, next_current_ksp0(next));547540}548541542542+/* Note there is an implicit fifth argument if (clone_flags & CLONE_SETTLS). */549543SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp,550544 void __user *, parent_tidptr, void __user *, child_tidptr,551545 struct pt_regs *, regs)
+4-6
arch/tile/kernel/signal.c
···5252 */53535454int restore_sigcontext(struct pt_regs *regs,5555- struct sigcontext __user *sc, long *pr0)5555+ struct sigcontext __user *sc)5656{5757 int err = 0;5858 int i;···75757676 regs->faultnum = INT_SWINT_1_SIGRETURN;77777878- err |= __get_user(*pr0, &sc->gregs[0]);7978 return err;8079}81808282-/* sigreturn() returns long since it restores r0 in the interrupted code. */8181+/* The assembly shim for this function arranges to ignore the return value. */8382SYSCALL_DEFINE1(rt_sigreturn, struct pt_regs *, regs)8483{8584 struct rt_sigframe __user *frame =8685 (struct rt_sigframe __user *)(regs->sp);8786 sigset_t set;8888- long r0;89879088 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))9189 goto badframe;···9698 recalc_sigpending();9799 spin_unlock_irq(¤t->sighand->siglock);981009999- if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &r0))101101+ if (restore_sigcontext(regs, &frame->uc.uc_mcontext))100102 goto badframe;101103102104 if (do_sigaltstack(&frame->uc.uc_stack, NULL, regs->sp) == -EFAULT)103105 goto badframe;104106105105- return r0;107107+ return 0;106108107109badframe:108110 force_sig(SIGSEGV, current);
+1-1
arch/x86/boot/compressed/misc.c
···355355 if (heap > 0x3fffffffffffUL)356356 error("Destination address too large");357357#else358358- if (heap > ((-__PAGE_OFFSET-(512<<20)-1) & 0x7fffffff))358358+ if (heap > ((-__PAGE_OFFSET-(128<<20)-1) & 0x7fffffff))359359 error("Destination address too large");360360#endif361361#ifndef CONFIG_RELOCATABLE
+1
arch/x86/crypto/ghash-clmulni-intel_glue.c
···1010 * by the Free Software Foundation.1111 */12121313+#include <linux/err.h>1314#include <linux/module.h>1415#include <linux/init.h>1516#include <linux/kernel.h>
+3
arch/x86/include/asm/e820.h
···7272#define BIOS_BEGIN 0x000a00007373#define BIOS_END 0x0010000074747575+#define BIOS_ROM_BASE 0xffe000007676+#define BIOS_ROM_END 0xffffffff7777+7578#ifdef __KERNEL__7679/* see comment in arch/x86/kernel/e820.c */7780extern struct e820map e820;
···13831383#endif1384138413851385 apic_pm_activate();13861386+13871387+ /*13881388+ * Now that local APIC setup is completed for BP, configure the fault13891389+ * handling for interrupt remapping.13901390+ */13911391+ if (!smp_processor_id() && intr_remapping_enabled)13921392+ enable_drhd_fault_handling();13931393+13861394}1387139513881396#ifdef CONFIG_X86_X2APIC
+2-2
arch/x86/kernel/apic/io_apic.c
···24292429{24302430 struct irq_cfg *cfg = data->chip_data;24312431 int i, do_unmask_irq = 0, irq = data->irq;24322432- struct irq_desc *desc = irq_to_desc(irq);24332432 unsigned long v;2434243324352434 irq_complete_move(cfg);24362435#ifdef CONFIG_GENERIC_PENDING_IRQ24372436 /* If we are moving the irq we need to mask it */24382438- if (unlikely(desc->status & IRQ_MOVE_PENDING)) {24372437+ if (unlikely(irq_to_desc(irq)->status & IRQ_MOVE_PENDING)) {24392438 do_unmask_irq = 1;24402439 mask_ioapic(cfg);24412440 }···33663367 msg.data |= MSI_DATA_VECTOR(cfg->vector);33673368 msg.address_lo &= ~MSI_ADDR_DEST_ID_MASK;33683369 msg.address_lo |= MSI_ADDR_DEST_ID(dest);33703370+ msg.address_hi = MSI_ADDR_BASE_HI | MSI_ADDR_EXT_DEST_ID(dest);3369337133703372 dmar_msi_write(irq, &msg);33713373
-7
arch/x86/kernel/apic/probe_64.c
···7979 /* need to update phys_pkg_id */8080 apic->phys_pkg_id = apicid_phys_pkg_id;8181 }8282-8383- /*8484- * Now that apic routing model is selected, configure the8585- * fault handling for intr remapping.8686- */8787- if (intr_remapping_enabled)8888- enable_drhd_fault_handling();8982}90839184/* Same for both flat and physical. */
+9-7
arch/x86/kernel/head_32.S
···6060#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)6161#endif62626363+/* Number of possible pages in the lowmem region */6464+LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)6565+6366/* Enough space to fit pagetables for the low memory linear map */6464-MAPPING_BEYOND_END = \6565- PAGE_TABLE_SIZE(((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT) << PAGE_SHIFT6767+MAPPING_BEYOND_END = PAGE_TABLE_SIZE(LOWMEM_PAGES) << PAGE_SHIFT66686769/*6870 * Worst-case size of the kernel mapping we need to make:6969- * the worst-case size of the kernel itself, plus the extra we need7070- * to map for the linear map.7171+ * a relocatable kernel can live anywhere in lowmem, so we need to be able7272+ * to map all of lowmem.7173 */7272-KERNEL_PAGES = (KERNEL_IMAGE_SIZE + MAPPING_BEYOND_END)>>PAGE_SHIFT7474+KERNEL_PAGES = LOWMEM_PAGES73757476INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE_asm7577RESERVE_BRK(pagetables, INIT_MAP_SIZE)···622620__PAGE_ALIGNED_BSS623621 .align PAGE_SIZE_asm624622#ifdef CONFIG_X86_PAE625625-initial_pg_pmd:623623+ENTRY(initial_pg_pmd)626624 .fill 1024*KPMDS,4,0627625#else628626ENTRY(initial_page_table)629627 .fill 1024,4,0630628#endif631631-initial_pg_fixmap:629629+ENTRY(initial_pg_fixmap)632630 .fill 1024,4,0633631ENTRY(empty_zero_page)634632 .fill 4096,1,0
+16-10
arch/x86/kernel/hpet.c
···2727#define HPET_DEV_FSB_CAP 0x10002828#define HPET_DEV_PERI_CAP 0x200029293030+#define HPET_MIN_CYCLES 1283131+#define HPET_MIN_PROG_DELTA (HPET_MIN_CYCLES + (HPET_MIN_CYCLES >> 1))3232+3033#define EVT_TO_HPET_DEV(evt) container_of(evt, struct hpet_dev, evt)31343235/*···302299 /* Calculate the min / max delta */303300 hpet_clockevent.max_delta_ns = clockevent_delta2ns(0x7FFFFFFF,304301 &hpet_clockevent);305305- /* 5 usec minimum reprogramming delta. */306306- hpet_clockevent.min_delta_ns = 5000;302302+ /* Setup minimum reprogramming delta. */303303+ hpet_clockevent.min_delta_ns = clockevent_delta2ns(HPET_MIN_PROG_DELTA,304304+ &hpet_clockevent);307305308306 /*309307 * Start hpet with the boot cpu mask and make it···397393 * the wraparound into account) nor a simple count down event398394 * mode. Further the write to the comparator register is399395 * delayed internally up to two HPET clock cycles in certain400400- * chipsets (ATI, ICH9,10). We worked around that by reading401401- * back the compare register, but that required another402402- * workaround for ICH9,10 chips where the first readout after403403- * write can return the old stale value. We already have a404404- * minimum delta of 5us enforced, but a NMI or SMI hitting396396+ * chipsets (ATI, ICH9,10). Some newer AMD chipsets have even397397+ * longer delays. We worked around that by reading back the398398+ * compare register, but that required another workaround for399399+ * ICH9,10 chips where the first readout after write can400400+ * return the old stale value. We already had a minimum401401+ * programming delta of 5us enforced, but a NMI or SMI hitting405402 * between the counter readout and the comparator write can406403 * move us behind that point easily. Now instead of reading407404 * the compare register back several times, we make the ETIME408405 * decision based on the following: Return ETIME if the409409- * counter value after the write is less than 8 HPET cycles406406+ * counter value after the write is less than HPET_MIN_CYCLES410407 * away from the event or if the counter is already ahead of411411- * the event.408408+ * the event. The minimum programming delta for the generic409409+ * clockevents code is set to 1.5 * HPET_MIN_CYCLES.412410 */413411 res = (s32)(cnt - hpet_readl(HPET_COUNTER));414412415415- return res < 8 ? -ETIME : 0;413413+ return res < HPET_MIN_CYCLES ? -ETIME : 0;416414}417415418416static void hpet_legacy_set_mode(enum clock_event_mode mode,
+48
arch/x86/kernel/resource.c
···11+#include <linux/ioport.h>22+#include <asm/e820.h>33+44+static void resource_clip(struct resource *res, resource_size_t start,55+ resource_size_t end)66+{77+ resource_size_t low = 0, high = 0;88+99+ if (res->end < start || res->start > end)1010+ return; /* no conflict */1111+1212+ if (res->start < start)1313+ low = start - res->start;1414+1515+ if (res->end > end)1616+ high = res->end - end;1717+1818+ /* Keep the area above or below the conflict, whichever is larger */1919+ if (low > high)2020+ res->end = start - 1;2121+ else2222+ res->start = end + 1;2323+}2424+2525+static void remove_e820_regions(struct resource *avail)2626+{2727+ int i;2828+ struct e820entry *entry;2929+3030+ for (i = 0; i < e820.nr_map; i++) {3131+ entry = &e820.map[i];3232+3333+ resource_clip(avail, entry->addr,3434+ entry->addr + entry->size - 1);3535+ }3636+}3737+3838+void arch_remove_reservations(struct resource *avail)3939+{4040+ /* Trim out BIOS areas (low 1MB and high 2MB) and E820 regions */4141+ if (avail->flags & IORESOURCE_MEM) {4242+ if (avail->start < BIOS_END)4343+ avail->start = BIOS_END;4444+ resource_clip(avail, BIOS_ROM_BASE, BIOS_ROM_END);4545+4646+ remove_e820_regions(avail);4747+ }4848+}
···394394 * Setup init_xstate_buf to represent the init state of395395 * all the features managed by the xsave396396 */397397- init_xstate_buf = alloc_bootmem(xstate_size);397397+ init_xstate_buf = alloc_bootmem_align(xstate_size,398398+ __alignof__(struct xsave_struct));398399 init_xstate_buf->i387.mxcsr = MXCSR_DEFAULT;399400400401 clts();
+4
arch/x86/kvm/svm.c
···34943494static void svm_set_supported_cpuid(u32 func, struct kvm_cpuid_entry2 *entry)34953495{34963496 switch (func) {34973497+ case 0x00000001:34983498+ /* Mask out xsave bit as long as it is not supported by SVM */34993499+ entry->ecx &= ~(bit(X86_FEATURE_XSAVE));35003500+ break;34973501 case 0x80000001:34983502 if (nested)34993503 entry->ecx |= (1 << 2); /* Set SVM bit */
···531531{532532 lguest_data.pgdir = cr3;533533 lazy_hcall1(LHCALL_NEW_PGTABLE, cr3);534534- cr3_changed = true;534534+535535+ /* These two page tables are simple, linear, and used during boot */536536+ if (cr3 != __pa(swapper_pg_dir) && cr3 != __pa(initial_page_table))537537+ cr3_changed = true;535538}536539537540static unsigned long lguest_read_cr3(void)···706703 * to forget all of them. Fortunately, this is very rare.707704 *708705 * ... except in early boot when the kernel sets up the initial pagetables,709709- * which makes booting astonishingly slow: 1.83 seconds! So we don't even tell710710- * the Host anything changed until we've done the first page table switch,711711- * which brings boot back to 0.25 seconds.706706+ * which makes booting astonishingly slow: 48 seconds! So we don't even tell707707+ * the Host anything changed until we've done the first real page table switch,708708+ * which brings boot back to 4.3 seconds.712709 */713710static void lguest_set_pte(pte_t *ptep, pte_t pteval)714711{···10051002 clockevents_register_device(&lguest_clockevent);1006100310071004 /* Finally, we unblock the timer interrupt. */10081008- enable_lguest_irq(0);10051005+ clear_bit(0, lguest_data.blocked_interrupts);10091006}1010100710111008/*···13511348 * per-cpu segment descriptor register %fs as well.13521349 */13531350 switch_to_new_gdt(0);13541354-13551355- /* We actually boot with all memory mapped, but let's say 128MB. */13561356- max_pfn_mapped = (128*1024*1024) >> PAGE_SHIFT;1357135113581352 /*13591353 * The Host<->Guest Switcher lives at the top of our address space, and
+105
arch/x86/lguest/i386_head.S
···44#include <asm/asm-offsets.h>55#include <asm/thread_info.h>66#include <asm/processor-flags.h>77+#include <asm/pgtable.h>7889/*G:020910 * Our story starts with the kernel booting into startup_32 in···3837 /* Set up the initial stack so we can run C code. */3938 movl $(init_thread_union+THREAD_SIZE),%esp40394040+ call init_pagetables4141+4142 /* Jumps are relative: we're running __PAGE_OFFSET too low. */4243 jmp lguest_init+__PAGE_OFFSET4444+4545+/*4646+ * Initialize page tables. This creates a PDE and a set of page4747+ * tables, which are located immediately beyond __brk_base. The variable4848+ * _brk_end is set up to point to the first "safe" location.4949+ * Mappings are created both at virtual address 0 (identity mapping)5050+ * and PAGE_OFFSET for up to _end.5151+ *5252+ * FIXME: This code is taken verbatim from arch/x86/kernel/head_32.S: they5353+ * don't have a stack at this point, so we can't just use call and ret.5454+ */5555+init_pagetables:5656+#if PTRS_PER_PMD > 15757+#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)5858+#else5959+#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)6060+#endif6161+#define pa(X) ((X) - __PAGE_OFFSET)6262+6363+/* Enough space to fit pagetables for the low memory linear map */6464+MAPPING_BEYOND_END = \6565+ PAGE_TABLE_SIZE(((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT) << PAGE_SHIFT6666+#ifdef CONFIG_X86_PAE6767+6868+ /*6969+ * In PAE mode initial_page_table is statically defined to contain7070+ * enough entries to cover the VMSPLIT option (that is the top 1, 2 or 37171+ * entries). The identity mapping is handled by pointing two PGD entries7272+ * to the first kernel PMD.7373+ *7474+ * Note the upper half of each PMD or PTE are always zero at this stage.7575+ */7676+7777+#define KPMDS (((-__PAGE_OFFSET) >> 30) & 3) /* Number of kernel PMDs */7878+7979+ xorl %ebx,%ebx /* %ebx is kept at zero */8080+8181+ movl $pa(__brk_base), %edi8282+ movl $pa(initial_pg_pmd), %edx8383+ movl $PTE_IDENT_ATTR, %eax8484+10:8585+ leal PDE_IDENT_ATTR(%edi),%ecx /* Create PMD entry */8686+ movl %ecx,(%edx) /* Store PMD entry */8787+ /* Upper half already zero */8888+ addl $8,%edx8989+ movl $512,%ecx9090+11:9191+ stosl9292+ xchgl %eax,%ebx9393+ stosl9494+ xchgl %eax,%ebx9595+ addl $0x1000,%eax9696+ loop 11b9797+9898+ /*9999+ * End condition: we must map up to the end + MAPPING_BEYOND_END.100100+ */101101+ movl $pa(_end) + MAPPING_BEYOND_END + PTE_IDENT_ATTR, %ebp102102+ cmpl %ebp,%eax103103+ jb 10b104104+1:105105+ addl $__PAGE_OFFSET, %edi106106+ movl %edi, pa(_brk_end)107107+ shrl $12, %eax108108+ movl %eax, pa(max_pfn_mapped)109109+110110+ /* Do early initialization of the fixmap area */111111+ movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax112112+ movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)113113+#else /* Not PAE */114114+115115+page_pde_offset = (__PAGE_OFFSET >> 20);116116+117117+ movl $pa(__brk_base), %edi118118+ movl $pa(initial_page_table), %edx119119+ movl $PTE_IDENT_ATTR, %eax120120+10:121121+ leal PDE_IDENT_ATTR(%edi),%ecx /* Create PDE entry */122122+ movl %ecx,(%edx) /* Store identity PDE entry */123123+ movl %ecx,page_pde_offset(%edx) /* Store kernel PDE entry */124124+ addl $4,%edx125125+ movl $1024, %ecx126126+11:127127+ stosl128128+ addl $0x1000,%eax129129+ loop 11b130130+ /*131131+ * End condition: we must map up to the end + MAPPING_BEYOND_END.132132+ */133133+ movl $pa(_end) + MAPPING_BEYOND_END + PTE_IDENT_ATTR, %ebp134134+ cmpl %ebp,%eax135135+ jb 10b136136+ addl $__PAGE_OFFSET, %edi137137+ movl %edi, pa(_brk_end)138138+ shrl $12, %eax139139+ movl %eax, pa(max_pfn_mapped)140140+141141+ /* Do early initialization of the fixmap area */142142+ movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax143143+ movl %eax,pa(initial_page_table+0xffc)144144+#endif145145+ ret4314644147/*G:05545148 * We create a macro which puts the assembler code between lgstart_ and lgend_
+5-13
arch/x86/pci/i386.c
···6565 resource_size_t size, resource_size_t align)6666{6767 struct pci_dev *dev = data;6868- resource_size_t start = round_down(res->end - size + 1, align);6868+ resource_size_t start = res->start;69697070 if (res->flags & IORESOURCE_IO) {7171-7272- /*7373- * If we're avoiding ISA aliases, the largest contiguous I/O7474- * port space is 256 bytes. Clearing bits 9 and 10 preserves7575- * all 256-byte and smaller alignments, so the result will7676- * still be correctly aligned.7777- */7878- if (!skip_isa_ioresource_align(dev))7979- start &= ~0x300;8080- } else if (res->flags & IORESOURCE_MEM) {8181- if (start < BIOS_END)8282- start = res->end; /* fail; no space */7171+ if (skip_isa_ioresource_align(dev))7272+ return start;7373+ if (start & 0x300)7474+ start = (start + 0x3ff) & ~0x3ff;8375 }8476 return start;8577}
+2-2
arch/x86/vdso/Makefile
···25252626export CPPFLAGS_vdso.lds += -P -C27272828-VDSO_LDFLAGS_vdso.lds = -m elf_x86_64 -Wl,-soname=linux-vdso.so.1 \2828+VDSO_LDFLAGS_vdso.lds = -m64 -Wl,-soname=linux-vdso.so.1 \2929 -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=409630303131$(obj)/vdso.o: $(src)/vdso.S $(obj)/vdso.so···6969vdso32-images = $(vdso32.so-y:%=vdso32-%.so)70707171CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds)7272-VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -Wl,-soname=linux-gate.so.17272+VDSO_LDFLAGS_vdso32.lds = -m32 -Wl,-soname=linux-gate.so.173737474# This makes sure the $(obj) subdirectory exists even though vdso32/7575# is not a kbuild sub-make subdirectory.
+3-2
block/blk-map.c
···201201 for (i = 0; i < iov_count; i++) {202202 unsigned long uaddr = (unsigned long)iov[i].iov_base;203203204204+ if (!iov[i].iov_len)205205+ return -EINVAL;206206+204207 if (uaddr & queue_dma_alignment(q)) {205208 unaligned = 1;206209 break;207210 }208208- if (!iov[i].iov_len)209209- return -EINVAL;210211 }211212212213 if (unaligned || (q->dma_pad_mask & len) || map_data)
+3-3
block/blk-merge.c
···2121 return 0;22222323 fbio = bio;2424- cluster = test_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags);2424+ cluster = blk_queue_cluster(q);2525 seg_size = 0;2626 nr_phys_segs = 0;2727 for_each_bio(bio) {···8787static int blk_phys_contig_segment(struct request_queue *q, struct bio *bio,8888 struct bio *nxt)8989{9090- if (!test_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags))9090+ if (!blk_queue_cluster(q))9191 return 0;92929393 if (bio->bi_seg_back_size + nxt->bi_seg_front_size >···123123 int nsegs, cluster;124124125125 nsegs = 0;126126- cluster = test_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags);126126+ cluster = blk_queue_cluster(q);127127128128 /*129129 * for each bio in rq
+22-29
block/blk-settings.c
···126126 lim->alignment_offset = 0;127127 lim->io_opt = 0;128128 lim->misaligned = 0;129129- lim->no_cluster = 0;129129+ lim->cluster = 1;130130}131131EXPORT_SYMBOL(blk_set_default_limits);132132···229229EXPORT_SYMBOL(blk_queue_bounce_limit);230230231231/**232232- * blk_queue_max_hw_sectors - set max sectors for a request for this queue233233- * @q: the request queue for the device232232+ * blk_limits_max_hw_sectors - set hard and soft limit of max sectors for request233233+ * @limits: the queue limits234234 * @max_hw_sectors: max hardware sectors in the usual 512b unit235235 *236236 * Description:···244244 * per-device basis in /sys/block/<device>/queue/max_sectors_kb.245245 * The soft limit can not exceed max_hw_sectors.246246 **/247247-void blk_queue_max_hw_sectors(struct request_queue *q, unsigned int max_hw_sectors)247247+void blk_limits_max_hw_sectors(struct queue_limits *limits, unsigned int max_hw_sectors)248248{249249 if ((max_hw_sectors << 9) < PAGE_CACHE_SIZE) {250250 max_hw_sectors = 1 << (PAGE_CACHE_SHIFT - 9);···252252 __func__, max_hw_sectors);253253 }254254255255- q->limits.max_hw_sectors = max_hw_sectors;256256- q->limits.max_sectors = min_t(unsigned int, max_hw_sectors,257257- BLK_DEF_MAX_SECTORS);255255+ limits->max_hw_sectors = max_hw_sectors;256256+ limits->max_sectors = min_t(unsigned int, max_hw_sectors,257257+ BLK_DEF_MAX_SECTORS);258258+}259259+EXPORT_SYMBOL(blk_limits_max_hw_sectors);260260+261261+/**262262+ * blk_queue_max_hw_sectors - set max sectors for a request for this queue263263+ * @q: the request queue for the device264264+ * @max_hw_sectors: max hardware sectors in the usual 512b unit265265+ *266266+ * Description:267267+ * See description for blk_limits_max_hw_sectors().268268+ **/269269+void blk_queue_max_hw_sectors(struct request_queue *q, unsigned int max_hw_sectors)270270+{271271+ blk_limits_max_hw_sectors(&q->limits, max_hw_sectors);258272}259273EXPORT_SYMBOL(blk_queue_max_hw_sectors);260274···478464void blk_queue_stack_limits(struct request_queue *t, struct request_queue *b)479465{480466 blk_stack_limits(&t->limits, &b->limits, 0);481481-482482- if (!t->queue_lock)483483- WARN_ON_ONCE(1);484484- else if (!test_bit(QUEUE_FLAG_CLUSTER, &b->queue_flags)) {485485- unsigned long flags;486486- spin_lock_irqsave(t->queue_lock, flags);487487- queue_flag_clear(QUEUE_FLAG_CLUSTER, t);488488- spin_unlock_irqrestore(t->queue_lock, flags);489489- }490467}491468EXPORT_SYMBOL(blk_queue_stack_limits);492469···550545 t->io_min = max(t->io_min, b->io_min);551546 t->io_opt = lcm(t->io_opt, b->io_opt);552547553553- t->no_cluster |= b->no_cluster;548548+ t->cluster &= b->cluster;554549 t->discard_zeroes_data &= b->discard_zeroes_data;555550556551 /* Physical block size a multiple of the logical block size? */···646641 sector_t offset)647642{648643 struct request_queue *t = disk->queue;649649- struct request_queue *b = bdev_get_queue(bdev);650644651645 if (bdev_stack_limits(&t->limits, bdev, offset >> 9) < 0) {652646 char top[BDEVNAME_SIZE], bottom[BDEVNAME_SIZE];···655651656652 printk(KERN_NOTICE "%s: Warning: Device %s is misaligned\n",657653 top, bottom);658658- }659659-660660- if (!t->queue_lock)661661- WARN_ON_ONCE(1);662662- else if (!test_bit(QUEUE_FLAG_CLUSTER, &b->queue_flags)) {663663- unsigned long flags;664664-665665- spin_lock_irqsave(t->queue_lock, flags);666666- if (!test_bit(QUEUE_FLAG_CLUSTER, &b->queue_flags))667667- queue_flag_clear(QUEUE_FLAG_CLUSTER, t);668668- spin_unlock_irqrestore(t->queue_lock, flags);669654 }670655}671656EXPORT_SYMBOL(disk_stack_limits);
+1-1
block/blk-sysfs.c
···119119120120static ssize_t queue_max_segment_size_show(struct request_queue *q, char *page)121121{122122- if (test_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags))122122+ if (blk_queue_cluster(q))123123 return queue_var_show(queue_max_segment_size(q), (page));124124125125 return queue_var_show(PAGE_CACHE_SIZE, (page));
+25-14
block/blk-throttle.c
···355355 tg->slice_end[rw], jiffies);356356}357357358358+static inline void throtl_set_slice_end(struct throtl_data *td,359359+ struct throtl_grp *tg, bool rw, unsigned long jiffy_end)360360+{361361+ tg->slice_end[rw] = roundup(jiffy_end, throtl_slice);362362+}363363+358364static inline void throtl_extend_slice(struct throtl_data *td,359365 struct throtl_grp *tg, bool rw, unsigned long jiffy_end)360366{···396390 */397391 if (throtl_slice_used(td, tg, rw))398392 return;393393+394394+ /*395395+ * A bio has been dispatched. Also adjust slice_end. It might happen396396+ * that initially cgroup limit was very low resulting in high397397+ * slice_end, but later limit was bumped up and bio was dispached398398+ * sooner, then we need to reduce slice_end. A high bogus slice_end399399+ * is bad because it does not allow new slice to start.400400+ */401401+402402+ throtl_set_slice_end(td, tg, rw, jiffies + throtl_slice);399403400404 time_elapsed = jiffies - tg->slice_start[rw];401405···725709 struct throtl_grp *tg;726710 struct hlist_node *pos, *n;727711728728- /*729729- * Make sure atomic_inc() effects from730730- * throtl_update_blkio_group_read_bps(), group of functions are731731- * visible.732732- * Is this required or smp_mb__after_atomic_inc() was suffcient733733- * after the atomic_inc().734734- */735735- smp_rmb();736712 if (!atomic_read(&td->limits_changed))737713 return;738714739715 throtl_log(td, "limit changed =%d", atomic_read(&td->limits_changed));740716741741- hlist_for_each_entry_safe(tg, pos, n, &td->tg_list, tg_node) {742742- /*743743- * Do I need an smp_rmb() here to make sure tg->limits_changed744744- * update is visible. I am relying on smp_rmb() at the745745- * beginning of function and not putting a new one here.746746- */717717+ /*718718+ * Make sure updates from throtl_update_blkio_group_read_bps() group719719+ * of functions to tg->limits_changed are visible. We do not720720+ * want update td->limits_changed to be visible but update to721721+ * tg->limits_changed not being visible yet on this cpu. Hence722722+ * the read barrier.723723+ */724724+ smp_rmb();747725726726+ hlist_for_each_entry_safe(tg, pos, n, &td->tg_list, tg_node) {748727 if (throtl_tg_on_rr(tg) && tg->limits_changed) {749728 throtl_log_tg(td, tg, "limit change rbps=%llu wbps=%llu"750729 " riops=%u wiops=%u", tg->bps[READ],
+8
block/bsg.c
···250250 int ret, rw;251251 unsigned int dxfer_len;252252 void *dxferp = NULL;253253+ struct bsg_class_device *bcd = &q->bsg_dev;254254+255255+ /* if the LLD has been removed then the bsg_unregister_queue will256256+ * eventually be called and the class_dev was freed, so we can no257257+ * longer use this request_queue. Return no such address.258258+ */259259+ if (!bcd->class_dev)260260+ return ERR_PTR(-ENXIO);253261254262 dprintk("map hdr %llx/%u %llx/%u\n", (unsigned long long) hdr->dout_xferp,255263 hdr->dout_xfer_len, (unsigned long long) hdr->din_xferp,
···8686 * It is used to provide exclusive accessing for ERST Error Log8787 * Address Range too.8888 */8989-static DEFINE_SPINLOCK(erst_lock);8989+static DEFINE_RAW_SPINLOCK(erst_lock);90909191static inline int erst_errno(int command_status)9292{···421421 if (erst_disable)422422 return -ENODEV;423423424424- spin_lock_irqsave(&erst_lock, flags);424424+ raw_spin_lock_irqsave(&erst_lock, flags);425425 count = __erst_get_record_count();426426- spin_unlock_irqrestore(&erst_lock, flags);426426+ raw_spin_unlock_irqrestore(&erst_lock, flags);427427428428 return count;429429}···456456 if (erst_disable)457457 return -ENODEV;458458459459- spin_lock_irqsave(&erst_lock, flags);459459+ raw_spin_lock_irqsave(&erst_lock, flags);460460 rc = __erst_get_next_record_id(record_id);461461- spin_unlock_irqrestore(&erst_lock, flags);461461+ raw_spin_unlock_irqrestore(&erst_lock, flags);462462463463 return rc;464464}···624624 return -EINVAL;625625626626 if (erst_erange.attr & ERST_RANGE_NVRAM) {627627- if (!spin_trylock_irqsave(&erst_lock, flags))627627+ if (!raw_spin_trylock_irqsave(&erst_lock, flags))628628 return -EBUSY;629629 rc = __erst_write_to_nvram(record);630630- spin_unlock_irqrestore(&erst_lock, flags);630630+ raw_spin_unlock_irqrestore(&erst_lock, flags);631631 return rc;632632 }633633634634 if (record->record_length > erst_erange.size)635635 return -EINVAL;636636637637- if (!spin_trylock_irqsave(&erst_lock, flags))637637+ if (!raw_spin_trylock_irqsave(&erst_lock, flags))638638 return -EBUSY;639639 memcpy(erst_erange.vaddr, record, record->record_length);640640 rcd_erange = erst_erange.vaddr;···642642 memcpy(&rcd_erange->persistence_information, "ER", 2);643643644644 rc = __erst_write_to_storage(0);645645- spin_unlock_irqrestore(&erst_lock, flags);645645+ raw_spin_unlock_irqrestore(&erst_lock, flags);646646647647 return rc;648648}···696696 if (erst_disable)697697 return -ENODEV;698698699699- spin_lock_irqsave(&erst_lock, flags);699699+ raw_spin_lock_irqsave(&erst_lock, flags);700700 len = __erst_read(record_id, record, buflen);701701- spin_unlock_irqrestore(&erst_lock, flags);701701+ raw_spin_unlock_irqrestore(&erst_lock, flags);702702 return len;703703}704704EXPORT_SYMBOL_GPL(erst_read);···719719 if (erst_disable)720720 return -ENODEV;721721722722- spin_lock_irqsave(&erst_lock, flags);722722+ raw_spin_lock_irqsave(&erst_lock, flags);723723 rc = __erst_get_next_record_id(&record_id);724724 if (rc) {725725- spin_unlock_irqrestore(&erst_lock, flags);725725+ raw_spin_unlock_irqrestore(&erst_lock, flags);726726 return rc;727727 }728728 /* no more record */729729 if (record_id == APEI_ERST_INVALID_RECORD_ID) {730730- spin_unlock_irqrestore(&erst_lock, flags);730730+ raw_spin_unlock_irqrestore(&erst_lock, flags);731731 return 0;732732 }733733734734 len = __erst_read(record_id, record, buflen);735735- spin_unlock_irqrestore(&erst_lock, flags);735735+ raw_spin_unlock_irqrestore(&erst_lock, flags);736736737737 return len;738738}···746746 if (erst_disable)747747 return -ENODEV;748748749749- spin_lock_irqsave(&erst_lock, flags);749749+ raw_spin_lock_irqsave(&erst_lock, flags);750750 if (erst_erange.attr & ERST_RANGE_NVRAM)751751 rc = __erst_clear_from_nvram(record_id);752752 else753753 rc = __erst_clear_from_storage(record_id);754754- spin_unlock_irqrestore(&erst_lock, flags);754754+ raw_spin_unlock_irqrestore(&erst_lock, flags);755755756756 return rc;757757}
+5-5
drivers/acpi/apei/hest.c
···46464747/* HEST table parsing */48484949-static struct acpi_table_hest *hest_tab;4949+static struct acpi_table_hest *__read_mostly hest_tab;50505151-static int hest_esrc_len_tab[ACPI_HEST_TYPE_RESERVED] = {5151+static const int hest_esrc_len_tab[ACPI_HEST_TYPE_RESERVED] = {5252 [ACPI_HEST_TYPE_IA32_CHECK] = -1, /* need further calculation */5353 [ACPI_HEST_TYPE_IA32_CORRECTED_CHECK] = -1,5454 [ACPI_HEST_TYPE_IA32_NMI] = sizeof(struct acpi_hest_ia_nmi),···126126 unsigned int count;127127};128128129129-static int hest_parse_ghes_count(struct acpi_hest_header *hest_hdr, void *data)129129+static int __init hest_parse_ghes_count(struct acpi_hest_header *hest_hdr, void *data)130130{131131 int *count = data;132132···135135 return 0;136136}137137138138-static int hest_parse_ghes(struct acpi_hest_header *hest_hdr, void *data)138138+static int __init hest_parse_ghes(struct acpi_hest_header *hest_hdr, void *data)139139{140140 struct platform_device *ghes_dev;141141 struct ghes_arr *ghes_arr = data;···165165 return rc;166166}167167168168-static int hest_ghes_dev_register(unsigned int ghes_count)168168+static int __init hest_ghes_dev_register(unsigned int ghes_count)169169{170170 int rc, i;171171 struct ghes_arr ghes_arr;
+5
drivers/acpi/battery.c
···130130 unsigned long flags;131131};132132133133+static int acpi_battery_update(struct acpi_battery *battery);134134+133135#define to_acpi_battery(x) container_of(x, struct acpi_battery, bat);134136135137inline int acpi_battery_present(struct acpi_battery *battery)···185183{186184 int ret = 0;187185 struct acpi_battery *battery = to_acpi_battery(psy);186186+187187+ if (acpi_battery_update(battery))188188+ return -ENODEV;188189189190 if (acpi_battery_present(battery)) {190191 /* run battery update only if it is present */
···110110static LIST_HEAD(acpi_ioremaps);111111static DEFINE_SPINLOCK(acpi_ioremap_lock);112112113113-#define OSI_STRING_LENGTH_MAX 64 /* arbitrary */114114-static char osi_setup_string[OSI_STRING_LENGTH_MAX];115115-116113static void __init acpi_osi_setup_late(void);117114118115/*···149152 unsigned int enable:1;150153 unsigned int dmi:1;151154 unsigned int cmdline:1;152152- unsigned int known:1;153153-} osi_linux = { 0, 0, 0, 0};155155+} osi_linux = {0, 0, 0};154156155157static u32 acpi_osi_handler(acpi_string interface, u32 supported)156158{···1051105510521056__setup("acpi_os_name=", acpi_os_name_setup);1053105710581058+#define OSI_STRING_LENGTH_MAX 64 /* arbitrary */10591059+#define OSI_STRING_ENTRIES_MAX 16 /* arbitrary */10601060+10611061+struct osi_setup_entry {10621062+ char string[OSI_STRING_LENGTH_MAX];10631063+ bool enable;10641064+};10651065+10661066+static struct osi_setup_entry __initdata osi_setup_entries[OSI_STRING_ENTRIES_MAX];10671067+10681068+void __init acpi_osi_setup(char *str)10691069+{10701070+ struct osi_setup_entry *osi;10711071+ bool enable = true;10721072+ int i;10731073+10741074+ if (!acpi_gbl_create_osi_method)10751075+ return;10761076+10771077+ if (str == NULL || *str == '\0') {10781078+ printk(KERN_INFO PREFIX "_OSI method disabled\n");10791079+ acpi_gbl_create_osi_method = FALSE;10801080+ return;10811081+ }10821082+10831083+ if (*str == '!') {10841084+ str++;10851085+ enable = false;10861086+ }10871087+10881088+ for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {10891089+ osi = &osi_setup_entries[i];10901090+ if (!strcmp(osi->string, str)) {10911091+ osi->enable = enable;10921092+ break;10931093+ } else if (osi->string[0] == '\0') {10941094+ osi->enable = enable;10951095+ strncpy(osi->string, str, OSI_STRING_LENGTH_MAX);10961096+ break;10971097+ }10981098+ }10991099+}11001100+10541101static void __init set_osi_linux(unsigned int enable)10551102{10561056- if (osi_linux.enable != enable) {11031103+ if (osi_linux.enable != enable)10571104 osi_linux.enable = enable;10581058- printk(KERN_NOTICE PREFIX "%sed _OSI(Linux)\n",10591059- enable ? "Add": "Delet");10601060- }1061110510621106 if (osi_linux.enable)10631107 acpi_osi_setup("Linux");···1109107311101074static void __init acpi_cmdline_osi_linux(unsigned int enable)11111075{11121112- osi_linux.cmdline = 1; /* cmdline set the default */10761076+ osi_linux.cmdline = 1; /* cmdline set the default and override DMI */10771077+ osi_linux.dmi = 0;11131078 set_osi_linux(enable);1114107911151080 return;···1118108111191082void __init acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d)11201083{11211121- osi_linux.dmi = 1; /* DMI knows that this box asks OSI(Linux) */11221122-11231084 printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident);1124108511251086 if (enable == -1)11261087 return;1127108811281128- osi_linux.known = 1; /* DMI knows which OSI(Linux) default needed */11291129-10891089+ osi_linux.dmi = 1; /* DMI knows that this box asks OSI(Linux) */11301090 set_osi_linux(enable);1131109111321092 return;···11381104 */11391105static void __init acpi_osi_setup_late(void)11401106{11411141- char *str = osi_setup_string;11071107+ struct osi_setup_entry *osi;11081108+ char *str;11091109+ int i;11101110+ acpi_status status;1142111111431143- if (*str == '\0')11441144- return;11121112+ for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {11131113+ osi = &osi_setup_entries[i];11141114+ str = osi->string;1145111511461146- if (!strcmp("!Linux", str)) {11471147- acpi_cmdline_osi_linux(0); /* !enable */11481148- } else if (*str == '!') {11491149- if (acpi_remove_interface(++str) == AE_OK)11501150- printk(KERN_INFO PREFIX "Deleted _OSI(%s)\n", str);11511151- } else if (!strcmp("Linux", str)) {11521152- acpi_cmdline_osi_linux(1); /* enable */11531153- } else {11541154- if (acpi_install_interface(str) == AE_OK)11551155- printk(KERN_INFO PREFIX "Added _OSI(%s)\n", str);11161116+ if (*str == '\0')11171117+ break;11181118+ if (osi->enable) {11191119+ status = acpi_install_interface(str);11201120+11211121+ if (ACPI_SUCCESS(status))11221122+ printk(KERN_INFO PREFIX "Added _OSI(%s)\n", str);11231123+ } else {11241124+ status = acpi_remove_interface(str);11251125+11261126+ if (ACPI_SUCCESS(status))11271127+ printk(KERN_INFO PREFIX "Deleted _OSI(%s)\n", str);11281128+ }11561129 }11571130}1158113111591159-int __init acpi_osi_setup(char *str)11321132+static int __init osi_setup(char *str)11601133{11611161- if (str == NULL || *str == '\0') {11621162- printk(KERN_INFO PREFIX "_OSI method disabled\n");11631163- acpi_gbl_create_osi_method = FALSE;11641164- } else {11651165- strncpy(osi_setup_string, str, OSI_STRING_LENGTH_MAX);11661166- }11341134+ if (str && !strcmp("Linux", str))11351135+ acpi_cmdline_osi_linux(1);11361136+ else if (str && !strcmp("!Linux", str))11371137+ acpi_cmdline_osi_linux(0);11381138+ else11391139+ acpi_osi_setup(str);1167114011681141 return 1;11691142}1170114311711171-__setup("acpi_osi=", acpi_osi_setup);11441144+__setup("acpi_osi=", osi_setup);1172114511731146/* enable serialization to combat AE_ALREADY_EXISTS errors */11741147static int __init acpi_serialize_setup(char *str)···15711530 return AE_OK;15721531}1573153215741574-acpi_status acpi_os_initialize1(void)15331533+acpi_status __init acpi_os_initialize1(void)15751534{15761535 kacpid_wq = create_workqueue("kacpid");15771536 kacpi_notify_wq = create_workqueue("kacpi_notify");
+6-6
drivers/acpi/power.c
···213213 resource->name));214214 } else {215215 result = __acpi_power_on(resource);216216+ if (result)217217+ resource->ref_count--;216218 }217219218220 mutex_unlock(&resource->resource_lock);219221220220- return 0;222222+ return result;221223}222224223225static int acpi_power_off_device(acpi_handle handle)···467465 struct acpi_handle_list *tl = NULL; /* Target Resources */468466 int i = 0;469467470470-471468 if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3))472469 return -EINVAL;470470+471471+ if (device->power.state == state)472472+ return 0;473473474474 if ((device->power.state < ACPI_STATE_D0)475475 || (device->power.state > ACPI_STATE_D3))···490486 result = acpi_power_on(tl->handles[i]);491487 if (result)492488 goto end;493493- }494494-495495- if (device->power.state == state) {496496- goto end;497489 }498490499491 /*
-9
drivers/acpi/processor_thermal.c
···156156 return 0;157157}158158159159-static int acpi_thermal_cpufreq_increase(unsigned int cpu)160160-{161161- return -ENODEV;162162-}163163-static int acpi_thermal_cpufreq_decrease(unsigned int cpu)164164-{165165- return -ENODEV;166166-}167167-168159#endif169160170161int acpi_processor_get_limit_info(struct acpi_processor *pr)
+10-2
drivers/acpi/sleep.c
···27272828static u8 sleep_states[ACPI_S_STATE_COUNT];29293030-static u32 acpi_target_sleep_state = ACPI_STATE_S0;3131-3230static void acpi_sleep_tts_switch(u32 acpi_state)3331{3432 union acpi_object in_arg = { ACPI_TYPE_INTEGER };···7981}80828183#ifdef CONFIG_ACPI_SLEEP8484+static u32 acpi_target_sleep_state = ACPI_STATE_S0;8585+8286/*8387 * The ACPI specification wants us to save NVS memory regions during hibernation8488 * and to restore them during the subsequent resume. Windows does that also for···425425 .matches = {426426 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),427427 DMI_MATCH(DMI_PRODUCT_NAME, "VPCEB1Z1E"),428428+ },429429+ },430430+ {431431+ .callback = init_nvs_nosave,432432+ .ident = "Sony Vaio VGN-NW130D",433433+ .matches = {434434+ DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),435435+ DMI_MATCH(DMI_PRODUCT_NAME, "VGN-NW130D"),428436 },429437 },430438 {},
···28342834 InquiryData_struct *inq_buff = NULL;2835283528362836 for (logvol = 0; logvol < CISS_MAX_LUN; logvol++) {28372837+ if (!h->drv[logvol])28382838+ continue;28372839 if (memcmp(h->drv[logvol]->LunID, drv->LunID,28382840 sizeof(drv->LunID)) == 0) {28392841 FOUND = 1;
+8-6
drivers/block/drbd/drbd_receiver.c
···36273627 }3628362836293629 shs = drbd_cmd_handler[cmd].pkt_size - sizeof(union p_header);36303630- rv = drbd_recv(mdev, &header->h80.payload, shs);36313631- if (unlikely(rv != shs)) {36323632- dev_err(DEV, "short read while reading sub header: rv=%d\n", rv);36333633- goto err_out;36343634- }36353635-36363630 if (packet_size - shs > 0 && !drbd_cmd_handler[cmd].expect_payload) {36373631 dev_err(DEV, "No payload expected %s l:%d\n", cmdname(cmd), packet_size);36383632 goto err_out;36333633+ }36343634+36353635+ if (shs) {36363636+ rv = drbd_recv(mdev, &header->h80.payload, shs);36373637+ if (unlikely(rv != shs)) {36383638+ dev_err(DEV, "short read while reading sub header: rv=%d\n", rv);36393639+ goto err_out;36403640+ }36393641 }3640364236413643 rv = drbd_cmd_handler[cmd].function(mdev, cmd, packet_size - shs);
+2-1
drivers/block/drbd/drbd_req.h
···339339}340340341341/* completion of master bio is outside of spinlock.342342- * If you need it irqsave, do it your self! */342342+ * If you need it irqsave, do it your self!343343+ * Which means: don't use from bio endio callback. */343344static inline int req_mod(struct drbd_request *req,344345 enum drbd_req_event what)345346{
+9-1
drivers/block/drbd/drbd_worker.c
···193193 */194194void drbd_endio_pri(struct bio *bio, int error)195195{196196+ unsigned long flags;196197 struct drbd_request *req = bio->bi_private;197198 struct drbd_conf *mdev = req->mdev;199199+ struct bio_and_error m;198200 enum drbd_req_event what;199201 int uptodate = bio_flagged(bio, BIO_UPTODATE);200202···222220 bio_put(req->private_bio);223221 req->private_bio = ERR_PTR(error);224222225225- req_mod(req, what);223223+ /* not req_mod(), we need irqsave here! */224224+ spin_lock_irqsave(&mdev->req_lock, flags);225225+ __req_mod(req, what, &m);226226+ spin_unlock_irqrestore(&mdev->req_lock, flags);227227+228228+ if (m.bio)229229+ complete_master_bio(mdev, &m);226230}227231228232int w_read_retry_remote(struct drbd_conf *mdev, struct drbd_work *w, int cancel)
+1-1
drivers/block/xen-blkfront.c
···7272static DEFINE_MUTEX(blkfront_mutex);7373static const struct block_device_operations xlvbd_block_fops;74747575-#define BLK_RING_SIZE __RING_SIZE((struct blkif_sring *)0, PAGE_SIZE)7575+#define BLK_RING_SIZE __CONST_RING_SIZE(blkif, PAGE_SIZE)76767777/*7878 * We have one of these per vbd, whether ide, scsi or 'other'. They
···722722 desc->lli.daddr = mem;723723 desc->lli.ctrla = ctrla724724 | ATC_DST_WIDTH(mem_width)725725- | len >> mem_width;725725+ | len >> reg_width;726726 desc->lli.ctrlb = ctrlb;727727728728 if (!first) {
+4-2
drivers/dma/fsldma.c
···5050 * EIE - Error interrupt enable5151 * EOSIE - End of segments interrupt enable (basic mode)5252 * EOLNIE - End of links interrupt enable5353+ * BWC - Bandwidth sharing among channels5354 */5454- DMA_OUT(chan, &chan->regs->mr, FSL_DMA_MR_EIE5555- | FSL_DMA_MR_EOLNIE | FSL_DMA_MR_EOSIE, 32);5555+ DMA_OUT(chan, &chan->regs->mr, FSL_DMA_MR_BWC5656+ | FSL_DMA_MR_EIE | FSL_DMA_MR_EOLNIE5757+ | FSL_DMA_MR_EOSIE, 32);5658 break;5759 case FSL_DMA_IP_83XX:5860 /* Set the channel to below modes:
+8-1
drivers/dma/fsldma.h
···11/*22- * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.22+ * Copyright (C) 2007-2010 Freescale Semiconductor, Inc. All rights reserved.33 *44 * Author:55 * Zhang Wei <wei.zhang@freescale.com>, Jul 2007···3535#define FSL_DMA_MR_EMS_EN 0x000400003636#define FSL_DMA_MR_DAHE 0x000020003737#define FSL_DMA_MR_SAHE 0x000010003838+3939+/*4040+ * Bandwidth/pause control determines how many bytes a given4141+ * channel is allowed to transfer before the DMA engine pauses4242+ * the current channel and switches to the next channel4343+ */4444+#define FSL_DMA_MR_BWC 0x0800000038453946/* Special MR definition for MPC8349 */4047#define FSL_DMA_MR_EOTIE 0x00000080
+1-1
drivers/dma/imx-dma.c
···379379 return 0;380380381381err_init:382382- while (i-- >= 0) {382382+ while (--i >= 0) {383383 struct imxdma_channel *imxdmac = &imxdma->channel[i];384384 imx_dma_free(imxdmac->imxdma_channel);385385 }
···878878 u32 tmp;879879880880 /* flush hdp cache so updates hit vram */881881- if ((rdev->family >= CHIP_RV770) && (rdev->family <= CHIP_RV740)) {881881+ if ((rdev->family >= CHIP_RV770) && (rdev->family <= CHIP_RV740) &&882882+ !(rdev->flags & RADEON_IS_AGP)) {882883 void __iomem *ptr = (void *)rdev->gart.table.vram.ptr;883884 u32 tmp;884885885886 /* r7xx hw bug. write to HDP_DEBUG1 followed by fb read886887 * rather than write to HDP_REG_COHERENCY_FLUSH_CNTL888888+ * This seems to cause problems on some AGP cards. Just use the old889889+ * method for them.887890 */888891 WREG32(HDP_DEBUG1, 0);889892 tmp = readl((void __iomem *)ptr);···34883485void r600_ioctl_wait_idle(struct radeon_device *rdev, struct radeon_bo *bo)34893486{34903487 /* r7xx hw bug. write to HDP_DEBUG1 followed by fb read34913491- * rather than write to HDP_REG_COHERENCY_FLUSH_CNTL34883488+ * rather than write to HDP_REG_COHERENCY_FLUSH_CNTL.34893489+ * This seems to cause problems on some AGP cards. Just use the old34903490+ * method for them.34923491 */34933492 if ((rdev->family >= CHIP_RV770) && (rdev->family <= CHIP_RV740) &&34943494- rdev->vram_scratch.ptr) {34933493+ rdev->vram_scratch.ptr && !(rdev->flags & RADEON_IS_AGP)) {34953494 void __iomem *ptr = (void *)rdev->vram_scratch.ptr;34963495 u32 tmp;34973496
···187187#define IT87_REG_FAN_MAIN_CTRL 0x13188188#define IT87_REG_FAN_CTL 0x14189189#define IT87_REG_PWM(nr) (0x15 + (nr))190190+#define IT87_REG_PWM_DUTY(nr) (0x63 + (nr) * 8)190191191192#define IT87_REG_VIN(nr) (0x20 + (nr))192193#define IT87_REG_TEMP(nr) (0x29 + (nr))···252251 u8 fan_main_ctrl; /* Register value */253252 u8 fan_ctl; /* Register value */254253255255- /* The following 3 arrays correspond to the same registers. The256256- * meaning of bits 6-0 depends on the value of bit 7, and we want257257- * to preserve settings on mode changes, so we have to track all258258- * values separately. */254254+ /* The following 3 arrays correspond to the same registers up to255255+ * the IT8720F. The meaning of bits 6-0 depends on the value of bit256256+ * 7, and we want to preserve settings on mode changes, so we have257257+ * to track all values separately.258258+ * Starting with the IT8721F, the manual PWM duty cycles are stored259259+ * in separate registers (8-bit values), so the separate tracking260260+ * is no longer needed, but it is still done to keep the driver261261+ * simple. */259262 u8 pwm_ctrl[3]; /* Register value */260260- u8 pwm_duty[3]; /* Manual PWM value set by user (bit 6-0) */263263+ u8 pwm_duty[3]; /* Manual PWM value set by user */261264 u8 pwm_temp_map[3]; /* PWM to temp. chan. mapping (bits 1-0) */262265263266 /* Automatic fan speed control registers */···837832 data->fan_main_ctrl);838833 } else {839834 if (val == 1) /* Manual mode */840840- data->pwm_ctrl[nr] = data->pwm_duty[nr];835835+ data->pwm_ctrl[nr] = data->type == it8721 ?836836+ data->pwm_temp_map[nr] :837837+ data->pwm_duty[nr];841838 else /* Automatic mode */842839 data->pwm_ctrl[nr] = 0x80 | data->pwm_temp_map[nr];843840 it87_write_value(data, IT87_REG_PWM(nr), data->pwm_ctrl[nr]);···865858 return -EINVAL;866859867860 mutex_lock(&data->update_lock);868868- data->pwm_duty[nr] = pwm_to_reg(data, val);869869- /* If we are in manual mode, write the duty cycle immediately;870870- * otherwise, just store it for later use. */871871- if (!(data->pwm_ctrl[nr] & 0x80)) {872872- data->pwm_ctrl[nr] = data->pwm_duty[nr];873873- it87_write_value(data, IT87_REG_PWM(nr), data->pwm_ctrl[nr]);861861+ if (data->type == it8721) {862862+ /* If we are in automatic mode, the PWM duty cycle register863863+ * is read-only so we can't write the value */864864+ if (data->pwm_ctrl[nr] & 0x80) {865865+ mutex_unlock(&data->update_lock);866866+ return -EBUSY;867867+ }868868+ data->pwm_duty[nr] = pwm_to_reg(data, val);869869+ it87_write_value(data, IT87_REG_PWM_DUTY(nr),870870+ data->pwm_duty[nr]);871871+ } else {872872+ data->pwm_duty[nr] = pwm_to_reg(data, val);873873+ /* If we are in manual mode, write the duty cycle immediately;874874+ * otherwise, just store it for later use. */875875+ if (!(data->pwm_ctrl[nr] & 0x80)) {876876+ data->pwm_ctrl[nr] = data->pwm_duty[nr];877877+ it87_write_value(data, IT87_REG_PWM(nr),878878+ data->pwm_ctrl[nr]);879879+ }874880 }875881 mutex_unlock(&data->update_lock);876882 return count;···19781958 * channels to use when later setting to automatic mode later.19791959 * Use a 1:1 mapping by default (we are clueless.)19801960 * In both cases, the value can (and should) be changed by the user19811981- * prior to switching to a different mode. */19611961+ * prior to switching to a different mode.19621962+ * Note that this is no longer needed for the IT8721F and later, as19631963+ * these have separate registers for the temperature mapping and the19641964+ * manual duty cycle. */19821965 for (i = 0; i < 3; i++) {19831966 data->pwm_temp_map[i] = i;19841967 data->pwm_duty[i] = 0x7f; /* Full speed */···20572034static void it87_update_pwm_ctrl(struct it87_data *data, int nr)20582035{20592036 data->pwm_ctrl[nr] = it87_read_value(data, IT87_REG_PWM(nr));20602060- if (data->pwm_ctrl[nr] & 0x80) /* Automatic mode */20372037+ if (data->type == it8721) {20612038 data->pwm_temp_map[nr] = data->pwm_ctrl[nr] & 0x03;20622062- else /* Manual mode */20632063- data->pwm_duty[nr] = data->pwm_ctrl[nr] & 0x7f;20392039+ data->pwm_duty[nr] = it87_read_value(data,20402040+ IT87_REG_PWM_DUTY(nr));20412041+ } else {20422042+ if (data->pwm_ctrl[nr] & 0x80) /* Automatic mode */20432043+ data->pwm_temp_map[nr] = data->pwm_ctrl[nr] & 0x03;20442044+ else /* Manual mode */20452045+ data->pwm_duty[nr] = data->pwm_ctrl[nr] & 0x7f;20462046+ }2064204720652048 if (has_old_autopwm(data)) {20662049 int i;
+2-2
drivers/hwmon/ltc4215.c
···205205206206/* Power (virtual) */207207LTC4215_POWER(power1_input);208208-LTC4215_ALARM(power1_alarm, (1 << 3), LTC4215_STATUS);209208210209/* Input Voltage */211210LTC4215_VOLTAGE(in1_input, LTC4215_ADIN);···213214214215/* Output Voltage */215216LTC4215_VOLTAGE(in2_input, LTC4215_SOURCE);217217+LTC4215_ALARM(in2_min_alarm, (1 << 3), LTC4215_STATUS);216218217219/* Finally, construct an array of pointers to members of the above objects,218220 * as required for sysfs_create_group()···223223 &sensor_dev_attr_curr1_max_alarm.dev_attr.attr,224224225225 &sensor_dev_attr_power1_input.dev_attr.attr,226226- &sensor_dev_attr_power1_alarm.dev_attr.attr,227226228227 &sensor_dev_attr_in1_input.dev_attr.attr,229228 &sensor_dev_attr_in1_max_alarm.dev_attr.attr,230229 &sensor_dev_attr_in1_min_alarm.dev_attr.attr,231230232231 &sensor_dev_attr_in2_input.dev_attr.attr,232232+ &sensor_dev_attr_in2_min_alarm.dev_attr.attr,233233234234 NULL,235235};
+1-1
drivers/i2c/busses/i2c-intel-mid.c
···99999910001000 /* Initialize struct members */10011001 snprintf(mrst->adap.name, sizeof(mrst->adap.name),10021002- "MRST/Medfield I2C at %lx", start);10021002+ "Intel MID I2C at %lx", start);10031003 mrst->adap.owner = THIS_MODULE;10041004 mrst->adap.algo = &intel_mid_i2c_algorithm;10051005 mrst->adap.dev.parent = &dev->dev;
+3-9
drivers/idle/intel_idle.c
···273273274274 pr_debug(PREFIX "MWAIT substates: 0x%x\n", mwait_substates);275275276276- if (boot_cpu_has(X86_FEATURE_ARAT)) /* Always Reliable APIC Timer */277277- lapic_timer_reliable_states = 0xFFFFFFFF;278276279277 if (boot_cpu_data.x86 != 6) /* family 6 */280278 return -ENODEV;···284286 case 0x1F: /* Core i7 and i5 Processor - Nehalem */285287 case 0x2E: /* Nehalem-EX Xeon */286288 case 0x2F: /* Westmere-EX Xeon */287287- lapic_timer_reliable_states = (1 << 1); /* C1 */288288-289289 case 0x25: /* Westmere */290290 case 0x2C: /* Westmere */291291 cpuidle_state_table = nehalem_cstates;···291295292296 case 0x1C: /* 28 - Atom Processor */293297 case 0x26: /* 38 - Lincroft Atom Processor */294294- lapic_timer_reliable_states = (1 << 1); /* C1 */295298 cpuidle_state_table = atom_cstates;296299 break;297300···298303 case 0x2D: /* SNB Xeon */299304 cpuidle_state_table = snb_cstates;300305 break;301301-#ifdef FUTURE_USE302302- case 0x17: /* 23 - Core 2 Duo */303303- lapic_timer_reliable_states = (1 << 2) | (1 << 1); /* C2, C1 */304304-#endif305306306307 default:307308 pr_debug(PREFIX "does not run on family %d model %d\n",308309 boot_cpu_data.x86, boot_cpu_data.x86_model);309310 return -ENODEV;310311 }312312+313313+ if (boot_cpu_has(X86_FEATURE_ARAT)) /* Always Reliable APIC Timer */314314+ lapic_timer_reliable_states = 0xFFFFFFFF;311315312316 pr_debug(PREFIX "v" INTEL_IDLE_VERSION313317 " model 0x%X\n", boot_cpu_data.x86_model);
+59-46
drivers/infiniband/core/uverbs_cmd.c
···893893 return ret ? ret : in_len;894894}895895896896+static int copy_wc_to_user(void __user *dest, struct ib_wc *wc)897897+{898898+ struct ib_uverbs_wc tmp;899899+900900+ tmp.wr_id = wc->wr_id;901901+ tmp.status = wc->status;902902+ tmp.opcode = wc->opcode;903903+ tmp.vendor_err = wc->vendor_err;904904+ tmp.byte_len = wc->byte_len;905905+ tmp.ex.imm_data = (__u32 __force) wc->ex.imm_data;906906+ tmp.qp_num = wc->qp->qp_num;907907+ tmp.src_qp = wc->src_qp;908908+ tmp.wc_flags = wc->wc_flags;909909+ tmp.pkey_index = wc->pkey_index;910910+ tmp.slid = wc->slid;911911+ tmp.sl = wc->sl;912912+ tmp.dlid_path_bits = wc->dlid_path_bits;913913+ tmp.port_num = wc->port_num;914914+ tmp.reserved = 0;915915+916916+ if (copy_to_user(dest, &tmp, sizeof tmp))917917+ return -EFAULT;918918+919919+ return 0;920920+}921921+896922ssize_t ib_uverbs_poll_cq(struct ib_uverbs_file *file,897923 const char __user *buf, int in_len,898924 int out_len)899925{900926 struct ib_uverbs_poll_cq cmd;901901- struct ib_uverbs_poll_cq_resp *resp;927927+ struct ib_uverbs_poll_cq_resp resp;928928+ u8 __user *header_ptr;929929+ u8 __user *data_ptr;902930 struct ib_cq *cq;903903- struct ib_wc *wc;904904- int ret = 0;905905- int i;906906- int rsize;931931+ struct ib_wc wc;932932+ int ret;907933908934 if (copy_from_user(&cmd, buf, sizeof cmd))909935 return -EFAULT;910936911911- wc = kmalloc(cmd.ne * sizeof *wc, GFP_KERNEL);912912- if (!wc)913913- return -ENOMEM;914914-915915- rsize = sizeof *resp + cmd.ne * sizeof(struct ib_uverbs_wc);916916- resp = kmalloc(rsize, GFP_KERNEL);917917- if (!resp) {918918- ret = -ENOMEM;919919- goto out_wc;920920- }921921-922937 cq = idr_read_cq(cmd.cq_handle, file->ucontext, 0);923923- if (!cq) {924924- ret = -EINVAL;925925- goto out;938938+ if (!cq)939939+ return -EINVAL;940940+941941+ /* we copy a struct ib_uverbs_poll_cq_resp to user space */942942+ header_ptr = (void __user *)(unsigned long) cmd.response;943943+ data_ptr = header_ptr + sizeof resp;944944+945945+ memset(&resp, 0, sizeof resp);946946+ while (resp.count < cmd.ne) {947947+ ret = ib_poll_cq(cq, 1, &wc);948948+ if (ret < 0)949949+ goto out_put;950950+ if (!ret)951951+ break;952952+953953+ ret = copy_wc_to_user(data_ptr, &wc);954954+ if (ret)955955+ goto out_put;956956+957957+ data_ptr += sizeof(struct ib_uverbs_wc);958958+ ++resp.count;926959 }927960928928- resp->count = ib_poll_cq(cq, cmd.ne, wc);929929-930930- put_cq_read(cq);931931-932932- for (i = 0; i < resp->count; i++) {933933- resp->wc[i].wr_id = wc[i].wr_id;934934- resp->wc[i].status = wc[i].status;935935- resp->wc[i].opcode = wc[i].opcode;936936- resp->wc[i].vendor_err = wc[i].vendor_err;937937- resp->wc[i].byte_len = wc[i].byte_len;938938- resp->wc[i].ex.imm_data = (__u32 __force) wc[i].ex.imm_data;939939- resp->wc[i].qp_num = wc[i].qp->qp_num;940940- resp->wc[i].src_qp = wc[i].src_qp;941941- resp->wc[i].wc_flags = wc[i].wc_flags;942942- resp->wc[i].pkey_index = wc[i].pkey_index;943943- resp->wc[i].slid = wc[i].slid;944944- resp->wc[i].sl = wc[i].sl;945945- resp->wc[i].dlid_path_bits = wc[i].dlid_path_bits;946946- resp->wc[i].port_num = wc[i].port_num;947947- }948948-949949- if (copy_to_user((void __user *) (unsigned long) cmd.response, resp, rsize))961961+ if (copy_to_user(header_ptr, &resp, sizeof resp)) {950962 ret = -EFAULT;963963+ goto out_put;964964+ }951965952952-out:953953- kfree(resp);966966+ ret = in_len;954967955955-out_wc:956956- kfree(wc);957957- return ret ? ret : in_len;968968+out_put:969969+ put_cq_read(cq);970970+ return ret;958971}959972960973ssize_t ib_uverbs_req_notify_cq(struct ib_uverbs_file *file,
+65-62
drivers/input/evdev.c
···534534}535535#undef OLD_KEY_MAX536536537537-static int evdev_handle_get_keycode(struct input_dev *dev,538538- void __user *p, size_t size)537537+static int evdev_handle_get_keycode(struct input_dev *dev, void __user *p)538538+{539539+ struct input_keymap_entry ke = {540540+ .len = sizeof(unsigned int),541541+ .flags = 0,542542+ };543543+ int __user *ip = (int __user *)p;544544+ int error;545545+546546+ /* legacy case */547547+ if (copy_from_user(ke.scancode, p, sizeof(unsigned int)))548548+ return -EFAULT;549549+550550+ error = input_get_keycode(dev, &ke);551551+ if (error)552552+ return error;553553+554554+ if (put_user(ke.keycode, ip + 1))555555+ return -EFAULT;556556+557557+ return 0;558558+}559559+560560+static int evdev_handle_get_keycode_v2(struct input_dev *dev, void __user *p)539561{540562 struct input_keymap_entry ke;541563 int error;542564543543- memset(&ke, 0, sizeof(ke));565565+ if (copy_from_user(&ke, p, sizeof(ke)))566566+ return -EFAULT;544567545545- if (size == sizeof(unsigned int[2])) {546546- /* legacy case */547547- int __user *ip = (int __user *)p;568568+ error = input_get_keycode(dev, &ke);569569+ if (error)570570+ return error;548571549549- if (copy_from_user(ke.scancode, p, sizeof(unsigned int)))550550- return -EFAULT;572572+ if (copy_to_user(p, &ke, sizeof(ke)))573573+ return -EFAULT;551574552552- ke.len = sizeof(unsigned int);553553- ke.flags = 0;554554-555555- error = input_get_keycode(dev, &ke);556556- if (error)557557- return error;558558-559559- if (put_user(ke.keycode, ip + 1))560560- return -EFAULT;561561-562562- } else {563563- size = min(size, sizeof(ke));564564-565565- if (copy_from_user(&ke, p, size))566566- return -EFAULT;567567-568568- error = input_get_keycode(dev, &ke);569569- if (error)570570- return error;571571-572572- if (copy_to_user(p, &ke, size))573573- return -EFAULT;574574- }575575 return 0;576576}577577578578-static int evdev_handle_set_keycode(struct input_dev *dev,579579- void __user *p, size_t size)578578+static int evdev_handle_set_keycode(struct input_dev *dev, void __user *p)579579+{580580+ struct input_keymap_entry ke = {581581+ .len = sizeof(unsigned int),582582+ .flags = 0,583583+ };584584+ int __user *ip = (int __user *)p;585585+586586+ if (copy_from_user(ke.scancode, p, sizeof(unsigned int)))587587+ return -EFAULT;588588+589589+ if (get_user(ke.keycode, ip + 1))590590+ return -EFAULT;591591+592592+ return input_set_keycode(dev, &ke);593593+}594594+595595+static int evdev_handle_set_keycode_v2(struct input_dev *dev, void __user *p)580596{581597 struct input_keymap_entry ke;582598583583- memset(&ke, 0, sizeof(ke));599599+ if (copy_from_user(&ke, p, sizeof(ke)))600600+ return -EFAULT;584601585585- if (size == sizeof(unsigned int[2])) {586586- /* legacy case */587587- int __user *ip = (int __user *)p;588588-589589- if (copy_from_user(ke.scancode, p, sizeof(unsigned int)))590590- return -EFAULT;591591-592592- if (get_user(ke.keycode, ip + 1))593593- return -EFAULT;594594-595595- ke.len = sizeof(unsigned int);596596- ke.flags = 0;597597-598598- } else {599599- size = min(size, sizeof(ke));600600-601601- if (copy_from_user(&ke, p, size))602602- return -EFAULT;603603-604604- if (ke.len > sizeof(ke.scancode))605605- return -EINVAL;606606- }602602+ if (ke.len > sizeof(ke.scancode))603603+ return -EINVAL;607604608605 return input_set_keycode(dev, &ke);609606}···666669 return evdev_grab(evdev, client);667670 else668671 return evdev_ungrab(evdev, client);672672+673673+ case EVIOCGKEYCODE:674674+ return evdev_handle_get_keycode(dev, p);675675+676676+ case EVIOCSKEYCODE:677677+ return evdev_handle_set_keycode(dev, p);678678+679679+ case EVIOCGKEYCODE_V2:680680+ return evdev_handle_get_keycode_v2(dev, p);681681+682682+ case EVIOCSKEYCODE_V2:683683+ return evdev_handle_set_keycode_v2(dev, p);669684 }670685671686 size = _IOC_SIZE(cmd);···717708 return -EFAULT;718709719710 return error;720720-721721- case EVIOC_MASK_SIZE(EVIOCGKEYCODE):722722- return evdev_handle_get_keycode(dev, p, size);723723-724724- case EVIOC_MASK_SIZE(EVIOCSKEYCODE):725725- return evdev_handle_set_keycode(dev, p, size);726711 }727712728713 /* Multi-number variable-length handlers */
···785785 }786786}787787788788-struct uvc_control *uvc_find_control(struct uvc_video_chain *chain,788788+static struct uvc_control *uvc_find_control(struct uvc_video_chain *chain,789789 __u32 v4l2_id, struct uvc_control_mapping **mapping)790790{791791 struct uvc_control *ctrl = NULL;···938938 if (ctrl->info.flags & UVC_CONTROL_GET_RES)939939 v4l2_ctrl->step = mapping->get(mapping, UVC_GET_RES,940940 uvc_ctrl_data(ctrl, UVC_CTRL_DATA_RES));941941+942942+done:943943+ mutex_unlock(&chain->ctrl_mutex);944944+ return ret;945945+}946946+947947+/*948948+ * Mapping V4L2 controls to UVC controls can be straighforward if done well.949949+ * Most of the UVC controls exist in V4L2, and can be mapped directly. Some950950+ * must be grouped (for instance the Red Balance, Blue Balance and Do White951951+ * Balance V4L2 controls use the White Balance Component UVC control) or952952+ * otherwise translated. The approach we take here is to use a translation953953+ * table for the controls that can be mapped directly, and handle the others954954+ * manually.955955+ */956956+int uvc_query_v4l2_menu(struct uvc_video_chain *chain,957957+ struct v4l2_querymenu *query_menu)958958+{959959+ struct uvc_menu_info *menu_info;960960+ struct uvc_control_mapping *mapping;961961+ struct uvc_control *ctrl;962962+ u32 index = query_menu->index;963963+ u32 id = query_menu->id;964964+ int ret;965965+966966+ memset(query_menu, 0, sizeof(*query_menu));967967+ query_menu->id = id;968968+ query_menu->index = index;969969+970970+ ret = mutex_lock_interruptible(&chain->ctrl_mutex);971971+ if (ret < 0)972972+ return -ERESTARTSYS;973973+974974+ ctrl = uvc_find_control(chain, query_menu->id, &mapping);975975+ if (ctrl == NULL || mapping->v4l2_type != V4L2_CTRL_TYPE_MENU) {976976+ ret = -EINVAL;977977+ goto done;978978+ }979979+980980+ if (query_menu->index >= mapping->menu_count) {981981+ ret = -EINVAL;982982+ goto done;983983+ }984984+985985+ menu_info = &mapping->menu_info[query_menu->index];986986+ strlcpy(query_menu->name, menu_info->name, sizeof query_menu->name);941987942988done:943989 mutex_unlock(&chain->ctrl_mutex);
+110-23
drivers/media/video/uvc/uvc_queue.c
···9090}91919292/*9393+ * Free the video buffers.9494+ *9595+ * This function must be called with the queue lock held.9696+ */9797+static int __uvc_free_buffers(struct uvc_video_queue *queue)9898+{9999+ unsigned int i;100100+101101+ for (i = 0; i < queue->count; ++i) {102102+ if (queue->buffer[i].vma_use_count != 0)103103+ return -EBUSY;104104+ }105105+106106+ if (queue->count) {107107+ vfree(queue->mem);108108+ queue->count = 0;109109+ }110110+111111+ return 0;112112+}113113+114114+int uvc_free_buffers(struct uvc_video_queue *queue)115115+{116116+ int ret;117117+118118+ mutex_lock(&queue->mutex);119119+ ret = __uvc_free_buffers(queue);120120+ mutex_unlock(&queue->mutex);121121+122122+ return ret;123123+}124124+125125+/*93126 * Allocate the video buffers.94127 *95128 * Pages are reserved to make sure they will not be swapped, as they will be···143110144111 mutex_lock(&queue->mutex);145112146146- if ((ret = uvc_free_buffers(queue)) < 0)113113+ if ((ret = __uvc_free_buffers(queue)) < 0)147114 goto done;148115149116 /* Bail out if no buffers should be allocated. */···182149done:183150 mutex_unlock(&queue->mutex);184151 return ret;185185-}186186-187187-/*188188- * Free the video buffers.189189- *190190- * This function must be called with the queue lock held.191191- */192192-int uvc_free_buffers(struct uvc_video_queue *queue)193193-{194194- unsigned int i;195195-196196- for (i = 0; i < queue->count; ++i) {197197- if (queue->buffer[i].vma_use_count != 0)198198- return -EBUSY;199199- }200200-201201- if (queue->count) {202202- vfree(queue->mem);203203- queue->count = 0;204204- }205205-206206- return 0;207152}208153209154/*···373362374363 list_del(&buf->stream);375364 __uvc_query_buffer(buf, v4l2_buf);365365+366366+done:367367+ mutex_unlock(&queue->mutex);368368+ return ret;369369+}370370+371371+/*372372+ * VMA operations.373373+ */374374+static void uvc_vm_open(struct vm_area_struct *vma)375375+{376376+ struct uvc_buffer *buffer = vma->vm_private_data;377377+ buffer->vma_use_count++;378378+}379379+380380+static void uvc_vm_close(struct vm_area_struct *vma)381381+{382382+ struct uvc_buffer *buffer = vma->vm_private_data;383383+ buffer->vma_use_count--;384384+}385385+386386+static const struct vm_operations_struct uvc_vm_ops = {387387+ .open = uvc_vm_open,388388+ .close = uvc_vm_close,389389+};390390+391391+/*392392+ * Memory-map a video buffer.393393+ *394394+ * This function implements video buffers memory mapping and is intended to be395395+ * used by the device mmap handler.396396+ */397397+int uvc_queue_mmap(struct uvc_video_queue *queue, struct vm_area_struct *vma)398398+{399399+ struct uvc_buffer *uninitialized_var(buffer);400400+ struct page *page;401401+ unsigned long addr, start, size;402402+ unsigned int i;403403+ int ret = 0;404404+405405+ start = vma->vm_start;406406+ size = vma->vm_end - vma->vm_start;407407+408408+ mutex_lock(&queue->mutex);409409+410410+ for (i = 0; i < queue->count; ++i) {411411+ buffer = &queue->buffer[i];412412+ if ((buffer->buf.m.offset >> PAGE_SHIFT) == vma->vm_pgoff)413413+ break;414414+ }415415+416416+ if (i == queue->count || size != queue->buf_size) {417417+ ret = -EINVAL;418418+ goto done;419419+ }420420+421421+ /*422422+ * VM_IO marks the area as being an mmaped region for I/O to a423423+ * device. It also prevents the region from being core dumped.424424+ */425425+ vma->vm_flags |= VM_IO;426426+427427+ addr = (unsigned long)queue->mem + buffer->buf.m.offset;428428+ while (size > 0) {429429+ page = vmalloc_to_page((void *)addr);430430+ if ((ret = vm_insert_page(vma, start, page)) < 0)431431+ goto done;432432+433433+ start += PAGE_SIZE;434434+ addr += PAGE_SIZE;435435+ size -= PAGE_SIZE;436436+ }437437+438438+ vma->vm_ops = &uvc_vm_ops;439439+ vma->vm_private_data = buffer;440440+ uvc_vm_open(vma);376441377442done:378443 mutex_unlock(&queue->mutex);
+58-127
drivers/media/video/uvc/uvc_v4l2.c
···101101 */102102103103/*104104- * Mapping V4L2 controls to UVC controls can be straighforward if done well.105105- * Most of the UVC controls exist in V4L2, and can be mapped directly. Some106106- * must be grouped (for instance the Red Balance, Blue Balance and Do White107107- * Balance V4L2 controls use the White Balance Component UVC control) or108108- * otherwise translated. The approach we take here is to use a translation109109- * table for the controls that can be mapped directly, and handle the others110110- * manually.111111- */112112-static int uvc_v4l2_query_menu(struct uvc_video_chain *chain,113113- struct v4l2_querymenu *query_menu)114114-{115115- struct uvc_menu_info *menu_info;116116- struct uvc_control_mapping *mapping;117117- struct uvc_control *ctrl;118118- u32 index = query_menu->index;119119- u32 id = query_menu->id;120120-121121- ctrl = uvc_find_control(chain, query_menu->id, &mapping);122122- if (ctrl == NULL || mapping->v4l2_type != V4L2_CTRL_TYPE_MENU)123123- return -EINVAL;124124-125125- if (query_menu->index >= mapping->menu_count)126126- return -EINVAL;127127-128128- memset(query_menu, 0, sizeof(*query_menu));129129- query_menu->id = id;130130- query_menu->index = index;131131-132132- menu_info = &mapping->menu_info[query_menu->index];133133- strlcpy(query_menu->name, menu_info->name, sizeof query_menu->name);134134- return 0;135135-}136136-137137-/*138104 * Find the frame interval closest to the requested frame interval for the139105 * given frame format and size. This should be done by the device as part of140106 * the Video Probe and Commit negotiation, but some hardware don't implement···226260 * developers test their webcams with the Linux driver as well as with227261 * the Windows driver).228262 */263263+ mutex_lock(&stream->mutex);229264 if (stream->dev->quirks & UVC_QUIRK_PROBE_EXTRAFIELDS)230265 probe->dwMaxVideoFrameSize =231266 stream->ctrl.dwMaxVideoFrameSize;232267233268 /* Probe the device. */234269 ret = uvc_probe_video(stream, probe);270270+ mutex_unlock(&stream->mutex);235271 if (ret < 0)236272 goto done;237273···257289static int uvc_v4l2_get_format(struct uvc_streaming *stream,258290 struct v4l2_format *fmt)259291{260260- struct uvc_format *format = stream->cur_format;261261- struct uvc_frame *frame = stream->cur_frame;292292+ struct uvc_format *format;293293+ struct uvc_frame *frame;294294+ int ret = 0;262295263296 if (fmt->type != stream->type)264297 return -EINVAL;265298266266- if (format == NULL || frame == NULL)267267- return -EINVAL;299299+ mutex_lock(&stream->mutex);300300+ format = stream->cur_format;301301+ frame = stream->cur_frame;302302+303303+ if (format == NULL || frame == NULL) {304304+ ret = -EINVAL;305305+ goto done;306306+ }268307269308 fmt->fmt.pix.pixelformat = format->fcc;270309 fmt->fmt.pix.width = frame->wWidth;···282307 fmt->fmt.pix.colorspace = format->colorspace;283308 fmt->fmt.pix.priv = 0;284309285285- return 0;310310+done:311311+ mutex_unlock(&stream->mutex);312312+ return ret;286313}287314288315static int uvc_v4l2_set_format(struct uvc_streaming *stream,···298321 if (fmt->type != stream->type)299322 return -EINVAL;300323301301- if (uvc_queue_allocated(&stream->queue))302302- return -EBUSY;303303-304324 ret = uvc_v4l2_try_format(stream, fmt, &probe, &format, &frame);305325 if (ret < 0)306326 return ret;327327+328328+ mutex_lock(&stream->mutex);329329+330330+ if (uvc_queue_allocated(&stream->queue)) {331331+ ret = -EBUSY;332332+ goto done;333333+ }307334308335 memcpy(&stream->ctrl, &probe, sizeof probe);309336 stream->cur_format = format;310337 stream->cur_frame = frame;311338312312- return 0;339339+done:340340+ mutex_unlock(&stream->mutex);341341+ return ret;313342}314343315344static int uvc_v4l2_get_streamparm(struct uvc_streaming *stream,···326343 if (parm->type != stream->type)327344 return -EINVAL;328345346346+ mutex_lock(&stream->mutex);329347 numerator = stream->ctrl.dwFrameInterval;348348+ mutex_unlock(&stream->mutex);349349+330350 denominator = 10000000;331351 uvc_simplify_fraction(&numerator, &denominator, 8, 333);332352···356370static int uvc_v4l2_set_streamparm(struct uvc_streaming *stream,357371 struct v4l2_streamparm *parm)358372{359359- struct uvc_frame *frame = stream->cur_frame;360373 struct uvc_streaming_control probe;361374 struct v4l2_fract timeperframe;362375 uint32_t interval;···364379 if (parm->type != stream->type)365380 return -EINVAL;366381367367- if (uvc_queue_streaming(&stream->queue))368368- return -EBUSY;369369-370382 if (parm->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)371383 timeperframe = parm->parm.capture.timeperframe;372384 else373385 timeperframe = parm->parm.output.timeperframe;374386375375- memcpy(&probe, &stream->ctrl, sizeof probe);376387 interval = uvc_fraction_to_interval(timeperframe.numerator,377388 timeperframe.denominator);378378-379389 uvc_trace(UVC_TRACE_FORMAT, "Setting frame interval to %u/%u (%u).\n",380390 timeperframe.numerator, timeperframe.denominator, interval);381381- probe.dwFrameInterval = uvc_try_frame_interval(frame, interval);391391+392392+ mutex_lock(&stream->mutex);393393+394394+ if (uvc_queue_streaming(&stream->queue)) {395395+ mutex_unlock(&stream->mutex);396396+ return -EBUSY;397397+ }398398+399399+ memcpy(&probe, &stream->ctrl, sizeof probe);400400+ probe.dwFrameInterval =401401+ uvc_try_frame_interval(stream->cur_frame, interval);382402383403 /* Probe the device with the new settings. */384404 ret = uvc_probe_video(stream, &probe);385385- if (ret < 0)405405+ if (ret < 0) {406406+ mutex_unlock(&stream->mutex);386407 return ret;408408+ }387409388410 memcpy(&stream->ctrl, &probe, sizeof probe);411411+ mutex_unlock(&stream->mutex);389412390413 /* Return the actual frame period. */391414 timeperframe.numerator = probe.dwFrameInterval;···521528 if (uvc_has_privileges(handle)) {522529 uvc_video_enable(stream, 0);523530524524- mutex_lock(&stream->queue.mutex);525531 if (uvc_free_buffers(&stream->queue) < 0)526532 uvc_printk(KERN_ERR, "uvc_v4l2_release: Unable to "527533 "free buffers.\n");528528- mutex_unlock(&stream->queue.mutex);529534 }530535531536 /* Release the file handle. */···615624 }616625617626 case VIDIOC_QUERYMENU:618618- return uvc_v4l2_query_menu(chain, arg);627627+ return uvc_query_v4l2_menu(chain, arg);619628620629 case VIDIOC_G_EXT_CTRLS:621630 {···896905 case VIDIOC_CROPCAP:897906 {898907 struct v4l2_cropcap *ccap = arg;899899- struct uvc_frame *frame = stream->cur_frame;900908901909 if (ccap->type != stream->type)902910 return -EINVAL;903911904912 ccap->bounds.left = 0;905913 ccap->bounds.top = 0;906906- ccap->bounds.width = frame->wWidth;907907- ccap->bounds.height = frame->wHeight;914914+915915+ mutex_lock(&stream->mutex);916916+ ccap->bounds.width = stream->cur_frame->wWidth;917917+ ccap->bounds.height = stream->cur_frame->wHeight;918918+ mutex_unlock(&stream->mutex);908919909920 ccap->defrect = ccap->bounds;910921···923930 case VIDIOC_REQBUFS:924931 {925932 struct v4l2_requestbuffers *rb = arg;926926- unsigned int bufsize =927927- stream->ctrl.dwMaxVideoFrameSize;928933929934 if (rb->type != stream->type ||930935 rb->memory != V4L2_MEMORY_MMAP)···931940 if ((ret = uvc_acquire_privileges(handle)) < 0)932941 return ret;933942934934- ret = uvc_alloc_buffers(&stream->queue, rb->count, bufsize);943943+ mutex_lock(&stream->mutex);944944+ ret = uvc_alloc_buffers(&stream->queue, rb->count,945945+ stream->ctrl.dwMaxVideoFrameSize);946946+ mutex_unlock(&stream->mutex);935947 if (ret < 0)936948 return ret;937949···982988 if (!uvc_has_privileges(handle))983989 return -EBUSY;984990991991+ mutex_lock(&stream->mutex);985992 ret = uvc_video_enable(stream, 1);993993+ mutex_unlock(&stream->mutex);986994 if (ret < 0)987995 return ret;988996 break;···10641068 return -EINVAL;10651069}1066107010671067-/*10681068- * VMA operations.10691069- */10701070-static void uvc_vm_open(struct vm_area_struct *vma)10711071-{10721072- struct uvc_buffer *buffer = vma->vm_private_data;10731073- buffer->vma_use_count++;10741074-}10751075-10761076-static void uvc_vm_close(struct vm_area_struct *vma)10771077-{10781078- struct uvc_buffer *buffer = vma->vm_private_data;10791079- buffer->vma_use_count--;10801080-}10811081-10821082-static const struct vm_operations_struct uvc_vm_ops = {10831083- .open = uvc_vm_open,10841084- .close = uvc_vm_close,10851085-};10861086-10871071static int uvc_v4l2_mmap(struct file *file, struct vm_area_struct *vma)10881072{10891073 struct uvc_fh *handle = file->private_data;10901074 struct uvc_streaming *stream = handle->stream;10911091- struct uvc_video_queue *queue = &stream->queue;10921092- struct uvc_buffer *uninitialized_var(buffer);10931093- struct page *page;10941094- unsigned long addr, start, size;10951095- unsigned int i;10961096- int ret = 0;1097107510981076 uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_mmap\n");1099107711001100- start = vma->vm_start;11011101- size = vma->vm_end - vma->vm_start;11021102-11031103- mutex_lock(&queue->mutex);11041104-11051105- for (i = 0; i < queue->count; ++i) {11061106- buffer = &queue->buffer[i];11071107- if ((buffer->buf.m.offset >> PAGE_SHIFT) == vma->vm_pgoff)11081108- break;11091109- }11101110-11111111- if (i == queue->count || size != queue->buf_size) {11121112- ret = -EINVAL;11131113- goto done;11141114- }11151115-11161116- /*11171117- * VM_IO marks the area as being an mmaped region for I/O to a11181118- * device. It also prevents the region from being core dumped.11191119- */11201120- vma->vm_flags |= VM_IO;11211121-11221122- addr = (unsigned long)queue->mem + buffer->buf.m.offset;11231123- while (size > 0) {11241124- page = vmalloc_to_page((void *)addr);11251125- if ((ret = vm_insert_page(vma, start, page)) < 0)11261126- goto done;11271127-11281128- start += PAGE_SIZE;11291129- addr += PAGE_SIZE;11301130- size -= PAGE_SIZE;11311131- }11321132-11331133- vma->vm_ops = &uvc_vm_ops;11341134- vma->vm_private_data = buffer;11351135- uvc_vm_open(vma);11361136-11371137-done:11381138- mutex_unlock(&queue->mutex);11391139- return ret;10781078+ return uvc_queue_mmap(&stream->queue, vma);11401079}1141108011421081static unsigned int uvc_v4l2_poll(struct file *file, poll_table *wait)···10881157 .owner = THIS_MODULE,10891158 .open = uvc_v4l2_open,10901159 .release = uvc_v4l2_release,10911091- .ioctl = uvc_v4l2_ioctl,11601160+ .unlocked_ioctl = uvc_v4l2_ioctl,10921161 .read = uvc_v4l2_read,10931162 .mmap = uvc_v4l2_mmap,10941163 .poll = uvc_v4l2_poll,
-3
drivers/media/video/uvc/uvc_video.c
···293293 unsigned int i;294294 int ret;295295296296- mutex_lock(&stream->mutex);297297-298296 /* Perform probing. The device should adjust the requested values299297 * according to its capabilities. However, some devices, namely the300298 * first generation UVC Logitech webcams, don't implement the Video···344346 }345347346348done:347347- mutex_unlock(&stream->mutex);348349 return ret;349350}350351
+7-3
drivers/media/video/uvc/uvcvideo.h
···436436 struct uvc_streaming_control ctrl;437437 struct uvc_format *cur_format;438438 struct uvc_frame *cur_frame;439439-439439+ /* Protect access to ctrl, cur_format, cur_frame and hardware video440440+ * probe control.441441+ */440442 struct mutex mutex;441443442444 unsigned int frozen : 1;···576574extern void uvc_queue_cancel(struct uvc_video_queue *queue, int disconnect);577575extern struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue,578576 struct uvc_buffer *buf);577577+extern int uvc_queue_mmap(struct uvc_video_queue *queue,578578+ struct vm_area_struct *vma);579579extern unsigned int uvc_queue_poll(struct uvc_video_queue *queue,580580 struct file *file, poll_table *wait);581581extern int uvc_queue_allocated(struct uvc_video_queue *queue);···610606extern int uvc_status_resume(struct uvc_device *dev);611607612608/* Controls */613613-extern struct uvc_control *uvc_find_control(struct uvc_video_chain *chain,614614- __u32 v4l2_id, struct uvc_control_mapping **mapping);615609extern int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,616610 struct v4l2_queryctrl *v4l2_ctrl);611611+extern int uvc_query_v4l2_menu(struct uvc_video_chain *chain,612612+ struct v4l2_querymenu *query_menu);617613618614extern int uvc_ctrl_add_mapping(struct uvc_video_chain *chain,619615 const struct uvc_control_mapping *mapping);
+51-18
drivers/media/video/v4l2-dev.c
···186186 size_t sz, loff_t *off)187187{188188 struct video_device *vdev = video_devdata(filp);189189- int ret = -EIO;189189+ int ret = -ENODEV;190190191191 if (!vdev->fops->read)192192 return -EINVAL;193193- if (vdev->lock)194194- mutex_lock(vdev->lock);193193+ if (vdev->lock && mutex_lock_interruptible(vdev->lock))194194+ return -ERESTARTSYS;195195 if (video_is_registered(vdev))196196 ret = vdev->fops->read(filp, buf, sz, off);197197 if (vdev->lock)···203203 size_t sz, loff_t *off)204204{205205 struct video_device *vdev = video_devdata(filp);206206- int ret = -EIO;206206+ int ret = -ENODEV;207207208208 if (!vdev->fops->write)209209 return -EINVAL;210210- if (vdev->lock)211211- mutex_lock(vdev->lock);210210+ if (vdev->lock && mutex_lock_interruptible(vdev->lock))211211+ return -ERESTARTSYS;212212 if (video_is_registered(vdev))213213 ret = vdev->fops->write(filp, buf, sz, off);214214 if (vdev->lock)···219219static unsigned int v4l2_poll(struct file *filp, struct poll_table_struct *poll)220220{221221 struct video_device *vdev = video_devdata(filp);222222- int ret = DEFAULT_POLLMASK;222222+ int ret = POLLERR | POLLHUP;223223224224 if (!vdev->fops->poll)225225- return ret;225225+ return DEFAULT_POLLMASK;226226 if (vdev->lock)227227 mutex_lock(vdev->lock);228228 if (video_is_registered(vdev))···238238 int ret = -ENODEV;239239240240 if (vdev->fops->unlocked_ioctl) {241241- if (vdev->lock)242242- mutex_lock(vdev->lock);241241+ if (vdev->lock && mutex_lock_interruptible(vdev->lock))242242+ return -ERESTARTSYS;243243 if (video_is_registered(vdev))244244 ret = vdev->fops->unlocked_ioctl(filp, cmd, arg);245245 if (vdev->lock)246246 mutex_unlock(vdev->lock);247247 } else if (vdev->fops->ioctl) {248248- /* TODO: convert all drivers to unlocked_ioctl */248248+ /* This code path is a replacement for the BKL. It is a major249249+ * hack but it will have to do for those drivers that are not250250+ * yet converted to use unlocked_ioctl.251251+ *252252+ * There are two options: if the driver implements struct253253+ * v4l2_device, then the lock defined there is used to254254+ * serialize the ioctls. Otherwise the v4l2 core lock defined255255+ * below is used. This lock is really bad since it serializes256256+ * completely independent devices.257257+ *258258+ * Both variants suffer from the same problem: if the driver259259+ * sleeps, then it blocks all ioctls since the lock is still260260+ * held. This is very common for VIDIOC_DQBUF since that261261+ * normally waits for a frame to arrive. As a result any other262262+ * ioctl calls will proceed very, very slowly since each call263263+ * will have to wait for the VIDIOC_QBUF to finish. Things that264264+ * should take 0.01s may now take 10-20 seconds.265265+ *266266+ * The workaround is to *not* take the lock for VIDIOC_DQBUF.267267+ * This actually works OK for videobuf-based drivers, since268268+ * videobuf will take its own internal lock.269269+ */249270 static DEFINE_MUTEX(v4l2_ioctl_mutex);271271+ struct mutex *m = vdev->v4l2_dev ?272272+ &vdev->v4l2_dev->ioctl_lock : &v4l2_ioctl_mutex;250273251251- mutex_lock(&v4l2_ioctl_mutex);274274+ if (cmd != VIDIOC_DQBUF && mutex_lock_interruptible(m))275275+ return -ERESTARTSYS;252276 if (video_is_registered(vdev))253277 ret = vdev->fops->ioctl(filp, cmd, arg);254254- mutex_unlock(&v4l2_ioctl_mutex);278278+ if (cmd != VIDIOC_DQBUF)279279+ mutex_unlock(m);255280 } else256281 ret = -ENOTTY;257282···290265291266 if (!vdev->fops->mmap)292267 return ret;293293- if (vdev->lock)294294- mutex_lock(vdev->lock);268268+ if (vdev->lock && mutex_lock_interruptible(vdev->lock))269269+ return -ERESTARTSYS;295270 if (video_is_registered(vdev))296271 ret = vdev->fops->mmap(filp, vm);297272 if (vdev->lock)···309284 mutex_lock(&videodev_lock);310285 vdev = video_devdata(filp);311286 /* return ENODEV if the video device has already been removed. */312312- if (vdev == NULL) {287287+ if (vdev == NULL || !video_is_registered(vdev)) {313288 mutex_unlock(&videodev_lock);314289 return -ENODEV;315290 }···317292 video_get(vdev);318293 mutex_unlock(&videodev_lock);319294 if (vdev->fops->open) {320320- if (vdev->lock)321321- mutex_lock(vdev->lock);295295+ if (vdev->lock && mutex_lock_interruptible(vdev->lock)) {296296+ ret = -ERESTARTSYS;297297+ goto err;298298+ }322299 if (video_is_registered(vdev))323300 ret = vdev->fops->open(filp);324301 else···329302 mutex_unlock(vdev->lock);330303 }331304305305+err:332306 /* decrease the refcount in case of an error */333307 if (ret)334308 video_put(vdev);···624596 if (!vdev || !video_is_registered(vdev))625597 return;626598599599+ mutex_lock(&videodev_lock);600600+ /* This must be in a critical section to prevent a race with v4l2_open.601601+ * Once this bit has been cleared video_get may never be called again.602602+ */627603 clear_bit(V4L2_FL_REGISTERED, &vdev->flags);604604+ mutex_unlock(&videodev_lock);628605 device_unregister(&vdev->dev);629606}630607EXPORT_SYMBOL(video_unregister_device);
+1
drivers/media/video/v4l2-device.c
···35353636 INIT_LIST_HEAD(&v4l2_dev->subdevs);3737 spin_lock_init(&v4l2_dev->lock);3838+ mutex_init(&v4l2_dev->ioctl_lock);3839 v4l2_dev->dev = dev;3940 if (dev == NULL) {4041 /* If dev == NULL, then name must be filled in by the caller */
···77 * it under the terms of the GNU General Public License version 2 as88 * published by the Free Software Foundation.99 */1010-#define CONFIG_MTD_NAND_OMAP_HWECC11101211#include <linux/platform_device.h>1312#include <linux/dma-mapping.h>
+5-6
drivers/net/b44.c
···381381 __b44_set_flow_ctrl(bp, pause_enab);382382}383383384384-#ifdef SSB_DRIVER_MIPS385385-extern char *nvram_get(char *name);384384+#ifdef CONFIG_BCM47XX385385+#include <asm/mach-bcm47xx/nvram.h>386386static void b44_wap54g10_workaround(struct b44 *bp)387387{388388- const char *str;388388+ char buf[20];389389 u32 val;390390 int err;391391···394394 * see https://dev.openwrt.org/ticket/146395395 * check and reset bit "isolate"396396 */397397- str = nvram_get("boardnum");398398- if (!str)397397+ if (nvram_getenv("boardnum", buf, sizeof(buf)) < 0)399398 return;400400- if (simple_strtoul(str, NULL, 0) == 2) {399399+ if (simple_strtoul(buf, NULL, 0) == 2) {401400 err = __b44_readphy(bp, 0, MII_BMCR, &val);402401 if (err)403402 goto error;
···838838/****************************************************************************839839* SRC initializations840840****************************************************************************/841841-841841+#ifdef BCM_CNIC842842/* called during init func stage */843843static void bnx2x_src_init_t2(struct bnx2x *bp, struct src_ent *t2,844844 dma_addr_t t2_mapping, int src_cid_count)···862862 U64_HI((u64)t2_mapping +863863 (src_cid_count-1) * sizeof(struct src_ent)));864864}865865-865865+#endif866866#endif /* BNX2X_INIT_OPS_H */
+6-13
drivers/net/bonding/bond_main.c
···171171/*----------------------------- Global variables ----------------------------*/172172173173#ifdef CONFIG_NET_POLL_CONTROLLER174174-cpumask_var_t netpoll_block_tx;174174+atomic_t netpoll_block_tx = ATOMIC_INIT(0);175175#endif176176177177static const char * const version =···1576157615771577 /* If this is the first slave, then we need to set the master's hardware15781578 * address to be the same as the slave's. */15791579- if (bond->slave_cnt == 0)15791579+ if (is_zero_ether_addr(bond->dev->dev_addr))15801580 memcpy(bond->dev->dev_addr, slave_dev->dev_addr,15811581 slave_dev->addr_len);15821582···52995299 if (res)53005300 goto out;5301530153025302-#ifdef CONFIG_NET_POLL_CONTROLLER53035303- if (!alloc_cpumask_var(&netpoll_block_tx, GFP_KERNEL)) {53045304- res = -ENOMEM;53055305- goto out;53065306- }53075307-#endif53085308-53095302 res = register_pernet_subsys(&bond_net_ops);53105303 if (res)53115304 goto out;···53275334 rtnl_link_unregister(&bond_link_ops);53285335err_link:53295336 unregister_pernet_subsys(&bond_net_ops);53305330-#ifdef CONFIG_NET_POLL_CONTROLLER53315331- free_cpumask_var(netpoll_block_tx);53325332-#endif53335337 goto out;5334533853355339}···53435353 unregister_pernet_subsys(&bond_net_ops);5344535453455355#ifdef CONFIG_NET_POLL_CONTROLLER53465346- free_cpumask_var(netpoll_block_tx);53565356+ /*53575357+ * Make sure we don't have an imbalance on our netpoll blocking53585358+ */53595359+ WARN_ON(atomic_read(&netpoll_block_tx));53475360#endif53485361}53495362
···22692269{22702270 struct sge *s = &adapter->sge;22712271 int q10g, n10g, qidx, pidx, qs;22722272+ size_t iqe_size;2272227322732274 /*22742275 * We should not be called till we know how many Queue Sets we can···23142313 s->ethqsets = qidx;2315231423162315 /*23162316+ * The Ingress Queue Entry Size for our various Response Queues needs23172317+ * to be big enough to accommodate the largest message we can receive23182318+ * from the chip/firmware; which is 64 bytes ...23192319+ */23202320+ iqe_size = 64;23212321+23222322+ /*23172323 * Set up default Queue Set parameters ... Start off with the23182324 * shortest interrupt holdoff timer.23192325 */···23282320 struct sge_eth_rxq *rxq = &s->ethrxq[qs];23292321 struct sge_eth_txq *txq = &s->ethtxq[qs];2330232223312331- init_rspq(&rxq->rspq, 0, 0, 1024, L1_CACHE_BYTES);23232323+ init_rspq(&rxq->rspq, 0, 0, 1024, iqe_size);23322324 rxq->fl.size = 72;23332325 txq->q.size = 1024;23342326 }···23372329 * The firmware event queue is used for link state changes and23382330 * notifications of TX DMA completions.23392331 */23402340- init_rspq(&s->fw_evtq, SGE_TIMER_RSTRT_CNTR, 0, 512,23412341- L1_CACHE_BYTES);23322332+ init_rspq(&s->fw_evtq, SGE_TIMER_RSTRT_CNTR, 0, 512, iqe_size);2342233323432334 /*23442335 * The forwarded interrupt queue is used when we're in MSI interrupt···23532346 * any time ...23542347 */23552348 init_rspq(&s->intrq, SGE_TIMER_RSTRT_CNTR, 0, MSIX_ENTRIES + 1,23562356- L1_CACHE_BYTES);23492349+ iqe_size);23572350}2358235123592352/*
···6464config ICPLUS_PHY6565 tristate "Drivers for ICPlus PHYs"6666 ---help---6767- Currently supports the IP175C PHY.6767+ Currently supports the IP175C and IP1001 PHYs.68686969config REALTEK_PHY7070 tristate "Drivers for Realtek PHYs"
+54-5
drivers/net/phy/icplus.c
···3030#include <asm/irq.h>3131#include <asm/uaccess.h>32323333-MODULE_DESCRIPTION("ICPlus IP175C PHY driver");3333+MODULE_DESCRIPTION("ICPlus IP175C/IC1001 PHY drivers");3434MODULE_AUTHOR("Michael Barkowski");3535MODULE_LICENSE("GPL");3636···8989 return 0;9090}91919292+static int ip1001_config_init(struct phy_device *phydev)9393+{9494+ int err, value;9595+9696+ /* Software Reset PHY */9797+ value = phy_read(phydev, MII_BMCR);9898+ value |= BMCR_RESET;9999+ err = phy_write(phydev, MII_BMCR, value);100100+ if (err < 0)101101+ return err;102102+103103+ do {104104+ value = phy_read(phydev, MII_BMCR);105105+ } while (value & BMCR_RESET);106106+107107+ /* Additional delay (2ns) used to adjust RX clock phase108108+ * at GMII/ RGMII interface */109109+ value = phy_read(phydev, 16);110110+ value |= 0x3;111111+112112+ err = phy_write(phydev, 16, value);113113+ if (err < 0)114114+ return err;115115+116116+ return err;117117+}118118+92119static int ip175c_read_status(struct phy_device *phydev)93120{94121 if (phydev->addr == 4) /* WAN port */···148121 .driver = { .owner = THIS_MODULE,},149122};150123151151-static int __init ip175c_init(void)124124+static struct phy_driver ip1001_driver = {125125+ .phy_id = 0x02430d90,126126+ .name = "ICPlus IP1001",127127+ .phy_id_mask = 0x0ffffff0,128128+ .features = PHY_GBIT_FEATURES | SUPPORTED_Pause |129129+ SUPPORTED_Asym_Pause,130130+ .config_init = &ip1001_config_init,131131+ .config_aneg = &genphy_config_aneg,132132+ .read_status = &genphy_read_status,133133+ .suspend = genphy_suspend,134134+ .resume = genphy_resume,135135+ .driver = { .owner = THIS_MODULE,},136136+};137137+138138+static int __init icplus_init(void)152139{140140+ int ret = 0;141141+142142+ ret = phy_driver_register(&ip1001_driver);143143+ if (ret < 0)144144+ return -ENODEV;145145+153146 return phy_driver_register(&ip175c_driver);154147}155148156156-static void __exit ip175c_exit(void)149149+static void __exit icplus_exit(void)157150{151151+ phy_driver_unregister(&ip1001_driver);158152 phy_driver_unregister(&ip175c_driver);159153}160154161161-module_init(ip175c_init);162162-module_exit(ip175c_exit);155155+module_init(icplus_init);156156+module_exit(icplus_exit);163157164158static struct mdio_device_id __maybe_unused icplus_tbl[] = {165159 { 0x02430d80, 0x0ffffff0 },160160+ { 0x02430d90, 0x0ffffff0 },166161 { }167162};168163
···534534 int status;535535 unsigned long count;536536537537+ mutex_lock(&qdev->mpi_mutex);537538538539 /* Begin polled mode for MPI */539540 ql_write32(qdev, INTR_MASK, (INTR_MASK_PI << 16));···604603end:605604 /* End polled mode for MPI */606605 ql_write32(qdev, INTR_MASK, (INTR_MASK_PI << 16) | INTR_MASK_PI);606606+ mutex_unlock(&qdev->mpi_mutex);607607 return status;608608}609609···11011099static int ql_set_port_cfg(struct ql_adapter *qdev)11021100{11031101 int status;11041104- rtnl_lock();11051102 status = ql_mb_set_port_cfg(qdev);11061106- rtnl_unlock();11071103 if (status)11081104 return status;11091105 status = ql_idc_wait(qdev);···11221122 container_of(work, struct ql_adapter, mpi_port_cfg_work.work);11231123 int status;1124112411251125- rtnl_lock();11261125 status = ql_mb_get_port_cfg(qdev);11271127- rtnl_unlock();11281126 if (status) {11291127 netif_err(qdev, drv, qdev->ndev,11301128 "Bug: Failed to get port config data.\n");···11651167 u32 aen;11661168 int timeout;1167116911681168- rtnl_lock();11691170 aen = mbcp->mbox_out[1] >> 16;11701171 timeout = (mbcp->mbox_out[1] >> 8) & 0xf;11711172···12281231 }12291232 break;12301233 }12311231- rtnl_unlock();12321234}1233123512341236void ql_mpi_work(struct work_struct *work)···12381242 struct mbox_params *mbcp = &mbc;12391243 int err = 0;1240124412411241- rtnl_lock();12451245+ mutex_lock(&qdev->mpi_mutex);12421246 /* Begin polled mode for MPI */12431247 ql_write32(qdev, INTR_MASK, (INTR_MASK_PI << 16));12441248···1255125912561260 /* End polled mode for MPI */12571261 ql_write32(qdev, INTR_MASK, (INTR_MASK_PI << 16) | INTR_MASK_PI);12581258- rtnl_unlock();12621262+ mutex_unlock(&qdev->mpi_mutex);12591263 ql_enable_completion_interrupt(qdev, 0);12601264}12611265
+16-10
drivers/net/r8169.c
···744744 mdio_write(ioaddr, MII_BMCR, val & 0xffff);745745}746746747747-static void rtl8169_check_link_status(struct net_device *dev,747747+static void __rtl8169_check_link_status(struct net_device *dev,748748 struct rtl8169_private *tp,749749- void __iomem *ioaddr)749749+ void __iomem *ioaddr,750750+ bool pm)750751{751752 unsigned long flags;752753753754 spin_lock_irqsave(&tp->lock, flags);754755 if (tp->link_ok(ioaddr)) {755756 /* This is to cancel a scheduled suspend if there's one. */756756- pm_request_resume(&tp->pci_dev->dev);757757+ if (pm)758758+ pm_request_resume(&tp->pci_dev->dev);757759 netif_carrier_on(dev);758760 netif_info(tp, ifup, dev, "link up\n");759761 } else {760762 netif_carrier_off(dev);761763 netif_info(tp, ifdown, dev, "link down\n");762762- pm_schedule_suspend(&tp->pci_dev->dev, 100);764764+ if (pm)765765+ pm_schedule_suspend(&tp->pci_dev->dev, 100);763766 }764767 spin_unlock_irqrestore(&tp->lock, flags);768768+}769769+770770+static void rtl8169_check_link_status(struct net_device *dev,771771+ struct rtl8169_private *tp,772772+ void __iomem *ioaddr)773773+{774774+ __rtl8169_check_link_status(dev, tp, ioaddr, false);765775}766776767777#define WAKE_ANY (WAKE_PHY | WAKE_MAGIC | WAKE_UCAST | WAKE_BCAST | WAKE_MCAST)···46104600 }4611460146124602 if (status & LinkChg)46134613- rtl8169_check_link_status(dev, tp, ioaddr);46034603+ __rtl8169_check_link_status(dev, tp, ioaddr, true);4614460446154605 /* We need to see the lastest version of tp->intr_mask to46164606 * avoid ignoring an MSI interrupt and having to wait for···49004890 struct net_device *dev = pci_get_drvdata(pdev);49014891 struct rtl8169_private *tp = netdev_priv(dev);4902489249034903- if (!tp->TxDescArray)49044904- return 0;49054905-49064906- rtl8169_check_link_status(dev, tp, tp->mmio_addr);49074907- return -EBUSY;48934893+ return tp->TxDescArray ? -EBUSY : 0;49084894}4909489549104896static const struct dev_pm_ops rtl8169_pm_ops = {
+29-14
drivers/net/sfc/efx.c
···197197198198static void efx_remove_channels(struct efx_nic *efx);199199static void efx_remove_port(struct efx_nic *efx);200200+static void efx_init_napi(struct efx_nic *efx);200201static void efx_fini_napi(struct efx_nic *efx);202202+static void efx_fini_napi_channel(struct efx_channel *channel);201203static void efx_fini_struct(struct efx_nic *efx);202204static void efx_start_all(struct efx_nic *efx);203205static void efx_stop_all(struct efx_nic *efx);···337335338336 /* Disable interrupts and wait for ISRs to complete */339337 efx_nic_disable_interrupts(efx);340340- if (efx->legacy_irq)338338+ if (efx->legacy_irq) {341339 synchronize_irq(efx->legacy_irq);340340+ efx->legacy_irq_enabled = false;341341+ }342342 if (channel->irq)343343 synchronize_irq(channel->irq);344344···355351 efx_channel_processed(channel);356352357353 napi_enable(&channel->napi_str);354354+ if (efx->legacy_irq)355355+ efx->legacy_irq_enabled = true;358356 efx_nic_enable_interrupts(efx);359357}360358···432426433427 *channel = *old_channel;434428429429+ channel->napi_dev = NULL;435430 memset(&channel->eventq, 0, sizeof(channel->eventq));436431437432 rx_queue = &channel->rx_queue;···743736 if (rc)744737 goto rollback;745738739739+ efx_init_napi(efx);740740+746741 /* Destroy old channels */747747- for (i = 0; i < efx->n_channels; i++)742742+ for (i = 0; i < efx->n_channels; i++) {743743+ efx_fini_napi_channel(other_channel[i]);748744 efx_remove_channel(other_channel[i]);745745+ }749746out:750747 /* Free unused channel structures */751748 for (i = 0; i < efx->n_channels; i++)···14111400 efx_start_channel(channel);14121401 }1413140214031403+ if (efx->legacy_irq)14041404+ efx->legacy_irq_enabled = true;14141405 efx_nic_enable_interrupts(efx);1415140614161407 /* Switch to event based MCDI completions after enabling interrupts.···1473146014741461 /* Disable interrupts and wait for ISR to complete */14751462 efx_nic_disable_interrupts(efx);14761476- if (efx->legacy_irq)14631463+ if (efx->legacy_irq) {14771464 synchronize_irq(efx->legacy_irq);14651465+ efx->legacy_irq_enabled = false;14661466+ }14781467 efx_for_each_channel(channel, efx) {14791468 if (channel->irq)14801469 synchronize_irq(channel->irq);···16081593 *16091594 **************************************************************************/1610159516111611-static int efx_init_napi(struct efx_nic *efx)15961596+static void efx_init_napi(struct efx_nic *efx)16121597{16131598 struct efx_channel *channel;16141599···16171602 netif_napi_add(channel->napi_dev, &channel->napi_str,16181603 efx_poll, napi_weight);16191604 }16201620- return 0;16051605+}16061606+16071607+static void efx_fini_napi_channel(struct efx_channel *channel)16081608+{16091609+ if (channel->napi_dev)16101610+ netif_napi_del(&channel->napi_str);16111611+ channel->napi_dev = NULL;16211612}1622161316231614static void efx_fini_napi(struct efx_nic *efx)16241615{16251616 struct efx_channel *channel;1626161716271627- efx_for_each_channel(channel, efx) {16281628- if (channel->napi_dev)16291629- netif_napi_del(&channel->napi_str);16301630- channel->napi_dev = NULL;16311631- }16181618+ efx_for_each_channel(channel, efx)16191619+ efx_fini_napi_channel(channel);16321620}1633162116341622/**************************************************************************···23532335 if (rc)23542336 goto fail1;2355233723562356- rc = efx_init_napi(efx);23572357- if (rc)23582358- goto fail2;23382338+ efx_init_napi(efx);2359233923602340 rc = efx->type->init(efx);23612341 if (rc) {···23842368 efx->type->fini(efx);23852369 fail3:23862370 efx_fini_napi(efx);23872387- fail2:23882371 efx_remove_all(efx);23892372 fail1:23902373 return rc;
+2
drivers/net/sfc/net_driver.h
···621621 * @pci_dev: The PCI device622622 * @type: Controller type attributes623623 * @legacy_irq: IRQ number624624+ * @legacy_irq_enabled: Are IRQs enabled on NIC (INT_EN_KER register)?624625 * @workqueue: Workqueue for port reconfigures and the HW monitor.625626 * Work items do not hold and must not acquire RTNL.626627 * @workqueue_name: Name of workqueue···710709 struct pci_dev *pci_dev;711710 const struct efx_nic_type *type;712711 int legacy_irq;712712+ bool legacy_irq_enabled;713713 struct workqueue_struct *workqueue;714714 char workqueue_name[16];715715 struct work_struct reset_work;
+6
drivers/net/sfc/nic.c
···14181418 u32 queues;14191419 int syserr;1420142014211421+ /* Could this be ours? If interrupts are disabled then the14221422+ * channel state may not be valid.14231423+ */14241424+ if (!efx->legacy_irq_enabled)14251425+ return result;14261426+14211427 /* Read the ISR which also ACKs the interrupts */14221428 efx_readd(efx, ®, FR_BZ_INT_ISR0);14231429 queues = EFX_EXTRACT_DWORD(reg, 0, 31);
+2-2
drivers/net/stmmac/stmmac_main.c
···15091509 pr_warning("\tno valid MAC address;"15101510 "please, use ifconfig or nwhwconfig!\n");1511151115121512+ spin_lock_init(&priv->lock);15131513+15121514 ret = register_netdev(dev);15131515 if (ret) {15141516 pr_err("%s: ERROR %i registering the device\n",···15211519 DBG(probe, DEBUG, "%s: Scatter/Gather: %s - HW checksums: %s\n",15221520 dev->name, (dev->features & NETIF_F_SG) ? "on" : "off",15231521 (dev->features & NETIF_F_HW_CSUM) ? "on" : "off");15241524-15251525- spin_lock_init(&priv->lock);1526152215271523 return ret;15281524}
+3-3
drivers/net/tulip/dmfe.c
···688688689689 DMFE_DBUG(0, "dmfe_start_xmit", 0);690690691691- /* Resource flag check */692692- netif_stop_queue(dev);693693-694691 /* Too large packet check */695692 if (skb->len > MAX_PACKET_SIZE) {696693 pr_err("big packet = %d\n", (u16)skb->len);697694 dev_kfree_skb(skb);698695 return NETDEV_TX_OK;699696 }697697+698698+ /* Resource flag check */699699+ netif_stop_queue(dev);700700701701 spin_lock_irqsave(&db->lock, flags);702702
-4
drivers/net/usb/hso.c
···958958 /* Packet is complete. Inject into stack. */959959 /* We have IP packet here */960960 odev->skb_rx_buf->protocol = cpu_to_be16(ETH_P_IP);961961- /* don't check it */962962- odev->skb_rx_buf->ip_summed =963963- CHECKSUM_UNNECESSARY;964964-965961 skb_reset_mac_header(odev->skb_rx_buf);966962967963 /* Ship it off to the kernel */
···10241024 struct hif_device_usb *hif_dev =10251025 (struct hif_device_usb *) usb_get_intfdata(interface);1026102610271027+ /*10281028+ * The device has to be set to FULLSLEEP mode in case no10291029+ * interface is up.10301030+ */10311031+ if (!(hif_dev->flags & HIF_USB_START))10321032+ ath9k_htc_suspend(hif_dev->htc_handle);10331033+10271034 ath9k_hif_usb_dealloc_urbs(hif_dev);1028103510291036 return 0;
···13921392 orinoco_add_hostscan_results(priv, buf, len);1393139313941394 kfree(buf);13951395- } else if (priv->scan_request) {13951395+ } else {13961396 /* Either abort or complete the scan */13971397- cfg80211_scan_done(priv->scan_request, (len < 0));13981398- priv->scan_request = NULL;13971397+ orinoco_scan_done(priv, (len < 0));13991398 }1400139914011400 spin_lock_irqsave(&priv->scan_lock, flags);···16831684 hermes_write_regn(hw, EVACK, 0xffff);16841685 }1685168616871687+ orinoco_scan_done(priv, true);16881688+16861689 /* firmware will have to reassociate */16871690 netif_carrier_off(dev);16881691 priv->last_linkstatus = 0xffff;···17631762 orinoco_unlock(priv, &flags);1764176317651764 /* Scanning support: Notify scan cancellation */17661766- if (priv->scan_request) {17671767- cfg80211_scan_done(priv->scan_request, 1);17681768- priv->scan_request = NULL;17691769- }17651765+ orinoco_scan_done(priv, true);1770176617711767 if (priv->hard_reset) {17721768 err = (*priv->hard_reset)(priv);···18101812{18111813 struct net_device *dev = priv->ndev;18121814 int err = 0;18151815+18161816+ /* If we've called commit, we are reconfiguring or bringing the18171817+ * interface up. Maintaining countermeasures across this would18181818+ * be confusing, so note that we've disabled them. The port will18191819+ * be enabled later in orinoco_commit or __orinoco_up. */18201820+ priv->tkip_cm_active = 0;1813182118141822 err = orinoco_hw_program_rids(priv);18151823
+7-7
drivers/net/wireless/orinoco/orinoco_cs.c
···151151 goto failed;152152 }153153154154- ret = pcmcia_request_irq(link, orinoco_interrupt);155155- if (ret)156156- goto failed;157157-158158- /* We initialize the hermes structure before completing PCMCIA159159- * configuration just in case the interrupt handler gets160160- * called. */161154 mem = ioport_map(link->resource[0]->start,162155 resource_size(link->resource[0]));163156 if (!mem)164157 goto failed;165158159159+ /* We initialize the hermes structure before completing PCMCIA160160+ * configuration just in case the interrupt handler gets161161+ * called. */166162 hermes_struct_init(hw, mem, HERMES_16BIT_REGSPACING);163163+164164+ ret = pcmcia_request_irq(link, orinoco_interrupt);165165+ if (ret)166166+ goto failed;167167168168 ret = pcmcia_enable_device(link);169169 if (ret)
···214214 goto failed;215215 }216216217217- ret = pcmcia_request_irq(link, orinoco_interrupt);218218- if (ret)219219- goto failed;220220-221221- /* We initialize the hermes structure before completing PCMCIA222222- * configuration just in case the interrupt handler gets223223- * called. */224217 mem = ioport_map(link->resource[0]->start,225218 resource_size(link->resource[0]));226219 if (!mem)227220 goto failed;228221222222+ /* We initialize the hermes structure before completing PCMCIA223223+ * configuration just in case the interrupt handler gets224224+ * called. */229225 hermes_struct_init(hw, mem, HERMES_16BIT_REGSPACING);230226 hw->eeprom_pda = true;227227+228228+ ret = pcmcia_request_irq(link, orinoco_interrupt);229229+ if (ret)230230+ goto failed;231231232232 ret = pcmcia_enable_device(link);233233 if (ret)
+2-2
drivers/net/wireless/orinoco/wext.c
···911911 */912912 if (param->value) {913913 priv->tkip_cm_active = 1;914914- ret = hermes_enable_port(hw, 0);914914+ ret = hermes_disable_port(hw, 0);915915 } else {916916 priv->tkip_cm_active = 0;917917- ret = hermes_disable_port(hw, 0);917917+ ret = hermes_enable_port(hw, 0);918918 }919919 break;920920
···23292329{23302330 u32 cfg;2331233123322332+ if (!pci_find_capability(dev, PCI_CAP_ID_HT))23332333+ return;23342334+23322335 pci_read_config_dword(dev, 0x74, &cfg);2333233623342337 if (cfg & ((1 << 2) | (1 << 15))) {···27672764DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5C832, ricoh_mmc_fixup_r5c832);27682765#endif /*CONFIG_MMC_RICOH_MMC*/2769276627672767+#if defined(CONFIG_DMAR) || defined(CONFIG_INTR_REMAP)27682768+#define VTUNCERRMSK_REG 0x1ac27692769+#define VTD_MSK_SPEC_ERRORS (1 << 31)27702770+/*27712771+ * This is a quirk for masking vt-d spec defined errors to platform error27722772+ * handling logic. With out this, platforms using Intel 7500, 5500 chipsets27732773+ * (and the derivative chipsets like X58 etc) seem to generate NMI/SMI (based27742774+ * on the RAS config settings of the platform) when a vt-d fault happens.27752775+ * The resulting SMI caused the system to hang.27762776+ *27772777+ * VT-d spec related errors are already handled by the VT-d OS code, so no27782778+ * need to report the same error through other channels.27792779+ */27802780+static void vtd_mask_spec_errors(struct pci_dev *dev)27812781+{27822782+ u32 word;27832783+27842784+ pci_read_config_dword(dev, VTUNCERRMSK_REG, &word);27852785+ pci_write_config_dword(dev, VTUNCERRMSK_REG, word | VTD_MSK_SPEC_ERRORS);27862786+}27872787+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x342e, vtd_mask_spec_errors);27882788+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x3c28, vtd_mask_spec_errors);27892789+#endif2770279027712791static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f,27722792 struct pci_fixup *end)
···951951 /* create a bio for continuation segment */952952 bio = bio_map_kern(req_q, or->cdb_cont.buff, or->cdb_cont.total_bytes,953953 GFP_KERNEL);954954- if (unlikely(!bio))955955- return -ENOMEM;954954+ if (IS_ERR(bio))955955+ return PTR_ERR(bio);956956957957 bio->bi_rw |= REQ_WRITE;958958
+3-1
drivers/scsi/pmcraid.c
···6262static unsigned int pmcraid_debug_log;6363static unsigned int pmcraid_disable_aen;6464static unsigned int pmcraid_log_level = IOASC_LOG_LEVEL_MUST;6565+static unsigned int pmcraid_enable_msix;65666667/*6768 * Data structures to support multiple adapters by the LLD.···46924691 int rc;46934692 struct pci_dev *pdev = pinstance->pdev;4694469346954695- if (pci_find_capability(pdev, PCI_CAP_ID_MSIX)) {46944694+ if ((pmcraid_enable_msix) &&46954695+ (pci_find_capability(pdev, PCI_CAP_ID_MSIX))) {46964696 int num_hrrq = PMCRAID_NUM_MSIX_VECTORS;46974697 struct msix_entry entries[PMCRAID_NUM_MSIX_VECTORS];46984698 int i;
+2-4
drivers/scsi/pmcraid.h
···4242 */4343#define PMCRAID_DRIVER_NAME "PMC MaxRAID"4444#define PMCRAID_DEVFILE "pmcsas"4545-#define PMCRAID_DRIVER_VERSION "2.0.3"4545+#define PMCRAID_DRIVER_VERSION "1.0.3"4646#define PMCRAID_DRIVER_DATE __DATE__47474848#define PMCRAID_FW_VERSION_1 0x002···333333 __u8 lun[PMCRAID_LUN_LEN];334334} __attribute__((packed, aligned(4)));335335336336-/* extended configuration table sizes are of 64 bytes in size */337337-#define PMCRAID_CFGTE_EXT_SIZE 32336336+/* extended configuration table sizes are also of 32 bytes in size */338337struct pmcraid_config_table_entry_ext {339338 struct pmcraid_config_table_entry cfgte;340340- __u8 cfgte_ext[PMCRAID_CFGTE_EXT_SIZE];341339};342340343341/* resource types (config_table_entry.resource_type values) */
···615615 return rtn;616616}617617618618-static int __scsi_try_to_abort_cmd(struct scsi_cmnd *scmd)618618+static int scsi_try_to_abort_cmd(struct scsi_cmnd *scmd)619619{620620 if (!scmd->device->host->hostt->eh_abort_handler)621621 return FAILED;···623623 return scmd->device->host->hostt->eh_abort_handler(scmd);624624}625625626626-/**627627- * scsi_try_to_abort_cmd - Ask host to abort a running command.628628- * @scmd: SCSI cmd to abort from Lower Level.629629- *630630- * Notes:631631- * This function will not return until the user's completion function632632- * has been called. there is no timeout on this operation. if the633633- * author of the low-level driver wishes this operation to be timed,634634- * they can provide this facility themselves. helper functions in635635- * scsi_error.c can be supplied to make this easier to do.636636- */637637-static int scsi_try_to_abort_cmd(struct scsi_cmnd *scmd)638638-{639639- /*640640- * scsi_done was called just after the command timed out and before641641- * we had a chance to process it. (db)642642- */643643- if (scmd->serial_number == 0)644644- return SUCCESS;645645- return __scsi_try_to_abort_cmd(scmd);646646-}647647-648626static void scsi_abort_eh_cmnd(struct scsi_cmnd *scmd)649627{650650- if (__scsi_try_to_abort_cmd(scmd) != SUCCESS)628628+ if (scsi_try_to_abort_cmd(scmd) != SUCCESS)651629 if (scsi_try_bus_device_reset(scmd) != SUCCESS)652630 if (scsi_try_target_reset(scmd) != SUCCESS)653631 if (scsi_try_bus_reset(scmd) != SUCCESS)
+1-7
drivers/scsi/scsi_lib.c
···1403140314041404 INIT_LIST_HEAD(&cmd->eh_entry);1405140514061406- /*14071407- * Set the serial numbers back to zero14081408- */14091409- cmd->serial_number = 0;14101410-14111406 atomic_inc(&cmd->device->iodone_cnt);14121407 if (cmd->result)14131408 atomic_inc(&cmd->device->ioerr_cnt);···1637164216381643 blk_queue_max_segment_size(q, dma_get_max_seg_size(dev));1639164416401640- /* New queue, no concurrency on queue_flags */16411645 if (!shost->use_clustering)16421642- queue_flag_clear_unlocked(QUEUE_FLAG_CLUSTER, q);16461646+ q->limits.cluster = 0;1643164716441648 /*16451649 * set a reasonable default alignment on word boundaries: the
+2-1
drivers/serial/kgdboc.c
···90909191static void kgdboc_restore_input(void)9292{9393- schedule_work(&kgdboc_restore_input_work);9393+ if (likely(system_state == SYSTEM_RUNNING))9494+ schedule_work(&kgdboc_restore_input_work);9495}95969697static int kgdboc_register_kbd(char **cptr)
+5
drivers/spi/dw_spi.c
···413413{414414 while (dws->write(dws))415415 dws->read(dws);416416+ /*417417+ * There is a possibility that the last word of a transaction418418+ * will be lost if data is not ready. Re-read to solve this issue.419419+ */420420+ dws->read(dws);416421417422 transfer_complete(dws);418423}
+4-4
drivers/staging/cx25821/cx25821-video.c
···9292 return ARRAY_SIZE(formats);9393}94949595-struct cx25821_fmt *format_by_fourcc(unsigned int fourcc)9595+struct cx25821_fmt *cx25821_format_by_fourcc(unsigned int fourcc)9696{9797 unsigned int i;9898···848848 pix_format =849849 (dev->channels[ch_id].pixel_formats ==850850 PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV;851851- fh->fmt = format_by_fourcc(pix_format);851851+ fh->fmt = cx25821_format_by_fourcc(pix_format);852852853853 v4l2_prio_open(&dev->channels[ch_id].prio, &fh->prio);854854···10101010 if (0 != err)10111011 return err;1012101210131013- fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat);10131013+ fh->fmt = cx25821_format_by_fourcc(f->fmt.pix.pixelformat);10141014 fh->vidq.field = f->fmt.pix.field;1015101510161016 /* check if width and height is valid based on set standard */···11191119 enum v4l2_field field;11201120 unsigned int maxw, maxh;1121112111221122- fmt = format_by_fourcc(f->fmt.pix.pixelformat);11221122+ fmt = cx25821_format_by_fourcc(f->fmt.pix.pixelformat);11231123 if (NULL == fmt)11241124 return -EINVAL;11251125
···951951 * condition: callbacks we register can be executed at once, before we have952952 * initialized the struct atm_dev. To protect against this, all callbacks953953 * abort if atm_dev->dev_data is NULL. */954954- atm_dev = atm_dev_register(instance->driver_name, &usbatm_atm_devops, -1, NULL);954954+ atm_dev = atm_dev_register(instance->driver_name,955955+ &instance->usb_intf->dev, &usbatm_atm_devops,956956+ -1, NULL);955957 if (!atm_dev) {956958 usb_err(instance, "%s: failed to register ATM device!\n", __func__);957959 return -1;···967965968966 /* temp init ATM device, set to 128kbit */969967 atm_dev->link_rate = 128 * 1000 / 424;970970-971971- ret = sysfs_create_link(&atm_dev->class_dev.kobj,972972- &instance->usb_intf->dev.kobj, "device");973973- if (ret) {974974- atm_err(instance, "%s: sysfs_create_link failed: %d\n",975975- __func__, ret);976976- goto fail_sysfs;977977- }978968979969 if (instance->driver->atm_start && ((ret = instance->driver->atm_start(instance, atm_dev)) < 0)) {980970 atm_err(instance, "%s: atm_start failed: %d!\n", __func__, ret);···986992 return 0;987993988994 fail:989989- sysfs_remove_link(&atm_dev->class_dev.kobj, "device");990990- fail_sysfs:991995 instance->atm_dev = NULL;992996 atm_dev_deregister(atm_dev); /* usbatm_atm_dev_close will eventually be called */993997 return ret;···1321132913221330 /* ATM finalize */13231331 if (instance->atm_dev) {13241324- sysfs_remove_link(&instance->atm_dev->class_dev.kobj, "device");13251332 atm_dev_deregister(instance->atm_dev);13261333 instance->atm_dev = NULL;13271334 }
+9-1
drivers/usb/core/Kconfig
···107107 If you are unsure about this, say N here.108108109109config USB_OTG110110- bool110110+ bool "OTG support"111111 depends on USB && EXPERIMENTAL112112 depends on USB_SUSPEND113113 default n114114+ help115115+ The most notable feature of USB OTG is support for a116116+ "Dual-Role" device, which can act as either a device117117+ or a host. The initial role is decided by the type of118118+ plug inserted and can be changed later when two dual119119+ role devices talk to each other.114120121121+ Select this only if your board has Mini-AB/Micro-AB122122+ connector.115123116124config USB_OTG_WHITELIST117125 bool "Rely on OTG Targeted Peripherals List"
+9-9
drivers/usb/gadget/composite.c
···10471047 kfree(cdev->req->buf);10481048 usb_ep_free_request(gadget->ep0, cdev->req);10491049 }10501050+ device_remove_file(&gadget->dev, &dev_attr_suspended);10501051 kfree(cdev);10511052 set_gadget_data(gadget, NULL);10521052- device_remove_file(&gadget->dev, &dev_attr_suspended);10531053 composite = NULL;10541054}10551055···11071107 */11081108 usb_ep_autoconfig_reset(cdev->gadget);1109110911101110- /* standardized runtime overrides for device ID data */11111111- if (idVendor)11121112- cdev->desc.idVendor = cpu_to_le16(idVendor);11131113- if (idProduct)11141114- cdev->desc.idProduct = cpu_to_le16(idProduct);11151115- if (bcdDevice)11161116- cdev->desc.bcdDevice = cpu_to_le16(bcdDevice);11171117-11181110 /* composite gadget needs to assign strings for whole device (like11191111 * serial number), register function drivers, potentially update11201112 * power state and consumption, etc···1117112511181126 cdev->desc = *composite->dev;11191127 cdev->desc.bMaxPacketSize0 = gadget->ep0->maxpacket;11281128+11291129+ /* standardized runtime overrides for device ID data */11301130+ if (idVendor)11311131+ cdev->desc.idVendor = cpu_to_le16(idVendor);11321132+ if (idProduct)11331133+ cdev->desc.idProduct = cpu_to_le16(idProduct);11341134+ if (bcdDevice)11351135+ cdev->desc.bcdDevice = cpu_to_le16(bcdDevice);1120113611211137 /* stirng overrides */11221138 if (iManufacturer || !cdev->desc.iManufacturer) {
+15-10
drivers/usb/host/xhci-mem.c
···16801680 xhci->port_array[i] = (u8) -1;16811681 }16821682 /* FIXME: Should we disable the port? */16831683+ continue;16831684 }16841685 xhci->port_array[i] = major_revision;16851686 if (major_revision == 0x03)···17591758 return -ENOMEM;1760175917611760 port_index = 0;17621762- for (i = 0; i < num_ports; i++)17631763- if (xhci->port_array[i] != 0x03) {17641764- xhci->usb2_ports[port_index] =17651765- &xhci->op_regs->port_status_base +17661766- NUM_PORT_REGS*i;17671767- xhci_dbg(xhci, "USB 2.0 port at index %u, "17681768- "addr = %p\n", i,17691769- xhci->usb2_ports[port_index]);17701770- port_index++;17711771- }17611761+ for (i = 0; i < num_ports; i++) {17621762+ if (xhci->port_array[i] == 0x03 ||17631763+ xhci->port_array[i] == 0 ||17641764+ xhci->port_array[i] == -1)17651765+ continue;17661766+17671767+ xhci->usb2_ports[port_index] =17681768+ &xhci->op_regs->port_status_base +17691769+ NUM_PORT_REGS*i;17701770+ xhci_dbg(xhci, "USB 2.0 port at index %u, "17711771+ "addr = %p\n", i,17721772+ xhci->usb2_ports[port_index]);17731773+ port_index++;17741774+ }17721775 }17731776 if (xhci->num_usb3_ports) {17741777 xhci->usb3_ports = kmalloc(sizeof(*xhci->usb3_ports)*
+3-1
drivers/usb/misc/uss720.c
···33/*44 * uss720.c -- USS720 USB Parport Cable.55 *66- * Copyright (C) 1999, 200566+ * Copyright (C) 1999, 2005, 201077 * Thomas Sailer (t.sailer@alumni.ethz.ch)88 *99 * This program is free software; you can redistribute it and/or modify···776776 { USB_DEVICE(0x0557, 0x2001) },777777 { USB_DEVICE(0x0729, 0x1284) },778778 { USB_DEVICE(0x1293, 0x0002) },779779+ { USB_DEVICE(0x1293, 0x0002) },780780+ { USB_DEVICE(0x050d, 0x0002) },779781 { } /* Terminating entry */780782};781783
···429429430430static int cache_block_group(struct btrfs_block_group_cache *cache,431431 struct btrfs_trans_handle *trans,432432+ struct btrfs_root *root,432433 int load_cache_only)433434{434435 struct btrfs_fs_info *fs_info = cache->fs_info;···443442444443 /*445444 * We can't do the read from on-disk cache during a commit since we need446446- * to have the normal tree locking.445445+ * to have the normal tree locking. Also if we are currently trying to446446+ * allocate blocks for the tree root we can't do the fast caching since447447+ * we likely hold important locks.447448 */448448- if (!trans->transaction->in_commit) {449449+ if (!trans->transaction->in_commit &&450450+ (root && root != root->fs_info->tree_root)) {449451 spin_lock(&cache->lock);450452 if (cache->cached != BTRFS_CACHE_NO) {451453 spin_unlock(&cache->lock);···27452741 struct btrfs_root *root = block_group->fs_info->tree_root;27462742 struct inode *inode = NULL;27472743 u64 alloc_hint = 0;27442744+ int dcs = BTRFS_DC_ERROR;27482745 int num_pages = 0;27492746 int retries = 0;27502747 int ret = 0;···2800279528012796 spin_lock(&block_group->lock);28022797 if (block_group->cached != BTRFS_CACHE_FINISHED) {27982798+ /* We're not cached, don't bother trying to write stuff out */27992799+ dcs = BTRFS_DC_WRITTEN;28032800 spin_unlock(&block_group->lock);28042801 goto out_put;28052802 }···28282821 ret = btrfs_prealloc_file_range_trans(inode, trans, 0, 0, num_pages,28292822 num_pages, num_pages,28302823 &alloc_hint);28242824+ if (!ret)28252825+ dcs = BTRFS_DC_SETUP;28312826 btrfs_free_reserved_data_space(inode, num_pages);28322827out_put:28332828 iput(inode);···28372828 btrfs_release_path(root, path);28382829out:28392830 spin_lock(&block_group->lock);28402840- if (ret)28412841- block_group->disk_cache_state = BTRFS_DC_ERROR;28422842- else28432843- block_group->disk_cache_state = BTRFS_DC_SETUP;28312831+ block_group->disk_cache_state = dcs;28442832 spin_unlock(&block_group->lock);2845283328462834 return ret;···3043303730443038u64 btrfs_reduce_alloc_profile(struct btrfs_root *root, u64 flags)30453039{30463046- u64 num_devices = root->fs_info->fs_devices->rw_devices;30403040+ /*30413041+ * we add in the count of missing devices because we want30423042+ * to make sure that any RAID levels on a degraded FS30433043+ * continue to be honored.30443044+ */30453045+ u64 num_devices = root->fs_info->fs_devices->rw_devices +30463046+ root->fs_info->fs_devices->missing_devices;3047304730483048 if (num_devices == 1)30493049 flags &= ~(BTRFS_BLOCK_GROUP_RAID1 | BTRFS_BLOCK_GROUP_RAID0);···40924080 * space back to the block group, otherwise we will leak space.40934081 */40944082 if (!alloc && cache->cached == BTRFS_CACHE_NO)40954095- cache_block_group(cache, trans, 1);40834083+ cache_block_group(cache, trans, NULL, 1);4096408440974085 byte_in_group = bytenr - cache->key.objectid;40984086 WARN_ON(byte_in_group > cache->key.offset);···49424930 btrfs_get_block_group(block_group);49434931 search_start = block_group->key.objectid;4944493249334933+ /*49344934+ * this can happen if we end up cycling through all the49354935+ * raid types, but we want to make sure we only allocate49364936+ * for the proper type.49374937+ */49384938+ if (!block_group_bits(block_group, data)) {49394939+ u64 extra = BTRFS_BLOCK_GROUP_DUP |49404940+ BTRFS_BLOCK_GROUP_RAID1 |49414941+ BTRFS_BLOCK_GROUP_RAID10;49424942+49434943+ /*49444944+ * if they asked for extra copies and this block group49454945+ * doesn't provide them, bail. This does allow us to49464946+ * fill raid0 from raid1.49474947+ */49484948+ if ((data & extra) && !(block_group->flags & extra))49494949+ goto loop;49504950+ }49514951+49454952have_block_group:49464953 if (unlikely(block_group->cached == BTRFS_CACHE_NO)) {49474954 u64 free_percent;4948495549494949- ret = cache_block_group(block_group, trans, 1);49564956+ ret = cache_block_group(block_group, trans,49574957+ orig_root, 1);49504958 if (block_group->cached == BTRFS_CACHE_FINISHED)49514959 goto have_block_group;49524960···49904958 if (loop > LOOP_CACHING_NOWAIT ||49914959 (loop > LOOP_FIND_IDEAL &&49924960 atomic_read(&space_info->caching_threads) < 2)) {49934993- ret = cache_block_group(block_group, trans, 0);49614961+ ret = cache_block_group(block_group, trans,49624962+ orig_root, 0);49944963 BUG_ON(ret);49954964 }49964965 found_uncached_bg = true;···55485515 u64 num_bytes = ins->offset;5549551655505517 block_group = btrfs_lookup_block_group(root->fs_info, ins->objectid);55515551- cache_block_group(block_group, trans, 0);55185518+ cache_block_group(block_group, trans, NULL, 0);55525519 caching_ctl = get_caching_control(block_group);5553552055545521 if (!caching_ctl) {···63336300 NULL, NULL);63346301 BUG_ON(ret < 0);63356302 if (ret > 0) {63366336- ret = btrfs_del_orphan_item(trans, tree_root,63376337- root->root_key.objectid);63386338- BUG_ON(ret);63036303+ /* if we fail to delete the orphan item this time63046304+ * around, it'll get picked up the next time.63056305+ *63066306+ * The most common failure here is just -ENOENT.63076307+ */63086308+ btrfs_del_orphan_item(trans, tree_root,63096309+ root->root_key.objectid);63396310 }63406311 }63416312···79157878 u64 stripped = BTRFS_BLOCK_GROUP_RAID0 |79167879 BTRFS_BLOCK_GROUP_RAID1 | BTRFS_BLOCK_GROUP_RAID10;7917788079187918- num_devices = root->fs_info->fs_devices->rw_devices;78817881+ /*78827882+ * we add in the count of missing devices because we want78837883+ * to make sure that any RAID levels on a degraded FS78847884+ * continue to be honored.78857885+ */78867886+ num_devices = root->fs_info->fs_devices->rw_devices +78877887+ root->fs_info->fs_devices->missing_devices;78887888+79197889 if (num_devices == 1) {79207890 stripped |= BTRFS_BLOCK_GROUP_DUP;79217891 stripped = flags & ~stripped;···82918247 break;82928248 if (ret != 0)82938249 goto error;82948294-82958250 leaf = path->nodes[0];82968251 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]);82978252 cache = kzalloc(sizeof(*cache), GFP_NOFS);
+61-33
fs/btrfs/file.c
···4848 struct page **prepared_pages,4949 struct iov_iter *i)5050{5151- size_t copied;5151+ size_t copied = 0;5252 int pg = 0;5353 int offset = pos & (PAGE_CACHE_SIZE - 1);5454+ int total_copied = 0;54555556 while (write_bytes > 0) {5657 size_t count = min_t(size_t,5758 PAGE_CACHE_SIZE - offset, write_bytes);5859 struct page *page = prepared_pages[pg];5959-again:6060- if (unlikely(iov_iter_fault_in_readable(i, count)))6161- return -EFAULT;6262-6363- /* Copy data from userspace to the current page */6464- copied = iov_iter_copy_from_user(page, i, offset, count);6060+ /*6161+ * Copy data from userspace to the current page6262+ *6363+ * Disable pagefault to avoid recursive lock since6464+ * the pages are already locked6565+ */6666+ pagefault_disable();6767+ copied = iov_iter_copy_from_user_atomic(page, i, offset, count);6868+ pagefault_enable();65696670 /* Flush processor's dcache for this page */6771 flush_dcache_page(page);6872 iov_iter_advance(i, copied);6973 write_bytes -= copied;7474+ total_copied += copied;70757676+ /* Return to btrfs_file_aio_write to fault page */7177 if (unlikely(copied == 0)) {7272- count = min_t(size_t, PAGE_CACHE_SIZE - offset,7373- iov_iter_single_seg_count(i));7474- goto again;7878+ break;7579 }76807781 if (unlikely(copied < PAGE_CACHE_SIZE - offset)) {···8581 offset = 0;8682 }8783 }8888- return 0;8484+ return total_copied;8985}90869187/*···858854 unsigned long last_index;859855 int will_write;860856 int buffered = 0;857857+ int copied = 0;858858+ int dirty_pages = 0;861859862860 will_write = ((file->f_flags & O_DSYNC) || IS_SYNC(inode) ||863861 (file->f_flags & O_DIRECT));···976970 WARN_ON(num_pages > nrptrs);977971 memset(pages, 0, sizeof(struct page *) * nrptrs);978972979979- ret = btrfs_delalloc_reserve_space(inode, write_bytes);973973+ /*974974+ * Fault pages before locking them in prepare_pages975975+ * to avoid recursive lock976976+ */977977+ if (unlikely(iov_iter_fault_in_readable(&i, write_bytes))) {978978+ ret = -EFAULT;979979+ goto out;980980+ }981981+982982+ ret = btrfs_delalloc_reserve_space(inode,983983+ num_pages << PAGE_CACHE_SHIFT);980984 if (ret)981985 goto out;982986···994978 pos, first_index, last_index,995979 write_bytes);996980 if (ret) {997997- btrfs_delalloc_release_space(inode, write_bytes);981981+ btrfs_delalloc_release_space(inode,982982+ num_pages << PAGE_CACHE_SHIFT);998983 goto out;999984 }100098510011001- ret = btrfs_copy_from_user(pos, num_pages,986986+ copied = btrfs_copy_from_user(pos, num_pages,1002987 write_bytes, pages, &i);10031003- if (ret == 0) {988988+ dirty_pages = (copied + PAGE_CACHE_SIZE - 1) >>989989+ PAGE_CACHE_SHIFT;990990+991991+ if (num_pages > dirty_pages) {992992+ if (copied > 0)993993+ atomic_inc(994994+ &BTRFS_I(inode)->outstanding_extents);995995+ btrfs_delalloc_release_space(inode,996996+ (num_pages - dirty_pages) <<997997+ PAGE_CACHE_SHIFT);998998+ }999999+10001000+ if (copied > 0) {10041001 dirty_and_release_pages(NULL, root, file, pages,10051005- num_pages, pos, write_bytes);10021002+ dirty_pages, pos, copied);10061003 }1007100410081005 btrfs_drop_pages(pages, num_pages);10091009- if (ret) {10101010- btrfs_delalloc_release_space(inode, write_bytes);10111011- goto out;10061006+10071007+ if (copied > 0) {10081008+ if (will_write) {10091009+ filemap_fdatawrite_range(inode->i_mapping, pos,10101010+ pos + copied - 1);10111011+ } else {10121012+ balance_dirty_pages_ratelimited_nr(10131013+ inode->i_mapping,10141014+ dirty_pages);10151015+ if (dirty_pages <10161016+ (root->leafsize >> PAGE_CACHE_SHIFT) + 1)10171017+ btrfs_btree_balance_dirty(root, 1);10181018+ btrfs_throttle(root);10191019+ }10121020 }1013102110141014- if (will_write) {10151015- filemap_fdatawrite_range(inode->i_mapping, pos,10161016- pos + write_bytes - 1);10171017- } else {10181018- balance_dirty_pages_ratelimited_nr(inode->i_mapping,10191019- num_pages);10201020- if (num_pages <10211021- (root->leafsize >> PAGE_CACHE_SHIFT) + 1)10221022- btrfs_btree_balance_dirty(root, 1);10231023- btrfs_throttle(root);10241024- }10251025-10261026- pos += write_bytes;10271027- num_written += write_bytes;10221022+ pos += copied;10231023+ num_written += copied;1028102410291025 cond_resched();10301026 }
+7-5
fs/btrfs/free-space-cache.c
···290290 (unsigned long long)BTRFS_I(inode)->generation,291291 (unsigned long long)generation,292292 (unsigned long long)block_group->key.objectid);293293- goto out;293293+ goto free_cache;294294 }295295296296 if (!num_entries)···524524 return 0;525525 }526526527527+ node = rb_first(&block_group->free_space_offset);528528+ if (!node) {529529+ iput(inode);530530+ return 0;531531+ }532532+527533 last_index = (i_size_read(inode) - 1) >> PAGE_CACHE_SHIFT;528534 filemap_write_and_wait(inode->i_mapping);529535 btrfs_wait_ordered_range(inode, inode->i_size &···548542 * our entries.549543 */550544 first_page_offset = (sizeof(u32) * num_checksums) + sizeof(u64);551551-552552- node = rb_first(&block_group->free_space_offset);553553- if (!node)554554- goto out_free;555545556546 /*557547 * Lock all pages first so we can lock the extent safely.
+5-6
fs/btrfs/inode.c
···495495 add_async_extent(async_cow, start, num_bytes,496496 total_compressed, pages, nr_pages_ret);497497498498- if (start + num_bytes < end && start + num_bytes < actual_end) {498498+ if (start + num_bytes < end) {499499 start += num_bytes;500500 pages = NULL;501501 cond_resched();···5712571257135713 if (err) {57145714 printk(KERN_ERR "btrfs direct IO failed ino %lu rw %lu "57155715- "disk_bytenr %lu len %u err no %d\n",57165716- dip->inode->i_ino, bio->bi_rw, bio->bi_sector,57175717- bio->bi_size, err);57155715+ "sector %#Lx len %u err no %d\n",57165716+ dip->inode->i_ino, bio->bi_rw,57175717+ (unsigned long long)bio->bi_sector, bio->bi_size, err);57185718 dip->errors = 1;5719571957205720 /*···59345934 */59355935 if (write) {59365936 struct btrfs_ordered_extent *ordered;59375937- ordered = btrfs_lookup_ordered_extent(inode,59385938- dip->logical_offset);59375937+ ordered = btrfs_lookup_ordered_extent(inode, file_offset);59395938 if (!test_bit(BTRFS_ORDERED_PREALLOC, &ordered->flags) &&59405939 !test_bit(BTRFS_ORDERED_NOCOW, &ordered->flags))59415940 btrfs_free_reserved_extent(root, ordered->start,
+35-23
fs/btrfs/ioctl.c
···947947948948static noinline int btrfs_ioctl_snap_create(struct file *file,949949 void __user *arg, int subvol,950950- int async)950950+ int v2)951951{952952 struct btrfs_ioctl_vol_args *vol_args = NULL;953953- struct btrfs_ioctl_async_vol_args *async_vol_args = NULL;953953+ struct btrfs_ioctl_vol_args_v2 *vol_args_v2 = NULL;954954 char *name;955955 u64 fd;956956- u64 transid = 0;957956 int ret;958957959959- if (async) {960960- async_vol_args = memdup_user(arg, sizeof(*async_vol_args));961961- if (IS_ERR(async_vol_args))962962- return PTR_ERR(async_vol_args);958958+ if (v2) {959959+ u64 transid = 0;960960+ u64 *ptr = NULL;963961964964- name = async_vol_args->name;965965- fd = async_vol_args->fd;966966- async_vol_args->name[BTRFS_SNAPSHOT_NAME_MAX] = '\0';962962+ vol_args_v2 = memdup_user(arg, sizeof(*vol_args_v2));963963+ if (IS_ERR(vol_args_v2))964964+ return PTR_ERR(vol_args_v2);965965+966966+ if (vol_args_v2->flags & ~BTRFS_SUBVOL_CREATE_ASYNC) {967967+ ret = -EINVAL;968968+ goto out;969969+ }970970+971971+ name = vol_args_v2->name;972972+ fd = vol_args_v2->fd;973973+ vol_args_v2->name[BTRFS_SUBVOL_NAME_MAX] = '\0';974974+975975+ if (vol_args_v2->flags & BTRFS_SUBVOL_CREATE_ASYNC)976976+ ptr = &transid;977977+978978+ ret = btrfs_ioctl_snap_create_transid(file, name, fd,979979+ subvol, ptr);980980+981981+ if (ret == 0 && ptr &&982982+ copy_to_user(arg +983983+ offsetof(struct btrfs_ioctl_vol_args_v2,984984+ transid), ptr, sizeof(*ptr)))985985+ ret = -EFAULT;967986 } else {968987 vol_args = memdup_user(arg, sizeof(*vol_args));969988 if (IS_ERR(vol_args))···990971 name = vol_args->name;991972 fd = vol_args->fd;992973 vol_args->name[BTRFS_PATH_NAME_MAX] = '\0';974974+975975+ ret = btrfs_ioctl_snap_create_transid(file, name, fd,976976+ subvol, NULL);993977 }994994-995995- ret = btrfs_ioctl_snap_create_transid(file, name, fd,996996- subvol, &transid);997997-998998- if (!ret && async) {999999- if (copy_to_user(arg +10001000- offsetof(struct btrfs_ioctl_async_vol_args,10011001- transid), &transid, sizeof(transid)))10021002- return -EFAULT;10031003- }10041004-978978+out:1005979 kfree(vol_args);10061006- kfree(async_vol_args);980980+ kfree(vol_args_v2);10079811008982 return ret;1009983}···22582246 return btrfs_ioctl_getversion(file, argp);22592247 case BTRFS_IOC_SNAP_CREATE:22602248 return btrfs_ioctl_snap_create(file, argp, 0, 0);22612261- case BTRFS_IOC_SNAP_CREATE_ASYNC:22492249+ case BTRFS_IOC_SNAP_CREATE_V2:22622250 return btrfs_ioctl_snap_create(file, argp, 0, 1);22632251 case BTRFS_IOC_SUBVOL_CREATE:22642252 return btrfs_ioctl_snap_create(file, argp, 1, 0);
···5656 return -ENOMEM;57575858 ret = btrfs_search_slot(trans, root, &key, path, -1, 1);5959- if (ret)5959+ if (ret < 0)6060 goto out;6161+ if (ret) {6262+ ret = -ENOENT;6363+ goto out;6464+ }61656266 ret = btrfs_del_item(trans, root, path);6367
+1-1
fs/btrfs/super.c
···685685 mutex_unlock(&root->d_inode->i_mutex);686686687687 if (IS_ERR(new_root)) {688688+ dput(root);688689 deactivate_locked_super(s);689690 error = PTR_ERR(new_root);690690- dput(root);691691 goto error_free_subvol_name;692692 }693693 if (!new_root->d_inode) {
+19-1
fs/btrfs/volumes.c
···412412413413 device->fs_devices = fs_devices;414414 fs_devices->num_devices++;415415- } else if (strcmp(device->name, path)) {415415+ } else if (!device->name || strcmp(device->name, path)) {416416 name = kstrdup(path, GFP_NOFS);417417 if (!name)418418 return -ENOMEM;419419 kfree(device->name);420420 device->name = name;421421+ if (device->missing) {422422+ fs_devices->missing_devices--;423423+ device->missing = 0;424424+ }421425 }422426423427 if (found_transid > fs_devices->latest_trans) {···12391235 mutex_unlock(&root->fs_info->fs_devices->device_list_mutex);1240123612411237 device->fs_devices->num_devices--;12381238+12391239+ if (device->missing)12401240+ root->fs_info->fs_devices->missing_devices--;1242124112431242 next_device = list_entry(root->fs_info->fs_devices->devices.next,12441243 struct btrfs_device, dev_list);···30873080 device->devid = devid;30883081 device->work.func = pending_bios_fn;30893082 device->fs_devices = fs_devices;30833083+ device->missing = 1;30903084 fs_devices->num_devices++;30853085+ fs_devices->missing_devices++;30913086 spin_lock_init(&device->io_lock);30923087 INIT_LIST_HEAD(&device->dev_alloc_list);30933088 memcpy(device->uuid, dev_uuid, BTRFS_UUID_SIZE);···32873278 device = add_missing_dev(root, devid, dev_uuid);32883279 if (!device)32893280 return -ENOMEM;32813281+ } else if (!device->missing) {32823282+ /*32833283+ * this happens when a device that was properly setup32843284+ * in the device info lists suddenly goes bad.32853285+ * device->bdev is NULL, and so we have to set32863286+ * device->missing to one here32873287+ */32883288+ root->fs_info->fs_devices->missing_devices++;32893289+ device->missing = 1;32903290 }32913291 }32923292
+2
fs/btrfs/volumes.h
···44444545 int writeable;4646 int in_fs_metadata;4747+ int missing;47484849 spinlock_t io_lock;4950···9493 u64 num_devices;9594 u64 open_devices;9695 u64 rw_devices;9696+ u64 missing_devices;9797 u64 total_rw_bytes;9898 struct block_device *latest_bdev;9999
+4-3
fs/ceph/dir.c
···4040 if (dentry->d_fsdata)4141 return 0;42424343- if (ceph_snap(dentry->d_parent->d_inode) == CEPH_NOSNAP)4343+ if (dentry->d_parent == NULL || /* nfs fh_to_dentry */4444+ ceph_snap(dentry->d_parent->d_inode) == CEPH_NOSNAP)4445 dentry->d_op = &ceph_dentry_ops;4546 else if (ceph_snap(dentry->d_parent->d_inode) == CEPH_SNAPDIR)4647 dentry->d_op = &ceph_snapdir_dentry_ops;···115114 spin_lock(&dcache_lock);116115117116 /* start at beginning? */118118- if (filp->f_pos == 2 || (last &&119119- filp->f_pos < ceph_dentry(last)->offset)) {117117+ if (filp->f_pos == 2 || last == NULL ||118118+ filp->f_pos < ceph_dentry(last)->offset) {120119 if (list_empty(&parent->d_subdirs))121120 goto out_unlock;122121 p = parent->d_subdirs.prev;
+23-16
fs/ceph/file.c
···282282static int striped_read(struct inode *inode,283283 u64 off, u64 len,284284 struct page **pages, int num_pages,285285- int *checkeof, bool align_to_pages)285285+ int *checkeof, bool align_to_pages,286286+ unsigned long buf_align)286287{287288 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);288289 struct ceph_inode_info *ci = ceph_inode(inode);···308307309308more:310309 if (align_to_pages)311311- page_align = (pos - io_align) & ~PAGE_MASK;310310+ page_align = (pos - io_align + buf_align) & ~PAGE_MASK;312311 else313312 page_align = pos & ~PAGE_MASK;314313 this_len = left;···377376 struct inode *inode = file->f_dentry->d_inode;378377 struct page **pages;379378 u64 off = *poff;380380- int num_pages = calc_pages_for(off, len);381381- int ret;379379+ int num_pages, ret;382380383381 dout("sync_read on file %p %llu~%u %s\n", file, off, len,384382 (file->f_flags & O_DIRECT) ? "O_DIRECT" : "");385383386386- if (file->f_flags & O_DIRECT)387387- pages = ceph_get_direct_page_vector(data, num_pages);388388- else384384+ if (file->f_flags & O_DIRECT) {385385+ num_pages = calc_pages_for((unsigned long)data, len);386386+ pages = ceph_get_direct_page_vector(data, num_pages, true);387387+ } else {388388+ num_pages = calc_pages_for(off, len);389389 pages = ceph_alloc_page_vector(num_pages, GFP_NOFS);390390+ }390391 if (IS_ERR(pages))391392 return PTR_ERR(pages);392393···403400 goto done;404401405402 ret = striped_read(inode, off, len, pages, num_pages, checkeof,406406- file->f_flags & O_DIRECT);403403+ file->f_flags & O_DIRECT,404404+ (unsigned long)data & ~PAGE_MASK);407405408406 if (ret >= 0 && (file->f_flags & O_DIRECT) == 0)409407 ret = ceph_copy_page_vector_to_user(pages, data, off, ret);···413409414410done:415411 if (file->f_flags & O_DIRECT)416416- ceph_put_page_vector(pages, num_pages);412412+ ceph_put_page_vector(pages, num_pages, true);417413 else418414 ceph_release_page_vector(pages, num_pages);419415 dout("sync_read result %d\n", ret);···460456 int do_sync = 0;461457 int check_caps = 0;462458 int page_align, io_align;459459+ unsigned long buf_align;463460 int ret;464461 struct timespec mtime = CURRENT_TIME;465462···476471 pos = *offset;477472478473 io_align = pos & ~PAGE_MASK;474474+ buf_align = (unsigned long)data & ~PAGE_MASK;479475480476 ret = filemap_write_and_wait_range(inode->i_mapping, pos, pos + left);481477 if (ret < 0)···502496 */503497more:504498 len = left;505505- if (file->f_flags & O_DIRECT)499499+ if (file->f_flags & O_DIRECT) {506500 /* write from beginning of first page, regardless of507501 io alignment */508508- page_align = (pos - io_align) & ~PAGE_MASK;509509- else502502+ page_align = (pos - io_align + buf_align) & ~PAGE_MASK;503503+ num_pages = calc_pages_for((unsigned long)data, len);504504+ } else {510505 page_align = pos & ~PAGE_MASK;506506+ num_pages = calc_pages_for(pos, len);507507+ }511508 req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout,512509 ceph_vino(inode), pos, &len,513510 CEPH_OSD_OP_WRITE, flags,···521512 if (!req)522513 return -ENOMEM;523514524524- num_pages = calc_pages_for(pos, len);525525-526515 if (file->f_flags & O_DIRECT) {527527- pages = ceph_get_direct_page_vector(data, num_pages);516516+ pages = ceph_get_direct_page_vector(data, num_pages, false);528517 if (IS_ERR(pages)) {529518 ret = PTR_ERR(pages);530519 goto out;···572565 }573566574567 if (file->f_flags & O_DIRECT)575575- ceph_put_page_vector(pages, num_pages);568568+ ceph_put_page_vector(pages, num_pages, false);576569 else if (file->f_flags & O_SYNC)577570 ceph_release_page_vector(pages, num_pages);578571
+1-1
fs/ceph/ioctl.h
···44#include <linux/ioctl.h>55#include <linux/types.h>6677-#define CEPH_IOCTL_MAGIC 0x9877+#define CEPH_IOCTL_MAGIC 0x978899/* just use u64 to align sanely on all archs */1010struct ceph_ioctl_layout {
+50-44
fs/ceph/locks.c
···1111 * Implement fcntl and flock locking functions.1212 */1313static int ceph_lock_message(u8 lock_type, u16 operation, struct file *file,1414- u64 pid, u64 pid_ns,1515- int cmd, u64 start, u64 length, u8 wait)1414+ int cmd, u8 wait, struct file_lock *fl)1615{1716 struct inode *inode = file->f_dentry->d_inode;1817 struct ceph_mds_client *mdsc =1918 ceph_sb_to_client(inode->i_sb)->mdsc;2019 struct ceph_mds_request *req;2120 int err;2121+ u64 length = 0;22222323 req = ceph_mdsc_create_request(mdsc, operation, USE_AUTH_MDS);2424 if (IS_ERR(req))2525 return PTR_ERR(req);2626 req->r_inode = igrab(inode);27272828+ /* mds requires start and length rather than start and end */2929+ if (LLONG_MAX == fl->fl_end)3030+ length = 0;3131+ else3232+ length = fl->fl_end - fl->fl_start + 1;3333+2834 dout("ceph_lock_message: rule: %d, op: %d, pid: %llu, start: %llu, "2935 "length: %llu, wait: %d, type`: %d", (int)lock_type,3030- (int)operation, pid, start, length, wait, cmd);3636+ (int)operation, (u64)fl->fl_pid, fl->fl_start,3737+ length, wait, fl->fl_type);3838+31393240 req->r_args.filelock_change.rule = lock_type;3341 req->r_args.filelock_change.type = cmd;3434- req->r_args.filelock_change.pid = cpu_to_le64(pid);4242+ req->r_args.filelock_change.pid = cpu_to_le64((u64)fl->fl_pid);3543 /* This should be adjusted, but I'm not sure if3644 namespaces actually get id numbers*/3745 req->r_args.filelock_change.pid_namespace =3838- cpu_to_le64((u64)pid_ns);3939- req->r_args.filelock_change.start = cpu_to_le64(start);4646+ cpu_to_le64((u64)(unsigned long)fl->fl_nspid);4747+ req->r_args.filelock_change.start = cpu_to_le64(fl->fl_start);4048 req->r_args.filelock_change.length = cpu_to_le64(length);4149 req->r_args.filelock_change.wait = wait;42504351 err = ceph_mdsc_do_request(mdsc, inode, req);5252+5353+ if ( operation == CEPH_MDS_OP_GETFILELOCK){5454+ fl->fl_pid = le64_to_cpu(req->r_reply_info.filelock_reply->pid);5555+ if (CEPH_LOCK_SHARED == req->r_reply_info.filelock_reply->type)5656+ fl->fl_type = F_RDLCK;5757+ else if (CEPH_LOCK_EXCL == req->r_reply_info.filelock_reply->type)5858+ fl->fl_type = F_WRLCK;5959+ else6060+ fl->fl_type = F_UNLCK;6161+6262+ fl->fl_start = le64_to_cpu(req->r_reply_info.filelock_reply->start);6363+ length = le64_to_cpu(req->r_reply_info.filelock_reply->start) +6464+ le64_to_cpu(req->r_reply_info.filelock_reply->length);6565+ if (length >= 1)6666+ fl->fl_end = length -1;6767+ else6868+ fl->fl_end = 0;6969+7070+ }4471 ceph_mdsc_put_request(req);4572 dout("ceph_lock_message: rule: %d, op: %d, pid: %llu, start: %llu, "4646- "length: %llu, wait: %d, type`: %d err code %d", (int)lock_type,4747- (int)operation, pid, start, length, wait, cmd, err);7373+ "length: %llu, wait: %d, type`: %d, err code %d", (int)lock_type,7474+ (int)operation, (u64)fl->fl_pid, fl->fl_start,7575+ length, wait, fl->fl_type, err);4876 return err;4977}5078···8254 */8355int ceph_lock(struct file *file, int cmd, struct file_lock *fl)8456{8585- u64 length;8657 u8 lock_cmd;8758 int err;8859 u8 wait = 0;···10376 else10477 lock_cmd = CEPH_LOCK_UNLOCK;10578106106- if (LLONG_MAX == fl->fl_end)107107- length = 0;108108- else109109- length = fl->fl_end - fl->fl_start + 1;110110-111111- err = ceph_lock_message(CEPH_LOCK_FCNTL, op, file,112112- (u64)fl->fl_pid,113113- (u64)(unsigned long)fl->fl_nspid,114114- lock_cmd, fl->fl_start,115115- length, wait);7979+ err = ceph_lock_message(CEPH_LOCK_FCNTL, op, file, lock_cmd, wait, fl);11680 if (!err) {117117- dout("mds locked, locking locally");118118- err = posix_lock_file(file, fl, NULL);119119- if (err && (CEPH_MDS_OP_SETFILELOCK == op)) {120120- /* undo! This should only happen if the kernel detects121121- * local deadlock. */122122- ceph_lock_message(CEPH_LOCK_FCNTL, op, file,123123- (u64)fl->fl_pid,124124- (u64)(unsigned long)fl->fl_nspid,125125- CEPH_LOCK_UNLOCK, fl->fl_start,126126- length, 0);127127- dout("got %d on posix_lock_file, undid lock", err);8181+ if ( op != CEPH_MDS_OP_GETFILELOCK ){8282+ dout("mds locked, locking locally");8383+ err = posix_lock_file(file, fl, NULL);8484+ if (err && (CEPH_MDS_OP_SETFILELOCK == op)) {8585+ /* undo! This should only happen if the kernel detects8686+ * local deadlock. */8787+ ceph_lock_message(CEPH_LOCK_FCNTL, op, file,8888+ CEPH_LOCK_UNLOCK, 0, fl);8989+ dout("got %d on posix_lock_file, undid lock", err);9090+ }12891 }9292+12993 } else {13094 dout("mds returned error code %d", err);13195 }···125107126108int ceph_flock(struct file *file, int cmd, struct file_lock *fl)127109{128128- u64 length;129110 u8 lock_cmd;130111 int err;131112 u8 wait = 1;···144127 lock_cmd = CEPH_LOCK_EXCL;145128 else146129 lock_cmd = CEPH_LOCK_UNLOCK;147147- /* mds requires start and length rather than start and end */148148- if (LLONG_MAX == fl->fl_end)149149- length = 0;150150- else151151- length = fl->fl_end - fl->fl_start + 1;152130153131 err = ceph_lock_message(CEPH_LOCK_FLOCK, CEPH_MDS_OP_SETFILELOCK,154154- file, (u64)fl->fl_pid,155155- (u64)(unsigned long)fl->fl_nspid,156156- lock_cmd, fl->fl_start,157157- length, wait);132132+ file, lock_cmd, wait, fl);158133 if (!err) {159134 err = flock_lock_file_wait(file, fl);160135 if (err) {161136 ceph_lock_message(CEPH_LOCK_FLOCK,162137 CEPH_MDS_OP_SETFILELOCK,163163- file, (u64)fl->fl_pid,164164- (u64)(unsigned long)fl->fl_nspid,165165- CEPH_LOCK_UNLOCK, fl->fl_start,166166- length, 0);138138+ file, CEPH_LOCK_UNLOCK, 0, fl);167139 dout("got %d on flock_lock_file_wait, undid lock", err);168140 }169141 } else {
···337337 wsize default write size (default 57344)338338 maximum wsize currently allowed by CIFS is 57344 (fourteen339339 4096 byte pages)340340+ actimeo=n attribute cache timeout in seconds (default 1 second).341341+ After this timeout, the cifs client requests fresh attribute342342+ information from the server. This option allows to tune the343343+ attribute cache timeout to suit the workload needs. Shorter344344+ timeouts mean better the cache coherency, but increased number345345+ of calls to the server. Longer timeouts mean reduced number346346+ of calls to the server at the expense of less stricter cache347347+ coherency checks (i.e. incorrect attribute cache for a short348348+ period of time).340349 rw mount the network share read-write (note that the341350 server may still consider the share read-only)342351 ro mount network share read-only
+1
fs/cifs/cifs_fs_sb.h
···4848 struct nls_table *local_nls;4949 unsigned int rsize;5050 unsigned int wsize;5151+ unsigned long actimeo; /* attribute cache timeout (jiffies) */5152 atomic_t active;5253 uid_t mnt_uid;5354 gid_t mnt_gid;
···4545#define CIFS_MIN_RCV_POOL 446464747/*4848+ * default attribute cache timeout (jiffies)4949+ */5050+#define CIFS_DEF_ACTIMEO (1 * HZ)5151+5252+/*5353+ * max attribute cache timeout (jiffies) - 2^305454+ */5555+#define CIFS_MAX_ACTIMEO (1 << 30)5656+5757+/*4858 * MAX_REQ is the maximum number of requests that WE will send4959 * on one socket concurrently. It also matches the most common5060 * value of max multiplex returned by servers. We may···756746GLOBAL_EXTERN unsigned int GlobalMaxActiveXid; /* prot by GlobalMid_Sem */757747GLOBAL_EXTERN spinlock_t GlobalMid_Lock; /* protects above & list operations */758748 /* on midQ entries */759759-GLOBAL_EXTERN char Local_System_Name[15];760760-761749/*762750 * Global counters, updated atomically763751 */
···24782478}2479247924802480#ifdef CONFIG_CIFS_EXPERIMENTAL24812481-/* Initialize NT TRANSACT SMB into small smb request buffer.24822482- This assumes that all NT TRANSACTS that we init here have24832483- total parm and data under about 400 bytes (to fit in small cifs24842484- buffer size), which is the case so far, it easily fits. NB:24852485- Setup words themselves and ByteCount24862486- MaxSetupCount (size of returned setup area) and24872487- MaxParameterCount (returned parms size) must be set by caller */24882488-static int24892489-smb_init_nttransact(const __u16 sub_command, const int setup_count,24902490- const int parm_len, struct cifsTconInfo *tcon,24912491- void **ret_buf)24922492-{24932493- int rc;24942494- __u32 temp_offset;24952495- struct smb_com_ntransact_req *pSMB;24962496-24972497- rc = small_smb_init(SMB_COM_NT_TRANSACT, 19 + setup_count, tcon,24982498- (void **)&pSMB);24992499- if (rc)25002500- return rc;25012501- *ret_buf = (void *)pSMB;25022502- pSMB->Reserved = 0;25032503- pSMB->TotalParameterCount = cpu_to_le32(parm_len);25042504- pSMB->TotalDataCount = 0;25052505- pSMB->MaxDataCount = cpu_to_le32((tcon->ses->server->maxBuf -25062506- MAX_CIFS_HDR_SIZE) & 0xFFFFFF00);25072507- pSMB->ParameterCount = pSMB->TotalParameterCount;25082508- pSMB->DataCount = pSMB->TotalDataCount;25092509- temp_offset = offsetof(struct smb_com_ntransact_req, Parms) +25102510- (setup_count * 2) - 4 /* for rfc1001 length itself */;25112511- pSMB->ParameterOffset = cpu_to_le32(temp_offset);25122512- pSMB->DataOffset = cpu_to_le32(temp_offset + parm_len);25132513- pSMB->SetupCount = setup_count; /* no need to le convert byte fields */25142514- pSMB->SubCommand = cpu_to_le16(sub_command);25152515- return 0;25162516-}25172517-25182518-static int25192519-validate_ntransact(char *buf, char **ppparm, char **ppdata,25202520- __u32 *pparmlen, __u32 *pdatalen)25212521-{25222522- char *end_of_smb;25232523- __u32 data_count, data_offset, parm_count, parm_offset;25242524- struct smb_com_ntransact_rsp *pSMBr;25252525-25262526- *pdatalen = 0;25272527- *pparmlen = 0;25282528-25292529- if (buf == NULL)25302530- return -EINVAL;25312531-25322532- pSMBr = (struct smb_com_ntransact_rsp *)buf;25332533-25342534- /* ByteCount was converted from little endian in SendReceive */25352535- end_of_smb = 2 /* sizeof byte count */ + pSMBr->ByteCount +25362536- (char *)&pSMBr->ByteCount;25372537-25382538- data_offset = le32_to_cpu(pSMBr->DataOffset);25392539- data_count = le32_to_cpu(pSMBr->DataCount);25402540- parm_offset = le32_to_cpu(pSMBr->ParameterOffset);25412541- parm_count = le32_to_cpu(pSMBr->ParameterCount);25422542-25432543- *ppparm = (char *)&pSMBr->hdr.Protocol + parm_offset;25442544- *ppdata = (char *)&pSMBr->hdr.Protocol + data_offset;25452545-25462546- /* should we also check that parm and data areas do not overlap? */25472547- if (*ppparm > end_of_smb) {25482548- cFYI(1, "parms start after end of smb");25492549- return -EINVAL;25502550- } else if (parm_count + *ppparm > end_of_smb) {25512551- cFYI(1, "parm end after end of smb");25522552- return -EINVAL;25532553- } else if (*ppdata > end_of_smb) {25542554- cFYI(1, "data starts after end of smb");25552555- return -EINVAL;25562556- } else if (data_count + *ppdata > end_of_smb) {25572557- cFYI(1, "data %p + count %d (%p) past smb end %p start %p",25582558- *ppdata, data_count, (data_count + *ppdata),25592559- end_of_smb, pSMBr);25602560- return -EINVAL;25612561- } else if (parm_count + data_count > pSMBr->ByteCount) {25622562- cFYI(1, "parm count and data count larger than SMB");25632563- return -EINVAL;25642564- }25652565- *pdatalen = data_count;25662566- *pparmlen = parm_count;25672567- return 0;25682568-}25692569-25702481int25712482CIFSSMBQueryReparseLinkInfo(const int xid, struct cifsTconInfo *tcon,25722483 const unsigned char *searchName,···2967305629683057#endif /* CONFIG_POSIX */2969305829702970-#ifdef CONFIG_CIFS_EXPERIMENTAL30593059+#ifdef CONFIG_CIFS_ACL30603060+/*30613061+ * Initialize NT TRANSACT SMB into small smb request buffer. This assumes that30623062+ * all NT TRANSACTS that we init here have total parm and data under about 40030633063+ * bytes (to fit in small cifs buffer size), which is the case so far, it30643064+ * easily fits. NB: Setup words themselves and ByteCount MaxSetupCount (size of30653065+ * returned setup area) and MaxParameterCount (returned parms size) must be set30663066+ * by caller30673067+ */30683068+static int30693069+smb_init_nttransact(const __u16 sub_command, const int setup_count,30703070+ const int parm_len, struct cifsTconInfo *tcon,30713071+ void **ret_buf)30723072+{30733073+ int rc;30743074+ __u32 temp_offset;30753075+ struct smb_com_ntransact_req *pSMB;30763076+30773077+ rc = small_smb_init(SMB_COM_NT_TRANSACT, 19 + setup_count, tcon,30783078+ (void **)&pSMB);30793079+ if (rc)30803080+ return rc;30813081+ *ret_buf = (void *)pSMB;30823082+ pSMB->Reserved = 0;30833083+ pSMB->TotalParameterCount = cpu_to_le32(parm_len);30843084+ pSMB->TotalDataCount = 0;30853085+ pSMB->MaxDataCount = cpu_to_le32((tcon->ses->server->maxBuf -30863086+ MAX_CIFS_HDR_SIZE) & 0xFFFFFF00);30873087+ pSMB->ParameterCount = pSMB->TotalParameterCount;30883088+ pSMB->DataCount = pSMB->TotalDataCount;30893089+ temp_offset = offsetof(struct smb_com_ntransact_req, Parms) +30903090+ (setup_count * 2) - 4 /* for rfc1001 length itself */;30913091+ pSMB->ParameterOffset = cpu_to_le32(temp_offset);30923092+ pSMB->DataOffset = cpu_to_le32(temp_offset + parm_len);30933093+ pSMB->SetupCount = setup_count; /* no need to le convert byte fields */30943094+ pSMB->SubCommand = cpu_to_le16(sub_command);30953095+ return 0;30963096+}30973097+30983098+static int30993099+validate_ntransact(char *buf, char **ppparm, char **ppdata,31003100+ __u32 *pparmlen, __u32 *pdatalen)31013101+{31023102+ char *end_of_smb;31033103+ __u32 data_count, data_offset, parm_count, parm_offset;31043104+ struct smb_com_ntransact_rsp *pSMBr;31053105+31063106+ *pdatalen = 0;31073107+ *pparmlen = 0;31083108+31093109+ if (buf == NULL)31103110+ return -EINVAL;31113111+31123112+ pSMBr = (struct smb_com_ntransact_rsp *)buf;31133113+31143114+ /* ByteCount was converted from little endian in SendReceive */31153115+ end_of_smb = 2 /* sizeof byte count */ + pSMBr->ByteCount +31163116+ (char *)&pSMBr->ByteCount;31173117+31183118+ data_offset = le32_to_cpu(pSMBr->DataOffset);31193119+ data_count = le32_to_cpu(pSMBr->DataCount);31203120+ parm_offset = le32_to_cpu(pSMBr->ParameterOffset);31213121+ parm_count = le32_to_cpu(pSMBr->ParameterCount);31223122+31233123+ *ppparm = (char *)&pSMBr->hdr.Protocol + parm_offset;31243124+ *ppdata = (char *)&pSMBr->hdr.Protocol + data_offset;31253125+31263126+ /* should we also check that parm and data areas do not overlap? */31273127+ if (*ppparm > end_of_smb) {31283128+ cFYI(1, "parms start after end of smb");31293129+ return -EINVAL;31303130+ } else if (parm_count + *ppparm > end_of_smb) {31313131+ cFYI(1, "parm end after end of smb");31323132+ return -EINVAL;31333133+ } else if (*ppdata > end_of_smb) {31343134+ cFYI(1, "data starts after end of smb");31353135+ return -EINVAL;31363136+ } else if (data_count + *ppdata > end_of_smb) {31373137+ cFYI(1, "data %p + count %d (%p) past smb end %p start %p",31383138+ *ppdata, data_count, (data_count + *ppdata),31393139+ end_of_smb, pSMBr);31403140+ return -EINVAL;31413141+ } else if (parm_count + data_count > pSMBr->ByteCount) {31423142+ cFYI(1, "parm count and data count larger than SMB");31433143+ return -EINVAL;31443144+ }31453145+ *pdatalen = data_count;31463146+ *pparmlen = parm_count;31473147+ return 0;31483148+}31493149+29713150/* Get Security Descriptor (by handle) from remote server for a file or dir */29723151int29733152CIFSSMBGetCIFSACL(const int xid, struct cifsTconInfo *tcon, __u16 fid,···32153214 return (rc);32163215}3217321632183218-#endif /* CONFIG_CIFS_EXPERIMENTAL */32173217+#endif /* CONFIG_CIFS_ACL */3219321832203219/* Legacy Query Path Information call for lookup to old servers such32213220 as Win9x/WinME */
+27-15
fs/cifs/connect.c
···105105 unsigned int wsize;106106 bool sockopt_tcp_nodelay:1;107107 unsigned short int port;108108+ unsigned long actimeo; /* attribute cache timeout (jiffies) */108109 char *prepath;109110 struct sockaddr_storage srcaddr; /* allow binding to a local IP */110111 struct nls_table *local_nls;···807806 short int override_gid = -1;808807 bool uid_specified = false;809808 bool gid_specified = false;809809+ char *nodename = utsname()->nodename;810810811811 separator[0] = ',';812812 separator[1] = 0;813813814814- if (Local_System_Name[0] != 0)815815- memcpy(vol->source_rfc1001_name, Local_System_Name, 15);816816- else {817817- char *nodename = utsname()->nodename;818818- int n = strnlen(nodename, 15);819819- memset(vol->source_rfc1001_name, 0x20, 15);820820- for (i = 0; i < n; i++) {821821- /* does not have to be perfect mapping since field is822822- informational, only used for servers that do not support823823- port 445 and it can be overridden at mount time */824824- vol->source_rfc1001_name[i] = toupper(nodename[i]);825825- }826826- }814814+ /*815815+ * does not have to be perfect mapping since field is816816+ * informational, only used for servers that do not support817817+ * port 445 and it can be overridden at mount time818818+ */819819+ memset(vol->source_rfc1001_name, 0x20, 15);820820+ for (i = 0; i < strnlen(nodename, 15); i++)821821+ vol->source_rfc1001_name[i] = toupper(nodename[i]);822822+827823 vol->source_rfc1001_name[15] = 0;828824 /* null target name indicates to use *SMBSERVR default called name829825 if we end up sending RFC1001 session initialize */···837839 vol->posix_paths = 1;838840 /* default to using server inode numbers where available */839841 vol->server_ino = 1;842842+843843+ vol->actimeo = CIFS_DEF_ACTIMEO;840844841845 if (!options)842846 return 1;···12131213 if ((i == 15) && (value[i] != 0))12141214 printk(KERN_WARNING "CIFS: server net"12151215 "biosname longer than 15 truncated.\n");12161216+ }12171217+ } else if (strnicmp(data, "actimeo", 7) == 0) {12181218+ if (value && *value) {12191219+ vol->actimeo = HZ * simple_strtoul(value,12201220+ &value, 0);12211221+ if (vol->actimeo > CIFS_MAX_ACTIMEO) {12221222+ cERROR(1, "CIFS: attribute cache"12231223+ "timeout too large");12241224+ return 1;12251225+ }12161226 }12171227 } else if (strnicmp(data, "credentials", 4) == 0) {12181228 /* ignore */···25812571 cFYI(1, "file mode: 0x%x dir mode: 0x%x",25822572 cifs_sb->mnt_file_mode, cifs_sb->mnt_dir_mode);2583257325742574+ cifs_sb->actimeo = pvolume_info->actimeo;25752575+25842576 if (pvolume_info->noperm)25852577 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_PERM;25862578 if (pvolume_info->setuids)···28332821 /* check if a whole path (including prepath) is not remote */28342822 if (!rc && cifs_sb->prepathlen && tcon) {28352823 /* build_path_to_root works only when we have a valid tcon */28362836- full_path = cifs_build_path_to_root(cifs_sb);28242824+ full_path = cifs_build_path_to_root(cifs_sb, tcon);28372825 if (full_path == NULL) {28382826 rc = -ENOMEM;28392827 goto mount_fail_check;28402828 }28412829 rc = is_path_accessible(xid, tcon, cifs_sb, full_path);28422842- if (rc != -EREMOTE) {28302830+ if (rc != 0 && rc != -EREMOTE) {28432831 kfree(full_path);28442832 goto mount_fail_check;28452833 }
···686686 cFYI(1, "cifs_sfu_type failed: %d", tmprc);687687 }688688689689-#ifdef CONFIG_CIFS_EXPERIMENTAL689689+#ifdef CONFIG_CIFS_ACL690690 /* fill in 0777 bits from ACL */691691 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) {692692 rc = cifs_acl_to_fattr(cifs_sb, &fattr, *pinode, full_path,···697697 goto cgii_exit;698698 }699699 }700700-#endif700700+#endif /* CONFIG_CIFS_ACL */701701702702 /* fill in remaining high mode bits e.g. SUID, VTX */703703 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL)···728728 .lookup = cifs_lookup,729729};730730731731-char *cifs_build_path_to_root(struct cifs_sb_info *cifs_sb)731731+char *cifs_build_path_to_root(struct cifs_sb_info *cifs_sb,732732+ struct cifsTconInfo *tcon)732733{733734 int pplen = cifs_sb->prepathlen;734735 int dfsplen;735736 char *full_path = NULL;736736- struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb);737737738738 /* if no prefix path, simply set path to the root of share to "" */739739 if (pplen == 0) {···875875 char *full_path;876876 struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb);877877878878- full_path = cifs_build_path_to_root(cifs_sb);878878+ full_path = cifs_build_path_to_root(cifs_sb, tcon);879879 if (full_path == NULL)880880 return ERR_PTR(-ENOMEM);881881···16531653cifs_inode_needs_reval(struct inode *inode)16541654{16551655 struct cifsInodeInfo *cifs_i = CIFS_I(inode);16561656+ struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);1656165716571658 if (cifs_i->clientCanCacheRead)16581659 return false;···16641663 if (cifs_i->time == 0)16651664 return true;1666166516671667- /* FIXME: the actimeo should be tunable */16681668- if (time_after_eq(jiffies, cifs_i->time + HZ))16661666+ if (!time_in_range(jiffies, cifs_i->time,16671667+ cifs_i->time + cifs_sb->actimeo))16691668 return true;1670166916711670 /* hardlinked files w/ noserverino get "special" treatment */16721672- if (!(CIFS_SB(inode->i_sb)->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) &&16711671+ if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) &&16731672 S_ISREG(inode->i_mode) && inode->i_nlink != 1)16741673 return true;16751674···2122212121232122 if (attrs->ia_valid & ATTR_MODE) {21242123 rc = 0;21252125-#ifdef CONFIG_CIFS_EXPERIMENTAL21242124+#ifdef CONFIG_CIFS_ACL21262125 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) {21272126 rc = mode_to_cifs_acl(inode, full_path, mode);21282127 if (rc) {···21312130 goto cifs_setattr_exit;21322131 }21332132 } else21342134-#endif21332133+#endif /* CONFIG_CIFS_ACL */21352134 if (((mode & S_IWUGO) == 0) &&21362135 (cifsInode->cifsAttrs & ATTR_READONLY) == 0) {21372136
-12
fs/cifs/readdir.c
···759759 rc = filldir(direntry, qstring.name, qstring.len, file->f_pos,760760 ino, fattr.cf_dtype);761761762762- /*763763- * we can not return filldir errors to the caller since they are764764- * "normal" when the stat blocksize is too small - we return remapped765765- * error instead766766- *767767- * FIXME: This looks bogus. filldir returns -EOVERFLOW in the above768768- * case already. Why should we be clobbering other errors from it?769769- */770770- if (rc) {771771- cFYI(1, "filldir rc = %d", rc);772772- rc = -EOVERFLOW;773773- }774762 dput(tmp_dentry);775763 return rc;776764}
···21252125 */21262126 if (unlikely(journal_data && PageChecked(page)))21272127 err = __ext4_journalled_writepage(page, len);21282128- else21282128+ else if (test_opt(inode->i_sb, MBLK_IO_SUBMIT))21292129 err = ext4_bio_write_page(&io_submit, page,21302130 len, mpd->wbc);21312131+ else21322132+ err = block_write_full_page(page,21332133+ noalloc_get_block_write, mpd->wbc);2131213421322135 if (!err)21332136 mpd->pages_written++;
+1-1
fs/ext4/namei.c
···872872 if (namelen > EXT4_NAME_LEN)873873 return NULL;874874 if ((namelen <= 2) && (name[0] == '.') &&875875- (name[1] == '.' || name[1] == '0')) {875875+ (name[1] == '.' || name[1] == '\0')) {876876 /*877877 * "." or ".." will only be in the first block878878 * NFS may look up ".."; "." should be handled by the VFS
···1313#include <linux/kernel.h>1414#include <linux/sched.h>1515#include <linux/module.h>1616+#include <linux/compat.h>16171718static const struct file_operations fuse_direct_io_file_operations;1819···16291628}1630162916311630/*16311631+ * CUSE servers compiled on 32bit broke on 64bit kernels because the16321632+ * ABI was defined to be 'struct iovec' which is different on 32bit16331633+ * and 64bit. Fortunately we can determine which structure the server16341634+ * used from the size of the reply.16351635+ */16361636+static int fuse_copy_ioctl_iovec(struct iovec *dst, void *src,16371637+ size_t transferred, unsigned count,16381638+ bool is_compat)16391639+{16401640+#ifdef CONFIG_COMPAT16411641+ if (count * sizeof(struct compat_iovec) == transferred) {16421642+ struct compat_iovec *ciov = src;16431643+ unsigned i;16441644+16451645+ /*16461646+ * With this interface a 32bit server cannot support16471647+ * non-compat (i.e. ones coming from 64bit apps) ioctl16481648+ * requests16491649+ */16501650+ if (!is_compat)16511651+ return -EINVAL;16521652+16531653+ for (i = 0; i < count; i++) {16541654+ dst[i].iov_base = compat_ptr(ciov[i].iov_base);16551655+ dst[i].iov_len = ciov[i].iov_len;16561656+ }16571657+ return 0;16581658+ }16591659+#endif16601660+16611661+ if (count * sizeof(struct iovec) != transferred)16621662+ return -EIO;16631663+16641664+ memcpy(dst, src, transferred);16651665+ return 0;16661666+}16671667+16681668+/* Make sure iov_length() won't overflow */16691669+static int fuse_verify_ioctl_iov(struct iovec *iov, size_t count)16701670+{16711671+ size_t n;16721672+ u32 max = FUSE_MAX_PAGES_PER_REQ << PAGE_SHIFT;16731673+16741674+ for (n = 0; n < count; n++) {16751675+ if (iov->iov_len > (size_t) max)16761676+ return -ENOMEM;16771677+ max -= iov->iov_len;16781678+ }16791679+ return 0;16801680+}16811681+16821682+/*16321683 * For ioctls, there is no generic way to determine how much memory16331684 * needs to be read and/or written. Furthermore, ioctls are allowed16341685 * to dereference the passed pointer, so the parameter requires deep···18611808 in_iovs + out_iovs > FUSE_IOCTL_MAX_IOV)18621809 goto out;1863181018641864- err = -EIO;18651865- if ((in_iovs + out_iovs) * sizeof(struct iovec) != transferred)18661866- goto out;18671867-18681868- /* okay, copy in iovs and retry */18691811 vaddr = kmap_atomic(pages[0], KM_USER0);18701870- memcpy(page_address(iov_page), vaddr, transferred);18121812+ err = fuse_copy_ioctl_iovec(page_address(iov_page), vaddr,18131813+ transferred, in_iovs + out_iovs,18141814+ (flags & FUSE_IOCTL_COMPAT) != 0);18711815 kunmap_atomic(vaddr, KM_USER0);18161816+ if (err)18171817+ goto out;1872181818731819 in_iov = page_address(iov_page);18741820 out_iov = in_iov + in_iovs;18211821+18221822+ err = fuse_verify_ioctl_iov(in_iov, in_iovs);18231823+ if (err)18241824+ goto out;18251825+18261826+ err = fuse_verify_ioctl_iov(out_iov, out_iovs);18271827+ if (err)18281828+ goto out;1875182918761830 goto retry;18771831 }
+3
fs/namei.c
···17481748 if (!(open_flag & O_CREAT))17491749 mode = 0;1750175017511751+ /* Must never be set by userspace */17521752+ open_flag &= ~FMODE_NONOTIFY;17531753+17511754 /*17521755 * O_SYNC is implemented as __O_SYNC|O_DSYNC. As many places only17531756 * check for O_DSYNC if the need any syncing at all we enforce it's
+35-41
fs/nfs/dir.c
···5757 struct inode *, struct dentry *);5858static int nfs_fsync_dir(struct file *, int);5959static loff_t nfs_llseek_dir(struct file *, loff_t, int);6060-static int nfs_readdir_clear_array(struct page*, gfp_t);6060+static void nfs_readdir_clear_array(struct page*);61616262const struct file_operations nfs_dir_operations = {6363 .llseek = nfs_llseek_dir,···8383 .setattr = nfs_setattr,8484};85858686-const struct address_space_operations nfs_dir_addr_space_ops = {8787- .releasepage = nfs_readdir_clear_array,8686+const struct address_space_operations nfs_dir_aops = {8787+ .freepage = nfs_readdir_clear_array,8888};89899090#ifdef CONFIG_NFS_V3···178178 struct page *page;179179 unsigned long page_index;180180 u64 *dir_cookie;181181+ u64 last_cookie;181182 loff_t current_index;182183 decode_dirent_t decode;183184···214213 * we are freeing strings created by nfs_add_to_readdir_array()215214 */216215static217217-int nfs_readdir_clear_array(struct page *page, gfp_t mask)216216+void nfs_readdir_clear_array(struct page *page)218217{219219- struct nfs_cache_array *array = nfs_readdir_get_array(page);218218+ struct nfs_cache_array *array;220219 int i;221220222222- if (IS_ERR(array))223223- return PTR_ERR(array);221221+ array = kmap_atomic(page, KM_USER0);224222 for (i = 0; i < array->size; i++)225223 kfree(array->array[i].string.name);226226- nfs_readdir_release_array(page);227227- return 0;224224+ kunmap_atomic(array, KM_USER0);228225}229226230227/*···271272 goto out;272273 array->last_cookie = entry->cookie;273274 array->size++;274274- if (entry->eof == 1)275275+ if (entry->eof != 0)275276 array->eof_index = array->size;276277out:277278 nfs_readdir_release_array(page);···311312 for (i = 0; i < array->size; i++) {312313 if (array->array[i].cookie == *desc->dir_cookie) {313314 desc->cache_entry_index = i;314314- status = 0;315315- goto out;315315+ return 0;316316 }317317 }318318- if (i == array->eof_index) {319319- desc->eof = 1;318318+ if (array->eof_index >= 0) {320319 status = -EBADCOOKIE;320320+ if (*desc->dir_cookie == array->last_cookie)321321+ desc->eof = 1;321322 }322322-out:323323 return status;324324}325325···326328int nfs_readdir_search_array(nfs_readdir_descriptor_t *desc)327329{328330 struct nfs_cache_array *array;329329- int status = -EBADCOOKIE;330330-331331- if (desc->dir_cookie == NULL)332332- goto out;331331+ int status;333332334333 array = nfs_readdir_get_array(desc->page);335334 if (IS_ERR(array)) {···339344 else340345 status = nfs_readdir_search_for_cookie(array, desc);341346347347+ if (status == -EAGAIN) {348348+ desc->last_cookie = array->last_cookie;349349+ desc->page_index++;350350+ }342351 nfs_readdir_release_array(desc->page);343352out:344353 return status;···489490490491 count++;491492492492- if (desc->plus == 1)493493+ if (desc->plus != 0)493494 nfs_prime_dcache(desc->file->f_path.dentry, entry);494495495496 status = nfs_readdir_add_to_array(entry, page);···497498 break;498499 } while (!entry->eof);499500500500- if (count == 0 || (status == -EBADCOOKIE && entry->eof == 1)) {501501+ if (count == 0 || (status == -EBADCOOKIE && entry->eof != 0)) {501502 array = nfs_readdir_get_array(page);502503 if (!IS_ERR(array)) {503504 array->eof_index = array->size;···562563 unsigned int array_size = ARRAY_SIZE(pages);563564564565 entry.prev_cookie = 0;565565- entry.cookie = *desc->dir_cookie;566566+ entry.cookie = desc->last_cookie;566567 entry.eof = 0;567568 entry.fh = nfs_alloc_fhandle();568569 entry.fattr = nfs_alloc_fattr();···635636static636637void cache_page_release(nfs_readdir_descriptor_t *desc)637638{639639+ if (!desc->page->mapping)640640+ nfs_readdir_clear_array(desc->page);638641 page_cache_release(desc->page);639642 desc->page = NULL;640643}···661660 return PTR_ERR(desc->page);662661663662 res = nfs_readdir_search_array(desc);664664- if (res == 0)665665- return 0;666666- cache_page_release(desc);663663+ if (res != 0)664664+ cache_page_release(desc);667665 return res;668666}669667···672672{673673 int res;674674675675- if (desc->page_index == 0)675675+ if (desc->page_index == 0) {676676 desc->current_index = 0;677677- while (1) {678678- res = find_cache_page(desc);679679- if (res != -EAGAIN)680680- break;681681- desc->page_index++;677677+ desc->last_cookie = 0;682678 }679679+ do {680680+ res = find_cache_page(desc);681681+ } while (res == -EAGAIN);683682 return res;684684-}685685-686686-static inline unsigned int dt_type(struct inode *inode)687687-{688688- return (inode->i_mode >> 12) & 15;689683}690684691685/*···711717 break;712718 }713719 file->f_pos++;714714- desc->cache_entry_index = i;715720 if (i < (array->size-1))716721 *desc->dir_cookie = array->array[i+1].cookie;717722 else718723 *desc->dir_cookie = array->last_cookie;719724 }720720- if (i == array->eof_index)725725+ if (array->eof_index >= 0)721726 desc->eof = 1;722727723728 nfs_readdir_release_array(desc->page);···757764 }758765759766 desc->page_index = 0;767767+ desc->last_cookie = *desc->dir_cookie;760768 desc->page = page;761769762770 status = nfs_readdir_xdr_to_array(desc, page, inode);···785791 struct inode *inode = dentry->d_inode;786792 nfs_readdir_descriptor_t my_desc,787793 *desc = &my_desc;788788- int res = -ENOMEM;794794+ int res;789795790796 dfprintk(FILE, "NFS: readdir(%s/%s) starting at cookie %llu\n",791797 dentry->d_parent->d_name.name, dentry->d_name.name,···810816 if (res < 0)811817 goto out;812818813813- while (desc->eof != 1) {819819+ do {814820 res = readdir_search_pagecache(desc);815821816822 if (res == -EBADCOOKIE) {···838844 res = nfs_do_filldir(desc, dirent, filldir);839845 if (res < 0)840846 break;841841- }847847+ } while (!desc->eof);842848out:843849 nfs_unblock_sillyrename(dentry);844850 if (res > 0)
+2
fs/nfs/file.c
···693693{694694 struct inode *inode = filp->f_mapping->host;695695 int status = 0;696696+ unsigned int saved_type = fl->fl_type;696697697698 /* Try local locking first */698699 posix_test_lock(filp, fl);···701700 /* found a conflict */702701 goto out;703702 }703703+ fl->fl_type = saved_type;704704705705 if (nfs_have_delegation(inode, FMODE_READ))706706 goto out_noconflict;
+1
fs/nfs/inode.c
···289289 } else if (S_ISDIR(inode->i_mode)) {290290 inode->i_op = NFS_SB(sb)->nfs_client->rpc_ops->dir_inode_ops;291291 inode->i_fop = &nfs_dir_operations;292292+ inode->i_data.a_ops = &nfs_dir_aops;292293 if (nfs_server_capable(inode, NFS_CAP_READDIRPLUS))293294 set_bit(NFS_INO_ADVISE_RDPLUS, &NFS_I(inode)->flags);294295 /* Deal with crossing mountpoints */
···176176int nilfs_init_gcinode(struct inode *inode)177177{178178 struct nilfs_inode_info *ii = NILFS_I(inode);179179- struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs;180179181180 inode->i_mode = S_IFREG;182181 mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS);···184185185186 ii->i_flags = 0;186187 nilfs_bmap_init_gc(ii->i_bmap);187187-188188- /*189189- * Add the inode to GC inode list. Garbage Collection190190- * is serialized and no two processes manipulate the191191- * list simultaneously.192192- */193193- igrab(inode);194194- list_add(&NILFS_I(inode)->i_dirty, &nilfs->ns_gc_inodes);195188196189 return 0;197190}
+12
fs/nilfs2/ioctl.c
···337337 struct nilfs_argv *argv, void *buf)338338{339339 size_t nmembs = argv->v_nmembs;340340+ struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs;340341 struct inode *inode;341342 struct nilfs_vdesc *vdesc;342343 struct buffer_head *bh, *n;···354353 ret = PTR_ERR(inode);355354 goto failed;356355 }356356+ if (list_empty(&NILFS_I(inode)->i_dirty)) {357357+ /*358358+ * Add the inode to GC inode list. Garbage Collection359359+ * is serialized and no two processes manipulate the360360+ * list simultaneously.361361+ */362362+ igrab(inode);363363+ list_add(&NILFS_I(inode)->i_dirty,364364+ &nilfs->ns_gc_inodes);365365+ }366366+357367 do {358368 ret = nilfs_ioctl_move_inode_block(inode, vdesc,359369 &buffers);
+5-1
fs/notify/fanotify/fanotify.c
···92929393 pr_debug("%s: group=%p event=%p\n", __func__, group, event);94949595- wait_event(group->fanotify_data.access_waitq, event->response);9595+ wait_event(group->fanotify_data.access_waitq, event->response ||9696+ atomic_read(&group->fanotify_data.bypass_perm));9797+9898+ if (!event->response) /* bypass_perm set */9999+ return 0;9610097101 /* userspace responded, convert to something usable */98102 spin_lock(&event->lock);
+51-30
fs/notify/fanotify/fanotify_user.c
···106106 return client_fd;107107}108108109109-static ssize_t fill_event_metadata(struct fsnotify_group *group,109109+static int fill_event_metadata(struct fsnotify_group *group,110110 struct fanotify_event_metadata *metadata,111111 struct fsnotify_event *event)112112{113113+ int ret = 0;114114+113115 pr_debug("%s: group=%p metadata=%p event=%p\n", __func__,114116 group, metadata, event);115117116118 metadata->event_len = FAN_EVENT_METADATA_LEN;119119+ metadata->metadata_len = FAN_EVENT_METADATA_LEN;117120 metadata->vers = FANOTIFY_METADATA_VERSION;118121 metadata->mask = event->mask & FAN_ALL_OUTGOING_EVENTS;119122 metadata->pid = pid_vnr(event->tgid);120120- metadata->fd = create_fd(group, event);123123+ if (unlikely(event->mask & FAN_Q_OVERFLOW))124124+ metadata->fd = FAN_NOFD;125125+ else {126126+ metadata->fd = create_fd(group, event);127127+ if (metadata->fd < 0)128128+ ret = metadata->fd;129129+ }121130122122- return metadata->fd;131131+ return ret;123132}124133125134#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS···209200210201 mutex_lock(&group->fanotify_data.access_mutex);211202212212- if (group->fanotify_data.bypass_perm) {203203+ if (atomic_read(&group->fanotify_data.bypass_perm)) {213204 mutex_unlock(&group->fanotify_data.access_mutex);214205 kmem_cache_free(fanotify_response_event_cache, re);215206 event->response = FAN_ALLOW;···266257267258 pr_debug("%s: group=%p event=%p\n", __func__, group, event);268259269269- fd = fill_event_metadata(group, &fanotify_event_metadata, event);270270- if (fd < 0)271271- return fd;260260+ ret = fill_event_metadata(group, &fanotify_event_metadata, event);261261+ if (ret < 0)262262+ goto out;272263264264+ fd = fanotify_event_metadata.fd;273265 ret = prepare_for_access_response(group, event, fd);274266 if (ret)275267 goto out_close_fd;276268277269 ret = -EFAULT;278278- if (copy_to_user(buf, &fanotify_event_metadata, FAN_EVENT_METADATA_LEN))270270+ if (copy_to_user(buf, &fanotify_event_metadata,271271+ fanotify_event_metadata.event_len))279272 goto out_kill_access_response;280273281281- return FAN_EVENT_METADATA_LEN;274274+ return fanotify_event_metadata.event_len;282275283276out_kill_access_response:284277 remove_access_response(group, event, fd);285278out_close_fd:286286- sys_close(fd);279279+ if (fd != FAN_NOFD)280280+ sys_close(fd);281281+out:282282+#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS283283+ if (event->mask & FAN_ALL_PERM_EVENTS) {284284+ event->response = FAN_DENY;285285+ wake_up(&group->fanotify_data.access_waitq);286286+ }287287+#endif287288 return ret;288289}289290···401382402383 mutex_lock(&group->fanotify_data.access_mutex);403384404404- group->fanotify_data.bypass_perm = true;385385+ atomic_inc(&group->fanotify_data.bypass_perm);405386406387 list_for_each_entry_safe(re, lre, &group->fanotify_data.access_list, list) {407388 pr_debug("%s: found group=%p re=%p event=%p\n", __func__, group,···605586{606587 struct fsnotify_mark *fsn_mark;607588 __u32 added;589589+ int ret = 0;608590609591 fsn_mark = fsnotify_find_vfsmount_mark(group, mnt);610592 if (!fsn_mark) {611611- int ret;612612-613593 if (atomic_read(&group->num_marks) > group->fanotify_data.max_marks)614594 return -ENOSPC;615595···618600619601 fsnotify_init_mark(fsn_mark, fanotify_free_mark);620602 ret = fsnotify_add_mark(fsn_mark, group, NULL, mnt, 0);621621- if (ret) {622622- fanotify_free_mark(fsn_mark);623623- return ret;624624- }603603+ if (ret)604604+ goto err;625605 }626606 added = fanotify_mark_add_to_mask(fsn_mark, mask, flags);627627- fsnotify_put_mark(fsn_mark);607607+628608 if (added & ~mnt->mnt_fsnotify_mask)629609 fsnotify_recalc_vfsmount_mask(mnt);630630-631631- return 0;610610+err:611611+ fsnotify_put_mark(fsn_mark);612612+ return ret;632613}633614634615static int fanotify_add_inode_mark(struct fsnotify_group *group,···636619{637620 struct fsnotify_mark *fsn_mark;638621 __u32 added;622622+ int ret = 0;639623640624 pr_debug("%s: group=%p inode=%p\n", __func__, group, inode);641625···652634653635 fsn_mark = fsnotify_find_inode_mark(group, inode);654636 if (!fsn_mark) {655655- int ret;656656-657637 if (atomic_read(&group->num_marks) > group->fanotify_data.max_marks)658638 return -ENOSPC;659639···661645662646 fsnotify_init_mark(fsn_mark, fanotify_free_mark);663647 ret = fsnotify_add_mark(fsn_mark, group, inode, NULL, 0);664664- if (ret) {665665- fanotify_free_mark(fsn_mark);666666- return ret;667667- }648648+ if (ret)649649+ goto err;668650 }669651 added = fanotify_mark_add_to_mask(fsn_mark, mask, flags);670670- fsnotify_put_mark(fsn_mark);652652+671653 if (added & ~inode->i_fsnotify_mask)672654 fsnotify_recalc_inode_mask(inode);673673- return 0;655655+err:656656+ fsnotify_put_mark(fsn_mark);657657+ return ret;674658}675659676660/* fanotify syscalls */···703687704688 /* fsnotify_alloc_group takes a ref. Dropped in fanotify_release */705689 group = fsnotify_alloc_group(&fanotify_fsnotify_ops);706706- if (IS_ERR(group))690690+ if (IS_ERR(group)) {691691+ free_uid(user);707692 return PTR_ERR(group);693693+ }708694709695 group->fanotify_data.user = user;710696 atomic_inc(&user->fanotify_listeners);···716698 mutex_init(&group->fanotify_data.access_mutex);717699 init_waitqueue_head(&group->fanotify_data.access_waitq);718700 INIT_LIST_HEAD(&group->fanotify_data.access_list);701701+ atomic_set(&group->fanotify_data.bypass_perm, 0);719702#endif720703 switch (flags & FAN_ALL_CLASS_BITS) {721704 case FAN_CLASS_NOTIF:···783764 if (flags & ~FAN_ALL_MARK_FLAGS)784765 return -EINVAL;785766 switch (flags & (FAN_MARK_ADD | FAN_MARK_REMOVE | FAN_MARK_FLUSH)) {786786- case FAN_MARK_ADD:767767+ case FAN_MARK_ADD: /* fallthrough */787768 case FAN_MARK_REMOVE:769769+ if (!mask)770770+ return -EINVAL;788771 case FAN_MARK_FLUSH:789772 break;790773 default:
+1
fs/notify/inotify/inotify_user.c
···752752 if (ret >= 0)753753 return ret;754754755755+ fsnotify_put_group(group);755756 atomic_dec(&user->inotify_devs);756757out_free_uid:757758 free_uid(user);
+1
fs/xfs/xfs_rename.c
···297297 * it and some incremental backup programs won't work without it.298298 */299299 xfs_trans_ichgtime(tp, src_ip, XFS_ICHGTIME_CHG);300300+ xfs_trans_log_inode(tp, src_ip, XFS_ILOG_CORE);300301301302 /*302303 * Adjust the link count on src_dp. This is necessary when
···227227extern void ceph_release_page_vector(struct page **pages, int num_pages);228228229229extern struct page **ceph_get_direct_page_vector(const char __user *data,230230- int num_pages);231231-extern void ceph_put_page_vector(struct page **pages, int num_pages);230230+ int num_pages,231231+ bool write_page);232232+extern void ceph_put_page_vector(struct page **pages, int num_pages,233233+ bool dirty);232234extern void ceph_release_page_vector(struct page **pages, int num_pages);233235extern struct page **ceph_alloc_page_vector(int num_pages, gfp_t flags);234236extern int ceph_copy_user_to_page_vector(struct page **pages,
+19-1
include/linux/cnt32_to_63.h
···6161 *6262 * 2) this code must not be preempted for a duration longer than the6363 * 32-bit counter half period minus the longest period between two6464- * calls to this code.6464+ * calls to this code;6565 *6666 * Those requirements ensure proper update to the state bit in memory.6767 * This is usually not a problem in practice, but if it is then a kernel6868 * timer should be scheduled to manage for this code to be executed often6969 * enough.7070+ *7171+ * And finally:7272+ *7373+ * 3) the cnt_lo argument must be seen as a globally incrementing value,7474+ * meaning that it should be a direct reference to the counter data which7575+ * can be evaluated according to a specific ordering within the macro,7676+ * and not the result of a previous evaluation stored in a variable.7777+ *7878+ * For example, this is wrong:7979+ *8080+ * u32 partial = get_hw_count();8181+ * u64 full = cnt32_to_63(partial);8282+ * return full;8383+ *8484+ * This is fine:8585+ *8686+ * u64 full = cnt32_to_63(get_hw_count());8787+ * return full;7088 *7189 * Note that the top bit (bit 63) in the returned value should be considered7290 * as garbage. It is not cleared here because callers are likely to use a
+7-3
include/linux/fanotify.h
···8383 FAN_ALL_PERM_EVENTS |\8484 FAN_Q_OVERFLOW)85858686-#define FANOTIFY_METADATA_VERSION 28686+#define FANOTIFY_METADATA_VERSION 387878888struct fanotify_event_metadata {8989 __u32 event_len;9090- __u32 vers;9090+ __u8 vers;9191+ __u8 reserved;9292+ __u16 metadata_len;9193 __aligned_u64 mask;9294 __s32 fd;9395 __s32 pid;···9896struct fanotify_response {9997 __s32 fd;10098 __u32 response;101101-} __attribute__ ((packed));9999+};102100103101/* Legit userspace responses to a _PERM event */104102#define FAN_ALLOW 0x01105103#define FAN_DENY 0x02104104+/* No fd set in event */105105+#define FAN_NOFD -1106106107107/* Helper functions to deal with fanotify_event_metadata buffers */108108#define FAN_EVENT_METADATA_LEN (sizeof(struct fanotify_event_metadata))
···235235 if (S_ISDIR(inode->i_mode))236236 mask |= FS_ISDIR;237237238238- /* FMODE_NONOTIFY must never be set from user */239239- file->f_mode &= ~FMODE_NONOTIFY;240240-241238 fsnotify_parent(path, NULL, mask);242239 fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0);243240}
+1-1
include/linux/fsnotify_backend.h
···166166 struct mutex access_mutex;167167 struct list_head access_list;168168 wait_queue_head_t access_waitq;169169- bool bypass_perm; /* protected by access_mutex */169169+ atomic_t bypass_perm;170170#endif /* CONFIG_FANOTIFY_ACCESS_PERMISSIONS */171171 int f_flags;172172 unsigned int max_marks;
+4-2
include/linux/input.h
···104104#define EVIOCGREP _IOR('E', 0x03, unsigned int[2]) /* get repeat settings */105105#define EVIOCSREP _IOW('E', 0x03, unsigned int[2]) /* set repeat settings */106106107107-#define EVIOCGKEYCODE _IOR('E', 0x04, struct input_keymap_entry) /* get keycode */108108-#define EVIOCSKEYCODE _IOW('E', 0x04, struct input_keymap_entry) /* set keycode */107107+#define EVIOCGKEYCODE _IOR('E', 0x04, unsigned int[2]) /* get keycode */108108+#define EVIOCGKEYCODE_V2 _IOR('E', 0x04, struct input_keymap_entry)109109+#define EVIOCSKEYCODE _IOW('E', 0x04, unsigned int[2]) /* set keycode */110110+#define EVIOCSKEYCODE_V2 _IOW('E', 0x04, struct input_keymap_entry)109111110112#define EVIOCGNAME(len) _IOC(_IOC_READ, 'E', 0x06, len) /* get device name */111113#define EVIOCGPHYS(len) _IOC(_IOC_READ, 'E', 0x07, len) /* get physical location */
+1-1
include/linux/ioport.h
···112112/* PC/ISA/whatever - the normal PC address spaces: IO and memory */113113extern struct resource ioport_resource;114114extern struct resource iomem_resource;115115-extern int resource_alloc_from_bottom;116115117116extern struct resource *request_resource_conflict(struct resource *root, struct resource *new);118117extern int request_resource(struct resource *root, struct resource *new);···123124extern struct resource *insert_resource_conflict(struct resource *parent, struct resource *new);124125extern int insert_resource(struct resource *parent, struct resource *new);125126extern void insert_resource_expand_to_fit(struct resource *root, struct resource *new);127127+extern void arch_remove_reservations(struct resource *avail);126128extern int allocate_resource(struct resource *root, struct resource *new,127129 resource_size_t size, resource_size_t min,128130 resource_size_t max, resource_size_t align,
+1-1
include/linux/mfd/wm8994/pdata.h
···2929#define WM8994_CONFIGURE_GPIO 0x800030303131#define WM8994_DRC_REGS 53232-#define WM8994_EQ_REGS 193232+#define WM8994_EQ_REGS 2033333434/**3535 * DRC configurations are specified with a label and a set of register
···143143extern unsigned long this_cpu_load(void);144144145145146146-extern void calc_global_load(void);146146+extern void calc_global_load(unsigned long ticks);147147148148extern unsigned long get_parent_ip(unsigned long addr);149149
···5151 unsigned int notification, void *arg);5252 /* The control handler. May be NULL. */5353 struct v4l2_ctrl_handler *ctrl_handler;5454+ /* BKL replacement mutex. Temporary solution only. */5555+ struct mutex ioctl_lock;5456};55575658/* Initialize v4l2_dev and make dev->driver_data point to v4l2_dev.
···2424 * A ring contains as many entries as will fit, rounded down to the nearest2525 * power of two (so we can mask with (size-1) to loop around).2626 */2727-#define __RING_SIZE(_s, _sz) \2828- (__RD32(((_sz) - (long)&(_s)->ring + (long)(_s)) / sizeof((_s)->ring[0])))2727+#define __CONST_RING_SIZE(_s, _sz) \2828+ (__RD32(((_sz) - offsetof(struct _s##_sring, ring)) / \2929+ sizeof(((struct _s##_sring *)0)->ring[0])))3030+3131+/*3232+ * The same for passing in an actual pointer instead of a name tag.3333+ */3434+#define __RING_SIZE(_s, _sz) \3535+ (__RD32(((_sz) - (long)&(_s)->ring + (long)(_s)) / sizeof((_s)->ring[0])))29363037/*3138 * Macros to make the correct C datatypes for a new kind of ring.
···30303131#include "power.h"32323333-#define HIBERNATE_SIG "LINHIB0001"3333+#define HIBERNATE_SIG "S1SUSPEND"34343535/*3636 * The swap map is a data structure used for keeping track of each page
···40404141static DEFINE_RWLOCK(resource_lock);42424343-/*4444- * By default, we allocate free space bottom-up. The architecture can request4545- * top-down by clearing this flag. The user can override the architecture's4646- * choice with the "resource_alloc_from_bottom" kernel boot option, but that4747- * should only be a debugging tool.4848- */4949-int resource_alloc_from_bottom = 1;5050-5151-static __init int setup_alloc_from_bottom(char *s)5252-{5353- printk(KERN_INFO5454- "resource: allocating from bottom-up; please report a bug\n");5555- resource_alloc_from_bottom = 1;5656- return 0;5757-}5858-early_param("resource_alloc_from_bottom", setup_alloc_from_bottom);5959-6043static void *r_next(struct seq_file *m, void *v, loff_t *pos)6144{6245 struct resource *p = v;···357374 return walk_system_ram_range(pfn, 1, NULL, __is_ram) == 1;358375}359376377377+void __weak arch_remove_reservations(struct resource *avail)378378+{379379+}380380+360381static resource_size_t simple_align_resource(void *data,361382 const struct resource *avail,362383 resource_size_t size,···384397}385398386399/*387387- * Find the resource before "child" in the sibling list of "root" children.388388- */389389-static struct resource *find_sibling_prev(struct resource *root, struct resource *child)390390-{391391- struct resource *this;392392-393393- for (this = root->child; this; this = this->sibling)394394- if (this->sibling == child)395395- return this;396396-397397- return NULL;398398-}399399-400400-/*401400 * Find empty slot in the resource tree given range and alignment.402402- * This version allocates from the end of the root resource first.403403- */404404-static int find_resource_from_top(struct resource *root, struct resource *new,405405- resource_size_t size, resource_size_t min,406406- resource_size_t max, resource_size_t align,407407- resource_size_t (*alignf)(void *,408408- const struct resource *,409409- resource_size_t,410410- resource_size_t),411411- void *alignf_data)412412-{413413- struct resource *this;414414- struct resource tmp, avail, alloc;415415-416416- tmp.start = root->end;417417- tmp.end = root->end;418418-419419- this = find_sibling_prev(root, NULL);420420- for (;;) {421421- if (this) {422422- if (this->end < root->end)423423- tmp.start = this->end + 1;424424- } else425425- tmp.start = root->start;426426-427427- resource_clip(&tmp, min, max);428428-429429- /* Check for overflow after ALIGN() */430430- avail = *new;431431- avail.start = ALIGN(tmp.start, align);432432- avail.end = tmp.end;433433- if (avail.start >= tmp.start) {434434- alloc.start = alignf(alignf_data, &avail, size, align);435435- alloc.end = alloc.start + size - 1;436436- if (resource_contains(&avail, &alloc)) {437437- new->start = alloc.start;438438- new->end = alloc.end;439439- return 0;440440- }441441- }442442-443443- if (!this || this->start == root->start)444444- break;445445-446446- tmp.end = this->start - 1;447447- this = find_sibling_prev(root, this);448448- }449449- return -EBUSY;450450-}451451-452452-/*453453- * Find empty slot in the resource tree given range and alignment.454454- * This version allocates from the beginning of the root resource first.455401 */456402static int find_resource(struct resource *root, struct resource *new,457403 resource_size_t size, resource_size_t min,···398478 struct resource *this = root->child;399479 struct resource tmp = *new, avail, alloc;400480481481+ tmp.flags = new->flags;401482 tmp.start = root->start;402483 /*403403- * Skip past an allocated resource that starts at 0, since the404404- * assignment of this->start - 1 to tmp->end below would cause an405405- * underflow.484484+ * Skip past an allocated resource that starts at 0, since the assignment485485+ * of this->start - 1 to tmp->end below would cause an underflow.406486 */407487 if (this && this->start == 0) {408488 tmp.start = this->end + 1;409489 this = this->sibling;410490 }411411- for (;;) {491491+ for(;;) {412492 if (this)413493 tmp.end = this->start - 1;414494 else415495 tmp.end = root->end;416496417497 resource_clip(&tmp, min, max);498498+ arch_remove_reservations(&tmp);418499419500 /* Check for overflow after ALIGN() */420501 avail = *new;···430509 return 0;431510 }432511 }433433-434512 if (!this)435513 break;436436-437514 tmp.start = this->end + 1;438515 this = this->sibling;439516 }···464545 alignf = simple_align_resource;465546466547 write_lock(&resource_lock);467467- if (resource_alloc_from_bottom)468468- err = find_resource(root, new, size, min, max, align, alignf, alignf_data);469469- else470470- err = find_resource_from_top(root, new, size, min, max, align, alignf, alignf_data);548548+ err = find_resource(root, new, size, min, max, align, alignf, alignf_data);471549 if (err >= 0 && __request_resource(root, new))472550 err = -EBUSY;473551 write_unlock(&resource_lock);
+238-53
kernel/sched.c
···636636637637#endif /* CONFIG_CGROUP_SCHED */638638639639-static u64 irq_time_cpu(int cpu);640640-static void sched_irq_time_avg_update(struct rq *rq, u64 irq_time);639639+static void update_rq_clock_task(struct rq *rq, s64 delta);641640642642-inline void update_rq_clock(struct rq *rq)641641+static void update_rq_clock(struct rq *rq)643642{644644- if (!rq->skip_clock_update) {645645- int cpu = cpu_of(rq);646646- u64 irq_time;643643+ s64 delta;647644648648- rq->clock = sched_clock_cpu(cpu);649649- irq_time = irq_time_cpu(cpu);650650- if (rq->clock - irq_time > rq->clock_task)651651- rq->clock_task = rq->clock - irq_time;645645+ if (rq->skip_clock_update)646646+ return;652647653653- sched_irq_time_avg_update(rq, irq_time);654654- }648648+ delta = sched_clock_cpu(cpu_of(rq)) - rq->clock;649649+ rq->clock += delta;650650+ update_rq_clock_task(rq, delta);655651}656652657653/*···19201924 * They are read and saved off onto struct rq in update_rq_clock().19211925 * This may result in other CPU reading this CPU's irq time and can19221926 * race with irq/account_system_vtime on this CPU. We would either get old19231923- * or new value (or semi updated value on 32 bit) with a side effect of19241924- * accounting a slice of irq time to wrong task when irq is in progress19251925- * while we read rq->clock. That is a worthy compromise in place of having19261926- * locks on each irq in account_system_time.19271927+ * or new value with a side effect of accounting a slice of irq time to wrong19281928+ * task when irq is in progress while we read rq->clock. That is a worthy19291929+ * compromise in place of having locks on each irq in account_system_time.19271930 */19281931static DEFINE_PER_CPU(u64, cpu_hardirq_time);19291932static DEFINE_PER_CPU(u64, cpu_softirq_time);···19401945 sched_clock_irqtime = 0;19411946}1942194719431943-static u64 irq_time_cpu(int cpu)19441944-{19451945- if (!sched_clock_irqtime)19461946- return 0;19481948+#ifndef CONFIG_64BIT19491949+static DEFINE_PER_CPU(seqcount_t, irq_time_seq);1947195019481948- return per_cpu(cpu_softirq_time, cpu) + per_cpu(cpu_hardirq_time, cpu);19511951+static inline void irq_time_write_begin(void)19521952+{19531953+ __this_cpu_inc(irq_time_seq.sequence);19541954+ smp_wmb();19491955}1950195619571957+static inline void irq_time_write_end(void)19581958+{19591959+ smp_wmb();19601960+ __this_cpu_inc(irq_time_seq.sequence);19611961+}19621962+19631963+static inline u64 irq_time_read(int cpu)19641964+{19651965+ u64 irq_time;19661966+ unsigned seq;19671967+19681968+ do {19691969+ seq = read_seqcount_begin(&per_cpu(irq_time_seq, cpu));19701970+ irq_time = per_cpu(cpu_softirq_time, cpu) +19711971+ per_cpu(cpu_hardirq_time, cpu);19721972+ } while (read_seqcount_retry(&per_cpu(irq_time_seq, cpu), seq));19731973+19741974+ return irq_time;19751975+}19761976+#else /* CONFIG_64BIT */19771977+static inline void irq_time_write_begin(void)19781978+{19791979+}19801980+19811981+static inline void irq_time_write_end(void)19821982+{19831983+}19841984+19851985+static inline u64 irq_time_read(int cpu)19861986+{19871987+ return per_cpu(cpu_softirq_time, cpu) + per_cpu(cpu_hardirq_time, cpu);19881988+}19891989+#endif /* CONFIG_64BIT */19901990+19911991+/*19921992+ * Called before incrementing preempt_count on {soft,}irq_enter19931993+ * and before decrementing preempt_count on {soft,}irq_exit.19941994+ */19511995void account_system_vtime(struct task_struct *curr)19521996{19531997 unsigned long flags;19981998+ s64 delta;19541999 int cpu;19551955- u64 now, delta;1956200019572001 if (!sched_clock_irqtime)19582002 return;···19991965 local_irq_save(flags);2000196620011967 cpu = smp_processor_id();20022002- now = sched_clock_cpu(cpu);20032003- delta = now - per_cpu(irq_start_time, cpu);20042004- per_cpu(irq_start_time, cpu) = now;19681968+ delta = sched_clock_cpu(cpu) - __this_cpu_read(irq_start_time);19691969+ __this_cpu_add(irq_start_time, delta);19701970+19711971+ irq_time_write_begin();20051972 /*20061973 * We do not account for softirq time from ksoftirqd here.20071974 * We want to continue accounting softirq time to ksoftirqd thread···20101975 * that do not consume any time, but still wants to run.20111976 */20121977 if (hardirq_count())20132013- per_cpu(cpu_hardirq_time, cpu) += delta;19781978+ __this_cpu_add(cpu_hardirq_time, delta);20141979 else if (in_serving_softirq() && !(curr->flags & PF_KSOFTIRQD))20152015- per_cpu(cpu_softirq_time, cpu) += delta;19801980+ __this_cpu_add(cpu_softirq_time, delta);2016198119821982+ irq_time_write_end();20171983 local_irq_restore(flags);20181984}20191985EXPORT_SYMBOL_GPL(account_system_vtime);2020198620212021-static void sched_irq_time_avg_update(struct rq *rq, u64 curr_irq_time)19871987+static void update_rq_clock_task(struct rq *rq, s64 delta)20221988{20232023- if (sched_clock_irqtime && sched_feat(NONIRQ_POWER)) {20242024- u64 delta_irq = curr_irq_time - rq->prev_irq_time;20252025- rq->prev_irq_time = curr_irq_time;20262026- sched_rt_avg_update(rq, delta_irq);20272027- }19891989+ s64 irq_delta;19901990+19911991+ irq_delta = irq_time_read(cpu_of(rq)) - rq->prev_irq_time;19921992+19931993+ /*19941994+ * Since irq_time is only updated on {soft,}irq_exit, we might run into19951995+ * this case when a previous update_rq_clock() happened inside a19961996+ * {soft,}irq region.19971997+ *19981998+ * When this happens, we stop ->clock_task and only update the19991999+ * prev_irq_time stamp to account for the part that fit, so that a next20002000+ * update will consume the rest. This ensures ->clock_task is20012001+ * monotonic.20022002+ *20032003+ * It does however cause some slight miss-attribution of {soft,}irq20042004+ * time, a more accurate solution would be to update the irq_time using20052005+ * the current rq->clock timestamp, except that would require using20062006+ * atomic ops.20072007+ */20082008+ if (irq_delta > delta)20092009+ irq_delta = delta;20102010+20112011+ rq->prev_irq_time += irq_delta;20122012+ delta -= irq_delta;20132013+ rq->clock_task += delta;20142014+20152015+ if (irq_delta && sched_feat(NONIRQ_POWER))20162016+ sched_rt_avg_update(rq, irq_delta);20282017}2029201820302030-#else20192019+#else /* CONFIG_IRQ_TIME_ACCOUNTING */2031202020322032-static u64 irq_time_cpu(int cpu)20212021+static void update_rq_clock_task(struct rq *rq, s64 delta)20332022{20342034- return 0;20232023+ rq->clock_task += delta;20352024}2036202520372037-static void sched_irq_time_avg_update(struct rq *rq, u64 curr_irq_time) { }20382038-20392039-#endif20262026+#endif /* CONFIG_IRQ_TIME_ACCOUNTING */2040202720412028#include "sched_idletask.c"20422029#include "sched_fair.c"···21862129 * A queue event has occurred, and we're going to schedule. In21872130 * this case, we can save a useless back to back clock update.21882131 */21892189- if (test_tsk_need_resched(rq->curr))21322132+ if (rq->curr->se.on_rq && test_tsk_need_resched(rq->curr))21902133 rq->skip_clock_update = 1;21912134}21922135···31763119 return delta;31773120}3178312131223122+static unsigned long31233123+calc_load(unsigned long load, unsigned long exp, unsigned long active)31243124+{31253125+ load *= exp;31263126+ load += active * (FIXED_1 - exp);31273127+ load += 1UL << (FSHIFT - 1);31283128+ return load >> FSHIFT;31293129+}31303130+31793131#ifdef CONFIG_NO_HZ31803132/*31813133 * For NO_HZ we delay the active fold to the next LOAD_FREQ update.···3214314832153149 return delta;32163150}31513151+31523152+/**31533153+ * fixed_power_int - compute: x^n, in O(log n) time31543154+ *31553155+ * @x: base of the power31563156+ * @frac_bits: fractional bits of @x31573157+ * @n: power to raise @x to.31583158+ *31593159+ * By exploiting the relation between the definition of the natural power31603160+ * function: x^n := x*x*...*x (x multiplied by itself for n times), and31613161+ * the binary encoding of numbers used by computers: n := \Sum n_i * 2^i,31623162+ * (where: n_i \elem {0, 1}, the binary vector representing n),31633163+ * we find: x^n := x^(\Sum n_i * 2^i) := \Prod x^(n_i * 2^i), which is31643164+ * of course trivially computable in O(log_2 n), the length of our binary31653165+ * vector.31663166+ */31673167+static unsigned long31683168+fixed_power_int(unsigned long x, unsigned int frac_bits, unsigned int n)31693169+{31703170+ unsigned long result = 1UL << frac_bits;31713171+31723172+ if (n) for (;;) {31733173+ if (n & 1) {31743174+ result *= x;31753175+ result += 1UL << (frac_bits - 1);31763176+ result >>= frac_bits;31773177+ }31783178+ n >>= 1;31793179+ if (!n)31803180+ break;31813181+ x *= x;31823182+ x += 1UL << (frac_bits - 1);31833183+ x >>= frac_bits;31843184+ }31853185+31863186+ return result;31873187+}31883188+31893189+/*31903190+ * a1 = a0 * e + a * (1 - e)31913191+ *31923192+ * a2 = a1 * e + a * (1 - e)31933193+ * = (a0 * e + a * (1 - e)) * e + a * (1 - e)31943194+ * = a0 * e^2 + a * (1 - e) * (1 + e)31953195+ *31963196+ * a3 = a2 * e + a * (1 - e)31973197+ * = (a0 * e^2 + a * (1 - e) * (1 + e)) * e + a * (1 - e)31983198+ * = a0 * e^3 + a * (1 - e) * (1 + e + e^2)31993199+ *32003200+ * ...32013201+ *32023202+ * an = a0 * e^n + a * (1 - e) * (1 + e + ... + e^n-1) [1]32033203+ * = a0 * e^n + a * (1 - e) * (1 - e^n)/(1 - e)32043204+ * = a0 * e^n + a * (1 - e^n)32053205+ *32063206+ * [1] application of the geometric series:32073207+ *32083208+ * n 1 - x^(n+1)32093209+ * S_n := \Sum x^i = -------------32103210+ * i=0 1 - x32113211+ */32123212+static unsigned long32133213+calc_load_n(unsigned long load, unsigned long exp,32143214+ unsigned long active, unsigned int n)32153215+{32163216+32173217+ return calc_load(load, fixed_power_int(exp, FSHIFT, n), active);32183218+}32193219+32203220+/*32213221+ * NO_HZ can leave us missing all per-cpu ticks calling32223222+ * calc_load_account_active(), but since an idle CPU folds its delta into32233223+ * calc_load_tasks_idle per calc_load_account_idle(), all we need to do is fold32243224+ * in the pending idle delta if our idle period crossed a load cycle boundary.32253225+ *32263226+ * Once we've updated the global active value, we need to apply the exponential32273227+ * weights adjusted to the number of cycles missed.32283228+ */32293229+static void calc_global_nohz(unsigned long ticks)32303230+{32313231+ long delta, active, n;32323232+32333233+ if (time_before(jiffies, calc_load_update))32343234+ return;32353235+32363236+ /*32373237+ * If we crossed a calc_load_update boundary, make sure to fold32383238+ * any pending idle changes, the respective CPUs might have32393239+ * missed the tick driven calc_load_account_active() update32403240+ * due to NO_HZ.32413241+ */32423242+ delta = calc_load_fold_idle();32433243+ if (delta)32443244+ atomic_long_add(delta, &calc_load_tasks);32453245+32463246+ /*32473247+ * If we were idle for multiple load cycles, apply them.32483248+ */32493249+ if (ticks >= LOAD_FREQ) {32503250+ n = ticks / LOAD_FREQ;32513251+32523252+ active = atomic_long_read(&calc_load_tasks);32533253+ active = active > 0 ? active * FIXED_1 : 0;32543254+32553255+ avenrun[0] = calc_load_n(avenrun[0], EXP_1, active, n);32563256+ avenrun[1] = calc_load_n(avenrun[1], EXP_5, active, n);32573257+ avenrun[2] = calc_load_n(avenrun[2], EXP_15, active, n);32583258+32593259+ calc_load_update += n * LOAD_FREQ;32603260+ }32613261+32623262+ /*32633263+ * Its possible the remainder of the above division also crosses32643264+ * a LOAD_FREQ period, the regular check in calc_global_load()32653265+ * which comes after this will take care of that.32663266+ *32673267+ * Consider us being 11 ticks before a cycle completion, and us32683268+ * sleeping for 4*LOAD_FREQ + 22 ticks, then the above code will32693269+ * age us 4 cycles, and the test in calc_global_load() will32703270+ * pick up the final one.32713271+ */32723272+}32173273#else32183274static void calc_load_account_idle(struct rq *this_rq)32193275{···33443156static inline long calc_load_fold_idle(void)33453157{33463158 return 0;31593159+}31603160+31613161+static void calc_global_nohz(unsigned long ticks)31623162+{33473163}33483164#endif33493165···33663174 loads[2] = (avenrun[2] + offset) << shift;33673175}3368317633693369-static unsigned long33703370-calc_load(unsigned long load, unsigned long exp, unsigned long active)33713371-{33723372- load *= exp;33733373- load += active * (FIXED_1 - exp);33743374- return load >> FSHIFT;33753375-}33763376-33773177/*33783178 * calc_load - update the avenrun load estimates 10 ticks after the33793179 * CPUs have updated calc_load_tasks.33803180 */33813381-void calc_global_load(void)31813181+void calc_global_load(unsigned long ticks)33823182{33833383- unsigned long upd = calc_load_update + 10;33843183 long active;3385318433863386- if (time_before(jiffies, upd))31853185+ calc_global_nohz(ticks);31863186+31873187+ if (time_before(jiffies, calc_load_update + 10))33873188 return;3388318933893190 active = atomic_long_read(&calc_load_tasks);···40303845{40313846 if (prev->se.on_rq)40323847 update_rq_clock(rq);40334033- rq->skip_clock_update = 0;40343848 prev->sched_class->put_prev_task(rq, prev);40353849}40363850···40873903 hrtick_clear(rq);4088390440893905 raw_spin_lock_irq(&rq->lock);40904090- clear_tsk_need_resched(prev);4091390640923907 switch_count = &prev->nivcsw;40933908 if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) {···4118393541193936 put_prev_task(rq, prev);41203937 next = pick_next_task(rq);39383938+ clear_tsk_need_resched(prev);39393939+ rq->skip_clock_update = 0;4121394041223941 if (likely(prev != next)) {41233942 sched_info_switch(prev, next);
+7-1
kernel/timer.c
···12521252 struct tvec_base *base = __get_cpu_var(tvec_bases);12531253 unsigned long expires;1254125412551255+ /*12561256+ * Pretend that there is no timer pending if the cpu is offline.12571257+ * Possible pending timers will be migrated later to an active cpu.12581258+ */12591259+ if (cpu_is_offline(smp_processor_id()))12601260+ return now + NEXT_TIMER_MAX_DELTA;12551261 spin_lock(&base->lock);12561262 if (time_before_eq(base->next_timer, base->timer_jiffies))12571263 base->next_timer = __next_timer_interrupt(base);···13251319{13261320 jiffies_64 += ticks;13271321 update_wall_time();13281328- calc_global_load();13221322+ calc_global_load(ticks);13291323}1330132413311325#ifdef __ARCH_WANT_SYS_ALARM
+4-3
kernel/workqueue.c
···661661{662662 struct worker *worker = kthread_data(task);663663664664- if (likely(!(worker->flags & WORKER_NOT_RUNNING)))664664+ if (!(worker->flags & WORKER_NOT_RUNNING))665665 atomic_inc(get_gcwq_nr_running(cpu));666666}667667···687687 struct global_cwq *gcwq = get_gcwq(cpu);688688 atomic_t *nr_running = get_gcwq_nr_running(cpu);689689690690- if (unlikely(worker->flags & WORKER_NOT_RUNNING))690690+ if (worker->flags & WORKER_NOT_RUNNING)691691 return NULL;692692693693 /* this can only happen on the local cpu */···36923692 system_nrt_wq = alloc_workqueue("events_nrt", WQ_NON_REENTRANT, 0);36933693 system_unbound_wq = alloc_workqueue("events_unbound", WQ_UNBOUND,36943694 WQ_UNBOUND_MAX_ACTIVE);36953695- BUG_ON(!system_wq || !system_long_wq || !system_nrt_wq);36953695+ BUG_ON(!system_wq || !system_long_wq || !system_nrt_wq ||36963696+ !system_unbound_wq);36963697 return 0;36973698}36983699early_initcall(init_workqueues);
···231231 /* when initializing use the value from init_rcv_wnd232232 * rather than the default from above233233 */234234- if (init_rcv_wnd &&235235- (*rcv_wnd > init_rcv_wnd * mss))236236- *rcv_wnd = init_rcv_wnd * mss;237237- else if (*rcv_wnd > init_cwnd * mss)238238- *rcv_wnd = init_cwnd * mss;234234+ if (init_rcv_wnd)235235+ *rcv_wnd = min(*rcv_wnd, init_rcv_wnd * mss);236236+ else237237+ *rcv_wnd = min(*rcv_wnd, init_cwnd * mss);239238 }240239241240 /* Set the clamp no higher than max representable value */···385386 */386387static u8 tcp_cookie_size_check(u8 desired)387388{388388- if (desired > 0) {389389+ int cookie_size;390390+391391+ if (desired > 0)389392 /* previously specified */390393 return desired;391391- }392392- if (sysctl_tcp_cookie_size <= 0) {394394+395395+ cookie_size = ACCESS_ONCE(sysctl_tcp_cookie_size);396396+ if (cookie_size <= 0)393397 /* no default specified */394398 return 0;395395- }396396- if (sysctl_tcp_cookie_size <= TCP_COOKIE_MIN) {399399+400400+ if (cookie_size <= TCP_COOKIE_MIN)397401 /* value too small, specify minimum */398402 return TCP_COOKIE_MIN;399399- }400400- if (sysctl_tcp_cookie_size >= TCP_COOKIE_MAX) {403403+404404+ if (cookie_size >= TCP_COOKIE_MAX)401405 /* value too large, specify maximum */402406 return TCP_COOKIE_MAX;403403- }404404- if (0x1 & sysctl_tcp_cookie_size) {407407+408408+ if (cookie_size & 1)405409 /* 8-bit multiple, illegal, fix it */406406- return (u8)(sysctl_tcp_cookie_size + 0x1);407407- }408408- return (u8)sysctl_tcp_cookie_size;410410+ cookie_size++;411411+412412+ return (u8)cookie_size;409413}410414411415/* Write previously computed TCP options to the packet.···15151513 struct tcp_sock *tp = tcp_sk(sk);15161514 const struct inet_connection_sock *icsk = inet_csk(sk);15171515 u32 send_win, cong_win, limit, in_flight;15161516+ int win_divisor;1518151715191518 if (TCP_SKB_CB(skb)->flags & TCPHDR_FIN)15201519 goto send_now;···15471544 if ((skb != tcp_write_queue_tail(sk)) && (limit >= skb->len))15481545 goto send_now;1549154615501550- if (sysctl_tcp_tso_win_divisor) {15471547+ win_divisor = ACCESS_ONCE(sysctl_tcp_tso_win_divisor);15481548+ if (win_divisor) {15511549 u32 chunk = min(tp->snd_wnd, tp->snd_cwnd * tp->mss_cache);1552155015531551 /* If at least some fraction of a window is available,15541552 * just use it.15551553 */15561556- chunk /= sysctl_tcp_tso_win_divisor;15541554+ chunk /= win_divisor;15571555 if (limit >= chunk)15581556 goto send_now;15591557 } else {
···606606 return 0;607607 }608608609609- icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);609609+ /* no tunnel matched, let upstream know, ipsec may handle it */610610 rcu_read_unlock();611611+ return 1;611612out:612613 kfree_skb(skb);613614 return 0;
+5-1
net/l2tp/l2tp_ip.c
···674674MODULE_AUTHOR("James Chapman <jchapman@katalix.com>");675675MODULE_DESCRIPTION("L2TP over IP");676676MODULE_VERSION("1.0");677677-MODULE_ALIAS_NET_PF_PROTO_TYPE(PF_INET, SOCK_DGRAM, IPPROTO_L2TP);677677+678678+/* Use the value of SOCK_DGRAM (2) directory, because __stringify does't like679679+ * enums680680+ */681681+MODULE_ALIAS_NET_PF_PROTO_TYPE(PF_INET, 2, IPPROTO_L2TP);
···15871587 list) {15881588 if (!ieee80211_sdata_running(tmp_sdata))15891589 continue;15901590- if (tmp_sdata->vif.type != NL80211_IFTYPE_AP)15901590+ if (tmp_sdata->vif.type ==15911591+ NL80211_IFTYPE_MONITOR ||15921592+ tmp_sdata->vif.type ==15931593+ NL80211_IFTYPE_AP_VLAN ||15941594+ tmp_sdata->vif.type ==15951595+ NL80211_IFTYPE_WDS)15911596 continue;15921597 if (compare_ether_addr(tmp_sdata->vif.addr,15931598 hdr->addr2) == 0) {···17371732 int nh_pos, h_pos;17381733 struct sta_info *sta = NULL;17391734 u32 sta_flags = 0;17351735+ struct sk_buff *tmp_skb;1740173617411737 if (unlikely(skb->len < ETH_HLEN)) {17421738 ret = NETDEV_TX_OK;17431739 goto fail;17441740 }17451745-17461746- nh_pos = skb_network_header(skb) - skb->data;17471747- h_pos = skb_transport_header(skb) - skb->data;1748174117491742 /* convert Ethernet header to proper 802.11 header (based on17501743 * operation mode) */···19161913 goto fail;19171914 }1918191519161916+ /*19171917+ * If the skb is shared we need to obtain our own copy.19181918+ */19191919+ if (skb_shared(skb)) {19201920+ tmp_skb = skb;19211921+ skb = skb_copy(skb, GFP_ATOMIC);19221922+ kfree_skb(tmp_skb);19231923+19241924+ if (!skb) {19251925+ ret = NETDEV_TX_OK;19261926+ goto fail;19271927+ }19281928+ }19291929+19191930 hdr.frame_control = fc;19201931 hdr.duration_id = 0;19211932 hdr.seq_ctrl = 0;···19471930 encaps_data = NULL;19481931 encaps_len = 0;19491932 }19331933+19341934+ nh_pos = skb_network_header(skb) - skb->data;19351935+ h_pos = skb_transport_header(skb) - skb->data;1950193619511937 skb_pull(skb, skip_header_bytes);19521938 nh_pos -= skip_header_bytes;
+8
net/sctp/socket.c
···29322932 struct sctp_association *asoc = NULL;29332933 struct sctp_setpeerprim prim;29342934 struct sctp_chunk *chunk;29352935+ struct sctp_af *af;29352936 int err;2936293729372938 sp = sctp_sk(sk);···2959295829602959 if (!sctp_state(asoc, ESTABLISHED))29612960 return -ENOTCONN;29612961+29622962+ af = sctp_get_af_specific(prim.sspp_addr.ss_family);29632963+ if (!af)29642964+ return -EINVAL;29652965+29662966+ if (!af->addr_valid((union sctp_addr *)&prim.sspp_addr, sp, NULL))29672967+ return -EADDRNOTAVAIL;2962296829632969 if (!sctp_assoc_lookup_laddr(asoc, (union sctp_addr *)&prim.sspp_addr))29642970 return -EADDRNOTAVAIL;
+15
net/socket.c
···732732 return ret;733733}734734735735+/**736736+ * kernel_recvmsg - Receive a message from a socket (kernel space)737737+ * @sock: The socket to receive the message from738738+ * @msg: Received message739739+ * @vec: Input s/g array for message data740740+ * @num: Size of input s/g array741741+ * @size: Number of bytes to read742742+ * @flags: Message flags (MSG_DONTWAIT, etc...)743743+ *744744+ * On return the msg structure contains the scatter/gather array passed in the745745+ * vec argument. The array is modified so that it consists of the unfilled746746+ * portion of the original array.747747+ *748748+ * The returned value is the total number of bytes received, or an error.749749+ */735750int kernel_recvmsg(struct socket *sock, struct msghdr *msg,736751 struct kvec *vec, size_t num, size_t size, int flags)737752{
+8-1
net/sunrpc/svc_xprt.c
···212212 spin_lock(&svc_xprt_class_lock);213213 list_for_each_entry(xcl, &svc_xprt_class_list, xcl_list) {214214 struct svc_xprt *newxprt;215215+ unsigned short newport;215216216217 if (strcmp(xprt_name, xcl->xcl_name))217218 continue;···231230 spin_lock_bh(&serv->sv_lock);232231 list_add(&newxprt->xpt_list, &serv->sv_permsocks);233232 spin_unlock_bh(&serv->sv_lock);233233+ newport = svc_xprt_local_port(newxprt);234234 clear_bit(XPT_BUSY, &newxprt->xpt_flags);235235- return svc_xprt_local_port(newxprt);235235+ return newport;236236 }237237 err:238238 spin_unlock(&svc_xprt_class_lock);···427425{428426 BUG_ON(!test_bit(XPT_BUSY, &xprt->xpt_flags));429427 xprt->xpt_pool = NULL;428428+ /* As soon as we clear busy, the xprt could be closed and429429+ * 'put', so we need a reference to call svc_xprt_enqueue with:430430+ */431431+ svc_xprt_get(xprt);430432 clear_bit(XPT_BUSY, &xprt->xpt_flags);431433 svc_xprt_enqueue(xprt);434434+ svc_xprt_put(xprt);432435}433436EXPORT_SYMBOL_GPL(svc_xprt_received);434437
···33393339 int mask;33403340 int active;3341334133423342- mask = snd_soc_read(codec, WM8962_INTERRUPT_STATUS_2);33423342+ mask = snd_soc_read(codec, WM8962_INTERRUPT_STATUS_2_MASK);3343334333443344 active = snd_soc_read(codec, WM8962_INTERRUPT_STATUS_2);33453345 active &= ~mask;