···8888Kenneth W Chen <kenneth.w.chen@intel.com>8989Konstantin Khlebnikov <koct9i@gmail.com> <k.khlebnikov@samsung.com>9090Koushik <raghavendra.koushik@neterion.com>9191+Krzysztof Kozlowski <krzk@kernel.org> <k.kozlowski@samsung.com>9192Krzysztof Kozlowski <krzk@kernel.org> <k.kozlowski.k@gmail.com>9293Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>9394Leonid I Ananiev <leonid.i.ananiev@intel.com>
+10-6
Documentation/arm/CCN.txt
···1818directory provides configuration templates for all documented1919events, that can be used with perf tool. For example "xp_valid_flit"2020is an equivalent of "type=0x8,event=0x4". Other parameters must be2121-explicitly specified. For events originating from device, "node"2222-defines its index. All crosspoint events require "xp" (index),2323-"port" (device port number) and "vc" (virtual channel ID) and2424-"dir" (direction). Watchpoints (special "event" value 0xfe) also2525-require comparator values ("cmp_l" and "cmp_h") and "mask", being2626-index of the comparator mask.2121+explicitly specified.27222323+For events originating from device, "node" defines its index.2424+2525+Crosspoint PMU events require "xp" (index), "bus" (bus number)2626+and "vc" (virtual channel ID).2727+2828+Crosspoint watchpoint-based events (special "event" value 0xfe)2929+require "xp" and "vc" as as above plus "port" (device port index),3030+"dir" (transmit/receive direction), comparator values ("cmp_l"3131+and "cmp_h") and "mask", being index of the comparator mask.2832Masks are defined separately from the event description2933(due to limited number of the config values) in the "cmp_mask"3034directory, with first 8 configurable by user and additional
+1-1
Documentation/cpu-freq/cpufreq-stats.txt
···103103 Power management options (ACPI, APM) --->104104 CPU Frequency scaling --->105105 [*] CPU Frequency scaling106106- <*> CPU frequency translation statistics 106106+ [*] CPU frequency translation statistics107107 [*] CPU frequency translation statistics details108108109109
+5
Documentation/i2c/slave-interface
···145145146146* Catch the slave interrupts and send appropriate i2c_slave_events to the backend.147147148148+Note that most hardware supports being master _and_ slave on the same bus. So,149149+if you extend a bus driver, please make sure that the driver supports that as150150+well. In almost all cases, slave support does not need to disable the master151151+functionality.152152+148153Check the i2c-rcar driver as an example.149154150155
+21-7
MAINTAINERS
···1624162416251625ARM/SAMSUNG EXYNOS ARM ARCHITECTURES16261626M: Kukjin Kim <kgene@kernel.org>16271627-M: Krzysztof Kozlowski <k.kozlowski@samsung.com>16271627+M: Krzysztof Kozlowski <krzk@kernel.org>16281628L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)16291629L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers)16301630S: Maintained···16441644F: drivers/*/*s5pv210*16451645F: drivers/memory/samsung/*16461646F: drivers/soc/samsung/*16471647-F: drivers/spi/spi-s3c*16481647F: Documentation/arm/Samsung/16491648F: Documentation/devicetree/bindings/arm/samsung/16501649F: Documentation/devicetree/bindings/sram/samsung-sram.txt···18311832ARM/UNIPHIER ARCHITECTURE18321833M: Masahiro Yamada <yamada.masahiro@socionext.com>18331834L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)18351835+T: git git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-uniphier.git18341836S: Maintained18351837F: arch/arm/boot/dts/uniphier*18361838F: arch/arm/include/asm/hardware/cache-uniphier.h···74657465F: sound/soc/codecs/max9860.*7466746674677467MAXIM MUIC CHARGER DRIVERS FOR EXYNOS BASED BOARDS74687468-M: Krzysztof Kozlowski <k.kozlowski@samsung.com>74687468+M: Krzysztof Kozlowski <krzk@kernel.org>74697469+M: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>74697470L: linux-pm@vger.kernel.org74707471S: Supported74717472F: drivers/power/max14577_charger.c···7482748174837482MAXIM PMIC AND MUIC DRIVERS FOR EXYNOS BASED BOARDS74847483M: Chanwoo Choi <cw00.choi@samsung.com>74857485-M: Krzysztof Kozlowski <k.kozlowski@samsung.com>74847484+M: Krzysztof Kozlowski <krzk@kernel.org>74857485+M: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>74867486L: linux-kernel@vger.kernel.org74877487S: Supported74887488F: drivers/*/max14577*.c···9249924792509248PIN CONTROLLER - SAMSUNG92519249M: Tomasz Figa <tomasz.figa@gmail.com>92529252-M: Krzysztof Kozlowski <k.kozlowski@samsung.com>92509250+M: Krzysztof Kozlowski <krzk@kernel.org>92539251M: Sylwester Nawrocki <s.nawrocki@samsung.com>92549252L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)92559253L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers)···1018210180F: drivers/platform/x86/samsung-laptop.c10183101811018410182SAMSUNG AUDIO (ASoC) DRIVERS1018510185-M: Krzysztof Kozlowski <k.kozlowski@samsung.com>1018310183+M: Krzysztof Kozlowski <krzk@kernel.org>1018610184M: Sangbeom Kim <sbkim73@samsung.com>1018710185M: Sylwester Nawrocki <s.nawrocki@samsung.com>1018810186L: alsa-devel@alsa-project.org (moderated for non-subscribers)···10197101951019810196SAMSUNG MULTIFUNCTION PMIC DEVICE DRIVERS1019910197M: Sangbeom Kim <sbkim73@samsung.com>1020010200-M: Krzysztof Kozlowski <k.kozlowski@samsung.com>1019810198+M: Krzysztof Kozlowski <krzk@kernel.org>1019910199+M: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>1020110200L: linux-kernel@vger.kernel.org1020210201L: linux-samsung-soc@vger.kernel.org1020310202S: Supported···1025610253S: Supported1025710254L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers)1025810255F: drivers/clk/samsung/1025610256+1025710257+SAMSUNG SPI DRIVERS1025810258+M: Kukjin Kim <kgene@kernel.org>1025910259+M: Krzysztof Kozlowski <krzk@kernel.org>1026010260+M: Andi Shyti <andi.shyti@samsung.com>1026110261+L: linux-spi@vger.kernel.org1026210262+L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers)1026310263+S: Maintained1026410264+F: Documentation/devicetree/bindings/spi/spi-samsung.txt1026510265+F: drivers/spi/spi-s3c*1026610266+F: include/linux/platform_data/spi-s3c64xx.h10259102671026010268SAMSUNG SXGBE DRIVERS1026110269M: Byungho An <bh74.an@samsung.com>
···336336 results in the system call being skipped immediately.337337 - seccomp syscall wired up338338339339- For best performance, an arch should use seccomp_phase1 and340340- seccomp_phase2 directly. It should call seccomp_phase1 for all341341- syscalls if TIF_SECCOMP is set, but seccomp_phase1 does not342342- need to be called from a ptrace-safe context. It must then343343- call seccomp_phase2 if seccomp_phase1 returns anything other344344- than SECCOMP_PHASE1_OK or SECCOMP_PHASE1_SKIP.345345-346346- As an additional optimization, an arch may provide seccomp_data347347- directly to seccomp_phase1; this avoids multiple calls348348- to the syscall_xyz helpers for every syscall.349349-350339config SECCOMP_FILTER351340 def_bool y352341 depends on HAVE_ARCH_SECCOMP_FILTER && SECCOMP && NET
···6464 if (parent == NULL)6565 pr_warn("failed to initialize soc device\n");66666767+ of_platform_default_populate(NULL, NULL, parent);6768 imx6ul_enet_init();6869 imx_anatop_init();6970 imx6ul_pm_init();
+2-2
arch/arm/mach-imx/pm-imx6.c
···295295 val &= ~BM_CLPCR_SBYOS;296296 if (cpu_is_imx6sl())297297 val |= BM_CLPCR_BYPASS_PMIC_READY;298298- if (cpu_is_imx6sl() || cpu_is_imx6sx())298298+ if (cpu_is_imx6sl() || cpu_is_imx6sx() || cpu_is_imx6ul())299299 val |= BM_CLPCR_BYP_MMDC_CH0_LPM_HS;300300 else301301 val |= BM_CLPCR_BYP_MMDC_CH1_LPM_HS;···310310 val |= 0x3 << BP_CLPCR_STBY_COUNT;311311 val |= BM_CLPCR_VSTBY;312312 val |= BM_CLPCR_SBYOS;313313- if (cpu_is_imx6sl())313313+ if (cpu_is_imx6sl() || cpu_is_imx6sx())314314 val |= BM_CLPCR_BYPASS_PMIC_READY;315315 if (cpu_is_imx6sl() || cpu_is_imx6sx() || cpu_is_imx6ul())316316 val |= BM_CLPCR_BYP_MMDC_CH0_LPM_HS;
-6
arch/arm/mach-omap2/cm33xx.c
···220220{221221 int i = 0;222222223223- if (!clkctrl_offs)224224- return 0;225225-226223 omap_test_timeout(_is_module_ready(inst, clkctrl_offs),227224 MAX_MODULE_READY_TIME, i);228225···242245 u8 bit_shift)243246{244247 int i = 0;245245-246246- if (!clkctrl_offs)247247- return 0;248248249249 omap_test_timeout((_clkctrl_idlest(inst, clkctrl_offs) ==250250 CLKCTRL_IDLEST_DISABLED),
-6
arch/arm/mach-omap2/cminst44xx.c
···278278{279279 int i = 0;280280281281- if (!clkctrl_offs)282282- return 0;283283-284281 omap_test_timeout(_is_module_ready(part, inst, clkctrl_offs),285282 MAX_MODULE_READY_TIME, i);286283···300303 u8 bit_shift)301304{302305 int i = 0;303303-304304- if (!clkctrl_offs)305305- return 0;306306307307 omap_test_timeout((_clkctrl_idlest(part, inst, clkctrl_offs) ==308308 CLKCTRL_IDLEST_DISABLED),
+8
arch/arm/mach-omap2/omap_hwmod.c
···10531053 if (oh->flags & HWMOD_NO_IDLEST)10541054 return 0;1055105510561056+ if (!oh->prcm.omap4.clkctrl_offs &&10571057+ !(oh->prcm.omap4.flags & HWMOD_OMAP4_ZERO_CLKCTRL_OFFSET))10581058+ return 0;10591059+10561060 return omap_cm_wait_module_idle(oh->clkdm->prcm_partition,10571061 oh->clkdm->cm_inst,10581062 oh->prcm.omap4.clkctrl_offs, 0);···29732969 return 0;2974297029752971 if (!_find_mpu_rt_port(oh))29722972+ return 0;29732973+29742974+ if (!oh->prcm.omap4.clkctrl_offs &&29752975+ !(oh->prcm.omap4.flags & HWMOD_OMAP4_ZERO_CLKCTRL_OFFSET))29762976 return 0;2977297729782978 /* XXX check module SIDLEMODE, hardreset status */
+4
arch/arm/mach-omap2/omap_hwmod.h
···443443 * HWMOD_OMAP4_NO_CONTEXT_LOSS_BIT: Some IP blocks don't have a PRCM444444 * module-level context loss register associated with them; this445445 * flag bit should be set in those cases446446+ * HWMOD_OMAP4_ZERO_CLKCTRL_OFFSET: Some IP blocks have a valid CLKCTRL447447+ * offset of zero; this flag bit should be set in those cases to448448+ * distinguish from hwmods that have no clkctrl offset.446449 */447450#define HWMOD_OMAP4_NO_CONTEXT_LOSS_BIT (1 << 0)451451+#define HWMOD_OMAP4_ZERO_CLKCTRL_OFFSET (1 << 1)448452449453/**450454 * struct omap_hwmod_omap4_prcm - OMAP4-specific PRCM data
···363363#define arch_read_relax(lock) cpu_relax()364364#define arch_write_relax(lock) cpu_relax()365365366366+/*367367+ * Accesses appearing in program order before a spin_lock() operation368368+ * can be reordered with accesses inside the critical section, by virtue369369+ * of arch_spin_lock being constructed using acquire semantics.370370+ *371371+ * In cases where this is problematic (e.g. try_to_wake_up), an372372+ * smp_mb__before_spinlock() can restore the required ordering.373373+ */374374+#define smp_mb__before_spinlock() smp_mb()375375+366376#endif /* __ASM_SPINLOCK_H */
···311311 unsigned long over;312312313313 if (access_ok(VERIFY_READ, from, n)) {314314- if (!__builtin_constant_p(n))315315- check_object_size(to, n, false);314314+ check_object_size(to, n, false);316315 return __copy_tofrom_user((__force void __user *)to, from, n);317316 }318317 if ((unsigned long)from < TASK_SIZE) {319318 over = (unsigned long)from + n - TASK_SIZE;320320- if (!__builtin_constant_p(n - over))321321- check_object_size(to, n - over, false);319319+ check_object_size(to, n - over, false);322320 return __copy_tofrom_user((__force void __user *)to, from,323321 n - over) + over;324322 }···329331 unsigned long over;330332331333 if (access_ok(VERIFY_WRITE, to, n)) {332332- if (!__builtin_constant_p(n))333333- check_object_size(from, n, true);334334+ check_object_size(from, n, true);334335 return __copy_tofrom_user(to, (__force void __user *)from, n);335336 }336337 if ((unsigned long)to < TASK_SIZE) {337338 over = (unsigned long)to + n - TASK_SIZE;338338- if (!__builtin_constant_p(n))339339- check_object_size(from, n - over, true);339339+ check_object_size(from, n - over, true);340340 return __copy_tofrom_user(to, (__force void __user *)from,341341 n - over) + over;342342 }···379383 return 0;380384 }381385382382- if (!__builtin_constant_p(n))383383- check_object_size(to, n, false);386386+ check_object_size(to, n, false);384387385388 return __copy_tofrom_user((__force void __user *)to, from, n);386389}···407412 if (ret == 0)408413 return 0;409414 }410410- if (!__builtin_constant_p(n))411411- check_object_size(from, n, true);415415+416416+ check_object_size(from, n, true);412417413418 return __copy_tofrom_user(to, (__force const void __user *)from, n);414419}
+4-3
arch/powerpc/lib/checksum_32.S
···127127 stw r7,12(r1)128128 stw r8,8(r1)129129130130- rlwinm r0,r4,3,0x8131131- rlwnm r6,r6,r0,0,31 /* odd destination address: rotate one byte */132132- cmplwi cr7,r0,0 /* is destination address even ? */133130 addic r12,r6,0134131 addi r6,r4,-4135132 neg r0,r4136133 addi r4,r3,-4137134 andi. r0,r0,CACHELINE_MASK /* # bytes to start of cache line */135135+ crset 4*cr7+eq138136 beq 58f139137140138 cmplw 0,r5,r0 /* is this more than total to do? */141139 blt 63f /* if not much to do */140140+ rlwinm r7,r6,3,0x8141141+ rlwnm r12,r12,r7,0,31 /* odd destination address: rotate one byte */142142+ cmplwi cr7,r7,0 /* is destination address even ? */142143 andi. r8,r0,3 /* get it word-aligned first */143144 mtctr r8144145 beq+ 61f
+6-1
arch/powerpc/mm/slb_low.S
···113113END_MMU_FTR_SECTION_IFCLR(MMU_FTR_1T_SEGMENT)114114 b slb_finish_load_1T115115116116-0:116116+0: /*117117+ * For userspace addresses, make sure this is region 0.118118+ */119119+ cmpdi r9, 0120120+ bne 8f121121+117122 /* when using slices, we extract the psize off the slice bitmaps118123 * and then we need to get the sllp encoding off the mmu_psize_defs119124 * array.
+11-7
arch/powerpc/platforms/powernv/pci-ioda.c
···162162static void pnv_ioda_free_pe(struct pnv_ioda_pe *pe)163163{164164 struct pnv_phb *phb = pe->phb;165165+ unsigned int pe_num = pe->pe_number;165166166167 WARN_ON(pe->pdev);167168168169 memset(pe, 0, sizeof(struct pnv_ioda_pe));169169- clear_bit(pe->pe_number, phb->ioda.pe_alloc);170170+ clear_bit(pe_num, phb->ioda.pe_alloc);170171}171172172173/* The default M64 BAR is shared by all PEs */···34033402 struct pnv_phb *phb = pe->phb;34043403 struct pnv_ioda_pe *slave, *tmp;3405340434063406- /* Release slave PEs in compound PE */34073407- if (pe->flags & PNV_IODA_PE_MASTER) {34083408- list_for_each_entry_safe(slave, tmp, &pe->slaves, list)34093409- pnv_ioda_release_pe(slave);34103410- }34113411-34123405 list_del(&pe->list);34133406 switch (phb->type) {34143407 case PNV_PHB_IODA1:···3417342234183423 pnv_ioda_release_pe_seg(pe);34193424 pnv_ioda_deconfigure_pe(pe->phb, pe);34253425+34263426+ /* Release slave PEs in the compound PE */34273427+ if (pe->flags & PNV_IODA_PE_MASTER) {34283428+ list_for_each_entry_safe(slave, tmp, &pe->slaves, list) {34293429+ list_del(&slave->list);34303430+ pnv_ioda_free_pe(slave);34313431+ }34323432+ }34333433+34203434 pnv_ioda_free_pe(pe);34213435}34223436
···23232424static void icp_opal_teardown_cpu(void)2525{2626- int cpu = smp_processor_id();2626+ int hw_cpu = hard_smp_processor_id();27272828 /* Clear any pending IPI */2929- opal_int_set_mfrr(cpu, 0xff);2929+ opal_int_set_mfrr(hw_cpu, 0xff);3030}31313232static void icp_opal_flush_ipi(void)···101101102102static void icp_opal_cause_ipi(int cpu, unsigned long data)103103{104104- opal_int_set_mfrr(cpu, IPI_PRIORITY);104104+ int hw_cpu = get_hard_smp_processor_id(cpu);105105+106106+ opal_int_set_mfrr(hw_cpu, IPI_PRIORITY);105107}106108107109static irqreturn_t icp_opal_ipi_action(int irq, void *dev_id)108110{109109- int cpu = smp_processor_id();111111+ int hw_cpu = hard_smp_processor_id();110112111111- opal_int_set_mfrr(cpu, 0xff);113113+ opal_int_set_mfrr(hw_cpu, 0xff);112114113115 return smp_ipi_demux();114116}
+3-6
arch/sparc/include/asm/uaccess_32.h
···249249static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)250250{251251 if (n && __access_ok((unsigned long) to, n)) {252252- if (!__builtin_constant_p(n))253253- check_object_size(from, n, true);252252+ check_object_size(from, n, true);254253 return __copy_user(to, (__force void __user *) from, n);255254 } else256255 return n;···257258258259static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)259260{260260- if (!__builtin_constant_p(n))261261- check_object_size(from, n, true);261261+ check_object_size(from, n, true);262262 return __copy_user(to, (__force void __user *) from, n);263263}264264265265static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)266266{267267 if (n && __access_ok((unsigned long) from, n)) {268268- if (!__builtin_constant_p(n))269269- check_object_size(to, n, false);268268+ check_object_size(to, n, false);270269 return __copy_user((__force void __user *) to, from, n);271270 } else272271 return n;
+3-4
arch/sparc/include/asm/uaccess_64.h
···212212{213213 unsigned long ret;214214215215- if (!__builtin_constant_p(size))216216- check_object_size(to, size, false);215215+ check_object_size(to, size, false);217216218217 ret = ___copy_from_user(to, from, size);219218 if (unlikely(ret))···232233{233234 unsigned long ret;234235235235- if (!__builtin_constant_p(size))236236- check_object_size(from, size, true);236236+ check_object_size(from, size, true);237237+237238 ret = ___copy_to_user(to, from, size);238239 if (unlikely(ret))239240 ret = copy_to_user_fixup(to, from, size);
+3-7
arch/um/kernel/skas/syscall.c
···2121 PT_REGS_SET_SYSCALL_RETURN(regs, -ENOSYS);22222323 if (syscall_trace_enter(regs))2424- return;2424+ goto out;25252626 /* Do the seccomp check after ptrace; failures should be fast. */2727 if (secure_computing(NULL) == -1)2828- return;2828+ goto out;29293030- /* Update the syscall number after orig_ax has potentially been updated3131- * with ptrace.3232- */3333- UPT_SYSCALL_NR(r) = PT_SYSCALL_NR(r->gp);3430 syscall = UPT_SYSCALL_NR(r);3535-3631 if (syscall >= 0 && syscall <= __NR_syscall_max)3732 PT_REGS_SET_SYSCALL_RETURN(regs,3833 EXECUTE_SYSCALL(syscall, regs));39343535+out:4036 syscall_trace_leave(regs);4137}
+2-2
arch/x86/include/asm/uaccess.h
···705705 WARN(1, "Buffer overflow detected (%d < %lu)!\n", size, count);706706}707707708708-static inline unsigned long __must_check708708+static __always_inline unsigned long __must_check709709copy_from_user(void *to, const void __user *from, unsigned long n)710710{711711 int sz = __compiletime_object_size(to);···725725 return n;726726}727727728728-static inline unsigned long __must_check728728+static __always_inline unsigned long __must_check729729copy_to_user(void __user *to, const void *from, unsigned long n)730730{731731 int sz = __compiletime_object_size(from);
+10-7
arch/x86/mm/pat.c
···927927}928928929929/*930930- * prot is passed in as a parameter for the new mapping. If the vma has a931931- * linear pfn mapping for the entire range reserve the entire vma range with932932- * single reserve_pfn_range call.930930+ * prot is passed in as a parameter for the new mapping. If the vma has931931+ * a linear pfn mapping for the entire range, or no vma is provided,932932+ * reserve the entire pfn + size range with single reserve_pfn_range933933+ * call.933934 */934935int track_pfn_remap(struct vm_area_struct *vma, pgprot_t *prot,935936 unsigned long pfn, unsigned long addr, unsigned long size)···939938 enum page_cache_mode pcm;940939941940 /* reserve the whole chunk starting from paddr */942942- if (addr == vma->vm_start && size == (vma->vm_end - vma->vm_start)) {941941+ if (!vma || (addr == vma->vm_start942942+ && size == (vma->vm_end - vma->vm_start))) {943943 int ret;944944945945 ret = reserve_pfn_range(paddr, size, prot, 0);946946- if (!ret)946946+ if (ret == 0 && vma)947947 vma->vm_flags |= VM_PAT;948948 return ret;949949 }···999997 resource_size_t paddr;1000998 unsigned long prot;100199910021002- if (!(vma->vm_flags & VM_PAT))10001000+ if (vma && !(vma->vm_flags & VM_PAT))10031001 return;1004100210051003 /* free the chunk starting from pfn or the whole chunk */···10131011 size = vma->vm_end - vma->vm_start;10141012 }10151013 free_pfn_range(paddr, size);10161016- vma->vm_flags &= ~VM_PAT;10141014+ if (vma)10151015+ vma->vm_flags &= ~VM_PAT;10171016}1018101710191018/*
+3
arch/x86/um/ptrace_32.c
···8484 case EAX:8585 case EIP:8686 case UESP:8787+ break;8788 case ORIG_EAX:8989+ /* Update the syscall number. */9090+ UPT_SYSCALL_NR(&child->thread.regs.regs) = value;8891 break;8992 case FS:9093 if (value && (value & 3) != 3)
+4
arch/x86/um/ptrace_64.c
···7878 case RSI:7979 case RDI:8080 case RBP:8181+ break;8282+8183 case ORIG_RAX:8484+ /* Update the syscall number. */8585+ UPT_SYSCALL_NR(&child->thread.regs.regs) = value;8286 break;83878488 case FS:
···4242 list_for_each_entry(nfit_spa, &acpi_desc->spas, list) {4343 struct acpi_nfit_system_address *spa = nfit_spa->spa;44444545- if (nfit_spa_type(spa) == NFIT_SPA_PM)4545+ if (nfit_spa_type(spa) != NFIT_SPA_PM)4646 continue;4747 /* find the spa that covers the mce addr */4848 if (spa->address > mce->addr)
+28-10
drivers/base/regmap/regcache-rbtree.c
···404404 unsigned int new_base_reg, new_top_reg;405405 unsigned int min, max;406406 unsigned int max_dist;407407+ unsigned int dist, best_dist = UINT_MAX;407408408409 max_dist = map->reg_stride * sizeof(*rbnode_tmp) /409410 map->cache_word_size;···424423 &base_reg, &top_reg);425424426425 if (base_reg <= max && top_reg >= min) {427427- new_base_reg = min(reg, base_reg);428428- new_top_reg = max(reg, top_reg);429429- } else {430430- if (max < base_reg)431431- node = node->rb_left;426426+ if (reg < base_reg)427427+ dist = base_reg - reg;428428+ else if (reg > top_reg)429429+ dist = reg - top_reg;432430 else433433- node = node->rb_right;434434-435435- continue;431431+ dist = 0;432432+ if (dist < best_dist) {433433+ rbnode = rbnode_tmp;434434+ best_dist = dist;435435+ new_base_reg = min(reg, base_reg);436436+ new_top_reg = max(reg, top_reg);437437+ }436438 }437439438438- ret = regcache_rbtree_insert_to_block(map, rbnode_tmp,440440+ /*441441+ * Keep looking, we want to choose the closest block,442442+ * otherwise we might end up creating overlapping443443+ * blocks, which breaks the rbtree.444444+ */445445+ if (reg < base_reg)446446+ node = node->rb_left;447447+ else if (reg > top_reg)448448+ node = node->rb_right;449449+ else450450+ break;451451+ }452452+453453+ if (rbnode) {454454+ ret = regcache_rbtree_insert_to_block(map, rbnode,439455 new_base_reg,440456 new_top_reg, reg,441457 value);442458 if (ret)443459 return ret;444444- rbtree_ctx->cached_rbnode = rbnode_tmp;460460+ rbtree_ctx->cached_rbnode = rbnode;445461 return 0;446462 }447463
+3-2
drivers/base/regmap/regcache.c
···38383939 /* calculate the size of reg_defaults */4040 for (count = 0, i = 0; i < map->num_reg_defaults_raw; i++)4141- if (!regmap_volatile(map, i * map->reg_stride))4141+ if (regmap_readable(map, i * map->reg_stride) &&4242+ !regmap_volatile(map, i * map->reg_stride))4243 count++;43444444- /* all registers are volatile, so just bypass */4545+ /* all registers are unreadable or volatile, so just bypass */4546 if (!count) {4647 map->cache_bypass = true;4748 return 0;
···767767 * depending on the scaling direction.768768 *769769 * Return: NOTIFY_STOP if the rate change should be aborted, NOTIFY_OK770770- * to acknowedge the change, NOTIFY_DONE if the notification is770770+ * to acknowledge the change, NOTIFY_DONE if the notification is771771 * considered irrelevant.772772 */773773static int cdns_i2c_clk_notifier_cb(struct notifier_block *nb, unsigned long
+10-6
drivers/i2c/busses/i2c-designware-core.c
···367367 dev_dbg(dev->dev, "Fast-mode HCNT:LCNT = %d:%d\n", hcnt, lcnt);368368369369 /* Configure SDA Hold Time if required */370370- if (dev->sda_hold_time) {371371- reg = dw_readl(dev, DW_IC_COMP_VERSION);372372- if (reg >= DW_IC_SDA_HOLD_MIN_VERS)370370+ reg = dw_readl(dev, DW_IC_COMP_VERSION);371371+ if (reg >= DW_IC_SDA_HOLD_MIN_VERS) {372372+ if (dev->sda_hold_time) {373373 dw_writel(dev, dev->sda_hold_time, DW_IC_SDA_HOLD);374374- else375375- dev_warn(dev->dev,376376- "Hardware too old to adjust SDA hold time.");374374+ } else {375375+ /* Keep previous hold time setting if no one set it */376376+ dev->sda_hold_time = dw_readl(dev, DW_IC_SDA_HOLD);377377+ }378378+ } else {379379+ dev_warn(dev->dev,380380+ "Hardware too old to adjust SDA hold time.\n");377381 }378382379383 /* Configure Tx/Rx FIFO threshold levels */
+1-1
drivers/i2c/busses/i2c-rcar.c
···378378 }379379380380 dma_addr = dma_map_single(chan->device->dev, buf, len, dir);381381- if (dma_mapping_error(dev, dma_addr)) {381381+ if (dma_mapping_error(chan->device->dev, dma_addr)) {382382 dev_dbg(dev, "dma map failed, using PIO\n");383383 return;384384 }
+13-1
drivers/i2c/busses/i2c-rk3x.c
···918918 * Code adapted from i2c-cadence.c.919919 *920920 * Return: NOTIFY_STOP if the rate change should be aborted, NOTIFY_OK921921- * to acknowedge the change, NOTIFY_DONE if the notification is921921+ * to acknowledge the change, NOTIFY_DONE if the notification is922922 * considered irrelevant.923923 */924924static int rk3x_i2c_clk_notifier_cb(struct notifier_block *nb, unsigned long···11091109 spin_unlock_irqrestore(&i2c->lock, flags);1110111011111111 return ret < 0 ? ret : num;11121112+}11131113+11141114+static __maybe_unused int rk3x_i2c_resume(struct device *dev)11151115+{11161116+ struct rk3x_i2c *i2c = dev_get_drvdata(dev);11171117+11181118+ rk3x_i2c_adapt_div(i2c, clk_get_rate(i2c->clk));11191119+11201120+ return 0;11121121}1113112211141123static u32 rk3x_i2c_func(struct i2c_adapter *adap)···13431334 return 0;13441335}1345133613371337+static SIMPLE_DEV_PM_OPS(rk3x_i2c_pm_ops, NULL, rk3x_i2c_resume);13381338+13461339static struct platform_driver rk3x_i2c_driver = {13471340 .probe = rk3x_i2c_probe,13481341 .remove = rk3x_i2c_remove,13491342 .driver = {13501343 .name = "rk3x-i2c",13511344 .of_match_table = rk3x_i2c_match,13451345+ .pm = &rk3x_i2c_pm_ops,13521346 },13531347};13541348
+1-1
drivers/i2c/busses/i2c-sh_mobile.c
···610610 return;611611612612 dma_addr = dma_map_single(chan->device->dev, pd->msg->buf, pd->msg->len, dir);613613- if (dma_mapping_error(pd->dev, dma_addr)) {613613+ if (dma_mapping_error(chan->device->dev, dma_addr)) {614614 dev_dbg(pd->dev, "dma map failed, using PIO\n");615615 return;616616 }
···6767#define BMC150_ACCEL_REG_PMU_BW 0x106868#define BMC150_ACCEL_DEF_BW 12569697070+#define BMC150_ACCEL_REG_RESET 0x147171+#define BMC150_ACCEL_RESET_VAL 0xB67272+7073#define BMC150_ACCEL_REG_INT_MAP_0 0x197174#define BMC150_ACCEL_INT_MAP_0_BIT_SLOPE BIT(2)7275···14991496 struct device *dev = regmap_get_device(data->regmap);15001497 int ret, i;15011498 unsigned int val;14991499+15001500+ /*15011501+ * Reset chip to get it in a known good state. A delay of 1.8ms after15021502+ * reset is required according to the data sheets of supported chips.15031503+ */15041504+ regmap_write(data->regmap, BMC150_ACCEL_REG_RESET,15051505+ BMC150_ACCEL_RESET_VAL);15061506+ usleep_range(1800, 2500);1502150715031508 ret = regmap_read(data->regmap, BMC150_ACCEL_REG_CHIP_ID, &val);15041509 if (ret < 0) {
+1
drivers/iio/accel/kxsd9.c
···166166 ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C));167167 if (ret < 0)168168 goto error_ret;169169+ *val = 0;169170 *val2 = kxsd9_micro_scales[ret & KXSD9_FS_MASK];170171 ret = IIO_VAL_INT_PLUS_MICRO;171172 break;
···110110 DEFINE_WAIT_FUNC(wait, woken_wake_function);111111 size_t datum_size;112112 size_t to_wait;113113- int ret;113113+ int ret = 0;114114115115 if (!indio_dev->info)116116 return -ENODEV;···153153 ret = rb->access->read_first_n(rb, n, buf);154154 if (ret == 0 && (filp->f_flags & O_NONBLOCK))155155 ret = -EAGAIN;156156- } while (ret == 0);156156+ } while (ret == 0);157157 remove_wait_queue(&rb->pollq, &wait);158158159159 return ret;
···94909490 write_csr(dd, DC_LCB_CFG_TX_FIFOS_RESET, 0x00);94919491}9492949294939493+/*94949494+ * Perform a test read on the QSFP. Return 0 on success, -ERRNO94959495+ * on error.94969496+ */94979497+static int test_qsfp_read(struct hfi1_pportdata *ppd)94989498+{94999499+ int ret;95009500+ u8 status;95019501+95029502+ /* report success if not a QSFP */95039503+ if (ppd->port_type != PORT_TYPE_QSFP)95049504+ return 0;95059505+95069506+ /* read byte 2, the status byte */95079507+ ret = one_qsfp_read(ppd, ppd->dd->hfi1_id, 2, &status, 1);95089508+ if (ret < 0)95099509+ return ret;95109510+ if (ret != 1)95119511+ return -EIO;95129512+95139513+ return 0; /* success */95149514+}95159515+95169516+/*95179517+ * Values for QSFP retry.95189518+ *95199519+ * Give up after 10s (20 x 500ms). The overall timeout was empirically95209520+ * arrived at from experience on a large cluster.95219521+ */95229522+#define MAX_QSFP_RETRIES 2095239523+#define QSFP_RETRY_WAIT 500 /* msec */95249524+95259525+/*95269526+ * Try a QSFP read. If it fails, schedule a retry for later.95279527+ * Called on first link activation after driver load.95289528+ */95299529+static void try_start_link(struct hfi1_pportdata *ppd)95309530+{95319531+ if (test_qsfp_read(ppd)) {95329532+ /* read failed */95339533+ if (ppd->qsfp_retry_count >= MAX_QSFP_RETRIES) {95349534+ dd_dev_err(ppd->dd, "QSFP not responding, giving up\n");95359535+ return;95369536+ }95379537+ dd_dev_info(ppd->dd,95389538+ "QSFP not responding, waiting and retrying %d\n",95399539+ (int)ppd->qsfp_retry_count);95409540+ ppd->qsfp_retry_count++;95419541+ queue_delayed_work(ppd->hfi1_wq, &ppd->start_link_work,95429542+ msecs_to_jiffies(QSFP_RETRY_WAIT));95439543+ return;95449544+ }95459545+ ppd->qsfp_retry_count = 0;95469546+95479547+ /*95489548+ * Tune the SerDes to a ballpark setting for optimal signal and bit95499549+ * error rate. Needs to be done before starting the link.95509550+ */95519551+ tune_serdes(ppd);95529552+ start_link(ppd);95539553+}95549554+95559555+/*95569556+ * Workqueue function to start the link after a delay.95579557+ */95589558+void handle_start_link(struct work_struct *work)95599559+{95609560+ struct hfi1_pportdata *ppd = container_of(work, struct hfi1_pportdata,95619561+ start_link_work.work);95629562+ try_start_link(ppd);95639563+}95649564+94939565int bringup_serdes(struct hfi1_pportdata *ppd)94949566{94959567 struct hfi1_devdata *dd = ppd->dd;···95979525 set_qsfp_int_n(ppd, 1);95989526 }9599952796009600- /*96019601- * Tune the SerDes to a ballpark setting for96029602- * optimal signal and bit error rate96039603- * Needs to be done before starting the link96049604- */96059605- tune_serdes(ppd);96069606-96079607- return start_link(ppd);95289528+ try_start_link(ppd);95299529+ return 0;96089530}9609953196109532void hfi1_quiet_serdes(struct hfi1_pportdata *ppd)···96149548 */96159549 ppd->driver_link_ready = 0;96169550 ppd->link_enabled = 0;95519551+95529552+ ppd->qsfp_retry_count = MAX_QSFP_RETRIES; /* prevent more retries */95539553+ flush_delayed_work(&ppd->start_link_work);95549554+ cancel_delayed_work_sync(&ppd->start_link_work);9617955596189556 ppd->offline_disabled_reason =96199557 HFI1_ODR_MASK(OPA_LINKDOWN_REASON_SMA_DISABLED);···1293512865 */1293612866static int set_up_context_variables(struct hfi1_devdata *dd)1293712867{1293812938- int num_kernel_contexts;1286812868+ unsigned long num_kernel_contexts;1293912869 int total_contexts;1294012870 int ret;1294112871 unsigned ngroups;···1296412894 */1296512895 if (num_kernel_contexts > (dd->chip_send_contexts - num_vls - 1)) {1296612896 dd_dev_err(dd,1296712967- "Reducing # kernel rcv contexts to: %d, from %d\n",1289712897+ "Reducing # kernel rcv contexts to: %d, from %lu\n",1296812898 (int)(dd->chip_send_contexts - num_vls - 1),1296912969- (int)num_kernel_contexts);1289912899+ num_kernel_contexts);1297012900 num_kernel_contexts = dd->chip_send_contexts - num_vls - 1;1297112901 }1297212902 /*
···59596060static struct dentry *hfi1_dbg_root;61616262+/* wrappers to enforce srcu in seq file */6363+static ssize_t hfi1_seq_read(6464+ struct file *file,6565+ char __user *buf,6666+ size_t size,6767+ loff_t *ppos)6868+{6969+ struct dentry *d = file->f_path.dentry;7070+ int srcu_idx;7171+ ssize_t r;7272+7373+ r = debugfs_use_file_start(d, &srcu_idx);7474+ if (likely(!r))7575+ r = seq_read(file, buf, size, ppos);7676+ debugfs_use_file_finish(srcu_idx);7777+ return r;7878+}7979+8080+static loff_t hfi1_seq_lseek(8181+ struct file *file,8282+ loff_t offset,8383+ int whence)8484+{8585+ struct dentry *d = file->f_path.dentry;8686+ int srcu_idx;8787+ loff_t r;8888+8989+ r = debugfs_use_file_start(d, &srcu_idx);9090+ if (likely(!r))9191+ r = seq_lseek(file, offset, whence);9292+ debugfs_use_file_finish(srcu_idx);9393+ return r;9494+}9595+6296#define private2dd(file) (file_inode(file)->i_private)6397#define private2ppd(file) (file_inode(file)->i_private)6498···12187static const struct file_operations _##name##_file_ops = { \12288 .owner = THIS_MODULE, \12389 .open = _##name##_open, \124124- .read = seq_read, \125125- .llseek = seq_lseek, \9090+ .read = hfi1_seq_read, \9191+ .llseek = hfi1_seq_lseek, \12692 .release = seq_release \12793}12894···139105 DEBUGFS_FILE_CREATE(#name, parent, data, &_##name##_file_ops, S_IRUGO)140106141107static void *_opcode_stats_seq_start(struct seq_file *s, loff_t *pos)142142-__acquires(RCU)143108{144109 struct hfi1_opcode_stats_perctx *opstats;145110146146- rcu_read_lock();147111 if (*pos >= ARRAY_SIZE(opstats->stats))148112 return NULL;149113 return pos;···158126}159127160128static void _opcode_stats_seq_stop(struct seq_file *s, void *v)161161-__releases(RCU)162129{163163- rcu_read_unlock();164130}165131166132static int _opcode_stats_seq_show(struct seq_file *s, void *v)···315285DEBUGFS_FILE_OPS(qp_stats);316286317287static void *_sdes_seq_start(struct seq_file *s, loff_t *pos)318318-__acquires(RCU)319288{320289 struct hfi1_ibdev *ibd;321290 struct hfi1_devdata *dd;322291323323- rcu_read_lock();324292 ibd = (struct hfi1_ibdev *)s->private;325293 dd = dd_from_dev(ibd);326294 if (!dd->per_sdma || *pos >= dd->num_sdma)···338310}339311340312static void _sdes_seq_stop(struct seq_file *s, void *v)341341-__releases(RCU)342313{343343- rcu_read_unlock();344314}345315346316static int _sdes_seq_show(struct seq_file *s, void *v)···365339 struct hfi1_devdata *dd;366340 ssize_t rval;367341368368- rcu_read_lock();369342 dd = private2dd(file);370343 avail = hfi1_read_cntrs(dd, NULL, &counters);371344 rval = simple_read_from_buffer(buf, count, ppos, counters, avail);372372- rcu_read_unlock();373345 return rval;374346}375347···380356 struct hfi1_devdata *dd;381357 ssize_t rval;382358383383- rcu_read_lock();384359 dd = private2dd(file);385360 avail = hfi1_read_cntrs(dd, &names, NULL);386361 rval = simple_read_from_buffer(buf, count, ppos, names, avail);387387- rcu_read_unlock();388362 return rval;389363}390364···405383 struct hfi1_devdata *dd;406384 ssize_t rval;407385408408- rcu_read_lock();409386 dd = private2dd(file);410387 avail = hfi1_read_portcntrs(dd->pport, &names, NULL);411388 rval = simple_read_from_buffer(buf, count, ppos, names, avail);412412- rcu_read_unlock();413389 return rval;414390}415391···420400 struct hfi1_pportdata *ppd;421401 ssize_t rval;422402423423- rcu_read_lock();424403 ppd = private2ppd(file);425404 avail = hfi1_read_portcntrs(ppd, NULL, &counters);426405 rval = simple_read_from_buffer(buf, count, ppos, counters, avail);427427- rcu_read_unlock();428406 return rval;429407}430408···452434 int used;453435 int i;454436455455- rcu_read_lock();456437 ppd = private2ppd(file);457438 dd = ppd->dd;458439 size = PAGE_SIZE;459440 used = 0;460441 tmp = kmalloc(size, GFP_KERNEL);461461- if (!tmp) {462462- rcu_read_unlock();442442+ if (!tmp)463443 return -ENOMEM;464464- }465444466445 scratch0 = read_csr(dd, ASIC_CFG_SCRATCH);467446 used += scnprintf(tmp + used, size - used,···485470 used += scnprintf(tmp + used, size - used, "Write bits to clear\n");486471487472 ret = simple_read_from_buffer(buf, count, ppos, tmp, used);488488- rcu_read_unlock();489473 kfree(tmp);490474 return ret;491475}···500486 u64 scratch0;501487 u64 clear;502488503503- rcu_read_lock();504489 ppd = private2ppd(file);505490 dd = ppd->dd;506491507492 buff = kmalloc(count + 1, GFP_KERNEL);508508- if (!buff) {509509- ret = -ENOMEM;510510- goto do_return;511511- }493493+ if (!buff)494494+ return -ENOMEM;512495513496 ret = copy_from_user(buff, buf, count);514497 if (ret > 0) {···538527539528 do_free:540529 kfree(buff);541541- do_return:542542- rcu_read_unlock();543530 return ret;544531}545532···551542 char *tmp;552543 int ret;553544554554- rcu_read_lock();555545 ppd = private2ppd(file);556546 tmp = kmalloc(PAGE_SIZE, GFP_KERNEL);557557- if (!tmp) {558558- rcu_read_unlock();547547+ if (!tmp)559548 return -ENOMEM;560560- }561549562550 ret = qsfp_dump(ppd, tmp, PAGE_SIZE);563551 if (ret > 0)564552 ret = simple_read_from_buffer(buf, count, ppos, tmp, ret);565565- rcu_read_unlock();566553 kfree(tmp);567554 return ret;568555}···574569 int offset;575570 int total_written;576571577577- rcu_read_lock();578572 ppd = private2ppd(file);579573580574 /* byte offset format: [offsetSize][i2cAddr][offsetHigh][offsetLow] */···581577 offset = *ppos & 0xffff;582578583579 /* explicitly reject invalid address 0 to catch cp and cat */584584- if (i2c_addr == 0) {585585- ret = -EINVAL;586586- goto _return;587587- }580580+ if (i2c_addr == 0)581581+ return -EINVAL;588582589583 buff = kmalloc(count, GFP_KERNEL);590590- if (!buff) {591591- ret = -ENOMEM;592592- goto _return;593593- }584584+ if (!buff)585585+ return -ENOMEM;594586595587 ret = copy_from_user(buff, buf, count);596588 if (ret > 0) {···606606607607 _free:608608 kfree(buff);609609- _return:610610- rcu_read_unlock();611609 return ret;612610}613611···634636 int offset;635637 int total_read;636638637637- rcu_read_lock();638639 ppd = private2ppd(file);639640640641 /* byte offset format: [offsetSize][i2cAddr][offsetHigh][offsetLow] */···641644 offset = *ppos & 0xffff;642645643646 /* explicitly reject invalid address 0 to catch cp and cat */644644- if (i2c_addr == 0) {645645- ret = -EINVAL;646646- goto _return;647647- }647647+ if (i2c_addr == 0)648648+ return -EINVAL;648649649650 buff = kmalloc(count, GFP_KERNEL);650650- if (!buff) {651651- ret = -ENOMEM;652652- goto _return;653653- }651651+ if (!buff)652652+ return -ENOMEM;654653655654 total_read = i2c_read(ppd, target, i2c_addr, offset, buff, count);656655 if (total_read < 0) {···666673667674 _free:668675 kfree(buff);669669- _return:670670- rcu_read_unlock();671676 return ret;672677}673678···692701 int ret;693702 int total_written;694703695695- rcu_read_lock();696696- if (*ppos + count > QSFP_PAGESIZE * 4) { /* base page + page00-page03 */697697- ret = -EINVAL;698698- goto _return;699699- }704704+ if (*ppos + count > QSFP_PAGESIZE * 4) /* base page + page00-page03 */705705+ return -EINVAL;700706701707 ppd = private2ppd(file);702708703709 buff = kmalloc(count, GFP_KERNEL);704704- if (!buff) {705705- ret = -ENOMEM;706706- goto _return;707707- }710710+ if (!buff)711711+ return -ENOMEM;708712709713 ret = copy_from_user(buff, buf, count);710714 if (ret > 0) {711715 ret = -EFAULT;712716 goto _free;713717 }714714-715718 total_written = qsfp_write(ppd, target, *ppos, buff, count);716719 if (total_written < 0) {717720 ret = total_written;···718733719734 _free:720735 kfree(buff);721721- _return:722722- rcu_read_unlock();723736 return ret;724737}725738···744761 int ret;745762 int total_read;746763747747- rcu_read_lock();748764 if (*ppos + count > QSFP_PAGESIZE * 4) { /* base page + page00-page03 */749765 ret = -EINVAL;750766 goto _return;···776794 _free:777795 kfree(buff);778796 _return:779779- rcu_read_unlock();780797 return ret;781798}782799···9911010 debugfs_remove_recursive(ibd->hfi1_ibdev_dbg);9921011out:9931012 ibd->hfi1_ibdev_dbg = NULL;994994- synchronize_rcu();9951013}99610149971015/*···10151035};1016103610171037static void *_driver_stats_names_seq_start(struct seq_file *s, loff_t *pos)10181018-__acquires(RCU)10191038{10201020- rcu_read_lock();10211039 if (*pos >= ARRAY_SIZE(hfi1_statnames))10221040 return NULL;10231041 return pos;···10331055}1034105610351057static void _driver_stats_names_seq_stop(struct seq_file *s, void *v)10361036-__releases(RCU)10371058{10381038- rcu_read_unlock();10391059}1040106010411061static int _driver_stats_names_seq_show(struct seq_file *s, void *v)···10491073DEBUGFS_FILE_OPS(driver_stats_names);1050107410511075static void *_driver_stats_seq_start(struct seq_file *s, loff_t *pos)10521052-__acquires(RCU)10531076{10541054- rcu_read_lock();10551077 if (*pos >= ARRAY_SIZE(hfi1_statnames))10561078 return NULL;10571079 return pos;···10641090}1065109110661092static void _driver_stats_seq_stop(struct seq_file *s, void *v)10671067-__releases(RCU)10681093{10691069- rcu_read_unlock();10701094}1071109510721096static u64 hfi1_sps_ints(void)
+3-1
drivers/infiniband/hw/hfi1/hfi.h
···605605 struct work_struct freeze_work;606606 struct work_struct link_downgrade_work;607607 struct work_struct link_bounce_work;608608+ struct delayed_work start_link_work;608609 /* host link state variables */609610 struct mutex hls_lock;610611 u32 host_link_state;···660659 u8 linkinit_reason;661660 u8 local_tx_rate; /* rate given to 8051 firmware */662661 u8 last_pstate; /* info only */662662+ u8 qsfp_retry_count;663663664664 /* placeholders for IB MAD packet settings */665665 u8 overrun_threshold;···18061804extern unsigned int hfi1_cu;18071805extern unsigned int user_credit_return_threshold;18081806extern int num_user_contexts;18091809-extern unsigned n_krcvqs;18071807+extern unsigned long n_krcvqs;18101808extern uint krcvqs[];18111809extern int krcvqsset;18121810extern uint kdeth_qp;
+2-1
drivers/infiniband/hw/hfi1/init.c
···9494MODULE_PARM_DESC(krcvqs, "Array of the number of non-control kernel receive queues by VL");95959696/* computed based on above array */9797-unsigned n_krcvqs;9797+unsigned long n_krcvqs;98989999static unsigned hfi1_rcvarr_split = 25;100100module_param_named(rcvarr_split, hfi1_rcvarr_split, uint, S_IRUGO);···500500 INIT_WORK(&ppd->link_downgrade_work, handle_link_downgrade);501501 INIT_WORK(&ppd->sma_message_work, handle_sma_message);502502 INIT_WORK(&ppd->link_bounce_work, handle_link_bounce);503503+ INIT_DELAYED_WORK(&ppd->start_link_work, handle_start_link);503504 INIT_WORK(&ppd->linkstate_active_work, receive_interrupt_work);504505 INIT_WORK(&ppd->qsfp_info.qsfp_work, qsfp_event);505506
+6-6
drivers/infiniband/hw/hfi1/mad.c
···26042604 u8 lq, num_vls;26052605 u8 res_lli, res_ler;26062606 u64 port_mask;26072607- unsigned long port_num;26072607+ u8 port_num;26082608 unsigned long vl;26092609 u32 vl_select_mask;26102610 int vfi;···26382638 */26392639 port_mask = be64_to_cpu(req->port_select_mask[3]);26402640 port_num = find_first_bit((unsigned long *)&port_mask,26412641- sizeof(port_mask));26412641+ sizeof(port_mask) * 8);2642264226432643- if ((u8)port_num != port) {26432643+ if (port_num != port) {26442644 pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD;26452645 return reply((struct ib_mad_hdr *)pmp);26462646 }···28422842 */28432843 port_mask = be64_to_cpu(req->port_select_mask[3]);28442844 port_num = find_first_bit((unsigned long *)&port_mask,28452845- sizeof(port_mask));28452845+ sizeof(port_mask) * 8);2846284628472847 if (port_num != port) {28482848 pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD;···30153015 */30163016 port_mask = be64_to_cpu(req->port_select_mask[3]);30173017 port_num = find_first_bit((unsigned long *)&port_mask,30183018- sizeof(port_mask));30183018+ sizeof(port_mask) * 8);3019301930203020 if (port_num != port) {30213021 pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD;···32523252 */32533253 port_mask = be64_to_cpu(req->port_select_mask[3]);32543254 port_num = find_first_bit((unsigned long *)&port_mask,32553255- sizeof(port_mask));32553255+ sizeof(port_mask) * 8);3256325632573257 if (port_num != port) {32583258 pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD;
+12
drivers/infiniband/hw/hfi1/pio_copy.c
···771771 read_extra_bytes(pbuf, from, to_fill);772772 from += to_fill;773773 nbytes -= to_fill;774774+ /* may not be enough valid bytes left to align */775775+ if (extra > nbytes)776776+ extra = nbytes;774777775778 /* ...now write carry */776779 dest = pbuf->start + (pbuf->qw_written * sizeof(u64));···801798 read_low_bytes(pbuf, from, extra);802799 from += extra;803800 nbytes -= extra;801801+ /*802802+ * If no bytes are left, return early - we are done.803803+ * NOTE: This short-circuit is *required* because804804+ * "extra" may have been reduced in size and "from"805805+ * is not aligned, as required when leaving this806806+ * if block.807807+ */808808+ if (nbytes == 0)809809+ return;804810 }805811806812 /* at this point, from is QW aligned */
···127127config BCM_PDC_MBOX128128 tristate "Broadcom PDC Mailbox"129129 depends on ARM64 || COMPILE_TEST130130+ depends on HAS_DMA130131 default ARCH_BCM_IPROC131132 help132133 Mailbox implementation for the Broadcom PDC ring manager,
+6-5
drivers/mailbox/bcm-pdc-mailbox.c
···469469 * this directory for a SPU.470470 * @pdcs: PDC state structure471471 */472472-void pdc_setup_debugfs(struct pdc_state *pdcs)472472+static void pdc_setup_debugfs(struct pdc_state *pdcs)473473{474474 char spu_stats_name[16];475475···485485 &pdc_debugfs_stats);486486}487487488488-void pdc_free_debugfs(void)488488+static void pdc_free_debugfs(void)489489{490490 if (debugfs_dir && simple_empty(debugfs_dir)) {491491 debugfs_remove_recursive(debugfs_dir);···11911191{11921192 struct pdc_state *pdcs = chan->con_priv;1193119311941194- if (pdcs)11951195- dev_dbg(&pdcs->pdev->dev,11961196- "Shutdown mailbox channel for PDC %u", pdcs->pdc_idx);11941194+ if (!pdcs)11951195+ return;1197119611971197+ dev_dbg(&pdcs->pdev->dev,11981198+ "Shutdown mailbox channel for PDC %u", pdcs->pdc_idx);11981199 pdc_ring_free(pdcs);11991200}12001201
+7-14
drivers/memory/omap-gpmc.c
···21852185 return 0;21862186}2187218721882188-static int gpmc_probe_dt_children(struct platform_device *pdev)21882188+static void gpmc_probe_dt_children(struct platform_device *pdev)21892189{21902190 int ret;21912191 struct device_node *child;···22002200 else22012201 ret = gpmc_probe_generic_child(pdev, child);2202220222032203- if (ret)22042204- return ret;22032203+ if (ret) {22042204+ dev_err(&pdev->dev, "failed to probe DT child '%s': %d\n",22052205+ child->name, ret);22062206+ }22052207 }22062206-22072207- return 0;22082208}22092209#else22102210static int gpmc_probe_dt(struct platform_device *pdev)···22122212 return 0;22132213}2214221422152215-static int gpmc_probe_dt_children(struct platform_device *pdev)22152215+static void gpmc_probe_dt_children(struct platform_device *pdev)22162216{22172217- return 0;22182217}22192218#endif /* CONFIG_OF */22202219···23682369 goto setup_irq_failed;23692370 }2370237123712371- rc = gpmc_probe_dt_children(pdev);23722372- if (rc < 0) {23732373- dev_err(gpmc->dev, "failed to probe DT children\n");23742374- goto dt_children_failed;23752375- }23722372+ gpmc_probe_dt_children(pdev);2376237323772374 return 0;2378237523792379-dt_children_failed:23802380- gpmc_free_irq(gpmc);23812376setup_irq_failed:23822377 gpmc_gpio_exit(gpmc);23832378gpio_init_failed:
+17-8
drivers/misc/lkdtm_usercopy.c
···99#include <linux/uaccess.h>1010#include <asm/cacheflush.h>11111212-static size_t cache_size = 1024;1212+/*1313+ * Many of the tests here end up using const sizes, but those would1414+ * normally be ignored by hardened usercopy, so force the compiler1515+ * into choosing the non-const path to make sure we trigger the1616+ * hardened usercopy checks by added "unconst" to all the const copies,1717+ * and making sure "cache_size" isn't optimized into a const.1818+ */1919+static volatile size_t unconst = 0;2020+static volatile size_t cache_size = 1024;1321static struct kmem_cache *bad_cache;14221523static const unsigned char test_text[] = "This is a test.\n";···7567 if (to_user) {7668 pr_info("attempting good copy_to_user of local stack\n");7769 if (copy_to_user((void __user *)user_addr, good_stack,7878- sizeof(good_stack))) {7070+ unconst + sizeof(good_stack))) {7971 pr_warn("copy_to_user failed unexpectedly?!\n");8072 goto free_user;8173 }82748375 pr_info("attempting bad copy_to_user of distant stack\n");8476 if (copy_to_user((void __user *)user_addr, bad_stack,8585- sizeof(good_stack))) {7777+ unconst + sizeof(good_stack))) {8678 pr_warn("copy_to_user failed, but lacked Oops\n");8779 goto free_user;8880 }···96889789 pr_info("attempting good copy_from_user of local stack\n");9890 if (copy_from_user(good_stack, (void __user *)user_addr,9999- sizeof(good_stack))) {9191+ unconst + sizeof(good_stack))) {10092 pr_warn("copy_from_user failed unexpectedly?!\n");10193 goto free_user;10294 }1039510496 pr_info("attempting bad copy_from_user of distant stack\n");10597 if (copy_from_user(bad_stack, (void __user *)user_addr,106106- sizeof(good_stack))) {9898+ unconst + sizeof(good_stack))) {10799 pr_warn("copy_from_user failed, but lacked Oops\n");108100 goto free_user;109101 }···117109{118110 unsigned long user_addr;119111 unsigned char *one, *two;120120- const size_t size = 1024;112112+ size_t size = unconst + 1024;121113122114 one = kmalloc(size, GFP_KERNEL);123115 two = kmalloc(size, GFP_KERNEL);···293285294286 pr_info("attempting good copy_to_user from kernel rodata\n");295287 if (copy_to_user((void __user *)user_addr, test_text,296296- sizeof(test_text))) {288288+ unconst + sizeof(test_text))) {297289 pr_warn("copy_to_user failed unexpectedly?!\n");298290 goto free_user;299291 }300292301293 pr_info("attempting bad copy_to_user from kernel text\n");302302- if (copy_to_user((void __user *)user_addr, vm_mmap, PAGE_SIZE)) {294294+ if (copy_to_user((void __user *)user_addr, vm_mmap,295295+ unconst + PAGE_SIZE)) {303296 pr_warn("copy_to_user failed, but lacked Oops\n");304297 goto free_user;305298 }
+5-1
drivers/nvdimm/bus.c
···185185 return -ENXIO;186186187187 nd_desc = nvdimm_bus->nd_desc;188188+ /*189189+ * if ndctl does not exist, it's PMEM_LEGACY and190190+ * we want to just pretend everything is handled.191191+ */188192 if (!nd_desc->ndctl)189189- return -ENXIO;193193+ return len;190194191195 memset(&ars_cap, 0, sizeof(ars_cap));192196 ars_cap.address = phys;
+1-1
drivers/nvme/host/Kconfig
···30303131config NVME_RDMA3232 tristate "NVM Express over Fabrics RDMA host driver"3333- depends on INFINIBAND3333+ depends on INFINIBAND && BLOCK3434 select NVME_CORE3535 select NVME_FABRICS3636 select SG_POOL
+2-3
drivers/pinctrl/intel/pinctrl-cherryview.c
···15391539 offset += range->npins;15401540 }1541154115421542- /* Mask and clear all interrupts */15431543- chv_writel(0, pctrl->regs + CHV_INTMASK);15421542+ /* Clear all interrupts */15441543 chv_writel(0xffff, pctrl->regs + CHV_INTSTAT);1545154415461545 ret = gpiochip_irqchip_add(chip, &chv_gpio_irqchip, 0,15471547- handle_simple_irq, IRQ_TYPE_NONE);15461546+ handle_bad_irq, IRQ_TYPE_NONE);15481547 if (ret) {15491548 dev_err(pctrl->dev, "failed to add IRQ chip\n");15501549 goto fail;
···22 * max14577.c - Regulator driver for the Maxim 14577/7783633 *44 * Copyright (C) 2013,2014 Samsung Electronics55- * Krzysztof Kozlowski <k.kozlowski@samsung.com>55+ * Krzysztof Kozlowski <krzk@kernel.org>66 *77 * This program is free software; you can redistribute it and/or modify88 * it under the terms of the GNU General Public License as published by···331331}332332module_exit(max14577_regulator_exit);333333334334-MODULE_AUTHOR("Krzysztof Kozlowski <k.kozlowski@samsung.com>");334334+MODULE_AUTHOR("Krzysztof Kozlowski <krzk@kernel.org>");335335MODULE_DESCRIPTION("Maxim 14577/77836 regulator driver");336336MODULE_LICENSE("GPL");337337MODULE_ALIAS("platform:max14577-regulator");
+2-2
drivers/regulator/max77693-regulator.c
···33 *44 * Copyright (C) 2013-2015 Samsung Electronics55 * Jonghwa Lee <jonghwa3.lee@samsung.com>66- * Krzysztof Kozlowski <k.kozlowski.k@gmail.com>66+ * Krzysztof Kozlowski <krzk@kernel.org>77 *88 * This program is free software; you can redistribute it and/or modify99 * it under the terms of the GNU General Public License as published by···314314315315MODULE_DESCRIPTION("MAXIM 77693/77843 regulator driver");316316MODULE_AUTHOR("Jonghwa Lee <jonghwa3.lee@samsung.com>");317317-MODULE_AUTHOR("Krzysztof Kozlowski <k.kozlowski.k@gmail.com>");317317+MODULE_AUTHOR("Krzysztof Kozlowski <krzk@kernel.org>");318318MODULE_LICENSE("GPL");
···361361362362/* Get sense key string or NULL if not available */363363const char *364364-scsi_sense_key_string(unsigned char key) {365365- if (key <= 0xE)364364+scsi_sense_key_string(unsigned char key)365365+{366366+ if (key < ARRAY_SIZE(snstext))366367 return snstext[key];367368 return NULL;368369}
···341341}342342343343/**344344- * is_sas_attached - check if device is SAS attached345345- * @sdev: scsi device to check346346- *347347- * returns true if the device is SAS attached348348- */349349-int is_sas_attached(struct scsi_device *sdev)350350-{351351- struct Scsi_Host *shost = sdev->host;352352-353353- return shost->transportt->host_attrs.ac.class ==354354- &sas_host_class.class;355355-}356356-EXPORT_SYMBOL(is_sas_attached);357357-358358-359359-/**360344 * sas_remove_children - tear down a devices SAS data structures361345 * @dev: device belonging to the sas object362346 *
+1-1
drivers/scsi/ses.c
···587587588588 ses_enclosure_data_process(edev, to_scsi_device(edev->edev.parent), 0);589589590590- if (is_sas_attached(sdev))590590+ if (scsi_is_sas_rphy(&sdev->sdev_gendev))591591 efd.addr = sas_get_address(sdev);592592593593 if (efd.addr) {
···262262263263 for (k = 0; k < ARRAY_SIZE(sh_msiof_spi_div_table); k++) {264264 brps = DIV_ROUND_UP(div, sh_msiof_spi_div_table[k].div);265265+ /* SCR_BRDV_DIV_1 is valid only if BRPS is x 1/1 or x 1/2 */266266+ if (sh_msiof_spi_div_table[k].div == 1 && brps > 2)267267+ continue;265268 if (brps <= 32) /* max of brdv is 32 */266269 break;267270 }
+8-2
drivers/spi/spi.c
···960960 struct spi_transfer *xfer;961961 bool keep_cs = false;962962 int ret = 0;963963- unsigned long ms = 1;963963+ unsigned long long ms = 1;964964 struct spi_statistics *statm = &master->statistics;965965 struct spi_statistics *stats = &msg->spi->statistics;966966···991991992992 if (ret > 0) {993993 ret = 0;994994- ms = xfer->len * 8 * 1000 / xfer->speed_hz;994994+ ms = 8LL * 1000LL * xfer->len;995995+ do_div(ms, xfer->speed_hz);995996 ms += ms + 100; /* some tolerance */997997+998998+ if (ms > UINT_MAX)999999+ ms = UINT_MAX;99610009971001 ms = wait_for_completion_timeout(&master->xfer_completion,9981002 msecs_to_jiffies(ms));···11631159 if (ret < 0) {11641160 dev_err(&master->dev, "Failed to power device: %d\n",11651161 ret);11621162+ mutex_unlock(&master->io_mutex);11661163 return;11671164 }11681165 }···1179117411801175 if (master->auto_runtime_pm)11811176 pm_runtime_put(master->dev.parent);11771177+ mutex_unlock(&master->io_mutex);11821178 return;11831179 }11841180 }
+1
drivers/thermal/rcar_thermal.c
···504504 if (IS_ERR(priv->zone)) {505505 dev_err(dev, "can't register thermal zone\n");506506 ret = PTR_ERR(priv->zone);507507+ priv->zone = NULL;507508 goto error_unregister;508509 }509510
+9
drivers/usb/chipidea/udc.c
···949949 int retval;950950 struct ci_hw_ep *hwep;951951952952+ /*953953+ * Unexpected USB controller behavior, caused by bad signal integrity954954+ * or ground reference problems, can lead to isr_setup_status_phase955955+ * being called with ci->status equal to NULL.956956+ * If this situation occurs, you should review your USB hardware design.957957+ */958958+ if (WARN_ON_ONCE(!ci->status))959959+ return -EPIPE;960960+952961 hwep = (ci->ep0_dir == TX) ? ci->ep0out : ci->ep0in;953962 ci->status->context = ci;954963 ci->status->complete = isr_setup_status_complete;
···342342 struct sk_buff *skb2 = NULL;343343 struct usb_ep *in = port->in_ep;344344 int headroom, tailroom, padlen = 0;345345- u16 len = skb->len;345345+ u16 len;346346347347 if (!skb)348348 return NULL;
+2
drivers/usb/gadget/udc/renesas_usb3.c
···106106107107/* DRD_CON */108108#define DRD_CON_PERI_CON BIT(24)109109+#define DRD_CON_VBOUT BIT(0)109110110111/* USB_INT_ENA_1 and USB_INT_STA_1 */111112#define USB_INT_1_B3_PLLWKUP BIT(31)···364363{365364 /* FIXME: How to change host / peripheral mode as well? */366365 usb3_set_bit(usb3, DRD_CON_PERI_CON, USB3_DRD_CON);366366+ usb3_clear_bit(usb3, DRD_CON_VBOUT, USB3_DRD_CON);367367368368 usb3_write(usb3, ~0, USB3_USB_INT_STA_1);369369 usb3_enable_irq_1(usb3, USB_INT_1_VBUS_CNG);
+5-1
drivers/usb/host/xhci-ring.c
···850850 spin_lock_irqsave(&xhci->lock, flags);851851852852 ep->stop_cmds_pending--;853853+ if (xhci->xhc_state & XHCI_STATE_REMOVING) {854854+ spin_unlock_irqrestore(&xhci->lock, flags);855855+ return;856856+ }853857 if (xhci->xhc_state & XHCI_STATE_DYING) {854858 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,855859 "Stop EP timer ran, but another timer marked "···907903 spin_unlock_irqrestore(&xhci->lock, flags);908904 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,909905 "Calling usb_hc_died()");910910- usb_hc_died(xhci_to_hcd(xhci)->primary_hcd);906906+ usb_hc_died(xhci_to_hcd(xhci));911907 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,912908 "xHCI host controller is dead.");913909}
+6-2
drivers/usb/phy/phy-generic.c
···144144int usb_gen_phy_init(struct usb_phy *phy)145145{146146 struct usb_phy_generic *nop = dev_get_drvdata(phy->dev);147147+ int ret;147148148149 if (!IS_ERR(nop->vcc)) {149150 if (regulator_enable(nop->vcc))150151 dev_err(phy->dev, "Failed to enable power\n");151152 }152153153153- if (!IS_ERR(nop->clk))154154- clk_prepare_enable(nop->clk);154154+ if (!IS_ERR(nop->clk)) {155155+ ret = clk_prepare_enable(nop->clk);156156+ if (ret)157157+ return ret;158158+ }155159156160 nop_reset(nop);157161
+9-2
drivers/usb/renesas_usbhs/mod.c
···282282 if (usbhs_mod_is_host(priv))283283 usbhs_write(priv, INTSTS1, ~irq_state.intsts1 & INTSTS1_MAGIC);284284285285- usbhs_write(priv, BRDYSTS, ~irq_state.brdysts);285285+ /*286286+ * The driver should not clear the xxxSTS after the line of287287+ * "call irq callback functions" because each "if" statement is288288+ * possible to call the callback function for avoiding any side effects.289289+ */290290+ if (irq_state.intsts0 & BRDY)291291+ usbhs_write(priv, BRDYSTS, ~irq_state.brdysts);286292 usbhs_write(priv, NRDYSTS, ~irq_state.nrdysts);287287- usbhs_write(priv, BEMPSTS, ~irq_state.bempsts);293293+ if (irq_state.intsts0 & BEMP)294294+ usbhs_write(priv, BEMPSTS, ~irq_state.bempsts);288295289296 /*290297 * call irq callback functions
+1-1
drivers/virtio/virtio_ring.c
···167167 * making all of the arch DMA ops work on the vring device itself168168 * is a mess. For now, we use the parent device for DMA ops.169169 */170170-struct device *vring_dma_dev(const struct vring_virtqueue *vq)170170+static struct device *vring_dma_dev(const struct vring_virtqueue *vq)171171{172172 return vq->vq.vdev->dev.parent;173173}
+1
fs/btrfs/ctree.h
···427427 struct list_head ro_bgs;428428 struct list_head priority_tickets;429429 struct list_head tickets;430430+ u64 tickets_id;430431431432 struct rw_semaphore groups_sem;432433 /* for block groups in our same type */
···2867286728682868 if (log_root_tree->log_transid_committed >= root_log_ctx.log_transid) {28692869 blk_finish_plug(&plug);28702870+ list_del_init(&root_log_ctx.list);28702871 mutex_unlock(&log_root_tree->log_mutex);28712872 ret = root_log_ctx.log_ret;28722873 goto out;
+1-1
fs/ceph/dir.c
···597597 if (is_hash_order(new_pos)) {598598 /* no need to reset last_name for a forward seek when599599 * dentries are sotred in hash order */600600- } else if (fi->frag |= fpos_frag(new_pos)) {600600+ } else if (fi->frag != fpos_frag(new_pos)) {601601 return true;602602 }603603 rinfo = fi->last_readdir ? &fi->last_readdir->r_reply_info : NULL;
+29-12
fs/crypto/policy.c
···1111#include <linux/random.h>1212#include <linux/string.h>1313#include <linux/fscrypto.h>1414+#include <linux/mount.h>14151516static int inode_has_encryption_context(struct inode *inode)1617{···9392 return inode->i_sb->s_cop->set_context(inode, &ctx, sizeof(ctx), NULL);9493}95949696-int fscrypt_process_policy(struct inode *inode,9595+int fscrypt_process_policy(struct file *filp,9796 const struct fscrypt_policy *policy)9897{9898+ struct inode *inode = file_inode(filp);9999+ int ret;100100+101101+ if (!inode_owner_or_capable(inode))102102+ return -EACCES;103103+99104 if (policy->version != 0)100105 return -EINVAL;101106107107+ ret = mnt_want_write_file(filp);108108+ if (ret)109109+ return ret;110110+102111 if (!inode_has_encryption_context(inode)) {103103- if (!inode->i_sb->s_cop->empty_dir)104104- return -EOPNOTSUPP;105105- if (!inode->i_sb->s_cop->empty_dir(inode))106106- return -ENOTEMPTY;107107- return create_encryption_context_from_policy(inode, policy);112112+ if (!S_ISDIR(inode->i_mode))113113+ ret = -EINVAL;114114+ else if (!inode->i_sb->s_cop->empty_dir)115115+ ret = -EOPNOTSUPP;116116+ else if (!inode->i_sb->s_cop->empty_dir(inode))117117+ ret = -ENOTEMPTY;118118+ else119119+ ret = create_encryption_context_from_policy(inode,120120+ policy);121121+ } else if (!is_encryption_context_consistent_with_policy(inode,122122+ policy)) {123123+ printk(KERN_WARNING124124+ "%s: Policy inconsistent with encryption context\n",125125+ __func__);126126+ ret = -EINVAL;108127 }109128110110- if (is_encryption_context_consistent_with_policy(inode, policy))111111- return 0;112112-113113- printk(KERN_WARNING "%s: Policy inconsistent with encryption context\n",114114- __func__);115115- return -EINVAL;129129+ mnt_drop_write_file(filp);130130+ return ret;116131}117132EXPORT_SYMBOL(fscrypt_process_policy);118133
···482482 return;483483 }484484485485- cancel_delayed_work_sync(&req->work);485485+ /*486486+ * This function may be called very early during boot, for example,487487+ * from of_clk_init(), where irq needs to stay disabled.488488+ * cancel_delayed_work_sync() assumes that irq is enabled on489489+ * invocation and re-enables it on return. Avoid calling it until490490+ * workqueue is initialized.491491+ */492492+ if (keventd_up())493493+ cancel_delayed_work_sync(&req->work);494494+486495 __pm_qos_update_request(req, new_value);487496}488497EXPORT_SYMBOL_GPL(pm_qos_update_request);
···134134 return NULL;135135}136136137137-static inline const char *check_heap_object(const void *ptr, unsigned long n,138138- bool to_user)137137+/* Checks for allocs that are marked in some way as spanning multiple pages. */138138+static inline const char *check_page_span(const void *ptr, unsigned long n,139139+ struct page *page, bool to_user)139140{140140- struct page *page, *endpage;141141+#ifdef CONFIG_HARDENED_USERCOPY_PAGESPAN141142 const void *end = ptr + n - 1;143143+ struct page *endpage;142144 bool is_reserved, is_cma;143143-144144- /*145145- * Some architectures (arm64) return true for virt_addr_valid() on146146- * vmalloced addresses. Work around this by checking for vmalloc147147- * first.148148- */149149- if (is_vmalloc_addr(ptr))150150- return NULL;151151-152152- if (!virt_addr_valid(ptr))153153- return NULL;154154-155155- page = virt_to_head_page(ptr);156156-157157- /* Check slab allocator for flags and size. */158158- if (PageSlab(page))159159- return __check_heap_object(ptr, n, page);160145161146 /*162147 * Sometimes the kernel data regions are not marked Reserved (see···171186 ((unsigned long)end & (unsigned long)PAGE_MASK)))172187 return NULL;173188174174- /* Allow if start and end are inside the same compound page. */189189+ /* Allow if fully inside the same compound (__GFP_COMP) page. */175190 endpage = virt_to_head_page(end);176191 if (likely(endpage == page))177192 return NULL;···184199 is_reserved = PageReserved(page);185200 is_cma = is_migrate_cma_page(page);186201 if (!is_reserved && !is_cma)187187- goto reject;202202+ return "<spans multiple pages>";188203189204 for (ptr += PAGE_SIZE; ptr <= end; ptr += PAGE_SIZE) {190205 page = virt_to_head_page(ptr);191206 if (is_reserved && !PageReserved(page))192192- goto reject;207207+ return "<spans Reserved and non-Reserved pages>";193208 if (is_cma && !is_migrate_cma_page(page))194194- goto reject;209209+ return "<spans CMA and non-CMA pages>";195210 }211211+#endif196212197213 return NULL;214214+}198215199199-reject:200200- return "<spans multiple pages>";216216+static inline const char *check_heap_object(const void *ptr, unsigned long n,217217+ bool to_user)218218+{219219+ struct page *page;220220+221221+ /*222222+ * Some architectures (arm64) return true for virt_addr_valid() on223223+ * vmalloced addresses. Work around this by checking for vmalloc224224+ * first.225225+ */226226+ if (is_vmalloc_addr(ptr))227227+ return NULL;228228+229229+ if (!virt_addr_valid(ptr))230230+ return NULL;231231+232232+ page = virt_to_head_page(ptr);233233+234234+ /* Check slab allocator for flags and size. */235235+ if (PageSlab(page))236236+ return __check_heap_object(ptr, n, page);237237+238238+ /* Verify object does not incorrectly span multiple pages. */239239+ return check_page_span(ptr, n, page, to_user);201240}202241203242/*
···147147 or are part of the kernel text. This kills entire classes148148 of heap overflow exploits and similar kernel memory exposures.149149150150+config HARDENED_USERCOPY_PAGESPAN151151+ bool "Refuse to copy allocations that span multiple pages"152152+ depends on HARDENED_USERCOPY153153+ depends on EXPERT154154+ help155155+ When a multi-page allocation is done without __GFP_COMP,156156+ hardened usercopy will reject attempts to copy it. There are,157157+ however, several cases of this in the kernel that have not all158158+ been removed. This config is intended to be used only while159159+ trying to find such users.160160+150161source security/selinux/Kconfig151162source security/smack/Kconfig152163source security/tomoyo/Kconfig
···2525{2626 unsigned int length, till_end, type;2727 struct snd_efw_transaction *t;2828+ u8 *pull_ptr;2829 long count = 0;29303031 if (remained < sizeof(type) + sizeof(struct snd_efw_transaction))···3938 buf += sizeof(type);40394140 /* write into buffer as many responses as possible */4242- while (efw->resp_queues > 0) {4343- t = (struct snd_efw_transaction *)(efw->pull_ptr);4141+ spin_lock_irq(&efw->lock);4242+4343+ /*4444+ * When another task reaches here during this task's access to user4545+ * space, it picks up current position in buffer and can read the same4646+ * series of responses.4747+ */4848+ pull_ptr = efw->pull_ptr;4949+5050+ while (efw->push_ptr != pull_ptr) {5151+ t = (struct snd_efw_transaction *)(pull_ptr);4452 length = be32_to_cpu(t->length) * sizeof(__be32);45534654 /* confirm enough space for this response */···5949 /* copy from ring buffer to user buffer */6050 while (length > 0) {6151 till_end = snd_efw_resp_buf_size -6262- (unsigned int)(efw->pull_ptr - efw->resp_buf);5252+ (unsigned int)(pull_ptr - efw->resp_buf);6353 till_end = min_t(unsigned int, length, till_end);64546565- if (copy_to_user(buf, efw->pull_ptr, till_end))5555+ spin_unlock_irq(&efw->lock);5656+5757+ if (copy_to_user(buf, pull_ptr, till_end))6658 return -EFAULT;67596868- efw->pull_ptr += till_end;6969- if (efw->pull_ptr >= efw->resp_buf +7070- snd_efw_resp_buf_size)7171- efw->pull_ptr -= snd_efw_resp_buf_size;6060+ spin_lock_irq(&efw->lock);6161+6262+ pull_ptr += till_end;6363+ if (pull_ptr >= efw->resp_buf + snd_efw_resp_buf_size)6464+ pull_ptr -= snd_efw_resp_buf_size;72657366 length -= till_end;7467 buf += till_end;7568 count += till_end;7669 remained -= till_end;7770 }7878-7979- efw->resp_queues--;8071 }7272+7373+ /*7474+ * All of tasks can read from the buffer nearly simultaneously, but the7575+ * last position for each task is different depending on the length of7676+ * given buffer. Here, for simplicity, a position of buffer is set by7777+ * the latest task. It's better for a listening application to allow one7878+ * thread to read from the buffer. Unless, each task can read different7979+ * sequence of responses depending on variation of buffer length.8080+ */8181+ efw->pull_ptr = pull_ptr;8282+8383+ spin_unlock_irq(&efw->lock);81848285 return count;8386}···9976hwdep_read_locked(struct snd_efw *efw, char __user *buf, long count,10077 loff_t *offset)10178{102102- union snd_firewire_event event;7979+ union snd_firewire_event event = {8080+ .lock_status.type = SNDRV_FIREWIRE_EVENT_LOCK_STATUS,8181+ };10382104104- memset(&event, 0, sizeof(event));8383+ spin_lock_irq(&efw->lock);10584106106- event.lock_status.type = SNDRV_FIREWIRE_EVENT_LOCK_STATUS;10785 event.lock_status.status = (efw->dev_lock_count > 0);10886 efw->dev_lock_changed = false;8787+8888+ spin_unlock_irq(&efw->lock);1098911090 count = min_t(long, count, sizeof(event.lock_status));11191···12498{12599 struct snd_efw *efw = hwdep->private_data;126100 DEFINE_WAIT(wait);101101+ bool dev_lock_changed;102102+ bool queued;127103128104 spin_lock_irq(&efw->lock);129105130130- while ((!efw->dev_lock_changed) && (efw->resp_queues == 0)) {106106+ dev_lock_changed = efw->dev_lock_changed;107107+ queued = efw->push_ptr != efw->pull_ptr;108108+109109+ while (!dev_lock_changed && !queued) {131110 prepare_to_wait(&efw->hwdep_wait, &wait, TASK_INTERRUPTIBLE);132111 spin_unlock_irq(&efw->lock);133112 schedule();···140109 if (signal_pending(current))141110 return -ERESTARTSYS;142111 spin_lock_irq(&efw->lock);112112+ dev_lock_changed = efw->dev_lock_changed;113113+ queued = efw->push_ptr != efw->pull_ptr;143114 }144115145145- if (efw->dev_lock_changed)146146- count = hwdep_read_locked(efw, buf, count, offset);147147- else if (efw->resp_queues > 0)148148- count = hwdep_read_resp_buf(efw, buf, count, offset);149149-150116 spin_unlock_irq(&efw->lock);117117+118118+ if (dev_lock_changed)119119+ count = hwdep_read_locked(efw, buf, count, offset);120120+ else if (queued)121121+ count = hwdep_read_resp_buf(efw, buf, count, offset);151122152123 return count;153124}···193160 poll_wait(file, &efw->hwdep_wait, wait);194161195162 spin_lock_irq(&efw->lock);196196- if (efw->dev_lock_changed || (efw->resp_queues > 0))163163+ if (efw->dev_lock_changed || efw->pull_ptr != efw->push_ptr)197164 events = POLLIN | POLLRDNORM;198165 else199166 events = 0;