diff --git a/patch/kernel/archive/sunxi-5.13/patch-1-5.13.7-8.patch b/patch/kernel/archive/sunxi-5.13/patch-1-5.13.7-8.patch deleted file mode 100644 index f6a05d4bf4..0000000000 --- a/patch/kernel/archive/sunxi-5.13/patch-1-5.13.7-8.patch +++ /dev/null @@ -1,4318 +0,0 @@ -diff --git a/Makefile b/Makefile -index 614327400aea2..fdb4e2fd9d8f3 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,7 +1,7 @@ - # SPDX-License-Identifier: GPL-2.0 - VERSION = 5 - PATCHLEVEL = 13 --SUBLEVEL = 7 -+SUBLEVEL = 8 - EXTRAVERSION = - NAME = Opossums on Parade - -diff --git a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c -index 03dda3beb3bd4..e5ec9b9b73a1d 100644 ---- a/arch/alpha/kernel/setup.c -+++ b/arch/alpha/kernel/setup.c -@@ -325,18 +325,19 @@ setup_memory(void *kernel_end) - i, cluster->usage, cluster->start_pfn, - cluster->start_pfn + cluster->numpages); - -- /* Bit 0 is console/PALcode reserved. Bit 1 is -- non-volatile memory -- we might want to mark -- this for later. */ -- if (cluster->usage & 3) -- continue; -- - end = cluster->start_pfn + cluster->numpages; - if (end > max_low_pfn) - max_low_pfn = end; - - memblock_add(PFN_PHYS(cluster->start_pfn), - cluster->numpages << PAGE_SHIFT); -+ -+ /* Bit 0 is console/PALcode reserved. Bit 1 is -+ non-volatile memory -- we might want to mark -+ this for later. */ -+ if (cluster->usage & 3) -+ memblock_reserve(PFN_PHYS(cluster->start_pfn), -+ cluster->numpages << PAGE_SHIFT); - } - - /* -diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c -index 897634d0a67ca..a951276f05475 100644 ---- a/arch/arm/net/bpf_jit_32.c -+++ b/arch/arm/net/bpf_jit_32.c -@@ -1602,6 +1602,9 @@ exit: - rn = arm_bpf_get_reg32(src_lo, tmp2[1], ctx); - emit_ldx_r(dst, rn, off, ctx, BPF_SIZE(code)); - break; -+ /* speculation barrier */ -+ case BPF_ST | BPF_NOSPEC: -+ break; - /* ST: *(size *)(dst + off) = imm */ - case BPF_ST | BPF_MEM | BPF_W: - case BPF_ST | BPF_MEM | BPF_H: -diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c -index f7b194878a99a..5a876af34230c 100644 ---- a/arch/arm64/net/bpf_jit_comp.c -+++ b/arch/arm64/net/bpf_jit_comp.c -@@ -829,6 +829,19 @@ emit_cond_jmp: - return ret; - break; - -+ /* speculation barrier */ -+ case BPF_ST | BPF_NOSPEC: -+ /* -+ * Nothing required here. -+ * -+ * In case of arm64, we rely on the firmware mitigation of -+ * Speculative Store Bypass as controlled via the ssbd kernel -+ * parameter. Whenever the mitigation is enabled, it works -+ * for all of the kernel code with no need to provide any -+ * additional instructions. -+ */ -+ break; -+ - /* ST: *(size *)(dst + off) = imm */ - case BPF_ST | BPF_MEM | BPF_W: - case BPF_ST | BPF_MEM | BPF_H: -diff --git a/arch/mips/net/ebpf_jit.c b/arch/mips/net/ebpf_jit.c -index 939dd06764bc9..3a73e93757121 100644 ---- a/arch/mips/net/ebpf_jit.c -+++ b/arch/mips/net/ebpf_jit.c -@@ -1355,6 +1355,9 @@ jeq_common: - } - break; - -+ case BPF_ST | BPF_NOSPEC: /* speculation barrier */ -+ break; -+ - case BPF_ST | BPF_B | BPF_MEM: - case BPF_ST | BPF_H | BPF_MEM: - case BPF_ST | BPF_W | BPF_MEM: -diff --git a/arch/powerpc/kernel/vdso64/Makefile b/arch/powerpc/kernel/vdso64/Makefile -index 2813e3f98db65..3c5baaa6f1e7f 100644 ---- a/arch/powerpc/kernel/vdso64/Makefile -+++ b/arch/powerpc/kernel/vdso64/Makefile -@@ -27,6 +27,13 @@ KASAN_SANITIZE := n - - ccflags-y := -shared -fno-common -fno-builtin -nostdlib \ - -Wl,-soname=linux-vdso64.so.1 -Wl,--hash-style=both -+ -+# Go prior to 1.16.x assumes r30 is not clobbered by any VDSO code. That used to be true -+# by accident when the VDSO was hand-written asm code, but may not be now that the VDSO is -+# compiler generated. To avoid breaking Go tell GCC not to use r30. Impact on code -+# generation is minimal, it will just use r29 instead. -+ccflags-y += $(call cc-option, -ffixed-r30) -+ - asflags-y := -D__VDSO64__ -s - - targets += vdso64.lds -diff --git a/arch/powerpc/net/bpf_jit_comp32.c b/arch/powerpc/net/bpf_jit_comp32.c -index 68476780047ac..6c0915285b171 100644 ---- a/arch/powerpc/net/bpf_jit_comp32.c -+++ b/arch/powerpc/net/bpf_jit_comp32.c -@@ -737,6 +737,12 @@ int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, struct codegen_context * - } - break; - -+ /* -+ * BPF_ST NOSPEC (speculation barrier) -+ */ -+ case BPF_ST | BPF_NOSPEC: -+ break; -+ - /* - * BPF_ST(X) - */ -diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c -index 94411af24013f..d3ad8dfba1f69 100644 ---- a/arch/powerpc/net/bpf_jit_comp64.c -+++ b/arch/powerpc/net/bpf_jit_comp64.c -@@ -627,6 +627,12 @@ emit_clear: - } - break; - -+ /* -+ * BPF_ST NOSPEC (speculation barrier) -+ */ -+ case BPF_ST | BPF_NOSPEC: -+ break; -+ - /* - * BPF_ST(X) - */ -diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c -index 754e493b7c05b..0338f481c12bb 100644 ---- a/arch/powerpc/platforms/pseries/setup.c -+++ b/arch/powerpc/platforms/pseries/setup.c -@@ -77,7 +77,7 @@ - #include "../../../../drivers/pci/pci.h" - - DEFINE_STATIC_KEY_FALSE(shared_processor); --EXPORT_SYMBOL_GPL(shared_processor); -+EXPORT_SYMBOL(shared_processor); - - int CMO_PrPSP = -1; - int CMO_SecPSP = -1; -diff --git a/arch/riscv/net/bpf_jit_comp32.c b/arch/riscv/net/bpf_jit_comp32.c -index 81de865f4c7c3..e6497424cbf60 100644 ---- a/arch/riscv/net/bpf_jit_comp32.c -+++ b/arch/riscv/net/bpf_jit_comp32.c -@@ -1251,6 +1251,10 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, struct rv_jit_context *ctx, - return -1; - break; - -+ /* speculation barrier */ -+ case BPF_ST | BPF_NOSPEC: -+ break; -+ - case BPF_ST | BPF_MEM | BPF_B: - case BPF_ST | BPF_MEM | BPF_H: - case BPF_ST | BPF_MEM | BPF_W: -diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c -index 87e3bf5b9086d..3af4131c22c7a 100644 ---- a/arch/riscv/net/bpf_jit_comp64.c -+++ b/arch/riscv/net/bpf_jit_comp64.c -@@ -939,6 +939,10 @@ out_be: - emit_ld(rd, 0, RV_REG_T1, ctx); - break; - -+ /* speculation barrier */ -+ case BPF_ST | BPF_NOSPEC: -+ break; -+ - /* ST: *(size *)(dst + off) = imm */ - case BPF_ST | BPF_MEM | BPF_B: - emit_imm(RV_REG_T1, imm, ctx); -diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c -index 2ae419f5115a5..88419263a89a9 100644 ---- a/arch/s390/net/bpf_jit_comp.c -+++ b/arch/s390/net/bpf_jit_comp.c -@@ -1153,6 +1153,11 @@ static noinline int bpf_jit_insn(struct bpf_jit *jit, struct bpf_prog *fp, - break; - } - break; -+ /* -+ * BPF_NOSPEC (speculation barrier) -+ */ -+ case BPF_ST | BPF_NOSPEC: -+ break; - /* - * BPF_ST(X) - */ -diff --git a/arch/sparc/net/bpf_jit_comp_64.c b/arch/sparc/net/bpf_jit_comp_64.c -index 4b8d3c65d2666..9a2f20cbd48b7 100644 ---- a/arch/sparc/net/bpf_jit_comp_64.c -+++ b/arch/sparc/net/bpf_jit_comp_64.c -@@ -1287,6 +1287,9 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx) - return 1; - break; - } -+ /* speculation barrier */ -+ case BPF_ST | BPF_NOSPEC: -+ break; - /* ST: *(size *)(dst + off) = imm */ - case BPF_ST | BPF_MEM | BPF_W: - case BPF_ST | BPF_MEM | BPF_H: -diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c -index 698969e18fe35..ff005fe738a4c 100644 ---- a/arch/x86/kvm/ioapic.c -+++ b/arch/x86/kvm/ioapic.c -@@ -96,7 +96,7 @@ static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic, - static void rtc_irq_eoi_tracking_reset(struct kvm_ioapic *ioapic) - { - ioapic->rtc_status.pending_eoi = 0; -- bitmap_zero(ioapic->rtc_status.dest_map.map, KVM_MAX_VCPU_ID); -+ bitmap_zero(ioapic->rtc_status.dest_map.map, KVM_MAX_VCPU_ID + 1); - } - - static void kvm_rtc_eoi_tracking_restore_all(struct kvm_ioapic *ioapic); -diff --git a/arch/x86/kvm/ioapic.h b/arch/x86/kvm/ioapic.h -index 660401700075d..11e4065e16176 100644 ---- a/arch/x86/kvm/ioapic.h -+++ b/arch/x86/kvm/ioapic.h -@@ -43,13 +43,13 @@ struct kvm_vcpu; - - struct dest_map { - /* vcpu bitmap where IRQ has been sent */ -- DECLARE_BITMAP(map, KVM_MAX_VCPU_ID); -+ DECLARE_BITMAP(map, KVM_MAX_VCPU_ID + 1); - - /* - * Vector sent to a given vcpu, only valid when - * the vcpu's bit in map is set - */ -- u8 vectors[KVM_MAX_VCPU_ID]; -+ u8 vectors[KVM_MAX_VCPU_ID + 1]; - }; - - -diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c -index b5a3de788b5fc..d6a9f05187849 100644 ---- a/arch/x86/kvm/x86.c -+++ b/arch/x86/kvm/x86.c -@@ -3314,7 +3314,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info) - return 1; - break; - case MSR_KVM_ASYNC_PF_ACK: -- if (!guest_pv_has(vcpu, KVM_FEATURE_ASYNC_PF)) -+ if (!guest_pv_has(vcpu, KVM_FEATURE_ASYNC_PF_INT)) - return 1; - if (data & 0x1) { - vcpu->arch.apf.pageready_pending = false; -@@ -3646,7 +3646,7 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info) - msr_info->data = vcpu->arch.apf.msr_int_val; - break; - case MSR_KVM_ASYNC_PF_ACK: -- if (!guest_pv_has(vcpu, KVM_FEATURE_ASYNC_PF)) -+ if (!guest_pv_has(vcpu, KVM_FEATURE_ASYNC_PF_INT)) - return 1; - - msr_info->data = 0; -diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c -index 66e304a84deb0..ee9971bbe034a 100644 ---- a/arch/x86/net/bpf_jit_comp.c -+++ b/arch/x86/net/bpf_jit_comp.c -@@ -1235,6 +1235,13 @@ static int do_jit(struct bpf_prog *bpf_prog, int *addrs, u8 *image, - } - break; - -+ /* speculation barrier */ -+ case BPF_ST | BPF_NOSPEC: -+ if (boot_cpu_has(X86_FEATURE_XMM2)) -+ /* Emit 'lfence' */ -+ EMIT3(0x0F, 0xAE, 0xE8); -+ break; -+ - /* ST: *(u8*)(dst_reg + off) = imm */ - case BPF_ST | BPF_MEM | BPF_B: - if (is_ereg(dst_reg)) -diff --git a/arch/x86/net/bpf_jit_comp32.c b/arch/x86/net/bpf_jit_comp32.c -index 3da88ded6ee39..3bfda5f502cb8 100644 ---- a/arch/x86/net/bpf_jit_comp32.c -+++ b/arch/x86/net/bpf_jit_comp32.c -@@ -1886,6 +1886,12 @@ static int do_jit(struct bpf_prog *bpf_prog, int *addrs, u8 *image, - i++; - break; - } -+ /* speculation barrier */ -+ case BPF_ST | BPF_NOSPEC: -+ if (boot_cpu_has(X86_FEATURE_XMM2)) -+ /* Emit 'lfence' */ -+ EMIT3(0x0F, 0xAE, 0xE8); -+ break; - /* ST: *(u8*)(dst_reg + off) = imm */ - case BPF_ST | BPF_MEM | BPF_H: - case BPF_ST | BPF_MEM | BPF_B: -diff --git a/block/blk-iocost.c b/block/blk-iocost.c -index c2d6bc88d3f15..5fac3757e6e05 100644 ---- a/block/blk-iocost.c -+++ b/block/blk-iocost.c -@@ -1440,16 +1440,17 @@ static int iocg_wake_fn(struct wait_queue_entry *wq_entry, unsigned mode, - return -1; - - iocg_commit_bio(ctx->iocg, wait->bio, wait->abs_cost, cost); -+ wait->committed = true; - - /* - * autoremove_wake_function() removes the wait entry only when it -- * actually changed the task state. We want the wait always -- * removed. Remove explicitly and use default_wake_function(). -+ * actually changed the task state. We want the wait always removed. -+ * Remove explicitly and use default_wake_function(). Note that the -+ * order of operations is important as finish_wait() tests whether -+ * @wq_entry is removed without grabbing the lock. - */ -- list_del_init(&wq_entry->entry); -- wait->committed = true; -- - default_wake_function(wq_entry, mode, flags, key); -+ list_del_init_careful(&wq_entry->entry); - return 0; - } - -diff --git a/block/genhd.c b/block/genhd.c -index ad7436bd60c1b..e8968fd30b2bc 100644 ---- a/block/genhd.c -+++ b/block/genhd.c -@@ -1124,10 +1124,9 @@ static void disk_release(struct device *dev) - disk_release_events(disk); - kfree(disk->random); - xa_destroy(&disk->part_tbl); -- bdput(disk->part0); - if (disk->queue) - blk_put_queue(disk->queue); -- kfree(disk); -+ bdput(disk->part0); /* frees the disk */ - } - struct class block_class = { - .name = "block", -diff --git a/drivers/acpi/dptf/dptf_pch_fivr.c b/drivers/acpi/dptf/dptf_pch_fivr.c -index 5fca18296bf68..550b9081fcbc2 100644 ---- a/drivers/acpi/dptf/dptf_pch_fivr.c -+++ b/drivers/acpi/dptf/dptf_pch_fivr.c -@@ -9,6 +9,42 @@ - #include - #include - -+struct pch_fivr_resp { -+ u64 status; -+ u64 result; -+}; -+ -+static int pch_fivr_read(acpi_handle handle, char *method, struct pch_fivr_resp *fivr_resp) -+{ -+ struct acpi_buffer resp = { sizeof(struct pch_fivr_resp), fivr_resp}; -+ struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; -+ struct acpi_buffer format = { sizeof("NN"), "NN" }; -+ union acpi_object *obj; -+ acpi_status status; -+ int ret = -EFAULT; -+ -+ status = acpi_evaluate_object(handle, method, NULL, &buffer); -+ if (ACPI_FAILURE(status)) -+ return ret; -+ -+ obj = buffer.pointer; -+ if (!obj || obj->type != ACPI_TYPE_PACKAGE) -+ goto release_buffer; -+ -+ status = acpi_extract_package(obj, &format, &resp); -+ if (ACPI_FAILURE(status)) -+ goto release_buffer; -+ -+ if (fivr_resp->status) -+ goto release_buffer; -+ -+ ret = 0; -+ -+release_buffer: -+ kfree(buffer.pointer); -+ return ret; -+} -+ - /* - * Presentation of attributes which are defined for INT1045 - * They are: -@@ -23,15 +59,14 @@ static ssize_t name##_show(struct device *dev,\ - char *buf)\ - {\ - struct acpi_device *acpi_dev = dev_get_drvdata(dev);\ -- unsigned long long val;\ -- acpi_status status;\ -+ struct pch_fivr_resp fivr_resp;\ -+ int status;\ - \ -- status = acpi_evaluate_integer(acpi_dev->handle, #method,\ -- NULL, &val);\ -- if (ACPI_SUCCESS(status))\ -- return sprintf(buf, "%d\n", (int)val);\ -- else\ -- return -EINVAL;\ -+ status = pch_fivr_read(acpi_dev->handle, #method, &fivr_resp);\ -+ if (status)\ -+ return status;\ -+\ -+ return sprintf(buf, "%llu\n", fivr_resp.result);\ - } - - #define PCH_FIVR_STORE(name, method) \ -diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c -index dc01fb550b28d..ee78a210c6068 100644 ---- a/drivers/acpi/resource.c -+++ b/drivers/acpi/resource.c -@@ -423,13 +423,6 @@ static void acpi_dev_get_irqresource(struct resource *res, u32 gsi, - } - } - --static bool irq_is_legacy(struct acpi_resource_irq *irq) --{ -- return irq->triggering == ACPI_EDGE_SENSITIVE && -- irq->polarity == ACPI_ACTIVE_HIGH && -- irq->shareable == ACPI_EXCLUSIVE; --} -- - /** - * acpi_dev_resource_interrupt - Extract ACPI interrupt resource information. - * @ares: Input ACPI resource object. -@@ -468,7 +461,7 @@ bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index, - } - acpi_dev_get_irqresource(res, irq->interrupts[index], - irq->triggering, irq->polarity, -- irq->shareable, irq_is_legacy(irq)); -+ irq->shareable, true); - break; - case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: - ext_irq = &ares->data.extended_irq; -diff --git a/drivers/block/loop.c b/drivers/block/loop.c -index 8271df1251535..e81298b912270 100644 ---- a/drivers/block/loop.c -+++ b/drivers/block/loop.c -@@ -86,6 +86,47 @@ - - static DEFINE_IDR(loop_index_idr); - static DEFINE_MUTEX(loop_ctl_mutex); -+static DEFINE_MUTEX(loop_validate_mutex); -+ -+/** -+ * loop_global_lock_killable() - take locks for safe loop_validate_file() test -+ * -+ * @lo: struct loop_device -+ * @global: true if @lo is about to bind another "struct loop_device", false otherwise -+ * -+ * Returns 0 on success, -EINTR otherwise. -+ * -+ * Since loop_validate_file() traverses on other "struct loop_device" if -+ * is_loop_device() is true, we need a global lock for serializing concurrent -+ * loop_configure()/loop_change_fd()/__loop_clr_fd() calls. -+ */ -+static int loop_global_lock_killable(struct loop_device *lo, bool global) -+{ -+ int err; -+ -+ if (global) { -+ err = mutex_lock_killable(&loop_validate_mutex); -+ if (err) -+ return err; -+ } -+ err = mutex_lock_killable(&lo->lo_mutex); -+ if (err && global) -+ mutex_unlock(&loop_validate_mutex); -+ return err; -+} -+ -+/** -+ * loop_global_unlock() - release locks taken by loop_global_lock_killable() -+ * -+ * @lo: struct loop_device -+ * @global: true if @lo was about to bind another "struct loop_device", false otherwise -+ */ -+static void loop_global_unlock(struct loop_device *lo, bool global) -+{ -+ mutex_unlock(&lo->lo_mutex); -+ if (global) -+ mutex_unlock(&loop_validate_mutex); -+} - - static int max_part; - static int part_shift; -@@ -676,13 +717,15 @@ static int loop_validate_file(struct file *file, struct block_device *bdev) - while (is_loop_device(f)) { - struct loop_device *l; - -+ lockdep_assert_held(&loop_validate_mutex); - if (f->f_mapping->host->i_rdev == bdev->bd_dev) - return -EBADF; - - l = I_BDEV(f->f_mapping->host)->bd_disk->private_data; -- if (l->lo_state != Lo_bound) { -+ if (l->lo_state != Lo_bound) - return -EINVAL; -- } -+ /* Order wrt setting lo->lo_backing_file in loop_configure(). */ -+ rmb(); - f = l->lo_backing_file; - } - if (!S_ISREG(inode->i_mode) && !S_ISBLK(inode->i_mode)) -@@ -701,13 +744,18 @@ static int loop_validate_file(struct file *file, struct block_device *bdev) - static int loop_change_fd(struct loop_device *lo, struct block_device *bdev, - unsigned int arg) - { -- struct file *file = NULL, *old_file; -- int error; -- bool partscan; -+ struct file *file = fget(arg); -+ struct file *old_file; -+ int error; -+ bool partscan; -+ bool is_loop; - -- error = mutex_lock_killable(&lo->lo_mutex); -+ if (!file) -+ return -EBADF; -+ is_loop = is_loop_device(file); -+ error = loop_global_lock_killable(lo, is_loop); - if (error) -- return error; -+ goto out_putf; - error = -ENXIO; - if (lo->lo_state != Lo_bound) - goto out_err; -@@ -717,11 +765,6 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev, - if (!(lo->lo_flags & LO_FLAGS_READ_ONLY)) - goto out_err; - -- error = -EBADF; -- file = fget(arg); -- if (!file) -- goto out_err; -- - error = loop_validate_file(file, bdev); - if (error) - goto out_err; -@@ -744,7 +787,16 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev, - loop_update_dio(lo); - blk_mq_unfreeze_queue(lo->lo_queue); - partscan = lo->lo_flags & LO_FLAGS_PARTSCAN; -- mutex_unlock(&lo->lo_mutex); -+ loop_global_unlock(lo, is_loop); -+ -+ /* -+ * Flush loop_validate_file() before fput(), for l->lo_backing_file -+ * might be pointing at old_file which might be the last reference. -+ */ -+ if (!is_loop) { -+ mutex_lock(&loop_validate_mutex); -+ mutex_unlock(&loop_validate_mutex); -+ } - /* - * We must drop file reference outside of lo_mutex as dropping - * the file ref can take bd_mutex which creates circular locking -@@ -756,9 +808,9 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev, - return 0; - - out_err: -- mutex_unlock(&lo->lo_mutex); -- if (file) -- fput(file); -+ loop_global_unlock(lo, is_loop); -+out_putf: -+ fput(file); - return error; - } - -@@ -1067,22 +1119,22 @@ static int loop_configure(struct loop_device *lo, fmode_t mode, - struct block_device *bdev, - const struct loop_config *config) - { -- struct file *file; -- struct inode *inode; -+ struct file *file = fget(config->fd); -+ struct inode *inode; - struct address_space *mapping; -- int error; -- loff_t size; -- bool partscan; -- unsigned short bsize; -+ int error; -+ loff_t size; -+ bool partscan; -+ unsigned short bsize; -+ bool is_loop; -+ -+ if (!file) -+ return -EBADF; -+ is_loop = is_loop_device(file); - - /* This is safe, since we have a reference from open(). */ - __module_get(THIS_MODULE); - -- error = -EBADF; -- file = fget(config->fd); -- if (!file) -- goto out; -- - /* - * If we don't hold exclusive handle for the device, upgrade to it - * here to avoid changing device under exclusive owner. -@@ -1093,7 +1145,7 @@ static int loop_configure(struct loop_device *lo, fmode_t mode, - goto out_putf; - } - -- error = mutex_lock_killable(&lo->lo_mutex); -+ error = loop_global_lock_killable(lo, is_loop); - if (error) - goto out_bdev; - -@@ -1162,6 +1214,9 @@ static int loop_configure(struct loop_device *lo, fmode_t mode, - size = get_loop_size(lo, file); - loop_set_size(lo, size); - -+ /* Order wrt reading lo_state in loop_validate_file(). */ -+ wmb(); -+ - lo->lo_state = Lo_bound; - if (part_shift) - lo->lo_flags |= LO_FLAGS_PARTSCAN; -@@ -1173,7 +1228,7 @@ static int loop_configure(struct loop_device *lo, fmode_t mode, - * put /dev/loopXX inode. Later in __loop_clr_fd() we bdput(bdev). - */ - bdgrab(bdev); -- mutex_unlock(&lo->lo_mutex); -+ loop_global_unlock(lo, is_loop); - if (partscan) - loop_reread_partitions(lo, bdev); - if (!(mode & FMODE_EXCL)) -@@ -1181,13 +1236,12 @@ static int loop_configure(struct loop_device *lo, fmode_t mode, - return 0; - - out_unlock: -- mutex_unlock(&lo->lo_mutex); -+ loop_global_unlock(lo, is_loop); - out_bdev: - if (!(mode & FMODE_EXCL)) - bd_abort_claiming(bdev, loop_configure); - out_putf: - fput(file); --out: - /* This is safe: open() is still holding a reference. */ - module_put(THIS_MODULE); - return error; -@@ -1202,6 +1256,18 @@ static int __loop_clr_fd(struct loop_device *lo, bool release) - bool partscan = false; - int lo_number; - -+ /* -+ * Flush loop_configure() and loop_change_fd(). It is acceptable for -+ * loop_validate_file() to succeed, for actual clear operation has not -+ * started yet. -+ */ -+ mutex_lock(&loop_validate_mutex); -+ mutex_unlock(&loop_validate_mutex); -+ /* -+ * loop_validate_file() now fails because l->lo_state != Lo_bound -+ * became visible. -+ */ -+ - mutex_lock(&lo->lo_mutex); - if (WARN_ON_ONCE(lo->lo_state != Lo_rundown)) { - err = -ENXIO; -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c -index 2e9b16fb3fcd1..355a6923849d3 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c -@@ -26,6 +26,7 @@ - #include - #include - #include -+#include - #include - #include - -@@ -906,7 +907,7 @@ bool amdgpu_acpi_is_s0ix_supported(struct amdgpu_device *adev) - #if defined(CONFIG_AMD_PMC) || defined(CONFIG_AMD_PMC_MODULE) - if (acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0) { - if (adev->flags & AMD_IS_APU) -- return true; -+ return pm_suspend_target_state == PM_SUSPEND_TO_IDLE; - } - #endif - return false; -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c -index d83f2ee150b86..cb3ad1395e13c 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c -@@ -3412,13 +3412,13 @@ int amdgpu_device_init(struct amdgpu_device *adev, - r = amdgpu_device_get_job_timeout_settings(adev); - if (r) { - dev_err(adev->dev, "invalid lockup_timeout parameter syntax\n"); -- goto failed_unmap; -+ return r; - } - - /* early init functions */ - r = amdgpu_device_ip_early_init(adev); - if (r) -- goto failed_unmap; -+ return r; - - /* doorbell bar mapping and doorbell index init*/ - amdgpu_device_doorbell_init(adev); -@@ -3644,10 +3644,6 @@ release_ras_con: - failed: - amdgpu_vf_error_trans_all(adev); - --failed_unmap: -- iounmap(adev->rmmio); -- adev->rmmio = NULL; -- - return r; - } - -diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v12_0.c b/drivers/gpu/drm/amd/amdgpu/psp_v12_0.c -index c4828bd3264bc..b0ee77ee80b90 100644 ---- a/drivers/gpu/drm/amd/amdgpu/psp_v12_0.c -+++ b/drivers/gpu/drm/amd/amdgpu/psp_v12_0.c -@@ -67,7 +67,7 @@ static int psp_v12_0_init_microcode(struct psp_context *psp) - - err = psp_init_asd_microcode(psp, chip_name); - if (err) -- goto out; -+ return err; - - snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_ta.bin", chip_name); - err = request_firmware(&adev->psp.ta_fw, fw_name, adev->dev); -@@ -80,7 +80,7 @@ static int psp_v12_0_init_microcode(struct psp_context *psp) - } else { - err = amdgpu_ucode_validate(adev->psp.ta_fw); - if (err) -- goto out2; -+ goto out; - - ta_hdr = (const struct ta_firmware_header_v1_0 *) - adev->psp.ta_fw->data; -@@ -105,10 +105,9 @@ static int psp_v12_0_init_microcode(struct psp_context *psp) - - return 0; - --out2: -+out: - release_firmware(adev->psp.ta_fw); - adev->psp.ta_fw = NULL; --out: - if (err) { - dev_err(adev->dev, - "psp v12.0: Failed to load firmware \"%s\"\n", -diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.c b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.c -index 372d53b5a34d4..f47d469ee9149 100644 ---- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.c -+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.c -@@ -135,7 +135,7 @@ void dcn20_update_clocks_update_dentist(struct clk_mgr_internal *clk_mgr) - - REG_UPDATE(DENTIST_DISPCLK_CNTL, - DENTIST_DISPCLK_WDIVIDER, dispclk_wdivider); --// REG_WAIT(DENTIST_DISPCLK_CNTL, DENTIST_DISPCLK_CHG_DONE, 1, 5, 100); -+ REG_WAIT(DENTIST_DISPCLK_CNTL, DENTIST_DISPCLK_CHG_DONE, 1, 50, 1000); - REG_UPDATE(DENTIST_DISPCLK_CNTL, - DENTIST_DPPCLK_WDIVIDER, dppclk_wdivider); - REG_WAIT(DENTIST_DISPCLK_CNTL, DENTIST_DPPCLK_CHG_DONE, 1, 5, 100); -diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c -index 3d0c035b5e380..04c8d2ff78673 100644 ---- a/drivers/gpu/drm/i915/display/intel_bios.c -+++ b/drivers/gpu/drm/i915/display/intel_bios.c -@@ -2130,7 +2130,8 @@ static void - init_vbt_missing_defaults(struct drm_i915_private *i915) - { - enum port port; -- int ports = PORT_A | PORT_B | PORT_C | PORT_D | PORT_E | PORT_F; -+ int ports = BIT(PORT_A) | BIT(PORT_B) | BIT(PORT_C) | -+ BIT(PORT_D) | BIT(PORT_E) | BIT(PORT_F); - - if (!HAS_DDI(i915) && !IS_CHERRYVIEW(i915)) - return; -diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c -index b569030a0847b..2daf81f630764 100644 ---- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c -+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c -@@ -268,7 +268,7 @@ static const struct dpu_mdp_cfg sc7180_mdp[] = { - static const struct dpu_mdp_cfg sm8250_mdp[] = { - { - .name = "top_0", .id = MDP_TOP, -- .base = 0x0, .len = 0x45C, -+ .base = 0x0, .len = 0x494, - .features = 0, - .highest_bank_bit = 0x3, /* TODO: 2 for LP_DDR4 */ - .clk_ctrls[DPU_CLK_CTRL_VIG0] = { -diff --git a/drivers/gpu/drm/msm/dp/dp_catalog.c b/drivers/gpu/drm/msm/dp/dp_catalog.c -index f4f53f23e331e..146a223a997ae 100644 ---- a/drivers/gpu/drm/msm/dp/dp_catalog.c -+++ b/drivers/gpu/drm/msm/dp/dp_catalog.c -@@ -762,6 +762,7 @@ int dp_catalog_panel_timing_cfg(struct dp_catalog *dp_catalog) - dp_write_link(catalog, REG_DP_HSYNC_VSYNC_WIDTH_POLARITY, - dp_catalog->width_blanking); - dp_write_link(catalog, REG_DP_ACTIVE_HOR_VER, dp_catalog->dp_active); -+ dp_write_p0(catalog, MMSS_DP_INTF_CONFIG, 0); - return 0; - } - -diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.c b/drivers/gpu/drm/msm/dp/dp_ctrl.c -index 2a8955ca70d1a..6856223e91e12 100644 ---- a/drivers/gpu/drm/msm/dp/dp_ctrl.c -+++ b/drivers/gpu/drm/msm/dp/dp_ctrl.c -@@ -1528,7 +1528,7 @@ static int dp_ctrl_process_phy_test_request(struct dp_ctrl_private *ctrl) - * running. Add the global reset just before disabling the - * link clocks and core clocks. - */ -- ret = dp_ctrl_off(&ctrl->dp_ctrl); -+ ret = dp_ctrl_off_link_stream(&ctrl->dp_ctrl); - if (ret) { - DRM_ERROR("failed to disable DP controller\n"); - return ret; -diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c -index be312b5c04dd9..1301d42cfffb4 100644 ---- a/drivers/gpu/drm/panel/panel-simple.c -+++ b/drivers/gpu/drm/panel/panel-simple.c -@@ -4124,7 +4124,7 @@ static const struct drm_display_mode yes_optoelectronics_ytc700tlag_05_201c_mode - static const struct panel_desc yes_optoelectronics_ytc700tlag_05_201c = { - .modes = &yes_optoelectronics_ytc700tlag_05_201c_mode, - .num_modes = 1, -- .bpc = 6, -+ .bpc = 8, - .size = { - .width = 154, - .height = 90, -diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c -index 81d7d12bcf342..496a000ef862c 100644 ---- a/drivers/hid/wacom_wac.c -+++ b/drivers/hid/wacom_wac.c -@@ -3831,7 +3831,7 @@ int wacom_setup_touch_input_capabilities(struct input_dev *input_dev, - wacom_wac->shared->touch->product == 0xF6) { - input_dev->evbit[0] |= BIT_MASK(EV_SW); - __set_bit(SW_MUTE_DEVICE, input_dev->swbit); -- wacom_wac->shared->has_mute_touch_switch = true; -+ wacom_wac->has_mute_touch_switch = true; - } - fallthrough; - -diff --git a/drivers/infiniband/hw/bnxt_re/main.c b/drivers/infiniband/hw/bnxt_re/main.c -index 8bfbf0231a9ef..25550d982238c 100644 ---- a/drivers/infiniband/hw/bnxt_re/main.c -+++ b/drivers/infiniband/hw/bnxt_re/main.c -@@ -120,6 +120,7 @@ static int bnxt_re_setup_chip_ctx(struct bnxt_re_dev *rdev, u8 wqe_mode) - if (!chip_ctx) - return -ENOMEM; - chip_ctx->chip_num = bp->chip_num; -+ chip_ctx->hw_stats_size = bp->hw_ring_stats_size; - - rdev->chip_ctx = chip_ctx; - /* rest members to follow eventually */ -@@ -547,6 +548,7 @@ static int bnxt_re_net_stats_ctx_alloc(struct bnxt_re_dev *rdev, - dma_addr_t dma_map, - u32 *fw_stats_ctx_id) - { -+ struct bnxt_qplib_chip_ctx *chip_ctx = rdev->chip_ctx; - struct hwrm_stat_ctx_alloc_output resp = {0}; - struct hwrm_stat_ctx_alloc_input req = {0}; - struct bnxt_en_dev *en_dev = rdev->en_dev; -@@ -563,7 +565,7 @@ static int bnxt_re_net_stats_ctx_alloc(struct bnxt_re_dev *rdev, - bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_STAT_CTX_ALLOC, -1, -1); - req.update_period_ms = cpu_to_le32(1000); - req.stats_dma_addr = cpu_to_le64(dma_map); -- req.stats_dma_length = cpu_to_le16(sizeof(struct ctx_hw_stats_ext)); -+ req.stats_dma_length = cpu_to_le16(chip_ctx->hw_stats_size); - req.stat_ctx_flags = STAT_CTX_ALLOC_REQ_STAT_CTX_FLAGS_ROCE; - bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp, - sizeof(resp), DFLT_HWRM_CMD_TIMEOUT); -diff --git a/drivers/infiniband/hw/bnxt_re/qplib_res.c b/drivers/infiniband/hw/bnxt_re/qplib_res.c -index 3ca47004b7527..754dcebeb4ca1 100644 ---- a/drivers/infiniband/hw/bnxt_re/qplib_res.c -+++ b/drivers/infiniband/hw/bnxt_re/qplib_res.c -@@ -56,6 +56,7 @@ - static void bnxt_qplib_free_stats_ctx(struct pci_dev *pdev, - struct bnxt_qplib_stats *stats); - static int bnxt_qplib_alloc_stats_ctx(struct pci_dev *pdev, -+ struct bnxt_qplib_chip_ctx *cctx, - struct bnxt_qplib_stats *stats); - - /* PBL */ -@@ -559,7 +560,7 @@ int bnxt_qplib_alloc_ctx(struct bnxt_qplib_res *res, - goto fail; - stats_alloc: - /* Stats */ -- rc = bnxt_qplib_alloc_stats_ctx(res->pdev, &ctx->stats); -+ rc = bnxt_qplib_alloc_stats_ctx(res->pdev, res->cctx, &ctx->stats); - if (rc) - goto fail; - -@@ -889,15 +890,12 @@ static void bnxt_qplib_free_stats_ctx(struct pci_dev *pdev, - } - - static int bnxt_qplib_alloc_stats_ctx(struct pci_dev *pdev, -+ struct bnxt_qplib_chip_ctx *cctx, - struct bnxt_qplib_stats *stats) - { - memset(stats, 0, sizeof(*stats)); - stats->fw_id = -1; -- /* 128 byte aligned context memory is required only for 57500. -- * However making this unconditional, it does not harm previous -- * generation. -- */ -- stats->size = ALIGN(sizeof(struct ctx_hw_stats), 128); -+ stats->size = cctx->hw_stats_size; - stats->dma = dma_alloc_coherent(&pdev->dev, stats->size, - &stats->dma_map, GFP_KERNEL); - if (!stats->dma) { -diff --git a/drivers/infiniband/hw/bnxt_re/qplib_res.h b/drivers/infiniband/hw/bnxt_re/qplib_res.h -index 7a1ab38b95da1..58bad6f784567 100644 ---- a/drivers/infiniband/hw/bnxt_re/qplib_res.h -+++ b/drivers/infiniband/hw/bnxt_re/qplib_res.h -@@ -60,6 +60,7 @@ struct bnxt_qplib_chip_ctx { - u16 chip_num; - u8 chip_rev; - u8 chip_metal; -+ u16 hw_stats_size; - struct bnxt_qplib_drv_modes modes; - }; - -diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c -index fe2b7d223183f..fa3d29825ef67 100644 ---- a/drivers/infiniband/sw/rxe/rxe_mr.c -+++ b/drivers/infiniband/sw/rxe/rxe_mr.c -@@ -130,13 +130,14 @@ int rxe_mr_init_user(struct rxe_pd *pd, u64 start, u64 length, u64 iova, - int num_buf; - void *vaddr; - int err; -+ int i; - - umem = ib_umem_get(pd->ibpd.device, start, length, access); - if (IS_ERR(umem)) { -- pr_warn("err %d from rxe_umem_get\n", -- (int)PTR_ERR(umem)); -+ pr_warn("%s: Unable to pin memory region err = %d\n", -+ __func__, (int)PTR_ERR(umem)); - err = PTR_ERR(umem); -- goto err1; -+ goto err_out; - } - - mr->umem = umem; -@@ -146,9 +147,9 @@ int rxe_mr_init_user(struct rxe_pd *pd, u64 start, u64 length, u64 iova, - - err = rxe_mr_alloc(mr, num_buf); - if (err) { -- pr_warn("err %d from rxe_mr_alloc\n", err); -- ib_umem_release(umem); -- goto err1; -+ pr_warn("%s: Unable to allocate memory for map\n", -+ __func__); -+ goto err_release_umem; - } - - mr->page_shift = PAGE_SHIFT; -@@ -168,10 +169,10 @@ int rxe_mr_init_user(struct rxe_pd *pd, u64 start, u64 length, u64 iova, - - vaddr = page_address(sg_page_iter_page(&sg_iter)); - if (!vaddr) { -- pr_warn("null vaddr\n"); -- ib_umem_release(umem); -+ pr_warn("%s: Unable to get virtual address\n", -+ __func__); - err = -ENOMEM; -- goto err1; -+ goto err_cleanup_map; - } - - buf->addr = (uintptr_t)vaddr; -@@ -194,7 +195,13 @@ int rxe_mr_init_user(struct rxe_pd *pd, u64 start, u64 length, u64 iova, - - return 0; - --err1: -+err_cleanup_map: -+ for (i = 0; i < mr->num_map; i++) -+ kfree(mr->map[i]); -+ kfree(mr->map); -+err_release_umem: -+ ib_umem_release(umem); -+err_out: - return err; - } - -diff --git a/drivers/net/can/spi/hi311x.c b/drivers/net/can/spi/hi311x.c -index 6f5d6d04a8b96..c84a198776c7a 100644 ---- a/drivers/net/can/spi/hi311x.c -+++ b/drivers/net/can/spi/hi311x.c -@@ -218,7 +218,7 @@ static int hi3110_spi_trans(struct spi_device *spi, int len) - return ret; - } - --static u8 hi3110_cmd(struct spi_device *spi, u8 command) -+static int hi3110_cmd(struct spi_device *spi, u8 command) - { - struct hi3110_priv *priv = spi_get_drvdata(spi); - -diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c -index e0ae00e34c7be..d371af7ab4969 100644 ---- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c -+++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c -@@ -2300,6 +2300,7 @@ static irqreturn_t mcp251xfd_irq(int irq, void *dev_id) - err, priv->regs_status.intf); - mcp251xfd_dump(priv); - mcp251xfd_chip_interrupts_disable(priv); -+ mcp251xfd_timestamp_stop(priv); - - return handled; - } -diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c -index 0a37af4a3fa40..2b5302e724353 100644 ---- a/drivers/net/can/usb/ems_usb.c -+++ b/drivers/net/can/usb/ems_usb.c -@@ -255,6 +255,8 @@ struct ems_usb { - unsigned int free_slots; /* remember number of available slots */ - - struct ems_cpc_msg active_params; /* active controller parameters */ -+ void *rxbuf[MAX_RX_URBS]; -+ dma_addr_t rxbuf_dma[MAX_RX_URBS]; - }; - - static void ems_usb_read_interrupt_callback(struct urb *urb) -@@ -587,6 +589,7 @@ static int ems_usb_start(struct ems_usb *dev) - for (i = 0; i < MAX_RX_URBS; i++) { - struct urb *urb = NULL; - u8 *buf = NULL; -+ dma_addr_t buf_dma; - - /* create a URB, and a buffer for it */ - urb = usb_alloc_urb(0, GFP_KERNEL); -@@ -596,7 +599,7 @@ static int ems_usb_start(struct ems_usb *dev) - } - - buf = usb_alloc_coherent(dev->udev, RX_BUFFER_SIZE, GFP_KERNEL, -- &urb->transfer_dma); -+ &buf_dma); - if (!buf) { - netdev_err(netdev, "No memory left for USB buffer\n"); - usb_free_urb(urb); -@@ -604,6 +607,8 @@ static int ems_usb_start(struct ems_usb *dev) - break; - } - -+ urb->transfer_dma = buf_dma; -+ - usb_fill_bulk_urb(urb, dev->udev, usb_rcvbulkpipe(dev->udev, 2), - buf, RX_BUFFER_SIZE, - ems_usb_read_bulk_callback, dev); -@@ -619,6 +624,9 @@ static int ems_usb_start(struct ems_usb *dev) - break; - } - -+ dev->rxbuf[i] = buf; -+ dev->rxbuf_dma[i] = buf_dma; -+ - /* Drop reference, USB core will take care of freeing it */ - usb_free_urb(urb); - } -@@ -684,6 +692,10 @@ static void unlink_all_urbs(struct ems_usb *dev) - - usb_kill_anchored_urbs(&dev->rx_submitted); - -+ for (i = 0; i < MAX_RX_URBS; ++i) -+ usb_free_coherent(dev->udev, RX_BUFFER_SIZE, -+ dev->rxbuf[i], dev->rxbuf_dma[i]); -+ - usb_kill_anchored_urbs(&dev->tx_submitted); - atomic_set(&dev->active_tx_urbs, 0); - -diff --git a/drivers/net/can/usb/esd_usb2.c b/drivers/net/can/usb/esd_usb2.c -index 65b58f8fc3287..66fa8b07c2e6f 100644 ---- a/drivers/net/can/usb/esd_usb2.c -+++ b/drivers/net/can/usb/esd_usb2.c -@@ -195,6 +195,8 @@ struct esd_usb2 { - int net_count; - u32 version; - int rxinitdone; -+ void *rxbuf[MAX_RX_URBS]; -+ dma_addr_t rxbuf_dma[MAX_RX_URBS]; - }; - - struct esd_usb2_net_priv { -@@ -545,6 +547,7 @@ static int esd_usb2_setup_rx_urbs(struct esd_usb2 *dev) - for (i = 0; i < MAX_RX_URBS; i++) { - struct urb *urb = NULL; - u8 *buf = NULL; -+ dma_addr_t buf_dma; - - /* create a URB, and a buffer for it */ - urb = usb_alloc_urb(0, GFP_KERNEL); -@@ -554,7 +557,7 @@ static int esd_usb2_setup_rx_urbs(struct esd_usb2 *dev) - } - - buf = usb_alloc_coherent(dev->udev, RX_BUFFER_SIZE, GFP_KERNEL, -- &urb->transfer_dma); -+ &buf_dma); - if (!buf) { - dev_warn(dev->udev->dev.parent, - "No memory left for USB buffer\n"); -@@ -562,6 +565,8 @@ static int esd_usb2_setup_rx_urbs(struct esd_usb2 *dev) - goto freeurb; - } - -+ urb->transfer_dma = buf_dma; -+ - usb_fill_bulk_urb(urb, dev->udev, - usb_rcvbulkpipe(dev->udev, 1), - buf, RX_BUFFER_SIZE, -@@ -574,8 +579,12 @@ static int esd_usb2_setup_rx_urbs(struct esd_usb2 *dev) - usb_unanchor_urb(urb); - usb_free_coherent(dev->udev, RX_BUFFER_SIZE, buf, - urb->transfer_dma); -+ goto freeurb; - } - -+ dev->rxbuf[i] = buf; -+ dev->rxbuf_dma[i] = buf_dma; -+ - freeurb: - /* Drop reference, USB core will take care of freeing it */ - usb_free_urb(urb); -@@ -663,6 +672,11 @@ static void unlink_all_urbs(struct esd_usb2 *dev) - int i, j; - - usb_kill_anchored_urbs(&dev->rx_submitted); -+ -+ for (i = 0; i < MAX_RX_URBS; ++i) -+ usb_free_coherent(dev->udev, RX_BUFFER_SIZE, -+ dev->rxbuf[i], dev->rxbuf_dma[i]); -+ - for (i = 0; i < dev->net_count; i++) { - priv = dev->nets[i]; - if (priv) { -diff --git a/drivers/net/can/usb/mcba_usb.c b/drivers/net/can/usb/mcba_usb.c -index a45865bd72546..a1a154c08b7f7 100644 ---- a/drivers/net/can/usb/mcba_usb.c -+++ b/drivers/net/can/usb/mcba_usb.c -@@ -653,6 +653,8 @@ static int mcba_usb_start(struct mcba_priv *priv) - break; - } - -+ urb->transfer_dma = buf_dma; -+ - usb_fill_bulk_urb(urb, priv->udev, - usb_rcvbulkpipe(priv->udev, MCBA_USB_EP_IN), - buf, MCBA_USB_RX_BUFF_SIZE, -diff --git a/drivers/net/can/usb/peak_usb/pcan_usb.c b/drivers/net/can/usb/peak_usb/pcan_usb.c -index 1d6f77252f018..899a3d21b77f9 100644 ---- a/drivers/net/can/usb/peak_usb/pcan_usb.c -+++ b/drivers/net/can/usb/peak_usb/pcan_usb.c -@@ -117,7 +117,8 @@ - #define PCAN_USB_BERR_MASK (PCAN_USB_ERR_RXERR | PCAN_USB_ERR_TXERR) - - /* identify bus event packets with rx/tx error counters */ --#define PCAN_USB_ERR_CNT 0x80 -+#define PCAN_USB_ERR_CNT_DEC 0x00 /* counters are decreasing */ -+#define PCAN_USB_ERR_CNT_INC 0x80 /* counters are increasing */ - - /* private to PCAN-USB adapter */ - struct pcan_usb { -@@ -608,11 +609,12 @@ static int pcan_usb_handle_bus_evt(struct pcan_usb_msg_context *mc, u8 ir) - - /* acccording to the content of the packet */ - switch (ir) { -- case PCAN_USB_ERR_CNT: -+ case PCAN_USB_ERR_CNT_DEC: -+ case PCAN_USB_ERR_CNT_INC: - - /* save rx/tx error counters from in the device context */ -- pdev->bec.rxerr = mc->ptr[0]; -- pdev->bec.txerr = mc->ptr[1]; -+ pdev->bec.rxerr = mc->ptr[1]; -+ pdev->bec.txerr = mc->ptr[2]; - break; - - default: -diff --git a/drivers/net/can/usb/usb_8dev.c b/drivers/net/can/usb/usb_8dev.c -index b6e7ef0d5bc69..d1b83bd1b3cb9 100644 ---- a/drivers/net/can/usb/usb_8dev.c -+++ b/drivers/net/can/usb/usb_8dev.c -@@ -137,7 +137,8 @@ struct usb_8dev_priv { - u8 *cmd_msg_buffer; - - struct mutex usb_8dev_cmd_lock; -- -+ void *rxbuf[MAX_RX_URBS]; -+ dma_addr_t rxbuf_dma[MAX_RX_URBS]; - }; - - /* tx frame */ -@@ -733,6 +734,7 @@ static int usb_8dev_start(struct usb_8dev_priv *priv) - for (i = 0; i < MAX_RX_URBS; i++) { - struct urb *urb = NULL; - u8 *buf; -+ dma_addr_t buf_dma; - - /* create a URB, and a buffer for it */ - urb = usb_alloc_urb(0, GFP_KERNEL); -@@ -742,7 +744,7 @@ static int usb_8dev_start(struct usb_8dev_priv *priv) - } - - buf = usb_alloc_coherent(priv->udev, RX_BUFFER_SIZE, GFP_KERNEL, -- &urb->transfer_dma); -+ &buf_dma); - if (!buf) { - netdev_err(netdev, "No memory left for USB buffer\n"); - usb_free_urb(urb); -@@ -750,6 +752,8 @@ static int usb_8dev_start(struct usb_8dev_priv *priv) - break; - } - -+ urb->transfer_dma = buf_dma; -+ - usb_fill_bulk_urb(urb, priv->udev, - usb_rcvbulkpipe(priv->udev, - USB_8DEV_ENDP_DATA_RX), -@@ -767,6 +771,9 @@ static int usb_8dev_start(struct usb_8dev_priv *priv) - break; - } - -+ priv->rxbuf[i] = buf; -+ priv->rxbuf_dma[i] = buf_dma; -+ - /* Drop reference, USB core will take care of freeing it */ - usb_free_urb(urb); - } -@@ -836,6 +843,10 @@ static void unlink_all_urbs(struct usb_8dev_priv *priv) - - usb_kill_anchored_urbs(&priv->rx_submitted); - -+ for (i = 0; i < MAX_RX_URBS; ++i) -+ usb_free_coherent(priv->udev, RX_BUFFER_SIZE, -+ priv->rxbuf[i], priv->rxbuf_dma[i]); -+ - usb_kill_anchored_urbs(&priv->tx_submitted); - atomic_set(&priv->active_tx_urbs, 0); - -diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c -index beb41572d04ea..272b0535d9461 100644 ---- a/drivers/net/dsa/mv88e6xxx/chip.c -+++ b/drivers/net/dsa/mv88e6xxx/chip.c -@@ -2155,7 +2155,7 @@ static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip, - int i, err; - - if (!vid) -- return -EOPNOTSUPP; -+ return 0; - - err = mv88e6xxx_vtu_get(chip, vid, &vlan); - if (err) -diff --git a/drivers/net/ethernet/dec/tulip/winbond-840.c b/drivers/net/ethernet/dec/tulip/winbond-840.c -index 514df170ec5df..c967e0e859e5e 100644 ---- a/drivers/net/ethernet/dec/tulip/winbond-840.c -+++ b/drivers/net/ethernet/dec/tulip/winbond-840.c -@@ -357,7 +357,7 @@ static int w840_probe1(struct pci_dev *pdev, const struct pci_device_id *ent) - int i, option = find_cnt < MAX_UNITS ? options[find_cnt] : 0; - void __iomem *ioaddr; - -- i = pci_enable_device(pdev); -+ i = pcim_enable_device(pdev); - if (i) return i; - - pci_set_master(pdev); -@@ -379,7 +379,7 @@ static int w840_probe1(struct pci_dev *pdev, const struct pci_device_id *ent) - - ioaddr = pci_iomap(pdev, TULIP_BAR, netdev_res_size); - if (!ioaddr) -- goto err_out_free_res; -+ goto err_out_netdev; - - for (i = 0; i < 3; i++) - ((__le16 *)dev->dev_addr)[i] = cpu_to_le16(eeprom_read(ioaddr, i)); -@@ -458,8 +458,6 @@ static int w840_probe1(struct pci_dev *pdev, const struct pci_device_id *ent) - - err_out_cleardev: - pci_iounmap(pdev, ioaddr); --err_out_free_res: -- pci_release_regions(pdev); - err_out_netdev: - free_netdev (dev); - return -ENODEV; -@@ -1526,7 +1524,6 @@ static void w840_remove1(struct pci_dev *pdev) - if (dev) { - struct netdev_private *np = netdev_priv(dev); - unregister_netdev(dev); -- pci_release_regions(pdev); - pci_iounmap(pdev, np->base_addr); - free_netdev(dev); - } -diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c -index 3e822bad48513..2c9e4eeb7270d 100644 ---- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c -+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c -@@ -980,7 +980,7 @@ static void i40e_get_settings_link_up(struct i40e_hw *hw, - default: - /* if we got here and link is up something bad is afoot */ - netdev_info(netdev, -- "WARNING: Link is up but PHY type 0x%x is not recognized.\n", -+ "WARNING: Link is up but PHY type 0x%x is not recognized, or incorrect cable is in use\n", - hw_link_info->phy_type); - } - -@@ -5294,6 +5294,10 @@ flags_complete: - dev_warn(&pf->pdev->dev, - "Device configuration forbids SW from starting the LLDP agent.\n"); - return -EINVAL; -+ case I40E_AQ_RC_EAGAIN: -+ dev_warn(&pf->pdev->dev, -+ "Stop FW LLDP agent command is still being processed, please try again in a second.\n"); -+ return -EBUSY; - default: - dev_warn(&pf->pdev->dev, - "Starting FW LLDP agent failed: error: %s, %s\n", -diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c -index f9fe500d4ec44..4e5c53a6265ce 100644 ---- a/drivers/net/ethernet/intel/i40e/i40e_main.c -+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c -@@ -4454,11 +4454,10 @@ int i40e_control_wait_tx_q(int seid, struct i40e_pf *pf, int pf_q, - } - - /** -- * i40e_vsi_control_tx - Start or stop a VSI's rings -+ * i40e_vsi_enable_tx - Start a VSI's rings - * @vsi: the VSI being configured -- * @enable: start or stop the rings - **/ --static int i40e_vsi_control_tx(struct i40e_vsi *vsi, bool enable) -+static int i40e_vsi_enable_tx(struct i40e_vsi *vsi) - { - struct i40e_pf *pf = vsi->back; - int i, pf_q, ret = 0; -@@ -4467,7 +4466,7 @@ static int i40e_vsi_control_tx(struct i40e_vsi *vsi, bool enable) - for (i = 0; i < vsi->num_queue_pairs; i++, pf_q++) { - ret = i40e_control_wait_tx_q(vsi->seid, pf, - pf_q, -- false /*is xdp*/, enable); -+ false /*is xdp*/, true); - if (ret) - break; - -@@ -4476,7 +4475,7 @@ static int i40e_vsi_control_tx(struct i40e_vsi *vsi, bool enable) - - ret = i40e_control_wait_tx_q(vsi->seid, pf, - pf_q + vsi->alloc_queue_pairs, -- true /*is xdp*/, enable); -+ true /*is xdp*/, true); - if (ret) - break; - } -@@ -4574,32 +4573,25 @@ int i40e_control_wait_rx_q(struct i40e_pf *pf, int pf_q, bool enable) - } - - /** -- * i40e_vsi_control_rx - Start or stop a VSI's rings -+ * i40e_vsi_enable_rx - Start a VSI's rings - * @vsi: the VSI being configured -- * @enable: start or stop the rings - **/ --static int i40e_vsi_control_rx(struct i40e_vsi *vsi, bool enable) -+static int i40e_vsi_enable_rx(struct i40e_vsi *vsi) - { - struct i40e_pf *pf = vsi->back; - int i, pf_q, ret = 0; - - pf_q = vsi->base_queue; - for (i = 0; i < vsi->num_queue_pairs; i++, pf_q++) { -- ret = i40e_control_wait_rx_q(pf, pf_q, enable); -+ ret = i40e_control_wait_rx_q(pf, pf_q, true); - if (ret) { - dev_info(&pf->pdev->dev, -- "VSI seid %d Rx ring %d %sable timeout\n", -- vsi->seid, pf_q, (enable ? "en" : "dis")); -+ "VSI seid %d Rx ring %d enable timeout\n", -+ vsi->seid, pf_q); - break; - } - } - -- /* Due to HW errata, on Rx disable only, the register can indicate done -- * before it really is. Needs 50ms to be sure -- */ -- if (!enable) -- mdelay(50); -- - return ret; - } - -@@ -4612,29 +4604,47 @@ int i40e_vsi_start_rings(struct i40e_vsi *vsi) - int ret = 0; - - /* do rx first for enable and last for disable */ -- ret = i40e_vsi_control_rx(vsi, true); -+ ret = i40e_vsi_enable_rx(vsi); - if (ret) - return ret; -- ret = i40e_vsi_control_tx(vsi, true); -+ ret = i40e_vsi_enable_tx(vsi); - - return ret; - } - -+#define I40E_DISABLE_TX_GAP_MSEC 50 -+ - /** - * i40e_vsi_stop_rings - Stop a VSI's rings - * @vsi: the VSI being configured - **/ - void i40e_vsi_stop_rings(struct i40e_vsi *vsi) - { -+ struct i40e_pf *pf = vsi->back; -+ int pf_q, err, q_end; -+ - /* When port TX is suspended, don't wait */ - if (test_bit(__I40E_PORT_SUSPENDED, vsi->back->state)) - return i40e_vsi_stop_rings_no_wait(vsi); - -- /* do rx first for enable and last for disable -- * Ignore return value, we need to shutdown whatever we can -- */ -- i40e_vsi_control_tx(vsi, false); -- i40e_vsi_control_rx(vsi, false); -+ q_end = vsi->base_queue + vsi->num_queue_pairs; -+ for (pf_q = vsi->base_queue; pf_q < q_end; pf_q++) -+ i40e_pre_tx_queue_cfg(&pf->hw, (u32)pf_q, false); -+ -+ for (pf_q = vsi->base_queue; pf_q < q_end; pf_q++) { -+ err = i40e_control_wait_rx_q(pf, pf_q, false); -+ if (err) -+ dev_info(&pf->pdev->dev, -+ "VSI seid %d Rx ring %d dissable timeout\n", -+ vsi->seid, pf_q); -+ } -+ -+ msleep(I40E_DISABLE_TX_GAP_MSEC); -+ pf_q = vsi->base_queue; -+ for (pf_q = vsi->base_queue; pf_q < q_end; pf_q++) -+ wr32(&pf->hw, I40E_QTX_ENA(pf_q), 0); -+ -+ i40e_vsi_wait_queues_disabled(vsi); - } - - /** -@@ -7280,6 +7290,8 @@ static int i40e_validate_mqprio_qopt(struct i40e_vsi *vsi, - } - if (vsi->num_queue_pairs < - (mqprio_qopt->qopt.offset[i] + mqprio_qopt->qopt.count[i])) { -+ dev_err(&vsi->back->pdev->dev, -+ "Failed to create traffic channel, insufficient number of queues.\n"); - return -EINVAL; - } - if (sum_max_rate > i40e_get_link_speed(vsi)) { -@@ -13261,6 +13273,7 @@ static const struct net_device_ops i40e_netdev_ops = { - .ndo_poll_controller = i40e_netpoll, - #endif - .ndo_setup_tc = __i40e_setup_tc, -+ .ndo_select_queue = i40e_lan_select_queue, - .ndo_set_features = i40e_set_features, - .ndo_set_vf_mac = i40e_ndo_set_vf_mac, - .ndo_set_vf_vlan = i40e_ndo_set_vf_port_vlan, -diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c -index b883ab809df30..107fb472319ee 100644 ---- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c -+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c -@@ -3633,6 +3633,56 @@ dma_error: - return -1; - } - -+static u16 i40e_swdcb_skb_tx_hash(struct net_device *dev, -+ const struct sk_buff *skb, -+ u16 num_tx_queues) -+{ -+ u32 jhash_initval_salt = 0xd631614b; -+ u32 hash; -+ -+ if (skb->sk && skb->sk->sk_hash) -+ hash = skb->sk->sk_hash; -+ else -+ hash = (__force u16)skb->protocol ^ skb->hash; -+ -+ hash = jhash_1word(hash, jhash_initval_salt); -+ -+ return (u16)(((u64)hash * num_tx_queues) >> 32); -+} -+ -+u16 i40e_lan_select_queue(struct net_device *netdev, -+ struct sk_buff *skb, -+ struct net_device __always_unused *sb_dev) -+{ -+ struct i40e_netdev_priv *np = netdev_priv(netdev); -+ struct i40e_vsi *vsi = np->vsi; -+ struct i40e_hw *hw; -+ u16 qoffset; -+ u16 qcount; -+ u8 tclass; -+ u16 hash; -+ u8 prio; -+ -+ /* is DCB enabled at all? */ -+ if (vsi->tc_config.numtc == 1) -+ return i40e_swdcb_skb_tx_hash(netdev, skb, -+ netdev->real_num_tx_queues); -+ -+ prio = skb->priority; -+ hw = &vsi->back->hw; -+ tclass = hw->local_dcbx_config.etscfg.prioritytable[prio]; -+ /* sanity check */ -+ if (unlikely(!(vsi->tc_config.enabled_tc & BIT(tclass)))) -+ tclass = 0; -+ -+ /* select a queue assigned for the given TC */ -+ qcount = vsi->tc_config.tc_info[tclass].qcount; -+ hash = i40e_swdcb_skb_tx_hash(netdev, skb, qcount); -+ -+ qoffset = vsi->tc_config.tc_info[tclass].qoffset; -+ return qoffset + hash; -+} -+ - /** - * i40e_xmit_xdp_ring - transmits an XDP buffer to an XDP Tx ring - * @xdpf: data to transmit -diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.h b/drivers/net/ethernet/intel/i40e/i40e_txrx.h -index 86fed05b4f193..bfc2845c99d1c 100644 ---- a/drivers/net/ethernet/intel/i40e/i40e_txrx.h -+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.h -@@ -451,6 +451,8 @@ static inline unsigned int i40e_rx_pg_order(struct i40e_ring *ring) - - bool i40e_alloc_rx_buffers(struct i40e_ring *rxr, u16 cleaned_count); - netdev_tx_t i40e_lan_xmit_frame(struct sk_buff *skb, struct net_device *netdev); -+u16 i40e_lan_select_queue(struct net_device *netdev, struct sk_buff *skb, -+ struct net_device *sb_dev); - void i40e_clean_tx_ring(struct i40e_ring *tx_ring); - void i40e_clean_rx_ring(struct i40e_ring *rx_ring); - int i40e_setup_tx_descriptors(struct i40e_ring *tx_ring); -diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c -index fac6474ad694d..f43cb1407e8cd 100644 ---- a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c -+++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c -@@ -1243,8 +1243,8 @@ static int cgx_lmac_init(struct cgx *cgx) - - /* Add reference */ - cgx->lmac_idmap[lmac->lmac_id] = lmac; -- cgx->mac_ops->mac_pause_frm_config(cgx, lmac->lmac_id, true); - set_bit(lmac->lmac_id, &cgx->lmac_bmap); -+ cgx->mac_ops->mac_pause_frm_config(cgx, lmac->lmac_id, true); - } - - return cgx_lmac_verify_fwi_version(cgx); -diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c -index 0a8bd667cb110..61ab4fdee73a3 100644 ---- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c -+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c -@@ -3587,7 +3587,6 @@ static void rvu_nix_block_freemem(struct rvu *rvu, int blkaddr, - vlan = &nix_hw->txvlan; - kfree(vlan->rsrc.bmap); - mutex_destroy(&vlan->rsrc_lock); -- devm_kfree(rvu->dev, vlan->entry2pfvf_map); - - mcast = &nix_hw->mcast; - qmem_free(rvu->dev, mcast->mce_ctx); -diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c -index cf7875d51d879..16ba457197a2b 100644 ---- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c -+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c -@@ -921,12 +921,14 @@ static int otx2_cq_init(struct otx2_nic *pfvf, u16 qidx) - aq->cq.drop = RQ_DROP_LVL_CQ(pfvf->hw.rq_skid, cq->cqe_cnt); - aq->cq.drop_ena = 1; - -- /* Enable receive CQ backpressure */ -- aq->cq.bp_ena = 1; -- aq->cq.bpid = pfvf->bpid[0]; -+ if (!is_otx2_lbkvf(pfvf->pdev)) { -+ /* Enable receive CQ backpressure */ -+ aq->cq.bp_ena = 1; -+ aq->cq.bpid = pfvf->bpid[0]; - -- /* Set backpressure level is same as cq pass level */ -- aq->cq.bp = RQ_PASS_LVL_CQ(pfvf->hw.rq_skid, qset->rqe_cnt); -+ /* Set backpressure level is same as cq pass level */ -+ aq->cq.bp = RQ_PASS_LVL_CQ(pfvf->hw.rq_skid, qset->rqe_cnt); -+ } - } - - /* Fill AQ info */ -@@ -1183,7 +1185,7 @@ static int otx2_aura_init(struct otx2_nic *pfvf, int aura_id, - aq->aura.fc_hyst_bits = 0; /* Store count on all updates */ - - /* Enable backpressure for RQ aura */ -- if (aura_id < pfvf->hw.rqpool_cnt) { -+ if (aura_id < pfvf->hw.rqpool_cnt && !is_otx2_lbkvf(pfvf->pdev)) { - aq->aura.bp_ena = 0; - aq->aura.nix0_bpid = pfvf->bpid[0]; - /* Set backpressure level for RQ's Aura */ -diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c -index 9d9a2e438acfc..ae06eeeb5a45d 100644 ---- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c -+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c -@@ -292,15 +292,14 @@ static int otx2_set_channels(struct net_device *dev, - err = otx2_set_real_num_queues(dev, channel->tx_count, - channel->rx_count); - if (err) -- goto fail; -+ return err; - - pfvf->hw.rx_queues = channel->rx_count; - pfvf->hw.tx_queues = channel->tx_count; - pfvf->qset.cq_cnt = pfvf->hw.tx_queues + pfvf->hw.rx_queues; - --fail: - if (if_up) -- dev->netdev_ops->ndo_open(dev); -+ err = dev->netdev_ops->ndo_open(dev); - - netdev_info(dev, "Setting num Tx rings to %d, Rx rings to %d success\n", - pfvf->hw.tx_queues, pfvf->hw.rx_queues); -@@ -404,7 +403,7 @@ static int otx2_set_ringparam(struct net_device *netdev, - qs->rqe_cnt = rx_count; - - if (if_up) -- netdev->netdev_ops->ndo_open(netdev); -+ return netdev->netdev_ops->ndo_open(netdev); - - return 0; - } -diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c -index 03004fdac0c6b..2af50250d13cc 100644 ---- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c -+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c -@@ -1648,6 +1648,7 @@ int otx2_open(struct net_device *netdev) - err_tx_stop_queues: - netif_tx_stop_all_queues(netdev); - netif_carrier_off(netdev); -+ pf->flags |= OTX2_FLAG_INTF_DOWN; - err_free_cints: - otx2_free_cints(pf, qidx); - vec = pci_irq_vector(pf->pdev, -@@ -1675,6 +1676,10 @@ int otx2_stop(struct net_device *netdev) - struct otx2_rss_info *rss; - int qidx, vec, wrk; - -+ /* If the DOWN flag is set resources are already freed */ -+ if (pf->flags & OTX2_FLAG_INTF_DOWN) -+ return 0; -+ - netif_carrier_off(netdev); - netif_tx_stop_all_queues(netdev); - -diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c -index 00c84656b2e7e..28ac4693da3cf 100644 ---- a/drivers/net/ethernet/mellanox/mlx4/main.c -+++ b/drivers/net/ethernet/mellanox/mlx4/main.c -@@ -3535,6 +3535,7 @@ slave_start: - - if (!SRIOV_VALID_STATE(dev->flags)) { - mlx4_err(dev, "Invalid SRIOV state\n"); -+ err = -EINVAL; - goto err_close; - } - } -diff --git a/drivers/net/ethernet/mellanox/mlx5/core/dev.c b/drivers/net/ethernet/mellanox/mlx5/core/dev.c -index ceebfc20f65e5..def2156e50eeb 100644 ---- a/drivers/net/ethernet/mellanox/mlx5/core/dev.c -+++ b/drivers/net/ethernet/mellanox/mlx5/core/dev.c -@@ -500,10 +500,7 @@ static int next_phys_dev(struct device *dev, const void *data) - return 1; - } - --/* This function is called with two flows: -- * 1. During initialization of mlx5_core_dev and we don't need to lock it. -- * 2. During LAG configure stage and caller holds &mlx5_intf_mutex. -- */ -+/* Must be called with intf_mutex held */ - struct mlx5_core_dev *mlx5_get_next_phys_dev(struct mlx5_core_dev *dev) - { - struct auxiliary_device *adev; -diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/params.c b/drivers/net/ethernet/mellanox/mlx5/core/en/params.c -index f410c12684225..133eb13facfd4 100644 ---- a/drivers/net/ethernet/mellanox/mlx5/core/en/params.c -+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/params.c -@@ -471,6 +471,15 @@ static void mlx5e_build_rx_cq_param(struct mlx5_core_dev *mdev, - param->cq_period_mode = params->rx_cq_moderation.cq_period_mode; - } - -+static u8 rq_end_pad_mode(struct mlx5_core_dev *mdev, struct mlx5e_params *params) -+{ -+ bool ro = pcie_relaxed_ordering_enabled(mdev->pdev) && -+ MLX5_CAP_GEN(mdev, relaxed_ordering_write); -+ -+ return ro && params->lro_en ? -+ MLX5_WQ_END_PAD_MODE_NONE : MLX5_WQ_END_PAD_MODE_ALIGN; -+} -+ - int mlx5e_build_rq_param(struct mlx5_core_dev *mdev, - struct mlx5e_params *params, - struct mlx5e_xsk_param *xsk, -@@ -508,7 +517,7 @@ int mlx5e_build_rq_param(struct mlx5_core_dev *mdev, - } - - MLX5_SET(wq, wq, wq_type, params->rq_wq_type); -- MLX5_SET(wq, wq, end_padding_mode, MLX5_WQ_END_PAD_MODE_ALIGN); -+ MLX5_SET(wq, wq, end_padding_mode, rq_end_pad_mode(mdev, params)); - MLX5_SET(wq, wq, log_wq_stride, - mlx5e_get_rqwq_log_stride(params->rq_wq_type, ndsegs)); - MLX5_SET(wq, wq, pd, mdev->mlx5e_res.hw_objs.pdn); -diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c b/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c -index 778e229310a93..0f6b3231ca1d7 100644 ---- a/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c -+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c -@@ -494,7 +494,7 @@ static int mlx5e_init_ptp_rq(struct mlx5e_ptp *c, struct mlx5e_params *params, - int err; - - rq->wq_type = params->rq_wq_type; -- rq->pdev = mdev->device; -+ rq->pdev = c->pdev; - rq->netdev = priv->netdev; - rq->priv = priv; - rq->clock = &mdev->clock; -diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/trap.c b/drivers/net/ethernet/mellanox/mlx5/core/en/trap.c -index 86ab4e864fe6c..7f94508594fb6 100644 ---- a/drivers/net/ethernet/mellanox/mlx5/core/en/trap.c -+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/trap.c -@@ -37,7 +37,7 @@ static void mlx5e_init_trap_rq(struct mlx5e_trap *t, struct mlx5e_params *params - struct mlx5e_priv *priv = t->priv; - - rq->wq_type = params->rq_wq_type; -- rq->pdev = mdev->device; -+ rq->pdev = t->pdev; - rq->netdev = priv->netdev; - rq->priv = priv; - rq->clock = &mdev->clock; -diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c -index d26b8ed511959..d0d9acb172536 100644 ---- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c -+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c -@@ -3825,6 +3825,24 @@ int mlx5e_set_features(struct net_device *netdev, netdev_features_t features) - return 0; - } - -+static netdev_features_t mlx5e_fix_uplink_rep_features(struct net_device *netdev, -+ netdev_features_t features) -+{ -+ features &= ~NETIF_F_HW_TLS_RX; -+ if (netdev->features & NETIF_F_HW_TLS_RX) -+ netdev_warn(netdev, "Disabling hw_tls_rx, not supported in switchdev mode\n"); -+ -+ features &= ~NETIF_F_HW_TLS_TX; -+ if (netdev->features & NETIF_F_HW_TLS_TX) -+ netdev_warn(netdev, "Disabling hw_tls_tx, not supported in switchdev mode\n"); -+ -+ features &= ~NETIF_F_NTUPLE; -+ if (netdev->features & NETIF_F_NTUPLE) -+ netdev_warn(netdev, "Disabling ntuple, not supported in switchdev mode\n"); -+ -+ return features; -+} -+ - static netdev_features_t mlx5e_fix_features(struct net_device *netdev, - netdev_features_t features) - { -@@ -3856,15 +3874,8 @@ static netdev_features_t mlx5e_fix_features(struct net_device *netdev, - netdev_warn(netdev, "Disabling rxhash, not supported when CQE compress is active\n"); - } - -- if (mlx5e_is_uplink_rep(priv)) { -- features &= ~NETIF_F_HW_TLS_RX; -- if (netdev->features & NETIF_F_HW_TLS_RX) -- netdev_warn(netdev, "Disabling hw_tls_rx, not supported in switchdev mode\n"); -- -- features &= ~NETIF_F_HW_TLS_TX; -- if (netdev->features & NETIF_F_HW_TLS_TX) -- netdev_warn(netdev, "Disabling hw_tls_tx, not supported in switchdev mode\n"); -- } -+ if (mlx5e_is_uplink_rep(priv)) -+ features = mlx5e_fix_uplink_rep_features(netdev, features); - - mutex_unlock(&priv->state_lock); - -@@ -4855,6 +4866,9 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev) - if (MLX5_CAP_ETH(mdev, scatter_fcs)) - netdev->hw_features |= NETIF_F_RXFCS; - -+ if (mlx5_qos_is_supported(mdev)) -+ netdev->hw_features |= NETIF_F_HW_TC; -+ - netdev->features = netdev->hw_features; - - /* Defaults */ -@@ -4875,8 +4889,6 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev) - netdev->hw_features |= NETIF_F_NTUPLE; - #endif - } -- if (mlx5_qos_is_supported(mdev)) -- netdev->features |= NETIF_F_HW_TC; - - netdev->features |= NETIF_F_HIGHDMA; - netdev->features |= NETIF_F_HW_VLAN_STAG_FILTER; -diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c -index d4b0f270b6bb8..47bd20ad81080 100644 ---- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c -+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c -@@ -424,12 +424,32 @@ static void mlx5e_detach_mod_hdr(struct mlx5e_priv *priv, - static - struct mlx5_core_dev *mlx5e_hairpin_get_mdev(struct net *net, int ifindex) - { -+ struct mlx5_core_dev *mdev; - struct net_device *netdev; - struct mlx5e_priv *priv; - -- netdev = __dev_get_by_index(net, ifindex); -+ netdev = dev_get_by_index(net, ifindex); -+ if (!netdev) -+ return ERR_PTR(-ENODEV); -+ - priv = netdev_priv(netdev); -- return priv->mdev; -+ mdev = priv->mdev; -+ dev_put(netdev); -+ -+ /* Mirred tc action holds a refcount on the ifindex net_device (see -+ * net/sched/act_mirred.c:tcf_mirred_get_dev). So, it's okay to continue using mdev -+ * after dev_put(netdev), while we're in the context of adding a tc flow. -+ * -+ * The mdev pointer corresponds to the peer/out net_device of a hairpin. It is then -+ * stored in a hairpin object, which exists until all flows, that refer to it, get -+ * removed. -+ * -+ * On the other hand, after a hairpin object has been created, the peer net_device may -+ * be removed/unbound while there are still some hairpin flows that are using it. This -+ * case is handled by mlx5e_tc_hairpin_update_dead_peer, which is hooked to -+ * NETDEV_UNREGISTER event of the peer net_device. -+ */ -+ return mdev; - } - - static int mlx5e_hairpin_create_transport(struct mlx5e_hairpin *hp) -@@ -638,6 +658,10 @@ mlx5e_hairpin_create(struct mlx5e_priv *priv, struct mlx5_hairpin_params *params - - func_mdev = priv->mdev; - peer_mdev = mlx5e_hairpin_get_mdev(dev_net(priv->netdev), peer_ifindex); -+ if (IS_ERR(peer_mdev)) { -+ err = PTR_ERR(peer_mdev); -+ goto create_pair_err; -+ } - - pair = mlx5_core_hairpin_create(func_mdev, peer_mdev, params); - if (IS_ERR(pair)) { -@@ -776,6 +800,11 @@ static int mlx5e_hairpin_flow_add(struct mlx5e_priv *priv, - int err; - - peer_mdev = mlx5e_hairpin_get_mdev(dev_net(priv->netdev), peer_ifindex); -+ if (IS_ERR(peer_mdev)) { -+ NL_SET_ERR_MSG_MOD(extack, "invalid ifindex of mirred device"); -+ return PTR_ERR(peer_mdev); -+ } -+ - if (!MLX5_CAP_GEN(priv->mdev, hairpin) || !MLX5_CAP_GEN(peer_mdev, hairpin)) { - NL_SET_ERR_MSG_MOD(extack, "hairpin is not supported"); - return -EOPNOTSUPP; -diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h -index 64ccb2bc0b58c..e0f6f75fd9d62 100644 ---- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h -+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h -@@ -629,7 +629,7 @@ struct esw_vport_tbl_namespace { - }; - - struct mlx5_vport_tbl_attr { -- u16 chain; -+ u32 chain; - u16 prio; - u16 vport; - const struct esw_vport_tbl_namespace *vport_ns; -diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c -index d18a28a6e9a63..b66e12753f37f 100644 ---- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c -+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c -@@ -382,10 +382,11 @@ esw_setup_vport_dest(struct mlx5_flow_destination *dest, struct mlx5_flow_act *f - { - dest[dest_idx].type = MLX5_FLOW_DESTINATION_TYPE_VPORT; - dest[dest_idx].vport.num = esw_attr->dests[attr_idx].rep->vport; -- dest[dest_idx].vport.vhca_id = -- MLX5_CAP_GEN(esw_attr->dests[attr_idx].mdev, vhca_id); -- if (MLX5_CAP_ESW(esw->dev, merged_eswitch)) -+ if (MLX5_CAP_ESW(esw->dev, merged_eswitch)) { -+ dest[dest_idx].vport.vhca_id = -+ MLX5_CAP_GEN(esw_attr->dests[attr_idx].mdev, vhca_id); - dest[dest_idx].vport.flags |= MLX5_FLOW_DEST_VPORT_VHCA_ID; -+ } - if (esw_attr->dests[attr_idx].flags & MLX5_ESW_DEST_ENCAP) { - if (pkt_reformat) { - flow_act->action |= MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT; -@@ -2350,6 +2351,9 @@ static int mlx5_esw_offloads_devcom_event(int event, - - switch (event) { - case ESW_OFFLOADS_DEVCOM_PAIR: -+ if (mlx5_get_next_phys_dev(esw->dev) != peer_esw->dev) -+ break; -+ - if (mlx5_eswitch_vport_match_metadata_enabled(esw) != - mlx5_eswitch_vport_match_metadata_enabled(peer_esw)) - break; -diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c -index f74d2c834037f..48fc242e066f7 100644 ---- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c -+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c -@@ -1024,17 +1024,19 @@ static int connect_fwd_rules(struct mlx5_core_dev *dev, - static int connect_flow_table(struct mlx5_core_dev *dev, struct mlx5_flow_table *ft, - struct fs_prio *prio) - { -- struct mlx5_flow_table *next_ft; -+ struct mlx5_flow_table *next_ft, *first_ft; - int err = 0; - - /* Connect_prev_fts and update_root_ft_create are mutually exclusive */ - -- if (list_empty(&prio->node.children)) { -+ first_ft = list_first_entry_or_null(&prio->node.children, -+ struct mlx5_flow_table, node.list); -+ if (!first_ft || first_ft->level > ft->level) { - err = connect_prev_fts(dev, ft, prio); - if (err) - return err; - -- next_ft = find_next_chained_ft(prio); -+ next_ft = first_ft ? first_ft : find_next_chained_ft(prio); - err = connect_fwd_rules(dev, ft, next_ft); - if (err) - return err; -@@ -2109,7 +2111,7 @@ static int disconnect_flow_table(struct mlx5_flow_table *ft) - node.list) == ft)) - return 0; - -- next_ft = find_next_chained_ft(prio); -+ next_ft = find_next_ft(ft); - err = connect_fwd_rules(dev, next_ft, ft); - if (err) - return err; -diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c -index 9ff163c5bcde8..9abeb80ffa316 100644 ---- a/drivers/net/ethernet/mellanox/mlx5/core/health.c -+++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c -@@ -626,8 +626,16 @@ static void mlx5_fw_fatal_reporter_err_work(struct work_struct *work) - } - fw_reporter_ctx.err_synd = health->synd; - fw_reporter_ctx.miss_counter = health->miss_counter; -- devlink_health_report(health->fw_fatal_reporter, -- "FW fatal error reported", &fw_reporter_ctx); -+ if (devlink_health_report(health->fw_fatal_reporter, -+ "FW fatal error reported", &fw_reporter_ctx) == -ECANCELED) { -+ /* If recovery wasn't performed, due to grace period, -+ * unload the driver. This ensures that the driver -+ * closes all its resources and it is not subjected to -+ * requests from the kernel. -+ */ -+ mlx5_core_err(dev, "Driver is in error state. Unloading\n"); -+ mlx5_unload_one(dev); -+ } - } - - static const struct devlink_health_reporter_ops mlx5_fw_fatal_reporter_ops = { -diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c -index af3a5368529cc..e795fa63ca12e 100644 ---- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c -+++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c -@@ -29,7 +29,7 @@ static const u8 ionic_qtype_versions[IONIC_QTYPE_MAX] = { - */ - }; - --static void ionic_lif_rx_mode(struct ionic_lif *lif, unsigned int rx_mode); -+static void ionic_lif_rx_mode(struct ionic_lif *lif); - static int ionic_lif_addr_add(struct ionic_lif *lif, const u8 *addr); - static int ionic_lif_addr_del(struct ionic_lif *lif, const u8 *addr); - static void ionic_link_status_check(struct ionic_lif *lif); -@@ -53,7 +53,19 @@ static void ionic_dim_work(struct work_struct *work) - cur_moder = net_dim_get_rx_moderation(dim->mode, dim->profile_ix); - qcq = container_of(dim, struct ionic_qcq, dim); - new_coal = ionic_coal_usec_to_hw(qcq->q.lif->ionic, cur_moder.usec); -- qcq->intr.dim_coal_hw = new_coal ? new_coal : 1; -+ new_coal = new_coal ? new_coal : 1; -+ -+ if (qcq->intr.dim_coal_hw != new_coal) { -+ unsigned int qi = qcq->cq.bound_q->index; -+ struct ionic_lif *lif = qcq->q.lif; -+ -+ qcq->intr.dim_coal_hw = new_coal; -+ -+ ionic_intr_coal_init(lif->ionic->idev.intr_ctrl, -+ lif->rxqcqs[qi]->intr.index, -+ qcq->intr.dim_coal_hw); -+ } -+ - dim->state = DIM_START_MEASURE; - } - -@@ -77,7 +89,7 @@ static void ionic_lif_deferred_work(struct work_struct *work) - - switch (w->type) { - case IONIC_DW_TYPE_RX_MODE: -- ionic_lif_rx_mode(lif, w->rx_mode); -+ ionic_lif_rx_mode(lif); - break; - case IONIC_DW_TYPE_RX_ADDR_ADD: - ionic_lif_addr_add(lif, w->addr); -@@ -1301,10 +1313,8 @@ static int ionic_lif_addr_del(struct ionic_lif *lif, const u8 *addr) - return 0; - } - --static int ionic_lif_addr(struct ionic_lif *lif, const u8 *addr, bool add, -- bool can_sleep) -+static int ionic_lif_addr(struct ionic_lif *lif, const u8 *addr, bool add) - { -- struct ionic_deferred_work *work; - unsigned int nmfilters; - unsigned int nufilters; - -@@ -1330,97 +1340,46 @@ static int ionic_lif_addr(struct ionic_lif *lif, const u8 *addr, bool add, - lif->nucast--; - } - -- if (!can_sleep) { -- work = kzalloc(sizeof(*work), GFP_ATOMIC); -- if (!work) -- return -ENOMEM; -- work->type = add ? IONIC_DW_TYPE_RX_ADDR_ADD : -- IONIC_DW_TYPE_RX_ADDR_DEL; -- memcpy(work->addr, addr, ETH_ALEN); -- netdev_dbg(lif->netdev, "deferred: rx_filter %s %pM\n", -- add ? "add" : "del", addr); -- ionic_lif_deferred_enqueue(&lif->deferred, work); -- } else { -- netdev_dbg(lif->netdev, "rx_filter %s %pM\n", -- add ? "add" : "del", addr); -- if (add) -- return ionic_lif_addr_add(lif, addr); -- else -- return ionic_lif_addr_del(lif, addr); -- } -+ netdev_dbg(lif->netdev, "rx_filter %s %pM\n", -+ add ? "add" : "del", addr); -+ if (add) -+ return ionic_lif_addr_add(lif, addr); -+ else -+ return ionic_lif_addr_del(lif, addr); - - return 0; - } - - static int ionic_addr_add(struct net_device *netdev, const u8 *addr) - { -- return ionic_lif_addr(netdev_priv(netdev), addr, ADD_ADDR, CAN_SLEEP); --} -- --static int ionic_ndo_addr_add(struct net_device *netdev, const u8 *addr) --{ -- return ionic_lif_addr(netdev_priv(netdev), addr, ADD_ADDR, CAN_NOT_SLEEP); -+ return ionic_lif_addr(netdev_priv(netdev), addr, ADD_ADDR); - } - - static int ionic_addr_del(struct net_device *netdev, const u8 *addr) - { -- return ionic_lif_addr(netdev_priv(netdev), addr, DEL_ADDR, CAN_SLEEP); -+ return ionic_lif_addr(netdev_priv(netdev), addr, DEL_ADDR); - } - --static int ionic_ndo_addr_del(struct net_device *netdev, const u8 *addr) -+static void ionic_lif_rx_mode(struct ionic_lif *lif) - { -- return ionic_lif_addr(netdev_priv(netdev), addr, DEL_ADDR, CAN_NOT_SLEEP); --} -- --static void ionic_lif_rx_mode(struct ionic_lif *lif, unsigned int rx_mode) --{ -- struct ionic_admin_ctx ctx = { -- .work = COMPLETION_INITIALIZER_ONSTACK(ctx.work), -- .cmd.rx_mode_set = { -- .opcode = IONIC_CMD_RX_MODE_SET, -- .lif_index = cpu_to_le16(lif->index), -- .rx_mode = cpu_to_le16(rx_mode), -- }, -- }; -+ struct net_device *netdev = lif->netdev; -+ unsigned int nfilters; -+ unsigned int nd_flags; - char buf[128]; -- int err; -+ u16 rx_mode; - int i; - #define REMAIN(__x) (sizeof(buf) - (__x)) - -- i = scnprintf(buf, sizeof(buf), "rx_mode 0x%04x -> 0x%04x:", -- lif->rx_mode, rx_mode); -- if (rx_mode & IONIC_RX_MODE_F_UNICAST) -- i += scnprintf(&buf[i], REMAIN(i), " RX_MODE_F_UNICAST"); -- if (rx_mode & IONIC_RX_MODE_F_MULTICAST) -- i += scnprintf(&buf[i], REMAIN(i), " RX_MODE_F_MULTICAST"); -- if (rx_mode & IONIC_RX_MODE_F_BROADCAST) -- i += scnprintf(&buf[i], REMAIN(i), " RX_MODE_F_BROADCAST"); -- if (rx_mode & IONIC_RX_MODE_F_PROMISC) -- i += scnprintf(&buf[i], REMAIN(i), " RX_MODE_F_PROMISC"); -- if (rx_mode & IONIC_RX_MODE_F_ALLMULTI) -- i += scnprintf(&buf[i], REMAIN(i), " RX_MODE_F_ALLMULTI"); -- netdev_dbg(lif->netdev, "lif%d %s\n", lif->index, buf); -- -- err = ionic_adminq_post_wait(lif, &ctx); -- if (err) -- netdev_warn(lif->netdev, "set rx_mode 0x%04x failed: %d\n", -- rx_mode, err); -- else -- lif->rx_mode = rx_mode; --} -+ mutex_lock(&lif->config_lock); - --static void ionic_set_rx_mode(struct net_device *netdev, bool can_sleep) --{ -- struct ionic_lif *lif = netdev_priv(netdev); -- struct ionic_deferred_work *work; -- unsigned int nfilters; -- unsigned int rx_mode; -+ /* grab the flags once for local use */ -+ nd_flags = netdev->flags; - - rx_mode = IONIC_RX_MODE_F_UNICAST; -- rx_mode |= (netdev->flags & IFF_MULTICAST) ? IONIC_RX_MODE_F_MULTICAST : 0; -- rx_mode |= (netdev->flags & IFF_BROADCAST) ? IONIC_RX_MODE_F_BROADCAST : 0; -- rx_mode |= (netdev->flags & IFF_PROMISC) ? IONIC_RX_MODE_F_PROMISC : 0; -- rx_mode |= (netdev->flags & IFF_ALLMULTI) ? IONIC_RX_MODE_F_ALLMULTI : 0; -+ rx_mode |= (nd_flags & IFF_MULTICAST) ? IONIC_RX_MODE_F_MULTICAST : 0; -+ rx_mode |= (nd_flags & IFF_BROADCAST) ? IONIC_RX_MODE_F_BROADCAST : 0; -+ rx_mode |= (nd_flags & IFF_PROMISC) ? IONIC_RX_MODE_F_PROMISC : 0; -+ rx_mode |= (nd_flags & IFF_ALLMULTI) ? IONIC_RX_MODE_F_ALLMULTI : 0; - - /* sync unicast addresses - * next check to see if we're in an overflow state -@@ -1429,49 +1388,83 @@ static void ionic_set_rx_mode(struct net_device *netdev, bool can_sleep) - * we remove our overflow flag and check the netdev flags - * to see if we can disable NIC PROMISC - */ -- if (can_sleep) -- __dev_uc_sync(netdev, ionic_addr_add, ionic_addr_del); -- else -- __dev_uc_sync(netdev, ionic_ndo_addr_add, ionic_ndo_addr_del); -+ __dev_uc_sync(netdev, ionic_addr_add, ionic_addr_del); - nfilters = le32_to_cpu(lif->identity->eth.max_ucast_filters); - if (netdev_uc_count(netdev) + 1 > nfilters) { - rx_mode |= IONIC_RX_MODE_F_PROMISC; - lif->uc_overflow = true; - } else if (lif->uc_overflow) { - lif->uc_overflow = false; -- if (!(netdev->flags & IFF_PROMISC)) -+ if (!(nd_flags & IFF_PROMISC)) - rx_mode &= ~IONIC_RX_MODE_F_PROMISC; - } - - /* same for multicast */ -- if (can_sleep) -- __dev_mc_sync(netdev, ionic_addr_add, ionic_addr_del); -- else -- __dev_mc_sync(netdev, ionic_ndo_addr_add, ionic_ndo_addr_del); -+ __dev_mc_sync(netdev, ionic_addr_add, ionic_addr_del); - nfilters = le32_to_cpu(lif->identity->eth.max_mcast_filters); - if (netdev_mc_count(netdev) > nfilters) { - rx_mode |= IONIC_RX_MODE_F_ALLMULTI; - lif->mc_overflow = true; - } else if (lif->mc_overflow) { - lif->mc_overflow = false; -- if (!(netdev->flags & IFF_ALLMULTI)) -+ if (!(nd_flags & IFF_ALLMULTI)) - rx_mode &= ~IONIC_RX_MODE_F_ALLMULTI; - } - -+ i = scnprintf(buf, sizeof(buf), "rx_mode 0x%04x -> 0x%04x:", -+ lif->rx_mode, rx_mode); -+ if (rx_mode & IONIC_RX_MODE_F_UNICAST) -+ i += scnprintf(&buf[i], REMAIN(i), " RX_MODE_F_UNICAST"); -+ if (rx_mode & IONIC_RX_MODE_F_MULTICAST) -+ i += scnprintf(&buf[i], REMAIN(i), " RX_MODE_F_MULTICAST"); -+ if (rx_mode & IONIC_RX_MODE_F_BROADCAST) -+ i += scnprintf(&buf[i], REMAIN(i), " RX_MODE_F_BROADCAST"); -+ if (rx_mode & IONIC_RX_MODE_F_PROMISC) -+ i += scnprintf(&buf[i], REMAIN(i), " RX_MODE_F_PROMISC"); -+ if (rx_mode & IONIC_RX_MODE_F_ALLMULTI) -+ i += scnprintf(&buf[i], REMAIN(i), " RX_MODE_F_ALLMULTI"); -+ if (rx_mode & IONIC_RX_MODE_F_RDMA_SNIFFER) -+ i += scnprintf(&buf[i], REMAIN(i), " RX_MODE_F_RDMA_SNIFFER"); -+ netdev_dbg(netdev, "lif%d %s\n", lif->index, buf); -+ - if (lif->rx_mode != rx_mode) { -- if (!can_sleep) { -- work = kzalloc(sizeof(*work), GFP_ATOMIC); -- if (!work) { -- netdev_err(lif->netdev, "rxmode change dropped\n"); -- return; -- } -- work->type = IONIC_DW_TYPE_RX_MODE; -- work->rx_mode = rx_mode; -- netdev_dbg(lif->netdev, "deferred: rx_mode\n"); -- ionic_lif_deferred_enqueue(&lif->deferred, work); -- } else { -- ionic_lif_rx_mode(lif, rx_mode); -+ struct ionic_admin_ctx ctx = { -+ .work = COMPLETION_INITIALIZER_ONSTACK(ctx.work), -+ .cmd.rx_mode_set = { -+ .opcode = IONIC_CMD_RX_MODE_SET, -+ .lif_index = cpu_to_le16(lif->index), -+ }, -+ }; -+ int err; -+ -+ ctx.cmd.rx_mode_set.rx_mode = cpu_to_le16(rx_mode); -+ err = ionic_adminq_post_wait(lif, &ctx); -+ if (err) -+ netdev_warn(netdev, "set rx_mode 0x%04x failed: %d\n", -+ rx_mode, err); -+ else -+ lif->rx_mode = rx_mode; -+ } -+ -+ mutex_unlock(&lif->config_lock); -+} -+ -+static void ionic_set_rx_mode(struct net_device *netdev, bool can_sleep) -+{ -+ struct ionic_lif *lif = netdev_priv(netdev); -+ struct ionic_deferred_work *work; -+ -+ if (!can_sleep) { -+ work = kzalloc(sizeof(*work), GFP_ATOMIC); -+ if (!work) { -+ netdev_err(lif->netdev, "rxmode change dropped\n"); -+ return; - } -+ work->type = IONIC_DW_TYPE_RX_MODE; -+ netdev_dbg(lif->netdev, "deferred: rx_mode\n"); -+ ionic_lif_deferred_enqueue(&lif->deferred, work); -+ } else { -+ ionic_lif_rx_mode(lif); - } - } - -@@ -3058,6 +3051,7 @@ void ionic_lif_deinit(struct ionic_lif *lif) - ionic_lif_qcq_deinit(lif, lif->notifyqcq); - ionic_lif_qcq_deinit(lif, lif->adminqcq); - -+ mutex_destroy(&lif->config_lock); - mutex_destroy(&lif->queue_lock); - ionic_lif_reset(lif); - } -@@ -3185,7 +3179,7 @@ static int ionic_station_set(struct ionic_lif *lif) - */ - if (!ether_addr_equal(ctx.comp.lif_getattr.mac, - netdev->dev_addr)) -- ionic_lif_addr(lif, netdev->dev_addr, ADD_ADDR, CAN_SLEEP); -+ ionic_lif_addr(lif, netdev->dev_addr, ADD_ADDR); - } else { - /* Update the netdev mac with the device's mac */ - memcpy(addr.sa_data, ctx.comp.lif_getattr.mac, netdev->addr_len); -@@ -3202,7 +3196,7 @@ static int ionic_station_set(struct ionic_lif *lif) - - netdev_dbg(lif->netdev, "adding station MAC addr %pM\n", - netdev->dev_addr); -- ionic_lif_addr(lif, netdev->dev_addr, ADD_ADDR, CAN_SLEEP); -+ ionic_lif_addr(lif, netdev->dev_addr, ADD_ADDR); - - return 0; - } -@@ -3225,6 +3219,7 @@ int ionic_lif_init(struct ionic_lif *lif) - - lif->hw_index = le16_to_cpu(comp.hw_index); - mutex_init(&lif->queue_lock); -+ mutex_init(&lif->config_lock); - - /* now that we have the hw_index we can figure out our doorbell page */ - lif->dbid_count = le32_to_cpu(lif->ionic->ident.dev.ndbpgs_per_lif); -diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.h b/drivers/net/ethernet/pensando/ionic/ionic_lif.h -index 346506f017153..69ab59fedb6c6 100644 ---- a/drivers/net/ethernet/pensando/ionic/ionic_lif.h -+++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.h -@@ -108,7 +108,6 @@ struct ionic_deferred_work { - struct list_head list; - enum ionic_deferred_work_type type; - union { -- unsigned int rx_mode; - u8 addr[ETH_ALEN]; - u8 fw_status; - }; -@@ -179,6 +178,7 @@ struct ionic_lif { - unsigned int index; - unsigned int hw_index; - struct mutex queue_lock; /* lock for queue structures */ -+ struct mutex config_lock; /* lock for config actions */ - spinlock_t adminq_lock; /* lock for AdminQ operations */ - struct ionic_qcq *adminqcq; - struct ionic_qcq *notifyqcq; -@@ -199,7 +199,7 @@ struct ionic_lif { - unsigned int nrxq_descs; - u32 rx_copybreak; - u64 rxq_features; -- unsigned int rx_mode; -+ u16 rx_mode; - u64 hw_features; - bool registered; - bool mc_overflow; -@@ -302,7 +302,7 @@ int ionic_lif_identify(struct ionic *ionic, u8 lif_type, - int ionic_lif_size(struct ionic *ionic); - - #if IS_ENABLED(CONFIG_PTP_1588_CLOCK) --int ionic_lif_hwstamp_replay(struct ionic_lif *lif); -+void ionic_lif_hwstamp_replay(struct ionic_lif *lif); - int ionic_lif_hwstamp_set(struct ionic_lif *lif, struct ifreq *ifr); - int ionic_lif_hwstamp_get(struct ionic_lif *lif, struct ifreq *ifr); - ktime_t ionic_lif_phc_ktime(struct ionic_lif *lif, u64 counter); -@@ -311,10 +311,7 @@ void ionic_lif_unregister_phc(struct ionic_lif *lif); - void ionic_lif_alloc_phc(struct ionic_lif *lif); - void ionic_lif_free_phc(struct ionic_lif *lif); - #else --static inline int ionic_lif_hwstamp_replay(struct ionic_lif *lif) --{ -- return -EOPNOTSUPP; --} -+static inline void ionic_lif_hwstamp_replay(struct ionic_lif *lif) {} - - static inline int ionic_lif_hwstamp_set(struct ionic_lif *lif, struct ifreq *ifr) - { -diff --git a/drivers/net/ethernet/pensando/ionic/ionic_phc.c b/drivers/net/ethernet/pensando/ionic/ionic_phc.c -index a87c87e86aef6..6e2403c716087 100644 ---- a/drivers/net/ethernet/pensando/ionic/ionic_phc.c -+++ b/drivers/net/ethernet/pensando/ionic/ionic_phc.c -@@ -188,6 +188,9 @@ int ionic_lif_hwstamp_set(struct ionic_lif *lif, struct ifreq *ifr) - struct hwtstamp_config config; - int err; - -+ if (!lif->phc || !lif->phc->ptp) -+ return -EOPNOTSUPP; -+ - if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) - return -EFAULT; - -@@ -203,15 +206,16 @@ int ionic_lif_hwstamp_set(struct ionic_lif *lif, struct ifreq *ifr) - return 0; - } - --int ionic_lif_hwstamp_replay(struct ionic_lif *lif) -+void ionic_lif_hwstamp_replay(struct ionic_lif *lif) - { - int err; - -+ if (!lif->phc || !lif->phc->ptp) -+ return; -+ - err = ionic_lif_hwstamp_set_ts_config(lif, NULL); - if (err) - netdev_info(lif->netdev, "hwstamp replay failed: %d\n", err); -- -- return err; - } - - int ionic_lif_hwstamp_get(struct ionic_lif *lif, struct ifreq *ifr) -diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c -index 08934888575ce..08870190e4d28 100644 ---- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c -+++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c -@@ -274,12 +274,11 @@ static void ionic_rx_clean(struct ionic_queue *q, - } - } - -- if (likely(netdev->features & NETIF_F_RXCSUM)) { -- if (comp->csum_flags & IONIC_RXQ_COMP_CSUM_F_CALC) { -- skb->ip_summed = CHECKSUM_COMPLETE; -- skb->csum = (__force __wsum)le16_to_cpu(comp->csum); -- stats->csum_complete++; -- } -+ if (likely(netdev->features & NETIF_F_RXCSUM) && -+ (comp->csum_flags & IONIC_RXQ_COMP_CSUM_F_CALC)) { -+ skb->ip_summed = CHECKSUM_COMPLETE; -+ skb->csum = (__force __wsum)le16_to_cpu(comp->csum); -+ stats->csum_complete++; - } else { - stats->csum_none++; - } -@@ -451,11 +450,12 @@ void ionic_rx_empty(struct ionic_queue *q) - q->tail_idx = 0; - } - --static void ionic_dim_update(struct ionic_qcq *qcq) -+static void ionic_dim_update(struct ionic_qcq *qcq, int napi_mode) - { - struct dim_sample dim_sample; - struct ionic_lif *lif; - unsigned int qi; -+ u64 pkts, bytes; - - if (!qcq->intr.dim_coal_hw) - return; -@@ -463,14 +463,23 @@ static void ionic_dim_update(struct ionic_qcq *qcq) - lif = qcq->q.lif; - qi = qcq->cq.bound_q->index; - -- ionic_intr_coal_init(lif->ionic->idev.intr_ctrl, -- lif->rxqcqs[qi]->intr.index, -- qcq->intr.dim_coal_hw); -+ switch (napi_mode) { -+ case IONIC_LIF_F_TX_DIM_INTR: -+ pkts = lif->txqstats[qi].pkts; -+ bytes = lif->txqstats[qi].bytes; -+ break; -+ case IONIC_LIF_F_RX_DIM_INTR: -+ pkts = lif->rxqstats[qi].pkts; -+ bytes = lif->rxqstats[qi].bytes; -+ break; -+ default: -+ pkts = lif->txqstats[qi].pkts + lif->rxqstats[qi].pkts; -+ bytes = lif->txqstats[qi].bytes + lif->rxqstats[qi].bytes; -+ break; -+ } - - dim_update_sample(qcq->cq.bound_intr->rearm_count, -- lif->txqstats[qi].pkts, -- lif->txqstats[qi].bytes, -- &dim_sample); -+ pkts, bytes, &dim_sample); - - net_dim(&qcq->dim, dim_sample); - } -@@ -491,7 +500,7 @@ int ionic_tx_napi(struct napi_struct *napi, int budget) - ionic_tx_service, NULL, NULL); - - if (work_done < budget && napi_complete_done(napi, work_done)) { -- ionic_dim_update(qcq); -+ ionic_dim_update(qcq, IONIC_LIF_F_TX_DIM_INTR); - flags |= IONIC_INTR_CRED_UNMASK; - cq->bound_intr->rearm_count++; - } -@@ -530,7 +539,7 @@ int ionic_rx_napi(struct napi_struct *napi, int budget) - ionic_rx_fill(cq->bound_q); - - if (work_done < budget && napi_complete_done(napi, work_done)) { -- ionic_dim_update(qcq); -+ ionic_dim_update(qcq, IONIC_LIF_F_RX_DIM_INTR); - flags |= IONIC_INTR_CRED_UNMASK; - cq->bound_intr->rearm_count++; - } -@@ -576,7 +585,7 @@ int ionic_txrx_napi(struct napi_struct *napi, int budget) - ionic_rx_fill(rxcq->bound_q); - - if (rx_work_done < budget && napi_complete_done(napi, rx_work_done)) { -- ionic_dim_update(qcq); -+ ionic_dim_update(qcq, 0); - flags |= IONIC_INTR_CRED_UNMASK; - rxcq->bound_intr->rearm_count++; - } -diff --git a/drivers/net/ethernet/sis/sis900.c b/drivers/net/ethernet/sis/sis900.c -index 620c26f71be89..e267b7ce3a45e 100644 ---- a/drivers/net/ethernet/sis/sis900.c -+++ b/drivers/net/ethernet/sis/sis900.c -@@ -443,7 +443,7 @@ static int sis900_probe(struct pci_dev *pci_dev, - #endif - - /* setup various bits in PCI command register */ -- ret = pci_enable_device(pci_dev); -+ ret = pcim_enable_device(pci_dev); - if(ret) return ret; - - i = dma_set_mask(&pci_dev->dev, DMA_BIT_MASK(32)); -@@ -469,7 +469,7 @@ static int sis900_probe(struct pci_dev *pci_dev, - ioaddr = pci_iomap(pci_dev, 0, 0); - if (!ioaddr) { - ret = -ENOMEM; -- goto err_out_cleardev; -+ goto err_out; - } - - sis_priv = netdev_priv(net_dev); -@@ -581,8 +581,6 @@ err_unmap_tx: - sis_priv->tx_ring_dma); - err_out_unmap: - pci_iounmap(pci_dev, ioaddr); --err_out_cleardev: -- pci_release_regions(pci_dev); - err_out: - free_netdev(net_dev); - return ret; -@@ -2499,7 +2497,6 @@ static void sis900_remove(struct pci_dev *pci_dev) - sis_priv->tx_ring_dma); - pci_iounmap(pci_dev, sis_priv->ioaddr); - free_netdev(net_dev); -- pci_release_regions(pci_dev); - } - - static int __maybe_unused sis900_suspend(struct device *dev) -diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c -index f35c03c9f91e3..2b03d970ca67a 100644 ---- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c -+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c -@@ -1249,6 +1249,7 @@ const struct stmmac_ops dwmac410_ops = { - .config_l3_filter = dwmac4_config_l3_filter, - .config_l4_filter = dwmac4_config_l4_filter, - .est_configure = dwmac5_est_configure, -+ .est_irq_status = dwmac5_est_irq_status, - .fpe_configure = dwmac5_fpe_configure, - .fpe_send_mpacket = dwmac5_fpe_send_mpacket, - .fpe_irq_status = dwmac5_fpe_irq_status, -@@ -1300,6 +1301,7 @@ const struct stmmac_ops dwmac510_ops = { - .config_l3_filter = dwmac4_config_l3_filter, - .config_l4_filter = dwmac4_config_l4_filter, - .est_configure = dwmac5_est_configure, -+ .est_irq_status = dwmac5_est_irq_status, - .fpe_configure = dwmac5_fpe_configure, - .fpe_send_mpacket = dwmac5_fpe_send_mpacket, - .fpe_irq_status = dwmac5_fpe_irq_status, -diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c -index 74e748662ec01..860644d182ab0 100644 ---- a/drivers/net/ethernet/sun/niu.c -+++ b/drivers/net/ethernet/sun/niu.c -@@ -8191,8 +8191,9 @@ static int niu_pci_vpd_fetch(struct niu *np, u32 start) - err = niu_pci_vpd_scan_props(np, here, end); - if (err < 0) - return err; -+ /* ret == 1 is not an error */ - if (err == 1) -- return -EINVAL; -+ return 0; - } - return 0; - } -diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c -index 7bf3011b8e777..83aea5c5cd03c 100644 ---- a/drivers/net/phy/broadcom.c -+++ b/drivers/net/phy/broadcom.c -@@ -288,7 +288,7 @@ static void bcm54xx_adjust_rxrefclk(struct phy_device *phydev) - if (phydev->dev_flags & PHY_BRCM_DIS_TXCRXC_NOENRGY) { - if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54210E || - BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54810 || -- BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54210E) -+ BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54811) - val |= BCM54XX_SHD_SCR3_RXCTXC_DIS; - else - val |= BCM54XX_SHD_SCR3_TRDDAPD; -diff --git a/drivers/nfc/nfcsim.c b/drivers/nfc/nfcsim.c -index a9864fcdfba6b..dd27c85190d34 100644 ---- a/drivers/nfc/nfcsim.c -+++ b/drivers/nfc/nfcsim.c -@@ -192,8 +192,7 @@ static void nfcsim_recv_wq(struct work_struct *work) - - if (!IS_ERR(skb)) - dev_kfree_skb(skb); -- -- skb = ERR_PTR(-ENODEV); -+ return; - } - - dev->cb(dev->nfc_digital_dev, dev->arg, skb); -diff --git a/drivers/platform/x86/amd-pmc.c b/drivers/platform/x86/amd-pmc.c -index b9da58ee9b1e3..ca95c2a52e260 100644 ---- a/drivers/platform/x86/amd-pmc.c -+++ b/drivers/platform/x86/amd-pmc.c -@@ -52,7 +52,6 @@ - #define AMD_CPU_ID_PCO AMD_CPU_ID_RV - #define AMD_CPU_ID_CZN AMD_CPU_ID_RN - --#define AMD_SMU_FW_VERSION 0x0 - #define PMC_MSG_DELAY_MIN_US 100 - #define RESPONSE_REGISTER_LOOP_MAX 200 - -@@ -68,6 +67,7 @@ struct amd_pmc_dev { - u32 base_addr; - u32 cpu_id; - struct device *dev; -+ struct mutex lock; /* generic mutex lock */ - #if IS_ENABLED(CONFIG_DEBUG_FS) - struct dentry *dbgfs_dir; - #endif /* CONFIG_DEBUG_FS */ -@@ -88,11 +88,6 @@ static inline void amd_pmc_reg_write(struct amd_pmc_dev *dev, int reg_offset, u3 - #ifdef CONFIG_DEBUG_FS - static int smu_fw_info_show(struct seq_file *s, void *unused) - { -- struct amd_pmc_dev *dev = s->private; -- u32 value; -- -- value = ioread32(dev->smu_base + AMD_SMU_FW_VERSION); -- seq_printf(s, "SMU FW Info: %x\n", value); - return 0; - } - DEFINE_SHOW_ATTRIBUTE(smu_fw_info); -@@ -138,13 +133,14 @@ static int amd_pmc_send_cmd(struct amd_pmc_dev *dev, bool set) - u8 msg; - u32 val; - -+ mutex_lock(&dev->lock); - /* Wait until we get a valid response */ - rc = readx_poll_timeout(ioread32, dev->regbase + AMD_PMC_REGISTER_RESPONSE, -- val, val > 0, PMC_MSG_DELAY_MIN_US, -+ val, val != 0, PMC_MSG_DELAY_MIN_US, - PMC_MSG_DELAY_MIN_US * RESPONSE_REGISTER_LOOP_MAX); - if (rc) { - dev_err(dev->dev, "failed to talk to SMU\n"); -- return rc; -+ goto out_unlock; - } - - /* Write zero to response register */ -@@ -156,7 +152,37 @@ static int amd_pmc_send_cmd(struct amd_pmc_dev *dev, bool set) - /* Write message ID to message ID register */ - msg = (dev->cpu_id == AMD_CPU_ID_RN) ? MSG_OS_HINT_RN : MSG_OS_HINT_PCO; - amd_pmc_reg_write(dev, AMD_PMC_REGISTER_MESSAGE, msg); -- return 0; -+ /* Wait until we get a valid response */ -+ rc = readx_poll_timeout(ioread32, dev->regbase + AMD_PMC_REGISTER_RESPONSE, -+ val, val != 0, PMC_MSG_DELAY_MIN_US, -+ PMC_MSG_DELAY_MIN_US * RESPONSE_REGISTER_LOOP_MAX); -+ if (rc) { -+ dev_err(dev->dev, "SMU response timed out\n"); -+ goto out_unlock; -+ } -+ -+ switch (val) { -+ case AMD_PMC_RESULT_OK: -+ break; -+ case AMD_PMC_RESULT_CMD_REJECT_BUSY: -+ dev_err(dev->dev, "SMU not ready. err: 0x%x\n", val); -+ rc = -EBUSY; -+ goto out_unlock; -+ case AMD_PMC_RESULT_CMD_UNKNOWN: -+ dev_err(dev->dev, "SMU cmd unknown. err: 0x%x\n", val); -+ rc = -EINVAL; -+ goto out_unlock; -+ case AMD_PMC_RESULT_CMD_REJECT_PREREQ: -+ case AMD_PMC_RESULT_FAILED: -+ default: -+ dev_err(dev->dev, "SMU cmd failed. err: 0x%x\n", val); -+ rc = -EIO; -+ goto out_unlock; -+ } -+ -+out_unlock: -+ mutex_unlock(&dev->lock); -+ return rc; - } - - static int __maybe_unused amd_pmc_suspend(struct device *dev) -@@ -248,10 +274,6 @@ static int amd_pmc_probe(struct platform_device *pdev) - pci_dev_put(rdev); - base_addr = ((u64)base_addr_hi << 32 | base_addr_lo); - -- dev->smu_base = devm_ioremap(dev->dev, base_addr, AMD_PMC_MAPPING_SIZE); -- if (!dev->smu_base) -- return -ENOMEM; -- - dev->regbase = devm_ioremap(dev->dev, base_addr + AMD_PMC_BASE_ADDR_OFFSET, - AMD_PMC_MAPPING_SIZE); - if (!dev->regbase) -@@ -259,6 +281,7 @@ static int amd_pmc_probe(struct platform_device *pdev) - - amd_pmc_dump_registers(dev); - -+ mutex_init(&dev->lock); - platform_set_drvdata(pdev, dev); - amd_pmc_dbgfs_register(dev); - return 0; -@@ -269,6 +292,7 @@ static int amd_pmc_remove(struct platform_device *pdev) - struct amd_pmc_dev *dev = platform_get_drvdata(pdev); - - amd_pmc_dbgfs_unregister(dev); -+ mutex_destroy(&dev->lock); - return 0; - } - -diff --git a/fs/block_dev.c b/fs/block_dev.c -index 6cc4d4cfe0c28..e4a80bd4ddf1f 100644 ---- a/fs/block_dev.c -+++ b/fs/block_dev.c -@@ -812,6 +812,8 @@ static void bdev_free_inode(struct inode *inode) - free_percpu(bdev->bd_stats); - kfree(bdev->bd_meta_info); - -+ if (!bdev_is_partition(bdev)) -+ kfree(bdev->bd_disk); - kmem_cache_free(bdev_cachep, BDEV_I(inode)); - } - -diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c -index 1346d698463a6..f69b8d3325743 100644 ---- a/fs/btrfs/compression.c -+++ b/fs/btrfs/compression.c -@@ -353,7 +353,7 @@ static void end_compressed_bio_write(struct bio *bio) - btrfs_record_physical_zoned(inode, cb->start, bio); - btrfs_writepage_endio_finish_ordered(cb->compressed_pages[0], - cb->start, cb->start + cb->len - 1, -- bio->bi_status == BLK_STS_OK); -+ !cb->errors); - cb->compressed_pages[0]->mapping = NULL; - - end_compressed_writeback(inode, cb); -diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c -index f08375cb871ed..24555cc1f42d5 100644 ---- a/fs/btrfs/tree-log.c -+++ b/fs/btrfs/tree-log.c -@@ -6492,8 +6492,8 @@ void btrfs_log_new_name(struct btrfs_trans_handle *trans, - * if this inode hasn't been logged and directory we're renaming it - * from hasn't been logged, we don't need to log it - */ -- if (inode->logged_trans < trans->transid && -- (!old_dir || old_dir->logged_trans < trans->transid)) -+ if (!inode_logged(trans, inode) && -+ (!old_dir || !inode_logged(trans, old_dir))) - return; - - /* -diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c -index 38633ab8108bb..9f723b744863f 100644 ---- a/fs/btrfs/volumes.c -+++ b/fs/btrfs/volumes.c -@@ -1078,6 +1078,7 @@ static void __btrfs_free_extra_devids(struct btrfs_fs_devices *fs_devices, - if (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state)) { - list_del_init(&device->dev_alloc_list); - clear_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state); -+ fs_devices->rw_devices--; - } - list_del_init(&device->dev_list); - fs_devices->num_devices--; -diff --git a/fs/cifs/file.c b/fs/cifs/file.c -index 379a427f3c2f1..ae4ce762f4fb4 100644 ---- a/fs/cifs/file.c -+++ b/fs/cifs/file.c -@@ -4631,7 +4631,7 @@ read_complete: - - static int cifs_readpage(struct file *file, struct page *page) - { -- loff_t offset = (loff_t)page->index << PAGE_SHIFT; -+ loff_t offset = page_file_offset(page); - int rc = -EACCES; - unsigned int xid; - -diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c -index 14292dba3a12d..2c2f179b69779 100644 ---- a/fs/ext2/dir.c -+++ b/fs/ext2/dir.c -@@ -106,12 +106,11 @@ static int ext2_commit_chunk(struct page *page, loff_t pos, unsigned len) - return err; - } - --static bool ext2_check_page(struct page *page, int quiet) -+static bool ext2_check_page(struct page *page, int quiet, char *kaddr) - { - struct inode *dir = page->mapping->host; - struct super_block *sb = dir->i_sb; - unsigned chunk_size = ext2_chunk_size(dir); -- char *kaddr = page_address(page); - u32 max_inumber = le32_to_cpu(EXT2_SB(sb)->s_es->s_inodes_count); - unsigned offs, rec_len; - unsigned limit = PAGE_SIZE; -@@ -205,7 +204,8 @@ static struct page * ext2_get_page(struct inode *dir, unsigned long n, - if (!IS_ERR(page)) { - *page_addr = kmap_local_page(page); - if (unlikely(!PageChecked(page))) { -- if (PageError(page) || !ext2_check_page(page, quiet)) -+ if (PageError(page) || !ext2_check_page(page, quiet, -+ *page_addr)) - goto fail; - } - } -@@ -584,10 +584,10 @@ out_unlock: - * ext2_delete_entry deletes a directory entry by merging it with the - * previous entry. Page is up-to-date. - */ --int ext2_delete_entry (struct ext2_dir_entry_2 * dir, struct page * page ) -+int ext2_delete_entry (struct ext2_dir_entry_2 *dir, struct page *page, -+ char *kaddr) - { - struct inode *inode = page->mapping->host; -- char *kaddr = page_address(page); - unsigned from = ((char*)dir - kaddr) & ~(ext2_chunk_size(inode)-1); - unsigned to = ((char *)dir - kaddr) + - ext2_rec_len_from_disk(dir->rec_len); -@@ -607,7 +607,7 @@ int ext2_delete_entry (struct ext2_dir_entry_2 * dir, struct page * page ) - de = ext2_next_entry(de); - } - if (pde) -- from = (char*)pde - (char*)page_address(page); -+ from = (char *)pde - kaddr; - pos = page_offset(page) + from; - lock_page(page); - err = ext2_prepare_chunk(page, pos, to - from); -diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h -index b0a694820cb7f..e512630cb63ed 100644 ---- a/fs/ext2/ext2.h -+++ b/fs/ext2/ext2.h -@@ -740,7 +740,8 @@ extern int ext2_inode_by_name(struct inode *dir, - extern int ext2_make_empty(struct inode *, struct inode *); - extern struct ext2_dir_entry_2 *ext2_find_entry(struct inode *, const struct qstr *, - struct page **, void **res_page_addr); --extern int ext2_delete_entry (struct ext2_dir_entry_2 *, struct page *); -+extern int ext2_delete_entry(struct ext2_dir_entry_2 *dir, struct page *page, -+ char *kaddr); - extern int ext2_empty_dir (struct inode *); - extern struct ext2_dir_entry_2 *ext2_dotdot(struct inode *dir, struct page **p, void **pa); - extern void ext2_set_link(struct inode *, struct ext2_dir_entry_2 *, struct page *, void *, -diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c -index 1f69b81655b66..5f6b7560eb3f3 100644 ---- a/fs/ext2/namei.c -+++ b/fs/ext2/namei.c -@@ -293,7 +293,7 @@ static int ext2_unlink(struct inode * dir, struct dentry *dentry) - goto out; - } - -- err = ext2_delete_entry (de, page); -+ err = ext2_delete_entry (de, page, page_addr); - ext2_put_page(page, page_addr); - if (err) - goto out; -@@ -397,7 +397,7 @@ static int ext2_rename (struct user_namespace * mnt_userns, - old_inode->i_ctime = current_time(old_inode); - mark_inode_dirty(old_inode); - -- ext2_delete_entry(old_de, old_page); -+ ext2_delete_entry(old_de, old_page, old_page_addr); - - if (dir_de) { - if (old_dir != new_dir) -diff --git a/fs/io_uring.c b/fs/io_uring.c -index df4288776815e..d465e99971574 100644 ---- a/fs/io_uring.c -+++ b/fs/io_uring.c -@@ -1258,8 +1258,17 @@ static void io_prep_async_link(struct io_kiocb *req) - { - struct io_kiocb *cur; - -- io_for_each_link(cur, req) -- io_prep_async_work(cur); -+ if (req->flags & REQ_F_LINK_TIMEOUT) { -+ struct io_ring_ctx *ctx = req->ctx; -+ -+ spin_lock_irq(&ctx->completion_lock); -+ io_for_each_link(cur, req) -+ io_prep_async_work(cur); -+ spin_unlock_irq(&ctx->completion_lock); -+ } else { -+ io_for_each_link(cur, req) -+ io_prep_async_work(cur); -+ } - } - - static void io_queue_async_work(struct io_kiocb *req) -@@ -1890,7 +1899,7 @@ static void tctx_task_work(struct callback_head *cb) - - clear_bit(0, &tctx->task_state); - -- while (!wq_list_empty(&tctx->task_list)) { -+ while (true) { - struct io_ring_ctx *ctx = NULL; - struct io_wq_work_list list; - struct io_wq_work_node *node; -@@ -1900,6 +1909,9 @@ static void tctx_task_work(struct callback_head *cb) - INIT_WQ_LIST(&tctx->task_list); - spin_unlock_irq(&tctx->task_lock); - -+ if (wq_list_empty(&list)) -+ break; -+ - node = list.first; - while (node) { - struct io_wq_work_node *next = node->next; -@@ -2448,6 +2460,12 @@ static bool io_rw_should_reissue(struct io_kiocb *req) - */ - if (percpu_ref_is_dying(&ctx->refs)) - return false; -+ /* -+ * Play it safe and assume not safe to re-import and reissue if we're -+ * not in the original thread group (or in task context). -+ */ -+ if (!same_thread_group(req->task, current) || !in_task()) -+ return false; - return true; - } - #else -@@ -4909,7 +4927,6 @@ static bool io_poll_complete(struct io_kiocb *req, __poll_t mask) - if (req->poll.events & EPOLLONESHOT) - flags = 0; - if (!io_cqring_fill_event(ctx, req->user_data, error, flags)) { -- io_poll_remove_waitqs(req); - req->poll.done = true; - flags = 0; - } -@@ -4933,6 +4950,7 @@ static void io_poll_task_func(struct callback_head *cb) - - done = io_poll_complete(req, req->result); - if (done) { -+ io_poll_remove_double(req); - hash_del(&req->hash_node); - } else { - req->result = 0; -@@ -5121,7 +5139,7 @@ static __poll_t __io_arm_poll_handler(struct io_kiocb *req, - ipt->error = -EINVAL; - - spin_lock_irq(&ctx->completion_lock); -- if (ipt->error) -+ if (ipt->error || (mask && (poll->events & EPOLLONESHOT))) - io_poll_remove_double(req); - if (likely(poll->head)) { - spin_lock(&poll->head->lock); -@@ -5192,7 +5210,6 @@ static bool io_arm_poll_handler(struct io_kiocb *req) - ret = __io_arm_poll_handler(req, &apoll->poll, &ipt, mask, - io_async_wake); - if (ret || ipt.error) { -- io_poll_remove_double(req); - spin_unlock_irq(&ctx->completion_lock); - return false; - } -diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c -index 7756579430578..54d7843c02114 100644 ---- a/fs/ocfs2/file.c -+++ b/fs/ocfs2/file.c -@@ -1529,6 +1529,45 @@ static void ocfs2_truncate_cluster_pages(struct inode *inode, u64 byte_start, - } - } - -+/* -+ * zero out partial blocks of one cluster. -+ * -+ * start: file offset where zero starts, will be made upper block aligned. -+ * len: it will be trimmed to the end of current cluster if "start + len" -+ * is bigger than it. -+ */ -+static int ocfs2_zeroout_partial_cluster(struct inode *inode, -+ u64 start, u64 len) -+{ -+ int ret; -+ u64 start_block, end_block, nr_blocks; -+ u64 p_block, offset; -+ u32 cluster, p_cluster, nr_clusters; -+ struct super_block *sb = inode->i_sb; -+ u64 end = ocfs2_align_bytes_to_clusters(sb, start); -+ -+ if (start + len < end) -+ end = start + len; -+ -+ start_block = ocfs2_blocks_for_bytes(sb, start); -+ end_block = ocfs2_blocks_for_bytes(sb, end); -+ nr_blocks = end_block - start_block; -+ if (!nr_blocks) -+ return 0; -+ -+ cluster = ocfs2_bytes_to_clusters(sb, start); -+ ret = ocfs2_get_clusters(inode, cluster, &p_cluster, -+ &nr_clusters, NULL); -+ if (ret) -+ return ret; -+ if (!p_cluster) -+ return 0; -+ -+ offset = start_block - ocfs2_clusters_to_blocks(sb, cluster); -+ p_block = ocfs2_clusters_to_blocks(sb, p_cluster) + offset; -+ return sb_issue_zeroout(sb, p_block, nr_blocks, GFP_NOFS); -+} -+ - static int ocfs2_zero_partial_clusters(struct inode *inode, - u64 start, u64 len) - { -@@ -1538,6 +1577,7 @@ static int ocfs2_zero_partial_clusters(struct inode *inode, - struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); - unsigned int csize = osb->s_clustersize; - handle_t *handle; -+ loff_t isize = i_size_read(inode); - - /* - * The "start" and "end" values are NOT necessarily part of -@@ -1558,6 +1598,26 @@ static int ocfs2_zero_partial_clusters(struct inode *inode, - if ((start & (csize - 1)) == 0 && (end & (csize - 1)) == 0) - goto out; - -+ /* No page cache for EOF blocks, issue zero out to disk. */ -+ if (end > isize) { -+ /* -+ * zeroout eof blocks in last cluster starting from -+ * "isize" even "start" > "isize" because it is -+ * complicated to zeroout just at "start" as "start" -+ * may be not aligned with block size, buffer write -+ * would be required to do that, but out of eof buffer -+ * write is not supported. -+ */ -+ ret = ocfs2_zeroout_partial_cluster(inode, isize, -+ end - isize); -+ if (ret) { -+ mlog_errno(ret); -+ goto out; -+ } -+ if (start >= isize) -+ goto out; -+ end = isize; -+ } - handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); - if (IS_ERR(handle)) { - ret = PTR_ERR(handle); -@@ -1855,45 +1915,6 @@ out: - return ret; - } - --/* -- * zero out partial blocks of one cluster. -- * -- * start: file offset where zero starts, will be made upper block aligned. -- * len: it will be trimmed to the end of current cluster if "start + len" -- * is bigger than it. -- */ --static int ocfs2_zeroout_partial_cluster(struct inode *inode, -- u64 start, u64 len) --{ -- int ret; -- u64 start_block, end_block, nr_blocks; -- u64 p_block, offset; -- u32 cluster, p_cluster, nr_clusters; -- struct super_block *sb = inode->i_sb; -- u64 end = ocfs2_align_bytes_to_clusters(sb, start); -- -- if (start + len < end) -- end = start + len; -- -- start_block = ocfs2_blocks_for_bytes(sb, start); -- end_block = ocfs2_blocks_for_bytes(sb, end); -- nr_blocks = end_block - start_block; -- if (!nr_blocks) -- return 0; -- -- cluster = ocfs2_bytes_to_clusters(sb, start); -- ret = ocfs2_get_clusters(inode, cluster, &p_cluster, -- &nr_clusters, NULL); -- if (ret) -- return ret; -- if (!p_cluster) -- return 0; -- -- offset = start_block - ocfs2_clusters_to_blocks(sb, cluster); -- p_block = ocfs2_clusters_to_blocks(sb, p_cluster) + offset; -- return sb_issue_zeroout(sb, p_block, nr_blocks, GFP_NOFS); --} -- - /* - * Parts of this function taken from xfs_change_file_space() - */ -@@ -1935,7 +1956,6 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode, - goto out_inode_unlock; - } - -- orig_isize = i_size_read(inode); - switch (sr->l_whence) { - case 0: /*SEEK_SET*/ - break; -@@ -1943,7 +1963,7 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode, - sr->l_start += f_pos; - break; - case 2: /*SEEK_END*/ -- sr->l_start += orig_isize; -+ sr->l_start += i_size_read(inode); - break; - default: - ret = -EINVAL; -@@ -1998,6 +2018,7 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode, - ret = -EINVAL; - } - -+ orig_isize = i_size_read(inode); - /* zeroout eof blocks in the cluster. */ - if (!ret && change_size && orig_isize < size) { - ret = ocfs2_zeroout_partial_cluster(inode, orig_isize, -diff --git a/fs/pipe.c b/fs/pipe.c -index bfd946a9ad01f..9ef4231cce61c 100644 ---- a/fs/pipe.c -+++ b/fs/pipe.c -@@ -429,20 +429,20 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from) - #endif - - /* -- * Only wake up if the pipe started out empty, since -- * otherwise there should be no readers waiting. -+ * Epoll nonsensically wants a wakeup whether the pipe -+ * was already empty or not. - * - * If it wasn't empty we try to merge new data into - * the last buffer. - * - * That naturally merges small writes, but it also -- * page-aligs the rest of the writes for large writes -+ * page-aligns the rest of the writes for large writes - * spanning multiple pages. - */ - head = pipe->head; -- was_empty = pipe_empty(head, pipe->tail); -+ was_empty = true; - chars = total_len & (PAGE_SIZE-1); -- if (chars && !was_empty) { -+ if (chars && !pipe_empty(head, pipe->tail)) { - unsigned int mask = pipe->ring_size - 1; - struct pipe_buffer *buf = &pipe->bufs[(head - 1) & mask]; - int offset = buf->offset + buf->len; -diff --git a/include/linux/bpf_types.h b/include/linux/bpf_types.h -index f883f01a5061f..def596a85752d 100644 ---- a/include/linux/bpf_types.h -+++ b/include/linux/bpf_types.h -@@ -132,4 +132,5 @@ BPF_LINK_TYPE(BPF_LINK_TYPE_CGROUP, cgroup) - BPF_LINK_TYPE(BPF_LINK_TYPE_ITER, iter) - #ifdef CONFIG_NET - BPF_LINK_TYPE(BPF_LINK_TYPE_NETNS, netns) -+BPF_LINK_TYPE(BPF_LINK_TYPE_XDP, xdp) - #endif -diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h -index 06841517ab1ed..6b6b201b75bf9 100644 ---- a/include/linux/bpf_verifier.h -+++ b/include/linux/bpf_verifier.h -@@ -215,6 +215,13 @@ struct bpf_idx_pair { - u32 idx; - }; - -+struct bpf_id_pair { -+ u32 old; -+ u32 cur; -+}; -+ -+/* Maximum number of register states that can exist at once */ -+#define BPF_ID_MAP_SIZE (MAX_BPF_REG + MAX_BPF_STACK / BPF_REG_SIZE) - #define MAX_CALL_FRAMES 8 - struct bpf_verifier_state { - /* call stack tracking */ -@@ -333,8 +340,8 @@ struct bpf_insn_aux_data { - }; - u64 map_key_state; /* constant (32 bit) key tracking for maps */ - int ctx_field_size; /* the ctx field size for load insn, maybe 0 */ -- int sanitize_stack_off; /* stack slot to be cleared */ - u32 seen; /* this insn was processed by the verifier at env->pass_cnt */ -+ bool sanitize_stack_spill; /* subject to Spectre v4 sanitation */ - bool zext_dst; /* this insn zero extends dst reg */ - u8 alu_state; /* used in combination with alu_limit */ - -@@ -407,6 +414,7 @@ struct bpf_verifier_env { - u32 used_map_cnt; /* number of used maps */ - u32 used_btf_cnt; /* number of used BTF objects */ - u32 id_gen; /* used to generate unique reg IDs */ -+ bool explore_alu_limits; - bool allow_ptr_leaks; - bool allow_uninit_stack; - bool allow_ptr_to_map_access; -@@ -418,6 +426,7 @@ struct bpf_verifier_env { - const struct bpf_line_info *prev_linfo; - struct bpf_verifier_log log; - struct bpf_subprog_info subprog_info[BPF_MAX_SUBPROGS + 1]; -+ struct bpf_id_pair idmap_scratch[BPF_ID_MAP_SIZE]; - struct { - int *insn_state; - int *insn_stack; -diff --git a/include/linux/filter.h b/include/linux/filter.h -index 9a09547bc7bae..16e5cebea82ca 100644 ---- a/include/linux/filter.h -+++ b/include/linux/filter.h -@@ -73,6 +73,11 @@ struct ctl_table_header; - /* unused opcode to mark call to interpreter with arguments */ - #define BPF_CALL_ARGS 0xe0 - -+/* unused opcode to mark speculation barrier for mitigating -+ * Speculative Store Bypass -+ */ -+#define BPF_NOSPEC 0xc0 -+ - /* As per nm, we expose JITed images as text (code) section for - * kallsyms. That way, tools like perf can find it to match - * addresses. -@@ -390,6 +395,16 @@ static inline bool insn_is_zext(const struct bpf_insn *insn) - .off = 0, \ - .imm = 0 }) - -+/* Speculation barrier */ -+ -+#define BPF_ST_NOSPEC() \ -+ ((struct bpf_insn) { \ -+ .code = BPF_ST | BPF_NOSPEC, \ -+ .dst_reg = 0, \ -+ .src_reg = 0, \ -+ .off = 0, \ -+ .imm = 0 }) -+ - /* Internal classic blocks for direct assignment */ - - #define __BPF_STMT(CODE, K) \ -diff --git a/include/net/llc_pdu.h b/include/net/llc_pdu.h -index c0f0a13ed8183..49aa79c7b278a 100644 ---- a/include/net/llc_pdu.h -+++ b/include/net/llc_pdu.h -@@ -15,9 +15,11 @@ - #include - - /* Lengths of frame formats */ --#define LLC_PDU_LEN_I 4 /* header and 2 control bytes */ --#define LLC_PDU_LEN_S 4 --#define LLC_PDU_LEN_U 3 /* header and 1 control byte */ -+#define LLC_PDU_LEN_I 4 /* header and 2 control bytes */ -+#define LLC_PDU_LEN_S 4 -+#define LLC_PDU_LEN_U 3 /* header and 1 control byte */ -+/* header and 1 control byte and XID info */ -+#define LLC_PDU_LEN_U_XID (LLC_PDU_LEN_U + sizeof(struct llc_xid_info)) - /* Known SAP addresses */ - #define LLC_GLOBAL_SAP 0xFF - #define LLC_NULL_SAP 0x00 /* not network-layer visible */ -@@ -50,9 +52,10 @@ - #define LLC_PDU_TYPE_U_MASK 0x03 /* 8-bit control field */ - #define LLC_PDU_TYPE_MASK 0x03 - --#define LLC_PDU_TYPE_I 0 /* first bit */ --#define LLC_PDU_TYPE_S 1 /* first two bits */ --#define LLC_PDU_TYPE_U 3 /* first two bits */ -+#define LLC_PDU_TYPE_I 0 /* first bit */ -+#define LLC_PDU_TYPE_S 1 /* first two bits */ -+#define LLC_PDU_TYPE_U 3 /* first two bits */ -+#define LLC_PDU_TYPE_U_XID 4 /* private type for detecting XID commands */ - - #define LLC_PDU_TYPE_IS_I(pdu) \ - ((!(pdu->ctrl_1 & LLC_PDU_TYPE_I_MASK)) ? 1 : 0) -@@ -230,9 +233,18 @@ static inline struct llc_pdu_un *llc_pdu_un_hdr(struct sk_buff *skb) - static inline void llc_pdu_header_init(struct sk_buff *skb, u8 type, - u8 ssap, u8 dsap, u8 cr) - { -- const int hlen = type == LLC_PDU_TYPE_U ? 3 : 4; -+ int hlen = 4; /* default value for I and S types */ - struct llc_pdu_un *pdu; - -+ switch (type) { -+ case LLC_PDU_TYPE_U: -+ hlen = 3; -+ break; -+ case LLC_PDU_TYPE_U_XID: -+ hlen = 6; -+ break; -+ } -+ - skb_push(skb, hlen); - skb_reset_network_header(skb); - pdu = llc_pdu_un_hdr(skb); -@@ -374,7 +386,10 @@ static inline void llc_pdu_init_as_xid_cmd(struct sk_buff *skb, - xid_info->fmt_id = LLC_XID_FMT_ID; /* 0x81 */ - xid_info->type = svcs_supported; - xid_info->rw = rx_window << 1; /* size of receive window */ -- skb_put(skb, sizeof(struct llc_xid_info)); -+ -+ /* no need to push/put since llc_pdu_header_init() has already -+ * pushed 3 + 3 bytes -+ */ - } - - /** -diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c -index 9b15774983738..b1a5fc04492bd 100644 ---- a/kernel/bpf/core.c -+++ b/kernel/bpf/core.c -@@ -32,6 +32,8 @@ - #include - #include - #include -+ -+#include - #include - - /* Registers */ -@@ -1377,6 +1379,7 @@ static u64 ___bpf_prog_run(u64 *regs, const struct bpf_insn *insn) - /* Non-UAPI available opcodes. */ - [BPF_JMP | BPF_CALL_ARGS] = &&JMP_CALL_ARGS, - [BPF_JMP | BPF_TAIL_CALL] = &&JMP_TAIL_CALL, -+ [BPF_ST | BPF_NOSPEC] = &&ST_NOSPEC, - [BPF_LDX | BPF_PROBE_MEM | BPF_B] = &&LDX_PROBE_MEM_B, - [BPF_LDX | BPF_PROBE_MEM | BPF_H] = &&LDX_PROBE_MEM_H, - [BPF_LDX | BPF_PROBE_MEM | BPF_W] = &&LDX_PROBE_MEM_W, -@@ -1621,7 +1624,21 @@ out: - COND_JMP(s, JSGE, >=) - COND_JMP(s, JSLE, <=) - #undef COND_JMP -- /* STX and ST and LDX*/ -+ /* ST, STX and LDX*/ -+ ST_NOSPEC: -+ /* Speculation barrier for mitigating Speculative Store Bypass. -+ * In case of arm64, we rely on the firmware mitigation as -+ * controlled via the ssbd kernel parameter. Whenever the -+ * mitigation is enabled, it works for all of the kernel code -+ * with no need to provide any additional instructions here. -+ * In case of x86, we use 'lfence' insn for mitigation. We -+ * reuse preexisting logic from Spectre v1 mitigation that -+ * happens to produce the required code on x86 for v4 as well. -+ */ -+#ifdef CONFIG_X86 -+ barrier_nospec(); -+#endif -+ CONT; - #define LDST(SIZEOP, SIZE) \ - STX_MEM_##SIZEOP: \ - *(SIZE *)(unsigned long) (DST + insn->off) = SRC; \ -diff --git a/kernel/bpf/disasm.c b/kernel/bpf/disasm.c -index bbfc6bb792400..ca3cd9aaa6ced 100644 ---- a/kernel/bpf/disasm.c -+++ b/kernel/bpf/disasm.c -@@ -206,15 +206,17 @@ void print_bpf_insn(const struct bpf_insn_cbs *cbs, - verbose(cbs->private_data, "BUG_%02x\n", insn->code); - } - } else if (class == BPF_ST) { -- if (BPF_MODE(insn->code) != BPF_MEM) { -+ if (BPF_MODE(insn->code) == BPF_MEM) { -+ verbose(cbs->private_data, "(%02x) *(%s *)(r%d %+d) = %d\n", -+ insn->code, -+ bpf_ldst_string[BPF_SIZE(insn->code) >> 3], -+ insn->dst_reg, -+ insn->off, insn->imm); -+ } else if (BPF_MODE(insn->code) == 0xc0 /* BPF_NOSPEC, no UAPI */) { -+ verbose(cbs->private_data, "(%02x) nospec\n", insn->code); -+ } else { - verbose(cbs->private_data, "BUG_st_%02x\n", insn->code); -- return; - } -- verbose(cbs->private_data, "(%02x) *(%s *)(r%d %+d) = %d\n", -- insn->code, -- bpf_ldst_string[BPF_SIZE(insn->code) >> 3], -- insn->dst_reg, -- insn->off, insn->imm); - } else if (class == BPF_LDX) { - if (BPF_MODE(insn->code) != BPF_MEM) { - verbose(cbs->private_data, "BUG_ldx_%02x\n", insn->code); -diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c -index e6db39a00de25..eab48745231fb 100644 ---- a/kernel/bpf/verifier.c -+++ b/kernel/bpf/verifier.c -@@ -2607,6 +2607,19 @@ static int check_stack_write_fixed_off(struct bpf_verifier_env *env, - cur = env->cur_state->frame[env->cur_state->curframe]; - if (value_regno >= 0) - reg = &cur->regs[value_regno]; -+ if (!env->bypass_spec_v4) { -+ bool sanitize = reg && is_spillable_regtype(reg->type); -+ -+ for (i = 0; i < size; i++) { -+ if (state->stack[spi].slot_type[i] == STACK_INVALID) { -+ sanitize = true; -+ break; -+ } -+ } -+ -+ if (sanitize) -+ env->insn_aux_data[insn_idx].sanitize_stack_spill = true; -+ } - - if (reg && size == BPF_REG_SIZE && register_is_bounded(reg) && - !register_is_null(reg) && env->bpf_capable) { -@@ -2629,47 +2642,10 @@ static int check_stack_write_fixed_off(struct bpf_verifier_env *env, - verbose(env, "invalid size of register spill\n"); - return -EACCES; - } -- - if (state != cur && reg->type == PTR_TO_STACK) { - verbose(env, "cannot spill pointers to stack into stack frame of the caller\n"); - return -EINVAL; - } -- -- if (!env->bypass_spec_v4) { -- bool sanitize = false; -- -- if (state->stack[spi].slot_type[0] == STACK_SPILL && -- register_is_const(&state->stack[spi].spilled_ptr)) -- sanitize = true; -- for (i = 0; i < BPF_REG_SIZE; i++) -- if (state->stack[spi].slot_type[i] == STACK_MISC) { -- sanitize = true; -- break; -- } -- if (sanitize) { -- int *poff = &env->insn_aux_data[insn_idx].sanitize_stack_off; -- int soff = (-spi - 1) * BPF_REG_SIZE; -- -- /* detected reuse of integer stack slot with a pointer -- * which means either llvm is reusing stack slot or -- * an attacker is trying to exploit CVE-2018-3639 -- * (speculative store bypass) -- * Have to sanitize that slot with preemptive -- * store of zero. -- */ -- if (*poff && *poff != soff) { -- /* disallow programs where single insn stores -- * into two different stack slots, since verifier -- * cannot sanitize them -- */ -- verbose(env, -- "insn %d cannot access two stack slots fp%d and fp%d", -- insn_idx, *poff, soff); -- return -EINVAL; -- } -- *poff = soff; -- } -- } - save_register_state(state, spi, reg); - } else { - u8 type = STACK_MISC; -@@ -6559,6 +6535,12 @@ static int sanitize_ptr_alu(struct bpf_verifier_env *env, - alu_state |= off_is_imm ? BPF_ALU_IMMEDIATE : 0; - alu_state |= ptr_is_dst_reg ? - BPF_ALU_SANITIZE_SRC : BPF_ALU_SANITIZE_DST; -+ -+ /* Limit pruning on unknown scalars to enable deep search for -+ * potential masking differences from other program paths. -+ */ -+ if (!off_is_imm) -+ env->explore_alu_limits = true; - } - - err = update_alu_sanitation_state(aux, alu_state, alu_limit); -@@ -9803,13 +9785,6 @@ static bool range_within(struct bpf_reg_state *old, - old->s32_max_value >= cur->s32_max_value; - } - --/* Maximum number of register states that can exist at once */ --#define ID_MAP_SIZE (MAX_BPF_REG + MAX_BPF_STACK / BPF_REG_SIZE) --struct idpair { -- u32 old; -- u32 cur; --}; -- - /* If in the old state two registers had the same id, then they need to have - * the same id in the new state as well. But that id could be different from - * the old state, so we need to track the mapping from old to new ids. -@@ -9820,11 +9795,11 @@ struct idpair { - * So we look through our idmap to see if this old id has been seen before. If - * so, we require the new id to match; otherwise, we add the id pair to the map. - */ --static bool check_ids(u32 old_id, u32 cur_id, struct idpair *idmap) -+static bool check_ids(u32 old_id, u32 cur_id, struct bpf_id_pair *idmap) - { - unsigned int i; - -- for (i = 0; i < ID_MAP_SIZE; i++) { -+ for (i = 0; i < BPF_ID_MAP_SIZE; i++) { - if (!idmap[i].old) { - /* Reached an empty slot; haven't seen this id before */ - idmap[i].old = old_id; -@@ -9936,8 +9911,8 @@ next: - } - - /* Returns true if (rold safe implies rcur safe) */ --static bool regsafe(struct bpf_reg_state *rold, struct bpf_reg_state *rcur, -- struct idpair *idmap) -+static bool regsafe(struct bpf_verifier_env *env, struct bpf_reg_state *rold, -+ struct bpf_reg_state *rcur, struct bpf_id_pair *idmap) - { - bool equal; - -@@ -9963,6 +9938,8 @@ static bool regsafe(struct bpf_reg_state *rold, struct bpf_reg_state *rcur, - return false; - switch (rold->type) { - case SCALAR_VALUE: -+ if (env->explore_alu_limits) -+ return false; - if (rcur->type == SCALAR_VALUE) { - if (!rold->precise && !rcur->precise) - return true; -@@ -10053,9 +10030,8 @@ static bool regsafe(struct bpf_reg_state *rold, struct bpf_reg_state *rcur, - return false; - } - --static bool stacksafe(struct bpf_func_state *old, -- struct bpf_func_state *cur, -- struct idpair *idmap) -+static bool stacksafe(struct bpf_verifier_env *env, struct bpf_func_state *old, -+ struct bpf_func_state *cur, struct bpf_id_pair *idmap) - { - int i, spi; - -@@ -10100,9 +10076,8 @@ static bool stacksafe(struct bpf_func_state *old, - continue; - if (old->stack[spi].slot_type[0] != STACK_SPILL) - continue; -- if (!regsafe(&old->stack[spi].spilled_ptr, -- &cur->stack[spi].spilled_ptr, -- idmap)) -+ if (!regsafe(env, &old->stack[spi].spilled_ptr, -+ &cur->stack[spi].spilled_ptr, idmap)) - /* when explored and current stack slot are both storing - * spilled registers, check that stored pointers types - * are the same as well. -@@ -10152,32 +10127,24 @@ static bool refsafe(struct bpf_func_state *old, struct bpf_func_state *cur) - * whereas register type in current state is meaningful, it means that - * the current state will reach 'bpf_exit' instruction safely - */ --static bool func_states_equal(struct bpf_func_state *old, -+static bool func_states_equal(struct bpf_verifier_env *env, struct bpf_func_state *old, - struct bpf_func_state *cur) - { -- struct idpair *idmap; -- bool ret = false; - int i; - -- idmap = kcalloc(ID_MAP_SIZE, sizeof(struct idpair), GFP_KERNEL); -- /* If we failed to allocate the idmap, just say it's not safe */ -- if (!idmap) -- return false; -- -- for (i = 0; i < MAX_BPF_REG; i++) { -- if (!regsafe(&old->regs[i], &cur->regs[i], idmap)) -- goto out_free; -- } -+ memset(env->idmap_scratch, 0, sizeof(env->idmap_scratch)); -+ for (i = 0; i < MAX_BPF_REG; i++) -+ if (!regsafe(env, &old->regs[i], &cur->regs[i], -+ env->idmap_scratch)) -+ return false; - -- if (!stacksafe(old, cur, idmap)) -- goto out_free; -+ if (!stacksafe(env, old, cur, env->idmap_scratch)) -+ return false; - - if (!refsafe(old, cur)) -- goto out_free; -- ret = true; --out_free: -- kfree(idmap); -- return ret; -+ return false; -+ -+ return true; - } - - static bool states_equal(struct bpf_verifier_env *env, -@@ -10204,7 +10171,7 @@ static bool states_equal(struct bpf_verifier_env *env, - for (i = 0; i <= old->curframe; i++) { - if (old->frame[i]->callsite != cur->frame[i]->callsite) - return false; -- if (!func_states_equal(old->frame[i], cur->frame[i])) -+ if (!func_states_equal(env, old->frame[i], cur->frame[i])) - return false; - } - return true; -@@ -11891,35 +11858,33 @@ static int convert_ctx_accesses(struct bpf_verifier_env *env) - - for (i = 0; i < insn_cnt; i++, insn++) { - bpf_convert_ctx_access_t convert_ctx_access; -+ bool ctx_access; - - if (insn->code == (BPF_LDX | BPF_MEM | BPF_B) || - insn->code == (BPF_LDX | BPF_MEM | BPF_H) || - insn->code == (BPF_LDX | BPF_MEM | BPF_W) || -- insn->code == (BPF_LDX | BPF_MEM | BPF_DW)) -+ insn->code == (BPF_LDX | BPF_MEM | BPF_DW)) { - type = BPF_READ; -- else if (insn->code == (BPF_STX | BPF_MEM | BPF_B) || -- insn->code == (BPF_STX | BPF_MEM | BPF_H) || -- insn->code == (BPF_STX | BPF_MEM | BPF_W) || -- insn->code == (BPF_STX | BPF_MEM | BPF_DW)) -+ ctx_access = true; -+ } else if (insn->code == (BPF_STX | BPF_MEM | BPF_B) || -+ insn->code == (BPF_STX | BPF_MEM | BPF_H) || -+ insn->code == (BPF_STX | BPF_MEM | BPF_W) || -+ insn->code == (BPF_STX | BPF_MEM | BPF_DW) || -+ insn->code == (BPF_ST | BPF_MEM | BPF_B) || -+ insn->code == (BPF_ST | BPF_MEM | BPF_H) || -+ insn->code == (BPF_ST | BPF_MEM | BPF_W) || -+ insn->code == (BPF_ST | BPF_MEM | BPF_DW)) { - type = BPF_WRITE; -- else -+ ctx_access = BPF_CLASS(insn->code) == BPF_STX; -+ } else { - continue; -+ } - - if (type == BPF_WRITE && -- env->insn_aux_data[i + delta].sanitize_stack_off) { -+ env->insn_aux_data[i + delta].sanitize_stack_spill) { - struct bpf_insn patch[] = { -- /* Sanitize suspicious stack slot with zero. -- * There are no memory dependencies for this store, -- * since it's only using frame pointer and immediate -- * constant of zero -- */ -- BPF_ST_MEM(BPF_DW, BPF_REG_FP, -- env->insn_aux_data[i + delta].sanitize_stack_off, -- 0), -- /* the original STX instruction will immediately -- * overwrite the same stack slot with appropriate value -- */ - *insn, -+ BPF_ST_NOSPEC(), - }; - - cnt = ARRAY_SIZE(patch); -@@ -11933,6 +11898,9 @@ static int convert_ctx_accesses(struct bpf_verifier_env *env) - continue; - } - -+ if (!ctx_access) -+ continue; -+ - switch (env->insn_aux_data[i + delta].ptr_type) { - case PTR_TO_CTX: - if (!ops->convert_ctx_access) -@@ -12737,37 +12705,6 @@ static void free_states(struct bpf_verifier_env *env) - } - } - --/* The verifier is using insn_aux_data[] to store temporary data during -- * verification and to store information for passes that run after the -- * verification like dead code sanitization. do_check_common() for subprogram N -- * may analyze many other subprograms. sanitize_insn_aux_data() clears all -- * temporary data after do_check_common() finds that subprogram N cannot be -- * verified independently. pass_cnt counts the number of times -- * do_check_common() was run and insn->aux->seen tells the pass number -- * insn_aux_data was touched. These variables are compared to clear temporary -- * data from failed pass. For testing and experiments do_check_common() can be -- * run multiple times even when prior attempt to verify is unsuccessful. -- * -- * Note that special handling is needed on !env->bypass_spec_v1 if this is -- * ever called outside of error path with subsequent program rejection. -- */ --static void sanitize_insn_aux_data(struct bpf_verifier_env *env) --{ -- struct bpf_insn *insn = env->prog->insnsi; -- struct bpf_insn_aux_data *aux; -- int i, class; -- -- for (i = 0; i < env->prog->len; i++) { -- class = BPF_CLASS(insn[i].code); -- if (class != BPF_LDX && class != BPF_STX) -- continue; -- aux = &env->insn_aux_data[i]; -- if (aux->seen != env->pass_cnt) -- continue; -- memset(aux, 0, offsetof(typeof(*aux), orig_idx)); -- } --} -- - static int do_check_common(struct bpf_verifier_env *env, int subprog) - { - bool pop_log = !(env->log.level & BPF_LOG_LEVEL2); -@@ -12844,9 +12781,6 @@ out: - if (!ret && pop_log) - bpf_vlog_reset(&env->log, 0); - free_states(env); -- if (ret) -- /* clean aux data in case subprog was rejected */ -- sanitize_insn_aux_data(env); - return ret; - } - -diff --git a/mm/memcontrol.c b/mm/memcontrol.c -index f4f2d05c8c7ba..946d848156932 100644 ---- a/mm/memcontrol.c -+++ b/mm/memcontrol.c -@@ -3394,7 +3394,8 @@ static unsigned long mem_cgroup_usage(struct mem_cgroup *memcg, bool swap) - unsigned long val; - - if (mem_cgroup_is_root(memcg)) { -- cgroup_rstat_flush(memcg->css.cgroup); -+ /* mem_cgroup_threshold() calls here from irqsafe context */ -+ cgroup_rstat_flush_irqsafe(memcg->css.cgroup); - val = memcg_page_state(memcg, NR_FILE_PAGES) + - memcg_page_state(memcg, NR_ANON_MAPPED); - if (swap) -diff --git a/mm/slab.h b/mm/slab.h -index b3294712a6868..aed67dbc79659 100644 ---- a/mm/slab.h -+++ b/mm/slab.h -@@ -350,7 +350,7 @@ static inline void memcg_slab_free_hook(struct kmem_cache *s_orig, - continue; - - page = virt_to_head_page(p[i]); -- objcgs = page_objcgs(page); -+ objcgs = page_objcgs_check(page); - if (!objcgs) - continue; - -diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c -index c3946c3558826..bdc95bd7a851f 100644 ---- a/net/can/j1939/transport.c -+++ b/net/can/j1939/transport.c -@@ -1075,11 +1075,16 @@ static bool j1939_session_deactivate_locked(struct j1939_session *session) - - static bool j1939_session_deactivate(struct j1939_session *session) - { -+ struct j1939_priv *priv = session->priv; - bool active; - -- j1939_session_list_lock(session->priv); -+ j1939_session_list_lock(priv); -+ /* This function should be called with a session ref-count of at -+ * least 2. -+ */ -+ WARN_ON_ONCE(kref_read(&session->kref) < 2); - active = j1939_session_deactivate_locked(session); -- j1939_session_list_unlock(session->priv); -+ j1939_session_list_unlock(priv); - - return active; - } -@@ -1869,7 +1874,7 @@ static void j1939_xtp_rx_dat_one(struct j1939_session *session, - if (!session->transmission) - j1939_tp_schedule_txtimer(session, 0); - } else { -- j1939_tp_set_rxtimeout(session, 250); -+ j1939_tp_set_rxtimeout(session, 750); - } - session->last_cmd = 0xff; - consume_skb(se_skb); -diff --git a/net/can/raw.c b/net/can/raw.c -index ac96fc2100253..5dca1e9e44cf5 100644 ---- a/net/can/raw.c -+++ b/net/can/raw.c -@@ -546,10 +546,18 @@ static int raw_setsockopt(struct socket *sock, int level, int optname, - return -EFAULT; - } - -+ rtnl_lock(); - lock_sock(sk); - -- if (ro->bound && ro->ifindex) -+ if (ro->bound && ro->ifindex) { - dev = dev_get_by_index(sock_net(sk), ro->ifindex); -+ if (!dev) { -+ if (count > 1) -+ kfree(filter); -+ err = -ENODEV; -+ goto out_fil; -+ } -+ } - - if (ro->bound) { - /* (try to) register the new filters */ -@@ -588,6 +596,7 @@ static int raw_setsockopt(struct socket *sock, int level, int optname, - dev_put(dev); - - release_sock(sk); -+ rtnl_unlock(); - - break; - -@@ -600,10 +609,16 @@ static int raw_setsockopt(struct socket *sock, int level, int optname, - - err_mask &= CAN_ERR_MASK; - -+ rtnl_lock(); - lock_sock(sk); - -- if (ro->bound && ro->ifindex) -+ if (ro->bound && ro->ifindex) { - dev = dev_get_by_index(sock_net(sk), ro->ifindex); -+ if (!dev) { -+ err = -ENODEV; -+ goto out_err; -+ } -+ } - - /* remove current error mask */ - if (ro->bound) { -@@ -627,6 +642,7 @@ static int raw_setsockopt(struct socket *sock, int level, int optname, - dev_put(dev); - - release_sock(sk); -+ rtnl_unlock(); - - break; - -diff --git a/net/core/skmsg.c b/net/core/skmsg.c -index b2410a1bfa23d..45b3a3adc886f 100644 ---- a/net/core/skmsg.c -+++ b/net/core/skmsg.c -@@ -790,8 +790,6 @@ static void sk_psock_destroy(struct work_struct *work) - - void sk_psock_drop(struct sock *sk, struct sk_psock *psock) - { -- sk_psock_stop(psock, false); -- - write_lock_bh(&sk->sk_callback_lock); - sk_psock_restore_proto(sk, psock); - rcu_assign_sk_user_data(sk, NULL); -@@ -801,6 +799,8 @@ void sk_psock_drop(struct sock *sk, struct sk_psock *psock) - sk_psock_stop_verdict(sk, psock); - write_unlock_bh(&sk->sk_callback_lock); - -+ sk_psock_stop(psock, false); -+ - INIT_RCU_WORK(&psock->rwork, sk_psock_destroy); - queue_rcu_work(system_wq, &psock->rwork); - } -diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c -index 0dca00745ac3c..be75b409445c2 100644 ---- a/net/ipv4/ip_tunnel.c -+++ b/net/ipv4/ip_tunnel.c -@@ -390,7 +390,7 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb, - tunnel->i_seqno = ntohl(tpi->seq) + 1; - } - -- skb_reset_network_header(skb); -+ skb_set_network_header(skb, (tunnel->dev->type == ARPHRD_ETHER) ? ETH_HLEN : 0); - - err = IP_ECN_decapsulate(iph, skb); - if (unlikely(err)) { -diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c -index 7180979114e49..ac5cadd02cfa8 100644 ---- a/net/llc/af_llc.c -+++ b/net/llc/af_llc.c -@@ -98,8 +98,16 @@ static inline u8 llc_ui_header_len(struct sock *sk, struct sockaddr_llc *addr) - { - u8 rc = LLC_PDU_LEN_U; - -- if (addr->sllc_test || addr->sllc_xid) -+ if (addr->sllc_test) - rc = LLC_PDU_LEN_U; -+ else if (addr->sllc_xid) -+ /* We need to expand header to sizeof(struct llc_xid_info) -+ * since llc_pdu_init_as_xid_cmd() sets 4,5,6 bytes of LLC header -+ * as XID PDU. In llc_ui_sendmsg() we reserved header size and then -+ * filled all other space with user data. If we won't reserve this -+ * bytes, llc_pdu_init_as_xid_cmd() will overwrite user data -+ */ -+ rc = LLC_PDU_LEN_U_XID; - else if (sk->sk_type == SOCK_STREAM) - rc = LLC_PDU_LEN_I; - return rc; -diff --git a/net/llc/llc_s_ac.c b/net/llc/llc_s_ac.c -index b554f26c68ee0..79d1cef8f15a9 100644 ---- a/net/llc/llc_s_ac.c -+++ b/net/llc/llc_s_ac.c -@@ -79,7 +79,7 @@ int llc_sap_action_send_xid_c(struct llc_sap *sap, struct sk_buff *skb) - struct llc_sap_state_ev *ev = llc_sap_ev(skb); - int rc; - -- llc_pdu_header_init(skb, LLC_PDU_TYPE_U, ev->saddr.lsap, -+ llc_pdu_header_init(skb, LLC_PDU_TYPE_U_XID, ev->saddr.lsap, - ev->daddr.lsap, LLC_PDU_CMD); - llc_pdu_init_as_xid_cmd(skb, LLC_XID_NULL_CLASS_2, 0); - rc = llc_mac_hdr_init(skb, ev->saddr.mac, ev->daddr.mac); -diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c -index 7a99892e5aba4..9f14434598527 100644 ---- a/net/mac80211/cfg.c -+++ b/net/mac80211/cfg.c -@@ -152,6 +152,8 @@ static int ieee80211_change_iface(struct wiphy *wiphy, - struct vif_params *params) - { - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); -+ struct ieee80211_local *local = sdata->local; -+ struct sta_info *sta; - int ret; - - ret = ieee80211_if_change_type(sdata, type); -@@ -162,7 +164,24 @@ static int ieee80211_change_iface(struct wiphy *wiphy, - RCU_INIT_POINTER(sdata->u.vlan.sta, NULL); - ieee80211_check_fast_rx_iface(sdata); - } else if (type == NL80211_IFTYPE_STATION && params->use_4addr >= 0) { -+ struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; -+ -+ if (params->use_4addr == ifmgd->use_4addr) -+ return 0; -+ - sdata->u.mgd.use_4addr = params->use_4addr; -+ if (!ifmgd->associated) -+ return 0; -+ -+ mutex_lock(&local->sta_mtx); -+ sta = sta_info_get(sdata, ifmgd->bssid); -+ if (sta) -+ drv_sta_set_4addr(local, sdata, &sta->sta, -+ params->use_4addr); -+ mutex_unlock(&local->sta_mtx); -+ -+ if (params->use_4addr) -+ ieee80211_send_4addr_nullfunc(local, sdata); - } - - if (sdata->vif.type == NL80211_IFTYPE_MONITOR) { -diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h -index 648696b49f897..1e1d2e72de4a0 100644 ---- a/net/mac80211/ieee80211_i.h -+++ b/net/mac80211/ieee80211_i.h -@@ -2045,6 +2045,8 @@ void ieee80211_dynamic_ps_timer(struct timer_list *t); - void ieee80211_send_nullfunc(struct ieee80211_local *local, - struct ieee80211_sub_if_data *sdata, - bool powersave); -+void ieee80211_send_4addr_nullfunc(struct ieee80211_local *local, -+ struct ieee80211_sub_if_data *sdata); - void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata, - struct ieee80211_hdr *hdr, bool ack, u16 tx_time); - -diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c -index b1c44fa63a06f..9bed6464c5bd6 100644 ---- a/net/mac80211/mlme.c -+++ b/net/mac80211/mlme.c -@@ -1115,8 +1115,8 @@ void ieee80211_send_nullfunc(struct ieee80211_local *local, - ieee80211_tx_skb(sdata, skb); - } - --static void ieee80211_send_4addr_nullfunc(struct ieee80211_local *local, -- struct ieee80211_sub_if_data *sdata) -+void ieee80211_send_4addr_nullfunc(struct ieee80211_local *local, -+ struct ieee80211_sub_if_data *sdata) - { - struct sk_buff *skb; - struct ieee80211_hdr *nullfunc; -diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c -index e0befcf8113a9..69079a382d3a5 100644 ---- a/net/netfilter/nf_conntrack_core.c -+++ b/net/netfilter/nf_conntrack_core.c -@@ -666,8 +666,13 @@ bool nf_ct_delete(struct nf_conn *ct, u32 portid, int report) - return false; - - tstamp = nf_conn_tstamp_find(ct); -- if (tstamp && tstamp->stop == 0) -+ if (tstamp) { -+ s32 timeout = ct->timeout - nfct_time_stamp; -+ - tstamp->stop = ktime_get_real_ns(); -+ if (timeout < 0) -+ tstamp->stop -= jiffies_to_nsecs(-timeout); -+ } - - if (nf_conntrack_event_report(IPCT_DESTROY, ct, - portid, report) < 0) { -diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c -index a5db7c59ad4e4..7512bb819dff3 100644 ---- a/net/netfilter/nf_tables_api.c -+++ b/net/netfilter/nf_tables_api.c -@@ -8479,6 +8479,16 @@ static int nf_tables_commit_audit_alloc(struct list_head *adl, - return 0; - } - -+static void nf_tables_commit_audit_free(struct list_head *adl) -+{ -+ struct nft_audit_data *adp, *adn; -+ -+ list_for_each_entry_safe(adp, adn, adl, list) { -+ list_del(&adp->list); -+ kfree(adp); -+ } -+} -+ - static void nf_tables_commit_audit_collect(struct list_head *adl, - struct nft_table *table, u32 op) - { -@@ -8543,6 +8553,7 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb) - ret = nf_tables_commit_audit_alloc(&adl, trans->ctx.table); - if (ret) { - nf_tables_commit_chain_prepare_cancel(net); -+ nf_tables_commit_audit_free(&adl); - return ret; - } - if (trans->msg_type == NFT_MSG_NEWRULE || -@@ -8552,6 +8563,7 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb) - ret = nf_tables_commit_chain_prepare(net, chain); - if (ret < 0) { - nf_tables_commit_chain_prepare_cancel(net); -+ nf_tables_commit_audit_free(&adl); - return ret; - } - } -diff --git a/net/netfilter/nft_nat.c b/net/netfilter/nft_nat.c -index 0840c635b752e..be1595d6979d8 100644 ---- a/net/netfilter/nft_nat.c -+++ b/net/netfilter/nft_nat.c -@@ -201,7 +201,9 @@ static int nft_nat_init(const struct nft_ctx *ctx, const struct nft_expr *expr, - alen = sizeof_field(struct nf_nat_range, min_addr.ip6); - break; - default: -- return -EAFNOSUPPORT; -+ if (tb[NFTA_NAT_REG_ADDR_MIN]) -+ return -EAFNOSUPPORT; -+ break; - } - priv->family = family; - -diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c -index f2efaa4225f91..67993bcfecdea 100644 ---- a/net/qrtr/qrtr.c -+++ b/net/qrtr/qrtr.c -@@ -518,8 +518,10 @@ int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len) - if (!ipc) - goto err; - -- if (sock_queue_rcv_skb(&ipc->sk, skb)) -+ if (sock_queue_rcv_skb(&ipc->sk, skb)) { -+ qrtr_port_put(ipc); - goto err; -+ } - - qrtr_port_put(ipc); - } -@@ -839,6 +841,8 @@ static int qrtr_local_enqueue(struct qrtr_node *node, struct sk_buff *skb, - - ipc = qrtr_port_lookup(to->sq_port); - if (!ipc || &ipc->sk == skb->sk) { /* do not send to self */ -+ if (ipc) -+ qrtr_port_put(ipc); - kfree_skb(skb); - return -ENODEV; - } -diff --git a/net/sctp/input.c b/net/sctp/input.c -index f72bff93745c4..ddb5b5c2550ef 100644 ---- a/net/sctp/input.c -+++ b/net/sctp/input.c -@@ -1175,7 +1175,7 @@ static struct sctp_association *__sctp_rcv_asconf_lookup( - if (unlikely(!af)) - return NULL; - -- if (af->from_addr_param(&paddr, param, peer_port, 0)) -+ if (!af->from_addr_param(&paddr, param, peer_port, 0)) - return NULL; - - return __sctp_lookup_association(net, laddr, &paddr, transportp); -diff --git a/net/tipc/crypto.c b/net/tipc/crypto.c -index e5c43d4d5a75f..c9391d38de85c 100644 ---- a/net/tipc/crypto.c -+++ b/net/tipc/crypto.c -@@ -898,16 +898,10 @@ static int tipc_aead_decrypt(struct net *net, struct tipc_aead *aead, - if (unlikely(!aead)) - return -ENOKEY; - -- /* Cow skb data if needed */ -- if (likely(!skb_cloned(skb) && -- (!skb_is_nonlinear(skb) || !skb_has_frag_list(skb)))) { -- nsg = 1 + skb_shinfo(skb)->nr_frags; -- } else { -- nsg = skb_cow_data(skb, 0, &unused); -- if (unlikely(nsg < 0)) { -- pr_err("RX: skb_cow_data() returned %d\n", nsg); -- return nsg; -- } -+ nsg = skb_cow_data(skb, 0, &unused); -+ if (unlikely(nsg < 0)) { -+ pr_err("RX: skb_cow_data() returned %d\n", nsg); -+ return nsg; - } - - /* Allocate memory for the AEAD operation */ -diff --git a/net/tipc/socket.c b/net/tipc/socket.c -index 53af72824c9ce..9bdc5147a65a1 100644 ---- a/net/tipc/socket.c -+++ b/net/tipc/socket.c -@@ -160,6 +160,7 @@ static void tipc_sk_remove(struct tipc_sock *tsk); - static int __tipc_sendstream(struct socket *sock, struct msghdr *m, size_t dsz); - static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dsz); - static void tipc_sk_push_backlog(struct tipc_sock *tsk, bool nagle_ack); -+static int tipc_wait_for_connect(struct socket *sock, long *timeo_p); - - static const struct proto_ops packet_ops; - static const struct proto_ops stream_ops; -@@ -1525,8 +1526,13 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen) - rc = 0; - } - -- if (unlikely(syn && !rc)) -+ if (unlikely(syn && !rc)) { - tipc_set_sk_state(sk, TIPC_CONNECTING); -+ if (timeout) { -+ timeout = msecs_to_jiffies(timeout); -+ tipc_wait_for_connect(sock, &timeout); -+ } -+ } - - return rc ? rc : dlen; - } -@@ -1574,7 +1580,7 @@ static int __tipc_sendstream(struct socket *sock, struct msghdr *m, size_t dlen) - return -EMSGSIZE; - - /* Handle implicit connection setup */ -- if (unlikely(dest)) { -+ if (unlikely(dest && sk->sk_state == TIPC_OPEN)) { - rc = __tipc_sendmsg(sock, m, dlen); - if (dlen && dlen == rc) { - tsk->peer_caps = tipc_node_get_capabilities(net, dnode); -@@ -2665,7 +2671,7 @@ static int tipc_listen(struct socket *sock, int len) - static int tipc_wait_for_accept(struct socket *sock, long timeo) - { - struct sock *sk = sock->sk; -- DEFINE_WAIT(wait); -+ DEFINE_WAIT_FUNC(wait, woken_wake_function); - int err; - - /* True wake-one mechanism for incoming connections: only -@@ -2674,12 +2680,12 @@ static int tipc_wait_for_accept(struct socket *sock, long timeo) - * anymore, the common case will execute the loop only once. - */ - for (;;) { -- prepare_to_wait_exclusive(sk_sleep(sk), &wait, -- TASK_INTERRUPTIBLE); - if (timeo && skb_queue_empty(&sk->sk_receive_queue)) { -+ add_wait_queue(sk_sleep(sk), &wait); - release_sock(sk); -- timeo = schedule_timeout(timeo); -+ timeo = wait_woken(&wait, TASK_INTERRUPTIBLE, timeo); - lock_sock(sk); -+ remove_wait_queue(sk_sleep(sk), &wait); - } - err = 0; - if (!skb_queue_empty(&sk->sk_receive_queue)) -@@ -2691,7 +2697,6 @@ static int tipc_wait_for_accept(struct socket *sock, long timeo) - if (signal_pending(current)) - break; - } -- finish_wait(sk_sleep(sk), &wait); - return err; - } - -@@ -2708,9 +2713,10 @@ static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags, - bool kern) - { - struct sock *new_sk, *sk = sock->sk; -- struct sk_buff *buf; - struct tipc_sock *new_tsock; -+ struct msghdr m = {NULL,}; - struct tipc_msg *msg; -+ struct sk_buff *buf; - long timeo; - int res; - -@@ -2755,19 +2761,17 @@ static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags, - } - - /* -- * Respond to 'SYN-' by discarding it & returning 'ACK'-. -- * Respond to 'SYN+' by queuing it on new socket. -+ * Respond to 'SYN-' by discarding it & returning 'ACK'. -+ * Respond to 'SYN+' by queuing it on new socket & returning 'ACK'. - */ - if (!msg_data_sz(msg)) { -- struct msghdr m = {NULL,}; -- - tsk_advance_rx_queue(sk); -- __tipc_sendstream(new_sock, &m, 0); - } else { - __skb_dequeue(&sk->sk_receive_queue); - __skb_queue_head(&new_sk->sk_receive_queue, buf); - skb_set_owner_r(buf, new_sk); - } -+ __tipc_sendstream(new_sock, &m, 0); - release_sock(new_sk); - exit: - release_sock(sk); -diff --git a/net/wireless/scan.c b/net/wireless/scan.c -index 4f06c1825029f..dd76accab018b 100644 ---- a/net/wireless/scan.c -+++ b/net/wireless/scan.c -@@ -1744,16 +1744,14 @@ cfg80211_bss_update(struct cfg80211_registered_device *rdev, - * be grouped with this beacon for updates ... - */ - if (!cfg80211_combine_bsses(rdev, new)) { -- kfree(new); -+ bss_ref_put(rdev, new); - goto drop; - } - } - - if (rdev->bss_entries >= bss_entries_limit && - !cfg80211_bss_expire_oldest(rdev)) { -- if (!list_empty(&new->hidden_list)) -- list_del(&new->hidden_list); -- kfree(new); -+ bss_ref_put(rdev, new); - goto drop; - } - -diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c -index 72e7f3616157e..8af693d9678ce 100644 ---- a/tools/perf/util/map.c -+++ b/tools/perf/util/map.c -@@ -192,8 +192,6 @@ struct map *map__new(struct machine *machine, u64 start, u64 len, - if (!(prot & PROT_EXEC)) - dso__set_loaded(dso); - } -- -- nsinfo__put(dso->nsinfo); - dso->nsinfo = nsi; - - if (build_id__is_defined(bid)) -diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c -index 44b90d638ad5f..538b8fa8a7109 100644 ---- a/tools/perf/util/pmu.c -+++ b/tools/perf/util/pmu.c -@@ -742,9 +742,13 @@ struct pmu_events_map *__weak pmu_events_map__find(void) - return perf_pmu__find_map(NULL); - } - --static bool perf_pmu__valid_suffix(char *pmu_name, char *tok) -+/* -+ * Suffix must be in form tok_{digits}, or tok{digits}, or same as pmu_name -+ * to be valid. -+ */ -+static bool perf_pmu__valid_suffix(const char *pmu_name, char *tok) - { -- char *p; -+ const char *p; - - if (strncmp(pmu_name, tok, strlen(tok))) - return false; -@@ -753,12 +757,16 @@ static bool perf_pmu__valid_suffix(char *pmu_name, char *tok) - if (*p == 0) - return true; - -- if (*p != '_') -- return false; -+ if (*p == '_') -+ ++p; - -- ++p; -- if (*p == 0 || !isdigit(*p)) -- return false; -+ /* Ensure we end in a number */ -+ while (1) { -+ if (!isdigit(*p)) -+ return false; -+ if (*(++p) == 0) -+ break; -+ } - - return true; - } -@@ -789,12 +797,19 @@ bool pmu_uncore_alias_match(const char *pmu_name, const char *name) - * match "socket" in "socketX_pmunameY" and then "pmuname" in - * "pmunameY". - */ -- for (; tok; name += strlen(tok), tok = strtok_r(NULL, ",", &tmp)) { -+ while (1) { -+ char *next_tok = strtok_r(NULL, ",", &tmp); -+ - name = strstr(name, tok); -- if (!name || !perf_pmu__valid_suffix((char *)name, tok)) { -+ if (!name || -+ (!next_tok && !perf_pmu__valid_suffix(name, tok))) { - res = false; - goto out; - } -+ if (!next_tok) -+ break; -+ tok = next_tok; -+ name += strlen(tok); - } - - res = true; -diff --git a/tools/testing/selftests/kvm/dirty_log_perf_test.c b/tools/testing/selftests/kvm/dirty_log_perf_test.c -index 04a2641261beb..80cbd3a748c02 100644 ---- a/tools/testing/selftests/kvm/dirty_log_perf_test.c -+++ b/tools/testing/selftests/kvm/dirty_log_perf_test.c -@@ -312,6 +312,7 @@ int main(int argc, char *argv[]) - break; - case 'o': - p.partition_vcpu_memory_access = false; -+ break; - case 's': - p.backing_src = parse_backing_src_type(optarg); - break; -diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c -index 3e1fef3d81045..be6d64c90eadb 100644 ---- a/tools/testing/selftests/vm/userfaultfd.c -+++ b/tools/testing/selftests/vm/userfaultfd.c -@@ -199,7 +199,7 @@ static void anon_allocate_area(void **alloc_area) - { - *alloc_area = mmap(NULL, nr_pages * page_size, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); -- if (*alloc_area == MAP_FAILED) -+ if (*alloc_area == MAP_FAILED) { - fprintf(stderr, "mmap of anonymous memory failed"); - *alloc_area = NULL; - } -diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c -index 46fb042837d20..0119466677b7d 100644 ---- a/virt/kvm/kvm_main.c -+++ b/virt/kvm/kvm_main.c -@@ -4183,6 +4183,16 @@ struct compat_kvm_dirty_log { - }; - }; - -+struct compat_kvm_clear_dirty_log { -+ __u32 slot; -+ __u32 num_pages; -+ __u64 first_page; -+ union { -+ compat_uptr_t dirty_bitmap; /* one bit per page */ -+ __u64 padding2; -+ }; -+}; -+ - static long kvm_vm_compat_ioctl(struct file *filp, - unsigned int ioctl, unsigned long arg) - { -@@ -4192,6 +4202,24 @@ static long kvm_vm_compat_ioctl(struct file *filp, - if (kvm->mm != current->mm) - return -EIO; - switch (ioctl) { -+#ifdef CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT -+ case KVM_CLEAR_DIRTY_LOG: { -+ struct compat_kvm_clear_dirty_log compat_log; -+ struct kvm_clear_dirty_log log; -+ -+ if (copy_from_user(&compat_log, (void __user *)arg, -+ sizeof(compat_log))) -+ return -EFAULT; -+ log.slot = compat_log.slot; -+ log.num_pages = compat_log.num_pages; -+ log.first_page = compat_log.first_page; -+ log.padding2 = compat_log.padding2; -+ log.dirty_bitmap = compat_ptr(compat_log.dirty_bitmap); -+ -+ r = kvm_vm_ioctl_clear_dirty_log(kvm, &log); -+ break; -+ } -+#endif - case KVM_GET_DIRTY_LOG: { - struct compat_kvm_dirty_log compat_log; - struct kvm_dirty_log log; diff --git a/patch/kernel/archive/sunxi-5.13/patch-1-5.13.8-9.patch b/patch/kernel/archive/sunxi-5.13/patch-1-5.13.8-9.patch deleted file mode 100644 index 2058d37e9e..0000000000 --- a/patch/kernel/archive/sunxi-5.13/patch-1-5.13.8-9.patch +++ /dev/null @@ -1,2415 +0,0 @@ -diff --git a/Makefile b/Makefile -index fdb4e2fd9d8f3..9d810e13a83f4 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,7 +1,7 @@ - # SPDX-License-Identifier: GPL-2.0 - VERSION = 5 - PATCHLEVEL = 13 --SUBLEVEL = 8 -+SUBLEVEL = 9 - EXTRAVERSION = - NAME = Opossums on Parade - -diff --git a/drivers/firmware/efi/mokvar-table.c b/drivers/firmware/efi/mokvar-table.c -index d8bc013406861..38722d2009e20 100644 ---- a/drivers/firmware/efi/mokvar-table.c -+++ b/drivers/firmware/efi/mokvar-table.c -@@ -180,7 +180,10 @@ void __init efi_mokvar_table_init(void) - pr_err("EFI MOKvar config table is not valid\n"); - return; - } -- efi_mem_reserve(efi.mokvar_table, map_size_needed); -+ -+ if (md.type == EFI_BOOT_SERVICES_DATA) -+ efi_mem_reserve(efi.mokvar_table, map_size_needed); -+ - efi_mokvar_table_size = map_size_needed; - } - -diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c -index ae6830ff1cf7d..774e825e5aab8 100644 ---- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c -+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c -@@ -1675,9 +1675,6 @@ static enum dp_panel_mode try_enable_assr(struct dc_stream_state *stream) - } else - panel_mode = DP_PANEL_MODE_DEFAULT; - --#else -- /* turn off ASSR if the implementation is not compiled in */ -- panel_mode = DP_PANEL_MODE_DEFAULT; - #endif - return panel_mode; - } -diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c -index d7d70b9bb3874..81f583733fa87 100644 ---- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c -+++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c -@@ -2093,8 +2093,10 @@ int dcn20_populate_dml_pipes_from_context( - - timing->v_border_bottom; - pipes[pipe_cnt].pipe.dest.htotal = timing->h_total; - pipes[pipe_cnt].pipe.dest.vtotal = v_total; -- pipes[pipe_cnt].pipe.dest.hactive = timing->h_addressable; -- pipes[pipe_cnt].pipe.dest.vactive = timing->v_addressable; -+ pipes[pipe_cnt].pipe.dest.hactive = -+ timing->h_addressable + timing->h_border_left + timing->h_border_right; -+ pipes[pipe_cnt].pipe.dest.vactive = -+ timing->v_addressable + timing->v_border_top + timing->v_border_bottom; - pipes[pipe_cnt].pipe.dest.interlaced = timing->flags.INTERLACE; - pipes[pipe_cnt].pipe.dest.pixel_rate_mhz = timing->pix_clk_100hz/10000.0; - if (timing->timing_3d_format == TIMING_3D_FORMAT_HW_FRAME_PACKING) -diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c b/drivers/gpu/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c -index 398210d1af34f..f497439293572 100644 ---- a/drivers/gpu/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c -+++ b/drivers/gpu/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c -@@ -4889,7 +4889,7 @@ void dml21_ModeSupportAndSystemConfigurationFull(struct display_mode_lib *mode_l - } - } while ((locals->PrefetchSupported[i][j] != true || locals->VRatioInPrefetchSupported[i][j] != true) - && (mode_lib->vba.NextMaxVStartup != mode_lib->vba.MaxMaxVStartup[0][0] -- || mode_lib->vba.NextPrefetchMode < mode_lib->vba.MaxPrefetchMode)); -+ || mode_lib->vba.NextPrefetchMode <= mode_lib->vba.MaxPrefetchMode)); - - if (locals->PrefetchSupported[i][j] == true && locals->VRatioInPrefetchSupported[i][j] == true) { - mode_lib->vba.BandwidthAvailableForImmediateFlip = locals->ReturnBWPerState[i][0]; -diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c -index 5964e67c7d363..305c320f9a838 100644 ---- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c -+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c -@@ -25,10 +25,8 @@ - #include "i915_gem_clflush.h" - #include "i915_gem_context.h" - #include "i915_gem_ioctls.h" --#include "i915_sw_fence_work.h" - #include "i915_trace.h" - #include "i915_user_extensions.h" --#include "i915_memcpy.h" - - struct eb_vma { - struct i915_vma *vma; -@@ -1456,6 +1454,10 @@ static u32 *reloc_gpu(struct i915_execbuffer *eb, - int err; - struct intel_engine_cs *engine = eb->engine; - -+ /* If we need to copy for the cmdparser, we will stall anyway */ -+ if (eb_use_cmdparser(eb)) -+ return ERR_PTR(-EWOULDBLOCK); -+ - if (!reloc_can_use_engine(engine)) { - engine = engine->gt->engine_class[COPY_ENGINE_CLASS][0]; - if (!engine) -@@ -2372,217 +2374,6 @@ shadow_batch_pin(struct i915_execbuffer *eb, - return vma; - } - --struct eb_parse_work { -- struct dma_fence_work base; -- struct intel_engine_cs *engine; -- struct i915_vma *batch; -- struct i915_vma *shadow; -- struct i915_vma *trampoline; -- unsigned long batch_offset; -- unsigned long batch_length; -- unsigned long *jump_whitelist; -- const void *batch_map; -- void *shadow_map; --}; -- --static int __eb_parse(struct dma_fence_work *work) --{ -- struct eb_parse_work *pw = container_of(work, typeof(*pw), base); -- int ret; -- bool cookie; -- -- cookie = dma_fence_begin_signalling(); -- ret = intel_engine_cmd_parser(pw->engine, -- pw->batch, -- pw->batch_offset, -- pw->batch_length, -- pw->shadow, -- pw->jump_whitelist, -- pw->shadow_map, -- pw->batch_map); -- dma_fence_end_signalling(cookie); -- -- return ret; --} -- --static void __eb_parse_release(struct dma_fence_work *work) --{ -- struct eb_parse_work *pw = container_of(work, typeof(*pw), base); -- -- if (!IS_ERR_OR_NULL(pw->jump_whitelist)) -- kfree(pw->jump_whitelist); -- -- if (pw->batch_map) -- i915_gem_object_unpin_map(pw->batch->obj); -- else -- i915_gem_object_unpin_pages(pw->batch->obj); -- -- i915_gem_object_unpin_map(pw->shadow->obj); -- -- if (pw->trampoline) -- i915_active_release(&pw->trampoline->active); -- i915_active_release(&pw->shadow->active); -- i915_active_release(&pw->batch->active); --} -- --static const struct dma_fence_work_ops eb_parse_ops = { -- .name = "eb_parse", -- .work = __eb_parse, -- .release = __eb_parse_release, --}; -- --static inline int --__parser_mark_active(struct i915_vma *vma, -- struct intel_timeline *tl, -- struct dma_fence *fence) --{ -- struct intel_gt_buffer_pool_node *node = vma->private; -- -- return i915_active_ref(&node->active, tl->fence_context, fence); --} -- --static int --parser_mark_active(struct eb_parse_work *pw, struct intel_timeline *tl) --{ -- int err; -- -- mutex_lock(&tl->mutex); -- -- err = __parser_mark_active(pw->shadow, tl, &pw->base.dma); -- if (err) -- goto unlock; -- -- if (pw->trampoline) { -- err = __parser_mark_active(pw->trampoline, tl, &pw->base.dma); -- if (err) -- goto unlock; -- } -- --unlock: -- mutex_unlock(&tl->mutex); -- return err; --} -- --static int eb_parse_pipeline(struct i915_execbuffer *eb, -- struct i915_vma *shadow, -- struct i915_vma *trampoline) --{ -- struct eb_parse_work *pw; -- struct drm_i915_gem_object *batch = eb->batch->vma->obj; -- bool needs_clflush; -- int err; -- -- GEM_BUG_ON(overflows_type(eb->batch_start_offset, pw->batch_offset)); -- GEM_BUG_ON(overflows_type(eb->batch_len, pw->batch_length)); -- -- pw = kzalloc(sizeof(*pw), GFP_KERNEL); -- if (!pw) -- return -ENOMEM; -- -- err = i915_active_acquire(&eb->batch->vma->active); -- if (err) -- goto err_free; -- -- err = i915_active_acquire(&shadow->active); -- if (err) -- goto err_batch; -- -- if (trampoline) { -- err = i915_active_acquire(&trampoline->active); -- if (err) -- goto err_shadow; -- } -- -- pw->shadow_map = i915_gem_object_pin_map(shadow->obj, I915_MAP_WB); -- if (IS_ERR(pw->shadow_map)) { -- err = PTR_ERR(pw->shadow_map); -- goto err_trampoline; -- } -- -- needs_clflush = -- !(batch->cache_coherent & I915_BO_CACHE_COHERENT_FOR_READ); -- -- pw->batch_map = ERR_PTR(-ENODEV); -- if (needs_clflush && i915_has_memcpy_from_wc()) -- pw->batch_map = i915_gem_object_pin_map(batch, I915_MAP_WC); -- -- if (IS_ERR(pw->batch_map)) { -- err = i915_gem_object_pin_pages(batch); -- if (err) -- goto err_unmap_shadow; -- pw->batch_map = NULL; -- } -- -- pw->jump_whitelist = -- intel_engine_cmd_parser_alloc_jump_whitelist(eb->batch_len, -- trampoline); -- if (IS_ERR(pw->jump_whitelist)) { -- err = PTR_ERR(pw->jump_whitelist); -- goto err_unmap_batch; -- } -- -- dma_fence_work_init(&pw->base, &eb_parse_ops); -- -- pw->engine = eb->engine; -- pw->batch = eb->batch->vma; -- pw->batch_offset = eb->batch_start_offset; -- pw->batch_length = eb->batch_len; -- pw->shadow = shadow; -- pw->trampoline = trampoline; -- -- /* Mark active refs early for this worker, in case we get interrupted */ -- err = parser_mark_active(pw, eb->context->timeline); -- if (err) -- goto err_commit; -- -- err = dma_resv_reserve_shared(pw->batch->resv, 1); -- if (err) -- goto err_commit; -- -- err = dma_resv_reserve_shared(shadow->resv, 1); -- if (err) -- goto err_commit; -- -- /* Wait for all writes (and relocs) into the batch to complete */ -- err = i915_sw_fence_await_reservation(&pw->base.chain, -- pw->batch->resv, NULL, false, -- 0, I915_FENCE_GFP); -- if (err < 0) -- goto err_commit; -- -- /* Keep the batch alive and unwritten as we parse */ -- dma_resv_add_shared_fence(pw->batch->resv, &pw->base.dma); -- -- /* Force execution to wait for completion of the parser */ -- dma_resv_add_excl_fence(shadow->resv, &pw->base.dma); -- -- dma_fence_work_commit_imm(&pw->base); -- return 0; -- --err_commit: -- i915_sw_fence_set_error_once(&pw->base.chain, err); -- dma_fence_work_commit_imm(&pw->base); -- return err; -- --err_unmap_batch: -- if (pw->batch_map) -- i915_gem_object_unpin_map(batch); -- else -- i915_gem_object_unpin_pages(batch); --err_unmap_shadow: -- i915_gem_object_unpin_map(shadow->obj); --err_trampoline: -- if (trampoline) -- i915_active_release(&trampoline->active); --err_shadow: -- i915_active_release(&shadow->active); --err_batch: -- i915_active_release(&eb->batch->vma->active); --err_free: -- kfree(pw); -- return err; --} -- - static struct i915_vma *eb_dispatch_secure(struct i915_execbuffer *eb, struct i915_vma *vma) - { - /* -@@ -2672,7 +2463,15 @@ static int eb_parse(struct i915_execbuffer *eb) - goto err_trampoline; - } - -- err = eb_parse_pipeline(eb, shadow, trampoline); -+ err = dma_resv_reserve_shared(shadow->resv, 1); -+ if (err) -+ goto err_trampoline; -+ -+ err = intel_engine_cmd_parser(eb->engine, -+ eb->batch->vma, -+ eb->batch_start_offset, -+ eb->batch_len, -+ shadow, trampoline); - if (err) - goto err_unpin_batch; - -diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/selftests/i915_gem_execbuffer.c -index 4df505e4c53ae..16162fc2782dc 100644 ---- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_execbuffer.c -+++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_execbuffer.c -@@ -125,6 +125,10 @@ static int igt_gpu_reloc(void *arg) - intel_gt_pm_get(&eb.i915->gt); - - for_each_uabi_engine(eb.engine, eb.i915) { -+ if (intel_engine_requires_cmd_parser(eb.engine) || -+ intel_engine_using_cmd_parser(eb.engine)) -+ continue; -+ - reloc_cache_init(&eb.reloc_cache, eb.i915); - memset(map, POISON_INUSE, 4096); - -diff --git a/drivers/gpu/drm/i915/i915_cmd_parser.c b/drivers/gpu/drm/i915/i915_cmd_parser.c -index e6f1e93abbbb3..ce61ea4506ea9 100644 ---- a/drivers/gpu/drm/i915/i915_cmd_parser.c -+++ b/drivers/gpu/drm/i915/i915_cmd_parser.c -@@ -1145,19 +1145,41 @@ find_reg(const struct intel_engine_cs *engine, u32 addr) - static u32 *copy_batch(struct drm_i915_gem_object *dst_obj, - struct drm_i915_gem_object *src_obj, - unsigned long offset, unsigned long length, -- void *dst, const void *src) -+ bool *needs_clflush_after) - { -- bool needs_clflush = -- !(src_obj->cache_coherent & I915_BO_CACHE_COHERENT_FOR_READ); -- -- if (src) { -- GEM_BUG_ON(!needs_clflush); -- i915_unaligned_memcpy_from_wc(dst, src + offset, length); -- } else { -- struct scatterlist *sg; -+ unsigned int src_needs_clflush; -+ unsigned int dst_needs_clflush; -+ void *dst, *src; -+ int ret; -+ -+ ret = i915_gem_object_prepare_write(dst_obj, &dst_needs_clflush); -+ if (ret) -+ return ERR_PTR(ret); -+ -+ dst = i915_gem_object_pin_map(dst_obj, I915_MAP_WB); -+ i915_gem_object_finish_access(dst_obj); -+ if (IS_ERR(dst)) -+ return dst; -+ -+ ret = i915_gem_object_prepare_read(src_obj, &src_needs_clflush); -+ if (ret) { -+ i915_gem_object_unpin_map(dst_obj); -+ return ERR_PTR(ret); -+ } -+ -+ src = ERR_PTR(-ENODEV); -+ if (src_needs_clflush && i915_has_memcpy_from_wc()) { -+ src = i915_gem_object_pin_map(src_obj, I915_MAP_WC); -+ if (!IS_ERR(src)) { -+ i915_unaligned_memcpy_from_wc(dst, -+ src + offset, -+ length); -+ i915_gem_object_unpin_map(src_obj); -+ } -+ } -+ if (IS_ERR(src)) { -+ unsigned long x, n, remain; - void *ptr; -- unsigned int x, sg_ofs; -- unsigned long remain; - - /* - * We can avoid clflushing partial cachelines before the write -@@ -1168,40 +1190,34 @@ static u32 *copy_batch(struct drm_i915_gem_object *dst_obj, - * validate up to the end of the batch. - */ - remain = length; -- if (!(dst_obj->cache_coherent & I915_BO_CACHE_COHERENT_FOR_READ)) -+ if (dst_needs_clflush & CLFLUSH_BEFORE) - remain = round_up(remain, - boot_cpu_data.x86_clflush_size); - - ptr = dst; - x = offset_in_page(offset); -- sg = i915_gem_object_get_sg(src_obj, offset >> PAGE_SHIFT, &sg_ofs, false); -- -- while (remain) { -- unsigned long sg_max = sg->length >> PAGE_SHIFT; -- -- for (; remain && sg_ofs < sg_max; sg_ofs++) { -- unsigned long len = min(remain, PAGE_SIZE - x); -- void *map; -- -- map = kmap_atomic(nth_page(sg_page(sg), sg_ofs)); -- if (needs_clflush) -- drm_clflush_virt_range(map + x, len); -- memcpy(ptr, map + x, len); -- kunmap_atomic(map); -- -- ptr += len; -- remain -= len; -- x = 0; -- } -- -- sg_ofs = 0; -- sg = sg_next(sg); -+ for (n = offset >> PAGE_SHIFT; remain; n++) { -+ int len = min(remain, PAGE_SIZE - x); -+ -+ src = kmap_atomic(i915_gem_object_get_page(src_obj, n)); -+ if (src_needs_clflush) -+ drm_clflush_virt_range(src + x, len); -+ memcpy(ptr, src + x, len); -+ kunmap_atomic(src); -+ -+ ptr += len; -+ remain -= len; -+ x = 0; - } - } - -+ i915_gem_object_finish_access(src_obj); -+ - memset32(dst + length, 0, (dst_obj->base.size - length) / sizeof(u32)); - - /* dst_obj is returned with vmap pinned */ -+ *needs_clflush_after = dst_needs_clflush & CLFLUSH_AFTER; -+ - return dst; - } - -@@ -1360,6 +1376,9 @@ static int check_bbstart(u32 *cmd, u32 offset, u32 length, - if (target_cmd_index == offset) - return 0; - -+ if (IS_ERR(jump_whitelist)) -+ return PTR_ERR(jump_whitelist); -+ - if (!test_bit(target_cmd_index, jump_whitelist)) { - DRM_DEBUG("CMD: BB_START to 0x%llx not a previously executed cmd\n", - jump_target); -@@ -1369,14 +1388,10 @@ static int check_bbstart(u32 *cmd, u32 offset, u32 length, - return 0; - } - --unsigned long *intel_engine_cmd_parser_alloc_jump_whitelist(u32 batch_length, -- bool trampoline) -+static unsigned long *alloc_whitelist(u32 batch_length) - { - unsigned long *jmp; - -- if (trampoline) -- return NULL; -- - /* - * We expect batch_length to be less than 256KiB for known users, - * i.e. we need at most an 8KiB bitmap allocation which should be -@@ -1409,21 +1424,21 @@ unsigned long *intel_engine_cmd_parser_alloc_jump_whitelist(u32 batch_length, - * Return: non-zero if the parser finds violations or otherwise fails; -EACCES - * if the batch appears legal but should use hardware parsing - */ -+ - int intel_engine_cmd_parser(struct intel_engine_cs *engine, - struct i915_vma *batch, - unsigned long batch_offset, - unsigned long batch_length, - struct i915_vma *shadow, -- unsigned long *jump_whitelist, -- void *shadow_map, -- const void *batch_map) -+ bool trampoline) - { - u32 *cmd, *batch_end, offset = 0; - struct drm_i915_cmd_descriptor default_desc = noop_desc; - const struct drm_i915_cmd_descriptor *desc = &default_desc; -+ bool needs_clflush_after = false; -+ unsigned long *jump_whitelist; - u64 batch_addr, shadow_addr; - int ret = 0; -- bool trampoline = !jump_whitelist; - - GEM_BUG_ON(!IS_ALIGNED(batch_offset, sizeof(*cmd))); - GEM_BUG_ON(!IS_ALIGNED(batch_length, sizeof(*cmd))); -@@ -1431,8 +1446,18 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine, - batch->size)); - GEM_BUG_ON(!batch_length); - -- cmd = copy_batch(shadow->obj, batch->obj, batch_offset, batch_length, -- shadow_map, batch_map); -+ cmd = copy_batch(shadow->obj, batch->obj, -+ batch_offset, batch_length, -+ &needs_clflush_after); -+ if (IS_ERR(cmd)) { -+ DRM_DEBUG("CMD: Failed to copy batch\n"); -+ return PTR_ERR(cmd); -+ } -+ -+ jump_whitelist = NULL; -+ if (!trampoline) -+ /* Defer failure until attempted use */ -+ jump_whitelist = alloc_whitelist(batch_length); - - shadow_addr = gen8_canonical_addr(shadow->node.start); - batch_addr = gen8_canonical_addr(batch->node.start + batch_offset); -@@ -1533,6 +1558,9 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine, - - i915_gem_object_flush_map(shadow->obj); - -+ if (!IS_ERR_OR_NULL(jump_whitelist)) -+ kfree(jump_whitelist); -+ i915_gem_object_unpin_map(shadow->obj); - return ret; - } - -diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h -index 69e43bf91a153..4c041e670904e 100644 ---- a/drivers/gpu/drm/i915/i915_drv.h -+++ b/drivers/gpu/drm/i915/i915_drv.h -@@ -1881,17 +1881,12 @@ const char *i915_cache_level_str(struct drm_i915_private *i915, int type); - int i915_cmd_parser_get_version(struct drm_i915_private *dev_priv); - int intel_engine_init_cmd_parser(struct intel_engine_cs *engine); - void intel_engine_cleanup_cmd_parser(struct intel_engine_cs *engine); --unsigned long *intel_engine_cmd_parser_alloc_jump_whitelist(u32 batch_length, -- bool trampoline); -- - int intel_engine_cmd_parser(struct intel_engine_cs *engine, - struct i915_vma *batch, - unsigned long batch_offset, - unsigned long batch_length, - struct i915_vma *shadow, -- unsigned long *jump_whitelist, -- void *shadow_map, -- const void *batch_map); -+ bool trampoline); - #define I915_CMD_PARSER_TRAMPOLINE_SIZE 8 - - /* intel_device_info.c */ -diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c -index bec9c3652188b..59d48a6a83d24 100644 ---- a/drivers/gpu/drm/i915/i915_request.c -+++ b/drivers/gpu/drm/i915/i915_request.c -@@ -1426,10 +1426,8 @@ i915_request_await_execution(struct i915_request *rq, - - do { - fence = *child++; -- if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) { -- i915_sw_fence_set_error_once(&rq->submit, fence->error); -+ if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) - continue; -- } - - if (fence->context == rq->fence.context) - continue; -@@ -1527,10 +1525,8 @@ i915_request_await_dma_fence(struct i915_request *rq, struct dma_fence *fence) - - do { - fence = *child++; -- if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) { -- i915_sw_fence_set_error_once(&rq->submit, fence->error); -+ if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) - continue; -- } - - /* - * Requests on the same timeline are explicitly ordered, along -diff --git a/drivers/net/dsa/sja1105/sja1105_clocking.c b/drivers/net/dsa/sja1105/sja1105_clocking.c -index 2a9b8a6a5306f..f54b4d03a0024 100644 ---- a/drivers/net/dsa/sja1105/sja1105_clocking.c -+++ b/drivers/net/dsa/sja1105/sja1105_clocking.c -@@ -721,9 +721,10 @@ int sja1105_clocking_setup_port(struct sja1105_private *priv, int port) - - int sja1105_clocking_setup(struct sja1105_private *priv) - { -+ struct dsa_switch *ds = priv->ds; - int port, rc; - -- for (port = 0; port < SJA1105_NUM_PORTS; port++) { -+ for (port = 0; port < ds->num_ports; port++) { - rc = sja1105_clocking_setup_port(priv, port); - if (rc < 0) - return rc; -diff --git a/drivers/net/dsa/sja1105/sja1105_flower.c b/drivers/net/dsa/sja1105/sja1105_flower.c -index 973761132fc35..77c54126b3fc8 100644 ---- a/drivers/net/dsa/sja1105/sja1105_flower.c -+++ b/drivers/net/dsa/sja1105/sja1105_flower.c -@@ -35,6 +35,7 @@ static int sja1105_setup_bcast_policer(struct sja1105_private *priv, - { - struct sja1105_rule *rule = sja1105_rule_find(priv, cookie); - struct sja1105_l2_policing_entry *policing; -+ struct dsa_switch *ds = priv->ds; - bool new_rule = false; - unsigned long p; - int rc; -@@ -59,7 +60,7 @@ static int sja1105_setup_bcast_policer(struct sja1105_private *priv, - - policing = priv->static_config.tables[BLK_IDX_L2_POLICING].entries; - -- if (policing[(SJA1105_NUM_PORTS * SJA1105_NUM_TC) + port].sharindx != port) { -+ if (policing[(ds->num_ports * SJA1105_NUM_TC) + port].sharindx != port) { - NL_SET_ERR_MSG_MOD(extack, - "Port already has a broadcast policer"); - rc = -EEXIST; -@@ -72,7 +73,7 @@ static int sja1105_setup_bcast_policer(struct sja1105_private *priv, - * point to the newly allocated policer - */ - for_each_set_bit(p, &rule->port_mask, SJA1105_NUM_PORTS) { -- int bcast = (SJA1105_NUM_PORTS * SJA1105_NUM_TC) + p; -+ int bcast = (ds->num_ports * SJA1105_NUM_TC) + p; - - policing[bcast].sharindx = rule->bcast_pol.sharindx; - } -@@ -435,7 +436,7 @@ int sja1105_cls_flower_del(struct dsa_switch *ds, int port, - policing = priv->static_config.tables[BLK_IDX_L2_POLICING].entries; - - if (rule->type == SJA1105_RULE_BCAST_POLICER) { -- int bcast = (SJA1105_NUM_PORTS * SJA1105_NUM_TC) + port; -+ int bcast = (ds->num_ports * SJA1105_NUM_TC) + port; - - old_sharindx = policing[bcast].sharindx; - policing[bcast].sharindx = port; -@@ -486,7 +487,7 @@ void sja1105_flower_setup(struct dsa_switch *ds) - - INIT_LIST_HEAD(&priv->flow_block.rules); - -- for (port = 0; port < SJA1105_NUM_PORTS; port++) -+ for (port = 0; port < ds->num_ports; port++) - priv->flow_block.l2_policer_used[port] = true; - } - -diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c -index 6e5dbe9f3892e..5b7947832b877 100644 ---- a/drivers/net/dsa/sja1105/sja1105_main.c -+++ b/drivers/net/dsa/sja1105/sja1105_main.c -@@ -107,6 +107,7 @@ static int sja1105_init_mac_settings(struct sja1105_private *priv) - .ingress = false, - }; - struct sja1105_mac_config_entry *mac; -+ struct dsa_switch *ds = priv->ds; - struct sja1105_table *table; - int i; - -@@ -118,25 +119,23 @@ static int sja1105_init_mac_settings(struct sja1105_private *priv) - table->entry_count = 0; - } - -- table->entries = kcalloc(SJA1105_NUM_PORTS, -+ table->entries = kcalloc(ds->num_ports, - table->ops->unpacked_entry_size, GFP_KERNEL); - if (!table->entries) - return -ENOMEM; - -- table->entry_count = SJA1105_NUM_PORTS; -+ table->entry_count = ds->num_ports; - - mac = table->entries; - -- for (i = 0; i < SJA1105_NUM_PORTS; i++) { -+ for (i = 0; i < ds->num_ports; i++) { - mac[i] = default_mac; -- if (i == dsa_upstream_port(priv->ds, i)) { -- /* STP doesn't get called for CPU port, so we need to -- * set the I/O parameters statically. -- */ -- mac[i].dyn_learn = true; -- mac[i].ingress = true; -- mac[i].egress = true; -- } -+ -+ /* Let sja1105_bridge_stp_state_set() keep address learning -+ * enabled for the CPU port. -+ */ -+ if (dsa_is_cpu_port(ds, i)) -+ priv->learn_ena |= BIT(i); - } - - return 0; -@@ -162,6 +161,7 @@ static int sja1105_init_mii_settings(struct sja1105_private *priv, - { - struct device *dev = &priv->spidev->dev; - struct sja1105_xmii_params_entry *mii; -+ struct dsa_switch *ds = priv->ds; - struct sja1105_table *table; - int i; - -@@ -183,7 +183,7 @@ static int sja1105_init_mii_settings(struct sja1105_private *priv, - - mii = table->entries; - -- for (i = 0; i < SJA1105_NUM_PORTS; i++) { -+ for (i = 0; i < ds->num_ports; i++) { - if (dsa_is_unused_port(priv->ds, i)) - continue; - -@@ -267,8 +267,6 @@ static int sja1105_init_static_fdb(struct sja1105_private *priv) - - static int sja1105_init_l2_lookup_params(struct sja1105_private *priv) - { -- struct sja1105_table *table; -- u64 max_fdb_entries = SJA1105_MAX_L2_LOOKUP_COUNT / SJA1105_NUM_PORTS; - struct sja1105_l2_lookup_params_entry default_l2_lookup_params = { - /* Learned FDB entries are forgotten after 300 seconds */ - .maxage = SJA1105_AGEING_TIME_MS(300000), -@@ -276,8 +274,6 @@ static int sja1105_init_l2_lookup_params(struct sja1105_private *priv) - .dyn_tbsz = SJA1105ET_FDB_BIN_SIZE, - /* And the P/Q/R/S equivalent setting: */ - .start_dynspc = 0, -- .maxaddrp = {max_fdb_entries, max_fdb_entries, max_fdb_entries, -- max_fdb_entries, max_fdb_entries, }, - /* 2^8 + 2^5 + 2^3 + 2^2 + 2^1 + 1 in Koopman notation */ - .poly = 0x97, - /* This selects between Independent VLAN Learning (IVL) and -@@ -301,6 +297,15 @@ static int sja1105_init_l2_lookup_params(struct sja1105_private *priv) - .owr_dyn = true, - .drpnolearn = true, - }; -+ struct dsa_switch *ds = priv->ds; -+ struct sja1105_table *table; -+ u64 max_fdb_entries; -+ int port; -+ -+ max_fdb_entries = SJA1105_MAX_L2_LOOKUP_COUNT / ds->num_ports; -+ -+ for (port = 0; port < ds->num_ports; port++) -+ default_l2_lookup_params.maxaddrp[port] = max_fdb_entries; - - table = &priv->static_config.tables[BLK_IDX_L2_LOOKUP_PARAMS]; - -@@ -393,6 +398,7 @@ static int sja1105_init_static_vlan(struct sja1105_private *priv) - static int sja1105_init_l2_forwarding(struct sja1105_private *priv) - { - struct sja1105_l2_forwarding_entry *l2fwd; -+ struct dsa_switch *ds = priv->ds; - struct sja1105_table *table; - int i, j; - -@@ -413,7 +419,7 @@ static int sja1105_init_l2_forwarding(struct sja1105_private *priv) - l2fwd = table->entries; - - /* First 5 entries define the forwarding rules */ -- for (i = 0; i < SJA1105_NUM_PORTS; i++) { -+ for (i = 0; i < ds->num_ports; i++) { - unsigned int upstream = dsa_upstream_port(priv->ds, i); - - for (j = 0; j < SJA1105_NUM_TC; j++) -@@ -441,8 +447,8 @@ static int sja1105_init_l2_forwarding(struct sja1105_private *priv) - * Create a one-to-one mapping. - */ - for (i = 0; i < SJA1105_NUM_TC; i++) -- for (j = 0; j < SJA1105_NUM_PORTS; j++) -- l2fwd[SJA1105_NUM_PORTS + i].vlan_pmap[j] = i; -+ for (j = 0; j < ds->num_ports; j++) -+ l2fwd[ds->num_ports + i].vlan_pmap[j] = i; - - return 0; - } -@@ -538,7 +544,7 @@ static int sja1105_init_general_params(struct sja1105_private *priv) - */ - .host_port = dsa_upstream_port(priv->ds, 0), - /* Default to an invalid value */ -- .mirr_port = SJA1105_NUM_PORTS, -+ .mirr_port = priv->ds->num_ports, - /* Link-local traffic received on casc_port will be forwarded - * to host_port without embedding the source port and device ID - * info in the destination MAC address (presumably because it -@@ -546,7 +552,7 @@ static int sja1105_init_general_params(struct sja1105_private *priv) - * that). Default to an invalid port (to disable the feature) - * and overwrite this if we find any DSA (cascaded) ports. - */ -- .casc_port = SJA1105_NUM_PORTS, -+ .casc_port = priv->ds->num_ports, - /* No TTEthernet */ - .vllupformat = SJA1105_VL_FORMAT_PSFP, - .vlmarker = 0, -@@ -667,6 +673,7 @@ static int sja1105_init_avb_params(struct sja1105_private *priv) - static int sja1105_init_l2_policing(struct sja1105_private *priv) - { - struct sja1105_l2_policing_entry *policing; -+ struct dsa_switch *ds = priv->ds; - struct sja1105_table *table; - int port, tc; - -@@ -688,8 +695,8 @@ static int sja1105_init_l2_policing(struct sja1105_private *priv) - policing = table->entries; - - /* Setup shared indices for the matchall policers */ -- for (port = 0; port < SJA1105_NUM_PORTS; port++) { -- int bcast = (SJA1105_NUM_PORTS * SJA1105_NUM_TC) + port; -+ for (port = 0; port < ds->num_ports; port++) { -+ int bcast = (ds->num_ports * SJA1105_NUM_TC) + port; - - for (tc = 0; tc < SJA1105_NUM_TC; tc++) - policing[port * SJA1105_NUM_TC + tc].sharindx = port; -@@ -698,7 +705,7 @@ static int sja1105_init_l2_policing(struct sja1105_private *priv) - } - - /* Setup the matchall policer parameters */ -- for (port = 0; port < SJA1105_NUM_PORTS; port++) { -+ for (port = 0; port < ds->num_ports; port++) { - int mtu = VLAN_ETH_FRAME_LEN + ETH_FCS_LEN; - - if (dsa_is_cpu_port(priv->ds, port)) -@@ -764,9 +771,10 @@ static int sja1105_static_config_load(struct sja1105_private *priv, - static int sja1105_parse_rgmii_delays(struct sja1105_private *priv, - const struct sja1105_dt_port *ports) - { -+ struct dsa_switch *ds = priv->ds; - int i; - -- for (i = 0; i < SJA1105_NUM_PORTS; i++) { -+ for (i = 0; i < ds->num_ports; i++) { - if (ports[i].role == XMII_MAC) - continue; - -@@ -1641,7 +1649,7 @@ static int sja1105_bridge_member(struct dsa_switch *ds, int port, - - l2_fwd = priv->static_config.tables[BLK_IDX_L2_FORWARDING].entries; - -- for (i = 0; i < SJA1105_NUM_PORTS; i++) { -+ for (i = 0; i < ds->num_ports; i++) { - /* Add this port to the forwarding matrix of the - * other ports in the same bridge, and viceversa. - */ -@@ -1863,7 +1871,7 @@ int sja1105_static_config_reload(struct sja1105_private *priv, - * switch wants to see in the static config in order to allow us to - * change it through the dynamic interface later. - */ -- for (i = 0; i < SJA1105_NUM_PORTS; i++) { -+ for (i = 0; i < ds->num_ports; i++) { - speed_mbps[i] = sja1105_speed[mac[i].speed]; - mac[i].speed = SJA1105_SPEED_AUTO; - } -@@ -1915,7 +1923,7 @@ out_unlock_ptp: - if (rc < 0) - goto out; - -- for (i = 0; i < SJA1105_NUM_PORTS; i++) { -+ for (i = 0; i < ds->num_ports; i++) { - rc = sja1105_adjust_port_config(priv, i, speed_mbps[i]); - if (rc < 0) - goto out; -@@ -3055,7 +3063,7 @@ static void sja1105_teardown(struct dsa_switch *ds) - struct sja1105_bridge_vlan *v, *n; - int port; - -- for (port = 0; port < SJA1105_NUM_PORTS; port++) { -+ for (port = 0; port < ds->num_ports; port++) { - struct sja1105_port *sp = &priv->ports[port]; - - if (!dsa_is_user_port(ds, port)) -@@ -3258,6 +3266,7 @@ static int sja1105_mirror_apply(struct sja1105_private *priv, int from, int to, - { - struct sja1105_general_params_entry *general_params; - struct sja1105_mac_config_entry *mac; -+ struct dsa_switch *ds = priv->ds; - struct sja1105_table *table; - bool already_enabled; - u64 new_mirr_port; -@@ -3268,7 +3277,7 @@ static int sja1105_mirror_apply(struct sja1105_private *priv, int from, int to, - - mac = priv->static_config.tables[BLK_IDX_MAC_CONFIG].entries; - -- already_enabled = (general_params->mirr_port != SJA1105_NUM_PORTS); -+ already_enabled = (general_params->mirr_port != ds->num_ports); - if (already_enabled && enabled && general_params->mirr_port != to) { - dev_err(priv->ds->dev, - "Delete mirroring rules towards port %llu first\n", -@@ -3282,7 +3291,7 @@ static int sja1105_mirror_apply(struct sja1105_private *priv, int from, int to, - int port; - - /* Anybody still referencing mirr_port? */ -- for (port = 0; port < SJA1105_NUM_PORTS; port++) { -+ for (port = 0; port < ds->num_ports; port++) { - if (mac[port].ing_mirr || mac[port].egr_mirr) { - keep = true; - break; -@@ -3290,7 +3299,7 @@ static int sja1105_mirror_apply(struct sja1105_private *priv, int from, int to, - } - /* Unset already_enabled for next time */ - if (!keep) -- new_mirr_port = SJA1105_NUM_PORTS; -+ new_mirr_port = ds->num_ports; - } - if (new_mirr_port != general_params->mirr_port) { - general_params->mirr_port = new_mirr_port; -@@ -3686,7 +3695,7 @@ static int sja1105_probe(struct spi_device *spi) - } - - /* Connections between dsa_port and sja1105_port */ -- for (port = 0; port < SJA1105_NUM_PORTS; port++) { -+ for (port = 0; port < ds->num_ports; port++) { - struct sja1105_port *sp = &priv->ports[port]; - struct dsa_port *dp = dsa_to_port(ds, port); - struct net_device *slave; -diff --git a/drivers/net/dsa/sja1105/sja1105_spi.c b/drivers/net/dsa/sja1105/sja1105_spi.c -index f7a1514f81e8d..923d617cbec69 100644 ---- a/drivers/net/dsa/sja1105/sja1105_spi.c -+++ b/drivers/net/dsa/sja1105/sja1105_spi.c -@@ -339,10 +339,10 @@ int static_config_buf_prepare_for_upload(struct sja1105_private *priv, - - int sja1105_static_config_upload(struct sja1105_private *priv) - { -- unsigned long port_bitmap = GENMASK_ULL(SJA1105_NUM_PORTS - 1, 0); - struct sja1105_static_config *config = &priv->static_config; - const struct sja1105_regs *regs = priv->info->regs; - struct device *dev = &priv->spidev->dev; -+ struct dsa_switch *ds = priv->ds; - struct sja1105_status status; - int rc, retries = RETRIES; - u8 *config_buf; -@@ -363,7 +363,7 @@ int sja1105_static_config_upload(struct sja1105_private *priv) - * Tx on all ports and waiting for current packet to drain. - * Otherwise, the PHY will see an unterminated Ethernet packet. - */ -- rc = sja1105_inhibit_tx(priv, port_bitmap, true); -+ rc = sja1105_inhibit_tx(priv, GENMASK_ULL(ds->num_ports - 1, 0), true); - if (rc < 0) { - dev_err(dev, "Failed to inhibit Tx on ports\n"); - rc = -ENXIO; -diff --git a/drivers/net/dsa/sja1105/sja1105_tas.c b/drivers/net/dsa/sja1105/sja1105_tas.c -index 31d8acff1f012..e6153848a9509 100644 ---- a/drivers/net/dsa/sja1105/sja1105_tas.c -+++ b/drivers/net/dsa/sja1105/sja1105_tas.c -@@ -27,7 +27,7 @@ static int sja1105_tas_set_runtime_params(struct sja1105_private *priv) - - tas_data->enabled = false; - -- for (port = 0; port < SJA1105_NUM_PORTS; port++) { -+ for (port = 0; port < ds->num_ports; port++) { - const struct tc_taprio_qopt_offload *offload; - - offload = tas_data->offload[port]; -@@ -164,6 +164,7 @@ int sja1105_init_scheduling(struct sja1105_private *priv) - struct sja1105_tas_data *tas_data = &priv->tas_data; - struct sja1105_gating_config *gating_cfg = &tas_data->gating_cfg; - struct sja1105_schedule_entry *schedule; -+ struct dsa_switch *ds = priv->ds; - struct sja1105_table *table; - int schedule_start_idx; - s64 entry_point_delta; -@@ -207,7 +208,7 @@ int sja1105_init_scheduling(struct sja1105_private *priv) - } - - /* Figure out the dimensioning of the problem */ -- for (port = 0; port < SJA1105_NUM_PORTS; port++) { -+ for (port = 0; port < ds->num_ports; port++) { - if (tas_data->offload[port]) { - num_entries += tas_data->offload[port]->num_entries; - num_cycles++; -@@ -269,7 +270,7 @@ int sja1105_init_scheduling(struct sja1105_private *priv) - schedule_entry_points_params->clksrc = SJA1105_TAS_CLKSRC_PTP; - schedule_entry_points_params->actsubsch = num_cycles - 1; - -- for (port = 0; port < SJA1105_NUM_PORTS; port++) { -+ for (port = 0; port < ds->num_ports; port++) { - const struct tc_taprio_qopt_offload *offload; - /* Relative base time */ - s64 rbt; -@@ -468,6 +469,7 @@ bool sja1105_gating_check_conflicts(struct sja1105_private *priv, int port, - struct sja1105_gating_config *gating_cfg = &priv->tas_data.gating_cfg; - size_t num_entries = gating_cfg->num_entries; - struct tc_taprio_qopt_offload *dummy; -+ struct dsa_switch *ds = priv->ds; - struct sja1105_gate_entry *e; - bool conflict; - int i = 0; -@@ -491,7 +493,7 @@ bool sja1105_gating_check_conflicts(struct sja1105_private *priv, int port, - if (port != -1) { - conflict = sja1105_tas_check_conflicts(priv, port, dummy); - } else { -- for (port = 0; port < SJA1105_NUM_PORTS; port++) { -+ for (port = 0; port < ds->num_ports; port++) { - conflict = sja1105_tas_check_conflicts(priv, port, - dummy); - if (conflict) -@@ -554,7 +556,7 @@ int sja1105_setup_tc_taprio(struct dsa_switch *ds, int port, - } - } - -- for (other_port = 0; other_port < SJA1105_NUM_PORTS; other_port++) { -+ for (other_port = 0; other_port < ds->num_ports; other_port++) { - if (other_port == port) - continue; - -@@ -885,7 +887,7 @@ void sja1105_tas_teardown(struct dsa_switch *ds) - - cancel_work_sync(&priv->tas_data.tas_work); - -- for (port = 0; port < SJA1105_NUM_PORTS; port++) { -+ for (port = 0; port < ds->num_ports; port++) { - offload = priv->tas_data.offload[port]; - if (!offload) - continue; -diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.c b/drivers/net/ethernet/qlogic/qed/qed_mcp.c -index cd882c4533942..caeef25c89bb1 100644 ---- a/drivers/net/ethernet/qlogic/qed/qed_mcp.c -+++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.c -@@ -474,14 +474,18 @@ _qed_mcp_cmd_and_union(struct qed_hwfn *p_hwfn, - - spin_lock_bh(&p_hwfn->mcp_info->cmd_lock); - -- if (!qed_mcp_has_pending_cmd(p_hwfn)) -+ if (!qed_mcp_has_pending_cmd(p_hwfn)) { -+ spin_unlock_bh(&p_hwfn->mcp_info->cmd_lock); - break; -+ } - - rc = qed_mcp_update_pending_cmd(p_hwfn, p_ptt); -- if (!rc) -+ if (!rc) { -+ spin_unlock_bh(&p_hwfn->mcp_info->cmd_lock); - break; -- else if (rc != -EAGAIN) -+ } else if (rc != -EAGAIN) { - goto err; -+ } - - spin_unlock_bh(&p_hwfn->mcp_info->cmd_lock); - -@@ -498,6 +502,8 @@ _qed_mcp_cmd_and_union(struct qed_hwfn *p_hwfn, - return -EAGAIN; - } - -+ spin_lock_bh(&p_hwfn->mcp_info->cmd_lock); -+ - /* Send the mailbox command */ - qed_mcp_reread_offsets(p_hwfn, p_ptt); - seq_num = ++p_hwfn->mcp_info->drv_mb_seq; -@@ -524,14 +530,18 @@ _qed_mcp_cmd_and_union(struct qed_hwfn *p_hwfn, - - spin_lock_bh(&p_hwfn->mcp_info->cmd_lock); - -- if (p_cmd_elem->b_is_completed) -+ if (p_cmd_elem->b_is_completed) { -+ spin_unlock_bh(&p_hwfn->mcp_info->cmd_lock); - break; -+ } - - rc = qed_mcp_update_pending_cmd(p_hwfn, p_ptt); -- if (!rc) -+ if (!rc) { -+ spin_unlock_bh(&p_hwfn->mcp_info->cmd_lock); - break; -- else if (rc != -EAGAIN) -+ } else if (rc != -EAGAIN) { - goto err; -+ } - - spin_unlock_bh(&p_hwfn->mcp_info->cmd_lock); - } while (++cnt < max_retries); -@@ -554,6 +564,7 @@ _qed_mcp_cmd_and_union(struct qed_hwfn *p_hwfn, - return -EAGAIN; - } - -+ spin_lock_bh(&p_hwfn->mcp_info->cmd_lock); - qed_mcp_cmd_del_elem(p_hwfn, p_cmd_elem); - spin_unlock_bh(&p_hwfn->mcp_info->cmd_lock); - -diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c -index e25bfb7021ed4..2cf763b4ea84f 100644 ---- a/drivers/net/usb/r8152.c -+++ b/drivers/net/usb/r8152.c -@@ -1550,7 +1550,8 @@ static int - rtl8152_set_speed(struct r8152 *tp, u8 autoneg, u32 speed, u8 duplex, - u32 advertising); - --static int rtl8152_set_mac_address(struct net_device *netdev, void *p) -+static int __rtl8152_set_mac_address(struct net_device *netdev, void *p, -+ bool in_resume) - { - struct r8152 *tp = netdev_priv(netdev); - struct sockaddr *addr = p; -@@ -1559,9 +1560,11 @@ static int rtl8152_set_mac_address(struct net_device *netdev, void *p) - if (!is_valid_ether_addr(addr->sa_data)) - goto out1; - -- ret = usb_autopm_get_interface(tp->intf); -- if (ret < 0) -- goto out1; -+ if (!in_resume) { -+ ret = usb_autopm_get_interface(tp->intf); -+ if (ret < 0) -+ goto out1; -+ } - - mutex_lock(&tp->control); - -@@ -1573,11 +1576,17 @@ static int rtl8152_set_mac_address(struct net_device *netdev, void *p) - - mutex_unlock(&tp->control); - -- usb_autopm_put_interface(tp->intf); -+ if (!in_resume) -+ usb_autopm_put_interface(tp->intf); - out1: - return ret; - } - -+static int rtl8152_set_mac_address(struct net_device *netdev, void *p) -+{ -+ return __rtl8152_set_mac_address(netdev, p, false); -+} -+ - /* Devices containing proper chips can support a persistent - * host system provided MAC address. - * Examples of this are Dell TB15 and Dell WD15 docks -@@ -1696,7 +1705,7 @@ static int determine_ethernet_addr(struct r8152 *tp, struct sockaddr *sa) - return ret; - } - --static int set_ethernet_addr(struct r8152 *tp) -+static int set_ethernet_addr(struct r8152 *tp, bool in_resume) - { - struct net_device *dev = tp->netdev; - struct sockaddr sa; -@@ -1709,7 +1718,7 @@ static int set_ethernet_addr(struct r8152 *tp) - if (tp->version == RTL_VER_01) - ether_addr_copy(dev->dev_addr, sa.sa_data); - else -- ret = rtl8152_set_mac_address(dev, &sa); -+ ret = __rtl8152_set_mac_address(dev, &sa, in_resume); - - return ret; - } -@@ -6761,9 +6770,10 @@ static int rtl8152_close(struct net_device *netdev) - tp->rtl_ops.down(tp); - - mutex_unlock(&tp->control); -+ } - -+ if (!res) - usb_autopm_put_interface(tp->intf); -- } - - free_all_mem(tp); - -@@ -8441,7 +8451,7 @@ static int rtl8152_reset_resume(struct usb_interface *intf) - clear_bit(SELECTIVE_SUSPEND, &tp->flags); - tp->rtl_ops.init(tp); - queue_delayed_work(system_long_wq, &tp->hw_phy_work, 0); -- set_ethernet_addr(tp); -+ set_ethernet_addr(tp, true); - return rtl8152_resume(intf); - } - -@@ -9561,7 +9571,7 @@ static int rtl8152_probe(struct usb_interface *intf, - tp->rtl_fw.retry = true; - #endif - queue_delayed_work(system_long_wq, &tp->hw_phy_work, 0); -- set_ethernet_addr(tp); -+ set_ethernet_addr(tp, false); - - usb_set_intfdata(intf, tp); - -diff --git a/drivers/nvme/host/trace.h b/drivers/nvme/host/trace.h -index daaf700eae799..35bac7a254227 100644 ---- a/drivers/nvme/host/trace.h -+++ b/drivers/nvme/host/trace.h -@@ -56,7 +56,7 @@ TRACE_EVENT(nvme_setup_cmd, - __field(u8, fctype) - __field(u16, cid) - __field(u32, nsid) -- __field(u64, metadata) -+ __field(bool, metadata) - __array(u8, cdw10, 24) - ), - TP_fast_assign( -@@ -66,13 +66,13 @@ TRACE_EVENT(nvme_setup_cmd, - __entry->flags = cmd->common.flags; - __entry->cid = cmd->common.command_id; - __entry->nsid = le32_to_cpu(cmd->common.nsid); -- __entry->metadata = le64_to_cpu(cmd->common.metadata); -+ __entry->metadata = !!blk_integrity_rq(req); - __entry->fctype = cmd->fabrics.fctype; - __assign_disk_name(__entry->disk, req->rq_disk); - memcpy(__entry->cdw10, &cmd->common.cdw10, - sizeof(__entry->cdw10)); - ), -- TP_printk("nvme%d: %sqid=%d, cmdid=%u, nsid=%u, flags=0x%x, meta=0x%llx, cmd=(%s %s)", -+ TP_printk("nvme%d: %sqid=%d, cmdid=%u, nsid=%u, flags=0x%x, meta=0x%x, cmd=(%s %s)", - __entry->ctrl_id, __print_disk_name(__entry->disk), - __entry->qid, __entry->cid, __entry->nsid, - __entry->flags, __entry->metadata, -diff --git a/drivers/power/supply/ab8500_btemp.c b/drivers/power/supply/ab8500_btemp.c -index 4df305c767c5c..dbdcff32f3539 100644 ---- a/drivers/power/supply/ab8500_btemp.c -+++ b/drivers/power/supply/ab8500_btemp.c -@@ -983,7 +983,6 @@ static const struct component_ops ab8500_btemp_component_ops = { - - static int ab8500_btemp_probe(struct platform_device *pdev) - { -- struct device_node *np = pdev->dev.of_node; - struct power_supply_config psy_cfg = {}; - struct device *dev = &pdev->dev; - struct ab8500_btemp *di; -@@ -996,12 +995,6 @@ static int ab8500_btemp_probe(struct platform_device *pdev) - - di->bm = &ab8500_bm_data; - -- ret = ab8500_bm_of_probe(dev, np, di->bm); -- if (ret) { -- dev_err(dev, "failed to get battery information\n"); -- return ret; -- } -- - /* get parent data */ - di->dev = dev; - di->parent = dev_get_drvdata(pdev->dev.parent); -diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c -index 46c718e9ebb7c..146a5f03818f2 100644 ---- a/drivers/power/supply/ab8500_fg.c -+++ b/drivers/power/supply/ab8500_fg.c -@@ -3058,12 +3058,6 @@ static int ab8500_fg_probe(struct platform_device *pdev) - - di->bm = &ab8500_bm_data; - -- ret = ab8500_bm_of_probe(dev, np, di->bm); -- if (ret) { -- dev_err(dev, "failed to get battery information\n"); -- return ret; -- } -- - mutex_init(&di->cc_lock); - - /* get parent data */ -diff --git a/drivers/power/supply/abx500_chargalg.c b/drivers/power/supply/abx500_chargalg.c -index 599684ce0e4b0..a17849bfacbff 100644 ---- a/drivers/power/supply/abx500_chargalg.c -+++ b/drivers/power/supply/abx500_chargalg.c -@@ -2002,7 +2002,6 @@ static const struct component_ops abx500_chargalg_component_ops = { - static int abx500_chargalg_probe(struct platform_device *pdev) - { - struct device *dev = &pdev->dev; -- struct device_node *np = dev->of_node; - struct power_supply_config psy_cfg = {}; - struct abx500_chargalg *di; - int ret = 0; -@@ -2013,12 +2012,6 @@ static int abx500_chargalg_probe(struct platform_device *pdev) - - di->bm = &ab8500_bm_data; - -- ret = ab8500_bm_of_probe(dev, np, di->bm); -- if (ret) { -- dev_err(dev, "failed to get battery information\n"); -- return ret; -- } -- - /* get device struct and parent */ - di->dev = dev; - di->parent = dev_get_drvdata(pdev->dev.parent); -diff --git a/drivers/regulator/mtk-dvfsrc-regulator.c b/drivers/regulator/mtk-dvfsrc-regulator.c -index d3d876198d6ec..234af3a66c77d 100644 ---- a/drivers/regulator/mtk-dvfsrc-regulator.c -+++ b/drivers/regulator/mtk-dvfsrc-regulator.c -@@ -179,8 +179,7 @@ static int dvfsrc_vcore_regulator_probe(struct platform_device *pdev) - for (i = 0; i < regulator_init_data->size; i++) { - config.dev = dev->parent; - config.driver_data = (mt_regulators + i); -- rdev = devm_regulator_register(dev->parent, -- &(mt_regulators + i)->desc, -+ rdev = devm_regulator_register(dev, &(mt_regulators + i)->desc, - &config); - if (IS_ERR(rdev)) { - dev_err(dev, "failed to register %s\n", -diff --git a/drivers/regulator/rtmv20-regulator.c b/drivers/regulator/rtmv20-regulator.c -index 4bca64de0f672..2ee334174e2b0 100644 ---- a/drivers/regulator/rtmv20-regulator.c -+++ b/drivers/regulator/rtmv20-regulator.c -@@ -37,7 +37,7 @@ - #define RTMV20_WIDTH2_MASK GENMASK(7, 0) - #define RTMV20_LBPLVL_MASK GENMASK(3, 0) - #define RTMV20_LBPEN_MASK BIT(7) --#define RTMV20_STROBEPOL_MASK BIT(1) -+#define RTMV20_STROBEPOL_MASK BIT(0) - #define RTMV20_VSYNPOL_MASK BIT(1) - #define RTMV20_FSINEN_MASK BIT(7) - #define RTMV20_ESEN_MASK BIT(6) -diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c -index 8d5fa7f1e5069..03510a744fa18 100644 ---- a/drivers/spi/spi-mt65xx.c -+++ b/drivers/spi/spi-mt65xx.c -@@ -426,24 +426,15 @@ static int mtk_spi_fifo_transfer(struct spi_master *master, - mtk_spi_prepare_transfer(master, xfer); - mtk_spi_setup_packet(master); - -- cnt = xfer->len / 4; -- if (xfer->tx_buf) -+ if (xfer->tx_buf) { -+ cnt = xfer->len / 4; - iowrite32_rep(mdata->base + SPI_TX_DATA_REG, xfer->tx_buf, cnt); -- -- if (xfer->rx_buf) -- ioread32_rep(mdata->base + SPI_RX_DATA_REG, xfer->rx_buf, cnt); -- -- remainder = xfer->len % 4; -- if (remainder > 0) { -- reg_val = 0; -- if (xfer->tx_buf) { -+ remainder = xfer->len % 4; -+ if (remainder > 0) { -+ reg_val = 0; - memcpy(®_val, xfer->tx_buf + (cnt * 4), remainder); - writel(reg_val, mdata->base + SPI_TX_DATA_REG); - } -- if (xfer->rx_buf) { -- reg_val = readl(mdata->base + SPI_RX_DATA_REG); -- memcpy(xfer->rx_buf + (cnt * 4), ®_val, remainder); -- } - } - - mtk_spi_enable_transfer(master); -diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c -index a92a28933edbb..05618a618939c 100644 ---- a/drivers/spi/spi-stm32.c -+++ b/drivers/spi/spi-stm32.c -@@ -884,15 +884,18 @@ static irqreturn_t stm32h7_spi_irq_thread(int irq, void *dev_id) - ier = readl_relaxed(spi->base + STM32H7_SPI_IER); - - mask = ier; -- /* EOTIE is triggered on EOT, SUSP and TXC events. */ -+ /* -+ * EOTIE enables irq from EOT, SUSP and TXC events. We need to set -+ * SUSP to acknowledge it later. TXC is automatically cleared -+ */ -+ - mask |= STM32H7_SPI_SR_SUSP; - /* -- * When TXTF is set, DXPIE and TXPIE are cleared. So in case of -- * Full-Duplex, need to poll RXP event to know if there are remaining -- * data, before disabling SPI. -+ * DXPIE is set in Full-Duplex, one IT will be raised if TXP and RXP -+ * are set. So in case of Full-Duplex, need to poll TXP and RXP event. - */ -- if (spi->rx_buf && !spi->cur_usedma) -- mask |= STM32H7_SPI_SR_RXP; -+ if ((spi->cur_comm == SPI_FULL_DUPLEX) && !spi->cur_usedma) -+ mask |= STM32H7_SPI_SR_TXP | STM32H7_SPI_SR_RXP; - - if (!(sr & mask)) { - dev_warn(spi->dev, "spurious IT (sr=0x%08x, ier=0x%08x)\n", -diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c -index 3f1324871cfd6..bf31d7b67a697 100644 ---- a/drivers/watchdog/iTCO_wdt.c -+++ b/drivers/watchdog/iTCO_wdt.c -@@ -71,8 +71,6 @@ - #define TCOBASE(p) ((p)->tco_res->start) - /* SMI Control and Enable Register */ - #define SMI_EN(p) ((p)->smi_res->start) --#define TCO_EN (1 << 13) --#define GBL_SMI_EN (1 << 0) - - #define TCO_RLD(p) (TCOBASE(p) + 0x00) /* TCO Timer Reload/Curr. Value */ - #define TCOv1_TMR(p) (TCOBASE(p) + 0x01) /* TCOv1 Timer Initial Value*/ -@@ -357,12 +355,8 @@ static int iTCO_wdt_set_timeout(struct watchdog_device *wd_dev, unsigned int t) - - tmrval = seconds_to_ticks(p, t); - -- /* -- * If TCO SMIs are off, the timer counts down twice before rebooting. -- * Otherwise, the BIOS generally reboots when the SMI triggers. -- */ -- if (p->smi_res && -- (SMI_EN(p) & (TCO_EN | GBL_SMI_EN)) != (TCO_EN | GBL_SMI_EN)) -+ /* For TCO v1 the timer counts down twice before rebooting */ -+ if (p->iTCO_version == 1) - tmrval /= 2; - - /* from the specs: */ -@@ -527,7 +521,7 @@ static int iTCO_wdt_probe(struct platform_device *pdev) - * Disables TCO logic generating an SMI# - */ - val32 = inl(SMI_EN(p)); -- val32 &= ~TCO_EN; /* Turn off SMI clearing watchdog */ -+ val32 &= 0xffffdfff; /* Turn off SMI clearing watchdog */ - outl(val32, SMI_EN(p)); - } - -diff --git a/fs/cifs/fs_context.c b/fs/cifs/fs_context.c -index 92d4ab029c917..72742eb1df4a7 100644 ---- a/fs/cifs/fs_context.c -+++ b/fs/cifs/fs_context.c -@@ -322,7 +322,6 @@ smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx - new_ctx->UNC = NULL; - new_ctx->source = NULL; - new_ctx->iocharset = NULL; -- - /* - * Make sure to stay in sync with smb3_cleanup_fs_context_contents() - */ -@@ -792,6 +791,8 @@ static int smb3_fs_context_parse_param(struct fs_context *fc, - int i, opt; - bool is_smb3 = !strcmp(fc->fs_type->name, "smb3"); - bool skip_parsing = false; -+ kuid_t uid; -+ kgid_t gid; - - cifs_dbg(FYI, "CIFS: parsing cifs mount option '%s'\n", param->key); - -@@ -904,18 +905,38 @@ static int smb3_fs_context_parse_param(struct fs_context *fc, - } - break; - case Opt_uid: -- ctx->linux_uid.val = result.uint_32; -+ uid = make_kuid(current_user_ns(), result.uint_32); -+ if (!uid_valid(uid)) -+ goto cifs_parse_mount_err; -+ ctx->linux_uid = uid; - ctx->uid_specified = true; - break; - case Opt_cruid: -- ctx->cred_uid.val = result.uint_32; -+ uid = make_kuid(current_user_ns(), result.uint_32); -+ if (!uid_valid(uid)) -+ goto cifs_parse_mount_err; -+ ctx->cred_uid = uid; -+ ctx->cruid_specified = true; -+ break; -+ case Opt_backupuid: -+ uid = make_kuid(current_user_ns(), result.uint_32); -+ if (!uid_valid(uid)) -+ goto cifs_parse_mount_err; -+ ctx->backupuid = uid; -+ ctx->backupuid_specified = true; - break; - case Opt_backupgid: -- ctx->backupgid.val = result.uint_32; -+ gid = make_kgid(current_user_ns(), result.uint_32); -+ if (!gid_valid(gid)) -+ goto cifs_parse_mount_err; -+ ctx->backupgid = gid; - ctx->backupgid_specified = true; - break; - case Opt_gid: -- ctx->linux_gid.val = result.uint_32; -+ gid = make_kgid(current_user_ns(), result.uint_32); -+ if (!gid_valid(gid)) -+ goto cifs_parse_mount_err; -+ ctx->linux_gid = gid; - ctx->gid_specified = true; - break; - case Opt_port: -diff --git a/fs/cifs/fs_context.h b/fs/cifs/fs_context.h -index 2a71c8e411ac1..b6243972edf3b 100644 ---- a/fs/cifs/fs_context.h -+++ b/fs/cifs/fs_context.h -@@ -155,6 +155,7 @@ enum cifs_param { - - struct smb3_fs_context { - bool uid_specified; -+ bool cruid_specified; - bool gid_specified; - bool sloppy; - bool got_ip; -diff --git a/fs/io-wq.c b/fs/io-wq.c -index 60f58efdb5f48..9efecdf025b9c 100644 ---- a/fs/io-wq.c -+++ b/fs/io-wq.c -@@ -736,7 +736,12 @@ static void io_wqe_enqueue(struct io_wqe *wqe, struct io_wq_work *work) - int work_flags; - unsigned long flags; - -- if (test_bit(IO_WQ_BIT_EXIT, &wqe->wq->state)) { -+ /* -+ * If io-wq is exiting for this task, or if the request has explicitly -+ * been marked as one that should not get executed, cancel it here. -+ */ -+ if (test_bit(IO_WQ_BIT_EXIT, &wqe->wq->state) || -+ (work->flags & IO_WQ_WORK_CANCEL)) { - io_run_cancel(work, wqe); - return; - } -diff --git a/fs/io_uring.c b/fs/io_uring.c -index d465e99971574..32f3df13a812d 100644 ---- a/fs/io_uring.c -+++ b/fs/io_uring.c -@@ -1282,6 +1282,17 @@ static void io_queue_async_work(struct io_kiocb *req) - - /* init ->work of the whole link before punting */ - io_prep_async_link(req); -+ -+ /* -+ * Not expected to happen, but if we do have a bug where this _can_ -+ * happen, catch it here and ensure the request is marked as -+ * canceled. That will make io-wq go through the usual work cancel -+ * procedure rather than attempt to run this request (or create a new -+ * worker for it). -+ */ -+ if (WARN_ON_ONCE(!same_thread_group(req->task, current))) -+ req->work.flags |= IO_WQ_WORK_CANCEL; -+ - trace_io_uring_queue_async_work(ctx, io_wq_is_hashed(&req->work), req, - &req->work, req->flags); - io_wq_enqueue(tctx->io_wq, &req->work); -@@ -2252,7 +2263,7 @@ static inline bool io_run_task_work(void) - * Find and free completed poll iocbs - */ - static void io_iopoll_complete(struct io_ring_ctx *ctx, unsigned int *nr_events, -- struct list_head *done) -+ struct list_head *done, bool resubmit) - { - struct req_batch rb; - struct io_kiocb *req; -@@ -2267,7 +2278,7 @@ static void io_iopoll_complete(struct io_ring_ctx *ctx, unsigned int *nr_events, - req = list_first_entry(done, struct io_kiocb, inflight_entry); - list_del(&req->inflight_entry); - -- if (READ_ONCE(req->result) == -EAGAIN && -+ if (READ_ONCE(req->result) == -EAGAIN && resubmit && - !(req->flags & REQ_F_DONT_REISSUE)) { - req->iopoll_completed = 0; - req_ref_get(req); -@@ -2291,7 +2302,7 @@ static void io_iopoll_complete(struct io_ring_ctx *ctx, unsigned int *nr_events, - } - - static int io_do_iopoll(struct io_ring_ctx *ctx, unsigned int *nr_events, -- long min) -+ long min, bool resubmit) - { - struct io_kiocb *req, *tmp; - LIST_HEAD(done); -@@ -2334,7 +2345,7 @@ static int io_do_iopoll(struct io_ring_ctx *ctx, unsigned int *nr_events, - } - - if (!list_empty(&done)) -- io_iopoll_complete(ctx, nr_events, &done); -+ io_iopoll_complete(ctx, nr_events, &done, resubmit); - - return ret; - } -@@ -2352,7 +2363,7 @@ static void io_iopoll_try_reap_events(struct io_ring_ctx *ctx) - while (!list_empty(&ctx->iopoll_list)) { - unsigned int nr_events = 0; - -- io_do_iopoll(ctx, &nr_events, 0); -+ io_do_iopoll(ctx, &nr_events, 0, false); - - /* let it sleep and repeat later if can't complete a request */ - if (nr_events == 0) -@@ -2410,7 +2421,7 @@ static int io_iopoll_check(struct io_ring_ctx *ctx, long min) - if (list_empty(&ctx->iopoll_list)) - break; - } -- ret = io_do_iopoll(ctx, &nr_events, min); -+ ret = io_do_iopoll(ctx, &nr_events, min, true); - } while (!ret && nr_events < min && !need_resched()); - out: - mutex_unlock(&ctx->uring_lock); -@@ -6804,7 +6815,7 @@ static int __io_sq_thread(struct io_ring_ctx *ctx, bool cap_entries) - - mutex_lock(&ctx->uring_lock); - if (!list_empty(&ctx->iopoll_list)) -- io_do_iopoll(ctx, &nr_events, 0); -+ io_do_iopoll(ctx, &nr_events, 0, true); - - /* - * Don't submit if refs are dying, good for io_uring_register(), -diff --git a/include/linux/mfd/rt5033-private.h b/include/linux/mfd/rt5033-private.h -index 2d1895c3efbf2..40a0c2dfb80ff 100644 ---- a/include/linux/mfd/rt5033-private.h -+++ b/include/linux/mfd/rt5033-private.h -@@ -200,13 +200,13 @@ enum rt5033_reg { - #define RT5033_REGULATOR_BUCK_VOLTAGE_MIN 1000000U - #define RT5033_REGULATOR_BUCK_VOLTAGE_MAX 3000000U - #define RT5033_REGULATOR_BUCK_VOLTAGE_STEP 100000U --#define RT5033_REGULATOR_BUCK_VOLTAGE_STEP_NUM 32 -+#define RT5033_REGULATOR_BUCK_VOLTAGE_STEP_NUM 21 - - /* RT5033 regulator LDO output voltage uV */ - #define RT5033_REGULATOR_LDO_VOLTAGE_MIN 1200000U - #define RT5033_REGULATOR_LDO_VOLTAGE_MAX 3000000U - #define RT5033_REGULATOR_LDO_VOLTAGE_STEP 100000U --#define RT5033_REGULATOR_LDO_VOLTAGE_STEP_NUM 32 -+#define RT5033_REGULATOR_LDO_VOLTAGE_STEP_NUM 19 - - /* RT5033 regulator SAFE LDO output voltage uV */ - #define RT5033_REGULATOR_SAFE_LDO_VOLTAGE 4900000U -diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c -index ded55f54d9c8e..7d71d104fdfda 100644 ---- a/net/bluetooth/hci_core.c -+++ b/net/bluetooth/hci_core.c -@@ -1721,6 +1721,14 @@ int hci_dev_do_close(struct hci_dev *hdev) - - BT_DBG("%s %p", hdev->name, hdev); - -+ if (!hci_dev_test_flag(hdev, HCI_UNREGISTER) && -+ !hci_dev_test_flag(hdev, HCI_USER_CHANNEL) && -+ test_bit(HCI_UP, &hdev->flags)) { -+ /* Execute vendor specific shutdown routine */ -+ if (hdev->shutdown) -+ hdev->shutdown(hdev); -+ } -+ - cancel_delayed_work(&hdev->power_off); - - hci_request_cancel_all(hdev); -@@ -1797,14 +1805,6 @@ int hci_dev_do_close(struct hci_dev *hdev) - clear_bit(HCI_INIT, &hdev->flags); - } - -- if (!hci_dev_test_flag(hdev, HCI_UNREGISTER) && -- !hci_dev_test_flag(hdev, HCI_USER_CHANNEL) && -- test_bit(HCI_UP, &hdev->flags)) { -- /* Execute vendor specific shutdown routine */ -- if (hdev->shutdown) -- hdev->shutdown(hdev); -- } -- - /* flush cmd work */ - flush_work(&hdev->cmd_work); - -diff --git a/net/core/skbuff.c b/net/core/skbuff.c -index 30ca61d91b69a..17b93177a68f8 100644 ---- a/net/core/skbuff.c -+++ b/net/core/skbuff.c -@@ -3006,8 +3006,11 @@ skb_zerocopy_headlen(const struct sk_buff *from) - - if (!from->head_frag || - skb_headlen(from) < L1_CACHE_BYTES || -- skb_shinfo(from)->nr_frags >= MAX_SKB_FRAGS) -+ skb_shinfo(from)->nr_frags >= MAX_SKB_FRAGS) { - hlen = skb_headlen(from); -+ if (!hlen) -+ hlen = from->len; -+ } - - if (skb_has_frag_list(from)) - hlen = from->len; -diff --git a/net/core/skmsg.c b/net/core/skmsg.c -index 45b3a3adc886f..7e7205e93258b 100644 ---- a/net/core/skmsg.c -+++ b/net/core/skmsg.c -@@ -607,23 +607,48 @@ static int sk_psock_handle_skb(struct sk_psock *psock, struct sk_buff *skb, - return sk_psock_skb_ingress(psock, skb); - } - -+static void sock_drop(struct sock *sk, struct sk_buff *skb) -+{ -+ sk_drops_add(sk, skb); -+ kfree_skb(skb); -+} -+ -+static void sk_psock_skb_state(struct sk_psock *psock, -+ struct sk_psock_work_state *state, -+ struct sk_buff *skb, -+ int len, int off) -+{ -+ spin_lock_bh(&psock->ingress_lock); -+ if (sk_psock_test_state(psock, SK_PSOCK_TX_ENABLED)) { -+ state->skb = skb; -+ state->len = len; -+ state->off = off; -+ } else { -+ sock_drop(psock->sk, skb); -+ } -+ spin_unlock_bh(&psock->ingress_lock); -+} -+ - static void sk_psock_backlog(struct work_struct *work) - { - struct sk_psock *psock = container_of(work, struct sk_psock, work); - struct sk_psock_work_state *state = &psock->work_state; -- struct sk_buff *skb; -+ struct sk_buff *skb = NULL; - bool ingress; - u32 len, off; - int ret; - - mutex_lock(&psock->work_mutex); -- if (state->skb) { -+ if (unlikely(state->skb)) { -+ spin_lock_bh(&psock->ingress_lock); - skb = state->skb; - len = state->len; - off = state->off; - state->skb = NULL; -- goto start; -+ spin_unlock_bh(&psock->ingress_lock); - } -+ if (skb) -+ goto start; - - while ((skb = skb_dequeue(&psock->ingress_skb))) { - len = skb->len; -@@ -638,15 +663,14 @@ start: - len, ingress); - if (ret <= 0) { - if (ret == -EAGAIN) { -- state->skb = skb; -- state->len = len; -- state->off = off; -+ sk_psock_skb_state(psock, state, skb, -+ len, off); - goto end; - } - /* Hard errors break pipe and stop xmit. */ - sk_psock_report_error(psock, ret ? -ret : EPIPE); - sk_psock_clear_state(psock, SK_PSOCK_TX_ENABLED); -- kfree_skb(skb); -+ sock_drop(psock->sk, skb); - goto end; - } - off += ret; -@@ -737,8 +761,13 @@ static void __sk_psock_zap_ingress(struct sk_psock *psock) - - while ((skb = skb_dequeue(&psock->ingress_skb)) != NULL) { - skb_bpf_redirect_clear(skb); -- kfree_skb(skb); -+ sock_drop(psock->sk, skb); - } -+ kfree_skb(psock->work_state.skb); -+ /* We null the skb here to ensure that calls to sk_psock_backlog -+ * do not pick up the free'd skb. -+ */ -+ psock->work_state.skb = NULL; - __sk_psock_purge_ingress_msg(psock); - } - -@@ -853,7 +882,7 @@ out: - } - EXPORT_SYMBOL_GPL(sk_psock_msg_verdict); - --static int sk_psock_skb_redirect(struct sk_buff *skb) -+static int sk_psock_skb_redirect(struct sk_psock *from, struct sk_buff *skb) - { - struct sk_psock *psock_other; - struct sock *sk_other; -@@ -863,7 +892,7 @@ static int sk_psock_skb_redirect(struct sk_buff *skb) - * return code, but then didn't set a redirect interface. - */ - if (unlikely(!sk_other)) { -- kfree_skb(skb); -+ sock_drop(from->sk, skb); - return -EIO; - } - psock_other = sk_psock(sk_other); -@@ -873,14 +902,14 @@ static int sk_psock_skb_redirect(struct sk_buff *skb) - */ - if (!psock_other || sock_flag(sk_other, SOCK_DEAD)) { - skb_bpf_redirect_clear(skb); -- kfree_skb(skb); -+ sock_drop(from->sk, skb); - return -EIO; - } - spin_lock_bh(&psock_other->ingress_lock); - if (!sk_psock_test_state(psock_other, SK_PSOCK_TX_ENABLED)) { - spin_unlock_bh(&psock_other->ingress_lock); - skb_bpf_redirect_clear(skb); -- kfree_skb(skb); -+ sock_drop(from->sk, skb); - return -EIO; - } - -@@ -890,11 +919,12 @@ static int sk_psock_skb_redirect(struct sk_buff *skb) - return 0; - } - --static void sk_psock_tls_verdict_apply(struct sk_buff *skb, struct sock *sk, int verdict) -+static void sk_psock_tls_verdict_apply(struct sk_buff *skb, -+ struct sk_psock *from, int verdict) - { - switch (verdict) { - case __SK_REDIRECT: -- sk_psock_skb_redirect(skb); -+ sk_psock_skb_redirect(from, skb); - break; - case __SK_PASS: - case __SK_DROP: -@@ -918,7 +948,7 @@ int sk_psock_tls_strp_read(struct sk_psock *psock, struct sk_buff *skb) - ret = sk_psock_map_verd(ret, skb_bpf_redirect_fetch(skb)); - skb->sk = NULL; - } -- sk_psock_tls_verdict_apply(skb, psock->sk, ret); -+ sk_psock_tls_verdict_apply(skb, psock, ret); - rcu_read_unlock(); - return ret; - } -@@ -965,12 +995,12 @@ static int sk_psock_verdict_apply(struct sk_psock *psock, struct sk_buff *skb, - } - break; - case __SK_REDIRECT: -- err = sk_psock_skb_redirect(skb); -+ err = sk_psock_skb_redirect(psock, skb); - break; - case __SK_DROP: - default: - out_free: -- kfree_skb(skb); -+ sock_drop(psock->sk, skb); - } - - return err; -@@ -1005,7 +1035,7 @@ static void sk_psock_strp_read(struct strparser *strp, struct sk_buff *skb) - sk = strp->sk; - psock = sk_psock(sk); - if (unlikely(!psock)) { -- kfree_skb(skb); -+ sock_drop(sk, skb); - goto out; - } - prog = READ_ONCE(psock->progs.stream_verdict); -@@ -1126,7 +1156,7 @@ static int sk_psock_verdict_recv(read_descriptor_t *desc, struct sk_buff *skb, - psock = sk_psock(sk); - if (unlikely(!psock)) { - len = 0; -- kfree_skb(skb); -+ sock_drop(sk, skb); - goto out; - } - prog = READ_ONCE(psock->progs.stream_verdict); -diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c -index e4c91571abaef..abcd6f4837888 100644 ---- a/sound/soc/codecs/rt5682.c -+++ b/sound/soc/codecs/rt5682.c -@@ -973,10 +973,14 @@ int rt5682_headset_detect(struct snd_soc_component *component, int jack_insert) - rt5682_enable_push_button_irq(component, false); - snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1, - RT5682_TRIG_JD_MASK, RT5682_TRIG_JD_LOW); -- if (!snd_soc_dapm_get_pin_status(dapm, "MICBIAS")) -+ if (!snd_soc_dapm_get_pin_status(dapm, "MICBIAS") && -+ !snd_soc_dapm_get_pin_status(dapm, "PLL1") && -+ !snd_soc_dapm_get_pin_status(dapm, "PLL2B")) - snd_soc_component_update_bits(component, - RT5682_PWR_ANLG_1, RT5682_PWR_MB, 0); -- if (!snd_soc_dapm_get_pin_status(dapm, "Vref2")) -+ if (!snd_soc_dapm_get_pin_status(dapm, "Vref2") && -+ !snd_soc_dapm_get_pin_status(dapm, "PLL1") && -+ !snd_soc_dapm_get_pin_status(dapm, "PLL2B")) - snd_soc_component_update_bits(component, - RT5682_PWR_ANLG_1, RT5682_PWR_VREF2, 0); - snd_soc_component_update_bits(component, RT5682_PWR_ANLG_3, -diff --git a/sound/soc/codecs/tlv320aic31xx.h b/sound/soc/codecs/tlv320aic31xx.h -index 81952984613d2..2513922a02923 100644 ---- a/sound/soc/codecs/tlv320aic31xx.h -+++ b/sound/soc/codecs/tlv320aic31xx.h -@@ -151,8 +151,8 @@ struct aic31xx_pdata { - #define AIC31XX_WORD_LEN_24BITS 0x02 - #define AIC31XX_WORD_LEN_32BITS 0x03 - #define AIC31XX_IFACE1_MASTER_MASK GENMASK(3, 2) --#define AIC31XX_BCLK_MASTER BIT(2) --#define AIC31XX_WCLK_MASTER BIT(3) -+#define AIC31XX_BCLK_MASTER BIT(3) -+#define AIC31XX_WCLK_MASTER BIT(2) - - /* AIC31XX_DATA_OFFSET */ - #define AIC31XX_DATA_OFFSET_MASK GENMASK(7, 0) -diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig -index 58379393b8e4c..ceeb618bd9508 100644 ---- a/sound/soc/intel/boards/Kconfig -+++ b/sound/soc/intel/boards/Kconfig -@@ -26,6 +26,12 @@ config SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES - interface. - If unsure select N. - -+config SND_SOC_INTEL_HDA_DSP_COMMON -+ tristate -+ -+config SND_SOC_INTEL_SOF_MAXIM_COMMON -+ tristate -+ - if SND_SOC_INTEL_CATPT - - config SND_SOC_INTEL_HASWELL_MACH -@@ -278,6 +284,7 @@ config SND_SOC_INTEL_DA7219_MAX98357A_GENERIC - select SND_SOC_MAX98390 - select SND_SOC_DMIC - select SND_SOC_HDAC_HDMI -+ select SND_SOC_INTEL_HDA_DSP_COMMON - - config SND_SOC_INTEL_BXT_DA7219_MAX98357A_COMMON - tristate -@@ -304,6 +311,7 @@ config SND_SOC_INTEL_BXT_RT298_MACH - select SND_SOC_RT298 - select SND_SOC_DMIC - select SND_SOC_HDAC_HDMI -+ select SND_SOC_INTEL_HDA_DSP_COMMON - help - This adds support for ASoC machine driver for Broxton platforms - with RT286 I2S audio codec. -@@ -422,6 +430,7 @@ config SND_SOC_INTEL_GLK_RT5682_MAX98357A_MACH - select SND_SOC_MAX98357A - select SND_SOC_DMIC - select SND_SOC_HDAC_HDMI -+ select SND_SOC_INTEL_HDA_DSP_COMMON - help - This adds support for ASoC machine driver for Geminilake platforms - with RT5682 + MAX98357A I2S audio codec. -@@ -437,6 +446,7 @@ config SND_SOC_INTEL_SKL_HDA_DSP_GENERIC_MACH - depends on SND_HDA_CODEC_HDMI - depends on GPIOLIB - select SND_SOC_HDAC_HDMI -+ select SND_SOC_INTEL_HDA_DSP_COMMON - select SND_SOC_DMIC - # SND_SOC_HDAC_HDA is already selected - help -@@ -461,6 +471,8 @@ config SND_SOC_INTEL_SOF_RT5682_MACH - select SND_SOC_RT5682_I2C - select SND_SOC_DMIC - select SND_SOC_HDAC_HDMI -+ select SND_SOC_INTEL_HDA_DSP_COMMON -+ select SND_SOC_INTEL_SOF_MAXIM_COMMON - help - This adds support for ASoC machine driver for SOF platforms - with rt5682 codec. -@@ -473,6 +485,7 @@ config SND_SOC_INTEL_SOF_PCM512x_MACH - depends on (SND_SOC_SOF_HDA_AUDIO_CODEC && (MFD_INTEL_LPSS || COMPILE_TEST)) ||\ - (SND_SOC_SOF_BAYTRAIL && (X86_INTEL_LPSS || COMPILE_TEST)) - depends on SND_HDA_CODEC_HDMI -+ select SND_SOC_INTEL_HDA_DSP_COMMON - select SND_SOC_PCM512x_I2C - help - This adds support for ASoC machine driver for SOF platforms -@@ -504,6 +517,7 @@ config SND_SOC_INTEL_SOF_CML_RT1011_RT5682_MACH - select SND_SOC_RT5682_I2C - select SND_SOC_DMIC - select SND_SOC_HDAC_HDMI -+ select SND_SOC_INTEL_HDA_DSP_COMMON - help - This adds support for ASoC machine driver for SOF platform with - RT1011 + RT5682 I2S codec. -@@ -519,6 +533,7 @@ config SND_SOC_INTEL_SOF_DA7219_MAX98373_MACH - depends on I2C && ACPI && GPIOLIB - depends on MFD_INTEL_LPSS || COMPILE_TEST - depends on SND_HDA_CODEC_HDMI && SND_SOC_SOF_HDA_AUDIO_CODEC -+ select SND_SOC_INTEL_HDA_DSP_COMMON - select SND_SOC_DA7219 - select SND_SOC_MAX98373_I2C - select SND_SOC_DMIC -@@ -539,6 +554,7 @@ config SND_SOC_INTEL_EHL_RT5660_MACH - depends on SND_HDA_CODEC_HDMI && SND_SOC_SOF_HDA_AUDIO_CODEC - select SND_SOC_RT5660 - select SND_SOC_DMIC -+ select SND_SOC_INTEL_HDA_DSP_COMMON - help - This adds support for ASoC machine driver for Elkhart Lake - platform with RT5660 I2S audio codec. -@@ -566,6 +582,8 @@ config SND_SOC_INTEL_SOUNDWIRE_SOF_MACH - select SND_SOC_RT715_SDCA_SDW - select SND_SOC_RT5682_SDW - select SND_SOC_DMIC -+ select SND_SOC_INTEL_HDA_DSP_COMMON -+ select SND_SOC_INTEL_SOF_MAXIM_COMMON - help - Add support for Intel SoundWire-based platforms connected to - MAX98373, RT700, RT711, RT1308 and RT715 -diff --git a/sound/soc/intel/boards/Makefile b/sound/soc/intel/boards/Makefile -index 616c5fbab7d5a..855296e8dfb83 100644 ---- a/sound/soc/intel/boards/Makefile -+++ b/sound/soc/intel/boards/Makefile -@@ -3,11 +3,11 @@ snd-soc-sst-haswell-objs := haswell.o - snd-soc-sst-bdw-rt5650-mach-objs := bdw-rt5650.o - snd-soc-sst-bdw-rt5677-mach-objs := bdw-rt5677.o - snd-soc-sst-broadwell-objs := broadwell.o --snd-soc-sst-bxt-da7219_max98357a-objs := bxt_da7219_max98357a.o hda_dsp_common.o --snd-soc-sst-bxt-rt298-objs := bxt_rt298.o hda_dsp_common.o --snd-soc-sst-sof-pcm512x-objs := sof_pcm512x.o hda_dsp_common.o -+snd-soc-sst-bxt-da7219_max98357a-objs := bxt_da7219_max98357a.o -+snd-soc-sst-bxt-rt298-objs := bxt_rt298.o -+snd-soc-sst-sof-pcm512x-objs := sof_pcm512x.o - snd-soc-sst-sof-wm8804-objs := sof_wm8804.o --snd-soc-sst-glk-rt5682_max98357a-objs := glk_rt5682_max98357a.o hda_dsp_common.o -+snd-soc-sst-glk-rt5682_max98357a-objs := glk_rt5682_max98357a.o - snd-soc-sst-bytcr-rt5640-objs := bytcr_rt5640.o - snd-soc-sst-bytcr-rt5651-objs := bytcr_rt5651.o - snd-soc-sst-bytcr-wm5102-objs := bytcr_wm5102.o -@@ -19,27 +19,26 @@ snd-soc-sst-byt-cht-cx2072x-objs := bytcht_cx2072x.o - snd-soc-sst-byt-cht-da7213-objs := bytcht_da7213.o - snd-soc-sst-byt-cht-es8316-objs := bytcht_es8316.o - snd-soc-sst-byt-cht-nocodec-objs := bytcht_nocodec.o --snd-soc-sof_rt5682-objs := sof_rt5682.o hda_dsp_common.o sof_maxim_common.o sof_realtek_common.o --snd-soc-cml_rt1011_rt5682-objs := cml_rt1011_rt5682.o hda_dsp_common.o -+snd-soc-sof_rt5682-objs := sof_rt5682.o sof_realtek_common.o -+snd-soc-cml_rt1011_rt5682-objs := cml_rt1011_rt5682.o - snd-soc-kbl_da7219_max98357a-objs := kbl_da7219_max98357a.o - snd-soc-kbl_da7219_max98927-objs := kbl_da7219_max98927.o - snd-soc-kbl_rt5663_max98927-objs := kbl_rt5663_max98927.o - snd-soc-kbl_rt5663_rt5514_max98927-objs := kbl_rt5663_rt5514_max98927.o - snd-soc-kbl_rt5660-objs := kbl_rt5660.o - snd-soc-skl_rt286-objs := skl_rt286.o --snd-soc-skl_hda_dsp-objs := skl_hda_dsp_generic.o skl_hda_dsp_common.o hda_dsp_common.o -+snd-soc-skl_hda_dsp-objs := skl_hda_dsp_generic.o skl_hda_dsp_common.o - snd-skl_nau88l25_max98357a-objs := skl_nau88l25_max98357a.o - snd-soc-skl_nau88l25_ssm4567-objs := skl_nau88l25_ssm4567.o --snd-soc-sof_da7219_max98373-objs := sof_da7219_max98373.o hda_dsp_common.o --snd-soc-ehl-rt5660-objs := ehl_rt5660.o hda_dsp_common.o -+snd-soc-sof_da7219_max98373-objs := sof_da7219_max98373.o -+snd-soc-ehl-rt5660-objs := ehl_rt5660.o - snd-soc-sof-sdw-objs += sof_sdw.o \ - sof_sdw_max98373.o \ - sof_sdw_rt1308.o sof_sdw_rt1316.o \ - sof_sdw_rt5682.o sof_sdw_rt700.o \ - sof_sdw_rt711.o sof_sdw_rt711_sdca.o \ - sof_sdw_rt715.o sof_sdw_rt715_sdca.o \ -- sof_maxim_common.o \ -- sof_sdw_dmic.o sof_sdw_hdmi.o hda_dsp_common.o -+ sof_sdw_dmic.o sof_sdw_hdmi.o - obj-$(CONFIG_SND_SOC_INTEL_SOF_RT5682_MACH) += snd-soc-sof_rt5682.o - obj-$(CONFIG_SND_SOC_INTEL_HASWELL_MACH) += snd-soc-sst-haswell.o - obj-$(CONFIG_SND_SOC_INTEL_BXT_DA7219_MAX98357A_COMMON) += snd-soc-sst-bxt-da7219_max98357a.o -@@ -74,3 +73,10 @@ obj-$(CONFIG_SND_SOC_INTEL_SKL_HDA_DSP_GENERIC_MACH) += snd-soc-skl_hda_dsp.o - obj-$(CONFIG_SND_SOC_INTEL_SOF_DA7219_MAX98373_MACH) += snd-soc-sof_da7219_max98373.o - obj-$(CONFIG_SND_SOC_INTEL_EHL_RT5660_MACH) += snd-soc-ehl-rt5660.o - obj-$(CONFIG_SND_SOC_INTEL_SOUNDWIRE_SOF_MACH) += snd-soc-sof-sdw.o -+ -+# common modules -+snd-soc-intel-hda-dsp-common-objs := hda_dsp_common.o -+obj-$(CONFIG_SND_SOC_INTEL_HDA_DSP_COMMON) += snd-soc-intel-hda-dsp-common.o -+ -+snd-soc-intel-sof-maxim-common-objs += sof_maxim_common.o -+obj-$(CONFIG_SND_SOC_INTEL_SOF_MAXIM_COMMON) += snd-soc-intel-sof-maxim-common.o -diff --git a/sound/soc/intel/boards/bxt_da7219_max98357a.c b/sound/soc/intel/boards/bxt_da7219_max98357a.c -index 9ffef396f8f2d..07ae950b01277 100644 ---- a/sound/soc/intel/boards/bxt_da7219_max98357a.c -+++ b/sound/soc/intel/boards/bxt_da7219_max98357a.c -@@ -869,3 +869,4 @@ MODULE_LICENSE("GPL v2"); - MODULE_ALIAS("platform:bxt_da7219_max98357a"); - MODULE_ALIAS("platform:glk_da7219_max98357a"); - MODULE_ALIAS("platform:cml_da7219_max98357a"); -+MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON); -diff --git a/sound/soc/intel/boards/bxt_rt298.c b/sound/soc/intel/boards/bxt_rt298.c -index 0f3157dfa8384..32a776fa0b865 100644 ---- a/sound/soc/intel/boards/bxt_rt298.c -+++ b/sound/soc/intel/boards/bxt_rt298.c -@@ -667,3 +667,4 @@ MODULE_DESCRIPTION("Intel SST Audio for Broxton"); - MODULE_LICENSE("GPL v2"); - MODULE_ALIAS("platform:bxt_alc298s_i2s"); - MODULE_ALIAS("platform:glk_alc298s_i2s"); -+MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON); -diff --git a/sound/soc/intel/boards/cml_rt1011_rt5682.c b/sound/soc/intel/boards/cml_rt1011_rt5682.c -index 14813beb33d16..27615acddacdf 100644 ---- a/sound/soc/intel/boards/cml_rt1011_rt5682.c -+++ b/sound/soc/intel/boards/cml_rt1011_rt5682.c -@@ -594,3 +594,4 @@ MODULE_AUTHOR("Shuming Fan "); - MODULE_AUTHOR("Mac Chiang "); - MODULE_LICENSE("GPL v2"); - MODULE_ALIAS("platform:cml_rt1011_rt5682"); -+MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON); -diff --git a/sound/soc/intel/boards/ehl_rt5660.c b/sound/soc/intel/boards/ehl_rt5660.c -index 7c0d4e9154067..b9b72d05b3358 100644 ---- a/sound/soc/intel/boards/ehl_rt5660.c -+++ b/sound/soc/intel/boards/ehl_rt5660.c -@@ -321,3 +321,4 @@ MODULE_DESCRIPTION("ASoC Intel(R) Elkhartlake + rt5660 Machine driver"); - MODULE_AUTHOR("libin.yang@intel.com"); - MODULE_LICENSE("GPL v2"); - MODULE_ALIAS("platform:ehl_rt5660"); -+MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON); -diff --git a/sound/soc/intel/boards/glk_rt5682_max98357a.c b/sound/soc/intel/boards/glk_rt5682_max98357a.c -index 62cca511522ea..19e2ff90886a9 100644 ---- a/sound/soc/intel/boards/glk_rt5682_max98357a.c -+++ b/sound/soc/intel/boards/glk_rt5682_max98357a.c -@@ -642,3 +642,4 @@ MODULE_AUTHOR("Naveen Manohar "); - MODULE_AUTHOR("Harsha Priya "); - MODULE_LICENSE("GPL v2"); - MODULE_ALIAS("platform:glk_rt5682_max98357a"); -+MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON); -diff --git a/sound/soc/intel/boards/hda_dsp_common.c b/sound/soc/intel/boards/hda_dsp_common.c -index 91ad2a0ad1ce1..efdc4bc4bb1f9 100644 ---- a/sound/soc/intel/boards/hda_dsp_common.c -+++ b/sound/soc/intel/boards/hda_dsp_common.c -@@ -2,6 +2,7 @@ - // - // Copyright(c) 2019 Intel Corporation. All rights reserved. - -+#include - #include - #include - #include -@@ -82,5 +83,9 @@ int hda_dsp_hdmi_build_controls(struct snd_soc_card *card, - - return err; - } -+EXPORT_SYMBOL_NS(hda_dsp_hdmi_build_controls, SND_SOC_INTEL_HDA_DSP_COMMON); - - #endif -+ -+MODULE_DESCRIPTION("ASoC Intel HDMI helpers"); -+MODULE_LICENSE("GPL"); -diff --git a/sound/soc/intel/boards/skl_hda_dsp_generic.c b/sound/soc/intel/boards/skl_hda_dsp_generic.c -index bc50eda297ab7..f4b4eeca3e03c 100644 ---- a/sound/soc/intel/boards/skl_hda_dsp_generic.c -+++ b/sound/soc/intel/boards/skl_hda_dsp_generic.c -@@ -258,3 +258,4 @@ MODULE_DESCRIPTION("SKL/KBL/BXT/APL HDA Generic Machine driver"); - MODULE_AUTHOR("Rakesh Ughreja "); - MODULE_LICENSE("GPL v2"); - MODULE_ALIAS("platform:skl_hda_dsp_generic"); -+MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON); -diff --git a/sound/soc/intel/boards/sof_da7219_max98373.c b/sound/soc/intel/boards/sof_da7219_max98373.c -index 8d1ad892e86b6..2116d70d1ea8b 100644 ---- a/sound/soc/intel/boards/sof_da7219_max98373.c -+++ b/sound/soc/intel/boards/sof_da7219_max98373.c -@@ -458,3 +458,4 @@ MODULE_AUTHOR("Yong Zhi "); - MODULE_LICENSE("GPL v2"); - MODULE_ALIAS("platform:sof_da7219_max98360a"); - MODULE_ALIAS("platform:sof_da7219_max98373"); -+MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON); -diff --git a/sound/soc/intel/boards/sof_maxim_common.c b/sound/soc/intel/boards/sof_maxim_common.c -index 437d205627539..7c4af6ec58e82 100644 ---- a/sound/soc/intel/boards/sof_maxim_common.c -+++ b/sound/soc/intel/boards/sof_maxim_common.c -@@ -1,6 +1,7 @@ - // SPDX-License-Identifier: GPL-2.0-only - // - // Copyright(c) 2020 Intel Corporation. All rights reserved. -+#include - #include - #include - #include -@@ -16,6 +17,7 @@ const struct snd_soc_dapm_route max_98373_dapm_routes[] = { - { "Left Spk", NULL, "Left BE_OUT" }, - { "Right Spk", NULL, "Right BE_OUT" }, - }; -+EXPORT_SYMBOL_NS(max_98373_dapm_routes, SND_SOC_INTEL_SOF_MAXIM_COMMON); - - static struct snd_soc_codec_conf max_98373_codec_conf[] = { - { -@@ -38,9 +40,10 @@ struct snd_soc_dai_link_component max_98373_components[] = { - .dai_name = MAX_98373_CODEC_DAI, - }, - }; -+EXPORT_SYMBOL_NS(max_98373_components, SND_SOC_INTEL_SOF_MAXIM_COMMON); - --static int max98373_hw_params(struct snd_pcm_substream *substream, -- struct snd_pcm_hw_params *params) -+static int max_98373_hw_params(struct snd_pcm_substream *substream, -+ struct snd_pcm_hw_params *params) - { - struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); - struct snd_soc_dai *codec_dai; -@@ -59,7 +62,7 @@ static int max98373_hw_params(struct snd_pcm_substream *substream, - return 0; - } - --int max98373_trigger(struct snd_pcm_substream *substream, int cmd) -+int max_98373_trigger(struct snd_pcm_substream *substream, int cmd) - { - struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); - struct snd_soc_dai *codec_dai; -@@ -102,13 +105,15 @@ int max98373_trigger(struct snd_pcm_substream *substream, int cmd) - - return ret; - } -+EXPORT_SYMBOL_NS(max_98373_trigger, SND_SOC_INTEL_SOF_MAXIM_COMMON); - - struct snd_soc_ops max_98373_ops = { -- .hw_params = max98373_hw_params, -- .trigger = max98373_trigger, -+ .hw_params = max_98373_hw_params, -+ .trigger = max_98373_trigger, - }; -+EXPORT_SYMBOL_NS(max_98373_ops, SND_SOC_INTEL_SOF_MAXIM_COMMON); - --int max98373_spk_codec_init(struct snd_soc_pcm_runtime *rtd) -+int max_98373_spk_codec_init(struct snd_soc_pcm_runtime *rtd) - { - struct snd_soc_card *card = rtd->card; - int ret; -@@ -119,9 +124,14 @@ int max98373_spk_codec_init(struct snd_soc_pcm_runtime *rtd) - dev_err(rtd->dev, "Speaker map addition failed: %d\n", ret); - return ret; - } -+EXPORT_SYMBOL_NS(max_98373_spk_codec_init, SND_SOC_INTEL_SOF_MAXIM_COMMON); - --void sof_max98373_codec_conf(struct snd_soc_card *card) -+void max_98373_set_codec_conf(struct snd_soc_card *card) - { - card->codec_conf = max_98373_codec_conf; - card->num_configs = ARRAY_SIZE(max_98373_codec_conf); - } -+EXPORT_SYMBOL_NS(max_98373_set_codec_conf, SND_SOC_INTEL_SOF_MAXIM_COMMON); -+ -+MODULE_DESCRIPTION("ASoC Intel SOF Maxim helpers"); -+MODULE_LICENSE("GPL"); -diff --git a/sound/soc/intel/boards/sof_maxim_common.h b/sound/soc/intel/boards/sof_maxim_common.h -index 5240b1c9d379b..566a664d5a636 100644 ---- a/sound/soc/intel/boards/sof_maxim_common.h -+++ b/sound/soc/intel/boards/sof_maxim_common.h -@@ -20,8 +20,8 @@ extern struct snd_soc_dai_link_component max_98373_components[2]; - extern struct snd_soc_ops max_98373_ops; - extern const struct snd_soc_dapm_route max_98373_dapm_routes[]; - --int max98373_spk_codec_init(struct snd_soc_pcm_runtime *rtd); --void sof_max98373_codec_conf(struct snd_soc_card *card); --int max98373_trigger(struct snd_pcm_substream *substream, int cmd); -+int max_98373_spk_codec_init(struct snd_soc_pcm_runtime *rtd); -+void max_98373_set_codec_conf(struct snd_soc_card *card); -+int max_98373_trigger(struct snd_pcm_substream *substream, int cmd); - - #endif /* __SOF_MAXIM_COMMON_H */ -diff --git a/sound/soc/intel/boards/sof_pcm512x.c b/sound/soc/intel/boards/sof_pcm512x.c -index d2b0456236c72..8620d4f38493a 100644 ---- a/sound/soc/intel/boards/sof_pcm512x.c -+++ b/sound/soc/intel/boards/sof_pcm512x.c -@@ -437,3 +437,4 @@ MODULE_DESCRIPTION("ASoC Intel(R) SOF + PCM512x Machine driver"); - MODULE_AUTHOR("Pierre-Louis Bossart"); - MODULE_LICENSE("GPL v2"); - MODULE_ALIAS("platform:sof_pcm512x"); -+MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON); -diff --git a/sound/soc/intel/boards/sof_rt5682.c b/sound/soc/intel/boards/sof_rt5682.c -index cf1d053733e22..78262c659983e 100644 ---- a/sound/soc/intel/boards/sof_rt5682.c -+++ b/sound/soc/intel/boards/sof_rt5682.c -@@ -742,7 +742,7 @@ static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev, - SOF_MAX98373_SPEAKER_AMP_PRESENT) { - links[id].codecs = max_98373_components; - links[id].num_codecs = ARRAY_SIZE(max_98373_components); -- links[id].init = max98373_spk_codec_init; -+ links[id].init = max_98373_spk_codec_init; - links[id].ops = &max_98373_ops; - /* feedback stream */ - links[id].dpcm_capture = 1; -@@ -863,7 +863,7 @@ static int sof_audio_probe(struct platform_device *pdev) - sof_audio_card_rt5682.num_links++; - - if (sof_rt5682_quirk & SOF_MAX98373_SPEAKER_AMP_PRESENT) -- sof_max98373_codec_conf(&sof_audio_card_rt5682); -+ max_98373_set_codec_conf(&sof_audio_card_rt5682); - else if (sof_rt5682_quirk & SOF_RT1011_SPEAKER_AMP_PRESENT) - sof_rt1011_codec_conf(&sof_audio_card_rt5682); - else if (sof_rt5682_quirk & SOF_RT1015P_SPEAKER_AMP_PRESENT) -@@ -994,3 +994,5 @@ MODULE_ALIAS("platform:jsl_rt5682_max98360a"); - MODULE_ALIAS("platform:cml_rt1015_rt5682"); - MODULE_ALIAS("platform:tgl_rt1011_rt5682"); - MODULE_ALIAS("platform:jsl_rt5682_rt1015p"); -+MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON); -+MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON); -diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c -index 5827a16773c90..3ca7e1ab48ab1 100644 ---- a/sound/soc/intel/boards/sof_sdw.c -+++ b/sound/soc/intel/boards/sof_sdw.c -@@ -1318,3 +1318,5 @@ MODULE_AUTHOR("Rander Wang "); - MODULE_AUTHOR("Pierre-Louis Bossart "); - MODULE_LICENSE("GPL v2"); - MODULE_ALIAS("platform:sof_sdw"); -+MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON); -+MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON); -diff --git a/sound/soc/intel/boards/sof_sdw_max98373.c b/sound/soc/intel/boards/sof_sdw_max98373.c -index cfdf970c5800f..25daef910aee1 100644 ---- a/sound/soc/intel/boards/sof_sdw_max98373.c -+++ b/sound/soc/intel/boards/sof_sdw_max98373.c -@@ -55,43 +55,68 @@ static int spk_init(struct snd_soc_pcm_runtime *rtd) - return ret; - } - --static int max98373_sdw_trigger(struct snd_pcm_substream *substream, int cmd) -+static int mx8373_enable_spk_pin(struct snd_pcm_substream *substream, bool enable) - { -+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); -+ struct snd_soc_dai *codec_dai; -+ struct snd_soc_dai *cpu_dai; - int ret; -+ int j; - -- switch (cmd) { -- case SNDRV_PCM_TRIGGER_START: -- case SNDRV_PCM_TRIGGER_RESUME: -- case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: -- /* enable max98373 first */ -- ret = max98373_trigger(substream, cmd); -- if (ret < 0) -- break; -- -- ret = sdw_trigger(substream, cmd); -- break; -- case SNDRV_PCM_TRIGGER_STOP: -- case SNDRV_PCM_TRIGGER_SUSPEND: -- case SNDRV_PCM_TRIGGER_PAUSE_PUSH: -- ret = sdw_trigger(substream, cmd); -- if (ret < 0) -- break; -- -- ret = max98373_trigger(substream, cmd); -- break; -- default: -- ret = -EINVAL; -- break; -+ /* set spk pin by playback only */ -+ if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) -+ return 0; -+ -+ cpu_dai = asoc_rtd_to_cpu(rtd, 0); -+ for_each_rtd_codec_dais(rtd, j, codec_dai) { -+ struct snd_soc_dapm_context *dapm = -+ snd_soc_component_get_dapm(cpu_dai->component); -+ char pin_name[16]; -+ -+ snprintf(pin_name, ARRAY_SIZE(pin_name), "%s Spk", -+ codec_dai->component->name_prefix); -+ -+ if (enable) -+ ret = snd_soc_dapm_enable_pin(dapm, pin_name); -+ else -+ ret = snd_soc_dapm_disable_pin(dapm, pin_name); -+ -+ if (!ret) -+ snd_soc_dapm_sync(dapm); - } - -- return ret; -+ return 0; -+} -+ -+static int mx8373_sdw_prepare(struct snd_pcm_substream *substream) -+{ -+ int ret = 0; -+ -+ /* according to soc_pcm_prepare dai link prepare is called first */ -+ ret = sdw_prepare(substream); -+ if (ret < 0) -+ return ret; -+ -+ return mx8373_enable_spk_pin(substream, true); -+} -+ -+static int mx8373_sdw_hw_free(struct snd_pcm_substream *substream) -+{ -+ int ret = 0; -+ -+ /* according to soc_pcm_hw_free dai link free is called first */ -+ ret = sdw_hw_free(substream); -+ if (ret < 0) -+ return ret; -+ -+ return mx8373_enable_spk_pin(substream, false); - } - - static const struct snd_soc_ops max_98373_sdw_ops = { - .startup = sdw_startup, -- .prepare = sdw_prepare, -- .trigger = max98373_sdw_trigger, -- .hw_free = sdw_hw_free, -+ .prepare = mx8373_sdw_prepare, -+ .trigger = sdw_trigger, -+ .hw_free = mx8373_sdw_hw_free, - .shutdown = sdw_shutdown, - }; - -diff --git a/sound/soc/ti/j721e-evm.c b/sound/soc/ti/j721e-evm.c -index a7c0484d44ec7..265bbc5a2f96a 100644 ---- a/sound/soc/ti/j721e-evm.c -+++ b/sound/soc/ti/j721e-evm.c -@@ -197,7 +197,7 @@ static int j721e_configure_refclk(struct j721e_priv *priv, - return ret; - } - -- if (priv->hsdiv_rates[domain->parent_clk_id] != scki) { -+ if (domain->parent_clk_id == -1 || priv->hsdiv_rates[domain->parent_clk_id] != scki) { - dev_dbg(priv->dev, - "%s configuration for %u Hz: %s, %dxFS (SCKI: %u Hz)\n", - audio_domain == J721E_AUDIO_DOMAIN_CPB ? "CPB" : "IVI", -@@ -278,23 +278,29 @@ static int j721e_audio_startup(struct snd_pcm_substream *substream) - j721e_rule_rate, &priv->rate_range, - SNDRV_PCM_HW_PARAM_RATE, -1); - -- mutex_unlock(&priv->mutex); - - if (ret) -- return ret; -+ goto out; - - /* Reset TDM slots to 32 */ - ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0x3, 0x3, 2, 32); - if (ret && ret != -ENOTSUPP) -- return ret; -+ goto out; - - for_each_rtd_codec_dais(rtd, i, codec_dai) { - ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x3, 0x3, 2, 32); - if (ret && ret != -ENOTSUPP) -- return ret; -+ goto out; - } - -- return 0; -+ if (ret == -ENOTSUPP) -+ ret = 0; -+out: -+ if (ret) -+ domain->active--; -+ mutex_unlock(&priv->mutex); -+ -+ return ret; - } - - static int j721e_audio_hw_params(struct snd_pcm_substream *substream, diff --git a/patch/kernel/archive/sunxi-5.13/patch-1-5.13.9-10.patch b/patch/kernel/archive/sunxi-5.13/patch-1-5.13.9-10.patch deleted file mode 100644 index 612fced3e6..0000000000 --- a/patch/kernel/archive/sunxi-5.13/patch-1-5.13.9-10.patch +++ /dev/null @@ -1,6040 +0,0 @@ -diff --git a/Makefile b/Makefile -index 9d810e13a83f4..4e9f877f513f9 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,7 +1,7 @@ - # SPDX-License-Identifier: GPL-2.0 - VERSION = 5 - PATCHLEVEL = 13 --SUBLEVEL = 9 -+SUBLEVEL = 10 - EXTRAVERSION = - NAME = Opossums on Parade - -@@ -1366,6 +1366,15 @@ scripts_unifdef: scripts_basic - $(Q)$(MAKE) $(build)=scripts scripts/unifdef - - # --------------------------------------------------------------------------- -+# Install -+ -+# Many distributions have the custom install script, /sbin/installkernel. -+# If DKMS is installed, 'make install' will eventually recuses back -+# to the this Makefile to build and install external modules. -+# Cancel sub_make_done so that options such as M=, V=, etc. are parsed. -+ -+install: sub_make_done := -+ - # Kernel selftest - - PHONY += kselftest -diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c -index 4b2575f936d46..cb64e4797d2a8 100644 ---- a/arch/alpha/kernel/smp.c -+++ b/arch/alpha/kernel/smp.c -@@ -582,7 +582,7 @@ void - smp_send_stop(void) - { - cpumask_t to_whom; -- cpumask_copy(&to_whom, cpu_possible_mask); -+ cpumask_copy(&to_whom, cpu_online_mask); - cpumask_clear_cpu(smp_processor_id(), &to_whom); - #ifdef DEBUG_IPI_MSG - if (hard_smp_processor_id() != boot_cpu_id) -diff --git a/arch/arm/boot/dts/am437x-l4.dtsi b/arch/arm/boot/dts/am437x-l4.dtsi -index a6f19ae7d3e6b..f73ecec1995a3 100644 ---- a/arch/arm/boot/dts/am437x-l4.dtsi -+++ b/arch/arm/boot/dts/am437x-l4.dtsi -@@ -1595,7 +1595,7 @@ - compatible = "ti,am4372-d_can", "ti,am3352-d_can"; - reg = <0x0 0x2000>; - clocks = <&dcan1_fck>; -- clock-name = "fck"; -+ clock-names = "fck"; - syscon-raminit = <&scm_conf 0x644 1>; - interrupts = ; - status = "disabled"; -diff --git a/arch/arm/boot/dts/imx53-m53menlo.dts b/arch/arm/boot/dts/imx53-m53menlo.dts -index f98691ae4415b..d3082b9774e40 100644 ---- a/arch/arm/boot/dts/imx53-m53menlo.dts -+++ b/arch/arm/boot/dts/imx53-m53menlo.dts -@@ -388,13 +388,13 @@ - - pinctrl_power_button: powerbutgrp { - fsl,pins = < -- MX53_PAD_SD2_DATA2__GPIO1_13 0x1e4 -+ MX53_PAD_SD2_DATA0__GPIO1_15 0x1e4 - >; - }; - - pinctrl_power_out: poweroutgrp { - fsl,pins = < -- MX53_PAD_SD2_DATA0__GPIO1_15 0x1e4 -+ MX53_PAD_SD2_DATA2__GPIO1_13 0x1e4 - >; - }; - -diff --git a/arch/arm/boot/dts/imx6qdl-sr-som.dtsi b/arch/arm/boot/dts/imx6qdl-sr-som.dtsi -index 0ad8ccde0cf87..f86efd0ccc404 100644 ---- a/arch/arm/boot/dts/imx6qdl-sr-som.dtsi -+++ b/arch/arm/boot/dts/imx6qdl-sr-som.dtsi -@@ -54,7 +54,13 @@ - pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_microsom_enet_ar8035>; - phy-mode = "rgmii-id"; -- phy-reset-duration = <2>; -+ -+ /* -+ * The PHY seems to require a long-enough reset duration to avoid -+ * some rare issues where the PHY gets stuck in an inconsistent and -+ * non-functional state at boot-up. 10ms proved to be fine . -+ */ -+ phy-reset-duration = <10>; - phy-reset-gpios = <&gpio4 15 GPIO_ACTIVE_LOW>; - status = "okay"; - -diff --git a/arch/arm/boot/dts/imx6ull-colibri-wifi.dtsi b/arch/arm/boot/dts/imx6ull-colibri-wifi.dtsi -index a0545431b3dc3..9f1e38282bee7 100644 ---- a/arch/arm/boot/dts/imx6ull-colibri-wifi.dtsi -+++ b/arch/arm/boot/dts/imx6ull-colibri-wifi.dtsi -@@ -43,6 +43,7 @@ - assigned-clock-rates = <0>, <198000000>; - cap-power-off-card; - keep-power-in-suspend; -+ max-frequency = <25000000>; - mmc-pwrseq = <&wifi_pwrseq>; - no-1-8-v; - non-removable; -diff --git a/arch/arm/boot/dts/omap5-board-common.dtsi b/arch/arm/boot/dts/omap5-board-common.dtsi -index d8f13626cfd1b..3a8f102314758 100644 ---- a/arch/arm/boot/dts/omap5-board-common.dtsi -+++ b/arch/arm/boot/dts/omap5-board-common.dtsi -@@ -30,14 +30,6 @@ - regulator-max-microvolt = <5000000>; - }; - -- vdds_1v8_main: fixedregulator-vdds_1v8_main { -- compatible = "regulator-fixed"; -- regulator-name = "vdds_1v8_main"; -- vin-supply = <&smps7_reg>; -- regulator-min-microvolt = <1800000>; -- regulator-max-microvolt = <1800000>; -- }; -- - vmmcsd_fixed: fixedregulator-mmcsd { - compatible = "regulator-fixed"; - regulator-name = "vmmcsd_fixed"; -@@ -487,6 +479,7 @@ - regulator-boot-on; - }; - -+ vdds_1v8_main: - smps7_reg: smps7 { - /* VDDS_1v8_OMAP over VDDS_1v8_MAIN */ - regulator-name = "smps7"; -diff --git a/arch/arm/boot/dts/stm32mp15xx-dhcom-pdk2.dtsi b/arch/arm/boot/dts/stm32mp15xx-dhcom-pdk2.dtsi -index c5ea08fec535f..6cf1c8b4c6e28 100644 ---- a/arch/arm/boot/dts/stm32mp15xx-dhcom-pdk2.dtsi -+++ b/arch/arm/boot/dts/stm32mp15xx-dhcom-pdk2.dtsi -@@ -37,7 +37,7 @@ - poll-interval = <20>; - - /* -- * The EXTi IRQ line 3 is shared with touchscreen and ethernet, -+ * The EXTi IRQ line 3 is shared with ethernet, - * so mark this as polled GPIO key. - */ - button-0 { -@@ -46,6 +46,16 @@ - gpios = <&gpiof 3 GPIO_ACTIVE_LOW>; - }; - -+ /* -+ * The EXTi IRQ line 6 is shared with touchscreen, -+ * so mark this as polled GPIO key. -+ */ -+ button-1 { -+ label = "TA2-GPIO-B"; -+ linux,code = ; -+ gpios = <&gpiod 6 GPIO_ACTIVE_LOW>; -+ }; -+ - /* - * The EXTi IRQ line 0 is shared with PMIC, - * so mark this as polled GPIO key. -@@ -60,13 +70,6 @@ - gpio-keys { - compatible = "gpio-keys"; - -- button-1 { -- label = "TA2-GPIO-B"; -- linux,code = ; -- gpios = <&gpiod 6 GPIO_ACTIVE_LOW>; -- wakeup-source; -- }; -- - button-3 { - label = "TA4-GPIO-D"; - linux,code = ; -@@ -82,6 +85,7 @@ - label = "green:led5"; - gpios = <&gpioc 6 GPIO_ACTIVE_HIGH>; - default-state = "off"; -+ status = "disabled"; - }; - - led-1 { -@@ -185,8 +189,8 @@ - touchscreen@38 { - compatible = "edt,edt-ft5406"; - reg = <0x38>; -- interrupt-parent = <&gpiog>; -- interrupts = <2 IRQ_TYPE_EDGE_FALLING>; /* GPIO E */ -+ interrupt-parent = <&gpioc>; -+ interrupts = <6 IRQ_TYPE_EDGE_FALLING>; /* GPIO E */ - }; - }; - -diff --git a/arch/arm/boot/dts/stm32mp15xx-dhcom-som.dtsi b/arch/arm/boot/dts/stm32mp15xx-dhcom-som.dtsi -index 2af0a67526747..8c41f819f7769 100644 ---- a/arch/arm/boot/dts/stm32mp15xx-dhcom-som.dtsi -+++ b/arch/arm/boot/dts/stm32mp15xx-dhcom-som.dtsi -@@ -12,6 +12,8 @@ - aliases { - ethernet0 = ðernet0; - ethernet1 = &ksz8851; -+ rtc0 = &hwrtc; -+ rtc1 = &rtc; - }; - - memory@c0000000 { -@@ -138,6 +140,7 @@ - reset-gpios = <&gpioh 3 GPIO_ACTIVE_LOW>; - reset-assert-us = <500>; - reset-deassert-us = <500>; -+ smsc,disable-energy-detect; - interrupt-parent = <&gpioi>; - interrupts = <11 IRQ_TYPE_LEVEL_LOW>; - }; -@@ -248,7 +251,7 @@ - /delete-property/dmas; - /delete-property/dma-names; - -- rtc@32 { -+ hwrtc: rtc@32 { - compatible = "microcrystal,rv8803"; - reg = <0x32>; - }; -diff --git a/arch/arm/mach-imx/mmdc.c b/arch/arm/mach-imx/mmdc.c -index 0dfd0ae7a63dd..af12668d0bf51 100644 ---- a/arch/arm/mach-imx/mmdc.c -+++ b/arch/arm/mach-imx/mmdc.c -@@ -103,6 +103,7 @@ struct mmdc_pmu { - struct perf_event *mmdc_events[MMDC_NUM_COUNTERS]; - struct hlist_node node; - struct fsl_mmdc_devtype_data *devtype_data; -+ struct clk *mmdc_ipg_clk; - }; - - /* -@@ -462,11 +463,14 @@ static int imx_mmdc_remove(struct platform_device *pdev) - - cpuhp_state_remove_instance_nocalls(cpuhp_mmdc_state, &pmu_mmdc->node); - perf_pmu_unregister(&pmu_mmdc->pmu); -+ iounmap(pmu_mmdc->mmdc_base); -+ clk_disable_unprepare(pmu_mmdc->mmdc_ipg_clk); - kfree(pmu_mmdc); - return 0; - } - --static int imx_mmdc_perf_init(struct platform_device *pdev, void __iomem *mmdc_base) -+static int imx_mmdc_perf_init(struct platform_device *pdev, void __iomem *mmdc_base, -+ struct clk *mmdc_ipg_clk) - { - struct mmdc_pmu *pmu_mmdc; - char *name; -@@ -494,6 +498,7 @@ static int imx_mmdc_perf_init(struct platform_device *pdev, void __iomem *mmdc_b - } - - mmdc_num = mmdc_pmu_init(pmu_mmdc, mmdc_base, &pdev->dev); -+ pmu_mmdc->mmdc_ipg_clk = mmdc_ipg_clk; - if (mmdc_num == 0) - name = "mmdc"; - else -@@ -529,7 +534,7 @@ pmu_free: - - #else - #define imx_mmdc_remove NULL --#define imx_mmdc_perf_init(pdev, mmdc_base) 0 -+#define imx_mmdc_perf_init(pdev, mmdc_base, mmdc_ipg_clk) 0 - #endif - - static int imx_mmdc_probe(struct platform_device *pdev) -@@ -567,7 +572,13 @@ static int imx_mmdc_probe(struct platform_device *pdev) - val &= ~(1 << BP_MMDC_MAPSR_PSD); - writel_relaxed(val, reg); - -- return imx_mmdc_perf_init(pdev, mmdc_base); -+ err = imx_mmdc_perf_init(pdev, mmdc_base, mmdc_ipg_clk); -+ if (err) { -+ iounmap(mmdc_base); -+ clk_disable_unprepare(mmdc_ipg_clk); -+ } -+ -+ return err; - } - - int imx_mmdc_get_ddr_type(void) -diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c -index 65934b2924fb5..12b26e04686fa 100644 ---- a/arch/arm/mach-omap2/omap_hwmod.c -+++ b/arch/arm/mach-omap2/omap_hwmod.c -@@ -3776,6 +3776,7 @@ struct powerdomain *omap_hwmod_get_pwrdm(struct omap_hwmod *oh) - struct omap_hwmod_ocp_if *oi; - struct clockdomain *clkdm; - struct clk_hw_omap *clk; -+ struct clk_hw *hw; - - if (!oh) - return NULL; -@@ -3792,7 +3793,14 @@ struct powerdomain *omap_hwmod_get_pwrdm(struct omap_hwmod *oh) - c = oi->_clk; - } - -- clk = to_clk_hw_omap(__clk_get_hw(c)); -+ hw = __clk_get_hw(c); -+ if (!hw) -+ return NULL; -+ -+ clk = to_clk_hw_omap(hw); -+ if (!clk) -+ return NULL; -+ - clkdm = clk->clkdm; - if (!clkdm) - return NULL; -diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1028a-kontron-sl28-var2.dts b/arch/arm64/boot/dts/freescale/fsl-ls1028a-kontron-sl28-var2.dts -index dd764b720fb0a..f6a79c8080d14 100644 ---- a/arch/arm64/boot/dts/freescale/fsl-ls1028a-kontron-sl28-var2.dts -+++ b/arch/arm64/boot/dts/freescale/fsl-ls1028a-kontron-sl28-var2.dts -@@ -54,6 +54,7 @@ - - &mscc_felix_port0 { - label = "swp0"; -+ managed = "in-band-status"; - phy-handle = <&phy0>; - phy-mode = "sgmii"; - status = "okay"; -@@ -61,6 +62,7 @@ - - &mscc_felix_port1 { - label = "swp1"; -+ managed = "in-band-status"; - phy-handle = <&phy1>; - phy-mode = "sgmii"; - status = "okay"; -diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi b/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi -index a30249ebffa8c..a94cbd6dcce66 100644 ---- a/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi -+++ b/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi -@@ -66,7 +66,7 @@ - }; - }; - -- sysclk: clock-sysclk { -+ sysclk: sysclk { - compatible = "fixed-clock"; - #clock-cells = <0>; - clock-frequency = <100000000>; -diff --git a/arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts b/arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts -index ce2bcddf396f8..a05b1ab2dd12c 100644 ---- a/arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts -+++ b/arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts -@@ -19,6 +19,8 @@ - aliases { - spi0 = &spi0; - ethernet1 = ð1; -+ mmc0 = &sdhci0; -+ mmc1 = &sdhci1; - }; - - chosen { -@@ -119,6 +121,7 @@ - pinctrl-names = "default"; - pinctrl-0 = <&i2c1_pins>; - clock-frequency = <100000>; -+ /delete-property/ mrvl,i2c-fast-mode; - status = "okay"; - - rtc@6f { -diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h -index e58bca832dfff..41b332c054ab8 100644 ---- a/arch/arm64/include/asm/ptrace.h -+++ b/arch/arm64/include/asm/ptrace.h -@@ -320,7 +320,17 @@ static inline unsigned long kernel_stack_pointer(struct pt_regs *regs) - - static inline unsigned long regs_return_value(struct pt_regs *regs) - { -- return regs->regs[0]; -+ unsigned long val = regs->regs[0]; -+ -+ /* -+ * Audit currently uses regs_return_value() instead of -+ * syscall_get_return_value(). Apply the same sign-extension here until -+ * audit is updated to use syscall_get_return_value(). -+ */ -+ if (compat_user_mode(regs)) -+ val = sign_extend64(val, 31); -+ -+ return val; - } - - static inline void regs_set_return_value(struct pt_regs *regs, unsigned long rc) -diff --git a/arch/arm64/include/asm/syscall.h b/arch/arm64/include/asm/syscall.h -index cfc0672013f67..03e20895453a7 100644 ---- a/arch/arm64/include/asm/syscall.h -+++ b/arch/arm64/include/asm/syscall.h -@@ -29,22 +29,23 @@ static inline void syscall_rollback(struct task_struct *task, - regs->regs[0] = regs->orig_x0; - } - -- --static inline long syscall_get_error(struct task_struct *task, -- struct pt_regs *regs) -+static inline long syscall_get_return_value(struct task_struct *task, -+ struct pt_regs *regs) - { -- unsigned long error = regs->regs[0]; -+ unsigned long val = regs->regs[0]; - - if (is_compat_thread(task_thread_info(task))) -- error = sign_extend64(error, 31); -+ val = sign_extend64(val, 31); - -- return IS_ERR_VALUE(error) ? error : 0; -+ return val; - } - --static inline long syscall_get_return_value(struct task_struct *task, -- struct pt_regs *regs) -+static inline long syscall_get_error(struct task_struct *task, -+ struct pt_regs *regs) - { -- return regs->regs[0]; -+ unsigned long error = syscall_get_return_value(task, regs); -+ -+ return IS_ERR_VALUE(error) ? error : 0; - } - - static inline void syscall_set_return_value(struct task_struct *task, -diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c -index eb2f73939b7bb..af3b64ca482d0 100644 ---- a/arch/arm64/kernel/ptrace.c -+++ b/arch/arm64/kernel/ptrace.c -@@ -1862,7 +1862,7 @@ void syscall_trace_exit(struct pt_regs *regs) - audit_syscall_exit(regs); - - if (flags & _TIF_SYSCALL_TRACEPOINT) -- trace_sys_exit(regs, regs_return_value(regs)); -+ trace_sys_exit(regs, syscall_get_return_value(current, regs)); - - if (flags & (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP)) - tracehook_report_syscall(regs, PTRACE_SYSCALL_EXIT); -diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c -index 6237486ff6bb7..22899c86711aa 100644 ---- a/arch/arm64/kernel/signal.c -+++ b/arch/arm64/kernel/signal.c -@@ -29,6 +29,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -890,7 +891,7 @@ static void do_signal(struct pt_regs *regs) - retval == -ERESTART_RESTARTBLOCK || - (retval == -ERESTARTSYS && - !(ksig.ka.sa.sa_flags & SA_RESTART)))) { -- regs->regs[0] = -EINTR; -+ syscall_set_return_value(current, regs, -EINTR, 0); - regs->pc = continue_addr; - } - -diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c -index de07147a79260..7ae41b35c923e 100644 ---- a/arch/arm64/kernel/stacktrace.c -+++ b/arch/arm64/kernel/stacktrace.c -@@ -220,7 +220,7 @@ void show_stack(struct task_struct *tsk, unsigned long *sp, const char *loglvl) - - #ifdef CONFIG_STACKTRACE - --noinline void arch_stack_walk(stack_trace_consume_fn consume_entry, -+noinline notrace void arch_stack_walk(stack_trace_consume_fn consume_entry, - void *cookie, struct task_struct *task, - struct pt_regs *regs) - { -diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c -index 263d6c1a525f3..50a0f1a38e849 100644 ---- a/arch/arm64/kernel/syscall.c -+++ b/arch/arm64/kernel/syscall.c -@@ -54,10 +54,7 @@ static void invoke_syscall(struct pt_regs *regs, unsigned int scno, - ret = do_ni_syscall(regs, scno); - } - -- if (is_compat_task()) -- ret = lower_32_bits(ret); -- -- regs->regs[0] = ret; -+ syscall_set_return_value(current, regs, 0, ret); - - /* - * Ultimately, this value will get limited by KSTACK_OFFSET_MAX(), -@@ -115,7 +112,7 @@ static void el0_svc_common(struct pt_regs *regs, int scno, int sc_nr, - * syscall. do_notify_resume() will send a signal to userspace - * before the syscall is restarted. - */ -- regs->regs[0] = -ERESTARTNOINTR; -+ syscall_set_return_value(current, regs, -ERESTARTNOINTR, 0); - return; - } - -@@ -136,7 +133,7 @@ static void el0_svc_common(struct pt_regs *regs, int scno, int sc_nr, - * anyway. - */ - if (scno == NO_SYSCALL) -- regs->regs[0] = -ENOSYS; -+ syscall_set_return_value(current, regs, -ENOSYS, 0); - scno = syscall_trace_enter(regs); - if (scno == NO_SYSCALL) - goto trace_exit; -diff --git a/arch/mips/Makefile b/arch/mips/Makefile -index 258234c35a096..674f68d16a73f 100644 ---- a/arch/mips/Makefile -+++ b/arch/mips/Makefile -@@ -321,7 +321,7 @@ KBUILD_LDFLAGS += -m $(ld-emul) - - ifdef CONFIG_MIPS - CHECKFLAGS += $(shell $(CC) $(KBUILD_CFLAGS) -dM -E -x c /dev/null | \ -- egrep -vw '__GNUC_(|MINOR_|PATCHLEVEL_)_' | \ -+ egrep -vw '__GNUC_(MINOR_|PATCHLEVEL_)?_' | \ - sed -e "s/^\#define /-D'/" -e "s/ /'='/" -e "s/$$/'/" -e 's/\$$/&&/g') - endif - -diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h -index d0cf997b4ba84..139b4050259fa 100644 ---- a/arch/mips/include/asm/pgalloc.h -+++ b/arch/mips/include/asm/pgalloc.h -@@ -59,15 +59,20 @@ do { \ - - static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address) - { -- pmd_t *pmd = NULL; -+ pmd_t *pmd; - struct page *pg; - -- pg = alloc_pages(GFP_KERNEL | __GFP_ACCOUNT, PMD_ORDER); -- if (pg) { -- pgtable_pmd_page_ctor(pg); -- pmd = (pmd_t *)page_address(pg); -- pmd_init((unsigned long)pmd, (unsigned long)invalid_pte_table); -+ pg = alloc_pages(GFP_KERNEL_ACCOUNT, PMD_ORDER); -+ if (!pg) -+ return NULL; -+ -+ if (!pgtable_pmd_page_ctor(pg)) { -+ __free_pages(pg, PMD_ORDER); -+ return NULL; - } -+ -+ pmd = (pmd_t *)page_address(pg); -+ pmd_init((unsigned long)pmd, (unsigned long)invalid_pte_table); - return pmd; - } - -diff --git a/arch/mips/mti-malta/malta-platform.c b/arch/mips/mti-malta/malta-platform.c -index 11e9527c6e441..62ffac500eb52 100644 ---- a/arch/mips/mti-malta/malta-platform.c -+++ b/arch/mips/mti-malta/malta-platform.c -@@ -47,7 +47,8 @@ static struct plat_serial8250_port uart8250_data[] = { - .mapbase = 0x1f000900, /* The CBUS UART */ - .irq = MIPS_CPU_IRQ_BASE + MIPSCPU_INT_MB2, - .uartclk = 3686400, /* Twice the usual clk! */ -- .iotype = UPIO_MEM32, -+ .iotype = IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) ? -+ UPIO_MEM32BE : UPIO_MEM32, - .flags = CBUS_UART_FLAGS, - .regshift = 3, - }, -diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig -index 18ec0f9bb8d5c..3c3647ac33cb8 100644 ---- a/arch/riscv/Kconfig -+++ b/arch/riscv/Kconfig -@@ -489,6 +489,7 @@ config CC_HAVE_STACKPROTECTOR_TLS - - config STACKPROTECTOR_PER_TASK - def_bool y -+ depends on !GCC_PLUGIN_RANDSTRUCT - depends on STACKPROTECTOR && CC_HAVE_STACKPROTECTOR_TLS - - config PHYS_RAM_BASE_FIXED -diff --git a/arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts b/arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts -index b1c3c596578f1..2e4ea84f27e77 100644 ---- a/arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts -+++ b/arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts -@@ -24,7 +24,7 @@ - - memory@80000000 { - device_type = "memory"; -- reg = <0x0 0x80000000 0x2 0x00000000>; -+ reg = <0x0 0x80000000 0x4 0x00000000>; - }; - - soc { -diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c -index bde85fc53357f..7bc8af75933a7 100644 ---- a/arch/riscv/kernel/stacktrace.c -+++ b/arch/riscv/kernel/stacktrace.c -@@ -27,7 +27,7 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs, - fp = frame_pointer(regs); - sp = user_stack_pointer(regs); - pc = instruction_pointer(regs); -- } else if (task == current) { -+ } else if (task == NULL || task == current) { - fp = (unsigned long)__builtin_frame_address(1); - sp = (unsigned long)__builtin_frame_address(0); - pc = (unsigned long)__builtin_return_address(0); -diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h -index 2bf1c7ea2758d..2938c902ffbe4 100644 ---- a/arch/x86/events/perf_event.h -+++ b/arch/x86/events/perf_event.h -@@ -1115,9 +1115,10 @@ void x86_pmu_stop(struct perf_event *event, int flags); - - static inline void x86_pmu_disable_event(struct perf_event *event) - { -+ u64 disable_mask = __this_cpu_read(cpu_hw_events.perf_ctr_virt_mask); - struct hw_perf_event *hwc = &event->hw; - -- wrmsrl(hwc->config_base, hwc->config); -+ wrmsrl(hwc->config_base, hwc->config & ~disable_mask); - - if (is_counter_pair(hwc)) - wrmsrl(x86_pmu_config_addr(hwc->idx + 1), 0); -diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c -index 716266ab177f4..ed469ddf20741 100644 ---- a/arch/x86/kvm/mmu/mmu.c -+++ b/arch/x86/kvm/mmu/mmu.c -@@ -1546,7 +1546,7 @@ static int is_empty_shadow_page(u64 *spt) - * aggregate version in order to make the slab shrinker - * faster - */ --static inline void kvm_mod_used_mmu_pages(struct kvm *kvm, unsigned long nr) -+static inline void kvm_mod_used_mmu_pages(struct kvm *kvm, long nr) - { - kvm->arch.n_used_mmu_pages += nr; - percpu_counter_add(&kvm_total_used_mmu_pages, nr); -diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c -index 02d60d7f903da..7498c1384b938 100644 ---- a/arch/x86/kvm/svm/sev.c -+++ b/arch/x86/kvm/svm/sev.c -@@ -188,7 +188,7 @@ static void sev_asid_free(struct kvm_sev_info *sev) - - for_each_possible_cpu(cpu) { - sd = per_cpu(svm_data, cpu); -- sd->sev_vmcbs[pos] = NULL; -+ sd->sev_vmcbs[sev->asid] = NULL; - } - - mutex_unlock(&sev_bitmap_lock); -diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c -index d6a9f05187849..1e11198f89934 100644 ---- a/arch/x86/kvm/x86.c -+++ b/arch/x86/kvm/x86.c -@@ -4252,8 +4252,17 @@ static int kvm_cpu_accept_dm_intr(struct kvm_vcpu *vcpu) - - static int kvm_vcpu_ready_for_interrupt_injection(struct kvm_vcpu *vcpu) - { -- return kvm_arch_interrupt_allowed(vcpu) && -- kvm_cpu_accept_dm_intr(vcpu); -+ /* -+ * Do not cause an interrupt window exit if an exception -+ * is pending or an event needs reinjection; userspace -+ * might want to inject the interrupt manually using KVM_SET_REGS -+ * or KVM_SET_SREGS. For that to work, we must be at an -+ * instruction boundary and with no events half-injected. -+ */ -+ return (kvm_arch_interrupt_allowed(vcpu) && -+ kvm_cpu_accept_dm_intr(vcpu) && -+ !kvm_event_needs_reinjection(vcpu) && -+ !vcpu->arch.exception.pending); - } - - static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, -diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c -index 04c5a44b96827..9ba700dc47de4 100644 ---- a/arch/x86/tools/relocs.c -+++ b/arch/x86/tools/relocs.c -@@ -57,12 +57,12 @@ static const char * const sym_regex_kernel[S_NSYMTYPES] = { - [S_REL] = - "^(__init_(begin|end)|" - "__x86_cpu_dev_(start|end)|" -- "(__parainstructions|__alt_instructions)(|_end)|" -- "(__iommu_table|__apicdrivers|__smp_locks)(|_end)|" -+ "(__parainstructions|__alt_instructions)(_end)?|" -+ "(__iommu_table|__apicdrivers|__smp_locks)(_end)?|" - "__(start|end)_pci_.*|" - "__(start|end)_builtin_fw|" -- "__(start|stop)___ksymtab(|_gpl)|" -- "__(start|stop)___kcrctab(|_gpl)|" -+ "__(start|stop)___ksymtab(_gpl)?|" -+ "__(start|stop)___kcrctab(_gpl)?|" - "__(start|stop)___param|" - "__(start|stop)___modver|" - "__(start|stop)___bug_table|" -diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c -index 81be0096411da..d8b0d8bd132bc 100644 ---- a/block/blk-iolatency.c -+++ b/block/blk-iolatency.c -@@ -833,7 +833,11 @@ static ssize_t iolatency_set_limit(struct kernfs_open_file *of, char *buf, - - enable = iolatency_set_min_lat_nsec(blkg, lat_val); - if (enable) { -- WARN_ON_ONCE(!blk_get_queue(blkg->q)); -+ if (!blk_get_queue(blkg->q)) { -+ ret = -ENODEV; -+ goto out; -+ } -+ - blkg_get(blkg); - } - -diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c -index 38e10ab976e67..14b71b41e8453 100644 ---- a/drivers/acpi/acpica/nsrepair2.c -+++ b/drivers/acpi/acpica/nsrepair2.c -@@ -379,13 +379,6 @@ acpi_ns_repair_CID(struct acpi_evaluate_info *info, - - (*element_ptr)->common.reference_count = - original_ref_count; -- -- /* -- * The original_element holds a reference from the package object -- * that represents _HID. Since a new element was created by _HID, -- * remove the reference from the _CID package. -- */ -- acpi_ut_remove_reference(original_element); - } - - element_ptr++; -diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c -index ae7189d1a5682..b71ea4a680b01 100644 ---- a/drivers/ata/libata-sff.c -+++ b/drivers/ata/libata-sff.c -@@ -637,6 +637,20 @@ unsigned int ata_sff_data_xfer32(struct ata_queued_cmd *qc, unsigned char *buf, - } - EXPORT_SYMBOL_GPL(ata_sff_data_xfer32); - -+static void ata_pio_xfer(struct ata_queued_cmd *qc, struct page *page, -+ unsigned int offset, size_t xfer_size) -+{ -+ bool do_write = (qc->tf.flags & ATA_TFLAG_WRITE); -+ unsigned char *buf; -+ -+ buf = kmap_atomic(page); -+ qc->ap->ops->sff_data_xfer(qc, buf + offset, xfer_size, do_write); -+ kunmap_atomic(buf); -+ -+ if (!do_write && !PageSlab(page)) -+ flush_dcache_page(page); -+} -+ - /** - * ata_pio_sector - Transfer a sector of data. - * @qc: Command on going -@@ -648,11 +662,9 @@ EXPORT_SYMBOL_GPL(ata_sff_data_xfer32); - */ - static void ata_pio_sector(struct ata_queued_cmd *qc) - { -- int do_write = (qc->tf.flags & ATA_TFLAG_WRITE); - struct ata_port *ap = qc->ap; - struct page *page; - unsigned int offset; -- unsigned char *buf; - - if (!qc->cursg) { - qc->curbytes = qc->nbytes; -@@ -670,13 +682,20 @@ static void ata_pio_sector(struct ata_queued_cmd *qc) - - DPRINTK("data %s\n", qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read"); - -- /* do the actual data transfer */ -- buf = kmap_atomic(page); -- ap->ops->sff_data_xfer(qc, buf + offset, qc->sect_size, do_write); -- kunmap_atomic(buf); -+ /* -+ * Split the transfer when it splits a page boundary. Note that the -+ * split still has to be dword aligned like all ATA data transfers. -+ */ -+ WARN_ON_ONCE(offset % 4); -+ if (offset + qc->sect_size > PAGE_SIZE) { -+ unsigned int split_len = PAGE_SIZE - offset; - -- if (!do_write && !PageSlab(page)) -- flush_dcache_page(page); -+ ata_pio_xfer(qc, page, offset, split_len); -+ ata_pio_xfer(qc, nth_page(page, 1), 0, -+ qc->sect_size - split_len); -+ } else { -+ ata_pio_xfer(qc, page, offset, qc->sect_size); -+ } - - qc->curbytes += qc->sect_size; - qc->cursg_ofs += qc->sect_size; -diff --git a/drivers/base/dd.c b/drivers/base/dd.c -index ecd7cf848daff..592b3955abe22 100644 ---- a/drivers/base/dd.c -+++ b/drivers/base/dd.c -@@ -634,8 +634,6 @@ dev_groups_failed: - else if (drv->remove) - drv->remove(dev); - probe_failed: -- kfree(dev->dma_range_map); -- dev->dma_range_map = NULL; - if (dev->bus) - blocking_notifier_call_chain(&dev->bus->p->bus_notifier, - BUS_NOTIFY_DRIVER_NOT_BOUND, dev); -@@ -643,6 +641,8 @@ pinctrl_bind_failed: - device_links_no_driver(dev); - devres_release_all(dev); - arch_teardown_dma_ops(dev); -+ kfree(dev->dma_range_map); -+ dev->dma_range_map = NULL; - driver_sysfs_remove(dev); - dev->driver = NULL; - dev_set_drvdata(dev, NULL); -diff --git a/drivers/base/firmware_loader/fallback.c b/drivers/base/firmware_loader/fallback.c -index 91899d185e311..d7d63c1aa993f 100644 ---- a/drivers/base/firmware_loader/fallback.c -+++ b/drivers/base/firmware_loader/fallback.c -@@ -89,12 +89,11 @@ static void __fw_load_abort(struct fw_priv *fw_priv) - { - /* - * There is a small window in which user can write to 'loading' -- * between loading done and disappearance of 'loading' -+ * between loading done/aborted and disappearance of 'loading' - */ -- if (fw_sysfs_done(fw_priv)) -+ if (fw_state_is_aborted(fw_priv) || fw_sysfs_done(fw_priv)) - return; - -- list_del_init(&fw_priv->pending_list); - fw_state_aborted(fw_priv); - } - -@@ -280,7 +279,6 @@ static ssize_t firmware_loading_store(struct device *dev, - * Same logic as fw_load_abort, only the DONE bit - * is ignored and we set ABORT only on failure. - */ -- list_del_init(&fw_priv->pending_list); - if (rc) { - fw_state_aborted(fw_priv); - written = rc; -@@ -513,6 +511,11 @@ static int fw_load_sysfs_fallback(struct fw_sysfs *fw_sysfs, long timeout) - } - - mutex_lock(&fw_lock); -+ if (fw_state_is_aborted(fw_priv)) { -+ mutex_unlock(&fw_lock); -+ retval = -EINTR; -+ goto out; -+ } - list_add(&fw_priv->pending_list, &pending_fw_head); - mutex_unlock(&fw_lock); - -@@ -535,11 +538,10 @@ static int fw_load_sysfs_fallback(struct fw_sysfs *fw_sysfs, long timeout) - if (fw_state_is_aborted(fw_priv)) { - if (retval == -ERESTARTSYS) - retval = -EINTR; -- else -- retval = -EAGAIN; - } else if (fw_priv->is_paged_buf && !fw_priv->data) - retval = -ENOMEM; - -+out: - device_del(f_dev); - err_put_dev: - put_device(f_dev); -diff --git a/drivers/base/firmware_loader/firmware.h b/drivers/base/firmware_loader/firmware.h -index 63bd29fdcb9c5..a3014e9e2c852 100644 ---- a/drivers/base/firmware_loader/firmware.h -+++ b/drivers/base/firmware_loader/firmware.h -@@ -117,8 +117,16 @@ static inline void __fw_state_set(struct fw_priv *fw_priv, - - WRITE_ONCE(fw_st->status, status); - -- if (status == FW_STATUS_DONE || status == FW_STATUS_ABORTED) -+ if (status == FW_STATUS_DONE || status == FW_STATUS_ABORTED) { -+#ifdef CONFIG_FW_LOADER_USER_HELPER -+ /* -+ * Doing this here ensures that the fw_priv is deleted from -+ * the pending list in all abort/done paths. -+ */ -+ list_del_init(&fw_priv->pending_list); -+#endif - complete_all(&fw_st->completion); -+ } - } - - static inline void fw_state_aborted(struct fw_priv *fw_priv) -diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c -index 4fdb8219cd083..68c549d712304 100644 ---- a/drivers/base/firmware_loader/main.c -+++ b/drivers/base/firmware_loader/main.c -@@ -783,8 +783,10 @@ static void fw_abort_batch_reqs(struct firmware *fw) - return; - - fw_priv = fw->priv; -+ mutex_lock(&fw_lock); - if (!fw_state_is_aborted(fw_priv)) - fw_state_aborted(fw_priv); -+ mutex_unlock(&fw_lock); - } - - /* called from request_firmware() and request_firmware_work_func() */ -diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c -index 38cb116ed433f..0ef98e3ba3410 100644 ---- a/drivers/bus/ti-sysc.c -+++ b/drivers/bus/ti-sysc.c -@@ -100,6 +100,7 @@ static const char * const clock_names[SYSC_MAX_CLOCKS] = { - * @cookie: data used by legacy platform callbacks - * @name: name if available - * @revision: interconnect target module revision -+ * @reserved: target module is reserved and already in use - * @enabled: sysc runtime enabled status - * @needs_resume: runtime resume needed on resume from suspend - * @child_needs_resume: runtime resume needed for child on resume from suspend -@@ -130,6 +131,7 @@ struct sysc { - struct ti_sysc_cookie cookie; - const char *name; - u32 revision; -+ unsigned int reserved:1; - unsigned int enabled:1; - unsigned int needs_resume:1; - unsigned int child_needs_resume:1; -@@ -2951,6 +2953,8 @@ static int sysc_init_soc(struct sysc *ddata) - case SOC_3430 ... SOC_3630: - sysc_add_disabled(0x48304000); /* timer12 */ - break; -+ case SOC_AM3: -+ sysc_add_disabled(0x48310000); /* rng */ - default: - break; - } -@@ -3093,8 +3097,8 @@ static int sysc_probe(struct platform_device *pdev) - return error; - - error = sysc_check_active_timer(ddata); -- if (error) -- return error; -+ if (error == -EBUSY) -+ ddata->reserved = true; - - error = sysc_get_clocks(ddata); - if (error) -@@ -3130,11 +3134,15 @@ static int sysc_probe(struct platform_device *pdev) - sysc_show_registers(ddata); - - ddata->dev->type = &sysc_device_type; -- error = of_platform_populate(ddata->dev->of_node, sysc_match_table, -- pdata ? pdata->auxdata : NULL, -- ddata->dev); -- if (error) -- goto err; -+ -+ if (!ddata->reserved) { -+ error = of_platform_populate(ddata->dev->of_node, -+ sysc_match_table, -+ pdata ? pdata->auxdata : NULL, -+ ddata->dev); -+ if (error) -+ goto err; -+ } - - INIT_DELAYED_WORK(&ddata->idle_work, ti_sysc_idle); - -diff --git a/drivers/char/tpm/tpm_ftpm_tee.c b/drivers/char/tpm/tpm_ftpm_tee.c -index 2ccdf8ac69948..6e3235565a4d8 100644 ---- a/drivers/char/tpm/tpm_ftpm_tee.c -+++ b/drivers/char/tpm/tpm_ftpm_tee.c -@@ -254,11 +254,11 @@ static int ftpm_tee_probe(struct device *dev) - pvt_data->session = sess_arg.session; - - /* Allocate dynamic shared memory with fTPM TA */ -- pvt_data->shm = tee_shm_alloc(pvt_data->ctx, -- MAX_COMMAND_SIZE + MAX_RESPONSE_SIZE, -- TEE_SHM_MAPPED | TEE_SHM_DMA_BUF); -+ pvt_data->shm = tee_shm_alloc_kernel_buf(pvt_data->ctx, -+ MAX_COMMAND_SIZE + -+ MAX_RESPONSE_SIZE); - if (IS_ERR(pvt_data->shm)) { -- dev_err(dev, "%s: tee_shm_alloc failed\n", __func__); -+ dev_err(dev, "%s: tee_shm_alloc_kernel_buf failed\n", __func__); - rc = -ENOMEM; - goto out_shm_alloc; - } -diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c -index be160764911bf..f9d5b73343417 100644 ---- a/drivers/clk/clk-devres.c -+++ b/drivers/clk/clk-devres.c -@@ -92,13 +92,20 @@ int __must_check devm_clk_bulk_get_optional(struct device *dev, int num_clks, - } - EXPORT_SYMBOL_GPL(devm_clk_bulk_get_optional); - -+static void devm_clk_bulk_release_all(struct device *dev, void *res) -+{ -+ struct clk_bulk_devres *devres = res; -+ -+ clk_bulk_put_all(devres->num_clks, devres->clks); -+} -+ - int __must_check devm_clk_bulk_get_all(struct device *dev, - struct clk_bulk_data **clks) - { - struct clk_bulk_devres *devres; - int ret; - -- devres = devres_alloc(devm_clk_bulk_release, -+ devres = devres_alloc(devm_clk_bulk_release_all, - sizeof(*devres), GFP_KERNEL); - if (!devres) - return -ENOMEM; -diff --git a/drivers/clk/clk-stm32f4.c b/drivers/clk/clk-stm32f4.c -index 18117ce5ff85f..5c75e3d906c20 100644 ---- a/drivers/clk/clk-stm32f4.c -+++ b/drivers/clk/clk-stm32f4.c -@@ -526,7 +526,7 @@ struct stm32f4_pll { - - struct stm32f4_pll_post_div_data { - int idx; -- u8 pll_num; -+ int pll_idx; - const char *name; - const char *parent; - u8 flag; -@@ -557,13 +557,13 @@ static const struct clk_div_table post_divr_table[] = { - - #define MAX_POST_DIV 3 - static const struct stm32f4_pll_post_div_data post_div_data[MAX_POST_DIV] = { -- { CLK_I2SQ_PDIV, PLL_I2S, "plli2s-q-div", "plli2s-q", -+ { CLK_I2SQ_PDIV, PLL_VCO_I2S, "plli2s-q-div", "plli2s-q", - CLK_SET_RATE_PARENT, STM32F4_RCC_DCKCFGR, 0, 5, 0, NULL}, - -- { CLK_SAIQ_PDIV, PLL_SAI, "pllsai-q-div", "pllsai-q", -+ { CLK_SAIQ_PDIV, PLL_VCO_SAI, "pllsai-q-div", "pllsai-q", - CLK_SET_RATE_PARENT, STM32F4_RCC_DCKCFGR, 8, 5, 0, NULL }, - -- { NO_IDX, PLL_SAI, "pllsai-r-div", "pllsai-r", CLK_SET_RATE_PARENT, -+ { NO_IDX, PLL_VCO_SAI, "pllsai-r-div", "pllsai-r", CLK_SET_RATE_PARENT, - STM32F4_RCC_DCKCFGR, 16, 2, 0, post_divr_table }, - }; - -@@ -1774,7 +1774,7 @@ static void __init stm32f4_rcc_init(struct device_node *np) - post_div->width, - post_div->flag_div, - post_div->div_table, -- clks[post_div->pll_num], -+ clks[post_div->pll_idx], - &stm32f4_clk_lock); - - if (post_div->idx != NO_IDX) -diff --git a/drivers/clk/tegra/clk-sdmmc-mux.c b/drivers/clk/tegra/clk-sdmmc-mux.c -index 316912d3b1a4f..4f2c3309eea4d 100644 ---- a/drivers/clk/tegra/clk-sdmmc-mux.c -+++ b/drivers/clk/tegra/clk-sdmmc-mux.c -@@ -194,6 +194,15 @@ static void clk_sdmmc_mux_disable(struct clk_hw *hw) - gate_ops->disable(gate_hw); - } - -+static void clk_sdmmc_mux_disable_unused(struct clk_hw *hw) -+{ -+ struct tegra_sdmmc_mux *sdmmc_mux = to_clk_sdmmc_mux(hw); -+ const struct clk_ops *gate_ops = sdmmc_mux->gate_ops; -+ struct clk_hw *gate_hw = &sdmmc_mux->gate.hw; -+ -+ gate_ops->disable_unused(gate_hw); -+} -+ - static void clk_sdmmc_mux_restore_context(struct clk_hw *hw) - { - struct clk_hw *parent = clk_hw_get_parent(hw); -@@ -218,6 +227,7 @@ static const struct clk_ops tegra_clk_sdmmc_mux_ops = { - .is_enabled = clk_sdmmc_mux_is_enabled, - .enable = clk_sdmmc_mux_enable, - .disable = clk_sdmmc_mux_disable, -+ .disable_unused = clk_sdmmc_mux_disable_unused, - .restore_context = clk_sdmmc_mux_restore_context, - }; - -diff --git a/drivers/dma/idxd/idxd.h b/drivers/dma/idxd/idxd.h -index 26482c7d4c3a3..fc708be7ad9a2 100644 ---- a/drivers/dma/idxd/idxd.h -+++ b/drivers/dma/idxd/idxd.h -@@ -294,6 +294,14 @@ struct idxd_desc { - struct idxd_wq *wq; - }; - -+/* -+ * This is software defined error for the completion status. We overload the error code -+ * that will never appear in completion status and only SWERR register. -+ */ -+enum idxd_completion_status { -+ IDXD_COMP_DESC_ABORT = 0xff, -+}; -+ - #define confdev_to_idxd(dev) container_of(dev, struct idxd_device, conf_dev) - #define confdev_to_wq(dev) container_of(dev, struct idxd_wq, conf_dev) - -@@ -482,4 +490,10 @@ static inline void perfmon_init(void) {} - static inline void perfmon_exit(void) {} - #endif - -+static inline void complete_desc(struct idxd_desc *desc, enum idxd_complete_type reason) -+{ -+ idxd_dma_complete_txd(desc, reason); -+ idxd_free_desc(desc->wq, desc); -+} -+ - #endif -diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c -index 442d55c11a5f4..32cca6a0e66ac 100644 ---- a/drivers/dma/idxd/init.c -+++ b/drivers/dma/idxd/init.c -@@ -102,6 +102,8 @@ static int idxd_setup_interrupts(struct idxd_device *idxd) - spin_lock_init(&idxd->irq_entries[i].list_lock); - } - -+ idxd_msix_perm_setup(idxd); -+ - irq_entry = &idxd->irq_entries[0]; - rc = request_threaded_irq(irq_entry->vector, NULL, idxd_misc_thread, - 0, "idxd-misc", irq_entry); -@@ -148,7 +150,6 @@ static int idxd_setup_interrupts(struct idxd_device *idxd) - } - - idxd_unmask_error_interrupts(idxd); -- idxd_msix_perm_setup(idxd); - return 0; - - err_wq_irqs: -@@ -162,6 +163,7 @@ static int idxd_setup_interrupts(struct idxd_device *idxd) - err_misc_irq: - /* Disable error interrupt generation */ - idxd_mask_error_interrupts(idxd); -+ idxd_msix_perm_clear(idxd); - err_irq_entries: - pci_free_irq_vectors(pdev); - dev_err(dev, "No usable interrupts\n"); -@@ -757,32 +759,40 @@ static void idxd_shutdown(struct pci_dev *pdev) - for (i = 0; i < msixcnt; i++) { - irq_entry = &idxd->irq_entries[i]; - synchronize_irq(irq_entry->vector); -- free_irq(irq_entry->vector, irq_entry); - if (i == 0) - continue; - idxd_flush_pending_llist(irq_entry); - idxd_flush_work_list(irq_entry); - } -- -- idxd_msix_perm_clear(idxd); -- idxd_release_int_handles(idxd); -- pci_free_irq_vectors(pdev); -- pci_iounmap(pdev, idxd->reg_base); -- pci_disable_device(pdev); -- destroy_workqueue(idxd->wq); -+ flush_workqueue(idxd->wq); - } - - static void idxd_remove(struct pci_dev *pdev) - { - struct idxd_device *idxd = pci_get_drvdata(pdev); -+ struct idxd_irq_entry *irq_entry; -+ int msixcnt = pci_msix_vec_count(pdev); -+ int i; - - dev_dbg(&pdev->dev, "%s called\n", __func__); - idxd_shutdown(pdev); - if (device_pasid_enabled(idxd)) - idxd_disable_system_pasid(idxd); - idxd_unregister_devices(idxd); -- perfmon_pmu_remove(idxd); -+ -+ for (i = 0; i < msixcnt; i++) { -+ irq_entry = &idxd->irq_entries[i]; -+ free_irq(irq_entry->vector, irq_entry); -+ } -+ idxd_msix_perm_clear(idxd); -+ idxd_release_int_handles(idxd); -+ pci_free_irq_vectors(pdev); -+ pci_iounmap(pdev, idxd->reg_base); - iommu_dev_disable_feature(&pdev->dev, IOMMU_DEV_FEAT_SVA); -+ pci_disable_device(pdev); -+ destroy_workqueue(idxd->wq); -+ perfmon_pmu_remove(idxd); -+ device_unregister(&idxd->conf_dev); - } - - static struct pci_driver idxd_pci_driver = { -diff --git a/drivers/dma/idxd/irq.c b/drivers/dma/idxd/irq.c -index ae68e1e5487a0..4e3a7198c0caf 100644 ---- a/drivers/dma/idxd/irq.c -+++ b/drivers/dma/idxd/irq.c -@@ -245,12 +245,6 @@ static inline bool match_fault(struct idxd_desc *desc, u64 fault_addr) - return false; - } - --static inline void complete_desc(struct idxd_desc *desc, enum idxd_complete_type reason) --{ -- idxd_dma_complete_txd(desc, reason); -- idxd_free_desc(desc->wq, desc); --} -- - static int irq_process_pending_llist(struct idxd_irq_entry *irq_entry, - enum irq_work_type wtype, - int *processed, u64 data) -@@ -272,8 +266,16 @@ static int irq_process_pending_llist(struct idxd_irq_entry *irq_entry, - reason = IDXD_COMPLETE_DEV_FAIL; - - llist_for_each_entry_safe(desc, t, head, llnode) { -- if (desc->completion->status) { -- if ((desc->completion->status & DSA_COMP_STATUS_MASK) != DSA_COMP_SUCCESS) -+ u8 status = desc->completion->status & DSA_COMP_STATUS_MASK; -+ -+ if (status) { -+ if (unlikely(status == IDXD_COMP_DESC_ABORT)) { -+ complete_desc(desc, IDXD_COMPLETE_ABORT); -+ (*processed)++; -+ continue; -+ } -+ -+ if (unlikely(status != DSA_COMP_SUCCESS)) - match_fault(desc, data); - complete_desc(desc, reason); - (*processed)++; -@@ -329,7 +331,14 @@ static int irq_process_work_list(struct idxd_irq_entry *irq_entry, - spin_unlock_irqrestore(&irq_entry->list_lock, flags); - - list_for_each_entry(desc, &flist, list) { -- if ((desc->completion->status & DSA_COMP_STATUS_MASK) != DSA_COMP_SUCCESS) -+ u8 status = desc->completion->status & DSA_COMP_STATUS_MASK; -+ -+ if (unlikely(status == IDXD_COMP_DESC_ABORT)) { -+ complete_desc(desc, IDXD_COMPLETE_ABORT); -+ continue; -+ } -+ -+ if (unlikely(status != DSA_COMP_SUCCESS)) - match_fault(desc, data); - complete_desc(desc, reason); - } -diff --git a/drivers/dma/idxd/submit.c b/drivers/dma/idxd/submit.c -index 19afb62abaffd..36c9c1a89b7e7 100644 ---- a/drivers/dma/idxd/submit.c -+++ b/drivers/dma/idxd/submit.c -@@ -25,11 +25,10 @@ static struct idxd_desc *__get_desc(struct idxd_wq *wq, int idx, int cpu) - * Descriptor completion vectors are 1...N for MSIX. We will round - * robin through the N vectors. - */ -- wq->vec_ptr = (wq->vec_ptr % idxd->num_wq_irqs) + 1; -+ wq->vec_ptr = desc->vector = (wq->vec_ptr % idxd->num_wq_irqs) + 1; - if (!idxd->int_handles) { - desc->hw->int_handle = wq->vec_ptr; - } else { -- desc->vector = wq->vec_ptr; - /* - * int_handles are only for descriptor completion. However for device - * MSIX enumeration, vec 0 is used for misc interrupts. Therefore even -@@ -88,9 +87,64 @@ void idxd_free_desc(struct idxd_wq *wq, struct idxd_desc *desc) - sbitmap_queue_clear(&wq->sbq, desc->id, cpu); - } - -+static struct idxd_desc *list_abort_desc(struct idxd_wq *wq, struct idxd_irq_entry *ie, -+ struct idxd_desc *desc) -+{ -+ struct idxd_desc *d, *n; -+ -+ lockdep_assert_held(&ie->list_lock); -+ list_for_each_entry_safe(d, n, &ie->work_list, list) { -+ if (d == desc) { -+ list_del(&d->list); -+ return d; -+ } -+ } -+ -+ /* -+ * At this point, the desc needs to be aborted is held by the completion -+ * handler where it has taken it off the pending list but has not added to the -+ * work list. It will be cleaned up by the interrupt handler when it sees the -+ * IDXD_COMP_DESC_ABORT for completion status. -+ */ -+ return NULL; -+} -+ -+static void llist_abort_desc(struct idxd_wq *wq, struct idxd_irq_entry *ie, -+ struct idxd_desc *desc) -+{ -+ struct idxd_desc *d, *t, *found = NULL; -+ struct llist_node *head; -+ unsigned long flags; -+ -+ desc->completion->status = IDXD_COMP_DESC_ABORT; -+ /* -+ * Grab the list lock so it will block the irq thread handler. This allows the -+ * abort code to locate the descriptor need to be aborted. -+ */ -+ spin_lock_irqsave(&ie->list_lock, flags); -+ head = llist_del_all(&ie->pending_llist); -+ if (head) { -+ llist_for_each_entry_safe(d, t, head, llnode) { -+ if (d == desc) { -+ found = desc; -+ continue; -+ } -+ list_add_tail(&desc->list, &ie->work_list); -+ } -+ } -+ -+ if (!found) -+ found = list_abort_desc(wq, ie, desc); -+ spin_unlock_irqrestore(&ie->list_lock, flags); -+ -+ if (found) -+ complete_desc(found, IDXD_COMPLETE_ABORT); -+} -+ - int idxd_submit_desc(struct idxd_wq *wq, struct idxd_desc *desc) - { - struct idxd_device *idxd = wq->idxd; -+ struct idxd_irq_entry *ie = NULL; - void __iomem *portal; - int rc; - -@@ -108,6 +162,16 @@ int idxd_submit_desc(struct idxd_wq *wq, struct idxd_desc *desc) - * even on UP because the recipient is a device. - */ - wmb(); -+ -+ /* -+ * Pending the descriptor to the lockless list for the irq_entry -+ * that we designated the descriptor to. -+ */ -+ if (desc->hw->flags & IDXD_OP_FLAG_RCI) { -+ ie = &idxd->irq_entries[desc->vector]; -+ llist_add(&desc->llnode, &ie->pending_llist); -+ } -+ - if (wq_dedicated(wq)) { - iosubmit_cmds512(portal, desc->hw, 1); - } else { -@@ -118,29 +182,13 @@ int idxd_submit_desc(struct idxd_wq *wq, struct idxd_desc *desc) - * device is not accepting descriptor at all. - */ - rc = enqcmds(portal, desc->hw); -- if (rc < 0) -+ if (rc < 0) { -+ if (ie) -+ llist_abort_desc(wq, ie, desc); - return rc; -+ } - } - - percpu_ref_put(&wq->wq_active); -- -- /* -- * Pending the descriptor to the lockless list for the irq_entry -- * that we designated the descriptor to. -- */ -- if (desc->hw->flags & IDXD_OP_FLAG_RCI) { -- int vec; -- -- /* -- * If the driver is on host kernel, it would be the value -- * assigned to interrupt handle, which is index for MSIX -- * vector. If it's guest then can't use the int_handle since -- * that is the index to IMS for the entire device. The guest -- * device local index will be used. -- */ -- vec = !idxd->int_handles ? desc->hw->int_handle : desc->vector; -- llist_add(&desc->llnode, &idxd->irq_entries[vec].pending_llist); -- } -- - return 0; - } -diff --git a/drivers/dma/idxd/sysfs.c b/drivers/dma/idxd/sysfs.c -index 0460d58e3941f..bb4df63906a72 100644 ---- a/drivers/dma/idxd/sysfs.c -+++ b/drivers/dma/idxd/sysfs.c -@@ -1744,8 +1744,6 @@ void idxd_unregister_devices(struct idxd_device *idxd) - - device_unregister(&group->conf_dev); - } -- -- device_unregister(&idxd->conf_dev); - } - - int idxd_register_bus_type(void) -diff --git a/drivers/dma/imx-dma.c b/drivers/dma/imx-dma.c -index 7f116bbcfad2a..2ddc31e64db03 100644 ---- a/drivers/dma/imx-dma.c -+++ b/drivers/dma/imx-dma.c -@@ -812,6 +812,8 @@ static struct dma_async_tx_descriptor *imxdma_prep_slave_sg( - dma_length += sg_dma_len(sg); - } - -+ imxdma_config_write(chan, &imxdmac->config, direction); -+ - switch (imxdmac->word_size) { - case DMA_SLAVE_BUSWIDTH_4_BYTES: - if (sg_dma_len(sgl) & 3 || sgl->dma_address & 3) -diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c -index f54ecb123a521..7dd1d3d0bf063 100644 ---- a/drivers/dma/stm32-dma.c -+++ b/drivers/dma/stm32-dma.c -@@ -1200,7 +1200,7 @@ static int stm32_dma_alloc_chan_resources(struct dma_chan *c) - - chan->config_init = false; - -- ret = pm_runtime_get_sync(dmadev->ddev.dev); -+ ret = pm_runtime_resume_and_get(dmadev->ddev.dev); - if (ret < 0) - return ret; - -@@ -1470,7 +1470,7 @@ static int stm32_dma_suspend(struct device *dev) - struct stm32_dma_device *dmadev = dev_get_drvdata(dev); - int id, ret, scr; - -- ret = pm_runtime_get_sync(dev); -+ ret = pm_runtime_resume_and_get(dev); - if (ret < 0) - return ret; - -diff --git a/drivers/dma/stm32-dmamux.c b/drivers/dma/stm32-dmamux.c -index ef0d0555103d9..a42164389ebc2 100644 ---- a/drivers/dma/stm32-dmamux.c -+++ b/drivers/dma/stm32-dmamux.c -@@ -137,7 +137,7 @@ static void *stm32_dmamux_route_allocate(struct of_phandle_args *dma_spec, - - /* Set dma request */ - spin_lock_irqsave(&dmamux->lock, flags); -- ret = pm_runtime_get_sync(&pdev->dev); -+ ret = pm_runtime_resume_and_get(&pdev->dev); - if (ret < 0) { - spin_unlock_irqrestore(&dmamux->lock, flags); - goto error; -@@ -336,7 +336,7 @@ static int stm32_dmamux_suspend(struct device *dev) - struct stm32_dmamux_data *stm32_dmamux = platform_get_drvdata(pdev); - int i, ret; - -- ret = pm_runtime_get_sync(dev); -+ ret = pm_runtime_resume_and_get(dev); - if (ret < 0) - return ret; - -@@ -361,7 +361,7 @@ static int stm32_dmamux_resume(struct device *dev) - if (ret < 0) - return ret; - -- ret = pm_runtime_get_sync(dev); -+ ret = pm_runtime_resume_and_get(dev); - if (ret < 0) - return ret; - -diff --git a/drivers/dma/uniphier-xdmac.c b/drivers/dma/uniphier-xdmac.c -index 16b19654873df..d6b8a202474f4 100644 ---- a/drivers/dma/uniphier-xdmac.c -+++ b/drivers/dma/uniphier-xdmac.c -@@ -209,8 +209,8 @@ static int uniphier_xdmac_chan_stop(struct uniphier_xdmac_chan *xc) - writel(0, xc->reg_ch_base + XDMAC_TSS); - - /* wait until transfer is stopped */ -- return readl_poll_timeout(xc->reg_ch_base + XDMAC_STAT, val, -- !(val & XDMAC_STAT_TENF), 100, 1000); -+ return readl_poll_timeout_atomic(xc->reg_ch_base + XDMAC_STAT, val, -+ !(val & XDMAC_STAT_TENF), 100, 1000); - } - - /* xc->vc.lock must be held by caller */ -diff --git a/drivers/fpga/dfl-fme-perf.c b/drivers/fpga/dfl-fme-perf.c -index 4299145ef347e..587c82be12f7a 100644 ---- a/drivers/fpga/dfl-fme-perf.c -+++ b/drivers/fpga/dfl-fme-perf.c -@@ -953,6 +953,8 @@ static int fme_perf_offline_cpu(unsigned int cpu, struct hlist_node *node) - return 0; - - priv->cpu = target; -+ perf_pmu_migrate_context(&priv->pmu, cpu, target); -+ - return 0; - } - -diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c -index 4b9157a69fca0..50b321a1ab1b6 100644 ---- a/drivers/gpio/gpio-mpc8xxx.c -+++ b/drivers/gpio/gpio-mpc8xxx.c -@@ -405,7 +405,7 @@ static int mpc8xxx_probe(struct platform_device *pdev) - - ret = devm_request_irq(&pdev->dev, mpc8xxx_gc->irqn, - mpc8xxx_gpio_irq_cascade, -- IRQF_SHARED, "gpio-cascade", -+ IRQF_NO_THREAD | IRQF_SHARED, "gpio-cascade", - mpc8xxx_gc); - if (ret) { - dev_err(&pdev->dev, -diff --git a/drivers/gpio/gpio-tqmx86.c b/drivers/gpio/gpio-tqmx86.c -index 5022e0ad0faee..0f5d17f343f1e 100644 ---- a/drivers/gpio/gpio-tqmx86.c -+++ b/drivers/gpio/gpio-tqmx86.c -@@ -238,8 +238,8 @@ static int tqmx86_gpio_probe(struct platform_device *pdev) - struct resource *res; - int ret, irq; - -- irq = platform_get_irq(pdev, 0); -- if (irq < 0) -+ irq = platform_get_irq_optional(pdev, 0); -+ if (irq < 0 && irq != -ENXIO) - return irq; - - res = platform_get_resource(pdev, IORESOURCE_IO, 0); -@@ -278,7 +278,7 @@ static int tqmx86_gpio_probe(struct platform_device *pdev) - - pm_runtime_enable(&pdev->dev); - -- if (irq) { -+ if (irq > 0) { - struct irq_chip *irq_chip = &gpio->irq_chip; - u8 irq_status; - -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c -index 355a6923849d3..b53eab384adb7 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c -@@ -904,7 +904,7 @@ void amdgpu_acpi_fini(struct amdgpu_device *adev) - */ - bool amdgpu_acpi_is_s0ix_supported(struct amdgpu_device *adev) - { --#if defined(CONFIG_AMD_PMC) || defined(CONFIG_AMD_PMC_MODULE) -+#if IS_ENABLED(CONFIG_AMD_PMC) && IS_ENABLED(CONFIG_PM_SLEEP) - if (acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0) { - if (adev->flags & AMD_IS_APU) - return pm_suspend_target_state == PM_SUSPEND_TO_IDLE; -diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c -index eeaae1cf2bc2b..0894cd505361a 100644 ---- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c -+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c -@@ -1493,6 +1493,7 @@ static int dm_dmub_sw_init(struct amdgpu_device *adev) - } - - hdr = (const struct dmcub_firmware_header_v1_0 *)adev->dm.dmub_fw->data; -+ adev->dm.dmcub_fw_version = le32_to_cpu(hdr->header.ucode_version); - - if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) { - adev->firmware.ucode[AMDGPU_UCODE_ID_DMCUB].ucode_id = -@@ -1506,7 +1507,6 @@ static int dm_dmub_sw_init(struct amdgpu_device *adev) - adev->dm.dmcub_fw_version); - } - -- adev->dm.dmcub_fw_version = le32_to_cpu(hdr->header.ucode_version); - - adev->dm.dmub_srv = kzalloc(sizeof(*adev->dm.dmub_srv), GFP_KERNEL); - dmub_srv = adev->dm.dmub_srv; -@@ -2367,9 +2367,9 @@ static void update_connector_ext_caps(struct amdgpu_dm_connector *aconnector) - max_cll = conn_base->hdr_sink_metadata.hdmi_type1.max_cll; - min_cll = conn_base->hdr_sink_metadata.hdmi_type1.min_cll; - -- if (caps->ext_caps->bits.oled == 1 || -+ if (caps->ext_caps->bits.oled == 1 /*|| - caps->ext_caps->bits.sdr_aux_backlight_control == 1 || -- caps->ext_caps->bits.hdr_aux_backlight_control == 1) -+ caps->ext_caps->bits.hdr_aux_backlight_control == 1*/) - caps->aux_support = true; - - if (amdgpu_backlight == 0) -diff --git a/drivers/gpu/drm/i915/i915_globals.c b/drivers/gpu/drm/i915/i915_globals.c -index 3aa2136842935..57d2943884ab6 100644 ---- a/drivers/gpu/drm/i915/i915_globals.c -+++ b/drivers/gpu/drm/i915/i915_globals.c -@@ -139,7 +139,7 @@ void i915_globals_unpark(void) - atomic_inc(&active); - } - --static void __exit __i915_globals_flush(void) -+static void __i915_globals_flush(void) - { - atomic_inc(&active); /* skip shrinking */ - -@@ -149,7 +149,7 @@ static void __exit __i915_globals_flush(void) - atomic_dec(&active); - } - --void __exit i915_globals_exit(void) -+void i915_globals_exit(void) - { - GEM_BUG_ON(atomic_read(&active)); - -diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c -index 480553746794f..a6261a8103f42 100644 ---- a/drivers/gpu/drm/i915/i915_pci.c -+++ b/drivers/gpu/drm/i915/i915_pci.c -@@ -1168,6 +1168,7 @@ static int __init i915_init(void) - err = pci_register_driver(&i915_pci_driver); - if (err) { - i915_pmu_exit(); -+ i915_globals_exit(); - return err; - } - -diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h -index cbf7a60afe542..97fc7a51c1006 100644 ---- a/drivers/gpu/drm/i915/i915_reg.h -+++ b/drivers/gpu/drm/i915/i915_reg.h -@@ -416,7 +416,7 @@ static inline bool i915_mmio_reg_valid(i915_reg_t reg) - #define GEN11_VECS_SFC_USAGE(engine) _MMIO((engine)->mmio_base + 0x2014) - #define GEN11_VECS_SFC_USAGE_BIT (1 << 0) - --#define GEN12_SFC_DONE(n) _MMIO(0x1cc00 + (n) * 0x100) -+#define GEN12_SFC_DONE(n) _MMIO(0x1cc000 + (n) * 0x1000) - #define GEN12_SFC_DONE_MAX 4 - - #define RING_PP_DIR_BASE(base) _MMIO((base) + 0x228) -diff --git a/drivers/gpu/drm/kmb/kmb_drv.c b/drivers/gpu/drm/kmb/kmb_drv.c -index 96ea1a2c11dd6..c0b1c6f992496 100644 ---- a/drivers/gpu/drm/kmb/kmb_drv.c -+++ b/drivers/gpu/drm/kmb/kmb_drv.c -@@ -203,6 +203,7 @@ static irqreturn_t handle_lcd_irq(struct drm_device *dev) - unsigned long status, val, val1; - int plane_id, dma0_state, dma1_state; - struct kmb_drm_private *kmb = to_kmb(dev); -+ u32 ctrl = 0; - - status = kmb_read_lcd(kmb, LCD_INT_STATUS); - -@@ -227,6 +228,19 @@ static irqreturn_t handle_lcd_irq(struct drm_device *dev) - kmb_clr_bitmask_lcd(kmb, LCD_CONTROL, - kmb->plane_status[plane_id].ctrl); - -+ ctrl = kmb_read_lcd(kmb, LCD_CONTROL); -+ if (!(ctrl & (LCD_CTRL_VL1_ENABLE | -+ LCD_CTRL_VL2_ENABLE | -+ LCD_CTRL_GL1_ENABLE | -+ LCD_CTRL_GL2_ENABLE))) { -+ /* If no LCD layers are using DMA, -+ * then disable DMA pipelined AXI read -+ * transactions. -+ */ -+ kmb_clr_bitmask_lcd(kmb, LCD_CONTROL, -+ LCD_CTRL_PIPELINE_DMA); -+ } -+ - kmb->plane_status[plane_id].disable = false; - } - } -diff --git a/drivers/gpu/drm/kmb/kmb_plane.c b/drivers/gpu/drm/kmb/kmb_plane.c -index d5b6195856d12..ecee6782612d8 100644 ---- a/drivers/gpu/drm/kmb/kmb_plane.c -+++ b/drivers/gpu/drm/kmb/kmb_plane.c -@@ -427,8 +427,14 @@ static void kmb_plane_atomic_update(struct drm_plane *plane, - - kmb_set_bitmask_lcd(kmb, LCD_CONTROL, ctrl); - -- /* FIXME no doc on how to set output format,these values are -- * taken from the Myriadx tests -+ /* Enable pipeline AXI read transactions for the DMA -+ * after setting graphics layers. This must be done -+ * in a separate write cycle. -+ */ -+ kmb_set_bitmask_lcd(kmb, LCD_CONTROL, LCD_CTRL_PIPELINE_DMA); -+ -+ /* FIXME no doc on how to set output format, these values are taken -+ * from the Myriadx tests - */ - out_format |= LCD_OUTF_FORMAT_RGB888; - -@@ -526,6 +532,11 @@ struct kmb_plane *kmb_plane_init(struct drm_device *drm) - plane->id = i; - } - -+ /* Disable pipeline AXI read transactions for the DMA -+ * prior to setting graphics layers -+ */ -+ kmb_clr_bitmask_lcd(kmb, LCD_CONTROL, LCD_CTRL_PIPELINE_DMA); -+ - return primary; - cleanup: - drmm_kfree(drm, plane); -diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c -index f43a8406cb9a9..e73776ae6976f 100644 ---- a/drivers/hid/hid-ft260.c -+++ b/drivers/hid/hid-ft260.c -@@ -742,7 +742,7 @@ static int ft260_is_interface_enabled(struct hid_device *hdev) - int ret; - - ret = ft260_get_system_config(hdev, &cfg); -- if (ret) -+ if (ret < 0) - return ret; - - ft260_dbg("interface: 0x%02x\n", interface); -@@ -754,23 +754,16 @@ static int ft260_is_interface_enabled(struct hid_device *hdev) - switch (cfg.chip_mode) { - case FT260_MODE_ALL: - case FT260_MODE_BOTH: -- if (interface == 1) { -+ if (interface == 1) - hid_info(hdev, "uart interface is not supported\n"); -- return 0; -- } -- ret = 1; -+ else -+ ret = 1; - break; - case FT260_MODE_UART: -- if (interface == 0) { -- hid_info(hdev, "uart is unsupported on interface 0\n"); -- ret = 0; -- } -+ hid_info(hdev, "uart interface is not supported\n"); - break; - case FT260_MODE_I2C: -- if (interface == 1) { -- hid_info(hdev, "i2c is unsupported on interface 1\n"); -- ret = 0; -- } -+ ret = 1; - break; - } - return ret; -@@ -1004,11 +997,9 @@ err_hid_stop: - - static void ft260_remove(struct hid_device *hdev) - { -- int ret; - struct ft260_device *dev = hid_get_drvdata(hdev); - -- ret = ft260_is_interface_enabled(hdev); -- if (ret <= 0) -+ if (!dev) - return; - - sysfs_remove_group(&hdev->dev.kobj, &ft260_attr_group); -diff --git a/drivers/infiniband/hw/hns/hns_roce_cmd.c b/drivers/infiniband/hw/hns/hns_roce_cmd.c -index 8f68cc3ff193f..84f3f2b5f0976 100644 ---- a/drivers/infiniband/hw/hns/hns_roce_cmd.c -+++ b/drivers/infiniband/hw/hns/hns_roce_cmd.c -@@ -213,8 +213,10 @@ int hns_roce_cmd_use_events(struct hns_roce_dev *hr_dev) - - hr_cmd->context = - kcalloc(hr_cmd->max_cmds, sizeof(*hr_cmd->context), GFP_KERNEL); -- if (!hr_cmd->context) -+ if (!hr_cmd->context) { -+ hr_dev->cmd_mod = 0; - return -ENOMEM; -+ } - - for (i = 0; i < hr_cmd->max_cmds; ++i) { - hr_cmd->context[i].token = i; -@@ -228,7 +230,6 @@ int hns_roce_cmd_use_events(struct hns_roce_dev *hr_dev) - spin_lock_init(&hr_cmd->context_lock); - - hr_cmd->use_events = 1; -- down(&hr_cmd->poll_sem); - - return 0; - } -@@ -239,8 +240,6 @@ void hns_roce_cmd_use_polling(struct hns_roce_dev *hr_dev) - - kfree(hr_cmd->context); - hr_cmd->use_events = 0; -- -- up(&hr_cmd->poll_sem); - } - - struct hns_roce_cmd_mailbox * -diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c -index 6c6e82b11d8bc..33b84f219d0d0 100644 ---- a/drivers/infiniband/hw/hns/hns_roce_main.c -+++ b/drivers/infiniband/hw/hns/hns_roce_main.c -@@ -897,11 +897,9 @@ int hns_roce_init(struct hns_roce_dev *hr_dev) - - if (hr_dev->cmd_mod) { - ret = hns_roce_cmd_use_events(hr_dev); -- if (ret) { -+ if (ret) - dev_warn(dev, - "Cmd event mode failed, set back to poll!\n"); -- hns_roce_cmd_use_polling(hr_dev); -- } - } - - ret = hns_roce_init_hem(hr_dev); -diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c -index 425423dfac724..fd113ddf6e862 100644 ---- a/drivers/infiniband/hw/mlx5/mr.c -+++ b/drivers/infiniband/hw/mlx5/mr.c -@@ -530,8 +530,8 @@ static void __cache_work_func(struct mlx5_cache_ent *ent) - */ - spin_unlock_irq(&ent->lock); - need_delay = need_resched() || someone_adding(cache) || -- time_after(jiffies, -- READ_ONCE(cache->last_add) + 300 * HZ); -+ !time_after(jiffies, -+ READ_ONCE(cache->last_add) + 300 * HZ); - spin_lock_irq(&ent->lock); - if (ent->disabled) - goto out; -diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c -index 8a1e70e008764..7887941730dbb 100644 ---- a/drivers/interconnect/core.c -+++ b/drivers/interconnect/core.c -@@ -403,7 +403,7 @@ struct icc_path *devm_of_icc_get(struct device *dev, const char *name) - { - struct icc_path **ptr, *path; - -- ptr = devres_alloc(devm_icc_release, sizeof(**ptr), GFP_KERNEL); -+ ptr = devres_alloc(devm_icc_release, sizeof(*ptr), GFP_KERNEL); - if (!ptr) - return ERR_PTR(-ENOMEM); - -@@ -973,9 +973,14 @@ void icc_node_add(struct icc_node *node, struct icc_provider *provider) - } - node->avg_bw = node->init_avg; - node->peak_bw = node->init_peak; -+ -+ if (provider->pre_aggregate) -+ provider->pre_aggregate(node); -+ - if (provider->aggregate) - provider->aggregate(node, 0, node->init_avg, node->init_peak, - &node->avg_bw, &node->peak_bw); -+ - provider->set(node, node); - node->avg_bw = 0; - node->peak_bw = 0; -@@ -1106,6 +1111,8 @@ void icc_sync_state(struct device *dev) - dev_dbg(p->dev, "interconnect provider is in synced state\n"); - list_for_each_entry(n, &p->nodes, node_list) { - if (n->init_avg || n->init_peak) { -+ n->init_avg = 0; -+ n->init_peak = 0; - aggregate_requests(n); - p->set(n, n); - } -diff --git a/drivers/interconnect/qcom/icc-rpmh.c b/drivers/interconnect/qcom/icc-rpmh.c -index bf01d09dba6c4..f6fae64861ce8 100644 ---- a/drivers/interconnect/qcom/icc-rpmh.c -+++ b/drivers/interconnect/qcom/icc-rpmh.c -@@ -57,6 +57,11 @@ int qcom_icc_aggregate(struct icc_node *node, u32 tag, u32 avg_bw, - qn->sum_avg[i] += avg_bw; - qn->max_peak[i] = max_t(u32, qn->max_peak[i], peak_bw); - } -+ -+ if (node->init_avg || node->init_peak) { -+ qn->sum_avg[i] = max_t(u64, qn->sum_avg[i], node->init_avg); -+ qn->max_peak[i] = max_t(u64, qn->max_peak[i], node->init_peak); -+ } - } - - *agg_avg += avg_bw; -@@ -79,7 +84,6 @@ EXPORT_SYMBOL_GPL(qcom_icc_aggregate); - int qcom_icc_set(struct icc_node *src, struct icc_node *dst) - { - struct qcom_icc_provider *qp; -- struct qcom_icc_node *qn; - struct icc_node *node; - - if (!src) -@@ -88,12 +92,6 @@ int qcom_icc_set(struct icc_node *src, struct icc_node *dst) - node = src; - - qp = to_qcom_provider(node->provider); -- qn = node->data; -- -- qn->sum_avg[QCOM_ICC_BUCKET_AMC] = max_t(u64, qn->sum_avg[QCOM_ICC_BUCKET_AMC], -- node->avg_bw); -- qn->max_peak[QCOM_ICC_BUCKET_AMC] = max_t(u64, qn->max_peak[QCOM_ICC_BUCKET_AMC], -- node->peak_bw); - - qcom_icc_bcm_voter_commit(qp->voter); - -diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c -index ced076ba560e1..753822ca96131 100644 ---- a/drivers/md/raid1.c -+++ b/drivers/md/raid1.c -@@ -472,8 +472,6 @@ static void raid1_end_write_request(struct bio *bio) - /* - * When the device is faulty, it is not necessary to - * handle write error. -- * For failfast, this is the only remaining device, -- * We need to retry the write without FailFast. - */ - if (!test_bit(Faulty, &rdev->flags)) - set_bit(R1BIO_WriteError, &r1_bio->state); -diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c -index 13f5e6b2a73d6..40e845fb97170 100644 ---- a/drivers/md/raid10.c -+++ b/drivers/md/raid10.c -@@ -469,12 +469,12 @@ static void raid10_end_write_request(struct bio *bio) - /* - * When the device is faulty, it is not necessary to - * handle write error. -- * For failfast, this is the only remaining device, -- * We need to retry the write without FailFast. - */ - if (!test_bit(Faulty, &rdev->flags)) - set_bit(R10BIO_WriteError, &r10_bio->state); - else { -+ /* Fail the request */ -+ set_bit(R10BIO_Degraded, &r10_bio->state); - r10_bio->devs[slot].bio = NULL; - to_put = bio; - dec_rdev = 1; -diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c -index 02281d13505f4..508ac295eb06e 100644 ---- a/drivers/media/common/videobuf2/videobuf2-core.c -+++ b/drivers/media/common/videobuf2/videobuf2-core.c -@@ -1573,6 +1573,7 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb, - struct media_request *req) - { - struct vb2_buffer *vb; -+ enum vb2_buffer_state orig_state; - int ret; - - if (q->error) { -@@ -1673,6 +1674,7 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb, - * Add to the queued buffers list, a buffer will stay on it until - * dequeued in dqbuf. - */ -+ orig_state = vb->state; - list_add_tail(&vb->queued_entry, &q->queued_list); - q->queued_count++; - q->waiting_for_buffers = false; -@@ -1703,8 +1705,17 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb, - if (q->streaming && !q->start_streaming_called && - q->queued_count >= q->min_buffers_needed) { - ret = vb2_start_streaming(q); -- if (ret) -+ if (ret) { -+ /* -+ * Since vb2_core_qbuf will return with an error, -+ * we should return it to state DEQUEUED since -+ * the error indicates that the buffer wasn't queued. -+ */ -+ list_del(&vb->queued_entry); -+ q->queued_count--; -+ vb->state = orig_state; - return ret; -+ } - } - - dprintk(q, 2, "qbuf of buffer %d succeeded\n", vb->index); -diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c -index 97ed17a141bbf..a6124472cb06f 100644 ---- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c -+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c -@@ -37,7 +37,16 @@ static int rtl28xxu_ctrl_msg(struct dvb_usb_device *d, struct rtl28xxu_req *req) - } else { - /* read */ - requesttype = (USB_TYPE_VENDOR | USB_DIR_IN); -- pipe = usb_rcvctrlpipe(d->udev, 0); -+ -+ /* -+ * Zero-length transfers must use usb_sndctrlpipe() and -+ * rtl28xxu_identify_state() uses a zero-length i2c read -+ * command to determine the chip type. -+ */ -+ if (req->size) -+ pipe = usb_rcvctrlpipe(d->udev, 0); -+ else -+ pipe = usb_sndctrlpipe(d->udev, 0); - } - - ret = usb_control_msg(d->udev, pipe, 0, requesttype, req->value, -diff --git a/drivers/net/dsa/qca/ar9331.c b/drivers/net/dsa/qca/ar9331.c -index ca2ad77b71f1c..6686192e1883e 100644 ---- a/drivers/net/dsa/qca/ar9331.c -+++ b/drivers/net/dsa/qca/ar9331.c -@@ -837,16 +837,24 @@ static int ar9331_mdio_write(void *ctx, u32 reg, u32 val) - return 0; - } - -- ret = __ar9331_mdio_write(sbus, AR9331_SW_MDIO_PHY_MODE_REG, reg, val); -+ /* In case of this switch we work with 32bit registers on top of 16bit -+ * bus. Some registers (for example access to forwarding database) have -+ * trigger bit on the first 16bit half of request, the result and -+ * configuration of request in the second half. -+ * To make it work properly, we should do the second part of transfer -+ * before the first one is done. -+ */ -+ ret = __ar9331_mdio_write(sbus, AR9331_SW_MDIO_PHY_MODE_REG, reg + 2, -+ val >> 16); - if (ret < 0) - goto error; - -- ret = __ar9331_mdio_write(sbus, AR9331_SW_MDIO_PHY_MODE_REG, reg + 2, -- val >> 16); -+ ret = __ar9331_mdio_write(sbus, AR9331_SW_MDIO_PHY_MODE_REG, reg, val); - if (ret < 0) - goto error; - - return 0; -+ - error: - dev_err_ratelimited(&sbus->dev, "Bus error. Failed to write register.\n"); - return ret; -diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c -index 5b7947832b877..4b05a2424623c 100644 ---- a/drivers/net/dsa/sja1105/sja1105_main.c -+++ b/drivers/net/dsa/sja1105/sja1105_main.c -@@ -1308,10 +1308,11 @@ static int sja1105et_is_fdb_entry_in_bin(struct sja1105_private *priv, int bin, - int sja1105et_fdb_add(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid) - { -- struct sja1105_l2_lookup_entry l2_lookup = {0}; -+ struct sja1105_l2_lookup_entry l2_lookup = {0}, tmp; - struct sja1105_private *priv = ds->priv; - struct device *dev = ds->dev; - int last_unused = -1; -+ int start, end, i; - int bin, way, rc; - - bin = sja1105et_fdb_hash(priv, addr, vid); -@@ -1323,7 +1324,7 @@ int sja1105et_fdb_add(struct dsa_switch *ds, int port, - * mask? If yes, we need to do nothing. If not, we need - * to rewrite the entry by adding this port to it. - */ -- if (l2_lookup.destports & BIT(port)) -+ if ((l2_lookup.destports & BIT(port)) && l2_lookup.lockeds) - return 0; - l2_lookup.destports |= BIT(port); - } else { -@@ -1354,6 +1355,7 @@ int sja1105et_fdb_add(struct dsa_switch *ds, int port, - index, NULL, false); - } - } -+ l2_lookup.lockeds = true; - l2_lookup.index = sja1105et_fdb_index(bin, way); - - rc = sja1105_dynamic_config_write(priv, BLK_IDX_L2_LOOKUP, -@@ -1362,6 +1364,29 @@ int sja1105et_fdb_add(struct dsa_switch *ds, int port, - if (rc < 0) - return rc; - -+ /* Invalidate a dynamically learned entry if that exists */ -+ start = sja1105et_fdb_index(bin, 0); -+ end = sja1105et_fdb_index(bin, way); -+ -+ for (i = start; i < end; i++) { -+ rc = sja1105_dynamic_config_read(priv, BLK_IDX_L2_LOOKUP, -+ i, &tmp); -+ if (rc == -ENOENT) -+ continue; -+ if (rc) -+ return rc; -+ -+ if (tmp.macaddr != ether_addr_to_u64(addr) || tmp.vlanid != vid) -+ continue; -+ -+ rc = sja1105_dynamic_config_write(priv, BLK_IDX_L2_LOOKUP, -+ i, NULL, false); -+ if (rc) -+ return rc; -+ -+ break; -+ } -+ - return sja1105_static_fdb_change(priv, port, &l2_lookup, true); - } - -@@ -1403,32 +1428,30 @@ int sja1105et_fdb_del(struct dsa_switch *ds, int port, - int sja1105pqrs_fdb_add(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid) - { -- struct sja1105_l2_lookup_entry l2_lookup = {0}; -+ struct sja1105_l2_lookup_entry l2_lookup = {0}, tmp; - struct sja1105_private *priv = ds->priv; - int rc, i; - - /* Search for an existing entry in the FDB table */ - l2_lookup.macaddr = ether_addr_to_u64(addr); - l2_lookup.vlanid = vid; -- l2_lookup.iotag = SJA1105_S_TAG; - l2_lookup.mask_macaddr = GENMASK_ULL(ETH_ALEN * 8 - 1, 0); -- if (priv->vlan_state != SJA1105_VLAN_UNAWARE) { -- l2_lookup.mask_vlanid = VLAN_VID_MASK; -- l2_lookup.mask_iotag = BIT(0); -- } else { -- l2_lookup.mask_vlanid = 0; -- l2_lookup.mask_iotag = 0; -- } -+ l2_lookup.mask_vlanid = VLAN_VID_MASK; - l2_lookup.destports = BIT(port); - -+ tmp = l2_lookup; -+ - rc = sja1105_dynamic_config_read(priv, BLK_IDX_L2_LOOKUP, -- SJA1105_SEARCH, &l2_lookup); -- if (rc == 0) { -- /* Found and this port is already in the entry's -+ SJA1105_SEARCH, &tmp); -+ if (rc == 0 && tmp.index != SJA1105_MAX_L2_LOOKUP_COUNT - 1) { -+ /* Found a static entry and this port is already in the entry's - * port mask => job done - */ -- if (l2_lookup.destports & BIT(port)) -+ if ((tmp.destports & BIT(port)) && tmp.lockeds) - return 0; -+ -+ l2_lookup = tmp; -+ - /* l2_lookup.index is populated by the switch in case it - * found something. - */ -@@ -1450,16 +1473,46 @@ int sja1105pqrs_fdb_add(struct dsa_switch *ds, int port, - dev_err(ds->dev, "FDB is full, cannot add entry.\n"); - return -EINVAL; - } -- l2_lookup.lockeds = true; - l2_lookup.index = i; - - skip_finding_an_index: -+ l2_lookup.lockeds = true; -+ - rc = sja1105_dynamic_config_write(priv, BLK_IDX_L2_LOOKUP, - l2_lookup.index, &l2_lookup, - true); - if (rc < 0) - return rc; - -+ /* The switch learns dynamic entries and looks up the FDB left to -+ * right. It is possible that our addition was concurrent with the -+ * dynamic learning of the same address, so now that the static entry -+ * has been installed, we are certain that address learning for this -+ * particular address has been turned off, so the dynamic entry either -+ * is in the FDB at an index smaller than the static one, or isn't (it -+ * can also be at a larger index, but in that case it is inactive -+ * because the static FDB entry will match first, and the dynamic one -+ * will eventually age out). Search for a dynamically learned address -+ * prior to our static one and invalidate it. -+ */ -+ tmp = l2_lookup; -+ -+ rc = sja1105_dynamic_config_read(priv, BLK_IDX_L2_LOOKUP, -+ SJA1105_SEARCH, &tmp); -+ if (rc < 0) { -+ dev_err(ds->dev, -+ "port %d failed to read back entry for %pM vid %d: %pe\n", -+ port, addr, vid, ERR_PTR(rc)); -+ return rc; -+ } -+ -+ if (tmp.index < l2_lookup.index) { -+ rc = sja1105_dynamic_config_write(priv, BLK_IDX_L2_LOOKUP, -+ tmp.index, NULL, false); -+ if (rc < 0) -+ return rc; -+ } -+ - return sja1105_static_fdb_change(priv, port, &l2_lookup, true); - } - -@@ -1473,15 +1526,8 @@ int sja1105pqrs_fdb_del(struct dsa_switch *ds, int port, - - l2_lookup.macaddr = ether_addr_to_u64(addr); - l2_lookup.vlanid = vid; -- l2_lookup.iotag = SJA1105_S_TAG; - l2_lookup.mask_macaddr = GENMASK_ULL(ETH_ALEN * 8 - 1, 0); -- if (priv->vlan_state != SJA1105_VLAN_UNAWARE) { -- l2_lookup.mask_vlanid = VLAN_VID_MASK; -- l2_lookup.mask_iotag = BIT(0); -- } else { -- l2_lookup.mask_vlanid = 0; -- l2_lookup.mask_iotag = 0; -- } -+ l2_lookup.mask_vlanid = VLAN_VID_MASK; - l2_lookup.destports = BIT(port); - - rc = sja1105_dynamic_config_read(priv, BLK_IDX_L2_LOOKUP, -diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c -index 1a6ec1a12d531..b5d954cb409ae 100644 ---- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c -+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c -@@ -2669,7 +2669,8 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode) - } - - /* Allocated memory for FW statistics */ -- if (bnx2x_alloc_fw_stats_mem(bp)) -+ rc = bnx2x_alloc_fw_stats_mem(bp); -+ if (rc) - LOAD_ERROR_EXIT(bp, load_error0); - - /* request pf to initialize status blocks */ -diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c -index 8aea707a65a77..7e4c4980ced79 100644 ---- a/drivers/net/ethernet/freescale/fec_main.c -+++ b/drivers/net/ethernet/freescale/fec_main.c -@@ -3843,13 +3843,13 @@ fec_drv_remove(struct platform_device *pdev) - if (of_phy_is_fixed_link(np)) - of_phy_deregister_fixed_link(np); - of_node_put(fep->phy_node); -- free_netdev(ndev); - - clk_disable_unprepare(fep->clk_ahb); - clk_disable_unprepare(fep->clk_ipg); - pm_runtime_put_noidle(&pdev->dev); - pm_runtime_disable(&pdev->dev); - -+ free_netdev(ndev); - return 0; - } - -diff --git a/drivers/net/ethernet/natsemi/natsemi.c b/drivers/net/ethernet/natsemi/natsemi.c -index b81e1487945c8..14a17ad730f03 100644 ---- a/drivers/net/ethernet/natsemi/natsemi.c -+++ b/drivers/net/ethernet/natsemi/natsemi.c -@@ -819,7 +819,7 @@ static int natsemi_probe1(struct pci_dev *pdev, const struct pci_device_id *ent) - printk(version); - #endif - -- i = pci_enable_device(pdev); -+ i = pcim_enable_device(pdev); - if (i) return i; - - /* natsemi has a non-standard PM control register -@@ -852,7 +852,7 @@ static int natsemi_probe1(struct pci_dev *pdev, const struct pci_device_id *ent) - ioaddr = ioremap(iostart, iosize); - if (!ioaddr) { - i = -ENOMEM; -- goto err_ioremap; -+ goto err_pci_request_regions; - } - - /* Work around the dropped serial bit. */ -@@ -974,9 +974,6 @@ static int natsemi_probe1(struct pci_dev *pdev, const struct pci_device_id *ent) - err_register_netdev: - iounmap(ioaddr); - -- err_ioremap: -- pci_release_regions(pdev); -- - err_pci_request_regions: - free_netdev(dev); - return i; -@@ -3241,7 +3238,6 @@ static void natsemi_remove1(struct pci_dev *pdev) - - NATSEMI_REMOVE_FILE(pdev, dspcfg_workaround); - unregister_netdev (dev); -- pci_release_regions (pdev); - iounmap(ioaddr); - free_netdev (dev); - } -diff --git a/drivers/net/ethernet/neterion/vxge/vxge-main.c b/drivers/net/ethernet/neterion/vxge/vxge-main.c -index 87892bd992b18..56556373548c4 100644 ---- a/drivers/net/ethernet/neterion/vxge/vxge-main.c -+++ b/drivers/net/ethernet/neterion/vxge/vxge-main.c -@@ -3527,13 +3527,13 @@ static void vxge_device_unregister(struct __vxge_hw_device *hldev) - - kfree(vdev->vpaths); - -- /* we are safe to free it now */ -- free_netdev(dev); -- - vxge_debug_init(vdev->level_trace, "%s: ethernet device unregistered", - buf); - vxge_debug_entryexit(vdev->level_trace, "%s: %s:%d Exiting...", buf, - __func__, __LINE__); -+ -+ /* we are safe to free it now */ -+ free_netdev(dev); - } - - /* -diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c b/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c -index 1b482446536dc..8803faadd3020 100644 ---- a/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c -+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c -@@ -286,6 +286,8 @@ nfp_net_get_link_ksettings(struct net_device *netdev, - - /* Init to unknowns */ - ethtool_link_ksettings_add_link_mode(cmd, supported, FIBRE); -+ ethtool_link_ksettings_add_link_mode(cmd, supported, Pause); -+ ethtool_link_ksettings_add_link_mode(cmd, advertising, Pause); - cmd->base.port = PORT_OTHER; - cmd->base.speed = SPEED_UNKNOWN; - cmd->base.duplex = DUPLEX_UNKNOWN; -diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c -index c59b72c902932..a2e4dfb5cb44e 100644 ---- a/drivers/net/ethernet/qlogic/qede/qede_filter.c -+++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c -@@ -831,7 +831,7 @@ int qede_configure_vlan_filters(struct qede_dev *edev) - int qede_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, u16 vid) - { - struct qede_dev *edev = netdev_priv(dev); -- struct qede_vlan *vlan = NULL; -+ struct qede_vlan *vlan; - int rc = 0; - - DP_VERBOSE(edev, NETIF_MSG_IFDOWN, "Removing vlan 0x%04x\n", vid); -@@ -842,7 +842,7 @@ int qede_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, u16 vid) - if (vlan->vid == vid) - break; - -- if (!vlan || (vlan->vid != vid)) { -+ if (list_entry_is_head(vlan, &edev->vlan_list, list)) { - DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN), - "Vlan isn't configured\n"); - goto out; -diff --git a/drivers/net/ethernet/qlogic/qla3xxx.c b/drivers/net/ethernet/qlogic/qla3xxx.c -index 2376b2729633f..c00ad57575eab 100644 ---- a/drivers/net/ethernet/qlogic/qla3xxx.c -+++ b/drivers/net/ethernet/qlogic/qla3xxx.c -@@ -154,7 +154,7 @@ static int ql_wait_for_drvr_lock(struct ql3_adapter *qdev) - "driver lock acquired\n"); - return 1; - } -- ssleep(1); -+ mdelay(1000); - } while (++i < 10); - - netdev_err(qdev->ndev, "Timed out waiting for driver lock...\n"); -@@ -3274,7 +3274,7 @@ static int ql_adapter_reset(struct ql3_adapter *qdev) - if ((value & ISP_CONTROL_SR) == 0) - break; - -- ssleep(1); -+ mdelay(1000); - } while ((--max_wait_time)); - - /* -@@ -3310,7 +3310,7 @@ static int ql_adapter_reset(struct ql3_adapter *qdev) - ispControlStatus); - if ((value & ISP_CONTROL_FSR) == 0) - break; -- ssleep(1); -+ mdelay(1000); - } while ((--max_wait_time)); - } - if (max_wait_time == 0) -diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c -index 718539cdd2f2e..67a08cbba859d 100644 ---- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c -+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c -@@ -2060,8 +2060,12 @@ static void am65_cpsw_port_offload_fwd_mark_update(struct am65_cpsw_common *comm - - for (i = 1; i <= common->port_num; i++) { - struct am65_cpsw_port *port = am65_common_get_port(common, i); -- struct am65_cpsw_ndev_priv *priv = am65_ndev_to_priv(port->ndev); -+ struct am65_cpsw_ndev_priv *priv; - -+ if (!port->ndev) -+ continue; -+ -+ priv = am65_ndev_to_priv(port->ndev); - priv->offload_fwd_mark = set_val; - } - } -diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c -index a14a00328fa37..7afd9edaf2490 100644 ---- a/drivers/net/phy/micrel.c -+++ b/drivers/net/phy/micrel.c -@@ -382,11 +382,11 @@ static int ksz8041_config_aneg(struct phy_device *phydev) - } - - static int ksz8051_ksz8795_match_phy_device(struct phy_device *phydev, -- const u32 ksz_phy_id) -+ const bool ksz_8051) - { - int ret; - -- if ((phydev->phy_id & MICREL_PHY_ID_MASK) != ksz_phy_id) -+ if ((phydev->phy_id & MICREL_PHY_ID_MASK) != PHY_ID_KSZ8051) - return 0; - - ret = phy_read(phydev, MII_BMSR); -@@ -399,7 +399,7 @@ static int ksz8051_ksz8795_match_phy_device(struct phy_device *phydev, - * the switch does not. - */ - ret &= BMSR_ERCAP; -- if (ksz_phy_id == PHY_ID_KSZ8051) -+ if (ksz_8051) - return ret; - else - return !ret; -@@ -407,7 +407,7 @@ static int ksz8051_ksz8795_match_phy_device(struct phy_device *phydev, - - static int ksz8051_match_phy_device(struct phy_device *phydev) - { -- return ksz8051_ksz8795_match_phy_device(phydev, PHY_ID_KSZ8051); -+ return ksz8051_ksz8795_match_phy_device(phydev, true); - } - - static int ksz8081_config_init(struct phy_device *phydev) -@@ -435,7 +435,7 @@ static int ksz8061_config_init(struct phy_device *phydev) - - static int ksz8795_match_phy_device(struct phy_device *phydev) - { -- return ksz8051_ksz8795_match_phy_device(phydev, PHY_ID_KSZ87XX); -+ return ksz8051_ksz8795_match_phy_device(phydev, false); - } - - static int ksz9021_load_values_from_of(struct phy_device *phydev, -diff --git a/drivers/net/usb/pegasus.c b/drivers/net/usb/pegasus.c -index 9a907182569cf..bc2dbf86496b5 100644 ---- a/drivers/net/usb/pegasus.c -+++ b/drivers/net/usb/pegasus.c -@@ -735,12 +735,16 @@ static inline void disable_net_traffic(pegasus_t *pegasus) - set_registers(pegasus, EthCtrl0, sizeof(tmp), &tmp); - } - --static inline void get_interrupt_interval(pegasus_t *pegasus) -+static inline int get_interrupt_interval(pegasus_t *pegasus) - { - u16 data; - u8 interval; -+ int ret; -+ -+ ret = read_eprom_word(pegasus, 4, &data); -+ if (ret < 0) -+ return ret; - -- read_eprom_word(pegasus, 4, &data); - interval = data >> 8; - if (pegasus->usb->speed != USB_SPEED_HIGH) { - if (interval < 0x80) { -@@ -755,6 +759,8 @@ static inline void get_interrupt_interval(pegasus_t *pegasus) - } - } - pegasus->intr_interval = interval; -+ -+ return 0; - } - - static void set_carrier(struct net_device *net) -@@ -1149,7 +1155,9 @@ static int pegasus_probe(struct usb_interface *intf, - | NETIF_MSG_PROBE | NETIF_MSG_LINK); - - pegasus->features = usb_dev_id[dev_index].private; -- get_interrupt_interval(pegasus); -+ res = get_interrupt_interval(pegasus); -+ if (res) -+ goto out2; - if (reset_mac(pegasus)) { - dev_err(&intf->dev, "can't reset MAC\n"); - res = -EIO; -diff --git a/drivers/net/wireless/virt_wifi.c b/drivers/net/wireless/virt_wifi.c -index 1df959532c7d3..514f2c1124b61 100644 ---- a/drivers/net/wireless/virt_wifi.c -+++ b/drivers/net/wireless/virt_wifi.c -@@ -136,6 +136,29 @@ static struct ieee80211_supported_band band_5ghz = { - /* Assigned at module init. Guaranteed locally-administered and unicast. */ - static u8 fake_router_bssid[ETH_ALEN] __ro_after_init = {}; - -+static void virt_wifi_inform_bss(struct wiphy *wiphy) -+{ -+ u64 tsf = div_u64(ktime_get_boottime_ns(), 1000); -+ struct cfg80211_bss *informed_bss; -+ static const struct { -+ u8 tag; -+ u8 len; -+ u8 ssid[8]; -+ } __packed ssid = { -+ .tag = WLAN_EID_SSID, -+ .len = 8, -+ .ssid = "VirtWifi", -+ }; -+ -+ informed_bss = cfg80211_inform_bss(wiphy, &channel_5ghz, -+ CFG80211_BSS_FTYPE_PRESP, -+ fake_router_bssid, tsf, -+ WLAN_CAPABILITY_ESS, 0, -+ (void *)&ssid, sizeof(ssid), -+ DBM_TO_MBM(-50), GFP_KERNEL); -+ cfg80211_put_bss(wiphy, informed_bss); -+} -+ - /* Called with the rtnl lock held. */ - static int virt_wifi_scan(struct wiphy *wiphy, - struct cfg80211_scan_request *request) -@@ -156,28 +179,13 @@ static int virt_wifi_scan(struct wiphy *wiphy, - /* Acquires and releases the rdev BSS lock. */ - static void virt_wifi_scan_result(struct work_struct *work) - { -- struct { -- u8 tag; -- u8 len; -- u8 ssid[8]; -- } __packed ssid = { -- .tag = WLAN_EID_SSID, .len = 8, .ssid = "VirtWifi", -- }; -- struct cfg80211_bss *informed_bss; - struct virt_wifi_wiphy_priv *priv = - container_of(work, struct virt_wifi_wiphy_priv, - scan_result.work); - struct wiphy *wiphy = priv_to_wiphy(priv); - struct cfg80211_scan_info scan_info = { .aborted = false }; -- u64 tsf = div_u64(ktime_get_boottime_ns(), 1000); - -- informed_bss = cfg80211_inform_bss(wiphy, &channel_5ghz, -- CFG80211_BSS_FTYPE_PRESP, -- fake_router_bssid, tsf, -- WLAN_CAPABILITY_ESS, 0, -- (void *)&ssid, sizeof(ssid), -- DBM_TO_MBM(-50), GFP_KERNEL); -- cfg80211_put_bss(wiphy, informed_bss); -+ virt_wifi_inform_bss(wiphy); - - /* Schedules work which acquires and releases the rtnl lock. */ - cfg80211_scan_done(priv->scan_request, &scan_info); -@@ -225,10 +233,12 @@ static int virt_wifi_connect(struct wiphy *wiphy, struct net_device *netdev, - if (!could_schedule) - return -EBUSY; - -- if (sme->bssid) -+ if (sme->bssid) { - ether_addr_copy(priv->connect_requested_bss, sme->bssid); -- else -+ } else { -+ virt_wifi_inform_bss(wiphy); - eth_zero_addr(priv->connect_requested_bss); -+ } - - wiphy_debug(wiphy, "connect\n"); - -@@ -241,11 +251,13 @@ static void virt_wifi_connect_complete(struct work_struct *work) - struct virt_wifi_netdev_priv *priv = - container_of(work, struct virt_wifi_netdev_priv, connect.work); - u8 *requested_bss = priv->connect_requested_bss; -- bool has_addr = !is_zero_ether_addr(requested_bss); - bool right_addr = ether_addr_equal(requested_bss, fake_router_bssid); - u16 status = WLAN_STATUS_SUCCESS; - -- if (!priv->is_up || (has_addr && !right_addr)) -+ if (is_zero_ether_addr(requested_bss)) -+ requested_bss = NULL; -+ -+ if (!priv->is_up || (requested_bss && !right_addr)) - status = WLAN_STATUS_UNSPECIFIED_FAILURE; - else - priv->is_connected = true; -diff --git a/drivers/pcmcia/i82092.c b/drivers/pcmcia/i82092.c -index 85887d885b5f3..192c9049d654f 100644 ---- a/drivers/pcmcia/i82092.c -+++ b/drivers/pcmcia/i82092.c -@@ -112,6 +112,7 @@ static int i82092aa_pci_probe(struct pci_dev *dev, - for (i = 0; i < socket_count; i++) { - sockets[i].card_state = 1; /* 1 = present but empty */ - sockets[i].io_base = pci_resource_start(dev, 0); -+ sockets[i].dev = dev; - sockets[i].socket.features |= SS_CAP_PCCARD; - sockets[i].socket.map_size = 0x1000; - sockets[i].socket.irq_mask = 0; -diff --git a/drivers/platform/x86/gigabyte-wmi.c b/drivers/platform/x86/gigabyte-wmi.c -index 5529d7b0abea3..fbb224a82e34c 100644 ---- a/drivers/platform/x86/gigabyte-wmi.c -+++ b/drivers/platform/x86/gigabyte-wmi.c -@@ -141,6 +141,7 @@ static u8 gigabyte_wmi_detect_sensor_usability(struct wmi_device *wdev) - - static const struct dmi_system_id gigabyte_wmi_known_working_platforms[] = { - DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B550 AORUS ELITE"), -+ DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B550 AORUS ELITE V2"), - DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B550 GAMING X V2"), - DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B550M AORUS PRO-P"), - DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B550M DS3H"), -diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c -index a6ac505cbdd7d..701c1d0094ec6 100644 ---- a/drivers/s390/block/dasd_eckd.c -+++ b/drivers/s390/block/dasd_eckd.c -@@ -1004,15 +1004,23 @@ static unsigned char dasd_eckd_path_access(void *conf_data, int conf_len) - static void dasd_eckd_store_conf_data(struct dasd_device *device, - struct dasd_conf_data *conf_data, int chp) - { -+ struct dasd_eckd_private *private = device->private; - struct channel_path_desc_fmt0 *chp_desc; - struct subchannel_id sch_id; -+ void *cdp; - -- ccw_device_get_schid(device->cdev, &sch_id); - /* - * path handling and read_conf allocate data - * free it before replacing the pointer -+ * also replace the old private->conf_data pointer -+ * with the new one if this points to the same data - */ -- kfree(device->path[chp].conf_data); -+ cdp = device->path[chp].conf_data; -+ if (private->conf_data == cdp) { -+ private->conf_data = (void *)conf_data; -+ dasd_eckd_identify_conf_parts(private); -+ } -+ ccw_device_get_schid(device->cdev, &sch_id); - device->path[chp].conf_data = conf_data; - device->path[chp].cssid = sch_id.cssid; - device->path[chp].ssid = sch_id.ssid; -@@ -1020,6 +1028,7 @@ static void dasd_eckd_store_conf_data(struct dasd_device *device, - if (chp_desc) - device->path[chp].chpid = chp_desc->chpid; - kfree(chp_desc); -+ kfree(cdp); - } - - static void dasd_eckd_clear_conf_data(struct dasd_device *device) -diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c -index 6540d48eb0e8e..23fd361343b48 100644 ---- a/drivers/scsi/ibmvscsi/ibmvfc.c -+++ b/drivers/scsi/ibmvscsi/ibmvfc.c -@@ -804,6 +804,13 @@ static int ibmvfc_init_event_pool(struct ibmvfc_host *vhost, - for (i = 0; i < size; ++i) { - struct ibmvfc_event *evt = &pool->events[i]; - -+ /* -+ * evt->active states -+ * 1 = in flight -+ * 0 = being completed -+ * -1 = free/freed -+ */ -+ atomic_set(&evt->active, -1); - atomic_set(&evt->free, 1); - evt->crq.valid = 0x80; - evt->crq.ioba = cpu_to_be64(pool->iu_token + (sizeof(*evt->xfer_iu) * i)); -@@ -1014,6 +1021,7 @@ static void ibmvfc_free_event(struct ibmvfc_event *evt) - - BUG_ON(!ibmvfc_valid_event(pool, evt)); - BUG_ON(atomic_inc_return(&evt->free) != 1); -+ BUG_ON(atomic_dec_and_test(&evt->active)); - - spin_lock_irqsave(&evt->queue->l_lock, flags); - list_add_tail(&evt->queue_list, &evt->queue->free); -@@ -1069,6 +1077,12 @@ static void ibmvfc_complete_purge(struct list_head *purge_list) - **/ - static void ibmvfc_fail_request(struct ibmvfc_event *evt, int error_code) - { -+ /* -+ * Anything we are failing should still be active. Otherwise, it -+ * implies we already got a response for the command and are doing -+ * something bad like double completing it. -+ */ -+ BUG_ON(!atomic_dec_and_test(&evt->active)); - if (evt->cmnd) { - evt->cmnd->result = (error_code << 16); - evt->done = ibmvfc_scsi_eh_done; -@@ -1720,6 +1734,7 @@ static int ibmvfc_send_event(struct ibmvfc_event *evt, - - evt->done(evt); - } else { -+ atomic_set(&evt->active, 1); - spin_unlock_irqrestore(&evt->queue->l_lock, flags); - ibmvfc_trc_start(evt); - } -@@ -3248,7 +3263,7 @@ static void ibmvfc_handle_crq(struct ibmvfc_crq *crq, struct ibmvfc_host *vhost, - return; - } - -- if (unlikely(atomic_read(&evt->free))) { -+ if (unlikely(atomic_dec_if_positive(&evt->active))) { - dev_err(vhost->dev, "Received duplicate correlation_token 0x%08llx!\n", - crq->ioba); - return; -@@ -3775,7 +3790,7 @@ static void ibmvfc_handle_scrq(struct ibmvfc_crq *crq, struct ibmvfc_host *vhost - return; - } - -- if (unlikely(atomic_read(&evt->free))) { -+ if (unlikely(atomic_dec_if_positive(&evt->active))) { - dev_err(vhost->dev, "Received duplicate correlation_token 0x%08llx!\n", - crq->ioba); - return; -diff --git a/drivers/scsi/ibmvscsi/ibmvfc.h b/drivers/scsi/ibmvscsi/ibmvfc.h -index 19dcec3ae9ba7..994846ec64c6b 100644 ---- a/drivers/scsi/ibmvscsi/ibmvfc.h -+++ b/drivers/scsi/ibmvscsi/ibmvfc.h -@@ -744,6 +744,7 @@ struct ibmvfc_event { - struct ibmvfc_target *tgt; - struct scsi_cmnd *cmnd; - atomic_t free; -+ atomic_t active; - union ibmvfc_iu *xfer_iu; - void (*done)(struct ibmvfc_event *evt); - void (*_done)(struct ibmvfc_event *evt); -diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c -index 1a94c7b1de2df..261d3663cbb70 100644 ---- a/drivers/scsi/sr.c -+++ b/drivers/scsi/sr.c -@@ -221,7 +221,7 @@ static unsigned int sr_get_events(struct scsi_device *sdev) - else if (med->media_event_code == 2) - return DISK_EVENT_MEDIA_CHANGE; - else if (med->media_event_code == 3) -- return DISK_EVENT_EJECT_REQUEST; -+ return DISK_EVENT_MEDIA_CHANGE; - return 0; - } - -diff --git a/drivers/soc/imx/soc-imx8m.c b/drivers/soc/imx/soc-imx8m.c -index 071e14496e4ba..cc57a384d74d2 100644 ---- a/drivers/soc/imx/soc-imx8m.c -+++ b/drivers/soc/imx/soc-imx8m.c -@@ -5,8 +5,6 @@ - - #include - #include --#include --#include - #include - #include - #include -@@ -31,7 +29,7 @@ - - struct imx8_soc_data { - char *name; -- u32 (*soc_revision)(struct device *dev); -+ u32 (*soc_revision)(void); - }; - - static u64 soc_uid; -@@ -52,7 +50,7 @@ static u32 imx8mq_soc_revision_from_atf(void) - static inline u32 imx8mq_soc_revision_from_atf(void) { return 0; }; - #endif - --static u32 __init imx8mq_soc_revision(struct device *dev) -+static u32 __init imx8mq_soc_revision(void) - { - struct device_node *np; - void __iomem *ocotp_base; -@@ -77,20 +75,9 @@ static u32 __init imx8mq_soc_revision(struct device *dev) - rev = REV_B1; - } - -- if (dev) { -- int ret; -- -- ret = nvmem_cell_read_u64(dev, "soc_unique_id", &soc_uid); -- if (ret) { -- iounmap(ocotp_base); -- of_node_put(np); -- return ret; -- } -- } else { -- soc_uid = readl_relaxed(ocotp_base + OCOTP_UID_HIGH); -- soc_uid <<= 32; -- soc_uid |= readl_relaxed(ocotp_base + OCOTP_UID_LOW); -- } -+ soc_uid = readl_relaxed(ocotp_base + OCOTP_UID_HIGH); -+ soc_uid <<= 32; -+ soc_uid |= readl_relaxed(ocotp_base + OCOTP_UID_LOW); - - iounmap(ocotp_base); - of_node_put(np); -@@ -120,7 +107,7 @@ static void __init imx8mm_soc_uid(void) - of_node_put(np); - } - --static u32 __init imx8mm_soc_revision(struct device *dev) -+static u32 __init imx8mm_soc_revision(void) - { - struct device_node *np; - void __iomem *anatop_base; -@@ -138,15 +125,7 @@ static u32 __init imx8mm_soc_revision(struct device *dev) - iounmap(anatop_base); - of_node_put(np); - -- if (dev) { -- int ret; -- -- ret = nvmem_cell_read_u64(dev, "soc_unique_id", &soc_uid); -- if (ret) -- return ret; -- } else { -- imx8mm_soc_uid(); -- } -+ imx8mm_soc_uid(); - - return rev; - } -@@ -171,7 +150,7 @@ static const struct imx8_soc_data imx8mp_soc_data = { - .soc_revision = imx8mm_soc_revision, - }; - --static __maybe_unused const struct of_device_id imx8_machine_match[] = { -+static __maybe_unused const struct of_device_id imx8_soc_match[] = { - { .compatible = "fsl,imx8mq", .data = &imx8mq_soc_data, }, - { .compatible = "fsl,imx8mm", .data = &imx8mm_soc_data, }, - { .compatible = "fsl,imx8mn", .data = &imx8mn_soc_data, }, -@@ -179,20 +158,12 @@ static __maybe_unused const struct of_device_id imx8_machine_match[] = { - { } - }; - --static __maybe_unused const struct of_device_id imx8_soc_match[] = { -- { .compatible = "fsl,imx8mq-soc", .data = &imx8mq_soc_data, }, -- { .compatible = "fsl,imx8mm-soc", .data = &imx8mm_soc_data, }, -- { .compatible = "fsl,imx8mn-soc", .data = &imx8mn_soc_data, }, -- { .compatible = "fsl,imx8mp-soc", .data = &imx8mp_soc_data, }, -- { } --}; -- - #define imx8_revision(soc_rev) \ - soc_rev ? \ - kasprintf(GFP_KERNEL, "%d.%d", (soc_rev >> 4) & 0xf, soc_rev & 0xf) : \ - "unknown" - --static int imx8_soc_info(struct platform_device *pdev) -+static int __init imx8_soc_init(void) - { - struct soc_device_attribute *soc_dev_attr; - struct soc_device *soc_dev; -@@ -211,10 +182,7 @@ static int imx8_soc_info(struct platform_device *pdev) - if (ret) - goto free_soc; - -- if (pdev) -- id = of_match_node(imx8_soc_match, pdev->dev.of_node); -- else -- id = of_match_node(imx8_machine_match, of_root); -+ id = of_match_node(imx8_soc_match, of_root); - if (!id) { - ret = -ENODEV; - goto free_soc; -@@ -223,16 +191,8 @@ static int imx8_soc_info(struct platform_device *pdev) - data = id->data; - if (data) { - soc_dev_attr->soc_id = data->name; -- if (data->soc_revision) { -- if (pdev) { -- soc_rev = data->soc_revision(&pdev->dev); -- ret = soc_rev; -- if (ret < 0) -- goto free_soc; -- } else { -- soc_rev = data->soc_revision(NULL); -- } -- } -+ if (data->soc_revision) -+ soc_rev = data->soc_revision(); - } - - soc_dev_attr->revision = imx8_revision(soc_rev); -@@ -270,24 +230,4 @@ free_soc: - kfree(soc_dev_attr); - return ret; - } -- --/* Retain device_initcall is for backward compatibility with DTS. */ --static int __init imx8_soc_init(void) --{ -- if (of_find_matching_node_and_match(NULL, imx8_soc_match, NULL)) -- return 0; -- -- return imx8_soc_info(NULL); --} - device_initcall(imx8_soc_init); -- --static struct platform_driver imx8_soc_info_driver = { -- .probe = imx8_soc_info, -- .driver = { -- .name = "imx8_soc_info", -- .of_match_table = imx8_soc_match, -- }, --}; -- --module_platform_driver(imx8_soc_info_driver); --MODULE_LICENSE("GPL v2"); -diff --git a/drivers/soc/ixp4xx/ixp4xx-npe.c b/drivers/soc/ixp4xx/ixp4xx-npe.c -index ec90b44fa0cd3..6065aaab67403 100644 ---- a/drivers/soc/ixp4xx/ixp4xx-npe.c -+++ b/drivers/soc/ixp4xx/ixp4xx-npe.c -@@ -690,8 +690,8 @@ static int ixp4xx_npe_probe(struct platform_device *pdev) - - if (!(ixp4xx_read_feature_bits() & - (IXP4XX_FEATURE_RESET_NPEA << i))) { -- dev_info(dev, "NPE%d at 0x%08x-0x%08x not available\n", -- i, res->start, res->end); -+ dev_info(dev, "NPE%d at %pR not available\n", -+ i, res); - continue; /* NPE already disabled or not present */ - } - npe->regs = devm_ioremap_resource(dev, res); -@@ -699,13 +699,12 @@ static int ixp4xx_npe_probe(struct platform_device *pdev) - return PTR_ERR(npe->regs); - - if (npe_reset(npe)) { -- dev_info(dev, "NPE%d at 0x%08x-0x%08x does not reset\n", -- i, res->start, res->end); -+ dev_info(dev, "NPE%d at %pR does not reset\n", -+ i, res); - continue; - } - npe->valid = 1; -- dev_info(dev, "NPE%d at 0x%08x-0x%08x registered\n", -- i, res->start, res->end); -+ dev_info(dev, "NPE%d at %pR registered\n", i, res); - found++; - } - -diff --git a/drivers/soc/ixp4xx/ixp4xx-qmgr.c b/drivers/soc/ixp4xx/ixp4xx-qmgr.c -index 8c968382cea76..065a800717bd5 100644 ---- a/drivers/soc/ixp4xx/ixp4xx-qmgr.c -+++ b/drivers/soc/ixp4xx/ixp4xx-qmgr.c -@@ -145,12 +145,12 @@ static irqreturn_t qmgr_irq1_a0(int irq, void *pdev) - /* ACK - it may clear any bits so don't rely on it */ - __raw_writel(0xFFFFFFFF, &qmgr_regs->irqstat[0]); - -- en_bitmap = qmgr_regs->irqen[0]; -+ en_bitmap = __raw_readl(&qmgr_regs->irqen[0]); - while (en_bitmap) { - i = __fls(en_bitmap); /* number of the last "low" queue */ - en_bitmap &= ~BIT(i); -- src = qmgr_regs->irqsrc[i >> 3]; -- stat = qmgr_regs->stat1[i >> 3]; -+ src = __raw_readl(&qmgr_regs->irqsrc[i >> 3]); -+ stat = __raw_readl(&qmgr_regs->stat1[i >> 3]); - if (src & 4) /* the IRQ condition is inverted */ - stat = ~stat; - if (stat & BIT(src & 3)) { -@@ -170,7 +170,8 @@ static irqreturn_t qmgr_irq2_a0(int irq, void *pdev) - /* ACK - it may clear any bits so don't rely on it */ - __raw_writel(0xFFFFFFFF, &qmgr_regs->irqstat[1]); - -- req_bitmap = qmgr_regs->irqen[1] & qmgr_regs->statne_h; -+ req_bitmap = __raw_readl(&qmgr_regs->irqen[1]) & -+ __raw_readl(&qmgr_regs->statne_h); - while (req_bitmap) { - i = __fls(req_bitmap); /* number of the last "high" queue */ - req_bitmap &= ~BIT(i); -diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c -index 39dc02e366f4b..2872993550bd5 100644 ---- a/drivers/spi/spi-imx.c -+++ b/drivers/spi/spi-imx.c -@@ -505,8 +505,10 @@ static int mx51_ecspi_prepare_message(struct spi_imx_data *spi_imx, - struct spi_message *msg) - { - struct spi_device *spi = msg->spi; -+ struct spi_transfer *xfer; - u32 ctrl = MX51_ECSPI_CTRL_ENABLE; -- u32 testreg; -+ u32 min_speed_hz = ~0U; -+ u32 testreg, delay; - u32 cfg = readl(spi_imx->base + MX51_ECSPI_CONFIG); - - /* set Master or Slave mode */ -@@ -567,6 +569,35 @@ static int mx51_ecspi_prepare_message(struct spi_imx_data *spi_imx, - - writel(cfg, spi_imx->base + MX51_ECSPI_CONFIG); - -+ /* -+ * Wait until the changes in the configuration register CONFIGREG -+ * propagate into the hardware. It takes exactly one tick of the -+ * SCLK clock, but we will wait two SCLK clock just to be sure. The -+ * effect of the delay it takes for the hardware to apply changes -+ * is noticable if the SCLK clock run very slow. In such a case, if -+ * the polarity of SCLK should be inverted, the GPIO ChipSelect might -+ * be asserted before the SCLK polarity changes, which would disrupt -+ * the SPI communication as the device on the other end would consider -+ * the change of SCLK polarity as a clock tick already. -+ * -+ * Because spi_imx->spi_bus_clk is only set in bitbang prepare_message -+ * callback, iterate over all the transfers in spi_message, find the -+ * one with lowest bus frequency, and use that bus frequency for the -+ * delay calculation. In case all transfers have speed_hz == 0, then -+ * min_speed_hz is ~0 and the resulting delay is zero. -+ */ -+ list_for_each_entry(xfer, &msg->transfers, transfer_list) { -+ if (!xfer->speed_hz) -+ continue; -+ min_speed_hz = min(xfer->speed_hz, min_speed_hz); -+ } -+ -+ delay = (2 * 1000000) / min_speed_hz; -+ if (likely(delay < 10)) /* SCLK is faster than 100 kHz */ -+ udelay(delay); -+ else /* SCLK is _very_ slow */ -+ usleep_range(delay, delay + 10); -+ - return 0; - } - -@@ -574,7 +605,7 @@ static int mx51_ecspi_prepare_transfer(struct spi_imx_data *spi_imx, - struct spi_device *spi) - { - u32 ctrl = readl(spi_imx->base + MX51_ECSPI_CTRL); -- u32 clk, delay; -+ u32 clk; - - /* Clear BL field and set the right value */ - ctrl &= ~MX51_ECSPI_CTRL_BL_MASK; -@@ -596,23 +627,6 @@ static int mx51_ecspi_prepare_transfer(struct spi_imx_data *spi_imx, - - writel(ctrl, spi_imx->base + MX51_ECSPI_CTRL); - -- /* -- * Wait until the changes in the configuration register CONFIGREG -- * propagate into the hardware. It takes exactly one tick of the -- * SCLK clock, but we will wait two SCLK clock just to be sure. The -- * effect of the delay it takes for the hardware to apply changes -- * is noticable if the SCLK clock run very slow. In such a case, if -- * the polarity of SCLK should be inverted, the GPIO ChipSelect might -- * be asserted before the SCLK polarity changes, which would disrupt -- * the SPI communication as the device on the other end would consider -- * the change of SCLK polarity as a clock tick already. -- */ -- delay = (2 * 1000000) / clk; -- if (likely(delay < 10)) /* SCLK is faster than 100 kHz */ -- udelay(delay); -- else /* SCLK is _very_ slow */ -- usleep_range(delay, delay + 10); -- - return 0; - } - -diff --git a/drivers/spi/spi-meson-spicc.c b/drivers/spi/spi-meson-spicc.c -index b2c4621db34d7..c208efeadd184 100644 ---- a/drivers/spi/spi-meson-spicc.c -+++ b/drivers/spi/spi-meson-spicc.c -@@ -785,6 +785,8 @@ static int meson_spicc_remove(struct platform_device *pdev) - clk_disable_unprepare(spicc->core); - clk_disable_unprepare(spicc->pclk); - -+ spi_master_put(spicc->master); -+ - return 0; - } - -diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c -index 22974277afa08..4eff3fdecdb8a 100644 ---- a/drivers/staging/rtl8712/hal_init.c -+++ b/drivers/staging/rtl8712/hal_init.c -@@ -29,21 +29,31 @@ - #define FWBUFF_ALIGN_SZ 512 - #define MAX_DUMP_FWSZ (48 * 1024) - -+static void rtl871x_load_fw_fail(struct _adapter *adapter) -+{ -+ struct usb_device *udev = adapter->dvobjpriv.pusbdev; -+ struct device *dev = &udev->dev; -+ struct device *parent = dev->parent; -+ -+ complete(&adapter->rtl8712_fw_ready); -+ -+ dev_err(&udev->dev, "r8712u: Firmware request failed\n"); -+ -+ if (parent) -+ device_lock(parent); -+ -+ device_release_driver(dev); -+ -+ if (parent) -+ device_unlock(parent); -+} -+ - static void rtl871x_load_fw_cb(const struct firmware *firmware, void *context) - { - struct _adapter *adapter = context; - - if (!firmware) { -- struct usb_device *udev = adapter->dvobjpriv.pusbdev; -- struct usb_interface *usb_intf = adapter->pusb_intf; -- -- dev_err(&udev->dev, "r8712u: Firmware request failed\n"); -- usb_put_dev(udev); -- usb_set_intfdata(usb_intf, NULL); -- r8712_free_drv_sw(adapter); -- adapter->dvobj_deinit(adapter); -- complete(&adapter->rtl8712_fw_ready); -- free_netdev(adapter->pnetdev); -+ rtl871x_load_fw_fail(adapter); - return; - } - adapter->fw = firmware; -diff --git a/drivers/staging/rtl8712/rtl8712_led.c b/drivers/staging/rtl8712/rtl8712_led.c -index 5901026949f25..d5fc9026b036e 100644 ---- a/drivers/staging/rtl8712/rtl8712_led.c -+++ b/drivers/staging/rtl8712/rtl8712_led.c -@@ -1820,3 +1820,11 @@ void LedControl871x(struct _adapter *padapter, enum LED_CTL_MODE LedAction) - break; - } - } -+ -+void r8712_flush_led_works(struct _adapter *padapter) -+{ -+ struct led_priv *pledpriv = &padapter->ledpriv; -+ -+ flush_work(&pledpriv->SwLed0.BlinkWorkItem); -+ flush_work(&pledpriv->SwLed1.BlinkWorkItem); -+} -diff --git a/drivers/staging/rtl8712/rtl871x_led.h b/drivers/staging/rtl8712/rtl871x_led.h -index ee19c873cf010..2f0768132ad8f 100644 ---- a/drivers/staging/rtl8712/rtl871x_led.h -+++ b/drivers/staging/rtl8712/rtl871x_led.h -@@ -112,6 +112,7 @@ struct led_priv { - void r8712_InitSwLeds(struct _adapter *padapter); - void r8712_DeInitSwLeds(struct _adapter *padapter); - void LedControl871x(struct _adapter *padapter, enum LED_CTL_MODE LedAction); -+void r8712_flush_led_works(struct _adapter *padapter); - - #endif - -diff --git a/drivers/staging/rtl8712/rtl871x_pwrctrl.c b/drivers/staging/rtl8712/rtl871x_pwrctrl.c -index 23cff43437e21..cd6d9ff0bebca 100644 ---- a/drivers/staging/rtl8712/rtl871x_pwrctrl.c -+++ b/drivers/staging/rtl8712/rtl871x_pwrctrl.c -@@ -224,3 +224,11 @@ void r8712_unregister_cmd_alive(struct _adapter *padapter) - } - mutex_unlock(&pwrctrl->mutex_lock); - } -+ -+void r8712_flush_rwctrl_works(struct _adapter *padapter) -+{ -+ struct pwrctrl_priv *pwrctrl = &padapter->pwrctrlpriv; -+ -+ flush_work(&pwrctrl->SetPSModeWorkItem); -+ flush_work(&pwrctrl->rpwm_workitem); -+} -diff --git a/drivers/staging/rtl8712/rtl871x_pwrctrl.h b/drivers/staging/rtl8712/rtl871x_pwrctrl.h -index bf6623cfaf27b..b35b9c7920ebb 100644 ---- a/drivers/staging/rtl8712/rtl871x_pwrctrl.h -+++ b/drivers/staging/rtl8712/rtl871x_pwrctrl.h -@@ -108,5 +108,6 @@ void r8712_cpwm_int_hdl(struct _adapter *padapter, - void r8712_set_ps_mode(struct _adapter *padapter, uint ps_mode, - uint smart_ps); - void r8712_set_rpwm(struct _adapter *padapter, u8 val8); -+void r8712_flush_rwctrl_works(struct _adapter *padapter); - - #endif /* __RTL871X_PWRCTRL_H_ */ -diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c -index b760bc3559373..17d28af0d0867 100644 ---- a/drivers/staging/rtl8712/usb_intf.c -+++ b/drivers/staging/rtl8712/usb_intf.c -@@ -594,35 +594,30 @@ static void r871xu_dev_remove(struct usb_interface *pusb_intf) - { - struct net_device *pnetdev = usb_get_intfdata(pusb_intf); - struct usb_device *udev = interface_to_usbdev(pusb_intf); -+ struct _adapter *padapter = netdev_priv(pnetdev); -+ -+ /* never exit with a firmware callback pending */ -+ wait_for_completion(&padapter->rtl8712_fw_ready); -+ usb_set_intfdata(pusb_intf, NULL); -+ release_firmware(padapter->fw); -+ if (drvpriv.drv_registered) -+ padapter->surprise_removed = true; -+ if (pnetdev->reg_state != NETREG_UNINITIALIZED) -+ unregister_netdev(pnetdev); /* will call netdev_close() */ -+ r8712_flush_rwctrl_works(padapter); -+ r8712_flush_led_works(padapter); -+ udelay(1); -+ /* Stop driver mlme relation timer */ -+ r8712_stop_drv_timers(padapter); -+ r871x_dev_unload(padapter); -+ r8712_free_drv_sw(padapter); -+ free_netdev(pnetdev); -+ -+ /* decrease the reference count of the usb device structure -+ * when disconnect -+ */ -+ usb_put_dev(udev); - -- if (pnetdev) { -- struct _adapter *padapter = netdev_priv(pnetdev); -- -- /* never exit with a firmware callback pending */ -- wait_for_completion(&padapter->rtl8712_fw_ready); -- pnetdev = usb_get_intfdata(pusb_intf); -- usb_set_intfdata(pusb_intf, NULL); -- if (!pnetdev) -- goto firmware_load_fail; -- release_firmware(padapter->fw); -- if (drvpriv.drv_registered) -- padapter->surprise_removed = true; -- if (pnetdev->reg_state != NETREG_UNINITIALIZED) -- unregister_netdev(pnetdev); /* will call netdev_close() */ -- flush_scheduled_work(); -- udelay(1); -- /* Stop driver mlme relation timer */ -- r8712_stop_drv_timers(padapter); -- r871x_dev_unload(padapter); -- r8712_free_drv_sw(padapter); -- free_netdev(pnetdev); -- -- /* decrease the reference count of the usb device structure -- * when disconnect -- */ -- usb_put_dev(udev); -- } --firmware_load_fail: - /* If we didn't unplug usb dongle and remove/insert module, driver - * fails on sitesurvey for the first time when device is up. - * Reset usb port for sitesurvey fail issue. -diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c -index a31694525bc1e..eaf7d689b0c55 100644 ---- a/drivers/staging/rtl8723bs/hal/sdio_ops.c -+++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c -@@ -921,6 +921,8 @@ void sd_int_dpc(struct adapter *adapter) - } else { - rtw_c2h_wk_cmd(adapter, (u8 *)c2h_evt); - } -+ } else { -+ kfree(c2h_evt); - } - } else { - /* Error handling for malloc fail */ -diff --git a/drivers/tee/optee/call.c b/drivers/tee/optee/call.c -index 6e6eb836e9b62..945f03da02237 100644 ---- a/drivers/tee/optee/call.c -+++ b/drivers/tee/optee/call.c -@@ -184,7 +184,7 @@ static struct tee_shm *get_msg_arg(struct tee_context *ctx, size_t num_params, - struct optee_msg_arg *ma; - - shm = tee_shm_alloc(ctx, OPTEE_MSG_GET_ARG_SIZE(num_params), -- TEE_SHM_MAPPED); -+ TEE_SHM_MAPPED | TEE_SHM_PRIV); - if (IS_ERR(shm)) - return shm; - -@@ -416,11 +416,13 @@ void optee_enable_shm_cache(struct optee *optee) - } - - /** -- * optee_disable_shm_cache() - Disables caching of some shared memory allocation -- * in OP-TEE -+ * __optee_disable_shm_cache() - Disables caching of some shared memory -+ * allocation in OP-TEE - * @optee: main service struct -+ * @is_mapped: true if the cached shared memory addresses were mapped by this -+ * kernel, are safe to dereference, and should be freed - */ --void optee_disable_shm_cache(struct optee *optee) -+static void __optee_disable_shm_cache(struct optee *optee, bool is_mapped) - { - struct optee_call_waiter w; - -@@ -439,6 +441,13 @@ void optee_disable_shm_cache(struct optee *optee) - if (res.result.status == OPTEE_SMC_RETURN_OK) { - struct tee_shm *shm; - -+ /* -+ * Shared memory references that were not mapped by -+ * this kernel must be ignored to prevent a crash. -+ */ -+ if (!is_mapped) -+ continue; -+ - shm = reg_pair_to_ptr(res.result.shm_upper32, - res.result.shm_lower32); - tee_shm_free(shm); -@@ -449,6 +458,27 @@ void optee_disable_shm_cache(struct optee *optee) - optee_cq_wait_final(&optee->call_queue, &w); - } - -+/** -+ * optee_disable_shm_cache() - Disables caching of mapped shared memory -+ * allocations in OP-TEE -+ * @optee: main service struct -+ */ -+void optee_disable_shm_cache(struct optee *optee) -+{ -+ return __optee_disable_shm_cache(optee, true); -+} -+ -+/** -+ * optee_disable_unmapped_shm_cache() - Disables caching of shared memory -+ * allocations in OP-TEE which are not -+ * currently mapped -+ * @optee: main service struct -+ */ -+void optee_disable_unmapped_shm_cache(struct optee *optee) -+{ -+ return __optee_disable_shm_cache(optee, false); -+} -+ - #define PAGELIST_ENTRIES_PER_PAGE \ - ((OPTEE_MSG_NONCONTIG_PAGE_SIZE / sizeof(u64)) - 1) - -diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c -index ddb8f9ecf3078..5ce13b099d7dc 100644 ---- a/drivers/tee/optee/core.c -+++ b/drivers/tee/optee/core.c -@@ -6,6 +6,7 @@ - #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - - #include -+#include - #include - #include - #include -@@ -277,7 +278,8 @@ static void optee_release(struct tee_context *ctx) - if (!ctxdata) - return; - -- shm = tee_shm_alloc(ctx, sizeof(struct optee_msg_arg), TEE_SHM_MAPPED); -+ shm = tee_shm_alloc(ctx, sizeof(struct optee_msg_arg), -+ TEE_SHM_MAPPED | TEE_SHM_PRIV); - if (!IS_ERR(shm)) { - arg = tee_shm_get_va(shm, 0); - /* -@@ -572,6 +574,13 @@ static optee_invoke_fn *get_invoke_func(struct device *dev) - return ERR_PTR(-EINVAL); - } - -+/* optee_remove - Device Removal Routine -+ * @pdev: platform device information struct -+ * -+ * optee_remove is called by platform subsystem to alert the driver -+ * that it should release the device -+ */ -+ - static int optee_remove(struct platform_device *pdev) - { - struct optee *optee = platform_get_drvdata(pdev); -@@ -602,6 +611,18 @@ static int optee_remove(struct platform_device *pdev) - return 0; - } - -+/* optee_shutdown - Device Removal Routine -+ * @pdev: platform device information struct -+ * -+ * platform_shutdown is called by the platform subsystem to alert -+ * the driver that a shutdown, reboot, or kexec is happening and -+ * device must be disabled. -+ */ -+static void optee_shutdown(struct platform_device *pdev) -+{ -+ optee_disable_shm_cache(platform_get_drvdata(pdev)); -+} -+ - static int optee_probe(struct platform_device *pdev) - { - optee_invoke_fn *invoke_fn; -@@ -612,6 +633,16 @@ static int optee_probe(struct platform_device *pdev) - u32 sec_caps; - int rc; - -+ /* -+ * The kernel may have crashed at the same time that all available -+ * secure world threads were suspended and we cannot reschedule the -+ * suspended threads without access to the crashed kernel's wait_queue. -+ * Therefore, we cannot reliably initialize the OP-TEE driver in the -+ * kdump kernel. -+ */ -+ if (is_kdump_kernel()) -+ return -ENODEV; -+ - invoke_fn = get_invoke_func(&pdev->dev); - if (IS_ERR(invoke_fn)) - return PTR_ERR(invoke_fn); -@@ -686,6 +717,15 @@ static int optee_probe(struct platform_device *pdev) - optee->memremaped_shm = memremaped_shm; - optee->pool = pool; - -+ /* -+ * Ensure that there are no pre-existing shm objects before enabling -+ * the shm cache so that there's no chance of receiving an invalid -+ * address during shutdown. This could occur, for example, if we're -+ * kexec booting from an older kernel that did not properly cleanup the -+ * shm cache. -+ */ -+ optee_disable_unmapped_shm_cache(optee); -+ - optee_enable_shm_cache(optee); - - if (optee->sec_caps & OPTEE_SMC_SEC_CAP_DYNAMIC_SHM) -@@ -728,6 +768,7 @@ MODULE_DEVICE_TABLE(of, optee_dt_match); - static struct platform_driver optee_driver = { - .probe = optee_probe, - .remove = optee_remove, -+ .shutdown = optee_shutdown, - .driver = { - .name = "optee", - .of_match_table = optee_dt_match, -diff --git a/drivers/tee/optee/optee_private.h b/drivers/tee/optee/optee_private.h -index e25b216a14ef8..dbdd367be1568 100644 ---- a/drivers/tee/optee/optee_private.h -+++ b/drivers/tee/optee/optee_private.h -@@ -159,6 +159,7 @@ int optee_cancel_req(struct tee_context *ctx, u32 cancel_id, u32 session); - - void optee_enable_shm_cache(struct optee *optee); - void optee_disable_shm_cache(struct optee *optee); -+void optee_disable_unmapped_shm_cache(struct optee *optee); - - int optee_shm_register(struct tee_context *ctx, struct tee_shm *shm, - struct page **pages, size_t num_pages, -diff --git a/drivers/tee/optee/rpc.c b/drivers/tee/optee/rpc.c -index 1849180b0278b..efbaff7ad7e59 100644 ---- a/drivers/tee/optee/rpc.c -+++ b/drivers/tee/optee/rpc.c -@@ -314,7 +314,7 @@ static void handle_rpc_func_cmd_shm_alloc(struct tee_context *ctx, - shm = cmd_alloc_suppl(ctx, sz); - break; - case OPTEE_RPC_SHM_TYPE_KERNEL: -- shm = tee_shm_alloc(ctx, sz, TEE_SHM_MAPPED); -+ shm = tee_shm_alloc(ctx, sz, TEE_SHM_MAPPED | TEE_SHM_PRIV); - break; - default: - arg->ret = TEEC_ERROR_BAD_PARAMETERS; -@@ -502,7 +502,8 @@ void optee_handle_rpc(struct tee_context *ctx, struct optee_rpc_param *param, - - switch (OPTEE_SMC_RETURN_GET_RPC_FUNC(param->a0)) { - case OPTEE_SMC_RPC_FUNC_ALLOC: -- shm = tee_shm_alloc(ctx, param->a1, TEE_SHM_MAPPED); -+ shm = tee_shm_alloc(ctx, param->a1, -+ TEE_SHM_MAPPED | TEE_SHM_PRIV); - if (!IS_ERR(shm) && !tee_shm_get_pa(shm, 0, &pa)) { - reg_pair_from_64(¶m->a1, ¶m->a2, pa); - reg_pair_from_64(¶m->a4, ¶m->a5, -diff --git a/drivers/tee/optee/shm_pool.c b/drivers/tee/optee/shm_pool.c -index d767eebf30bdd..c41a9a501a6e9 100644 ---- a/drivers/tee/optee/shm_pool.c -+++ b/drivers/tee/optee/shm_pool.c -@@ -27,13 +27,19 @@ static int pool_op_alloc(struct tee_shm_pool_mgr *poolm, - shm->paddr = page_to_phys(page); - shm->size = PAGE_SIZE << order; - -- if (shm->flags & TEE_SHM_DMA_BUF) { -+ /* -+ * Shared memory private to the OP-TEE driver doesn't need -+ * to be registered with OP-TEE. -+ */ -+ if (!(shm->flags & TEE_SHM_PRIV)) { - unsigned int nr_pages = 1 << order, i; - struct page **pages; - - pages = kcalloc(nr_pages, sizeof(pages), GFP_KERNEL); -- if (!pages) -- return -ENOMEM; -+ if (!pages) { -+ rc = -ENOMEM; -+ goto err; -+ } - - for (i = 0; i < nr_pages; i++) { - pages[i] = page; -@@ -44,15 +50,21 @@ static int pool_op_alloc(struct tee_shm_pool_mgr *poolm, - rc = optee_shm_register(shm->ctx, shm, pages, nr_pages, - (unsigned long)shm->kaddr); - kfree(pages); -+ if (rc) -+ goto err; - } - -+ return 0; -+ -+err: -+ __free_pages(page, order); - return rc; - } - - static void pool_op_free(struct tee_shm_pool_mgr *poolm, - struct tee_shm *shm) - { -- if (shm->flags & TEE_SHM_DMA_BUF) -+ if (!(shm->flags & TEE_SHM_PRIV)) - optee_shm_unregister(shm->ctx, shm); - - free_pages((unsigned long)shm->kaddr, get_order(shm->size)); -diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c -index 00472f5ce22e4..8a9384a64f3e2 100644 ---- a/drivers/tee/tee_shm.c -+++ b/drivers/tee/tee_shm.c -@@ -117,7 +117,7 @@ struct tee_shm *tee_shm_alloc(struct tee_context *ctx, size_t size, u32 flags) - return ERR_PTR(-EINVAL); - } - -- if ((flags & ~(TEE_SHM_MAPPED | TEE_SHM_DMA_BUF))) { -+ if ((flags & ~(TEE_SHM_MAPPED | TEE_SHM_DMA_BUF | TEE_SHM_PRIV))) { - dev_err(teedev->dev.parent, "invalid shm flags 0x%x", flags); - return ERR_PTR(-EINVAL); - } -@@ -193,6 +193,24 @@ err_dev_put: - } - EXPORT_SYMBOL_GPL(tee_shm_alloc); - -+/** -+ * tee_shm_alloc_kernel_buf() - Allocate shared memory for kernel buffer -+ * @ctx: Context that allocates the shared memory -+ * @size: Requested size of shared memory -+ * -+ * The returned memory registered in secure world and is suitable to be -+ * passed as a memory buffer in parameter argument to -+ * tee_client_invoke_func(). The memory allocated is later freed with a -+ * call to tee_shm_free(). -+ * -+ * @returns a pointer to 'struct tee_shm' -+ */ -+struct tee_shm *tee_shm_alloc_kernel_buf(struct tee_context *ctx, size_t size) -+{ -+ return tee_shm_alloc(ctx, size, TEE_SHM_MAPPED); -+} -+EXPORT_SYMBOL_GPL(tee_shm_alloc_kernel_buf); -+ - struct tee_shm *tee_shm_register(struct tee_context *ctx, unsigned long addr, - size_t length, u32 flags) - { -diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c -index e73cd296db7ef..a82032c081e83 100644 ---- a/drivers/thunderbolt/switch.c -+++ b/drivers/thunderbolt/switch.c -@@ -1740,18 +1740,6 @@ static struct attribute *switch_attrs[] = { - NULL, - }; - --static bool has_port(const struct tb_switch *sw, enum tb_port_type type) --{ -- const struct tb_port *port; -- -- tb_switch_for_each_port(sw, port) { -- if (!port->disabled && port->config.type == type) -- return true; -- } -- -- return false; --} -- - static umode_t switch_attr_is_visible(struct kobject *kobj, - struct attribute *attr, int n) - { -@@ -1760,8 +1748,7 @@ static umode_t switch_attr_is_visible(struct kobject *kobj, - - if (attr == &dev_attr_authorized.attr) { - if (sw->tb->security_level == TB_SECURITY_NOPCIE || -- sw->tb->security_level == TB_SECURITY_DPONLY || -- !has_port(sw, TB_TYPE_PCIE_UP)) -+ sw->tb->security_level == TB_SECURITY_DPONLY) - return 0; - } else if (attr == &dev_attr_device.attr) { - if (!sw->device) -diff --git a/drivers/tty/serial/8250/8250_aspeed_vuart.c b/drivers/tty/serial/8250/8250_aspeed_vuart.c -index d035d08cb9871..60dfd1aa4ad22 100644 ---- a/drivers/tty/serial/8250/8250_aspeed_vuart.c -+++ b/drivers/tty/serial/8250/8250_aspeed_vuart.c -@@ -320,6 +320,7 @@ static int aspeed_vuart_handle_irq(struct uart_port *port) - { - struct uart_8250_port *up = up_to_u8250p(port); - unsigned int iir, lsr; -+ unsigned long flags; - int space, count; - - iir = serial_port_in(port, UART_IIR); -@@ -327,7 +328,7 @@ static int aspeed_vuart_handle_irq(struct uart_port *port) - if (iir & UART_IIR_NO_INT) - return 0; - -- spin_lock(&port->lock); -+ spin_lock_irqsave(&port->lock, flags); - - lsr = serial_port_in(port, UART_LSR); - -@@ -363,7 +364,7 @@ static int aspeed_vuart_handle_irq(struct uart_port *port) - if (lsr & UART_LSR_THRE) - serial8250_tx_chars(up); - -- uart_unlock_and_check_sysrq(port); -+ uart_unlock_and_check_sysrq_irqrestore(port, flags); - - return 1; - } -diff --git a/drivers/tty/serial/8250/8250_fsl.c b/drivers/tty/serial/8250/8250_fsl.c -index 4e75d2e4f87cb..fc65a2293ce9e 100644 ---- a/drivers/tty/serial/8250/8250_fsl.c -+++ b/drivers/tty/serial/8250/8250_fsl.c -@@ -30,10 +30,11 @@ struct fsl8250_data { - int fsl8250_handle_irq(struct uart_port *port) - { - unsigned char lsr, orig_lsr; -+ unsigned long flags; - unsigned int iir; - struct uart_8250_port *up = up_to_u8250p(port); - -- spin_lock(&up->port.lock); -+ spin_lock_irqsave(&up->port.lock, flags); - - iir = port->serial_in(port, UART_IIR); - if (iir & UART_IIR_NO_INT) { -@@ -82,7 +83,7 @@ int fsl8250_handle_irq(struct uart_port *port) - - up->lsr_saved_flags = orig_lsr; - -- uart_unlock_and_check_sysrq(&up->port); -+ uart_unlock_and_check_sysrq_irqrestore(&up->port, flags); - - return 1; - } -diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c -index f7d3023f860f0..fb65dc601b237 100644 ---- a/drivers/tty/serial/8250/8250_mtk.c -+++ b/drivers/tty/serial/8250/8250_mtk.c -@@ -93,10 +93,13 @@ static void mtk8250_dma_rx_complete(void *param) - struct dma_tx_state state; - int copied, total, cnt; - unsigned char *ptr; -+ unsigned long flags; - - if (data->rx_status == DMA_RX_SHUTDOWN) - return; - -+ spin_lock_irqsave(&up->port.lock, flags); -+ - dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state); - total = dma->rx_size - state.residue; - cnt = total; -@@ -120,6 +123,8 @@ static void mtk8250_dma_rx_complete(void *param) - tty_flip_buffer_push(tty_port); - - mtk8250_rx_dma(up); -+ -+ spin_unlock_irqrestore(&up->port.lock, flags); - } - - static void mtk8250_rx_dma(struct uart_8250_port *up) -diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c -index 780cc99732b62..1934940b96170 100644 ---- a/drivers/tty/serial/8250/8250_pci.c -+++ b/drivers/tty/serial/8250/8250_pci.c -@@ -3804,6 +3804,12 @@ static const struct pci_device_id blacklist[] = { - { PCI_VDEVICE(INTEL, 0x0f0c), }, - { PCI_VDEVICE(INTEL, 0x228a), }, - { PCI_VDEVICE(INTEL, 0x228c), }, -+ { PCI_VDEVICE(INTEL, 0x4b96), }, -+ { PCI_VDEVICE(INTEL, 0x4b97), }, -+ { PCI_VDEVICE(INTEL, 0x4b98), }, -+ { PCI_VDEVICE(INTEL, 0x4b99), }, -+ { PCI_VDEVICE(INTEL, 0x4b9a), }, -+ { PCI_VDEVICE(INTEL, 0x4b9b), }, - { PCI_VDEVICE(INTEL, 0x9ce3), }, - { PCI_VDEVICE(INTEL, 0x9ce4), }, - -@@ -3964,6 +3970,7 @@ pciserial_init_ports(struct pci_dev *dev, const struct pciserial_board *board) - if (pci_match_id(pci_use_msi, dev)) { - dev_dbg(&dev->dev, "Using MSI(-X) interrupts\n"); - pci_set_master(dev); -+ uart.port.flags &= ~UPF_SHARE_IRQ; - rc = pci_alloc_irq_vectors(dev, 1, 1, PCI_IRQ_ALL_TYPES); - } else { - dev_dbg(&dev->dev, "Using legacy interrupts\n"); -diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c -index ff3f13693def7..9422284bb3f33 100644 ---- a/drivers/tty/serial/8250/8250_port.c -+++ b/drivers/tty/serial/8250/8250_port.c -@@ -311,7 +311,11 @@ static const struct serial8250_config uart_config[] = { - /* Uart divisor latch read */ - static int default_serial_dl_read(struct uart_8250_port *up) - { -- return serial_in(up, UART_DLL) | serial_in(up, UART_DLM) << 8; -+ /* Assign these in pieces to truncate any bits above 7. */ -+ unsigned char dll = serial_in(up, UART_DLL); -+ unsigned char dlm = serial_in(up, UART_DLM); -+ -+ return dll | dlm << 8; - } - - /* Uart divisor latch write */ -@@ -1297,9 +1301,11 @@ static void autoconfig(struct uart_8250_port *up) - serial_out(up, UART_LCR, 0); - - serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); -- scratch = serial_in(up, UART_IIR) >> 6; - -- switch (scratch) { -+ /* Assign this as it is to truncate any bits above 7. */ -+ scratch = serial_in(up, UART_IIR); -+ -+ switch (scratch >> 6) { - case 0: - autoconfig_8250(up); - break; -@@ -1893,11 +1899,12 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir) - unsigned char status; - struct uart_8250_port *up = up_to_u8250p(port); - bool skip_rx = false; -+ unsigned long flags; - - if (iir & UART_IIR_NO_INT) - return 0; - -- spin_lock(&port->lock); -+ spin_lock_irqsave(&port->lock, flags); - - status = serial_port_in(port, UART_LSR); - -@@ -1923,7 +1930,7 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir) - (up->ier & UART_IER_THRI)) - serial8250_tx_chars(up); - -- uart_unlock_and_check_sysrq(port); -+ uart_unlock_and_check_sysrq_irqrestore(port, flags); - - return 1; - } -diff --git a/drivers/tty/serial/serial-tegra.c b/drivers/tty/serial/serial-tegra.c -index 222032792d6c2..eba5b9ecba348 100644 ---- a/drivers/tty/serial/serial-tegra.c -+++ b/drivers/tty/serial/serial-tegra.c -@@ -1045,9 +1045,11 @@ static int tegra_uart_hw_init(struct tegra_uart_port *tup) - - if (tup->cdata->fifo_mode_enable_status) { - ret = tegra_uart_wait_fifo_mode_enabled(tup); -- dev_err(tup->uport.dev, "FIFO mode not enabled\n"); -- if (ret < 0) -+ if (ret < 0) { -+ dev_err(tup->uport.dev, -+ "Failed to enable FIFO mode: %d\n", ret); - return ret; -+ } - } else { - /* - * For all tegra devices (up to t210), there is a hardware -diff --git a/drivers/usb/cdns3/cdns3-ep0.c b/drivers/usb/cdns3/cdns3-ep0.c -index 9a17802275d51..ec5bfd8944c36 100644 ---- a/drivers/usb/cdns3/cdns3-ep0.c -+++ b/drivers/usb/cdns3/cdns3-ep0.c -@@ -731,6 +731,7 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep, - request->actual = 0; - priv_dev->status_completion_no_call = true; - priv_dev->pending_status_request = request; -+ usb_gadget_set_state(&priv_dev->gadget, USB_STATE_CONFIGURED); - spin_unlock_irqrestore(&priv_dev->lock, flags); - - /* -diff --git a/drivers/usb/cdns3/cdnsp-gadget.c b/drivers/usb/cdns3/cdnsp-gadget.c -index c083985e387b2..cf03ba79a3553 100644 ---- a/drivers/usb/cdns3/cdnsp-gadget.c -+++ b/drivers/usb/cdns3/cdnsp-gadget.c -@@ -1881,7 +1881,7 @@ static int __cdnsp_gadget_init(struct cdns *cdns) - pdev->gadget.name = "cdnsp-gadget"; - pdev->gadget.speed = USB_SPEED_UNKNOWN; - pdev->gadget.sg_supported = 1; -- pdev->gadget.max_speed = USB_SPEED_SUPER_PLUS; -+ pdev->gadget.max_speed = max_speed; - pdev->gadget.lpm_capable = 1; - - pdev->setup_buf = kzalloc(CDNSP_EP0_SETUP_SIZE, GFP_KERNEL); -diff --git a/drivers/usb/cdns3/cdnsp-gadget.h b/drivers/usb/cdns3/cdnsp-gadget.h -index 783ca8ffde007..f740fa6089d85 100644 ---- a/drivers/usb/cdns3/cdnsp-gadget.h -+++ b/drivers/usb/cdns3/cdnsp-gadget.h -@@ -383,8 +383,8 @@ struct cdnsp_intr_reg { - #define IMAN_IE BIT(1) - #define IMAN_IP BIT(0) - /* bits 2:31 need to be preserved */ --#define IMAN_IE_SET(p) (((p) & IMAN_IE) | 0x2) --#define IMAN_IE_CLEAR(p) (((p) & IMAN_IE) & ~(0x2)) -+#define IMAN_IE_SET(p) ((p) | IMAN_IE) -+#define IMAN_IE_CLEAR(p) ((p) & ~IMAN_IE) - - /* IMOD - Interrupter Moderation Register - irq_control bitmasks. */ - /* -diff --git a/drivers/usb/cdns3/cdnsp-ring.c b/drivers/usb/cdns3/cdnsp-ring.c -index 68972746e3636..1b1438457fb04 100644 ---- a/drivers/usb/cdns3/cdnsp-ring.c -+++ b/drivers/usb/cdns3/cdnsp-ring.c -@@ -1932,15 +1932,13 @@ int cdnsp_queue_bulk_tx(struct cdnsp_device *pdev, struct cdnsp_request *preq) - } - - if (enqd_len + trb_buff_len >= full_len) { -- if (need_zero_pkt && zero_len_trb) { -- zero_len_trb = true; -- } else { -- field &= ~TRB_CHAIN; -- field |= TRB_IOC; -- more_trbs_coming = false; -- need_zero_pkt = false; -- preq->td.last_trb = ring->enqueue; -- } -+ if (need_zero_pkt) -+ zero_len_trb = !zero_len_trb; -+ -+ field &= ~TRB_CHAIN; -+ field |= TRB_IOC; -+ more_trbs_coming = false; -+ preq->td.last_trb = ring->enqueue; - } - - /* Only set interrupt on short packet for OUT endpoints. */ -@@ -1955,7 +1953,7 @@ int cdnsp_queue_bulk_tx(struct cdnsp_device *pdev, struct cdnsp_request *preq) - length_field = TRB_LEN(trb_buff_len) | TRB_TD_SIZE(remainder) | - TRB_INTR_TARGET(0); - -- cdnsp_queue_trb(pdev, ring, more_trbs_coming | need_zero_pkt, -+ cdnsp_queue_trb(pdev, ring, more_trbs_coming | zero_len_trb, - lower_32_bits(send_addr), - upper_32_bits(send_addr), - length_field, -diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c -index 74d5a9c5238af..73f419adce610 100644 ---- a/drivers/usb/class/usbtmc.c -+++ b/drivers/usb/class/usbtmc.c -@@ -2324,17 +2324,10 @@ static void usbtmc_interrupt(struct urb *urb) - dev_err(dev, "overflow with length %d, actual length is %d\n", - data->iin_wMaxPacketSize, urb->actual_length); - fallthrough; -- case -ECONNRESET: -- case -ENOENT: -- case -ESHUTDOWN: -- case -EILSEQ: -- case -ETIME: -- case -EPIPE: -+ default: - /* urb terminated, clean up */ - dev_dbg(dev, "urb terminated, status: %d\n", status); - return; -- default: -- dev_err(dev, "unknown status received: %d\n", status); - } - exit: - rv = usb_submit_urb(urb, GFP_ATOMIC); -diff --git a/drivers/usb/common/usb-otg-fsm.c b/drivers/usb/common/usb-otg-fsm.c -index 3740cf95560e9..0697fde51d00f 100644 ---- a/drivers/usb/common/usb-otg-fsm.c -+++ b/drivers/usb/common/usb-otg-fsm.c -@@ -193,7 +193,11 @@ static void otg_start_hnp_polling(struct otg_fsm *fsm) - if (!fsm->host_req_flag) - return; - -- INIT_DELAYED_WORK(&fsm->hnp_polling_work, otg_hnp_polling_work); -+ if (!fsm->hnp_work_inited) { -+ INIT_DELAYED_WORK(&fsm->hnp_polling_work, otg_hnp_polling_work); -+ fsm->hnp_work_inited = true; -+ } -+ - schedule_delayed_work(&fsm->hnp_polling_work, - msecs_to_jiffies(T_HOST_REQ_POLL)); - } -diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c -index f14c2aa837598..b9ff414a0e9d2 100644 ---- a/drivers/usb/dwc3/gadget.c -+++ b/drivers/usb/dwc3/gadget.c -@@ -1741,9 +1741,13 @@ static void dwc3_gadget_ep_cleanup_cancelled_requests(struct dwc3_ep *dep) - { - struct dwc3_request *req; - struct dwc3_request *tmp; -+ struct list_head local; - struct dwc3 *dwc = dep->dwc; - -- list_for_each_entry_safe(req, tmp, &dep->cancelled_list, list) { -+restart: -+ list_replace_init(&dep->cancelled_list, &local); -+ -+ list_for_each_entry_safe(req, tmp, &local, list) { - dwc3_gadget_ep_skip_trbs(dep, req); - switch (req->status) { - case DWC3_REQUEST_STATUS_DISCONNECTED: -@@ -1761,6 +1765,9 @@ static void dwc3_gadget_ep_cleanup_cancelled_requests(struct dwc3_ep *dep) - break; - } - } -+ -+ if (!list_empty(&dep->cancelled_list)) -+ goto restart; - } - - static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, -@@ -2249,6 +2256,17 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) - } - } - -+ /* -+ * Avoid issuing a runtime resume if the device is already in the -+ * suspended state during gadget disconnect. DWC3 gadget was already -+ * halted/stopped during runtime suspend. -+ */ -+ if (!is_on) { -+ pm_runtime_barrier(dwc->dev); -+ if (pm_runtime_suspended(dwc->dev)) -+ return 0; -+ } -+ - /* - * Check the return value for successful resume, or error. For a - * successful resume, the DWC3 runtime PM resume routine will handle -@@ -2945,8 +2963,12 @@ static void dwc3_gadget_ep_cleanup_completed_requests(struct dwc3_ep *dep, - { - struct dwc3_request *req; - struct dwc3_request *tmp; -+ struct list_head local; - -- list_for_each_entry_safe(req, tmp, &dep->started_list, list) { -+restart: -+ list_replace_init(&dep->started_list, &local); -+ -+ list_for_each_entry_safe(req, tmp, &local, list) { - int ret; - - ret = dwc3_gadget_ep_cleanup_completed_request(dep, event, -@@ -2954,6 +2976,9 @@ static void dwc3_gadget_ep_cleanup_completed_requests(struct dwc3_ep *dep, - if (ret) - break; - } -+ -+ if (!list_empty(&dep->started_list)) -+ goto restart; - } - - static bool dwc3_gadget_ep_should_continue(struct dwc3_ep *dep) -diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c -index a82b3de1a54be..6742271cd6e6a 100644 ---- a/drivers/usb/gadget/function/f_hid.c -+++ b/drivers/usb/gadget/function/f_hid.c -@@ -41,6 +41,7 @@ struct f_hidg { - unsigned char bInterfaceSubClass; - unsigned char bInterfaceProtocol; - unsigned char protocol; -+ unsigned char idle; - unsigned short report_desc_length; - char *report_desc; - unsigned short report_length; -@@ -338,6 +339,11 @@ static ssize_t f_hidg_write(struct file *file, const char __user *buffer, - - spin_lock_irqsave(&hidg->write_spinlock, flags); - -+ if (!hidg->req) { -+ spin_unlock_irqrestore(&hidg->write_spinlock, flags); -+ return -ESHUTDOWN; -+ } -+ - #define WRITE_COND (!hidg->write_pending) - try_again: - /* write queue */ -@@ -358,8 +364,14 @@ try_again: - count = min_t(unsigned, count, hidg->report_length); - - spin_unlock_irqrestore(&hidg->write_spinlock, flags); -- status = copy_from_user(req->buf, buffer, count); - -+ if (!req) { -+ ERROR(hidg->func.config->cdev, "hidg->req is NULL\n"); -+ status = -ESHUTDOWN; -+ goto release_write_pending; -+ } -+ -+ status = copy_from_user(req->buf, buffer, count); - if (status != 0) { - ERROR(hidg->func.config->cdev, - "copy_from_user error\n"); -@@ -387,14 +399,17 @@ try_again: - - spin_unlock_irqrestore(&hidg->write_spinlock, flags); - -+ if (!hidg->in_ep->enabled) { -+ ERROR(hidg->func.config->cdev, "in_ep is disabled\n"); -+ status = -ESHUTDOWN; -+ goto release_write_pending; -+ } -+ - status = usb_ep_queue(hidg->in_ep, req, GFP_ATOMIC); -- if (status < 0) { -- ERROR(hidg->func.config->cdev, -- "usb_ep_queue error on int endpoint %zd\n", status); -+ if (status < 0) - goto release_write_pending; -- } else { -+ else - status = count; -- } - - return status; - release_write_pending: -@@ -523,6 +538,14 @@ static int hidg_setup(struct usb_function *f, - goto respond; - break; - -+ case ((USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8 -+ | HID_REQ_GET_IDLE): -+ VDBG(cdev, "get_idle\n"); -+ length = min_t(unsigned int, length, 1); -+ ((u8 *) req->buf)[0] = hidg->idle; -+ goto respond; -+ break; -+ - case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8 - | HID_REQ_SET_REPORT): - VDBG(cdev, "set_report | wLength=%d\n", ctrl->wLength); -@@ -546,6 +569,14 @@ static int hidg_setup(struct usb_function *f, - goto stall; - break; - -+ case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8 -+ | HID_REQ_SET_IDLE): -+ VDBG(cdev, "set_idle\n"); -+ length = 0; -+ hidg->idle = value >> 8; -+ goto respond; -+ break; -+ - case ((USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_INTERFACE) << 8 - | USB_REQ_GET_DESCRIPTOR): - switch (value >> 8) { -@@ -773,6 +804,7 @@ static int hidg_bind(struct usb_configuration *c, struct usb_function *f) - hidg_interface_desc.bInterfaceSubClass = hidg->bInterfaceSubClass; - hidg_interface_desc.bInterfaceProtocol = hidg->bInterfaceProtocol; - hidg->protocol = HID_REPORT_PROTOCOL; -+ hidg->idle = 1; - hidg_ss_in_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); - hidg_ss_in_comp_desc.wBytesPerInterval = - cpu_to_le16(hidg->report_length); -diff --git a/drivers/usb/gadget/udc/max3420_udc.c b/drivers/usb/gadget/udc/max3420_udc.c -index 35179543c3272..91c9e9057cff3 100644 ---- a/drivers/usb/gadget/udc/max3420_udc.c -+++ b/drivers/usb/gadget/udc/max3420_udc.c -@@ -1260,12 +1260,14 @@ static int max3420_probe(struct spi_device *spi) - err = devm_request_irq(&spi->dev, irq, max3420_irq_handler, 0, - "max3420", udc); - if (err < 0) -- return err; -+ goto del_gadget; - - udc->thread_task = kthread_create(max3420_thread, udc, - "max3420-thread"); -- if (IS_ERR(udc->thread_task)) -- return PTR_ERR(udc->thread_task); -+ if (IS_ERR(udc->thread_task)) { -+ err = PTR_ERR(udc->thread_task); -+ goto del_gadget; -+ } - - irq = of_irq_get_byname(spi->dev.of_node, "vbus"); - if (irq <= 0) { /* no vbus irq implies self-powered design */ -@@ -1285,10 +1287,14 @@ static int max3420_probe(struct spi_device *spi) - err = devm_request_irq(&spi->dev, irq, - max3420_vbus_handler, 0, "vbus", udc); - if (err < 0) -- return err; -+ goto del_gadget; - } - - return 0; -+ -+del_gadget: -+ usb_del_gadget_udc(&udc->gadget); -+ return err; - } - - static int max3420_remove(struct spi_device *spi) -diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c -index 9bbd7ddd0003e..a24aea3d2759e 100644 ---- a/drivers/usb/host/ohci-at91.c -+++ b/drivers/usb/host/ohci-at91.c -@@ -611,8 +611,6 @@ ohci_hcd_at91_drv_suspend(struct device *dev) - if (ohci_at91->wakeup) - enable_irq_wake(hcd->irq); - -- ohci_at91_port_suspend(ohci_at91->sfr_regmap, 1); -- - ret = ohci_suspend(hcd, ohci_at91->wakeup); - if (ret) { - if (ohci_at91->wakeup) -@@ -632,7 +630,10 @@ ohci_hcd_at91_drv_suspend(struct device *dev) - /* flush the writes */ - (void) ohci_readl (ohci, &ohci->regs->control); - msleep(1); -+ ohci_at91_port_suspend(ohci_at91->sfr_regmap, 1); - at91_stop_clock(ohci_at91); -+ } else { -+ ohci_at91_port_suspend(ohci_at91->sfr_regmap, 1); - } - - return ret; -@@ -644,6 +645,8 @@ ohci_hcd_at91_drv_resume(struct device *dev) - struct usb_hcd *hcd = dev_get_drvdata(dev); - struct ohci_at91_priv *ohci_at91 = hcd_to_ohci_at91_priv(hcd); - -+ ohci_at91_port_suspend(ohci_at91->sfr_regmap, 0); -+ - if (ohci_at91->wakeup) - disable_irq_wake(hcd->irq); - else -@@ -651,8 +654,6 @@ ohci_hcd_at91_drv_resume(struct device *dev) - - ohci_resume(hcd, false); - -- ohci_at91_port_suspend(ohci_at91->sfr_regmap, 0); -- - return 0; - } - -diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c -index 2db917eab7995..8a521b5ea769e 100644 ---- a/drivers/usb/serial/ch341.c -+++ b/drivers/usb/serial/ch341.c -@@ -851,6 +851,7 @@ static struct usb_serial_driver ch341_device = { - .owner = THIS_MODULE, - .name = "ch341-uart", - }, -+ .bulk_in_size = 512, - .id_table = id_table, - .num_ports = 1, - .open = ch341_open, -diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c -index 4a1f3a95d0177..33bbb3470ca3b 100644 ---- a/drivers/usb/serial/ftdi_sio.c -+++ b/drivers/usb/serial/ftdi_sio.c -@@ -219,6 +219,7 @@ static const struct usb_device_id id_table_combined[] = { - { USB_DEVICE(FTDI_VID, FTDI_MTXORB_6_PID) }, - { USB_DEVICE(FTDI_VID, FTDI_R2000KU_TRUE_RNG) }, - { USB_DEVICE(FTDI_VID, FTDI_VARDAAN_PID) }, -+ { USB_DEVICE(FTDI_VID, FTDI_AUTO_M3_OP_COM_V2_PID) }, - { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0100_PID) }, - { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0101_PID) }, - { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0102_PID) }, -diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h -index add602bebd820..755858ca20bac 100644 ---- a/drivers/usb/serial/ftdi_sio_ids.h -+++ b/drivers/usb/serial/ftdi_sio_ids.h -@@ -159,6 +159,9 @@ - /* Vardaan Enterprises Serial Interface VEUSB422R3 */ - #define FTDI_VARDAAN_PID 0xF070 - -+/* Auto-M3 Ltd. - OP-COM USB V2 - OBD interface Adapter */ -+#define FTDI_AUTO_M3_OP_COM_V2_PID 0x4f50 -+ - /* - * Xsens Technologies BV products (http://www.xsens.com). - */ -diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c -index 0fbe253dc570b..039450069ca45 100644 ---- a/drivers/usb/serial/option.c -+++ b/drivers/usb/serial/option.c -@@ -1203,6 +1203,8 @@ static const struct usb_device_id option_ids[] = { - .driver_info = NCTRL(2) | RSVD(3) }, - { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1055, 0xff), /* Telit FN980 (PCIe) */ - .driver_info = NCTRL(0) | RSVD(1) }, -+ { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1056, 0xff), /* Telit FD980 */ -+ .driver_info = NCTRL(2) | RSVD(3) }, - { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910), - .driver_info = NCTRL(0) | RSVD(1) | RSVD(3) }, - { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910_DUAL_MODEM), -diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c -index 940050c314822..2ce9cbf49e974 100644 ---- a/drivers/usb/serial/pl2303.c -+++ b/drivers/usb/serial/pl2303.c -@@ -418,24 +418,34 @@ static int pl2303_detect_type(struct usb_serial *serial) - bcdDevice = le16_to_cpu(desc->bcdDevice); - bcdUSB = le16_to_cpu(desc->bcdUSB); - -- switch (bcdDevice) { -- case 0x100: -- /* -- * Assume it's an HXN-type if the device doesn't support the old read -- * request value. -- */ -- if (bcdUSB == 0x200 && !pl2303_supports_hx_status(serial)) -- return TYPE_HXN; -+ switch (bcdUSB) { -+ case 0x110: -+ switch (bcdDevice) { -+ case 0x300: -+ return TYPE_HX; -+ case 0x400: -+ return TYPE_HXD; -+ default: -+ return TYPE_HX; -+ } - break; -- case 0x300: -- if (bcdUSB == 0x200) -+ case 0x200: -+ switch (bcdDevice) { -+ case 0x100: -+ case 0x305: -+ /* -+ * Assume it's an HXN-type if the device doesn't -+ * support the old read request value. -+ */ -+ if (!pl2303_supports_hx_status(serial)) -+ return TYPE_HXN; -+ break; -+ case 0x300: - return TYPE_TA; -- -- return TYPE_HX; -- case 0x400: -- return TYPE_HXD; -- case 0x500: -- return TYPE_TB; -+ case 0x500: -+ return TYPE_TB; -+ } -+ break; - } - - dev_err(&serial->interface->dev, -diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c -index 1b7f18d35df45..426e37a1e78c5 100644 ---- a/drivers/usb/typec/tcpm/tcpm.c -+++ b/drivers/usb/typec/tcpm/tcpm.c -@@ -5355,7 +5355,7 @@ EXPORT_SYMBOL_GPL(tcpm_pd_hard_reset); - void tcpm_sink_frs(struct tcpm_port *port) - { - spin_lock(&port->pd_event_lock); -- port->pd_events = TCPM_FRS_EVENT; -+ port->pd_events |= TCPM_FRS_EVENT; - spin_unlock(&port->pd_event_lock); - kthread_queue_work(port->wq, &port->event_work); - } -@@ -5364,7 +5364,7 @@ EXPORT_SYMBOL_GPL(tcpm_sink_frs); - void tcpm_sourcing_vbus(struct tcpm_port *port) - { - spin_lock(&port->pd_event_lock); -- port->pd_events = TCPM_SOURCING_VBUS; -+ port->pd_events |= TCPM_SOURCING_VBUS; - spin_unlock(&port->pd_event_lock); - kthread_queue_work(port->wq, &port->event_work); - } -diff --git a/drivers/virt/acrn/vm.c b/drivers/virt/acrn/vm.c -index 0d002a355a936..fbc9f1042000c 100644 ---- a/drivers/virt/acrn/vm.c -+++ b/drivers/virt/acrn/vm.c -@@ -64,6 +64,14 @@ int acrn_vm_destroy(struct acrn_vm *vm) - test_and_set_bit(ACRN_VM_FLAG_DESTROYED, &vm->flags)) - return 0; - -+ ret = hcall_destroy_vm(vm->vmid); -+ if (ret < 0) { -+ dev_err(acrn_dev.this_device, -+ "Failed to destroy VM %u\n", vm->vmid); -+ clear_bit(ACRN_VM_FLAG_DESTROYED, &vm->flags); -+ return ret; -+ } -+ - /* Remove from global VM list */ - write_lock_bh(&acrn_vm_list_lock); - list_del_init(&vm->list); -@@ -78,14 +86,6 @@ int acrn_vm_destroy(struct acrn_vm *vm) - vm->monitor_page = NULL; - } - -- ret = hcall_destroy_vm(vm->vmid); -- if (ret < 0) { -- dev_err(acrn_dev.this_device, -- "Failed to destroy VM %u\n", vm->vmid); -- clear_bit(ACRN_VM_FLAG_DESTROYED, &vm->flags); -- return ret; -- } -- - acrn_vm_all_ram_unmap(vm); - - dev_dbg(acrn_dev.this_device, "VM %u destroyed.\n", vm->vmid); -diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c -index 398c941e38974..f77156187a0ae 100644 ---- a/fs/cifs/smb2ops.c -+++ b/fs/cifs/smb2ops.c -@@ -3613,7 +3613,8 @@ static int smb3_simple_fallocate_write_range(unsigned int xid, - char *buf) - { - struct cifs_io_parms io_parms = {0}; -- int rc, nbytes; -+ int nbytes; -+ int rc = 0; - struct kvec iov[2]; - - io_parms.netfid = cfile->fid.netfid; -diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c -index bc364c119af6a..cebea4270817e 100644 ---- a/fs/ext4/mmp.c -+++ b/fs/ext4/mmp.c -@@ -138,7 +138,7 @@ static int kmmpd(void *data) - unsigned mmp_check_interval; - unsigned long last_update_time; - unsigned long diff; -- int retval; -+ int retval = 0; - - mmp_block = le64_to_cpu(es->s_mmp_block); - mmp = (struct mmp_struct *)(bh->b_data); -diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c -index a4af26d4459a3..18332550b4464 100644 ---- a/fs/ext4/namei.c -+++ b/fs/ext4/namei.c -@@ -2517,7 +2517,7 @@ again: - goto journal_error; - err = ext4_handle_dirty_dx_node(handle, dir, - frame->bh); -- if (err) -+ if (restart || err) - goto journal_error; - } else { - struct dx_root *dxroot; -diff --git a/fs/io-wq.c b/fs/io-wq.c -index 9efecdf025b9c..77026d42cb799 100644 ---- a/fs/io-wq.c -+++ b/fs/io-wq.c -@@ -131,6 +131,7 @@ struct io_cb_cancel_data { - }; - - static void create_io_worker(struct io_wq *wq, struct io_wqe *wqe, int index); -+static void io_wqe_dec_running(struct io_worker *worker); - - static bool io_worker_get(struct io_worker *worker) - { -@@ -169,26 +170,21 @@ static void io_worker_exit(struct io_worker *worker) - { - struct io_wqe *wqe = worker->wqe; - struct io_wqe_acct *acct = io_wqe_get_acct(worker); -- unsigned flags; - - if (refcount_dec_and_test(&worker->ref)) - complete(&worker->ref_done); - wait_for_completion(&worker->ref_done); - -- preempt_disable(); -- current->flags &= ~PF_IO_WORKER; -- flags = worker->flags; -- worker->flags = 0; -- if (flags & IO_WORKER_F_RUNNING) -- atomic_dec(&acct->nr_running); -- worker->flags = 0; -- preempt_enable(); -- - raw_spin_lock_irq(&wqe->lock); -- if (flags & IO_WORKER_F_FREE) -+ if (worker->flags & IO_WORKER_F_FREE) - hlist_nulls_del_rcu(&worker->nulls_node); - list_del_rcu(&worker->all_list); - acct->nr_workers--; -+ preempt_disable(); -+ io_wqe_dec_running(worker); -+ worker->flags = 0; -+ current->flags &= ~PF_IO_WORKER; -+ preempt_enable(); - raw_spin_unlock_irq(&wqe->lock); - - kfree_rcu(worker, rcu); -@@ -215,15 +211,19 @@ static bool io_wqe_activate_free_worker(struct io_wqe *wqe) - struct hlist_nulls_node *n; - struct io_worker *worker; - -- n = rcu_dereference(hlist_nulls_first_rcu(&wqe->free_list)); -- if (is_a_nulls(n)) -- return false; -- -- worker = hlist_nulls_entry(n, struct io_worker, nulls_node); -- if (io_worker_get(worker)) { -- wake_up_process(worker->task); -+ /* -+ * Iterate free_list and see if we can find an idle worker to -+ * activate. If a given worker is on the free_list but in the process -+ * of exiting, keep trying. -+ */ -+ hlist_nulls_for_each_entry_rcu(worker, n, &wqe->free_list, nulls_node) { -+ if (!io_worker_get(worker)) -+ continue; -+ if (wake_up_process(worker->task)) { -+ io_worker_release(worker); -+ return true; -+ } - io_worker_release(worker); -- return true; - } - - return false; -@@ -248,10 +248,19 @@ static void io_wqe_wake_worker(struct io_wqe *wqe, struct io_wqe_acct *acct) - ret = io_wqe_activate_free_worker(wqe); - rcu_read_unlock(); - -- if (!ret && acct->nr_workers < acct->max_workers) { -- atomic_inc(&acct->nr_running); -- atomic_inc(&wqe->wq->worker_refs); -- create_io_worker(wqe->wq, wqe, acct->index); -+ if (!ret) { -+ bool do_create = false; -+ -+ raw_spin_lock_irq(&wqe->lock); -+ if (acct->nr_workers < acct->max_workers) { -+ atomic_inc(&acct->nr_running); -+ atomic_inc(&wqe->wq->worker_refs); -+ acct->nr_workers++; -+ do_create = true; -+ } -+ raw_spin_unlock_irq(&wqe->lock); -+ if (do_create) -+ create_io_worker(wqe->wq, wqe, acct->index); - } - } - -@@ -272,9 +281,17 @@ static void create_worker_cb(struct callback_head *cb) - { - struct create_worker_data *cwd; - struct io_wq *wq; -+ struct io_wqe *wqe; -+ struct io_wqe_acct *acct; - - cwd = container_of(cb, struct create_worker_data, work); -- wq = cwd->wqe->wq; -+ wqe = cwd->wqe; -+ wq = wqe->wq; -+ acct = &wqe->acct[cwd->index]; -+ raw_spin_lock_irq(&wqe->lock); -+ if (acct->nr_workers < acct->max_workers) -+ acct->nr_workers++; -+ raw_spin_unlock_irq(&wqe->lock); - create_io_worker(wq, cwd->wqe, cwd->index); - kfree(cwd); - } -@@ -640,6 +657,9 @@ static void create_io_worker(struct io_wq *wq, struct io_wqe *wqe, int index) - kfree(worker); - fail: - atomic_dec(&acct->nr_running); -+ raw_spin_lock_irq(&wqe->lock); -+ acct->nr_workers--; -+ raw_spin_unlock_irq(&wqe->lock); - io_worker_ref_put(wq); - return; - } -@@ -655,9 +675,8 @@ fail: - worker->flags |= IO_WORKER_F_FREE; - if (index == IO_WQ_ACCT_BOUND) - worker->flags |= IO_WORKER_F_BOUND; -- if (!acct->nr_workers && (worker->flags & IO_WORKER_F_BOUND)) -+ if ((acct->nr_workers == 1) && (worker->flags & IO_WORKER_F_BOUND)) - worker->flags |= IO_WORKER_F_FIXED; -- acct->nr_workers++; - raw_spin_unlock_irq(&wqe->lock); - wake_up_new_task(tsk); - } -diff --git a/fs/pipe.c b/fs/pipe.c -index 9ef4231cce61c..8e6ef62aeb1c6 100644 ---- a/fs/pipe.c -+++ b/fs/pipe.c -@@ -31,6 +31,21 @@ - - #include "internal.h" - -+/* -+ * New pipe buffers will be restricted to this size while the user is exceeding -+ * their pipe buffer quota. The general pipe use case needs at least two -+ * buffers: one for data yet to be read, and one for new data. If this is less -+ * than two, then a write to a non-empty pipe may block even if the pipe is not -+ * full. This can occur with GNU make jobserver or similar uses of pipes as -+ * semaphores: multiple processes may be waiting to write tokens back to the -+ * pipe before reading tokens: https://lore.kernel.org/lkml/1628086770.5rn8p04n6j.none@localhost/. -+ * -+ * Users can reduce their pipe buffers with F_SETPIPE_SZ below this at their -+ * own risk, namely: pipe writes to non-full pipes may block until the pipe is -+ * emptied. -+ */ -+#define PIPE_MIN_DEF_BUFFERS 2 -+ - /* - * The max size that a non-root user is allowed to grow the pipe. Can - * be set by root in /proc/sys/fs/pipe-max-size -@@ -781,8 +796,8 @@ struct pipe_inode_info *alloc_pipe_info(void) - user_bufs = account_pipe_buffers(user, 0, pipe_bufs); - - if (too_many_pipe_buffers_soft(user_bufs) && pipe_is_unprivileged_user()) { -- user_bufs = account_pipe_buffers(user, pipe_bufs, 1); -- pipe_bufs = 1; -+ user_bufs = account_pipe_buffers(user, pipe_bufs, PIPE_MIN_DEF_BUFFERS); -+ pipe_bufs = PIPE_MIN_DEF_BUFFERS; - } - - if (too_many_pipe_buffers_hard(user_bufs) && pipe_is_unprivileged_user()) -diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c -index 476a7ff494822..ef42729216d1f 100644 ---- a/fs/reiserfs/stree.c -+++ b/fs/reiserfs/stree.c -@@ -387,6 +387,24 @@ void pathrelse(struct treepath *search_path) - search_path->path_length = ILLEGAL_PATH_ELEMENT_OFFSET; - } - -+static int has_valid_deh_location(struct buffer_head *bh, struct item_head *ih) -+{ -+ struct reiserfs_de_head *deh; -+ int i; -+ -+ deh = B_I_DEH(bh, ih); -+ for (i = 0; i < ih_entry_count(ih); i++) { -+ if (deh_location(&deh[i]) > ih_item_len(ih)) { -+ reiserfs_warning(NULL, "reiserfs-5094", -+ "directory entry location seems wrong %h", -+ &deh[i]); -+ return 0; -+ } -+ } -+ -+ return 1; -+} -+ - static int is_leaf(char *buf, int blocksize, struct buffer_head *bh) - { - struct block_head *blkh; -@@ -454,11 +472,14 @@ static int is_leaf(char *buf, int blocksize, struct buffer_head *bh) - "(second one): %h", ih); - return 0; - } -- if (is_direntry_le_ih(ih) && (ih_item_len(ih) < (ih_entry_count(ih) * IH_SIZE))) { -- reiserfs_warning(NULL, "reiserfs-5093", -- "item entry count seems wrong %h", -- ih); -- return 0; -+ if (is_direntry_le_ih(ih)) { -+ if (ih_item_len(ih) < (ih_entry_count(ih) * IH_SIZE)) { -+ reiserfs_warning(NULL, "reiserfs-5093", -+ "item entry count seems wrong %h", -+ ih); -+ return 0; -+ } -+ return has_valid_deh_location(bh, ih); - } - prev_location = ih_location(ih); - } -diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c -index 3ffafc73acf02..58481f8d63d5b 100644 ---- a/fs/reiserfs/super.c -+++ b/fs/reiserfs/super.c -@@ -2082,6 +2082,14 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent) - unlock_new_inode(root_inode); - } - -+ if (!S_ISDIR(root_inode->i_mode) || !inode_get_bytes(root_inode) || -+ !root_inode->i_size) { -+ SWARN(silent, s, "", "corrupt root inode, run fsck"); -+ iput(root_inode); -+ errval = -EUCLEAN; -+ goto error; -+ } -+ - s->s_root = d_make_root(root_inode); - if (!s->s_root) - goto error; -diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h -index d7ed00f1594ef..a11067cebdabc 100644 ---- a/include/linux/serial_core.h -+++ b/include/linux/serial_core.h -@@ -517,6 +517,25 @@ static inline void uart_unlock_and_check_sysrq(struct uart_port *port) - if (sysrq_ch) - handle_sysrq(sysrq_ch); - } -+ -+static inline void uart_unlock_and_check_sysrq_irqrestore(struct uart_port *port, -+ unsigned long flags) -+{ -+ int sysrq_ch; -+ -+ if (!port->has_sysrq) { -+ spin_unlock_irqrestore(&port->lock, flags); -+ return; -+ } -+ -+ sysrq_ch = port->sysrq_ch; -+ port->sysrq_ch = 0; -+ -+ spin_unlock_irqrestore(&port->lock, flags); -+ -+ if (sysrq_ch) -+ handle_sysrq(sysrq_ch); -+} - #else /* CONFIG_MAGIC_SYSRQ_SERIAL */ - static inline int uart_handle_sysrq_char(struct uart_port *port, unsigned int ch) - { -@@ -530,6 +549,11 @@ static inline void uart_unlock_and_check_sysrq(struct uart_port *port) - { - spin_unlock(&port->lock); - } -+static inline void uart_unlock_and_check_sysrq_irqrestore(struct uart_port *port, -+ unsigned long flags) -+{ -+ spin_unlock_irqrestore(&port->lock, flags); -+} - #endif /* CONFIG_MAGIC_SYSRQ_SERIAL */ - - /* -diff --git a/include/linux/tee_drv.h b/include/linux/tee_drv.h -index 54269e47ac9a3..3ebfea0781f10 100644 ---- a/include/linux/tee_drv.h -+++ b/include/linux/tee_drv.h -@@ -27,6 +27,7 @@ - #define TEE_SHM_USER_MAPPED BIT(4) /* Memory mapped in user space */ - #define TEE_SHM_POOL BIT(5) /* Memory allocated from pool */ - #define TEE_SHM_KERNEL_MAPPED BIT(6) /* Memory mapped in kernel space */ -+#define TEE_SHM_PRIV BIT(7) /* Memory private to TEE driver */ - - struct device; - struct tee_device; -@@ -332,6 +333,7 @@ void *tee_get_drvdata(struct tee_device *teedev); - * @returns a pointer to 'struct tee_shm' - */ - struct tee_shm *tee_shm_alloc(struct tee_context *ctx, size_t size, u32 flags); -+struct tee_shm *tee_shm_alloc_kernel_buf(struct tee_context *ctx, size_t size); - - /** - * tee_shm_register() - Register shared memory buffer -diff --git a/include/linux/usb/otg-fsm.h b/include/linux/usb/otg-fsm.h -index e78eb577d0fa1..8ef7d148c1493 100644 ---- a/include/linux/usb/otg-fsm.h -+++ b/include/linux/usb/otg-fsm.h -@@ -196,6 +196,7 @@ struct otg_fsm { - struct mutex lock; - u8 *host_req_flag; - struct delayed_work hnp_polling_work; -+ bool hnp_work_inited; - bool state_changed; - }; - -diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h -index 89c8406dddb4a..34a92d5ed12b5 100644 ---- a/include/net/bluetooth/hci_core.h -+++ b/include/net/bluetooth/hci_core.h -@@ -1229,6 +1229,7 @@ struct hci_dev *hci_alloc_dev(void); - void hci_free_dev(struct hci_dev *hdev); - int hci_register_dev(struct hci_dev *hdev); - void hci_unregister_dev(struct hci_dev *hdev); -+void hci_cleanup_dev(struct hci_dev *hdev); - int hci_suspend_dev(struct hci_dev *hdev); - int hci_resume_dev(struct hci_dev *hdev); - int hci_reset_dev(struct hci_dev *hdev); -diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h -index 625a38ccb5d94..0bf09a9bca4e0 100644 ---- a/include/net/ip6_route.h -+++ b/include/net/ip6_route.h -@@ -265,7 +265,7 @@ int ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, - - static inline unsigned int ip6_skb_dst_mtu(struct sk_buff *skb) - { -- int mtu; -+ unsigned int mtu; - - struct ipv6_pinfo *np = skb->sk && !dev_recursion_level() ? - inet6_sk(skb->sk) : NULL; -diff --git a/include/net/netns/xfrm.h b/include/net/netns/xfrm.h -index e816b6a3ef2b0..9b376b87bd543 100644 ---- a/include/net/netns/xfrm.h -+++ b/include/net/netns/xfrm.h -@@ -74,6 +74,7 @@ struct netns_xfrm { - #endif - spinlock_t xfrm_state_lock; - seqcount_spinlock_t xfrm_state_hash_generation; -+ seqcount_spinlock_t xfrm_policy_hash_generation; - - spinlock_t xfrm_policy_lock; - struct mutex xfrm_cfg_mutex; -diff --git a/kernel/events/core.c b/kernel/events/core.c -index 9ebac2a794679..49a5678750fbf 100644 ---- a/kernel/events/core.c -+++ b/kernel/events/core.c -@@ -12159,10 +12159,33 @@ SYSCALL_DEFINE5(perf_event_open, - } - - if (task) { -+ unsigned int ptrace_mode = PTRACE_MODE_READ_REALCREDS; -+ bool is_capable; -+ - err = down_read_interruptible(&task->signal->exec_update_lock); - if (err) - goto err_file; - -+ is_capable = perfmon_capable(); -+ if (attr.sigtrap) { -+ /* -+ * perf_event_attr::sigtrap sends signals to the other -+ * task. Require the current task to also have -+ * CAP_KILL. -+ */ -+ rcu_read_lock(); -+ is_capable &= ns_capable(__task_cred(task)->user_ns, CAP_KILL); -+ rcu_read_unlock(); -+ -+ /* -+ * If the required capabilities aren't available, checks -+ * for ptrace permissions: upgrade to ATTACH, since -+ * sending signals can effectively change the target -+ * task. -+ */ -+ ptrace_mode = PTRACE_MODE_ATTACH_REALCREDS; -+ } -+ - /* - * Preserve ptrace permission check for backwards compatibility. - * -@@ -12172,7 +12195,7 @@ SYSCALL_DEFINE5(perf_event_open, - * perf_event_exit_task() that could imply). - */ - err = -EACCES; -- if (!perfmon_capable() && !ptrace_may_access(task, PTRACE_MODE_READ_REALCREDS)) -+ if (!is_capable && !ptrace_may_access(task, ptrace_mode)) - goto err_cred; - } - -diff --git a/kernel/sched/core.c b/kernel/sched/core.c -index e5858999b54de..15b4d2fb6be38 100644 ---- a/kernel/sched/core.c -+++ b/kernel/sched/core.c -@@ -1632,12 +1632,18 @@ void deactivate_task(struct rq *rq, struct task_struct *p, int flags) - dequeue_task(rq, p, flags); - } - --/* -- * __normal_prio - return the priority that is based on the static prio -- */ --static inline int __normal_prio(struct task_struct *p) -+static inline int __normal_prio(int policy, int rt_prio, int nice) - { -- return p->static_prio; -+ int prio; -+ -+ if (dl_policy(policy)) -+ prio = MAX_DL_PRIO - 1; -+ else if (rt_policy(policy)) -+ prio = MAX_RT_PRIO - 1 - rt_prio; -+ else -+ prio = NICE_TO_PRIO(nice); -+ -+ return prio; - } - - /* -@@ -1649,15 +1655,7 @@ static inline int __normal_prio(struct task_struct *p) - */ - static inline int normal_prio(struct task_struct *p) - { -- int prio; -- -- if (task_has_dl_policy(p)) -- prio = MAX_DL_PRIO-1; -- else if (task_has_rt_policy(p)) -- prio = MAX_RT_PRIO-1 - p->rt_priority; -- else -- prio = __normal_prio(p); -- return prio; -+ return __normal_prio(p->policy, p->rt_priority, PRIO_TO_NICE(p->static_prio)); - } - - /* -@@ -3759,7 +3757,7 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p) - } else if (PRIO_TO_NICE(p->static_prio) < 0) - p->static_prio = NICE_TO_PRIO(0); - -- p->prio = p->normal_prio = __normal_prio(p); -+ p->prio = p->normal_prio = p->static_prio; - set_load_weight(p, false); - - /* -@@ -5552,6 +5550,18 @@ int default_wake_function(wait_queue_entry_t *curr, unsigned mode, int wake_flag - } - EXPORT_SYMBOL(default_wake_function); - -+static void __setscheduler_prio(struct task_struct *p, int prio) -+{ -+ if (dl_prio(prio)) -+ p->sched_class = &dl_sched_class; -+ else if (rt_prio(prio)) -+ p->sched_class = &rt_sched_class; -+ else -+ p->sched_class = &fair_sched_class; -+ -+ p->prio = prio; -+} -+ - #ifdef CONFIG_RT_MUTEXES - - static inline int __rt_effective_prio(struct task_struct *pi_task, int prio) -@@ -5667,22 +5677,19 @@ void rt_mutex_setprio(struct task_struct *p, struct task_struct *pi_task) - } else { - p->dl.pi_se = &p->dl; - } -- p->sched_class = &dl_sched_class; - } else if (rt_prio(prio)) { - if (dl_prio(oldprio)) - p->dl.pi_se = &p->dl; - if (oldprio < prio) - queue_flag |= ENQUEUE_HEAD; -- p->sched_class = &rt_sched_class; - } else { - if (dl_prio(oldprio)) - p->dl.pi_se = &p->dl; - if (rt_prio(oldprio)) - p->rt.timeout = 0; -- p->sched_class = &fair_sched_class; - } - -- p->prio = prio; -+ __setscheduler_prio(p, prio); - - if (queued) - enqueue_task(rq, p, queue_flag); -@@ -6035,35 +6042,6 @@ static void __setscheduler_params(struct task_struct *p, - set_load_weight(p, true); - } - --/* Actually do priority change: must hold pi & rq lock. */ --static void __setscheduler(struct rq *rq, struct task_struct *p, -- const struct sched_attr *attr, bool keep_boost) --{ -- /* -- * If params can't change scheduling class changes aren't allowed -- * either. -- */ -- if (attr->sched_flags & SCHED_FLAG_KEEP_PARAMS) -- return; -- -- __setscheduler_params(p, attr); -- -- /* -- * Keep a potential priority boosting if called from -- * sched_setscheduler(). -- */ -- p->prio = normal_prio(p); -- if (keep_boost) -- p->prio = rt_effective_prio(p, p->prio); -- -- if (dl_prio(p->prio)) -- p->sched_class = &dl_sched_class; -- else if (rt_prio(p->prio)) -- p->sched_class = &rt_sched_class; -- else -- p->sched_class = &fair_sched_class; --} -- - /* - * Check the target process has a UID that matches the current process's: - */ -@@ -6084,10 +6062,8 @@ static int __sched_setscheduler(struct task_struct *p, - const struct sched_attr *attr, - bool user, bool pi) - { -- int newprio = dl_policy(attr->sched_policy) ? MAX_DL_PRIO - 1 : -- MAX_RT_PRIO - 1 - attr->sched_priority; -- int retval, oldprio, oldpolicy = -1, queued, running; -- int new_effective_prio, policy = attr->sched_policy; -+ int oldpolicy = -1, policy = attr->sched_policy; -+ int retval, oldprio, newprio, queued, running; - const struct sched_class *prev_class; - struct callback_head *head; - struct rq_flags rf; -@@ -6285,6 +6261,7 @@ change: - p->sched_reset_on_fork = reset_on_fork; - oldprio = p->prio; - -+ newprio = __normal_prio(policy, attr->sched_priority, attr->sched_nice); - if (pi) { - /* - * Take priority boosted tasks into account. If the new -@@ -6293,8 +6270,8 @@ change: - * the runqueue. This will be done when the task deboost - * itself. - */ -- new_effective_prio = rt_effective_prio(p, newprio); -- if (new_effective_prio == oldprio) -+ newprio = rt_effective_prio(p, newprio); -+ if (newprio == oldprio) - queue_flags &= ~DEQUEUE_MOVE; - } - -@@ -6307,7 +6284,10 @@ change: - - prev_class = p->sched_class; - -- __setscheduler(rq, p, attr, pi); -+ if (!(attr->sched_flags & SCHED_FLAG_KEEP_PARAMS)) { -+ __setscheduler_params(p, attr); -+ __setscheduler_prio(p, newprio); -+ } - __setscheduler_uclamp(p, attr); - - if (queued) { -diff --git a/kernel/time/timer.c b/kernel/time/timer.c -index 99b97ccefdbdf..2870a7a51638c 100644 ---- a/kernel/time/timer.c -+++ b/kernel/time/timer.c -@@ -1279,8 +1279,10 @@ static inline void timer_base_unlock_expiry(struct timer_base *base) - static void timer_sync_wait_running(struct timer_base *base) - { - if (atomic_read(&base->timer_waiters)) { -+ raw_spin_unlock_irq(&base->lock); - spin_unlock(&base->expiry_lock); - spin_lock(&base->expiry_lock); -+ raw_spin_lock_irq(&base->lock); - } - } - -@@ -1471,14 +1473,14 @@ static void expire_timers(struct timer_base *base, struct hlist_head *head) - if (timer->flags & TIMER_IRQSAFE) { - raw_spin_unlock(&base->lock); - call_timer_fn(timer, fn, baseclk); -- base->running_timer = NULL; - raw_spin_lock(&base->lock); -+ base->running_timer = NULL; - } else { - raw_spin_unlock_irq(&base->lock); - call_timer_fn(timer, fn, baseclk); -+ raw_spin_lock_irq(&base->lock); - base->running_timer = NULL; - timer_sync_wait_running(base); -- raw_spin_lock_irq(&base->lock); - } - } - } -diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c -index 20196380fc545..018067e379f2b 100644 ---- a/kernel/trace/trace.c -+++ b/kernel/trace/trace.c -@@ -9006,8 +9006,10 @@ static int trace_array_create_dir(struct trace_array *tr) - return -EINVAL; - - ret = event_trace_add_tracer(tr->dir, tr); -- if (ret) -+ if (ret) { - tracefs_remove(tr->dir); -+ return ret; -+ } - - init_tracer_tracefs(tr, tr->dir); - __update_tracer_options(tr); -diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c -index 023777a4a04d7..c59793ffd59ce 100644 ---- a/kernel/trace/trace_events_hist.c -+++ b/kernel/trace/trace_events_hist.c -@@ -65,7 +65,8 @@ - C(INVALID_SORT_MODIFIER,"Invalid sort modifier"), \ - C(EMPTY_SORT_FIELD, "Empty sort field"), \ - C(TOO_MANY_SORT_FIELDS, "Too many sort fields (Max = 2)"), \ -- C(INVALID_SORT_FIELD, "Sort field must be a key or a val"), -+ C(INVALID_SORT_FIELD, "Sort field must be a key or a val"), \ -+ C(INVALID_STR_OPERAND, "String type can not be an operand in expression"), - - #undef C - #define C(a, b) HIST_ERR_##a -@@ -2156,6 +2157,13 @@ static struct hist_field *parse_unary(struct hist_trigger_data *hist_data, - ret = PTR_ERR(operand1); - goto free; - } -+ if (operand1->flags & HIST_FIELD_FL_STRING) { -+ /* String type can not be the operand of unary operator. */ -+ hist_err(file->tr, HIST_ERR_INVALID_STR_OPERAND, errpos(str)); -+ destroy_hist_field(operand1, 0); -+ ret = -EINVAL; -+ goto free; -+ } - - expr->flags |= operand1->flags & - (HIST_FIELD_FL_TIMESTAMP | HIST_FIELD_FL_TIMESTAMP_USECS); -@@ -2257,6 +2265,11 @@ static struct hist_field *parse_expr(struct hist_trigger_data *hist_data, - operand1 = NULL; - goto free; - } -+ if (operand1->flags & HIST_FIELD_FL_STRING) { -+ hist_err(file->tr, HIST_ERR_INVALID_STR_OPERAND, errpos(operand1_str)); -+ ret = -EINVAL; -+ goto free; -+ } - - /* rest of string could be another expression e.g. b+c in a+b+c */ - operand_flags = 0; -@@ -2266,6 +2279,11 @@ static struct hist_field *parse_expr(struct hist_trigger_data *hist_data, - operand2 = NULL; - goto free; - } -+ if (operand2->flags & HIST_FIELD_FL_STRING) { -+ hist_err(file->tr, HIST_ERR_INVALID_STR_OPERAND, errpos(str)); -+ ret = -EINVAL; -+ goto free; -+ } - - ret = check_expr_operands(file->tr, operand1, operand2); - if (ret) -@@ -2287,6 +2305,10 @@ static struct hist_field *parse_expr(struct hist_trigger_data *hist_data, - - expr->operands[0] = operand1; - expr->operands[1] = operand2; -+ -+ /* The operand sizes should be the same, so just pick one */ -+ expr->size = operand1->size; -+ - expr->operator = field_op; - expr->name = expr_str(expr, 0); - expr->type = kstrdup(operand1->type, GFP_KERNEL); -diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c -index fc32821f8240b..efd14c79fab41 100644 ---- a/kernel/tracepoint.c -+++ b/kernel/tracepoint.c -@@ -15,12 +15,57 @@ - #include - #include - -+enum tp_func_state { -+ TP_FUNC_0, -+ TP_FUNC_1, -+ TP_FUNC_2, -+ TP_FUNC_N, -+}; -+ - extern tracepoint_ptr_t __start___tracepoints_ptrs[]; - extern tracepoint_ptr_t __stop___tracepoints_ptrs[]; - - DEFINE_SRCU(tracepoint_srcu); - EXPORT_SYMBOL_GPL(tracepoint_srcu); - -+enum tp_transition_sync { -+ TP_TRANSITION_SYNC_1_0_1, -+ TP_TRANSITION_SYNC_N_2_1, -+ -+ _NR_TP_TRANSITION_SYNC, -+}; -+ -+struct tp_transition_snapshot { -+ unsigned long rcu; -+ unsigned long srcu; -+ bool ongoing; -+}; -+ -+/* Protected by tracepoints_mutex */ -+static struct tp_transition_snapshot tp_transition_snapshot[_NR_TP_TRANSITION_SYNC]; -+ -+static void tp_rcu_get_state(enum tp_transition_sync sync) -+{ -+ struct tp_transition_snapshot *snapshot = &tp_transition_snapshot[sync]; -+ -+ /* Keep the latest get_state snapshot. */ -+ snapshot->rcu = get_state_synchronize_rcu(); -+ snapshot->srcu = start_poll_synchronize_srcu(&tracepoint_srcu); -+ snapshot->ongoing = true; -+} -+ -+static void tp_rcu_cond_sync(enum tp_transition_sync sync) -+{ -+ struct tp_transition_snapshot *snapshot = &tp_transition_snapshot[sync]; -+ -+ if (!snapshot->ongoing) -+ return; -+ cond_synchronize_rcu(snapshot->rcu); -+ if (!poll_state_synchronize_srcu(&tracepoint_srcu, snapshot->srcu)) -+ synchronize_srcu(&tracepoint_srcu); -+ snapshot->ongoing = false; -+} -+ - /* Set to 1 to enable tracepoint debug output */ - static const int tracepoint_debug; - -@@ -246,26 +291,29 @@ static void *func_remove(struct tracepoint_func **funcs, - return old; - } - --static void tracepoint_update_call(struct tracepoint *tp, struct tracepoint_func *tp_funcs, bool sync) -+/* -+ * Count the number of functions (enum tp_func_state) in a tp_funcs array. -+ */ -+static enum tp_func_state nr_func_state(const struct tracepoint_func *tp_funcs) -+{ -+ if (!tp_funcs) -+ return TP_FUNC_0; -+ if (!tp_funcs[1].func) -+ return TP_FUNC_1; -+ if (!tp_funcs[2].func) -+ return TP_FUNC_2; -+ return TP_FUNC_N; /* 3 or more */ -+} -+ -+static void tracepoint_update_call(struct tracepoint *tp, struct tracepoint_func *tp_funcs) - { - void *func = tp->iterator; - - /* Synthetic events do not have static call sites */ - if (!tp->static_call_key) - return; -- -- if (!tp_funcs[1].func) { -+ if (nr_func_state(tp_funcs) == TP_FUNC_1) - func = tp_funcs[0].func; -- /* -- * If going from the iterator back to a single caller, -- * we need to synchronize with __DO_TRACE to make sure -- * that the data passed to the callback is the one that -- * belongs to that callback. -- */ -- if (sync) -- tracepoint_synchronize_unregister(); -- } -- - __static_call_update(tp->static_call_key, tp->static_call_tramp, func); - } - -@@ -299,9 +347,41 @@ static int tracepoint_add_func(struct tracepoint *tp, - * a pointer to it. This array is referenced by __DO_TRACE from - * include/linux/tracepoint.h using rcu_dereference_sched(). - */ -- tracepoint_update_call(tp, tp_funcs, false); -- rcu_assign_pointer(tp->funcs, tp_funcs); -- static_key_enable(&tp->key); -+ switch (nr_func_state(tp_funcs)) { -+ case TP_FUNC_1: /* 0->1 */ -+ /* -+ * Make sure new static func never uses old data after a -+ * 1->0->1 transition sequence. -+ */ -+ tp_rcu_cond_sync(TP_TRANSITION_SYNC_1_0_1); -+ /* Set static call to first function */ -+ tracepoint_update_call(tp, tp_funcs); -+ /* Both iterator and static call handle NULL tp->funcs */ -+ rcu_assign_pointer(tp->funcs, tp_funcs); -+ static_key_enable(&tp->key); -+ break; -+ case TP_FUNC_2: /* 1->2 */ -+ /* Set iterator static call */ -+ tracepoint_update_call(tp, tp_funcs); -+ /* -+ * Iterator callback installed before updating tp->funcs. -+ * Requires ordering between RCU assign/dereference and -+ * static call update/call. -+ */ -+ fallthrough; -+ case TP_FUNC_N: /* N->N+1 (N>1) */ -+ rcu_assign_pointer(tp->funcs, tp_funcs); -+ /* -+ * Make sure static func never uses incorrect data after a -+ * N->...->2->1 (N>1) transition sequence. -+ */ -+ if (tp_funcs[0].data != old[0].data) -+ tp_rcu_get_state(TP_TRANSITION_SYNC_N_2_1); -+ break; -+ default: -+ WARN_ON_ONCE(1); -+ break; -+ } - - release_probes(old); - return 0; -@@ -328,17 +408,52 @@ static int tracepoint_remove_func(struct tracepoint *tp, - /* Failed allocating new tp_funcs, replaced func with stub */ - return 0; - -- if (!tp_funcs) { -+ switch (nr_func_state(tp_funcs)) { -+ case TP_FUNC_0: /* 1->0 */ - /* Removed last function */ - if (tp->unregfunc && static_key_enabled(&tp->key)) - tp->unregfunc(); - - static_key_disable(&tp->key); -+ /* Set iterator static call */ -+ tracepoint_update_call(tp, tp_funcs); -+ /* Both iterator and static call handle NULL tp->funcs */ -+ rcu_assign_pointer(tp->funcs, NULL); -+ /* -+ * Make sure new static func never uses old data after a -+ * 1->0->1 transition sequence. -+ */ -+ tp_rcu_get_state(TP_TRANSITION_SYNC_1_0_1); -+ break; -+ case TP_FUNC_1: /* 2->1 */ - rcu_assign_pointer(tp->funcs, tp_funcs); -- } else { -+ /* -+ * Make sure static func never uses incorrect data after a -+ * N->...->2->1 (N>2) transition sequence. If the first -+ * element's data has changed, then force the synchronization -+ * to prevent current readers that have loaded the old data -+ * from calling the new function. -+ */ -+ if (tp_funcs[0].data != old[0].data) -+ tp_rcu_get_state(TP_TRANSITION_SYNC_N_2_1); -+ tp_rcu_cond_sync(TP_TRANSITION_SYNC_N_2_1); -+ /* Set static call to first function */ -+ tracepoint_update_call(tp, tp_funcs); -+ break; -+ case TP_FUNC_2: /* N->N-1 (N>2) */ -+ fallthrough; -+ case TP_FUNC_N: - rcu_assign_pointer(tp->funcs, tp_funcs); -- tracepoint_update_call(tp, tp_funcs, -- tp_funcs[0].func != old[0].func); -+ /* -+ * Make sure static func never uses incorrect data after a -+ * N->...->2->1 (N>2) transition sequence. -+ */ -+ if (tp_funcs[0].data != old[0].data) -+ tp_rcu_get_state(TP_TRANSITION_SYNC_N_2_1); -+ break; -+ default: -+ WARN_ON_ONCE(1); -+ break; - } - release_probes(old); - return 0; -diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c -index 7d71d104fdfda..ee59d1c7f1f6c 100644 ---- a/net/bluetooth/hci_core.c -+++ b/net/bluetooth/hci_core.c -@@ -3976,14 +3976,10 @@ EXPORT_SYMBOL(hci_register_dev); - /* Unregister HCI device */ - void hci_unregister_dev(struct hci_dev *hdev) - { -- int id; -- - BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus); - - hci_dev_set_flag(hdev, HCI_UNREGISTER); - -- id = hdev->id; -- - write_lock(&hci_dev_list_lock); - list_del(&hdev->list); - write_unlock(&hci_dev_list_lock); -@@ -4018,7 +4014,14 @@ void hci_unregister_dev(struct hci_dev *hdev) - } - - device_del(&hdev->dev); -+ /* Actual cleanup is deferred until hci_cleanup_dev(). */ -+ hci_dev_put(hdev); -+} -+EXPORT_SYMBOL(hci_unregister_dev); - -+/* Cleanup HCI device */ -+void hci_cleanup_dev(struct hci_dev *hdev) -+{ - debugfs_remove_recursive(hdev->debugfs); - kfree_const(hdev->hw_info); - kfree_const(hdev->fw_info); -@@ -4043,11 +4046,8 @@ void hci_unregister_dev(struct hci_dev *hdev) - hci_blocked_keys_clear(hdev); - hci_dev_unlock(hdev); - -- hci_dev_put(hdev); -- -- ida_simple_remove(&hci_index_ida, id); -+ ida_simple_remove(&hci_index_ida, hdev->id); - } --EXPORT_SYMBOL(hci_unregister_dev); - - /* Suspend HCI device */ - int hci_suspend_dev(struct hci_dev *hdev) -diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c -index eed0dd066e12c..53f85d7c5f9e5 100644 ---- a/net/bluetooth/hci_sock.c -+++ b/net/bluetooth/hci_sock.c -@@ -59,6 +59,17 @@ struct hci_pinfo { - char comm[TASK_COMM_LEN]; - }; - -+static struct hci_dev *hci_hdev_from_sock(struct sock *sk) -+{ -+ struct hci_dev *hdev = hci_pi(sk)->hdev; -+ -+ if (!hdev) -+ return ERR_PTR(-EBADFD); -+ if (hci_dev_test_flag(hdev, HCI_UNREGISTER)) -+ return ERR_PTR(-EPIPE); -+ return hdev; -+} -+ - void hci_sock_set_flag(struct sock *sk, int nr) - { - set_bit(nr, &hci_pi(sk)->flags); -@@ -759,19 +770,13 @@ void hci_sock_dev_event(struct hci_dev *hdev, int event) - if (event == HCI_DEV_UNREG) { - struct sock *sk; - -- /* Detach sockets from device */ -+ /* Wake up sockets using this dead device */ - read_lock(&hci_sk_list.lock); - sk_for_each(sk, &hci_sk_list.head) { -- lock_sock(sk); - if (hci_pi(sk)->hdev == hdev) { -- hci_pi(sk)->hdev = NULL; - sk->sk_err = EPIPE; -- sk->sk_state = BT_OPEN; - sk->sk_state_change(sk); -- -- hci_dev_put(hdev); - } -- release_sock(sk); - } - read_unlock(&hci_sk_list.lock); - } -@@ -930,10 +935,10 @@ static int hci_sock_blacklist_del(struct hci_dev *hdev, void __user *arg) - static int hci_sock_bound_ioctl(struct sock *sk, unsigned int cmd, - unsigned long arg) - { -- struct hci_dev *hdev = hci_pi(sk)->hdev; -+ struct hci_dev *hdev = hci_hdev_from_sock(sk); - -- if (!hdev) -- return -EBADFD; -+ if (IS_ERR(hdev)) -+ return PTR_ERR(hdev); - - if (hci_dev_test_flag(hdev, HCI_USER_CHANNEL)) - return -EBUSY; -@@ -1103,6 +1108,18 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, - - lock_sock(sk); - -+ /* Allow detaching from dead device and attaching to alive device, if -+ * the caller wants to re-bind (instead of close) this socket in -+ * response to hci_sock_dev_event(HCI_DEV_UNREG) notification. -+ */ -+ hdev = hci_pi(sk)->hdev; -+ if (hdev && hci_dev_test_flag(hdev, HCI_UNREGISTER)) { -+ hci_pi(sk)->hdev = NULL; -+ sk->sk_state = BT_OPEN; -+ hci_dev_put(hdev); -+ } -+ hdev = NULL; -+ - if (sk->sk_state == BT_BOUND) { - err = -EALREADY; - goto done; -@@ -1379,9 +1396,9 @@ static int hci_sock_getname(struct socket *sock, struct sockaddr *addr, - - lock_sock(sk); - -- hdev = hci_pi(sk)->hdev; -- if (!hdev) { -- err = -EBADFD; -+ hdev = hci_hdev_from_sock(sk); -+ if (IS_ERR(hdev)) { -+ err = PTR_ERR(hdev); - goto done; - } - -@@ -1743,9 +1760,9 @@ static int hci_sock_sendmsg(struct socket *sock, struct msghdr *msg, - goto done; - } - -- hdev = hci_pi(sk)->hdev; -- if (!hdev) { -- err = -EBADFD; -+ hdev = hci_hdev_from_sock(sk); -+ if (IS_ERR(hdev)) { -+ err = PTR_ERR(hdev); - goto done; - } - -diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c -index 9874844a95a98..b69d88b88d2e4 100644 ---- a/net/bluetooth/hci_sysfs.c -+++ b/net/bluetooth/hci_sysfs.c -@@ -83,6 +83,9 @@ void hci_conn_del_sysfs(struct hci_conn *conn) - static void bt_host_release(struct device *dev) - { - struct hci_dev *hdev = to_hci_dev(dev); -+ -+ if (hci_dev_test_flag(hdev, HCI_UNREGISTER)) -+ hci_cleanup_dev(hdev); - kfree(hdev); - module_put(THIS_MODULE); - } -diff --git a/net/bridge/br.c b/net/bridge/br.c -index ef743f94254d7..bbab9984f24e5 100644 ---- a/net/bridge/br.c -+++ b/net/bridge/br.c -@@ -166,7 +166,8 @@ static int br_switchdev_event(struct notifier_block *unused, - case SWITCHDEV_FDB_ADD_TO_BRIDGE: - fdb_info = ptr; - err = br_fdb_external_learn_add(br, p, fdb_info->addr, -- fdb_info->vid, false); -+ fdb_info->vid, -+ fdb_info->is_local, false); - if (err) { - err = notifier_from_errno(err); - break; -diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c -index 698b79747d32e..87ce52bba6498 100644 ---- a/net/bridge/br_fdb.c -+++ b/net/bridge/br_fdb.c -@@ -1001,7 +1001,8 @@ static int fdb_add_entry(struct net_bridge *br, struct net_bridge_port *source, - - static int __br_fdb_add(struct ndmsg *ndm, struct net_bridge *br, - struct net_bridge_port *p, const unsigned char *addr, -- u16 nlh_flags, u16 vid, struct nlattr *nfea_tb[]) -+ u16 nlh_flags, u16 vid, struct nlattr *nfea_tb[], -+ struct netlink_ext_ack *extack) - { - int err = 0; - -@@ -1020,7 +1021,15 @@ static int __br_fdb_add(struct ndmsg *ndm, struct net_bridge *br, - rcu_read_unlock(); - local_bh_enable(); - } else if (ndm->ndm_flags & NTF_EXT_LEARNED) { -- err = br_fdb_external_learn_add(br, p, addr, vid, true); -+ if (!p && !(ndm->ndm_state & NUD_PERMANENT)) { -+ NL_SET_ERR_MSG_MOD(extack, -+ "FDB entry towards bridge must be permanent"); -+ return -EINVAL; -+ } -+ -+ err = br_fdb_external_learn_add(br, p, addr, vid, -+ ndm->ndm_state & NUD_PERMANENT, -+ true); - } else { - spin_lock_bh(&br->hash_lock); - err = fdb_add_entry(br, p, addr, ndm, nlh_flags, vid, nfea_tb); -@@ -1092,9 +1101,11 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], - } - - /* VID was specified, so use it. */ -- err = __br_fdb_add(ndm, br, p, addr, nlh_flags, vid, nfea_tb); -+ err = __br_fdb_add(ndm, br, p, addr, nlh_flags, vid, nfea_tb, -+ extack); - } else { -- err = __br_fdb_add(ndm, br, p, addr, nlh_flags, 0, nfea_tb); -+ err = __br_fdb_add(ndm, br, p, addr, nlh_flags, 0, nfea_tb, -+ extack); - if (err || !vg || !vg->num_vlans) - goto out; - -@@ -1106,7 +1117,7 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], - if (!br_vlan_should_use(v)) - continue; - err = __br_fdb_add(ndm, br, p, addr, nlh_flags, v->vid, -- nfea_tb); -+ nfea_tb, extack); - if (err) - goto out; - } -@@ -1246,7 +1257,7 @@ void br_fdb_unsync_static(struct net_bridge *br, struct net_bridge_port *p) - } - - int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p, -- const unsigned char *addr, u16 vid, -+ const unsigned char *addr, u16 vid, bool is_local, - bool swdev_notify) - { - struct net_bridge_fdb_entry *fdb; -@@ -1263,6 +1274,10 @@ int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p, - - if (swdev_notify) - flags |= BIT(BR_FDB_ADDED_BY_USER); -+ -+ if (is_local) -+ flags |= BIT(BR_FDB_LOCAL); -+ - fdb = fdb_create(br, p, addr, vid, flags); - if (!fdb) { - err = -ENOMEM; -@@ -1289,6 +1304,9 @@ int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p, - if (swdev_notify) - set_bit(BR_FDB_ADDED_BY_USER, &fdb->flags); - -+ if (is_local) -+ set_bit(BR_FDB_LOCAL, &fdb->flags); -+ - if (modified) - fdb_notify(br, fdb, RTM_NEWNEIGH, swdev_notify); - } -diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h -index e013d33f1c7ca..4e3d26e0a2d11 100644 ---- a/net/bridge/br_private.h -+++ b/net/bridge/br_private.h -@@ -707,7 +707,7 @@ int br_fdb_get(struct sk_buff *skb, struct nlattr *tb[], struct net_device *dev, - int br_fdb_sync_static(struct net_bridge *br, struct net_bridge_port *p); - void br_fdb_unsync_static(struct net_bridge *br, struct net_bridge_port *p); - int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p, -- const unsigned char *addr, u16 vid, -+ const unsigned char *addr, u16 vid, bool is_local, - bool swdev_notify); - int br_fdb_external_learn_del(struct net_bridge *br, struct net_bridge_port *p, - const unsigned char *addr, u16 vid, -diff --git a/net/ipv4/tcp_offload.c b/net/ipv4/tcp_offload.c -index e09147ac9a990..fc61cd3fea652 100644 ---- a/net/ipv4/tcp_offload.c -+++ b/net/ipv4/tcp_offload.c -@@ -298,6 +298,9 @@ int tcp_gro_complete(struct sk_buff *skb) - if (th->cwr) - skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_ECN; - -+ if (skb->encapsulation) -+ skb->inner_transport_header = skb->transport_header; -+ - return 0; - } - EXPORT_SYMBOL(tcp_gro_complete); -diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c -index 9dde1e5fb449b..1380a6b6f4ff4 100644 ---- a/net/ipv4/udp_offload.c -+++ b/net/ipv4/udp_offload.c -@@ -624,6 +624,10 @@ static int udp_gro_complete_segment(struct sk_buff *skb) - - skb_shinfo(skb)->gso_segs = NAPI_GRO_CB(skb)->count; - skb_shinfo(skb)->gso_type |= SKB_GSO_UDP_L4; -+ -+ if (skb->encapsulation) -+ skb->inner_transport_header = skb->transport_header; -+ - return 0; - } - -diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c -index fc8b56bcabf39..1ee96a5c5ee0a 100644 ---- a/net/sched/sch_generic.c -+++ b/net/sched/sch_generic.c -@@ -886,7 +886,7 @@ struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue, - - /* seqlock has the same scope of busylock, for NOLOCK qdisc */ - spin_lock_init(&sch->seqlock); -- lockdep_set_class(&sch->busylock, -+ lockdep_set_class(&sch->seqlock, - dev->qdisc_tx_busylock ?: &qdisc_tx_busylock); - - seqcount_init(&sch->running); -diff --git a/net/sctp/auth.c b/net/sctp/auth.c -index fe74c5f956303..db6b7373d16c3 100644 ---- a/net/sctp/auth.c -+++ b/net/sctp/auth.c -@@ -857,14 +857,18 @@ int sctp_auth_set_key(struct sctp_endpoint *ep, - memcpy(key->data, &auth_key->sca_key[0], auth_key->sca_keylength); - cur_key->key = key; - -- if (replace) { -- list_del_init(&shkey->key_list); -- sctp_auth_shkey_release(shkey); -- if (asoc && asoc->active_key_id == auth_key->sca_keynumber) -- sctp_auth_asoc_init_active_key(asoc, GFP_KERNEL); -+ if (!replace) { -+ list_add(&cur_key->key_list, sh_keys); -+ return 0; - } -+ -+ list_del_init(&shkey->key_list); -+ sctp_auth_shkey_release(shkey); - list_add(&cur_key->key_list, sh_keys); - -+ if (asoc && asoc->active_key_id == auth_key->sca_keynumber) -+ sctp_auth_asoc_init_active_key(asoc, GFP_KERNEL); -+ - return 0; - } - -diff --git a/net/xfrm/xfrm_compat.c b/net/xfrm/xfrm_compat.c -index a20aec9d73933..2bf2693901631 100644 ---- a/net/xfrm/xfrm_compat.c -+++ b/net/xfrm/xfrm_compat.c -@@ -298,8 +298,16 @@ static int xfrm_xlate64(struct sk_buff *dst, const struct nlmsghdr *nlh_src) - len = nlmsg_attrlen(nlh_src, xfrm_msg_min[type]); - - nla_for_each_attr(nla, attrs, len, remaining) { -- int err = xfrm_xlate64_attr(dst, nla); -+ int err; - -+ switch (type) { -+ case XFRM_MSG_NEWSPDINFO: -+ err = xfrm_nla_cpy(dst, nla, nla_len(nla)); -+ break; -+ default: -+ err = xfrm_xlate64_attr(dst, nla); -+ break; -+ } - if (err) - return err; - } -@@ -341,7 +349,8 @@ static int xfrm_alloc_compat(struct sk_buff *skb, const struct nlmsghdr *nlh_src - - /* Calculates len of translated 64-bit message. */ - static size_t xfrm_user_rcv_calculate_len64(const struct nlmsghdr *src, -- struct nlattr *attrs[XFRMA_MAX+1]) -+ struct nlattr *attrs[XFRMA_MAX + 1], -+ int maxtype) - { - size_t len = nlmsg_len(src); - -@@ -358,10 +367,20 @@ static size_t xfrm_user_rcv_calculate_len64(const struct nlmsghdr *src, - case XFRM_MSG_POLEXPIRE: - len += 8; - break; -+ case XFRM_MSG_NEWSPDINFO: -+ /* attirbutes are xfrm_spdattr_type_t, not xfrm_attr_type_t */ -+ return len; - default: - break; - } - -+ /* Unexpected for anything, but XFRM_MSG_NEWSPDINFO, please -+ * correct both 64=>32-bit and 32=>64-bit translators to copy -+ * new attributes. -+ */ -+ if (WARN_ON_ONCE(maxtype)) -+ return len; -+ - if (attrs[XFRMA_SA]) - len += 4; - if (attrs[XFRMA_POLICY]) -@@ -440,7 +459,8 @@ static int xfrm_xlate32_attr(void *dst, const struct nlattr *nla, - - static int xfrm_xlate32(struct nlmsghdr *dst, const struct nlmsghdr *src, - struct nlattr *attrs[XFRMA_MAX+1], -- size_t size, u8 type, struct netlink_ext_ack *extack) -+ size_t size, u8 type, int maxtype, -+ struct netlink_ext_ack *extack) - { - size_t pos; - int i; -@@ -520,6 +540,25 @@ static int xfrm_xlate32(struct nlmsghdr *dst, const struct nlmsghdr *src, - } - pos = dst->nlmsg_len; - -+ if (maxtype) { -+ /* attirbutes are xfrm_spdattr_type_t, not xfrm_attr_type_t */ -+ WARN_ON_ONCE(src->nlmsg_type != XFRM_MSG_NEWSPDINFO); -+ -+ for (i = 1; i <= maxtype; i++) { -+ int err; -+ -+ if (!attrs[i]) -+ continue; -+ -+ /* just copy - no need for translation */ -+ err = xfrm_attr_cpy32(dst, &pos, attrs[i], size, -+ nla_len(attrs[i]), nla_len(attrs[i])); -+ if (err) -+ return err; -+ } -+ return 0; -+ } -+ - for (i = 1; i < XFRMA_MAX + 1; i++) { - int err; - -@@ -564,7 +603,7 @@ static struct nlmsghdr *xfrm_user_rcv_msg_compat(const struct nlmsghdr *h32, - if (err < 0) - return ERR_PTR(err); - -- len = xfrm_user_rcv_calculate_len64(h32, attrs); -+ len = xfrm_user_rcv_calculate_len64(h32, attrs, maxtype); - /* The message doesn't need translation */ - if (len == nlmsg_len(h32)) - return NULL; -@@ -574,7 +613,7 @@ static struct nlmsghdr *xfrm_user_rcv_msg_compat(const struct nlmsghdr *h32, - if (!h64) - return ERR_PTR(-ENOMEM); - -- err = xfrm_xlate32(h64, h32, attrs, len, type, extack); -+ err = xfrm_xlate32(h64, h32, attrs, len, type, maxtype, extack); - if (err < 0) { - kvfree(h64); - return ERR_PTR(err); -diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c -index ce500f847b991..46a6d15b66d6f 100644 ---- a/net/xfrm/xfrm_policy.c -+++ b/net/xfrm/xfrm_policy.c -@@ -155,7 +155,6 @@ static struct xfrm_policy_afinfo const __rcu *xfrm_policy_afinfo[AF_INET6 + 1] - __read_mostly; - - static struct kmem_cache *xfrm_dst_cache __ro_after_init; --static __read_mostly seqcount_mutex_t xfrm_policy_hash_generation; - - static struct rhashtable xfrm_policy_inexact_table; - static const struct rhashtable_params xfrm_pol_inexact_params; -@@ -585,7 +584,7 @@ static void xfrm_bydst_resize(struct net *net, int dir) - return; - - spin_lock_bh(&net->xfrm.xfrm_policy_lock); -- write_seqcount_begin(&xfrm_policy_hash_generation); -+ write_seqcount_begin(&net->xfrm.xfrm_policy_hash_generation); - - odst = rcu_dereference_protected(net->xfrm.policy_bydst[dir].table, - lockdep_is_held(&net->xfrm.xfrm_policy_lock)); -@@ -596,7 +595,7 @@ static void xfrm_bydst_resize(struct net *net, int dir) - rcu_assign_pointer(net->xfrm.policy_bydst[dir].table, ndst); - net->xfrm.policy_bydst[dir].hmask = nhashmask; - -- write_seqcount_end(&xfrm_policy_hash_generation); -+ write_seqcount_end(&net->xfrm.xfrm_policy_hash_generation); - spin_unlock_bh(&net->xfrm.xfrm_policy_lock); - - synchronize_rcu(); -@@ -1245,7 +1244,7 @@ static void xfrm_hash_rebuild(struct work_struct *work) - } while (read_seqretry(&net->xfrm.policy_hthresh.lock, seq)); - - spin_lock_bh(&net->xfrm.xfrm_policy_lock); -- write_seqcount_begin(&xfrm_policy_hash_generation); -+ write_seqcount_begin(&net->xfrm.xfrm_policy_hash_generation); - - /* make sure that we can insert the indirect policies again before - * we start with destructive action. -@@ -1354,7 +1353,7 @@ static void xfrm_hash_rebuild(struct work_struct *work) - - out_unlock: - __xfrm_policy_inexact_flush(net); -- write_seqcount_end(&xfrm_policy_hash_generation); -+ write_seqcount_end(&net->xfrm.xfrm_policy_hash_generation); - spin_unlock_bh(&net->xfrm.xfrm_policy_lock); - - mutex_unlock(&hash_resize_mutex); -@@ -2095,9 +2094,9 @@ static struct xfrm_policy *xfrm_policy_lookup_bytype(struct net *net, u8 type, - rcu_read_lock(); - retry: - do { -- sequence = read_seqcount_begin(&xfrm_policy_hash_generation); -+ sequence = read_seqcount_begin(&net->xfrm.xfrm_policy_hash_generation); - chain = policy_hash_direct(net, daddr, saddr, family, dir); -- } while (read_seqcount_retry(&xfrm_policy_hash_generation, sequence)); -+ } while (read_seqcount_retry(&net->xfrm.xfrm_policy_hash_generation, sequence)); - - ret = NULL; - hlist_for_each_entry_rcu(pol, chain, bydst) { -@@ -2128,7 +2127,7 @@ static struct xfrm_policy *xfrm_policy_lookup_bytype(struct net *net, u8 type, - } - - skip_inexact: -- if (read_seqcount_retry(&xfrm_policy_hash_generation, sequence)) -+ if (read_seqcount_retry(&net->xfrm.xfrm_policy_hash_generation, sequence)) - goto retry; - - if (ret && !xfrm_pol_hold_rcu(ret)) -@@ -4084,6 +4083,7 @@ static int __net_init xfrm_net_init(struct net *net) - /* Initialize the per-net locks here */ - spin_lock_init(&net->xfrm.xfrm_state_lock); - spin_lock_init(&net->xfrm.xfrm_policy_lock); -+ seqcount_spinlock_init(&net->xfrm.xfrm_policy_hash_generation, &net->xfrm.xfrm_policy_lock); - mutex_init(&net->xfrm.xfrm_cfg_mutex); - - rv = xfrm_statistics_init(net); -@@ -4128,7 +4128,6 @@ void __init xfrm_init(void) - { - register_pernet_subsys(&xfrm_net_ops); - xfrm_dev_init(); -- seqcount_mutex_init(&xfrm_policy_hash_generation, &hash_resize_mutex); - xfrm_input_init(); - - #ifdef CONFIG_XFRM_ESPINTCP -diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c -index b47d613409b70..7aff641c717d7 100644 ---- a/net/xfrm/xfrm_user.c -+++ b/net/xfrm/xfrm_user.c -@@ -2811,6 +2811,16 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, - - err = link->doit(skb, nlh, attrs); - -+ /* We need to free skb allocated in xfrm_alloc_compat() before -+ * returning from this function, because consume_skb() won't take -+ * care of frag_list since netlink destructor sets -+ * sbk->head to NULL. (see netlink_skb_destructor()) -+ */ -+ if (skb_has_frag_list(skb)) { -+ kfree_skb(skb_shinfo(skb)->frag_list); -+ skb_shinfo(skb)->frag_list = NULL; -+ } -+ - err: - kvfree(nlh64); - return err; -diff --git a/scripts/tracing/draw_functrace.py b/scripts/tracing/draw_functrace.py -index 74f8aadfd4cbc..7011fbe003ff2 100755 ---- a/scripts/tracing/draw_functrace.py -+++ b/scripts/tracing/draw_functrace.py -@@ -17,7 +17,7 @@ Usage: - $ cat /sys/kernel/debug/tracing/trace_pipe > ~/raw_trace_func - Wait some times but not too much, the script is a bit slow. - Break the pipe (Ctrl + Z) -- $ scripts/draw_functrace.py < raw_trace_func > draw_functrace -+ $ scripts/tracing/draw_functrace.py < ~/raw_trace_func > draw_functrace - Then you have your drawn trace in draw_functrace - """ - -@@ -103,10 +103,10 @@ def parseLine(line): - line = line.strip() - if line.startswith("#"): - raise CommentLineException -- m = re.match("[^]]+?\\] +([0-9.]+): (\\w+) <-(\\w+)", line) -+ m = re.match("[^]]+?\\] +([a-z.]+) +([0-9.]+): (\\w+) <-(\\w+)", line) - if m is None: - raise BrokenLineException -- return (m.group(1), m.group(2), m.group(3)) -+ return (m.group(2), m.group(3), m.group(4)) - - - def main(): -diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c -index 9fccf417006b0..6a04de21343f8 100644 ---- a/security/selinux/ss/policydb.c -+++ b/security/selinux/ss/policydb.c -@@ -874,7 +874,7 @@ int policydb_load_isids(struct policydb *p, struct sidtab *s) - rc = sidtab_init(s); - if (rc) { - pr_err("SELinux: out of memory on SID table init\n"); -- goto out; -+ return rc; - } - - head = p->ocontexts[OCON_ISID]; -@@ -885,7 +885,7 @@ int policydb_load_isids(struct policydb *p, struct sidtab *s) - if (sid == SECSID_NULL) { - pr_err("SELinux: SID 0 was assigned a context.\n"); - sidtab_destroy(s); -- goto out; -+ return -EINVAL; - } - - /* Ignore initial SIDs unused by this kernel. */ -@@ -897,12 +897,10 @@ int policydb_load_isids(struct policydb *p, struct sidtab *s) - pr_err("SELinux: unable to load initial SID %s.\n", - name); - sidtab_destroy(s); -- goto out; -+ return rc; - } - } -- rc = 0; --out: -- return rc; -+ return 0; - } - - int policydb_class_isvalid(struct policydb *p, unsigned int class) -diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c -index a9fd486089a7a..2b3c164d21f17 100644 ---- a/sound/core/pcm_native.c -+++ b/sound/core/pcm_native.c -@@ -246,7 +246,7 @@ static bool hw_support_mmap(struct snd_pcm_substream *substream) - if (!(substream->runtime->hw.info & SNDRV_PCM_INFO_MMAP)) - return false; - -- if (substream->ops->mmap) -+ if (substream->ops->mmap || substream->ops->page) - return true; - - switch (substream->dma_buffer.dev.type) { -diff --git a/sound/core/seq/seq_ports.c b/sound/core/seq/seq_ports.c -index b9c2ce2b8d5a3..84d78630463e4 100644 ---- a/sound/core/seq/seq_ports.c -+++ b/sound/core/seq/seq_ports.c -@@ -514,10 +514,11 @@ static int check_and_subscribe_port(struct snd_seq_client *client, - return err; - } - --static void delete_and_unsubscribe_port(struct snd_seq_client *client, -- struct snd_seq_client_port *port, -- struct snd_seq_subscribers *subs, -- bool is_src, bool ack) -+/* called with grp->list_mutex held */ -+static void __delete_and_unsubscribe_port(struct snd_seq_client *client, -+ struct snd_seq_client_port *port, -+ struct snd_seq_subscribers *subs, -+ bool is_src, bool ack) - { - struct snd_seq_port_subs_info *grp; - struct list_head *list; -@@ -525,7 +526,6 @@ static void delete_and_unsubscribe_port(struct snd_seq_client *client, - - grp = is_src ? &port->c_src : &port->c_dest; - list = is_src ? &subs->src_list : &subs->dest_list; -- down_write(&grp->list_mutex); - write_lock_irq(&grp->list_lock); - empty = list_empty(list); - if (!empty) -@@ -535,6 +535,18 @@ static void delete_and_unsubscribe_port(struct snd_seq_client *client, - - if (!empty) - unsubscribe_port(client, port, grp, &subs->info, ack); -+} -+ -+static void delete_and_unsubscribe_port(struct snd_seq_client *client, -+ struct snd_seq_client_port *port, -+ struct snd_seq_subscribers *subs, -+ bool is_src, bool ack) -+{ -+ struct snd_seq_port_subs_info *grp; -+ -+ grp = is_src ? &port->c_src : &port->c_dest; -+ down_write(&grp->list_mutex); -+ __delete_and_unsubscribe_port(client, port, subs, is_src, ack); - up_write(&grp->list_mutex); - } - -@@ -590,27 +602,30 @@ int snd_seq_port_disconnect(struct snd_seq_client *connector, - struct snd_seq_client_port *dest_port, - struct snd_seq_port_subscribe *info) - { -- struct snd_seq_port_subs_info *src = &src_port->c_src; -+ struct snd_seq_port_subs_info *dest = &dest_port->c_dest; - struct snd_seq_subscribers *subs; - int err = -ENOENT; - -- down_write(&src->list_mutex); -+ /* always start from deleting the dest port for avoiding concurrent -+ * deletions -+ */ -+ down_write(&dest->list_mutex); - /* look for the connection */ -- list_for_each_entry(subs, &src->list_head, src_list) { -+ list_for_each_entry(subs, &dest->list_head, dest_list) { - if (match_subs_info(info, &subs->info)) { -- atomic_dec(&subs->ref_count); /* mark as not ready */ -+ __delete_and_unsubscribe_port(dest_client, dest_port, -+ subs, false, -+ connector->number != dest_client->number); - err = 0; - break; - } - } -- up_write(&src->list_mutex); -+ up_write(&dest->list_mutex); - if (err < 0) - return err; - - delete_and_unsubscribe_port(src_client, src_port, subs, true, - connector->number != src_client->number); -- delete_and_unsubscribe_port(dest_client, dest_port, subs, false, -- connector->number != dest_client->number); - kfree(subs); - return 0; - } -diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c -index 19a3ae79c0012..c92d9b9cf9441 100644 ---- a/sound/pci/hda/patch_realtek.c -+++ b/sound/pci/hda/patch_realtek.c -@@ -8214,9 +8214,11 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { - SND_PCI_QUIRK(0x1025, 0x1290, "Acer Veriton Z4860G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC), - SND_PCI_QUIRK(0x1025, 0x1291, "Acer Veriton Z4660G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC), - SND_PCI_QUIRK(0x1025, 0x129c, "Acer SWIFT SF314-55", ALC256_FIXUP_ACER_HEADSET_MIC), -+ SND_PCI_QUIRK(0x1025, 0x1300, "Acer SWIFT SF314-56", ALC256_FIXUP_ACER_MIC_NO_PRESENCE), - SND_PCI_QUIRK(0x1025, 0x1308, "Acer Aspire Z24-890", ALC286_FIXUP_ACER_AIO_HEADSET_MIC), - SND_PCI_QUIRK(0x1025, 0x132a, "Acer TravelMate B114-21", ALC233_FIXUP_ACER_HEADSET_MIC), - SND_PCI_QUIRK(0x1025, 0x1330, "Acer TravelMate X514-51T", ALC255_FIXUP_ACER_HEADSET_MIC), -+ SND_PCI_QUIRK(0x1025, 0x142b, "Acer Swift SF314-42", ALC255_FIXUP_ACER_MIC_NO_PRESENCE), - SND_PCI_QUIRK(0x1025, 0x1430, "Acer TravelMate B311R-31", ALC256_FIXUP_ACER_MIC_NO_PRESENCE), - SND_PCI_QUIRK(0x1025, 0x1466, "Acer Aspire A515-56", ALC255_FIXUP_ACER_HEADPHONE_AND_MIC), - SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), -diff --git a/sound/usb/card.c b/sound/usb/card.c -index 2f6a62416c057..a1f8c3a026f57 100644 ---- a/sound/usb/card.c -+++ b/sound/usb/card.c -@@ -907,7 +907,7 @@ static void usb_audio_disconnect(struct usb_interface *intf) - } - } - -- if (chip->quirk_type & QUIRK_SETUP_DISABLE_AUTOSUSPEND) -+ if (chip->quirk_type == QUIRK_SETUP_DISABLE_AUTOSUSPEND) - usb_enable_autosuspend(interface_to_usbdev(intf)); - - chip->num_interfaces--; -diff --git a/sound/usb/clock.c b/sound/usb/clock.c -index 17bbde73d4d15..14772209194bc 100644 ---- a/sound/usb/clock.c -+++ b/sound/usb/clock.c -@@ -325,6 +325,12 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip, - selector->baCSourceID[ret - 1], - visited, validate); - if (ret > 0) { -+ /* -+ * For Samsung USBC Headset (AKG), setting clock selector again -+ * will result in incorrect default clock setting problems -+ */ -+ if (chip->usb_id == USB_ID(0x04e8, 0xa051)) -+ return ret; - err = uac_clock_selector_set_val(chip, entity_id, cur); - if (err < 0) - return err; -diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c -index f4cdaf1ba44ac..9b713b4a5ec4c 100644 ---- a/sound/usb/mixer.c -+++ b/sound/usb/mixer.c -@@ -1816,6 +1816,15 @@ static void get_connector_control_name(struct usb_mixer_interface *mixer, - strlcat(name, " - Output Jack", name_size); - } - -+/* get connector value to "wake up" the USB audio */ -+static int connector_mixer_resume(struct usb_mixer_elem_list *list) -+{ -+ struct usb_mixer_elem_info *cval = mixer_elem_list_to_info(list); -+ -+ get_connector_value(cval, NULL, NULL); -+ return 0; -+} -+ - /* Build a mixer control for a UAC connector control (jack-detect) */ - static void build_connector_control(struct usb_mixer_interface *mixer, - const struct usbmix_name_map *imap, -@@ -1833,6 +1842,10 @@ static void build_connector_control(struct usb_mixer_interface *mixer, - if (!cval) - return; - snd_usb_mixer_elem_init_std(&cval->head, mixer, term->id); -+ -+ /* set up a specific resume callback */ -+ cval->head.resume = connector_mixer_resume; -+ - /* - * UAC2: The first byte from reading the UAC2_TE_CONNECTOR control returns the - * number of channels connected. -@@ -3642,23 +3655,15 @@ static int restore_mixer_value(struct usb_mixer_elem_list *list) - return 0; - } - --static int default_mixer_resume(struct usb_mixer_elem_list *list) --{ -- struct usb_mixer_elem_info *cval = mixer_elem_list_to_info(list); -- -- /* get connector value to "wake up" the USB audio */ -- if (cval->val_type == USB_MIXER_BOOLEAN && cval->channels == 1) -- get_connector_value(cval, NULL, NULL); -- -- return 0; --} -- - static int default_mixer_reset_resume(struct usb_mixer_elem_list *list) - { -- int err = default_mixer_resume(list); -+ int err; - -- if (err < 0) -- return err; -+ if (list->resume) { -+ err = list->resume(list); -+ if (err < 0) -+ return err; -+ } - return restore_mixer_value(list); - } - -@@ -3697,7 +3702,7 @@ void snd_usb_mixer_elem_init_std(struct usb_mixer_elem_list *list, - list->id = unitid; - list->dump = snd_usb_mixer_dump_cval; - #ifdef CONFIG_PM -- list->resume = default_mixer_resume; -+ list->resume = NULL; - list->reset_resume = default_mixer_reset_resume; - #endif - } -diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c -index e7accd87e0632..326d1b0ea5e69 100644 ---- a/sound/usb/quirks.c -+++ b/sound/usb/quirks.c -@@ -1899,6 +1899,7 @@ static const struct registration_quirk registration_quirks[] = { - REG_QUIRK_ENTRY(0x0951, 0x16ea, 2), /* Kingston HyperX Cloud Flight S */ - REG_QUIRK_ENTRY(0x0ecb, 0x1f46, 2), /* JBL Quantum 600 */ - REG_QUIRK_ENTRY(0x0ecb, 0x2039, 2), /* JBL Quantum 400 */ -+ REG_QUIRK_ENTRY(0x0ecb, 0x203c, 2), /* JBL Quantum 600 */ - REG_QUIRK_ENTRY(0x0ecb, 0x203e, 2), /* JBL Quantum 800 */ - { 0 } /* terminator */ - }; -diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c -index 0119466677b7d..1dcc66060a19a 100644 ---- a/virt/kvm/kvm_main.c -+++ b/virt/kvm/kvm_main.c -@@ -845,6 +845,8 @@ static void kvm_destroy_vm_debugfs(struct kvm *kvm) - - static int kvm_create_vm_debugfs(struct kvm *kvm, int fd) - { -+ static DEFINE_MUTEX(kvm_debugfs_lock); -+ struct dentry *dent; - char dir_name[ITOA_MAX_LEN * 2]; - struct kvm_stat_data *stat_data; - struct kvm_stats_debugfs_item *p; -@@ -853,8 +855,20 @@ static int kvm_create_vm_debugfs(struct kvm *kvm, int fd) - return 0; - - snprintf(dir_name, sizeof(dir_name), "%d-%d", task_pid_nr(current), fd); -- kvm->debugfs_dentry = debugfs_create_dir(dir_name, kvm_debugfs_dir); -+ mutex_lock(&kvm_debugfs_lock); -+ dent = debugfs_lookup(dir_name, kvm_debugfs_dir); -+ if (dent) { -+ pr_warn_ratelimited("KVM: debugfs: duplicate directory %s\n", dir_name); -+ dput(dent); -+ mutex_unlock(&kvm_debugfs_lock); -+ return 0; -+ } -+ dent = debugfs_create_dir(dir_name, kvm_debugfs_dir); -+ mutex_unlock(&kvm_debugfs_lock); -+ if (IS_ERR(dent)) -+ return 0; - -+ kvm->debugfs_dentry = dent; - kvm->debugfs_stat_data = kcalloc(kvm_debugfs_num_entries, - sizeof(*kvm->debugfs_stat_data), - GFP_KERNEL_ACCOUNT); -@@ -4993,7 +5007,7 @@ static void kvm_uevent_notify_change(unsigned int type, struct kvm *kvm) - } - add_uevent_var(env, "PID=%d", kvm->userspace_pid); - -- if (!IS_ERR_OR_NULL(kvm->debugfs_dentry)) { -+ if (kvm->debugfs_dentry) { - char *tmp, *p = kmalloc(PATH_MAX, GFP_KERNEL_ACCOUNT); - - if (p) { diff --git a/patch/kernel/archive/sunxi-5.13/patch-2-5.13.10-11.patch b/patch/kernel/archive/sunxi-5.13/patch-2-5.13.10-11.patch deleted file mode 100644 index 0ca1f85011..0000000000 --- a/patch/kernel/archive/sunxi-5.13/patch-2-5.13.10-11.patch +++ /dev/null @@ -1,257 +0,0 @@ -diff --git a/Makefile b/Makefile -index 4e9f877f513f9..eaf1df54ad123 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,7 +1,7 @@ - # SPDX-License-Identifier: GPL-2.0 - VERSION = 5 - PATCHLEVEL = 13 --SUBLEVEL = 10 -+SUBLEVEL = 11 - EXTRAVERSION = - NAME = Opossums on Parade - -diff --git a/drivers/firmware/broadcom/tee_bnxt_fw.c b/drivers/firmware/broadcom/tee_bnxt_fw.c -index ed10da5313e86..a5bf4c3f6dc74 100644 ---- a/drivers/firmware/broadcom/tee_bnxt_fw.c -+++ b/drivers/firmware/broadcom/tee_bnxt_fw.c -@@ -212,10 +212,9 @@ static int tee_bnxt_fw_probe(struct device *dev) - - pvt_data.dev = dev; - -- fw_shm_pool = tee_shm_alloc(pvt_data.ctx, MAX_SHM_MEM_SZ, -- TEE_SHM_MAPPED | TEE_SHM_DMA_BUF); -+ fw_shm_pool = tee_shm_alloc_kernel_buf(pvt_data.ctx, MAX_SHM_MEM_SZ); - if (IS_ERR(fw_shm_pool)) { -- dev_err(pvt_data.dev, "tee_shm_alloc failed\n"); -+ dev_err(pvt_data.dev, "tee_shm_alloc_kernel_buf failed\n"); - err = PTR_ERR(fw_shm_pool); - goto out_sess; - } -@@ -242,6 +241,14 @@ static int tee_bnxt_fw_remove(struct device *dev) - return 0; - } - -+static void tee_bnxt_fw_shutdown(struct device *dev) -+{ -+ tee_shm_free(pvt_data.fw_shm_pool); -+ tee_client_close_session(pvt_data.ctx, pvt_data.session_id); -+ tee_client_close_context(pvt_data.ctx); -+ pvt_data.ctx = NULL; -+} -+ - static const struct tee_client_device_id tee_bnxt_fw_id_table[] = { - {UUID_INIT(0x6272636D, 0x2019, 0x0716, - 0x42, 0x43, 0x4D, 0x5F, 0x53, 0x43, 0x48, 0x49)}, -@@ -257,6 +264,7 @@ static struct tee_client_driver tee_bnxt_fw_driver = { - .bus = &tee_bus_type, - .probe = tee_bnxt_fw_probe, - .remove = tee_bnxt_fw_remove, -+ .shutdown = tee_bnxt_fw_shutdown, - }, - }; - -diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c -index 930e49ef15f6a..b9dd47bd597ff 100644 ---- a/drivers/net/ppp/ppp_generic.c -+++ b/drivers/net/ppp/ppp_generic.c -@@ -284,7 +284,7 @@ static struct channel *ppp_find_channel(struct ppp_net *pn, int unit); - static int ppp_connect_channel(struct channel *pch, int unit); - static int ppp_disconnect_channel(struct channel *pch); - static void ppp_destroy_channel(struct channel *pch); --static int unit_get(struct idr *p, void *ptr); -+static int unit_get(struct idr *p, void *ptr, int min); - static int unit_set(struct idr *p, void *ptr, int n); - static void unit_put(struct idr *p, int n); - static void *unit_find(struct idr *p, int n); -@@ -1155,9 +1155,20 @@ static int ppp_unit_register(struct ppp *ppp, int unit, bool ifname_is_set) - mutex_lock(&pn->all_ppp_mutex); - - if (unit < 0) { -- ret = unit_get(&pn->units_idr, ppp); -+ ret = unit_get(&pn->units_idr, ppp, 0); - if (ret < 0) - goto err; -+ if (!ifname_is_set) { -+ while (1) { -+ snprintf(ppp->dev->name, IFNAMSIZ, "ppp%i", ret); -+ if (!__dev_get_by_name(ppp->ppp_net, ppp->dev->name)) -+ break; -+ unit_put(&pn->units_idr, ret); -+ ret = unit_get(&pn->units_idr, ppp, ret + 1); -+ if (ret < 0) -+ goto err; -+ } -+ } - } else { - /* Caller asked for a specific unit number. Fail with -EEXIST - * if unavailable. For backward compatibility, return -EEXIST -@@ -3552,9 +3563,9 @@ static int unit_set(struct idr *p, void *ptr, int n) - } - - /* get new free unit number and associate pointer with it */ --static int unit_get(struct idr *p, void *ptr) -+static int unit_get(struct idr *p, void *ptr, int min) - { -- return idr_alloc(p, ptr, 0, 0, GFP_KERNEL); -+ return idr_alloc(p, ptr, min, 0, GFP_KERNEL); - } - - /* put unit number back to a pool */ -diff --git a/fs/namespace.c b/fs/namespace.c -index c3f1a78ba3697..caad091fb204d 100644 ---- a/fs/namespace.c -+++ b/fs/namespace.c -@@ -1938,6 +1938,20 @@ void drop_collected_mounts(struct vfsmount *mnt) - namespace_unlock(); - } - -+static bool has_locked_children(struct mount *mnt, struct dentry *dentry) -+{ -+ struct mount *child; -+ -+ list_for_each_entry(child, &mnt->mnt_mounts, mnt_child) { -+ if (!is_subdir(child->mnt_mountpoint, dentry)) -+ continue; -+ -+ if (child->mnt.mnt_flags & MNT_LOCKED) -+ return true; -+ } -+ return false; -+} -+ - /** - * clone_private_mount - create a private clone of a path - * @path: path to clone -@@ -1953,10 +1967,19 @@ struct vfsmount *clone_private_mount(const struct path *path) - struct mount *old_mnt = real_mount(path->mnt); - struct mount *new_mnt; - -+ down_read(&namespace_sem); - if (IS_MNT_UNBINDABLE(old_mnt)) -- return ERR_PTR(-EINVAL); -+ goto invalid; -+ -+ if (!check_mnt(old_mnt)) -+ goto invalid; -+ -+ if (has_locked_children(old_mnt, path->dentry)) -+ goto invalid; - - new_mnt = clone_mnt(old_mnt, path->dentry, CL_PRIVATE); -+ up_read(&namespace_sem); -+ - if (IS_ERR(new_mnt)) - return ERR_CAST(new_mnt); - -@@ -1964,6 +1987,10 @@ struct vfsmount *clone_private_mount(const struct path *path) - new_mnt->mnt_ns = MNT_NS_INTERNAL; - - return &new_mnt->mnt; -+ -+invalid: -+ up_read(&namespace_sem); -+ return ERR_PTR(-EINVAL); - } - EXPORT_SYMBOL_GPL(clone_private_mount); - -@@ -2315,19 +2342,6 @@ static int do_change_type(struct path *path, int ms_flags) - return err; - } - --static bool has_locked_children(struct mount *mnt, struct dentry *dentry) --{ -- struct mount *child; -- list_for_each_entry(child, &mnt->mnt_mounts, mnt_child) { -- if (!is_subdir(child->mnt_mountpoint, dentry)) -- continue; -- -- if (child->mnt.mnt_flags & MNT_LOCKED) -- return true; -- } -- return false; --} -- - static struct mount *__do_loopback(struct path *old_path, int recurse) - { - struct mount *mnt = ERR_PTR(-EINVAL), *old = real_mount(old_path->mnt); -diff --git a/include/linux/security.h b/include/linux/security.h -index 06f7c50ce77f9..0acd1b68bf301 100644 ---- a/include/linux/security.h -+++ b/include/linux/security.h -@@ -120,6 +120,7 @@ enum lockdown_reason { - LOCKDOWN_MMIOTRACE, - LOCKDOWN_DEBUGFS, - LOCKDOWN_XMON_WR, -+ LOCKDOWN_BPF_WRITE_USER, - LOCKDOWN_INTEGRITY_MAX, - LOCKDOWN_KCORE, - LOCKDOWN_KPROBES, -diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c -index f0568b3d6bd1e..77a0d0fb97a99 100644 ---- a/kernel/trace/bpf_trace.c -+++ b/kernel/trace/bpf_trace.c -@@ -990,12 +990,13 @@ bpf_tracing_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) - return &bpf_get_numa_node_id_proto; - case BPF_FUNC_perf_event_read: - return &bpf_perf_event_read_proto; -- case BPF_FUNC_probe_write_user: -- return bpf_get_probe_write_proto(); - case BPF_FUNC_current_task_under_cgroup: - return &bpf_current_task_under_cgroup_proto; - case BPF_FUNC_get_prandom_u32: - return &bpf_get_prandom_u32_proto; -+ case BPF_FUNC_probe_write_user: -+ return security_locked_down(LOCKDOWN_BPF_WRITE_USER) < 0 ? -+ NULL : bpf_get_probe_write_proto(); - case BPF_FUNC_probe_read_user: - return &bpf_probe_read_user_proto; - case BPF_FUNC_probe_read_kernel: -diff --git a/security/security.c b/security/security.c -index b38155b2de83f..0d626c0dafccd 100644 ---- a/security/security.c -+++ b/security/security.c -@@ -58,6 +58,7 @@ const char *const lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1] = { - [LOCKDOWN_MMIOTRACE] = "unsafe mmio", - [LOCKDOWN_DEBUGFS] = "debugfs access", - [LOCKDOWN_XMON_WR] = "xmon write access", -+ [LOCKDOWN_BPF_WRITE_USER] = "use of bpf to write user RAM", - [LOCKDOWN_INTEGRITY_MAX] = "integrity", - [LOCKDOWN_KCORE] = "/proc/kcore access", - [LOCKDOWN_KPROBES] = "use of kprobes", -diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c -index 2b3c164d21f17..cb795135ffc27 100644 ---- a/sound/core/pcm_native.c -+++ b/sound/core/pcm_native.c -@@ -251,7 +251,10 @@ static bool hw_support_mmap(struct snd_pcm_substream *substream) - - switch (substream->dma_buffer.dev.type) { - case SNDRV_DMA_TYPE_UNKNOWN: -- return false; -+ /* we can't know the device, so just assume that the driver does -+ * everything right -+ */ -+ return true; - case SNDRV_DMA_TYPE_CONTINUOUS: - case SNDRV_DMA_TYPE_VMALLOC: - return true; -diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c -index c92d9b9cf9441..6d8c4dedfe0fe 100644 ---- a/sound/pci/hda/patch_realtek.c -+++ b/sound/pci/hda/patch_realtek.c -@@ -8371,6 +8371,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { - SND_PCI_QUIRK(0x103c, 0x87f4, "HP", ALC287_FIXUP_HP_GPIO_LED), - SND_PCI_QUIRK(0x103c, 0x87f5, "HP", ALC287_FIXUP_HP_GPIO_LED), - SND_PCI_QUIRK(0x103c, 0x87f7, "HP Spectre x360 14", ALC245_FIXUP_HP_X360_AMP), -+ SND_PCI_QUIRK(0x103c, 0x8805, "HP ProBook 650 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED), - SND_PCI_QUIRK(0x103c, 0x880d, "HP EliteBook 830 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED), - SND_PCI_QUIRK(0x103c, 0x8846, "HP EliteBook 850 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED), - SND_PCI_QUIRK(0x103c, 0x8847, "HP EliteBook x360 830 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED), -@@ -8405,6 +8406,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { - SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC), - SND_PCI_QUIRK(0x1043, 0x1740, "ASUS UX430UA", ALC295_FIXUP_ASUS_DACS), - SND_PCI_QUIRK(0x1043, 0x17d1, "ASUS UX431FL", ALC294_FIXUP_ASUS_DUAL_SPK), -+ SND_PCI_QUIRK(0x1043, 0x1662, "ASUS GV301QH", ALC294_FIXUP_ASUS_DUAL_SPK), - SND_PCI_QUIRK(0x1043, 0x1881, "ASUS Zephyrus S/M", ALC294_FIXUP_ASUS_GX502_PINS), - SND_PCI_QUIRK(0x1043, 0x18b1, "Asus MJ401TA", ALC256_FIXUP_ASUS_HEADSET_MIC), - SND_PCI_QUIRK(0x1043, 0x18f1, "Asus FX505DT", ALC256_FIXUP_ASUS_HEADSET_MIC),