···462462 struct iov_iter *iter,463463 netfs_io_terminated_t term_func,464464 void *term_func_priv);465465+466466+ int (*query_occupancy)(struct netfs_cache_resources *cres,467467+ loff_t start, size_t len, size_t granularity,468468+ loff_t *_data_start, size_t *_data_len);465469 };466470467471With a termination handler function pointer::···539535 with the number of bytes transferred or an error code, plus a flag540536 indicating whether the termination is definitely happening in the caller's541537 context.538538+539539+ * ``query_occupancy()``540540+541541+ [Required] Called to find out where the next piece of data is within a542542+ particular region of the cache. The start and length of the region to be543543+ queried are passed in, along with the granularity to which the answer needs544544+ to be aligned. The function passes back the start and length of the data,545545+ if any, available within that region. Note that there may be a hole at the546546+ front.547547+548548+ It returns 0 if some data was found, -ENODATA if there was no usable data549549+ within the region or -ENOBUFS if there is no caching on this file.542550543551Note that these methods are passed a pointer to the cache resource structure,544552not the read request structure as they could be used in other situations where
-24
Documentation/gpu/todo.rst
···300300301301Level: Advanced302302303303-Garbage collect fbdev scrolling acceleration304304---------------------------------------------305305-306306-Scroll acceleration has been disabled in fbcon. Now it works as the old307307-SCROLL_REDRAW mode. A ton of code was removed in fbcon.c and the hook bmove was308308-removed from fbcon_ops.309309-Remaining tasks:310310-311311-- a bunch of the hooks in fbcon_ops could be removed or simplified by calling312312- directly instead of the function table (with a switch on p->rotate)313313-314314-- fb_copyarea is unused after this, and can be deleted from all drivers315315-316316-- after that, fb_copyarea can be deleted from fb_ops in include/linux/fb.h as317317- well as cfb_copyarea318318-319319-Note that not all acceleration code can be deleted, since clearing and cursor320320-support is still accelerated, which might be good candidates for further321321-deletion projects.322322-323323-Contact: Daniel Vetter324324-325325-Level: Intermediate326326-327303idr_init_base()328304---------------329305
···1313static int crypto_blake2s_update_arm(struct shash_desc *desc,1414 const u8 *in, unsigned int inlen)1515{1616- return crypto_blake2s_update(desc, in, inlen, blake2s_compress);1616+ return crypto_blake2s_update(desc, in, inlen, false);1717}18181919static int crypto_blake2s_final_arm(struct shash_desc *desc, u8 *out)2020{2121- return crypto_blake2s_final(desc, out, blake2s_compress);2121+ return crypto_blake2s_final(desc, out, false);2222}23232424#define BLAKE2S_ALG(name, driver_name, digest_size) \
+16
arch/arm64/Kconfig
···680680681681 If unsure, say Y.682682683683+config ARM64_ERRATUM_2077057684684+ bool "Cortex-A510: 2077057: workaround software-step corrupting SPSR_EL2"685685+ help686686+ This option adds the workaround for ARM Cortex-A510 erratum 2077057.687687+ Affected Cortex-A510 may corrupt SPSR_EL2 when the a step exception is688688+ expected, but a Pointer Authentication trap is taken instead. The689689+ erratum causes SPSR_EL1 to be copied to SPSR_EL2, which could allow690690+ EL1 to cause a return to EL2 with a guest controlled ELR_EL2.691691+692692+ This can only happen when EL2 is stepping EL1.693693+694694+ When these conditions occur, the SPSR_EL2 value is unchanged from the695695+ previous guest entry, and can be restored from the in-memory copy.696696+697697+ If unsure, say Y.698698+683699config ARM64_ERRATUM_2119858684700 bool "Cortex-A710/X2: 2119858: workaround TRBE overwriting trace data in FILL mode"685701 default y
···797797 xfer_to_guest_mode_work_pending();798798}799799800800+/*801801+ * Actually run the vCPU, entering an RCU extended quiescent state (EQS) while802802+ * the vCPU is running.803803+ *804804+ * This must be noinstr as instrumentation may make use of RCU, and this is not805805+ * safe during the EQS.806806+ */807807+static int noinstr kvm_arm_vcpu_enter_exit(struct kvm_vcpu *vcpu)808808+{809809+ int ret;810810+811811+ guest_state_enter_irqoff();812812+ ret = kvm_call_hyp_ret(__kvm_vcpu_run, vcpu);813813+ guest_state_exit_irqoff();814814+815815+ return ret;816816+}817817+800818/**801819 * kvm_arch_vcpu_ioctl_run - the main VCPU run function to execute guest code802820 * @vcpu: The VCPU pointer···899881 * Enter the guest900882 */901883 trace_kvm_entry(*vcpu_pc(vcpu));902902- guest_enter_irqoff();884884+ guest_timing_enter_irqoff();903885904904- ret = kvm_call_hyp_ret(__kvm_vcpu_run, vcpu);886886+ ret = kvm_arm_vcpu_enter_exit(vcpu);905887906888 vcpu->mode = OUTSIDE_GUEST_MODE;907889 vcpu->stat.exits++;···936918 kvm_arch_vcpu_ctxsync_fp(vcpu);937919938920 /*939939- * We may have taken a host interrupt in HYP mode (ie940940- * while executing the guest). This interrupt is still941941- * pending, as we haven't serviced it yet!921921+ * We must ensure that any pending interrupts are taken before922922+ * we exit guest timing so that timer ticks are accounted as923923+ * guest time. Transiently unmask interrupts so that any924924+ * pending interrupts are taken.942925 *943943- * We're now back in SVC mode, with interrupts944944- * disabled. Enabling the interrupts now will have945945- * the effect of taking the interrupt again, in SVC946946- * mode this time.926926+ * Per ARM DDI 0487G.b section D1.13.4, an ISB (or other927927+ * context synchronization event) is necessary to ensure that928928+ * pending interrupts are taken.947929 */948930 local_irq_enable();931931+ isb();932932+ local_irq_disable();949933950950- /*951951- * We do local_irq_enable() before calling guest_exit() so952952- * that if a timer interrupt hits while running the guest we953953- * account that tick as being spent in the guest. We enable954954- * preemption after calling guest_exit() so that if we get955955- * preempted we make sure ticks after that is not counted as956956- * guest time.957957- */958958- guest_exit();934934+ guest_timing_exit_irqoff();935935+936936+ local_irq_enable();937937+959938 trace_kvm_exit(ret, kvm_vcpu_trap_get_class(vcpu), *vcpu_pc(vcpu));960939961940 /* Exit types that need handling before we can be preempted */
+8
arch/arm64/kvm/handle_exit.c
···228228{229229 struct kvm_run *run = vcpu->run;230230231231+ if (ARM_SERROR_PENDING(exception_index)) {232232+ /*233233+ * The SError is handled by handle_exit_early(). If the guest234234+ * survives it will re-execute the original instruction.235235+ */236236+ return 1;237237+ }238238+231239 exception_index = ARM_EXCEPTION_CODE(exception_index);232240233241 switch (exception_index) {
+21-2
arch/arm64/kvm/hyp/include/hyp/switch.h
···402402 return false;403403}404404405405+static inline void synchronize_vcpu_pstate(struct kvm_vcpu *vcpu, u64 *exit_code)406406+{407407+ /*408408+ * Check for the conditions of Cortex-A510's #2077057. When these occur409409+ * SPSR_EL2 can't be trusted, but isn't needed either as it is410410+ * unchanged from the value in vcpu_gp_regs(vcpu)->pstate.411411+ * Are we single-stepping the guest, and took a PAC exception from the412412+ * active-not-pending state?413413+ */414414+ if (cpus_have_final_cap(ARM64_WORKAROUND_2077057) &&415415+ vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP &&416416+ *vcpu_cpsr(vcpu) & DBG_SPSR_SS &&417417+ ESR_ELx_EC(read_sysreg_el2(SYS_ESR)) == ESR_ELx_EC_PAC)418418+ write_sysreg_el2(*vcpu_cpsr(vcpu), SYS_SPSR);419419+420420+ vcpu->arch.ctxt.regs.pstate = read_sysreg_el2(SYS_SPSR);421421+}422422+405423/*406424 * Return true when we were able to fixup the guest exit and should return to407425 * the guest, false when we should restore the host state and return to the···431413 * Save PSTATE early so that we can evaluate the vcpu mode432414 * early on.433415 */434434- vcpu->arch.ctxt.regs.pstate = read_sysreg_el2(SYS_SPSR);416416+ synchronize_vcpu_pstate(vcpu, exit_code);435417436418 /*437419 * Check whether we want to repaint the state one way or···442424 if (ARM_EXCEPTION_CODE(*exit_code) != ARM_EXCEPTION_IRQ)443425 vcpu->arch.fault.esr_el2 = read_sysreg_el2(SYS_ESR);444426445445- if (ARM_SERROR_PENDING(*exit_code)) {427427+ if (ARM_SERROR_PENDING(*exit_code) &&428428+ ARM_EXCEPTION_CODE(*exit_code) != ARM_EXCEPTION_IRQ) {446429 u8 esr_ec = kvm_vcpu_trap_get_class(vcpu);447430448431 /*
···414414 return -ENOIOCTLCMD;415415}416416417417+/*418418+ * Actually run the vCPU, entering an RCU extended quiescent state (EQS) while419419+ * the vCPU is running.420420+ *421421+ * This must be noinstr as instrumentation may make use of RCU, and this is not422422+ * safe during the EQS.423423+ */424424+static int noinstr kvm_mips_vcpu_enter_exit(struct kvm_vcpu *vcpu)425425+{426426+ int ret;427427+428428+ guest_state_enter_irqoff();429429+ ret = kvm_mips_callbacks->vcpu_run(vcpu);430430+ guest_state_exit_irqoff();431431+432432+ return ret;433433+}434434+417435int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)418436{419437 int r = -EINTR;···452434 lose_fpu(1);453435454436 local_irq_disable();455455- guest_enter_irqoff();437437+ guest_timing_enter_irqoff();456438 trace_kvm_enter(vcpu);457439458440 /*···463445 */464446 smp_store_mb(vcpu->mode, IN_GUEST_MODE);465447466466- r = kvm_mips_callbacks->vcpu_run(vcpu);448448+ r = kvm_mips_vcpu_enter_exit(vcpu);449449+450450+ /*451451+ * We must ensure that any pending interrupts are taken before452452+ * we exit guest timing so that timer ticks are accounted as453453+ * guest time. Transiently unmask interrupts so that any454454+ * pending interrupts are taken.455455+ *456456+ * TODO: is there a barrier which ensures that pending interrupts are457457+ * recognised? Currently this just hopes that the CPU takes any pending458458+ * interrupts between the enable and disable.459459+ */460460+ local_irq_enable();461461+ local_irq_disable();467462468463 trace_kvm_out(vcpu);469469- guest_exit_irqoff();464464+ guest_timing_exit_irqoff();470465 local_irq_enable();471466472467out:···11991168/*12001169 * Return value is in the form (errcode<<2 | RESUME_FLAG_HOST | RESUME_FLAG_NV)12011170 */12021202-int kvm_mips_handle_exit(struct kvm_vcpu *vcpu)11711171+static int __kvm_mips_handle_exit(struct kvm_vcpu *vcpu)12031172{12041173 struct kvm_run *run = vcpu->run;12051174 u32 cause = vcpu->arch.host_cp0_cause;···13851354 read_c0_config5() & MIPS_CONF5_MSAEN)13861355 __kvm_restore_msacsr(&vcpu->arch);13871356 }13571357+ return ret;13581358+}13591359+13601360+int noinstr kvm_mips_handle_exit(struct kvm_vcpu *vcpu)13611361+{13621362+ int ret;13631363+13641364+ guest_state_exit_irqoff();13651365+ ret = __kvm_mips_handle_exit(vcpu);13661366+ guest_state_enter_irqoff();13671367+13881368 return ret;13891369}13901370
+31-17
arch/riscv/kvm/vcpu.c
···9090int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)9191{9292 struct kvm_cpu_context *cntx;9393+ struct kvm_vcpu_csr *reset_csr = &vcpu->arch.guest_reset_csr;93949495 /* Mark this VCPU never ran */9596 vcpu->arch.ran_atleast_once = false;···106105 cntx->hstatus |= HSTATUS_VTW;107106 cntx->hstatus |= HSTATUS_SPVP;108107 cntx->hstatus |= HSTATUS_SPV;108108+109109+ /* By default, make CY, TM, and IR counters accessible in VU mode */110110+ reset_csr->scounteren = 0x7;109111110112 /* Setup VCPU timer */111113 kvm_riscv_vcpu_timer_init(vcpu);···703699 csr_write(CSR_HVIP, csr->hvip);704700}705701702702+/*703703+ * Actually run the vCPU, entering an RCU extended quiescent state (EQS) while704704+ * the vCPU is running.705705+ *706706+ * This must be noinstr as instrumentation may make use of RCU, and this is not707707+ * safe during the EQS.708708+ */709709+static void noinstr kvm_riscv_vcpu_enter_exit(struct kvm_vcpu *vcpu)710710+{711711+ guest_state_enter_irqoff();712712+ __kvm_riscv_switch_to(&vcpu->arch);713713+ guest_state_exit_irqoff();714714+}715715+706716int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)707717{708718 int ret;···808790 continue;809791 }810792811811- guest_enter_irqoff();793793+ guest_timing_enter_irqoff();812794813813- __kvm_riscv_switch_to(&vcpu->arch);795795+ kvm_riscv_vcpu_enter_exit(vcpu);814796815797 vcpu->mode = OUTSIDE_GUEST_MODE;816798 vcpu->stat.exits++;···830812 kvm_riscv_vcpu_sync_interrupts(vcpu);831813832814 /*833833- * We may have taken a host interrupt in VS/VU-mode (i.e.834834- * while executing the guest). This interrupt is still835835- * pending, as we haven't serviced it yet!815815+ * We must ensure that any pending interrupts are taken before816816+ * we exit guest timing so that timer ticks are accounted as817817+ * guest time. Transiently unmask interrupts so that any818818+ * pending interrupts are taken.836819 *837837- * We're now back in HS-mode with interrupts disabled838838- * so enabling the interrupts now will have the effect839839- * of taking the interrupt again, in HS-mode this time.820820+ * There's no barrier which ensures that pending interrupts are821821+ * recognised, so we just hope that the CPU takes any pending822822+ * interrupts between the enable and disable.840823 */841824 local_irq_enable();825825+ local_irq_disable();842826843843- /*844844- * We do local_irq_enable() before calling guest_exit() so845845- * that if a timer interrupt hits while running the guest846846- * we account that tick as being spent in the guest. We847847- * enable preemption after calling guest_exit() so that if848848- * we get preempted we make sure ticks after that is not849849- * counted as guest time.850850- */851851- guest_exit();827827+ guest_timing_exit_irqoff();828828+829829+ local_irq_enable();852830853831 preempt_enable();854832
+2-1
arch/riscv/kvm/vcpu_sbi_base.c
···99#include <linux/errno.h>1010#include <linux/err.h>1111#include <linux/kvm_host.h>1212+#include <linux/version.h>1213#include <asm/csr.h>1314#include <asm/sbi.h>1415#include <asm/kvm_vcpu_timer.h>···3332 *out_val = KVM_SBI_IMPID;3433 break;3534 case SBI_EXT_BASE_GET_IMP_VERSION:3636- *out_val = 0;3535+ *out_val = LINUX_VERSION_CODE;3736 break;3837 case SBI_EXT_BASE_PROBE_EXT:3938 if ((cp->a0 >= SBI_EXT_EXPERIMENTAL_START &&
+2
arch/s390/kvm/kvm-s390.c
···46674667 return -EINVAL;46684668 if (mop->size + mop->sida_offset > sida_size(vcpu->arch.sie_block))46694669 return -E2BIG;46704670+ if (!kvm_s390_pv_cpu_is_protected(vcpu))46714671+ return -EINVAL;4670467246714673 switch (mop->op) {46724674 case KVM_S390_MEMOP_SIDA_READ:
+2-2
arch/x86/crypto/blake2s-shash.c
···1818static int crypto_blake2s_update_x86(struct shash_desc *desc,1919 const u8 *in, unsigned int inlen)2020{2121- return crypto_blake2s_update(desc, in, inlen, blake2s_compress);2121+ return crypto_blake2s_update(desc, in, inlen, false);2222}23232424static int crypto_blake2s_final_x86(struct shash_desc *desc, u8 *out)2525{2626- return crypto_blake2s_final(desc, out, blake2s_compress);2626+ return crypto_blake2s_final(desc, out, false);2727}28282929#define BLAKE2S_ALG(name, driver_name, digest_size) \
+13
arch/x86/events/intel/core.c
···47034703 .lbr_read = intel_pmu_lbr_read_64,47044704 .lbr_save = intel_pmu_lbr_save,47054705 .lbr_restore = intel_pmu_lbr_restore,47064706+47074707+ /*47084708+ * SMM has access to all 4 rings and while traditionally SMM code only47094709+ * ran in CPL0, 2021-era firmware is starting to make use of CPL3 in SMM.47104710+ *47114711+ * Since the EVENTSEL.{USR,OS} CPL filtering makes no distinction47124712+ * between SMM or not, this results in what should be pure userspace47134713+ * counters including SMM data.47144714+ *47154715+ * This is a clear privilege issue, therefore globally disable47164716+ * counting SMM by default.47174717+ */47184718+ .attr_freeze_on_smi = 1,47064719};4707472047084721static __init void intel_clovertown_quirk(void)
+3-2
arch/x86/events/intel/pt.c
···897897 * means we are already losing data; need to let the decoder898898 * know.899899 */900900- if (!intel_pt_validate_hw_cap(PT_CAP_topa_multiple_entries) ||901901- buf->output_off == pt_buffer_region_size(buf)) {900900+ if (!buf->single &&901901+ (!intel_pt_validate_hw_cap(PT_CAP_topa_multiple_entries) ||902902+ buf->output_off == pt_buffer_region_size(buf))) {902903 perf_aux_output_flag(&pt->handle,903904 PERF_AUX_FLAG_TRUNCATED);904905 advance++;
···40414041 return 0;40424042}4043404340444044+static void vmx_deliver_interrupt(struct kvm_lapic *apic, int delivery_mode,40454045+ int trig_mode, int vector)40464046+{40474047+ struct kvm_vcpu *vcpu = apic->vcpu;40484048+40494049+ if (vmx_deliver_posted_interrupt(vcpu, vector)) {40504050+ kvm_lapic_set_irr(vector, apic);40514051+ kvm_make_request(KVM_REQ_EVENT, vcpu);40524052+ kvm_vcpu_kick(vcpu);40534053+ } else {40544054+ trace_kvm_apicv_accept_irq(vcpu->vcpu_id, delivery_mode,40554055+ trig_mode, vector);40564056+ }40574057+}40584058+40444059/*40454060 * Set up the vmcs's constant host-state fields, i.e., host-state fields that40464061 * will not change in the lifetime of the guest.···67696754static noinstr void vmx_vcpu_enter_exit(struct kvm_vcpu *vcpu,67706755 struct vcpu_vmx *vmx)67716756{67726772- kvm_guest_enter_irqoff();67576757+ guest_state_enter_irqoff();6773675867746759 /* L1D Flush includes CPU buffer clear to mitigate MDS */67756760 if (static_branch_unlikely(&vmx_l1d_should_flush))···6785677067866771 vcpu->arch.cr2 = native_read_cr2();6787677267886788- kvm_guest_exit_irqoff();67736773+ guest_state_exit_irqoff();67896774}6790677567916776static fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu)···77837768 .hwapic_isr_update = vmx_hwapic_isr_update,77847769 .guest_apic_has_interrupt = vmx_guest_apic_has_interrupt,77857770 .sync_pir_to_irr = vmx_sync_pir_to_irr,77867786- .deliver_posted_interrupt = vmx_deliver_posted_interrupt,77717771+ .deliver_interrupt = vmx_deliver_interrupt,77877772 .dy_apicv_has_pending_interrupt = pi_has_pending_interrupt,7788777377897774 .set_tss_addr = vmx_set_tss_addr,
+6-4
arch/x86/kvm/x86.c
···9090u64 __read_mostly kvm_mce_cap_supported = MCG_CTL_P | MCG_SER_P;9191EXPORT_SYMBOL_GPL(kvm_mce_cap_supported);92929393+#define ERR_PTR_USR(e) ((void __user *)ERR_PTR(e))9494+9395#define emul_to_vcpu(ctxt) \9496 ((struct kvm_vcpu *)(ctxt)->vcpu)9597···43424340 void __user *uaddr = (void __user*)(unsigned long)attr->addr;4343434143444342 if ((u64)(unsigned long)uaddr != attr->addr)43454345- return ERR_PTR(-EFAULT);43434343+ return ERR_PTR_USR(-EFAULT);43464344 return uaddr;43474345}43484346···1004310041 set_debugreg(0, 7);1004410042 }10045100431004410044+ guest_timing_enter_irqoff();1004510045+1004610046 for (;;) {1004710047 /*1004810048 * Assert that vCPU vs. VM APICv state is consistent. An APICv···1012910125 * of accounting via context tracking, but the loss of accuracy is1013010126 * acceptable for all known use cases.1013110127 */1013210132- vtime_account_guest_exit();1012810128+ guest_timing_exit_irqoff();10133101291013410130 if (lapic_in_kernel(vcpu)) {1013510131 s64 delta = vcpu->arch.apic->lapic_timer.advance_expire_delta;···1164211638 cancel_delayed_work_sync(&kvm->arch.kvmclock_update_work);1164311639 kvm_free_pit(kvm);1164411640}1164511645-1164611646-#define ERR_PTR_USR(e) ((void __user *)ERR_PTR(e))11647116411164811642/**1164911643 * __x86_set_memory_region: Setup KVM internal memory slot
-45
arch/x86/kvm/x86.h
···10101111void kvm_spurious_fault(void);12121313-static __always_inline void kvm_guest_enter_irqoff(void)1414-{1515- /*1616- * VMENTER enables interrupts (host state), but the kernel state is1717- * interrupts disabled when this is invoked. Also tell RCU about1818- * it. This is the same logic as for exit_to_user_mode().1919- *2020- * This ensures that e.g. latency analysis on the host observes2121- * guest mode as interrupt enabled.2222- *2323- * guest_enter_irqoff() informs context tracking about the2424- * transition to guest mode and if enabled adjusts RCU state2525- * accordingly.2626- */2727- instrumentation_begin();2828- trace_hardirqs_on_prepare();2929- lockdep_hardirqs_on_prepare(CALLER_ADDR0);3030- instrumentation_end();3131-3232- guest_enter_irqoff();3333- lockdep_hardirqs_on(CALLER_ADDR0);3434-}3535-3636-static __always_inline void kvm_guest_exit_irqoff(void)3737-{3838- /*3939- * VMEXIT disables interrupts (host state), but tracing and lockdep4040- * have them in state 'on' as recorded before entering guest mode.4141- * Same as enter_from_user_mode().4242- *4343- * context_tracking_guest_exit() restores host context and reinstates4444- * RCU if enabled and required.4545- *4646- * This needs to be done immediately after VM-Exit, before any code4747- * that might contain tracepoints or call out to the greater world,4848- * e.g. before x86_spec_ctrl_restore_host().4949- */5050- lockdep_hardirqs_off(CALLER_ADDR0);5151- context_tracking_guest_exit();5252-5353- instrumentation_begin();5454- trace_hardirqs_off_finish();5555- instrumentation_end();5656-}5757-5813#define KVM_NESTED_VMENTER_CONSISTENCY_CHECK(consistency_check) \5914({ \6015 bool failed = (consistency_check); \
···148148 return rc;149149}150150151151-static void __init xen_fill_possible_map(void)152152-{153153- int i, rc;154154-155155- if (xen_initial_domain())156156- return;157157-158158- for (i = 0; i < nr_cpu_ids; i++) {159159- rc = HYPERVISOR_vcpu_op(VCPUOP_is_up, i, NULL);160160- if (rc >= 0) {161161- num_processors++;162162- set_cpu_possible(i, true);163163- }164164- }165165-}166166-167167-static void __init xen_filter_cpu_maps(void)151151+static void __init _get_smp_config(unsigned int early)168152{169153 int i, rc;170154 unsigned int subtract = 0;171155172172- if (!xen_initial_domain())156156+ if (early)173157 return;174158175159 num_processors = 0;···194210 * sure the old memory can be recycled. */195211 make_lowmem_page_readwrite(xen_initial_gdt);196212197197- xen_filter_cpu_maps();198213 xen_setup_vcpu_info_placement();199214200215 /*···459476void __init xen_smp_init(void)460477{461478 smp_ops = xen_smp_ops;462462- xen_fill_possible_map();479479+480480+ /* Avoid searching for BIOS MP tables */481481+ x86_init.mpparse.find_smp_config = x86_init_noop;482482+ x86_init.mpparse.get_smp_config = _get_smp_config;463483}
···1515static int crypto_blake2s_update_generic(struct shash_desc *desc,1616 const u8 *in, unsigned int inlen)1717{1818- return crypto_blake2s_update(desc, in, inlen, blake2s_compress_generic);1818+ return crypto_blake2s_update(desc, in, inlen, true);1919}20202121static int crypto_blake2s_final_generic(struct shash_desc *desc, u8 *out)2222{2323- return crypto_blake2s_final(desc, out, blake2s_compress_generic);2323+ return crypto_blake2s_final(desc, out, true);2424}25252626#define BLAKE2S_ALG(name, driver_name, digest_size) \
+1
drivers/acpi/Kconfig
···1111 depends on ARCH_SUPPORTS_ACPI1212 select PNP1313 select NLS1414+ select CRC321415 default y if X861516 help1617 Advanced Configuration and Power Interface (ACPI) support for
+16-8
drivers/ata/libata-core.c
···20072007{20082008 struct ata_port *ap = dev->link->ap;2009200920102010+ if (dev->horkage & ATA_HORKAGE_NO_LOG_DIR)20112011+ return false;20122012+20102013 if (ata_read_log_page(dev, ATA_LOG_DIRECTORY, 0, ap->sector_buf, 1))20112014 return false;20122015 return get_unaligned_le16(&ap->sector_buf[log * 2]) ? true : false;···24482445 struct ata_cpr_log *cpr_log = NULL;24492446 u8 *desc, *buf = NULL;2450244724512451- if (!ata_identify_page_supported(dev,24522452- ATA_LOG_CONCURRENT_POSITIONING_RANGES))24482448+ if (ata_id_major_version(dev->id) < 11 ||24492449+ !ata_log_supported(dev, ATA_LOG_CONCURRENT_POSITIONING_RANGES))24532450 goto out;2454245124552452 /*24562456- * Read IDENTIFY DEVICE data log, page 0x4724572457- * (concurrent positioning ranges). We can have at most 255 32B range24582458- * descriptors plus a 64B header.24532453+ * Read the concurrent positioning ranges log (0x47). We can have at24542454+ * most 255 32B range descriptors plus a 64B header.24592455 */24602456 buf_len = (64 + 255 * 32 + 511) & ~511;24612457 buf = kzalloc(buf_len, GFP_KERNEL);24622458 if (!buf)24632459 goto out;2464246024652465- err_mask = ata_read_log_page(dev, ATA_LOG_IDENTIFY_DEVICE,24662466- ATA_LOG_CONCURRENT_POSITIONING_RANGES,24672467- buf, buf_len >> 9);24612461+ err_mask = ata_read_log_page(dev, ATA_LOG_CONCURRENT_POSITIONING_RANGES,24622462+ 0, buf, buf_len >> 9);24682463 if (err_mask)24692464 goto out;24702465···40734072 { "WDC WD2500JD-*", NULL, ATA_HORKAGE_WD_BROKEN_LPM },40744073 { "WDC WD3000JD-*", NULL, ATA_HORKAGE_WD_BROKEN_LPM },40754074 { "WDC WD3200JD-*", NULL, ATA_HORKAGE_WD_BROKEN_LPM },40754075+40764076+ /*40774077+ * This sata dom device goes on a walkabout when the ATA_LOG_DIRECTORY40784078+ * log page is accessed. Ensure we never ask for this log page with40794079+ * these devices.40804080+ */40814081+ { "SATADOM-ML 3ME", NULL, ATA_HORKAGE_NO_LOG_DIR },4076408240774083 /* End Marker */40784084 { }
+22-17
drivers/char/random.c
···762762 return arch_init;763763}764764765765-static bool __init crng_init_try_arch_early(struct crng_state *crng)765765+static bool __init crng_init_try_arch_early(void)766766{767767 int i;768768 bool arch_init = true;···774774 rv = random_get_entropy();775775 arch_init = false;776776 }777777- crng->state[i] ^= rv;777777+ primary_crng.state[i] ^= rv;778778 }779779780780 return arch_init;···788788 crng->init_time = jiffies - CRNG_RESEED_INTERVAL - 1;789789}790790791791-static void __init crng_initialize_primary(struct crng_state *crng)791791+static void __init crng_initialize_primary(void)792792{793793- _extract_entropy(&crng->state[4], sizeof(u32) * 12);794794- if (crng_init_try_arch_early(crng) && trust_cpu && crng_init < 2) {793793+ _extract_entropy(&primary_crng.state[4], sizeof(u32) * 12);794794+ if (crng_init_try_arch_early() && trust_cpu && crng_init < 2) {795795 invalidate_batched_entropy();796796 numa_crng_init();797797 crng_init = 2;798798 pr_notice("crng init done (trusting CPU's manufacturer)\n");799799 }800800- crng->init_time = jiffies - CRNG_RESEED_INTERVAL - 1;800800+ primary_crng.init_time = jiffies - CRNG_RESEED_INTERVAL - 1;801801}802802803803-static void crng_finalize_init(struct crng_state *crng)803803+static void crng_finalize_init(void)804804{805805- if (crng != &primary_crng || crng_init >= 2)806806- return;807805 if (!system_wq) {808806 /* We can't call numa_crng_init until we have workqueues,809807 * so mark this for processing later. */···812814 invalidate_batched_entropy();813815 numa_crng_init();814816 crng_init = 2;817817+ crng_need_final_init = false;815818 process_random_ready_list();816819 wake_up_interruptible(&crng_init_wait);817820 kill_fasync(&fasync, SIGIO, POLL_IN);···979980 memzero_explicit(&buf, sizeof(buf));980981 WRITE_ONCE(crng->init_time, jiffies);981982 spin_unlock_irqrestore(&crng->lock, flags);982982- crng_finalize_init(crng);983983+ if (crng == &primary_crng && crng_init < 2)984984+ crng_finalize_init();983985}984986985987static void _extract_crng(struct crng_state *crng, u8 out[CHACHA_BLOCK_SIZE])···16971697{16981698 init_std_data();16991699 if (crng_need_final_init)17001700- crng_finalize_init(&primary_crng);17011701- crng_initialize_primary(&primary_crng);17001700+ crng_finalize_init();17011701+ crng_initialize_primary();17021702 crng_global_init_time = jiffies;17031703 if (ratelimit_disable) {17041704 urandom_warning.interval = 0;···18561856 */18571857 if (!capable(CAP_SYS_ADMIN))18581858 return -EPERM;18591859- input_pool.entropy_count = 0;18591859+ if (xchg(&input_pool.entropy_count, 0) && random_write_wakeup_bits) {18601860+ wake_up_interruptible(&random_write_wait);18611861+ kill_fasync(&fasync, SIGIO, POLL_OUT);18621862+ }18601863 return 0;18611864 case RNDRESEEDCRNG:18621865 if (!capable(CAP_SYS_ADMIN))···22082205 return;22092206 }2210220722112211- /* Suspend writing if we're above the trickle threshold.22082208+ /* Throttle writing if we're above the trickle threshold.22122209 * We'll be woken up again once below random_write_wakeup_thresh,22132213- * or when the calling thread is about to terminate.22102210+ * when the calling thread is about to terminate, or once22112211+ * CRNG_RESEED_INTERVAL has lapsed.22142212 */22152215- wait_event_interruptible(random_write_wait,22132213+ wait_event_interruptible_timeout(random_write_wait,22162214 !system_wq || kthread_should_stop() ||22172217- POOL_ENTROPY_BITS() <= random_write_wakeup_bits);22152215+ POOL_ENTROPY_BITS() <= random_write_wakeup_bits,22162216+ CRNG_RESEED_INTERVAL);22182217 mix_pool_bytes(buffer, count);22192218 credit_entropy_bits(entropy);22202219}
···10311031 }10321032}1033103310341034+#if IS_ENABLED(CONFIG_SUSPEND)10351035+/**10361036+ * amdgpu_acpi_is_s3_active10371037+ *10381038+ * @adev: amdgpu_device_pointer10391039+ *10401040+ * returns true if supported, false if not.10411041+ */10421042+bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev)10431043+{10441044+ return !(adev->flags & AMD_IS_APU) ||10451045+ (pm_suspend_target_state == PM_SUSPEND_MEM);10461046+}10471047+10341048/**10351049 * amdgpu_acpi_is_s0ix_active10361050 *···10541040 */10551041bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev)10561042{10571057-#if IS_ENABLED(CONFIG_AMD_PMC) && IS_ENABLED(CONFIG_SUSPEND)10581058- if (acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0) {10591059- if (adev->flags & AMD_IS_APU)10601060- return pm_suspend_target_state == PM_SUSPEND_TO_IDLE;10431043+ if (!(adev->flags & AMD_IS_APU) ||10441044+ (pm_suspend_target_state != PM_SUSPEND_TO_IDLE))10451045+ return false;10461046+10471047+ if (!(acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0)) {10481048+ dev_warn_once(adev->dev,10491049+ "Power consumption will be higher as BIOS has not been configured for suspend-to-idle.\n"10501050+ "To use suspend-to-idle change the sleep mode in BIOS setup.\n");10511051+ return false;10611052 }10621062-#endif10531053+10541054+#if !IS_ENABLED(CONFIG_AMD_PMC)10551055+ dev_warn_once(adev->dev,10561056+ "Power consumption will be higher as the kernel has not been compiled with CONFIG_AMD_PMC.\n");10631057 return false;10581058+#else10591059+ return true;10601060+#endif /* CONFIG_AMD_PMC */10641061}10621062+10631063+#endif /* CONFIG_SUSPEND */
+9-2
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
···22462246static int amdgpu_pmops_prepare(struct device *dev)22472247{22482248 struct drm_device *drm_dev = dev_get_drvdata(dev);22492249+ struct amdgpu_device *adev = drm_to_adev(drm_dev);2249225022502251 /* Return a positive number here so22512252 * DPM_FLAG_SMART_SUSPEND works properly22522253 */22532254 if (amdgpu_device_supports_boco(drm_dev))22542254- return pm_runtime_suspended(dev) &&22552255- pm_suspend_via_firmware();22552255+ return pm_runtime_suspended(dev);22562256+22572257+ /* if we will not support s3 or s2i for the device22582258+ * then skip suspend22592259+ */22602260+ if (!amdgpu_acpi_is_s0ix_active(adev) &&22612261+ !amdgpu_acpi_is_s3_active(adev))22622262+ return 1;2256226322572264 return 0;22582265}
+1-1
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
···19041904 unsigned i;19051905 int r;1906190619071907- if (direct_submit && !ring->sched.ready) {19071907+ if (!direct_submit && !ring->sched.ready) {19081908 DRM_ERROR("Trying to move memory with ring turned off.\n");19091909 return -EINVAL;19101910 }
···3696369636973697static int sienna_cichlid_enable_mgpu_fan_boost(struct smu_context *smu)36983698{36993699- struct smu_table_context *table_context = &smu->smu_table;37003700- PPTable_t *smc_pptable = table_context->driver_pptable;36993699+ uint16_t *mgpu_fan_boost_limit_rpm;3701370037013701+ GET_PPTABLE_MEMBER(MGpuFanBoostLimitRpm, &mgpu_fan_boost_limit_rpm);37023702 /*37033703 * Skip the MGpuFanBoost setting for those ASICs37043704 * which do not support it37053705 */37063706- if (!smc_pptable->MGpuFanBoostLimitRpm)37063706+ if (*mgpu_fan_boost_limit_rpm == 0)37073707 return 0;3708370837093709 return smu_cmn_send_smc_msg_with_param(smu,
···345345static bool adl_tc_phy_status_complete(struct intel_digital_port *dig_port)346346{347347 struct drm_i915_private *i915 = to_i915(dig_port->base.base.dev);348348+ enum tc_port tc_port = intel_port_to_tc(i915, dig_port->base.port);348349 struct intel_uncore *uncore = &i915->uncore;349350 u32 val;350351351351- val = intel_uncore_read(uncore, TCSS_DDI_STATUS(dig_port->tc_phy_fia_idx));352352+ val = intel_uncore_read(uncore, TCSS_DDI_STATUS(tc_port));352353 if (val == 0xffffffff) {353354 drm_dbg_kms(&i915->drm,354355 "Port %s: PHY in TCCOLD, assuming not complete\n",
+7-2
drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
···25052505 timeout) < 0) {25062506 i915_request_put(rq);2507250725082508- tl = intel_context_timeline_lock(ce);25082508+ /*25092509+ * Error path, cannot use intel_context_timeline_lock as25102510+ * that is user interruptable and this clean up step25112511+ * must be done.25122512+ */25132513+ mutex_lock(&ce->timeline->mutex);25092514 intel_context_exit(ce);25102510- intel_context_timeline_unlock(tl);25152515+ mutex_unlock(&ce->timeline->mutex);2511251625122517 if (nonblock)25132518 return -EWOULDBLOCK;
+5
drivers/gpu/drm/i915/gt/uc/intel_guc.h
···206206 * context usage for overflows.207207 */208208 struct delayed_work work;209209+210210+ /**211211+ * @shift: Right shift value for the gpm timestamp212212+ */213213+ u32 shift;209214 } timestamp;210215211216#ifdef CONFIG_DRM_I915_SELFTEST
+97-17
drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
···11131113 if (new_start == lower_32_bits(*prev_start))11141114 return;1115111511161116+ /*11171117+ * When gt is unparked, we update the gt timestamp and start the ping11181118+ * worker that updates the gt_stamp every POLL_TIME_CLKS. As long as gt11191119+ * is unparked, all switched in contexts will have a start time that is11201120+ * within +/- POLL_TIME_CLKS of the most recent gt_stamp.11211121+ *11221122+ * If neither gt_stamp nor new_start has rolled over, then the11231123+ * gt_stamp_hi does not need to be adjusted, however if one of them has11241124+ * rolled over, we need to adjust gt_stamp_hi accordingly.11251125+ *11261126+ * The below conditions address the cases of new_start rollover and11271127+ * gt_stamp_last rollover respectively.11281128+ */11161129 if (new_start < gt_stamp_last &&11171130 (new_start - gt_stamp_last) <= POLL_TIME_CLKS)11181131 gt_stamp_hi++;···11371124 *prev_start = ((u64)gt_stamp_hi << 32) | new_start;11381125}1139112611401140-static void guc_update_engine_gt_clks(struct intel_engine_cs *engine)11271127+/*11281128+ * GuC updates shared memory and KMD reads it. Since this is not synchronized,11291129+ * we run into a race where the value read is inconsistent. Sometimes the11301130+ * inconsistency is in reading the upper MSB bytes of the last_in value when11311131+ * this race occurs. 2 types of cases are seen - upper 8 bits are zero and upper11321132+ * 24 bits are zero. Since these are non-zero values, it is non-trivial to11331133+ * determine validity of these values. Instead we read the values multiple times11341134+ * until they are consistent. In test runs, 3 attempts results in consistent11351135+ * values. The upper bound is set to 6 attempts and may need to be tuned as per11361136+ * any new occurences.11371137+ */11381138+static void __get_engine_usage_record(struct intel_engine_cs *engine,11391139+ u32 *last_in, u32 *id, u32 *total)11411140{11421141 struct guc_engine_usage_record *rec = intel_guc_engine_usage(engine);11421142+ int i = 0;11431143+11441144+ do {11451145+ *last_in = READ_ONCE(rec->last_switch_in_stamp);11461146+ *id = READ_ONCE(rec->current_context_index);11471147+ *total = READ_ONCE(rec->total_runtime);11481148+11491149+ if (READ_ONCE(rec->last_switch_in_stamp) == *last_in &&11501150+ READ_ONCE(rec->current_context_index) == *id &&11511151+ READ_ONCE(rec->total_runtime) == *total)11521152+ break;11531153+ } while (++i < 6);11541154+}11551155+11561156+static void guc_update_engine_gt_clks(struct intel_engine_cs *engine)11571157+{11431158 struct intel_engine_guc_stats *stats = &engine->stats.guc;11441159 struct intel_guc *guc = &engine->gt->uc.guc;11451145- u32 last_switch = rec->last_switch_in_stamp;11461146- u32 ctx_id = rec->current_context_index;11471147- u32 total = rec->total_runtime;11601160+ u32 last_switch, ctx_id, total;1148116111491162 lockdep_assert_held(&guc->timestamp.lock);11631163+11641164+ __get_engine_usage_record(engine, &last_switch, &ctx_id, &total);1150116511511166 stats->running = ctx_id != ~0U && last_switch;11521167 if (stats->running)···11901149 }11911150}1192115111931193-static void guc_update_pm_timestamp(struct intel_guc *guc,11941194- struct intel_engine_cs *engine,11951195- ktime_t *now)11521152+static u32 gpm_timestamp_shift(struct intel_gt *gt)11961153{11971197- u32 gt_stamp_now, gt_stamp_hi;11541154+ intel_wakeref_t wakeref;11551155+ u32 reg, shift;11561156+11571157+ with_intel_runtime_pm(gt->uncore->rpm, wakeref)11581158+ reg = intel_uncore_read(gt->uncore, RPM_CONFIG0);11591159+11601160+ shift = (reg & GEN10_RPM_CONFIG0_CTC_SHIFT_PARAMETER_MASK) >>11611161+ GEN10_RPM_CONFIG0_CTC_SHIFT_PARAMETER_SHIFT;11621162+11631163+ return 3 - shift;11641164+}11651165+11661166+static u64 gpm_timestamp(struct intel_gt *gt)11671167+{11681168+ u32 lo, hi, old_hi, loop = 0;11691169+11701170+ hi = intel_uncore_read(gt->uncore, MISC_STATUS1);11711171+ do {11721172+ lo = intel_uncore_read(gt->uncore, MISC_STATUS0);11731173+ old_hi = hi;11741174+ hi = intel_uncore_read(gt->uncore, MISC_STATUS1);11751175+ } while (old_hi != hi && loop++ < 2);11761176+11771177+ return ((u64)hi << 32) | lo;11781178+}11791179+11801180+static void guc_update_pm_timestamp(struct intel_guc *guc, ktime_t *now)11811181+{11821182+ struct intel_gt *gt = guc_to_gt(guc);11831183+ u32 gt_stamp_lo, gt_stamp_hi;11841184+ u64 gpm_ts;1198118511991186 lockdep_assert_held(&guc->timestamp.lock);1200118712011188 gt_stamp_hi = upper_32_bits(guc->timestamp.gt_stamp);12021202- gt_stamp_now = intel_uncore_read(engine->uncore,12031203- RING_TIMESTAMP(engine->mmio_base));11891189+ gpm_ts = gpm_timestamp(gt) >> guc->timestamp.shift;11901190+ gt_stamp_lo = lower_32_bits(gpm_ts);12041191 *now = ktime_get();1205119212061206- if (gt_stamp_now < lower_32_bits(guc->timestamp.gt_stamp))11931193+ if (gt_stamp_lo < lower_32_bits(guc->timestamp.gt_stamp))12071194 gt_stamp_hi++;1208119512091209- guc->timestamp.gt_stamp = ((u64)gt_stamp_hi << 32) | gt_stamp_now;11961196+ guc->timestamp.gt_stamp = ((u64)gt_stamp_hi << 32) | gt_stamp_lo;12101197}1211119812121199/*···12771208 if (!in_reset && intel_gt_pm_get_if_awake(gt)) {12781209 stats_saved = *stats;12791210 gt_stamp_saved = guc->timestamp.gt_stamp;12111211+ /*12121212+ * Update gt_clks, then gt timestamp to simplify the 'gt_stamp -12131213+ * start_gt_clk' calculation below for active engines.12141214+ */12801215 guc_update_engine_gt_clks(engine);12811281- guc_update_pm_timestamp(guc, engine, now);12161216+ guc_update_pm_timestamp(guc, now);12821217 intel_gt_pm_put_async(gt);12831218 if (i915_reset_count(gpu_error) != reset_count) {12841219 *stats = stats_saved;···1314124113151242 spin_lock_irqsave(&guc->timestamp.lock, flags);1316124312441244+ guc_update_pm_timestamp(guc, &unused);13171245 for_each_engine(engine, gt, id) {13181318- guc_update_pm_timestamp(guc, engine, &unused);13191246 guc_update_engine_gt_clks(engine);13201247 engine->stats.guc.prev_total = 0;13211248 }···13321259 ktime_t unused;1333126013341261 spin_lock_irqsave(&guc->timestamp.lock, flags);13351335- for_each_engine(engine, gt, id) {13361336- guc_update_pm_timestamp(guc, engine, &unused);12621262+12631263+ guc_update_pm_timestamp(guc, &unused);12641264+ for_each_engine(engine, gt, id)13371265 guc_update_engine_gt_clks(engine);13381338- }12661266+13391267 spin_unlock_irqrestore(&guc->timestamp.lock, flags);13401268}13411269···14091335void intel_guc_busyness_unpark(struct intel_gt *gt)14101336{14111337 struct intel_guc *guc = >->uc.guc;13381338+ unsigned long flags;13391339+ ktime_t unused;1412134014131341 if (!guc_submission_initialized(guc))14141342 return;1415134313441344+ spin_lock_irqsave(&guc->timestamp.lock, flags);13451345+ guc_update_pm_timestamp(guc, &unused);13461346+ spin_unlock_irqrestore(&guc->timestamp.lock, flags);14161347 mod_delayed_work(system_highpri_wq, &guc->timestamp.work,14171348 guc->timestamp.ping_delay);14181349}···18621783 spin_lock_init(&guc->timestamp.lock);18631784 INIT_DELAYED_WORK(&guc->timestamp.work, guc_timestamp_ping);18641785 guc->timestamp.ping_delay = (POLL_TIME_CLKS / gt->clock_frequency + 1) * HZ;17861786+ guc->timestamp.shift = gpm_timestamp_shift(gt);1865178718661788 return 0;18671789}
+1-1
drivers/gpu/drm/i915/i915_gpu_error.c
···15221522 struct i915_request *rq = NULL;15231523 unsigned long flags;1524152415251525- ee = intel_engine_coredump_alloc(engine, GFP_KERNEL);15251525+ ee = intel_engine_coredump_alloc(engine, ALLOW_FAIL);15261526 if (!ee)15271527 return NULL;15281528
···158158 case LAYER_1:159159 kmb->plane_status[plane_id].ctrl = LCD_CTRL_VL2_ENABLE;160160 break;161161- case LAYER_2:162162- kmb->plane_status[plane_id].ctrl = LCD_CTRL_GL1_ENABLE;163163- break;164164- case LAYER_3:165165- kmb->plane_status[plane_id].ctrl = LCD_CTRL_GL2_ENABLE;166166- break;167161 }168162169163 kmb->plane_status[plane_id].disable = true;
+5-1
drivers/gpu/drm/mxsfb/mxsfb_kms.c
···361361 bridge_state =362362 drm_atomic_get_new_bridge_state(state,363363 mxsfb->bridge);364364- bus_format = bridge_state->input_bus_cfg.format;364364+ if (!bridge_state)365365+ bus_format = MEDIA_BUS_FMT_FIXED;366366+ else367367+ bus_format = bridge_state->input_bus_cfg.format;368368+365369 if (bus_format == MEDIA_BUS_FMT_FIXED) {366370 dev_warn_once(drm->dev,367371 "Bridge does not provide bus format, assuming MEDIA_BUS_FMT_RGB888_1X24.\n"
···2121#include <linux/export.h>2222#include <linux/kmemleak.h>2323#include <linux/cc_platform.h>2424+#include <linux/iopoll.h>2425#include <asm/pci-direct.h>2526#include <asm/iommu.h>2627#include <asm/apic.h>···835834 status = readl(iommu->mmio_base + MMIO_STATUS_OFFSET);836835 if (status & (MMIO_STATUS_GALOG_RUN_MASK))837836 break;837837+ udelay(10);838838 }839839840840 if (WARN_ON(i >= LOOP_TIMEOUT))
+10-3
drivers/iommu/intel/irq_remapping.c
···569569 fn, &intel_ir_domain_ops,570570 iommu);571571 if (!iommu->ir_domain) {572572- irq_domain_free_fwnode(fn);573572 pr_err("IR%d: failed to allocate irqdomain\n", iommu->seq_id);574574- goto out_free_bitmap;573573+ goto out_free_fwnode;575574 }576575 iommu->ir_msi_domain =577576 arch_create_remap_msi_irq_domain(iommu->ir_domain,···594595595596 if (dmar_enable_qi(iommu)) {596597 pr_err("Failed to enable queued invalidation\n");597597- goto out_free_bitmap;598598+ goto out_free_ir_domain;598599 }599600 }600601···618619619620 return 0;620621622622+out_free_ir_domain:623623+ if (iommu->ir_msi_domain)624624+ irq_domain_remove(iommu->ir_msi_domain);625625+ iommu->ir_msi_domain = NULL;626626+ irq_domain_remove(iommu->ir_domain);627627+ iommu->ir_domain = NULL;628628+out_free_fwnode:629629+ irq_domain_free_fwnode(fn);621630out_free_bitmap:622631 bitmap_free(bitmap);623632out_free_pages:
+1
drivers/iommu/ioasid.c
···349349350350/**351351 * ioasid_get - obtain a reference to the IOASID352352+ * @ioasid: the ID to get352353 */353354void ioasid_get(ioasid_t ioasid)354355{
+19-14
drivers/iommu/iommu.c
···207207208208static void dev_iommu_free(struct device *dev)209209{210210- iommu_fwspec_free(dev);211211- kfree(dev->iommu);210210+ struct dev_iommu *param = dev->iommu;211211+212212 dev->iommu = NULL;213213+ if (param->fwspec) {214214+ fwnode_handle_put(param->fwspec->iommu_fwnode);215215+ kfree(param->fwspec);216216+ }217217+ kfree(param);213218}214219215220static int __iommu_probe_device(struct device *dev, struct list_head *group_list)···985980 return ret;986981}987982988988-/**989989- * iommu_group_for_each_dev - iterate over each device in the group990990- * @group: the group991991- * @data: caller opaque data to be passed to callback function992992- * @fn: caller supplied callback function993993- *994994- * This function is called by group users to iterate over group devices.995995- * Callers should hold a reference count to the group during callback.996996- * The group->mutex is held across callbacks, which will block calls to997997- * iommu_group_add/remove_device.998998- */999983static int __iommu_group_for_each_dev(struct iommu_group *group, void *data,1000984 int (*fn)(struct device *, void *))1001985{···9991005 return ret;10001006}1001100710021002-10081008+/**10091009+ * iommu_group_for_each_dev - iterate over each device in the group10101010+ * @group: the group10111011+ * @data: caller opaque data to be passed to callback function10121012+ * @fn: caller supplied callback function10131013+ *10141014+ * This function is called by group users to iterate over group devices.10151015+ * Callers should hold a reference count to the group during callback.10161016+ * The group->mutex is held across callbacks, which will block calls to10171017+ * iommu_group_add/remove_device.10181018+ */10031019int iommu_group_for_each_dev(struct iommu_group *group, void *data,10041020 int (*fn)(struct device *, void *))10051021{···30363032 * iommu_sva_bind_device() - Bind a process address space to a device30373033 * @dev: the device30383034 * @mm: the mm to bind, caller must hold a reference to it30353035+ * @drvdata: opaque data pointer to pass to bind callback30393036 *30403037 * Create a bond between device and address space, allowing the device to access30413038 * the mm using the returned PASID. If a bond already exists between @device and
+1-1
drivers/iommu/omap-iommu.c
···10851085}1086108610871087/**10881088- * omap_iommu_suspend_prepare - prepare() dev_pm_ops implementation10881088+ * omap_iommu_prepare - prepare() dev_pm_ops implementation10891089 * @dev: iommu device10901090 *10911091 * This function performs the necessary checks to determine if the IOMMU
+4-4
drivers/md/md.c
···58695869 nowait = nowait && blk_queue_nowait(bdev_get_queue(rdev->bdev));58705870 }5871587158725872- /* Set the NOWAIT flags if all underlying devices support it */58735873- if (nowait)58745874- blk_queue_flag_set(QUEUE_FLAG_NOWAIT, mddev->queue);58755875-58765872 if (!bioset_initialized(&mddev->bio_set)) {58775873 err = bioset_init(&mddev->bio_set, BIO_POOL_SIZE, 0, BIOSET_NEED_BVECS);58785874 if (err)···60066010 else60076011 blk_queue_flag_clear(QUEUE_FLAG_NONROT, mddev->queue);60086012 blk_queue_flag_set(QUEUE_FLAG_IO_STAT, mddev->queue);60136013+60146014+ /* Set the NOWAIT flags if all underlying devices support it */60156015+ if (nowait)60166016+ blk_queue_flag_set(QUEUE_FLAG_NOWAIT, mddev->queue);60096017 }60106018 if (pers->sync_request) {60116019 if (mddev->kobj.sd &&
+7-1
drivers/mmc/core/sd.c
···6767 __res & __mask; \6868 })69697070-#define SD_POWEROFF_NOTIFY_TIMEOUT_MS 20007070+#define SD_POWEROFF_NOTIFY_TIMEOUT_MS 10007171#define SD_WRITE_EXTR_SINGLE_TIMEOUT_MS 100072727373struct sd_busy_data {···16631663 mmc_hostname(card->host), err);16641664 goto out;16651665 }16661666+16671667+ /* Find out when the command is completed. */16681668+ err = mmc_poll_for_busy(card, SD_WRITE_EXTR_SINGLE_TIMEOUT_MS, false,16691669+ MMC_BUSY_EXTR_SINGLE);16701670+ if (err)16711671+ goto out;1666167216671673 cb_data.card = card;16681674 cb_data.reg_buf = reg_buf;
···498498static int gswip_mdio(struct gswip_priv *priv, struct device_node *mdio_np)499499{500500 struct dsa_switch *ds = priv->ds;501501+ int err;501502502502- ds->slave_mii_bus = devm_mdiobus_alloc(priv->dev);503503+ ds->slave_mii_bus = mdiobus_alloc();503504 if (!ds->slave_mii_bus)504505 return -ENOMEM;505506···513512 ds->slave_mii_bus->parent = priv->dev;514513 ds->slave_mii_bus->phy_mask = ~ds->phys_mii_mask;515514516516- return of_mdiobus_register(ds->slave_mii_bus, mdio_np);515515+ err = of_mdiobus_register(ds->slave_mii_bus, mdio_np);516516+ if (err)517517+ mdiobus_free(ds->slave_mii_bus);518518+519519+ return err;517520}518521519522static int gswip_pce_table_entry_read(struct gswip_priv *priv,···21502145 gswip_mdio_mask(priv, GSWIP_MDIO_GLOB_ENABLE, 0, GSWIP_MDIO_GLOB);21512146 dsa_unregister_switch(priv->ds);21522147mdio_bus:21532153- if (mdio_np)21482148+ if (mdio_np) {21542149 mdiobus_unregister(priv->ds->slave_mii_bus);21502150+ mdiobus_free(priv->ds->slave_mii_bus);21512151+ }21552152put_mdio_node:21562153 of_node_put(mdio_np);21572154 for (i = 0; i < priv->num_gphy_fw; i++)···2176216921772170 if (priv->ds->slave_mii_bus) {21782171 mdiobus_unregister(priv->ds->slave_mii_bus);21722172+ mdiobus_free(priv->ds->slave_mii_bus);21792173 of_node_put(priv->ds->slave_mii_bus->dev.of_node);21802174 }21812175
+1-1
drivers/net/dsa/mt7530.c
···20742074 if (priv->irq)20752075 mt7530_setup_mdio_irq(priv);2076207620772077- ret = mdiobus_register(bus);20772077+ ret = devm_mdiobus_register(dev, bus);20782078 if (ret) {20792079 dev_err(dev, "failed to register MDIO bus: %d\n", ret);20802080 if (priv->irq)
···10291029 }1030103010311031 /* Needed in order to initialize the bus mutex lock */10321032- rc = of_mdiobus_register(bus, NULL);10321032+ rc = devm_of_mdiobus_register(dev, bus, NULL);10331033 if (rc < 0) {10341034 dev_err(dev, "failed to register MDIO bus\n");10351035 return rc;···10831083 mdio_device_free(mdio_device);10841084 lynx_pcs_destroy(phylink_pcs);10851085 }10861086- mdiobus_unregister(felix->imdio);10861086+10871087+ /* mdiobus_unregister and mdiobus_free handled by devres */10871088}1088108910891090static const struct felix_info seville_info_vsc9953 = {
+1-2
drivers/net/dsa/qca/ar9331.c
···378378 if (!mnp)379379 return -ENODEV;380380381381- ret = of_mdiobus_register(mbus, mnp);381381+ ret = devm_of_mdiobus_register(dev, mbus, mnp);382382 of_node_put(mnp);383383 if (ret)384384 return ret;···10661066 }1067106710681068 irq_domain_remove(priv->irqdomain);10691069- mdiobus_unregister(priv->mbus);10701069 dsa_unregister_switch(&priv->ds);1071107010721071 reset_control_assert(priv->sw_reset);
+3
drivers/net/ethernet/amd/xgbe/xgbe-pci.c
···425425426426 pci_free_irq_vectors(pdata->pcidev);427427428428+ /* Disable all interrupts in the hardware */429429+ XP_IOWRITE(pdata, XP_INT_EN, 0x0);430430+428431 xgbe_free_pdata(pdata);429432}430433
···487487 ICE_FLAG_MDD_AUTO_RESET_VF,488488 ICE_FLAG_VF_VLAN_PRUNING,489489 ICE_FLAG_LINK_LENIENT_MODE_ENA,490490+ ICE_FLAG_PLUG_AUX_DEV,490491 ICE_PF_FLAGS_NBITS /* must be last */491492};492493···892891 if (pf->hw.func_caps.common_cap.rdma && pf->num_rdma_msix) {893892 set_bit(ICE_FLAG_RDMA_ENA, pf->flags);894893 set_bit(ICE_FLAG_AUX_ENA, pf->flags);895895- ice_plug_aux_dev(pf);894894+ set_bit(ICE_FLAG_PLUG_AUX_DEV, pf->flags);896895 }897896}898897
+2-1
drivers/net/ethernet/intel/ice/ice_common.c
···33813381 !ice_fw_supports_report_dflt_cfg(hw)) {33823382 struct ice_link_default_override_tlv tlv;3383338333843384- if (ice_get_link_default_override(&tlv, pi))33843384+ status = ice_get_link_default_override(&tlv, pi);33853385+ if (status)33853386 goto out;3386338733873388 if (!(tlv.options & ICE_LINK_OVERRIDE_STRICT_MODE) &&
+28-6
drivers/net/ethernet/intel/ice/ice_lag.c
···204204 lag->upper_netdev = NULL;205205 }206206207207- if (lag->peer_netdev) {208208- dev_put(lag->peer_netdev);209209- lag->peer_netdev = NULL;210210- }211211-207207+ lag->peer_netdev = NULL;212208 ice_set_sriov_cap(pf);213209 ice_set_rdma_cap(pf);210210+ lag->bonded = false;211211+ lag->role = ICE_LAG_NONE;212212+}213213+214214+/**215215+ * ice_lag_unregister - handle netdev unregister events216216+ * @lag: LAG info struct217217+ * @netdev: netdev reporting the event218218+ */219219+static void ice_lag_unregister(struct ice_lag *lag, struct net_device *netdev)220220+{221221+ struct ice_pf *pf = lag->pf;222222+223223+ /* check to see if this event is for this netdev224224+ * check that we are in an aggregate225225+ */226226+ if (netdev != lag->netdev || !lag->bonded)227227+ return;228228+229229+ if (lag->upper_netdev) {230230+ dev_put(lag->upper_netdev);231231+ lag->upper_netdev = NULL;232232+ ice_set_sriov_cap(pf);233233+ ice_set_rdma_cap(pf);234234+ }235235+ /* perform some cleanup in case we come back */214236 lag->bonded = false;215237 lag->role = ICE_LAG_NONE;216238}···329307 ice_lag_info_event(lag, ptr);330308 break;331309 case NETDEV_UNREGISTER:332332- ice_lag_unlink(lag, ptr);310310+ ice_lag_unregister(lag, netdev);333311 break;334312 default:335313 break;
···22562256 return;22572257 }2258225822592259+ if (test_and_clear_bit(ICE_FLAG_PLUG_AUX_DEV, pf->flags))22602260+ ice_plug_aux_dev(pf);22612261+22592262 ice_clean_adminq_subtask(pf);22602263 ice_check_media_subtask(pf);22612264 ice_check_for_hang_subtask(pf);···87278724 struct net_device __always_unused *netdev,87288725 netdev_features_t features)87298726{87278727+ bool gso = skb_is_gso(skb);87308728 size_t len;8731872987328730 /* No point in doing any of this if neither checksum nor GSO are···87408736 /* We cannot support GSO if the MSS is going to be less than87418737 * 64 bytes. If it is then we need to drop support for GSO.87428738 */87438743- if (skb_is_gso(skb) && (skb_shinfo(skb)->gso_size < 64))87398739+ if (gso && (skb_shinfo(skb)->gso_size < ICE_TXD_CTX_MIN_MSS))87448740 features &= ~NETIF_F_GSO_MASK;8745874187468746- len = skb_network_header(skb) - skb->data;87428742+ len = skb_network_offset(skb);87478743 if (len > ICE_TXD_MACLEN_MAX || len & 0x1)87488744 goto out_rm_features;8749874587508750- len = skb_transport_header(skb) - skb_network_header(skb);87468746+ len = skb_network_header_len(skb);87518747 if (len > ICE_TXD_IPLEN_MAX || len & 0x1)87528748 goto out_rm_features;8753874987548750 if (skb->encapsulation) {87558755- len = skb_inner_network_header(skb) - skb_transport_header(skb);87568756- if (len > ICE_TXD_L4LEN_MAX || len & 0x1)87578757- goto out_rm_features;87518751+ /* this must work for VXLAN frames AND IPIP/SIT frames, and in87528752+ * the case of IPIP frames, the transport header pointer is87538753+ * after the inner header! So check to make sure that this87548754+ * is a GRE or UDP_TUNNEL frame before doing that math.87558755+ */87568756+ if (gso && (skb_shinfo(skb)->gso_type &87578757+ (SKB_GSO_GRE | SKB_GSO_UDP_TUNNEL))) {87588758+ len = skb_inner_network_header(skb) -87598759+ skb_transport_header(skb);87608760+ if (len > ICE_TXD_L4LEN_MAX || len & 0x1)87618761+ goto out_rm_features;87628762+ }8758876387598759- len = skb_inner_transport_header(skb) -87608760- skb_inner_network_header(skb);87648764+ len = skb_inner_network_header_len(skb);87618765 if (len > ICE_TXD_IPLEN_MAX || len & 0x1)87628766 goto out_rm_features;87638767 }
+8-7
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
···19841984 if (adapter->flags & IXGBEVF_FLAGS_LEGACY_RX)19851985 return;1986198619871987+ if (PAGE_SIZE < 8192)19881988+ if (max_frame > IXGBEVF_MAX_FRAME_BUILD_SKB)19891989+ set_ring_uses_large_buffer(rx_ring);19901990+19911991+ /* 82599 can't rely on RXDCTL.RLPML to restrict the size of the frame */19921992+ if (adapter->hw.mac.type == ixgbe_mac_82599_vf && !ring_uses_large_buffer(rx_ring))19931993+ return;19941994+19871995 set_ring_build_skb_enabled(rx_ring);19881988-19891989- if (PAGE_SIZE < 8192) {19901990- if (max_frame <= IXGBEVF_MAX_FRAME_BUILD_SKB)19911991- return;19921992-19931993- set_ring_uses_large_buffer(rx_ring);19941994- }19951996}1996199719971998/**
+1-1
drivers/net/ethernet/litex/Kconfig
···17171818config LITEX_LITEETH1919 tristate "LiteX Ethernet support"2020- depends on OF2020+ depends on OF && HAS_IOMEM2121 help2222 If you wish to compile a kernel for hardware with a LiteX LiteEth2323 device then you should answer Y to this.
···10111011 struct nfp_flower_repr_priv *repr_priv;10121012 struct nfp_tun_offloaded_mac *entry;10131013 struct nfp_repr *repr;10141014+ u16 nfp_mac_idx;10141015 int ida_idx;1015101610161017 entry = nfp_tunnel_lookup_offloaded_macs(app, mac);···10301029 entry->bridge_count--;1031103010321031 if (!entry->bridge_count && entry->ref_count) {10331033- u16 nfp_mac_idx;10341034-10351032 nfp_mac_idx = entry->index & ~NFP_TUN_PRE_TUN_IDX_BIT;10361033 if (__nfp_tunnel_offload_mac(app, mac, nfp_mac_idx,10371034 false)) {···1045104610461047 /* If MAC is now used by 1 repr set the offloaded MAC index to port. */10471048 if (entry->ref_count == 1 && list_is_singular(&entry->repr_list)) {10481048- u16 nfp_mac_idx;10491049 int port, err;1050105010511051 repr_priv = list_first_entry(&entry->repr_list,···10721074 WARN_ON_ONCE(rhashtable_remove_fast(&priv->tun.offloaded_macs,10731075 &entry->ht_node,10741076 offloaded_macs_params));10771077+10781078+ if (nfp_flower_is_supported_bridge(netdev))10791079+ nfp_mac_idx = entry->index & ~NFP_TUN_PRE_TUN_IDX_BIT;10801080+ else10811081+ nfp_mac_idx = entry->index;10821082+10751083 /* If MAC has global ID then extract and free the ida entry. */10761076- if (nfp_tunnel_is_mac_idx_global(entry->index)) {10841084+ if (nfp_tunnel_is_mac_idx_global(nfp_mac_idx)) {10771085 ida_idx = nfp_tunnel_get_ida_from_global_mac_idx(entry->index);10781086 ida_simple_remove(&priv->tun.mac_off_ids, ida_idx);10791087 }
···265265{266266 /* Write ptr_ring before reading rx_notify_masked */267267 smp_mb();268268- if (!rq->rx_notify_masked) {269269- rq->rx_notify_masked = true;270270- napi_schedule(&rq->xdp_napi);268268+ if (!READ_ONCE(rq->rx_notify_masked) &&269269+ napi_schedule_prep(&rq->xdp_napi)) {270270+ WRITE_ONCE(rq->rx_notify_masked, true);271271+ __napi_schedule(&rq->xdp_napi);271272 }272273}273274···913912 /* Write rx_notify_masked before reading ptr_ring */914913 smp_store_mb(rq->rx_notify_masked, false);915914 if (unlikely(!__ptr_ring_empty(&rq->xdp_ring))) {916916- rq->rx_notify_masked = true;917917- napi_schedule(&rq->xdp_napi);915915+ if (napi_schedule_prep(&rq->xdp_napi)) {916916+ WRITE_ONCE(rq->rx_notify_masked, true);917917+ __napi_schedule(&rq->xdp_napi);918918+ }918919 }919920 }920921
+8-1
drivers/nvme/host/core.c
···42534253 container_of(work, struct nvme_ctrl, async_event_work);4254425442554255 nvme_aen_uevent(ctrl);42564256- ctrl->ops->submit_async_event(ctrl);42564256+42574257+ /*42584258+ * The transport drivers must guarantee AER submission here is safe by42594259+ * flushing ctrl async_event_work after changing the controller state42604260+ * from LIVE and before freeing the admin queue.42614261+ */42624262+ if (ctrl->state == NVME_CTRL_LIVE)42634263+ ctrl->ops->submit_async_event(ctrl);42574264}4258426542594266static bool nvme_ctrl_pp_status(struct nvme_ctrl *ctrl)
···11111111 if (!desc)11121112 return cpu_possible_mask;1113111311141114- if (WARN_ON_ONCE(!desc->affinity))11141114+ /* MSI[X] interrupts can be allocated without affinity descriptor */11151115+ if (!desc->affinity)11151116 return NULL;1116111711171118 /*
···214214 SCSI_TIMEOUT, 3, NULL);215215}216216217217+static int scsi_realloc_sdev_budget_map(struct scsi_device *sdev,218218+ unsigned int depth)219219+{220220+ int new_shift = sbitmap_calculate_shift(depth);221221+ bool need_alloc = !sdev->budget_map.map;222222+ bool need_free = false;223223+ int ret;224224+ struct sbitmap sb_backup;225225+226226+ /*227227+ * realloc if new shift is calculated, which is caused by setting228228+ * up one new default queue depth after calling ->slave_configure229229+ */230230+ if (!need_alloc && new_shift != sdev->budget_map.shift)231231+ need_alloc = need_free = true;232232+233233+ if (!need_alloc)234234+ return 0;235235+236236+ /*237237+ * Request queue has to be frozen for reallocating budget map,238238+ * and here disk isn't added yet, so freezing is pretty fast239239+ */240240+ if (need_free) {241241+ blk_mq_freeze_queue(sdev->request_queue);242242+ sb_backup = sdev->budget_map;243243+ }244244+ ret = sbitmap_init_node(&sdev->budget_map,245245+ scsi_device_max_queue_depth(sdev),246246+ new_shift, GFP_KERNEL,247247+ sdev->request_queue->node, false, true);248248+ if (need_free) {249249+ if (ret)250250+ sdev->budget_map = sb_backup;251251+ else252252+ sbitmap_free(&sb_backup);253253+ ret = 0;254254+ blk_mq_unfreeze_queue(sdev->request_queue);255255+ }256256+ return ret;257257+}258258+217259/**218260 * scsi_alloc_sdev - allocate and setup a scsi_Device219261 * @starget: which target to allocate a &scsi_device for···348306 * default device queue depth to figure out sbitmap shift349307 * since we use this queue depth most of times.350308 */351351- if (sbitmap_init_node(&sdev->budget_map,352352- scsi_device_max_queue_depth(sdev),353353- sbitmap_calculate_shift(depth),354354- GFP_KERNEL, sdev->request_queue->node,355355- false, true)) {309309+ if (scsi_realloc_sdev_budget_map(sdev, depth)) {356310 put_device(&starget->dev);357311 kfree(sdev);358312 goto out;···10551017 }10561018 return SCSI_SCAN_NO_RESPONSE;10571019 }10201020+10211021+ /*10221022+ * The queue_depth is often changed in ->slave_configure.10231023+ * Set up budget map again since memory consumption of10241024+ * the map depends on actual queue depth.10251025+ */10261026+ scsi_realloc_sdev_budget_map(sdev, sdev->queue_depth);10581027 }1059102810601029 if (sdev->scsi_level >= SCSI_3)
+20
drivers/video/console/Kconfig
···7878 help7979 Low-level framebuffer-based console driver.80808181+config FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION8282+ bool "Enable legacy fbcon hardware acceleration code"8383+ depends on FRAMEBUFFER_CONSOLE8484+ default y if PARISC8585+ default n8686+ help8787+ This option enables the fbcon (framebuffer text-based) hardware8888+ acceleration for graphics drivers which were written for the fbdev8989+ graphics interface.9090+9191+ On modern machines, on mainstream machines (like x86-64) or when9292+ using a modern Linux distribution those fbdev drivers usually aren't used.9393+ So enabling this option wouldn't have any effect, which is why you want9494+ to disable this option on such newer machines.9595+9696+ If you compile this kernel for older machines which still require the9797+ fbdev drivers, you may want to say Y.9898+9999+ If unsure, select n.100100+81101config FRAMEBUFFER_CONSOLE_DETECT_PRIMARY82102 bool "Map the console to the primary display device"83103 depends on FRAMEBUFFER_CONSOLE
+16
drivers/video/fbdev/core/bitblit.c
···4343 }4444}45454646+static void bit_bmove(struct vc_data *vc, struct fb_info *info, int sy,4747+ int sx, int dy, int dx, int height, int width)4848+{4949+ struct fb_copyarea area;5050+5151+ area.sx = sx * vc->vc_font.width;5252+ area.sy = sy * vc->vc_font.height;5353+ area.dx = dx * vc->vc_font.width;5454+ area.dy = dy * vc->vc_font.height;5555+ area.height = height * vc->vc_font.height;5656+ area.width = width * vc->vc_font.width;5757+5858+ info->fbops->fb_copyarea(info, &area);5959+}6060+4661static void bit_clear(struct vc_data *vc, struct fb_info *info, int sy,4762 int sx, int height, int width)4863{···393378394379void fbcon_set_bitops(struct fbcon_ops *ops)395380{381381+ ops->bmove = bit_bmove;396382 ops->clear = bit_clear;397383 ops->putcs = bit_putcs;398384 ops->clear_margins = bit_clear_margins;
+536-21
drivers/video/fbdev/core/fbcon.c
···173173 int count, int ypos, int xpos);174174static void fbcon_clear_margins(struct vc_data *vc, int bottom_only);175175static void fbcon_cursor(struct vc_data *vc, int mode);176176+static void fbcon_bmove(struct vc_data *vc, int sy, int sx, int dy, int dx,177177+ int height, int width);176178static int fbcon_switch(struct vc_data *vc);177179static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch);178180static void fbcon_set_palette(struct vc_data *vc, const unsigned char *table);···182180/*183181 * Internal routines184182 */183183+static __inline__ void ywrap_up(struct vc_data *vc, int count);184184+static __inline__ void ywrap_down(struct vc_data *vc, int count);185185+static __inline__ void ypan_up(struct vc_data *vc, int count);186186+static __inline__ void ypan_down(struct vc_data *vc, int count);187187+static void fbcon_bmove_rec(struct vc_data *vc, struct fbcon_display *p, int sy, int sx,188188+ int dy, int dx, int height, int width, u_int y_break);185189static void fbcon_set_disp(struct fb_info *info, struct fb_var_screeninfo *var,186190 int unit);191191+static void fbcon_redraw_move(struct vc_data *vc, struct fbcon_display *p,192192+ int line, int count, int dy);187193static void fbcon_modechanged(struct fb_info *info);188194static void fbcon_set_all_vcs(struct fb_info *info);189195static void fbcon_start(void);···10251015 struct vc_data *svc = *default_mode;10261016 struct fbcon_display *t, *p = &fb_display[vc->vc_num];10271017 int logo = 1, new_rows, new_cols, rows, cols;10281028- int ret;10181018+ int cap, ret;1029101910301020 if (WARN_ON(info_idx == -1))10311021 return;···10341024 con2fb_map[vc->vc_num] = info_idx;1035102510361026 info = registered_fb[con2fb_map[vc->vc_num]];10271027+ cap = info->flags;1037102810381029 if (logo_shown < 0 && console_loglevel <= CONSOLE_LOGLEVEL_QUIET)10391030 logo_shown = FBCON_LOGO_DONTSHOW;···1136112511371126 ops->graphics = 0;1138112711281128+#ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION11291129+ if ((cap & FBINFO_HWACCEL_COPYAREA) &&11301130+ !(cap & FBINFO_HWACCEL_DISABLED))11311131+ p->scrollmode = SCROLL_MOVE;11321132+ else /* default to something safe */11331133+ p->scrollmode = SCROLL_REDRAW;11341134+#endif11351135+11391136 /*11401137 * ++guenther: console.c:vc_allocate() relies on initializing11411138 * vc_{cols,rows}, but we must not set those if we are only···12301211 * This system is now divided into two levels because of complications12311212 * caused by hardware scrolling. Top level functions:12321213 *12331233- * fbcon_clear(), fbcon_putc(), fbcon_clear_margins()12141214+ * fbcon_bmove(), fbcon_clear(), fbcon_putc(), fbcon_clear_margins()12341215 *12351216 * handles y values in range [0, scr_height-1] that correspond to real12361217 * screen positions. y_wrap shift means that first line of bitmap may be12371218 * anywhere on this display. These functions convert lineoffsets to12381219 * bitmap offsets and deal with the wrap-around case by splitting blits.12391220 *12211221+ * fbcon_bmove_physical_8() -- These functions fast implementations12401222 * fbcon_clear_physical_8() -- of original fbcon_XXX fns.12411223 * fbcon_putc_physical_8() -- (font width != 8) may be added later12421224 *···14101390 }14111391}1412139213931393+static __inline__ void ywrap_up(struct vc_data *vc, int count)13941394+{13951395+ struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];13961396+ struct fbcon_ops *ops = info->fbcon_par;13971397+ struct fbcon_display *p = &fb_display[vc->vc_num];13981398+13991399+ p->yscroll += count;14001400+ if (p->yscroll >= p->vrows) /* Deal with wrap */14011401+ p->yscroll -= p->vrows;14021402+ ops->var.xoffset = 0;14031403+ ops->var.yoffset = p->yscroll * vc->vc_font.height;14041404+ ops->var.vmode |= FB_VMODE_YWRAP;14051405+ ops->update_start(info);14061406+ scrollback_max += count;14071407+ if (scrollback_max > scrollback_phys_max)14081408+ scrollback_max = scrollback_phys_max;14091409+ scrollback_current = 0;14101410+}14111411+14121412+static __inline__ void ywrap_down(struct vc_data *vc, int count)14131413+{14141414+ struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];14151415+ struct fbcon_ops *ops = info->fbcon_par;14161416+ struct fbcon_display *p = &fb_display[vc->vc_num];14171417+14181418+ p->yscroll -= count;14191419+ if (p->yscroll < 0) /* Deal with wrap */14201420+ p->yscroll += p->vrows;14211421+ ops->var.xoffset = 0;14221422+ ops->var.yoffset = p->yscroll * vc->vc_font.height;14231423+ ops->var.vmode |= FB_VMODE_YWRAP;14241424+ ops->update_start(info);14251425+ scrollback_max -= count;14261426+ if (scrollback_max < 0)14271427+ scrollback_max = 0;14281428+ scrollback_current = 0;14291429+}14301430+14311431+static __inline__ void ypan_up(struct vc_data *vc, int count)14321432+{14331433+ struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];14341434+ struct fbcon_display *p = &fb_display[vc->vc_num];14351435+ struct fbcon_ops *ops = info->fbcon_par;14361436+14371437+ p->yscroll += count;14381438+ if (p->yscroll > p->vrows - vc->vc_rows) {14391439+ ops->bmove(vc, info, p->vrows - vc->vc_rows,14401440+ 0, 0, 0, vc->vc_rows, vc->vc_cols);14411441+ p->yscroll -= p->vrows - vc->vc_rows;14421442+ }14431443+14441444+ ops->var.xoffset = 0;14451445+ ops->var.yoffset = p->yscroll * vc->vc_font.height;14461446+ ops->var.vmode &= ~FB_VMODE_YWRAP;14471447+ ops->update_start(info);14481448+ fbcon_clear_margins(vc, 1);14491449+ scrollback_max += count;14501450+ if (scrollback_max > scrollback_phys_max)14511451+ scrollback_max = scrollback_phys_max;14521452+ scrollback_current = 0;14531453+}14541454+14551455+static __inline__ void ypan_up_redraw(struct vc_data *vc, int t, int count)14561456+{14571457+ struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];14581458+ struct fbcon_ops *ops = info->fbcon_par;14591459+ struct fbcon_display *p = &fb_display[vc->vc_num];14601460+14611461+ p->yscroll += count;14621462+14631463+ if (p->yscroll > p->vrows - vc->vc_rows) {14641464+ p->yscroll -= p->vrows - vc->vc_rows;14651465+ fbcon_redraw_move(vc, p, t + count, vc->vc_rows - count, t);14661466+ }14671467+14681468+ ops->var.xoffset = 0;14691469+ ops->var.yoffset = p->yscroll * vc->vc_font.height;14701470+ ops->var.vmode &= ~FB_VMODE_YWRAP;14711471+ ops->update_start(info);14721472+ fbcon_clear_margins(vc, 1);14731473+ scrollback_max += count;14741474+ if (scrollback_max > scrollback_phys_max)14751475+ scrollback_max = scrollback_phys_max;14761476+ scrollback_current = 0;14771477+}14781478+14791479+static __inline__ void ypan_down(struct vc_data *vc, int count)14801480+{14811481+ struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];14821482+ struct fbcon_display *p = &fb_display[vc->vc_num];14831483+ struct fbcon_ops *ops = info->fbcon_par;14841484+14851485+ p->yscroll -= count;14861486+ if (p->yscroll < 0) {14871487+ ops->bmove(vc, info, 0, 0, p->vrows - vc->vc_rows,14881488+ 0, vc->vc_rows, vc->vc_cols);14891489+ p->yscroll += p->vrows - vc->vc_rows;14901490+ }14911491+14921492+ ops->var.xoffset = 0;14931493+ ops->var.yoffset = p->yscroll * vc->vc_font.height;14941494+ ops->var.vmode &= ~FB_VMODE_YWRAP;14951495+ ops->update_start(info);14961496+ fbcon_clear_margins(vc, 1);14971497+ scrollback_max -= count;14981498+ if (scrollback_max < 0)14991499+ scrollback_max = 0;15001500+ scrollback_current = 0;15011501+}15021502+15031503+static __inline__ void ypan_down_redraw(struct vc_data *vc, int t, int count)15041504+{15051505+ struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];15061506+ struct fbcon_ops *ops = info->fbcon_par;15071507+ struct fbcon_display *p = &fb_display[vc->vc_num];15081508+15091509+ p->yscroll -= count;15101510+15111511+ if (p->yscroll < 0) {15121512+ p->yscroll += p->vrows - vc->vc_rows;15131513+ fbcon_redraw_move(vc, p, t, vc->vc_rows - count, t + count);15141514+ }15151515+15161516+ ops->var.xoffset = 0;15171517+ ops->var.yoffset = p->yscroll * vc->vc_font.height;15181518+ ops->var.vmode &= ~FB_VMODE_YWRAP;15191519+ ops->update_start(info);15201520+ fbcon_clear_margins(vc, 1);15211521+ scrollback_max -= count;15221522+ if (scrollback_max < 0)15231523+ scrollback_max = 0;15241524+ scrollback_current = 0;15251525+}15261526+15271527+static void fbcon_redraw_move(struct vc_data *vc, struct fbcon_display *p,15281528+ int line, int count, int dy)15291529+{15301530+ unsigned short *s = (unsigned short *)15311531+ (vc->vc_origin + vc->vc_size_row * line);15321532+15331533+ while (count--) {15341534+ unsigned short *start = s;15351535+ unsigned short *le = advance_row(s, 1);15361536+ unsigned short c;15371537+ int x = 0;15381538+ unsigned short attr = 1;15391539+15401540+ do {15411541+ c = scr_readw(s);15421542+ if (attr != (c & 0xff00)) {15431543+ attr = c & 0xff00;15441544+ if (s > start) {15451545+ fbcon_putcs(vc, start, s - start,15461546+ dy, x);15471547+ x += s - start;15481548+ start = s;15491549+ }15501550+ }15511551+ console_conditional_schedule();15521552+ s++;15531553+ } while (s < le);15541554+ if (s > start)15551555+ fbcon_putcs(vc, start, s - start, dy, x);15561556+ console_conditional_schedule();15571557+ dy++;15581558+ }15591559+}15601560+15611561+static void fbcon_redraw_blit(struct vc_data *vc, struct fb_info *info,15621562+ struct fbcon_display *p, int line, int count, int ycount)15631563+{15641564+ int offset = ycount * vc->vc_cols;15651565+ unsigned short *d = (unsigned short *)15661566+ (vc->vc_origin + vc->vc_size_row * line);15671567+ unsigned short *s = d + offset;15681568+ struct fbcon_ops *ops = info->fbcon_par;15691569+15701570+ while (count--) {15711571+ unsigned short *start = s;15721572+ unsigned short *le = advance_row(s, 1);15731573+ unsigned short c;15741574+ int x = 0;15751575+15761576+ do {15771577+ c = scr_readw(s);15781578+15791579+ if (c == scr_readw(d)) {15801580+ if (s > start) {15811581+ ops->bmove(vc, info, line + ycount, x,15821582+ line, x, 1, s-start);15831583+ x += s - start + 1;15841584+ start = s + 1;15851585+ } else {15861586+ x++;15871587+ start++;15881588+ }15891589+ }15901590+15911591+ scr_writew(c, d);15921592+ console_conditional_schedule();15931593+ s++;15941594+ d++;15951595+ } while (s < le);15961596+ if (s > start)15971597+ ops->bmove(vc, info, line + ycount, x, line, x, 1,15981598+ s-start);15991599+ console_conditional_schedule();16001600+ if (ycount > 0)16011601+ line++;16021602+ else {16031603+ line--;16041604+ /* NOTE: We subtract two lines from these pointers */16051605+ s -= vc->vc_size_row;16061606+ d -= vc->vc_size_row;16071607+ }16081608+ }16091609+}16101610+14131611static void fbcon_redraw(struct vc_data *vc, struct fbcon_display *p,14141612 int line, int count, int offset)14151613{···16881450{16891451 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];16901452 struct fbcon_display *p = &fb_display[vc->vc_num];14531453+ int scroll_partial = info->flags & FBINFO_PARTIAL_PAN_OK;1691145416921455 if (fbcon_is_inactive(vc, info))16931456 return true;···17051466 case SM_UP:17061467 if (count > vc->vc_rows) /* Maximum realistic size */17071468 count = vc->vc_rows;17081708- fbcon_redraw(vc, p, t, b - t - count,17091709- count * vc->vc_cols);17101710- fbcon_clear(vc, b - count, 0, count, vc->vc_cols);17111711- scr_memsetw((unsigned short *) (vc->vc_origin +17121712- vc->vc_size_row *17131713- (b - count)),17141714- vc->vc_video_erase_char,17151715- vc->vc_size_row * count);17161716- return true;14691469+ if (logo_shown >= 0)14701470+ goto redraw_up;14711471+ switch (fb_scrollmode(p)) {14721472+ case SCROLL_MOVE:14731473+ fbcon_redraw_blit(vc, info, p, t, b - t - count,14741474+ count);14751475+ fbcon_clear(vc, b - count, 0, count, vc->vc_cols);14761476+ scr_memsetw((unsigned short *) (vc->vc_origin +14771477+ vc->vc_size_row *14781478+ (b - count)),14791479+ vc->vc_video_erase_char,14801480+ vc->vc_size_row * count);14811481+ return true;14821482+14831483+ case SCROLL_WRAP_MOVE:14841484+ if (b - t - count > 3 * vc->vc_rows >> 2) {14851485+ if (t > 0)14861486+ fbcon_bmove(vc, 0, 0, count, 0, t,14871487+ vc->vc_cols);14881488+ ywrap_up(vc, count);14891489+ if (vc->vc_rows - b > 0)14901490+ fbcon_bmove(vc, b - count, 0, b, 0,14911491+ vc->vc_rows - b,14921492+ vc->vc_cols);14931493+ } else if (info->flags & FBINFO_READS_FAST)14941494+ fbcon_bmove(vc, t + count, 0, t, 0,14951495+ b - t - count, vc->vc_cols);14961496+ else14971497+ goto redraw_up;14981498+ fbcon_clear(vc, b - count, 0, count, vc->vc_cols);14991499+ break;15001500+15011501+ case SCROLL_PAN_REDRAW:15021502+ if ((p->yscroll + count <=15031503+ 2 * (p->vrows - vc->vc_rows))15041504+ && ((!scroll_partial && (b - t == vc->vc_rows))15051505+ || (scroll_partial15061506+ && (b - t - count >15071507+ 3 * vc->vc_rows >> 2)))) {15081508+ if (t > 0)15091509+ fbcon_redraw_move(vc, p, 0, t, count);15101510+ ypan_up_redraw(vc, t, count);15111511+ if (vc->vc_rows - b > 0)15121512+ fbcon_redraw_move(vc, p, b,15131513+ vc->vc_rows - b, b);15141514+ } else15151515+ fbcon_redraw_move(vc, p, t + count, b - t - count, t);15161516+ fbcon_clear(vc, b - count, 0, count, vc->vc_cols);15171517+ break;15181518+15191519+ case SCROLL_PAN_MOVE:15201520+ if ((p->yscroll + count <=15211521+ 2 * (p->vrows - vc->vc_rows))15221522+ && ((!scroll_partial && (b - t == vc->vc_rows))15231523+ || (scroll_partial15241524+ && (b - t - count >15251525+ 3 * vc->vc_rows >> 2)))) {15261526+ if (t > 0)15271527+ fbcon_bmove(vc, 0, 0, count, 0, t,15281528+ vc->vc_cols);15291529+ ypan_up(vc, count);15301530+ if (vc->vc_rows - b > 0)15311531+ fbcon_bmove(vc, b - count, 0, b, 0,15321532+ vc->vc_rows - b,15331533+ vc->vc_cols);15341534+ } else if (info->flags & FBINFO_READS_FAST)15351535+ fbcon_bmove(vc, t + count, 0, t, 0,15361536+ b - t - count, vc->vc_cols);15371537+ else15381538+ goto redraw_up;15391539+ fbcon_clear(vc, b - count, 0, count, vc->vc_cols);15401540+ break;15411541+15421542+ case SCROLL_REDRAW:15431543+ redraw_up:15441544+ fbcon_redraw(vc, p, t, b - t - count,15451545+ count * vc->vc_cols);15461546+ fbcon_clear(vc, b - count, 0, count, vc->vc_cols);15471547+ scr_memsetw((unsigned short *) (vc->vc_origin +15481548+ vc->vc_size_row *15491549+ (b - count)),15501550+ vc->vc_video_erase_char,15511551+ vc->vc_size_row * count);15521552+ return true;15531553+ }15541554+ break;1717155517181556 case SM_DOWN:17191557 if (count > vc->vc_rows) /* Maximum realistic size */17201558 count = vc->vc_rows;17211721- fbcon_redraw(vc, p, b - 1, b - t - count,17221722- -count * vc->vc_cols);17231723- fbcon_clear(vc, t, 0, count, vc->vc_cols);17241724- scr_memsetw((unsigned short *) (vc->vc_origin +17251725- vc->vc_size_row *17261726- t),17271727- vc->vc_video_erase_char,17281728- vc->vc_size_row * count);17291729- return true;15591559+ if (logo_shown >= 0)15601560+ goto redraw_down;15611561+ switch (fb_scrollmode(p)) {15621562+ case SCROLL_MOVE:15631563+ fbcon_redraw_blit(vc, info, p, b - 1, b - t - count,15641564+ -count);15651565+ fbcon_clear(vc, t, 0, count, vc->vc_cols);15661566+ scr_memsetw((unsigned short *) (vc->vc_origin +15671567+ vc->vc_size_row *15681568+ t),15691569+ vc->vc_video_erase_char,15701570+ vc->vc_size_row * count);15711571+ return true;15721572+15731573+ case SCROLL_WRAP_MOVE:15741574+ if (b - t - count > 3 * vc->vc_rows >> 2) {15751575+ if (vc->vc_rows - b > 0)15761576+ fbcon_bmove(vc, b, 0, b - count, 0,15771577+ vc->vc_rows - b,15781578+ vc->vc_cols);15791579+ ywrap_down(vc, count);15801580+ if (t > 0)15811581+ fbcon_bmove(vc, count, 0, 0, 0, t,15821582+ vc->vc_cols);15831583+ } else if (info->flags & FBINFO_READS_FAST)15841584+ fbcon_bmove(vc, t, 0, t + count, 0,15851585+ b - t - count, vc->vc_cols);15861586+ else15871587+ goto redraw_down;15881588+ fbcon_clear(vc, t, 0, count, vc->vc_cols);15891589+ break;15901590+15911591+ case SCROLL_PAN_MOVE:15921592+ if ((count - p->yscroll <= p->vrows - vc->vc_rows)15931593+ && ((!scroll_partial && (b - t == vc->vc_rows))15941594+ || (scroll_partial15951595+ && (b - t - count >15961596+ 3 * vc->vc_rows >> 2)))) {15971597+ if (vc->vc_rows - b > 0)15981598+ fbcon_bmove(vc, b, 0, b - count, 0,15991599+ vc->vc_rows - b,16001600+ vc->vc_cols);16011601+ ypan_down(vc, count);16021602+ if (t > 0)16031603+ fbcon_bmove(vc, count, 0, 0, 0, t,16041604+ vc->vc_cols);16051605+ } else if (info->flags & FBINFO_READS_FAST)16061606+ fbcon_bmove(vc, t, 0, t + count, 0,16071607+ b - t - count, vc->vc_cols);16081608+ else16091609+ goto redraw_down;16101610+ fbcon_clear(vc, t, 0, count, vc->vc_cols);16111611+ break;16121612+16131613+ case SCROLL_PAN_REDRAW:16141614+ if ((count - p->yscroll <= p->vrows - vc->vc_rows)16151615+ && ((!scroll_partial && (b - t == vc->vc_rows))16161616+ || (scroll_partial16171617+ && (b - t - count >16181618+ 3 * vc->vc_rows >> 2)))) {16191619+ if (vc->vc_rows - b > 0)16201620+ fbcon_redraw_move(vc, p, b, vc->vc_rows - b,16211621+ b - count);16221622+ ypan_down_redraw(vc, t, count);16231623+ if (t > 0)16241624+ fbcon_redraw_move(vc, p, count, t, 0);16251625+ } else16261626+ fbcon_redraw_move(vc, p, t, b - t - count, t + count);16271627+ fbcon_clear(vc, t, 0, count, vc->vc_cols);16281628+ break;16291629+16301630+ case SCROLL_REDRAW:16311631+ redraw_down:16321632+ fbcon_redraw(vc, p, b - 1, b - t - count,16331633+ -count * vc->vc_cols);16341634+ fbcon_clear(vc, t, 0, count, vc->vc_cols);16351635+ scr_memsetw((unsigned short *) (vc->vc_origin +16361636+ vc->vc_size_row *16371637+ t),16381638+ vc->vc_video_erase_char,16391639+ vc->vc_size_row * count);16401640+ return true;16411641+ }17301642 }17311643 return false;16441644+}16451645+16461646+16471647+static void fbcon_bmove(struct vc_data *vc, int sy, int sx, int dy, int dx,16481648+ int height, int width)16491649+{16501650+ struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];16511651+ struct fbcon_display *p = &fb_display[vc->vc_num];16521652+16531653+ if (fbcon_is_inactive(vc, info))16541654+ return;16551655+16561656+ if (!width || !height)16571657+ return;16581658+16591659+ /* Split blits that cross physical y_wrap case.16601660+ * Pathological case involves 4 blits, better to use recursive16611661+ * code rather than unrolled case16621662+ *16631663+ * Recursive invocations don't need to erase the cursor over and16641664+ * over again, so we use fbcon_bmove_rec()16651665+ */16661666+ fbcon_bmove_rec(vc, p, sy, sx, dy, dx, height, width,16671667+ p->vrows - p->yscroll);16681668+}16691669+16701670+static void fbcon_bmove_rec(struct vc_data *vc, struct fbcon_display *p, int sy, int sx,16711671+ int dy, int dx, int height, int width, u_int y_break)16721672+{16731673+ struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];16741674+ struct fbcon_ops *ops = info->fbcon_par;16751675+ u_int b;16761676+16771677+ if (sy < y_break && sy + height > y_break) {16781678+ b = y_break - sy;16791679+ if (dy < sy) { /* Avoid trashing self */16801680+ fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width,16811681+ y_break);16821682+ fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx,16831683+ height - b, width, y_break);16841684+ } else {16851685+ fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx,16861686+ height - b, width, y_break);16871687+ fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width,16881688+ y_break);16891689+ }16901690+ return;16911691+ }16921692+16931693+ if (dy < y_break && dy + height > y_break) {16941694+ b = y_break - dy;16951695+ if (dy < sy) { /* Avoid trashing self */16961696+ fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width,16971697+ y_break);16981698+ fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx,16991699+ height - b, width, y_break);17001700+ } else {17011701+ fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx,17021702+ height - b, width, y_break);17031703+ fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width,17041704+ y_break);17051705+ }17061706+ return;17071707+ }17081708+ ops->bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx,17091709+ height, width);17101710+}17111711+17121712+static void updatescrollmode_accel(struct fbcon_display *p,17131713+ struct fb_info *info,17141714+ struct vc_data *vc)17151715+{17161716+#ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION17171717+ struct fbcon_ops *ops = info->fbcon_par;17181718+ int cap = info->flags;17191719+ u16 t = 0;17201720+ int ypan = FBCON_SWAP(ops->rotate, info->fix.ypanstep,17211721+ info->fix.xpanstep);17221722+ int ywrap = FBCON_SWAP(ops->rotate, info->fix.ywrapstep, t);17231723+ int yres = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);17241724+ int vyres = FBCON_SWAP(ops->rotate, info->var.yres_virtual,17251725+ info->var.xres_virtual);17261726+ int good_pan = (cap & FBINFO_HWACCEL_YPAN) &&17271727+ divides(ypan, vc->vc_font.height) && vyres > yres;17281728+ int good_wrap = (cap & FBINFO_HWACCEL_YWRAP) &&17291729+ divides(ywrap, vc->vc_font.height) &&17301730+ divides(vc->vc_font.height, vyres) &&17311731+ divides(vc->vc_font.height, yres);17321732+ int reading_fast = cap & FBINFO_READS_FAST;17331733+ int fast_copyarea = (cap & FBINFO_HWACCEL_COPYAREA) &&17341734+ !(cap & FBINFO_HWACCEL_DISABLED);17351735+ int fast_imageblit = (cap & FBINFO_HWACCEL_IMAGEBLIT) &&17361736+ !(cap & FBINFO_HWACCEL_DISABLED);17371737+17381738+ if (good_wrap || good_pan) {17391739+ if (reading_fast || fast_copyarea)17401740+ p->scrollmode = good_wrap ?17411741+ SCROLL_WRAP_MOVE : SCROLL_PAN_MOVE;17421742+ else17431743+ p->scrollmode = good_wrap ? SCROLL_REDRAW :17441744+ SCROLL_PAN_REDRAW;17451745+ } else {17461746+ if (reading_fast || (fast_copyarea && !fast_imageblit))17471747+ p->scrollmode = SCROLL_MOVE;17481748+ else17491749+ p->scrollmode = SCROLL_REDRAW;17501750+ }17511751+#endif17321752}1733175317341754static void updatescrollmode(struct fbcon_display *p,···20051507 p->vrows -= (yres - (fh * vc->vc_rows)) / fh;20061508 if ((yres % fh) && (vyres % fh < yres % fh))20071509 p->vrows--;15101510+15111511+ /* update scrollmode in case hardware acceleration is used */15121512+ updatescrollmode_accel(p, info, vc);20081513}2009151420101515#define PITCH(w) (((w) + 7) >> 3)···2165166421661665 updatescrollmode(p, info, vc);2167166621682168- scrollback_phys_max = 0;16671667+ switch (fb_scrollmode(p)) {16681668+ case SCROLL_WRAP_MOVE:16691669+ scrollback_phys_max = p->vrows - vc->vc_rows;16701670+ break;16711671+ case SCROLL_PAN_MOVE:16721672+ case SCROLL_PAN_REDRAW:16731673+ scrollback_phys_max = p->vrows - 2 * vc->vc_rows;16741674+ if (scrollback_phys_max < 0)16751675+ scrollback_phys_max = 0;16761676+ break;16771677+ default:16781678+ scrollback_phys_max = 0;16791679+ break;16801680+ }16811681+21691682 scrollback_max = 0;21701683 scrollback_current = 0;21711684
+72
drivers/video/fbdev/core/fbcon.h
···2929 /* Filled in by the low-level console driver */3030 const u_char *fontdata;3131 int userfont; /* != 0 if fontdata kmalloc()ed */3232+#ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION3333+ u_short scrollmode; /* Scroll Method, use fb_scrollmode() */3434+#endif3235 u_short inverse; /* != 0 text black on white as default */3336 short yscroll; /* Hardware scrolling */3437 int vrows; /* number of virtual rows */···5451};55525653struct fbcon_ops {5454+ void (*bmove)(struct vc_data *vc, struct fb_info *info, int sy,5555+ int sx, int dy, int dx, int height, int width);5756 void (*clear)(struct vc_data *vc, struct fb_info *info, int sy,5857 int sx, int height, int width);5958 void (*putcs)(struct vc_data *vc, struct fb_info *info,···153148154149#define attr_bgcol_ec(bgshift, vc, info) attr_col_ec(bgshift, vc, info, 0)155150#define attr_fgcol_ec(fgshift, vc, info) attr_col_ec(fgshift, vc, info, 1)151151+152152+ /*153153+ * Scroll Method154154+ */155155+156156+/* There are several methods fbcon can use to move text around the screen:157157+ *158158+ * Operation Pan Wrap159159+ *---------------------------------------------160160+ * SCROLL_MOVE copyarea No No161161+ * SCROLL_PAN_MOVE copyarea Yes No162162+ * SCROLL_WRAP_MOVE copyarea No Yes163163+ * SCROLL_REDRAW imageblit No No164164+ * SCROLL_PAN_REDRAW imageblit Yes No165165+ * SCROLL_WRAP_REDRAW imageblit No Yes166166+ *167167+ * (SCROLL_WRAP_REDRAW is not implemented yet)168168+ *169169+ * In general, fbcon will choose the best scrolling170170+ * method based on the rule below:171171+ *172172+ * Pan/Wrap > accel imageblit > accel copyarea >173173+ * soft imageblit > (soft copyarea)174174+ *175175+ * Exception to the rule: Pan + accel copyarea is176176+ * preferred over Pan + accel imageblit.177177+ *178178+ * The above is typical for PCI/AGP cards. Unless179179+ * overridden, fbcon will never use soft copyarea.180180+ *181181+ * If you need to override the above rule, set the182182+ * appropriate flags in fb_info->flags. For example,183183+ * to prefer copyarea over imageblit, set184184+ * FBINFO_READS_FAST.185185+ *186186+ * Other notes:187187+ * + use the hardware engine to move the text188188+ * (hw-accelerated copyarea() and fillrect())189189+ * + use hardware-supported panning on a large virtual screen190190+ * + amifb can not only pan, but also wrap the display by N lines191191+ * (i.e. visible line i = physical line (i+N) % yres).192192+ * + read what's already rendered on the screen and193193+ * write it in a different place (this is cfb_copyarea())194194+ * + re-render the text to the screen195195+ *196196+ * Whether to use wrapping or panning can only be figured out at197197+ * runtime (when we know whether our font height is a multiple198198+ * of the pan/wrap step)199199+ *200200+ */201201+202202+#define SCROLL_MOVE 0x001203203+#define SCROLL_PAN_MOVE 0x002204204+#define SCROLL_WRAP_MOVE 0x003205205+#define SCROLL_REDRAW 0x004206206+#define SCROLL_PAN_REDRAW 0x005207207+208208+static inline u_short fb_scrollmode(struct fbcon_display *fb)209209+{210210+#ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION211211+ return fb->scrollmode;212212+#else213213+ /* hardcoded to SCROLL_REDRAW if acceleration was disabled. */214214+ return SCROLL_REDRAW;215215+#endif216216+}217217+156218157219#ifdef CONFIG_FB_TILEBLITTING158220extern void fbcon_set_tileops(struct vc_data *vc, struct fb_info *info);
···1616#include <asm/types.h>1717#include "fbcon.h"18181919+static void tile_bmove(struct vc_data *vc, struct fb_info *info, int sy,2020+ int sx, int dy, int dx, int height, int width)2121+{2222+ struct fb_tilearea area;2323+2424+ area.sx = sx;2525+ area.sy = sy;2626+ area.dx = dx;2727+ area.dy = dy;2828+ area.height = height;2929+ area.width = width;3030+3131+ info->tileops->fb_tilecopy(info, &area);3232+}3333+1934static void tile_clear(struct vc_data *vc, struct fb_info *info, int sy,2035 int sx, int height, int width)2136{···133118 struct fb_tilemap map;134119 struct fbcon_ops *ops = info->fbcon_par;135120121121+ ops->bmove = tile_bmove;136122 ops->clear = tile_clear;137123 ops->putcs = tile_putcs;138124 ops->clear_margins = tile_clear_margins;
+6-6
drivers/video/fbdev/skeletonfb.c
···505505}506506507507/**508508- * xxxfb_copyarea - OBSOLETE function.508508+ * xxxfb_copyarea - REQUIRED function. Can use generic routines if509509+ * non acclerated hardware and packed pixel based.509510 * Copies one area of the screen to another area.510510- * Will be deleted in a future version511511 *512512 * @info: frame buffer structure that represents a single frame buffer513513 * @area: Structure providing the data to copy the framebuffer contents514514 * from one region to another.515515 *516516- * This drawing operation copied a rectangular area from one area of the516516+ * This drawing operation copies a rectangular area from one area of the517517 * screen to another area.518518 */519519void xxxfb_copyarea(struct fb_info *p, const struct fb_copyarea *area) ···645645 .fb_setcolreg = xxxfb_setcolreg,646646 .fb_blank = xxxfb_blank,647647 .fb_pan_display = xxxfb_pan_display,648648- .fb_fillrect = xxxfb_fillrect, /* Needed !!! */649649- .fb_copyarea = xxxfb_copyarea, /* Obsolete */650650- .fb_imageblit = xxxfb_imageblit, /* Needed !!! */648648+ .fb_fillrect = xxxfb_fillrect, /* Needed !!! */649649+ .fb_copyarea = xxxfb_copyarea, /* Needed !!! */650650+ .fb_imageblit = xxxfb_imageblit, /* Needed !!! */651651 .fb_cursor = xxxfb_cursor, /* Optional !!! */652652 .fb_sync = xxxfb_sync,653653 .fb_ioctl = xxxfb_ioctl,
+4-5
fs/9p/fid.c
···9696 dentry, dentry, from_kuid(&init_user_ns, uid),9797 any);9898 ret = NULL;9999-100100- if (d_inode(dentry))101101- ret = v9fs_fid_find_inode(d_inode(dentry), uid);102102-10399 /* we'll recheck under lock if there's anything to look in */104104- if (!ret && dentry->d_fsdata) {100100+ if (dentry->d_fsdata) {105101 struct hlist_head *h = (struct hlist_head *)&dentry->d_fsdata;106102107103 spin_lock(&dentry->d_lock);···109113 }110114 }111115 spin_unlock(&dentry->d_lock);116116+ } else {117117+ if (dentry->d_inode)118118+ ret = v9fs_fid_find_inode(dentry->d_inode, uid);112119 }113120114121 return ret;
+2-2
fs/Kconfig
···369369370370config SMBFS_COMMON371371 tristate372372- default y if CIFS=y373373- default m if CIFS=m372372+ default y if CIFS=y || SMB_SERVER=y373373+ default m if CIFS=m || SMB_SERVER=m374374375375source "fs/coda/Kconfig"376376source "fs/afs/Kconfig"
+1-5
fs/binfmt_misc.c
···817817};818818MODULE_ALIAS_FS("binfmt_misc");819819820820-static struct ctl_table_header *binfmt_misc_header;821821-822820static int __init init_misc_binfmt(void)823821{824822 int err = register_filesystem(&bm_fs_type);825823 if (!err)826824 insert_binfmt(&misc_format);827827- binfmt_misc_header = register_sysctl_mount_point("fs/binfmt_misc");828828- return 0;825825+ return err;829826}830827831828static void __exit exit_misc_binfmt(void)832829{833833- unregister_sysctl_table(binfmt_misc_header);834830 unregister_binfmt(&misc_format);835831 unregister_filesystem(&bm_fs_type);836832}
+37-2
fs/btrfs/block-group.c
···124124{125125 if (refcount_dec_and_test(&cache->refs)) {126126 WARN_ON(cache->pinned > 0);127127- WARN_ON(cache->reserved > 0);127127+ /*128128+ * If there was a failure to cleanup a log tree, very likely due129129+ * to an IO failure on a writeback attempt of one or more of its130130+ * extent buffers, we could not do proper (and cheap) unaccounting131131+ * of their reserved space, so don't warn on reserved > 0 in that132132+ * case.133133+ */134134+ if (!(cache->flags & BTRFS_BLOCK_GROUP_METADATA) ||135135+ !BTRFS_FS_LOG_CLEANUP_ERROR(cache->fs_info))136136+ WARN_ON(cache->reserved > 0);128137129138 /*130139 * A block_group shouldn't be on the discard_list anymore.···25532544 int ret;25542545 bool dirty_bg_running;2555254625472547+ /*25482548+ * This can only happen when we are doing read-only scrub on read-only25492549+ * mount.25502550+ * In that case we should not start a new transaction on read-only fs.25512551+ * Thus here we skip all chunk allocations.25522552+ */25532553+ if (sb_rdonly(fs_info->sb)) {25542554+ mutex_lock(&fs_info->ro_block_group_mutex);25552555+ ret = inc_block_group_ro(cache, 0);25562556+ mutex_unlock(&fs_info->ro_block_group_mutex);25572557+ return ret;25582558+ }25592559+25562560 do {25572561 trans = btrfs_join_transaction(root);25582562 if (IS_ERR(trans))···39963974 * important and indicates a real bug if this happens.39973975 */39983976 if (WARN_ON(space_info->bytes_pinned > 0 ||39993999- space_info->bytes_reserved > 0 ||40003977 space_info->bytes_may_use > 0))40013978 btrfs_dump_space_info(info, space_info, 0, 0);39793979+39803980+ /*39813981+ * If there was a failure to cleanup a log tree, very likely due39823982+ * to an IO failure on a writeback attempt of one or more of its39833983+ * extent buffers, we could not do proper (and cheap) unaccounting39843984+ * of their reserved space, so don't warn on bytes_reserved > 0 in39853985+ * that case.39863986+ */39873987+ if (!(space_info->flags & BTRFS_BLOCK_GROUP_METADATA) ||39883988+ !BTRFS_FS_LOG_CLEANUP_ERROR(info)) {39893989+ if (WARN_ON(space_info->bytes_reserved > 0))39903990+ btrfs_dump_space_info(info, space_info, 0, 0);39913991+ }39923992+40023993 WARN_ON(space_info->reclaim_size > 0);40033994 list_del(&space_info->list);40043995 btrfs_sysfs_remove_space_info(space_info);
+6
fs/btrfs/ctree.h
···145145 BTRFS_FS_STATE_DUMMY_FS_INFO,146146147147 BTRFS_FS_STATE_NO_CSUMS,148148+149149+ /* Indicates there was an error cleaning up a log tree. */150150+ BTRFS_FS_STATE_LOG_CLEANUP_ERROR,148151};149152150153#define BTRFS_BACKREF_REV_MAX 256···3596359335973594#define BTRFS_FS_ERROR(fs_info) (unlikely(test_bit(BTRFS_FS_STATE_ERROR, \35983595 &(fs_info)->fs_state)))35963596+#define BTRFS_FS_LOG_CLEANUP_ERROR(fs_info) \35973597+ (unlikely(test_bit(BTRFS_FS_STATE_LOG_CLEANUP_ERROR, \35983598+ &(fs_info)->fs_state)))3599359936003600__printf(5, 6)36013601__cold
+2-5
fs/btrfs/ioctl.c
···805805 goto fail;806806 }807807808808- spin_lock(&fs_info->trans_lock);809809- list_add(&pending_snapshot->list,810810- &trans->transaction->pending_snapshots);811811- spin_unlock(&fs_info->trans_lock);808808+ trans->pending_snapshot = pending_snapshot;812809813810 ret = btrfs_commit_transaction(trans);814811 if (ret)···33513354 struct block_device *bdev = NULL;33523355 fmode_t mode;33533356 int ret;33543354- bool cancel;33573357+ bool cancel = false;3355335833563359 if (!capable(CAP_SYS_ADMIN))33573360 return -EPERM;
+19-2
fs/btrfs/qgroup.c
···11851185 struct btrfs_trans_handle *trans = NULL;11861186 int ret = 0;1187118711881188+ /*11891189+ * We need to have subvol_sem write locked, to prevent races between11901190+ * concurrent tasks trying to disable quotas, because we will unlock11911191+ * and relock qgroup_ioctl_lock across BTRFS_FS_QUOTA_ENABLED changes.11921192+ */11931193+ lockdep_assert_held_write(&fs_info->subvol_sem);11941194+11881195 mutex_lock(&fs_info->qgroup_ioctl_lock);11891196 if (!fs_info->quota_root)11901197 goto out;11981198+11991199+ /*12001200+ * Request qgroup rescan worker to complete and wait for it. This wait12011201+ * must be done before transaction start for quota disable since it may12021202+ * deadlock with transaction by the qgroup rescan worker.12031203+ */12041204+ clear_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags);12051205+ btrfs_qgroup_wait_for_completion(fs_info, false);11911206 mutex_unlock(&fs_info->qgroup_ioctl_lock);1192120711931208 /*···12201205 if (IS_ERR(trans)) {12211206 ret = PTR_ERR(trans);12221207 trans = NULL;12081208+ set_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags);12231209 goto out;12241210 }1225121112261212 if (!fs_info->quota_root)12271213 goto out;1228121412291229- clear_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags);12301230- btrfs_qgroup_wait_for_completion(fs_info, false);12311215 spin_lock(&fs_info->qgroup_lock);12321216 quota_root = fs_info->quota_root;12331217 fs_info->quota_root = NULL;···33973383 btrfs_warn(fs_info,33983384 "qgroup rescan init failed, qgroup is not enabled");33993385 ret = -EINVAL;33863386+ } else if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags)) {33873387+ /* Quota disable is in progress */33883388+ ret = -EBUSY;34003389 }3401339034023391 if (ret) {
+24
fs/btrfs/transaction.c
···20002000 btrfs_wait_ordered_roots(fs_info, U64_MAX, 0, (u64)-1);20012001}2002200220032003+/*20042004+ * Add a pending snapshot associated with the given transaction handle to the20052005+ * respective handle. This must be called after the transaction commit started20062006+ * and while holding fs_info->trans_lock.20072007+ * This serves to guarantee a caller of btrfs_commit_transaction() that it can20082008+ * safely free the pending snapshot pointer in case btrfs_commit_transaction()20092009+ * returns an error.20102010+ */20112011+static void add_pending_snapshot(struct btrfs_trans_handle *trans)20122012+{20132013+ struct btrfs_transaction *cur_trans = trans->transaction;20142014+20152015+ if (!trans->pending_snapshot)20162016+ return;20172017+20182018+ lockdep_assert_held(&trans->fs_info->trans_lock);20192019+ ASSERT(cur_trans->state >= TRANS_STATE_COMMIT_START);20202020+20212021+ list_add(&trans->pending_snapshot->list, &cur_trans->pending_snapshots);20222022+}20232023+20032024int btrfs_commit_transaction(struct btrfs_trans_handle *trans)20042025{20052026 struct btrfs_fs_info *fs_info = trans->fs_info;···20932072 spin_lock(&fs_info->trans_lock);20942073 if (cur_trans->state >= TRANS_STATE_COMMIT_START) {20952074 enum btrfs_trans_state want_state = TRANS_STATE_COMPLETED;20752075+20762076+ add_pending_snapshot(trans);2096207720972078 spin_unlock(&fs_info->trans_lock);20982079 refcount_inc(&cur_trans->use_count);···21862163 * COMMIT_DOING so make sure to wait for num_writers to == 1 again.21872164 */21882165 spin_lock(&fs_info->trans_lock);21662166+ add_pending_snapshot(trans);21892167 cur_trans->state = TRANS_STATE_COMMIT_DOING;21902168 spin_unlock(&fs_info->trans_lock);21912169 wait_event(cur_trans->writer_wait,
+2
fs/btrfs/transaction.h
···123123 struct btrfs_transaction *transaction;124124 struct btrfs_block_rsv *block_rsv;125125 struct btrfs_block_rsv *orig_rsv;126126+ /* Set by a task that wants to create a snapshot. */127127+ struct btrfs_pending_snapshot *pending_snapshot;126128 refcount_t use_count;127129 unsigned int type;128130 /*
···34143414 if (log->node) {34153415 ret = walk_log_tree(trans, log, &wc);34163416 if (ret) {34173417+ /*34183418+ * We weren't able to traverse the entire log tree, the34193419+ * typical scenario is getting an -EIO when reading an34203420+ * extent buffer of the tree, due to a previous writeback34213421+ * failure of it.34223422+ */34233423+ set_bit(BTRFS_FS_STATE_LOG_CLEANUP_ERROR,34243424+ &log->fs_info->fs_state);34253425+34263426+ /*34273427+ * Some extent buffers of the log tree may still be dirty34283428+ * and not yet written back to storage, because we may34293429+ * have updates to a log tree without syncing a log tree,34303430+ * such as during rename and link operations. So flush34313431+ * them out and wait for their writeback to complete, so34323432+ * that we properly cleanup their state and pages.34333433+ */34343434+ btrfs_write_marked_extents(log->fs_info,34353435+ &log->dirty_log_pages,34363436+ EXTENT_DIRTY | EXTENT_NEW);34373437+ btrfs_wait_tree_log_extents(log,34383438+ EXTENT_DIRTY | EXTENT_NEW);34393439+34173440 if (trans)34183441 btrfs_abort_transaction(trans, ret);34193442 else
+59
fs/cachefiles/io.c
···192192}193193194194/*195195+ * Query the occupancy of the cache in a region, returning where the next chunk196196+ * of data starts and how long it is.197197+ */198198+static int cachefiles_query_occupancy(struct netfs_cache_resources *cres,199199+ loff_t start, size_t len, size_t granularity,200200+ loff_t *_data_start, size_t *_data_len)201201+{202202+ struct cachefiles_object *object;203203+ struct file *file;204204+ loff_t off, off2;205205+206206+ *_data_start = -1;207207+ *_data_len = 0;208208+209209+ if (!fscache_wait_for_operation(cres, FSCACHE_WANT_READ))210210+ return -ENOBUFS;211211+212212+ object = cachefiles_cres_object(cres);213213+ file = cachefiles_cres_file(cres);214214+ granularity = max_t(size_t, object->volume->cache->bsize, granularity);215215+216216+ _enter("%pD,%li,%llx,%zx/%llx",217217+ file, file_inode(file)->i_ino, start, len,218218+ i_size_read(file_inode(file)));219219+220220+ off = cachefiles_inject_read_error();221221+ if (off == 0)222222+ off = vfs_llseek(file, start, SEEK_DATA);223223+ if (off == -ENXIO)224224+ return -ENODATA; /* Beyond EOF */225225+ if (off < 0 && off >= (loff_t)-MAX_ERRNO)226226+ return -ENOBUFS; /* Error. */227227+ if (round_up(off, granularity) >= start + len)228228+ return -ENODATA; /* No data in range */229229+230230+ off2 = cachefiles_inject_read_error();231231+ if (off2 == 0)232232+ off2 = vfs_llseek(file, off, SEEK_HOLE);233233+ if (off2 == -ENXIO)234234+ return -ENODATA; /* Beyond EOF */235235+ if (off2 < 0 && off2 >= (loff_t)-MAX_ERRNO)236236+ return -ENOBUFS; /* Error. */237237+238238+ /* Round away partial blocks */239239+ off = round_up(off, granularity);240240+ off2 = round_down(off2, granularity);241241+ if (off2 <= off)242242+ return -ENODATA;243243+244244+ *_data_start = off;245245+ if (off2 > start + len)246246+ *_data_len = len;247247+ else248248+ *_data_len = off2 - off;249249+ return 0;250250+}251251+252252+/*195253 * Handle completion of a write to the cache.196254 */197255static void cachefiles_write_complete(struct kiocb *iocb, long ret)···603545 .write = cachefiles_write,604546 .prepare_read = cachefiles_prepare_read,605547 .prepare_write = cachefiles_prepare_write,548548+ .query_occupancy = cachefiles_query_occupancy,606549};607550608551/*
+16-7
fs/cifs/connect.c
···162162 mutex_unlock(&server->srv_mutex);163163}164164165165-/**165165+/*166166 * Mark all sessions and tcons for reconnect.167167 *168168 * @server needs to be previously set to CifsNeedReconnect.···18311831 int i;1832183218331833 for (i = 1; i < chan_count; i++) {18341834- /*18351835- * note: for now, we're okay accessing ses->chans18361836- * without chan_lock. But when chans can go away, we'll18371837- * need to introduce ref counting to make sure that chan18381838- * is not freed from under us.18391839- */18341834+ spin_unlock(&ses->chan_lock);18401835 cifs_put_tcp_session(ses->chans[i].server, 0);18361836+ spin_lock(&ses->chan_lock);18411837 ses->chans[i].server = NULL;18421838 }18431839 }···19751979 ctx->password = NULL;19761980 goto out_key_put;19771981 }19821982+ }19831983+19841984+ ctx->workstation_name = kstrdup(ses->workstation_name, GFP_KERNEL);19851985+ if (!ctx->workstation_name) {19861986+ cifs_dbg(FYI, "Unable to allocate memory for workstation_name\n");19871987+ rc = -ENOMEM;19881988+ kfree(ctx->username);19891989+ ctx->username = NULL;19901990+ kfree_sensitive(ctx->password);19911991+ ctx->password = NULL;19921992+ kfree(ctx->domainname);19931993+ ctx->domainname = NULL;19941994+ goto out_key_put;19781995 }1979199619801997out_key_put:
+83-140
fs/cifs/file.c
···42694269 for (i = 0; i < rdata->nr_pages; i++) {42704270 struct page *page = rdata->pages[i];4271427142724272- lru_cache_add(page);42734273-42744272 if (rdata->result == 0 ||42754273 (rdata->result == -EAGAIN && got_bytes)) {42764274 flush_dcache_page(page);···42764278 } else42774279 SetPageError(page);4278428042794279- unlock_page(page);42804280-42814281 if (rdata->result == 0 ||42824282 (rdata->result == -EAGAIN && got_bytes))42834283 cifs_readpage_to_fscache(rdata->mapping->host, page);42844284+42854285+ unlock_page(page);4284428642854287 got_bytes -= min_t(unsigned int, PAGE_SIZE, got_bytes);42864288···43384340 * fill them until the writes are flushed.43394341 */43404342 zero_user(page, 0, PAGE_SIZE);43414341- lru_cache_add(page);43424343 flush_dcache_page(page);43434344 SetPageUptodate(page);43444345 unlock_page(page);···43474350 continue;43484351 } else {43494352 /* no need to hold page hostage */43504350- lru_cache_add(page);43514353 unlock_page(page);43524354 put_page(page);43534355 rdata->pages[i] = NULL;···43894393 return readpages_fill_pages(server, rdata, iter, iter->count);43904394}4391439543924392-static int43934393-readpages_get_pages(struct address_space *mapping, struct list_head *page_list,43944394- unsigned int rsize, struct list_head *tmplist,43954395- unsigned int *nr_pages, loff_t *offset, unsigned int *bytes)43964396-{43974397- struct page *page, *tpage;43984398- unsigned int expected_index;43994399- int rc;44004400- gfp_t gfp = readahead_gfp_mask(mapping);44014401-44024402- INIT_LIST_HEAD(tmplist);44034403-44044404- page = lru_to_page(page_list);44054405-44064406- /*44074407- * Lock the page and put it in the cache. Since no one else44084408- * should have access to this page, we're safe to simply set44094409- * PG_locked without checking it first.44104410- */44114411- __SetPageLocked(page);44124412- rc = add_to_page_cache_locked(page, mapping,44134413- page->index, gfp);44144414-44154415- /* give up if we can't stick it in the cache */44164416- if (rc) {44174417- __ClearPageLocked(page);44184418- return rc;44194419- }44204420-44214421- /* move first page to the tmplist */44224422- *offset = (loff_t)page->index << PAGE_SHIFT;44234423- *bytes = PAGE_SIZE;44244424- *nr_pages = 1;44254425- list_move_tail(&page->lru, tmplist);44264426-44274427- /* now try and add more pages onto the request */44284428- expected_index = page->index + 1;44294429- list_for_each_entry_safe_reverse(page, tpage, page_list, lru) {44304430- /* discontinuity ? */44314431- if (page->index != expected_index)44324432- break;44334433-44344434- /* would this page push the read over the rsize? */44354435- if (*bytes + PAGE_SIZE > rsize)44364436- break;44374437-44384438- __SetPageLocked(page);44394439- rc = add_to_page_cache_locked(page, mapping, page->index, gfp);44404440- if (rc) {44414441- __ClearPageLocked(page);44424442- break;44434443- }44444444- list_move_tail(&page->lru, tmplist);44454445- (*bytes) += PAGE_SIZE;44464446- expected_index++;44474447- (*nr_pages)++;44484448- }44494449- return rc;44504450-}44514451-44524452-static int cifs_readpages(struct file *file, struct address_space *mapping,44534453- struct list_head *page_list, unsigned num_pages)43964396+static void cifs_readahead(struct readahead_control *ractl)44544397{44554398 int rc;44564456- int err = 0;44574457- struct list_head tmplist;44584458- struct cifsFileInfo *open_file = file->private_data;44594459- struct cifs_sb_info *cifs_sb = CIFS_FILE_SB(file);43994399+ struct cifsFileInfo *open_file = ractl->file->private_data;44004400+ struct cifs_sb_info *cifs_sb = CIFS_FILE_SB(ractl->file);44604401 struct TCP_Server_Info *server;44614402 pid_t pid;44624462- unsigned int xid;44034403+ unsigned int xid, nr_pages, last_batch_size = 0, cache_nr_pages = 0;44044404+ pgoff_t next_cached = ULONG_MAX;44054405+ bool caching = fscache_cookie_enabled(cifs_inode_cookie(ractl->mapping->host)) &&44064406+ cifs_inode_cookie(ractl->mapping->host)->cache_priv;44074407+ bool check_cache = caching;4463440844644409 xid = get_xid();44654465- /*44664466- * Reads as many pages as possible from fscache. Returns -ENOBUFS44674467- * immediately if the cookie is negative44684468- *44694469- * After this point, every page in the list might have PG_fscache set,44704470- * so we will need to clean that up off of every page we don't use.44714471- */44724472- rc = cifs_readpages_from_fscache(mapping->host, mapping, page_list,44734473- &num_pages);44744474- if (rc == 0) {44754475- free_xid(xid);44764476- return rc;44774477- }4478441044794411 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD)44804412 pid = open_file->pid;···44134489 server = cifs_pick_channel(tlink_tcon(open_file->tlink)->ses);4414449044154491 cifs_dbg(FYI, "%s: file=%p mapping=%p num_pages=%u\n",44164416- __func__, file, mapping, num_pages);44924492+ __func__, ractl->file, ractl->mapping, readahead_count(ractl));4417449344184494 /*44194419- * Start with the page at end of list and move it to private44204420- * list. Do the same with any following pages until we hit44214421- * the rsize limit, hit an index discontinuity, or run out of44224422- * pages. Issue the async read and then start the loop again44234423- * until the list is empty.44244424- *44254425- * Note that list order is important. The page_list is in44264426- * the order of declining indexes. When we put the pages in44274427- * the rdata->pages, then we want them in increasing order.44954495+ * Chop the readahead request up into rsize-sized read requests.44284496 */44294429- while (!list_empty(page_list) && !err) {44304430- unsigned int i, nr_pages, bytes, rsize;44314431- loff_t offset;44324432- struct page *page, *tpage;44974497+ while ((nr_pages = readahead_count(ractl) - last_batch_size)) {44984498+ unsigned int i, got, rsize;44994499+ struct page *page;44334500 struct cifs_readdata *rdata;44344501 struct cifs_credits credits_on_stack;44354502 struct cifs_credits *credits = &credits_on_stack;45034503+ pgoff_t index = readahead_index(ractl) + last_batch_size;45044504+45054505+ /*45064506+ * Find out if we have anything cached in the range of45074507+ * interest, and if so, where the next chunk of cached data is.45084508+ */45094509+ if (caching) {45104510+ if (check_cache) {45114511+ rc = cifs_fscache_query_occupancy(45124512+ ractl->mapping->host, index, nr_pages,45134513+ &next_cached, &cache_nr_pages);45144514+ if (rc < 0)45154515+ caching = false;45164516+ check_cache = false;45174517+ }45184518+45194519+ if (index == next_cached) {45204520+ /*45214521+ * TODO: Send a whole batch of pages to be read45224522+ * by the cache.45234523+ */45244524+ page = readahead_page(ractl);45254525+ last_batch_size = 1 << thp_order(page);45264526+ if (cifs_readpage_from_fscache(ractl->mapping->host,45274527+ page) < 0) {45284528+ /*45294529+ * TODO: Deal with cache read failure45304530+ * here, but for the moment, delegate45314531+ * that to readpage.45324532+ */45334533+ caching = false;45344534+ }45354535+ unlock_page(page);45364536+ next_cached++;45374537+ cache_nr_pages--;45384538+ if (cache_nr_pages == 0)45394539+ check_cache = true;45404540+ continue;45414541+ }45424542+ }4436454344374544 if (open_file->invalidHandle) {44384545 rc = cifs_reopen_file(open_file, true);44394439- if (rc == -EAGAIN)44404440- continue;44414441- else if (rc)45464546+ if (rc) {45474547+ if (rc == -EAGAIN)45484548+ continue;44424549 break;45504550+ }44434551 }4444455244454553 rc = server->ops->wait_mtu_credits(server, cifs_sb->ctx->rsize,44464554 &rsize, credits);44474555 if (rc)44484556 break;45574557+ nr_pages = min_t(size_t, rsize / PAGE_SIZE, readahead_count(ractl));45584558+ nr_pages = min_t(size_t, nr_pages, next_cached - index);4449455944504560 /*44514561 * Give up immediately if rsize is too small to read an entire···44874529 * reach this point however since we set ra_pages to 0 when the44884530 * rsize is smaller than a cache page.44894531 */44904490- if (unlikely(rsize < PAGE_SIZE)) {44914491- add_credits_and_wake_if(server, credits, 0);44924492- free_xid(xid);44934493- return 0;44944494- }44954495-44964496- nr_pages = 0;44974497- err = readpages_get_pages(mapping, page_list, rsize, &tmplist,44984498- &nr_pages, &offset, &bytes);44994499- if (!nr_pages) {45324532+ if (unlikely(!nr_pages)) {45004533 add_credits_and_wake_if(server, credits, 0);45014534 break;45024535 }···44954546 rdata = cifs_readdata_alloc(nr_pages, cifs_readv_complete);44964547 if (!rdata) {44974548 /* best to give up if we're out of mem */44984498- list_for_each_entry_safe(page, tpage, &tmplist, lru) {44994499- list_del(&page->lru);45004500- lru_cache_add(page);45014501- unlock_page(page);45024502- put_page(page);45034503- }45044504- rc = -ENOMEM;45054549 add_credits_and_wake_if(server, credits, 0);45064550 break;45074551 }4508455245094509- rdata->cfile = cifsFileInfo_get(open_file);45104510- rdata->server = server;45114511- rdata->mapping = mapping;45124512- rdata->offset = offset;45134513- rdata->bytes = bytes;45144514- rdata->pid = pid;45154515- rdata->pagesz = PAGE_SIZE;45164516- rdata->tailsz = PAGE_SIZE;45174517- rdata->read_into_pages = cifs_readpages_read_into_pages;45184518- rdata->copy_into_pages = cifs_readpages_copy_into_pages;45194519- rdata->credits = credits_on_stack;45204520-45214521- list_for_each_entry_safe(page, tpage, &tmplist, lru) {45224522- list_del(&page->lru);45234523- rdata->pages[rdata->nr_pages++] = page;45534553+ got = __readahead_batch(ractl, rdata->pages, nr_pages);45544554+ if (got != nr_pages) {45554555+ pr_warn("__readahead_batch() returned %u/%u\n",45564556+ got, nr_pages);45574557+ nr_pages = got;45244558 }4525455945264526- rc = adjust_credits(server, &rdata->credits, rdata->bytes);45604560+ rdata->nr_pages = nr_pages;45614561+ rdata->bytes = readahead_batch_length(ractl);45624562+ rdata->cfile = cifsFileInfo_get(open_file);45634563+ rdata->server = server;45644564+ rdata->mapping = ractl->mapping;45654565+ rdata->offset = readahead_pos(ractl);45664566+ rdata->pid = pid;45674567+ rdata->pagesz = PAGE_SIZE;45684568+ rdata->tailsz = PAGE_SIZE;45694569+ rdata->read_into_pages = cifs_readpages_read_into_pages;45704570+ rdata->copy_into_pages = cifs_readpages_copy_into_pages;45714571+ rdata->credits = credits_on_stack;4527457245734573+ rc = adjust_credits(server, &rdata->credits, rdata->bytes);45284574 if (!rc) {45294575 if (rdata->cfile->invalidHandle)45304576 rc = -EAGAIN;···45314587 add_credits_and_wake_if(server, &rdata->credits, 0);45324588 for (i = 0; i < rdata->nr_pages; i++) {45334589 page = rdata->pages[i];45344534- lru_cache_add(page);45354590 unlock_page(page);45364591 put_page(page);45374592 }···45404597 }4541459845424599 kref_put(&rdata->refcount, cifs_readdata_release);46004600+ last_batch_size = nr_pages;45434601 }4544460245454603 free_xid(xid);45464546- return rc;45474604}4548460545494606/*···48674924 * In the non-cached mode (mount with cache=none), we shunt off direct read and write requests48684925 * so this method should never be called.48694926 *48704870- * Direct IO is not yet supported in the cached mode. 49274927+ * Direct IO is not yet supported in the cached mode.48714928 */48724929static ssize_t48734930cifs_direct_io(struct kiocb *iocb, struct iov_iter *iter)···4949500649505007const struct address_space_operations cifs_addr_ops = {49515008 .readpage = cifs_readpage,49524952- .readpages = cifs_readpages,50095009+ .readahead = cifs_readahead,49535010 .writepage = cifs_writepage,49545011 .writepages = cifs_writepages,49555012 .write_begin = cifs_write_begin,
+111-21
fs/cifs/fscache.c
···134134 }135135}136136137137+static inline void fscache_end_operation(struct netfs_cache_resources *cres)138138+{139139+ const struct netfs_cache_ops *ops = fscache_operation_valid(cres);140140+141141+ if (ops)142142+ ops->end_operation(cres);143143+}144144+145145+/*146146+ * Fallback page reading interface.147147+ */148148+static int fscache_fallback_read_page(struct inode *inode, struct page *page)149149+{150150+ struct netfs_cache_resources cres;151151+ struct fscache_cookie *cookie = cifs_inode_cookie(inode);152152+ struct iov_iter iter;153153+ struct bio_vec bvec[1];154154+ int ret;155155+156156+ memset(&cres, 0, sizeof(cres));157157+ bvec[0].bv_page = page;158158+ bvec[0].bv_offset = 0;159159+ bvec[0].bv_len = PAGE_SIZE;160160+ iov_iter_bvec(&iter, READ, bvec, ARRAY_SIZE(bvec), PAGE_SIZE);161161+162162+ ret = fscache_begin_read_operation(&cres, cookie);163163+ if (ret < 0)164164+ return ret;165165+166166+ ret = fscache_read(&cres, page_offset(page), &iter, NETFS_READ_HOLE_FAIL,167167+ NULL, NULL);168168+ fscache_end_operation(&cres);169169+ return ret;170170+}171171+172172+/*173173+ * Fallback page writing interface.174174+ */175175+static int fscache_fallback_write_page(struct inode *inode, struct page *page,176176+ bool no_space_allocated_yet)177177+{178178+ struct netfs_cache_resources cres;179179+ struct fscache_cookie *cookie = cifs_inode_cookie(inode);180180+ struct iov_iter iter;181181+ struct bio_vec bvec[1];182182+ loff_t start = page_offset(page);183183+ size_t len = PAGE_SIZE;184184+ int ret;185185+186186+ memset(&cres, 0, sizeof(cres));187187+ bvec[0].bv_page = page;188188+ bvec[0].bv_offset = 0;189189+ bvec[0].bv_len = PAGE_SIZE;190190+ iov_iter_bvec(&iter, WRITE, bvec, ARRAY_SIZE(bvec), PAGE_SIZE);191191+192192+ ret = fscache_begin_write_operation(&cres, cookie);193193+ if (ret < 0)194194+ return ret;195195+196196+ ret = cres.ops->prepare_write(&cres, &start, &len, i_size_read(inode),197197+ no_space_allocated_yet);198198+ if (ret == 0)199199+ ret = fscache_write(&cres, page_offset(page), &iter, NULL, NULL);200200+ fscache_end_operation(&cres);201201+ return ret;202202+}203203+137204/*138205 * Retrieve a page from FS-Cache139206 */140207int __cifs_readpage_from_fscache(struct inode *inode, struct page *page)141208{142142- cifs_dbg(FYI, "%s: (fsc:%p, p:%p, i:0x%p\n",143143- __func__, CIFS_I(inode)->fscache, page, inode);144144- return -ENOBUFS; // Needs conversion to using netfslib145145-}209209+ int ret;146210147147-/*148148- * Retrieve a set of pages from FS-Cache149149- */150150-int __cifs_readpages_from_fscache(struct inode *inode,151151- struct address_space *mapping,152152- struct list_head *pages,153153- unsigned *nr_pages)154154-{155155- cifs_dbg(FYI, "%s: (0x%p/%u/0x%p)\n",156156- __func__, CIFS_I(inode)->fscache, *nr_pages, inode);157157- return -ENOBUFS; // Needs conversion to using netfslib211211+ cifs_dbg(FYI, "%s: (fsc:%p, p:%p, i:0x%p\n",212212+ __func__, cifs_inode_cookie(inode), page, inode);213213+214214+ ret = fscache_fallback_read_page(inode, page);215215+ if (ret < 0)216216+ return ret;217217+218218+ /* Read completed synchronously */219219+ SetPageUptodate(page);220220+ return 0;158221}159222160223void __cifs_readpage_to_fscache(struct inode *inode, struct page *page)161224{162162- struct cifsInodeInfo *cifsi = CIFS_I(inode);163163-164164- WARN_ON(!cifsi->fscache);165165-166225 cifs_dbg(FYI, "%s: (fsc: %p, p: %p, i: %p)\n",167167- __func__, cifsi->fscache, page, inode);226226+ __func__, cifs_inode_cookie(inode), page, inode);168227169169- // Needs conversion to using netfslib228228+ fscache_fallback_write_page(inode, page, true);229229+}230230+231231+/*232232+ * Query the cache occupancy.233233+ */234234+int __cifs_fscache_query_occupancy(struct inode *inode,235235+ pgoff_t first, unsigned int nr_pages,236236+ pgoff_t *_data_first,237237+ unsigned int *_data_nr_pages)238238+{239239+ struct netfs_cache_resources cres;240240+ struct fscache_cookie *cookie = cifs_inode_cookie(inode);241241+ loff_t start, data_start;242242+ size_t len, data_len;243243+ int ret;244244+245245+ ret = fscache_begin_read_operation(&cres, cookie);246246+ if (ret < 0)247247+ return ret;248248+249249+ start = first * PAGE_SIZE;250250+ len = nr_pages * PAGE_SIZE;251251+ ret = cres.ops->query_occupancy(&cres, start, len, PAGE_SIZE,252252+ &data_start, &data_len);253253+ if (ret == 0) {254254+ *_data_first = data_start / PAGE_SIZE;255255+ *_data_nr_pages = len / PAGE_SIZE;256256+ }257257+258258+ fscache_end_operation(&cres);259259+ return ret;170260}
+50-31
fs/cifs/fscache.h
···99#ifndef _CIFS_FSCACHE_H1010#define _CIFS_FSCACHE_H11111212+#include <linux/swap.h>1213#include <linux/fscache.h>13141415#include "cifsglob.h"···5958}605961606262-extern int cifs_fscache_release_page(struct page *page, gfp_t gfp);6363-extern int __cifs_readpage_from_fscache(struct inode *, struct page *);6464-extern int __cifs_readpages_from_fscache(struct inode *,6565- struct address_space *,6666- struct list_head *,6767- unsigned *);6868-extern void __cifs_readpage_to_fscache(struct inode *, struct page *);6969-7061static inline struct fscache_cookie *cifs_inode_cookie(struct inode *inode)7162{7263 return CIFS_I(inode)->fscache;···7380 i_size_read(inode), flags);7481}75828383+extern int __cifs_fscache_query_occupancy(struct inode *inode,8484+ pgoff_t first, unsigned int nr_pages,8585+ pgoff_t *_data_first,8686+ unsigned int *_data_nr_pages);8787+8888+static inline int cifs_fscache_query_occupancy(struct inode *inode,8989+ pgoff_t first, unsigned int nr_pages,9090+ pgoff_t *_data_first,9191+ unsigned int *_data_nr_pages)9292+{9393+ if (!cifs_inode_cookie(inode))9494+ return -ENOBUFS;9595+ return __cifs_fscache_query_occupancy(inode, first, nr_pages,9696+ _data_first, _data_nr_pages);9797+}9898+9999+extern int __cifs_readpage_from_fscache(struct inode *pinode, struct page *ppage);100100+extern void __cifs_readpage_to_fscache(struct inode *pinode, struct page *ppage);101101+102102+76103static inline int cifs_readpage_from_fscache(struct inode *inode,77104 struct page *page)78105{7979- if (CIFS_I(inode)->fscache)106106+ if (cifs_inode_cookie(inode))80107 return __cifs_readpage_from_fscache(inode, page);8181-8282- return -ENOBUFS;8383-}8484-8585-static inline int cifs_readpages_from_fscache(struct inode *inode,8686- struct address_space *mapping,8787- struct list_head *pages,8888- unsigned *nr_pages)8989-{9090- if (CIFS_I(inode)->fscache)9191- return __cifs_readpages_from_fscache(inode, mapping, pages,9292- nr_pages);93108 return -ENOBUFS;94109}9511096111static inline void cifs_readpage_to_fscache(struct inode *inode,97112 struct page *page)98113{9999- if (PageFsCache(page))114114+ if (cifs_inode_cookie(inode))100115 __cifs_readpage_to_fscache(inode, page);116116+}117117+118118+static inline int cifs_fscache_release_page(struct page *page, gfp_t gfp)119119+{120120+ if (PageFsCache(page)) {121121+ if (current_is_kswapd() || !(gfp & __GFP_FS))122122+ return false;123123+ wait_on_page_fscache(page);124124+ fscache_note_page_release(cifs_inode_cookie(page->mapping->host));125125+ }126126+ return true;101127}102128103129#else /* CONFIG_CIFS_FSCACHE */···135123static inline struct fscache_cookie *cifs_inode_cookie(struct inode *inode) { return NULL; }136124static inline void cifs_invalidate_cache(struct inode *inode, unsigned int flags) {}137125126126+static inline int cifs_fscache_query_occupancy(struct inode *inode,127127+ pgoff_t first, unsigned int nr_pages,128128+ pgoff_t *_data_first,129129+ unsigned int *_data_nr_pages)130130+{131131+ *_data_first = ULONG_MAX;132132+ *_data_nr_pages = 0;133133+ return -ENOBUFS;134134+}135135+138136static inline int139137cifs_readpage_from_fscache(struct inode *inode, struct page *page)140138{141139 return -ENOBUFS;142140}143141144144-static inline int cifs_readpages_from_fscache(struct inode *inode,145145- struct address_space *mapping,146146- struct list_head *pages,147147- unsigned *nr_pages)148148-{149149- return -ENOBUFS;150150-}142142+static inline143143+void cifs_readpage_to_fscache(struct inode *inode, struct page *page) {}151144152152-static inline void cifs_readpage_to_fscache(struct inode *inode,153153- struct page *page) {}145145+static inline int nfs_fscache_release_page(struct page *page, gfp_t gfp)146146+{147147+ return true; /* May release page */148148+}154149155150#endif /* CONFIG_CIFS_FSCACHE */156151
···810810 return false;811811}812812813813-static void z_erofs_decompressqueue_work(struct work_struct *work);814814-static void z_erofs_decompress_kickoff(struct z_erofs_decompressqueue *io,815815- bool sync, int bios)816816-{817817- struct erofs_sb_info *const sbi = EROFS_SB(io->sb);818818-819819- /* wake up the caller thread for sync decompression */820820- if (sync) {821821- unsigned long flags;822822-823823- spin_lock_irqsave(&io->u.wait.lock, flags);824824- if (!atomic_add_return(bios, &io->pending_bios))825825- wake_up_locked(&io->u.wait);826826- spin_unlock_irqrestore(&io->u.wait.lock, flags);827827- return;828828- }829829-830830- if (atomic_add_return(bios, &io->pending_bios))831831- return;832832- /* Use workqueue and sync decompression for atomic contexts only */833833- if (in_atomic() || irqs_disabled()) {834834- queue_work(z_erofs_workqueue, &io->u.work);835835- /* enable sync decompression for readahead */836836- if (sbi->opt.sync_decompress == EROFS_SYNC_DECOMPRESS_AUTO)837837- sbi->opt.sync_decompress = EROFS_SYNC_DECOMPRESS_FORCE_ON;838838- return;839839- }840840- z_erofs_decompressqueue_work(&io->u.work);841841-}842842-843813static bool z_erofs_page_is_invalidated(struct page *page)844814{845815 return !page->mapping && !z_erofs_is_shortlived_page(page);846846-}847847-848848-static void z_erofs_decompressqueue_endio(struct bio *bio)849849-{850850- tagptr1_t t = tagptr_init(tagptr1_t, bio->bi_private);851851- struct z_erofs_decompressqueue *q = tagptr_unfold_ptr(t);852852- blk_status_t err = bio->bi_status;853853- struct bio_vec *bvec;854854- struct bvec_iter_all iter_all;855855-856856- bio_for_each_segment_all(bvec, bio, iter_all) {857857- struct page *page = bvec->bv_page;858858-859859- DBG_BUGON(PageUptodate(page));860860- DBG_BUGON(z_erofs_page_is_invalidated(page));861861-862862- if (err)863863- SetPageError(page);864864-865865- if (erofs_page_is_managed(EROFS_SB(q->sb), page)) {866866- if (!err)867867- SetPageUptodate(page);868868- unlock_page(page);869869- }870870- }871871- z_erofs_decompress_kickoff(q, tagptr_unfold_tags(t), -1);872872- bio_put(bio);873816}874817875818static int z_erofs_decompress_pcluster(struct super_block *sb,···10661123 kvfree(bgq);10671124}1068112511261126+static void z_erofs_decompress_kickoff(struct z_erofs_decompressqueue *io,11271127+ bool sync, int bios)11281128+{11291129+ struct erofs_sb_info *const sbi = EROFS_SB(io->sb);11301130+11311131+ /* wake up the caller thread for sync decompression */11321132+ if (sync) {11331133+ unsigned long flags;11341134+11351135+ spin_lock_irqsave(&io->u.wait.lock, flags);11361136+ if (!atomic_add_return(bios, &io->pending_bios))11371137+ wake_up_locked(&io->u.wait);11381138+ spin_unlock_irqrestore(&io->u.wait.lock, flags);11391139+ return;11401140+ }11411141+11421142+ if (atomic_add_return(bios, &io->pending_bios))11431143+ return;11441144+ /* Use workqueue and sync decompression for atomic contexts only */11451145+ if (in_atomic() || irqs_disabled()) {11461146+ queue_work(z_erofs_workqueue, &io->u.work);11471147+ /* enable sync decompression for readahead */11481148+ if (sbi->opt.sync_decompress == EROFS_SYNC_DECOMPRESS_AUTO)11491149+ sbi->opt.sync_decompress = EROFS_SYNC_DECOMPRESS_FORCE_ON;11501150+ return;11511151+ }11521152+ z_erofs_decompressqueue_work(&io->u.work);11531153+}11541154+10691155static struct page *pickup_page_for_submission(struct z_erofs_pcluster *pcl,10701156 unsigned int nr,10711157 struct page **pagepool,···12701298 WRITE_ONCE(*bypass_qtail, &pcl->next);1271129912721300 qtail[JQ_BYPASS] = &pcl->next;13011301+}13021302+13031303+static void z_erofs_decompressqueue_endio(struct bio *bio)13041304+{13051305+ tagptr1_t t = tagptr_init(tagptr1_t, bio->bi_private);13061306+ struct z_erofs_decompressqueue *q = tagptr_unfold_ptr(t);13071307+ blk_status_t err = bio->bi_status;13081308+ struct bio_vec *bvec;13091309+ struct bvec_iter_all iter_all;13101310+13111311+ bio_for_each_segment_all(bvec, bio, iter_all) {13121312+ struct page *page = bvec->bv_page;13131313+13141314+ DBG_BUGON(PageUptodate(page));13151315+ DBG_BUGON(z_erofs_page_is_invalidated(page));13161316+13171317+ if (err)13181318+ SetPageError(page);13191319+13201320+ if (erofs_page_is_managed(EROFS_SB(q->sb), page)) {13211321+ if (!err)13221322+ SetPageUptodate(page);13231323+ unlock_page(page);13241324+ }13251325+ }13261326+ z_erofs_decompress_kickoff(q, tagptr_unfold_tags(t), -1);13271327+ bio_put(bio);12731328}1274132912751330static void z_erofs_submit_queue(struct super_block *sb,
+7
fs/erofs/zmap.c
···630630 if (endoff >= m.clusterofs) {631631 m.headtype = m.type;632632 map->m_la = (m.lcn << lclusterbits) | m.clusterofs;633633+ /*634634+ * For ztailpacking files, in order to inline data more635635+ * effectively, special EOF lclusters are now supported636636+ * which can have three parts at most.637637+ */638638+ if (ztailpacking && end > inode->i_size)639639+ end = inode->i_size;633640 break;634641 }635642 /* m.lcn should be >= 1 if endoff < m.clusterofs */
+4-4
fs/ext4/acl.c
···139139/*140140 * Inode operation get_posix_acl().141141 *142142- * inode->i_mutex: don't care142142+ * inode->i_rwsem: don't care143143 */144144struct posix_acl *145145ext4_get_acl(struct inode *inode, int type, bool rcu)···183183/*184184 * Set the access or default ACL of an inode.185185 *186186- * inode->i_mutex: down unless called from ext4_new_inode186186+ * inode->i_rwsem: down unless called from ext4_new_inode187187 */188188static int189189__ext4_set_acl(handle_t *handle, struct inode *inode, int type,···271271/*272272 * Initialize the ACLs of a new inode. Called from ext4_new_inode.273273 *274274- * dir->i_mutex: down275275- * inode->i_mutex: up (access to inode is still exclusive)274274+ * dir->i_rwsem: down275275+ * inode->i_rwsem: up (access to inode is still exclusive)276276 */277277int278278ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
+9-8
fs/ext4/ext4.h
···1028102810291029 /*10301030 * Extended attributes can be read independently of the main file10311031- * data. Taking i_mutex even when reading would cause contention10311031+ * data. Taking i_rwsem even when reading would cause contention10321032 * between readers of EAs and writers of regular file data, so10331033 * instead we synchronize on xattr_sem when reading or changing10341034 * EAs.···17501750 spinlock_t s_fc_lock;17511751 struct buffer_head *s_fc_bh;17521752 struct ext4_fc_stats s_fc_stats;17531753+ tid_t s_fc_ineligible_tid;17531754#ifdef CONFIG_EXT4_DEBUG17541755 int s_fc_debug_max_replay;17551756#endif···17961795enum {17971796 EXT4_MF_MNTDIR_SAMPLED,17981797 EXT4_MF_FS_ABORTED, /* Fatal error detected */17991799- EXT4_MF_FC_INELIGIBLE, /* Fast commit ineligible */18001800- EXT4_MF_FC_COMMITTING /* File system underoing a fast18011801- * commit.18021802- */17981798+ EXT4_MF_FC_INELIGIBLE /* Fast commit ineligible */18031799};1804180018051801static inline void ext4_set_mount_flag(struct super_block *sb, int bit)···29242926 struct dentry *dentry);29252927void ext4_fc_track_create(handle_t *handle, struct dentry *dentry);29262928void ext4_fc_track_inode(handle_t *handle, struct inode *inode);29272927-void ext4_fc_mark_ineligible(struct super_block *sb, int reason);29292929+void ext4_fc_mark_ineligible(struct super_block *sb, int reason, handle_t *handle);29282930void ext4_fc_start_update(struct inode *inode);29292931void ext4_fc_stop_update(struct inode *inode);29302932void ext4_fc_del(struct inode *inode);···29332935int ext4_fc_commit(journal_t *journal, tid_t commit_tid);29342936int __init ext4_fc_init_dentry_cache(void);29352937void ext4_fc_destroy_dentry_cache(void);29382938+int ext4_fc_record_regions(struct super_block *sb, int ino,29392939+ ext4_lblk_t lblk, ext4_fsblk_t pblk,29402940+ int len, int replay);2936294129372942/* mballoc.c */29382943extern const struct seq_operations ext4_mb_seq_groups_ops;···34083407#define EXT4_FREECLUSTERS_WATERMARK 034093408#endif3410340934113411-/* Update i_disksize. Requires i_mutex to avoid races with truncate */34103410+/* Update i_disksize. Requires i_rwsem to avoid races with truncate */34123411static inline void ext4_update_i_disksize(struct inode *inode, loff_t newsize)34133412{34143413 WARN_ON_ONCE(S_ISREG(inode->i_mode) &&···34193418 up_write(&EXT4_I(inode)->i_data_sem);34203419}3421342034223422-/* Update i_size, i_disksize. Requires i_mutex to avoid races with truncate */34213421+/* Update i_size, i_disksize. Requires i_rwsem to avoid races with truncate */34233422static inline int ext4_update_inode_size(struct inode *inode, loff_t newsize)34243423{34253424 int changed = 0;
+1-1
fs/ext4/ext4_jbd2.h
···491491/*492492 * This function controls whether or not we should try to go down the493493 * dioread_nolock code paths, which makes it safe to avoid taking494494- * i_mutex for direct I/O reads. This only works for extent-based494494+ * i_rwsem for direct I/O reads. This only works for extent-based495495 * files, and it doesn't work if data journaling is enabled, since the496496 * dioread_nolock code uses b_private to pass information back to the497497 * I/O completion handler, and this conflicts with the jbd's use of
+10-6
fs/ext4/extents.c
···9797 * Drop i_data_sem to avoid deadlock with ext4_map_blocks. At this9898 * moment, get_block can be called only for blocks inside i_size since9999 * page cache has been already dropped and writes are blocked by100100- * i_mutex. So we can safely drop the i_data_sem here.100100+ * i_rwsem. So we can safely drop the i_data_sem here.101101 */102102 BUG_ON(EXT4_JOURNAL(inode) == NULL);103103 ext4_discard_preallocations(inode, 0);···4572457245734573 flags = EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT;4574457445754575- /* Wait all existing dio workers, newcomers will block on i_mutex */45754575+ /* Wait all existing dio workers, newcomers will block on i_rwsem */45764576 inode_dio_wait(inode);4577457745784578 /* Preallocate the range including the unaligned edges */···47384738 goto out;47394739 }4740474047414741- /* Wait all existing dio workers, newcomers will block on i_mutex */47414741+ /* Wait all existing dio workers, newcomers will block on i_rwsem */47424742 inode_dio_wait(inode);4743474347444744 ret = ext4_alloc_file_blocks(file, lblk, max_blocks, new_size, flags);···53345334 ret = PTR_ERR(handle);53355335 goto out_mmap;53365336 }53375337- ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_FALLOC_RANGE);53375337+ ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_FALLOC_RANGE, handle);5338533853395339 down_write(&EXT4_I(inode)->i_data_sem);53405340 ext4_discard_preallocations(inode, 0);···54745474 ret = PTR_ERR(handle);54755475 goto out_mmap;54765476 }54775477- ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_FALLOC_RANGE);54775477+ ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_FALLOC_RANGE, handle);5478547854795479 /* Expand file to avoid data loss if there is error while shifting */54805480 inode->i_size += len;···55715571 * stuff such as page-cache locking consistency, bh mapping consistency or55725572 * extent's data copying must be performed by caller.55735573 * Locking:55745574- * i_mutex is held for both inodes55745574+ * i_rwsem is held for both inodes55755575 * i_data_sem is locked for write for both inodes55765576 * Assumptions:55775577 * All pages from requested range are locked for both inodes···6091609160926092 ext4_mb_mark_bb(inode->i_sb,60936093 path[j].p_block, 1, 0);60946094+ ext4_fc_record_regions(inode->i_sb, inode->i_ino,60956095+ 0, path[j].p_block, 1, 1);60946096 }60956097 ext4_ext_drop_refs(path);60966098 kfree(path);60976099 }60986100 ext4_mb_mark_bb(inode->i_sb, map.m_pblk, map.m_len, 0);61016101+ ext4_fc_record_regions(inode->i_sb, inode->i_ino,61026102+ map.m_lblk, map.m_pblk, map.m_len, 1);60996103 }61006104 cur = cur + map.m_len;61016105 }
+78-55
fs/ext4/fast_commit.c
···300300}301301302302/*303303- * Mark file system as fast commit ineligible. This means that next commit304304- * operation would result in a full jbd2 commit.303303+ * Mark file system as fast commit ineligible, and record latest304304+ * ineligible transaction tid. This means until the recorded305305+ * transaction, commit operation would result in a full jbd2 commit.305306 */306306-void ext4_fc_mark_ineligible(struct super_block *sb, int reason)307307+void ext4_fc_mark_ineligible(struct super_block *sb, int reason, handle_t *handle)307308{308309 struct ext4_sb_info *sbi = EXT4_SB(sb);310310+ tid_t tid;309311310312 if (!test_opt2(sb, JOURNAL_FAST_COMMIT) ||311313 (EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY))312314 return;313315314316 ext4_set_mount_flag(sb, EXT4_MF_FC_INELIGIBLE);317317+ if (handle && !IS_ERR(handle))318318+ tid = handle->h_transaction->t_tid;319319+ else {320320+ read_lock(&sbi->s_journal->j_state_lock);321321+ tid = sbi->s_journal->j_running_transaction ?322322+ sbi->s_journal->j_running_transaction->t_tid : 0;323323+ read_unlock(&sbi->s_journal->j_state_lock);324324+ }325325+ spin_lock(&sbi->s_fc_lock);326326+ if (sbi->s_fc_ineligible_tid < tid)327327+ sbi->s_fc_ineligible_tid = tid;328328+ spin_unlock(&sbi->s_fc_lock);315329 WARN_ON(reason >= EXT4_FC_REASON_MAX);316330 sbi->s_fc_stats.fc_ineligible_reason_count[reason]++;317331}···375361 spin_lock(&sbi->s_fc_lock);376362 if (list_empty(&EXT4_I(inode)->i_fc_list))377363 list_add_tail(&EXT4_I(inode)->i_fc_list,378378- (ext4_test_mount_flag(inode->i_sb, EXT4_MF_FC_COMMITTING)) ?364364+ (sbi->s_journal->j_flags & JBD2_FULL_COMMIT_ONGOING ||365365+ sbi->s_journal->j_flags & JBD2_FAST_COMMIT_ONGOING) ?379366 &sbi->s_fc_q[FC_Q_STAGING] :380367 &sbi->s_fc_q[FC_Q_MAIN]);381368 spin_unlock(&sbi->s_fc_lock);···402387 mutex_unlock(&ei->i_fc_lock);403388 node = kmem_cache_alloc(ext4_fc_dentry_cachep, GFP_NOFS);404389 if (!node) {405405- ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_NOMEM);390390+ ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_NOMEM, NULL);406391 mutex_lock(&ei->i_fc_lock);407392 return -ENOMEM;408393 }···415400 if (!node->fcd_name.name) {416401 kmem_cache_free(ext4_fc_dentry_cachep, node);417402 ext4_fc_mark_ineligible(inode->i_sb,418418- EXT4_FC_REASON_NOMEM);403403+ EXT4_FC_REASON_NOMEM, NULL);419404 mutex_lock(&ei->i_fc_lock);420405 return -ENOMEM;421406 }···429414 node->fcd_name.len = dentry->d_name.len;430415431416 spin_lock(&sbi->s_fc_lock);432432- if (ext4_test_mount_flag(inode->i_sb, EXT4_MF_FC_COMMITTING))417417+ if (sbi->s_journal->j_flags & JBD2_FULL_COMMIT_ONGOING ||418418+ sbi->s_journal->j_flags & JBD2_FAST_COMMIT_ONGOING)433419 list_add_tail(&node->fcd_list,434420 &sbi->s_fc_dentry_q[FC_Q_STAGING]);435421 else···518502519503 if (ext4_should_journal_data(inode)) {520504 ext4_fc_mark_ineligible(inode->i_sb,521521- EXT4_FC_REASON_INODE_JOURNAL_DATA);505505+ EXT4_FC_REASON_INODE_JOURNAL_DATA, handle);522506 return;523507 }524508···895879 int ret = 0;896880897881 spin_lock(&sbi->s_fc_lock);898898- ext4_set_mount_flag(sb, EXT4_MF_FC_COMMITTING);899882 list_for_each_entry(ei, &sbi->s_fc_q[FC_Q_MAIN], i_fc_list) {900883 ext4_set_inode_state(&ei->vfs_inode, EXT4_STATE_FC_COMMITTING);901884 while (atomic_read(&ei->i_fc_updates)) {···11941179 * Fast commit cleanup routine. This is called after every fast commit and11951180 * full commit. full is true if we are called after a full commit.11961181 */11971197-static void ext4_fc_cleanup(journal_t *journal, int full)11821182+static void ext4_fc_cleanup(journal_t *journal, int full, tid_t tid)11981183{11991184 struct super_block *sb = journal->j_private;12001185 struct ext4_sb_info *sbi = EXT4_SB(sb);···12121197 list_del_init(&iter->i_fc_list);12131198 ext4_clear_inode_state(&iter->vfs_inode,12141199 EXT4_STATE_FC_COMMITTING);12151215- ext4_fc_reset_inode(&iter->vfs_inode);12001200+ if (iter->i_sync_tid <= tid)12011201+ ext4_fc_reset_inode(&iter->vfs_inode);12161202 /* Make sure EXT4_STATE_FC_COMMITTING bit is clear */12171203 smp_mb();12181204#if (BITS_PER_LONG < 64)···12421226 list_splice_init(&sbi->s_fc_q[FC_Q_STAGING],12431227 &sbi->s_fc_q[FC_Q_MAIN]);1244122812451245- ext4_clear_mount_flag(sb, EXT4_MF_FC_COMMITTING);12461246- ext4_clear_mount_flag(sb, EXT4_MF_FC_INELIGIBLE);12291229+ if (tid >= sbi->s_fc_ineligible_tid) {12301230+ sbi->s_fc_ineligible_tid = 0;12311231+ ext4_clear_mount_flag(sb, EXT4_MF_FC_INELIGIBLE);12321232+ }1247123312481234 if (full)12491235 sbi->s_fc_bytes = 0;···14101392 if (state->fc_modified_inodes[i] == ino)14111393 return 0;14121394 if (state->fc_modified_inodes_used == state->fc_modified_inodes_size) {14131413- state->fc_modified_inodes_size +=14141414- EXT4_FC_REPLAY_REALLOC_INCREMENT;14151395 state->fc_modified_inodes = krealloc(14161416- state->fc_modified_inodes, sizeof(int) *14171417- state->fc_modified_inodes_size,14181418- GFP_KERNEL);13961396+ state->fc_modified_inodes,13971397+ sizeof(int) * (state->fc_modified_inodes_size +13981398+ EXT4_FC_REPLAY_REALLOC_INCREMENT),13991399+ GFP_KERNEL);14191400 if (!state->fc_modified_inodes)14201401 return -ENOMEM;14021402+ state->fc_modified_inodes_size +=14031403+ EXT4_FC_REPLAY_REALLOC_INCREMENT;14211404 }14221405 state->fc_modified_inodes[state->fc_modified_inodes_used++] = ino;14231406 return 0;···14501431 }14511432 inode = NULL;1452143314531453- ext4_fc_record_modified_inode(sb, ino);14341434+ ret = ext4_fc_record_modified_inode(sb, ino);14351435+ if (ret)14361436+ goto out;1454143714551438 raw_fc_inode = (struct ext4_inode *)14561439 (val + offsetof(struct ext4_fc_inode, fc_raw_inode));···15841563}1585156415861565/*15871587- * Record physical disk regions which are in use as per fast commit area. Our15881588- * simple replay phase allocator excludes these regions from allocation.15661566+ * Record physical disk regions which are in use as per fast commit area,15671567+ * and used by inodes during replay phase. Our simple replay phase15681568+ * allocator excludes these regions from allocation.15891569 */15901590-static int ext4_fc_record_regions(struct super_block *sb, int ino,15911591- ext4_lblk_t lblk, ext4_fsblk_t pblk, int len)15701570+int ext4_fc_record_regions(struct super_block *sb, int ino,15711571+ ext4_lblk_t lblk, ext4_fsblk_t pblk, int len, int replay)15921572{15931573 struct ext4_fc_replay_state *state;15941574 struct ext4_fc_alloc_region *region;1595157515961576 state = &EXT4_SB(sb)->s_fc_replay_state;15771577+ /*15781578+ * during replay phase, the fc_regions_valid may not same as15791579+ * fc_regions_used, update it when do new additions.15801580+ */15811581+ if (replay && state->fc_regions_used != state->fc_regions_valid)15821582+ state->fc_regions_used = state->fc_regions_valid;15971583 if (state->fc_regions_used == state->fc_regions_size) {15981584 state->fc_regions_size +=15991585 EXT4_FC_REPLAY_REALLOC_INCREMENT;···16171589 region->lblk = lblk;16181590 region->pblk = pblk;16191591 region->len = len;15921592+15931593+ if (replay)15941594+ state->fc_regions_valid++;1620159516211596 return 0;16221597}···16521621 }1653162216541623 ret = ext4_fc_record_modified_inode(sb, inode->i_ino);16241624+ if (ret)16251625+ goto out;1655162616561627 start = le32_to_cpu(ex->ee_block);16571628 start_pblk = ext4_ext_pblock(ex);···16711638 map.m_pblk = 0;16721639 ret = ext4_map_blocks(NULL, inode, &map, 0);1673164016741674- if (ret < 0) {16751675- iput(inode);16761676- return 0;16771677- }16411641+ if (ret < 0)16421642+ goto out;1678164316791644 if (ret == 0) {16801645 /* Range is not mapped */16811646 path = ext4_find_extent(inode, cur, NULL, 0);16821682- if (IS_ERR(path)) {16831683- iput(inode);16841684- return 0;16851685- }16471647+ if (IS_ERR(path))16481648+ goto out;16861649 memset(&newex, 0, sizeof(newex));16871650 newex.ee_block = cpu_to_le32(cur);16881651 ext4_ext_store_pblock(···16921663 up_write((&EXT4_I(inode)->i_data_sem));16931664 ext4_ext_drop_refs(path);16941665 kfree(path);16951695- if (ret) {16961696- iput(inode);16971697- return 0;16981698- }16661666+ if (ret)16671667+ goto out;16991668 goto next;17001669 }17011670···17061679 ret = ext4_ext_replay_update_ex(inode, cur, map.m_len,17071680 ext4_ext_is_unwritten(ex),17081681 start_pblk + cur - start);17091709- if (ret) {17101710- iput(inode);17111711- return 0;17121712- }16821682+ if (ret)16831683+ goto out;17131684 /*17141685 * Mark the old blocks as free since they aren't used17151686 * anymore. We maintain an array of all the modified···17271702 ext4_ext_is_unwritten(ex), map.m_pblk);17281703 ret = ext4_ext_replay_update_ex(inode, cur, map.m_len,17291704 ext4_ext_is_unwritten(ex), map.m_pblk);17301730- if (ret) {17311731- iput(inode);17321732- return 0;17331733- }17051705+ if (ret)17061706+ goto out;17341707 /*17351708 * We may have split the extent tree while toggling the state.17361709 * Try to shrink the extent tree now.···17401717 }17411718 ext4_ext_replay_shrink_inode(inode, i_size_read(inode) >>17421719 sb->s_blocksize_bits);17201720+out:17431721 iput(inode);17441722 return 0;17451723}···17701746 }1771174717721748 ret = ext4_fc_record_modified_inode(sb, inode->i_ino);17491749+ if (ret)17501750+ goto out;1773175117741752 jbd_debug(1, "DEL_RANGE, inode %ld, lblk %d, len %d\n",17751753 inode->i_ino, le32_to_cpu(lrange.fc_lblk),···17811755 map.m_len = remaining;1782175617831757 ret = ext4_map_blocks(NULL, inode, &map, 0);17841784- if (ret < 0) {17851785- iput(inode);17861786- return 0;17871787- }17581758+ if (ret < 0)17591759+ goto out;17881760 if (ret > 0) {17891761 remaining -= ret;17901762 cur += ret;···17941770 }1795177117961772 down_write(&EXT4_I(inode)->i_data_sem);17971797- ret = ext4_ext_remove_space(inode, lrange.fc_lblk,17981798- lrange.fc_lblk + lrange.fc_len - 1);17731773+ ret = ext4_ext_remove_space(inode, le32_to_cpu(lrange.fc_lblk),17741774+ le32_to_cpu(lrange.fc_lblk) +17751775+ le32_to_cpu(lrange.fc_len) - 1);17991776 up_write(&EXT4_I(inode)->i_data_sem);18001800- if (ret) {18011801- iput(inode);18021802- return 0;18031803- }17771777+ if (ret)17781778+ goto out;18041779 ext4_ext_replay_shrink_inode(inode,18051780 i_size_read(inode) >> sb->s_blocksize_bits);18061781 ext4_mark_inode_dirty(NULL, inode);17821782+out:18071783 iput(inode);18081808-18091784 return 0;18101785}18111786···19601937 ret = ext4_fc_record_regions(sb,19611938 le32_to_cpu(ext.fc_ino),19621939 le32_to_cpu(ex->ee_block), ext4_ext_pblock(ex),19631963- ext4_ext_get_actual_len(ex));19401940+ ext4_ext_get_actual_len(ex), 0);19641941 if (ret < 0)19651942 break;19661943 ret = JBD2_FC_REPLAY_CONTINUE;
+1-1
fs/ext4/indirect.c
···696696 * Drop i_data_sem to avoid deadlock with ext4_map_blocks. At this697697 * moment, get_block can be called only for blocks inside i_size since698698 * page cache has been already dropped and writes are blocked by699699- * i_mutex. So we can safely drop the i_data_sem here.699699+ * i_rwsem. So we can safely drop the i_data_sem here.700700 */701701 BUG_ON(EXT4_JOURNAL(inode) == NULL);702702 ext4_discard_preallocations(inode, 0);
+13-10
fs/ext4/inline.c
···911911 struct page **pagep,912912 void **fsdata)913913{914914- int ret, inline_size;914914+ int ret;915915 handle_t *handle;916916 struct page *page;917917 struct ext4_iloc iloc;···928928 goto out;929929 }930930931931- inline_size = ext4_get_max_inline_size(inode);932932-933933- ret = -ENOSPC;934934- if (inline_size >= pos + len) {935935- ret = ext4_prepare_inline_data(handle, inode, pos + len);936936- if (ret && ret != -ENOSPC)937937- goto out_journal;938938- }931931+ ret = ext4_prepare_inline_data(handle, inode, pos + len);932932+ if (ret && ret != -ENOSPC)933933+ goto out_journal;939934940935 /*941936 * We cannot recurse into the filesystem as the transaction···11281133 struct ext4_iloc *iloc,11291134 void *buf, int inline_size)11301135{11311131- ext4_create_inline_data(handle, inode, inline_size);11361136+ int ret;11371137+11381138+ ret = ext4_create_inline_data(handle, inode, inline_size);11391139+ if (ret) {11401140+ ext4_msg(inode->i_sb, KERN_EMERG,11411141+ "error restoring inline_data for inode -- potential data loss! (inode %lu, error %d)",11421142+ inode->i_ino, ret);11431143+ return;11441144+ }11321145 ext4_write_inline_data(inode, iloc, buf, 0, inline_size);11331146 ext4_set_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA);11341147}
+6-6
fs/ext4/inode.c
···338338 return;339339no_delete:340340 if (!list_empty(&EXT4_I(inode)->i_fc_list))341341- ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_NOMEM);341341+ ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_NOMEM, NULL);342342 ext4_clear_inode(inode); /* We must guarantee clearing of inode... */343343}344344···12241224 /*12251225 * __block_write_begin may have instantiated a few blocks12261226 * outside i_size. Trim these off again. Don't need12271227- * i_size_read because we hold i_mutex.12271227+ * i_size_read because we hold i_rwsem.12281228 *12291229 * Add inode to orphan list in case we crash before12301230 * truncate finishes···3979397939803980 }3981398139823982- /* Wait all existing dio workers, newcomers will block on i_mutex */39823982+ /* Wait all existing dio workers, newcomers will block on i_rwsem */39833983 inode_dio_wait(inode);3984398439853985 /*···41294129 /*41304130 * There is a possibility that we're either freeing the inode41314131 * or it's a completely new inode. In those cases we might not41324132- * have i_mutex locked because it's not necessary.41324132+ * have i_rwsem locked because it's not necessary.41334133 */41344134 if (!(inode->i_state & (I_NEW|I_FREEING)))41354135 WARN_ON(!inode_is_locked(inode));···52715271 * transaction are already on disk (truncate waits for pages under52725272 * writeback).52735273 *52745274- * Called with inode->i_mutex down.52745274+ * Called with inode->i_rwsem down.52755275 */52765276int ext4_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,52775277 struct iattr *attr)···59835983 return PTR_ERR(handle);5984598459855985 ext4_fc_mark_ineligible(inode->i_sb,59865986- EXT4_FC_REASON_JOURNAL_FLAG_CHANGE);59865986+ EXT4_FC_REASON_JOURNAL_FLAG_CHANGE, handle);59875987 err = ext4_mark_inode_dirty(handle, inode);59885988 ext4_handle_sync(handle);59895989 ext4_journal_stop(handle);
···57535753 struct super_block *sb = ar->inode->i_sb;57545754 ext4_group_t group;57555755 ext4_grpblk_t blkoff;57565756- int i = sb->s_blocksize;57565756+ ext4_grpblk_t max = EXT4_CLUSTERS_PER_GROUP(sb);57575757+ ext4_grpblk_t i = 0;57575758 ext4_fsblk_t goal, block;57585759 struct ext4_super_block *es = EXT4_SB(sb)->s_es;57595760···57765775 ext4_get_group_no_and_offset(sb,57775776 max(ext4_group_first_block_no(sb, group), goal),57785777 NULL, &blkoff);57795779- i = mb_find_next_zero_bit(bitmap_bh->b_data, sb->s_blocksize,57785778+ while (1) {57795779+ i = mb_find_next_zero_bit(bitmap_bh->b_data, max,57805780 blkoff);57815781+ if (i >= max)57825782+ break;57835783+ if (ext4_fc_replay_check_excluded(sb,57845784+ ext4_group_first_block_no(sb, group) + i)) {57855785+ blkoff = i + 1;57865786+ } else57875787+ break;57885788+ }57815789 brelse(bitmap_bh);57825782- if (i >= sb->s_blocksize)57835783- continue;57845784- if (ext4_fc_replay_check_excluded(sb,57855785- ext4_group_first_block_no(sb, group) + i))57865786- continue;57875787- break;57905790+ if (i < max)57915791+ break;57885792 }5789579357905790- if (group >= ext4_get_groups_count(sb) && i >= sb->s_blocksize)57945794+ if (group >= ext4_get_groups_count(sb) || i >= max) {57955795+ *errp = -ENOSPC;57915796 return 0;57975797+ }5792579857935799 block = ext4_group_first_block_no(sb, group) + i;57945800 ext4_mb_mark_bb(sb, block, 1, 1);
+1-1
fs/ext4/migrate.c
···485485 * when we add extents we extent the journal486486 */487487 /*488488- * Even though we take i_mutex we can still cause block488488+ * Even though we take i_rwsem we can still cause block489489 * allocation via mmap write to holes. If we have allocated490490 * new blocks we fail migrate. New block allocation will491491 * clear EXT4_STATE_EXT_MIGRATE flag. The flag is updated
+2-2
fs/ext4/namei.c
···38893889 * dirents in directories.38903890 */38913891 ext4_fc_mark_ineligible(old.inode->i_sb,38923892- EXT4_FC_REASON_RENAME_DIR);38923892+ EXT4_FC_REASON_RENAME_DIR, handle);38933893 } else {38943894 if (new.inode)38953895 ext4_fc_track_unlink(handle, new.dentry);···40494049 if (unlikely(retval))40504050 goto end_rename;40514051 ext4_fc_mark_ineligible(new.inode->i_sb,40524052- EXT4_FC_REASON_CROSS_RENAME);40524052+ EXT4_FC_REASON_CROSS_RENAME, handle);40534053 if (old.dir_bh) {40544054 retval = ext4_rename_dir_finish(handle, &old, new.dir->i_ino);40554055 if (retval)
+2-2
fs/ext4/orphan.c
···9393 * At filesystem recovery time, we walk this list deleting unlinked9494 * inodes and truncating linked inodes in ext4_orphan_cleanup().9595 *9696- * Orphan list manipulation functions must be called under i_mutex unless9696+ * Orphan list manipulation functions must be called under i_rwsem unless9797 * we are just creating the inode or deleting it.9898 */9999int ext4_orphan_add(handle_t *handle, struct inode *inode)···119119 /*120120 * Orphan handling is only valid for files with data blocks121121 * being truncated, or files being unlinked. Note that we either122122- * hold i_mutex, or the inode can not be referenced from outside,122122+ * hold i_rwsem, or the inode can not be referenced from outside,123123 * so i_nlink should not be bumped due to race124124 */125125 ASSERT((S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
···119119static int __init init_fs_stat_sysctls(void)120120{121121 register_sysctl_init("fs", fs_stat_sysctls);122122+ if (IS_ENABLED(CONFIG_BINFMT_MISC))123123+ register_sysctl_mount_point("fs/binfmt_misc");122124 return 0;123125}124126fs_initcall(init_fs_stat_sysctls);
+48-4
fs/iomap/buffered-io.c
···21212222#include "../internal.h"23232424+#define IOEND_BATCH_SIZE 40962525+2426/*2527 * Structure allocated for each folio when block size < folio size2628 * to track sub-folio uptodate status and I/O completions.···10411039 * state, release holds on bios, and finally free up memory. Do not use the10421040 * ioend after this.10431041 */10441044-static void10421042+static u3210451043iomap_finish_ioend(struct iomap_ioend *ioend, int error)10461044{10471045 struct inode *inode = ioend->io_inode;···10501048 u64 start = bio->bi_iter.bi_sector;10511049 loff_t offset = ioend->io_offset;10521050 bool quiet = bio_flagged(bio, BIO_QUIET);10511051+ u32 folio_count = 0;1053105210541053 for (bio = &ioend->io_inline_bio; bio; bio = next) {10551054 struct folio_iter fi;···10651062 next = bio->bi_private;1066106310671064 /* walk all folios in bio, ending page IO on them */10681068- bio_for_each_folio_all(fi, bio)10651065+ bio_for_each_folio_all(fi, bio) {10691066 iomap_finish_folio_write(inode, fi.folio, fi.length,10701067 error);10681068+ folio_count++;10691069+ }10711070 bio_put(bio);10721071 }10731072 /* The ioend has been freed by bio_put() */···10791074"%s: writeback error on inode %lu, offset %lld, sector %llu",10801075 inode->i_sb->s_id, inode->i_ino, offset, start);10811076 }10771077+ return folio_count;10821078}1083107910801080+/*10811081+ * Ioend completion routine for merged bios. This can only be called from task10821082+ * contexts as merged ioends can be of unbound length. Hence we have to break up10831083+ * the writeback completions into manageable chunks to avoid long scheduler10841084+ * holdoffs. We aim to keep scheduler holdoffs down below 10ms so that we get10851085+ * good batch processing throughput without creating adverse scheduler latency10861086+ * conditions.10871087+ */10841088void10851089iomap_finish_ioends(struct iomap_ioend *ioend, int error)10861090{10871091 struct list_head tmp;10921092+ u32 completions;10931093+10941094+ might_sleep();1088109510891096 list_replace_init(&ioend->io_list, &tmp);10901090- iomap_finish_ioend(ioend, error);10971097+ completions = iomap_finish_ioend(ioend, error);1091109810921099 while (!list_empty(&tmp)) {11001100+ if (completions > IOEND_BATCH_SIZE * 8) {11011101+ cond_resched();11021102+ completions = 0;11031103+ }10931104 ioend = list_first_entry(&tmp, struct iomap_ioend, io_list);10941105 list_del_init(&ioend->io_list);10951095- iomap_finish_ioend(ioend, error);11061106+ completions += iomap_finish_ioend(ioend, error);10961107 }10971108}10981109EXPORT_SYMBOL_GPL(iomap_finish_ioends);···11281107 (next->io_type == IOMAP_UNWRITTEN))11291108 return false;11301109 if (ioend->io_offset + ioend->io_size != next->io_offset)11101110+ return false;11111111+ /*11121112+ * Do not merge physically discontiguous ioends. The filesystem11131113+ * completion functions will have to iterate the physical11141114+ * discontiguities even if we merge the ioends at a logical level, so11151115+ * we don't gain anything by merging physical discontiguities here.11161116+ *11171117+ * We cannot use bio->bi_iter.bi_sector here as it is modified during11181118+ * submission so does not point to the start sector of the bio at11191119+ * completion.11201120+ */11211121+ if (ioend->io_sector + (ioend->io_size >> 9) != next->io_sector)11311122 return false;11321123 return true;11331124}···12421209 ioend->io_flags = wpc->iomap.flags;12431210 ioend->io_inode = inode;12441211 ioend->io_size = 0;12121212+ ioend->io_folios = 0;12451213 ioend->io_offset = offset;12461214 ioend->io_bio = bio;12151215+ ioend->io_sector = sector;12471216 return ioend;12481217}12491218···12851250 if (offset != wpc->ioend->io_offset + wpc->ioend->io_size)12861251 return false;12871252 if (sector != bio_end_sector(wpc->ioend->io_bio))12531253+ return false;12541254+ /*12551255+ * Limit ioend bio chain lengths to minimise IO completion latency. This12561256+ * also prevents long tight loops ending page writeback on all the12571257+ * folios in the ioend.12581258+ */12591259+ if (wpc->ioend->io_folios >= IOEND_BATCH_SIZE)12881260 return false;12891261 return true;12901262}···13771335 &submit_list);13781336 count++;13791337 }13381338+ if (count)13391339+ wpc->ioend->io_folios++;1380134013811341 WARN_ON_ONCE(!wpc->ioend && !list_empty(&submit_list));13821342 WARN_ON_ONCE(!folio_test_locked(folio));
+4-17
fs/jbd2/commit.c
···484484 stats.run.rs_running = jbd2_time_diff(commit_transaction->t_start,485485 stats.run.rs_locked);486486487487- spin_lock(&commit_transaction->t_handle_lock);488488- while (atomic_read(&commit_transaction->t_updates)) {489489- DEFINE_WAIT(wait);487487+ // waits for any t_updates to finish488488+ jbd2_journal_wait_updates(journal);490489491491- prepare_to_wait(&journal->j_wait_updates, &wait,492492- TASK_UNINTERRUPTIBLE);493493- if (atomic_read(&commit_transaction->t_updates)) {494494- spin_unlock(&commit_transaction->t_handle_lock);495495- write_unlock(&journal->j_state_lock);496496- schedule();497497- write_lock(&journal->j_state_lock);498498- spin_lock(&commit_transaction->t_handle_lock);499499- }500500- finish_wait(&journal->j_wait_updates, &wait);501501- }502502- spin_unlock(&commit_transaction->t_handle_lock);503490 commit_transaction->t_state = T_SWITCH;504491 write_unlock(&journal->j_state_lock);505492···804817 commit_transaction->t_state = T_COMMIT_DFLUSH;805818 write_unlock(&journal->j_state_lock);806819807807- /* 820820+ /*808821 * If the journal is not located on the file system device,809822 * then we must flush the file system device before we issue810823 * the commit record···11571170 if (journal->j_commit_callback)11581171 journal->j_commit_callback(journal, commit_transaction);11591172 if (journal->j_fc_cleanup_callback)11601160- journal->j_fc_cleanup_callback(journal, 1);11731173+ journal->j_fc_cleanup_callback(journal, 1, commit_transaction->t_tid);1161117411621175 trace_jbd2_end_commit(journal, commit_transaction);11631176 jbd_debug(1, "JBD2: commit %d complete, head %d\n",
+5-1
fs/jbd2/journal.c
···771771{772772 jbd2_journal_unlock_updates(journal);773773 if (journal->j_fc_cleanup_callback)774774- journal->j_fc_cleanup_callback(journal, 0);774774+ journal->j_fc_cleanup_callback(journal, 0, tid);775775 write_lock(&journal->j_state_lock);776776 journal->j_flags &= ~JBD2_FAST_COMMIT_ONGOING;777777 if (fallback)···1287128712881288/**12891289 * jbd2_journal_shrink_scan()12901290+ * @shrink: shrinker to work on12911291+ * @sc: reclaim request to process12901292 *12911293 * Scan the checkpointed buffer on the checkpoint list and release the12921294 * journal_head.···1314131213151313/**13161314 * jbd2_journal_shrink_count()13151315+ * @shrink: shrinker to work on13161316+ * @sc: reclaim request to process13171317 *13181318 * Count the number of checkpoint buffers on the checkpoint list.13191319 */
+32-21
fs/jbd2/transaction.c
···449449 }450450451451 /* OK, account for the buffers that this operation expects to452452- * use and add the handle to the running transaction. 452452+ * use and add the handle to the running transaction.453453 */454454 update_t_max_wait(transaction, ts);455455 handle->h_transaction = transaction;···836836}837837EXPORT_SYMBOL(jbd2_journal_restart);838838839839+/*840840+ * Waits for any outstanding t_updates to finish.841841+ * This is called with write j_state_lock held.842842+ */843843+void jbd2_journal_wait_updates(journal_t *journal)844844+{845845+ transaction_t *commit_transaction = journal->j_running_transaction;846846+847847+ if (!commit_transaction)848848+ return;849849+850850+ spin_lock(&commit_transaction->t_handle_lock);851851+ while (atomic_read(&commit_transaction->t_updates)) {852852+ DEFINE_WAIT(wait);853853+854854+ prepare_to_wait(&journal->j_wait_updates, &wait,855855+ TASK_UNINTERRUPTIBLE);856856+ if (atomic_read(&commit_transaction->t_updates)) {857857+ spin_unlock(&commit_transaction->t_handle_lock);858858+ write_unlock(&journal->j_state_lock);859859+ schedule();860860+ write_lock(&journal->j_state_lock);861861+ spin_lock(&commit_transaction->t_handle_lock);862862+ }863863+ finish_wait(&journal->j_wait_updates, &wait);864864+ }865865+ spin_unlock(&commit_transaction->t_handle_lock);866866+}867867+839868/**840869 * jbd2_journal_lock_updates () - establish a transaction barrier.841870 * @journal: Journal to establish a barrier on.···892863 write_lock(&journal->j_state_lock);893864 }894865895895- /* Wait until there are no running updates */896896- while (1) {897897- transaction_t *transaction = journal->j_running_transaction;866866+ /* Wait until there are no running t_updates */867867+ jbd2_journal_wait_updates(journal);898868899899- if (!transaction)900900- break;901901-902902- spin_lock(&transaction->t_handle_lock);903903- prepare_to_wait(&journal->j_wait_updates, &wait,904904- TASK_UNINTERRUPTIBLE);905905- if (!atomic_read(&transaction->t_updates)) {906906- spin_unlock(&transaction->t_handle_lock);907907- finish_wait(&journal->j_wait_updates, &wait);908908- break;909909- }910910- spin_unlock(&transaction->t_handle_lock);911911- write_unlock(&journal->j_state_lock);912912- schedule();913913- finish_wait(&journal->j_wait_updates, &wait);914914- write_lock(&journal->j_state_lock);915915- }916869 write_unlock(&journal->j_state_lock);917870918871 /*
+27
fs/ksmbd/auth.c
···2929#include "mgmt/user_config.h"3030#include "crypto_ctx.h"3131#include "transport_ipc.h"3232+#include "../smbfs_common/arc4.h"32333334/*3435 * Fixed format data defining GSS header and fixed string···337336 nt_len - CIFS_ENCPWD_SIZE,338337 domain_name, conn->ntlmssp.cryptkey);339338 kfree(domain_name);339339+340340+ /* The recovered secondary session key */341341+ if (conn->ntlmssp.client_flags & NTLMSSP_NEGOTIATE_KEY_XCH) {342342+ struct arc4_ctx *ctx_arc4;343343+ unsigned int sess_key_off, sess_key_len;344344+345345+ sess_key_off = le32_to_cpu(authblob->SessionKey.BufferOffset);346346+ sess_key_len = le16_to_cpu(authblob->SessionKey.Length);347347+348348+ if (blob_len < (u64)sess_key_off + sess_key_len)349349+ return -EINVAL;350350+351351+ ctx_arc4 = kmalloc(sizeof(*ctx_arc4), GFP_KERNEL);352352+ if (!ctx_arc4)353353+ return -ENOMEM;354354+355355+ cifs_arc4_setkey(ctx_arc4, sess->sess_key,356356+ SMB2_NTLMV2_SESSKEY_SIZE);357357+ cifs_arc4_crypt(ctx_arc4, sess->sess_key,358358+ (char *)authblob + sess_key_off, sess_key_len);359359+ kfree_sensitive(ctx_arc4);360360+ }361361+340362 return ret;341363}342364···431407 if (conn->use_spnego &&432408 (cflags & NTLMSSP_NEGOTIATE_EXTENDED_SEC))433409 flags |= NTLMSSP_NEGOTIATE_EXTENDED_SEC;410410+411411+ if (cflags & NTLMSSP_NEGOTIATE_KEY_XCH)412412+ flags |= NTLMSSP_NEGOTIATE_KEY_XCH;434413435414 chgblob->NegotiateFlags = cpu_to_le32(flags);436415 len = strlen(ksmbd_netbios_name());
···308308 for (i = 0; i < 2; i++) {309309 struct kstat kstat;310310 struct ksmbd_kstat ksmbd_kstat;311311+ struct dentry *dentry;311312312313 if (!dir->dot_dotdot[i]) { /* fill dot entry info */313314 if (i == 0) {314315 d_info->name = ".";315316 d_info->name_len = 1;317317+ dentry = dir->filp->f_path.dentry;316318 } else {317319 d_info->name = "..";318320 d_info->name_len = 2;321321+ dentry = dir->filp->f_path.dentry->d_parent;319322 }320323321324 if (!match_pattern(d_info->name, d_info->name_len,···330327 ksmbd_kstat.kstat = &kstat;331328 ksmbd_vfs_fill_dentry_attrs(work,332329 user_ns,333333- dir->filp->f_path.dentry->d_parent,330330+ dentry,334331 &ksmbd_kstat);335332 rc = fn(conn, info_level, d_info, &ksmbd_kstat);336333 if (rc)
+1-1
fs/ksmbd/transport_rdma.c
···8080/* The maximum single-message size which can be received */8181static int smb_direct_max_receive_size = 8192;82828383-static int smb_direct_max_read_write_size = 1048512;8383+static int smb_direct_max_read_write_size = 524224;84848585static int smb_direct_max_outstanding_rw_ops = 8;8686
+1
fs/ksmbd/vfs.h
···4747 int last_entry_offset;4848 bool hide_dot_file;4949 int flags;5050+ int last_entry_off_align;5051};51525253struct ksmbd_readdir_data {
···8032803280338033/**80348034 * nfs4_proc_get_locations - discover locations for a migrated FSID80358035- * @inode: inode on FSID that is migrating80358035+ * @server: pointer to nfs_server to process80368036+ * @fhandle: pointer to the kernel NFS client file handle80368037 * @locations: result of query80378038 * @page: buffer80388039 * @cred: credential to use for this operation
+11-8
fs/nfsd/nfs3proc.c
···150150 unsigned int len;151151 int v;152152153153- argp->count = min_t(u32, argp->count, max_blocksize);154154-155153 dprintk("nfsd: READ(3) %s %lu bytes at %Lu\n",156154 SVCFH_fmt(&argp->fh),157155 (unsigned long) argp->count,158156 (unsigned long long) argp->offset);157157+158158+ argp->count = min_t(u32, argp->count, max_blocksize);159159+ if (argp->offset > (u64)OFFSET_MAX)160160+ argp->offset = (u64)OFFSET_MAX;161161+ if (argp->offset + argp->count > (u64)OFFSET_MAX)162162+ argp->count = (u64)OFFSET_MAX - argp->offset;159163160164 v = 0;161165 len = argp->count;···202198 argp->len,203199 (unsigned long long) argp->offset,204200 argp->stable? " stable" : "");201201+202202+ resp->status = nfserr_fbig;203203+ if (argp->offset > (u64)OFFSET_MAX ||204204+ argp->offset + argp->len > (u64)OFFSET_MAX)205205+ return rpc_success;205206206207 fh_copy(&resp->fh, &argp->fh);207208 resp->committed = argp->stable;···660651 argp->count,661652 (unsigned long long) argp->offset);662653663663- if (argp->offset > NFS_OFFSET_MAX) {664664- resp->status = nfserr_inval;665665- goto out;666666- }667667-668654 fh_copy(&resp->fh, &argp->fh);669655 resp->status = nfsd_commit(rqstp, &resp->fh, argp->offset,670656 argp->count, resp->verf);671671-out:672657 return rpc_success;673658}674659
···435435 .ia_size = iap->ia_size,436436 };437437438438+ host_err = -EFBIG;439439+ if (iap->ia_size < 0)440440+ goto out_unlock;441441+438442 host_err = notify_change(&init_user_ns, dentry, &size_attr, NULL);439443 if (host_err)440444 goto out_unlock;···11141110}1115111111161112#ifdef CONFIG_NFSD_V311171117-/*11181118- * Commit all pending writes to stable storage.11131113+/**11141114+ * nfsd_commit - Commit pending writes to stable storage11151115+ * @rqstp: RPC request being processed11161116+ * @fhp: NFS filehandle11171117+ * @offset: raw offset from beginning of file11181118+ * @count: raw count of bytes to sync11191119+ * @verf: filled in with the server's current write verifier11191120 *11201120- * Note: we only guarantee that data that lies within the range specified11211121- * by the 'offset' and 'count' parameters will be synced.11211121+ * Note: we guarantee that data that lies within the range specified11221122+ * by the 'offset' and 'count' parameters will be synced. The server11231123+ * is permitted to sync data that lies outside this range at the11241124+ * same time.11221125 *11231126 * Unfortunately we cannot lock the file to make sure we return full WCC11241127 * data to the client, as locking happens lower down in the filesystem.11281128+ *11291129+ * Return values:11301130+ * An nfsstat value in network byte order.11251131 */11261132__be3211271127-nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp,11281128- loff_t offset, unsigned long count, __be32 *verf)11331133+nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp, u64 offset,11341134+ u32 count, __be32 *verf)11291135{11361136+ u64 maxbytes;11371137+ loff_t start, end;11301138 struct nfsd_net *nn;11311139 struct nfsd_file *nf;11321132- loff_t end = LLONG_MAX;11331133- __be32 err = nfserr_inval;11341134-11351135- if (offset < 0)11361136- goto out;11371137- if (count != 0) {11381138- end = offset + (loff_t)count - 1;11391139- if (end < offset)11401140- goto out;11411141- }11401140+ __be32 err;1142114111431142 err = nfsd_file_acquire(rqstp, fhp,11441143 NFSD_MAY_WRITE|NFSD_MAY_NOT_BREAK_LEASE, &nf);11451144 if (err)11461145 goto out;11461146+11471147+ /*11481148+ * Convert the client-provided (offset, count) range to a11491149+ * (start, end) range. If the client-provided range falls11501150+ * outside the maximum file size of the underlying FS,11511151+ * clamp the sync range appropriately.11521152+ */11531153+ start = 0;11541154+ end = LLONG_MAX;11551155+ maxbytes = (u64)fhp->fh_dentry->d_sb->s_maxbytes;11561156+ if (offset < maxbytes) {11571157+ start = offset;11581158+ if (count && (offset + count - 1 < maxbytes))11591159+ end = offset + count - 1;11601160+ }11611161+11471162 nn = net_generic(nf->nf_net, nfsd_net_id);11481163 if (EX_ISSYNC(fhp->fh_export)) {11491164 errseq_t since = READ_ONCE(nf->nf_file->f_wb_err);11501165 int err2;1151116611521152- err2 = vfs_fsync_range(nf->nf_file, offset, end, 0);11671167+ err2 = vfs_fsync_range(nf->nf_file, start, end, 0);11531168 switch (err2) {11541169 case 0:11551170 nfsd_copy_write_verifier(verf, nn);
···690690 /* This is not very clever (and fast) but currently I don't know about691691 * any other simple way of getting quota data to disk and we must get692692 * them there for userspace to be visible... */693693- if (sb->s_op->sync_fs)694694- sb->s_op->sync_fs(sb, 1);695695- sync_blockdev(sb->s_bdev);693693+ if (sb->s_op->sync_fs) {694694+ ret = sb->s_op->sync_fs(sb, 1);695695+ if (ret)696696+ return ret;697697+ }698698+ ret = sync_blockdev(sb->s_bdev);699699+ if (ret)700700+ return ret;696701697702 /*698703 * Now when everything is written we can discard the pagecache so
+12-7
fs/super.c
···16161616 percpu_rwsem_acquire(sb->s_writers.rw_sem + level, 0, _THIS_IP_);16171617}1618161816191619-static void sb_freeze_unlock(struct super_block *sb)16191619+static void sb_freeze_unlock(struct super_block *sb, int level)16201620{16211621- int level;16221622-16231623- for (level = SB_FREEZE_LEVELS - 1; level >= 0; level--)16211621+ for (level--; level >= 0; level--)16241622 percpu_up_write(sb->s_writers.rw_sem + level);16251623}16261624···16891691 sb_wait_write(sb, SB_FREEZE_PAGEFAULT);1690169216911693 /* All writers are done so after syncing there won't be dirty data */16921692- sync_filesystem(sb);16941694+ ret = sync_filesystem(sb);16951695+ if (ret) {16961696+ sb->s_writers.frozen = SB_UNFROZEN;16971697+ sb_freeze_unlock(sb, SB_FREEZE_PAGEFAULT);16981698+ wake_up(&sb->s_writers.wait_unfrozen);16991699+ deactivate_locked_super(sb);17001700+ return ret;17011701+ }1693170216941703 /* Now wait for internal filesystem counter */16951704 sb->s_writers.frozen = SB_FREEZE_FS;···17081703 printk(KERN_ERR17091704 "VFS:Filesystem freeze failed\n");17101705 sb->s_writers.frozen = SB_UNFROZEN;17111711- sb_freeze_unlock(sb);17061706+ sb_freeze_unlock(sb, SB_FREEZE_FS);17121707 wake_up(&sb->s_writers.wait_unfrozen);17131708 deactivate_locked_super(sb);17141709 return ret;···17531748 }1754174917551750 sb->s_writers.frozen = SB_UNFROZEN;17561756- sb_freeze_unlock(sb);17511751+ sb_freeze_unlock(sb, SB_FREEZE_FS);17571752out:17581753 wake_up(&sb->s_writers.wait_unfrozen);17591754 deactivate_locked_super(sb);
+12-6
fs/sync.c
···2929 */3030int sync_filesystem(struct super_block *sb)3131{3232- int ret;3232+ int ret = 0;33333434 /*3535 * We need to be protected against the filesystem going from···5252 * at a time.5353 */5454 writeback_inodes_sb(sb, WB_REASON_SYNC);5555- if (sb->s_op->sync_fs)5656- sb->s_op->sync_fs(sb, 0);5555+ if (sb->s_op->sync_fs) {5656+ ret = sb->s_op->sync_fs(sb, 0);5757+ if (ret)5858+ return ret;5959+ }5760 ret = sync_blockdev_nowait(sb->s_bdev);5858- if (ret < 0)6161+ if (ret)5962 return ret;60636164 sync_inodes_sb(sb);6262- if (sb->s_op->sync_fs)6363- sb->s_op->sync_fs(sb, 1);6565+ if (sb->s_op->sync_fs) {6666+ ret = sb->s_op->sync_fs(sb, 1);6767+ if (ret)6868+ return ret;6969+ }6470 return sync_blockdev(sb->s_bdev);6571}6672EXPORT_SYMBOL(sync_filesystem);
+15-1
fs/xfs/xfs_aops.c
···136136 memalloc_nofs_restore(nofs_flag);137137}138138139139-/* Finish all pending io completions. */139139+/*140140+ * Finish all pending IO completions that require transactional modifications.141141+ *142142+ * We try to merge physical and logically contiguous ioends before completion to143143+ * minimise the number of transactions we need to perform during IO completion.144144+ * Both unwritten extent conversion and COW remapping need to iterate and modify145145+ * one physical extent at a time, so we gain nothing by merging physically146146+ * discontiguous extents here.147147+ *148148+ * The ioend chain length that we can be processing here is largely unbound in149149+ * length and we may have to perform significant amounts of work on each ioend150150+ * to complete it. Hence we have to be careful about holding the CPU for too151151+ * long in this loop.152152+ */140153void141154xfs_end_io(142155 struct work_struct *work)···170157 list_del_init(&ioend->io_list);171158 iomap_ioend_try_merge(ioend, &tmp);172159 xfs_end_ioend(ioend);160160+ cond_resched();173161 }174162}175163
+3-6
fs/xfs/xfs_bmap_util.c
···850850 rblocks = 0;851851 }852852853853- /*854854- * Allocate and setup the transaction.855855- */856853 error = xfs_trans_alloc_inode(ip, &M_RES(mp)->tr_write,857854 dblocks, rblocks, false, &tp);858855 if (error)···866869 if (error)867870 goto error;868871869869- /*870870- * Complete the transaction871871- */872872+ ip->i_diflags |= XFS_DIFLAG_PREALLOC;873873+ xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);874874+872875 error = xfs_trans_commit(tp);873876 xfs_iunlock(ip, XFS_ILOCK_EXCL);874877 if (error)
+26-60
fs/xfs/xfs_file.c
···6666 return !((pos | len) & mask);6767}68686969-int7070-xfs_update_prealloc_flags(7171- struct xfs_inode *ip,7272- enum xfs_prealloc_flags flags)7373-{7474- struct xfs_trans *tp;7575- int error;7676-7777- error = xfs_trans_alloc(ip->i_mount, &M_RES(ip->i_mount)->tr_writeid,7878- 0, 0, 0, &tp);7979- if (error)8080- return error;8181-8282- xfs_ilock(ip, XFS_ILOCK_EXCL);8383- xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);8484-8585- if (!(flags & XFS_PREALLOC_INVISIBLE)) {8686- VFS_I(ip)->i_mode &= ~S_ISUID;8787- if (VFS_I(ip)->i_mode & S_IXGRP)8888- VFS_I(ip)->i_mode &= ~S_ISGID;8989- xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);9090- }9191-9292- if (flags & XFS_PREALLOC_SET)9393- ip->i_diflags |= XFS_DIFLAG_PREALLOC;9494- if (flags & XFS_PREALLOC_CLEAR)9595- ip->i_diflags &= ~XFS_DIFLAG_PREALLOC;9696-9797- xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);9898- if (flags & XFS_PREALLOC_SYNC)9999- xfs_trans_set_sync(tp);100100- return xfs_trans_commit(tp);101101-}102102-10369/*10470 * Fsync operations on directories are much simpler than on regular files,10571 * as there is no file data to flush, and thus also no need for explicit···861895 return error;862896}863897898898+/* Does this file, inode, or mount want synchronous writes? */899899+static inline bool xfs_file_sync_writes(struct file *filp)900900+{901901+ struct xfs_inode *ip = XFS_I(file_inode(filp));902902+903903+ if (xfs_has_wsync(ip->i_mount))904904+ return true;905905+ if (filp->f_flags & (__O_SYNC | O_DSYNC))906906+ return true;907907+ if (IS_SYNC(file_inode(filp)))908908+ return true;909909+910910+ return false;911911+}912912+864913#define XFS_FALLOC_FL_SUPPORTED \865914 (FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE | \866915 FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_ZERO_RANGE | \···891910 struct inode *inode = file_inode(file);892911 struct xfs_inode *ip = XFS_I(inode);893912 long error;894894- enum xfs_prealloc_flags flags = 0;895913 uint iolock = XFS_IOLOCK_EXCL | XFS_MMAPLOCK_EXCL;896914 loff_t new_size = 0;897915 bool do_file_insert = false;···934954 if (error)935955 goto out_unlock;936956 }957957+958958+ error = file_modified(file);959959+ if (error)960960+ goto out_unlock;937961938962 if (mode & FALLOC_FL_PUNCH_HOLE) {939963 error = xfs_free_file_space(ip, offset, len);···9881004 }9891005 do_file_insert = true;9901006 } else {991991- flags |= XFS_PREALLOC_SET;992992-9931007 if (!(mode & FALLOC_FL_KEEP_SIZE) &&9941008 offset + len > i_size_read(inode)) {9951009 new_size = offset + len;···10391057 }10401058 }1041105910421042- if (file->f_flags & O_DSYNC)10431043- flags |= XFS_PREALLOC_SYNC;10441044-10451045- error = xfs_update_prealloc_flags(ip, flags);10461046- if (error)10471047- goto out_unlock;10481048-10491060 /* Change file size if needed */10501061 if (new_size) {10511062 struct iattr iattr;···10571082 * leave shifted extents past EOF and hence losing access to10581083 * the data that is contained within them.10591084 */10601060- if (do_file_insert)10851085+ if (do_file_insert) {10611086 error = xfs_insert_file_space(ip, offset, len);10871087+ if (error)10881088+ goto out_unlock;10891089+ }10901090+10911091+ if (xfs_file_sync_writes(file))10921092+ error = xfs_log_force_inode(ip);1062109310631094out_unlock:10641095 xfs_iunlock(ip, iolock);···10941113 if (lockflags)10951114 xfs_iunlock(ip, lockflags);10961115 return ret;10971097-}10981098-10991099-/* Does this file, inode, or mount want synchronous writes? */11001100-static inline bool xfs_file_sync_writes(struct file *filp)11011101-{11021102- struct xfs_inode *ip = XFS_I(file_inode(filp));11031103-11041104- if (xfs_has_wsync(ip->i_mount))11051105- return true;11061106- if (filp->f_flags & (__O_SYNC | O_DSYNC))11071107- return true;11081108- if (IS_SYNC(file_inode(filp)))11091109- return true;11101110-11111111- return false;11121116}1113111711141118STATIC loff_t
···1464146414651465 if (bmx.bmv_count < 2)14661466 return -EINVAL;14671467- if (bmx.bmv_count > ULONG_MAX / recsize)14671467+ if (bmx.bmv_count >= INT_MAX / recsize)14681468 return -ENOMEM;1469146914701470 buf = kvcalloc(bmx.bmv_count, sizeof(*buf), GFP_KERNEL);
+39-3
fs/xfs/xfs_pnfs.c
···7171}72727373/*7474+ * We cannot use file based VFS helpers such as file_modified() to update7575+ * inode state as we modify the data/metadata in the inode here. Hence we have7676+ * to open code the timestamp updates and SUID/SGID stripping. We also need7777+ * to set the inode prealloc flag to ensure that the extents we allocate are not7878+ * removed if the inode is reclaimed from memory before xfs_fs_block_commit()7979+ * is from the client to indicate that data has been written and the file size8080+ * can be extended.8181+ */8282+static int8383+xfs_fs_map_update_inode(8484+ struct xfs_inode *ip)8585+{8686+ struct xfs_trans *tp;8787+ int error;8888+8989+ error = xfs_trans_alloc(ip->i_mount, &M_RES(ip->i_mount)->tr_writeid,9090+ 0, 0, 0, &tp);9191+ if (error)9292+ return error;9393+9494+ xfs_ilock(ip, XFS_ILOCK_EXCL);9595+ xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);9696+9797+ VFS_I(ip)->i_mode &= ~S_ISUID;9898+ if (VFS_I(ip)->i_mode & S_IXGRP)9999+ VFS_I(ip)->i_mode &= ~S_ISGID;100100+ xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);101101+ ip->i_diflags |= XFS_DIFLAG_PREALLOC;102102+103103+ xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);104104+ return xfs_trans_commit(tp);105105+}106106+107107+/*74108 * Get a layout for the pNFS client.75109 */76110int···198164 * that the blocks allocated and handed out to the client are199165 * guaranteed to be present even after a server crash.200166 */201201- error = xfs_update_prealloc_flags(ip,202202- XFS_PREALLOC_SET | XFS_PREALLOC_SYNC);167167+ error = xfs_fs_map_update_inode(ip);168168+ if (!error)169169+ error = xfs_log_force_inode(ip);203170 if (error)204171 goto out_unlock;172172+205173 } else {206174 xfs_iunlock(ip, lock_flags);207175 }···291255 length = end - start;292256 if (!length)293257 continue;294294-258258+295259 /*296260 * Make sure reads through the pagecache see the new data.297261 */
+5-1
fs/xfs/xfs_super.c
···735735 int wait)736736{737737 struct xfs_mount *mp = XFS_M(sb);738738+ int error;738739739740 trace_xfs_fs_sync_fs(mp, __return_address);740741···745744 if (!wait)746745 return 0;747746748748- xfs_log_force(mp, XFS_LOG_SYNC);747747+ error = xfs_log_force(mp, XFS_LOG_SYNC);748748+ if (error)749749+ return error;750750+749751 if (laptop_mode) {750752 /*751753 * The disk must be active because we're syncing.
···262262263263 /* Draws a rectangle */264264 void (*fb_fillrect) (struct fb_info *info, const struct fb_fillrect *rect);265265- /* Copy data from area to another. Obsolete. */265265+ /* Copy data from area to another */266266 void (*fb_copyarea) (struct fb_info *info, const struct fb_copyarea *region);267267 /* Draws a image to the display */268268 void (*fb_imageblit) (struct fb_info *info, const struct fb_image *image);
+2
include/linux/iomap.h
···263263 struct list_head io_list; /* next ioend in chain */264264 u16 io_type;265265 u16 io_flags; /* IOMAP_F_* */266266+ u32 io_folios; /* folios added to ioend */266267 struct inode *io_inode; /* file being written to */267268 size_t io_size; /* size of the extent */268269 loff_t io_offset; /* offset in the file */270270+ sector_t io_sector; /* start sector of ioend */269271 struct bio *io_bio; /* bio being built */270272 struct bio io_inline_bio; /* MUST BE LAST! */271273};
+4-9
include/linux/jbd2.h
···594594 */595595 unsigned long t_log_start;596596597597- /* 597597+ /*598598 * Number of buffers on the t_buffers list [j_list_lock, no locks599599 * needed for jbd2 thread]600600 */···12951295 * Clean-up after fast commit or full commit. JBD2 calls this function12961296 * after every commit operation.12971297 */12981298- void (*j_fc_cleanup_callback)(struct journal_s *journal, int);12981298+ void (*j_fc_cleanup_callback)(struct journal_s *journal, int full, tid_t tid);1299129913001300 /**13011301 * @j_fc_replay_callback:···14191419extern bool __jbd2_journal_refile_buffer(struct journal_head *);14201420extern void jbd2_journal_refile_buffer(journal_t *, struct journal_head *);14211421extern void __jbd2_journal_file_buffer(struct journal_head *, transaction_t *, int);14221422-extern void __journal_free_buffer(struct journal_head *bh);14231422extern void jbd2_journal_file_buffer(struct journal_head *, transaction_t *, int);14241424-extern void __journal_clean_data_list(transaction_t *transaction);14251423static inline void jbd2_file_log_bh(struct list_head *head, struct buffer_head *bh)14261424{14271425 list_add_tail(&bh->b_assoc_buffers, head);···14841486 struct buffer_head **bh_out,14851487 sector_t blocknr);1486148814871487-/* Transaction locking */14881488-extern void __wait_on_journal (journal_t *);14891489-14901489/* Transaction cache support */14911490extern void jbd2_journal_destroy_transaction_cache(void);14921491extern int __init jbd2_journal_init_transaction_cache(void);···15371542extern int jbd2_journal_flush(journal_t *journal, unsigned int flags);15381543extern void jbd2_journal_lock_updates (journal_t *);15391544extern void jbd2_journal_unlock_updates (journal_t *);15451545+15461546+void jbd2_journal_wait_updates(journal_t *);1540154715411548extern journal_t * jbd2_journal_init_dev(struct block_device *bdev,15421549 struct block_device *fs_dev,···17701773#define BJ_Shadow 3 /* Buffer contents being shadowed to the log */17711774#define BJ_Reserved 4 /* Buffer is reserved for access by journal */17721775#define BJ_Types 517731773-17741774-extern int jbd_blocks_per_page(struct inode *inode);1775177617761777/* JBD uses a CRC32 checksum */17771778#define JBD_MAX_CHECKSUM_SIZE 4
+109-3
include/linux/kvm_host.h
···2929#include <linux/refcount.h>3030#include <linux/nospec.h>3131#include <linux/notifier.h>3232+#include <linux/ftrace.h>3233#include <linux/hashtable.h>3434+#include <linux/instrumentation.h>3335#include <linux/interval_tree.h>3436#include <linux/rbtree.h>3537#include <linux/xarray.h>···370368 u64 last_used_slot_gen;371369};372370373373-/* must be called with irqs disabled */374374-static __always_inline void guest_enter_irqoff(void)371371+/*372372+ * Start accounting time towards a guest.373373+ * Must be called before entering guest context.374374+ */375375+static __always_inline void guest_timing_enter_irqoff(void)375376{376377 /*377378 * This is running in ioctl context so its safe to assume that it's the···383378 instrumentation_begin();384379 vtime_account_guest_enter();385380 instrumentation_end();381381+}386382383383+/*384384+ * Enter guest context and enter an RCU extended quiescent state.385385+ *386386+ * Between guest_context_enter_irqoff() and guest_context_exit_irqoff() it is387387+ * unsafe to use any code which may directly or indirectly use RCU, tracing388388+ * (including IRQ flag tracing), or lockdep. All code in this period must be389389+ * non-instrumentable.390390+ */391391+static __always_inline void guest_context_enter_irqoff(void)392392+{387393 /*388394 * KVM does not hold any references to rcu protected data when it389395 * switches CPU into a guest mode. In fact switching to a guest mode···410394 }411395}412396413413-static __always_inline void guest_exit_irqoff(void)397397+/*398398+ * Deprecated. Architectures should move to guest_timing_enter_irqoff() and399399+ * guest_state_enter_irqoff().400400+ */401401+static __always_inline void guest_enter_irqoff(void)402402+{403403+ guest_timing_enter_irqoff();404404+ guest_context_enter_irqoff();405405+}406406+407407+/**408408+ * guest_state_enter_irqoff - Fixup state when entering a guest409409+ *410410+ * Entry to a guest will enable interrupts, but the kernel state is interrupts411411+ * disabled when this is invoked. Also tell RCU about it.412412+ *413413+ * 1) Trace interrupts on state414414+ * 2) Invoke context tracking if enabled to adjust RCU state415415+ * 3) Tell lockdep that interrupts are enabled416416+ *417417+ * Invoked from architecture specific code before entering a guest.418418+ * Must be called with interrupts disabled and the caller must be419419+ * non-instrumentable.420420+ * The caller has to invoke guest_timing_enter_irqoff() before this.421421+ *422422+ * Note: this is analogous to exit_to_user_mode().423423+ */424424+static __always_inline void guest_state_enter_irqoff(void)425425+{426426+ instrumentation_begin();427427+ trace_hardirqs_on_prepare();428428+ lockdep_hardirqs_on_prepare(CALLER_ADDR0);429429+ instrumentation_end();430430+431431+ guest_context_enter_irqoff();432432+ lockdep_hardirqs_on(CALLER_ADDR0);433433+}434434+435435+/*436436+ * Exit guest context and exit an RCU extended quiescent state.437437+ *438438+ * Between guest_context_enter_irqoff() and guest_context_exit_irqoff() it is439439+ * unsafe to use any code which may directly or indirectly use RCU, tracing440440+ * (including IRQ flag tracing), or lockdep. All code in this period must be441441+ * non-instrumentable.442442+ */443443+static __always_inline void guest_context_exit_irqoff(void)414444{415445 context_tracking_guest_exit();446446+}416447448448+/*449449+ * Stop accounting time towards a guest.450450+ * Must be called after exiting guest context.451451+ */452452+static __always_inline void guest_timing_exit_irqoff(void)453453+{417454 instrumentation_begin();418455 /* Flush the guest cputime we spent on the guest */419456 vtime_account_guest_exit();420457 instrumentation_end();458458+}459459+460460+/*461461+ * Deprecated. Architectures should move to guest_state_exit_irqoff() and462462+ * guest_timing_exit_irqoff().463463+ */464464+static __always_inline void guest_exit_irqoff(void)465465+{466466+ guest_context_exit_irqoff();467467+ guest_timing_exit_irqoff();421468}422469423470static inline void guest_exit(void)···490411 local_irq_save(flags);491412 guest_exit_irqoff();492413 local_irq_restore(flags);414414+}415415+416416+/**417417+ * guest_state_exit_irqoff - Establish state when returning from guest mode418418+ *419419+ * Entry from a guest disables interrupts, but guest mode is traced as420420+ * interrupts enabled. Also with NO_HZ_FULL RCU might be idle.421421+ *422422+ * 1) Tell lockdep that interrupts are disabled423423+ * 2) Invoke context tracking if enabled to reactivate RCU424424+ * 3) Trace interrupts off state425425+ *426426+ * Invoked from architecture specific code after exiting a guest.427427+ * Must be invoked with interrupts disabled and the caller must be428428+ * non-instrumentable.429429+ * The caller has to invoke guest_timing_exit_irqoff() after this.430430+ *431431+ * Note: this is analogous to enter_from_user_mode().432432+ */433433+static __always_inline void guest_state_exit_irqoff(void)434434+{435435+ lockdep_hardirqs_off(CALLER_ADDR0);436436+ guest_context_exit_irqoff();437437+438438+ instrumentation_begin();439439+ trace_hardirqs_off_finish();440440+ instrumentation_end();493441}494442495443static inline int kvm_vcpu_exiting_guest_mode(struct kvm_vcpu *vcpu)
+1
include/linux/libata.h
···380380 ATA_HORKAGE_MAX_TRIM_128M = (1 << 26), /* Limit max trim size to 128M */381381 ATA_HORKAGE_NO_NCQ_ON_ATI = (1 << 27), /* Disable NCQ on ATI chipset */382382 ATA_HORKAGE_NO_ID_DEV_LOG = (1 << 28), /* Identify device log missing */383383+ ATA_HORKAGE_NO_LOG_DIR = (1 << 29), /* Do not read log directory */383384384385 /* DMA mask for user DMA control: User visible values; DO NOT385386 renumber */
+7
include/linux/netfs.h
···244244 int (*prepare_write)(struct netfs_cache_resources *cres,245245 loff_t *_start, size_t *_len, loff_t i_size,246246 bool no_space_allocated_yet);247247+248248+ /* Query the occupancy of the cache in a region, returning where the249249+ * next chunk of data starts and how long it is.250250+ */251251+ int (*query_occupancy)(struct netfs_cache_resources *cres,252252+ loff_t start, size_t len, size_t granularity,253253+ loff_t *_data_start, size_t *_data_len);247254};248255249256struct readahead_control;
-8
include/linux/nfs.h
···3636 memcpy(target->data, source->data, source->size);3737}38383939-4040-/*4141- * This is really a general kernel constant, but since nothing like4242- * this is defined in the kernel headers, I have to do it here.4343- */4444-#define NFS_OFFSET_MAX ((__s64)((~(__u64)0) >> 1))4545-4646-4739enum nfs3_stable_how {4840 NFS_UNSTABLE = 0,4941 NFS_DATA_SYNC = 1,
···6262{6363 return (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1);6464}6565+#define pte_index pte_index65666667#ifndef pmd_index6768static inline unsigned long pmd_index(unsigned long address)
+13-1
include/net/dst_metadata.h
···123123124124 memcpy(&new_md->u.tun_info, &md_dst->u.tun_info,125125 sizeof(struct ip_tunnel_info) + md_size);126126+#ifdef CONFIG_DST_CACHE127127+ /* Unclone the dst cache if there is one */128128+ if (new_md->u.tun_info.dst_cache.cache) {129129+ int ret;130130+131131+ ret = dst_cache_init(&new_md->u.tun_info.dst_cache, GFP_ATOMIC);132132+ if (ret) {133133+ metadata_dst_free(new_md);134134+ return ERR_PTR(ret);135135+ }136136+ }137137+#endif138138+126139 skb_dst_drop(skb);127127- dst_hold(&new_md->dst);128140 skb_dst_set(skb, &new_md->dst);129141 return new_md;130142}
+15
include/sound/pcm.h
···617617void snd_pcm_stream_lock_irq(struct snd_pcm_substream *substream);618618void snd_pcm_stream_unlock_irq(struct snd_pcm_substream *substream);619619unsigned long _snd_pcm_stream_lock_irqsave(struct snd_pcm_substream *substream);620620+unsigned long _snd_pcm_stream_lock_irqsave_nested(struct snd_pcm_substream *substream);620621621622/**622623 * snd_pcm_stream_lock_irqsave - Lock the PCM stream···635634 } while (0)636635void snd_pcm_stream_unlock_irqrestore(struct snd_pcm_substream *substream,637636 unsigned long flags);637637+638638+/**639639+ * snd_pcm_stream_lock_irqsave_nested - Single-nested PCM stream locking640640+ * @substream: PCM substream641641+ * @flags: irq flags642642+ *643643+ * This locks the PCM stream like snd_pcm_stream_lock_irqsave() but with644644+ * the single-depth lockdep subclass.645645+ */646646+#define snd_pcm_stream_lock_irqsave_nested(substream, flags) \647647+ do { \648648+ typecheck(unsigned long, flags); \649649+ flags = _snd_pcm_stream_lock_irqsave_nested(substream); \650650+ } while (0)638651639652/**640653 * snd_pcm_group_for_each_entry - iterate over the linked substreams
+3-3
include/uapi/linux/kvm.h
···16241624#define KVM_S390_NORMAL_RESET _IO(KVMIO, 0xc3)16251625#define KVM_S390_CLEAR_RESET _IO(KVMIO, 0xc4)1626162616271627-/* Available with KVM_CAP_XSAVE2 */16281628-#define KVM_GET_XSAVE2 _IOR(KVMIO, 0xcf, struct kvm_xsave)16291629-16301627struct kvm_s390_pv_sec_parm {16311628 __u64 origin;16321629 __u64 length;···20442047};2045204820462049#define KVM_GET_STATS_FD _IO(KVMIO, 0xce)20502050+20512051+/* Available with KVM_CAP_XSAVE2 */20522052+#define KVM_GET_XSAVE2 _IOR(KVMIO, 0xcf, struct kvm_xsave)2047205320482054#endif /* __LINUX_KVM_H */
···465465 /*466466 * User provided data if sigtrap=1, passed back to user via467467 * siginfo_t::si_perf_data, e.g. to permit user to identify the event.468468+ * Note, siginfo_t::si_perf_data is long-sized, and sig_data will be469469+ * truncated accordingly on 32 bit architectures.468470 */469471 __u64 sig_data;470472};
···4747/*4848 * Inserts the grant references into the mapping table of an instance4949 * of gntdev. N.B. This does not perform the mapping, which is deferred5050- * until mmap() is called with @index as the offset.5050+ * until mmap() is called with @index as the offset. @index should be5151+ * considered opaque to userspace, with one exception: if no grant5252+ * references have ever been inserted into the mapping table of this5353+ * instance, @index will be set to 0. This is necessary to use gntdev5454+ * with userspace APIs that expect a file descriptor that can be5555+ * mmap()'d at offset 0, such as Wayland. If @count is set to 0, this5656+ * ioctl will fail.5157 */5258#define IOCTL_GNTDEV_MAP_GRANT_REF \5359_IOC(_IOC_NONE, 'G', 0, sizeof(struct ioctl_gntdev_map_grant_ref))
···32383238 return err;32393239}3240324032413241+/*32423242+ * Copy event-type-independent attributes that may be modified.32433243+ */32443244+static void perf_event_modify_copy_attr(struct perf_event_attr *to,32453245+ const struct perf_event_attr *from)32463246+{32473247+ to->sig_data = from->sig_data;32483248+}32493249+32413250static int perf_event_modify_attr(struct perf_event *event,32423251 struct perf_event_attr *attr)32433252{···32693260 WARN_ON_ONCE(event->ctx->parent_ctx);3270326132713262 mutex_lock(&event->child_mutex);32633263+ /*32643264+ * Event-type-independent attributes must be copied before event-type32653265+ * modification, which will validate that final attributes match the32663266+ * source attributes after all relevant attributes have been copied.32673267+ */32683268+ perf_event_modify_copy_attr(&event->attr, attr);32723269 err = func(event, attr);32733270 if (err)32743271 goto out;32753272 list_for_each_entry(child, &event->child_list, child_list) {32733273+ perf_event_modify_copy_attr(&child->attr, attr);32763274 err = func(child, attr);32773275 if (err)32783276 goto out;
···14101410{14111411 unsigned long flags;14121412 struct kmemleak_object *object;14131413- int i;14131413+ struct zone *zone;14141414+ int __maybe_unused i;14141415 int new_leaks = 0;1415141614161417 jiffies_last_scan = jiffies;···14511450 * Struct page scanning for each node.14521451 */14531452 get_online_mems();14541454- for_each_online_node(i) {14551455- unsigned long start_pfn = node_start_pfn(i);14561456- unsigned long end_pfn = node_end_pfn(i);14531453+ for_each_populated_zone(zone) {14541454+ unsigned long start_pfn = zone->zone_start_pfn;14551455+ unsigned long end_pfn = zone_end_pfn(zone);14571456 unsigned long pfn;1458145714591458 for (pfn = start_pfn; pfn < end_pfn; pfn++) {···14621461 if (!page)14631462 continue;1464146314651465- /* only scan pages belonging to this node */14661466- if (page_to_nid(page) != i)14641464+ /* only scan pages belonging to this zone */14651465+ if (page_zone(page) != zone)14671466 continue;14681467 /* only scan if page is in use */14691468 if (page_count(page) == 0)
+1-1
mm/page_isolation.c
···115115 * onlining - just onlined memory won't immediately be considered for116116 * allocation.117117 */118118- if (!isolated_page && PageBuddy(page)) {118118+ if (!isolated_page) {119119 nr_pages = move_freepages_block(zone, page, migratetype, NULL);120120 __mod_zone_freepage_state(zone, nr_pages, migratetype);121121 }
+27-28
mm/page_table_check.c
···8686{8787 struct page_ext *page_ext;8888 struct page *page;8989+ unsigned long i;8990 bool anon;9090- int i;91919292 if (!pfn_valid(pfn))9393 return;···121121{122122 struct page_ext *page_ext;123123 struct page *page;124124+ unsigned long i;124125 bool anon;125125- int i;126126127127 if (!pfn_valid(pfn))128128 return;···152152void __page_table_check_zero(struct page *page, unsigned int order)153153{154154 struct page_ext *page_ext = lookup_page_ext(page);155155- int i;155155+ unsigned long i;156156157157 BUG_ON(!page_ext);158158- for (i = 0; i < (1 << order); i++) {158158+ for (i = 0; i < (1ul << order); i++) {159159 struct page_table_check *ptc = get_page_table_check(page_ext);160160161161 BUG_ON(atomic_read(&ptc->anon_map_count));···206206void __page_table_check_pte_set(struct mm_struct *mm, unsigned long addr,207207 pte_t *ptep, pte_t pte)208208{209209- pte_t old_pte;210210-211209 if (&init_mm == mm)212210 return;213211214214- old_pte = *ptep;215215- if (pte_user_accessible_page(old_pte)) {216216- page_table_check_clear(mm, addr, pte_pfn(old_pte),217217- PAGE_SIZE >> PAGE_SHIFT);218218- }219219-212212+ __page_table_check_pte_clear(mm, addr, *ptep);220213 if (pte_user_accessible_page(pte)) {221214 page_table_check_set(mm, addr, pte_pfn(pte),222215 PAGE_SIZE >> PAGE_SHIFT,···221228void __page_table_check_pmd_set(struct mm_struct *mm, unsigned long addr,222229 pmd_t *pmdp, pmd_t pmd)223230{224224- pmd_t old_pmd;225225-226231 if (&init_mm == mm)227232 return;228233229229- old_pmd = *pmdp;230230- if (pmd_user_accessible_page(old_pmd)) {231231- page_table_check_clear(mm, addr, pmd_pfn(old_pmd),232232- PMD_PAGE_SIZE >> PAGE_SHIFT);233233- }234234-234234+ __page_table_check_pmd_clear(mm, addr, *pmdp);235235 if (pmd_user_accessible_page(pmd)) {236236 page_table_check_set(mm, addr, pmd_pfn(pmd),237237 PMD_PAGE_SIZE >> PAGE_SHIFT,···236250void __page_table_check_pud_set(struct mm_struct *mm, unsigned long addr,237251 pud_t *pudp, pud_t pud)238252{239239- pud_t old_pud;240240-241253 if (&init_mm == mm)242254 return;243255244244- old_pud = *pudp;245245- if (pud_user_accessible_page(old_pud)) {246246- page_table_check_clear(mm, addr, pud_pfn(old_pud),247247- PUD_PAGE_SIZE >> PAGE_SHIFT);248248- }249249-256256+ __page_table_check_pud_clear(mm, addr, *pudp);250257 if (pud_user_accessible_page(pud)) {251258 page_table_check_set(mm, addr, pud_pfn(pud),252259 PUD_PAGE_SIZE >> PAGE_SHIFT,···247268 }248269}249270EXPORT_SYMBOL(__page_table_check_pud_set);271271+272272+void __page_table_check_pte_clear_range(struct mm_struct *mm,273273+ unsigned long addr,274274+ pmd_t pmd)275275+{276276+ if (&init_mm == mm)277277+ return;278278+279279+ if (!pmd_bad(pmd) && !pmd_leaf(pmd)) {280280+ pte_t *ptep = pte_offset_map(&pmd, addr);281281+ unsigned long i;282282+283283+ pte_unmap(ptep);284284+ for (i = 0; i < PTRS_PER_PTE; i++) {285285+ __page_table_check_pte_clear(mm, addr, *ptep);286286+ addr += PAGE_SIZE;287287+ ptep++;288288+ }289289+ }290290+}
···622622}623623624624/* Note: this function might be called multiple times for the same device. */625625-void vlan_dev_uninit(struct net_device *dev)625625+void vlan_dev_free_egress_priority(const struct net_device *dev)626626{627627 struct vlan_priority_tci_mapping *pm;628628 struct vlan_dev_priv *vlan = vlan_dev_priv(dev);···634634 kfree(pm);635635 }636636 }637637+}638638+639639+static void vlan_dev_uninit(struct net_device *dev)640640+{641641+ struct vlan_dev_priv *vlan = vlan_dev_priv(dev);642642+643643+ vlan_dev_free_egress_priority(dev);644644+645645+ /* Get rid of the vlan's reference to real_dev */646646+ dev_put_track(vlan->real_dev, &vlan->dev_tracker);637647}638648639649static netdev_features_t vlan_dev_fix_features(struct net_device *dev,···856846857847 free_percpu(vlan->vlan_pcpu_stats);858848 vlan->vlan_pcpu_stats = NULL;859859-860860- /* Get rid of the vlan's reference to real_dev */861861- dev_put_track(vlan->real_dev, &vlan->dev_tracker);862849}863850864851void vlan_setup(struct net_device *dev)
+4-3
net/8021q/vlan_netlink.c
···183183 return -EINVAL;184184185185 err = vlan_changelink(dev, tb, data, extack);186186- if (!err)187187- err = register_vlan_dev(dev, extack);188186 if (err)189189- vlan_dev_uninit(dev);187187+ return err;188188+ err = register_vlan_dev(dev, extack);189189+ if (err)190190+ vlan_dev_free_egress_priority(dev);190191 return err;191192}192193
+5-2
net/ax25/af_ax25.c
···9191 spin_unlock_bh(&ax25_list_lock);9292 lock_sock(sk);9393 s->ax25_dev = NULL;9494+ dev_put_track(ax25_dev->dev, &ax25_dev->dev_tracker);9495 ax25_dev_put(ax25_dev);9595- release_sock(sk);9696 ax25_disconnect(s, ENETUNREACH);9797+ release_sock(sk);9798 spin_lock_bh(&ax25_list_lock);9899 sock_put(sk);99100 /* The entry could have been deleted from the···11171116 }11181117 }1119111811201120- if (ax25_dev != NULL)11191119+ if (ax25_dev) {11211120 ax25_fillin_cb(ax25, ax25_dev);11211121+ dev_hold_track(ax25_dev->dev, &ax25_dev->dev_tracker, GFP_ATOMIC);11221122+ }1122112311231124done:11241125 ax25_cb_add(ax25);
+22-7
net/can/isotp.c
···5656#include <linux/module.h>5757#include <linux/init.h>5858#include <linux/interrupt.h>5959+#include <linux/spinlock.h>5960#include <linux/hrtimer.h>6061#include <linux/wait.h>6162#include <linux/uio.h>···146145 struct tpcon rx, tx;147146 struct list_head notifier;148147 wait_queue_head_t wait;148148+ spinlock_t rx_lock; /* protect single thread state machine */149149};150150151151static LIST_HEAD(isotp_notifier_list);···617615618616 n_pci_type = cf->data[ae] & 0xF0;619617618618+ /* Make sure the state changes and data structures stay consistent at619619+ * CAN frame reception time. This locking is not needed in real world620620+ * use cases but the inconsistency can be triggered with syzkaller.621621+ */622622+ spin_lock(&so->rx_lock);623623+620624 if (so->opt.flags & CAN_ISOTP_HALF_DUPLEX) {621625 /* check rx/tx path half duplex expectations */622626 if ((so->tx.state != ISOTP_IDLE && n_pci_type != N_PCI_FC) ||623627 (so->rx.state != ISOTP_IDLE && n_pci_type == N_PCI_FC))624624- return;628628+ goto out_unlock;625629 }626630627631 switch (n_pci_type) {···676668 isotp_rcv_cf(sk, cf, ae, skb);677669 break;678670 }671671+672672+out_unlock:673673+ spin_unlock(&so->rx_lock);679674}680675681676static void isotp_fill_dataframe(struct canfd_frame *cf, struct isotp_sock *so,···887876888877 if (!size || size > MAX_MSG_LENGTH) {889878 err = -EINVAL;890890- goto err_out;879879+ goto err_out_drop;891880 }892881893882 /* take care of a potential SF_DL ESC offset for TX_DL > 8 */···897886 if ((so->opt.flags & CAN_ISOTP_SF_BROADCAST) &&898887 (size > so->tx.ll_dl - SF_PCI_SZ4 - ae - off)) {899888 err = -EINVAL;900900- goto err_out;889889+ goto err_out_drop;901890 }902891903892 err = memcpy_from_msg(so->tx.buf, msg, size);904893 if (err < 0)905905- goto err_out;894894+ goto err_out_drop;906895907896 dev = dev_get_by_index(sock_net(sk), so->ifindex);908897 if (!dev) {909898 err = -ENXIO;910910- goto err_out;899899+ goto err_out_drop;911900 }912901913902 skb = sock_alloc_send_skb(sk, so->ll.mtu + sizeof(struct can_skb_priv),914903 msg->msg_flags & MSG_DONTWAIT, &err);915904 if (!skb) {916905 dev_put(dev);917917- goto err_out;906906+ goto err_out_drop;918907 }919908920909 can_skb_reserve(skb);···976965 if (err) {977966 pr_notice_once("can-isotp: %s: can_send_ret %pe\n",978967 __func__, ERR_PTR(err));979979- goto err_out;968968+ goto err_out_drop;980969 }981970982971 if (wait_tx_done) {···989978990979 return size;991980981981+err_out_drop:982982+ /* drop this PDU and unlock a potential wait queue */983983+ old_state = ISOTP_IDLE;992984err_out:993985 so->tx.state = old_state;994986 if (so->tx.state == ISOTP_IDLE)···14581444 so->txtimer.function = isotp_tx_timer_handler;1459144514601446 init_waitqueue_head(&so->wait);14471447+ spin_lock_init(&so->rx_lock);1461144814621449 spin_lock(&isotp_notifier_lock);14631450 list_add_tail(&so->notifier, &isotp_notifier_list);
···515515 ceph_msg_put(con->out_msg);516516 con->out_msg = NULL;517517 }518518+ if (con->bounce_page) {519519+ __free_page(con->bounce_page);520520+ con->bounce_page = NULL;521521+ }518522519523 if (ceph_msgr2(from_msgr(con->msgr)))520524 ceph_con_v2_reset_protocol(con);
+48-6
net/ceph/messenger_v1.c
···992992993993static int read_partial_msg_data(struct ceph_connection *con)994994{995995- struct ceph_msg *msg = con->in_msg;996996- struct ceph_msg_data_cursor *cursor = &msg->cursor;995995+ struct ceph_msg_data_cursor *cursor = &con->in_msg->cursor;997996 bool do_datacrc = !ceph_test_opt(from_msgr(con->msgr), NOCRC);998997 struct page *page;999998 size_t page_offset;1000999 size_t length;10011000 u32 crc = 0;10021001 int ret;10031003-10041004- if (!msg->num_data_items)10051005- return -EIO;1006100210071003 if (do_datacrc)10081004 crc = con->in_data_crc;···10231027 }10241028 if (do_datacrc)10251029 con->in_data_crc = crc;10301030+10311031+ return 1; /* must return > 0 to indicate success */10321032+}10331033+10341034+static int read_partial_msg_data_bounce(struct ceph_connection *con)10351035+{10361036+ struct ceph_msg_data_cursor *cursor = &con->in_msg->cursor;10371037+ struct page *page;10381038+ size_t off, len;10391039+ u32 crc;10401040+ int ret;10411041+10421042+ if (unlikely(!con->bounce_page)) {10431043+ con->bounce_page = alloc_page(GFP_NOIO);10441044+ if (!con->bounce_page) {10451045+ pr_err("failed to allocate bounce page\n");10461046+ return -ENOMEM;10471047+ }10481048+ }10491049+10501050+ crc = con->in_data_crc;10511051+ while (cursor->total_resid) {10521052+ if (!cursor->resid) {10531053+ ceph_msg_data_advance(cursor, 0);10541054+ continue;10551055+ }10561056+10571057+ page = ceph_msg_data_next(cursor, &off, &len, NULL);10581058+ ret = ceph_tcp_recvpage(con->sock, con->bounce_page, 0, len);10591059+ if (ret <= 0) {10601060+ con->in_data_crc = crc;10611061+ return ret;10621062+ }10631063+10641064+ crc = crc32c(crc, page_address(con->bounce_page), ret);10651065+ memcpy_to_page(page, off, page_address(con->bounce_page), ret);10661066+10671067+ ceph_msg_data_advance(cursor, ret);10681068+ }10691069+ con->in_data_crc = crc;1026107010271071 return 1; /* must return > 0 to indicate success */10281072}···1177114111781142 /* (page) data */11791143 if (data_len) {11801180- ret = read_partial_msg_data(con);11441144+ if (!m->num_data_items)11451145+ return -EIO;11461146+11471147+ if (ceph_test_opt(from_msgr(con->msgr), RXBOUNCE))11481148+ ret = read_partial_msg_data_bounce(con);11491149+ else11501150+ ret = read_partial_msg_data(con);11811151 if (ret <= 0)11821152 return ret;11831153 }
+186-64
net/ceph/messenger_v2.c
···5757#define IN_S_HANDLE_CONTROL_REMAINDER 35858#define IN_S_PREPARE_READ_DATA 45959#define IN_S_PREPARE_READ_DATA_CONT 56060-#define IN_S_HANDLE_EPILOGUE 66161-#define IN_S_FINISH_SKIP 76060+#define IN_S_PREPARE_READ_ENC_PAGE 66161+#define IN_S_HANDLE_EPILOGUE 76262+#define IN_S_FINISH_SKIP 862636364#define OUT_S_QUEUE_DATA 16465#define OUT_S_QUEUE_DATA_CONT 2···10331032 padded_len(rem_len) + CEPH_GCM_TAG_LEN);10341033}1035103410361036-static int decrypt_message(struct ceph_connection *con)10351035+static int decrypt_tail(struct ceph_connection *con)10371036{10371037+ struct sg_table enc_sgt = {};10381038 struct sg_table sgt = {};10391039+ int tail_len;10391040 int ret;10411041+10421042+ tail_len = tail_onwire_len(con->in_msg, true);10431043+ ret = sg_alloc_table_from_pages(&enc_sgt, con->v2.in_enc_pages,10441044+ con->v2.in_enc_page_cnt, 0, tail_len,10451045+ GFP_NOIO);10461046+ if (ret)10471047+ goto out;1040104810411049 ret = setup_message_sgs(&sgt, con->in_msg, FRONT_PAD(con->v2.in_buf),10421050 MIDDLE_PAD(con->v2.in_buf), DATA_PAD(con->v2.in_buf),···10531043 if (ret)10541044 goto out;1055104510561056- ret = gcm_crypt(con, false, sgt.sgl, sgt.sgl,10571057- tail_onwire_len(con->in_msg, true));10461046+ dout("%s con %p msg %p enc_page_cnt %d sg_cnt %d\n", __func__, con,10471047+ con->in_msg, con->v2.in_enc_page_cnt, sgt.orig_nents);10481048+ ret = gcm_crypt(con, false, enc_sgt.sgl, sgt.sgl, tail_len);10491049+ if (ret)10501050+ goto out;10511051+10521052+ WARN_ON(!con->v2.in_enc_page_cnt);10531053+ ceph_release_page_vector(con->v2.in_enc_pages,10541054+ con->v2.in_enc_page_cnt);10551055+ con->v2.in_enc_pages = NULL;10561056+ con->v2.in_enc_page_cnt = 0;1058105710591058out:10601059 sg_free_table(&sgt);10601060+ sg_free_table(&enc_sgt);10611061 return ret;10621062}10631063···17531733 return 0;17541734}1755173517561756-static void prepare_read_data(struct ceph_connection *con)17361736+static int prepare_read_data(struct ceph_connection *con)17571737{17581738 struct bio_vec bv;1759173917601760- if (!con_secure(con))17611761- con->in_data_crc = -1;17401740+ con->in_data_crc = -1;17621741 ceph_msg_data_cursor_init(&con->v2.in_cursor, con->in_msg,17631742 data_len(con->in_msg));1764174317651744 get_bvec_at(&con->v2.in_cursor, &bv);17661766- set_in_bvec(con, &bv);17451745+ if (ceph_test_opt(from_msgr(con->msgr), RXBOUNCE)) {17461746+ if (unlikely(!con->bounce_page)) {17471747+ con->bounce_page = alloc_page(GFP_NOIO);17481748+ if (!con->bounce_page) {17491749+ pr_err("failed to allocate bounce page\n");17501750+ return -ENOMEM;17511751+ }17521752+ }17531753+17541754+ bv.bv_page = con->bounce_page;17551755+ bv.bv_offset = 0;17561756+ set_in_bvec(con, &bv);17571757+ } else {17581758+ set_in_bvec(con, &bv);17591759+ }17671760 con->v2.in_state = IN_S_PREPARE_READ_DATA_CONT;17611761+ return 0;17681762}1769176317701764static void prepare_read_data_cont(struct ceph_connection *con)17711765{17721766 struct bio_vec bv;1773176717741774- if (!con_secure(con))17681768+ if (ceph_test_opt(from_msgr(con->msgr), RXBOUNCE)) {17691769+ con->in_data_crc = crc32c(con->in_data_crc,17701770+ page_address(con->bounce_page),17711771+ con->v2.in_bvec.bv_len);17721772+17731773+ get_bvec_at(&con->v2.in_cursor, &bv);17741774+ memcpy_to_page(bv.bv_page, bv.bv_offset,17751775+ page_address(con->bounce_page),17761776+ con->v2.in_bvec.bv_len);17771777+ } else {17751778 con->in_data_crc = ceph_crc32c_page(con->in_data_crc,17761779 con->v2.in_bvec.bv_page,17771780 con->v2.in_bvec.bv_offset,17781781 con->v2.in_bvec.bv_len);17821782+ }1779178317801784 ceph_msg_data_advance(&con->v2.in_cursor, con->v2.in_bvec.bv_len);17811785 if (con->v2.in_cursor.total_resid) {17821786 get_bvec_at(&con->v2.in_cursor, &bv);17831783- set_in_bvec(con, &bv);17871787+ if (ceph_test_opt(from_msgr(con->msgr), RXBOUNCE)) {17881788+ bv.bv_page = con->bounce_page;17891789+ bv.bv_offset = 0;17901790+ set_in_bvec(con, &bv);17911791+ } else {17921792+ set_in_bvec(con, &bv);17931793+ }17841794 WARN_ON(con->v2.in_state != IN_S_PREPARE_READ_DATA_CONT);17851795 return;17861796 }1787179717881798 /*17891789- * We've read all data. Prepare to read data padding (if any)17901790- * and epilogue.17991799+ * We've read all data. Prepare to read epilogue.17911800 */17921801 reset_in_kvecs(con);17931793- if (con_secure(con)) {17941794- if (need_padding(data_len(con->in_msg)))17951795- add_in_kvec(con, DATA_PAD(con->v2.in_buf),17961796- padding_len(data_len(con->in_msg)));17971797- add_in_kvec(con, con->v2.in_buf, CEPH_EPILOGUE_SECURE_LEN);18021802+ add_in_kvec(con, con->v2.in_buf, CEPH_EPILOGUE_PLAIN_LEN);18031803+ con->v2.in_state = IN_S_HANDLE_EPILOGUE;18041804+}18051805+18061806+static int prepare_read_tail_plain(struct ceph_connection *con)18071807+{18081808+ struct ceph_msg *msg = con->in_msg;18091809+18101810+ if (!front_len(msg) && !middle_len(msg)) {18111811+ WARN_ON(!data_len(msg));18121812+ return prepare_read_data(con);18131813+ }18141814+18151815+ reset_in_kvecs(con);18161816+ if (front_len(msg)) {18171817+ add_in_kvec(con, msg->front.iov_base, front_len(msg));18181818+ WARN_ON(msg->front.iov_len != front_len(msg));18191819+ }18201820+ if (middle_len(msg)) {18211821+ add_in_kvec(con, msg->middle->vec.iov_base, middle_len(msg));18221822+ WARN_ON(msg->middle->vec.iov_len != middle_len(msg));18231823+ }18241824+18251825+ if (data_len(msg)) {18261826+ con->v2.in_state = IN_S_PREPARE_READ_DATA;17981827 } else {17991828 add_in_kvec(con, con->v2.in_buf, CEPH_EPILOGUE_PLAIN_LEN);18291829+ con->v2.in_state = IN_S_HANDLE_EPILOGUE;18001830 }18311831+ return 0;18321832+}18331833+18341834+static void prepare_read_enc_page(struct ceph_connection *con)18351835+{18361836+ struct bio_vec bv;18371837+18381838+ dout("%s con %p i %d resid %d\n", __func__, con, con->v2.in_enc_i,18391839+ con->v2.in_enc_resid);18401840+ WARN_ON(!con->v2.in_enc_resid);18411841+18421842+ bv.bv_page = con->v2.in_enc_pages[con->v2.in_enc_i];18431843+ bv.bv_offset = 0;18441844+ bv.bv_len = min(con->v2.in_enc_resid, (int)PAGE_SIZE);18451845+18461846+ set_in_bvec(con, &bv);18471847+ con->v2.in_enc_i++;18481848+ con->v2.in_enc_resid -= bv.bv_len;18491849+18501850+ if (con->v2.in_enc_resid) {18511851+ con->v2.in_state = IN_S_PREPARE_READ_ENC_PAGE;18521852+ return;18531853+ }18541854+18551855+ /*18561856+ * We are set to read the last piece of ciphertext (ending18571857+ * with epilogue) + auth tag.18581858+ */18591859+ WARN_ON(con->v2.in_enc_i != con->v2.in_enc_page_cnt);18011860 con->v2.in_state = IN_S_HANDLE_EPILOGUE;18611861+}18621862+18631863+static int prepare_read_tail_secure(struct ceph_connection *con)18641864+{18651865+ struct page **enc_pages;18661866+ int enc_page_cnt;18671867+ int tail_len;18681868+18691869+ tail_len = tail_onwire_len(con->in_msg, true);18701870+ WARN_ON(!tail_len);18711871+18721872+ enc_page_cnt = calc_pages_for(0, tail_len);18731873+ enc_pages = ceph_alloc_page_vector(enc_page_cnt, GFP_NOIO);18741874+ if (IS_ERR(enc_pages))18751875+ return PTR_ERR(enc_pages);18761876+18771877+ WARN_ON(con->v2.in_enc_pages || con->v2.in_enc_page_cnt);18781878+ con->v2.in_enc_pages = enc_pages;18791879+ con->v2.in_enc_page_cnt = enc_page_cnt;18801880+ con->v2.in_enc_resid = tail_len;18811881+ con->v2.in_enc_i = 0;18821882+18831883+ prepare_read_enc_page(con);18841884+ return 0;18021885}1803188618041887static void __finish_skip(struct ceph_connection *con)···27122589 }2713259027142591 msg = con->in_msg; /* set in process_message_header() */27152715- if (!front_len(msg) && !middle_len(msg)) {27162716- if (!data_len(msg))27172717- return process_message(con);27182718-27192719- prepare_read_data(con);27202720- return 0;27212721- }27222722-27232723- reset_in_kvecs(con);27242592 if (front_len(msg)) {27252593 WARN_ON(front_len(msg) > msg->front_alloc_len);27262726- add_in_kvec(con, msg->front.iov_base, front_len(msg));27272594 msg->front.iov_len = front_len(msg);27282728-27292729- if (con_secure(con) && need_padding(front_len(msg)))27302730- add_in_kvec(con, FRONT_PAD(con->v2.in_buf),27312731- padding_len(front_len(msg)));27322595 } else {27332596 msg->front.iov_len = 0;27342597 }27352598 if (middle_len(msg)) {27362599 WARN_ON(middle_len(msg) > msg->middle->alloc_len);27372737- add_in_kvec(con, msg->middle->vec.iov_base, middle_len(msg));27382600 msg->middle->vec.iov_len = middle_len(msg);27392739-27402740- if (con_secure(con) && need_padding(middle_len(msg)))27412741- add_in_kvec(con, MIDDLE_PAD(con->v2.in_buf),27422742- padding_len(middle_len(msg)));27432601 } else if (msg->middle) {27442602 msg->middle->vec.iov_len = 0;27452603 }2746260427472747- if (data_len(msg)) {27482748- con->v2.in_state = IN_S_PREPARE_READ_DATA;27492749- } else {27502750- add_in_kvec(con, con->v2.in_buf,27512751- con_secure(con) ? CEPH_EPILOGUE_SECURE_LEN :27522752- CEPH_EPILOGUE_PLAIN_LEN);27532753- con->v2.in_state = IN_S_HANDLE_EPILOGUE;27542754- }27552755- return 0;26052605+ if (!front_len(msg) && !middle_len(msg) && !data_len(msg))26062606+ return process_message(con);26072607+26082608+ if (con_secure(con))26092609+ return prepare_read_tail_secure(con);26102610+26112611+ return prepare_read_tail_plain(con);27562612}2757261327582614static int handle_preamble(struct ceph_connection *con)···28192717 int ret;2820271828212719 if (con_secure(con)) {28222822- ret = decrypt_message(con);27202720+ ret = decrypt_tail(con);28232721 if (ret) {28242722 if (ret == -EBADMSG)28252723 con->error_msg = "integrity error, bad epilogue auth tag";···28872785 ret = handle_control_remainder(con);28882786 break;28892787 case IN_S_PREPARE_READ_DATA:28902890- prepare_read_data(con);28912891- ret = 0;27882788+ ret = prepare_read_data(con);28922789 break;28932790 case IN_S_PREPARE_READ_DATA_CONT:28942791 prepare_read_data_cont(con);27922792+ ret = 0;27932793+ break;27942794+ case IN_S_PREPARE_READ_ENC_PAGE:27952795+ prepare_read_enc_page(con);28952796 ret = 0;28962797 break;28972798 case IN_S_HANDLE_EPILOGUE:···3431332634323327static void revoke_at_prepare_read_data(struct ceph_connection *con)34333328{34343434- int remaining; /* data + [data padding] + epilogue */33293329+ int remaining;34353330 int resid;3436333133323332+ WARN_ON(con_secure(con));34373333 WARN_ON(!data_len(con->in_msg));34383334 WARN_ON(!iov_iter_is_kvec(&con->v2.in_iter));34393335 resid = iov_iter_count(&con->v2.in_iter);34403336 WARN_ON(!resid);3441333734423442- if (con_secure(con))34433443- remaining = padded_len(data_len(con->in_msg)) +34443444- CEPH_EPILOGUE_SECURE_LEN;34453445- else34463446- remaining = data_len(con->in_msg) + CEPH_EPILOGUE_PLAIN_LEN;34473447-33383338+ remaining = data_len(con->in_msg) + CEPH_EPILOGUE_PLAIN_LEN;34483339 dout("%s con %p resid %d remaining %d\n", __func__, con, resid,34493340 remaining);34503341 con->v2.in_iter.count -= resid;···34513350static void revoke_at_prepare_read_data_cont(struct ceph_connection *con)34523351{34533352 int recved, resid; /* current piece of data */34543454- int remaining; /* [data padding] + epilogue */33533353+ int remaining;3455335433553355+ WARN_ON(con_secure(con));34563356 WARN_ON(!data_len(con->in_msg));34573357 WARN_ON(!iov_iter_is_bvec(&con->v2.in_iter));34583358 resid = iov_iter_count(&con->v2.in_iter);···34653363 ceph_msg_data_advance(&con->v2.in_cursor, recved);34663364 WARN_ON(resid > con->v2.in_cursor.total_resid);3467336534683468- if (con_secure(con))34693469- remaining = padding_len(data_len(con->in_msg)) +34703470- CEPH_EPILOGUE_SECURE_LEN;34713471- else34723472- remaining = CEPH_EPILOGUE_PLAIN_LEN;34733473-33663366+ remaining = CEPH_EPILOGUE_PLAIN_LEN;34743367 dout("%s con %p total_resid %zu remaining %d\n", __func__, con,34753368 con->v2.in_cursor.total_resid, remaining);34763369 con->v2.in_iter.count -= resid;···34733376 con->v2.in_state = IN_S_FINISH_SKIP;34743377}3475337833793379+static void revoke_at_prepare_read_enc_page(struct ceph_connection *con)33803380+{33813381+ int resid; /* current enc page (not necessarily data) */33823382+33833383+ WARN_ON(!con_secure(con));33843384+ WARN_ON(!iov_iter_is_bvec(&con->v2.in_iter));33853385+ resid = iov_iter_count(&con->v2.in_iter);33863386+ WARN_ON(!resid || resid > con->v2.in_bvec.bv_len);33873387+33883388+ dout("%s con %p resid %d enc_resid %d\n", __func__, con, resid,33893389+ con->v2.in_enc_resid);33903390+ con->v2.in_iter.count -= resid;33913391+ set_in_skip(con, resid + con->v2.in_enc_resid);33923392+ con->v2.in_state = IN_S_FINISH_SKIP;33933393+}33943394+34763395static void revoke_at_handle_epilogue(struct ceph_connection *con)34773396{34783397 int resid;3479339834803480- WARN_ON(!iov_iter_is_kvec(&con->v2.in_iter));34813399 resid = iov_iter_count(&con->v2.in_iter);34823400 WARN_ON(!resid);34833401···35103398 break;35113399 case IN_S_PREPARE_READ_DATA_CONT:35123400 revoke_at_prepare_read_data_cont(con);34013401+ break;34023402+ case IN_S_PREPARE_READ_ENC_PAGE:34033403+ revoke_at_prepare_read_enc_page(con);35133404 break;35143405 case IN_S_HANDLE_EPILOGUE:35153406 revoke_at_handle_epilogue(con);···35473432 clear_out_sign_kvecs(con);35483433 free_conn_bufs(con);3549343434353435+ if (con->v2.in_enc_pages) {34363436+ WARN_ON(!con->v2.in_enc_page_cnt);34373437+ ceph_release_page_vector(con->v2.in_enc_pages,34383438+ con->v2.in_enc_page_cnt);34393439+ con->v2.in_enc_pages = NULL;34403440+ con->v2.in_enc_page_cnt = 0;34413441+ }35503442 if (con->v2.out_enc_pages) {35513443 WARN_ON(!con->v2.out_enc_page_cnt);35523444 ceph_release_page_vector(con->v2.out_enc_pages,
+1-1
net/core/skbuff.c
···681681 * while trying to recycle fragments on __skb_frag_unref() we need682682 * to make one SKB responsible for triggering the recycle path.683683 * So disable the recycling bit if an SKB is cloned and we have684684- * additional references to to the fragmented part of the SKB.684684+ * additional references to the fragmented part of the SKB.685685 * Eventually the last SKB will have the recycling bit set and it's686686 * dataref set to 0, which will trigger the recycling687687 */
+6-19
net/dsa/dsa2.c
···17841784void dsa_switch_shutdown(struct dsa_switch *ds)17851785{17861786 struct net_device *master, *slave_dev;17871787- LIST_HEAD(unregister_list);17881787 struct dsa_port *dp;1789178817901789 mutex_lock(&dsa2_mutex);···17941795 slave_dev = dp->slave;1795179617961797 netdev_upper_dev_unlink(master, slave_dev);17971797- /* Just unlinking ourselves as uppers of the master is not17981798- * sufficient. When the master net device unregisters, that will17991799- * also call dev_close, which we will catch as NETDEV_GOING_DOWN18001800- * and trigger a dev_close on our own devices (dsa_slave_close).18011801- * In turn, that will call dev_mc_unsync on the master's net18021802- * device. If the master is also a DSA switch port, this will18031803- * trigger dsa_slave_set_rx_mode which will call dev_mc_sync on18041804- * its own master. Lockdep will complain about the fact that18051805- * all cascaded masters have the same dsa_master_addr_list_lock_key,18061806- * which it normally would not do if the cascaded masters would18071807- * be in a proper upper/lower relationship, which we've just18081808- * destroyed.18091809- * To suppress the lockdep warnings, let's actually unregister18101810- * the DSA slave interfaces too, to avoid the nonsensical18111811- * multicast address list synchronization on shutdown.18121812- */18131813- unregister_netdevice_queue(slave_dev, &unregister_list);18141798 }18151815- unregister_netdevice_many(&unregister_list);17991799+18001800+ /* Disconnect from further netdevice notifiers on the master,18011801+ * since netdev_uses_dsa() will now return false.18021802+ */18031803+ dsa_switch_for_each_cpu_port(dp, ds)18041804+ dp->master->dsa_ptr = NULL;1816180518171806 rtnl_unlock();18181807 mutex_unlock(&dsa2_mutex);
···23212321 if (helper->from_nlattr)23222322 helper->from_nlattr(helpinfo, ct);2323232323242324- /* not in hash table yet so not strictly necessary */23242324+ /* disable helper auto-assignment for this entry */23252325+ ct->status |= IPS_HELPER;23252326 RCU_INIT_POINTER(help->helper, helper);23262327 }23272328 } else {
+9
net/netfilter/nf_conntrack_proto_sctp.c
···489489 pr_debug("Setting vtag %x for dir %d\n",490490 ih->init_tag, !dir);491491 ct->proto.sctp.vtag[!dir] = ih->init_tag;492492+493493+ /* don't renew timeout on init retransmit so494494+ * port reuse by client or NAT middlebox cannot495495+ * keep entry alive indefinitely (incl. nat info).496496+ */497497+ if (new_state == SCTP_CONNTRACK_CLOSED &&498498+ old_state == SCTP_CONNTRACK_CLOSED &&499499+ nf_ct_is_confirmed(ct))500500+ ignore = true;492501 }493502494503 ct->proto.sctp.state = new_state;
+41-18
net/netfilter/nf_conntrack_proto_tcp.c
···446446 }447447}448448449449+static void tcp_init_sender(struct ip_ct_tcp_state *sender,450450+ struct ip_ct_tcp_state *receiver,451451+ const struct sk_buff *skb,452452+ unsigned int dataoff,453453+ const struct tcphdr *tcph,454454+ u32 end, u32 win)455455+{456456+ /* SYN-ACK in reply to a SYN457457+ * or SYN from reply direction in simultaneous open.458458+ */459459+ sender->td_end =460460+ sender->td_maxend = end;461461+ sender->td_maxwin = (win == 0 ? 1 : win);462462+463463+ tcp_options(skb, dataoff, tcph, sender);464464+ /* RFC 1323:465465+ * Both sides must send the Window Scale option466466+ * to enable window scaling in either direction.467467+ */468468+ if (!(sender->flags & IP_CT_TCP_FLAG_WINDOW_SCALE &&469469+ receiver->flags & IP_CT_TCP_FLAG_WINDOW_SCALE)) {470470+ sender->td_scale = 0;471471+ receiver->td_scale = 0;472472+ }473473+}474474+449475static bool tcp_in_window(struct nf_conn *ct,450476 enum ip_conntrack_dir dir,451477 unsigned int index,···525499 * Initialize sender data.526500 */527501 if (tcph->syn) {528528- /*529529- * SYN-ACK in reply to a SYN530530- * or SYN from reply direction in simultaneous open.531531- */532532- sender->td_end =533533- sender->td_maxend = end;534534- sender->td_maxwin = (win == 0 ? 1 : win);535535-536536- tcp_options(skb, dataoff, tcph, sender);537537- /*538538- * RFC 1323:539539- * Both sides must send the Window Scale option540540- * to enable window scaling in either direction.541541- */542542- if (!(sender->flags & IP_CT_TCP_FLAG_WINDOW_SCALE543543- && receiver->flags & IP_CT_TCP_FLAG_WINDOW_SCALE))544544- sender->td_scale =545545- receiver->td_scale = 0;502502+ tcp_init_sender(sender, receiver,503503+ skb, dataoff, tcph,504504+ end, win);546505 if (!tcph->ack)547506 /* Simultaneous open */548507 return true;···571560 sender->td_maxwin = (win == 0 ? 1 : win);572561573562 tcp_options(skb, dataoff, tcph, sender);563563+ } else if (tcph->syn && dir == IP_CT_DIR_REPLY &&564564+ state->state == TCP_CONNTRACK_SYN_SENT) {565565+ /* Retransmitted syn-ack, or syn (simultaneous open).566566+ *567567+ * Re-init state for this direction, just like for the first568568+ * syn(-ack) reply, it might differ in seq, ack or tcp options.569569+ */570570+ tcp_init_sender(sender, receiver,571571+ skb, dataoff, tcph,572572+ end, win);573573+ if (!tcph->ack)574574+ return true;574575 }575576576577 if (!(tcph->ack)) {
···1967196719681968 rcu_read_lock();1969196919701970+ /* Do not print rules with inactive LSM labels */19711971+ for (i = 0; i < MAX_LSM_RULES; i++) {19721972+ if (entry->lsm[i].args_p && !entry->lsm[i].rule) {19731973+ rcu_read_unlock();19741974+ return 0;19751975+ }19761976+ }19771977+19701978 if (entry->action & MEASURE)19711979 seq_puts(m, pt(Opt_measure));19721980 if (entry->action & DONT_MEASURE)
+7-3
security/integrity/ima/ima_template.c
···29293030static LIST_HEAD(defined_templates);3131static DEFINE_SPINLOCK(template_list);3232+static int template_setup_done;32333334static const struct ima_template_field supported_fields[] = {3435 {.field_id = "d", .field_init = ima_eventdigest_init,···102101 struct ima_template_desc *template_desc;103102 int template_len = strlen(str);104103105105- if (ima_template)104104+ if (template_setup_done)106105 return 1;107106108108- ima_init_template_list();107107+ if (!ima_template)108108+ ima_init_template_list();109109110110 /*111111 * Verify that a template with the supplied name exists.···130128 }131129132130 ima_template = template_desc;131131+ template_setup_done = 1;133132 return 1;134133}135134__setup("ima_template=", ima_template_setup);···139136{140137 int num_templates = ARRAY_SIZE(builtin_templates);141138142142- if (ima_template)139139+ if (template_setup_done)143140 return 1;144141145142 if (template_desc_init_fields(str, NULL, NULL) < 0) {···150147151148 builtin_templates[num_templates - 1].fmt = str;152149 ima_template = builtin_templates + num_templates - 1;150150+ template_setup_done = 1;153151154152 return 1;155153}
+2
security/integrity/integrity_audit.c
···4545 return;46464747 ab = audit_log_start(audit_context(), GFP_KERNEL, audit_msgno);4848+ if (!ab)4949+ return;4850 audit_log_format(ab, "pid=%d uid=%u auid=%u ses=%u",4951 task_pid_nr(current),5052 from_kuid(&init_user_ns, current_uid()),
+13
sound/core/pcm_native.c
···172172}173173EXPORT_SYMBOL_GPL(_snd_pcm_stream_lock_irqsave);174174175175+unsigned long _snd_pcm_stream_lock_irqsave_nested(struct snd_pcm_substream *substream)176176+{177177+ unsigned long flags = 0;178178+ if (substream->pcm->nonatomic)179179+ mutex_lock_nested(&substream->self_group.mutex,180180+ SINGLE_DEPTH_NESTING);181181+ else182182+ spin_lock_irqsave_nested(&substream->self_group.lock, flags,183183+ SINGLE_DEPTH_NESTING);184184+ return flags;185185+}186186+EXPORT_SYMBOL_GPL(_snd_pcm_stream_lock_irqsave_nested);187187+175188/**176189 * snd_pcm_stream_unlock_irqrestore - Unlock the PCM stream177190 * @substream: PCM substream
···981981 int id = HDA_FIXUP_ID_NOT_SET;982982 const char *name = NULL;983983 const char *type = NULL;984984- int vendor, device;984984+ unsigned int vendor, device;985985986986 if (codec->fixup_id != HDA_FIXUP_ID_NOT_SET)987987 return;
+4
sound/pci/hda/hda_codec.c
···30003000{30013001 struct hda_pcm *cpcm;3002300230033003+ /* Skip the shutdown if codec is not registered */30043004+ if (!codec->registered)30053005+ return;30063006+30033007 list_for_each_entry(cpcm, &codec->pcm_list_head, list)30043008 snd_pcm_suspend_all(cpcm->pcm);30053009
···9393 dev_err(&op->dev, "platform_device_alloc() failed\n");94949595 ret = platform_device_add(pdata->codec_device);9696- if (ret)9696+ if (ret) {9797 dev_err(&op->dev, "platform_device_add() failed: %d\n", ret);9898+ platform_device_put(pdata->codec_device);9999+ }9810099101 ret = snd_soc_register_card(card);100100- if (ret)102102+ if (ret) {101103 dev_err(&op->dev, "snd_soc_register_card() failed: %d\n", ret);104104+ platform_device_del(pdata->codec_device);105105+ platform_device_put(pdata->codec_device);106106+ }102107103108 platform_set_drvdata(op, pdata);104104-105109 return ret;110110+106111}107112108113static int pcm030_fabric_remove(struct platform_device *op)
+25-1
sound/soc/generic/simple-card.c
···2828 .hw_params = asoc_simple_hw_params,2929};30303131+static int asoc_simple_parse_platform(struct device_node *node,3232+ struct snd_soc_dai_link_component *dlc)3333+{3434+ struct of_phandle_args args;3535+ int ret;3636+3737+ if (!node)3838+ return 0;3939+4040+ /*4141+ * Get node via "sound-dai = <&phandle port>"4242+ * it will be used as xxx_of_node on soc_bind_dai_link()4343+ */4444+ ret = of_parse_phandle_with_args(node, DAI, CELL, 0, &args);4545+ if (ret)4646+ return ret;4747+4848+ /* dai_name is not required and may not exist for plat component */4949+5050+ dlc->of_node = args.np;5151+5252+ return 0;5353+}5454+3155static int asoc_simple_parse_dai(struct device_node *node,3256 struct snd_soc_dai_link_component *dlc,3357 int *is_single_link)···313289 if (ret < 0)314290 goto dai_link_of_err;315291316316- ret = asoc_simple_parse_dai(plat, platforms, NULL);292292+ ret = asoc_simple_parse_platform(plat, platforms);317293 if (ret < 0)318294 goto dai_link_of_err;319295
+1-1
sound/soc/mediatek/Kconfig
···216216217217config SND_SOC_MT8195_MT6359_RT1011_RT5682218218 tristate "ASoC Audio driver for MT8195 with MT6359 RT1011 RT5682 codec"219219- depends on I2C219219+ depends on I2C && GPIOLIB220220 depends on SND_SOC_MT8195 && MTK_PMIC_WRAP221221 select SND_SOC_MT6359222222 select SND_SOC_RT1011
+5-2
sound/soc/qcom/qdsp6/q6apm-dai.c
···308308 struct snd_pcm_runtime *runtime = substream->runtime;309309 struct q6apm_dai_rtd *prtd = runtime->private_data;310310311311- q6apm_graph_stop(prtd->graph);312312- q6apm_unmap_memory_regions(prtd->graph, substream->stream);311311+ if (prtd->state) { /* only stop graph that is started */312312+ q6apm_graph_stop(prtd->graph);313313+ q6apm_unmap_memory_regions(prtd->graph, substream->stream);314314+ }315315+313316 q6apm_graph_close(prtd->graph);314317 prtd->graph = NULL;315318 kfree(prtd);
···316316 if (sign_bit)317317 mask = BIT(sign_bit + 1) - 1;318318319319- val = ((ucontrol->value.integer.value[0] + min) & mask);319319+ if (ucontrol->value.integer.value[0] < 0)320320+ return -EINVAL;321321+ val = ucontrol->value.integer.value[0];322322+ if (mc->platform_max && val > mc->platform_max)323323+ return -EINVAL;324324+ if (val > max - min)325325+ return -EINVAL;326326+ val = (val + min) & mask;320327 if (invert)321328 val = max - val;322329 val_mask = mask << shift;323330 val = val << shift;324331 if (snd_soc_volsw_is_stereo(mc)) {325325- val2 = ((ucontrol->value.integer.value[1] + min) & mask);332332+ if (ucontrol->value.integer.value[1] < 0)333333+ return -EINVAL;334334+ val2 = ucontrol->value.integer.value[1];335335+ if (mc->platform_max && val2 > mc->platform_max)336336+ return -EINVAL;337337+ if (val2 > max - min)338338+ return -EINVAL;339339+ val2 = (val2 + min) & mask;326340 if (invert)327341 val2 = max - val2;328342 if (reg == reg2) {···423409 int err = 0;424410 unsigned int val, val_mask;425411412412+ if (ucontrol->value.integer.value[0] < 0)413413+ return -EINVAL;414414+ val = ucontrol->value.integer.value[0];415415+ if (mc->platform_max && val > mc->platform_max)416416+ return -EINVAL;417417+ if (val > max - min)418418+ return -EINVAL;426419 val_mask = mask << shift;427427- val = (ucontrol->value.integer.value[0] + min) & mask;420420+ val = (val + min) & mask;428421 val = val << shift;429422430423 err = snd_soc_component_update_bits(component, reg, val_mask, val);···879858 long val = ucontrol->value.integer.value[0];880859 unsigned int i;881860861861+ if (val < mc->min || val > mc->max)862862+ return -EINVAL;882863 if (invert)883864 val = max - val;884865 val &= mask;
+13-7
sound/soc/soc-pcm.c
···4646 snd_pcm_stream_lock_irq(snd_soc_dpcm_get_substream(rtd, stream));4747}48484949-#define snd_soc_dpcm_stream_lock_irqsave(rtd, stream, flags) \5050- snd_pcm_stream_lock_irqsave(snd_soc_dpcm_get_substream(rtd, stream), flags)4949+#define snd_soc_dpcm_stream_lock_irqsave_nested(rtd, stream, flags) \5050+ snd_pcm_stream_lock_irqsave_nested(snd_soc_dpcm_get_substream(rtd, stream), flags)51515252static inline void snd_soc_dpcm_stream_unlock_irq(struct snd_soc_pcm_runtime *rtd,5353 int stream)···12681268void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream)12691269{12701270 struct snd_soc_dpcm *dpcm, *d;12711271+ LIST_HEAD(deleted_dpcms);1271127212721273 snd_soc_dpcm_mutex_assert_held(fe);12731274···12881287 /* BEs still alive need new FE */12891288 dpcm_be_reparent(fe, dpcm->be, stream);1290128912911291- dpcm_remove_debugfs_state(dpcm);12921292-12931290 list_del(&dpcm->list_be);12941294- list_del(&dpcm->list_fe);12951295- kfree(dpcm);12911291+ list_move(&dpcm->list_fe, &deleted_dpcms);12961292 }12971293 snd_soc_dpcm_stream_unlock_irq(fe, stream);12941294+12951295+ while (!list_empty(&deleted_dpcms)) {12961296+ dpcm = list_first_entry(&deleted_dpcms, struct snd_soc_dpcm,12971297+ list_fe);12981298+ list_del(&dpcm->list_fe);12991299+ dpcm_remove_debugfs_state(dpcm);13001300+ kfree(dpcm);13011301+ }12981302}1299130313001304/* get BE for DAI widget and stream */···21002094 be = dpcm->be;21012095 be_substream = snd_soc_dpcm_get_substream(be, stream);2102209621032103- snd_soc_dpcm_stream_lock_irqsave(be, stream, flags);20972097+ snd_soc_dpcm_stream_lock_irqsave_nested(be, stream, flags);2104209821052099 /* is this op for this BE ? */21062100 if (!snd_soc_dpcm_be_can_update(fe, be, stream))
+24-3
sound/soc/xilinx/xlnx_formatter_pcm.c
···3737#define XLNX_AUD_XFER_COUNT 0x283838#define XLNX_AUD_CH_STS_START 0x2C3939#define XLNX_BYTES_PER_CH 0x444040+#define XLNX_AUD_ALIGN_BYTES 6440414142#define AUD_STS_IOC_IRQ_MASK BIT(31)4243#define AUD_STS_CH_STS_MASK BIT(29)···369368 snd_soc_set_runtime_hwparams(substream, &xlnx_pcm_hardware);370369 runtime->private_data = stream_data;371370372372- /* Resize the period size divisible by 64 */371371+ /* Resize the period bytes as divisible by 64 */373372 err = snd_pcm_hw_constraint_step(runtime, 0,374374- SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64);373373+ SNDRV_PCM_HW_PARAM_PERIOD_BYTES,374374+ XLNX_AUD_ALIGN_BYTES);375375 if (err) {376376 dev_err(component->dev,377377- "unable to set constraint on period bytes\n");377377+ "Unable to set constraint on period bytes\n");378378+ return err;379379+ }380380+381381+ /* Resize the buffer bytes as divisible by 64 */382382+ err = snd_pcm_hw_constraint_step(runtime, 0,383383+ SNDRV_PCM_HW_PARAM_BUFFER_BYTES,384384+ XLNX_AUD_ALIGN_BYTES);385385+ if (err) {386386+ dev_err(component->dev,387387+ "Unable to set constraint on buffer bytes\n");388388+ return err;389389+ }390390+391391+ /* Set periods as integer multiple */392392+ err = snd_pcm_hw_constraint_integer(runtime,393393+ SNDRV_PCM_HW_PARAM_PERIODS);394394+ if (err < 0) {395395+ dev_err(component->dev,396396+ "Unable to set constraint on periods to be integer\n");378397 return err;379398 }380399
···5656 * *5757 ****************************************************************************/58585959+#define AES_IEC958_STATUS_SIZE 246060+5961struct snd_aes_iec958 {6060- unsigned char status[24]; /* AES/IEC958 channel status bits */6262+ unsigned char status[AES_IEC958_STATUS_SIZE]; /* AES/IEC958 channel status bits */6163 unsigned char subcode[147]; /* AES/IEC958 subcode bits */6264 unsigned char pad; /* nothing */6365 unsigned char dig_subframe[4]; /* AES/IEC958 subframe bits */···204202#define SNDRV_PCM_FORMAT_S24_BE ((__force snd_pcm_format_t) 7) /* low three bytes */205203#define SNDRV_PCM_FORMAT_U24_LE ((__force snd_pcm_format_t) 8) /* low three bytes */206204#define SNDRV_PCM_FORMAT_U24_BE ((__force snd_pcm_format_t) 9) /* low three bytes */205205+/*206206+ * For S32/U32 formats, 'msbits' hardware parameter is often used to deliver information about the207207+ * available bit count in most significant bit. It's for the case of so-called 'left-justified' or208208+ * `right-padding` sample which has less width than 32 bit.209209+ */207210#define SNDRV_PCM_FORMAT_S32_LE ((__force snd_pcm_format_t) 10)208211#define SNDRV_PCM_FORMAT_S32_BE ((__force snd_pcm_format_t) 11)209212#define SNDRV_PCM_FORMAT_U32_LE ((__force snd_pcm_format_t) 12)···307300#define SNDRV_PCM_INFO_HAS_LINK_ESTIMATED_ATIME 0x04000000 /* report estimated link audio time */308301#define SNDRV_PCM_INFO_HAS_LINK_SYNCHRONIZED_ATIME 0x08000000 /* report synchronized audio/system time */309302#define SNDRV_PCM_INFO_EXPLICIT_SYNC 0x10000000 /* needs explicit sync of pointers and data */310310-303303+#define SNDRV_PCM_INFO_NO_REWINDS 0x20000000 /* hardware can only support monotonic changes of appl_ptr */311304#define SNDRV_PCM_INFO_DRAIN_TRIGGER 0x40000000 /* internal kernel flag - trigger in drain */312305#define SNDRV_PCM_INFO_FIFO_IN_FRAMES 0x80000000 /* internal kernel flag - FIFO size is in frames */313306
···585585586586 alias = list_prepare_entry(counter, &(evlist->core.entries), core.node);587587 list_for_each_entry_continue (alias, &evlist->core.entries, core.node) {588588- if (strcmp(evsel__name(alias), evsel__name(counter)) ||589589- alias->scale != counter->scale ||590590- alias->cgrp != counter->cgrp ||591591- strcmp(alias->unit, counter->unit) ||592592- evsel__is_clock(alias) != evsel__is_clock(counter) ||593593- !strcmp(alias->pmu_name, counter->pmu_name))594594- break;595595- alias->merged_stat = true;596596- cb(config, alias, data, false);588588+ /* Merge events with the same name, etc. but on different PMUs. */589589+ if (!strcmp(evsel__name(alias), evsel__name(counter)) &&590590+ alias->scale == counter->scale &&591591+ alias->cgrp == counter->cgrp &&592592+ !strcmp(alias->unit, counter->unit) &&593593+ evsel__is_clock(alias) == evsel__is_clock(counter) &&594594+ strcmp(alias->pmu_name, counter->pmu_name)) {595595+ alias->merged_stat = true;596596+ cb(config, alias, data, false);597597+ }597598 }598599}599600
+19
tools/perf/util/synthetic-events.c
···17841784 perf_event__handler_t process, bool needs_mmap,17851785 bool data_mmap, unsigned int nr_threads_synthesize)17861786{17871787+ /*17881788+ * When perf runs in non-root PID namespace, and the namespace's proc FS17891789+ * is not mounted, nsinfo__is_in_root_namespace() returns false.17901790+ * In this case, the proc FS is coming for the parent namespace, thus17911791+ * perf tool will wrongly gather process info from its parent PID17921792+ * namespace.17931793+ *17941794+ * To avoid the confusion that the perf tool runs in a child PID17951795+ * namespace but it synthesizes thread info from its parent PID17961796+ * namespace, returns failure with warning.17971797+ */17981798+ if (!nsinfo__is_in_root_namespace()) {17991799+ pr_err("Perf runs in non-root PID namespace but it tries to ");18001800+ pr_err("gather process info from its parent PID namespace.\n");18011801+ pr_err("Please mount the proc file system properly, e.g. ");18021802+ pr_err("add the option '--mount-proc' for unshare command.\n");18031803+ return -EPERM;18041804+ }18051805+17871806 if (target__has_task(target))17881807 return perf_event__synthesize_thread_map(tool, threads, process, machine,17891808 needs_mmap, data_mmap);
···2929#define SYSFS_PATH_MAX 2563030#define DNAME_PATH_MAX 25631313232+/*3333+ * Support ancient lirc.h which does not have these values. Can be removed3434+ * once RHEL 8 is no longer a relevant testing platform.3535+ */3636+#if RC_PROTO_MAX < 263737+#define RC_PROTO_RCMM12 243838+#define RC_PROTO_RCMM24 253939+#define RC_PROTO_RCMM32 264040+#endif4141+3242static const struct {3343 enum rc_proto proto;3444 const char *name;
+1
tools/testing/selftests/net/mptcp/mptcp_join.sh
···12991299 pm_nl_add_endpoint $ns2 10.0.3.2 flags signal13001300 pm_nl_add_endpoint $ns2 10.0.4.2 flags signal13011301 run_tests $ns1 $ns2 10.0.1.113021302+ chk_join_nr "signal addresses race test" 3 3 31302130313031304 # the server will not signal the address terminating13041305 # the MPC subflow