···11+ ==============================22+ KERNEL MODULE SIGNING FACILITY33+ ==============================44+55+CONTENTS66+77+ - Overview.88+ - Configuring module signing.99+ - Generating signing keys.1010+ - Public keys in the kernel.1111+ - Manually signing modules.1212+ - Signed modules and stripping.1313+ - Loading signed modules.1414+ - Non-valid signatures and unsigned modules.1515+ - Administering/protecting the private key.1616+1717+1818+========1919+OVERVIEW2020+========2121+2222+The kernel module signing facility cryptographically signs modules during2323+installation and then checks the signature upon loading the module. This2424+allows increased kernel security by disallowing the loading of unsigned modules2525+or modules signed with an invalid key. Module signing increases security by2626+making it harder to load a malicious module into the kernel. The module2727+signature checking is done by the kernel so that it is not necessary to have2828+trusted userspace bits.2929+3030+This facility uses X.509 ITU-T standard certificates to encode the public keys3131+involved. The signatures are not themselves encoded in any industrial standard3232+type. The facility currently only supports the RSA public key encryption3333+standard (though it is pluggable and permits others to be used). The possible3434+hash algorithms that can be used are SHA-1, SHA-224, SHA-256, SHA-384, and3535+SHA-512 (the algorithm is selected by data in the signature).3636+3737+3838+==========================3939+CONFIGURING MODULE SIGNING4040+==========================4141+4242+The module signing facility is enabled by going to the "Enable Loadable Module4343+Support" section of the kernel configuration and turning on4444+4545+ CONFIG_MODULE_SIG "Module signature verification"4646+4747+This has a number of options available:4848+4949+ (1) "Require modules to be validly signed" (CONFIG_MODULE_SIG_FORCE)5050+5151+ This specifies how the kernel should deal with a module that has a5252+ signature for which the key is not known or a module that is unsigned.5353+5454+ If this is off (ie. "permissive"), then modules for which the key is not5555+ available and modules that are unsigned are permitted, but the kernel will5656+ be marked as being tainted.5757+5858+ If this is on (ie. "restrictive"), only modules that have a valid5959+ signature that can be verified by a public key in the kernel's possession6060+ will be loaded. All other modules will generate an error.6161+6262+ Irrespective of the setting here, if the module has a signature block that6363+ cannot be parsed, it will be rejected out of hand.6464+6565+6666+ (2) "Automatically sign all modules" (CONFIG_MODULE_SIG_ALL)6767+6868+ If this is on then modules will be automatically signed during the6969+ modules_install phase of a build. If this is off, then the modules must7070+ be signed manually using:7171+7272+ scripts/sign-file7373+7474+7575+ (3) "Which hash algorithm should modules be signed with?"7676+7777+ This presents a choice of which hash algorithm the installation phase will7878+ sign the modules with:7979+8080+ CONFIG_SIG_SHA1 "Sign modules with SHA-1"8181+ CONFIG_SIG_SHA224 "Sign modules with SHA-224"8282+ CONFIG_SIG_SHA256 "Sign modules with SHA-256"8383+ CONFIG_SIG_SHA384 "Sign modules with SHA-384"8484+ CONFIG_SIG_SHA512 "Sign modules with SHA-512"8585+8686+ The algorithm selected here will also be built into the kernel (rather8787+ than being a module) so that modules signed with that algorithm can have8888+ their signatures checked without causing a dependency loop.8989+9090+9191+=======================9292+GENERATING SIGNING KEYS9393+=======================9494+9595+Cryptographic keypairs are required to generate and check signatures. A9696+private key is used to generate a signature and the corresponding public key is9797+used to check it. The private key is only needed during the build, after which9898+it can be deleted or stored securely. The public key gets built into the9999+kernel so that it can be used to check the signatures as the modules are100100+loaded.101101+102102+Under normal conditions, the kernel build will automatically generate a new103103+keypair using openssl if one does not exist in the files:104104+105105+ signing_key.priv106106+ signing_key.x509107107+108108+during the building of vmlinux (the public part of the key needs to be built109109+into vmlinux) using parameters in the:110110+111111+ x509.genkey112112+113113+file (which is also generated if it does not already exist).114114+115115+It is strongly recommended that you provide your own x509.genkey file.116116+117117+Most notably, in the x509.genkey file, the req_distinguished_name section118118+should be altered from the default:119119+120120+ [ req_distinguished_name ]121121+ O = Magrathea122122+ CN = Glacier signing key123123+ emailAddress = slartibartfast@magrathea.h2g2124124+125125+The generated RSA key size can also be set with:126126+127127+ [ req ]128128+ default_bits = 4096129129+130130+131131+It is also possible to manually generate the key private/public files using the132132+x509.genkey key generation configuration file in the root node of the Linux133133+kernel sources tree and the openssl command. The following is an example to134134+generate the public/private key files:135135+136136+ openssl req -new -nodes -utf8 -sha256 -days 36500 -batch -x509 \137137+ -config x509.genkey -outform DER -out signing_key.x509 \138138+ -keyout signing_key.priv139139+140140+141141+=========================142142+PUBLIC KEYS IN THE KERNEL143143+=========================144144+145145+The kernel contains a ring of public keys that can be viewed by root. They're146146+in a keyring called ".system_keyring" that can be seen by:147147+148148+ [root@deneb ~]# cat /proc/keys149149+ ...150150+ 223c7853 I------ 1 perm 1f030000 0 0 keyring .system_keyring: 1151151+ 302d2d52 I------ 1 perm 1f010000 0 0 asymmetri Fedora kernel signing key: d69a84e6bce3d216b979e9505b3e3ef9a7118079: X509.RSA a7118079 []152152+ ...153153+154154+Beyond the public key generated specifically for module signing, any file155155+placed in the kernel source root directory or the kernel build root directory156156+whose name is suffixed with ".x509" will be assumed to be an X.509 public key157157+and will be added to the keyring.158158+159159+Further, the architecture code may take public keys from a hardware store and160160+add those in also (e.g. from the UEFI key database).161161+162162+Finally, it is possible to add additional public keys by doing:163163+164164+ keyctl padd asymmetric "" [.system_keyring-ID] <[key-file]165165+166166+e.g.:167167+168168+ keyctl padd asymmetric "" 0x223c7853 <my_public_key.x509169169+170170+Note, however, that the kernel will only permit keys to be added to171171+.system_keyring _if_ the new key's X.509 wrapper is validly signed by a key172172+that is already resident in the .system_keyring at the time the key was added.173173+174174+175175+=========================176176+MANUALLY SIGNING MODULES177177+=========================178178+179179+To manually sign a module, use the scripts/sign-file tool available in180180+the Linux kernel source tree. The script requires 4 arguments:181181+182182+ 1. The hash algorithm (e.g., sha256)183183+ 2. The private key filename184184+ 3. The public key filename185185+ 4. The kernel module to be signed186186+187187+The following is an example to sign a kernel module:188188+189189+ scripts/sign-file sha512 kernel-signkey.priv \190190+ kernel-signkey.x509 module.ko191191+192192+The hash algorithm used does not have to match the one configured, but if it193193+doesn't, you should make sure that hash algorithm is either built into the194194+kernel or can be loaded without requiring itself.195195+196196+197197+============================198198+SIGNED MODULES AND STRIPPING199199+============================200200+201201+A signed module has a digital signature simply appended at the end. The string202202+"~Module signature appended~." at the end of the module's file confirms that a203203+signature is present but it does not confirm that the signature is valid!204204+205205+Signed modules are BRITTLE as the signature is outside of the defined ELF206206+container. Thus they MAY NOT be stripped once the signature is computed and207207+attached. Note the entire module is the signed payload, including any and all208208+debug information present at the time of signing.209209+210210+211211+======================212212+LOADING SIGNED MODULES213213+======================214214+215215+Modules are loaded with insmod, modprobe, init_module() or finit_module(),216216+exactly as for unsigned modules as no processing is done in userspace. The217217+signature checking is all done within the kernel.218218+219219+220220+=========================================221221+NON-VALID SIGNATURES AND UNSIGNED MODULES222222+=========================================223223+224224+If CONFIG_MODULE_SIG_FORCE is enabled or enforcemodulesig=1 is supplied on225225+the kernel command line, the kernel will only load validly signed modules226226+for which it has a public key. Otherwise, it will also load modules that are227227+unsigned. Any module for which the kernel has a key, but which proves to have228228+a signature mismatch will not be permitted to load.229229+230230+Any module that has an unparseable signature will be rejected.231231+232232+233233+=========================================234234+ADMINISTERING/PROTECTING THE PRIVATE KEY235235+=========================================236236+237237+Since the private key is used to sign modules, viruses and malware could use238238+the private key to sign modules and compromise the operating system. The239239+private key must be either destroyed or moved to a secure location and not kept240240+in the root node of the kernel source tree.
+6-2
Documentation/networking/ip-sysctl.txt
···1616 Default: 64 (as recommended by RFC1700)17171818ip_no_pmtu_disc - BOOLEAN1919- Disable Path MTU Discovery.2020- default FALSE1919+ Disable Path MTU Discovery. If enabled and a2020+ fragmentation-required ICMP is received, the PMTU to this2121+ destination will be set to min_pmtu (see below). You will need2222+ to raise min_pmtu to the smallest interface MTU on your system2323+ manually if you want to avoid locally generated fragments.2424+ Default: FALSE21252226min_pmtu - INTEGER2327 default 552 - minimum discovered Path MTU
···225225 is_io = pa & (HPTE_R_I | HPTE_R_W);226226 pte_size = PAGE_SIZE << (pa & KVMPPC_PAGE_ORDER_MASK);227227 pa &= PAGE_MASK;228228+ pa |= gpa & ~PAGE_MASK;228229 } else {229230 /* Translate to host virtual address */230231 hva = __gfn_to_hva_memslot(memslot, gfn);···239238 ptel = hpte_make_readonly(ptel);240239 is_io = hpte_cache_bits(pte_val(pte));241240 pa = pte_pfn(pte) << PAGE_SHIFT;241241+ pa |= hva & (pte_size - 1);242242+ pa |= gpa & ~PAGE_MASK;242243 }243244 }244245245246 if (pte_size < psize)246247 return H_PARAMETER;247247- if (pa && pte_size > psize)248248- pa |= gpa & (pte_size - 1);249248250249 ptel &= ~(HPTE_R_PP0 - psize);251250 ptel |= pa;···750749 20, /* 1M, unsupported */751750};752751752752+/* When called from virtmode, this func should be protected by753753+ * preempt_disable(), otherwise, the holding of HPTE_V_HVLOCK754754+ * can trigger deadlock issue.755755+ */753756long kvmppc_hv_find_lock_hpte(struct kvm *kvm, gva_t eaddr, unsigned long slb_v,754757 unsigned long valid)755758{
+13-10
arch/powerpc/kvm/book3s_hv_rmhandlers.S
···15315315415413: b machine_check_fwnmi155155156156-157156/*158157 * We come in here when wakened from nap mode on a secondary hw thread.159158 * Relocation is off and most register values are lost.···223224 /* Clear our vcpu pointer so we don't come back in early */224225 li r0, 0225226 std r0, HSTATE_KVM_VCPU(r13)227227+ /*228228+ * Make sure we clear HSTATE_KVM_VCPU(r13) before incrementing229229+ * the nap_count, because once the increment to nap_count is230230+ * visible we could be given another vcpu.231231+ */226232 lwsync227233 /* Clear any pending IPI - we're an offline thread */228234 ld r5, HSTATE_XICS_PHYS(r13)···245241 /* increment the nap count and then go to nap mode */246242 ld r4, HSTATE_KVM_VCORE(r13)247243 addi r4, r4, VCORE_NAP_COUNT248248- lwsync /* make previous updates visible */24924451: lwarx r3, 0, r4250245 addi r3, r3, 1251246 stwcx. r3, 0, r4···754751 * guest CR, R12 saved in shadow VCPU SCRATCH1/0755752 * guest R13 saved in SPRN_SCRATCH0756753 */757757- /* abuse host_r2 as third scratch area; we get r2 from PACATOC(r13) */758758- std r9, HSTATE_HOST_R2(r13)754754+ std r9, HSTATE_SCRATCH2(r13)759755760756 lbz r9, HSTATE_IN_GUEST(r13)761757 cmpwi r9, KVM_GUEST_MODE_HOST_HV762758 beq kvmppc_bad_host_intr763759#ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE764760 cmpwi r9, KVM_GUEST_MODE_GUEST765765- ld r9, HSTATE_HOST_R2(r13)761761+ ld r9, HSTATE_SCRATCH2(r13)766762 beq kvmppc_interrupt_pr767763#endif768764 /* We're now back in the host but in guest MMU context */···781779 std r6, VCPU_GPR(R6)(r9)782780 std r7, VCPU_GPR(R7)(r9)783781 std r8, VCPU_GPR(R8)(r9)784784- ld r0, HSTATE_HOST_R2(r13)782782+ ld r0, HSTATE_SCRATCH2(r13)785783 std r0, VCPU_GPR(R9)(r9)786784 std r10, VCPU_GPR(R10)(r9)787785 std r11, VCPU_GPR(R11)(r9)···992990 */993991 /* Increment the threads-exiting-guest count in the 0xff00994992 bits of vcore->entry_exit_count */995995- lwsync996993 ld r5,HSTATE_KVM_VCORE(r13)997994 addi r6,r5,VCORE_ENTRY_EXIT99899541: lwarx r3,0,r6999996 addi r0,r3,0x1001000997 stwcx. r0,0,r61001998 bne 41b10021002- lwsync999999+ isync /* order stwcx. vs. reading napping_threads */1003100010041001 /*10051002 * At this point we have an interrupt that we have to pass···10311030 sld r0,r0,r410321031 andc. r3,r3,r0 /* no sense IPI'ing ourselves */10331032 beq 43f10331033+ /* Order entry/exit update vs. IPIs */10341034+ sync10341035 mulli r4,r4,PACA_SIZE /* get paca for thread 0 */10351036 subf r6,r4,r131036103742: andi. r0,r3,1···16411638 bge kvm_cede_exit16421639 stwcx. r4,0,r616431640 bne 31b16411641+ /* order napping_threads update vs testing entry_exit_count */16421642+ isync16441643 li r0,116451644 stb r0,HSTATE_NAPPING(r13)16461646- /* order napping_threads update vs testing entry_exit_count */16471647- lwsync16481645 mr r4,r316491646 lwz r7,VCORE_ENTRY_EXIT(r5)16501647 cmpwi r7,0x100
+11-8
arch/powerpc/kvm/book3s_interrupts.S
···129129 * R12 = exit handler id130130 * R13 = PACA131131 * SVCPU.* = guest *132132+ * MSR.EE = 1132133 *133134 */134135136136+ PPC_LL r3, GPR4(r1) /* vcpu pointer */137137+138138+ /*139139+ * kvmppc_copy_from_svcpu can clobber volatile registers, save140140+ * the exit handler id to the vcpu and restore it from there later.141141+ */142142+ stw r12, VCPU_TRAP(r3)143143+135144 /* Transfer reg values from shadow vcpu back to vcpu struct */136145 /* On 64-bit, interrupts are still off at this point */137137- PPC_LL r3, GPR4(r1) /* vcpu pointer */146146+138147 GET_SHADOW_VCPU(r4)139148 bl FUNC(kvmppc_copy_from_svcpu)140149 nop141150142151#ifdef CONFIG_PPC_BOOK3S_64143143- /* Re-enable interrupts */144144- ld r3, HSTATE_HOST_MSR(r13)145145- ori r3, r3, MSR_EE146146- MTMSR_EERI(r3)147147-148152 /*149153 * Reload kernel SPRG3 value.150154 * No need to save guest value as usermode can't modify SPRG3.151155 */152156 ld r3, PACA_SPRG3(r13)153157 mtspr SPRN_SPRG3, r3154154-155158#endif /* CONFIG_PPC_BOOK3S_64 */156159157160 /* R7 = vcpu */···180177 PPC_STL r31, VCPU_GPR(R31)(r7)181178182179 /* Pass the exit number as 3rd argument to kvmppc_handle_exit */183183- mr r5, r12180180+ lwz r5, VCPU_TRAP(r7)184181185182 /* Restore r3 (kvm_run) and r4 (vcpu) */186183 REST_2GPRS(3, r1)
+22
arch/powerpc/kvm/book3s_pr.c
···6666 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);6767 memcpy(svcpu->slb, to_book3s(vcpu)->slb_shadow, sizeof(svcpu->slb));6868 svcpu->slb_max = to_book3s(vcpu)->slb_shadow_max;6969+ svcpu->in_use = 0;6970 svcpu_put(svcpu);7071#endif7172 vcpu->cpu = smp_processor_id();···7978{8079#ifdef CONFIG_PPC_BOOK3S_648180 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);8181+ if (svcpu->in_use) {8282+ kvmppc_copy_from_svcpu(vcpu, svcpu);8383+ }8284 memcpy(to_book3s(vcpu)->slb_shadow, svcpu->slb, sizeof(svcpu->slb));8385 to_book3s(vcpu)->slb_shadow_max = svcpu->slb_max;8486 svcpu_put(svcpu);···114110 svcpu->ctr = vcpu->arch.ctr;115111 svcpu->lr = vcpu->arch.lr;116112 svcpu->pc = vcpu->arch.pc;113113+ svcpu->in_use = true;117114}118115119116/* Copy data touched by real-mode code from shadow vcpu back to vcpu */120117void kvmppc_copy_from_svcpu(struct kvm_vcpu *vcpu,121118 struct kvmppc_book3s_shadow_vcpu *svcpu)122119{120120+ /*121121+ * vcpu_put would just call us again because in_use hasn't122122+ * been updated yet.123123+ */124124+ preempt_disable();125125+126126+ /*127127+ * Maybe we were already preempted and synced the svcpu from128128+ * our preempt notifiers. Don't bother touching this svcpu then.129129+ */130130+ if (!svcpu->in_use)131131+ goto out;132132+123133 vcpu->arch.gpr[0] = svcpu->gpr[0];124134 vcpu->arch.gpr[1] = svcpu->gpr[1];125135 vcpu->arch.gpr[2] = svcpu->gpr[2];···157139 vcpu->arch.fault_dar = svcpu->fault_dar;158140 vcpu->arch.fault_dsisr = svcpu->fault_dsisr;159141 vcpu->arch.last_inst = svcpu->last_inst;142142+ svcpu->in_use = false;143143+144144+out:145145+ preempt_enable();160146}161147162148static int kvmppc_core_check_requests_pr(struct kvm_vcpu *vcpu)
+1-5
arch/powerpc/kvm/book3s_rmhandlers.S
···153153154154 li r6, MSR_IR | MSR_DR155155 andc r6, r5, r6 /* Clear DR and IR in MSR value */156156-#ifdef CONFIG_PPC_BOOK3S_32157156 /*158157 * Set EE in HOST_MSR so that it's enabled when we get into our159159- * C exit handler function. On 64-bit we delay enabling160160- * interrupts until we have finished transferring stuff161161- * to or from the PACA.158158+ * C exit handler function.162159 */163160 ori r5, r5, MSR_EE164164-#endif165161 mtsrr0 r7166162 mtsrr1 r6167163 RFI
+6-6
arch/powerpc/kvm/booke.c
···681681int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)682682{683683 int ret, s;684684- struct thread_struct thread;684684+ struct debug_reg debug;685685#ifdef CONFIG_PPC_FPU686686 struct thread_fp_state fp;687687 int fpexc_mode;···723723#endif724724725725 /* Switch to guest debug context */726726- thread.debug = vcpu->arch.shadow_dbg_reg;727727- switch_booke_debug_regs(&thread);728728- thread.debug = current->thread.debug;726726+ debug = vcpu->arch.shadow_dbg_reg;727727+ switch_booke_debug_regs(&debug);728728+ debug = current->thread.debug;729729 current->thread.debug = vcpu->arch.shadow_dbg_reg;730730731731 kvmppc_fix_ee_before_entry();···736736 We also get here with interrupts enabled. */737737738738 /* Switch back to user space debug context */739739- switch_booke_debug_regs(&thread);740740- current->thread.debug = thread.debug;739739+ switch_booke_debug_regs(&debug);740740+ current->thread.debug = debug;741741742742#ifdef CONFIG_PPC_FPU743743 kvmppc_save_guest_fp(vcpu);
···619619}620620621621#define pte_accessible pte_accessible622622-static inline unsigned long pte_accessible(pte_t a)622622+static inline unsigned long pte_accessible(struct mm_struct *mm, pte_t a)623623{624624 return pte_val(a) & _PAGE_VALID;625625}···847847 * SUN4V NOTE: _PAGE_VALID is the same value in both the SUN4U848848 * and SUN4V pte layout, so this inline test is fine.849849 */850850- if (likely(mm != &init_mm) && pte_accessible(orig))850850+ if (likely(mm != &init_mm) && pte_accessible(mm, orig))851851 tlb_batch_add(mm, addr, ptep, orig, fullmm);852852}853853
+1
arch/x86/Kconfig
···2626 select HAVE_AOUT if X86_322727 select HAVE_UNSTABLE_SCHED_CLOCK2828 select ARCH_SUPPORTS_NUMA_BALANCING2929+ select ARCH_SUPPORTS_INT128 if X86_642930 select ARCH_WANTS_PROT_NUMA_PROT_NONE3031 select HAVE_IDE3132 select HAVE_OPROFILE
+9-2
arch/x86/include/asm/pgtable.h
···452452}453453454454#define pte_accessible pte_accessible455455-static inline int pte_accessible(pte_t a)455455+static inline bool pte_accessible(struct mm_struct *mm, pte_t a)456456{457457- return pte_flags(a) & _PAGE_PRESENT;457457+ if (pte_flags(a) & _PAGE_PRESENT)458458+ return true;459459+460460+ if ((pte_flags(a) & (_PAGE_PROTNONE | _PAGE_NUMA)) &&461461+ mm_tlb_flush_pending(mm))462462+ return true;463463+464464+ return false;458465}459466460467static inline int pte_hidden(pte_t pte)
+11
arch/x86/include/asm/preempt.h
···88DECLARE_PER_CPU(int, __preempt_count);991010/*1111+ * We use the PREEMPT_NEED_RESCHED bit as an inverted NEED_RESCHED such1212+ * that a decrement hitting 0 means we can and should reschedule.1313+ */1414+#define PREEMPT_ENABLED (0 + PREEMPT_NEED_RESCHED)1515+1616+/*1117 * We mask the PREEMPT_NEED_RESCHED bit so as not to confuse all current users1218 * that think a non-zero value indicates we cannot preempt.1319 */···8074 __this_cpu_add_4(__preempt_count, -val);8175}82767777+/*7878+ * Because we keep PREEMPT_NEED_RESCHED set when we do _not_ need to reschedule7979+ * a decrement which hits zero means we have no preempt_count and should8080+ * reschedule.8181+ */8382static __always_inline bool __preempt_count_dec_and_test(void)8483{8584 GEN_UNARY_RMWcc("decl", __preempt_count, __percpu_arg(0), "e");
+12-3
arch/x86/kernel/cpu/perf_event.h
···262262 __EVENT_CONSTRAINT(c, n, INTEL_ARCH_EVENT_MASK, \263263 HWEIGHT(n), 0, PERF_X86_EVENT_PEBS_ST_HSW)264264265265-#define EVENT_CONSTRAINT_END \266266- EVENT_CONSTRAINT(0, 0, 0)265265+/*266266+ * We define the end marker as having a weight of -1267267+ * to enable blacklisting of events using a counter bitmask268268+ * of zero and thus a weight of zero.269269+ * The end marker has a weight that cannot possibly be270270+ * obtained from counting the bits in the bitmask.271271+ */272272+#define EVENT_CONSTRAINT_END { .weight = -1 }267273274274+/*275275+ * Check for end marker with weight == -1276276+ */268277#define for_each_event_constraint(e, c) \269269- for ((e) = (c); (e)->weight; (e)++)278278+ for ((e) = (c); (e)->weight != -1; (e)++)270279271280/*272281 * Extra registers for specific events.
+13
arch/x86/mm/gup.c
···8383 pte_t pte = gup_get_pte(ptep);8484 struct page *page;85858686+ /* Similar to the PMD case, NUMA hinting must take slow path */8787+ if (pte_numa(pte)) {8888+ pte_unmap(ptep);8989+ return 0;9090+ }9191+8692 if ((pte_flags(pte) & (mask | _PAGE_SPECIAL)) != mask) {8793 pte_unmap(ptep);8894 return 0;···173167 if (pmd_none(pmd) || pmd_trans_splitting(pmd))174168 return 0;175169 if (unlikely(pmd_large(pmd))) {170170+ /*171171+ * NUMA hinting faults need to be handled in the GUP172172+ * slowpath for accounting purposes and so that they173173+ * can be serialised against THP migration.174174+ */175175+ if (pmd_numa(pmd))176176+ return 0;176177 if (!gup_huge_pmd(pmd, addr, next, write, pages, nr))177178 return 0;178179 } else {
···6060 struct s2mps11_clk *s2mps11 = to_s2mps11_clk(hw);6161 int ret;62626363- ret = regmap_update_bits(s2mps11->iodev->regmap,6363+ ret = regmap_update_bits(s2mps11->iodev->regmap_pmic,6464 S2MPS11_REG_RTC_CTRL,6565 s2mps11->mask, s2mps11->mask);6666 if (!ret)···7474 struct s2mps11_clk *s2mps11 = to_s2mps11_clk(hw);7575 int ret;76767777- ret = regmap_update_bits(s2mps11->iodev->regmap, S2MPS11_REG_RTC_CTRL,7777+ ret = regmap_update_bits(s2mps11->iodev->regmap_pmic, S2MPS11_REG_RTC_CTRL,7878 s2mps11->mask, ~s2mps11->mask);79798080 if (!ret)···174174 s2mps11_clk->hw.init = &s2mps11_clks_init[i];175175 s2mps11_clk->mask = 1 << i;176176177177- ret = regmap_read(s2mps11_clk->iodev->regmap,177177+ ret = regmap_read(s2mps11_clk->iodev->regmap_pmic,178178 S2MPS11_REG_RTC_CTRL, &val);179179 if (ret < 0)180180 goto err_reg;
+1
drivers/clocksource/Kconfig
···7575config CLKSRC_EFM327676 bool "Clocksource for Energy Micro's EFM32 SoCs" if !ARCH_EFM327777 depends on OF && ARM && (ARCH_EFM32 || COMPILE_TEST)7878+ select CLKSRC_MMIO7879 default ARCH_EFM327980 help8081 Support to use the timers of EFM32 SoCs as clock source and clock
···179179 writel(TIMER_CTL_CLK_SRC(TIMER_CTL_CLK_SRC_OSC24M),180180 timer_base + TIMER_CTL_REG(0));181181182182+ /* Make sure timer is stopped before playing with interrupts */183183+ sun4i_clkevt_time_stop(0);184184+182185 ret = setup_irq(irq, &sun4i_timer_irq);183186 if (ret)184187 pr_warn("failed to setup irq %d\n", irq);
+5-5
drivers/clocksource/time-armada-370-xp.c
···256256 ticks_per_jiffy = (timer_clk + HZ / 2) / HZ;257257258258 /*259259- * Set scale and timer for sched_clock.260260- */261261- sched_clock_register(armada_370_xp_read_sched_clock, 32, timer_clk);262262-263263- /*264259 * Setup free-running clocksource timer (interrupts265260 * disabled).266261 */···264269265270 timer_ctrl_clrset(0, TIMER0_EN | TIMER0_RELOAD_EN |266271 TIMER0_DIV(TIMER_DIVIDER_SHIFT));272272+273273+ /*274274+ * Set scale and timer for sched_clock.275275+ */276276+ sched_clock_register(armada_370_xp_read_sched_clock, 32, timer_clk);267277268278 clocksource_mmio_init(timer_base + TIMER0_VAL_OFF,269279 "armada_370_xp_clocksource",
+7
drivers/dma/Kconfig
···6262 tristate "Intel I/OAT DMA support"6363 depends on PCI && X866464 select DMA_ENGINE6565+ select DMA_ENGINE_RAID6566 select DCA6667 help6768 Enable support for the Intel(R) I/OAT DMA engine present···113112 bool "Marvell XOR engine support"114113 depends on PLAT_ORION115114 select DMA_ENGINE115115+ select DMA_ENGINE_RAID116116 select ASYNC_TX_ENABLE_CHANNEL_SWITCH117117 ---help---118118 Enable support for the Marvell XOR engine.···189187 tristate "AMCC PPC440SPe ADMA support"190188 depends on 440SPe || 440SP191189 select DMA_ENGINE190190+ select DMA_ENGINE_RAID192191 select ARCH_HAS_ASYNC_TX_FIND_CHANNEL193192 select ASYNC_TX_ENABLE_CHANNEL_SWITCH194193 help···355352 bool "Network: TCP receive copy offload"356353 depends on DMA_ENGINE && NET357354 default (INTEL_IOATDMA || FSL_DMA)355355+ depends on BROKEN358356 help359357 This enables the use of DMA engines in the network stack to360358 offload receive copy-to-user operations, freeing CPU cycles.···380376 help381377 Simple DMA test client. Say N unless you're debugging a382378 DMA Device driver.379379+380380+config DMA_ENGINE_RAID381381+ bool383382384383endif
···300300 if (offset < TWL4030_GPIO_MAX)301301 ret = twl4030_set_gpio_direction(offset, 1);302302 else303303- ret = -EINVAL;303303+ ret = -EINVAL; /* LED outputs can't be set as input */304304305305 if (!ret)306306 priv->direction &= ~BIT(offset);···354354static int twl_direction_out(struct gpio_chip *chip, unsigned offset, int value)355355{356356 struct gpio_twl4030_priv *priv = to_gpio_twl4030(chip);357357- int ret = -EINVAL;357357+ int ret = 0;358358359359 mutex_lock(&priv->mutex);360360- if (offset < TWL4030_GPIO_MAX)360360+ if (offset < TWL4030_GPIO_MAX) {361361 ret = twl4030_set_gpio_direction(offset, 0);362362+ if (ret) {363363+ mutex_unlock(&priv->mutex);364364+ return ret;365365+ }366366+ }367367+368368+ /*369369+ * LED gpios i.e. offset >= TWL4030_GPIO_MAX are always output370370+ */362371363372 priv->direction |= BIT(offset);364373 mutex_unlock(&priv->mutex);
···566566 if (dev->driver->unload)567567 dev->driver->unload(dev);568568err_primary_node:569569- drm_put_minor(dev->primary);569569+ drm_unplug_minor(dev->primary);570570err_render_node:571571- drm_put_minor(dev->render);571571+ drm_unplug_minor(dev->render);572572err_control_node:573573- drm_put_minor(dev->control);573573+ drm_unplug_minor(dev->control);574574err_agp:575575 if (dev->driver->bus->agp_destroy)576576 dev->driver->bus->agp_destroy(dev);
+11-9
drivers/gpu/drm/i915/i915_dma.c
···8383 drm_i915_private_t *dev_priv = dev->dev_private;8484 struct drm_i915_master_private *master_priv;85858686+ /*8787+ * The dri breadcrumb update races against the drm master disappearing.8888+ * Instead of trying to fix this (this is by far not the only ums issue)8989+ * just don't do the update in kms mode.9090+ */9191+ if (drm_core_check_feature(dev, DRIVER_MODESET))9292+ return;9393+8694 if (dev->primary->master) {8795 master_priv = dev->primary->master->driver_priv;8896 if (master_priv->sarea_priv)···14981490 spin_lock_init(&dev_priv->uncore.lock);14991491 spin_lock_init(&dev_priv->mm.object_stat_lock);15001492 mutex_init(&dev_priv->dpio_lock);15011501- mutex_init(&dev_priv->rps.hw_lock);15021493 mutex_init(&dev_priv->modeset_restore_lock);1503149415041504- mutex_init(&dev_priv->pc8.lock);15051505- dev_priv->pc8.requirements_met = false;15061506- dev_priv->pc8.gpu_idle = false;15071507- dev_priv->pc8.irqs_disabled = false;15081508- dev_priv->pc8.enabled = false;15091509- dev_priv->pc8.disable_count = 2; /* requirements_met + gpu_idle */15101510- INIT_DELAYED_WORK(&dev_priv->pc8.enable_work, hsw_enable_pc8_work);14951495+ intel_pm_setup(dev);1511149615121497 intel_display_crc_init(dev);15131498···16041603 }1605160416061605 intel_irq_init(dev);16071607- intel_pm_init(dev);16081606 intel_uncore_sanitize(dev);1609160716101608 /* Try to make sure MCHBAR is enabled before poking at it */···1848184818491849void i915_driver_preclose(struct drm_device * dev, struct drm_file *file_priv)18501850{18511851+ mutex_lock(&dev->struct_mutex);18511852 i915_gem_context_close(dev, file_priv);18521853 i915_gem_release(dev, file_priv);18541854+ mutex_unlock(&dev->struct_mutex);18531855}1854185618551857void i915_driver_postclose(struct drm_device *dev, struct drm_file *file)
···347347{348348 struct drm_i915_file_private *file_priv = file->driver_priv;349349350350- mutex_lock(&dev->struct_mutex);351350 idr_for_each(&file_priv->context_idr, context_idr_cleanup, NULL);352351 idr_destroy(&file_priv->context_idr);353353- mutex_unlock(&dev->struct_mutex);354352}355353356354static struct i915_hw_context *···421423 if (ret)422424 return ret;423425424424- /* Clear this page out of any CPU caches for coherent swap-in/out. Note426426+ /*427427+ * Pin can switch back to the default context if we end up calling into428428+ * evict_everything - as a last ditch gtt defrag effort that also429429+ * switches to the default context. Hence we need to reload from here.430430+ */431431+ from = ring->last_context;432432+433433+ /*434434+ * Clear this page out of any CPU caches for coherent swap-in/out. Note425435 * that thanks to write = false in this call and us not setting any gpu426436 * write domains when putting a context object onto the active list427437 * (when switching away from it), this won't block.428428- * XXX: We need a real interface to do this instead of trickery. */438438+ *439439+ * XXX: We need a real interface to do this instead of trickery.440440+ */429441 ret = i915_gem_object_set_to_gtt_domain(to->obj, false);430442 if (ret) {431443 i915_gem_object_unpin(to->obj);
+11-3
drivers/gpu/drm/i915/i915_gem_evict.c
···8888 } else8989 drm_mm_init_scan(&vm->mm, min_size, alignment, cache_level);90909191+search_again:9192 /* First see if there is a large enough contiguous idle region... */9293 list_for_each_entry(vma, &vm->inactive_list, mm_list) {9394 if (mark_free(vma, &unwind_list))···116115 list_del_init(&vma->exec_list);117116 }118117119119- /* We expect the caller to unpin, evict all and try again, or give up.120120- * So calling i915_gem_evict_vm() is unnecessary.118118+ /* Can we unpin some objects such as idle hw contents,119119+ * or pending flips?121120 */122122- return -ENOSPC;121121+ ret = nonblocking ? -ENOSPC : i915_gpu_idle(dev);122122+ if (ret)123123+ return ret;124124+125125+ /* Only idle the GPU and repeat the search once */126126+ i915_gem_retire_requests(dev);127127+ nonblocking = true;128128+ goto search_again;123129124130found:125131 /* drm_mm doesn't allow any other other operations while
···784784int intel_gpu_reset(struct drm_device *dev)785785{786786 switch (INTEL_INFO(dev)->gen) {787787+ case 8:787788 case 7:788789 case 6: return gen6_do_reset(dev);789790 case 5: return ironlake_do_reset(dev);
+6
drivers/gpu/drm/nouveau/nouveau_drm.c
···858858 if (nouveau_runtime_pm == 0)859859 return -EINVAL;860860861861+ /* are we optimus enabled? */862862+ if (nouveau_runtime_pm == -1 && !nouveau_is_optimus() && !nouveau_is_v1_dsm()) {863863+ DRM_DEBUG_DRIVER("failing to power off - not optimus\n");864864+ return -EINVAL;865865+ }866866+861867 nv_debug_level(SILENT);862868 drm_kms_helper_poll_disable(drm_dev);863869 vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_OFF);
+3-1
drivers/gpu/drm/radeon/atombios_crtc.c
···11961196 } else if ((rdev->family == CHIP_TAHITI) ||11971197 (rdev->family == CHIP_PITCAIRN))11981198 fb_format |= SI_GRPH_PIPE_CONFIG(SI_ADDR_SURF_P8_32x32_8x16);11991199- else if (rdev->family == CHIP_VERDE)11991199+ else if ((rdev->family == CHIP_VERDE) ||12001200+ (rdev->family == CHIP_OLAND) ||12011201+ (rdev->family == CHIP_HAINAN)) /* for completeness. HAINAN has no display hw */12001202 fb_format |= SI_GRPH_PIPE_CONFIG(SI_ADDR_SURF_P4_8x16);1201120312021204 switch (radeon_crtc->crtc_id) {
···162162 base = RREG32_MC(R_000100_MCCFG_FB_LOCATION);163163 base = G_000100_MC_FB_START(base) << 16;164164 rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev);165165+ /* Some boards seem to be configured for 128MB of sideport memory,166166+ * but really only have 64MB. Just skip the sideport and use167167+ * UMA memory.168168+ */169169+ if (rdev->mc.igp_sideport_enabled &&170170+ (rdev->mc.real_vram_size == (384 * 1024 * 1024))) {171171+ base += 128 * 1024 * 1024;172172+ rdev->mc.real_vram_size -= 128 * 1024 * 1024;173173+ rdev->mc.mc_vram_size = rdev->mc.real_vram_size;174174+ }165175166176 /* Use K8 direct mapping for fast fb access. */ 167177 rdev->fastfb_working = false;
···149149static void intc_irqpin_mask_unmask_prio(struct intc_irqpin_priv *p,150150 int irq, int do_mask)151151{152152- int bitfield_width = 4; /* PRIO assumed to have fixed bitfield width */153153- int shift = (7 - irq) * bitfield_width; /* PRIO assumed to be 32-bit */152152+ /* The PRIO register is assumed to be 32-bit with fixed 4-bit fields. */153153+ int bitfield_width = 4;154154+ int shift = 32 - (irq + 1) * bitfield_width;154155155156 intc_irqpin_read_modify_write(p, INTC_IRQPIN_REG_PRIO,156157 shift, bitfield_width,···160159161160static int intc_irqpin_set_sense(struct intc_irqpin_priv *p, int irq, int value)162161{162162+ /* The SENSE register is assumed to be 32-bit. */163163 int bitfield_width = p->config.sense_bitfield_width;164164- int shift = (7 - irq) * bitfield_width; /* SENSE assumed to be 32-bit */164164+ int shift = 32 - (irq + 1) * bitfield_width;165165166166 dev_dbg(&p->pdev->dev, "sense irq = %d, mode = %d\n", irq, value);167167
···927927 /* set LED in default state (end of init phase) */928928 pcan_usb_pro_set_led(dev, 0, 1);929929930930+ kfree(bi);931931+ kfree(fi);932932+930933 return 0;931934932935 err_out:
···667667static int qlcnic_validate_ring_count(struct qlcnic_adapter *adapter,668668 u8 rx_ring, u8 tx_ring)669669{670670+ if (rx_ring == 0 || tx_ring == 0)671671+ return -EINVAL;672672+670673 if (rx_ring != 0) {671674 if (rx_ring > adapter->max_sds_rings) {672672- netdev_err(adapter->netdev, "Invalid ring count, SDS ring count %d should not be greater than max %d driver sds rings.\n",675675+ netdev_err(adapter->netdev,676676+ "Invalid ring count, SDS ring count %d should not be greater than max %d driver sds rings.\n",673677 rx_ring, adapter->max_sds_rings);674678 return -EINVAL;675679 }676680 }677681678682 if (tx_ring != 0) {679679- if (qlcnic_82xx_check(adapter) &&680680- (tx_ring > adapter->max_tx_rings)) {683683+ if (tx_ring > adapter->max_tx_rings) {681684 netdev_err(adapter->netdev,682685 "Invalid ring count, Tx ring count %d should not be greater than max %d driver Tx rings.\n",683686 tx_ring, adapter->max_tx_rings);684687 return -EINVAL;685685- }686686-687687- if (qlcnic_83xx_check(adapter) &&688688- (tx_ring > QLCNIC_SINGLE_RING)) {689689- netdev_err(adapter->netdev,690690- "Invalid ring count, Tx ring count %d should not be greater than %d driver Tx rings.\n",691691- tx_ring, QLCNIC_SINGLE_RING);692692- return -EINVAL;693688 }694689 }695690···943948 struct qlcnic_hardware_context *ahw = adapter->ahw;944949 struct qlcnic_cmd_args cmd;945950 int ret, drv_sds_rings = adapter->drv_sds_rings;951951+ int drv_tx_rings = adapter->drv_tx_rings;946952947953 if (qlcnic_83xx_check(adapter))948954 return qlcnic_83xx_interrupt_test(netdev);···976980977981clear_diag_irq:978982 adapter->drv_sds_rings = drv_sds_rings;983983+ adapter->drv_tx_rings = drv_tx_rings;979984 clear_bit(__QLCNIC_RESETTING, &adapter->state);980985981986 return ret;
+2-8
drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
···687687 if (adapter->ahw->linkup && !linkup) {688688 netdev_info(netdev, "NIC Link is down\n");689689 adapter->ahw->linkup = 0;690690- if (netif_running(netdev)) {691691- netif_carrier_off(netdev);692692- netif_tx_stop_all_queues(netdev);693693- }690690+ netif_carrier_off(netdev);694691 } else if (!adapter->ahw->linkup && linkup) {695692 netdev_info(netdev, "NIC Link is up\n");696693 adapter->ahw->linkup = 1;697697- if (netif_running(netdev)) {698698- netif_carrier_on(netdev);699699- netif_wake_queue(netdev);700700- }694694+ netif_carrier_on(netdev);701695 }702696}703697
···2424config OMAP_USB22525 tristate "OMAP USB2 PHY Driver"2626 depends on ARCH_OMAP2PLUS2727+ depends on USB_PHY2728 select GENERIC_PHY2828- select USB_PHY2929 select OMAP_CONTROL_USB3030 help3131 Enable this to support the transceiver that is part of SOC. This···3636config TWL4030_USB3737 tristate "TWL4030 USB Transceiver Driver"3838 depends on TWL4030_CORE && REGULATOR_TWL4030 && USB_MUSB_OMAP2PLUS3939+ depends on USB_PHY3940 select GENERIC_PHY4040- select USB_PHY4141 help4242 Enable this to support the USB OTG transceiver on TWL40304343 family chips (including the TWL5030 and TPS659x0 devices).
+10-16
drivers/phy/phy-core.c
···437437 int id;438438 struct phy *phy;439439440440- if (!dev) {441441- dev_WARN(dev, "no device provided for PHY\n");442442- ret = -EINVAL;443443- goto err0;444444- }440440+ if (WARN_ON(!dev))441441+ return ERR_PTR(-EINVAL);445442446443 phy = kzalloc(sizeof(*phy), GFP_KERNEL);447447- if (!phy) {448448- ret = -ENOMEM;449449- goto err0;450450- }444444+ if (!phy)445445+ return ERR_PTR(-ENOMEM);451446452447 id = ida_simple_get(&phy_ida, 0, 0, GFP_KERNEL);453448 if (id < 0) {454449 dev_err(dev, "unable to get id\n");455450 ret = id;456456- goto err0;451451+ goto free_phy;457452 }458453459454 device_initialize(&phy->dev);···463468464469 ret = dev_set_name(&phy->dev, "phy-%s.%d", dev_name(dev), id);465470 if (ret)466466- goto err1;471471+ goto put_dev;467472468473 ret = device_add(&phy->dev);469474 if (ret)470470- goto err1;475475+ goto put_dev;471476472477 if (pm_runtime_enabled(dev)) {473478 pm_runtime_enable(&phy->dev);···476481477482 return phy;478483479479-err1:480480- ida_remove(&phy_ida, phy->id);484484+put_dev:481485 put_device(&phy->dev);486486+ ida_remove(&phy_ida, phy->id);487487+free_phy:482488 kfree(phy);483483-484484-err0:485489 return ERR_PTR(ret);486490}487491EXPORT_SYMBOL_GPL(phy_create);
···88888989 imx_drm_device_put();90909191- drm_mode_config_cleanup(imxdrm->drm);9191+ drm_vblank_cleanup(imxdrm->drm);9292 drm_kms_helper_poll_fini(imxdrm->drm);9393+ drm_mode_config_cleanup(imxdrm->drm);93949495 return 0;9596}···200199 if (!file->is_master)201200 return;202201203203- for (i = 0; i < 4; i++)204204- imx_drm_disable_vblank(drm , i);202202+ for (i = 0; i < MAX_CRTC; i++)203203+ imx_drm_disable_vblank(drm, i);205204}206205207206static const struct file_operations imx_drm_driver_fops = {···377376 struct imx_drm_device *imxdrm = __imx_drm_device();378377 int ret;379378380380- drm_crtc_init(imxdrm->drm, imx_drm_crtc->crtc,381381- imx_drm_crtc->imx_drm_helper_funcs.crtc_funcs);382379 ret = drm_mode_crtc_set_gamma_size(imx_drm_crtc->crtc, 256);383380 if (ret)384381 return ret;385382386383 drm_crtc_helper_add(imx_drm_crtc->crtc,387384 imx_drm_crtc->imx_drm_helper_funcs.crtc_helper_funcs);385385+386386+ drm_crtc_init(imxdrm->drm, imx_drm_crtc->crtc,387387+ imx_drm_crtc->imx_drm_helper_funcs.crtc_funcs);388388389389 drm_mode_group_reinit(imxdrm->drm);390390···430428 ret = drm_mode_group_init_legacy_group(imxdrm->drm,431429 &imxdrm->drm->primary->mode_group);432430 if (ret)433433- goto err_init;431431+ goto err_kms;434432435433 ret = drm_vblank_init(imxdrm->drm, MAX_CRTC);436434 if (ret)437437- goto err_init;435435+ goto err_kms;438436439437 /*440438 * with vblank_disable_allowed = true, vblank interrupt will be disabled···443441 */444442 imxdrm->drm->vblank_disable_allowed = true;445443446446- if (!imx_drm_device_get())444444+ if (!imx_drm_device_get()) {447445 ret = -EINVAL;446446+ goto err_vblank;447447+ }448448449449 platform_set_drvdata(drm->platformdev, drm);450450+ mutex_unlock(&imxdrm->mutex);451451+ return 0;450452451451- ret = 0;452452-453453-err_init:453453+err_vblank:454454+ drm_vblank_cleanup(drm);455455+err_kms:456456+ drm_kms_helper_poll_fini(drm);457457+ drm_mode_config_cleanup(drm);454458 mutex_unlock(&imxdrm->mutex);455459456460 return ret;···502494503495 mutex_lock(&imxdrm->mutex);504496497497+ /*498498+ * The vblank arrays are dimensioned by MAX_CRTC - we can't499499+ * pass IDs greater than this to those functions.500500+ */501501+ if (imxdrm->pipes >= MAX_CRTC) {502502+ ret = -EINVAL;503503+ goto err_busy;504504+ }505505+505506 if (imxdrm->drm->open_count) {506507 ret = -EBUSY;507508 goto err_busy;···547530 return 0;548531549532err_register:533533+ list_del(&imx_drm_crtc->list);550534 kfree(imx_drm_crtc);551535err_alloc:552536err_busy:
-9
drivers/staging/imx-drm/imx-tve.c
···114114 struct drm_encoder encoder;115115 struct imx_drm_encoder *imx_drm_encoder;116116 struct device *dev;117117- spinlock_t enable_lock; /* serializes tve_enable/disable */118117 spinlock_t lock; /* register lock */119118 bool enabled;120119 int mode;···145146146147static void tve_enable(struct imx_tve *tve)147148{148148- unsigned long flags;149149 int ret;150150151151- spin_lock_irqsave(&tve->enable_lock, flags);152151 if (!tve->enabled) {153152 tve->enabled = true;154153 clk_prepare_enable(tve->clk);···166169 TVE_CD_SM_IEN |167170 TVE_CD_LM_IEN |168171 TVE_CD_MON_END_IEN);169169-170170- spin_unlock_irqrestore(&tve->enable_lock, flags);171172}172173173174static void tve_disable(struct imx_tve *tve)174175{175175- unsigned long flags;176176 int ret;177177178178- spin_lock_irqsave(&tve->enable_lock, flags);179178 if (tve->enabled) {180179 tve->enabled = false;181180 ret = regmap_update_bits(tve->regmap, TVE_COM_CONF_REG,182181 TVE_IPU_CLK_EN | TVE_EN, 0);183182 clk_disable_unprepare(tve->clk);184183 }185185- spin_unlock_irqrestore(&tve->enable_lock, flags);186184}187185188186static int tve_setup_tvout(struct imx_tve *tve)···593601594602 tve->dev = &pdev->dev;595603 spin_lock_init(&tve->lock);596596- spin_lock_init(&tve->enable_lock);597604598605 ddc_node = of_parse_phandle(np, "ddc", 0);599606 if (ddc_node) {
+16-16
drivers/staging/imx-drm/ipu-v3/ipu-common.c
···995995 },996996};997997998998+static DEFINE_MUTEX(ipu_client_id_mutex);998999static int ipu_client_id;999999-10001000-static int ipu_add_subdevice_pdata(struct device *dev,10011001- const struct ipu_platform_reg *reg)10021002-{10031003- struct platform_device *pdev;10041004-10051005- pdev = platform_device_register_data(dev, reg->name, ipu_client_id++,10061006- ®->pdata, sizeof(struct ipu_platform_reg));10071007-10081008- return PTR_ERR_OR_ZERO(pdev);10091009-}1010100010111001static int ipu_add_client_devices(struct ipu_soc *ipu)10121002{10131013- int ret;10141014- int i;10031003+ struct device *dev = ipu->dev;10041004+ unsigned i;10051005+ int id, ret;10061006+10071007+ mutex_lock(&ipu_client_id_mutex);10081008+ id = ipu_client_id;10091009+ ipu_client_id += ARRAY_SIZE(client_reg);10101010+ mutex_unlock(&ipu_client_id_mutex);1015101110161012 for (i = 0; i < ARRAY_SIZE(client_reg); i++) {10171013 const struct ipu_platform_reg *reg = &client_reg[i];10181018- ret = ipu_add_subdevice_pdata(ipu->dev, reg);10191019- if (ret)10141014+ struct platform_device *pdev;10151015+10161016+ pdev = platform_device_register_data(dev, reg->name,10171017+ id++, ®->pdata, sizeof(reg->pdata));10181018+10191019+ if (IS_ERR(pdev))10201020 goto err_register;10211021 }1022102210231023 return 0;1024102410251025err_register:10261026- platform_device_unregister_children(to_platform_device(ipu->dev));10261026+ platform_device_unregister_children(to_platform_device(dev));1027102710281028 return ret;10291029}
+13-14
drivers/target/iscsi/iscsi_target.c
···465465 */466466 send_sig(SIGINT, np->np_thread, 1);467467 kthread_stop(np->np_thread);468468+ np->np_thread = NULL;468469 }469470470471 np->np_transport->iscsit_free_np(np);···824823 if (((hdr->flags & ISCSI_FLAG_CMD_READ) ||825824 (hdr->flags & ISCSI_FLAG_CMD_WRITE)) && !hdr->data_length) {826825 /*827827- * Vmware ESX v3.0 uses a modified Cisco Initiator (v3.4.2)828828- * that adds support for RESERVE/RELEASE. There is a bug829829- * add with this new functionality that sets R/W bits when830830- * neither CDB carries any READ or WRITE datapayloads.826826+ * From RFC-3720 Section 10.3.1:827827+ *828828+ * "Either or both of R and W MAY be 1 when either the829829+ * Expected Data Transfer Length and/or Bidirectional Read830830+ * Expected Data Transfer Length are 0"831831+ *832832+ * For this case, go ahead and clear the unnecssary bits833833+ * to avoid any confusion with ->data_direction.831834 */832832- if ((hdr->cdb[0] == 0x16) || (hdr->cdb[0] == 0x17)) {833833- hdr->flags &= ~ISCSI_FLAG_CMD_READ;834834- hdr->flags &= ~ISCSI_FLAG_CMD_WRITE;835835- goto done;836836- }835835+ hdr->flags &= ~ISCSI_FLAG_CMD_READ;836836+ hdr->flags &= ~ISCSI_FLAG_CMD_WRITE;837837838838- pr_err("ISCSI_FLAG_CMD_READ or ISCSI_FLAG_CMD_WRITE"838838+ pr_warn("ISCSI_FLAG_CMD_READ or ISCSI_FLAG_CMD_WRITE"839839 " set when Expected Data Transfer Length is 0 for"840840- " CDB: 0x%02x. Bad iSCSI Initiator.\n", hdr->cdb[0]);841841- return iscsit_add_reject_cmd(cmd,842842- ISCSI_REASON_BOOKMARK_INVALID, buf);840840+ " CDB: 0x%02x, Fixing up flags\n", hdr->cdb[0]);843841 }844844-done:845842846843 if (!(hdr->flags & ISCSI_FLAG_CMD_READ) &&847844 !(hdr->flags & ISCSI_FLAG_CMD_WRITE) && (hdr->data_length != 0)) {
···8686 return atomic_long_add_return(delta, (atomic_long_t *)&sem->count);8787}88888989+/*9090+ * ldsem_cmpxchg() updates @*old with the last-known sem->count value.9191+ * Returns 1 if count was successfully changed; @*old will have @new value.9292+ * Returns 0 if count was not changed; @*old will have most recent sem->count9393+ */8994static inline int ldsem_cmpxchg(long *old, long new, struct ld_semaphore *sem)9095{9191- long tmp = *old;9292- *old = atomic_long_cmpxchg(&sem->count, *old, new);9393- return *old == tmp;9696+ long tmp = atomic_long_cmpxchg(&sem->count, *old, new);9797+ if (tmp == *old) {9898+ *old = new;9999+ return 1;100100+ } else {101101+ *old = tmp;102102+ return 0;103103+ }94104}9510596106/*
+4
drivers/usb/chipidea/core.c
···642642 : CI_ROLE_GADGET;643643 }644644645645+ /* only update vbus status for peripheral */646646+ if (ci->role == CI_ROLE_GADGET)647647+ ci_handle_vbus_change(ci);648648+645649 ret = ci_role_start(ci, ci->role);646650 if (ret) {647651 dev_err(dev, "can't start %s role\n", ci_role(ci)->name);
+2-1
drivers/usb/chipidea/host.c
···8888 return ret;89899090disable_reg:9191- regulator_disable(ci->platdata->reg_vbus);9191+ if (ci->platdata->reg_vbus)9292+ regulator_disable(ci->platdata->reg_vbus);92939394put_hcd:9495 usb_put_hcd(hcd);
···854854{855855 /* need autopm_get/put here to ensure the usbcore sees the new value */856856 int rv = usb_autopm_get_interface(intf);857857- if (rv < 0)858858- goto err;859857860858 intf->needs_remote_wakeup = on;861861- usb_autopm_put_interface(intf);862862-err:863863- return rv;859859+ if (!rv)860860+ usb_autopm_put_interface(intf);861861+ return 0;864862}865863866864static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id)
+5-3
drivers/usb/dwc3/core.c
···455455 if (IS_ERR(regs))456456 return PTR_ERR(regs);457457458458- usb_phy_set_suspend(dwc->usb2_phy, 0);459459- usb_phy_set_suspend(dwc->usb3_phy, 0);460460-461458 spin_lock_init(&dwc->lock);462459 platform_set_drvdata(pdev, dwc);463460···484487 dev_err(dev, "failed to initialize core\n");485488 goto err0;486489 }490490+491491+ usb_phy_set_suspend(dwc->usb2_phy, 0);492492+ usb_phy_set_suspend(dwc->usb3_phy, 0);487493488494 ret = dwc3_event_buffers_setup(dwc);489495 if (ret) {···569569 dwc3_event_buffers_cleanup(dwc);570570571571err1:572572+ usb_phy_set_suspend(dwc->usb2_phy, 1);573573+ usb_phy_set_suspend(dwc->usb3_phy, 1);572574 dwc3_core_exit(dwc);573575574576err0:
···128128 * any other sleep) on Haswell machines with LPT and LPT-LP129129 * with the new Intel BIOS130130 */131131- xhci->quirks |= XHCI_SPURIOUS_WAKEUP;131131+ /* Limit the quirk to only known vendors, as this triggers132132+ * yet another BIOS bug on some other machines133133+ * https://bugzilla.kernel.org/show_bug.cgi?id=66171134134+ */135135+ if (pdev->subsystem_vendor == PCI_VENDOR_ID_HP)136136+ xhci->quirks |= XHCI_SPURIOUS_WAKEUP;132137 }133138 if (pdev->vendor == PCI_VENDOR_ID_ETRON &&134139 pdev->device == PCI_DEVICE_ID_ASROCK_P67) {
+3-1
drivers/usb/phy/Kconfig
···1919 in host mode, low speed.20202121config FSL_USB2_OTG2222- bool "Freescale USB OTG Transceiver Driver"2222+ tristate "Freescale USB OTG Transceiver Driver"2323 depends on USB_EHCI_FSL && USB_FSL_USB2 && PM_RUNTIME2424+ depends on USB2425 select USB_OTG2526 select USB_PHY2627 help···3029config ISP1301_OMAP3130 tristate "Philips ISP1301 with OMAP OTG"3231 depends on I2C && ARCH_OMAP_OTG3232+ depends on USB3333 select USB_PHY3434 help3535 If you say yes here you get support for the Philips ISP1301
+1-1
drivers/usb/phy/phy-tegra-usb.c
···876876877877 tegra_phy->pad_regs = devm_ioremap(&pdev->dev, res->start,878878 resource_size(res));879879- if (!tegra_phy->regs) {879879+ if (!tegra_phy->pad_regs) {880880 dev_err(&pdev->dev, "Failed to remap UTMI Pad regs\n");881881 return -ENOMEM;882882 }
+2-1
drivers/usb/phy/phy-twl6030-usb.c
···127127128128static inline u8 twl6030_readb(struct twl6030_usb *twl, u8 module, u8 address)129129{130130- u8 data, ret = 0;130130+ u8 data;131131+ int ret;131132132133 ret = twl_i2c_read_u8(module, &data, address);133134 if (ret >= 0)
···609609 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;610610 struct kobject *kobj = attr_sd->s_parent->s_dir.kobj;611611 struct sysfs_open_file *of;612612- bool has_read, has_write, has_mmap;612612+ bool has_read, has_write;613613 int error = -EACCES;614614615615 /* need attr_sd for attr and ops, its parent for kobj */···621621622622 has_read = battr->read || battr->mmap;623623 has_write = battr->write || battr->mmap;624624- has_mmap = battr->mmap;625624 } else {626625 const struct sysfs_ops *ops = sysfs_file_ops(attr_sd);627626···632633633634 has_read = ops->show;634635 has_write = ops->store;635635- has_mmap = false;636636 }637637638638 /* check perms and supported operations */···659661 * open file has a separate mutex, it's okay as long as those don't660662 * happen on the same file. At this point, we can't easily give661663 * each file a separate locking class. Let's differentiate on662662- * whether the file has mmap or not for now.664664+ * whether the file is bin or not for now.663665 */664664- if (has_mmap)666666+ if (sysfs_is_bin(attr_sd))665667 mutex_init(&of->mutex);666668 else667669 mutex_init(&of->mutex);
+24-8
fs/xfs/xfs_bmap.c
···16351635 * blocks at the end of the file which do not start at the previous data block,16361636 * we will try to align the new blocks at stripe unit boundaries.16371637 *16381638- * Returns 0 in bma->aeof if the file (fork) is empty as any new write will be16381638+ * Returns 1 in bma->aeof if the file (fork) is empty as any new write will be16391639 * at, or past the EOF.16401640 */16411641STATIC int···16501650 bma->aeof = 0;16511651 error = xfs_bmap_last_extent(NULL, bma->ip, whichfork, &rec,16521652 &is_empty);16531653- if (error || is_empty)16531653+ if (error)16541654 return error;16551655+16561656+ if (is_empty) {16571657+ bma->aeof = 1;16581658+ return 0;16591659+ }1655166016561661 /*16571662 * Check if we are allocation or past the last extent, or at least into···36483643 int isaligned;36493644 int tryagain;36503645 int error;36463646+ int stripe_align;3651364736523648 ASSERT(ap->length);3653364936543650 mp = ap->ip->i_mount;36513651+36523652+ /* stripe alignment for allocation is determined by mount parameters */36533653+ stripe_align = 0;36543654+ if (mp->m_swidth && (mp->m_flags & XFS_MOUNT_SWALLOC))36553655+ stripe_align = mp->m_swidth;36563656+ else if (mp->m_dalign)36573657+ stripe_align = mp->m_dalign;36583658+36553659 align = ap->userdata ? xfs_get_extsz_hint(ap->ip) : 0;36563660 if (unlikely(align)) {36573661 error = xfs_bmap_extsize_align(mp, &ap->got, &ap->prev,···36693655 ASSERT(!error);36703656 ASSERT(ap->length);36713657 }36583658+36593659+36723660 nullfb = *ap->firstblock == NULLFSBLOCK;36733661 fb_agno = nullfb ? NULLAGNUMBER : XFS_FSB_TO_AGNO(mp, *ap->firstblock);36743662 if (nullfb) {···37463730 */37473731 if (!ap->flist->xbf_low && ap->aeof) {37483732 if (!ap->offset) {37493749- args.alignment = mp->m_dalign;37333733+ args.alignment = stripe_align;37503734 atype = args.type;37513735 isaligned = 1;37523736 /*···37713755 * of minlen+alignment+slop doesn't go up37723756 * between the calls.37733757 */37743774- if (blen > mp->m_dalign && blen <= args.maxlen)37753775- nextminlen = blen - mp->m_dalign;37583758+ if (blen > stripe_align && blen <= args.maxlen)37593759+ nextminlen = blen - stripe_align;37763760 else37773761 nextminlen = args.minlen;37783778- if (nextminlen + mp->m_dalign > args.minlen + 1)37623762+ if (nextminlen + stripe_align > args.minlen + 1)37793763 args.minalignslop =37803780- nextminlen + mp->m_dalign -37643764+ nextminlen + stripe_align -37813765 args.minlen - 1;37823766 else37833767 args.minalignslop = 0;···37993783 */38003784 args.type = atype;38013785 args.fsbno = ap->blkno;38023802- args.alignment = mp->m_dalign;37863786+ args.alignment = stripe_align;38033787 args.minlen = nextminlen;38043788 args.minalignslop = 0;38053789 isaligned = 1;
···698698 bp->b_flags |= XBF_READ;699699 bp->b_ops = ops;700700701701- xfsbdstrat(target->bt_mount, bp);701701+ if (XFS_FORCED_SHUTDOWN(target->bt_mount)) {702702+ xfs_buf_relse(bp);703703+ return NULL;704704+ }705705+ xfs_buf_iorequest(bp);702706 xfs_buf_iowait(bp);703707 return bp;704708}···10931089 * This is meant for userdata errors; metadata bufs come with10941090 * iodone functions attached, so that we can track down errors.10951091 */10961096-STATIC int10921092+int10971093xfs_bioerror_relse(10981094 struct xfs_buf *bp)10991095{···11561152 ASSERT(xfs_buf_islocked(bp));1157115311581154 bp->b_flags |= XBF_WRITE;11591159- bp->b_flags &= ~(XBF_ASYNC | XBF_READ | _XBF_DELWRI_Q);11551155+ bp->b_flags &= ~(XBF_ASYNC | XBF_READ | _XBF_DELWRI_Q | XBF_WRITE_FAIL);1160115611611157 xfs_bdstrat_cb(bp);11621158···11661162 SHUTDOWN_META_IO_ERROR);11671163 }11681164 return error;11691169-}11701170-11711171-/*11721172- * Wrapper around bdstrat so that we can stop data from going to disk in case11731173- * we are shutting down the filesystem. Typically user data goes thru this11741174- * path; one of the exceptions is the superblock.11751175- */11761176-void11771177-xfsbdstrat(11781178- struct xfs_mount *mp,11791179- struct xfs_buf *bp)11801180-{11811181- if (XFS_FORCED_SHUTDOWN(mp)) {11821182- trace_xfs_bdstrat_shut(bp, _RET_IP_);11831183- xfs_bioerror_relse(bp);11841184- return;11851185- }11861186-11871187- xfs_buf_iorequest(bp);11881165}1189116611901167STATIC void···15011516 struct xfs_buf *bp;15021517 bp = list_first_entry(&dispose, struct xfs_buf, b_lru);15031518 list_del_init(&bp->b_lru);15191519+ if (bp->b_flags & XBF_WRITE_FAIL) {15201520+ xfs_alert(btp->bt_mount,15211521+"Corruption Alert: Buffer at block 0x%llx had permanent write failures!\n"15221522+"Please run xfs_repair to determine the extent of the problem.",15231523+ (long long)bp->b_bn);15241524+ }15041525 xfs_buf_rele(bp);15051526 }15061527 if (loop++ != 0)···1790179917911800 blk_start_plug(&plug);17921801 list_for_each_entry_safe(bp, n, io_list, b_list) {17931793- bp->b_flags &= ~(_XBF_DELWRI_Q | XBF_ASYNC);18021802+ bp->b_flags &= ~(_XBF_DELWRI_Q | XBF_ASYNC | XBF_WRITE_FAIL);17941803 bp->b_flags |= XBF_WRITE;1795180417961805 if (!wait) {
+7-4
fs/xfs/xfs_buf.h
···4545#define XBF_ASYNC (1 << 4) /* initiator will not wait for completion */4646#define XBF_DONE (1 << 5) /* all pages in the buffer uptodate */4747#define XBF_STALE (1 << 6) /* buffer has been staled, do not find it */4848+#define XBF_WRITE_FAIL (1 << 24)/* async writes have failed on this buffer */48494950/* I/O hints for the BIO layer */5051#define XBF_SYNCIO (1 << 10)/* treat this buffer as synchronous I/O */···7170 { XBF_ASYNC, "ASYNC" }, \7271 { XBF_DONE, "DONE" }, \7372 { XBF_STALE, "STALE" }, \7373+ { XBF_WRITE_FAIL, "WRITE_FAIL" }, \7474 { XBF_SYNCIO, "SYNCIO" }, \7575 { XBF_FUA, "FUA" }, \7676 { XBF_FLUSH, "FLUSH" }, \···8179 { _XBF_KMEM, "KMEM" }, \8280 { _XBF_DELWRI_Q, "DELWRI_Q" }, \8381 { _XBF_COMPOUND, "COMPOUND" }8282+84838584/*8685 * Internal state flags.···272269273270/* Buffer Read and Write Routines */274271extern int xfs_bwrite(struct xfs_buf *bp);275275-276276-extern void xfsbdstrat(struct xfs_mount *, struct xfs_buf *);277277-278272extern void xfs_buf_ioend(xfs_buf_t *, int);279273extern void xfs_buf_ioerror(xfs_buf_t *, int);280274extern void xfs_buf_ioerror_alert(struct xfs_buf *, const char *func);···281281 xfs_buf_rw_t);282282#define xfs_buf_zero(bp, off, len) \283283 xfs_buf_iomove((bp), (off), (len), NULL, XBRW_ZERO)284284+285285+extern int xfs_bioerror_relse(struct xfs_buf *);284286285287static inline int xfs_buf_geterror(xfs_buf_t *bp)286288{···303301304302#define XFS_BUF_ZEROFLAGS(bp) \305303 ((bp)->b_flags &= ~(XBF_READ|XBF_WRITE|XBF_ASYNC| \306306- XBF_SYNCIO|XBF_FUA|XBF_FLUSH))304304+ XBF_SYNCIO|XBF_FUA|XBF_FLUSH| \305305+ XBF_WRITE_FAIL))307306308307void xfs_buf_stale(struct xfs_buf *bp);309308#define XFS_BUF_UNSTALE(bp) ((bp)->b_flags &= ~XBF_STALE)
+19-2
fs/xfs/xfs_buf_item.c
···496496 }497497}498498499499+/*500500+ * Buffer IO error rate limiting. Limit it to no more than 10 messages per 30501501+ * seconds so as to not spam logs too much on repeated detection of the same502502+ * buffer being bad..503503+ */504504+505505+DEFINE_RATELIMIT_STATE(xfs_buf_write_fail_rl_state, 30 * HZ, 10);506506+499507STATIC uint500508xfs_buf_item_push(501509 struct xfs_log_item *lip,···531523 ASSERT(!(bip->bli_flags & XFS_BLI_STALE));532524533525 trace_xfs_buf_item_push(bip);526526+527527+ /* has a previous flush failed due to IO errors? */528528+ if ((bp->b_flags & XBF_WRITE_FAIL) &&529529+ ___ratelimit(&xfs_buf_write_fail_rl_state, "XFS:")) {530530+ xfs_warn(bp->b_target->bt_mount,531531+"Detected failing async write on buffer block 0x%llx. Retrying async write.\n",532532+ (long long)bp->b_bn);533533+ }534534535535 if (!xfs_buf_delwri_queue(bp, buffer_list))536536 rval = XFS_ITEM_FLUSHING;···1112109611131097 xfs_buf_ioerror(bp, 0); /* errno of 0 unsets the flag */1114109811151115- if (!XFS_BUF_ISSTALE(bp)) {11161116- bp->b_flags |= XBF_WRITE | XBF_ASYNC | XBF_DONE;10991099+ if (!(bp->b_flags & (XBF_STALE|XBF_WRITE_FAIL))) {11001100+ bp->b_flags |= XBF_WRITE | XBF_ASYNC |11011101+ XBF_DONE | XBF_WRITE_FAIL;11171102 xfs_buf_iorequest(bp);11181103 } else {11191104 xfs_buf_relse(bp);
+13-13
fs/xfs/xfs_dir2_node.c
···20672067 */20682068int /* error */20692069xfs_dir2_node_removename(20702070- xfs_da_args_t *args) /* operation arguments */20702070+ struct xfs_da_args *args) /* operation arguments */20712071{20722072- xfs_da_state_blk_t *blk; /* leaf block */20722072+ struct xfs_da_state_blk *blk; /* leaf block */20732073 int error; /* error return value */20742074 int rval; /* operation return value */20752075- xfs_da_state_t *state; /* btree cursor */20752075+ struct xfs_da_state *state; /* btree cursor */2076207620772077 trace_xfs_dir2_node_removename(args);20782078···20842084 state->mp = args->dp->i_mount;20852085 state->blocksize = state->mp->m_dirblksize;20862086 state->node_ents = state->mp->m_dir_node_ents;20872087- /*20882088- * Look up the entry we're deleting, set up the cursor.20892089- */20872087+20882088+ /* Look up the entry we're deleting, set up the cursor. */20902089 error = xfs_da3_node_lookup_int(state, &rval);20912090 if (error)20922092- rval = error;20932093- /*20942094- * Didn't find it, upper layer screwed up.20952095- */20912091+ goto out_free;20922092+20932093+ /* Didn't find it, upper layer screwed up. */20962094 if (rval != EEXIST) {20972097- xfs_da_state_free(state);20982098- return rval;20952095+ error = rval;20962096+ goto out_free;20992097 }20982098+21002099 blk = &state->path.blk[state->path.active - 1];21012100 ASSERT(blk->magic == XFS_DIR2_LEAFN_MAGIC);21022101 ASSERT(state->extravalid);···21062107 error = xfs_dir2_leafn_remove(args, blk->bp, blk->index,21072108 &state->extrablk, &rval);21082109 if (error)21092109- return error;21102110+ goto out_free;21102111 /*21112112 * Fix the hash values up the btree.21122113 */···21212122 */21222123 if (!error)21232124 error = xfs_dir2_node_to_leaf(state);21252125+out_free:21242126 xfs_da_state_free(state);21252127 return error;21262128}
···134134{135135 struct xfs_mount *mp = dqp->q_mount;136136 struct xfs_quotainfo *qi = mp->m_quotainfo;137137- struct xfs_dquot *gdqp = NULL;138138- struct xfs_dquot *pdqp = NULL;139137140138 xfs_dqlock(dqp);141139 if ((dqp->dq_flags & XFS_DQ_FREEING) || dqp->q_nrefs != 0) {142140 xfs_dqunlock(dqp);143141 return EAGAIN;144144- }145145-146146- /*147147- * If this quota has a hint attached, prepare for releasing it now.148148- */149149- gdqp = dqp->q_gdquot;150150- if (gdqp) {151151- xfs_dqlock(gdqp);152152- dqp->q_gdquot = NULL;153153- }154154-155155- pdqp = dqp->q_pdquot;156156- if (pdqp) {157157- xfs_dqlock(pdqp);158158- dqp->q_pdquot = NULL;159142 }160143161144 dqp->dq_flags |= XFS_DQ_FREEING;···189206 XFS_STATS_DEC(xs_qm_dquot_unused);190207191208 xfs_qm_dqdestroy(dqp);209209+ return 0;210210+}211211+212212+/*213213+ * Release the group or project dquot pointers the user dquots maybe carrying214214+ * around as a hint, and proceed to purge the user dquot cache if requested.215215+*/216216+STATIC int217217+xfs_qm_dqpurge_hints(218218+ struct xfs_dquot *dqp,219219+ void *data)220220+{221221+ struct xfs_dquot *gdqp = NULL;222222+ struct xfs_dquot *pdqp = NULL;223223+ uint flags = *((uint *)data);224224+225225+ xfs_dqlock(dqp);226226+ if (dqp->dq_flags & XFS_DQ_FREEING) {227227+ xfs_dqunlock(dqp);228228+ return EAGAIN;229229+ }230230+231231+ /* If this quota has a hint attached, prepare for releasing it now */232232+ gdqp = dqp->q_gdquot;233233+ if (gdqp)234234+ dqp->q_gdquot = NULL;235235+236236+ pdqp = dqp->q_pdquot;237237+ if (pdqp)238238+ dqp->q_pdquot = NULL;239239+240240+ xfs_dqunlock(dqp);192241193242 if (gdqp)194194- xfs_qm_dqput(gdqp);243243+ xfs_qm_dqrele(gdqp);195244 if (pdqp)196196- xfs_qm_dqput(pdqp);245245+ xfs_qm_dqrele(pdqp);246246+247247+ if (flags & XFS_QMOPT_UQUOTA)248248+ return xfs_qm_dqpurge(dqp, NULL);249249+197250 return 0;198251}199252···241222 struct xfs_mount *mp,242223 uint flags)243224{244244- if (flags & XFS_QMOPT_UQUOTA)245245- xfs_qm_dquot_walk(mp, XFS_DQ_USER, xfs_qm_dqpurge, NULL);225225+ /*226226+ * We have to release group/project dquot hint(s) from the user dquot227227+ * at first if they are there, otherwise we would run into an infinite228228+ * loop while walking through radix tree to purge other type of dquots229229+ * since their refcount is not zero if the user dquot refers to them230230+ * as hint.231231+ *232232+ * Call the special xfs_qm_dqpurge_hints() will end up go through the233233+ * general xfs_qm_dqpurge() against user dquot cache if requested.234234+ */235235+ xfs_qm_dquot_walk(mp, XFS_DQ_USER, xfs_qm_dqpurge_hints, &flags);236236+246237 if (flags & XFS_QMOPT_GQUOTA)247238 xfs_qm_dquot_walk(mp, XFS_DQ_GROUP, xfs_qm_dqpurge, NULL);248239 if (flags & XFS_QMOPT_PQUOTA)···21112082 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));21122083 ASSERT(XFS_IS_QUOTA_RUNNING(mp));2113208421142114- if (udqp) {20852085+ if (udqp && XFS_IS_UQUOTA_ON(mp)) {21152086 ASSERT(ip->i_udquot == NULL);21162116- ASSERT(XFS_IS_UQUOTA_ON(mp));21172087 ASSERT(ip->i_d.di_uid == be32_to_cpu(udqp->q_core.d_id));2118208821192089 ip->i_udquot = xfs_qm_dqhold(udqp);21202090 xfs_trans_mod_dquot(tp, udqp, XFS_TRANS_DQ_ICOUNT, 1);21212091 }21222122- if (gdqp) {20922092+ if (gdqp && XFS_IS_GQUOTA_ON(mp)) {21232093 ASSERT(ip->i_gdquot == NULL);21242124- ASSERT(XFS_IS_GQUOTA_ON(mp));21252094 ASSERT(ip->i_d.di_gid == be32_to_cpu(gdqp->q_core.d_id));21262095 ip->i_gdquot = xfs_qm_dqhold(gdqp);21272096 xfs_trans_mod_dquot(tp, gdqp, XFS_TRANS_DQ_ICOUNT, 1);21282097 }21292129- if (pdqp) {20982098+ if (pdqp && XFS_IS_PQUOTA_ON(mp)) {21302099 ASSERT(ip->i_pdquot == NULL);21312131- ASSERT(XFS_IS_PQUOTA_ON(mp));21322100 ASSERT(xfs_get_projid(ip) == be32_to_cpu(pdqp->q_core.d_id));2133210121342102 ip->i_pdquot = xfs_qm_dqhold(pdqp);
+12-1
fs/xfs/xfs_trans_buf.c
···314314 ASSERT(bp->b_iodone == NULL);315315 XFS_BUF_READ(bp);316316 bp->b_ops = ops;317317- xfsbdstrat(tp->t_mountp, bp);317317+318318+ /*319319+ * XXX(hch): clean up the error handling here to be less320320+ * of a mess..321321+ */322322+ if (XFS_FORCED_SHUTDOWN(mp)) {323323+ trace_xfs_bdstrat_shut(bp, _RET_IP_);324324+ xfs_bioerror_relse(bp);325325+ } else {326326+ xfs_buf_iorequest(bp);327327+ }328328+318329 error = xfs_buf_iowait(bp);319330 if (error) {320331 xfs_buf_ioerror_alert(bp, __func__);
+3-4
include/asm-generic/pgtable.h
···217217#endif218218219219#ifndef pte_accessible220220-# define pte_accessible(pte) ((void)(pte),1)220220+# define pte_accessible(mm, pte) ((void)(pte), 1)221221#endif222222223223#ifndef flush_tlb_fix_spurious_fault···599599#ifdef CONFIG_TRANSPARENT_HUGEPAGE600600 barrier();601601#endif602602- if (pmd_none(pmdval))602602+ if (pmd_none(pmdval) || pmd_trans_huge(pmdval))603603 return 1;604604 if (unlikely(pmd_bad(pmdval))) {605605- if (!pmd_trans_huge(pmdval))606606- pmd_clear_bad(pmd);605605+ pmd_clear_bad(pmd);607606 return 1;608607 }609608 return 0;
+11-24
include/asm-generic/preempt.h
···3344#include <linux/thread_info.h>5566-/*77- * We mask the PREEMPT_NEED_RESCHED bit so as not to confuse all current users88- * that think a non-zero value indicates we cannot preempt.99- */66+#define PREEMPT_ENABLED (0)77+108static __always_inline int preempt_count(void)119{1212- return current_thread_info()->preempt_count & ~PREEMPT_NEED_RESCHED;1010+ return current_thread_info()->preempt_count;1311}14121513static __always_inline int *preempt_count_ptr(void)···1517 return ¤t_thread_info()->preempt_count;1618}17191818-/*1919- * We now loose PREEMPT_NEED_RESCHED and cause an extra reschedule; however the2020- * alternative is loosing a reschedule. Better schedule too often -- also this2121- * should be a very rare operation.2222- */2320static __always_inline void preempt_count_set(int pc)2421{2522 *preempt_count_ptr() = pc;···3441 task_thread_info(p)->preempt_count = PREEMPT_ENABLED; \3542} while (0)36433737-/*3838- * We fold the NEED_RESCHED bit into the preempt count such that3939- * preempt_enable() can decrement and test for needing to reschedule with a4040- * single instruction.4141- *4242- * We invert the actual bit, so that when the decrement hits 0 we know we both4343- * need to resched (the bit is cleared) and can resched (no preempt count).4444- */4545-4644static __always_inline void set_preempt_need_resched(void)4745{4848- *preempt_count_ptr() &= ~PREEMPT_NEED_RESCHED;4946}50475148static __always_inline void clear_preempt_need_resched(void)5249{5353- *preempt_count_ptr() |= PREEMPT_NEED_RESCHED;5450}55515652static __always_inline bool test_preempt_need_resched(void)5753{5858- return !(*preempt_count_ptr() & PREEMPT_NEED_RESCHED);5454+ return false;5955}60566157/*···63816482static __always_inline bool __preempt_count_dec_and_test(void)6583{6666- return !--*preempt_count_ptr();8484+ /*8585+ * Because of load-store architectures cannot do per-cpu atomic8686+ * operations; we cannot use PREEMPT_NEED_RESCHED because it might get8787+ * lost.8888+ */8989+ return !--*preempt_count_ptr() && tif_need_resched();6790}68916992/*···7689 */7790static __always_inline bool should_resched(void)7891{7979- return unlikely(!*preempt_count_ptr());9292+ return unlikely(!preempt_count() && tif_need_resched());8093}81948295#ifdef CONFIG_PREEMPT
···2626#define USE_SPLIT_PTE_PTLOCKS (NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS)2727#define USE_SPLIT_PMD_PTLOCKS (USE_SPLIT_PTE_PTLOCKS && \2828 IS_ENABLED(CONFIG_ARCH_ENABLE_SPLIT_PMD_PTLOCK))2929+#define ALLOC_SPLIT_PTLOCKS (SPINLOCK_SIZE > BITS_PER_LONG/8)29303031/*3132 * Each physical page in the system has a struct page associated with···156155 * system if PG_buddy is set.157156 */158157#if USE_SPLIT_PTE_PTLOCKS159159-#if BLOATED_SPINLOCKS158158+#if ALLOC_SPLIT_PTLOCKS160159 spinlock_t *ptl;161160#else162161 spinlock_t ptl;···444443 /* numa_scan_seq prevents two threads setting pte_numa */445444 int numa_scan_seq;446445#endif446446+#if defined(CONFIG_NUMA_BALANCING) || defined(CONFIG_COMPACTION)447447+ /*448448+ * An operation with batched TLB flushing is going on. Anything that449449+ * can move process memory needs to flush the TLB when moving a450450+ * PROT_NONE or PROT_NUMA mapped page.451451+ */452452+ bool tlb_flush_pending;453453+#endif447454 struct uprobes_state uprobes_state;448455};449456···467458{468459 return mm->cpu_vm_mask_var;469460}461461+462462+#if defined(CONFIG_NUMA_BALANCING) || defined(CONFIG_COMPACTION)463463+/*464464+ * Memory barriers to keep this state in sync are graciously provided by465465+ * the page table locks, outside of which no page table modifications happen.466466+ * The barriers below prevent the compiler from re-ordering the instructions467467+ * around the memory barriers that are already present in the code.468468+ */469469+static inline bool mm_tlb_flush_pending(struct mm_struct *mm)470470+{471471+ barrier();472472+ return mm->tlb_flush_pending;473473+}474474+static inline void set_tlb_flush_pending(struct mm_struct *mm)475475+{476476+ mm->tlb_flush_pending = true;477477+478478+ /*479479+ * Guarantee that the tlb_flush_pending store does not leak into the480480+ * critical section updating the page tables481481+ */482482+ smp_mb__before_spinlock();483483+}484484+/* Clearing is done after a TLB flush, which also provides a barrier. */485485+static inline void clear_tlb_flush_pending(struct mm_struct *mm)486486+{487487+ barrier();488488+ mm->tlb_flush_pending = false;489489+}490490+#else491491+static inline bool mm_tlb_flush_pending(struct mm_struct *mm)492492+{493493+ return false;494494+}495495+static inline void set_tlb_flush_pending(struct mm_struct *mm)496496+{497497+}498498+static inline void clear_tlb_flush_pending(struct mm_struct *mm)499499+{500500+}501501+#endif470502471503#endif /* _LINUX_MM_TYPES_H */
+3
include/linux/pstore.h
···5151 char *buf;5252 size_t bufsize;5353 struct mutex read_mutex; /* serialize open/read/close */5454+ int flags;5455 int (*open)(struct pstore_info *psi);5556 int (*close)(struct pstore_info *psi);5657 ssize_t (*read)(u64 *id, enum pstore_type_id *type,···7069 struct pstore_info *psi);7170 void *data;7271};7272+7373+#define PSTORE_FLAGS_FRAGILE 173747475#ifdef CONFIG_PSTORE7576extern int pstore_register(struct pstore_info *);
···146146struct blkif_request_rw {147147 uint8_t nr_segments; /* number of segments */148148 blkif_vdev_t handle; /* only for read/write requests */149149-#ifdef CONFIG_X86_64149149+#ifndef CONFIG_X86_32150150 uint32_t _pad1; /* offsetof(blkif_request,u.rw.id) == 8 */151151#endif152152 uint64_t id; /* private guest value, echoed in resp */···163163 uint8_t flag; /* BLKIF_DISCARD_SECURE or zero. */164164#define BLKIF_DISCARD_SECURE (1<<0) /* ignored if discard-secure=0 */165165 blkif_vdev_t _pad1; /* only for read/write requests */166166-#ifdef CONFIG_X86_64166166+#ifndef CONFIG_X86_32167167 uint32_t _pad2; /* offsetof(blkif_req..,u.discard.id)==8*/168168#endif169169 uint64_t id; /* private guest value, echoed in resp */···175175struct blkif_request_other {176176 uint8_t _pad1;177177 blkif_vdev_t _pad2; /* only for read/write requests */178178-#ifdef CONFIG_X86_64178178+#ifndef CONFIG_X86_32179179 uint32_t _pad3; /* offsetof(blkif_req..,u.other.id)==8*/180180#endif181181 uint64_t id; /* private guest value, echoed in resp */···184184struct blkif_request_indirect {185185 uint8_t indirect_op;186186 uint16_t nr_segments;187187-#ifdef CONFIG_X86_64187187+#ifndef CONFIG_X86_32188188 uint32_t _pad1; /* offsetof(blkif_...,u.indirect.id) == 8 */189189#endif190190 uint64_t id;···192192 blkif_vdev_t handle;193193 uint16_t _pad2;194194 grant_ref_t indirect_grefs[BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST];195195-#ifdef CONFIG_X86_64195195+#ifndef CONFIG_X86_32196196 uint32_t _pad3; /* make it 64 byte aligned */197197#else198198 uint64_t _pad3; /* make it 64 byte aligned */
+6
init/Kconfig
···809809config ARCH_SUPPORTS_NUMA_BALANCING810810 bool811811812812+#813813+# For architectures that know their GCC __int128 support is sound814814+#815815+config ARCH_SUPPORTS_INT128816816+ bool817817+812818# For architectures that (ab)use NUMA to represent different memory regions813819# all cpu-local but of different latencies, such as SuperH.814820#
···104104}105105EXPORT_SYMBOL(unregister_reboot_notifier);106106107107-static void migrate_to_reboot_cpu(void)107107+void migrate_to_reboot_cpu(void)108108{109109 /* The boot cpu is always logical cpu 0 */110110 int cpu = reboot_cpu;
+4-2
kernel/sched/core.c
···49024902static void update_top_cache_domain(int cpu)49034903{49044904 struct sched_domain *sd;49054905+ struct sched_domain *busy_sd = NULL;49054906 int id = cpu;49064907 int size = 1;49074908···49104909 if (sd) {49114910 id = cpumask_first(sched_domain_span(sd));49124911 size = cpumask_weight(sched_domain_span(sd));49134913- sd = sd->parent; /* sd_busy */49124912+ busy_sd = sd->parent; /* sd_busy */49144913 }49154915- rcu_assign_pointer(per_cpu(sd_busy, cpu), sd);49144914+ rcu_assign_pointer(per_cpu(sd_busy, cpu), busy_sd);4916491549174916 rcu_assign_pointer(per_cpu(sd_llc, cpu), sd);49184917 per_cpu(sd_llc_size, cpu) = size;···51135112 * die on a /0 trap.51145113 */51155114 sg->sgp->power = SCHED_POWER_SCALE * cpumask_weight(sg_span);51155115+ sg->sgp->power_orig = sg->sgp->power;5116511651175117 /*51185118 * Make sure the first group of this domain contains the
+72-81
kernel/sched/fair.c
···178178 update_sysctl();179179}180180181181-#if BITS_PER_LONG == 32182182-# define WMULT_CONST (~0UL)183183-#else184184-# define WMULT_CONST (1UL << 32)185185-#endif186186-181181+#define WMULT_CONST (~0U)187182#define WMULT_SHIFT 32188183189189-/*190190- * Shift right and round:191191- */192192-#define SRR(x, y) (((x) + (1UL << ((y) - 1))) >> (y))193193-194194-/*195195- * delta *= weight / lw196196- */197197-static unsigned long198198-calc_delta_mine(unsigned long delta_exec, unsigned long weight,199199- struct load_weight *lw)184184+static void __update_inv_weight(struct load_weight *lw)200185{201201- u64 tmp;186186+ unsigned long w;202187203203- /*204204- * weight can be less than 2^SCHED_LOAD_RESOLUTION for task group sched205205- * entities since MIN_SHARES = 2. Treat weight as 1 if less than206206- * 2^SCHED_LOAD_RESOLUTION.207207- */208208- if (likely(weight > (1UL << SCHED_LOAD_RESOLUTION)))209209- tmp = (u64)delta_exec * scale_load_down(weight);188188+ if (likely(lw->inv_weight))189189+ return;190190+191191+ w = scale_load_down(lw->weight);192192+193193+ if (BITS_PER_LONG > 32 && unlikely(w >= WMULT_CONST))194194+ lw->inv_weight = 1;195195+ else if (unlikely(!w))196196+ lw->inv_weight = WMULT_CONST;210197 else211211- tmp = (u64)delta_exec;198198+ lw->inv_weight = WMULT_CONST / w;199199+}212200213213- if (!lw->inv_weight) {214214- unsigned long w = scale_load_down(lw->weight);201201+/*202202+ * delta_exec * weight / lw.weight203203+ * OR204204+ * (delta_exec * (weight * lw->inv_weight)) >> WMULT_SHIFT205205+ *206206+ * Either weight := NICE_0_LOAD and lw \e prio_to_wmult[], in which case207207+ * we're guaranteed shift stays positive because inv_weight is guaranteed to208208+ * fit 32 bits, and NICE_0_LOAD gives another 10 bits; therefore shift >= 22.209209+ *210210+ * Or, weight =< lw.weight (because lw.weight is the runqueue weight), thus211211+ * weight/lw.weight <= 1, and therefore our shift will also be positive.212212+ */213213+static u64 __calc_delta(u64 delta_exec, unsigned long weight, struct load_weight *lw)214214+{215215+ u64 fact = scale_load_down(weight);216216+ int shift = WMULT_SHIFT;215217216216- if (BITS_PER_LONG > 32 && unlikely(w >= WMULT_CONST))217217- lw->inv_weight = 1;218218- else if (unlikely(!w))219219- lw->inv_weight = WMULT_CONST;220220- else221221- lw->inv_weight = WMULT_CONST / w;218218+ __update_inv_weight(lw);219219+220220+ if (unlikely(fact >> 32)) {221221+ while (fact >> 32) {222222+ fact >>= 1;223223+ shift--;224224+ }222225 }223226224224- /*225225- * Check whether we'd overflow the 64-bit multiplication:226226- */227227- if (unlikely(tmp > WMULT_CONST))228228- tmp = SRR(SRR(tmp, WMULT_SHIFT/2) * lw->inv_weight,229229- WMULT_SHIFT/2);230230- else231231- tmp = SRR(tmp * lw->inv_weight, WMULT_SHIFT);227227+ /* hint to use a 32x32->64 mul */228228+ fact = (u64)(u32)fact * lw->inv_weight;232229233233- return (unsigned long)min(tmp, (u64)(unsigned long)LONG_MAX);230230+ while (fact >> 32) {231231+ fact >>= 1;232232+ shift--;233233+ }234234+235235+ return mul_u64_u32_shr(delta_exec, fact, shift);234236}235237236238···445443#endif /* CONFIG_FAIR_GROUP_SCHED */446444447445static __always_inline448448-void account_cfs_rq_runtime(struct cfs_rq *cfs_rq, unsigned long delta_exec);446446+void account_cfs_rq_runtime(struct cfs_rq *cfs_rq, u64 delta_exec);449447450448/**************************************************************451449 * Scheduling class tree data structure manipulation methods:···614612/*615613 * delta /= w616614 */617617-static inline unsigned long618618-calc_delta_fair(unsigned long delta, struct sched_entity *se)615615+static inline u64 calc_delta_fair(u64 delta, struct sched_entity *se)619616{620617 if (unlikely(se->load.weight != NICE_0_LOAD))621621- delta = calc_delta_mine(delta, NICE_0_LOAD, &se->load);618618+ delta = __calc_delta(delta, NICE_0_LOAD, &se->load);622619623620 return delta;624621}···666665 update_load_add(&lw, se->load.weight);667666 load = &lw;668667 }669669- slice = calc_delta_mine(slice, se->load.weight, load);668668+ slice = __calc_delta(slice, se->load.weight, load);670669 }671670 return slice;672671}···704703#endif705704706705/*707707- * Update the current task's runtime statistics. Skip current tasks that708708- * are not in our scheduling class.706706+ * Update the current task's runtime statistics.709707 */710710-static inline void711711-__update_curr(struct cfs_rq *cfs_rq, struct sched_entity *curr,712712- unsigned long delta_exec)713713-{714714- unsigned long delta_exec_weighted;715715-716716- schedstat_set(curr->statistics.exec_max,717717- max((u64)delta_exec, curr->statistics.exec_max));718718-719719- curr->sum_exec_runtime += delta_exec;720720- schedstat_add(cfs_rq, exec_clock, delta_exec);721721- delta_exec_weighted = calc_delta_fair(delta_exec, curr);722722-723723- curr->vruntime += delta_exec_weighted;724724- update_min_vruntime(cfs_rq);725725-}726726-727708static void update_curr(struct cfs_rq *cfs_rq)728709{729710 struct sched_entity *curr = cfs_rq->curr;730711 u64 now = rq_clock_task(rq_of(cfs_rq));731731- unsigned long delta_exec;712712+ u64 delta_exec;732713733714 if (unlikely(!curr))734715 return;735716736736- /*737737- * Get the amount of time the current task was running738738- * since the last time we changed load (this cannot739739- * overflow on 32 bits):740740- */741741- delta_exec = (unsigned long)(now - curr->exec_start);742742- if (!delta_exec)717717+ delta_exec = now - curr->exec_start;718718+ if (unlikely((s64)delta_exec <= 0))743719 return;744720745745- __update_curr(cfs_rq, curr, delta_exec);746721 curr->exec_start = now;722722+723723+ schedstat_set(curr->statistics.exec_max,724724+ max(delta_exec, curr->statistics.exec_max));725725+726726+ curr->sum_exec_runtime += delta_exec;727727+ schedstat_add(cfs_rq, exec_clock, delta_exec);728728+729729+ curr->vruntime += calc_delta_fair(delta_exec, curr);730730+ update_min_vruntime(cfs_rq);747731748732 if (entity_is_task(curr)) {749733 struct task_struct *curtask = task_of(curr);···17361750 */17371751 if (!vma->vm_mm ||17381752 (vma->vm_file && (vma->vm_flags & (VM_READ|VM_WRITE)) == (VM_READ)))17531753+ continue;17541754+17551755+ /*17561756+ * Skip inaccessible VMAs to avoid any confusion between17571757+ * PROT_NONE and NUMA hinting ptes17581758+ */17591759+ if (!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)))17391760 continue;1740176117411762 do {···30083015 }30093016}3010301730113011-static void __account_cfs_rq_runtime(struct cfs_rq *cfs_rq,30123012- unsigned long delta_exec)30183018+static void __account_cfs_rq_runtime(struct cfs_rq *cfs_rq, u64 delta_exec)30133019{30143020 /* dock delta_exec before expiring quota (as it could span periods) */30153021 cfs_rq->runtime_remaining -= delta_exec;···30263034}3027303530283036static __always_inline30293029-void account_cfs_rq_runtime(struct cfs_rq *cfs_rq, unsigned long delta_exec)30373037+void account_cfs_rq_runtime(struct cfs_rq *cfs_rq, u64 delta_exec)30303038{30313039 if (!cfs_bandwidth_used() || !cfs_rq->runtime_enabled)30323040 return;···35663574 return rq_clock_task(rq_of(cfs_rq));35673575}3568357635693569-static void account_cfs_rq_runtime(struct cfs_rq *cfs_rq,35703570- unsigned long delta_exec) {}35773577+static void account_cfs_rq_runtime(struct cfs_rq *cfs_rq, u64 delta_exec) {}35713578static void check_cfs_rq_runtime(struct cfs_rq *cfs_rq) {}35723579static void check_enqueue_throttle(struct cfs_rq *cfs_rq) {}35733580static __always_inline void return_cfs_rq_runtime(struct cfs_rq *cfs_rq) {}
+14
kernel/sched/rt.c
···901901{902902 struct rq *rq = rq_of_rt_rq(rt_rq);903903904904+#ifdef CONFIG_RT_GROUP_SCHED905905+ /*906906+ * Change rq's cpupri only if rt_rq is the top queue.907907+ */908908+ if (&rq->rt != rt_rq)909909+ return;910910+#endif904911 if (rq->online && prio < prev_prio)905912 cpupri_set(&rq->rd->cpupri, rq->cpu, prio);906913}···917910{918911 struct rq *rq = rq_of_rt_rq(rt_rq);919912913913+#ifdef CONFIG_RT_GROUP_SCHED914914+ /*915915+ * Change rq's cpupri only if rt_rq is the top queue.916916+ */917917+ if (&rq->rt != rt_rq)918918+ return;919919+#endif920920 if (rq->online && rt_rq->highest_prio.curr != prev_prio)921921 cpupri_set(&rq->rd->cpupri, rq->cpu, rt_rq->highest_prio.curr);922922}
+1-1
kernel/trace/ftrace.c
···775775 int cpu;776776 int ret = 0;777777778778- for_each_online_cpu(cpu) {778778+ for_each_possible_cpu(cpu) {779779 ret = ftrace_profile_init_cpu(cpu);780780 if (ret)781781 break;
···882882 ret = 0;883883 goto out_unlock;884884 }885885+886886+ /* mmap_sem prevents this happening but warn if that changes */887887+ WARN_ON(pmd_trans_migrating(pmd));888888+885889 if (unlikely(pmd_trans_splitting(pmd))) {886890 /* split huge page running from under us */887891 spin_unlock(src_ptl);···12471243 if ((flags & FOLL_DUMP) && is_huge_zero_pmd(*pmd))12481244 return ERR_PTR(-EFAULT);1249124512461246+ /* Full NUMA hinting faults to serialise migration in fault paths */12471247+ if ((flags & FOLL_NUMA) && pmd_numa(*pmd))12481248+ goto out;12491249+12501250 page = pmd_page(*pmd);12511251 VM_BUG_ON(!PageHead(page));12521252 if (flags & FOLL_TOUCH) {···13031295 if (unlikely(!pmd_same(pmd, *pmdp)))13041296 goto out_unlock;1305129712981298+ /*12991299+ * If there are potential migrations, wait for completion and retry13001300+ * without disrupting NUMA hinting information. Do not relock and13011301+ * check_same as the page may no longer be mapped.13021302+ */13031303+ if (unlikely(pmd_trans_migrating(*pmdp))) {13041304+ spin_unlock(ptl);13051305+ wait_migrate_huge_page(vma->anon_vma, pmdp);13061306+ goto out;13071307+ }13081308+13061309 page = pmd_page(pmd);13071310 BUG_ON(is_huge_zero_page(page));13081311 page_nid = page_to_nid(page);···13421323 /* If the page was locked, there are no parallel migrations */13431324 if (page_locked)13441325 goto clear_pmdnuma;13261326+ }1345132713461346- /*13471347- * Otherwise wait for potential migrations and retry. We do13481348- * relock and check_same as the page may no longer be mapped.13491349- * As the fault is being retried, do not account for it.13501350- */13281328+ /* Migration could have started since the pmd_trans_migrating check */13291329+ if (!page_locked) {13511330 spin_unlock(ptl);13521331 wait_on_page_locked(page);13531332 page_nid = -1;13541333 goto out;13551334 }1356133513571357- /* Page is misplaced, serialise migrations and parallel THP splits */13361336+ /*13371337+ * Page is misplaced. Page lock serialises migrations. Acquire anon_vma13381338+ * to serialises splits13391339+ */13581340 get_page(page);13591341 spin_unlock(ptl);13601360- if (!page_locked)13611361- lock_page(page);13621342 anon_vma = page_lock_anon_vma_read(page);1363134313641344 /* Confirm the PMD did not change while page_table_lock was released */···13671349 put_page(page);13681350 page_nid = -1;13691351 goto out_unlock;13521352+ }13531353+13541354+ /* Bail if we fail to protect against THP splits for any reason */13551355+ if (unlikely(!anon_vma)) {13561356+ put_page(page);13571357+ page_nid = -1;13581358+ goto clear_pmdnuma;13701359 }1371136013721361 /*···15421517 ret = 1;15431518 if (!prot_numa) {15441519 entry = pmdp_get_and_clear(mm, addr, pmd);15201520+ if (pmd_numa(entry))15211521+ entry = pmd_mknonnuma(entry);15451522 entry = pmd_modify(entry, newprot);15461523 ret = HPAGE_PMD_NR;15471524 BUG_ON(pmd_write(entry));···15581531 */15591532 if (!is_huge_zero_page(page) &&15601533 !pmd_numa(*pmd)) {15611561- entry = pmdp_get_and_clear(mm, addr, pmd);15341534+ entry = *pmd;15621535 entry = pmd_mknuma(entry);15631536 ret = HPAGE_PMD_NR;15641537 }
+10-4
mm/memory-failure.c
···15051505 if (ret > 0)15061506 ret = -EIO;15071507 } else {15081508- set_page_hwpoison_huge_page(hpage);15091509- dequeue_hwpoisoned_huge_page(hpage);15101510- atomic_long_add(1 << compound_order(hpage),15111511- &num_poisoned_pages);15081508+ /* overcommit hugetlb page will be freed to buddy */15091509+ if (PageHuge(page)) {15101510+ set_page_hwpoison_huge_page(hpage);15111511+ dequeue_hwpoisoned_huge_page(hpage);15121512+ atomic_long_add(1 << compound_order(hpage),15131513+ &num_poisoned_pages);15141514+ } else {15151515+ SetPageHWPoison(page);15161516+ atomic_long_inc(&num_poisoned_pages);15171517+ }15121518 }15131519 return ret;15141520}
···11971197 break;11981198 vma = vma->vm_next;11991199 }12001200- /*12011201- * queue_pages_range() confirms that @page belongs to some vma,12021202- * so vma shouldn't be NULL.12031203- */12041204- BUG_ON(!vma);1205120012061206- if (PageHuge(page))12071207- return alloc_huge_page_noerr(vma, address, 1);12011201+ if (PageHuge(page)) {12021202+ if (vma)12031203+ return alloc_huge_page_noerr(vma, address, 1);12041204+ else12051205+ return NULL;12061206+ }12071207+ /*12081208+ * if !vma, alloc_page_vma() will use task or system default policy12091209+ */12081210 return alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, address);12091211}12101212#else···13201318 if (nr_failed && (flags & MPOL_MF_STRICT))13211319 err = -EIO;13221320 } else13231323- putback_lru_pages(&pagelist);13211321+ putback_movable_pages(&pagelist);1324132213251323 up_write(&mm->mmap_sem);13261324 mpol_out:
+65-17
mm/migrate.c
···3636#include <linux/hugetlb_cgroup.h>3737#include <linux/gfp.h>3838#include <linux/balloon_compaction.h>3939+#include <linux/mmu_notifier.h>39404041#include <asm/tlbflush.h>4142···317316 */318317int migrate_page_move_mapping(struct address_space *mapping,319318 struct page *newpage, struct page *page,320320- struct buffer_head *head, enum migrate_mode mode)319319+ struct buffer_head *head, enum migrate_mode mode,320320+ int extra_count)321321{322322- int expected_count = 0;322322+ int expected_count = 1 + extra_count;323323 void **pslot;324324325325 if (!mapping) {326326 /* Anonymous page without mapping */327327- if (page_count(page) != 1)327327+ if (page_count(page) != expected_count)328328 return -EAGAIN;329329 return MIGRATEPAGE_SUCCESS;330330 }···335333 pslot = radix_tree_lookup_slot(&mapping->page_tree,336334 page_index(page));337335338338- expected_count = 2 + page_has_private(page);336336+ expected_count += 1 + page_has_private(page);339337 if (page_count(page) != expected_count ||340338 radix_tree_deref_slot_protected(pslot, &mapping->tree_lock) != page) {341339 spin_unlock_irq(&mapping->tree_lock);···585583586584 BUG_ON(PageWriteback(page)); /* Writeback must be complete */587585588588- rc = migrate_page_move_mapping(mapping, newpage, page, NULL, mode);586586+ rc = migrate_page_move_mapping(mapping, newpage, page, NULL, mode, 0);589587590588 if (rc != MIGRATEPAGE_SUCCESS)591589 return rc;···612610613611 head = page_buffers(page);614612615615- rc = migrate_page_move_mapping(mapping, newpage, page, head, mode);613613+ rc = migrate_page_move_mapping(mapping, newpage, page, head, mode, 0);616614617615 if (rc != MIGRATEPAGE_SUCCESS)618616 return rc;···16561654 return 1;16571655}1658165616571657+bool pmd_trans_migrating(pmd_t pmd)16581658+{16591659+ struct page *page = pmd_page(pmd);16601660+ return PageLocked(page);16611661+}16621662+16631663+void wait_migrate_huge_page(struct anon_vma *anon_vma, pmd_t *pmd)16641664+{16651665+ struct page *page = pmd_page(*pmd);16661666+ wait_on_page_locked(page);16671667+}16681668+16591669/*16601670 * Attempt to migrate a misplaced page to the specified destination16611671 * node. Caller is expected to have an elevated reference count on···17301716 struct page *page, int node)17311717{17321718 spinlock_t *ptl;17331733- unsigned long haddr = address & HPAGE_PMD_MASK;17341719 pg_data_t *pgdat = NODE_DATA(node);17351720 int isolated = 0;17361721 struct page *new_page = NULL;17371722 struct mem_cgroup *memcg = NULL;17381723 int page_lru = page_is_file_cache(page);17241724+ unsigned long mmun_start = address & HPAGE_PMD_MASK;17251725+ unsigned long mmun_end = mmun_start + HPAGE_PMD_SIZE;17261726+ pmd_t orig_entry;1739172717401728 /*17411729 * Rate-limit the amount of data that is being migrated to a node.···17601744 goto out_fail;17611745 }1762174617471747+ if (mm_tlb_flush_pending(mm))17481748+ flush_tlb_range(vma, mmun_start, mmun_end);17491749+17631750 /* Prepare a page as a migration target */17641751 __set_page_locked(new_page);17651752 SetPageSwapBacked(new_page);···17741755 WARN_ON(PageLRU(new_page));1775175617761757 /* Recheck the target PMD */17581758+ mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end);17771759 ptl = pmd_lock(mm, pmd);17781778- if (unlikely(!pmd_same(*pmd, entry))) {17601760+ if (unlikely(!pmd_same(*pmd, entry) || page_count(page) != 2)) {17611761+fail_putback:17791762 spin_unlock(ptl);17631763+ mmu_notifier_invalidate_range_end(mm, mmun_start, mmun_end);1780176417811765 /* Reverse changes made by migrate_page_copy() */17821766 if (TestClearPageActive(new_page))···17961774 putback_lru_page(page);17971775 mod_zone_page_state(page_zone(page),17981776 NR_ISOLATED_ANON + page_lru, -HPAGE_PMD_NR);17991799- goto out_fail;17771777+17781778+ goto out_unlock;18001779 }1801178018021781 /*···18091786 */18101787 mem_cgroup_prepare_migration(page, new_page, &memcg);1811178817891789+ orig_entry = *pmd;18121790 entry = mk_pmd(new_page, vma->vm_page_prot);18131813- entry = pmd_mknonnuma(entry);18141814- entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma);18151791 entry = pmd_mkhuge(entry);17921792+ entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma);1816179318171817- pmdp_clear_flush(vma, haddr, pmd);18181818- set_pmd_at(mm, haddr, pmd, entry);18191819- page_add_new_anon_rmap(new_page, vma, haddr);17941794+ /*17951795+ * Clear the old entry under pagetable lock and establish the new PTE.17961796+ * Any parallel GUP will either observe the old page blocking on the17971797+ * page lock, block on the page table lock or observe the new page.17981798+ * The SetPageUptodate on the new page and page_add_new_anon_rmap17991799+ * guarantee the copy is visible before the pagetable update.18001800+ */18011801+ flush_cache_range(vma, mmun_start, mmun_end);18021802+ page_add_new_anon_rmap(new_page, vma, mmun_start);18031803+ pmdp_clear_flush(vma, mmun_start, pmd);18041804+ set_pmd_at(mm, mmun_start, pmd, entry);18051805+ flush_tlb_range(vma, mmun_start, mmun_end);18201806 update_mmu_cache_pmd(vma, address, &entry);18071807+18081808+ if (page_count(page) != 2) {18091809+ set_pmd_at(mm, mmun_start, pmd, orig_entry);18101810+ flush_tlb_range(vma, mmun_start, mmun_end);18111811+ update_mmu_cache_pmd(vma, address, &entry);18121812+ page_remove_rmap(new_page);18131813+ goto fail_putback;18141814+ }18151815+18211816 page_remove_rmap(page);18171817+18221818 /*18231819 * Finish the charge transaction under the page table lock to18241820 * prevent split_huge_page() from dividing up the charge···18451803 */18461804 mem_cgroup_end_migration(memcg, page, new_page, true);18471805 spin_unlock(ptl);18061806+ mmu_notifier_invalidate_range_end(mm, mmun_start, mmun_end);1848180718491808 unlock_page(new_page);18501809 unlock_page(page);···18631820out_fail:18641821 count_vm_events(PGMIGRATE_FAIL, HPAGE_PMD_NR);18651822out_dropref:18661866- entry = pmd_mknonnuma(entry);18671867- set_pmd_at(mm, haddr, pmd, entry);18681868- update_mmu_cache_pmd(vma, address, &entry);18231823+ ptl = pmd_lock(mm, pmd);18241824+ if (pmd_same(*pmd, entry)) {18251825+ entry = pmd_mknonnuma(entry);18261826+ set_pmd_at(mm, mmun_start, pmd, entry);18271827+ update_mmu_cache_pmd(vma, address, &entry);18281828+ }18291829+ spin_unlock(ptl);1869183018311831+out_unlock:18701832 unlock_page(page);18711833 put_page(page);18721834 return 0;
+11-2
mm/mprotect.c
···5252 pte_t ptent;5353 bool updated = false;54545555- ptent = ptep_modify_prot_start(mm, addr, pte);5655 if (!prot_numa) {5656+ ptent = ptep_modify_prot_start(mm, addr, pte);5757+ if (pte_numa(ptent))5858+ ptent = pte_mknonnuma(ptent);5759 ptent = pte_modify(ptent, newprot);5860 updated = true;5961 } else {6062 struct page *page;61636464+ ptent = *pte;6265 page = vm_normal_page(vma, addr, oldpte);6366 if (page) {6467 if (!pte_numa(oldpte)) {6568 ptent = pte_mknuma(ptent);6969+ set_pte_at(mm, addr, pte, ptent);6670 updated = true;6771 }6872 }···83798480 if (updated)8581 pages++;8686- ptep_modify_prot_commit(mm, addr, pte, ptent);8282+8383+ /* Only !prot_numa always clears the pte */8484+ if (!prot_numa)8585+ ptep_modify_prot_commit(mm, addr, pte, ptent);8786 } else if (IS_ENABLED(CONFIG_MIGRATION) && !pte_file(oldpte)) {8887 swp_entry_t entry = pte_to_swp_entry(oldpte);8988···188181 BUG_ON(addr >= end);189182 pgd = pgd_offset(mm, addr);190183 flush_cache_range(vma, addr, end);184184+ set_tlb_flush_pending(mm);191185 do {192186 next = pgd_addr_end(addr, end);193187 if (pgd_none_or_clear_bad(pgd))···200192 /* Only flush the TLB if we actually modified any entries: */201193 if (pages)202194 flush_tlb_range(vma, start, end);195195+ clear_tlb_flush_pending(mm);203196204197 return pages;205198}
+9-10
mm/page_alloc.c
···1816181618171817static bool zone_local(struct zone *local_zone, struct zone *zone)18181818{18191819- return node_distance(local_zone->node, zone->node) == LOCAL_DISTANCE;18191819+ return local_zone->node == zone->node;18201820}1821182118221822static bool zone_allows_reclaim(struct zone *local_zone, struct zone *zone)···19131913 * page was allocated in should have no effect on the19141914 * time the page has in memory before being reclaimed.19151915 *19161916- * When zone_reclaim_mode is enabled, try to stay in19171917- * local zones in the fastpath. If that fails, the19181918- * slowpath is entered, which will do another pass19191919- * starting with the local zones, but ultimately fall19201920- * back to remote zones that do not partake in the19211921- * fairness round-robin cycle of this zonelist.19161916+ * Try to stay in local zones in the fastpath. If19171917+ * that fails, the slowpath is entered, which will do19181918+ * another pass starting with the local zones, but19191919+ * ultimately fall back to remote zones that do not19201920+ * partake in the fairness round-robin cycle of this19211921+ * zonelist.19221922 */19231923 if (alloc_flags & ALLOC_WMARK_LOW) {19241924 if (zone_page_state(zone, NR_ALLOC_BATCH) <= 0)19251925 continue;19261926- if (zone_reclaim_mode &&19271927- !zone_local(preferred_zone, zone))19261926+ if (!zone_local(preferred_zone, zone))19281927 continue;19291928 }19301929 /*···23892390 * thrash fairness information for zones that are not23902391 * actually part of this zonelist's round-robin cycle.23912392 */23922392- if (zone_reclaim_mode && !zone_local(preferred_zone, zone))23932393+ if (!zone_local(preferred_zone, zone))23932394 continue;23942395 mod_zone_page_state(zone, NR_ALLOC_BATCH,23952396 high_wmark_pages(zone) -
···600600 spinlock_t *ptl;601601602602 if (unlikely(PageHuge(page))) {603603+ /* when pud is not present, pte will be NULL */603604 pte = huge_pte_offset(mm, address);605605+ if (!pte)606606+ return NULL;607607+604608 ptl = huge_pte_lockptr(page_hstate(page), mm, pte);605609 goto check;606610 }
···7272{7373 const struct nft_reject *priv = nft_expr_priv(expr);74747575- if (nla_put_be32(skb, NFTA_REJECT_TYPE, priv->type))7575+ if (nla_put_be32(skb, NFTA_REJECT_TYPE, htonl(priv->type)))7676 goto nla_put_failure;77777878 switch (priv->type) {
+4-9
net/ipv4/udp.c
···16001600}1601160116021602/* For TCP sockets, sk_rx_dst is protected by socket lock16031603- * For UDP, we use sk_dst_lock to guard against concurrent changes.16031603+ * For UDP, we use xchg() to guard against concurrent changes.16041604 */16051605static void udp_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst)16061606{16071607 struct dst_entry *old;1608160816091609- spin_lock(&sk->sk_dst_lock);16101610- old = sk->sk_rx_dst;16111611- if (likely(old != dst)) {16121612- dst_hold(dst);16131613- sk->sk_rx_dst = dst;16141614- dst_release(old);16151615- }16161616- spin_unlock(&sk->sk_dst_lock);16091609+ dst_hold(dst);16101610+ old = xchg(&sk->sk_rx_dst, dst);16111611+ dst_release(old);16171612}1618161316191614/*
···3838#include <net/sctp/sctp.h>3939#include <net/sctp/sm.h>40404141+MODULE_SOFTDEP("pre: sctp");4142MODULE_AUTHOR("Wei Yongjun <yjwei@cn.fujitsu.com>");4243MODULE_DESCRIPTION("SCTP snooper");4344MODULE_LICENSE("GPL");···183182 .entry = jsctp_sf_eat_sack,184183};185184185185+static __init int sctp_setup_jprobe(void)186186+{187187+ int ret = register_jprobe(&sctp_recv_probe);188188+189189+ if (ret) {190190+ if (request_module("sctp"))191191+ goto out;192192+ ret = register_jprobe(&sctp_recv_probe);193193+ }194194+195195+out:196196+ return ret;197197+}198198+186199static __init int sctpprobe_init(void)187200{188201 int ret = -ENOMEM;···217202 &sctpprobe_fops))218203 goto free_kfifo;219204220220- ret = register_jprobe(&sctp_recv_probe);205205+ ret = sctp_setup_jprobe();221206 if (ret)222207 goto remove_proc;223208
+6-2
net/unix/af_unix.c
···718718 int err;719719 unsigned int retries = 0;720720721721- mutex_lock(&u->readlock);721721+ err = mutex_lock_interruptible(&u->readlock);722722+ if (err)723723+ return err;722724723725 err = 0;724726 if (u->addr)···879877 goto out;880878 addr_len = err;881879882882- mutex_lock(&u->readlock);880880+ err = mutex_lock_interruptible(&u->readlock);881881+ if (err)882882+ goto out;883883884884 err = -EINVAL;885885 if (u->addr)
+2
sound/core/pcm_lib.c
···19371937 case SNDRV_PCM_STATE_DISCONNECTED:19381938 err = -EBADFD;19391939 goto _endloop;19401940+ case SNDRV_PCM_STATE_PAUSED:19411941+ continue;19401942 }19411943 if (!tout) {19421944 snd_printd("%s write error (DMA or IRQ trouble?)\n",
···24392439 snd_soc_update_bits(codec, WM8962_CLOCKING_4,24402440 WM8962_SYSCLK_RATE_MASK, clocking4);2441244124422442+ /* DSPCLK_DIV can be only generated correctly after enabling SYSCLK.24432443+ * So we here provisionally enable it and then disable it afterward24442444+ * if current bias_level hasn't reached SND_SOC_BIAS_ON.24452445+ */24462446+ if (codec->dapm.bias_level != SND_SOC_BIAS_ON)24472447+ snd_soc_update_bits(codec, WM8962_CLOCKING2,24482448+ WM8962_SYSCLK_ENA_MASK, WM8962_SYSCLK_ENA);24492449+24422450 dspclk = snd_soc_read(codec, WM8962_CLOCKING1);24512451+24522452+ if (codec->dapm.bias_level != SND_SOC_BIAS_ON)24532453+ snd_soc_update_bits(codec, WM8962_CLOCKING2,24542454+ WM8962_SYSCLK_ENA_MASK, 0);24552455+24432456 if (dspclk < 0) {24442457 dev_err(codec->dev, "Failed to read DSPCLK: %d\n", dspclk);24452458 return;
+7-3
sound/soc/codecs/wm_adsp.c
···14741474 return ret;1475147514761476 /* Wait for the RAM to start, should be near instantaneous */14771477- count = 0;14781478- do {14771477+ for (count = 0; count < 10; ++count) {14791478 ret = regmap_read(dsp->regmap, dsp->base + ADSP2_STATUS1,14801479 &val);14811480 if (ret != 0)14821481 return ret;14831483- } while (!(val & ADSP2_RAM_RDY) && ++count < 10);14821482+14831483+ if (val & ADSP2_RAM_RDY)14841484+ break;14851485+14861486+ msleep(1);14871487+ }1484148814851489 if (!(val & ADSP2_RAM_RDY)) {14861490 adsp_err(dsp, "Failed to start DSP RAM\n");